Prev: 6253 Up: Map Next: 62DA
625C: Update Radar
Used by the routine at HandlerPlayer.
Updates the radar. A blip is shown by clearing a 02 by 02 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.
Before After
update-radar-before update-radar-after
Draw the player at the centre of the radar.
UpdateRadar 625C LD HL,$6513 HL=6513 (the pixel column and row of the centre of the radar).
625F LD BC,$0202 BC=0202 (the size of a blip).
6262 CALL ClearPixels Call ClearPixels to clear the pixels.
Work out the new position of each blip.
6265 LD IX,$5E68 Point IX at the first blip record (RadarBlips).
6269 LD BC,($5E90) Fetch the X position of the car at Entity_Car_1 from Entity_Car_1_X.
626D LD DE,($5E92) Fetch the Y position of the car at Entity_Car_1 from Entity_Car_1_Y.
6271 CALL LocateRadarBlip Call LocateRadarBlip.
6274 LD BC,$0004 Set the size of a blip record, 04.
6277 ADD IX,BC Point IX at the next blip record.
6279 LD BC,($5E9C) Fetch the X position of the car at Entity_Car_2 from Entity_Car_2_X.
627D LD DE,($5E9E) Fetch the Y position of the car at Entity_Car_2 from Entity_Car_2_Y.
6281 CALL LocateRadarBlip Call LocateRadarBlip.
6284 LD BC,$0004 Set the size of a blip record, 04.
6287 ADD IX,BC Point IX at the next blip record.
6289 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.
628C LD IX,$5E68 Point IX at the first blip record (RadarBlips).
6290 LD C,$03 Set the blip counter to 03.
UpdateRadar_Loop 6292 LD B,$02 Set the pass counter to 02.
6294 LD L,(IX+$00) Fetch the column of the blip.
6297 LD H,(IX+$01) Fetch the row of the blip.
UpdateRadar_Pass 629A LD A,L If the blip is not on the radar then jump to UpdateRadar_Hidden.
629B OR H
629C JR Z,UpdateRadar_Hidden
629E LD A,L Add 07 (the left edge of the radar) to the column.
629F ADD A,$07
62A1 LD L,A
62A2 LD A,H Add 57 (the top edge of the radar) to the row.
62A3 ADD A,$57
62A5 LD H,A
62A6 DEC B Decrease the pass counter by one.
62A7 PUSH BC Stash the counters on the stack.
62A8 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.
62AA LD BC,$0202 BC=0202 (the size of a blip).
62AD CALL ClearPixels Call ClearPixels to clear the pixels.
62B0 POP BC Restore the counters from the stack.
The new position becomes the position that was drawn.
UpdateRadar_Next 62B1 LD A,(IX+$02) Fetch the new column of the blip.
62B4 LD (IX+$00),A Store it as the column drawn.
62B7 LD A,(IX+$03) Fetch the new row of the blip.
62BA LD (IX+$01),A Store it as the row drawn.
62BD LD DE,$0004 Set the size of a blip record, 04.
62C0 ADD IX,DE Point IX at the next blip record.
62C2 DEC C Decrease the blip counter by one and loop back to UpdateRadar_Loop until all 03 blips have been done.
62C3 JR NZ,UpdateRadar_Loop
62C5 RET Return.
This is the first pass, so remove the blip from where it was drawn last time.
UpdateRadar_RemoveBlip 62C6 LD BC,$0202 BC=0202 (the size of a blip).
62C9 CALL SetPixels Call SetPixels to set the pixels.
62CC POP BC Restore the counters from the stack.
UpdateRadar_NewPosition 62CD LD L,(IX+$02) Fetch the new column of the blip.
62D0 LD H,(IX+$03) Fetch the new row of the blip.
62D3 JR UpdateRadar_Pass Jump to UpdateRadar_Pass for the second pass.
There is no blip at this position.
UpdateRadar_Hidden 62D5 DEC B Decrease the pass counter by one and jump to UpdateRadar_Next if both passes are done.
62D6 JR Z,UpdateRadar_Next
62D8 JR UpdateRadar_NewPosition Jump to UpdateRadar_NewPosition for the second pass.
Prev: 6253 Up: Map Next: 62DA