| rick-roll-md: Z80 PCM driver test ROM. Loads the driver, points window 7 at the | sample data, starts it, then services the driver's page requests and keeps V_GO | set (no DMA happens here). The emulator's --audio capture is then checked by | tools/pcm_check.py: every sample must appear, in order, held for exactly 3 FM | sample periods. .text .globl _start .long 0x00FFFE00, _start .rept 24 .long exception .endr .long exception, exception, hblank, exception, vblank, exception .rept 32 .long exception .endr .ascii "SEGA SSF " .ascii "(C)RRMD 2026.OCT" .ascii "PCM TEST " .ascii "PCM TEST " .ascii "GM 00000000-00" .word 0x0000 .ascii "J " .long 0x00000000, 0x00FFFFFF .long 0x00FF0000, 0x00FFFFFF .ascii " " .ascii " " .ascii " " .ascii "JUE " .equ VDP_CTRL, 0xC00004 .equ VERSION, 0xA10001 .equ TMSS, 0xA14000 .equ Z80_RAM, 0xA00000 .equ Z80_BUSREQ, 0xA11100 .equ Z80_RESET, 0xA11200 .equ BANK7, 0xA130FE | window 7 ($380000) page register (word write) .equ AUDIO_PAGE, 1 | the sample data sits at $080000 = page 1 .equ V_GO, Z80_RAM+0x0F00 .equ V_WANT_PAGE, Z80_RAM+0x0F01 .equ V_PAGE_ACK, Z80_RAM+0x0F02 .equ V_RUN, Z80_RAM+0x0F03 _start: move.w #0x2700,sr move.b VERSION,d0 andi.b #0x0F,d0 beq.s 1f move.l #0x53454741,TMSS 1: lea VDP_CTRL,a0 move.w (a0),d0 lea vdp_regs,a2 moveq #(vdp_regs_end-vdp_regs)/2-1,d1 2: move.w (a2)+,(a0) dbra d1,2b move.w #AUDIO_PAGE,BANK7 bsr load_z80 | start: with the bus held, set the flags, then let the Z80 run bsr z80_request move.b #1,V_GO move.b #0,V_WANT_PAGE move.b #0,V_PAGE_ACK move.b #1,V_RUN bsr z80_release move.w #0x8174,(a0) | display on (blank picture), VINT on main: stop #0x2300 | sleep until the next interrupt: the Z80 gets the bus to itself bra.s main | -- the vertical interrupt: serve a page request ------------------------------------- vblank: movem.l d0-d1/a0,-(sp) bsr z80_request move.b V_WANT_PAGE,d0 cmp.b V_PAGE_ACK,d0 beq.s 1f moveq #0,d1 move.b d0,d1 addq.w #AUDIO_PAGE,d1 move.w d1,BANK7 move.b d0,V_PAGE_ACK move.b #1,V_GO 1: bsr z80_release movem.l (sp)+,d0-d1/a0 rte hblank: rte exception: bra.s exception | -- Z80 control ----------------------------------------------------------------------- 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 | request the bus move.w #0x100,Z80_RESET | and take the Z80 (and the YM2612) out of 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 | reset pulse: resets the Z80 and the YM2612 moveq #0x7F,d1 3: dbra d1,3b move.w #0x100,Z80_RESET rts .align 2 vdp_regs: .word 0x8004, 0x8134, 0x8230, 0x8334, 0x8407, 0x856C, 0x8600, 0x8700 .word 0x8800, 0x8900, 0x8AFF, 0x8B00, 0x8C81, 0x8D37, 0x8E00, 0x8F02 .word 0x9001, 0x9100, 0x9200 vdp_regs_end: .align 2 z80_driver: .incbin "pcm.bin" z80_driver_end: .org 0x80000 audio: .incbin "tone.u8" .align 2