Skip to navigation


Main loop: MainDrivingLoop (Part 1 of 5)

Name: MainDrivingLoop (Part 1 of 5) [Show more] Type: Subroutine Category: Main loop Summary: Main driving loop: Switch to the track and start the main loop Deep dive: Program flow of the main game loop
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * HeadToTrack calls MainDrivingLoop

Returns: configStop Contains details of why we are exiting the driving loop: * Bit 5 set = retire from race/lap (SHIFT-f7 pressed) * Bit 7 and bit 6 set = pit stop (SHIFT-f0 pressed) * Bit 7 set and bit 6 clear = restart game (SHIFT and right arrow pressed)
.MainDrivingLoop JSR SetCustomScreen \ Switch to the custom screen mode, which also sets \ screenSection to -2, so the interrupt handler doesn't \ do any palette switching just yet, but leaves the \ palette mapped to black, so the screen is blank LDA #0 \ Set printMode = 0 so text printing pokes directly into STA printMode \ screen memory JSR CopyDashData \ Copy the dash data from the main game code to screen \ memory JSR DrawTrackView \ Copy the data from the dash data blocks to the screen \ to draw the track view \ \ As the screen is currently mapped to black, this \ doesn't show anything, but it does zero all the dash \ data blocks, so they are ready to be filled with the \ track view BIT configStop \ If bit 6 of configStop is set then we are returning to BVS main4 \ the track after visiting the pits, so jump to main4 \ to reset the pit stop flag and enter the driving loop .main1 \ We jump back here when restarting practice laps LDX #0 \ Zero the clock timer, as there is no time limit on the JSR ZeroTimer \ practice session .main2 \ We jump back here when restarting qualifying laps JSR ResetVariables \ Reset a number of variables for driving, and print the \ top two text lines .main3 \ We jump back here when restarting a Novice race JSR BuildPlayerCar \ Build the objects for the player's car .main4 LDA #0 \ Set configStop = 0 so we clear out any existing STA configStop \ stop-related key presses JSR ScaleWingSettings \ Scale the wing settings and calculate the wing balance \ for use in the driving model