Prev: 51163 Up: Map Next: 51235
51198: Test Near To
Used by the routines at NudgeObjectsToArch and FlagObjectsNearArch.
Tests whether an object is close to the point that the arch keeps as the middle of its doorway: less than L away in X, less than H away in Y and less than 4 away in Z.
Input
H Distance in Y that counts as near
L Distance in X that counts as near
IX Address of the arch object
IY Address of the object
Output
F Carry flag set if the object is near
Test the distance in X, then in Y, then in Z.
TestNearTo 51198 LD A,(IX+9) Fetch the X coordinate of the middle of the doorway.
51201 SUB (IY+1) Subtract the X coordinate of the object.
51204 JR NC,TestNearTo_Y Jump to TestNearTo_Y if it is positive.
51206 NEG Make it positive.
TestNearTo_Y 51208 CP L Compare it with the distance in X.
51209 RET NC Return if it is too far.
51210 LD A,(IX+10) Fetch the Y coordinate of the middle of the doorway.
51213 SUB (IY+2) Subtract the Y coordinate of the object.
51216 JR NC,TestNearTo_Z Jump to TestNearTo_Z if it is positive.
51218 NEG Make it positive.
TestNearTo_Z 51220 CP H Compare it with the distance in Y.
51221 RET NC Return if it is too far.
51222 LD A,(IX+11) Fetch the Z coordinate of the middle of the doorway.
51225 SUB (IY+3) Subtract the Z coordinate of the object.
51228 JR NC,TestNearTo_Done Jump to TestNearTo_Done if it is positive.
51230 NEG Make it positive.
TestNearTo_Done 51232 CP 4 Compare it with 4.
51234 RET Return.
View the equivalent code in;
Prev: 51163 Up: Map Next: 51235