.UpdateLinesToShow LDX linesToShowEnd \ If the linesToShow list is empty, jump to upll5 to BEQ upll5 \ return from the subroutine, as there is nothing to \ process LDA #255 \ Set linesToShowPointer = 255, to use as a pointer STA linesToShowPointer \ to the end of the new linesToShow list as we build it \ up in-situ LDA #0 \ Set lineCounter = 0, to use as a line counter as we STA lineCounter \ loop through the linesToShow list .upll1 LDX lineCounter \ Set lineId to the ID of the next line in the LDA linesToShow,X \ linesToShow list STA lineId LDA #1 \ Set HH = 1, so in the following call to ProcessLine STA HH \ we do not check the line's distance against \ maxLineDistance in the visibility checks JSR ProcessLine \ Check whether this line is visible, returning the \ result in showLine LDA lineId \ If lineId = 0, then this is the runway, so skip the BEQ upll2 \ following instruction to keep the line in the list LDX showLine \ If showLine is non-zero then this line is not visible, BNE upll3 \ so jump to upll3 .upll2 \ If we get here then we want to keep this line in the \ linesToShow list INC linesToShowPointer \ Increment the linesToShowPointer pointer to point to \ the next free slot in the new list we are creating LDX linesToShowPointer \ Store the line ID at the end of the new list we are STA linesToShow,X \ creating JMP upll4 \ Jump down to upll4 to move on to the next line in the \ list .upll3 \ If we get here then we do not want to keep this line \ in the linesToShow list, so we need to move it to the \ linesToHide list INC linesToHideEnd \ Increment linesToHideEnd to point to the next free \ entry at the end of the linesToHide list LDX linesToHideEnd \ Add the line ID to the end of the linesToHide list STA linesToHide,X .upll4 INC lineCounter \ Increment the loop counter to point to the next line \ in the linesToShow list LDA lineCounter \ Loop back to process the next line from linesToShow CMP linesToShowEnd \ until we have worked our way to the end BCC upll1 LDA linesToShowPointer \ Set linesToShowEnd = linesToShowPointer + 1 ADC #0 \ STA linesToShowEnd \ so it points to the index of the first empty entry in \ the newly processed linesToShow list .upll5 RTS \ Return from the subroutineName: UpdateLinesToShow [Show more] Type: Subroutine Category: Visibility Summary: Update the linesToShow list, moving any lines that aren't visible into the linesToHide list Deep dive: Visibility checksContext: See this subroutine in context in the source code References: This subroutine is called as follows: * MainLoop (Part 5 of 15) calls UpdateLinesToShow
[X]
Subroutine ProcessLine (Part 1 of 7) (category: Visibility)
Process a line, rotating and transforming it to the correct coordinates and calculating its visibility
[X]
Variable lineCounter in workspace Zero page
Temporary storage, typically used to loop through lines
[X]
Variable linesToHide in workspace Main variable workspace
A list of line IDs for lines that are not visible
[X]
Variable linesToHideEnd in workspace Zero page
The index of the last entry in the linesToHide list
[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 linesToShowPointer in workspace Zero page
A pointer into the linesToShow list to keep track of where we have processed up to
[X]
Variable showLine in workspace Main variable workspace
Determines whether a line is visible
[X]
Label upll1 is local to this routine
[X]
Label upll2 is local to this routine
[X]
Label upll3 is local to this routine
[X]
Label upll4 is local to this routine
[X]
Label upll5 is local to this routine