Prev: 25992 Up: Map Next: 26109
26033: Update Terrain Dot
Used by the routine at UpdateTerrainDots.
Erases a terrain dot if it has been drawn, then draws it at its new position if that is inside the play area. The attribute of the cell containing the dot is also set. A dot is drawn as a 2 by 2 block of pixels.
Input
D Low byte of the player Y map position
E Low byte of the player X map position (flipped)
IX Terrain dot (an entry in TerrainDots)
UpdateTerrainDot 26033 LD BC,514 Set the size of a dot (0514).
26036 BIT 0,(IX+0) If bit 0 of the X position is set (the dot has been drawn) then call HandlerTerrainDots to erase it.
26040 CALL NZ,HandlerTerrainDots
Work out the X position of the dot on the screen.
26043 LD A,(IX+0) Fetch the X position of the dot.
26046 AND %11111110 Keep only bits 1-7.
26048 NEG Negate it, as the dots move the opposite way to the car.
26050 ADD A,E Add the player's X position to give the X position of the dot on the screen.
26051 CP 72 Return if this is before the left edge of the play area (less than 72).
26053 RET C
26054 CP 248 Return if this is after the right edge of the play area (248 or more).
26056 RET NC
26057 LD L,A Set the X position on the screen in L.
Work out the Y position of the dot on the screen.
26058 LD A,D Fetch the player's Y position.
26059 SUB (IX+1) Take the Y position of the dot away to give the Y position on the screen.
26062 CP 8 Return if this is above the top of the play area (less than 8).
26064 RET C
26065 CP 184 Return if this is below the bottom of the play area (184 or more).
26067 RET NC
26068 LD H,A Set the Y position on the screen in H.
Draw the dot.
26069 SET 0,(IX+0) Set bit 0 of the X position to show that the dot has been drawn.
26073 LD BC,514 BC=514 (the size of a dot).
26076 PUSH HL Stash the pixel co-ordinates on the stack.
26077 CALL SetPixels Call SetPixels.
26080 POP HL Restore the pixel co-ordinates from the stack.
26081 PUSH DE Stash DE on the stack.
26082 CALL AttributeAddress Find the attribute address of the cell using AttributeAddress.
26085 POP DE Restore DE from the stack.
Set the attribute of the cell. At night this is the background attribute with white ink, so the dot can be seen. In the day it is the background attribute.
26086 LD A,(24131) Jump to UpdateTerrainDot_Day if Flag_DayNight is zero.
26089 AND A
26090 JR Z,UpdateTerrainDot_Day
26092 LD A,(24132) Fetch the background attribute (Background_Attribute).
26095 OR %00000111 Set bits 0-2, which gives white ink so the dot can be seen.
UpdateTerrainDot_Apply 26097 LD C,A Keep the new attribute in C.
26098 LD A,(HL) Fetch the current attribute of the cell.
26099 CP 118 Return if the attribute is already 118.
26101 RET Z
26102 LD (HL),C Set the attribute of the cell.
26103 RET Return.
UpdateTerrainDot_Day 26104 LD A,(24132) Fetch the background attribute (Background_Attribute).
26107 JR UpdateTerrainDot_Apply Jump to UpdateTerrainDot_Apply.
Prev: 25992 Up: Map Next: 26109