![]() |
Routines |
| Prev: C54B | Up: Map | Next: C5E9 |
|
Used by the routine at DrawCellWithWalls.
Draws two wall tiles, one above the other, for a step along the edge of a cell. A bit in ColumnFlags is set to record that the column has a wall in it, and if it already has one the step is skipped. The horizontal position in ScreenHorizontalPosition chooses the bit, and is written into the BIT instruction at DrawWallStrips_Test and the SET instruction at C5BF. The lower tile is drawn at ScreenVerticalPosition by DrawWallStrip, and the upper tile 40 above it. The step is skipped if either position is off the screen. It always moves on to the next two tiles of the list.
|
||||||||||
|
Return unless the column is on the screen.
|
||||||||||
| DrawWallStrips | C59B | LD HL,($A24E) | Fetch ScreenHorizontalPosition. | |||||||
| C59E | LD A,H | Jump to DrawWallStrips_Skip if it is off the screen. | ||||||||
| C59F | AND A | |||||||||
| C5A0 | JR NZ,DrawWallStrips_Skip | |||||||||
|
Keep the position and change the BIT and SET instructions.
|
||||||||||
| C5A2 | LD A,L | Keep the horizontal position in E. | ||||||||
| C5A3 | LD E,A | |||||||||
| C5A4 | RRCA | Move the bits which say which sixteen pixels it is in... | ||||||||
| C5A5 | AND %00111000 | ...to make the number of a bit... | ||||||||
| C5A7 | OR %01000110 | ...in the second byte of a BIT instruction. | ||||||||
| C5A9 | LD ($C5BC),A | Store it as the second byte of the BIT instruction at DrawWallStrips_Test. | ||||||||
| C5AC | OR %10000000 | Change it to the second byte of a SET instruction. | ||||||||
| C5AE | LD ($C5C0),A | Store it as the second byte of the SET instruction at C5C0. | ||||||||
|
Choose the byte of ColumnFlags.
|
||||||||||
| C5B1 | LD A,L | Fetch the horizontal position again. | ||||||||
| C5B2 | RLCA | Move the top bit of the horizontal position... | ||||||||
| C5B3 | AND %00000001 | ...into a single bit. | ||||||||
| C5B5 | LD HL,$A248 | Point HL at ColumnFlags. | ||||||||
| C5B8 | JR Z,DrawWallStrips_Test | Jump to DrawWallStrips_Test if the position is in the first half of the screen. | ||||||||
| C5BA | INC HL | Point HL at the second byte of the flags. | ||||||||
|
Test and set the flag for this column.
|
||||||||||
| DrawWallStrips_Test | C5BB | BIT 0,(HL) | Jump to DrawWallStrips_Skip if there is already a wall there. | |||||||
| C5BD | JR NZ,DrawWallStrips_Skip | |||||||||
| C5BF | SET 0,(HL) | Set the bit. | ||||||||
|
Draw the lower tile.
|
||||||||||
| C5C1 | LD HL,($A250) | Fetch ScreenVerticalPosition. | ||||||||
| C5C4 | LD A,H | Jump to DrawWallStrips_Skip if it is off the screen. | ||||||||
| C5C5 | AND A | |||||||||
| C5C6 | JR NZ,DrawWallStrips_Skip | |||||||||
| C5C8 | LD D,L | Keep the low byte of the vertical position in D. | ||||||||
| C5C9 | PUSH BC | Stash the count of steps and the position on the stack. | ||||||||
| C5CA | PUSH DE | |||||||||
| C5CB | CALL DrawWallStrip | Call DrawWallStrip. | ||||||||
| C5CE | POP DE | Restore the position. | ||||||||
| C5CF | INC IY | Move on to the next tile of the list. | ||||||||
|
Draw the upper tile.
|
||||||||||
| C5D1 | LD HL,($A250) | Fetch ScreenVerticalPosition. | ||||||||
| C5D4 | LD BC,$0040 | Set BC to 40. | ||||||||
| C5D7 | ADD HL,BC | Move up by that much. | ||||||||
| C5D8 | LD A,H | Jump to DrawWallStrips_RestoreCount if it is off the screen. | ||||||||
| C5D9 | AND A | |||||||||
| C5DA | JR NZ,DrawWallStrips_RestoreCount | |||||||||
| C5DC | LD D,L | Keep the low byte of the vertical position in D. | ||||||||
| C5DD | CALL DrawWallStrip | Call DrawWallStrip. | ||||||||
|
Restore the count and move on.
|
||||||||||
| DrawWallStrips_RestoreCount | C5E0 | POP BC | Restore the count of steps. | |||||||
| C5E1 | INC IY | Move on to the next tile of the list. | ||||||||
| C5E3 | RET | Return. | ||||||||
|
There is nothing to draw, so skip both of the tiles.
|
||||||||||
| DrawWallStrips_Skip | C5E4 | INC IY | Move on past the two tiles of the list. | |||||||
| C5E6 | INC IY | |||||||||
| C5E8 | RET | Return. | ||||||||
|
View the equivalent code in;
|
||||||||||
| Prev: C54B | Up: Map | Next: C5E9 |