Prev: 37639 Up: Map Next: 37773
37697: Accelerate Towards Target
Used by the routines at UpdateChasingObject, ChasePlayer and ChasePlayerBriefly.
Sets the acceleration of an object so that it heads towards another object.
Input
IX Address of the object that is moving
IY Address of the object that is the target
AccelerateTowardsTarget 37697 LD (IX+11),0 Set the horizontal acceleration to 192.
37701 LD (IX+12),192
37705 LD A,(IX+1) Fetch the map column of the object.
37708 CP (IY+1) Compare it with the map column of the target.
37711 JR NZ,AccelerateTowardsTarget_Column Jump to AccelerateTowardsTarget_Column if they are different.
37713 LD A,(IX+2) Fetch the horizontal position of the object.
37716 CP (IY+2) Compare it with the horizontal position of the target.
37719 JR NC,AccelerateTowardsTarget_Left Jump to AccelerateTowardsTarget_Left if it is not lower.
37721 JR AccelerateTowardsTarget_Vertical Jump to AccelerateTowardsTarget_Vertical.
AccelerateTowardsTarget_Column 37723 LD A,(56823) Fetch the column from NextColumn.
37726 CP (IX+1) Compare it with the map column of the object.
37729 JR Z,AccelerateTowardsTarget_Left Jump to AccelerateTowardsTarget_Left if they are the same.
37731 JR AccelerateTowardsTarget_Vertical Jump to AccelerateTowardsTarget_Vertical.
AccelerateTowardsTarget_Left 37733 LD (IX+11),255 Set the horizontal acceleration to 65344.
37737 LD (IX+12),64
AccelerateTowardsTarget_Vertical 37741 LD H,(IX+4) Fetch the map zone and vertical position of the object into HL.
37744 LD L,(IX+5)
37747 LD D,(IY+4) Fetch the map zone and vertical position of the target into DE.
37750 LD E,(IY+5)
37753 SBC HL,DE Subtract them.
37755 LD (IX+14),0 Set the vertical acceleration to 192.
37759 LD (IX+15),192
37763 RET C Return if the target is lower.
37764 LD (IX+14),255 Otherwise set the vertical acceleration to 65344.
37768 LD (IX+15),64
37772 RET Return.
Prev: 37639 Up: Map Next: 37773