.DrawCanopyView JSR ModifyDrawRoutine \ Modify the drawing routines to use the current colour \ cycle LDA linesToShowEnd \ If linesToShowEnd is non-zero, jump to view1 to skip BNE view1 \ the following instruction, as there are lines in the \ linesToShow list that we need to draw BEQ view6 \ linesToShowEnd is zero, which means the linesToShow \ list is empty, so there is nothing to draw, so we \ jump down to view6 to flip the colours (this BEQ is \ effectively a JMP as we know A is zero) .view1 LDA #0 \ Set lineCounter = 0 to act as a counter in the STA lineCounter \ following loop, where we loop through the linesToShow \ list .view2 TAX \ Set lineId to the next line ID from the linesToShow LDA linesToShow,X \ list STA lineId BNE view3 \ If lineId is non-zero, jump to view3, as this is not \ the horizon JSR DrawHalfHorizon \ The line ID is 0, which is the horizon, so draw half \ of the horizon line (as only half of the horizon is \ stored in line 0) LDA lineId \ Retrieve the line's ID, as it will have been corrupted \ by the call to DrawHalfHorizon, and fall through into \ view3 to draw the other half of the horizon .view3 TAX \ Set M to the point ID for the line's end point LDY lineEndPointId,X STY M LDA #0 \ Zero the end point's status byte, so it is no longer STA pointStatus,Y \ marked as having had its coordinates and visibility \ calculated LDY lineStartPointId,X \ Set L to the point ID for the line's start point STY L STA pointStatus,Y \ Zero the start point's status byte, so it is no longer \ marked as having had its coordinates and visibility \ calculated JSR DrawClippedLine \ Draw the line, clipping it to the canopy view if \ required INC lineCounter \ Increment the loop counter LDA lineCounter \ Loop back to draw the next line from the linesToShow CMP linesToShowEnd \ list BCC view2 JSR DrawGunSights \ Draw the gun sights, if shown \ We now flip the screens between the old screen (which \ is being shown in white) and the new one (which we \ just drew in black) LDA colourCycle \ If bit 7 of colourCycle is set, i.e. %11110000, jump BMI view4 \ down to view4 to hide colour 1 and show colour 2 \ If we get here then colourCycle is %00001111 LDX #2 \ Set logical colour 2 to black, to hide the old canopy JSR SetColourToBlack \ view in colour 2 LDX #1 \ Set logical colour 1 to white, to show the new canopy JSR SetColourToWhite \ view that we just drew in colour 1 JMP view5 \ Now that we have cycled the colours, jump down to \ view5 .view4 \ If we get here then colourCycle is %11110000 LDX #1 \ Set logical colour 1 to black, to hide the old canopy JSR SetColourToBlack \ view in colour 1 LDX #2 \ Set logical colour 2 to white, to show the new JSR SetColourToWhite \ view that we just drew in colour 2 .view5 JSR EraseCanopyLines \ Erase the lines that are now hidden, and which are \ stored in the relevant line buffer .view6 JSR FlipColours \ Flip the values of colourCycle and colourLogic to \ cycle to the next colour state RTS \ Return from the subroutineName: DrawCanopyView [Show more] Type: Subroutine Category: Graphics Summary: Draw the main view out of the canopy Deep dive: Flicker-free animation through colour cyclingContext: See this subroutine in context in the source code References: This subroutine is called as follows: * MainLoop (Part 13 of 15) calls DrawCanopyView
[X]
Subroutine DrawClippedLine (Part 1 of 6) (category: Drawing lines)
Clip a line to fit on-screen, starting with the line deltas
[X]
Subroutine DrawGunSights (category: Graphics)
Draw the canopy corners and the gun sights, if shown
[X]
Subroutine DrawHalfHorizon (category: Drawing lines)
Draw half of the horizon line
[X]
Subroutine EraseCanopyLines (category: Drawing lines)
Draw all the lines from a line buffer to erase them
[X]
Subroutine FlipColours (category: Graphics)
Flip the values of colourCycle and colourLogic to cycle to the next colour state
[X]
Subroutine ModifyDrawRoutine (category: Drawing lines)
Modify the drawing routines to draw in the correct colour for the current colour cycle
[X]
Subroutine SetColourToBlack (category: Graphics)
Set a logical colour to black
[X]
Subroutine SetColourToWhite (category: Graphics)
Set a logical colour to white
[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 lineCounter in workspace Zero page
Temporary storage, typically used to loop through lines
[X]
Variable lineEndPointId (category: 3D geometry)
The point ID for a line's end point
[X]
Variable lineStartPointId (category: 3D geometry)
The point ID for a line's start point
[X]
Variable linesToShow in workspace Main variable workspace
A list of line IDs for lines that are visible
[X]
Variable linesToShowEnd in workspace Zero page
The index of the first empty entry in the linesToShow list
[X]
Variable pointStatus in workspace Main variable workspace
Each point's status byte
[X]
Label view1 is local to this routine
[X]
Label view2 is local to this routine
[X]
Label view3 is local to this routine
[X]
Label view4 is local to this routine
[X]
Label view5 is local to this routine
[X]
Label view6 is local to this routine