| rick-roll-md player, Phase 1: boot, set the VDP up, load one encoded frame, show it. | GNU as, Motorola operand syntax. Register names without % (--register-prefix-optional). | | VRAM map (PLAN.md 2, "VRAM"): | $0000-$BFFF tiles (1536 slots, tile 0 blank) | $C000-$CFFF plane A name table, 64x32 | $D000-$D7FF window name table (unused, left zero) | $D800-$DA7F sprite table (left zero: one blank sprite off screen) | $DC00-$DC03 h-scroll (left zero) | $E000-$EFFF plane B name table (left zero: all tile 0, low priority) .text .globl _start | -- vector table ----------------------------------------------------------------- .long 0x00FFFE00 | initial SSP .long _start | initial PC .rept 24 .long exception | bus error .. reserved (vectors 2-25) .endr .long exception | 26: level 2 (external) .long exception .long hblank | 28: level 4 (horizontal) .long exception .long vblank | 30: level 6 (vertical) .long exception .rept 32 .long exception | 32-63: traps and reserved .endr | -- header (offset $100) --------------------------------------------------------- .ascii "SEGA SSF " | console: Krikzz Extended SSF mapper .ascii "(C)RRMD 2026.OCT" .ascii "RICK ROLL MD " | domestic, 48 .ascii "RICK ROLL MD " | overseas, 48 .ascii "GM 00000000-00" | serial .word 0x0000 | checksum (not verified by hardware) .ascii "J " | I/O support .long 0x00000000, 0x00FFFFFF | ROM start, end (16 MB, mapper paged) .long 0x00FF0000, 0x00FFFFFF | RAM .ascii " " | no backup RAM .ascii " " | no modem .ascii " " | notes, 40 .ascii "JUE " | region | offset $200 | -- constants -------------------------------------------------------------------- .equ VDP_DATA, 0xC00000 .equ VDP_CTRL, 0xC00004 .equ VERSION, 0xA10001 .equ TMSS, 0xA14000 | VDP control words for a write at address A: | VRAM: 0x40000000 | (A & 0x3FFF) << 16 | (A >> 14) | CRAM: 0xC0000000 | (A & 0x3FFF) << 16 .equ VRAM_TILES, 0x40000000 | $0000 .equ VRAM_PLANE_A, 0x40000003 | $C000 .equ CRAM_0, 0xC0000000 | -- entry ------------------------------------------------------------------------ _start: move.w #0x2700,sr | TMSS: a console whose version register's low nibble is nonzero wants "SEGA" | at $A14000 before its first VDP access (the emulator's Lockup otherwise). move.b VERSION,d0 andi.b #0x0F,d0 beq.s 1f move.l #0x53454741,TMSS 1: lea VDP_CTRL,a0 lea VDP_DATA,a1 move.w (a0),d0 | read status: clears the control-word latch | registers, display off while we load lea vdp_regs,a2 moveq #(vdp_regs_end-vdp_regs)/2-1,d1 2: move.w (a2)+,(a0) dbra d1,2b | tiles -> VRAM $0000 (CPU writes: Phase 1 keeps the DMA out of the picture) move.l #VRAM_TILES,(a0) lea tiles,a2 move.l #(tiles_end-tiles)/2-1,d1 3: move.w (a2)+,(a1) subq.l #1,d1 bpl.s 3b | CRAM, all four lines move.l #CRAM_0,(a0) lea cram,a2 moveq #64-1,d1 4: move.w (a2)+,(a1) dbra d1,4b | plane A name table, 64x32 words move.l #VRAM_PLANE_A,(a0) lea nametable,a2 move.w #2048-1,d1 5: move.w (a2)+,(a1) dbra d1,5b | display on: reg 1 = display | VINT | DMA | M5 move.w #0x8174,(a0) move.w #0x2300,sr | let the vertical interrupt through idle: bra.s idle | -- interrupts ------------------------------------------------------------------- vblank: rte hblank: rte exception: bra.s exception | -- VDP register image ----------------------------------------------------------- .align 2 vdp_regs: .word 0x8004 | 0: H-int off, full-colour mode .word 0x8134 | 1: display OFF, VINT on, DMA on, V28, M5 .word 0x8230 | 2: plane A at $C000 .word 0x8334 | 3: window at $D000 .word 0x8407 | 4: plane B at $E000 .word 0x856C | 5: sprites at $D800 .word 0x8600 .word 0x8700 | 7: backdrop = colour 0 (black) .word 0x8800 .word 0x8900 .word 0x8AFF | 10: H-int counter (unused) .word 0x8B00 | 11: full-screen scroll, no external interrupt .word 0x8C89 | 12: H40, shadow/highlight ON .word 0x8D37 | 13: h-scroll table at $DC00 .word 0x8E00 .word 0x8F02 | 15: auto-increment 2 .word 0x9001 | 16: planes 64x32 .word 0x9100 | 17: window X .word 0x9200 | 18: window Y vdp_regs_end: | -- the encoded frame (from python -m rrmd frame) -------------------------------- .align 2 cram: .incbin "cram.bin" nametable: .incbin "nametable.bin" tiles: .incbin "tiles.bin" tiles_end: .align 2