![]() |
Routines |
| Prev: 6A15 | Up: Map | Next: 6A73 |
|
Used by the routine at HandlerPlayer.
Draws the car in the centre of the play area, using the frame from PlayerSpriteTable which matches the current direction.
|
||||||||||
|
||||||||||
| DrawPlayer | 6A39 | LD HL,($5E10) | Fetch the direction the car is facing (Player_Direction). | |||||||
| 6A3C | LD BC,$0020 | BC=0020 (half of a step between two of the 10 directions, so the direction is rounded to the nearest). | ||||||||
| 6A3F | ADD HL,BC | HL=HL + BC. | ||||||||
| 6A40 | LD A,H | A=H. | ||||||||
| 6A41 | AND %00000011 | Keep only bits 0-1. | ||||||||
|
Shift the top two bits of L into the bottom of A to make a direction between 00 and 0F.
|
||||||||||
| 6A43 | RL L | Rotate L left and shift its top bit into A. | ||||||||
| 6A45 | RLA | |||||||||
| 6A46 | RL L | |||||||||
| 6A48 | RLA | |||||||||
| 6A49 | SLA A | Double A to use it as an index into a table of words. | ||||||||
| 6A4B | LD HL,$7F24 | Point HL at the table of player sprites (PlayerSpriteTable). | ||||||||
| 6A4E | LD C,A | Create an offset in BC. | ||||||||
| 6A4F | LD B,$00 | |||||||||
| 6A51 | ADD HL,BC | HL=PlayerSpriteTable + offset. | ||||||||
| 6A52 | LD E,(HL) | Fetch the pointer to the sprite of the player for this direction into DE. | ||||||||
| 6A53 | INC HL | |||||||||
| 6A54 | LD D,(HL) | |||||||||
|
The player is drawn statically in the centre of the play area.
|
||||||||||
| 6A55 | LD HL,$4F93 | Set the screen address to draw the player at, the centre of the play area (4F93). | ||||||||
|
The player sprite is 02 bytes in width.
|
||||||||||
| 6A58 | LD A,$02 | Write 02 to WidthCounter. | ||||||||
| 6A5A | LD ($5E2C),A | |||||||||
| 6A5D | LD A,(DE) | Fetch the height of the sprite. | ||||||||
| 6A5E | INC DE | Increment DE by one to point to the sprite data. | ||||||||
| 6A5F | LD C,A | Keep the height of the sprite in C as the row counter. | ||||||||
| DrawPlayer_NextRow | 6A60 | LD A,($5E2C) | Set the byte counter to the width of the sprite (WidthCounter). | |||||||
| 6A63 | LD B,A | |||||||||
| 6A64 | PUSH HL | Stash the screen address of the start of the row on the stack. | ||||||||
| DrawPlayer_NextCol | 6A65 | LD A,(DE) | Copy a byte from DE (the player sprite data) to HL (the screen position). | |||||||
| 6A66 | LD (HL),A | |||||||||
| 6A67 | INC DE | Move on to the next byte of sprite data. | ||||||||
| 6A68 | INC L | Move on to the next screen byte. | ||||||||
| 6A69 | DJNZ DrawPlayer_NextCol | Decrease the byte counter by one and loop back to DrawPlayer_NextCol until the row has been drawn. | ||||||||
| 6A6B | POP HL | Restore the screen address of the start of the row from the stack. | ||||||||
| 6A6C | CALL ScreenPosition1PixelAbove | Call ScreenPosition1PixelAbove to move up one pixel line. | ||||||||
| 6A6F | DEC C | Decrease the row counter by one and jump to DrawPlayer_NextRow until all of the rows have been drawn. | ||||||||
| 6A70 | JR NZ,DrawPlayer_NextRow | |||||||||
| 6A72 | RET | Return. | ||||||||
| Prev: 6A15 | Up: Map | Next: 6A73 |