← CC56 Update the objects' behaviors Map CD16 → Sweep this inhabitant against the pool objects that are not balls
CCD2: Ball kill, the shared overlap helpers, then the per-type handlers
Tests one inhabitant against the live balls and kills it on a wide overlap. This entry also opens the inhabitant-behavior block. The shared helpers come first: this one, the sweep and the wide overlap. The per-type handlers follow, from the face monster's handler on.
Most handlers run the reaction-state machine and advance the animation. They then move or steer, despawn off the far edge, and call these helpers. They differ only in movement and in what an overlap does.
Input
C the inhabitant's own pool-slot index (object_table)
IY the inhabitant's logic record (obj2_record), whose animation frame and state a kill sets
B the per-type death payload, banked into pending_score on a kill
Output
F carry set on a kill, clear on a miss
The test is the wide overlap between the inhabitant's sprite and a ball's. Ball A is always tested. Ball B shares the secondary object's place and is tested only while that holds a ball. The slot holds a ball when its sprite pointer is the ball sprite. Either overlap is a kill.
ball_kill CCD2 LD A,C Name the inhabitant (C) as the first overlap operand and ball A as the second, then run the wide overlap test.
CCD3 LD (overlap_slot_1),A
CCD6 LD A,$01
CCD8 LD (overlap_slot_2),A
CCDB CALL overlap_wide
CCDE OR A Wide overlap with ball A: take the kill path.
CCDF JR NZ,ball_kill_hit
CCE1 PUSH IX Test the secondary object only while its sprite pointer shows it holds a ball. Otherwise take the miss path.
CCE3 LD IX,obj2_object
CCE7 LD L,(IX+$06)
CCEA LD H,(IX+$07)
CCED POP IX
CCEF LD DE,slot_ball
CCF2 XOR A
CCF3 SBC HL,DE
CCF5 JR NZ,ball_kill_miss
CCF7 LD A,C Name the secondary object as the second overlap operand and test it the same way. An overlap also kills.
CCF8 LD (overlap_slot_1),A
CCFB LD A,$02
CCFD LD (overlap_slot_2),A
CD00 CALL overlap_wide
CD03 OR A
CD04 JR NZ,ball_kill_hit
ball_kill_miss CD06 AND A No overlap: clear carry and return.
CD07 RET
ball_kill_hit CD08 LD (IY+$0B),$00 Kill: zero the animation frame, start the death reaction, bank B into the pending score, set carry and return.
CD0C LD (IY+$0C),$02
CD10 LD A,B
CD11 LD (pending_score),A
CD14 SCF
CD15 RET
← CC56 Update the objects' behaviors Map CD16 → Sweep this inhabitant against the pool objects that are not balls
Fork me on GitHub