Prev: 46317 Up: Map Next: 46392
46333: 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 46333 PUSH BC Stash the registers on the stack.
46334 PUSH DE
46335 PUSH HL
46336 PUSH IY
46338 LD IY,23560 Point IY at ObjectsTable.
46342 LD B,40 Set B to the number of objects in the table.
46344 LD C,0 Set the speed in X to test with to zero.
46346 LD L,C Set the speed in Y to zero.
46347 LD H,C Set the speed in Z to zero.
46348 SET 1,(IX+7) 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 46352 CALL TestObjectSolid Test whether the object of the table is solid.
46355 JR Z,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if it is not.
46357 CALL TestOverlapInX Test whether the objects overlap in X.
46360 JR NC,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if they do not.
46362 CALL TestOverlapInY Test whether the objects overlap in Y.
46365 JR NC,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if they do not.
46367 CALL TestOverlapInZ Test whether the objects overlap in Z.
46370 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 46372 POP IY Restore the registers from the stack.
46374 POP HL
46375 POP DE
46376 POP BC
46377 RES 1,(IX+7) Stop the object being ignored in the 3D calculations.
46381 RET Return.
Move on to the next object.
TestObjectIntersections_NextObject 46382 LD DE,32 Set DE to the size of an object.
46385 ADD IY,DE Move on to the next object in the table.
46387 DJNZ TestObjectIntersections_TestObject Decrease the object counter and loop back to TestObjectIntersections_TestObject until all of the objects have been tested.
46389 AND A Clear the carry flag, as nothing intersects.
46390 JR TestObjectIntersections_Done Jump to TestObjectIntersections_Done.
View the equivalent code in;
Prev: 46317 Up: Map Next: 46392