processor 6502 include vcs.h include macro.h ;set origin to the start RAM ;this is where variables are declared SEG.U vars;this declares Uninitialized space. i.e. RAM ; "vars" is the label. YOU NEED THIS!! ORG $80 ;$80 is the beginning of RAM ; vet up variables YPosP0 ds 1 HeightP0 ds 1 YPosP1 ds 1 HeightP1 ds 1 ;set origin to the start of the 4k rom SEG;this end the unitialized space and begins Initialized space ; i.e. ROM ORG $F000 ;$F000 is the beginning of ROM Reset ;Clear RAM and all TIA registers ldx #0 lda #0 Clear sta 0,x inx bne Clear ;total 9 bytes! ;////////////////////////////////////// ; InitializeVariables ;////////////////////////////////////// lda #90 sta YPosP0 sta YPosP1 ;EndInitializeVariables ;//////////////////////////////////////// StartOfFrame; Beginning of the game ;//////////////////////////////////////// ;===================================== ; VerticalSync ;top 3 scanlines ;using macro. this also stops vsync VERTICAL_SYNC ;===================================== ;===================================== ;VerticalBlank ;37 scanlines ldx #37 ; 37 scanlines of vertical blank... SLEEP 23 STA RESP0;put player 0 at clock 68 SLEEP 20 STA RESP1 ;put player 1 at clock 130 vblankloop sta WSYNC dex bne vblankloop LDX #0 STX VBLANK ;EndVerticalBlank ;======================================== ;======================================== ;DrawScreen ;192 scanlines ;now you have 192 scanlines of picture ;remember, that's 228 clocks or 76 cpu cycles LDA #$00 ;2 (load immediate) STA COLUBK ;3 [5] (store zero page); Set Background to Black STA COLUPF ;3 [8] STA GRP0 ;3 [11] STA GRP1 ;3 [14] LDA #1 ;2 [16] sta CTRLPF ;3 [19] lda #$1C ;2 [21] sta COLUP0 ;3 [24] lda #$66 ;2 [26] sta COLUP1 ;3 [29] lda #%00000101 ;2 [31] sta NUSIZ0 ;3 [34] LDY #0 ;2 [36] STY HeightP0 ;3 [39] STY HeightP1 ;3 [42] LDX #191 ;2 [44] STA WSYNC LoopScanLines LDA #0 ;2 STA GRP0 ;3 [5] STA GRP1 ;3 [8] ;test player 0 CPX YPosP0 ;3 [11] BNE EndP0 ;2+ [13][14];if not at Y position, then jump to end ;else LDY #8 ;2 [15] ;load Y with Player 0 height STY HeightP0 ;3 [18] EndP0 ;do we draw player 0? LDY HeightP0 ;2 [20 if bne wasnot taken] ; [16 if bne was taken] BEQ EndDrawP0 ;2+ [22][18] ;if heightP0 is zero we are done drawing LDA Player_0-1,Y;4+ [26][22] ;else draw Player 0 STA GRP0 ;3 [29][25] DEC HeightP0 ;5 [34][30] EndDrawP0 ;test player 1 CPX YPosP1 ;3 [37][33] BNE EndP1 ;2+ [39][35] LDY #8 ;2 [41][37] STY HeightP1 ;3 [44][40] EndP1 ;do we draw player 1? LDY HeightP1 ;2 [46][42] BEQ EndDrawP1 ;2+ [48][44] LDA Player_0-1,Y;4+ [52] STA GRP1 ;3 [55] DEC HeightP1 ;5 [60] EndDrawP1 FinishP0 sta WSYNC ;3 [63][51] DEX ;2 ;jump here if we are not painting BNE LoopScanLines;2+ LDA #2;#%01000010 ; Disable TIA Output STA VBLANK ;EndDrawScreen ;================================ ;================================ OverScan ;now you have 30 scanlines of overscan ;(2280 machine cycles, 6840 color clocks LDX #30 O1 STA WSYNC DEX BNE O1 ;EndOverScan ;================================== ;/////////////////////////////////////// ;go back to the beginning: ;inifinate loop JMP StartOfFrame ;////////////////////////////////////// ;***************************** ;Graphics ;***************************** Player_0 .byte #%00001000 .byte #%00010100 .byte #%00100010 .byte #%01000001 .byte #%10000010 .byte #%01000100 .byte #%00101000 .byte #%00010000 ;this is the end. change origin to the end of the 4k rom org $FFFA TheEnd .word Reset ;NMI;used in 7800? .word Reset ;RESET .word Reset ;IRQ;used in 7800? ;end of file END
Jim













