.dlin32 \ This routine draws a part of a line (one pixel row, \ i.e. a byte) and moves us down to the next character \ row (though it may be modified to move up a row for \ lines that are being drawn in that direction) \ \ We call this subroutine with: \ \ * A = the current slope error \ \ * X = the index of the pixel byte at colour1L2R \ \ * The C flag is always set ADC RR \ Set SS = A + RR + C STA SS \ = slope error + (255 - |x-delta|) + 1 \ = slope error + 256 - |x-delta| \ = slope error - |x-delta| .dlin33 LDA colour1L2R,X \ Fetch the X-th pixel byte from colour1L2R \ \ Gets modified by the DrawCanopyLine routine, which in \ turn gets modified by the ModifyDrawRoutine routine: \ \ * colour1L2R when colourLogic = %01000000 \ \ * colour2L2R when colourLogic = %01000000 \ \ * colour1Row when colourLogic = %00000000 \ and colourCycle = %00001111 \ \ * colour2Row when colourLogic = %00000000 \ and colourCycle = %11110000 \ \ In other words, this instruction has already been \ modified to implement the current colour cycle .dlin34 ORA (P),Y \ OR the pixel byte with the current screen contents \ \ Gets modified by the ModifyDrawRoutine routine: \ \ * ORA (P),Y when colourLogic = %01000000 \ \ * AND (P),Y when colourLogic = %00000000 \ \ In other words, this instruction has already been \ modified to implement the current drawing logic STA (P),Y \ Update the Y-th byte of (Q P) with the result, which \ sets 4 pixels to the pixel pattern in A .dlin35 INY \ Increment Y to point to the next screen byte, i.e. the \ offset of the next row in the character block \ \ Gets modified by the DrawCanopyLine routine: \ \ * INY when bit 6 of V is set \ \ * TYA when bit 6 of V is clear \ \ In other words, this instruction has already been \ modified to implement the current drawing direction .dlin36 TYA \ Set A to the offset of the next row in the character \ block \ \ Gets modified by the DrawCanopyLine routine: \ \ * TYA when bit 6 of V is set \ \ * DEY when bit 6 of V is clear \ \ In other words, this instruction has already been \ modified to implement the current drawing direction AND #7 \ If A mod 7 <> 0 then we haven't reached the end of the BNE dlin39 \ 8-row character block, so jump to dlin39 to skip the \ following \ Otherwise we have reached the last row of the \ character block, so we now add &138 to (Q P) to move \ to the address of the start of the character block \ in the row below (as each character row in mode 5 \ contains &140 bytes, so this is &140 - 8 to cater for \ the block we just finished) LDA P \ We start by adding &38 to the low byte in P CLC .dlin37 ADC #&38 \ Add &38 to the low byte \ \ Gets modified by the DrawCanopyLine routine: \ \ * ADC #&38 when bit 6 of V is set \ \ * ADC #&E8 when bit 6 of V is clear \ \ In other words, this instruction has already been \ modified to implement the current drawing direction STA P \ Store the updated low byte in P LDA Q \ Then add the high bytes .dlin38 ADC #1 \ Add &1 to the high byte \ \ Gets modified by the DrawCanopyLine routine: \ \ * ADC #1 when bit 6 of V is set \ \ * ADC #&FE when bit 6 of V is clear \ \ In other words, this instruction has already been \ modified to implement the current drawing direction STA Q \ Which we store in Q, so now we have: \ \ (Q P) = (Q P) + &138 \ \ so (Q P) is the address of the start of the character \ block in the row below .dlin39 LDA SS \ Set A = SS, so it contains the current slope error CPY J \ If the current y-coordinate in Y = J, then we have CLC \ reached the y-coordinate of the end of the line (which BEQ dlin40 \ we set in part 2), so jump to dlin40 to stop drawing \ the line and move on to the clipped part of the line RTS \ Return from the subroutine with the C flag clear .dlin40 TSX \ Remove two bytes from the top of the stack, so the INX \ next RTS returns us to caller of the DrawCanopyLine INX \ routine rather than the caller of dlin32 (so this TXS \ effectively breaks out of the current line-drawing \ loop) JMP dlin65 \ Jump to dlin65 to process the clipped part of the \ line, if applicableName: DrawCanopyLine (Part 6 of 9) [Show more] Type: Subroutine Category: Drawing lines Summary: Draw a part of the line, working along the screenContext: 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, and by the DrawCanopyLine routine itself. The default code (i.e. the unmodified version in the source) is run when: * The current colour cycle is drawing in colour 1, using the pixel bitmaps at colour1L2R and OR logic for updating the screen * 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]
Label dlin39 is local to this routine
[X]
Label dlin40 is local to this routine
[X]
Label dlin65 in subroutine DrawCanopyLine (Part 9 of 9)