Prev: D18E Up: Map Next: D1FA
D19D: Draw Cell
Used by the routines at DrawView and DrawCellAndObjects.
Draws a cell of the map from the two lists of strips for its tile. Each list is made of sixteen strips, which are drawn along the edge of the cell: the first list from left to right and the second list from right to left. Nothing is drawn if the cell is empty. When the view is rotated, the lists are drawn in the opposite order.
Input
L The column
H The row
Find the code of the cell.
DrawCell D19D CALL GetMapCell Call GetMapCell.
D1A0 RET Z Return if there is nothing in the cell.
Double the code to make the number of its first list.
D1A1 ADD A,A Double the code.
D1A2 PUSH AF Stash it on the stack.
Find the position of the cell on the screen.
D1A3 CALL ProjectCell Work out the position of the cell on the screen.
D1A6 POP AF Get the number of the list back, and keep it again.
D1A7 PUSH AF
Draw the second list at the bottom when the view is rotated.
D1A8 LD HL,$BBBA Jump to DrawCell_Rotated if the view is turned round.
D1AB BIT 0,(HL)
D1AD JR NZ,DrawCell_Rotated
Draw the edges at the bottom.
D1AF CALL DrawStripsLeftToRight Call DrawStripsLeftToRight.
Get the number of the list back and make it the number of the second list.
D1B2 POP AF Restore the list number from the stack.
D1B3 OR %00000001 Use the second list.
Draw the edges at the top, starting from the right corner of the cell.
DrawCell_RightToLeft D1B5 LD HL,($BBB6) Move the position back to the last strip that was drawn.
D1B8 LD DE,$FFF0
D1BB ADD HL,DE
D1BC LD ($BBB6),HL
D1BF LD BC,$62A4 Point BC at StripListTable.
Find the address of the list.
D1C2 CALL GetTableEntry Call GetTableEntry.
D1C5 PUSH HL Copy the list address to IY (using the stack).
D1C6 POP IY
Draw tiles as they are.
D1C8 XOR A Write 00 to *MirrorFlag.
D1C9 LD ($BBF2),A
D1CC 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_Down D1CF CALL DrawStrip Call DrawStrip.
D1D2 CALL StepDownLeftInList Call StepDownLeftInList.
D1D5 DJNZ DrawCell_Down Jump to DrawCell_Down if there are any left.
Move down by eight pixels to start the second run.
D1D7 LD HL,($BBB8) Move the position of the strips up one step.
D1DA LD DE,$FFF8
D1DD ADD HL,DE
D1DE LD ($BBB8),HL
Draw the rest of the tiles flipped.
D1E1 LD A,$01 Write 01 to *MirrorFlag.
D1E3 LD ($BBF2),A
D1E6 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_Up D1E9 CALL DrawStrip Call DrawStrip.
D1EC CALL StepUpLeftInList Call StepUpLeftInList.
D1EF DJNZ DrawCell_Up Jump to DrawCell_Up if there are any left.
D1F1 RET Return.
The view is rotated, so draw the second list at the bottom and the first at the top.
DrawCell_Rotated D1F2 OR %00000001 Use the second list.
Draw the edges at the bottom.
D1F4 CALL DrawStripsLeftToRight Call DrawStripsLeftToRight.
D1F7 POP AF Restore the list number from the stack.
Draw the edges at the top.
D1F8 JR DrawCell_RightToLeft Jump to DrawCell_RightToLeft.
View the equivalent code in;
Prev: D18E Up: Map Next: D1FA