.main25 LDX previousListEnd \ If the value of linesToHideEnd has changed since the CPX linesToHideEnd \ start of the main loop - in other words, it is not the BNE main26 \ same as the value we stored in previousListEnd - then \ this means the value of linesToHideEnd has changed \ during this iteration of the main loop, so jump down \ to main26 to process the new additions to the \ linesToHide list JMP MainLoop \ Otherwise we are done, so jump back up to the top of \ the main loop for the next iteration .main26 \ The first time we get here, X contains the size of the \ linesToHide list as it was when we started this \ iteration of the main loop, and we have added new \ lines to the list, so now we need to process those \ new lines INX \ Increment X to point to the next line, which will be \ the first new one to process LDY linesToHide,X \ Set Y to this line's ID from linesToHide STX previousListEnd \ Update the value of previousListEnd, so if we revisit \ the main26 loop, we will move on to the next line \ Now to process the line LDX lineStartPointId,Y \ Set X to the ID of this line's start point LDA #0 \ Zero the start point's status byte, so it is no longer STA pointStatus,X \ marked as having had its coordinates and visibility \ calculated LDX lineEndPointId,Y \ Set X to the ID of this line's end point STA pointStatus,X \ Zero the end point's status byte, so it is no longer \ marked as having had its coordinates and visibility \ calculated JMP main25 \ Jump back to main25 to repeat this process until we \ have zeroed all the new additions to linesToHideName: MainLoop (Part 15 of 15) [Show more] Type: Subroutine Category: Main loop Summary: Update the status of any new line points Deep dive: Program flow of the main game loopContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
If we have added any lines to the linesToHide list during the main loop (and therefore incremented linesToHideEnd), we reset the point status bytes for the line's start and end points, so they are no longer flagged as having had their visibility checked already.
[X]
Subroutine MainLoop (Part 1 of 15) (category: Main loop)
Start the main loop by processing gunfire and bullets
[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 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]
Label main25 is local to this routine
[X]
Label main26 is local to this routine
[X]
Variable pointStatus in workspace Main variable workspace
Each point's status byte
[X]
Variable previousListEnd in workspace Main variable workspace
Used to store the value of linesToHideEnd at the start of each iteration of the main loop, so we can refer to it at the end of the main loop to see if we have added anything to the list during the main loop