Prev: 46850 Up: Map Next: 46925
46866: 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 46866 PUSH BC Stash the registers on the stack.
46867 PUSH DE
46868 PUSH HL
46869 PUSH IY
46871 LD IY,23432 Point IY at PlayerBottomObject.
46875 LD B,56 Set a counter of 56 objects.
46877 LD C,0 Set the x speed to 0.
46879 LD L,C Set the y and z speeds to 0.
46880 LD H,C
46881 SET 1,(IX+7) Set bit 1 of the object flags.
Test whether this object overlaps on all three axes.
TestObjectIntersections_TestObject 46885 CALL TestObjectSolid Call TestObjectSolid.
46888 JR Z,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if the object is not used or is ignored.
46890 CALL TestOverlapInX Call TestOverlapInX.
46893 JR NC,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if they do not overlap along x.
46895 CALL TestOverlapInY Call TestOverlapInY.
46898 JR NC,TestObjectIntersections_NextObject Jump to TestObjectIntersections_NextObject if they do not overlap along y.
46900 CALL TestOverlapInZ Call TestOverlapInZ.
46903 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 46905 POP IY Restore IY, HL, DE and BC from the stack.
46907 POP HL
46908 POP DE
46909 POP BC
46910 RES 1,(IX+7) Reset bit 1 of the object flags.
46914 RET Return.
Move on to the next object.
TestObjectIntersections_NextObject 46915 LD DE,32 Set the size of an object record to 32.
46918 ADD IY,DE Move on to the next object.
46920 DJNZ TestObjectIntersections_TestObject Jump to TestObjectIntersections_TestObject until all of the objects have been tested.
46922 AND A Clear the carry flag.
46923 JR TestObjectIntersections_Done Jump to TestObjectIntersections_Done.
View the equivalent code in;
Prev: 46850 Up: Map Next: 46925