Prev: 693C Up: Map Next: 6980
6949: Plot Map Points
Used by the routine at CreateWindow.
Plots a dot on the map in the sidebar for every entry in the map points table at MapPoints, except place names and collected cups (which are marked with 60). One pixel on the map is 80 map units.
Before After
plot-map-before plot-map-after
PlotMapPoints 6949 LD BC,$7811 Point BC at the map points (MapPoints).
PlotMapPoints_Loop 694C LD HL,$4708 HL=4708 (pixel co-ordinates of the bottom left of the map: H is the Y position and L is the X position).
Handle the X co-ordinate.
694F LD A,(BC) Fetch the X position of the map point.
6950 INC BC Increment the map pointer in BC by one.
Scale the X co-ordinate for the smaller map display output.
6951 SRL A Divide the X position by 04 to scale it for the map.
6953 SRL A
6955 LD E,A Keep the scaled X position in E.
Handle the Y co-ordinate.
6956 LD A,(BC) Fetch the Y position of the map point.
6957 INC BC Increment the map pointer in BC by one.
Scale the Y co-ordinate for the smaller map display output.
6958 SRL A Divide the Y position by 08 to scale it for the map.
695A SRL A
695C SRL A
695E LD D,A Keep the scaled Y position in D.
Calculate the pixel co-ordinates of our currently processed map point.
695F LD A,H Take the scaled Y position away from the Y pixel position, as the map counts up from the bottom.
6960 SUB D
6961 LD H,A
6962 LD A,L Add the scaled X position to the X pixel position.
6963 ADD A,E
6964 LD L,A
Handle the map point "type" - place names are excluded.
6965 LD A,(BC) Fetch the sprite ID of the map point.
6966 INC BC Increment the map pointer in BC by one. Now pointing to the next record.
6967 PUSH BC Stash the pointer to the next map point on the stack.
6968 LD BC,$0101 BC=0101 (a single pixel, used in SetPixels).
Skip place names - they don't show a marker on the map.
696B BIT 6,A If bit 6 is set then this is a place name so skip and jump to PlotMapPoints_Continue.
696D JR Z,PlotMapPoints_Continue
696F CP $60 If A is 60 (a collected cup), jump to PlotMapPoints_Continue.
6971 JR Z,PlotMapPoints_Continue
6973 CALL SetPixels Plot the point using SetPixels.
Check if finished. The stack contains the start of the next record, or the first byte past the end of the map points.
PlotMapPoints_Continue 6976 POP BC Restore the pointer to the next map point from the stack.
6977 LD HL,$7CD6 Point HL at the end of the map points (Sprite_Car_1, one byte past the end of MapPoints).
697A AND A Reset the carry flag.
697B SBC HL,BC Compare the map pointer with the end of the map points.
697D JR NZ,PlotMapPoints_Loop If the end of the map points has not been reached then jump to PlotMapPoints_Loop.
697F RET Return.
Prev: 693C Up: Map Next: 6980