dc.l $0, start dc.l empty_handler dc.l empty_handler ;$10 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$20 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$30 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$40 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$50 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$60 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$70 dc.l int_4 dc.l empty_handler dc.l int_6 dc.l empty_handler ;$80 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$90 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$A0 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$B0 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$C0 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$D0 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$E0 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler ;$F0 dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.l empty_handler dc.b "SEGA IS COOL " dc.b "(C)M.Pavone 2015" dc.b "Z80 Bus Arbitrat" dc.b "ion Test ROM " dc.b " " dc.b "Z80 Bus Arbitrat" dc.b "ion Test ROM " dc.b " " dc.b "MP 20151031-01",0,0 dc.b "J " dc.l $0 dc.l romend-1 dc.l $FF0000 dc.l $FFFFFF dc.b " " dc.b " " dc.b " " dc.b " " dc.b "JUE " int_4: int_6: empty_handler: rte start: move.b $A10001, d0 and.b #$F, d0 beq no_tmss move.l #'SEGA', $A14000 no_tmss: lea $C00000, a0 lea $C00004, a1 move.w #$8104, (a1) ;Mode 5, everything turned off move.w #$8004, (a1) move.w #$8220, (a1) ;Scroll a table $8000 move.w #$8404, (a1) ;Scroll b table $8000 move.w #$8560, (a1) ;SAT table $C000 move.w #$8700, (a1) ;backdrop color 0 move.w #$8A01, (a1) ;Set HINT counter move.w #$8B00, (a1) ;full screen scroll move.w #$8C81, (a1) ;40 cell mode, no interlace move.w #$8D00, (a1) ;hscroll table at 0 move.w #$8F02, (a1) ;autoinc 2 move.w #$9011, (a1) ;64x64 scroll size move.l #$C0000000, (a1) move.w #$000, (a0) move.w #$EEE, (a0) ;clear scroll table move.l #$40000000, (a1) move.l #0, (a0) ;load tiles move.l #$44000000, (a1) lea font(pc), a2 move.w #((fontend-font)/4 - 1), d0 tloop: move.l (a2)+, (a0) dbra d0, tloop ;clear name table move.l #$40000002, (a1) moveq #32, d0 move.w #(64*64-1), d1 ploop: move.w d0, (a0) dbra d1, ploop move.b #$40, $A10009 move.b #$00, $A10003 top: move.w #$8104, (a1) ;disable display ;will assert reset and clear BUSREQ on exit bsr clear_zram moveq #$56, d7 moveq #0, d6 moveq #0, d5 moveq #0, d4 moveq #0, d3 moveq #0, d2 lea $A00000, a5 rept 4 nop endr move.b d7, (a5);A00000 move.b (a5)+, d6 add.b #$11, d7 move.b #1, $A11100 ;assert BUSREQ rept 4 nop endr move.b d7, (a5);A00001 move.b (a5)+, d5 add.b #$11, d7 move.b #1, $A11200 ;release reset rept 4 nop endr move.b d7, (a5);;A00002 move.b (a5)+, d4 add.b #$11, d7 move.b d7, (a5) move.w (-1, a5), d2 move.w #$BEEF, (-1, a5) move.b (-1, a5), d3 lsl.w #8, d3 move.b (a5)+, d3 add.b #$11, d7 move.b #0, $A11100 ;release BUSREQ rept 4 nop endr move.b d7, (a5) move.b (a5), d7 move.w d2, a2 move.w d3, a3 move.l #$40840002, (a1) moveq #0, d0 lea ResetOnly(pc), a6 bsr print_string move.w d6, d0 moveq #0, d1 bsr print_hexw cmp.b #$56, d6 bsr pass_if_ne both_display: move.l #$41040002, (a1) moveq #0, d0 lea Both(pc), a6 bsr print_string move.w d5, d0 moveq #0, d1 bsr print_hexw cmp.b #$67, d5 bsr pass_if_ne move.l #$41840002, (a1) moveq #0, d0 lea BusreqOnly(pc), a6 bsr print_string move.w d4, d0 moveq #0, d1 bsr print_hexw cmp.b #$78, d4 bsr pass_if_eq move.l #$42040002, (a1) moveq #0, d0 lea Neither(pc), a6 bsr print_string move.w d7, d0 moveq #0, d1 bsr print_hexw cmp.b #$89, d7 bsr pass_if_ne move.l #$42840002, (a1) moveq #0, d0 lea WordRead(pc), a6 bsr print_string move.w a2, d0 moveq #0, d1 bsr print_hexw cmp.w #$7878, a2 bsr pass_if_eq move.l #$43040002, (a1) moveq #0, d0 lea WordWrite(pc), a6 bsr print_string move.w a3, d0 moveq #0, d1 bsr print_hexw cmp.w #$BE89, a3 bsr pass_if_eq move.l #$43840002, (a1) moveq #0, d0 lea UnusedBusack(pc), a6 bsr print_string move.b $A11100, d0 and.w #$FE, d0 move.b d0, d4 moveq #0, d1 bsr print_hexw tst.b d0 bsr pass_if_ne move.l #$44040002, (a1) moveq #0, d0 lea UnusedReset(pc), a6 bsr print_string move.b $A11200, d0 and.w #$FE, d0 move.b d0, d4 moveq #0, d1 bsr print_hexw tst.b d0 bsr pass_if_ne bsr clear_zram move.l #$44840002, (a1) moveq #0, d0 lea BusackDelay(pc), a6 bsr print_string ;clear reset move.b #1, ($100, a2) ;wait a bit nop nop nop nop nop ;assert busreq move.b #1, (a2) move.b (a2), d1 move.b (a2), d2 move.b (a2), d3 move.b (a2), d4 move.b (a2), d5 move.b (a2), d6 move.b (a2), d7 moveq #0, d0 btst #0, d1 beq .done addq #1, d0 btst #0, d2 beq .done addq #1, d0 btst #0, d3 beq .done addq #1, d0 btst #0, d4 beq .done addq #1, d0 btst #0, d5 beq .done addq #1, d0 btst #0, d6 beq .done addq #1, d0 btst #0, d7 beq .done addq #1, d0 .done moveq #0, d1 bsr print_hexw long_inst_test: moveq #3, d0 bsr clear_zram_value move.l #$45040002, (a1) moveq #0, d0 lea BusackDelayLong(pc), a6 bsr print_string ;clear reset move.b #1, ($100, a2) ;wait a bit nop nop nop nop nop nop ;assert busreq move.b #1, (a2) move.b (a2), d1 move.b (a2), d2 move.b (a2), d3 move.b (a2), d4 move.b (a2), d5 move.b (a2), d6 move.b (a2), d7 moveq #0, d0 btst #0, d1 beq .done addq #1, d0 btst #0, d2 beq .done addq #1, d0 btst #0, d3 beq .done addq #1, d0 btst #0, d4 beq .done addq #1, d0 btst #0, d5 beq .done addq #1, d0 btst #0, d6 beq .done addq #1, d0 btst #0, d7 beq .done addq #1, d0 .done moveq #0, d1 bsr print_hexw move.b #1, $A11100 ;assert BUSREQ move.b #1, $A11200 ;clear reset .wait_busreq btst #0, $A11100 bne.s .wait_busreq lea $A00000, a3 move.b #$21, (a3)+ ; ld hl, nn move.b #$00, (a3)+ move.b #$60, (a3)+ move.b #$3E, (a3)+ ; ld a, n move.b #$01, (a3)+ rept 9 move.b #$77, (a3)+ ; ld (hl), a endr move.b #$26, (a3)+ ;ld h, n move.b #$80, (a3)+ move.b #$3E, (a3)+ ; ld a, n move.b #$42, (a3)+ move.b #$11, (a3)+ ; ld de, nn move.b #$00, (a3)+ move.b #$10, (a3)+ move.b #$77, (a3)+ ; ld (hl), a move.b #$23, (a3)+ ; inc hl move.b #$3C, (a3)+ ; inc a move.b #$77, (a3)+ ; ld (hl), a move.b #$23, (a3)+ ; inc hl move.b #$7E, (a3)+ ; ld a, (hl) move.b #$12, (a3)+ ; ld (de) a move.b #$23, (a3)+ ; inc hl move.b #$13, (a3)+ ; inc de move.b #$7E, (a3)+ ; ld a, (hl) move.b #$12, (a3)+ ; ld (de) a move.b #$18, (a3)+ ; jr move.b #$FE, (a3)+ ; move.l #$DEADBEEF, $FFFF8000.w move.b #0, $A11200 ;assert reset move.b #0, $A11100 ;clear BUSREQ rept 9 nop endr move.b #1, $A11200 ;clear reset moveq #$7F, d0 wait_z80 dbra d0, wait_z80 move.b #1, $A11100 ;assert BUSREQ .wait_busreq btst #0, $A11100 bne.s .wait_busreq move.l #$45840002, (a1) moveq #0, d0 lea Z80WRamWrite(pc), a6 bsr print_string move.w $FFFF8000.w, d0 moveq #0, d1 bsr print_hexw move.l #$46040002, (a1) moveq #0, d0 lea Z80WRamRead(pc), a6 bsr print_string move.b $A01000, d0 lsl.w #8, d0 move.b $A01001, d0 moveq #0, d1 bsr print_hexw move.l #$4D040002, (a1) moveq #0, d0 lea Message(pc), a6 bsr print_string move.w #$8144, (a1) ;enable display ;initial state to make it easier to setup a logic analyzer trigger move.b #1, $A11100 ;assert BUSREQ move.b #0, $A11200 ;assert reset wait_button: btst.b #5, $A10003 bne wait_button bra top clear_zram: moveq #0, d0 clear_zram_value: lea $A11100, a2 ;assert busreq move.b #1, (a2) ;clear reset move.b #1, ($100, a2) .wait_z80 btst.b #0, (a2) bne .wait_z80 lea $A00000, a3 move.w #$1FFF, d1 .loop move.b d0, (a3)+ dbra d1, .loop ;assert RESET move.b #0, ($100, a2) ;clear BUSREQ move.b #0, (a2) rts pass_if_eq: bne .fail lea Pass(pc), a6 bra .printmsg .fail lea Fail(pc), a6 .printmsg moveq #0, d0 bra print_string pass_if_ne: beq .fail lea Pass(pc), a6 bra .printmsg .fail lea Fail(pc), a6 .printmsg moveq #0, d0 bra print_string Message: dc.b "Press Start to retest", 0 ResetOnly: dc.b "RESET and not BUSREQ: ", 0 Both: dc.b "RESET and BUSREQ: ", 0 BusreqOnly: dc.b "BUSREQ and not RESET: ", 0 Neither: dc.b "Normal operation: ", 0 WordRead: dc.b "Byte writes + word read: ", 0 WordWrite: dc.b "Word write + byte reads: ", 0 UnusedBusack: dc.b "Unused BUSACK bits: ", 0 UnusedReset: dc.b "Unused RESET bits: ", 0 BusackDelay: dc.b "BUSACK delay: ", 0 BusackDelayLong: dc.b "Delay with 6T M-cycle: ", 0 Z80WRamWrite: dc.b "Z80 writes to work RAM: ", 0 Z80WRamRead: dc.b "Z80 reads to work RAM: ", 0 Pass: dc.b " PASS", 0 Fail: dc.b " FAIL", 0 align 1 ;Prints a number in hex format ;d0.w - number to print ;d1.w - base tile attribute ;a0 - VDP data port ; ;Clobbers: d2.l, d3.l ; print_hexw: moveq #3, d3 .digitloop rol.w #4, d0 moveq #$F, d2 and.b d0, d2 cmp.b #$A, d2 bge .hex add.w #$30, d2 bra .makeattrib .hex add.w #($41-$A), d2 .makeattrib add.w d1, d2 move.w d2, (a0) dbra d3, .digitloop rts ;Prints a null terminated string ;a6 - pointer to string ;a0 - VDP data port ;d0 - base tile attribute ; ;Clobbers: d1.w print_string: .loop moveq #0, d1 move.b (a6)+, d1 beq .end add.w d0, d1 move.w d1, (a0) bra .loop .end rts align 1 font: incbin font.tiles fontend romend