Prev: AD33 Up: Map Next: AD59
AD36: Test Actor Side
Test whether this actor is to the left of Jetman. The world wraps at 2000 so carry is set when Jetman's world X (Jetman_Position) is less than 1000 ahead of the actor.
Input
IX Actor slot
Handler_Missile AD36 LD HL,($607A) Fetch Jetman_Position.
This entry point is used by the routine at AlignToRover.
Handler_Missile_FetchActorX AD39 LD C,(IX+$02) Fetch the actor world X.
AD3C LD B,(IX+$03) Fetch the high byte.
Return carry if HL is ahead of BC (to its right) by less than 1000 (allowing for the wrap at 2000).
Handler_Missile_CompareWorldX AD3F AND A Clear the carry flag.
AD40 SBC HL,BC Subtract the second world X.
AD42 LD A,H Fetch the high byte of the difference.
AD43 AND A Jump to Handler_Missile_NegateThenRange if the result is negative.
AD44 JP M,Handler_Missile_NegateThenRange
Test a positive difference against the range and return carry.
AD47 LD BC,$1000 Set the range in BC to 1000.
AD4A AND A Clear the carry flag.
AD4B SBC HL,BC Subtract the range.
AD4D RET Return.
Call NegatePair on a negative difference, then test it against the range and invert the carry.
Handler_Missile_NegateThenRange AD4E CALL NegatePair Call NegatePair.
AD51 LD BC,$1000 Set the range in BC to 1000.
AD54 AND A Clear the carry flag.
AD55 SBC HL,BC Subtract the range.
AD57 CCF Invert the carry flag.
AD58 RET Return.
Prev: AD33 Up: Map Next: AD59