Skip to navigation

Revs on the BBC Micro

Main loop: MainDrivingLoop (Part 2 of 5)

Name: MainDrivingLoop (Part 2 of 5) [Show more] Type: Subroutine Category: Main loop Summary: Main driving loop: The body of the main loop 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
.main5 \ The main driving loop starts here, and we loop back to \ here from part 5 JSR ProcessTime \ Increment the timers and the main loop counter, and \ set the speed for the next non-player drivers JSR ShowStartingLights \ If this is a race, show the starting lights on the \ right of the screen JSR ProcessDrivingKeys \ Check for and process the main driving keys JSR ApplyDrivingModel \ Apply the driving model to the player's car JSR GetTrackAndMarkers \ Calculate the coordinates for the track sides and \ corner markers JSR MovePlayerOnTrack \ Update the position of the player's car within the \ current track segment JSR MovePlayerSegment \ Move the player's car into the correct segment JSR UpdateLapTimers \ Update the lap timers and display timer-related \ messages at the top of the screen JSR MakeDrivingSounds \ Make the relevant sounds for the engine and tyres JSR ResetTrackLines \ Reset the track lines below the horizon in the track \ view JSR DrawTrack \ Draw the track into the screen buffer JSR MakeDrivingSounds \ Make the relevant sounds for the engine and tyres JSR SetBackground \ Set the background colour for any track lines in the \ track view that do not currently have a background set JSR BuildRoadSign \ Build the road sign (if one is visible) LDX #23 \ Draw the road sign we just built JSR DrawCarOrSign JSR DrawCornerMarkers \ Draw any visible corner markers JSR MoveAndDrawCars \ Move the cars around the track and draw any that are \ visible, up to a maximum of five JSR CopyTyreDashEdges \ Copy the pixels from the edges of the left tyre and \ right dashboard so they can be used when drawing the \ track view around the tyres and dashboard, and fill \ the blocks to the right of the edges with the \ appropriate content JSR UpdateMirrors \ Update the view in the wing mirrors JSR MakeDrivingSounds \ Make the relevant sounds for the engine and tyres JSR MoveHorizon \ Move the position of the horizon palette switch up or \ down, depending on the current track pitch angle JSR ProcessContact \ Process any car-on-car contact, if there has been any JSR CheckForCrash \ Check to see if we have crashed into the fence, and if \ so, display the fence, make the crash sound and set \ crashedIntoFence = &FF JSR DrawTrackView \ Copy the data from the dash data blocks to the screen \ to draw the track view, fitting it around the tyres \ and dashboard