processor 6502 include vcs.h HEIGHT = 72 RED = $42 GREEN = $d6;$c6 BLUE = $86 ;=============================================================================== ; Z P - V A R I A B L E S ;=============================================================================== SEG.U variables ORG $80 tmpVar .byte tmpVar2 .byte frameCnt .byte ptr ds 6*2 colPtr ds 2 ;=============================================================================== ; M A C R O S ;=============================================================================== MAC BIT_B .byte $24 ENDM MAC BIT_W .byte $2c ENDM MAC SLEEP IF {1} = 1 ECHO "ERROR: SLEEP 1 not allowed !" END ENDIF IF {1} & 1 nop $00 REPEAT ({1}-3)/2 nop REPEND ELSE REPEAT ({1})/2 nop REPEND ENDIF ENDM ;=============================================================================== ; R O M - C O D E ;=============================================================================== SEG Bank0 ORG $f000 Start SUBROUTINE sei ; Disable interrupts, if there are any. cld ; Clear BCD math bit. ldx #0 txs pha ; Set stack to beginning. txa .clearLoop: pha dex bne .clearLoop jsr GameInit .mainLoop: jsr VerticalBlank jsr GameCalc jsr DrawScreen jsr OverScan jmp .mainLoop GameInit SUBROUTINE lda #$00 sta COLUP0 lda #$00 sta COLUP1 lda #$06 sta COLUPF lda #1 sta CTRLPF lda #%011 sta NUSIZ0 sta NUSIZ1 sta VDELP0 sta VDELP1 lda #>ColTbl sta colPtr+1 sta WSYNC SLEEP 37 sta RESP0 sta RESP1 lda #$10 sta HMP0 lda #$20 sta HMP1 sta WSYNC sta HMOVE rts VerticalBlank SUBROUTINE lda #2 sta WSYNC sta VSYNC sta WSYNC sta WSYNC lsr ldx #44 sta WSYNC sta VSYNC stx TIM64T rts GameCalc SUBROUTINE ldx frameCnt dex bpl .skipReset ldx #2 .skipReset: stx frameCnt txa clc adc #Clown0_0, >Clown2_0, >Clown1_0 .byte >Clown0_3, >Clown2_3, >Clown1_3 org $f7fc .word Start .word Start