.HeadToTrack LDA #%00101000 \ Set A to the value for practice or a qualifying lap \ (this instruction will be skipped when starting a race \ by calling HeadToTrack+2) STA raceStarted \ Set raceStarted to the value of A, so bit 7 gets set \ if this is a race, but is clear for practice or a \ qualifying lap STA raceStarting \ Set raceStarting to the value of A, which will be 128 \ if this is a race, so the starting lights get shown \ and the restrictions of the starting grid are applied \ (i.e. can't move the car, timers are disabled) \ \ If this not a race then we clear bit 7 of raceStarting \ so the restrictions are not applied .race1 JSR GetWingSettings \ Get the front and rear wing settings from the player JSR MainDrivingLoop \ Call the main driving loop to switch to the custom \ mode, implement the driving part of the game, and \ return here with the screen mode back to mode 7 BIT configStop \ If bit 6 of configStop is set then we are returning to BVS race1 \ the track after visiting the pits, so loop back to \ race1 to get new wing settings before rejoining the \ driving loop BPL race2 \ If bit 7 of configStop is clear then we did not use \ SHIFT and right arrow to exit the main driving loop, \ so jump to race2 to return from the subroutine \ If we get here then bit 6 of configStop is clear and \ bit 7 of configStop is set, which means we presses \ SHIFT and right arrow to exit the main driving loop, \ which is the key combination for restarting the whole \ game JSR RestartGame \ Jump to RestartGame to restart the game, which removes \ the return address from the stack and jumps to the \ main loop, so this call acts like JMP RestartGame .race2 RTS \ Return from the subroutineName: HeadToTrack [Show more] Type: Subroutine Category: Main Loop Summary: Get the wing settings and start a race, practice or qualifying lap Deep dive: Program flow of the main game loopContext: See this subroutine in context in the source code References: This subroutine is called as follows: * MainLoop (Part 1 of 6) calls HeadToTrack * MainLoop (Part 3 of 6) calls HeadToTrack * MainLoop (Part 5 of 6) calls via HeadToTrack+2
Other entry points: HeadToTrack+2 Called with A = %10000000 to start a race, as opposed to practice or a qualifying lap
[X]
Subroutine GetWingSettings (category: Keyboard)
Get the front and rear wing settings from the player
[X]
Subroutine MainDrivingLoop (Part 1 of 5) (category: Main loop)
Main driving loop: Switch to the track and start the main loop
[X]
Entry point RestartGame in subroutine CheckRestartKeys (category: Keyboard)
Restart the game, putting the C flag into bit 7 of pressingShiftArrow
[X]
Variable configStop in workspace Main variable workspace
A key has been pressed that stops the race
[X]
Label race1 is local to this routine
[X]
Label race2 is local to this routine
[X]
Variable raceStarted in workspace Zero page
Flag determining whether the race has started
[X]
Variable raceStarting in workspace Zero page
The current stage of the starting lights at the start of the race