; Z80 side of the window-7 mapper test (z80asm syntax). ; ; A command loop driven by the 68000 over the shared RAM. The 68000 halts the Z80 with ; BUSREQ to poke a command and to read the result back, so no timing is involved. ; ; V_CMD = 1 write the bank register for 68000 address $380000, then read ($8000) ; V_CMD = 2 read ($8000) WITHOUT touching the bank register ; V_CMD = 0 idle; the Z80 clears it when the result is in V_RESULT ; ; The only difference between the two commands is the bank-register write, which is ; what the test is about: on hardware a read through this window goes out over the ; 68000 bus and the cartridge decodes the address with whatever the mapper currently ; says, so command 2 should see a page the 68000 mapped after the last bank write. V_CMD: equ $0F00 V_RESULT: equ $0F01 V_READY: equ $0F02 ; 1 once the loop is running: the 68000 waits for it, ; or its first command is cleared by the init below BANK_REG: equ $6000 ; $6000-$60FF all decode to the bank register WINDOW: equ $8000 ; the Z80's banked window into 68000 space org $0000 di im 1 ld sp,$1000 xor a ld (V_RESULT),a ld (V_CMD),a ld (V_READY),a ld a,1 ld (V_READY),a ; only now may the 68000 issue a command wait: ld a,(V_CMD) or a jr z,wait dec a jr nz,read_only ; command 2: no bank write call set_bank ; command 1: point the window at $380000 first read_only: ld a,(WINDOW) ld (V_RESULT),a xor a ld (V_CMD),a ; done; the 68000 is polling for this jr wait set_bank: ; A15..A23 of $380000, least significant first, one write each ld hl,bank_bits ld de,BANK_REG ld bc,9 ldir ret bank_bits: db 0,0,0,0,1,1,1,0,0