Prev: D356 Up: Map Next: D3C2
D372: Draw a building's walls
Used by the routine at DRAW_CELLS.
For a cell behind the knight -- the five the drawing order (DRAW_CELLS) draws walls for, one less in U or one more in V -- the building on it is drawn as two walls standing on its near edges: the definition for the cell's type and the view (BUILDING_TABLE, type times two plus VIEW) gives each face eight columns of a lower and an upper tile, and DRAW_WALL_COLUMN draws each column from the cell's corner (PROJECT_CELL) rightwards, down the screen along the first face and then, mirrored, up it along the second.
Walls are drawn nearest first among themselves, and each claims the screen columns it covers (COLUMNS_DRAWN): a tile is written over what is under it, and a wall and its colour reach from its bottom to the top of the play area, so nothing behind it in the same column could show. A wall further back only fills the columns still unclaimed, and as soon as all sixteen are claimed the routine stops. The drawing order puts the things in an open cell after the walls that stand behind it and before those in front of it, which cover them.
Input
HL the cell, as the drawing order sees it
DRAW_WALLS D372 CALL LOOK_UP_CELL The cell's type (LOOK_UP_CELL); open ground: nothing
D375 RET Z
D376 LD (CELL_TYPE),A Kept for the colour (COLOUR_WALL)
D379 ADD A,A IY = the building definition: the type times two, plus 1 turned round
D37A LD HL,VIEW
D37D OR (HL)
D37E LD BC,BUILDING_TABLE
D381 CALL TABLE_WORD
D384 PUSH HL
D385 POP IY
D387 CALL PROJECT_CELL DRAW_X and DRAW_Y = the cell's corner on the screen
D38A XOR A The first face, unmirrored: eight columns
D38B LD (DRAW_PASS),A
D38E LD B,$08
DRAW_WALLS_0 D390 CALL DRAW_WALL_COLUMN A column; with every screen column claimed, stop
D393 LD HL,(COLUMNS_DRAWN)
D396 LD A,L
D397 AND H
D398 CPL
D399 AND A
D39A RET Z
D39B CALL STEP_RIGHT_DOWN Right and down the screen to the next
D39E DJNZ DRAW_WALLS_0
D3A0 LD HL,(DRAW_Y) Up 8 lines for the second face, which slopes the other way
D3A3 LD DE,$0008
D3A6 ADD HL,DE
D3A7 LD (DRAW_Y),HL
D3AA LD A,$01 Mirrored: eight columns
D3AC LD (DRAW_PASS),A
D3AF LD B,$08
DRAW_WALLS_1 D3B1 CALL DRAW_WALL_COLUMN The same, rightwards and up
D3B4 LD HL,(COLUMNS_DRAWN)
D3B7 LD A,L
D3B8 AND H
D3B9 CPL
D3BA AND A
D3BB RET Z
D3BC CALL STEP_RIGHT_UP
D3BF DJNZ DRAW_WALLS_1
D3C1 RET
Prev: D356 Up: Map Next: D3C2