;;; BANK 15 FOR REGISTERS ;;; BANK 14 FOR CHARACTER ROM ;;; CHARACTER ROM IS AT $D000-$DFFF ;;; STARTUP ROUTINE -- EASY TO JUMP TO $1300. START: $1300 JSR INIT JSR SETCOLORS JMP LOOP ;;; ZERO PAGE VARIABLES USED BY THE EDITOR ROM ATTR: $F1 ; CURRENT TEXT ATTRIBUTE ;;; VIC/CIA REGISTERS SSCOLLISION: $D01E JOYSTICK_2: $DC00 ;;; SCREEN EDITOR ROUTINES IN THE EDITOR ROM JWINDOW: $C02D ; SETS THE WINDOW POS, A = ROW, X = COL CLEAR: $C142 ; CLEARS THE WINDOW ;;; VARS USED BY THE "GAME" WINDOW_TOP: .BYTE #$00 ; TOP ROW OF THE WINDOW TO SET WINDOW_LEFT: .BYTE #$00 ; LEFT COL OF THE WINDOW TO SET WINDOW_BOT: .BYTE #$24 ; BOTTOM ROW OF THE WINDOW TO SET WINDOW_RIGHT: .BYTE #$39 ; RIGHT COL OF THE WINDOW TO SET ;;; CLEARS A REGION OF THE SCREEN ;;; THIS SETS THE WINDOW USING JWINDOW USING THE WINDOW_* VARS AS INPUT AND THEN ;;; CALLS THE EDITOR ROUTINE CLEAR. CLEARWIN: LDA WINDOW_TOP LDX WINDOW_LEFT CLC JSR JWINDOW LDA WINDOW_BOT LDX WINDOW_RIGHT SEC JSR JWINDOW JSR CLEAR RTS ;;; CLEARS A 6X3 WINDOW OF THE SCREEN FOR THE JAIL WINDOW CLEARJAIL: LDA WINDOW_TOP ADC #$03 STA WINDOW_BOT LDA WINDOW_LEFT ADC #$06 STA WINDOW_RIGHT JSR CLEARWIN RTS ;;; FILLS THE SCREEN WITH RED BRICKS ;;; DOES SO BY ITERATING THROUGH SCREEN MEMORY DIRECTLY INSTEAD OF USING EDITOR ;;; ROUTINES. DRAWBRICKS: LDX #$00 -: LDA &'@' STA $0400,X STA $0500,X STA $0600,X STA $06E9,X LDA #$0A ; RED STA $D800,X STA $D900,X STA $DA00,X STA $DB00,X INX BNE - RTS ;;; INITIALIZATION ROUTINE: SETS THE SPRITE AND MC COLORS SETCOLORS: LDA #$00 STA $D025 ; SET SPRITE MC0 TO BLACK LDA #$01 STA $D026 ; SET SPRITE MC1 TO WHITE LDA #$0A STA $D028 ; SET SPRITE1 COLOR TO LT.RED LDA #$02 STA $D01C ; SET SPRITE1 TO MULTICOLOR ;; SET CHARACTER COLORS LDA #$08 STA $D022 ; SET CHR MC0 TO BLACK / %01 LDA #$09 STA $D023 ; SET CHR MC1 TO WHITE / %10 RTS ;;; INITIALIZES THE SYSTEM FOR THE "GAME". ;;; THIS DISABLES BASIC IRQS FOR SPRITE MOVEMENT, ENABLES MULTICOLOR FOR SPRITES ;;; AND CHARS, AND SETS UP THE CUSTOM CHARMAP AT $2000. INIT: CLD ; DON'T NEED BCD MATH LDA #$FF ; DISABLE BASIC IRQS STA $D8 STA $12FD LDA #$10 ; ENABLE VIC MC CHARS EOR $D016 STA $D016 LDA $D018 ; SETUP THE CHARMAP AT $2000 EOR #%00001000 AND #%11111001 STA $D018 LDA #$03 STA $D015 ; ENABLE SPRITE 0 AND 1 RTS ;;; MOVES THE JAIL VERTICALLY, BASED UPON CARRY BIT JAILMOVEVERT: PHA LDA SPR0_Y BCS _ADD _SUB: SEC SBC #$08 ; ALWAYS OFFSET BY 8 JMP _STORE _ADD: CLC ADC #$08 ; ALWAYS OFFSET BY 8 _STORE: STA SPR0_Y PLA RTS ;;; MOVES THE JAIL HORIZONTALLY, ACCOUNTING FOR SEAM ;;; LIKE JAILMOVEVERT, USES CARRY BIT TO DETERMINE WHICH DIRECTION JAILMOVEHORIZ: PHA LDA SPR0_X BCS _ADD _SUB: SEC SBC #$08 JMP _STORE _ADD: CLC ADC #$08 _STORE: STA SPR0_X LDA SPXMSB BCC _CLEAR _SET: EOR #$01 JMP _STORE _CLEAR: AND #$FE _STORE: STA SPXMSB PLA RTS ;;; MOVES THE SPRITE FROM LEFT TO RIGHT ACROSS THE SCREEN ;;; THIS SIMPLY DOES WHAT IT SAYS -- IT MOVES THE SPRITE LEFT AND RIGHT ACROSS ;;; THE SCREEN, TOGGLING THE MSB AS WE GO. SPRITERUN: RTS ;;; ATTEMPT TO JAIL THE SPRITE ;;; CHECKS TO SEE IF THE SPRITE AND JAIL COLLIDE USING THE VIC REGISTERS. IF ;;; THEY DO, THEN THIS DRAWS THE BRICKS AROUND THE SPRITE JAIL POSITION, CUTS A ;;; WINDOW FOR THE SPRITE, AND THEN EFFECTIVELY STOPS THE PROGRAM BY ENTERING AN ;;; INFINITE LOOP. JAILSPRITE: ;; CHECK SPRITE POSITION LDA SSCOLLISION AND #%00000011 CMP #%00000011 ;; JAIL IF COLLISION BETWEEN SPRITES 0 AND 1 BEQ _JAIL RTS _JAIL: JSR DRAWBRICKS ;; FIGURE OUT JAIL POSITION JSR CLEARJAIL _END: JMP _END ;;; MAIN UPDATE LOOP ;;; INFINITE LOOP THAT MOVES THE SPRITE, UPDATES THE JAIL BASED ON JOYSTICK ;;; INPUTS, AND ATTEMPTS TO JAIL THE SPRITE IF FIRE IS PRESSED. LOOP: JSR SPRITERUN ;; GET JOYSTICK STATE LDA JOYSTICK_2 ;; IF DIRECTIONS PRESSED ;; MOVE JAIL IN DIRECTION INDICATED _CKUP: LSR BCS _CKDOWN JSR JAILMOVEVERT _CKDOWN: LSR BCS _CKLEFT JSR JAILMOVEVERT _CKLEFT: LSR BCS _CKRIGHT JSR JAILMOVEHORIZ _CKRIGHT: LSR BCS _CKFIRE JSR JAILMOVEHORIZ _CKFIRE: ;; IF FIRE PRESSED LSR BCS JAILSPRITE JMP LOOP