Prev: 49282 Up: Map Next: 49342
49305: 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 4 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 49305 LD A,(IX+9) Fetch the x of the doorway middle.
49308 SUB (IY+1) Subtract the x of the object.
49311 JR NC,TestNearTo_Y Jump to TestNearTo_Y if carry is not set.
49313 NEG Negate A.
TestNearTo_Y 49315 CP L Return if the object is too far along the x axis.
49316 RET NC
Compare along y.
49317 LD A,(IX+10) Fetch the y of the doorway middle.
49320 SUB (IY+2) Subtract the y of the object.
49323 JR NC,TestNearTo_Z Jump to TestNearTo_Z if carry is not set.
49325 NEG Negate A.
TestNearTo_Z 49327 CP H Return if the object is too far along the y axis.
49328 RET NC
Compare along z against 4.
49329 LD A,(IX+11) Fetch the z of the doorway middle.
49332 SUB (IY+3) Subtract the z of the object.
49335 JR NC,TestNearTo_Done Jump to TestNearTo_Done if carry is not set.
49337 NEG Negate A.
TestNearTo_Done 49339 CP 4 Compare it with 4.
49341 RET Return.
View the equivalent code in;
Prev: 49282 Up: Map Next: 49342