Prev: B702 Up: Map Next: B74D
B712: Test Object Intersections
Used by the routine at HandlePickupAndDrop.
Tests whether an object overlaps any other solid object in the table that starts at PlayerBottomObject, without moving. The object itself is ignored while the table is searched.
Input
IX The address of the object
Output
F Carry flag set if the object intersects another object
Start at the first object with no movement.
TestObjectIntersections B712 PUSH BC Stash the registers on the stack.
B713 PUSH DE
B714 PUSH HL
B715 PUSH IY
B717 LD IY,$5B88 Point IY at PlayerBottomObject.
B71B LD B,$38 Set a counter of 38 objects.
B71D LD C,$00 Set the x speed to 00.
B71F LD L,C Set the y and z speeds to 00.
B720 LD H,C
B721 SET 1,(IX+$07) Set bit 1 of the object flags.
Test whether this object overlaps on all three axes.
TestObjectIntersections_TestObject B725 CALL TestObjectSolid Call TestObjectSolid.
B728 JR Z,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if the object is not used or is ignored.
B72A CALL TestOverlapInX Call TestOverlapInX.
B72D JR NC,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if they do not overlap along x.
B72F CALL TestOverlapInY Call TestOverlapInY.
B732 JR NC,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if they do not overlap along y.
B734 CALL TestOverlapInZ Call TestOverlapInZ.
B737 JR NC,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if they do not overlap along z.
The objects overlap on all three axes (and the carry flag is set), or there are none left to try (and it is not).
TestObjectIntersections_Done B739 POP IY Restore IY, HL, DE and BC from the stack.
B73B POP HL
B73C POP DE
B73D POP BC
B73E RES 1,(IX+$07) Reset bit 1 of the object flags.
B742 RET Return.
Move on to the next object.
TestObjectIntersections_NextObject B743 LD DE,$0020 Set the size of an object record to 20.
B746 ADD IY,DE Move on to the next object.
B748 DJNZ TestObjectIntersections_TestObject Jump to TestObjectIntersections_TestObject until all of the objects have been tested.
B74A AND A Clear the carry flag.
B74B JR TestObjectIntersections_Done Jump to TestObjectIntersections_Done.
View the equivalent code in;
Prev: B702 Up: Map Next: B74D