Prev: C383 Up: Map Next: C3EF
C392: Draw Cell
Used by the routine at DrawTown.
Draws the outline of a cell of the town, using the lists of tiles in the table at TileListPointers. There are two lists for each kind of cell: one for the edges at the bottom, drawn from the left corner, and one for the edges at the top, drawn from the right corner. Each list is drawn as two runs of eight tiles which are 16 pixels wide, using the first byte of each pair of bytes in the list, in the shape of a V for the bottom and an upside-down V for the top. When the view is rotated the two lists change places.
Input
L The column
H The row
Find the code of the cell.
DrawCell C392 CALL GetMapCell Call GetMapCell.
C395 RET Z Return if there is nothing in the cell.
Double the code to make the number of its first list.
C396 ADD A,A Double the code.
C397 PUSH AF Stash it on the stack.
Find the position of the cell on the screen.
C398 CALL ProjectCell Call ProjectCell.
C39B POP AF Restore the list number from the stack, leaving it there.
C39C PUSH AF
Draw the second list at the bottom when the view is rotated.
C39D LD HL,$A268 Jump to DrawCell_Rotated if the view is rotated.
C3A0 BIT 0,(HL)
C3A2 JR NZ,DrawCell_Rotated
Draw the edges at the bottom.
C3A4 CALL DrawStripsLeftToRight Call DrawStripsLeftToRight.
C3A7 POP AF Restore the list number from the stack.
C3A8 OR %00000001 Use the second list.
Draw the edges at the top, starting from the right corner of the cell.
DrawCell_Top C3AA LD HL,($A24E) Move ScreenHorizontalPosition sixteen pixels to the left.
C3AD LD DE,$FFF0
C3B0 ADD HL,DE
C3B1 LD ($A24E),HL
C3B4 LD BC,$626C Point BC at TileListPointers.
Find the address of the list.
C3B7 CALL GetTableEntry Call GetTableEntry.
C3BA PUSH HL Copy the list address to IY (using the stack).
C3BB POP IY
Draw tiles as they are.
C3BD XOR A Write 00 to *FlipFlag.
C3BE LD ($A252),A
C3C1 LD BC,$0801 Set a count of eight tiles, and swap each for its pair.
Draw eight tiles going up and to the left.
DrawCell_TopLeft C3C4 CALL DrawStrip Call DrawStrip.
C3C7 CALL StepUpLeft Call StepUpLeft.
C3CA DJNZ DrawCell_TopLeft Jump to DrawCell_TopLeft if there are any left.
Move down by eight pixels to start the second run.
C3CC LD HL,($A250) Move ScreenVerticalPosition down by eight pixels.
C3CF LD DE,$FFF8
C3D2 ADD HL,DE
C3D3 LD ($A250),HL
Draw the rest of the tiles flipped.
C3D6 LD A,$01 Write 01 to *FlipFlag.
C3D8 LD ($A252),A
C3DB LD BC,$0801 Set a count of eight tiles, and swap each for its pair.
Draw eight tiles going down and to the left.
DrawCell_TopRight C3DE CALL DrawStrip Call DrawStrip.
C3E1 CALL StepDownLeft Call StepDownLeft.
C3E4 DJNZ DrawCell_TopRight Jump to DrawCell_TopRight if there are any left.
C3E6 RET Return.
The view is rotated, so draw the second list at the bottom and the first at the top.
DrawCell_Rotated C3E7 OR %00000001 Use the second list.
Draw the edges at the bottom.
C3E9 CALL DrawStripsLeftToRight Call DrawStripsLeftToRight.
C3EC POP AF Restore the list number from the stack.
Draw the edges at the top.
C3ED JR DrawCell_Top Jump to DrawCell_Top.
View the equivalent code in;
Prev: C383 Up: Map Next: C3EF