processor 6502 include "vcs.h" include "macro.h" SEG ORG $F000 ; build with dasm mouse.asm -f3 -omouse.bin ; Memory for wall hole patterns starts at $92; there are six walls, each of which is two rows, each two scanlines ; thick. Every five bytes represent the pixels across the playfield registers (the low half of the PF0 register ; is shifted and used for the PF3 register), so 5 x 2 x 6 = 60 bytes, about half our RAM, for wall gnawing. HOLES = $70 ; Not actually used for holes data, since offsets 0..$F indicate non-wall areas; $BF is next available address HOLESP1 = $71 ; just HOLES plus 1 HOLESP2 = $72 ; just HOLES plus 2 HOLESP3 = $73 ; just HOLES plus 3 HOLESP4 = $74 ; just HOLES plus 4 HOLESEND = $BB ; HOLES plus HOLESRESERVED plus HOLESSIZE HOLESRESERVED = $10 ; first 16 values are for special uses HOLESSIZE = 60 MOUSEX0 = $BC ; Mouse 0's X location MOUSEX1 = $BD ; Mouse 1's X location MOUSEY0 = $BE ; Mouse 0's Y location MOUSEY1 = $BF ; Mouse 1's Y location MOUSEYT0 = $C0 ; Mouse 0's temporary Y location MOUSEYT1 = $C1 ; Mouse 1's temporary Y location ; ; Heading Scheme ; ; H1 H0 (direction bits) ; ------+----------- ; 0 0 | Faces up ; 0 1 | Faces down ; 1 0 | Faces left ; 1 1 | Faces right ; ; H3 H2 (animation bits) ; ------+----------- ; 0 0 | animation frame 0 (not moving) ; 0 1 | animation frame 1 (first step) ; 1 0 | animation frame 2 (second step) ; MOUSEH0 = $C2 ; Mouse 0's heading/animation step MOUSEH1 = $C3 ; Mouse 0's heading/animation step ; Initialize mouse animation matrix ; Mouse animation matrix (see heading bits, above) ; This lets us reference "(H0000,x)" where x is the heading/step of a mouse, to get its frame H0000 = $C4 lda #MSFU-#MSFU sta H0000 H0001 = $C5 lda #MSFD-#MSFU sta H0001 H0010 = $C6 lda #MSFL-#MSFU sta H0010 H0011 = $C7 lda #MSFR-#MSFU sta H0011 H0100 = $C8 lda #MWFU0-#MSFU sta H0100 H0101 = $C9 lda #MWFD0-#MSFU sta H0101 H0110 = $CA lda #MWFL0-#MSFU sta H0110 H0111 = $CB lda #MWFR0-#MSFU sta H0111 H1000 = $CC lda #MWFU1-#MSFU sta H1000 H1001 = $CD lda #MWFD1-#MSFU sta H1001 H1010 = $CE lda #MWFL1-#MSFU sta H1010 H1011 = $CF lda #MWFR1-#MSFU sta H1011 ; Selected mouse graphic offsets from MSFU for the respective players - set before screen is drawn MOUSEG0 = $D0 MOUSEG1 = $D1 ; pre-stored playfield registers used for walls PF0a = $D2 ; left side PF0 PF1a = $D3 ; left side PF1 PF2a = $D4 ; left side PF2 PF0b = $D5 ; right side PF0 PF1b = $D6 ; right side PF1 PF2b = $D7 ; right side PF2 TEMP = $FD ; temporary variable for miscellaneous SCANLINE = $FE ; which scanline we're on, if we need to stash it somewhere temporarily TICK = $FF ; game clock ; Andrew Davie's magical reset formula. Optimizing best where it's least needed! Reset ldx #0 lda #0 Clear sta 0,x inx bne Clear ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright kernal ; With help from Eckhardt Stolberg's movable 48 pixel sprite demo and Eric Mooney's Stella post on VDEL Copyright2004Height = 7 BearYellowHeight = 49 BearWhiteHeight = 49 TLRLogoHeight = 17 ;Macro for drawing 32-pixel-wide graphics in the middle of the screen using VDEL ;Takes one parameter, the basename of the label of the memory and height value to use ;Munges all registers, burns through {1}Height (eg, BearYellowHeight) scanlines MAC HIREZDRAW ldy #0 DrawVDEL{1} lda {1}A,y sta GRP0 sta WSYNC ; 0 lda {1}B,y ; 0+4=4 sta GRP1 ; 4+3=7 lda {1}C,y ; 7+4=11 sta GRP0 ; 11+3=14 lda {1}D,y ; 14+4=18 sleep 24 ; 18+20=38 sta GRP1 ; 38+3=41 (*3=123) lda #0 sta GRP0 iny cpy #{1}Height bne DrawVDEL{1} sta WSYNC lda #0 sta GRP0 sta GRP1 sta GRP0 sta GRP1 ENDM ; VDEL is used to generate the big graphic for the copyright screen lda #1 sta VDELP0 sta VDELP1 ; need two copies of each player lda #$01 sta NUSIZ0 sta NUSIZ1 ; Position the player graphics right next to one-another on a cpu clock boundary sta WSYNC SLEEP 36 sta RESP0 sta RESP1 lda #%10110000 ; nudge them both over to get the timing right sta HMP0 lda #%11000000 ; nudge one of them over a smidge more to line them up sta HMP1 sta WSYNC sta HMOVE StartCopyright lda #0 sta VBLANK lda #2 ; put a 1 in D1 of VSYNC sta VSYNC sta WSYNC sta WSYNC sta WSYNC lda #0 sta VSYNC ; vertical blank area (37 blank lines at top of screen, plus 52 blank lines at top of screen) ; tick-tock goes the clock lda TICK clc adc #1 sta TICK ; set yellow color lda #$1c sta COLUP0 sta COLUP1 sta WSYNC ldy #106 CopyBurnVBlank dey sta WSYNC bne CopyBurnVBlank ; now LDY is set to zero, which is the first row of the display HIREZDRAW Copyright2004 ; put some space between copyright and bear sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC ; on alternate clocks, draw white parts or yellow parts of bear lda TICK and #%1 beq BearWhite lda #$1F sta COLUP0 sta COLUP1 sta WSYNC HIREZDRAW BearYellow jmp Logo BearWhite lda #$7F sta COLUP0 sta COLUP1 sta WSYNC HIREZDRAW BearWhite ; draw logo! Logo sta WSYNC lda #$1c sta COLUP0 sta COLUP1 sta WSYNC sta WSYNC sta WSYNC sta WSYNC HIREZDRAW TLRLogo ldy #35 CopyBurnScreen dey sta WSYNC bne CopyBurnScreen ; now LDY is set to zero, which is the first row of the display ; wait until next frame CopyNewFrame lda #%01000010 sta VBLANK ; overscan area lda #0 sta COLUPF ldy #30 CopyOverscan dey sta WSYNC bne CopyOverscan jmp StartCopyright Copyright2004A .byte %00000111 .byte %00001000 .byte %00001011 .byte %00001010 .byte %00001011 .byte %00001000 .byte %00000111 .byte %00000000 Copyright2004B .byte %10011000 .byte %01000101 .byte %01000101 .byte %01001001 .byte %01010001 .byte %01010001 .byte %10011100 .byte %00000000 Copyright2004C .byte %10001001 .byte %01010101 .byte %01010101 .byte %01010101 .byte %01010100 .byte %01010100 .byte %10001000 .byte %00000000 Copyright2004D .byte %00000000 .byte %01000000 .byte %01000000 .byte %11000000 .byte %01000000 .byte %01000000 .byte %01000000 .byte %00000000 BearYellowA .byte %00000000 .byte %00000001 .byte %00000001 .byte %00000001 .byte %00000001 .byte %00000001 .byte %00000001 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000001 .byte %00000011 .byte %00000011 .byte %00000011 .byte %00000011 .byte %00000001 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000001 .byte %00000011 .byte %00000011 .byte %00000011 .byte %00000011 .byte %00000001 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 BearYellowB .byte %11100000 .byte %11110111 .byte %11111111 .byte %11111111 .byte %11111111 .byte %11111111 .byte %11111111 .byte %11111110 .byte %01101110 .byte %00011110 .byte %00111111 .byte %00111111 .byte %00111111 .byte %00111111 .byte %00111111 .byte %00111111 .byte %00111111 .byte %00011111 .byte %00011111 .byte %00001111 .byte %11000111 .byte %11101111 .byte %11111111 .byte %11111111 .byte %11111111 .byte %11111111 .byte %11111111 .byte %00111111 .byte %00011111 .byte %00111111 .byte %00111111 .byte %00111111 .byte %00111111 .byte %00111111 .byte %00111111 .byte %00111111 .byte %01011111 .byte %11011111 .byte %11101111 .byte %11111111 .byte %11111111 .byte %11101111 .byte %11001111 .byte %10001111 .byte %00001111 .byte %00001111 .byte %00001111 .byte %00001111 .byte %00000110 BearYellowC .byte %00000000 .byte %11000000 .byte %11100000 .byte %11110000 .byte %11110000 .byte %11111000 .byte %11111000 .byte %01100000 .byte %01100000 .byte %11110000 .byte %11111000 .byte %11111000 .byte %11101000 .byte %11000001 .byte %11001011 .byte %11101111 .byte %11100111 .byte %11011111 .byte %11111111 .byte %11111111 .byte %11111111 .byte %11111110 .byte %11111100 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111100 .byte %11111110 .byte %11111111 .byte %10111111 .byte %00011111 .byte %00001111 .byte %00000110 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 BearYellowD .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %10000000 .byte %10000000 .byte %10000000 .byte %10000000 .byte %10000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 BearWhiteA .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000001 .byte %00000011 .byte %00000011 .byte %00000001 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000010 .byte %00000001 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 BearWhiteB .byte %00000000 .byte %00000000 .byte %01100000 .byte %11110001 .byte %11110001 .byte %11110011 .byte %01110011 .byte %00000110 .byte %00000110 .byte %00000110 .byte %00000111 .byte %00000111 .byte %00000111 .byte %00000110 .byte %00000110 .byte %00000110 .byte %00000110 .byte %00000110 .byte %00000011 .byte %00000000 .byte %00000001 .byte %10000011 .byte %11000111 .byte %11000011 .byte %11000011 .byte %10000011 .byte %00000011 .byte %00000111 .byte %00001111 .byte %00001111 .byte %00001111 .byte %00001111 .byte %00001111 .byte %00001111 .byte %00001111 .byte %00000111 .byte %00000111 .byte %00000011 .byte %00000011 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000110 BearWhiteC .byte %00000000 .byte %00000000 .byte %00000000 .byte %11100000 .byte %11110000 .byte %11111000 .byte %11111000 .byte %01100000 .byte %01100000 .byte %11110000 .byte %10001000 .byte %00110000 .byte %01100000 .byte %01000000 .byte %01001000 .byte %01101000 .byte %01100000 .byte %01011000 .byte %00110000 .byte %00100000 .byte %11000000 .byte %11100000 .byte %11110000 .byte %11110000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %11111000 .byte %10110000 .byte %11010000 .byte %11101000 .byte %11101000 .byte %11010000 .byte %11010000 .byte %10111000 .byte %11110000 .byte %11110000 .byte %11100000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000001 .byte %00000010 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 BearWhiteD .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 TLRLogoA .byte %00111101 .byte %00111101 .byte %00011001 .byte %00011001 .byte %00011001 .byte %00000000 .byte %11000111 .byte %11000110 .byte %11000111 .byte %11000110 .byte %11110111 .byte %00000000 .byte %00000111 .byte %00000110 .byte %00000111 .byte %00000110 .byte %00000110 TLRLogoB .byte %10110111 .byte %10110110 .byte %11110111 .byte %10110110 .byte %10110110 .byte %00000000 .byte %10011100 .byte %00110010 .byte %00110000 .byte %00110110 .byte %10011110 .byte %00000000 .byte %11011110 .byte %01011010 .byte %11011010 .byte %10011110 .byte %11011010 TLRLogoC .byte %11011110 .byte %01011000 .byte %11011100 .byte %10011000 .byte %11011110 .byte %00000000 .byte %01110011 .byte %11001011 .byte %11000011 .byte %11011011 .byte %01111011 .byte %00000000 .byte %01110011 .byte %11001011 .byte %11000011 .byte %11001011 .byte %01110011 TLRLogoD .byte %11110000 .byte %11000000 .byte %11100000 .byte %11000000 .byte %11110000 .byte %00000000 .byte %11011100 .byte %00011010 .byte %10011010 .byte %00011010 .byte %11011100 .byte %00000000 .byte %11000000 .byte %00000000 .byte %10000000 .byte %00000000 .byte %11000000 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Game kernal - starts upon reset or button press ; Initialize wallmaps - fill $92 through $CD with $FF lda #HOLESSIZE ; offset starting at the top adc #HOLESRESERVED ; offset to first memory location tax lda #%11111111 FillHoles sta HOLESP1,x dex bne FillHoles ; Initialize mouse 0 lda #%1001 ; begin facing down in step 2 of animation sta MOUSEH0 lda #56 ; start at y=180 sta MOUSEY0 lda #1 ; start at x=120 sta MOUSEX0 sta WSYNC SLEEP 2 ; wait for 120th pixel sta RESP0 SLEEP 5 sta RESP1 ; Start the game! jmp StartFrame ; Mouse Sitting Facing Up - what'd you think it stood for? MSFU .byte %00010000 .byte %01010100 .byte %00111000 .byte %10111010 .byte %01111100 .byte %01111100 .byte %00111000 .byte %00010000 .byte %00010000 .byte %00001100 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Mouse walking up, frame 0 MWFU0 .byte %00010000 .byte %00010100 .byte %01111000 .byte %10111000 .byte %01111010 .byte %01111100 .byte %00111100 .byte %00010000 .byte %00010000 .byte %00001000 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Mouse walking up, frame 1 MWFU1 .byte %00010000 .byte %01010000 .byte %00111100 .byte %00111010 .byte %10111100 .byte %01111100 .byte %01111000 .byte %00010000 .byte %00010000 .byte %00100000 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Sitting mouse facing down MSFD .byte %00001100 .byte %00010000 .byte %00010000 .byte %00111000 .byte %01111100 .byte %01111100 .byte %10111010 .byte %00111000 .byte %01010100 .byte %00010000 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Mouse walking down, frame 0 MWFD0 .byte %00001000 .byte %00010000 .byte %00010000 .byte %00111100 .byte %01111100 .byte %01111010 .byte %10111000 .byte %01111000 .byte %00010100 .byte %00010000 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Mouse walking down, frame 1 MWFD1 .byte %00100000 .byte %00010000 .byte %00010000 .byte %01111000 .byte %01111100 .byte %10111100 .byte %00111010 .byte %00111100 .byte %01010000 .byte %00010000 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Sitting mouse facing right MSFR .byte %00000101 .byte %00001010 .byte %00011110 .byte %01111111 .byte %10011110 .byte %00011110 .byte %00000101 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Mouse walking right, frame 0 MWFR0 .byte %00000110 .byte %00001010 .byte %00011110 .byte %01111111 .byte %10011110 .byte %00011010 .byte %00001001 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Mouse walking right, frame 1 MWFR1 .byte %00001001 .byte %00011010 .byte %10011110 .byte %01111111 .byte %00011110 .byte %00001010 .byte %00000110 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Sitting mouse facing left MSFL .byte %10100000 .byte %01010000 .byte %01111000 .byte %11111110 .byte %01111001 .byte %01111000 .byte %10100000 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Mouse walking left, frame 0 MWFL0 .byte %01100000 .byte %01010000 .byte %01111000 .byte %11111110 .byte %01111001 .byte %01011000 .byte %10010000 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; Mouse walking left, frame 1 MWFL1 .byte %10010000 .byte %01010000 .byte %01111001 .byte %11111110 .byte %01111000 .byte %01010000 .byte %01100000 ; padding out to 16 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 ; scores - PF1 single digit; shift score value left 3 bits, then add scanline SCORES0 .byte %0100 .byte %1110 .byte %1010 .byte %1010 .byte %1010 .byte %1010 .byte %1110 .byte %0100 SCORES1 .byte %0100 .byte %1100 .byte %0100 .byte %0100 .byte %0100 .byte %0100 .byte %0100 .byte %1110 SCORES2 .byte %0100 .byte %1110 .byte %1010 .byte %0010 .byte %0110 .byte %1100 .byte %1110 .byte %1110 SCORES3 .byte %1110 .byte %1110 .byte %0010 .byte %0100 .byte %0010 .byte %1010 .byte %1110 .byte %0100 SCORES4 .byte %0010 .byte %0010 .byte %1010 .byte %1111 .byte %1111 .byte %0010 .byte %0010 .byte %0010 SCORES5 .byte %1110 .byte %1110 .byte %1000 .byte %1100 .byte %1110 .byte %0010 .byte %1110 .byte %1100 SCORES6 .byte %0100 .byte %1100 .byte %1000 .byte %1100 .byte %1110 .byte %1010 .byte %1110 .byte %0100 SCORES7 .byte %1110 .byte %1110 .byte %0010 .byte %0010 .byte %0010 .byte %0100 .byte %0100 .byte %0100 SCORES8 .byte %0100 .byte %1110 .byte %1010 .byte %1100 .byte %0110 .byte %1010 .byte %1110 .byte %0100 SCORES9 .byte %0100 .byte %1110 .byte %1010 .byte %1110 .byte %0110 .byte %0010 .byte %0110 .byte %0100 StartFrame lda #0 sta VBLANK lda #2 ; put a 1 in D1 of VSYNC sta VSYNC sta WSYNC sta WSYNC sta WSYNC lda #0 sta VSYNC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; vertical blank area (37 blank lines at top of screen, during which we can perform set-up) VerticalBlank lda #2 ldy #33 ; ====> "scanlines to waste" ; burn off extra scanlines (number of extras set in y register, above) BurnVBlank dey sty COLUBK sta WSYNC bne BurnVBlank ; now LDY is set to zero, which is the first row of the display ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; set up time before display area (be sure to reduce "scanlines to waste," above, as appropriate) ; set score mode for score area playfield, and set ball size at 4 clock-pixels wide for wall studs lda #%00010010 sta CTRLPF ;clear PF registers lda #0 sta PF0 sta PF1 sta PF2 sta WSYNC ; figure out which mouse graphics to use lda #0 ; clear mouse graphics (so they don't show in the score area) sta GRP0 sta GRP1 lda TICK clc ; clear carry - other adc instructions may have left it set adc #1 sta TICK and #%111 ; every eigth cycle, move mice beq MoveMice ; Don't move mice - just maintain ldx MOUSEH0 lda H0000,x sta MOUSEG0 lda MOUSEY0 sta MOUSEYT0 ; temporary mouse Y must be reset each frame jmp DoneMovingMice MoveMice lda MOUSEH0 ; get mouse's current heading tax eor #%1100 ; (&&&if moving!) alternate steps of animation sta MOUSEH0 lda H0000,x ; get offset from MSFU graphic sta MOUSEG0 lda MOUSEY0 adc #2 sta MOUSEY0 sta MOUSEYT0 ; temporary MOUSEY which can be modified during the screen for optimizational purposes DoneMovingMice sta WSYNC ;single-digit score code lda #5 ; score of 5 asl ; multiply by 8 asl asl tax ; store left score in X register lda #6 ; score of 6 asl ; multiply by 8 asl asl tay ; store right score in Y register sta WSYNC ; score background lda #$0f ; white sta COLUBK ; player colors (will be more complicated for 2 player...) lda #$10 ; dark brown mouse sta COLUP0 lda #$18 ; orangish cat sta COLUP1 sta WSYNC ; blank line sta WSYNC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; display area (192 golden lines of screen time) Score lda SCORES0,x sta PF1 inx lda SCORES0,y iny SLEEP 22 sta PF1 sta WSYNC ; first row complete lda SCORES0,x sta PF1 inx lda SCORES0,y iny SLEEP 22 sta PF1 sta WSYNC ; second row complete lda SCORES0,x sta PF1 inx lda SCORES0,y iny SLEEP 22 sta PF1 sta WSYNC ; third lda SCORES0,x sta PF1 inx lda SCORES0,y iny SLEEP 22 sta PF1 sta WSYNC ; fourth lda SCORES0,x sta PF1 inx lda SCORES0,y iny SLEEP 22 sta PF1 sta WSYNC ; fifth lda SCORES0,x sta PF1 inx lda SCORES0,y iny SLEEP 22 sta PF1 sta WSYNC ; sixth lda SCORES0,x sta PF1 inx lda SCORES0,y iny SLEEP 22 sta PF1 sta WSYNC ; seventh lda SCORES0,x sta PF1 inx lda SCORES0,y iny SLEEP 22 sta PF1 sta WSYNC ; eighth line of score display ; white line between score and game board ; unset score mode for rest of playfield, and set (keep) ball size at 4 clock-pixels wide for wall studs lda #%00010000 ; 0+2=2 sta CTRLPF ; 2+3=5 lda #$0f ; 10+2=12 - set color to white sta COLUPF ; 12+3=15 lda #$ff ; 15+2=17 - set playfields sta PF0 ; 17+3=20 sta PF1 ; 20+3=23 sta PF2 ; 23+3=26 lda #$00 ; 5+2=7 - set color to black sta COLUBK ; 7+3=10 ; we've had 8 rows of display now, so we'll be continuing on row 9 ldy #0 ; 26+2=28 - starting game area at scanline 0 ; Mouse drawing routine - takes one parameter, the mouse to draw; munges A and X MAC DrawMouse cpy MOUSEYT{1} ; 0+3=3 - see if Mouse{1} is at or below this scanline bcc MouseNotDrawn ; 3+2=5 tya ; 5+2=7 - copy ordinate of scanline to A sbc MOUSEYT{1} ; 7+3=10 - how far into the mouse are we? tax ; 10+2=12 cmp #16 ; 12+2=14 - we don't have any graphics taller than 16 bcs MouseDone ; 14+2=16 lda MOUSEG{1} ; 16+3=19 - find offset from start of graphic table for current frame and scanline tax ; 19+2=21 adc #1 ; 21+2=23 sta MOUSEG{1} ; 23+3=26 - increment to next scanline within graphic lda MSFU,x ; 26+4=30 - grab graphic for this scanline jmp MouseDrawn ; 30+3=33 MouseDone lda #193 ; push mouse off screen so remaining rows take less CPU sta MOUSEYT{1} MouseNotDrawn lda #0 ; clear mouse graphic register MouseDrawn sta GRP0 ; 33+3=36 ENDM GameBoardEmpty sta WSYNC ; now wait for display to start! iny ; odd number - color lda MAP,y ; 0+3=3 sta COLUBK ; 3+3=6 lda #0 ; 6+2=8 - prepare to clear playfield sta PF0 ; 8+3=11 sta PF1 ; 11+3=14 sta PF2 ; 14+3=17 jmp SpriteLine ; 17+3=20 GameBoardFloor sta WSYNC ; now wait for display to start! iny ; odd number - color lda MAP,y ; 0+3=3 - get background color for this row sta COLUBK ; 3+3=6 lda FLRTILE0,x ; 6+3=9 sta PF0 ; 9+3=12 lda FLRTILE1,x ; 12+3=15 sta PF1 ; 15+3=18 lda FLRTILE2,x ; 18+3=21 sta PF2 ; 21+3=24 jmp SpriteLine ; 24+3=27 ; must be a wall - load the first three segments & turn on wall collisions GameBoardWall sta WSYNC ; now wait for display to start! lda HOLESP1,x ; 0+4=4 sta PF1 ; 4+3=7 sta PF1 lda HOLESP2,x ; 7+4=11 sta PF2 ; 11+3=14 lda HOLES,x ; 14+4=18 sta PF0 ; 18+3=21 ; load the second half asl ; 21+2=23 asl ; 23+2=25 asl ; 25+2=27 asl ; 27+2=29 iny ; 29+2=31 odd number - had to do this somewhere! SLEEP 8 ; 31+8=39 sta PF0 ; 39+3=42 lda HOLESP3,x ; 42+4=46 sta PF1 ; 46+3=49 lda HOLESP4,x ; 49+4=53 sta PF2 ; 53+3=56 ;jmp SpriteLine SpriteLine sta WSYNC DrawMouse 0 ; CURRENT WORK (SEP 1): MODIFICATION TO RUN PF CODE EVERY OTHER SCANLINE AND SPRITE CODE THE OTHER - CONVERTED DATA TONIGHT ; load in next scan line - if there is a next scanline! FinishLine cpy #191 ; 56+2=58 - see if we've reached the bottom beq NewFrame ; 58+2=60 (except last scanline, where it's 3) iny ; 60+2=62 - update to next scanline lda MAP,y ; 62+4=66 get wall/not-wall status of next row (if wall, is also holes pattern offset) tax cpx #HOLESRESERVED ; +2= - see if x is HOLESRESERVED ($10 right now) or more bcs GameBoardWall ; 66+3=69 - branch if x > 10 cpx #2 ; +2= - see if it's 2 or more bcc GameBoardFloor jmp GameBoardEmpty ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; wait until next frame NewFrame lda #%01000010 sta VBLANK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; overscan area lda #0 sta COLUPF ldy #30 Overscan dey sta WSYNC bne Overscan jmp StartFrame ; MAP - the game board ; the background consists of a 2-PF-Pixel left edge, four 13-PF-Pixel center tiles and a 3-PF-Pixel righthand end ; these tiles alternate between two colors defined in this table ; scanline list; groups clustered together represent walls ; Removed June 20, 2004 ; MAPSCLN .byte 9, 35,36,37, 39, 42, 46, 50, 54,56,57, 58, 60, 91,92,93, 95, 98, 103, 107, 110,112,113, 114, 147,148,149, 151, 154, 159, 163, 166,168,169, 170 ; "floor" pattern for "background" patterns (pattern 0 starts at FLRTILE0, offset 0: 2 bits on, 2 bits off, 2 bits on; pattern 1 starts at FLRTILE0, offset 1: 2 bits off, 2 bits on, ...) FLRTILE0 .byte %11001100 FLRTILE1 .byte %00110011 FLRTILE2 .byte %11001100 .byte %00110011 ; FLRTILE2, offset 1 MAP .byte $01 ; rows 009 - 010 checkerboard pattern 1: --xx--xx .byte $0C ; rows 009 - 010 light gray .byte $00 ; rows 011 - 012 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 011 - 012 light gray .byte $00 ; rows 013 - 014 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 013 - 014 light gray .byte $00 ; rows 015 - 016 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 015 - 016 light gray .byte $00 ; rows 017 - 018 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 017 - 018 light gray .byte $00 ; rows 019 - 020 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 019 - 020 light gray .byte $00 ; rows 021 - 022 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 021 - 022 light gray .byte $01 ; rows 023 - 024 checkerboard pattern 1: --xx--xx .byte $0C ; rows 023 - 024 light gray .byte $01 ; rows 025 - 026 checkerboard pattern 1: --xx--xx .byte $0C ; rows 025 - 026 light gray .byte $01 ; rows 027 - 028 checkerboard pattern 1: --xx--xx .byte $0C ; rows 027 - 028 light gray .byte $01 ; rows 029 - 030 checkerboard pattern 1: --xx--xx .byte $0C ; rows 029 - 030 light gray .byte $01 ; rows 031 - 032 checkerboard pattern 1: --xx--xx .byte $0C ; rows 031 - 032 light gray .byte $01 ; rows 033 - 034 checkerboard pattern 1: --xx--xx .byte $0C ; rows 033 - 034 light gray .byte $11 ; rows 035 - 036 wall with five pattern bytes starting at $11 .byte $0C ; rows 035 - 036 light gray .byte $16 ; rows 037 - 038 wall with five pattern bytes starting at $16 .byte $0C ; rows 037 - 038 light gray .byte $02 ; rows 039 - 040 blank scanline .byte $06 ; rows 039 - 040 dark gray .byte $02 ; rows 041 - 042 blank scanline .byte $06 ; rows 041 - 042 dark gray .byte $02 ; rows 043 - 044 blank scanline .byte $06 ; rows 043 - 044 dark gray .byte $02 ; rows 045 - 046 blank scanline .byte $06 ; rows 045 - 046 dark gray .byte $02 ; rows 047 - 048 blank scanline .byte $06 ; rows 047 - 048 dark gray .byte $02 ; rows 049 - 050 blank scanline .byte $06 ; rows 049 - 050 dark gray .byte $02 ; rows 051 - 052 blank scanline .byte $06 ; rows 051 - 052 dark gray .byte $1B ; rows 053 - 054 wall with five pattern bytes starting at $1B .byte $0C ; rows 053 - 054 light gray .byte $20 ; rows 055 - 056 wall with five pattern bytes starting at $20 .byte $0C ; rows 055 - 056 light gray .byte $02 ; rows 057 - 058 blank scanline .byte $EC ; rows 057 - 058 light green .byte $02 ; rows 059 - 060 blank scanline .byte $EC ; rows 059 - 060 light green .byte $02 ; rows 061 - 062 blank scanline .byte $EC ; rows 061 - 062 light green .byte $02 ; rows 063 - 064 blank scanline .byte $EC ; rows 063 - 064 light green .byte $02 ; rows 065 - 066 blank scanline .byte $EC ; rows 065 - 066 light green .byte $02 ; rows 067 - 068 blank scanline .byte $EC ; rows 067 - 068 light green .byte $02 ; rows 069 - 070 blank scanline .byte $EC ; rows 069 - 070 light green .byte $02 ; rows 071 - 072 blank scanline .byte $EC ; rows 071 - 072 light green .byte $02 ; rows 073 - 074 blank scanline .byte $EC ; rows 073 - 074 light green .byte $02 ; rows 075 - 076 blank scanline .byte $EC ; rows 075 - 076 light green .byte $02 ; rows 077 - 078 blank scanline .byte $EC ; rows 077 - 078 light green .byte $02 ; rows 079 - 080 blank scanline .byte $EC ; rows 079 - 080 light green .byte $02 ; rows 081 - 082 blank scanline .byte $EC ; rows 081 - 082 light green .byte $02 ; rows 083 - 084 blank scanline .byte $EC ; rows 083 - 084 light green .byte $02 ; rows 085 - 086 blank scanline .byte $EC ; rows 085 - 086 light green .byte $02 ; rows 087 - 088 blank scanline .byte $EC ; rows 087 - 088 light green .byte $02 ; rows 089 - 090 blank scanline .byte $EC ; rows 089 - 090 light green .byte $25 ; rows 091 - 092 wall with five pattern bytes starting at $25 .byte $0C ; rows 091 - 092 light gray .byte $2A ; rows 093 - 094 wall with five pattern bytes starting at $2A .byte $0C ; rows 093 - 094 light gray .byte $02 ; rows 095 - 096 blank scanline .byte $06 ; rows 095 - 096 dark gray .byte $02 ; rows 097 - 098 blank scanline .byte $06 ; rows 097 - 098 dark gray .byte $02 ; rows 099 - 100 blank scanline .byte $06 ; rows 099 - 100 dark gray .byte $02 ; rows 101 - 102 blank scanline .byte $06 ; rows 101 - 102 dark gray .byte $02 ; rows 103 - 104 blank scanline .byte $06 ; rows 103 - 104 dark gray .byte $02 ; rows 105 - 106 blank scanline .byte $06 ; rows 105 - 106 dark gray .byte $02 ; rows 107 - 108 blank scanline .byte $06 ; rows 107 - 108 dark gray .byte $2F ; rows 109 - 110 wall with five pattern bytes starting at $2F .byte $0C ; rows 109 - 110 light gray .byte $34 ; rows 111 - 112 wall with five pattern bytes starting at $34 .byte $0C ; rows 111 - 112 light gray .byte $00 ; rows 113 - 114 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 113 - 114 light gray .byte $00 ; rows 115 - 116 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 115 - 116 light gray .byte $00 ; rows 117 - 118 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 117 - 118 light gray .byte $00 ; rows 119 - 120 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 119 - 120 light gray .byte $00 ; rows 121 - 122 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 121 - 122 light gray .byte $00 ; rows 123 - 124 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 123 - 124 light gray .byte $00 ; rows 125 - 126 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 125 - 126 light gray .byte $00 ; rows 127 - 128 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 127 - 128 light gray .byte $00 ; rows 129 - 130 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 129 - 130 light gray .byte $00 ; rows 131 - 132 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 131 - 132 light gray .byte $00 ; rows 133 - 134 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 133 - 134 light gray .byte $00 ; rows 135 - 136 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 135 - 136 light gray .byte $00 ; rows 137 - 138 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 137 - 138 light gray .byte $00 ; rows 139 - 140 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 139 - 140 light gray .byte $00 ; rows 141 - 142 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 141 - 142 light gray .byte $00 ; rows 143 - 144 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 143 - 144 light gray .byte $00 ; rows 145 - 146 checkerboard pattern 0: xx--xx-- .byte $0C ; rows 145 - 146 light gray .byte $39 ; rows 147 - 148 wall with five pattern bytes starting at $39 .byte $09 ; rows 147 - 148 middling gray .byte $3E ; rows 149 - 150 wall with five pattern bytes starting at $3E .byte $09 ; rows 149 - 150 middling gray .byte $02 ; rows 151 - 152 blank scanline .byte $06 ; rows 151 - 152 dark gray .byte $02 ; rows 153 - 154 blank scanline .byte $08 ; rows 153 - 154 gray .byte $02 ; rows 155 - 156 blank scanline .byte $08 ; rows 155 - 156 gray .byte $02 ; rows 157 - 158 blank scanline .byte $08 ; rows 157 - 158 gray .byte $02 ; rows 159 - 160 blank scanline .byte $04 ; rows 159 - 160 darker gray .byte $02 ; rows 161 - 162 blank scanline .byte $04 ; rows 161 - 162 darker gray .byte $02 ; rows 163 - 164 blank scanline .byte $02 ; rows 163 - 164 darkest gray .byte $43 ; rows 165 - 166 wall with five pattern bytes starting at $43 .byte $09 ; rows 165 - 166 middling gray .byte $48 ; rows 167 - 168 wall with five pattern bytes starting at $48 .byte $09 ; rows 167 - 168 middling gray .byte $02 ; rows 169 - 170 blank scanline .byte $C4 ; rows 169 - 170 grass green .byte $02 ; rows 171 - 172 blank scanline .byte $C4 ; rows 171 - 172 grass green .byte $02 ; rows 173 - 174 blank scanline .byte $C4 ; rows 173 - 174 grass green .byte $02 ; rows 175 - 176 blank scanline .byte $C4 ; rows 175 - 176 grass green .byte $02 ; rows 177 - 178 blank scanline .byte $C4 ; rows 177 - 178 grass green .byte $02 ; rows 179 - 180 blank scanline .byte $C4 ; rows 179 - 180 grass green .byte $02 ; rows 181 - 182 blank scanline .byte $C4 ; rows 181 - 182 grass green .byte $02 ; rows 183 - 184 blank scanline .byte $C4 ; rows 183 - 184 grass green .byte $02 ; rows 185 - 186 blank scanline .byte $C4 ; rows 185 - 186 grass green .byte $02 ; rows 187 - 188 blank scanline .byte $C4 ; rows 187 - 188 grass green .byte $02 ; rows 189 - 190 blank scanline .byte $C4 ; rows 189 - 190 grass green .byte $02 ; rows 191 - 192 blank scanline .byte $C4 ; rows 191 - 192 grass green ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Interrupt Vectors ORG $FFFA .word Reset ; NMI .word Reset ; RESET .word Reset ; IRQ END