Prev: 26940 Up: Map Next: 27008
26953: 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 96). One pixel on the map is 128 map units.
Before After
plot-map-before plot-map-after
PlotMapPoints 26953 LD BC,30737 Point BC at the map points (MapPoints).
PlotMapPoints_Loop 26956 LD HL,18184 HL=18184 (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.
26959 LD A,(BC) Fetch the X position of the map point.
26960 INC BC Increment the map pointer in BC by one.
Scale the X co-ordinate for the smaller map display output.
26961 SRL A Divide the X position by 4 to scale it for the map.
26963 SRL A
26965 LD E,A Keep the scaled X position in E.
Handle the Y co-ordinate.
26966 LD A,(BC) Fetch the Y position of the map point.
26967 INC BC Increment the map pointer in BC by one.
Scale the Y co-ordinate for the smaller map display output.
26968 SRL A Divide the Y position by 8 to scale it for the map.
26970 SRL A
26972 SRL A
26974 LD D,A Keep the scaled Y position in D.
Calculate the pixel co-ordinates of our currently processed map point.
26975 LD A,H Take the scaled Y position away from the Y pixel position, as the map counts up from the bottom.
26976 SUB D
26977 LD H,A
26978 LD A,L Add the scaled X position to the X pixel position.
26979 ADD A,E
26980 LD L,A
Handle the map point "type" - place names are excluded.
26981 LD A,(BC) Fetch the sprite ID of the map point.
26982 INC BC Increment the map pointer in BC by one. Now pointing to the next record.
26983 PUSH BC Stash the pointer to the next map point on the stack.
26984 LD BC,257 BC=0257 (a single pixel, used in SetPixels).
Skip place names - they don't show a marker on the map.
26987 BIT 6,A If bit 6 is set then this is a place name so skip and jump to PlotMapPoints_Continue.
26989 JR Z,PlotMapPoints_Continue
26991 CP 96 If A is 96 (a collected cup), jump to PlotMapPoints_Continue.
26993 JR Z,PlotMapPoints_Continue
26995 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 26998 POP BC Restore the pointer to the next map point from the stack.
26999 LD HL,31958 Point HL at the end of the map points (Sprite_Car_1, one byte past the end of MapPoints).
27002 AND A Reset the carry flag.
27003 SBC HL,BC Compare the map pointer with the end of the map points.
27005 JR NZ,PlotMapPoints_Loop If the end of the map points has not been reached then jump to PlotMapPoints_Loop.
27007 RET Return.
Prev: 26940 Up: Map Next: 27008