;move a happy face with the joystick by Kirk Israel ; (with a can't'dodge'em line sweeping across the screen) processor 6502 include vcs.h org $F000 YPosFromBot = $80; VisiblePlayerLine = $81; booleanFujiFrame = $82 ;generic start up stuff... Start SEI CLD LDX #$FF TXS LDA #0 ClearMem STA 0,X DEX BNE ClearMem LDA #$00 ;start with a black background STA COLUBK LDA #66 ;lets go for bright yellow, the traditional color for happyfaces STA COLUP0 ;Setting some variables... LDA #80 STA YPosFromBot ;Initial Y Position ;; Let's set up the sweeping line. as Missile 1 ;VSYNC time MainLoop LDA #2 STA VSYNC STA WSYNC STA WSYNC STA WSYNC LDA #43 STA TIM64T LDA #0 STA VSYNC LDA booleanFujiFrame BEQ FujiWasZeroInBlank FujiWasNotZeroInBlank LDA #0 STA booleanFujiFrame JMP DoneSettingFuji FujiWasZeroInBlank LDA #1 STA booleanFujiFrame DoneSettingFuji ;Main Computations; check down, up, left, right ;general idea is to do a BIT compare to see if ;a certain direction is pressed, and skip the value ;change if so ; ;Not the most effecient code, but gets the job done, ;including diagonal movement ; ; for up and down, we INC or DEC ; the Y Position LDA #%00010000 ;Down? BIT SWCHA BNE SkipMoveDown INC YPosFromBot SkipMoveDown LDA #%00100000 ;Up? BIT SWCHA BNE SkipMoveUp DEC YPosFromBot SkipMoveUp ; for left and right, we're gonna ; set the horizontal speed, and then do ; a single HMOVE. We'll use X to hold the ; horizontal speed, then store it in the ; appropriate register ;assum horiz speed will be zero LDX #0 LDA #%01000000 ;Left? BIT SWCHA BNE SkipMoveLeft LDX #$10 ;a 1 in the left nibble means go left SkipMoveLeft LDA #%10000000 ;Right? BIT SWCHA BNE SkipMoveRight LDX #$F0 ;a -1 in the left nibble means go right... SkipMoveRight STX HMP0 ;set the move for player 0, not the missile like last time... WaitForVblankEnd LDA INTIM BNE WaitForVblankEnd LDY #96 STA WSYNC STA HMOVE STA VBLANK ;main scanline loop... ScanLoop STA WSYNC STA WSYNC ; here the idea is that VisiblePlayerLine ; is zero if the line isn't being drawn now, ; otherwise it's however many lines we have to go CheckActivatePlayer CPY YPosFromBot BNE SkipActivatePlayer LDA #48 STA VisiblePlayerLine SkipActivatePlayer ;set player graphic to all zeros for this line, and then see if ;we need to load it with graphic data LDA #0 STA GRP0 ; ;if the VisiblePlayerLine is non zero, ;we're drawing it now! ; LDX VisiblePlayerLine ;check the visible player line... BEQ FinishPlayer ;skip the drawing if its zero... IsPlayerOn LDA booleanFujiFrame BEQ FujiWasZeroFrame FujiWasNotZeroFrame LDA Fuji0-1,X JMP TitleDoneChooseDrawPlayer1 FujiWasZeroFrame LDA Fuji1-1,X TitleDoneChooseDrawPlayer1 STA GRP0 ;put that line as player graphic DEC VisiblePlayerLine ;and decrement the line count FinishPlayer DEY BNE ScanLoop LDA #2 STA WSYNC STA VBLANK LDX #30 OverScanWait STA WSYNC DEX BNE OverScanWait JMP MainLoop ; here's the actual graphic! If you squint you can see its ; upsidedown smiling self Fuji0 .byte #%00000000 .byte #%10011001 .byte #%11011011 .byte #%01111110 .byte #%00111100 .byte #%00111100 .byte #%00111100 .byte #%00000000 .byte #%00000000 .byte #%11011011 .byte #%01111110 .byte #%00111100 .byte #%00111100 .byte #%00111100 .byte #%00111100 .byte #%00000000 .byte #%00000000 .byte #%11000011 .byte #%01100110 .byte #%00111100 .byte #%00111100 .byte #%00111100 .byte #%00111100 .byte #%00000000 .byte #%00000000 .byte #%10010010 .byte #%01010100 .byte #%00111000 .byte #%00111000 .byte #%00111000 .byte #%00111000 .byte #%00000000 .byte #%00000000 .byte #%10010010 .byte #%01010100 .byte #%00101000 .byte #%00101000 .byte #%00101000 .byte #%00111000 .byte #%00000000 .byte #%00000000 .byte #%10010010 .byte #%01010100 .byte #%00101000 .byte #%00101000 .byte #%00101000 .byte #%00101000 .byte #%00000000 Fuji1 .byte #%00000000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00000000 .byte #%00000000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00000000 .byte #%00000000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00011000 .byte #%00000000 .byte #%00000000 .byte #%10010010 .byte #%01010100 .byte #%00111000 .byte #%00111000 .byte #%00111000 .byte #%00111000 .byte #%00000000 .byte #%00000000 .byte #%10010010 .byte #%01010100 .byte #%00101000 .byte #%00101000 .byte #%00101000 .byte #%00111000 .byte #%00000000 .byte #%00000000 .byte #%10010010 .byte #%01010100 .byte #%00101000 .byte #%00101000 .byte #%00101000 .byte #%00101000 .byte #%00000000 org $FFFC .word Start .word Start