| Minimal test: does a Z80 read through its banked window see an Extended-SSF page | the 68000 mapped after the Z80's last bank-register write? | | Window 7 of the Extended SSF mapper ($A130FE) puts a 512 KB page of the cartridge at | 68000 address $380000. The Z80's bank register ($6000) points its $8000-$FFFF window | at a 32 KB slice of 68000 space - here $380000, i.e. the start of window 7. So a Z80 | read of $8000 goes out over the 68000 bus to $380000 and the cartridge decodes it | with whatever page the mapper currently holds. | | The test maps page 1, has the Z80 read (marker $A1), maps page 2, and has the Z80 | read again WITHOUT rewriting its bank register. Then it has the Z80 rewrite the bank | register and read once more. A 68000 read of $380000 is taken in between as a control | that the mapper write itself took effect. | | r0 Z80 read, page 1 mapped, bank register just written expect $A1 | r1 68000 read of $380000 after mapping page 2 expect $B2 (control) | r2 Z80 read after mapping page 2, NO bank rewrite expect $B2 | r3 Z80 read after rewriting the bank register expect $B2 | | Screen colour is the verdict, so no font is needed: | GREEN r2 == $B2 the read saw the newly mapped page | RED r2 == $A1 the read saw the page mapped before, i.e. a stale window | BLUE r2 is neither (unexpected: see r0..r3) | WHITE the control r1 failed - the mapper write did not take effect at all, so | the test says nothing about the Z80 path | | r0..r3 are also left at $FF0000..$FF0003 for inspection in a debugger. | | Built by tools/mapper_test/build.py. GNU as, Motorola operand syntax. .text .globl _start .long 0x00FFFE00, _start .rept 24 .long exception .endr .long exception, exception, exception, exception, exception, exception .rept 32 .long exception .endr | -- header: "SEGA SSF" is what selects the mapper ---------------------------------- .ascii "SEGA SSF " .ascii "(C)RRMD 2026.OCT" .ascii "WINDOW 7 MAPPER TEST " .ascii "WINDOW 7 MAPPER TEST " .ascii "GM 00000000-00" .word 0x0000 .ascii "J " .long 0x00000000, 0x004FFFFF .long 0x00FF0000, 0x00FFFFFF .ascii " " .ascii " " .ascii " " .ascii "JUE " .equ VDP_DATA, 0xC00000 .equ VDP_CTRL, 0xC00004 .equ VERSION, 0xA10001 .equ TMSS, 0xA14000 .equ BANK7, 0xA130FE | Extended SSF window 7 page register (word write) .equ WINDOW7, 0x380000 .equ Z80_RAM, 0xA00000 .equ Z80_BUSREQ, 0xA11100 .equ Z80_RESET, 0xA11200 .equ V_CMD, Z80_RAM+0x0F00 .equ V_RESULT, Z80_RAM+0x0F01 .equ V_READY, Z80_RAM+0x0F02 .equ RESULTS, 0xFF0000 .equ PAGE_A, 1 | ROM 0x080000, holding MARK_A at its first byte .equ PAGE_B, 2 | ROM 0x100000, holding MARK_B .equ MARK_A, 0xA1 .equ MARK_B, 0xB2 .equ GREEN, 0x00E0 .equ RED, 0x000E .equ BLUE, 0x0E00 .equ WHITE, 0x0EEE _start: move.w #0x2700,sr move.b VERSION,d0 andi.b #0x0F,d0 beq.s 1f move.l #0x53454741,TMSS | "SEGA": take the bus from TMSS 1: lea VDP_CTRL,a0 lea vdp_regs,a1 moveq #(vdp_regs_end-vdp_regs)/2-1,d1 2: move.w (a1)+,(a0) dbra d1,2b bsr load_z80 bsr z80_wait_ready | r0: page A mapped, Z80 writes its bank register and reads move.w #PAGE_A,BANK7 moveq #1,d0 bsr z80_cmd move.b d0,RESULTS+0 | map page B; r1 is the 68000's own read of the same address, as a control move.w #PAGE_B,BANK7 move.b WINDOW7,d1 move.b d1,RESULTS+1 | r2: Z80 reads again, without rewriting its bank register moveq #2,d0 bsr z80_cmd move.b d0,RESULTS+2 move.b d0,d2 | keep it: this is the answer | r3: Z80 rewrites its bank register, then reads moveq #1,d0 bsr z80_cmd move.b d0,RESULTS+3 | verdict move.w #BLUE,d3 cmpi.b #MARK_B,d2 bne.s 3f move.w #GREEN,d3 bra.s 4f 3: cmpi.b #MARK_A,d2 bne.s 4f move.w #RED,d3 4: cmpi.b #MARK_B,RESULTS+1 | control: did the mapper write take effect for the 68000? beq.s 5f move.w #WHITE,d3 5: move.l #0xC0000000,(a0) | CRAM entry 0 = the backdrop move.w d3,VDP_DATA move.w #0x8144,(a0) | display on hang: bra.s hang | -- Z80 helpers ------------------------------------------------------------------- | Every access to Z80 RAM is made with the Z80 halted; the command byte is cleared by | the Z80 itself, so the poll releases the bus between reads to let it run. z80_cmd: | d0 = command; returns the result byte in d0 bsr z80_request move.b d0,V_CMD bsr z80_release 1: bsr z80_request move.b V_CMD,d1 bsr z80_release tst.b d1 bne.s 1b bsr z80_request move.b V_RESULT,d0 bsr z80_release rts z80_wait_ready: | the Z80's own init clears V_CMD, so a command issued before it is | running would be swallowed and the poll below would read a stale result bsr z80_request move.b V_READY,d1 bsr z80_release tst.b d1 beq.s z80_wait_ready rts z80_request: move.w #0x100,Z80_BUSREQ 1: btst #0,Z80_BUSREQ bne.s 1b rts z80_release: move.w #0,Z80_BUSREQ rts load_z80: move.w #0x100,Z80_BUSREQ move.w #0x100,Z80_RESET 1: btst #0,Z80_BUSREQ bne.s 1b lea z80_driver,a1 lea Z80_RAM,a2 move.w #(z80_driver_end-z80_driver)-1,d1 2: move.b (a1)+,(a2)+ dbra d1,2b move.w #0,Z80_RESET nop nop nop nop move.w #0x100,Z80_RESET move.w #0,Z80_BUSREQ rts exception: bra.s exception .align 2 z80_driver: .incbin "mapper_z80.bin" z80_driver_end: vdp_regs: .word 0x8004, 0x8174, 0x8230, 0x8328, 0x8407, 0x8500, 0x8700 .word 0x8800, 0x8900, 0x8A00, 0x8B00, 0x8C81, 0x8D00, 0x8E00 .word 0x8F02, 0x9001, 0x9100, 0x9200 .word 0x8104 | display off until the verdict is known vdp_regs_end: | -- the two marker pages ---------------------------------------------------------- .org PAGE_A*0x80000 .byte MARK_A .org PAGE_B*0x80000 .byte MARK_B .org 0x4FFFFF | pad past 4 MB so the mapper is in play .byte 0