| ← A680 | Map | A75D → |
A717: Overlap test between two named objects
|
Reports whether the two objects named by the overlap operands touch. An inactive object never overlaps.
|
|||||||
|
|||||||
| overlap_pair | A717 | PUSH BC | |||||
| A718 | PUSH IX | ||||||
| A71A | LD A,(overlap_slot_1) | Look up the first overlap operand's sprite record into IX. | |||||
| A71D | CALL object_slot_ptr | ||||||
| A720 | BIT 0,(IX+$08) | First overlap operand inactive? Then there is no overlap. | |||||
| A724 | JR Z,overlap_pair_no | ||||||
| A726 | LD D,(IX+$00) | Save the first overlap operand's position (X in D, Y in E) across the second lookup. | |||||
| A729 | LD E,(IX+$01) | ||||||
| A72C | PUSH DE | ||||||
| A72D | LD A,(overlap_slot_2) | Look up the second overlap operand's sprite record into IX, and restore the first's X,Y into DE. | |||||
| A730 | CALL object_slot_ptr | ||||||
| A733 | POP DE | ||||||
| A734 | BIT 0,(IX+$08) | Second overlap operand inactive? Then there is no overlap. | |||||
| A738 | JR Z,overlap_pair_no | ||||||
|
The accepted band reaches 12 pixels one way and 11 the other, on both axes.
|
|||||||
| A73A | LD A,D | Subtract the second overlap operand's X from the first's. | |||||
| A73B | SUB (IX+$00) | ||||||
| A73E | JP P,overlap_pair_dx | Fold a negative distance to its magnitude. The CPL leaves it one short. | |||||
| A741 | CPL | ||||||
| overlap_pair_dx | A742 | CP $0C | Too far apart on X? Then there is no overlap. The band is off-center, so a swap of the two slots moves the accepted box by a pixel. | ||||
| A744 | JR NC,overlap_pair_no | ||||||
| A746 | LD A,E | Subtract the second overlap operand's Y from the first's. | |||||
| A747 | SUB (IX+$01) | ||||||
| A74A | JP P,overlap_pair_dy | Fold a negative Y distance the same way. | |||||
| A74D | CPL | ||||||
| overlap_pair_dy | A74E | CP $0C | Too far apart on Y? Then there is no overlap. | ||||
| A750 | JR NC,overlap_pair_no | ||||||
| A752 | LD A,$01 | Within 12 px on both axes: report an overlap. | |||||
| A754 | POP IX | ||||||
| A756 | POP BC | ||||||
| A757 | RET | ||||||
| overlap_pair_no | A758 | XOR A | No overlap, or an object inactive | ||||
| A759 | POP IX | ||||||
| A75B | POP BC | ||||||
| A75C | RET | ||||||
| ← A680 | Map | A75D → |
