Prev: 52568 Up: Map Next: 52655
52638: Limit Distance
Used by the routine at UpdateEndingGhost.
Subtracts a position from a target and limits the difference to four pixels in either direction.
Input
A Target position
IX Object
Output
A The distance to move, from 252 to 4
LimitDistance 52638 SUB (IX+10) Work out how far the object is from the target along the X axis, and jump to LimitDistance_Negative if the target is on the left.
52641 JR C,LimitDistance_Negative
52643 CP 4 Return if the distance is less than four.
52645 RET C
52646 LD A,4 Limit the distance to four and return.
52648 RET
LimitDistance_Negative 52649 CP 252 Return if the distance is 252 or more, which means it is less than four to the left.
52651 RET NC
52652 LD A,252 Limit the distance to minus four and return.
52654 RET
Prev: 52568 Up: Map Next: 52655