Prev: 41983 Up: Map Next: 42215
42170: 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 42170 LD L,(IX+2) Fetch the actor world X.
42173 LD H,(IX+3) Fetch the high byte.
42176 ADD HL,HL Multiply it by 8.
42177 ADD HL,HL
42178 ADD HL,HL
42179 LD C,L Copy it into BC.
42180 LD B,H
Work out the horizontal distance between the rover and the actor.
42181 LD HL,(24722) Fetch Rover_Position.
42184 ADD HL,HL Multiply it by 8.
42185 ADD HL,HL
42186 ADD HL,HL
42187 AND A Clear the carry flag.
42188 SBC HL,BC Subtract the actor world X.
Make the difference positive.
42190 LD A,H Fetch the high byte of the difference.
42191 AND A Jump to CompareActorDistance_TestRange if the result is positive.
42192 JP P,CompareActorDistance_TestRange
42195 CALL NegatePair Call NegatePair.
Return if the actor is outside the collect range.
CompareActorDistance_TestRange 42198 LD BC,192 Set the collect range in BC to 0192.
42201 AND A Clear the carry flag.
42202 SBC HL,BC Subtract the collect range.
42204 RET NC Return if the actor is too far away.
Compare the rover's height against the actor's Y.
42205 LD A,(24724) Fetch the rover Y.
42208 DEC A Decrease it by one.
42209 SUB (IX+4) Subtract the actor Y.
42212 CP 22 Compare it against 22.
42214 RET Return.
Prev: 41983 Up: Map Next: 42215