Prev: 50507 Up: Map Next: 50665
50587: Draw Wall Strips
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 50623. The lower tile is drawn at ScreenVerticalPosition by DrawWallStrip, and the upper tile 64 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.
Input
BC The count of steps in B
IY The address of the first tile of the step in its list
Return unless the column is on the screen.
DrawWallStrips 50587 LD HL,(41550) Fetch ScreenHorizontalPosition.
50590 LD A,H Jump to DrawWallStrips_Skip if it is off the screen.
50591 AND A
50592 JR NZ,DrawWallStrips_Skip
Keep the position and change the BIT and SET instructions.
50594 LD A,L Keep the horizontal position in E.
50595 LD E,A
50596 RRCA Move the bits which say which sixteen pixels it is in...
50597 AND %00111000 ...to make the number of a bit...
50599 OR %01000110 ...in the second byte of a BIT instruction.
50601 LD (50620),A Store it as the second byte of the BIT instruction at DrawWallStrips_Test.
50604 OR %10000000 Change it to the second byte of a SET instruction.
50606 LD (50624),A Store it as the second byte of the SET instruction at 50624.
Choose the byte of ColumnFlags.
50609 LD A,L Fetch the horizontal position again.
50610 RLCA Move the top bit of the horizontal position...
50611 AND %00000001 ...into a single bit.
50613 LD HL,41544 Point HL at ColumnFlags.
50616 JR Z,DrawWallStrips_Test Jump to DrawWallStrips_Test if the position is in the first half of the screen.
50618 INC HL Point HL at the second byte of the flags.
Test and set the flag for this column.
DrawWallStrips_Test 50619 BIT 0,(HL) Jump to DrawWallStrips_Skip if there is already a wall there.
50621 JR NZ,DrawWallStrips_Skip
50623 SET 0,(HL) Set the bit.
Draw the lower tile.
50625 LD HL,(41552) Fetch ScreenVerticalPosition.
50628 LD A,H Jump to DrawWallStrips_Skip if it is off the screen.
50629 AND A
50630 JR NZ,DrawWallStrips_Skip
50632 LD D,L Keep the low byte of the vertical position in D.
50633 PUSH BC Stash the count of steps and the position on the stack.
50634 PUSH DE
50635 CALL DrawWallStrip Call DrawWallStrip.
50638 POP DE Restore the position.
50639 INC IY Move on to the next tile of the list.
Draw the upper tile.
50641 LD HL,(41552) Fetch ScreenVerticalPosition.
50644 LD BC,64 Set BC to 64.
50647 ADD HL,BC Move up by that much.
50648 LD A,H Jump to DrawWallStrips_RestoreCount if it is off the screen.
50649 AND A
50650 JR NZ,DrawWallStrips_RestoreCount
50652 LD D,L Keep the low byte of the vertical position in D.
50653 CALL DrawWallStrip Call DrawWallStrip.
Restore the count and move on.
DrawWallStrips_RestoreCount 50656 POP BC Restore the count of steps.
50657 INC IY Move on to the next tile of the list.
50659 RET Return.
There is nothing to draw, so skip both of the tiles.
DrawWallStrips_Skip 50660 INC IY Move on past the two tiles of the list.
50662 INC IY
50664 RET Return.
View the equivalent code in;
Prev: 50507 Up: Map Next: 50665