Prev: A3FF Up: Map Next: A4E7
A4BA: Compare Actor Distance
Return carry if this actor is close enough to the rover to collect.
Input
IX Actor slot
Output
F Carry if this actor is in range
Return carry if this actor is close enough to the rover.
CompareActorDistance A4BA LD L,(IX+$02) Fetch the actor world X.
A4BD LD H,(IX+$03) Fetch the high byte.
A4C0 ADD HL,HL Multiply it by 08.
A4C1 ADD HL,HL
A4C2 ADD HL,HL
A4C3 LD C,L Copy it into BC.
A4C4 LD B,H
Work out the horizontal distance between the rover and the actor.
A4C5 LD HL,($6092) Fetch Rover_Position.
A4C8 ADD HL,HL Multiply it by 08.
A4C9 ADD HL,HL
A4CA ADD HL,HL
A4CB AND A Clear the carry flag.
A4CC SBC HL,BC Subtract the actor world X.
Make the difference positive.
A4CE LD A,H Fetch the high byte of the difference.
A4CF AND A Jump to CompareActorDistance_TestRange if the result is positive.
A4D0 JP P,CompareActorDistance_TestRange
A4D3 CALL NegatePair Call NegatePair.
Return if the actor is outside the collect range.
CompareActorDistance_TestRange A4D6 LD BC,$00C0 Set the collect range in BC to 00C0.
A4D9 AND A Clear the carry flag.
A4DA SBC HL,BC Subtract the collect range.
A4DC RET NC Return if the actor is too far away.
Compare the rover's height against the actor's Y.
A4DD LD A,($6094) Fetch the rover Y.
A4E0 DEC A Decrease it by one.
A4E1 SUB (IX+$04) Subtract the actor Y.
A4E4 CP $16 Compare it against 16.
A4E6 RET Return.
Prev: A3FF Up: Map Next: A4E7