Prev: 8C3F Up: Map Next: 8CB2
8C58: Accelerate Towards Player
Used by the routine at ProcessObjectFlags.
Sets the acceleration of an object so that it heads towards the player. Objects of type 1D and 1E are left alone.
Input
IX Address of the object
AccelerateTowardsPlayer 8C58 LD A,(IX+$00) Fetch the type of the object.
8C5B CP $1D Is it 1D?
8C5D RET Z Return if so.
8C5E CP $1E Is it 1E?
8C60 RET Z Return if so.
8C61 LD A,($5C31) Fetch the value from ContactFlags.
8C64 AND %10000000 Keep bit 7.
8C66 RET NZ Return if it is set.
This entry point is used by the routine at SpawnEnemy.
AccelerateTowardsPlayer_Horizontal 8C67 LD (IX+$0B),$00 Set the horizontal acceleration to 20.
8C6B LD (IX+$0C),$20
8C6F LD A,($CE57) Fetch the map column of the player from MapPosition.
8C72 CP (IX+$01) Compare it with the map column of the object.
8C75 JR Z,AccelerateTowardsPlayer_Stop Jump to AccelerateTowardsPlayer_Stop if they are the same.
8C77 LD (IX+$0C),$E0 Otherwise set the horizontal acceleration to FFE0.
8C7B LD (IX+$0B),$FF
AccelerateTowardsPlayer_Stop 8C7F XOR A Clear the speeds of the object and its vertical acceleration.
8C80 LD (IX+$09),A
8C83 LD (IX+$0A),A
8C86 LD (IX+$0E),A
8C89 LD (IX+$0F),A
8C8C LD A,($CE58) Fetch the map zone of the player from CE58.
8C8F CP (IX+$04) Compare it with the map zone of the object.
8C92 LD A,($CE46) Fetch the vertical position of the player from PositionDown.
8C95 JR NZ,AccelerateTowardsPlayer_Other Jump to AccelerateTowardsPlayer_Other if the zones are different.
8C97 CP (IX+$05) Compare it with the vertical position of the object.
8C9A RET C Return if it is lower.
8C9B LD (IX+$0E),$00 Set the vertical acceleration to 20.
8C9F LD (IX+$0F),$20
8CA3 RET Return.
AccelerateTowardsPlayer_Other 8CA4 CP (IX+$05) Compare the vertical position of the player with that of the object.
8CA7 RET NC Return if it is not lower.
8CA8 LD (IX+$0E),$FF Set the vertical acceleration to FFE0.
8CAC LD (IX+$0F),$E0
8CB0 RET Return.
8CB1 DEFB $00
Prev: 8C3F Up: Map Next: 8CB2