arch snes.cpu define '0' 0 define '1' 1 define '2' 2 define '3' 3 define '4' 4 define '5' 5 define '6' 6 define '7' 7 define '8' 8 define '9' 9 define 'A' 10 define 'B' 11 define 'C' 12 define 'D' 13 define 'E' 14 define 'F' 15 define 'G' 16 define 'H' 17 define 'I' 18 define 'J' 19 define 'K' 20 define 'L' 21 define 'M' 22 define 'N' 23 define 'O' 0 define 'P' 24 define 'Q' 25 define 'R' 26 define 'S' 27 define 'T' 28 define 'U' 29 define 'V' 30 define 'W' 31 define 'X' 32 define 'Y' 33 define 'Z' 34 define ' ' 35 define ':' 36 // ---------------- Variables namespace zp base $0000 trampoline: ; seek 1 pointer: ; seek 2 nmitask: ; seek 1 ppuctrl: ; seek 1 exram: ; seek 1 mirroring: ; seek 1 bankorder: ; seek 1 inputnew: ; seek 1 inputold: ; seek 1 databanks: ; seek 8 // ---------------- Task indexes namespace task base $0000 readdata: ; seek 2 setppuctrl: ; seek 2 setexram: ; seek 2 setmirror: ; seek 2 setbanks: ; seek 2 initialize: ; seek 2 namespace global macro seek n org ({n} & $1fff) base {n} endmacro macro vram x, y; ($2000 + ({y} << 5) + {x}); endmacro {seek $e000} fill $2000 {seek $fffa} dw NMIVector dw ResetVector dw ResetVector {seek $e000} ResetVector: cld ldx #$00 stx $2000 stx $2001 stx $4010 stx $4015 stx $5010 stx $5015 bit $2002 - bit $2002 bpl {-} - bit $2002 bpl {-} stx >8 sta OAMData,x sta $0200,y dex dey bpl {-} rts // ---------------- NMI event loop NMIVector: lda #$00 sta $2003 lda #$02 sta $4014 bit $2002 ldx JumpTable,x sta JumpTable+1,x sta CHRAddrTable,x sta $2006 sty $2006 lda $2007 lda $2007 sta >8 sta $2006 lda #<{vram 15, 18} sta $2006 lda >8 stx $2006 ldx #<{vram 24, 8} stx $2006 ldx #$00 stx $5105 // make sure real nametable is mapped in and #$08 // current OBJ pattern table beq {+} inx + stx $2007 lda >8 sta $2006 lda #<{vram 18, 12} sta $2006 // pointer = bankorder * 12 + BankOrderData lda >8 adc #$00 sta PaletteData - sty $2007 inx lda >PaletteData,x sta $2007 inx lda >PaletteData,x sta $2007 sty $2007 cpx #$10 bcc {-} rts PaletteData: db $00 db $20,$0F db $22,$0F db $2A,$0F db $26,$0F db $33,$0F db $36,$0F db $39,$0F db $3C,$0F // ---------------- VRAM data VRAMData: db 4*32+7, 18, "MMC5 CHR BANK TEST" db 7+32+7, 18, "REGISTER SETTINGS:" db 7+32+4, 18, "OBJ PATTERN TABLE:", 3, 3, "000" db 4 +4, 17, "BG PATTERN TABLE:", 4, 3, "000" db 4+32+18, 12, "0123456789AB" db 2 +2, 15, "BANK SET ORDER:" db 15+32+7, 18, "CURRENT CHR BANKS:" db 7+32+9, 4, "OBJ:" db 19 +9, 3, "BG:", 7, 4, $25,$65,$A5,$E5 db 9 +9, 5, "DATA:" db 18+32+12, 9, "CONTROLS:" db 11+32+3, 2, "A:", 7, 17, "OBJ PATTERN TABLE" db 3 +3, 2, "B:", 7, 16, "BG PATTERN TABLE" db 4 +3, 6, "START:", 3, 15, "CHANGE OBJ SIZE" db 5 +3, 21, "SELECT: TOGGLE EXRAM" db 8 +3, 6, "PAD U:", 3, 16, "TOGGLE FILL MODE" db 4 +3, 26, "PAD L R: CHANGE BANK ORDER" db 3+32*2, 64 db $00,$00,$00,$00,$00,$00,$00,$00 db $00,$00,$00,$00,$00,$00,$00,$00 db $00,$00,$00,$00,$00,$00,$05,$00 db $00,$00,$00,$00,$04,$05,$05,$01 db $00,$00,$00,$80,$A8,$AA,$00,$00 db $C0,$30,$00,$00,$00,$00,$00,$00 db $CC,$FF,$F3,$00,$00,$00,$00,$00 db $00,$00,$00,$00,$00,$00,$00,$00 db 0 // ---------------- OAM data define ypos 119 define xpos 176 OAMData: // 8x8 db {ypos}, $25, 0, {xpos}-24 db {ypos}, $65, 1, {xpos}-16 db {ypos}, $a5, 2, {xpos}-8 db {ypos}, $e5, 3, {xpos} db $f0, $f0, $f0, $f0 db $f0, $f0, $f0, $f0 db $f0, $f0, $f0, $f0 db $f0, $f0, $f0, $f0 // 8x16 db {ypos}-8, $26, 0, {xpos}-56 db {ypos}-8, $66, 1, {xpos}-48 db {ypos}-8, $a6, 2, {xpos}-40 db {ypos}-8, $e6, 3, {xpos}-32 db {ypos}-8, $27, 0, {xpos}-24 db {ypos}-8, $67, 1, {xpos}-16 db {ypos}-8, $a7, 2, {xpos}-8 db {ypos}-8, $e7, 3, {xpos}