.game5 LDA currentPlayer \ We have now got all the player names and qualifying STA lowestPlayerNumber \ times that we need, so store the player number in \ lowestPlayerNumber, which will contain 19 if there is \ one player, 18 if there are two, and so on \ \ Human players take the place of drivers with higher \ numbers, so the first player takes the place of driver \ 19 (the aptly called Dummy Driver, as they never get \ to race), and the second player takes the place of \ driver 18 (Peter Out), the third player replaces \ driver 17 (Rick Shaw) and so on \ \ So this not only represents the lowest player number, \ but also the highest non-human driver number (which is \ lowestPlayerNumber - 1) LDA #0 \ Sort the drivers by best lap time, putting the results JSR SortDrivers \ into positionNumber and driversInOrder, so they now \ contain the order of the drivers on the grid for the \ coming race \ We now adjust the class of the race to cater for the \ player's qualifying lap time, which makes things more \ fun for a mixed group of player skills LDX #0 \ Set X to the race class number for Novice .game6 LDY driversInOrder+19 \ Set Y to the driver number with the slowest lap time CPY lowestPlayerNumber \ If Y < lowestPlayerNumber, then driver Y is one of the BCC game8 \ computer-controlled drivers and they have the slowest \ lap time, so jump to game8 as the race class doesn't \ need changing \ Otherwise the slowest lap time is by one of the human \ players, so we now set the race class (i.e. the race \ difficulty setting) according to the figures in the \ track data) LDA bestLapSeconds,Y \ Calculate the slowest lap time minus the time for SEC \ class X from the track data, starting with the seconds SBC trackLapTimeSec,X LDA bestLapMinutes,Y \ And then the minutes SBC trackLapTimeMin,X \ Note that for X = 2 (professional), the track data \ figure is 0, so the C flag will always be set BCS game7 \ If the slowest lap time is longer than trackLapTimeMin \ from the track data, jump to game7 to consider setting \ the class to X, if it is easier than the current class \ \ In other words, if the slowest lap time is really slow \ and is by a human player, this can make the game \ easier if the race class isn't already on Novice \ \ For example, for Silverstone: \ \ * We will consider setting the class to Novice if \ the longest lap is > 1:33 and by a human player \ \ * We will consider setting the class to Amateur if \ the longest lap is <= 1:33 and > 1:29 and by a \ human player \ \ * We will consider setting the class to Professional \ if the longest lap is <= 1:29 and by a human \ player \ If we get here, the slowest lap time is quicker than \ the figure from the track data, so we now check the \ next figure from the track data and try again INX \ Increment X to the next difficulty level BNE game6 \ Jump back to game6 to check the next race class (this \ BNE is effectively a JMP as X is never zero) .game7 CPX raceClass \ If X >= raceClass then X is the same or more difficult BCS game8 \ than the current setting, so jump to game8 to leave \ the class unchanged STX raceClass \ Otherwise set the race class to the easier class in XName: MainLoop (Part 4 of 6) [Show more] Type: Subroutine Category: Main loop Summary: The main game loop: the competition race 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
This part of the main loop checks the slowest qualifying lap times to see if we should make the game easier.
[X]
Subroutine SortDrivers (category: Drivers)
Create a sorted list of driver numbers, ordered as specified
[X]
Variable bestLapMinutes in workspace Main variable workspace
Minutes of each driver's best lap time, stored in BCD
[X]
Variable bestLapSeconds in workspace Main variable workspace
Seconds of each driver's best lap time, stored in BCD
[X]
Variable currentPlayer in workspace Zero page
The number of the current player
[X]
Variable driversInOrder in workspace Stack variables
A list of driver numbers in order
[X]
Label game6 is local to this routine
[X]
Label game7 is local to this routine
[X]
Label game8 in subroutine MainLoop (Part 5 of 6)
[X]
Variable lowestPlayerNumber (category: Drivers)
The number of the player with the lowest player number
[X]
Variable raceClass (category: Drivers)
The class of the current race
[X]
Variable trackLapTimeMin in workspace trackData
Lap times for adjusting the race class (minutes)
[X]
Variable trackLapTimeSec in workspace trackData
Lap times for adjusting the race class (seconds)