Created
June 30, 2021 09:11
-
-
Save RoelN/f306af0b1d058b377673d4ba80dcc9fd to your computer and use it in GitHub Desktop.
Player 79 - Commodore 64 Moveable Sprite in 79 bytes
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
// Player 79 | |
// | |
// Commodore 64 Moveable Sprite in 84b | |
// | |
// Joystick in Port 2 to move sprite. | |
// Purely for fun to see how few bytes it | |
// can be done in. Public Domain, do what | |
// you want with the code but credit is | |
// always appreciated. | |
// | |
// Original 84 bytes by: https://github.com/alannakelly | |
// Date: 2021-06-30 | |
// | |
// 79 bytes version by Roel in KickAssembler syntax | |
// Kernal CLS Routine | |
.var INIT_SCREEN = $e544 | |
// Variables | |
.var player_x = $d000 | |
.var player_y = $d001 | |
.var player_c = $d027 | |
*=$0801 | |
.byte $0b, $08, $0a, $00, $9e // 10 SYS | |
.byte $32, $30, $36, $31 // 2061 | |
.byte $00, $00, $00 // End | |
start: | |
// Setup screen and sprites | |
// X = 0 | |
// Set Background to Black | |
stx $d020 | |
stx $d021 | |
dex // X = 255 | |
// Make a Square Player Sprite | |
txa // A = 255 | |
!: | |
sta $2100,x //132*64,x | |
inx | |
bpl !- | |
// 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: | |
// Read Joystick Port 2 | |
lda $dc00 | |
// Read Up | |
lsr // Up -> Carry | |
bcs down // If C==0 up is pushed | |
dec player_y // player_y-- | |
down: // Read Down | |
lsr | |
bcs left | |
inc player_y // player_y++ | |
left: // Read Left | |
lsr | |
bcs right | |
dec player_x // player_x-- | |
right: // Read Right | |
lsr | |
bcs vsync | |
inc player_x // player_x++ | |
// Wait for next frame | |
vsync: | |
ldx $d012 | |
inx | |
bne vsync | |
beq main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment