Last active
December 2, 2021 14:43
-
-
Save jeff-1amstudios/7355d73284aab8e4e34aa7119e09c6a5 to your computer and use it in GitHub Desktop.
C64 sprite animation routine
This file contains 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
FRAME_COUNT = 10 ; constant for the nbr of sprite frames you have | |
.frame_counter !byte .FRAME_COUNT ; variable to keep track of how far through the animation we are | |
SPRITE_INITIAL_DATA_POINTER = 128 ; sprite data will be read by VIC-II at 128*64 ($2000) | |
on_screen_refresh | |
dec .frame_counter ; frame_counter variable -= 1 | |
bne .increment_sprite_pointer ; if frame_counter > 0, goto .increment_sprite_pointer... | |
lda #SPRITE_INITIAL_DATA_POINTER ; ... otherwise, we should reset to the start of the animation | |
sta $07f8 ; reset the sprite pointer to start of sprite data | |
ldx #FRAME_COUNT | |
stx .frame_counter ; reset frame_counter to the nbr of sprite frames again | |
rts ; return | |
.increment_sprite_pointer | |
inc $07f8 ; sprite pointer += 1 (moves to the next frame) | |
rts ; return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment