Prev: 25943 Up: Map Next: 26033
25992: Update Terrain Dots
Used by the routine at HandlerPlayer.
Moves the dots which are scattered over the play area, to give the impression that the car is moving. Nothing happens unless the car has moved since last time. Each of the 16 dots at TerrainDots is then redrawn by UpdateTerrainDot. The low bytes of the player's X (flipped) and Y positions are saved in PlayerWorldPosition so the dots can be erased from where they were drawn.
Before After
terrain-dots-before terrain-dots-after
UpdateTerrainDots 25992 LD HL,(24116) Fetch the player position used last time (PlayerWorldPosition).
25995 LD A,(24069) Fetch the low byte of the player's X position on the map (PlayerMapPosition).
25998 CPL Flip all the bits, as the dots move the opposite way to the car.
25999 LD E,A Keep the flipped X position in E.
26000 LD A,(24072) Fetch the low byte of the player's Y position on the map (PlayerMapPositionY) and keep it in D.
26003 LD D,A
Check if the player has moved.
26004 AND A Reset the carry flag.
26005 PUSH HL Stash HL on the stack.
26006 SBC HL,DE Compare the new player position with the position used last time.
26008 POP HL Restore HL from the stack.
26009 RET Z Return if the player has not moved.
26010 PUSH DE Stash the new player position on the stack.
26011 LD IX,26109 Point IX at the first terrain dot (TerrainDots).
26015 LD B,16 Set the dot counter to 16.
UpdateTerrainDots_Loop 26017 PUSH BC Stash the dot counter on the stack.
26018 CALL UpdateTerrainDot Update the dot using UpdateTerrainDot.
26021 INC IX Point IX at the next dot.
26023 INC IX
26025 POP BC Restore the dot counter from the stack.
26026 DJNZ UpdateTerrainDots_Loop Decrease the dot counter by one and loop back to UpdateTerrainDots_Loop until all 16 dots have been updated.
26028 POP HL Restore the new player position from the stack.
26029 LD (24116),HL Write HL to PlayerWorldPosition.
26032 RET Return.
Prev: 25943 Up: Map Next: 26033