SHOW:
|
|
- or go back to the newest paste.
1 | ; MADS options | |
2 | ; generate headers | |
3 | ||
4 | opt h+ | |
5 | ||
6 | ; zero page variables | |
7 | ||
8 | screen_pointer = $80 | |
9 | current_color = $82 | |
10 | lines_counter = $83 | |
11 | lines_counter_add = $84 | |
12 | bar_counter = $85 | |
13 | ||
14 | ; OS equates | |
15 | ||
16 | RTCLOK = $0012 | |
17 | SDLSTL = $0230 | |
18 | GPRIOR = $026f | |
19 | COLOR4 = $02c8 | |
20 | COLBK = $d01a | |
21 | WSYNC = $d40a | |
22 | VCOUNT = $d40b | |
23 | ||
24 | org $2000 | |
25 | ||
26 | ; init with black color | |
27 | ||
28 | lda #0 | |
29 | sta COLOR4 | |
30 | ||
31 | ; store screen pointer on zero page | |
32 | ||
33 | jsr set_screen_pointer | |
34 | ||
35 | ; set display list | |
36 | ||
37 | lda <display_list | |
38 | sta SDLSTL | |
39 | lda >display_list | |
40 | sta SDLSTL+1 | |
41 | ||
42 | ; activate GTIA mode | |
43 | ||
44 | lda #$40 | |
45 | sta GPRIOR | |
46 | ||
47 | ; initialize color to 0 (black) | |
48 | ||
49 | lda #0 | |
50 | sta current_color | |
51 | ||
52 | ; draw 6 horizontal bars | |
53 | ||
54 | lda #6 | |
55 | sta bar_counter | |
56 | ||
57 | ; colors 0 → 14 | |
58 | ||
59 | @ ldx #14 | |
60 | @ jsr draw_line | |
61 | jsr increase_color_brightness | |
62 | jsr increase_screen_pointer | |
63 | dex | |
64 | bpl @- | |
65 | ||
66 | ; colors 14 → 0 | |
67 | ||
68 | ldx #14 | |
69 | @ jsr draw_line | |
70 | jsr decrease_color_brightness | |
71 | jsr increase_screen_pointer | |
72 | dex | |
73 | bpl @- | |
74 | ||
75 | dec bar_counter | |
76 | bne @-2 | |
77 | ||
78 | ; reset screen pointer | |
79 | ||
80 | jsr set_screen_pointer | |
81 | ||
82 | ; center add bar | |
83 | ||
84 | adw screen_pointer #11 | |
85 | ||
86 | ; start loop which will create center bar | |
87 | ||
88 | lda #192 | |
89 | sta lines_counter | |
90 | ||
91 | ; move to center of line | |
92 | ||
93 | @ adw screen_pointer #40 | |
94 | ||
95 | ; and copy 15 bytes | |
96 | ||
97 | ldy #0 | |
98 | ldx #0 | |
99 | @ lda colors_pixels,x | |
100 | sta (screen_pointer),y | |
101 | iny | |
102 | inx | |
103 | cpx #18 | |
104 | bne @- | |
105 | ||
106 | dec lines_counter | |
107 | bne @-1 | |
108 | ||
109 | ; add one more bar in the middle | |
110 | ||
111 | lda <screen+((192/2)-20)*40 | |
112 | sta screen_pointer | |
113 | lda >screen+((192/2)-20)*40 | |
114 | sta screen_pointer + 1 | |
115 | ||
116 | ; colors 0 → 14 | |
117 | ||
118 | ldx #14 | |
119 | @ jsr draw_line | |
120 | jsr increase_color_brightness | |
121 | jsr increase_screen_pointer | |
122 | dex | |
123 | bpl @- | |
124 | ||
125 | ; colors 14 → 0 | |
126 | ||
127 | ldx #14 | |
128 | @ jsr draw_line | |
129 | jsr decrease_color_brightness | |
130 | jsr increase_screen_pointer | |
131 | dex | |
132 | bpl @- | |
133 | ||
134 | ; dirty method for coloring the screen | |
135 | ; without display list interrupts | |
136 | ||
137 | loop | |
138 | ||
139 | ; wait for start of new frame | |
140 | ||
141 | lda RTCLOK+2 | |
142 | cmp RTCLOK+2 | |
143 | beq *-2 | |
144 | ||
145 | ; border should be black | |
146 | ; set black color | |
147 | ||
148 | lda #0 | |
149 | sta COLOR4 | |
150 | ||
151 | ; so wait for 8 lines | |
152 | ||
153 | lda #8 | |
154 | sta lines_counter | |
155 | ||
156 | ; set color index | |
157 | ||
158 | ldx #7 | |
159 | ||
160 | ; draw 2 full bars | |
161 | ; first | |
162 | ||
163 | ldy #15 | |
164 | jsr draw_bar | |
165 | ||
166 | ; move color index | |
167 | ||
168 | dex | |
169 | ||
170 | ; second full bar | |
171 | ||
172 | ldy #15 | |
173 | jsr draw_bar | |
174 | ||
175 | ; move color index | |
176 | ||
177 | dex | |
178 | ||
179 | ; draw half bar | |
180 | ||
181 | ldy #8 | |
182 | jsr draw_bar | |
183 | ||
184 | ; move color index | |
185 | ||
186 | dex | |
187 | ||
188 | ; draw full bar (in the middle) | |
189 | ||
190 | ldy #14 | |
191 | jsr draw_bar | |
192 | ||
193 | ; move color index | |
194 | ||
195 | dex | |
196 | ||
197 | ; draw half bar | |
198 | ||
199 | ldy #7 | |
200 | jsr draw_bar | |
201 | ||
202 | ; move color index | |
203 | ||
204 | dex | |
205 | ||
206 | ; draw full bar | |
207 | ||
208 | ldy #15 | |
209 | jsr draw_bar | |
210 | ||
211 | ; move color index | |
212 | ||
213 | dex | |
214 | ||
215 | ; draw full bar | |
216 | ||
217 | ldy #15 | |
218 | jsr draw_bar | |
219 | ||
220 | ; move color index | |
221 | ||
222 | dex | |
223 | ||
224 | ; draw full bar | |
225 | ||
226 | ldy #17 | |
227 | jsr draw_bar | |
228 | ||
229 | jmp loop | |
230 | ||
231 | ; procedures ------------------------ | |
232 | ||
233 | ; set screen pointer | |
234 | ||
235 | set_screen_pointer | |
236 | lda <screen | |
237 | sta screen_pointer | |
238 | lda >screen | |
239 | sta screen_pointer + 1 | |
240 | rts | |
241 | ||
242 | ; drawing line - simply put 40 bytes | |
243 | ||
244 | draw_line | |
245 | ldy #39 | |
246 | lda current_color | |
247 | @ sta (screen_pointer),y | |
248 | dey | |
249 | bpl @- | |
250 | rts | |
251 | ||
252 | ; increase color + 1 | |
253 | ||
254 | increase_color_brightness | |
255 | lda current_color | |
256 | clc | |
257 | adc #17 | |
258 | sta current_color | |
259 | rts | |
260 | ||
261 | ; decrease color - 1 | |
262 | ||
263 | decrease_color_brightness | |
264 | lda current_color | |
265 | sec | |
266 | sbc #17 | |
267 | sta current_color | |
268 | rts | |
269 | ||
270 | ; move screen pointer by 40 bytes | |
271 | ||
272 | increase_screen_pointer | |
273 | lda screen_pointer | |
274 | clc | |
275 | adc #40 | |
276 | sta screen_pointer | |
277 | bcc @+ | |
278 | inc screen_pointer+1 | |
279 | @ rts | |
280 | ||
281 | draw_bar ; x = color_table index, y = lines | |
282 | ||
283 | sty lines_counter_add | |
284 | lda VCOUNT | |
285 | cmp lines_counter | |
286 | bne *-5 | |
287 | ||
288 | lda colors_horizontal,x | |
289 | sta WSYNC | |
290 | sta COLBK | |
291 | ||
292 | lda lines_counter | |
293 | add lines_counter_add | |
294 | sta lines_counter | |
295 | rts | |
296 | ||
297 | ; display list | |
298 | ||
299 | org $3000 | |
300 | ||
301 | display_list | |
302 | .byte $70 ; 8 empty lines | |
303 | .byte $4f ; LMS + ANTIC $f | |
304 | .word $4010 | |
305 | :100 .byte $f ; 101 lines | |
306 | .byte $4f ; LMS + ANTIC $f | |
307 | .word $5000 | |
308 | :77 .byte $f ; 80 lines | |
309 | .byte $41 ; JVB | |
310 | .word display_list | |
311 | ||
312 | ; horizontal stripes | |
313 | ||
314 | colors_pixels | |
315 | .byte 0, $01, $23, $45, $67, $89, $ab, $cd, $ef, $fe, $dc, $ba, $98, $76, $54, $32, $10, 0 | |
316 | ||
317 | ; center bar - table of colors | |
318 | ||
319 | colors_horizontal | |
320 | .byte $0, $70, $80, $90, $a0, $c0, $10, $30 | |
321 | ||
322 | ; video RAM | |
323 | ||
324 | org $4010 | |
325 | ||
326 | screen .byte 0 |