.dlin7 \ By the time we get here, the code has been modified to \ work with the step directions given in bits 6 and 7 of \ V, as well as the current colour cycle \ \ To keep things simple, we will only document the \ default code, which is for a shallow horizontal slope \ with the following: \ \ * Bit 7 of V is clear, so we step along the x-axis \ in a positive direction, i.e. to the right \ \ * Bit 6 of V is set, so we step along the y-axis in \ a negative direction, i.e. down the screen \ \ * The current colour cycle is drawing in colour 1, \ using the pixel bitmaps at colour1L2R \ \ By this point, we also have the following variables \ set: \ \ * (Q P) is the screen address of the pixel row \ containing pixel (R, S), out by 8 bytes for each \ row above or below the top of the dashboard \ \ * I = 39, the number of the last character block on \ a screen row, heading left to right \ \ * J = 160 - G, the y-coordinate of the end of the \ line, flipped around so it increases as we go down \ the screen \ \ The last two have different values with different line \ directions, but these are the values for the default \ case that we're considering here LDA #159 \ Set Y = 159 - S SEC \ SBC S \ This gets added to the screen address in (Q P) that we TAY \ set above, to give the screen address of the starting \ point at coordinate (R, S) LDA #255 \ Set RR = 255 - T SEC \ = 255 - |x-delta| SBC T STA RR CLC \ Set SS = RR ADC #1 \ = 255 - T + 1 STA SS \ \ This is the starting value for the slope error LDA V \ If bits 0 and 1 of V are both clear, then this is not AND #%00000011 \ the horizon line or a clipped line, so jump to dlin8 BEQ dlin8 \ to skip the following LDA U \ If U < 2, jump to dlin8 to skip the following CMP #2 BCC dlin8 \ If we get here then U >= 2, and this is either the \ horizon line or the line has been clipped LDA #255 \ Set SS = 255 STA SS .dlin8 LDA R \ Set X = bits 0 and 1 of R, so X is the pixel number AND #%00000011 \ in the character row for pixel (R, S), in the range TAX \ 0 to 3 \ We are going to use QQ to keep track of the current \ character block number as we work our way along the \ line, drawing as we go, so we need to initialise it to \ the character block number of the starting point in \ (R, S) LDA R \ Set QQ = R / 4 LSR A \ LSR A \ so QQ is the number of the character block containing STA QQ \ pixel (R, S), as each character block is 4 pixels wide LDA SS \ Set A = SS, so it contains the current slope error BIT V \ If bit 7 of V is set, then we are stepping along the BMI dlin10 \ x-axis in a negative direction, i.e. to the left, so \ jump to dlin10 CPX #1 \ If X < 1 (i.e. X = 0), jump to dlin13 BCC dlin13 BNE dlin9 \ If X <> 1 (i.e. X = 2 or 3), jump to dlin9 CLC \ If we get here then X = 1, so clear the C flag and BCC dlin14 \ jump to dlin14 (this BCC is effectively a JMP as we \ know the C flag is clear) .dlin9 \ If we get here then X = 2 or 3 CPX #3 \ If X < 3 (i.e. X = 2), jump to dlin16 BCC dlin16 CLC \ If we get here then X = 3, so clear the C flag and BCC dlin18 \ jump to dlin18 (this BCC is effectively a JMP as we \ know the C flag is clear) .dlin10 \ If we get here then bit 7 of V is set, so we are \ stepping along the x-axis in a negative direction, \ i.e. to the left CPX #1 \ If X < 1 (i.e. X = 0), jump to dlin18 BCC dlin18 BNE dlin11 \ If X <> 1 (i.e. X = 2 or 3), jump to dlin11 CLC \ If we get here then X = 1, so clear the C flag and BCC dlin16 \ jump to dlin16 (this BCC is effectively a JMP as we \ know the C flag is clear) .dlin11 CPX #3 \ If X < 3 (i.e. X = 2), jump to dlin14 BCC dlin14 CLC \ If we get here then X = 3, so clear the C flag and BCC dlin13 \ jump to dlin13 (this BCC is effectively a JMP as we \ know the C flag is clear)Name: DrawCanopyLine (Part 3 of 9) [Show more] Type: Subroutine Category: Drawing lines Summary: Draw a line as a shallow horizontal slopeContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Label dlin10 is local to this routine
[X]
Label dlin11 is local to this routine
[X]
Label dlin13 in subroutine DrawCanopyLine (Part 4 of 9)
[X]
Label dlin14 in subroutine DrawCanopyLine (Part 4 of 9)
[X]
Label dlin16 in subroutine DrawCanopyLine (Part 4 of 9)
[X]
Label dlin18 in subroutine DrawCanopyLine (Part 4 of 9)
[X]
Label dlin8 is local to this routine
[X]
Label dlin9 is local to this routine