Prev: 50051 Up: Map Next: 50159
50066: 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 50066 CALL GetMapCell Call GetMapCell.
50069 RET Z Return if there is nothing in the cell.
Double the code to make the number of its first list.
50070 ADD A,A Double the code.
50071 PUSH AF Stash it on the stack.
Find the position of the cell on the screen.
50072 CALL ProjectCell Call ProjectCell.
50075 POP AF Restore the list number from the stack, leaving it there.
50076 PUSH AF
Draw the second list at the bottom when the view is rotated.
50077 LD HL,41576 Jump to DrawCell_Rotated if the view is rotated.
50080 BIT 0,(HL)
50082 JR NZ,DrawCell_Rotated
Draw the edges at the bottom.
50084 CALL DrawStripsLeftToRight Call DrawStripsLeftToRight.
50087 POP AF Restore the list number from the stack.
50088 OR %00000001 Use the second list.
Draw the edges at the top, starting from the right corner of the cell.
DrawCell_Top 50090 LD HL,(41550) Move ScreenHorizontalPosition sixteen pixels to the left.
50093 LD DE,65520
50096 ADD HL,DE
50097 LD (41550),HL
50100 LD BC,25196 Point BC at TileListPointers.
Find the address of the list.
50103 CALL GetTableEntry Call GetTableEntry.
50106 PUSH HL Copy the list address to IY (using the stack).
50107 POP IY
Draw tiles as they are.
50109 XOR A Write 0 to *FlipFlag.
50110 LD (41554),A
50113 LD BC,2049 Set a count of eight tiles, and swap each for its pair.
Draw eight tiles going up and to the left.
DrawCell_TopLeft 50116 CALL DrawStrip Call DrawStrip.
50119 CALL StepUpLeft Call StepUpLeft.
50122 DJNZ DrawCell_TopLeft Jump to DrawCell_TopLeft if there are any left.
Move down by eight pixels to start the second run.
50124 LD HL,(41552) Move ScreenVerticalPosition down by eight pixels.
50127 LD DE,65528
50130 ADD HL,DE
50131 LD (41552),HL
Draw the rest of the tiles flipped.
50134 LD A,1 Write 1 to *FlipFlag.
50136 LD (41554),A
50139 LD BC,2049 Set a count of eight tiles, and swap each for its pair.
Draw eight tiles going down and to the left.
DrawCell_TopRight 50142 CALL DrawStrip Call DrawStrip.
50145 CALL StepDownLeft Call StepDownLeft.
50148 DJNZ DrawCell_TopRight Jump to DrawCell_TopRight if there are any left.
50150 RET Return.
The view is rotated, so draw the second list at the bottom and the first at the top.
DrawCell_Rotated 50151 OR %00000001 Use the second list.
Draw the edges at the bottom.
50153 CALL DrawStripsLeftToRight Call DrawStripsLeftToRight.
50156 POP AF Restore the list number from the stack.
Draw the edges at the top.
50157 JR DrawCell_Top Jump to DrawCell_Top.
View the equivalent code in;
Prev: 50051 Up: Map Next: 50159