Skip to navigation

Revs on the BBC Micro

Drivers: InitialiseDrivers

Name: InitialiseDrivers [Show more] Type: Subroutine Category: Drivers Summary: Initialise all 20 drivers on the starting grid
Context: 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
.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 subroutine