Prev: D372 Up: Map Next: D415
D3C2: Draw one column of a wall, unless a nearer wall has it
Used by the routine at DRAW_WALLS.
The screen is taken as sixteen columns 16 pixels wide, x / 16, a bit each in COLUMNS_DRAWN (bit 7 of x picking the byte). Every tile column in a turn lies at the same x within its 16 pixels, since the cells' corners are 128 pixels apart, so a column of wall and a screen column always coincide. The column's bit is patched into the BIT at TEST_COLUMN and the SET at CLAIM_COLUMN. DRAW_CELLS starts each turn with the first column (left of the buffer) and the last three (right of it) already claimed, so walls are clipped at the sides here.
An unclaimed column is claimed, then drawn: the lower tile with its bottom row at DRAW_Y (PUT_TILE), its colour up to the top (COLOUR_WALL), and the upper tile 64 lines above it. A column off the screen's 0-255 range in x or y is skipped, and IY moved past its two tiles either way.
Input
IY the column's pair of tiles in the building definition
Output
IY the next column's
DRAW_WALL_COLUMN D3C2 LD HL,(DRAW_X) x off the 0-255 range: skip it
D3C5 LD A,H
D3C6 AND A
D3C7 JR NZ,DRAW_WALL_COLUMN_1
D3C9 LD A,L The column's bit, bits 4-6 of x, patched into the BIT and the SET below
D3CA LD E,A
D3CB RRCA
D3CC AND $38
D3CE OR $46
D3D0 LD ($D3E3),A
D3D3 OR $80
D3D5 LD ($D3E7),A
D3D8 LD A,L HL = COLUMNS_DRAWN, or its second byte for x of 128 up
D3D9 RLCA
D3DA AND $01
D3DC LD HL,COLUMNS_DRAWN
D3DF JR Z,TEST_COLUMN
D3E1 INC HL
TEST_COLUMN D3E2 BIT 0,(HL) Patched BIT: claimed already by a nearer wall, skip it
D3E4 JR NZ,DRAW_WALL_COLUMN_1
CLAIM_COLUMN D3E6 SET 0,(HL) Patched SET: claim it (before y is looked at)
D3E8 LD HL,(DRAW_Y) y off the 0-255 range: skip it; D = y, E = x
D3EB LD A,H
D3EC AND A
D3ED JR NZ,DRAW_WALL_COLUMN_1
D3EF LD D,L
D3F0 PUSH BC The lower tile (PUT_TILE)
D3F1 PUSH DE
D3F2 CALL PUT_TILE
D3F5 POP DE The wall's colour (COLOUR_WALL)
D3F6 PUSH DE
D3F7 CALL COLOUR_WALL
D3FA POP DE The upper tile...
D3FB INC IY
D3FD LD HL,(DRAW_Y) ...64 lines up, if that is still in range
D400 LD BC,$0040
D403 ADD HL,BC
D404 LD A,H
D405 AND A
D406 JR NZ,DRAW_WALL_COLUMN_0
D408 LD D,L Draw it
D409 CALL PUT_TILE
DRAW_WALL_COLUMN_0 D40C POP BC Past the upper tile
D40D INC IY
D40F RET
DRAW_WALL_COLUMN_1 D410 INC IY Skipped: past both tiles
D412 INC IY
D414 RET
Prev: D372 Up: Map Next: D415