Prev: 48909 Up: Map Next: 48982
48923: Test Object Intersections
Used by the routines at LoadRoomObjects, HandlePickupAndDrop and CreateCreature.
Tests whether an object overlaps any other solid object in the table that starts at ObjectsTable, 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 48923 PUSH BC Stash the registers on the stack.
48924 PUSH DE
48925 PUSH HL
48926 PUSH IY
48928 LD IY,42863 Start with the first object record, ObjectsTable.
48932 LD B,54 Set a counter in B of the number of object records, 54.
48934 LD C,0 Set the x speed to 0.
48936 LD L,C Set the y and z speeds to 0.
48937 LD H,C
48938 SET 1,(IX+7) Flag the object as being moved, so that it is not tested against itself.
Test whether this object overlaps on all three axes.
TestObjectIntersections_Loop 48942 CALL TestObjectSolid Call TestObjectSolid.
48945 JR Z,TestObjectIntersections_Next Jump to TestObjectIntersections_Next if the object is not used or is ignored.
Jump to TestObjectIntersections_Next to try the next object if they do not overlap along x.
48947 CALL TestOverlapInX Call TestOverlapInX.
48950 JR NC,TestObjectIntersections_Next Jump to TestObjectIntersections_Next if they do not overlap along x.
Jump to TestObjectIntersections_Next to try the next object if they do not overlap along y.
48952 CALL TestOverlapInY Call TestOverlapInY.
48955 JR NC,TestObjectIntersections_Next Jump to TestObjectIntersections_Next if they do not overlap along y.
Jump to TestObjectIntersections_Next to try the next object if they do not overlap along z.
48957 CALL TestOverlapInZ Call TestOverlapInZ.
48960 JR NC,TestObjectIntersections_Next Jump to TestObjectIntersections_Next 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 48962 POP IY Restore IY, HL, DE and BC from the stack.
48964 POP HL
48965 POP DE
48966 POP BC
48967 RES 1,(IX+7) Clear the flag that says that the object is being moved.
48971 RET Return.
Move on to the next object.
TestObjectIntersections_Next 48972 LD DE,32 Set the size of an object record to 32.
48975 ADD IY,DE Move on to the next object.
48977 DJNZ TestObjectIntersections_Loop Decrease the counter and loop until all the records have been tried.
48979 AND A Clear the carry flag, as nothing overlaps the object.
48980 JR TestObjectIntersections_Done Jump to TestObjectIntersections_Done.
View the equivalent code in;
Prev: 48909 Up: Map Next: 48982