Skip to navigation

Drawing polygons: GetPolygonLines (Part 1 of 6)

Name: GetPolygonLines (Part 1 of 6) [Show more] Type: Subroutine Category: Drawing polygons Summary: Calculate the points in a two-face tile polygon when it consists of a pair of triangles
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.gpol1 \ If we get here then we are drawing a two-face tile as \ a pair of triangles and A contains the offset of the \ rear left tile corner in the drawing tables \ For a triangle, we number the points like this: \ \ 1. Rear left \ 3. Point 2 + trianglePointAdd,Y \ 2. Front left \ \ We also set point 4 to be the same as point 1, so that \ the third edge from point 3 to point 4 is effectively \ from point 3 to point 1 LDY triangleStartPoint \ Set Y to the number of the starting point for this \ tile shape BVC gpol2 \ If bit 6 of polygonType is clear then we are drawing \ the first triangle in a two-face tile, so jump to \ gpol2 to do this \ If we get here then bit 6 and 7 of polygonType are \ both set, so we are drawing the second triangle in a \ two-face file CLC \ Set A = (A + 32 + 1) mod 64 ADC #33 \ AND #63 \ So this moves diagonally from top-left to bottom-right \ or bottom-left to top-right: \ \ offset x offset x + 1 \ \ offset 32 + x offset 32 + x + 1 INY \ Set Y = Y + 2 INY \ \ to give 2 or 3 .gpol2 STA polygonPoint \ Set the first triangle point to A STA polygonPoint+3 \ Set the fourth triangle point to A, so the third edge \ in the triangle joins with the start of the first \ edge EOR #32 \ Set the second triangle point to the equivalent to A STA polygonPoint+1 \ but in the other drawing table offset CLC \ Set the third triangle point to A + the Y-th entry ADC trianglePointAdd,Y \ from trianglePointAdd, mod 64 AND #63 STA polygonPoint+2 LDX #3 \ Set X = 3 to set as the value of polygonEdgeCount as \ there are three edges in a triangle polygon BNE gpol3 \ Jump to gpol3 in part 1 to set polygonEdgeCount = 3 \ and move on to part 4