.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 dashboardName: 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 loopContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine ApplyDrivingModel (category: Driving model)
Apply the driving model to the player's car
[X]
Subroutine BuildRoadSign (category: 3D objects)
Create an object for the road sign
[X]
Subroutine CheckForCrash (category: Car geometry)
Check to see if we have crashed into the fence, and if so, display the fence and make the crash sound
[X]
Subroutine CopyTyreDashEdges (category: Dashboard)
Fetch the pixel bytes from the right edge of the left tyre and the right edge of the dashboard, and fill to the right of the edge
[X]
Subroutine DrawCarOrSign (category: Drawing objects)
Draw a car or sign
[X]
Subroutine DrawCornerMarkers (category: Drawing objects)
Draw any visible corner markers
[X]
Subroutine DrawTrack (category: Drawing the track)
Draw the track into the screen buffer
[X]
Subroutine DrawTrackView (Part 1 of 4) (category: Screen buffer)
Draw the top part of the track view using the data in the dash data blocks
[X]
Subroutine GetTrackAndMarkers (category: Track geometry)
Calculate the 3D coordinates of the track and corner markers
[X]
Subroutine MakeDrivingSounds (category: Sound)
Make the relevant sounds for the engine and tyres
[X]
Subroutine MoveAndDrawCars (category: Car geometry)
Move the cars around the track and draw any that are visible, up to a maximum of five
[X]
Subroutine MoveHorizon (category: Screen mode)
Move the position of the horizon palette switch up or down, depending on the current track pitch angle
[X]
Subroutine MovePlayerOnTrack (category: Car geometry)
Update the position of the player's car within the current track segment
[X]
Subroutine MovePlayerSegment (category: Car geometry)
Move the player's car in the correct direction
[X]
Subroutine ProcessContact (category: Car geometry)
Process collisions between the player and the other cars
[X]
Subroutine ProcessDrivingKeys (Part 1 of 6) (category: Keyboard)
Process joystick steering
[X]
Subroutine ProcessTime (category: Main loop)
Increment the timers and the main loop counter
[X]
Subroutine ResetTrackLines (category: Screen buffer)
Reset the track lines below the horizon in the track view
[X]
Subroutine SetBackground (category: Screen buffer)
Set the background colour for any track lines that have not yet had a background colour set
[X]
Subroutine ShowStartingLights (category: Dashboard)
Show the lights at the start of the race
[X]
Subroutine UpdateLapTimers (category: Drivers)
Update the lap timers and display timer-related messages at the top of the screen
[X]
Subroutine UpdateMirrors (category: Dashboard)
Update the wing mirrors to show any cars behind us