.InitialiseDrivers STX setSpeedForDriver \ Set setSpeedForDriver = 0, to use as a loop counter \ when initialising all 20 drivers STX raceClass \ Set raceClass = 0 (Novice) JSR GetSectionSteering \ Set up the optimum steering for each section for a \ Novice race, storing the results in sectionSteering \ and returning with X unchanged \ The following loop works starts with X = 0, and then \ loops down from 19 to 1, working its way through each \ of the 20 drivers .driv1 TXA \ Set A to the current driver number in X STA driversInOrder,X \ Set driversInOrder for driver X to the driver number LSR A \ Set the grid row for driver X to driver number >> 1, NOP \ so drivers 0 and 1 are on row 0, drivers 2 and 3 are STA driverGridRow,X \ on row 1, and so on, up to row 9 at the back of the \ grid JSR SetDriverSpeed \ Set the base speed for driver X \ \ It also decrements X to the next driver number and \ updates setSpeedForDriver accordingly LDA #0 \ Zero (totalPointsTop totalPointsHi totalPointsLo) for STA totalPointsLo,X \ driver X STA totalPointsHi,X STA totalPointsTop,X TXA \ If X <> 0, loop back to driv1 to process the next BNE driv1 \ driver, until we have processed all 20 of them RTS \ Return from the subroutineName: InitialiseDrivers [Show more] Type: Subroutine Category: Drivers Summary: Initialise all 20 drivers on the starting gridContext: See this subroutine in context in the source code References: This subroutine is called as follows: * MainLoop (Part 1 of 6) calls InitialiseDrivers
Arguments: X The routine is always called with X = 0
[X]
Subroutine GetSectionSteering (category: Tactics)
Calculate the optimum steering for each track section
[X]
Subroutine SetDriverSpeed (category: Drivers)
Set the speed for a specific driver
[X]
Label driv1 is local to this routine
[X]
Variable driverGridRow in workspace Main variable workspace
The grid row for each driver (0 to 9)
[X]
Variable driversInOrder in workspace Stack variables
A list of driver numbers in order
[X]
Variable raceClass (category: Drivers)
The class of the current race
[X]
Variable setSpeedForDriver in workspace Zero page
The driver whose speed will be set on the next call to the SetDriverSpeed routine
[X]
Variable totalPointsHi (category: Drivers)
High byte of total accumulated points for each driver
[X]
Variable totalPointsLo (category: Drivers)
Low byte of total accumulated points for each driver
[X]
Variable totalPointsTop in workspace Main variable workspace
Top byte of total accumulated points for each driver