Prev: BF0D Up: Map Next: BF56
BF1B: 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 BF1B PUSH BC Stash the registers on the stack.
BF1C PUSH DE
BF1D PUSH HL
BF1E PUSH IY
BF20 LD IY,$A76F Start with the first object record, ObjectsTable.
BF24 LD B,$36 Set a counter in B of the number of object records, 36.
BF26 LD C,$00 Set the x speed to 00.
BF28 LD L,C Set the y and z speeds to 00.
BF29 LD H,C
BF2A SET 1,(IX+$07) 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 BF2E CALL TestObjectSolid Call TestObjectSolid.
BF31 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.
BF33 CALL TestOverlapInX Call TestOverlapInX.
BF36 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.
BF38 CALL TestOverlapInY Call TestOverlapInY.
BF3B 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.
BF3D CALL TestOverlapInZ Call TestOverlapInZ.
BF40 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 BF42 POP IY Restore IY, HL, DE and BC from the stack.
BF44 POP HL
BF45 POP DE
BF46 POP BC
BF47 RES 1,(IX+$07) Clear the flag that says that the object is being moved.
BF4B RET Return.
Move on to the next object.
TestObjectIntersections_Next BF4C LD DE,$0020 Set the size of an object record to 20.
BF4F ADD IY,DE Move on to the next object.
BF51 DJNZ TestObjectIntersections_Loop Decrease the counter and loop until all the records have been tried.
BF53 AND A Clear the carry flag, as nothing overlaps the object.
BF54 JR TestObjectIntersections_Done Jump to TestObjectIntersections_Done.
View the equivalent code in;
Prev: BF0D Up: Map Next: BF56