← CD16 Sweep this inhabitant against the pool objects that are not balls Map CDB1 → Face-monster behavior handler
CD6B: Wide overlap test between two named objects
The wide overlap test between the two pool objects named by the first overlap operand and the second overlap operand. It returns 1 in A when both objects are active and their sprites are within 14 pixels on both axes, and 0 otherwise.
Output
A 1 if the two objects overlap, 0 otherwise
The ball kill uses it as the inhabitant-versus-ball test: the first operand names the inhabitant slot and the second a ball slot. Either object inactive is an immediate miss. The window reaches 14 pixels one way and 13 the other on each axis, with the same one-short fold as the plain overlap.
overlap_wide CD6B PUSH BC Resolve the first overlap operand to its sprite record. Miss if it is inactive.
CD6C PUSH IX
CD6E LD A,(overlap_slot_1)
CD71 CALL object_slot_ptr
CD74 BIT 0,(IX+$08)
CD78 JR Z,overlap_wide_miss
CD7A LD D,(IX+$00) Save that object's X and Y, resolve the second overlap operand's sprite record, and miss if it is inactive.
CD7D LD E,(IX+$01)
CD80 PUSH DE
CD81 LD A,(overlap_slot_2)
CD84 CALL object_slot_ptr
CD87 POP DE
CD88 BIT 0,(IX+$08)
CD8C JR Z,overlap_wide_miss
CD8E LD A,D Form the X gap between the two objects. A negative gap folds to one less than its magnitude.
CD8F SUB (IX+$00)
CD92 JP P,overlap_wide_dx
CD95 CPL
overlap_wide_dx CD96 CP $0E X gap inside the window: form the Y gap the same way.
CD98 JR NC,overlap_wide_miss
CD9A LD A,E
CD9B SUB (IX+$01)
CD9E JP P,overlap_wide_dy
CDA1 CPL
overlap_wide_dy CDA2 CP $0E Y gap inside it too: report overlap with 1 in A and restore IX, BC.
CDA4 JR NC,overlap_wide_miss
CDA6 LD A,$01
CDA8 POP IX
CDAA POP BC
CDAB RET
overlap_wide_miss CDAC XOR A No overlap: return 0 in A, and restore IX and BC.
CDAD POP IX
CDAF POP BC
CDB0 RET
← CD16 Sweep this inhabitant against the pool objects that are not balls Map CDB1 → Face-monster behavior handler
Fork me on GitHub