.DrawSlopingTile TAX \ Set X to the tile shape so we can retrieve it later SEC \ Set Y = (A - viewingQuadrantx4) mod 16 SBC viewingQuadrantx4 \ AND #%00001111 \ Tiles are grouped into four groups, so this sets the TAY \ correct group for the orientation of the viewer \ \ In other words, this makes the shape numbers relative \ to the viewer's orientation, so we can set the correct \ colours for the shape's faces \ \ Specifically, it realigns the following tile shape \ numbers so that the numbering starts in the quadrant \ where the player is facing: \ \ 1 0 0 Y = 1-3 when facing 12 o'clock \ 1 1 = 5-7 when facing 9 o'clock \ = 9-11 when facing 6 o'clock \ 2 1 1 = 13-15 when facing 3 o'clock \ 0 1 \ \ 3 1 0 \ 1 1 \ \ \ 5 1 0 Y = 1-3 when facing 3 o'clock \ 1 0 = 5-7 when facing 12 o'clock \ = 9-11 when facing 9 o'clock \ 6 1 0 = 13-15 when facing 6 o'clock \ 0 0 \ \ 7 1 1 \ 1 0 \ \ \ 9 1 1 Y = 1-3 when facing 6 o'clock \ 0 0 = 5-7 when facing 3 o'clock \ = 9-11 when facing 12 o'clock \ 10 0 1 = 13-15 when facing 9 o'clock \ 0 0 \ \ 11 0 0 \ 1 0 \ \ \ 13 0 1 Y = 1-3 when facing 9 o'clock \ 0 1 = 5-7 when facing 6 o'clock \ = 9-11 when facing 3 o'clock \ 14 0 0 = 13-15 when facing 12 o'clock \ 0 1 \ \ 15 0 1 \ 1 1 \ \ We use this value below when calculating the colours \ of the two faces in two-face tiles AND #%00000011 \ If Y mod 4 = 1 then the tile shape is the first shape CMP #%00000001 \ in one of the groups above, so it's a single sloping BEQ DrawOneFaceTile \ face from one horizontal edge to another, so jump to \ DrawOneFaceTile to draw this one-face tile \ If we get here then the tile shape is the second or \ third shape in one of the groups above, so one corner \ is a different altitude to the others \ \ We now use the value of Y to pick the correct value \ for triangleStartPoint and the correct tileShapeColour \ table offset for the tile colour, so we can pass them \ to DrawTwoFaceTile to draw the tile LDA triangleStart,Y \ Set triangleStartPoint = 1 for Y = 6, 7, 14, 15 STA triangleStartPoint \ 0 for Y = 2, 3, 10, 11 TXA \ Set A = 1 for tile shapes 6, 7, 14, 15 AND #%00000100 \ 0 for tile shapes 2, 3, 10, 11 LSR A LSR A CLC \ Set C flag if viewingQuadrantOpp = 1 and A = 1 ADC viewingQuadrantOpp \ or viewingQuadrantOpp = 2 CMP #2 \ or viewingQuadrantOpp = 3 \ \ Clear C flag if viewingQuadrantOpp = 0 \ or viewingQuadrantOpp = 1 and A = 0 TXA \ Set A to the tile shape to pass to DrawTwoFaceTile BCS DrawTwoFaceTile \ Add 16 to the tile shape if the C flag is clear ORA #16 \ Fall through into DrawTwoFaceTile to draw the tile \ with two triangular (three-sided) facesName: DrawSlopingTile [Show more] Type: Subroutine Category: Drawing the landscape Summary: Draw a sloping tile that is not shape 4 or 12Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawTileAndObjects calls DrawSlopingTile
Arguments: A The shape of the tile to draw (not 0, 4 or 12)
[X]
Subroutine DrawOneFaceTile (category: Drawing the landscape)
Draw a tile with one quadrilateral (four-sided) face
[X]
Subroutine DrawTwoFaceTile (category: Drawing the landscape)
Draw a tile with two triangular (three-sided) faces
[X]
Variable triangleStart (category: Drawing polygons)
The number of the first point in each two-face shape that is drawn as a pair of triangles
[X]
Variable triangleStartPoint in workspace Zero page
The number of the starting point for the tile shape being drawn
[X]
Variable viewingQuadrantOpp in workspace Zero page
The opposite quadrant number to that containing the right edge of the viewing arc
[X]
Variable viewingQuadrantx4 in workspace Zero page
The quadrant number containing the right edge of the viewing arc, multiplied by 4, for use when calculating the number of faces in a tile in DrawSlopingTile