← C91C Steer an object toward a target object Map C9A2 → Test the level tiles in the path of an object in motion for a collision
C977: Remove an inhabitant that has left the far playfield edge
Deactivates the inhabitant if it has moved off the playfield edge on the bat's side. The inhabitant crosses toward the bat and exits past it. Carry comes back set so the handler stops. It comes back clear when the inhabitant lives on.
Input
IX the object's sprite record (object_table), whose X is tested
IY the object's logic record (obj2_record); its type is cleared on despawn
C the object's pool-slot index
Output
F carry set when the object is despawned, clear when it is kept
inhabitant_offscreen C977 LD A,(bat_side) The far edge is the one on the bat's side. Read the bat side: 0 for the right, non-zero for the left.
C97A OR A
C97B JR NZ,offscreen_left_bat
C97D LD A,(IX+$00) Bat on the right: the far edge is the right one – off-field once its sprite X reaches it.
C980 CP $EA
C982 JR C,offscreen_keep
C984 JR despawn_inhabitant
offscreen_left_bat C986 LD A,(IX+$00) Bat on the left: the far edge is the left one – off-field once sprite X drops under it.
C989 CP $06
C98B JR NC,offscreen_keep
despawn_inhabitant C98D LD A,C Off the far edge: for the ball gem's pool slot also clear the ball gem frame, then empty the slot.
C98E CP $02
C990 JR NZ,despawn_clear_slot
C992 XOR A
C993 LD (ball_gem_frame),A
despawn_clear_slot C996 XOR A Empty the slot – clear its type and its active flag – and return carry set.
C997 LD (IY+$08),A
C99A RES 0,(IX+$08)
C99E SCF
C99F RET
offscreen_keep C9A0 XOR A Still on the field: return carry clear and keep the object.
C9A1 RET
← C91C Steer an object toward a target object Map C9A2 → Test the level tiles in the path of an object in motion for a collision
Fork me on GitHub