Skip to navigation


Main loop: MainLoop (Part 15 of 15)

Name: 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 loop
Context: 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.
.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 linesToHide