Prev: C89A Up: Map Next: C8D2
C8AD: Test Near To
Used by the routines at TestDoorPassage and NudgeObjectsToArch.
Tests if the player is standing in the place in front of a door, which is a box that is centred on the place that is held in the speeds and the z position of the door, as far as the sizes in HL along x and y and 04 along z.
Input
H Size of the box along y
L Size of the box along x
IX Door record
IY Record of the legs of the player
Output
F Carry flag set if the player is in the box
Test along x.
TestNearTo C8AD LD A,(IX+$09) Fetch the x position of the place.
C8B0 SUB (IY+$01) Take away the x position of the player.
C8B3 JR NC,TestNearTo_Y Jump to TestNearTo_Y if the difference is not negative.
C8B5 NEG Make it positive.
Test along y.
TestNearTo_Y C8B7 CP L Return with the carry flag clear if it is not less than the size of the box along x.
C8B8 RET NC
C8B9 LD A,(IX+$0A) Fetch the y position of the place.
C8BC SUB (IY+$02) Take away the y position of the player.
C8BF JR NC,TestNearTo_Z Jump to TestNearTo_Z if the difference is not negative.
C8C1 NEG Make it positive.
Test along z.
TestNearTo_Z C8C3 CP H Return with the carry flag clear if it is not less than the size of the box along y.
C8C4 RET NC
C8C5 LD A,(IX+$0B) Fetch the z position of the place.
C8C8 SUB (IY+$03) Take away the z position of the player.
C8CB JR NC,TestNearTo_Done Jump to TestNearTo_Done if the difference is not negative.
C8CD NEG Make it positive.
TestNearTo_Done C8CF CP $04 Compare the difference with 04.
C8D1 RET Return with the carry flag set if it is less.
View the equivalent code in;
Prev: C89A Up: Map Next: C8D2