.EraseCanopyLines LDA #%00000000 \ Set colourLogic = %00000000 so when we draw a line, it STA colourLogic \ erases it JSR ModifyDrawRoutine \ Modify the drawing routines to use AND logic and the \ bit patterns that match colourCycle .ecal1 LDA colourCycle \ If bit 7 of colourCycle is clear, i.e. %00001111, jump BPL ecal3 \ down to ecal3 \ If we get here, colourCycle is %11110000 LDX lineBuffer2Count \ If lineBuffer2Count <> 47, line buffer 2 is not CPX #47 \ empty, so jump down to ecal2 to draw the next line BNE ecal2 \ from the buffer RTS \ Return from the subroutine .ecal2 DEC lineBuffer2Count \ Decrement the value in lineBuffer2Count as we are \ about to draw the next line from buffer 2 JMP ecal5 \ Jump down to ecal5 to draw the next line from buffer 2 .ecal3 LDX lineBuffer1Count \ If lineBuffer1Count <> -1, line buffer 1 is not CPX #255 \ empty, so jump down to ecal4 to draw the next line BNE ecal4 \ from the buffer RTS \ Return from the subroutine .ecal4 DEC lineBuffer1Count \ Decrement the value in lineBuffer1Count as we are \ about to draw the next line from buffer 1 .ecal5 \ We now fetch the next line from the line buffer LDA lineBufferR,X \ Set R to the start x-coordinate from lineBufferR STA R STA xTemp1Lo \ Set the x-coordinate of (R, S) = (xTemp1Lo, yTemp1Lo) \ so we can access it in the DrawCanopyLine routine LDA lineBufferW,X \ Set W to the max/min x-coordinate from lineBufferW STA W LDA lineBufferS,X \ Set S to the start y-coordinate from lineBufferS STA S STA yTemp1Lo \ Set the y-coordinate of (R, S) = (xTemp1Lo, yTemp1Lo) \ so we can access it in the DrawCanopyLine routine LDA lineBufferG,X \ Set G to max/min y-coordinate from lineBufferG STA G LDA lineBufferT,X \ Set T to the |x-delta| from lineBufferT STA T LDA lineBufferU,X \ Set U to the |y-delta| from lineBufferU STA U LDA lineBufferV,X \ Set V to the direction from lineBufferV STA V JSR DrawCanopyLine \ Draw the line (to erase it) JMP ecal1 \ Loop back to ecal1 to erase the next line EQUB &17 \ This byte appears to be unusedName: EraseCanopyLines [Show more] Type: Subroutine Category: Drawing lines Summary: Draw all the lines from a line buffer to erase them Deep dive: Line buffersContext: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawCanopyView calls EraseCanopyLines
We call this routine from DrawCanopyView, after drawing all the new lines and just before we flip colours. See the DrawCanopyView routine for more details of the colour-cycling system that this forms part of. This is what the EraseCanopyLines routine does: If colourCycle = %00001111, then colour 1 is white and colour 2 is black: * Draw the lines in line buffer 1, using AND logic and bit pattern %00001111 * Colour 2 on-screen is %11110000, so AND'ing with %00001111 gives 0 * So this erases all the lines in buffer 1, which are on-screen in colour 2 i.e. we erase all the lines in line buffer 1 from the hidden screen If colourCycle = %11110000, then colour 1 is black and colour 2 is white: * Draw the lines in line buffer 2, using AND logic and bit pattern %11110000 * Colour 1 is %00001111, so AND'ing with %11110000 gives 0 * So this erases all the lines in buffer 2, which are on-screen in colour 1 i.e. we erase all the lines in line buffer 2 from the hidden screen
[X]
Subroutine DrawCanopyLine (Part 1 of 9) (category: Drawing lines)
Draw a line in the canopy view
[X]
Subroutine ModifyDrawRoutine (category: Drawing lines)
Modify the drawing routines to draw in the correct colour for the current colour cycle
[X]
Variable colourCycle in workspace Main variable workspace
Determines which of the two canopy screens we are showing, so we can use colour cycling for smooth animation
[X]
Variable colourLogic in workspace Main variable workspace
Determines the logic and bit patterns used to draw the canopy view
[X]
Label ecal1 is local to this routine
[X]
Label ecal2 is local to this routine
[X]
Label ecal3 is local to this routine
[X]
Label ecal4 is local to this routine
[X]
Label ecal5 is local to this routine
[X]
Variable lineBuffer1Count in workspace Main variable workspace
Offset of the last line stored in buffer 1
[X]
Variable lineBuffer2Count in workspace Main variable workspace
Offset of the last line stored in buffer 2
[X]
Variable lineBufferG (category: Drawing lines)
Line buffer storage for the max/min y-coordinate (G)
[X]
Variable lineBufferR (category: Drawing lines)
Line buffer storage for the start x-coordinate (R)
[X]
Variable lineBufferS (category: Drawing lines)
Line buffer storage for the start y-coordinate (S)
[X]
Variable lineBufferT (category: Drawing lines)
Line buffer storage for the line's |x-delta| (T)
[X]
Variable lineBufferU in workspace Stack variables
Line buffer storage for the line's |y-delta| (U)
[X]
Variable lineBufferV (category: Drawing lines)
Line buffer storage for the line direction (V)
[X]
Variable lineBufferW (category: Drawing lines)
Line buffer storage for the max/min x-coordinate (W)
[X]
Variable xTemp1Lo in workspace Main variable workspace
The low byte of the xTemp1 temporary variable
[X]
Variable yTemp1Lo in workspace Main variable workspace
The low byte of the yTemp1 temporary variable