Skip to navigation

Revs on the BBC Micro

Main Loop: HeadToTrack

Name: 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 loop
Context: 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
.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 subroutine