![]() |
Routines |
| Prev: 6208 | Up: Map | Next: 624D |
|
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 20 map units. The column (00-18) and row (00-1C) 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 0C pixels to the left or right of the player, or more than 0E pixels above or below, then both are set to 00 and the blip is hidden.
|
||||||||||||
|
Work out the horizontal distance between the player and the target.
|
||||||||||||
| LocateRadarBlip | 6212 | LD HL,($5E05) | HL=player X map position (PlayerMapPosition). | |||||||||
| 6215 | SLA L | Double the value so it matches the scale of the target position. | ||||||||||
| 6217 | RL H | |||||||||||
| 6219 | AND A | Reset the carry flag. | ||||||||||
| 621A | SBC HL,BC | Work out the horizontal distance from the target to the player. | ||||||||||
| 621C | 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.
|
||||||||||||
| 621E | CALL NegateHL | Call NegateHL. | ||||||||||
| 6221 | CALL MultiplyHLByFour | Call MultiplyHLByFour to multiply the distance by 04 which leaves the distance in radar pixels in H. | ||||||||||
| 6224 | LD A,$0C | Start from the centre column of the radar (0C). | ||||||||||
| 6226 | CP H | Compare the distance with 0C. | ||||||||||
| 6227 | JR C,HideRadarBlip | If the target is more than 0C pixels to the right then jump to HideRadarBlip. | ||||||||||
| 6229 | 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 | 622A | LD (IX+$02),A | Store the column in the blip record. | |||||||||
| 622D | LD HL,($5E08) | HL=player Y map position (PlayerMapPositionY). | ||||||||||
| 6230 | SLA L | Double the value so it matches the scale of the target position. | ||||||||||
| 6232 | RL H | |||||||||||
| 6234 | AND A | Reset the carry flag. | ||||||||||
| 6235 | SBC HL,DE | Work out the vertical distance from the target to the player. | ||||||||||
| 6237 | 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.
|
||||||||||||
| 6239 | CALL NegateHL | Call NegateHL. | ||||||||||
| 623C | CALL MultiplyHLByFour | Call MultiplyHLByFour to multiply the distance by 04 which leaves the distance in radar pixels in H. | ||||||||||
| 623F | LD A,$0E | Start from the centre row of the radar (0E). | ||||||||||
| 6241 | CP H | Compare the distance with 0E. | ||||||||||
| 6242 | JR C,HideRadarBlip | If the target is more than 0E pixels away then jump to HideRadarBlip. | ||||||||||
| 6244 | 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 | 6245 | NEG | Negate A. | |||||||||
| 6247 | ADD A,$1C | Add 1C 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 | 6249 | LD (IX+$03),A | Store the row in the blip record. | |||||||||
| 624C | RET | Return. | ||||||||||
| Prev: 6208 | Up: Map | Next: 624D |