Prev: D372 Up: Map Next: D415
D3C2: Draw Wall Strips
Used by the routine at DrawCellWithWalls.
Draws two wall strips, one above the other, for a step along the edge of a cell. A bit in DrawnColumns 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 ScreenXPosition chooses the bit, and is written into the BIT instruction at DrawWallStrips_Test and the SET instruction at D3E6. The lower strip is drawn at ScreenYPosition by DrawWallStrip, the column is coloured by ColourWallColumn, and the upper strip 40 above it. The step is skipped if either position is off the screen. It always moves on to the next two strips of the list.
Input
BC The count of steps in B
IY The address of the first strip of the step in its list
Return unless the column is on the screen.
DrawWallStrips D3C2 LD HL,($BBB6) Fetch ScreenXPosition.
D3C5 LD A,H Jump to DrawWallStrips_Skip if it is off the screen.
D3C6 AND A
D3C7 JR NZ,DrawWallStrips_Skip
Keep the position and change the BIT and SET instructions.
D3C9 LD A,L Keep the horizontal position in E.
D3CA LD E,A
D3CB RRCA Move the bits which say which sixteen pixels it is in...
D3CC AND %00111000 ...to make the number of a bit...
D3CE OR %01000110 ...in the second byte of a BIT instruction.
D3D0 LD ($D3E3),A Store it as the second byte of the BIT instruction at DrawWallStrips_Test.
D3D3 OR %10000000 Change it to the second byte of a SET instruction.
D3D5 LD ($D3E7),A Store it as the second byte of the SET instruction at D3E7.
Choose the byte of DrawnColumns.
D3D8 LD A,L Fetch the horizontal position again.
D3D9 RLCA Move the top bit of the horizontal position...
D3DA AND %00000001 ...into a single bit.
D3DC LD HL,$BBBB Point HL at DrawnColumns.
D3DF JR Z,DrawWallStrips_Test Jump to DrawWallStrips_Test if the position is in the first half of the screen.
D3E1 INC HL Point HL at the second byte of the flags.
Test and set the flag for this column.
DrawWallStrips_Test D3E2 BIT 0,(HL) Jump to DrawWallStrips_Skip if there is already a wall there.
D3E4 JR NZ,DrawWallStrips_Skip
D3E6 SET 0,(HL) Set the bit.
Draw the lower strip and colour the column.
D3E8 LD HL,($BBB8) Fetch ScreenYPosition.
D3EB LD A,H Jump to DrawWallStrips_Skip if it is off the screen.
D3EC AND A
D3ED JR NZ,DrawWallStrips_Skip
D3EF LD D,L Keep the low byte of the vertical position in D.
D3F0 PUSH BC Stash the count of steps and the position on the stack.
D3F1 PUSH DE
D3F2 CALL DrawWallStrip Call DrawWallStrip.
D3F5 POP DE Restore the position from the stack and stash it again.
D3F6 PUSH DE
D3F7 CALL ColourWallColumn Call ColourWallColumn.
D3FA POP DE Restore the position from the stack.
D3FB INC IY Move on to the next strip of the list.
Draw the upper strip.
D3FD LD HL,($BBB8) Fetch ScreenYPosition.
D400 LD BC,$0040 Set BC to 40.
D403 ADD HL,BC Move up by that much.
D404 LD A,H Jump to DrawWallStrips_Done if it is off the screen.
D405 AND A
D406 JR NZ,DrawWallStrips_Done
D408 LD D,L Keep the low byte of the vertical position in D.
D409 CALL DrawWallStrip Call DrawWallStrip.
Restore the count and move on.
DrawWallStrips_Done D40C POP BC Restore the count of steps from the stack.
D40D INC IY Move on to the next strip of the list.
D40F RET Return.
There is nothing to draw, so skip both of the strips.
DrawWallStrips_Skip D410 INC IY Move on past the two strips of the list.
D412 INC IY
D414 RET Return.
View the equivalent code in;
Prev: D372 Up: Map Next: D415