Mercurial > repos > blastem
comparison gen_test_hv.s68 @ 649:c86f27f5c5a6
Added HV counter test ROM source
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 14 Dec 2014 18:17:29 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
648:a5e46ad97192 | 649:c86f27f5c5a6 |
---|---|
1 dc.l $0, start | |
2 dc.l empty_handler | |
3 dc.l empty_handler | |
4 ;$10 | |
5 dc.l empty_handler | |
6 dc.l empty_handler | |
7 dc.l empty_handler | |
8 dc.l empty_handler | |
9 ;$20 | |
10 dc.l empty_handler | |
11 dc.l empty_handler | |
12 dc.l empty_handler | |
13 dc.l empty_handler | |
14 ;$30 | |
15 dc.l empty_handler | |
16 dc.l empty_handler | |
17 dc.l empty_handler | |
18 dc.l empty_handler | |
19 ;$40 | |
20 dc.l empty_handler | |
21 dc.l empty_handler | |
22 dc.l empty_handler | |
23 dc.l empty_handler | |
24 ;$50 | |
25 dc.l empty_handler | |
26 dc.l empty_handler | |
27 dc.l empty_handler | |
28 dc.l empty_handler | |
29 ;$60 | |
30 dc.l empty_handler | |
31 dc.l empty_handler | |
32 dc.l empty_handler | |
33 dc.l empty_handler | |
34 ;$70 | |
35 dc.l int_4 | |
36 dc.l empty_handler | |
37 dc.l int_6 | |
38 dc.l empty_handler | |
39 ;$80 | |
40 dc.l empty_handler | |
41 dc.l empty_handler | |
42 dc.l empty_handler | |
43 dc.l empty_handler | |
44 ;$90 | |
45 dc.l empty_handler | |
46 dc.l empty_handler | |
47 dc.l empty_handler | |
48 dc.l empty_handler | |
49 ;$A0 | |
50 dc.l empty_handler | |
51 dc.l empty_handler | |
52 dc.l empty_handler | |
53 dc.l empty_handler | |
54 ;$B0 | |
55 dc.l empty_handler | |
56 dc.l empty_handler | |
57 dc.l empty_handler | |
58 dc.l empty_handler | |
59 ;$C0 | |
60 dc.l empty_handler | |
61 dc.l empty_handler | |
62 dc.l empty_handler | |
63 dc.l empty_handler | |
64 ;$D0 | |
65 dc.l empty_handler | |
66 dc.l empty_handler | |
67 dc.l empty_handler | |
68 dc.l empty_handler | |
69 ;$E0 | |
70 dc.l empty_handler | |
71 dc.l empty_handler | |
72 dc.l empty_handler | |
73 dc.l empty_handler | |
74 ;$F0 | |
75 dc.l empty_handler | |
76 dc.l empty_handler | |
77 dc.l empty_handler | |
78 dc.l empty_handler | |
79 dc.b "SEGA" | |
80 empty_handler: | |
81 int_6: | |
82 rte | |
83 int_4: | |
84 move.w (a2), d0 | |
85 ori.w #$8000, d0 | |
86 move.w d0, (a4)+ | |
87 rte | |
88 | |
89 start: | |
90 lea $C00000, a0 | |
91 lea $C00004, a1 | |
92 move.w #$8104, (a1) ;Mode 5, everything turned off | |
93 move.w #$8004, (a1) | |
94 move.w #$8220, (a1) ;Scroll a table $8000 | |
95 move.w #$8404, (a1) ;Scroll b table $8000 | |
96 move.w #$8560, (a1) ;SAT table $C000 | |
97 move.w #$8700, (a1) ;backdrop color 0 | |
98 move.w #$8B00, (a1) ;full screen scroll | |
99 move.w #$8C81, (a1) ;40 cell mode, no interlace | |
100 move.w #$8C81, (mode).w | |
101 move.w #$8D00, (a1) ;hscroll table at 0 | |
102 move.w #$8F02, (a1) ;autoinc 2 | |
103 move.w #$9011, (a1) ;64x64 scroll size | |
104 move.l #$C0000000, (a1) | |
105 move.w #$000, (a0) | |
106 move.w #$EEE, (a0) | |
107 | |
108 ;clear scroll table | |
109 move.l #$40000000, (a1) | |
110 move.l #0, (a0) | |
111 | |
112 ;load tiles | |
113 move.l #$44000000, (a1) | |
114 lea font(pc), a2 | |
115 move.w #((fontend-font)/4 - 1), d0 | |
116 tloop: | |
117 move.l (a2)+, (a0) | |
118 dbra d0, tloop | |
119 | |
120 | |
121 | |
122 ;clear name table | |
123 move.l #$40000002, (a1) | |
124 moveq #32, d0 | |
125 move.w #(64*64-1), d1 | |
126 ploop: | |
127 move.w d0, (a0) | |
128 dbra d1, ploop | |
129 | |
130 | |
131 lea $FF0000, a4 | |
132 move.b #$40, (a4, 6) | |
133 move.w #$8144, (a1) ;enable display | |
134 move #$2300, sr | |
135 | |
136 lea (4, a1), a2 ;hv counter line address | |
137 lea (2, a1), a3 ;second contro/status address | |
138 | |
139 move.b #254, d0 | |
140 init_wait: | |
141 cmp.b (a2), d0 | |
142 beq init_wait | |
143 | |
144 top: | |
145 move.b #254, d0 | |
146 lea $FF0000, a4 | |
147 move.w #$8F00, (a1) ;autoinc of 0 | |
148 move.l #$40040000, (a1) ;unused VRAM address | |
149 wait_active: | |
150 cmp.b (a2), d0 | |
151 bne.s wait_active | |
152 | |
153 move.l #$8A718014, (a1) ;enable Hints | |
154 | |
155 ;sync to VDP by attempting to fill FIFO | |
156 ;being in vblank makes this a bit difficult | |
157 | |
158 rept 8 | |
159 move.l d0, (a0) | |
160 endr | |
161 | |
162 ;sample data for vblank flag off | |
163 rept 82 ;two lines worth of move.l | |
164 move.l (a3), (a4)+ | |
165 endr | |
166 | |
167 move.l a4, a5 ;save end of first buffer | |
168 | |
169 move.b (a2), d0 | |
170 wait_new_line: | |
171 cmp.b (a2), d0 | |
172 beq.s wait_new_line | |
173 | |
174 ;sync to VDP by filling FIFO | |
175 move.l d0, (a0) | |
176 move.l d0, (a0) | |
177 move.w d0, (a0) | |
178 | |
179 ;sample data for line change HV value | |
180 rept 45 ;one line worth of move.l | |
181 move.l (a2), (a4)+ | |
182 endr | |
183 | |
184 move.l a4, usp ;save end of second buffer | |
185 | |
186 moveq #$70, d0 | |
187 wait_hint_line: | |
188 cmp.b (a2), d0 | |
189 bne.s wait_hint_line | |
190 | |
191 ;sample data for line change HV value | |
192 rept 45 ;one line worth of move.l | |
193 move.l (a2), (a4)+ | |
194 endr | |
195 | |
196 move.l a4, a6 | |
197 | |
198 move.b #223, d0 | |
199 wait_inactive: | |
200 cmp.b (a2), d0 | |
201 bne.s wait_inactive | |
202 | |
203 ;sync to VDP by filling FIFO | |
204 move.l d0, (a0) | |
205 move.l d0, (a0) | |
206 move.w d0, (a0) | |
207 | |
208 ;sample data for vblank on | |
209 rept 82 ;two lines worth of move.l | |
210 move.l (a3), (a4)+ | |
211 endr | |
212 | |
213 move.l #$8AFF8004, (a1) ;disable Hints | |
214 | |
215 rsset $FFFF8000 | |
216 vblank_start_min rs.w 1 | |
217 vblank_start_max rs.w 1 | |
218 vblank_end_min rs.w 1 | |
219 vblank_end_max rs.w 1 | |
220 hblank_start_min rs.w 1 | |
221 hblank_start_max rs.w 1 | |
222 hblank_end_min rs.w 1 | |
223 hblank_end_max rs.w 1 | |
224 line_change_min rs.w 1 | |
225 line_change_max rs.w 1 | |
226 hint_min rs.w 1 | |
227 hint_max rs.w 1 | |
228 mode rs.w 1 | |
229 printed_hv_dump rs.b 1 | |
230 button_state rs.b 1 | |
231 | |
232 lea $FF0001, a4 | |
233 .loop: | |
234 btst.b #3, (a4) | |
235 beq.s found_vblank_off | |
236 move.w 1(a4), d6 | |
237 addq #4, a4 | |
238 bra.s .loop | |
239 found_vblank_off: | |
240 | |
241 move.w (vblank_end_max).w, d0 | |
242 beq .new_max | |
243 cmp.w d0, d6 | |
244 blo .no_new_max | |
245 .new_max | |
246 move.w d6, (vblank_end_max).w | |
247 .no_new_max: | |
248 | |
249 | |
250 move.w 1(a4), d6 | |
251 | |
252 move.w (vblank_end_min).w, d0 | |
253 beq .new_min | |
254 cmp.w d0, d6 | |
255 bhi .no_new_min | |
256 .new_min | |
257 move.w d6, (vblank_end_min).w | |
258 .no_new_min: | |
259 | |
260 lea $FF0001, a4 | |
261 ;first find a point where HBLANK is not set | |
262 bra.s .start | |
263 .loop: | |
264 addq #4, a4 | |
265 .start | |
266 btst.b #2, (a4) | |
267 bne.s .loop | |
268 | |
269 ;then find a point after that where it switches to on | |
270 .loop2: | |
271 btst.b #2, (a4) | |
272 bne.s found_hblank_on | |
273 move.w 1(a4), d5 | |
274 addq #4, a4 | |
275 bra.s .loop2 | |
276 found_hblank_on: | |
277 | |
278 move.w (hblank_start_max).w, d0 | |
279 beq .new_max | |
280 cmp.w d0, d5 | |
281 blo .no_new_max | |
282 .new_max | |
283 move.w d5, (hblank_start_max).w | |
284 .no_new_max: | |
285 | |
286 | |
287 move.w 1(a4), d5 | |
288 | |
289 move.w (hblank_start_min).w, d0 | |
290 beq .new_min | |
291 cmp.w d0, d5 | |
292 bhi .no_new_min | |
293 .new_min | |
294 move.w d5, (hblank_start_min).w | |
295 .no_new_min: | |
296 | |
297 ;finally find a point after that where it switches back off | |
298 .loop2: | |
299 btst.b #2, (a4) | |
300 beq.s found_hblank_off | |
301 move.w 1(a4), d5 | |
302 addq #4, a4 | |
303 bra.s .loop2 | |
304 found_hblank_off: | |
305 | |
306 move.w (hblank_end_max).w, d0 | |
307 beq .new_max | |
308 cmp.w d0, d5 | |
309 blo .no_new_max | |
310 .new_max | |
311 move.w d5, (hblank_end_max).w | |
312 .no_new_max: | |
313 | |
314 | |
315 move.w 1(a4), d5 | |
316 | |
317 move.w (hblank_end_min).w, d0 | |
318 beq .new_min | |
319 cmp.w d0, d5 | |
320 bhi .no_new_min | |
321 .new_min | |
322 move.w d5, (hblank_end_min).w | |
323 .no_new_min: | |
324 | |
325 move.l a5, a4 ;save line change buffer for later | |
326 move.b (a5), d0 | |
327 .loop | |
328 move.w (a5), d7 | |
329 addq #2, a5 | |
330 cmp.b (a5), d0 | |
331 beq .loop | |
332 found_line_change: | |
333 | |
334 move.w (line_change_max).w, d0 | |
335 beq .new_max | |
336 cmp.w d0, d7 | |
337 blo .no_new_max | |
338 .new_max | |
339 move.w d7, (line_change_max).w | |
340 .no_new_max: | |
341 | |
342 move.w (a5), d7 | |
343 | |
344 move.w (line_change_min).w, d0 | |
345 beq .new_min | |
346 cmp.w d0, d7 | |
347 bhi .no_new_min | |
348 .new_min | |
349 move.w d7, (line_change_min).w | |
350 .no_new_min: | |
351 | |
352 addq #1, a6 | |
353 .loop: | |
354 btst.b #3, (a6) | |
355 bne.s found_vblank_on | |
356 move.w 1(a6), d5 | |
357 addq #4, a6 | |
358 bra.s .loop | |
359 found_vblank_on: | |
360 | |
361 move.w (vblank_start_max).w, d0 | |
362 beq .new_max | |
363 cmp.w d0, d5 | |
364 blo .no_new_max | |
365 .new_max | |
366 move.w d5, (vblank_start_max).w | |
367 .no_new_max: | |
368 | |
369 move.w 1(a6), d5 | |
370 | |
371 move.w (vblank_start_min).w, d0 | |
372 beq .new_min | |
373 cmp.b d0, d5 | |
374 bhi .no_new_min | |
375 .new_min | |
376 move.w d5, (vblank_start_min).w | |
377 .no_new_min: | |
378 | |
379 move usp, a5 | |
380 .loop: | |
381 btst.b #7, (a5) | |
382 bne.s found_hint | |
383 move.w (a5), d1 | |
384 addq #2, a5 | |
385 bra.s .loop | |
386 found_hint: | |
387 | |
388 move.w (hint_max).w, d0 | |
389 beq .new_max | |
390 cmp.w d0, d1 | |
391 blo .no_new_max | |
392 .new_max | |
393 move.w d1, (hint_max).w | |
394 .no_new_max: | |
395 | |
396 move.w (a5), d1 | |
397 and.w #$7FFF, d1 | |
398 | |
399 move.w (hint_min).w, d0 | |
400 beq .new_min | |
401 cmp.b d0, d1 | |
402 bhi .no_new_min | |
403 .new_min | |
404 move.w d1, (hint_min).w | |
405 .no_new_min: | |
406 | |
407 draw_info: | |
408 ;draw data | |
409 move.w #$8F02, (a1) ;autoinc of 2 | |
410 move.l #$40840002, (a1) | |
411 | |
412 moveq #0, d0 | |
413 lea VBlankStart(pc), a6 | |
414 bsr print_string | |
415 | |
416 | |
417 move.w (vblank_start_max), d0 | |
418 moveq #0, d1 | |
419 bsr print_hexw | |
420 | |
421 move.w #32, (a0) | |
422 move.w d5, d0 | |
423 bsr print_hexw | |
424 | |
425 move.w #32, (a0) | |
426 move.w (vblank_start_min), d0 | |
427 bsr print_hexw | |
428 | |
429 moveq #0, d0 | |
430 move.l #$41040002, (a1) | |
431 lea VBlankEnd(pc), a6 | |
432 bsr print_string | |
433 | |
434 ;max value before vblank end | |
435 moveq #0, d1 | |
436 move.w (vblank_end_max), d0 | |
437 bsr print_hexw | |
438 | |
439 move.w #32, (a0) | |
440 move.w d6, d0 | |
441 bsr print_hexw | |
442 | |
443 ;min value after vblank end | |
444 move.w (vblank_end_min), d0 | |
445 move.w #32, (a0) | |
446 bsr print_hexw | |
447 | |
448 moveq #0, d0 | |
449 move.l #$41840002, (a1) | |
450 lea LineChange(pc), a6 | |
451 bsr print_string | |
452 | |
453 move.w (line_change_max), d0 | |
454 moveq #0, d1 | |
455 bsr print_hexw | |
456 | |
457 move.w #32, (a0) | |
458 move.w d7, d0 | |
459 bsr print_hexw | |
460 | |
461 move.w (line_change_min), d0 | |
462 move.w #32, (a0) | |
463 bsr print_hexw | |
464 | |
465 moveq #0, d0 | |
466 move.l #$42040002, (a1) | |
467 lea HBlankStart(pc), a6 | |
468 bsr print_string | |
469 | |
470 move.w (hblank_start_max), d0 | |
471 moveq #0, d1 | |
472 bsr print_hexw | |
473 | |
474 move.w (hblank_start_min), d0 | |
475 move.w #32, (a0) | |
476 bsr print_hexw | |
477 | |
478 moveq #0, d0 | |
479 move.l #$42840002, (a1) | |
480 lea HBlankEnd(pc), a6 | |
481 bsr print_string | |
482 | |
483 move.w (hblank_end_max), d0 | |
484 moveq #0, d1 | |
485 bsr print_hexw | |
486 | |
487 move.w (hblank_end_min), d0 | |
488 move.w #32, (a0) | |
489 bsr print_hexw | |
490 | |
491 moveq #0, d0 | |
492 move.l #$43040002, (a1) | |
493 lea HInterrupt(pc), a6 | |
494 bsr print_string | |
495 | |
496 move.w (hint_max), d0 | |
497 moveq #0, d1 | |
498 bsr print_hexw | |
499 | |
500 move.w (hint_min), d0 | |
501 move.w #32, (a0) | |
502 bsr print_hexw | |
503 | |
504 ;read pad | |
505 move.b #$40, $A10003 | |
506 move.b $A10003, d0 | |
507 move.b #$00, $A10003 | |
508 and.b #$3f, d0 | |
509 move.b $A10003, d1 | |
510 and.b #$30, d1 | |
511 lsl.b #2, d1 | |
512 or.b d1, d0 | |
513 not.b d0 | |
514 move.b (button_state).w, d2 | |
515 eor.b d0, d2 | |
516 and.b d0, d2 | |
517 move.b d2, d3 ;d3 contains newly pressed buttons, SACBRLDU | |
518 move.b d0, (button_state).w | |
519 | |
520 btst.l #7, d3 | |
521 beq not_pressed | |
522 | |
523 moveq #0, d0 | |
524 move.l d0, (vblank_start_min).w | |
525 move.l d0, (vblank_end_min).w | |
526 move.l d0, (hblank_start_min).w | |
527 move.l d0, (hblank_end_min).w | |
528 move.l d0, (line_change_min).w | |
529 move.l d0, (hint_min).w | |
530 move.b d0, (printed_hv_dump).w | |
531 move.w (mode).w, d0 | |
532 eor.w #$81, d0 | |
533 move.w d0, (mode).w | |
534 move.w d0, (a1) | |
535 bra top | |
536 | |
537 not_pressed | |
538 | |
539 move.b (printed_hv_dump).w, d0 | |
540 bne top | |
541 move.b #1, (printed_hv_dump).w | |
542 | |
543 moveq #0, d1 | |
544 moveq #89, d4 | |
545 moveq #6, d5 | |
546 move.l #$45820002, d6 | |
547 move.l d6, (a1) | |
548 | |
549 print_loop: | |
550 dbra d5, .no_line_change | |
551 ;#$45820002 | |
552 add.l #$00800000, d6 | |
553 move.l d6, (a1) | |
554 moveq #5, d5 | |
555 .no_line_change | |
556 move.w #32, (a0) | |
557 move.w (a4)+, d0 | |
558 bsr print_hexw | |
559 dbra d4, print_loop | |
560 | |
561 add.l #$01020000, d6 | |
562 move.l d6, (a1) | |
563 moveq #0, d0 | |
564 lea Instructions(pc), a6 | |
565 bsr print_string | |
566 | |
567 bra top | |
568 | |
569 VBlankStart: | |
570 dc.b "VBlank Start: ", 0 | |
571 VBlankEnd: | |
572 dc.b "VBlank End: ", 0 | |
573 LineChange: | |
574 dc.b "Line Change: ", 0 | |
575 HBlankStart: | |
576 dc.b "HBlank Start: ", 0 | |
577 HBlankEnd: | |
578 dc.b "HBlank End: ", 0 | |
579 HInterrupt: | |
580 dc.b "HInterrupt: ", 0 | |
581 Instructions: | |
582 dc.b "Press Start to switch modes", 0 | |
583 | |
584 align 1 | |
585 ;Prints a number in hex format | |
586 ;d0.w - number to print | |
587 ;d1.w - base tile attribute | |
588 ;a0 - VDP data port | |
589 ; | |
590 ;Clobbers: d2.l, d3.l | |
591 ; | |
592 print_hexw: | |
593 moveq #3, d3 | |
594 .digitloop | |
595 rol.w #4, d0 | |
596 moveq #$F, d2 | |
597 and.b d0, d2 | |
598 cmp.b #$A, d2 | |
599 bge .hex | |
600 add.w #$30, d2 | |
601 bra .makeattrib | |
602 .hex | |
603 add.w #($41-$A), d2 | |
604 .makeattrib | |
605 add.w d1, d2 | |
606 move.w d2, (a0) | |
607 dbra d3, .digitloop | |
608 rts | |
609 | |
610 ;Prints a null terminated string | |
611 ;a6 - pointer to string | |
612 ;a0 - VDP data port | |
613 ;d0 - base tile attribute | |
614 ; | |
615 ;Clobbers: d1.w | |
616 print_string: | |
617 .loop | |
618 moveq #0, d1 | |
619 move.b (a6)+, d1 | |
620 beq .end | |
621 add.w d0, d1 | |
622 move.w d1, (a0) | |
623 bra .loop | |
624 .end | |
625 rts | |
626 | |
627 align 1 | |
628 font: | |
629 incbin font.tiles | |
630 fontend | |
631 |