Skip to navigation

Aviator on the BBC Micro

Visibility: ProcessLinesToHide

Name: ProcessLinesToHide [Show more] Type: Subroutine Category: Visibility Summary: Process an unprocessed line from the linesToHide list Deep dive: Visibility checks
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * MainLoop (Part 12 of 15) calls ProcessLinesToHide

This routine is called from the main loop, but only when there are fewer than 35 related points, and only if there is enough time (the routine is called in batches of three, until we have spent 9 centiseconds processing the lines to hide list). It pulls a line ID from the end of the linesToHide list, and checks the line's visibility. If it is visible, then it moves the line to the linesToShow list so it gets shown on-screen, but if it is not visible, it sticks the line on the end of the linesToHide list and moves on to the next. In this way the game is constantly checking hidden lines to see if they are visible, so when we fly near enough to a line that it should be shown, this is the routine that shows it. (And, if that line is part of an object, then other lines in the object will also be shown, via the related points list.)
.ProcessLinesToHide LDA linesToHidePointer \ Set A to the position within the linesToHide list up \ to which we have processed lines CMP linesToHideEnd \ If we have processed all the way to the end of the BEQ ProcessLine-1 \ list, then linesToHidePointer = linesToHideEnd, so \ return from the subroutine (as ProcessLine-1 \ contains an RTS) CLC \ Otherwise we have lines on the end of the linesToHide ADC #1 \ list that we have not yet processed, so increment STA linesToHidePointer \ the linesToHidePointer, as we are about to process a \ line TAX \ Set lineId to the line's ID from the linesToHide list LDA linesToHide,X STA lineId CMP #60 \ If lineId = 60, jump back to ProcessLinesToHide to BEQ ProcessLinesToHide \ pick another line CMP #61 \ If lineId = 61, jump back to ProcessLinesToHide to BEQ ProcessLinesToHide \ pick another line \ Fall through into ShowOrHideLine to process the line \ and add it to the linesToShow or linesToHide list