Prev: 9307 Up: Map Next: 938D
9341: 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 9341 LD (IX+$0B),$00 Set the horizontal acceleration to C0.
9345 LD (IX+$0C),$C0
9349 LD A,(IX+$01) Fetch the map column of the object.
934C CP (IY+$01) Compare it with the map column of the target.
934F JR NZ,AccelerateTowardsTarget_Column Jump to AccelerateTowardsTarget_Column if they are different.
9351 LD A,(IX+$02) Fetch the horizontal position of the object.
9354 CP (IY+$02) Compare it with the horizontal position of the target.
9357 JR NC,AccelerateTowardsTarget_Left Jump to AccelerateTowardsTarget_Left if it is not lower.
9359 JR AccelerateTowardsTarget_Vertical Jump to AccelerateTowardsTarget_Vertical.
AccelerateTowardsTarget_Column 935B LD A,($DDF7) Fetch the column from NextColumn.
935E CP (IX+$01) Compare it with the map column of the object.
9361 JR Z,AccelerateTowardsTarget_Left Jump to AccelerateTowardsTarget_Left if they are the same.
9363 JR AccelerateTowardsTarget_Vertical Jump to AccelerateTowardsTarget_Vertical.
AccelerateTowardsTarget_Left 9365 LD (IX+$0B),$FF Set the horizontal acceleration to FF40.
9369 LD (IX+$0C),$40
AccelerateTowardsTarget_Vertical 936D LD H,(IX+$04) Fetch the map zone and vertical position of the object into HL.
9370 LD L,(IX+$05)
9373 LD D,(IY+$04) Fetch the map zone and vertical position of the target into DE.
9376 LD E,(IY+$05)
9379 SBC HL,DE Subtract them.
937B LD (IX+$0E),$00 Set the vertical acceleration to C0.
937F LD (IX+$0F),$C0
9383 RET C Return if the target is lower.
9384 LD (IX+$0E),$FF Otherwise set the vertical acceleration to FF40.
9388 LD (IX+$0F),$40
938C RET Return.
Prev: 9307 Up: Map Next: 938D