Prev: 9307 Up: Map Next: 938D
9341: Accelerate an object towards another
Used by the routines at update_missile, home_on_ship and turn_at_ship.
Sets the acceleration (+$0B, +$0E) to $C0 (three quarters of a pixel a pass, each pass) towards the target in each axis. In X: the same page column decides by the pixel; otherwise the target is taken to be to the left when the object is in the column after the view's (kept in start_filled), and to the right otherwise. In Y, by the whole position.
Input
IX The object
IY The target
steer_towards 9341 LD (IX+$0B),$00 X: right, unless...
9345 LD (IX+$0C),$C0
9349 LD A,(IX+$01)
934C CP (IY+$01)
934F JR NZ,steer_towards_0
9351 LD A,(IX+$02)
9354 CP (IY+$02)
9357 JR NC,steer_towards_1
9359 JR steer_towards_2
steer_towards_0 935B LD A,(right_map_column) ...in the other page column
935E CP (IX+$01)
9361 JR Z,steer_towards_1
9363 JR steer_towards_2
steer_towards_1 9365 LD (IX+$0B),$FF Left
9369 LD (IX+$0C),$40
steer_towards_2 936D LD H,(IX+$04) Y: compare the positions (page row and pixel)
9370 LD L,(IX+$05)
9373 LD D,(IY+$04)
9376 LD E,(IY+$05)
9379 SBC HL,DE
937B LD (IX+$0E),$00 Down
937F LD (IX+$0F),$C0
9383 RET C
9384 LD (IX+$0E),$FF Up
9388 LD (IX+$0F),$40
938C RET
Prev: 9307 Up: Map Next: 938D