Code: Select all
player_walking_1:
.byte $00,$32,%00000000,$00
.byte $00,$33,%00000000,$08
.byte $08,$34,%00000000,$00
.byte $08,$35,%00000000,$08
player_walking_2:
.byte $00,$36,%00000000,$00
.byte $00,$37,%00000000,$08
.byte $08,$38,%00000000,$00
.byte $08,$39,%00000000,$08
etc...
player_walk_animation:
.byte $04 ; number of frames
.word player_walking_1, player_walking_2, player_walking_3, player_walking_4
Code: Select all
.macro play_animation animation, counter, sprite_ptr
; load sprite frame counter
ldx counter
; increase x to put offset at the begginning of frame data
inx
; set current sprite to current animation frame
lda animation, x
sta sprite_ptr + 0
inx
lda animation, x
sta sprite_ptr + 1
; get number of frames and store it in temp1
lda animation
sta temp1
; check if frame counter is equal to number of frames
ldx counter
cpx temp1
beq reset_counter
; advance frame counter if counter < number of frames
inx
inx
stx counter
jmp callback_done
reset_counter:
lda #$00
sta counter
callback_done:
.endmacro