Prev: 53646 Up: Map Next: 53754
53661: 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 53661 CALL GetMapCell Call GetMapCell.
53664 RET Z Return if there is nothing in the cell.
Double the code to make the number of its first list.
53665 ADD A,A Double the code.
53666 PUSH AF Stash it on the stack.
Find the position of the cell on the screen.
53667 CALL ProjectCell Work out the position of the cell on the screen.
53670 POP AF Get the number of the list back, and keep it again.
53671 PUSH AF
Draw the second list at the bottom when the view is rotated.
53672 LD HL,48058 Jump to DrawCell_Rotated if the view is turned round.
53675 BIT 0,(HL)
53677 JR NZ,DrawCell_Rotated
Draw the edges at the bottom.
53679 CALL DrawStripsLeftToRight Call DrawStripsLeftToRight.
Get the number of the list back and make it the number of the second list.
53682 POP AF Restore the list number from the stack.
53683 OR %00000001 Use the second list.
Draw the edges at the top, starting from the right corner of the cell.
DrawCell_RightToLeft 53685 LD HL,(48054) Move the position back to the last strip that was drawn.
53688 LD DE,65520
53691 ADD HL,DE
53692 LD (48054),HL
53695 LD BC,25252 Point BC at StripListTable.
Find the address of the list.
53698 CALL GetTableEntry Call GetTableEntry.
53701 PUSH HL Copy the list address to IY (using the stack).
53702 POP IY
Draw tiles as they are.
53704 XOR A Write 0 to *MirrorFlag.
53705 LD (48114),A
53708 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_Down 53711 CALL DrawStrip Call DrawStrip.
53714 CALL StepDownLeftInList Call StepDownLeftInList.
53717 DJNZ DrawCell_Down Jump to DrawCell_Down if there are any left.
Move down by eight pixels to start the second run.
53719 LD HL,(48056) Move the position of the strips up one step.
53722 LD DE,65528
53725 ADD HL,DE
53726 LD (48056),HL
Draw the rest of the tiles flipped.
53729 LD A,1 Write 1 to *MirrorFlag.
53731 LD (48114),A
53734 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_Up 53737 CALL DrawStrip Call DrawStrip.
53740 CALL StepUpLeftInList Call StepUpLeftInList.
53743 DJNZ DrawCell_Up Jump to DrawCell_Up if there are any left.
53745 RET Return.
The view is rotated, so draw the second list at the bottom and the first at the top.
DrawCell_Rotated 53746 OR %00000001 Use the second list.
Draw the edges at the bottom.
53748 CALL DrawStripsLeftToRight Call DrawStripsLeftToRight.
53751 POP AF Restore the list number from the stack.
Draw the edges at the top.
53752 JR DrawCell_RightToLeft Jump to DrawCell_RightToLeft.
View the equivalent code in;
Prev: 53646 Up: Map Next: 53754