![]() |
Routines |
| Prev: 25171 | Up: Map | Next: 25306 |
|
Used by the routine at HandlerPlayer.
Updates the radar. A blip is shown by clearing a 2 by 2 block of pixels, and removed again by setting them. The player is always the blip at the centre. The other blips are the two cars (at Entity_Car_1 and Entity_Car_2) and the first cup within range, which are tracked by three four-byte records starting at RadarBlips. The first two bytes of a record hold the column and row that were drawn last time and the next two bytes hold the new column and row, or zero if the target is not on the radar.
|
||||||||
|
Draw the player at the centre of the radar.
|
||||||||
| UpdateRadar | 25180 | LD HL,25875 | HL=25875 (the pixel column and row of the centre of the radar). | |||||
| 25183 | LD BC,514 | BC=0514 (the size of a blip). | ||||||
| 25186 | CALL ClearPixels | Call ClearPixels to clear the pixels. | ||||||
|
Work out the new position of each blip.
|
||||||||
| 25189 | LD IX,24168 | Point IX at the first blip record (RadarBlips). | ||||||
| 25193 | LD BC,(24208) | Fetch the X position of the car at Entity_Car_1 from Entity_Car_1_X. | ||||||
| 25197 | LD DE,(24210) | Fetch the Y position of the car at Entity_Car_1 from Entity_Car_1_Y. | ||||||
| 25201 | CALL LocateRadarBlip | Call LocateRadarBlip. | ||||||
| 25204 | LD BC,4 | Set the size of a blip record, 4. | ||||||
| 25207 | ADD IX,BC | Point IX at the next blip record. | ||||||
| 25209 | LD BC,(24220) | Fetch the X position of the car at Entity_Car_2 from Entity_Car_2_X. | ||||||
| 25213 | LD DE,(24222) | Fetch the Y position of the car at Entity_Car_2 from Entity_Car_2_Y. | ||||||
| 25217 | CALL LocateRadarBlip | Call LocateRadarBlip. | ||||||
| 25220 | LD BC,4 | Set the size of a blip record, 4. | ||||||
| 25223 | ADD IX,BC | Point IX at the next blip record. | ||||||
| 25225 | CALL CollisionCup | Call CollisionCup to find a cup to show. | ||||||
|
Now move each blip. This takes two passes: the first removes the blip from where it was last time and the second draws it at the new position.
|
||||||||
| 25228 | LD IX,24168 | Point IX at the first blip record (RadarBlips). | ||||||
| 25232 | LD C,3 | Set the blip counter to 3. | ||||||
| UpdateRadar_Loop | 25234 | LD B,2 | Set the pass counter to 2. | |||||
| 25236 | LD L,(IX+0) | Fetch the column of the blip. | ||||||
| 25239 | LD H,(IX+1) | Fetch the row of the blip. | ||||||
| UpdateRadar_Pass | 25242 | LD A,L | If the blip is not on the radar then jump to UpdateRadar_Hidden. | |||||
| 25243 | OR H | |||||||
| 25244 | JR Z,UpdateRadar_Hidden | |||||||
| 25246 | LD A,L | Add 7 (the left edge of the radar) to the column. | ||||||
| 25247 | ADD A,7 | |||||||
| 25249 | LD L,A | |||||||
| 25250 | LD A,H | Add 87 (the top edge of the radar) to the row. | ||||||
| 25251 | ADD A,87 | |||||||
| 25253 | LD H,A | |||||||
| 25254 | DEC B | Decrease the pass counter by one. | ||||||
| 25255 | PUSH BC | Stash the counters on the stack. | ||||||
| 25256 | JR NZ,UpdateRadar_RemoveBlip | If this was the first pass then jump to UpdateRadar_RemoveBlip. | ||||||
|
This is the second pass, so draw the blip at its new position.
|
||||||||
| 25258 | LD BC,514 | BC=0514 (the size of a blip). | ||||||
| 25261 | CALL ClearPixels | Call ClearPixels to clear the pixels. | ||||||
| 25264 | POP BC | Restore the counters from the stack. | ||||||
|
The new position becomes the position that was drawn.
|
||||||||
| UpdateRadar_Next | 25265 | LD A,(IX+2) | Fetch the new column of the blip. | |||||
| 25268 | LD (IX+0),A | Store it as the column drawn. | ||||||
| 25271 | LD A,(IX+3) | Fetch the new row of the blip. | ||||||
| 25274 | LD (IX+1),A | Store it as the row drawn. | ||||||
| 25277 | LD DE,4 | Set the size of a blip record, 4. | ||||||
| 25280 | ADD IX,DE | Point IX at the next blip record. | ||||||
| 25282 | DEC C | Decrease the blip counter by one and loop back to UpdateRadar_Loop until all 3 blips have been done. | ||||||
| 25283 | JR NZ,UpdateRadar_Loop | |||||||
| 25285 | RET | Return. | ||||||
|
This is the first pass, so remove the blip from where it was drawn last time.
|
||||||||
| UpdateRadar_RemoveBlip | 25286 | LD BC,514 | BC=0514 (the size of a blip). | |||||
| 25289 | CALL SetPixels | Call SetPixels to set the pixels. | ||||||
| 25292 | POP BC | Restore the counters from the stack. | ||||||
| UpdateRadar_NewPosition | 25293 | LD L,(IX+2) | Fetch the new column of the blip. | |||||
| 25296 | LD H,(IX+3) | Fetch the new row of the blip. | ||||||
| 25299 | JR UpdateRadar_Pass | Jump to UpdateRadar_Pass for the second pass. | ||||||
|
There is no blip at this position.
|
||||||||
| UpdateRadar_Hidden | 25301 | DEC B | Decrease the pass counter by one and jump to UpdateRadar_Next if both passes are done. | |||||
| 25302 | JR Z,UpdateRadar_Next | |||||||
| 25304 | JR UpdateRadar_NewPosition | Jump to UpdateRadar_NewPosition for the second pass. | ||||||
| Prev: 25171 | Up: Map | Next: 25306 |