Prev: C7DB Up: Map Next: C823
C7FE: 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 04 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 C7FE LD A,(IX+$09) Fetch the X coordinate of the middle of the doorway.
C801 SUB (IY+$01) Subtract the X coordinate of the object.
C804 JR NC,TestNearTo_Y Jump to TestNearTo_Y if it is positive.
C806 NEG Make it positive.
TestNearTo_Y C808 CP L Compare it with the distance in X.
C809 RET NC Return if it is too far.
C80A LD A,(IX+$0A) Fetch the Y coordinate of the middle of the doorway.
C80D SUB (IY+$02) Subtract the Y coordinate of the object.
C810 JR NC,TestNearTo_Z Jump to TestNearTo_Z if it is positive.
C812 NEG Make it positive.
TestNearTo_Z C814 CP H Compare it with the distance in Y.
C815 RET NC Return if it is too far.
C816 LD A,(IX+$0B) Fetch the Z coordinate of the middle of the doorway.
C819 SUB (IY+$03) Subtract the Z coordinate of the object.
C81C JR NC,TestNearTo_Done Jump to TestNearTo_Done if it is positive.
C81E NEG Make it positive.
TestNearTo_Done C820 CP $04 Compare it with 04.
C822 RET Return.
View the equivalent code in;
Prev: C7DB Up: Map Next: C823