Skip to navigation


Main loop: MainDrivingLoop (Part 4 of 5)

Name: MainDrivingLoop (Part 4 of 5) [Show more] Type: Subroutine Category: Main loop Summary: Main driving loop: Leave the track 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
.main9 \ If we get here then either: \ \ * We have quit the race or lap by pressing SHIFT-f7 \ (in which case we jumped here from part 5) \ \ * This is either an Amateur or a Professional race \ and we crashed (in which case we fell through from \ part 3) \ \ * leaveTrackTimer = 1 (in which case we jumped here \ from part 5 after the leave track timer ran down) \ \ In all cases, we are done racing and need to leave \ the track JSR FlushSoundBuffers \ Flush all four sound channel buffers LDA qualifyingTime \ If bit 7 of qualifyingTime is set then this is a BMI main8 \ practice lap (i.e. qualifyingTime = 255), so jump to \ main1 via main8, so we start a new practice lap LDX #48 \ Blank out the first text line at the top of the screen JSR PrintSecondLineGap \ and print token 48 on the second line, to give: \ \ " " \ " PLEASE WAIT " JSR FinishRace \ Continue running the race until all the non-player \ drivers have finished and we have a result LDA configStop \ If bit 7 of configStop is set then we must be pressing BMI main13 \ either SHIFT-f0 for a pit stop or SHIFT and right \ arrow to restart the game, so jump to main13 to leave \ the track LDA #%00100000 \ Set bit 5 of configStop to indicate that we have STA configStop \ retired from the race (so we leave the track \ permanently rather than just visiting the pits) BNE main13 \ Jump to main13 to leave the track (this BNE is \ effectively a JMP as A is never zero)