← CBCC Step-collision probe offsets Map CBFE → Spawn and death reaction state machine
CBDC: Advance an object's animation
Advances the object's animation by one frame on every other call. It does not wrap the animation frame, so the caller resets it at the animation's length.
Input
HL base of this animation's frame table (a word per frame, each a sprite-data pointer)
IX the object's 9-byte sprite record (one slot of object_table)
IY the object's 16-byte logic record (layout at obj2_record)
advance_anim CBDC INC (IY+$0E) Act only on every other call: tick the animation timer and return until it comes round.
CBDF LD A,(IY+$0E)
CBE2 CP $02
CBE4 RET NZ
CBE5 XOR A Reset the animation timer to 0 for the next pair of calls.
CBE6 LD (IY+$0E),A
CBE9 LD A,(IY+$0B) Index the frame table by the animation frame, two bytes per entry.
CBEC ADD A,A
CBED LD E,A
CBEE LD D,$00
CBF0 ADD HL,DE
CBF1 LD E,(HL) Read that frame's sprite-data pointer.
CBF2 INC HL
CBF3 LD D,(HL)
CBF4 LD (IX+$06),E Store it into the sprite record's pointer so the next draw shows this frame.
CBF7 LD (IX+$07),D
CBFA INC (IY+$0B) Step to the next frame.
CBFD RET
← CBCC Step-collision probe offsets Map CBFE → Spawn and death reaction state machine
Fork me on GitHub