![]() |
Routines |
| Prev: 6588 | Up: Map | Next: 65FD |
|
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 02 by 02 block of pixels.
|
||||||||||||
| UpdateTerrainDot | 65B1 | LD BC,$0202 | Set the size of a dot (0202). | |||||||||
| 65B4 | BIT 0,(IX+$00) | If bit 0 of the X position is set (the dot has been drawn) then call HandlerTerrainDots to erase it. | ||||||||||
| 65B8 | CALL NZ,HandlerTerrainDots | |||||||||||
|
Work out the X position of the dot on the screen.
|
||||||||||||
| 65BB | LD A,(IX+$00) | Fetch the X position of the dot. | ||||||||||
| 65BE | AND %11111110 | Keep only bits 1-7. | ||||||||||
| 65C0 | NEG | Negate it, as the dots move the opposite way to the car. | ||||||||||
| 65C2 | ADD A,E | Add the player's X position to give the X position of the dot on the screen. | ||||||||||
| 65C3 | CP $48 | Return if this is before the left edge of the play area (less than 48). | ||||||||||
| 65C5 | RET C | |||||||||||
| 65C6 | CP $F8 | Return if this is after the right edge of the play area (F8 or more). | ||||||||||
| 65C8 | RET NC | |||||||||||
| 65C9 | LD L,A | Set the X position on the screen in L. | ||||||||||
|
Work out the Y position of the dot on the screen.
|
||||||||||||
| 65CA | LD A,D | Fetch the player's Y position. | ||||||||||
| 65CB | SUB (IX+$01) | Take the Y position of the dot away to give the Y position on the screen. | ||||||||||
| 65CE | CP $08 | Return if this is above the top of the play area (less than 08). | ||||||||||
| 65D0 | RET C | |||||||||||
| 65D1 | CP $B8 | Return if this is below the bottom of the play area (B8 or more). | ||||||||||
| 65D3 | RET NC | |||||||||||
| 65D4 | LD H,A | Set the Y position on the screen in H. | ||||||||||
|
Draw the dot.
|
||||||||||||
| 65D5 | SET 0,(IX+$00) | Set bit 0 of the X position to show that the dot has been drawn. | ||||||||||
| 65D9 | LD BC,$0202 | BC=0202 (the size of a dot). | ||||||||||
| 65DC | PUSH HL | Stash the pixel co-ordinates on the stack. | ||||||||||
| 65DD | CALL SetPixels | Call SetPixels. | ||||||||||
| 65E0 | POP HL | Restore the pixel co-ordinates from the stack. | ||||||||||
| 65E1 | PUSH DE | Stash DE on the stack. | ||||||||||
| 65E2 | CALL AttributeAddress | Find the attribute address of the cell using AttributeAddress. | ||||||||||
| 65E5 | 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.
|
||||||||||||
| 65E6 | LD A,($5E43) | Jump to UpdateTerrainDot_Day if Flag_DayNight is zero. | ||||||||||
| 65E9 | AND A | |||||||||||
| 65EA | JR Z,UpdateTerrainDot_Day | |||||||||||
| 65EC | LD A,($5E44) | Fetch the background attribute (Background_Attribute). | ||||||||||
| 65EF | OR %00000111 | Set bits 0-2, which gives white ink so the dot can be seen. | ||||||||||
| UpdateTerrainDot_Apply | 65F1 | LD C,A | Keep the new attribute in C. | |||||||||
| 65F2 | LD A,(HL) | Fetch the current attribute of the cell. | ||||||||||
| 65F3 | CP $76 | Return if the attribute is already 76. | ||||||||||
| 65F5 | RET Z | |||||||||||
| 65F6 | LD (HL),C | Set the attribute of the cell. | ||||||||||
| 65F7 | RET | Return. | ||||||||||
| UpdateTerrainDot_Day | 65F8 | LD A,($5E44) | Fetch the background attribute (Background_Attribute). | |||||||||
| 65FB | JR UpdateTerrainDot_Apply | Jump to UpdateTerrainDot_Apply. | ||||||||||
| Prev: 6588 | Up: Map | Next: 65FD |