.dlin1 \ If we get here then the line is a shallow horizontal \ slope BIT V \ If bit 7 of V is set, jump to dlin3 to step along the BMI dlin3 \ x-axis in a negative direction, i.e. to the left \ If we get here then bit 7 of V is clear, so we step \ along the x-axis in a positive direction, i.e. to the \ right, which we implement by modifying the routine's \ code, setting it back to the default LDA #5 \ Modify the following instruction at dlin20: STA dlin20+1 \ \ BCC dlin22 -> BCC dlin22 \ \ i.e. set it back to the default LDA #9 \ Modify the following instruction at dlin21: STA dlin21+1 \ \ BNE dlin25 -> BNE dlin25 \ \ i.e. set it back to the default .dlin2 LDA #LO(colour1L2R) \ Modify the following instruction at dlin33: STA dlin33+1 \ \ LDA colour1L2R,X -> LDA colour1L2R,X \ \ Note that this is a two-layer modification, as the \ LDA #LO(colour1L2R) instruction gets modified by the \ ModifyDrawRoutine routine as follows: \ \ * LO(colour1L2R) when colourLogic = %01000000 \ so the bit pattern lookup table uses colour 1 \ i.e. LDA colour1L2R,X \ \ * LO(colour2L2R) when colourLogic = %01000000 \ so the bit pattern lookup table uses colour 2 \ i.e. LDA colour2L2R,X \ \ * LO(colour1Row) when colourLogic = %00000000 \ and colourCycle = %00001111 \ so the bit pattern lookup is always %00001111 \ i.e. LDA colour1Row,X \ \ * LO(colour2Row) when colourLogic = %00000000 \ and colourCycle = %11110000 \ so the bit pattern lookup is always %11110000 \ i.e. LDA colour2Row,X \ \ In other words, this instruction has already been \ modified to implement the current colour cycle LDA #39 \ Set I = 39, the number of the last character block STA I \ on the row BNE dlin5 \ Jump to dlin5 to skip the code modifications for the \ other value of bit 7 (this BNE is effectively a JMP as \ A is never zero) .dlin3 \ If we get here then bit 7 of V is set, so we step \ along the x-axis in a negative direction, i.e. to the \ left, which we implement by modifying the routine's \ code LDA #&24 \ Modify the following instruction at dlin20: STA dlin20+1 \ \ BCC dlin22 -> BCC dlin27 LDA #&28 \ Modify the following instruction at dlin21: STA dlin21+1 \ \ BNE dlin25 -> BNE dlin30 .dlin4 \ Modify the following instruction at dlin33: LDA #LO(colour1R2L) \ STA dlin33+1 \ LDA colour1L2R,X -> LDA colour1R2L,X \ \ Note that this is a two-layer modification, as the \ LDA #LO(colour1R2L) instruction gets modified by the \ ModifyDrawRoutine routine as follows: \ * LO(colour1R2L) when colourLogic = %01000000 \ so the bit pattern lookup table uses colour 1 \ i.e. LDA colour1R2L,X \ \ * LO(colour2R2L) when colourLogic = %01000000 \ so the bit pattern lookup table uses colour 2 \ i.e. LDA colour2R2L,X \ \ * LO(colour1Row) when colourLogic = %00000000 \ and colourCycle = %00001111 \ so the bit pattern lookup is always %00001111 \ i.e. LDA colour1Row,X \ \ * LO(colour2Row) when colourLogic = %00000000 \ and colourCycle = %11110000 \ so the bit pattern lookup is always %11110000 \ i.e. LDA colour2Row,X \ \ In other words, this instruction has already been \ modified to implement the current colour cycle LDA #0 \ Set I = 0, the number of the first character block STA I \ on the row .dlin5 BIT V \ If bit 6 of V is set, jump to dlin6 to step along the BVS dlin6 \ y-axis in a negative direction, i.e. down the screen \ If we get here then bit 6 of V is clear, so we step \ along the y-axis in a positive direction, i.e. up the \ screen, which we implement by modifying the routine's \ code LDA #&98 \ Modify the following instruction at dlin35: STA dlin35 \ \ INY -> TYA LDA #&88 \ Modify the following instruction at dlin36: STA dlin36 \ \ TYA -> DEY LDA #&C8 \ Modify the following instruction at dlin37: STA dlin37+1 \ \ ADC #&38 -> ADC #&C8 LDA #&FE \ Modify the following instruction at dlin38: STA dlin38+1 \ \ ADC #1 -> ADC #&FE LDA #158 \ Set J = 158 - G SEC \ SBC G \ So J contains the y-coordinate of the end of the line, STA J \ flipped to match screen memory (so higher values of \ the y-coordinate are lower down the screen) JMP dlin7 \ Jump to dlin7 to skip the code modifications for the \ other value of bit 6 .dlin6 \ If we get here then bit 6 of V is set, so we step \ along the y-axis in a negative direction, i.e. down \ the screen, which we implement by modifying the \ routine's code, setting it back to the default LDA #&C8 \ Modify the following instruction at dlin35: STA dlin35 \ \ INY -> INY \ \ i.e. set it back to the default LDA #&98 \ Modify the following instruction at dlin36: STA dlin36 \ \ TYA -> TYA \ \ i.e. set it back to the default LDA #&38 \ Modify the following instruction at dlin37: STA dlin37+1 \ \ ADC #&38 -> ADC #&38 \ \ i.e. set it back to the default LDA #1 \ Modify the following instruction at dlin38: STA dlin38+1 \ \ ADC #1 -> ADC #1 \ \ i.e. set it back to the default LDA #160 \ Set J = 160 - G SEC \ SBC G \ So J contains the y-coordinate of the end of the line, STA J \ flipped to match screen memory (so higher values of \ the y-coordinate are lower down the screen)Name: DrawCanopyLine (Part 2 of 9) [Show more] Type: Subroutine Category: Drawing lines Summary: Modify the line drawing routine for a shallow horizontal slopeContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
The code in this routine is modified by the ModifyDrawRoutine routine, and by the DrawCanopyLine routine itself. The default code (i.e. the unmodified version in the source) is run when: * 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
[X]
Variable colour1L2R (category: Drawing lines)
Pixel bytes for drawing canopy lines left to right in colour 1
[X]
Variable colour1R2L (category: Drawing lines)
Pixel bytes for drawing canopy lines right to left in colour 1
[X]
Label dlin20 in subroutine DrawCanopyLine (Part 4 of 9)
[X]
Label dlin21 in subroutine DrawCanopyLine (Part 4 of 9)
[X]
Label dlin3 is local to this routine
[X]
Label dlin33 in subroutine DrawCanopyLine (Part 6 of 9)
[X]
Label dlin35 in subroutine DrawCanopyLine (Part 6 of 9)
[X]
Label dlin36 in subroutine DrawCanopyLine (Part 6 of 9)
[X]
Label dlin37 in subroutine DrawCanopyLine (Part 6 of 9)
[X]
Label dlin38 in subroutine DrawCanopyLine (Part 6 of 9)
[X]
Label dlin5 is local to this routine
[X]
Label dlin6 is local to this routine
[X]
Label dlin7 in subroutine DrawCanopyLine (Part 3 of 9)