Skip to navigation

Revs on the BBC Micro

List of all subroutines

This index contains every subroutine and entry point that appears in the source code for Revs, grouped by category. An entry points is a label within a subroutine that is called from outside the subroutine, which typically implements a subset or variation of the functionality of the parent subroutine.

3D objects
----------

BuildCarObjects (Part 1 of 3)Calculate the 3D coordinate of the specified car
BuildCarObjects (Part 2 of 3)Add the racing line to the 3D coordinate of the specified car
BuildCarObjects (Part 3 of 3)Calculate the screen coordinates of all the objects in the specified car
BuildPlayerCarBuild the objects for the player's car
BuildPlayerCar-1Contains an RTS
BuildRoadSignCreate an object for the road sign
BuildVisibleCarCheck the distance to the specified car and build the car object if it is close enough
CompareSegmentsCalculate the distance between two objects, in terms of the difference in their segment numbers
GetObjectAnglesCalculate the object's yaw and pitch angles, and set the object's visibility, scale and type
GetObjectAngles-2Use xCoord2 for the object's 3D coordinates in the call to GetObjYawAngle
GetObjectDistanceCalculate the distance between an object and the player's car, for collision purposes
GetObjPitchAngleCalculate an object's pitch angle
GetObjPitchAngle-2Use yPlayerCoord (Y = 0)
GetObjYawAngle (Part 1 of 4)Calculate an object's yaw angle
GetObjYawAngle (Part 2 of 4)Calculate yaw angle for when |x-delta| > |z-delta|
GetObjYawAngle (Part 3 of 4)Calculate yaw angle for when |x-delta| = |z-delta|
GetObjYawAngle (Part 4 of 4)Calculate yaw angle for when |x-delta| < |z-delta|
GetObjYawAngle-2Use xPlayerCoord (Y = 0)
HideObjectSet an object to be hidden
MoveObjectBackMove a specified object backwards along the track by one segment
MoveObjectForwardMove a specified object forwards along the track by one segment
SetObjectDetailsSet an object's visibility, scale and type
SetObjectStatusSet an object's status byte

Car geometry
------------

ChangeDirectionUpdate the track segment buffer when the player's car spins so it changes the direction in which it is facing along the track
ChangeDirection-1Contains an RTS
CheckForContactCheck to see if the object is close enough to the player car to make contact
CheckForContact-2Set Y = 37, so we make contact if (L K) <= 37
CheckForCrashCheck to see if we have crashed into the fence, and if so, display the fence and make the crash sound
CompareCarSegmentsCalculate the distance between two cars, in terms of segments and progress with the current segment
GetCarInSegmentCalculate the player car's position within the current segment
HideAllCarsSet all the cars to hidden
MoveAndDrawCarsMove the cars around the track and draw any that are visible, up to a maximum of five
MoveCars (Part 1 of 2)Move the cars around the track
MoveCars (Part 2 of 2)Move the cars forward around the track, and apply steering
MoveCars-1Contains an RTS
MovePlayerMove the player's car forwards or backwards by one segment
MovePlayerBackMove the player's car backwards by one track segment and update the track segment buffer
MovePlayerForwardMove the player's car forwards by one track segment and add the segment to the track segment buffer
MovePlayerOnTrackUpdate the position of the player's car within the current track segment
MovePlayerSegmentMove the player's car in the correct direction
PlaceCarsOnTrackPosition the cars on the track, ready for a race or qualifying lap
ProcessContactProcess collosions between the player and the other cars
PushCarOffTrackPush a car off the track and out of the race
ScaleCarInSegmentWork out how far a car is within a segment by scaling the angle in which the car is pointing
SetPlayerDriftSupRecord player drift, but only if the player is not in the first three segments of a track section
TurnPlayerAroundTurn the player around and initialise the specified number of track segments in the new direction

Dashboard
---------

AnimateTyresUpdate screen memory to animate the tyres
CopyTyreDashEdgesFetch the pixel bytes from the right edge of the left tyre and the right edge of the dashboard, and fill to the right of the edge
DrawCarInMirrorDraw a car in a specified segment of one of the wing mirrors, or clear a specified segment
DrawDashboardLineDraw a hand on the rev counter or a line on the steering wheel
DrawRevCounterDraw the hand on the rev counter
EraseRevCounterErase a line by replacing each pixel in the line with its original contents
GetTyreDashEdgeCopy the pixel bytes along the tyre and dashboard edges so they can be feathered
GetTyreDashEdgesFetch the pixel bytes from along the edge of the dashboard or tyre and fill the block to the right of the edge appropriately
GetTyreDashEdgeSupCopy the pixel bytes along the tyre and dashboard edges so they can be feathered
ShowStartingLightsShow the lights at the start of the race
UpdateDashboardUpdate the rev counter and steering wheel lines on the dashboard
UpdateMirrorsUpdate the wing mirrors to show any cars behind us

Drawing objects
---------------

DrawCarInPositionDraw the car in a specified race position
DrawCarOrSignDraw a car or sign
DrawCarsDraw all the car objects, with four objects for the closest car in front of us
DrawCornerMarkersDraw any visible corner markers
DrawEdgeDraw an edge, overwriting whatever is already on-screen
DrawObjectDraw an object of a specific type
DrawObjectEdge (Part 1 of 5)Draw the specified edge of an object part
DrawObjectEdge (Part 2 of 5)Calculate the screen address for the edge we want to draw
DrawObjectEdge (Part 3 of 5)Construct a pixel byte for the edge we want to draw
DrawObjectEdge (Part 4 of 5)Draw the edge into the screen buffer, merging with any content already in the buffer
DrawObjectEdge (Part 5 of 5)Fill the object if required and loop back for the next edge
DrawObjectEdge-1Contains an RTS
DrawObjectEdgesDraw all the parts of an object by drawing edges into the screen buffer
FillAfterObjectFill the block to the right of an object
FillAfterObjectSupFill the block to the right of an object
FillInsideObjectFill the object part from the previous edge to the current edge
ScaleObjectScale an object's scaffold by the scale factors in scaleUp and scaleDown

Drawing pixels
--------------

GetScreenAddressReturn the screen address for a specified screen coordinate
GetScreenAddress-2Treat the x-coordinate as a character column number rather than a pixel coordinate (0 to 39)

Drawing the track
-----------------

CheckVergeOnScreenCheck whether a verge coordinate is on-screen
DrawGrassLeftDraw a green byte into the screen buffer in the first dash data block for the edge
DrawGrassRightDraw a green byte into the screen buffer in the second dash data block for the edge
DrawSegmentEdge (Part 1 of 7)Draw a single segment's edge as part of a whole track verge edge
DrawSegmentEdge (Part 2 of 7)Set up the edge's gradient
DrawSegmentEdge (Part 3 of 7)Modify the drawing routines according to the edge gradient
DrawSegmentEdge (Part 4 of 7)Set variables to use when updating the background colour
DrawSegmentEdge (Part 5 of 7)Calculate the dash data block and screen addresses for the edge
DrawSegmentEdge (Part 6 of 7)Calculate the dash data block for the edge
DrawSegmentEdge (Part 7 of 7)Save the angles for the next call to DrawSegmentEdge and return from the subroutine
DrawShallowToLeftDraw a verge edge with a shallow gradient from right to left
DrawShallowToRightDraw a verge edge with a shallow gradient from left to right
DrawSteepToLeftDraw a verge edge with a steep gradient from right to left
DrawSteepToRightDraw a verge edge with a steep gradient from left to right
DrawTrackDraw the track into the screen buffer
DrawVergeByteLeftDraw two bytes into the screen buffer in the first and second dash data blocks for the edge
DrawVergeByteRightDraw two bytes into the screen buffer in the second and third dash data blocks for the edge
DrawVergeEdgeDraw one of the four track verge edges into the screen buffer
MapSegmentsToLinesMap verges in the track segment list to track lines in the track view
SetVergeBackgroundUpdate the background colour table for any verges that overlap the left edge of the screen
StopDrawingEdgeStop drawing the current segment's verge edge
UpdateBackgroundUpdate the background colour table for when we draw a verge edge off the left edge of the screen

Drivers
-------

AddRacePointsAdd the race points to the driver's total points
AddTimeToTimerAdd time to the specified timer
AwardRacePointsAward points following a race
ClearTotalRaceTimeClear a specified driver's total race time following the end of an incomplete race
GetPositionAheadDecrement X to the previous position number (from 19 to 0 and round again), which gives the position ahead of X
GetPositionBehindIncrement X to the next position number (from 0 to 19 and round again), which gives the position behind X
InitialiseDriversInitialise all 20 drivers on the starting grid
ResetBestLapTimeReset the best lap time to 10:00.0 for a specific driver
ResetBestLapTimesReset the best lap times to 10:00.0 for all drivers
SetDriverSpeedSet the speed for a specific driver
SetPlayerPositionsSet the current player's position, plus the positions behind and in front
SortDriversCreate a sorted list of driver numbers, ordered as specified
SwapDriverPositionSwap the position for two drivers (i.e. overtake)
UpdateLapsIncrement the lap number and lap times for a specific driver
UpdateLapTimersUpdate the lap timers and display timer-related messages at the top of the screen
ZeroTimerZero the specified timer

Driving model
-------------

AddSteeringForceAdd the steering force to xVelocity or xTyreForceNose
ApplyBounceApply a bounce to the player's car when it hits the ground
ApplyDeltasApply the deltas in the x-axis and z-axis to the player's coordinates
ApplyDrivingModelApply the driving model to the player's car
ApplyElevation (Part 1 of 5)Calculate changes in the car's elevation
ApplyElevation (Part 2 of 5)Calculate the player's heading and sideways flag
ApplyElevation (Part 3 of 5)Calculate player's elevation above the track
ApplyElevation (Part 4 of 5)Calculate the height of the car above the track
ApplyElevation (Part 5 of 5)Calculate the player's 3D y-coordinate and progress speed
ApplyEngineApply the effects of the engine
ApplyGrassOrTrackApply the effects of driving or braking on grass
ApplyLimitAndSignApply a maximum limit and a sign to a 16-bit number
ApplyLimitThrottleApply a maximum limit to a 16-bit number, unless the throttle is being applied
ApplySkidForcesCalculate the tyre forces when the car is skidding
ApplySpinYawCalculate variables based on the spin yaw angle
ApplySteeringForceApply steering to xTyreForceNose and zTyreForceNose
ApplySteeringSpeedApply steering to the car's speed in xVelocity and zVelocity
ApplyTyreForcesCalculate the tyre forces on the car
ApplyTyresAndSkidsCalculate the forces on the front or rear tyres and apply skid forces and sound effects where applicable
ApplyVergeJumpApply a jump to the player's car when hitting the track verge
ApplyWingBalanceApply the effect of the wing settings
CalcRevsNoTorqueCalculate the value of the rev counter according to the throttle being applied and zero the engine torque
CalcRevsNoTorque-2Set clutchEngaged to A before running the routine
GetTyreForcesCalculate the tyre forces due to the throttle or brakes
ProcessEngineStartProcess the key press for starting the engine
ScaleTyreForcesScale the tyre forces and calculate the combined tyre force on the player
ScaleWingSettingsScale the wing settings and calculate the wing balance, for use in the driving model
SetEngineTorqueSet engineTorque and soundRevTarget
SetRevsNoTorqueSet the rev counter and zero the engine torque
SquealTyresMake the tyres squeal
ThrobRevsNoTorqueSet the rev counter after adding a random throb and zero the engine torque
UpdateVelocityUpdate the player's velocity and spin yaw angle
ZeroEngineTorqueZero engineTorque

Extra tracks
------------

CalcSegmentVector (Brands Hatch)Calculate the segment vector for the current segment
CalcSegmentVector (Donington Park)Calculate the segment vector for the current segment
CalcSegmentVector (Nürburgring)Calculate the segment vector for the current segment
CalcSegmentVector (Oulton Park)Calculate the segment vector for the current segment
CalcSegmentVector (Snetterton)Calculate the segment vector for the current segment
CallTrackHook (Brands Hatch)The track file's hook code
CallTrackHook (Donington Park)The track file's hook code
CallTrackHook (Nürburgring)The track file's hook code
CallTrackHook (Oulton Park)The track file's hook code
CallTrackHook (Snetterton)The track file's hook code
Hook80Percent (Brands Hatch)Set the horizonTrackWidth to 80% of the width of the track on the horizon
Hook80Percent (Donington Park)Set the horizonTrackWidth to 80% of the width of the track on the horizon
Hook80Percent (Nürburgring)Set the horizonTrackWidth to 80% of the width of the track on the horizon
Hook80Percent (Oulton Park)Set the horizonTrackWidth to 80% of the width of the track on the horizon
Hook80Percent (Snetterton)Set the horizonTrackWidth to 80% of the width of the track on the horizon
HookBackground (Donington Park)Do not update the background colour when the track line above is showing green for the leftTrackStart verge
HookBackground (Snetterton)Do not update the background colour when the track line above is showing green for the leftTrackStart verge
HookDataPointers (Brands Hatch)If the current section is dynamically generated, update the data pointers
HookDataPointers (Donington Park)If the current section is dynamically generated, update the data pointers
HookDataPointers (Nürburgring)If the current section is dynamically generated, update the data pointers
HookDataPointers (Oulton Park)If the current section is dynamically generated, update the data pointers
HookDataPointers (Snetterton)If the current section is dynamically generated, update the data pointers
HookFieldOfView (Brands Hatch)When populating the verge buffer in GetSegmentAngles, don't give up so easily when we get segments outside the field of view
HookFieldOfView (Donington Park)When populating the verge buffer in GetSegmentAngles, don't give up so easily when we get segments outside the field of view
HookFieldOfView (Nürburgring)When populating the verge buffer in GetSegmentAngles, don't give up so easily when we get segments outside the field of view
HookFieldOfView (Oulton Park)When populating the verge buffer in GetSegmentAngles, don't give up so easily when we get segments outside the field of view
HookFieldOfView (Snetterton)When populating the verge buffer in GetSegmentAngles, don't give up so easily when we get segments outside the field of view
HookFirstSegment (Brands Hatch)Move to the next to the next segment vector along the track and calculate the segment vector
HookFirstSegment (Donington Park)Move to the next to the next segment vector along the track and calculate the segment vector
HookFirstSegment (Nürburgring)Move to the next to the next segment vector along the track and calculate the segment vector
HookFirstSegment (Oulton Park)Move to the next to the next segment vector along the track and calculate the segment vector
HookFirstSegment (Snetterton)Move to the next to the next segment vector along the track and calculate the segment vector
HookFixHorizon (Brands Hatch)Apply the horizon line in A instead of horizonLine
HookFixHorizon (Donington Park)Apply the horizon line in A instead of horizonLine
HookFixHorizon (Nürburgring)Apply the horizon line in A instead of horizonLine
HookFixHorizon (Oulton Park)Apply the horizon line in A instead of horizonLine
HookFixHorizon (Snetterton)Apply the horizon line in A instead of horizonLine
HookFlattenHills (Brands Hatch)Flatten any hills in the verge buffer, calculate the hill height and track width, cut objects off at the hill height
HookFlattenHills (Donington Park)Flatten any hills in the verge buffer, calculate the hill height and track width, cut objects off at the hill height
HookFlattenHills (Oulton Park)Flatten any hills in the verge buffer, calculate the hill height and track width, cut objects off at the hill height
HookFlattenHills (Part 2 of 2) (Snetterton)Flatten any hills in the verge buffer, calculate the hill height and track width, cut objects off at the hill height
HookFlattenHills (Part 1 of 2) (Snetterton)Flatten any hills in the verge buffer, calculate the hill height and track width, cut objects off at the hill height
HookFlattenHills (Part 2 of 3) (Nürburgring)Flatten any hills in the verge buffer, calculate the hill height and track width, cut objects off at the hill height
HookFlattenHills (Part 3 of 3) (Nürburgring)Flatten any hills in the verge buffer, calculate the hill height and track width, cut objects off at the hill height
HookFlattenHills (Part 1 of 3) (Nürburgring)Flatten any hills in the verge buffer, calculate the hill height and track width, cut objects off at the hill height
HookFlipAbsolute (Brands Hatch)Set the sign of A according to the direction we are facing along the track
HookFlipAbsolute (Donington Park)Set the sign of A according to the direction we are facing along the track
HookFlipAbsolute (Nürburgring)Set the sign of A according to the direction we are facing along the track
HookFlipAbsolute (Oulton Park)Set the sign of A according to the direction we are facing along the track
HookFlipAbsolute (Snetterton)Set the sign of A according to the direction we are facing along the track
HookForward (Donington Park)Move the player forward by an extra segment when edgeSegmentNumber is 10
HookJoystick (Brands Hatch)Apply enhanced joystick steering to specific track sections
HookJoystick (Part 2 of 2) (Nürburgring)Apply enhanced joystick steering to specific track sections
HookJoystick (Part 1 of 2) (Nürburgring)Apply enhanced joystick steering to specific track sections
HookJoystick (Part 2 of 2) (Oulton Park)Apply enhanced joystick steering to specific track sections
HookJoystick (Part 1 of 2) (Oulton Park)Apply enhanced joystick steering to specific track sections
HookJoystick (Part 3 of 3) (Donington Park)Apply enhanced joystick steering to specific track sections
HookJoystick (Part 1 of 3) (Donington Park)Apply enhanced joystick steering to specific track sections
HookJoystick (Part 2 of 3) (Donington Park)Apply enhanced joystick steering to specific track sections
HookJoystick (Part 3 of 3) (Snetterton)Apply enhanced joystick steering to specific track sections
HookJoystick (Part 1 of 3) (Snetterton)Apply enhanced joystick steering to specific track sections
HookJoystick (Part 2 of 3) (Snetterton)Apply enhanced joystick steering to specific track sections
HookMoveBack (Brands Hatch)Only move the player backwards if the player has not yet driven past the segment
HookMoveBack (Donington Park)Only move the player backwards if the player has not yet driven past the segment
HookMoveBack (Nürburgring)Only move the player backwards if the player has not yet driven past the segment
HookMoveBack (Oulton Park)Only move the player backwards if the player has not yet driven past the segment
HookMoveBack (Snetterton)Only move the player backwards if the player has not yet driven past the segment
HookSectionFrom (Brands Hatch)Initialise and calculate the current segment vector
HookSectionFrom (Donington Park)Initialise and calculate the current segment vector
HookSectionFrom (Nürburgring)Initialise and calculate the current segment vector
HookSectionFrom (Oulton Park)Initialise and calculate the current segment vector
HookSectionFrom (Snetterton)Initialise and calculate the current segment vector
HookSegmentVector (Brands Hatch)If the current section is dynamically generated, move to the next segment vector, calculate it and store it
HookSegmentVector (Donington Park)If the current section is dynamically generated, move to the next segment vector, calculate it and store it
HookSegmentVector (Nürburgring)If the current section is dynamically generated, move to the next segment vector, calculate it and store it
HookSegmentVector (Oulton Park)If the current section is dynamically generated, move to the next segment vector, calculate it and store it
HookSegmentVector (Snetterton)If the current section is dynamically generated, move to the next segment vector, calculate it and store it
HookSlopeJump (Brands Hatch)Jump the car when driving fast over sloping segments
HookSlopeJump (Donington Park)Jump the car when driving fast over sloping segments
HookSlopeJump (Nürburgring)Jump the car when driving fast over sloping segments
HookSlopeJump (Oulton Park)Jump the car when driving fast over sloping segments
HookSlopeJump (Snetterton)Jump the car when driving fast over sloping segments
HookUpdateHorizon (Brands Hatch)Only update the horizon if we have found fewer than 12 visible segments
HookUpdateHorizon (Donington Park)Only update the horizon if we have found fewer than 12 visible segments
HookUpdateHorizon (Nürburgring)Only update the horizon if we have found fewer than 12 visible segments
HookUpdateHorizon (Oulton Park)Only update the horizon if we have found fewer than 12 visible segments
HookUpdateHorizon (Snetterton)Only update the horizon if we have found fewer than 12 visible segments
ModifyGameCode (Part 3 of 3) (Brands Hatch)Modify the game code to support the extra track data
ModifyGameCode (Part 1 of 3) (Brands Hatch)Modify the game code to support the extra track data
ModifyGameCode (Part 2 of 3) (Brands Hatch)Modify the game code to support the extra track data
ModifyGameCode (Part 3 of 3) (Nürburgring)Modify the game code to support the extra track data
ModifyGameCode (Part 2 of 3) (Nürburgring)Modify the game code to support the extra track data
ModifyGameCode (Part 3 of 3) (Oulton Park)Modify the game code to support the extra track data
ModifyGameCode (Part 1 of 3) (Oulton Park)Modify the game code to support the extra track data
ModifyGameCode (Part 2 of 3) (Oulton Park)Modify the game code to support the extra track data
ModifyGameCode (Part 3 of 3) (Snetterton)Modify the game code to support the extra track data
ModifyGameCode (Part 1 of 3) (Snetterton)Modify the game code to support the extra track data
ModifyGameCode (Part 2 of 3) (Snetterton)Modify the game code to support the extra track data
ModifyGameCode (Part 4 of 4) (Donington Park)Modify the game code to support the extra track data
ModifyGameCode (Part 3 of 4) (Donington Park)Modify the game code to support the extra track data
ModifyGameCode (Part 1 of 4) (Donington Park)Modify the game code to support the extra track data
ModifyGameCode (Part 2 of 4) (Donington Park)Modify the game code to support the extra track data
ModifyGameCode (Part 1 of 4) (Nürburgring)Modify the game code to support the extra track data
MoveToNextVector (Brands Hatch)Move to the next to the next segment vector along the track and update the pointers
MoveToNextVector (Donington Park)Move to the next to the next segment vector along the track and update the pointers
MoveToNextVector (Nürburgring)Move to the next to the next segment vector along the track and update the pointers
MoveToNextVector (Oulton Park)Move to the next to the next segment vector along the track and update the pointers
MoveToNextVector (Snetterton)Move to the next to the next segment vector along the track and update the pointers
Multiply80Percent (Donington Park)Calculate (A T) = 0.80 * A
Multiply8x8Signed (Brands Hatch)Multiply two 8-bit numbers, one of which is signed
Multiply8x8Signed (Donington Park)Multiply two 8-bit numbers, one of which is signed
Multiply8x8Signed (Nürburgring)Multiply two 8-bit numbers, one of which is signed
Multiply8x8Signed (Oulton Park)Multiply two 8-bit numbers, one of which is signed
Multiply8x8Signed (Snetterton)Multiply two 8-bit numbers, one of which is signed
SetSegmentVector (Brands Hatch)Add the yaw angle and height deltas to the yaw angle and height (for curved sections) and calculate the segment vector
SetSegmentVector (Donington Park)Add the yaw angle and height deltas to the yaw angle and height (for curved sections) and calculate the segment vector
SetSegmentVector (Nürburgring)Add the yaw angle and height deltas to the yaw angle and height (for curved sections) and calculate the segment vector
SetSegmentVector (Oulton Park)Add the yaw angle and height deltas to the yaw angle and height (for curved sections) and calculate the segment vector
SetSegmentVector (Snetterton)Add the yaw angle and height deltas to the yaw angle and height (for curved sections) and calculate the segment vector
UpdateDataPointers (Brands Hatch)Update the sub-section and segment numbers to point to the next segment along the track in the correct direction
UpdateDataPointers (Donington Park)Update the sub-section and segment numbers to point to the next segment along the track in the correct direction
UpdateDataPointers (Nürburgring)Update the sub-section and segment numbers to point to the next segment along the track in the correct direction
UpdateDataPointers (Oulton Park)Update the sub-section and segment numbers to point to the next segment along the track in the correct direction
UpdateDataPointers (Snetterton)Update the sub-section and segment numbers to point to the next segment along the track in the correct direction

Keyboard
--------

CheckRestartKeysIf the restart keys are being pressed, restart the game
GetADCChannelRead the value of an ADC channel (used to read the joystick)
GetDriverNameFetch a player's name from the keyboard
GetMenuOptionScan the keyboard for a menu entry number, highlight the choice, show the SPACE bar message and return the choice number
GetNumberInputFetch a number between 0 and 40 from the keyboard
GetTextInputFetch a string from the keyboard, padded with spaces if required
GetWingSettingsGet the front and rear wing settings from the player
ProcessDrivingKeys (Part 1 of 6)Process joystick steering
ProcessDrivingKeys (Part 2 of 6)Process keyboard steering
ProcessDrivingKeys (Part 3 of 6)Process joystick brake and throttle
ProcessDrivingKeys (Part 4 of 6)Process keyboard brake and throttle
ProcessDrivingKeys (Part 5 of 6)Process joystick gear change
ProcessDrivingKeys (Part 6 of 6)Process keyboard gear change
ProcessShiftedKeysCheck for shifted keys (i.e. those that need SHIFT holding down to trigger) and process them accordingly
RestartGameRestart the game, putting the C flag into bit 7 of pressingShiftArrow
ScanKeyboardScan the kayboard for a specific key press
ScanKeyboard-1Contains an RTS
SetSteeringLimitApply a maximum limit to the amount of steering
WaitForSpacePrint a prompt, wait for the SPACE key to be released, and wait for SPACE to be pressed
WaitForSpaceReturnPrint a prompt, wait for the SPACE key to be released, and wait for either SPACE or RETURN to be pressed

Main loop
---------

DelayDelay for a specified number of loops
FinishRaceContinue running the race until all the non-player drivers have finished and we have a result
HeadToTrackGet the wing settings and start a race, practice or qualifying lap
HeadToTrack+2Called with A = %10000000 to start a race, as opposed to practice or a qualifying lap
MainDrivingLoop (Part 1 of 5)Main driving loop: Switch to the track and start the main loop
MainDrivingLoop (Part 2 of 5)Main driving loop: The body of the main loop
MainDrivingLoop (Part 3 of 5)Main driving loop: Process rejoining the race or lap after a crash
MainDrivingLoop (Part 4 of 5)Main driving loop: Leave the track
MainDrivingLoop (Part 5 of 5)Main driving loop: Process driving keys, potentially leaving the track, and loop back to part 2
MainLoop (Part 1 of 6)The main game loop: practice laps
MainLoop (Part 2 of 6)The main game loop: competition setup
MainLoop (Part 3 of 6)The main game loop: qualifying laps
MainLoop (Part 4 of 6)The main game loop: the competition race
MainLoop (Part 5 of 6)The main game loop: the competition race
MainLoop (Part 6 of 6)The main game loop: race points and competition results
ProcessTimeIncrement the timers and the main loop counter
ResetVariablesReset a number of variables for driving, and print the top two text lines

Maths (Arithmetic)
------------------

Absolute16BitCalculate the absolute value (modulus) of a 16-bit number
Absolute8BitCalculate the absolute value (modulus) of an 8-bit number
ConvertNumberToBCDConvert a number into binary coded decimal (BCD), for printing
Divide8x8Calculate T = 256 * A / V
Multiply16x16Multiply a sign-magnitude 16-bit number and a signed 16-bit number
Multiply8x16Multiply an 8-bit and a 16-bit number
Multiply8x16SignedMultiply an 8-bit and a 16-bit number and apply a sign to the result
Multiply8x8Calculate (A T) = T * U
Multiply8x8+2Calculate (A T) = T * U
MultiplyBy1Point5Multiply a 16-bit signed number by 1.5
MultiplyCoordsMultiply a 16-bit coordinate value and a 16-bit factor, optionally tallying or changing the sign of the result
MultiplyCoords+7Use the following variables instead of the above: * Y = Offset of the 16-bit signed number to multiply (instead of N)
Negate16BitNegate a 16-bit number
Negate16Bit+2Set (A T) = -(U T)
Scale16BitScale up a 16-bit value by 2^5

Maths (Geometry)
----------------

AddCoordsAdd to a specified coordinate variable
AddScaledVectorAdd a scaled vector to another vector, one axis at a time
AddVectorsAdd two three-axis vectors together
GetAngleInRadiansConvert a 16-bit angle into radians, restricted to a quarter circle
GetRotationMatrix (Part 1 of 5)Calculate the rotation matrix for rotating the player's yaw angle into the global 3D coordinate system
GetRotationMatrix (Part 2 of 5)Calculate sin(H G) for smaller angles
GetRotationMatrix (Part 3 of 5)Calculate sin(H G) for bigger angles
GetRotationMatrix (Part 4 of 5)Loop back to calculate cos instead of sin
GetRotationMatrix (Part 5 of 5)Apply the correct signs to the result
HalveCoordinateHalve a coordinate with three 16-bit axes
RotateCarToCoordRotate a vector from the frame of reference of the player's car into the 3D world coordinate system
RotateCoordToCarRotate a vector from the 3D world coordinate system into the frame of reference of the player's car
RotateVectorRotate a vector by a rotation matrix
SubtractCoordsSubtract from a specified coordinate variable

Screen buffer
-------------

CheckDashDataCheck whether a dash data block index is pointing to dash data
CopyDashDataCopy the dash data from the main game code to screen memory, and vice versa
DrawFence (Part 2 of 2)Draw the fence that we crash into when running off the track
DrawFence (Part 1 of 2)Draw the fence that we crash into when running off the track
DrawFence-1Contains an RTS
DrawTrackBytes (Part 1 of 3)Draw the pixel bytes that make up the track view (0 to 15)
DrawTrackBytes (Part 2 of 3)Draw the pixel bytes that make up the track view (16 to 39)
DrawTrackBytes (Part 3 of 3)Return from the subroutine
DrawTrackLine (Part 2 of 2)Draw a pixel line across the screen in the track view
DrawTrackLine (Part 1 of 2)Draw a pixel line across the screen in the track view, broken up into bytes
DrawTrackView (Part 4 of 4)Revert all the code modifications made by the DrawTrackView routine
DrawTrackView (Part 1 of 4)Draw the top part of the track view using the data in the dash data blocks
DrawTrackView (Part 2 of 4)Draw the part of the track view that fits around the dashboard
DrawTrackView (Part 3 of 4)Draw the part of the track view that fits around the dashboard and tyres
GetColour (Part 1 of 3)Calculate the colour of a specific pixel byte in the screen buffer
GetColour (Part 2 of 3)Process the left verge
GetColour (Part 3 of 3)Process the right verge
GetColourSupCalculate the colour of a specific pixel byte in the screen buffer
ResetTrackLinesReset the track lines below the horizon in the track view
SetBackgroundSet the background colour for any track lines that have not yet had a background colour set
SetMarkerInsert a marker value into a dash data block
SetMarker+3Use the value of A passed to the routine SetMarker+6 Use Y and V in place of A and Y
SetMarker+6Use Y and V in place of A and Y

Screen mode
-----------

KillCustomScreenDisable the custom screen mode and switch to mode 7
MoveHorizonMove the position of the horizon palette switch up or down, depending on the current track pitch angle
ScreenHandlerThe IRQ handler for the custom screen mode
ScreenHandler-3Jump to the original IRQ handler
SetCustomScreenSwitch to the custom screen mode
SetScreenMode7Change to screen mode 7 and hide the cursor

Setup
-----

CallTrackHookThe track file's hook code
EntryThe main entry point for the game: move code into upper memory and call it
MoveCodeMove and reset various blocks around in memory
ProtectDecrypt or unprotect the game code (disabled)
SetupGameDecrypt or unprotect the game code (disabled)
SwapCodeMove the track data to the right place and run a checksum on it

Sound
-----

DefineEnvelopeDefine a sound envelope
FlushSoundBufferFlush the specified sound buffer
FlushSoundBuffersFlush all four specified sound buffers
MakeDrivingSoundsMake the relevant sounds for the engine and tyres
MakeSoundMake a sound
MakeSound-3Make the sound at the current volume level
MakeSoundEnvelopeEither make a sound or set up an envelope

Tactics
-------

AssistSteeringApply computer assisted steering (CAS) when configured
AssistSteeringKeysFor keyboard-controlled steering
GetSectionSteeringCalculate the optimum steering for each track section
GetSegmentSteeringCalculate the optimum steering to take for the current track segment
GetSteeringAssistFetch the current computer assisted steering (CAS) status and show or hide the CAS indicator
ProcessOvertaking (Part 1 of 3)Process all cars for overtaking manoeuvres, checking first to see if the car has just finished overtaking the car in front
ProcessOvertaking (Part 2 of 3)The car we are processing has not overtaken the car in front of it, so if applicable, we can keep maneouvring into position
ProcessOvertaking (Part 3 of 3)Update the car status (if configured) and loop back for the next car

Text
----

GetDriverAddressGet the address of the specified driver's name
GetNumberFromTextConvert a two-digit string into a number
Print234DigitBCDPrint a specific driver's accumulated points as a padded two-, three- or four-digit number
Print2DigitBCDPrint a binary coded decimal (BCD) number in the specified format
Print2DigitBCD-6Print the number at screen coordinate (X, Y), where X is the character column and Y is the pixel row of the bottom of the character
Print4DigitBCDPrint a specific driver's accumulated points as a four-digit number
Print4DigitBCD+3Do not print the first two digits (i.e. omit printing A)
PrintBestLapTimePrint the best lap time and the current lap time at the top of the screen
PrintCharacterPrint a character on-screen
PrintCharacter-6Print double-width character (this is used to print the double-width number on the gear stick)
PrintDriverNamePrint a driver's name
PrintDriverPromptPrint the "DRIVER ->" prompt and a driver's name, to show whose turn it is next when playing a multi-player game
PrintDriverTablePrint the table of drivers
PrintFirstLinePrints a text token on the first text line at the top of the driving screen
PrintFirstLine+2Print the token on the second text line at the top of the driving screen
PrintGearNumberPrint the number of the current gear in double-width characters on the gear stick
PrintHeaderConfigure and print a double-height header in screen mode 7
PrintHeaderChecksPrint chequered lines above and below the header
PrintLapTimePrint the current lap time at the top of the screen
PrintLapTime+2Format the lap time using the format value in A (see PrintTimer for details)
PrintNearestDriverPrint a driver's name in the "In front" or "Behind" slot in the header
PrintPositionNamePrint the name of the driver in a specific position in the driver position list
PrintRaceClassPrint the race class
PrintSecondLinePrints a text token on the second text line at the top of the driving screen
PrintSecondLineGapPrints a text token on the second text line at the top of the driving screen, with an empty gap on the line above
PrintSpacesPrint the specified number of spaces
PrintTimerPrint the specified timer
PrintTokenPrint a recursive token
SetRowColoursSet the foreground and background colorus for a table row
UpdatePositionInfoApply any position changes and update the position information at the top of the screen

Track data
----------

CallTrackHook (Silverstone)The track file's hook code

Track geometry
--------------

CopySectionDataCopy a 16-bit y-coordinate from the track section data
GetFirstSegmentGet the track section coordinates and flags from the track data and populate the first track segment
GetPlayerIndexSet the index for the player's segment in the track section buffer to be 32 segments behind the front segment
GetSectionAngles (Part 1 of 3)Get the yaw and pitch angles for the inner and outer track sections
GetSectionAngles (Part 2 of 3)Calculate the track section number for this track section entry
GetSectionAngles (Part 3 of 3)Calculate the yaw and pitch angles for the track section entry that we want to update
GetSectionAngles-1Contains an RTS
GetSectionCoordCopy a three-part 16-bit coordinate from the track section data
GetSectionCoordsCopy two three-part 16-bit coordinates from the track section data
GetSectionYawAngleCalculate the difference in yaw angle between an object and the player
GetSegmentAngles (Part 1 of 3)Get the yaw and pitch angles for the inner or outer track segments
GetSegmentAngles (Part 2 of 3)Process a segment that is not visible by trying to process a segment that's one-quarter of the size
GetSegmentAngles (Part 3 of 3)Process a visible segment
GetSegmentDetailsGet the details for the segment in front or behind
GetSegmentVectorFetch a segment vector from the track data file
GetSegmentYawAngleCalculate the difference in yaw angle between a track segment and the player
GetTrackAndMarkersCalculate the 3D coordinates of the track and corner markers
GetTrackSegment (Part 1 of 3)Set up the next track segment in the track segment buffer
GetTrackSegment (Part 2 of 3)Set the flags for the new front segment in the track segment buffer
GetTrackSegment (Part 3 of 3)Set the inner and outer track coordinates for the new track segment
GetVergeAndMarkers (Part 1 of 4)Get the details for a segment's corner markers and verge marks
GetVergeAndMarkers (Part 2 of 4)Calculate the segment's verge width and outside verge coordinates
GetVergeAndMarkers (Part 3 of 4)Process the segment's corner markers
GetVergeAndMarkers (Part 4 of 4)Store details of the segment's verge marks
IncSectionPointersIncrement the track section list pointers following a shuffle
MultiplyHeightMultiply the height above ground of a specified track segment by A
SetSectionPointersSet the track section list pointer to a specific value and update the validity pointer accordingly
ShuffleSectionListShuffle the track section list along by one position
SpinTrackSectionApply spin to a section in the track section list
UpdateCurveVectorMove to the next segment vector along in the direction we are facing, but only for curved track sections
UpdateVectorNumberMove to the next segment vector along the track in the direction we are facing