-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGFX.S
204 lines (144 loc) · 3.25 KB
/
GFX.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
mask_r: equ %1111100000000000
mask_g: equ %0000011111100000
mask_b: equ %0000000000011111
shift_r: equ 11
shift_g: equ 5
one_r: equ 2048
one_g: equ 32
section text
clear_debug: movem.l d0/a0,-(sp)
move.l screen_adr,a0
move.l #8*v_scr_w-1,d0
cd1: move.w #0,(a0)+
dbf d0,cd1
move.l #0,counter
movem.l (sp)+,d0/a0
rts
debug_bars: movem.l d0-d1/a0,-(sp)
move.l screen_adr,a0
move.l counter,d1
lsl.l #2,d1
adda.l d1,a0
and.l #$1f,d1
moveq.l #7,d0
debug_r_loop:
cmp #0,d1
beq blue
move.w #$f800,(a0)
bra debug_done
blue: move.w #$001f,(a0)
debug_done: adda.l #v_scr_w*2,a0
dbf d0,debug_r_loop
addq.l #1,counter
movem.l (sp)+,d0-d1/a0
rts
debug_blue: movem.l d7/a0,-(sp)
move.l screen_adr,a0
lsl.l #2,d7
adda.l d7,a0
move.w #$001f,(a0)+
; move.w #$001f,(a0)+
movem.l (sp)+,d7/a0
rts
inc_screen:
move.l screen_adr,a0
move.l #scr_h,d0
inc_screen_y: move.l #scr_w,d1
move.w d0,d2
lsr.w #3,d2
inc_screen_x: move.w d2,(a0)+
dbf d1,inc_screen_x
dbf d0,inc_screen_y
rts
red_screen: movem.l d0/a0,-(sp)
move.w #$F800,d0
movea.l screen_adr,a0
jsr clear_scr
movem.l (sp)+,d0/a0
rts
green_screen: movem.l d0/a0,-(sp)
move.w #$7E0,d0
movea.l screen_adr,a0
jsr clear_scr
movem.l (sp)+,d0/a0
rts
clear_scr: ; clears the virtual screen to the colour in d0
movem.l d1/a0,-(sp)
move.l #v_scr_w*v_scr_h/4,d1 ; dbf is 16-bit so loop
clear_scr_l: move.w d0,(a0)+ ; quarter of the count
move.w d0,(a0)+ ; as virtual screen can
move.w d0,(a0)+ ; be 640x480
move.w d0,(a0)+ ; do 4 moves each time
dbf d1,clear_scr_l
movem.l (sp)+,d1/a0
rts
full_screen: ; blits an entire screen from a0 to a1
movem.l d0,-(sp)
move.l #v_scr_w*v_scr_h/4,d0
fs1: move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
dbf d0,fs1
movem.l (sp)+,d0
rts
fade_black:
move.b work_flag,d1
cmpi.b #0,d1
bne fade_black_l
move.b #1,work_flag ; first pass, setup counter
move.l #5,d0
move.l d0,counter
fade_black_l:
move.l counter,d0 ; dec counter
subq.l #1,d0
move.l d0,counter
cmpi.l #0,d0 ; done?
blt fade_black_l2
;move.b #0,work_flag ; yes, clear work flag
rts
fade_black_l2:
move.l screen_adr,a0 ; no, get screen adr
move.l mask_0,a1 ; address of mask 1
add.l d0,a1 ; point to the right mask
move.l #scr_w*scr_h,d0 ; init loop
fade_black_l3:
move.w (a0),d1
and.l (a1),d1 ; apply the mask
move.w d1,(a0)+ ; write the pixel back
subq.l #1,d0
cmpi.l #0,d0
bne fade_black_l3
rts
blit_16x16: movem.l a0-a1,-(sp)
REPT 16
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
move.w (a1)+,(a0)+
adda.l #v_scr_w*2-16*2,a0 ; next row
adda.l #v_scr_w*2-16*2,a1
ENDR
movem.l (sp)+,a0-a1
rts
section data
debug_count: dc.l 0
counter: dc.l 0
work_flag: dc.b 0
mask_0: dc.w 0
mask_1: dc.w %0000100001100001
mask_2: dc.w %0001100011100011
mask_3: dc.w %0011100111100111
mask_4: dc.w %0111101111101111