Created
June 30, 2021 14:50
-
-
Save RoelN/f551e358b46b420baebdf6282e2db760 to your computer and use it in GitHub Desktop.
65 bytes version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on the work of @alannakelly_ie, @MonstersGo and myself | |
// Kernal CLS Routine | |
.label INIT_SCREEN = $e544 | |
// Variables | |
.label player_x = $d000 | |
.label player_y = $d001 | |
.label player_c = $d027 | |
.file [name="spritemove.prg", segments="CODE"] | |
.segment CODE [start=$0326,max=$1000] | |
* = $326 "Code" | |
// hijack the kernal routines | |
// this is the pointer to CHROUT routine that's called by the kernal after loading to print "READY" | |
.word setup | |
// don't change this value | |
.word $f6ed | |
setup: | |
// Setup screen and sprites | |
// X = ff here | |
// Make a Square Player Sprite | |
txa // A = 255 | |
!: | |
sta $2100,x //132*64,x | |
inx | |
bpl !- | |
// X = 80 here, which is good enough to turn the screen black | |
// Set Background to Black | |
stx $d020 | |
stx $d021 | |
// Clear Screen | |
jsr INIT_SCREEN | |
// X = 1 after INIT_SCREEN | |
// Y = 132 after INIT_SCREEN | |
// Setup Player | |
sty $07f8 // Set sprite pointer | |
sty player_x // Set player x | |
sty player_y // Set player y | |
stx player_c // set color to white | |
stx $d015 // enable sprite 1 | |
// Program loop | |
main: | |
ldx #$02 | |
// stx $0500 | |
// Loop joystick read code | |
// Read Joystick Port 2 | |
lda $dc00 | |
// Joystick read loop. First iteration | |
// checks up and down. Second iteration | |
// checks left and right. | |
joy_read_loop: | |
lsr // U or L to -> Carry | |
// If C==0 up is pushed | |
bcs down_or_right | |
dec player_x - 1,x // pl_y or player_x -- | |
// Read Down or Right | |
down_or_right: | |
lsr | |
bcs next | |
inc player_x - 1,x // pl_y or player_x ++ | |
next: | |
dex // X-- | |
// Exit loop if X == 0 | |
bne joy_read_loop | |
// Wait for next frame | |
dex | |
// x = 0 when we get here | |
vsync: | |
cpx $d012 | |
bne vsync | |
beq main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment