← CFB1 Bee behavior handler Map D05B → Orb (ball-capturer) behavior handler
D00C: Capsule behavior handler
Per-frame handler for the capsule, worth 50 points to a ball kill. The capsule wanders freely until its step lands on a brick.
Input
IX the capsule's sprite record
IY the capsule's logic record, read for its heading, animation frame and state
C the capsule's pool-slot index
The handler runs the reaction state machine first, then animates and tests for a brick strike. A hit kills it. Otherwise it wanders freely, avoids walls, moves, and runs the offscreen, ball-kill and sweep tests.
update_capsule D00C CALL inhabitant_react_state Reaction-state machine first; carry means skip this frame.
D00F RET C
D010 LD HL,anim_capsule Cycle the capsule animation, and wrap at its last frame.
D013 CALL advance_anim
D016 LD A,(IY+$0B)
D019 CP $08
D01B JR C,capsule_brick
D01D LD (IY+$0B),$00
Test for a brick strike with the shared step collision test, which sets two flags: the blocked flag and the wall qualifier. When the wall qualifier is 0 and the blocked flag is non-zero the capsule hit a brick, so it dies. Otherwise it moves normally.
capsule_brick D021 CALL test_step_collision Test for a brick collision.
D024 LD A,(step_hit_wall) Brick struck – the wall qualifier clear and the blocked flag set?
D027 OR A
D028 JR NZ,capsule_move
D02A LD A,(step_blocked)
D02D OR A
D02E JR Z,capsule_move
D030 LD (IY+$0B),$00 Yes: restart the animation and die.
D034 LD (IY+$0C),$02
D038 RET
capsule_move D039 XOR A Free wander: every heading is allowed.
D03A CALL pick_wander_heading Count down the wander timer, and turn when it runs out.
D03D CALL object_avoid_walls Steer away from walls.
D040 CALL move_object Advance one step.
D043 CALL inhabitant_offscreen Despawn off the far edge; carry means gone.
D046 RET C
D047 LD B,$05 Award 50 points if a ball hits it. Carry means killed.
D049 CALL ball_kill
D04C RET C
D04D CALL overlap_sweep The sweep: non-zero means a hit.
D050 OR A
D051 RET Z
D052 LD (IY+$0B),$00 On a hit, restart the animation and die.
D056 LD (IY+$0C),$02
D05A RET
← CFB1 Bee behavior handler Map D05B → Orb (ball-capturer) behavior handler
Fork me on GitHub