.ModifyStoringCode PHA \ Store A on the stack so we can preserve it LDA yEdgeStartHi \ If yEdgeStartHi = 0 then jump to stor1 BEQ stor1 \ If we get here then: \ \ * yEdgeStartHi <> 0 LDA #&2C \ Set A to the opcode for the BIT addr instruction, so \ the TracePolygonEdge routine does not store anything \ in the xPolygonLeft or xPolygonRight table (as the BIT \ instruction has no effect beyond setting the status \ flags) BNE stor5 \ Jump to stor5 to modify the instructions at tred41 and \ tred50 (this BNE is effectively a JMP as A is never \ zero) .stor1 \ If we get here then: \ \ * yEdgeStartHi = 0 \ \ and A = 0 STA drawPolygon \ Set drawPolygon = 0 so the polygon gets drawn LDA xEdgeStartHi \ If xEdgeStartHi <> 0 then jump to stor2 BNE stor2 \ If we get here then: \ \ * xEdgeStartHi = 0 \ \ * yEdgeStartHi = 0 LDA #&8E \ Set A to the opcode for the STX addr instruction, so \ the TracePolygonEdge routine stores the value of X \ into the xPolygonLeft or xPolygonRight table BNE stor5 \ Jump to stor5 to modify the instructions at tred41 and \ tred50 (this BNE is effectively a JMP as A is never \ zero) .stor2 \ If we get here then: \ \ * xEdgeStartHi <> 0 \ \ * yEdgeStartHi = 0 \ \ and the flags are set according to the value of \ xEdgeStartHi BPL stor3 \ If xEdgeStartHi is positive, jump to stor3 \ If we get here then: \ \ * xEdgeStartHi < 0 \ \ * yEdgeStartHi = 0 LDY #0 \ Set Y = 0 JMP stor4 \ Jump to stor4 to modify the code to use STY .stor3 \ If we get here then: \ \ * xEdgeStartHi > 0 \ \ * yEdgeStartHi = 0 LDY #255 \ Set Y = 255 .stor4 LDA #&8C \ Set A to the opcode for the STY addr instruction, so \ the TracePolygonEdge routine stores the value of Y \ into the xPolygonLeft or xPolygonRight table .stor5 STA tred41 \ Modify the instruction at tred41 to use the opcode \ specified in A STA tred50 \ Modify the instruction at tred50 to use the opcode \ specified in A PLA \ Restore the value of A that we stored on the stack \ above RTS \ Return from the subroutineName: ModifyStoringCode [Show more] Type: Subroutine Category: Drawing polygons Summary: Modify the code in TracePolygonEdge that stores the coordinates of the polygon edge that is being tracedContext: See this subroutine in context in the source code References: This subroutine is called as follows: * TracePolygonEdge (Part 7 of 8) calls ModifyStoringCode * TracePolygonEdge (Part 8 of 8) calls ModifyStoringCode
This routine modifies the code in part 6 of TracePolygonEdge that stores the x-coordinates of the polygon edge and sets the values of drawPolygon and Y as we trace the edge: yEdgeStartHi = 0 yEdgeStartHi <> 0 xEdgeStartHi < 0 STY, drawPolygon = 0, Y = 0 BIT xEdgeStartHi = 0 STX, drawPolygon = 0 BIT xEdgeStartHi > 0 STY, drawPolygon = 0, Y = 255 BIT Note that the value of Y doesn't appear to be used anywhere.
Returns: A A is preserved
[X]
Variable drawPolygon in workspace Zero page
A flag to record whether the polygon we are currently processing contains any visible pixels, so it can be used to control whether we actually draw the polygon
[X]
Label stor1 is local to this routine
[X]
Label stor2 is local to this routine
[X]
Label stor3 is local to this routine
[X]
Label stor4 is local to this routine
[X]
Label stor5 is local to this routine
[X]
Label tred41 in subroutine TracePolygonEdge (Part 7 of 8)
[X]
Label tred50 in subroutine TracePolygonEdge (Part 8 of 8)
[X]
Variable xEdgeStartHi in workspace Zero page
The x-coordinate of the start point in the polygon edge being processed (high byte)
[X]
Variable yEdgeStartHi in workspace Zero page
The y-coordinate of the start point in the polygon edge being processed (high byte)