Prev: 25096 Up: Map Next: 25165
25106: Locate Radar Blip
Used by the routines at UpdateRadar and CollisionCup.
Works out where a target is shown on the radar. The radar is centred on the player and one radar pixel covers 32 map units. The column (0-24) and row (0-28) are stored in the third and fourth bytes of the blip record, measured from the top left of the radar. If the target is more than 12 pixels to the left or right of the player, or more than 14 pixels above or below, then both are set to 0 and the blip is hidden.
Input
BC Target X position (doubled)
DE Target Y position (doubled)
IX Radar blip record
Work out the horizontal distance between the player and the target.
LocateRadarBlip 25106 LD HL,(24069) HL=player X map position (PlayerMapPosition).
25109 SLA L Double the value so it matches the scale of the target position.
25111 RL H
25113 AND A Reset the carry flag.
25114 SBC HL,BC Work out the horizontal distance from the target to the player.
25116 JR NC,OffsetBlipLeft If the target is not to the right of the player then jump to OffsetBlipLeft.
The target is to the right of the player, so make the distance positive.
25118 CALL NegateHL Call NegateHL.
25121 CALL MultiplyHLByFour Call MultiplyHLByFour to multiply the distance by 4 which leaves the distance in radar pixels in H.
25124 LD A,12 Start from the centre column of the radar (12).
25126 CP H Compare the distance with 12.
25127 JR C,HideRadarBlip If the target is more than 12 pixels to the right then jump to HideRadarBlip.
25129 ADD A,H Add the distance to the centre column to give the column to the right of the player.
This entry point is used by the routine at OffsetBlipLeft.
Store the column and do the same for the vertical distance.
LocateRadarBlip_StoreColumn 25130 LD (IX+2),A Store the column in the blip record.
25133 LD HL,(24072) HL=player Y map position (PlayerMapPositionY).
25136 SLA L Double the value so it matches the scale of the target position.
25138 RL H
25140 AND A Reset the carry flag.
25141 SBC HL,DE Work out the vertical distance from the target to the player.
25143 JR NC,OffsetBlipDown If the target is not further up the map than the player then jump to OffsetBlipDown.
The target is further up the map than the player, so make the distance positive.
25145 CALL NegateHL Call NegateHL.
25148 CALL MultiplyHLByFour Call MultiplyHLByFour to multiply the distance by 4 which leaves the distance in radar pixels in H.
25151 LD A,14 Start from the centre row of the radar (14).
25153 CP H Compare the distance with 14.
25154 JR C,HideRadarBlip If the target is more than 14 pixels away then jump to HideRadarBlip.
25156 ADD A,H Add the distance to the centre row.
This entry point is used by the routine at OffsetBlipDown.
Rows are counted down the radar, so flip the value to give the row above the centre.
LocateRadarBlip_FlipRow 25157 NEG Negate A.
25159 ADD A,28 Add 28 so the row counts down from the top of the radar.
This entry point is used by the routine at HideRadarBlip.
Store the row.
LocateRadarBlip_StoreRow 25161 LD (IX+3),A Store the row in the blip record.
25164 RET Return.
Prev: 25096 Up: Map Next: 25165