I might need to post all of my code, as something odd is happening, or it's just a complete misunderstanding on my part.
I have a routine to display metasprites which appears to work fine. Now I am trying to animate them by keeping track of an "anim delay" and the current frame of animation. I increment the delay until it matches the current animation's "delay" value, then increment the frame. I am using the "all in NMI" method for now if this is important.
This is an excerpt from my update_sprites routine, that I run at the end of the NMI routine.
Code: Select all
lda spr_delay,x
cmp #$08
beq delay_done
inc spr_delay,x
jmp update_next_sprite
delay_done:
lda #$00
sta spr_delay,x
; update frame
lda spr_frame,x
cmp #$02
beq reset_frame
inc spr_frame,x
jmp update_next_sprite
reset_frame:
lda #$00
sta spr_frame,x
update_next_sprite:
inx
cpx #MAX_SPRITES
bne -
rts
Code: Select all
lda #$08
sta anim_delay
lda #'$02
sta anim_frames
lda spr_delay,x
cmp anim_delay
beq delay_done
inc spr_delay,x
jmp update_next_sprite
delay_done:
lda #$00
sta spr_delay,x
; update frame
lda spr_frame,x
cmp anim_frames
beq reset_frame
inc spr_frame,x
jmp update_next_sprite
reset_frame:
lda #$00
sta spr_frame,x
update_next_sprite:
inx
cpx #MAX_SPRITES
bne -
rts