Prev: 54130 Up: Map Next: 54293
54210: 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 54246. The lower strip is drawn at ScreenYPosition by DrawWallStrip, the column is coloured by ColourWallColumn, and the upper strip 64 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 54210 LD HL,(48054) Fetch ScreenXPosition.
54213 LD A,H Jump to DrawWallStrips_Skip if it is off the screen.
54214 AND A
54215 JR NZ,DrawWallStrips_Skip
Keep the position and change the BIT and SET instructions.
54217 LD A,L Keep the horizontal position in E.
54218 LD E,A
54219 RRCA Move the bits which say which sixteen pixels it is in...
54220 AND %00111000 ...to make the number of a bit...
54222 OR %01000110 ...in the second byte of a BIT instruction.
54224 LD (54243),A Store it as the second byte of the BIT instruction at DrawWallStrips_Test.
54227 OR %10000000 Change it to the second byte of a SET instruction.
54229 LD (54247),A Store it as the second byte of the SET instruction at 54247.
Choose the byte of DrawnColumns.
54232 LD A,L Fetch the horizontal position again.
54233 RLCA Move the top bit of the horizontal position...
54234 AND %00000001 ...into a single bit.
54236 LD HL,48059 Point HL at DrawnColumns.
54239 JR Z,DrawWallStrips_Test Jump to DrawWallStrips_Test if the position is in the first half of the screen.
54241 INC HL Point HL at the second byte of the flags.
Test and set the flag for this column.
DrawWallStrips_Test 54242 BIT 0,(HL) Jump to DrawWallStrips_Skip if there is already a wall there.
54244 JR NZ,DrawWallStrips_Skip
54246 SET 0,(HL) Set the bit.
Draw the lower strip and colour the column.
54248 LD HL,(48056) Fetch ScreenYPosition.
54251 LD A,H Jump to DrawWallStrips_Skip if it is off the screen.
54252 AND A
54253 JR NZ,DrawWallStrips_Skip
54255 LD D,L Keep the low byte of the vertical position in D.
54256 PUSH BC Stash the count of steps and the position on the stack.
54257 PUSH DE
54258 CALL DrawWallStrip Call DrawWallStrip.
54261 POP DE Restore the position from the stack and stash it again.
54262 PUSH DE
54263 CALL ColourWallColumn Call ColourWallColumn.
54266 POP DE Restore the position from the stack.
54267 INC IY Move on to the next strip of the list.
Draw the upper strip.
54269 LD HL,(48056) Fetch ScreenYPosition.
54272 LD BC,64 Set BC to 64.
54275 ADD HL,BC Move up by that much.
54276 LD A,H Jump to DrawWallStrips_Done if it is off the screen.
54277 AND A
54278 JR NZ,DrawWallStrips_Done
54280 LD D,L Keep the low byte of the vertical position in D.
54281 CALL DrawWallStrip Call DrawWallStrip.
Restore the count and move on.
DrawWallStrips_Done 54284 POP BC Restore the count of steps from the stack.
54285 INC IY Move on to the next strip of the list.
54287 RET Return.
There is nothing to draw, so skip both of the strips.
DrawWallStrips_Skip 54288 INC IY Move on past the two strips of the list.
54290 INC IY
54292 RET Return.
View the equivalent code in;
Prev: 54130 Up: Map Next: 54293