Prev: C082 Up: Map Next: C0BE
C099: Test Near To
Used by the routines at NudgePlayerToArch and FlagPlayerNearArch.
Tests whether an object is close to the point that the arch keeps as the middle of its doorway: less than L away along the x axis, less than H away along the y axis and less than 04 away along the z axis.
Input
H Reach along the y axis
L Reach along the x axis
IX The address of the arch object
IY The address of the object
Output
F Carry flag set if the object is near
Compare along x.
TestNearTo C099 LD A,(IX+$09) Fetch the x of the doorway middle.
C09C SUB (IY+$01) Subtract the x of the object.
C09F JR NC,TestNearTo_Y Jump to TestNearTo_Y if carry is not set.
C0A1 NEG Negate A.
TestNearTo_Y C0A3 CP L Return if the object is too far along the x axis.
C0A4 RET NC
Compare along y.
C0A5 LD A,(IX+$0A) Fetch the y of the doorway middle.
C0A8 SUB (IY+$02) Subtract the y of the object.
C0AB JR NC,TestNearTo_Z Jump to TestNearTo_Z if carry is not set.
C0AD NEG Negate A.
TestNearTo_Z C0AF CP H Return if the object is too far along the y axis.
C0B0 RET NC
Compare along z against 04.
C0B1 LD A,(IX+$0B) Fetch the z of the doorway middle.
C0B4 SUB (IY+$03) Subtract the z of the object.
C0B7 JR NC,TestNearTo_Done Jump to TestNearTo_Done if carry is not set.
C0B9 NEG Negate A.
TestNearTo_Done C0BB CP $04 Compare it with 04.
C0BD RET Return.
View the equivalent code in;
Prev: C082 Up: Map Next: C0BE