Prev: B4ED Up: Map Next: B538
B4FD: Test Object Intersections
Used by the routine at HandlePickupAndDrop.
Tests whether the object that IX points at overlaps any other solid object in the objects table, without it moving. The object itself is flagged to be ignored while the table is searched. All registers are preserved.
Input
IX Address of the object
Output
F Carry flag set if the object intersects another object
TestObjectIntersections B4FD PUSH BC Stash the registers on the stack.
B4FE PUSH DE
B4FF PUSH HL
B500 PUSH IY
B502 LD IY,$5C08 Point IY at ObjectsTable.
B506 LD B,$28 Set B to the number of objects in the table.
B508 LD C,$00 Set the speed in X to test with to zero.
B50A LD L,C Set the speed in Y to zero.
B50B LD H,C Set the speed in Z to zero.
B50C SET 1,(IX+$07) Flag the object as ignored in the 3D calculations, so that it does not intersect itself.
Test whether this object overlaps on all three axes.
TestObjectIntersections_TestObject B510 CALL TestObjectSolid Test whether the object of the table is solid.
B513 JR Z,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if it is not.
B515 CALL TestOverlapInX Test whether the objects overlap in X.
B518 JR NC,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if they do not.
B51A CALL TestOverlapInY Test whether the objects overlap in Y.
B51D JR NC,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if they do not.
B51F CALL TestOverlapInZ Test whether the objects overlap in Z.
B522 JR NC,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if they do not.
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 B524 POP IY Restore the registers from the stack.
B526 POP HL
B527 POP DE
B528 POP BC
B529 RES 1,(IX+$07) Stop the object being ignored in the 3D calculations.
B52D RET Return.
Move on to the next object.
TestObjectIntersections_NextObject B52E LD DE,$0020 Set DE to the size of an object.
B531 ADD IY,DE Move on to the next object in the table.
B533 DJNZ TestObjectIntersections_TestObject Decrease the object counter and loop back to TestObjectIntersections_TestObject until all of the objects have been tested.
B535 AND A Clear the carry flag, as nothing intersects.
B536 JR TestObjectIntersections_Done Jump to TestObjectIntersections_Done.
View the equivalent code in;
Prev: B4ED Up: Map Next: B538