Skip to navigation

Revs on the BBC Micro

Workspaces: Zero page

Name: Zero page [Show more] Type: Workspace Address: &0070 to &008F Category: Workspaces Summary: Mainly temporary variables that are used a lot
Context: See this workspace in context in the source code References: No direct references to this workspace in this source file
ORG &0000 .playerMoving SKIP 1 \ Flag to denote whether the player's car is moving \ \ * 0 = player's car is not moving \ \ * Non-zero = player's car is moving .thisSectionFlags SKIP 1 \ The track section flags for the current track section .thisVectorNumber SKIP 1 \ The number of the segment vector for the current track \ segment, ready to store in the track segment buffer \ as segmentVector .currentPosition SKIP 1 \ The position of the current player \ \ This refers to the current player's position in the \ driversInOrder list .thisSectionNumber SKIP 1 \ The number * 8 of the current section number when \ calculating the track verges .sectionListStart SKIP 1 \ The start index of the track section list that's \ used when calculating the positions of the track \ verges \ \ The list runs from index sectionListStart up to 6 .sectionListValid SKIP 1 \ The index of the first valid entry in the track \ section list \ \ The list runs from index sectionListStart up to 6, and \ valid entries run from index sectionListValid up to 6 \ \ Set to 6 in ResetVariables to indicate that the list \ does not yet contain any valid entries .sectionListSize SKIP 1 \ The size of the track section list that's used when \ calculating the positions of the track verges .sectionListPointer SKIP 1 \ The index of the current entry in the track section \ list, as we only update one entry in the list on each \ iteration of the main driving loop \ \ The list runs from index sectionListStart up to 6 \ \ Set to 6 in ResetVariables .oddsOfEngineStart SKIP 1 \ The chances of the engine starting while revving the \ engine (the engine will start with a chance of 1 in \ oddsOfEngineStart) \ \ Set to 7 in ResetVariables .playerYawAngleLo SKIP 1 \ Low byte of the player's yaw angle \ \ This is the left-right rotation of the player's car \ \ Stored as a 16-bit value (playerYawAngleHi \ playerYawAngleLo) .playerYawAngleHi SKIP 1 \ High byte of the player's yaw angle \ \ This is the left-right rotation of the player's car \ \ Stored as a 16-bit value (playerYawAngleHi \ playerYawAngleLo) .vectorNumber SKIP 1 \ The segment vector number when building car objects \ in the BuildCarObjects routine .playerPitchAngle SKIP 1 \ The player's pitch angle \ \ This is the up-down rotation of the player's car .segmentOffset SKIP 1 \ The offset to use for the segment being processed in \ the GetSegmentAngles routine \ \ * 0 when our car is facing in the same direction \ \ * 120 when our car is facing the opposite direction .leaveTrackTimer SKIP 1 \ The leave track timer \ \ When set to a non-zero figure, the timer starts to \ count down by one every iteration of the main loop, \ until it reaches 1, at which point we leave the track \ \ During the countdown we are unable to accelerate or \ brake, but can steer .edgeDistanceLo SKIP 1 \ Low byte of the distance between the player's car and \ the nearest track edge \ \ Stored as a 16-bit value (edgeDistanceHi \ edgeDistanceLo) .edgeDistanceHi SKIP 1 \ High byte of the distance between the player's car and \ the nearest track edge \ \ Stored as a 16-bit value (edgeDistanceHi \ edgeDistanceLo) .segmentListPointer SKIP 1 \ The index of the current entry in the track segment \ list \ \ As the segment list for the left side of the track is \ populated after the right side, this gives us the \ index of the last entry for the left side of the track \ once it has been populated \ \ segmentListRight gives us the equivalent index for the \ the right side of the track \ \ The list runs from index 6 upwards .edgeSegmentNumber SKIP 1 \ The number of the segment within the track segment \ list that is closest to the player's car .prevSegmentOffset SKIP 1 \ The segment coordinate offset for the previous segment \ when adding segments to the track segment list .segmentListRight SKIP 1 \ The index of the last entry in the track segment \ list for the right side of the track \ \ segmentListPointer gives us the equivalent index for \ the left side of the track .previousSteering SKIP 1 \ The previous value of sectionSteering when calculating \ the optimum steering for a track segment .turnCounter SKIP 1 \ A counter for the length of turn when calculating the \ optimum steering for a track segment .prevDriverSpeed06 SKIP 1 \ Bits 0-6 of the previous value of trackDriverSpeed \ when calculating the optimum steering for a track \ segment .gearChange SKIP 1 \ Used to store the direction of the gear change \ \ * 1 = change up \ \ * 0 = no gear change \ \ * -1 = change down .debugSpinning SKIP 1 \ This variable is never read, but is set to 64 and back \ to 0 when the car spins past the point where it \ changes the direction that it is facing along the \ track \ \ Perhaps it was used for debugging the spinning \ routines? .thisPitchIndex SKIP 0 \ The index of the pitch angle in the track segment list \ for the verge we are processing .thisObjectIndex SKIP 0 \ The index of the current object part's data as we work \ our way through an object's constituent parts .rowCounter SKIP 1 \ The table row number when printing the driver tables .pressingShiftArrow SKIP 1 \ Bit 7 is set if we are pressing SHIFT and right arrow \ (which restarts the game) .thisPosition SKIP 1 \ The position of the car that we are analysing in the \ MoveAndDrawCars routine .vergeOnScreenEdge SKIP 1 \ Determines whether the verge edge we are drawing for \ the current segment is partially off-screen \ \ * 0 = Edge is either wholly on-screen or off-screen \ \ * &FF = Edge is partially off-screen .horizonLine SKIP 1 \ The track line number of the horizon \ \ Track lines are one pixel high, and go from 79 (at the \ top of the track view, in the sky), down to 3 (the \ lowest track line, between the mirrors and dashboard) .prevDriverSpeed7 SKIP 1 \ The previous value of trackDriverSpeed when \ calculating the optimum steering for a track segment, \ only used for accessing bit 7 .sectionBehind SKIP 1 \ Used to store the number * 8 of the track section \ behind us when we drive backwards along the track \ \ Track sections are numbered from 0 to 23, so this \ ranges from 0 to 184 .playerSegmentIndex SKIP 1 \ Used to store the index * 3 of the track segment \ containing the player's car in the track segment \ buffer \ \ The player's car is always 32 segments behind the \ front segment in the track segment buffer, so this \ always contains frontSegmentIndex - 96, wrapped around \ as required (as there are three bytes per buffer \ entry) .prevSegmentIndex SKIP 1 \ Used to store the index * 3 of the previous track \ segment .frontSegmentIndex SKIP 1 \ Used to store the index * 3 of the front track \ segment in the track segment buffer \ \ Track segment indexes are numbered from 0 to 39, so \ this ranges from 0 to 117 .directionFacing SKIP 1 \ The direction that our car is facing \ \ * Bit 7 clear = facing forwards \ \ * Bit 7 set = facing backwards .yGravityDelta SKIP 1 \ The distance in the y-axis that the car would fall if \ the track wasn't there, for use when calculating the \ outcome of jumps and being dropped from the crane .vergeType SKIP 1 \ The type of verge that is currently being drawn in \ the DrawTrack routine: \ \ * 0 = leftVergeStart, the left edge of the left \ verge \ \ * 1 = leftTrackStart, the right edge of the left \ verge \ \ * 2 = rightVergeStart, the left edge of the right \ verge \ \ * 3 = rightGrassStart, the right edge of the right \ verge .yJumpHeight SKIP 1 \ The height of the car's jump (or crane lift), in terms \ of track lines, which we use to alter the position of \ the horizon .vergeTopRight SKIP 1 \ The track line just above the segment at \ vergeDepthOfField (i.e. the furthest segment that \ might contain a verge) when drawing the right verge .scaleUp SKIP 1 \ The nominator scale factor for scaling an object \ scaffold (i.e. scale up) \ \ The scaffold is multiplied by scaleUp .scaleDown SKIP 1 \ The denominator scale factor for scaling an object \ scaffold (i.e. scale down) \ \ The scaffold is divided by 2^scaleDown .vergeTopLeft SKIP 1 \ The track line just above the segment at \ vergeDepthOfField (i.e. the furthest segment that \ might contain a verge) when drawing the left verge .heightAboveTrack SKIP 1 \ The car's height above the track, for when it is being \ dropped from the crane, or jumping from hitting the \ verge too fast .playerSpeedLo SKIP 1 \ Low byte of the speed of the player's car along the \ track \ \ This appears to be in mph, with the high byte \ containing the miles per hour, and the low byte \ containing a fraction \ \ Stored as a 16-bit value (playerSpeedHi \ playerSpeedLo) .positionChangeBCD SKIP 1 \ The change in BCD for the player's race position \ \ Gets added to currentPositionBCD when non-zero \ \ Set to the current player's position in BCD in \ ResetVariables .pastHalfway SKIP 1 \ Stores which half of the track the player is in \ \ * 0 = the first half of the track \ \ * 1 = the second half of the track \ \ The halfway point is defined as the middle track \ section, or if there is an odd number of track \ sections, the section before the middle track section \ \ Set to 1 in ResetVariables .currentPositionBCD SKIP 1 \ The current race position in BCD \ \ Displayed at the top of the screen after "Position" .pixelMaskVerge SKIP 1 \ Offset within the vergePixelMask table for segments \ that are close enough to show a verge, i.e. those \ within the verge depth of field .backgroundLeft SKIP 1 \ Details of the verge colour for the left side of the \ verge edge we are drawing, to use as the track line's \ background colour .backgroundRight SKIP 1 \ Details of the verge colour for the right side of the \ verge edge we are drawing, to use as the track line's \ background colour .xPixelCoord SKIP 1 \ The pixel x-coordinate of the centre of the current \ object \ \ In terms of screen coordinates, so 0 is the left edge \ of the screen, 80 is the centre and 159 is the right \ edge .yPixelCoord SKIP 1 \ The pixel y-coordinate of the centre of the current \ object \ \ In terms of track lines, so 80 is the top of the track \ view and 0 is the bottom of the track view .objectType SKIP 1 \ The type of object to draw (0 to 12) \ \ * 0 = Four-object car, front tyres \ * 1 = Four-object car, body and helmet \ * 2 = Four-object car, rear tyres \ * 3 = Four-object car, rear wing \ * 4 = Standard car \ * 5 = Distant car \ * 6 = Corner marker \ * 7 = Straight sign \ * 8 = Start flag \ * 9 = Blank road sign \ * 10 = Chicane road sign \ * 11 = Right turn road sign \ * 12 = Left turn road sign .xPrevVelocityLo SKIP 1 \ Used to store the low byte of the x-coordinate of the \ player's previous velocity vector during the driving \ model calculations (i.e. the velocity from the last \ iteration of the main loop) \ \ Stored as a 16-bit value (xPrevVelocityHi \ xPrevVelocityLo) .xPrevVelocityHi SKIP 1 \ Used to store the high byte of the x-coordinate of the \ player's previous velocity vector during the driving \ model calculations (i.e. the velocity from the last \ iteration of the main loop) \ \ Stored as a 16-bit value (xPrevVelocityHi \ xPrevVelocityLo) .xSpinVelocityLo SKIP 1 \ Used to store the low byte of the scaled spin yaw \ angle during the driving model calculations \ \ Stored as a 16-bit value (xSpinVelocityHi \ xSpinVelocityLo) .xSpinVelocityHi SKIP 1 \ Used to store the high byte of the scaled spin yaw \ angle during the driving model calculations \ \ Stored as a 16-bit value (xSpinVelocityHi \ xSpinVelocityLo) .revCount SKIP 1 \ The current rev count, as shown on the rev counter .engineTorque SKIP 1 \ The power being generated by the engine .throttleBrakeState SKIP 1 \ Denotes whether the throttle or brake are being \ applied \ \ * Bit 7 is set if there is no brake or throttle key \ press \ \ * 0 = brakes are being applied \ \ * 1 = throttle is being applied .throttleBrake SKIP 1 \ The amount of throttle or brake being applied .gearNumber SKIP 1 \ The current gear number \ \ * 0 = reverse \ \ * 1 = neutral \ \ * 2-7 = 1 to 5 .objectDistanceLo SKIP 1 \ The low byte of the distance to the current object \ \ If a car's objectDistanceHi is >= 5, then it is drawn \ as a distant car \ \ Stored as a 16-bit value (objectDistanceHi \ objectDistanceLo) .colourScheme SKIP 0 \ The number of the table colour scheme passed to the \ SetRowColours routine: \ \ Scheme 0: Even rows: 132 on 134 (blue on cyan) \ Odd rows: 134 on 135 (cyan on white) \ \ Scheme 4: Even rows: 129 on 132 (red on blue) \ Odd rows: 131 on 130 (yellow on green) \ \ Scheme 8: Even rows: 131 on 132 (yellow on blue) \ Odd rows: 129 on 135 (red on white) .objectNumber SKIP 0 \ The object number of the four-part car we are drawing .sectionCounter SKIP 0 \ A counter for the track section we are processing .segmentCounter SKIP 0 \ A counter for the track segment we are processing .blockCounter SKIP 0 \ A counter for the dash data block we are processing .secondAxis SKIP 1 \ The number of the second axis to calculate in the \ GetRotationMatrix routine .playerPastSegment SKIP 1 \ Determines whether the player has gone past the \ closest segment to the player (i.e. whether the \ relative yaw angle of the segment is greater than 90 \ degrees) \ \ * Bit 7 clear = not yet \ \ * Bit 7 set = player has gone past the closest \ segment .playerHeading SKIP 1 \ The player's yaw angle, relative to the direction of \ the track, where a heading of 0 means the player is \ pointing straight along the track .driverPrinted SKIP 0 \ The number of the driver we just printed in the \ PrintPositionName routine .thisDriver SKIP 0 \ The number of the car we are currently drawing .xStoreDraw SKIP 0 \ Temporary storage for X so it can be preserved through \ calls to DrawCarInPosition, DrawCarOrSign and \ DrawSegmentEdge .thisYawIndex SKIP 0 \ The index of the yaw angle in the track segment list \ for the verge we are processing .thisSignNumber SKIP 1 \ The sign number that we are currently building .timerAdjust SKIP 1 \ A counter for implementing the clock speed adjustment \ \ Starts out with the value of trackTimerAdjust from the \ track data (see the ProcessTime routine) \ \ Gets decremented on each iteration of the main driving \ loop, looping back to trackTimerAdjust after reaching \ zero \ \ When timerAdjust matches equals trackTimerAdjust, the \ clock timer adds 18/100 of a second rather than the \ usual 9/100 of a second, so the clock timer speeds up \ every time the counter loops round \ \ Decreasing the value of trackTimerAdjust therefore \ speeds up the clock timer, allowing the speed of the \ clock timer to be adjusted on a per-track basis \ \ The Silverstone track has a trackTimerAdjust value of \ 24, so timerAdjust wraps around from 0 to 24 .bottomTrackLine SKIP 1 \ The bottom track line for the current object part .prevEdgeInByte SKIP 1 \ Determines whether we are drawing two edges within the \ same pixel byte in DrawObjectEdge .segmentDirection SKIP 1 \ The relative dirction of our car, to use when \ processing segments in the GetSegmentAngles routine \ \ * 0 when our car is facing in the same direction \ \ * 1 when our car is facing in the opposite direction .setSpeedForDriver SKIP 1 \ The driver whose speed will be set on the next call to \ the SetDriverSpeed routine .vergeBufferEnd SKIP 1 \ The index of the last entry in the track verge buffer \ for the side of the track we are currently drawing in \ DrawTrack .prevPitchIndex SKIP 1 \ The index of the pitch angles in the verge buffer for \ the previous entry in the verge buffer when drawing \ the verge edges .positionAhead SKIP 1 \ The number of the position ahead of the current \ player's position \ \ This refers to the current player's position in the \ driversInOrder list \ \ The position ahead of the leader is last place .spinPitchAngle SKIP 1 \ The amount of pitch angle spin that is being applied \ to the player's car .prevYawIndex SKIP 1 \ The index of the yaw angles in the verge buffer for \ the previous entry in the verge buffer when drawing \ the verge edges .vergeDepthOfField SKIP 1 \ The index into the verge buffer of the furthest verge \ mark, so for segments further from the player than \ this point, we do not draw verge marks .horizonListIndex SKIP 1 \ The track section or segment that's on the horizon, \ given in terms of the index within the track section \ list (or the track segment list) \ \ Specifically, entry number horizonListIndex at \ yVergeRight equals horizonLine, as does the same entry \ in yVergeLeft (as the track is level in a left to \ right direction) .prevHorizonIndex SKIP 1 \ The value of horizonListIndex from the previous call \ to the GetTrackAndMarkers routine .updateBackground SKIP 1 \ Flag to indicate we have changed the background colour \ of a track line \ \ Set to non-zero if we draw a track verge in the first \ part of the track line on the left edge of the screen .pixelMaskIndex SKIP 1 \ The index into the vergePixelMask table for the colour \ of the verge edge we are drawing in DrawSegmentEdge .objectDistanceHi SKIP 1 \ The high byte of the distance to the current object \ \ If a car's objectDistanceHi is >= 5, then it is drawn \ as a distant car \ \ Stored as a 16-bit value (objectDistanceHi \ objectDistanceLo) .markerNumber SKIP 1 \ The marker number that we are drawing in the \ DrawCornerMarkers routine .markersToDraw SKIP 1 \ The number of corner markers to draw .gearChangeKey SKIP 1 \ Determines whether or not a gear change key has been \ pressed \ \ * Bit 7 set = a gear change key has been pressed .clutchEngaged SKIP 1 \ Determines whether the clutch is engaged \ \ * Bit 7 clear = clutch is engaged \ \ * Bit 7 set = clutch is not fully engaged .revsOnGearChange SKIP 1 \ The rev count when the gear was last changed .positionBehind SKIP 1 \ The number of the position behind the current player's \ position \ \ This refers to the current player's position in the \ driversInOrder list \ \ The position behind last place is the leader .edgeSegmentPointer SKIP 1 \ The index of the segment within the track verge buffer \ that is closest to the player's car .bumpyGrassHeight SKIP 1 \ The height of the bumps when driving over grass, which \ fluctuates randomly in the range 1 to 7 .edgeYawAngle SKIP 1 \ The yaw angle of the track segment that is closest to \ the player's car, from the point of view of the car .soundRevTarget SKIP 1 \ The target pitch for the revs sound \ \ The pitch for the revs sound moves towards this pitch \ level one step at a time, to simulate the sound of the \ engine "catching up" to the throttle \ \ The target pitch is set to revCount + 25 .soundRevCount SKIP 1 \ The current pitch for the revs sound .engineStatus SKIP 1 \ Whether or not the engine is on \ \ * 0 = engine is off \ \ * &FF = engine is on .resetSectionList SKIP 1 \ Controls whether to reset the contents of the track \ section list \ \ * 0 = do not reset the track section list \ \ * Non-zero = reset the track section list .playerSpeedHi SKIP 1 \ High byte of the speed of the player's car along the \ track \ \ This appears to be in mph, with the high byte \ containing the miles per hour, and the low byte \ containing a fraction \ \ Stored as a 16-bit value (playerSpeedHi \ playerSpeedLo) .printMode SKIP 1 \ Determines how the next character is printed \ on-screen: \ \ * 0 = poke the character directly into screen memory \ \ * 1 = print the character with OSWRCH (for mode 7) .qualifyTimeEnding SKIP 1 \ Determines whether the time warnings have been shown \ at the end of the qualifying time: \ \ * Bit 6 set = the one-minute warning has been shown \ \ * Bit 7 set = the time-up watning has been shown .updateDrivingInfo SKIP 1 \ Determines which parts of the driving information \ should be updated at the top of the screen \ \ * Bit 7 set = update lap number (during a race) \ update lap time (practice/qualifying) \ \ * Bit 6 set = we are driving the first practice or \ qualifying lap, so do not update the \ best lap time \ \ Set to %10000000 in ResetVariables for race laps only .collisionDriver SKIP 1 \ The number of the driver being hit by the player's car .processContact SKIP 1 \ Another car is close enough to the player's car for us \ to process car-on-car contact \ \ * 0 = no car is close enough \ \ * Non-zero = a car is close enough to check for \ contact .lineBufferSize SKIP 1 \ The size of the line buffer \ \ Zeroed in SetupGame .mainLoopCounterLo SKIP 1 \ Low byte of the main loop counter, which increments on \ each iteration of the main driving loop \ \ Stored as a 16-bit value (mainLoopCounterHi \ mainLoopCounterLo) .startingStack SKIP 1 \ The value of the stack pointer when the game starts, \ so we can restore it when restarting the game .raceStarted SKIP 1 \ Flag determining whether the race has started \ \ * Bit 7 clear = this is practice or a qualifying lap \ \ * Bit 7 set = the race has started .raceStarting SKIP 1 \ The current stage of the starting lights at the start \ of the race \ \ When a race is about to start, raceStarting is set to \ 128, and stays on this value until the engine is \ started, at which point it starts to count down, with \ one tick per iteration of the main loop, working \ through the following sequence: \ \ * 128 = show black lights, engine not yet started \ \ * Start counting down from 240 once engine starts \ \ * 240-192 = show black lights \ \ * 191-161 = show blue lights \ \ * 160 = keep showing blue lights and stop counting \ down until main loop counter is a multiple \ of 64 \ \ * Start counting down from 40 once loop counter is \ a multiple of 64 \ \ * 40-1 = show green lights \ \ * 0 = show no lights (race has started) \ \ When bit 7 is set (i.e. raceStarting >= 128), we are \ on the grid, so we do not increment the clock timer in \ ProcessTime, and the MoveCars routine has no effect .numberOfLaps SKIP 1 \ The number of laps in the race (5, 10 or 20) .currentPlayer SKIP 1 \ The number of the current player \ \ * 0 for practice \ \ * 0 to 19 for competition .P SKIP 1 \ Temporary storage, used in a number of places .Q SKIP 1 \ Temporary storage, used in a number of places .R SKIP 1 \ Temporary storage, used in a number of places .S SKIP 1 \ Temporary storage, used in a number of places .T SKIP 1 \ Temporary storage, used in a number of places .U SKIP 1 \ Temporary storage, used in a number of places .edgePixel SKIP 0 \ The current edge, as a one-pixel byte .V SKIP 1 \ Temporary storage, used in a number of places .W SKIP 1 \ Temporary storage, used in a number of places .leftOfEdge SKIP 0 \ The fill colour to the left of the edge we are drawing .G SKIP 1 \ Temporary storage, used in a number of places .rightOfEdge SKIP 0 \ The fill colour to the right of the edge we are \ drawing .H SKIP 1 \ Temporary storage, used in a number of places .I SKIP 1 \ Temporary storage, used in a number of places .J SKIP 1 \ Temporary storage, used in a number of places .prevBlockNumber SKIP 0 \ The dash data block number for the previous edge .K SKIP 1 \ Temporary storage, used in a number of places .L SKIP 1 \ Temporary storage, used in a number of places .thisEdge SKIP 0 \ The current edge that we are drawing as part of an \ object part .M SKIP 1 \ Temporary storage, used in a number of places .topTrackLine SKIP 0 \ The top track line for the current object part .N SKIP 1 \ Temporary storage, used in a number of places .PP SKIP 1 \ Temporary storage, used in a number of places .QQ SKIP 1 \ Temporary storage, used in a number of places .blockOffset SKIP 0 \ The dash data offset for the current edge .RR SKIP 1 \ Temporary storage, used in a number of places .nextEdge SKIP 0 \ The next edge that we are drawing as part of an \ object part (where applicable) .SS SKIP 1 \ Temporary storage, used in a number of places .colourData SKIP 0 \ Colour data for the current object part .TT SKIP 1 \ Temporary storage, used in a number of places .blockNumber SKIP 0 \ The dash data block number for the current edge .UU SKIP 1 \ Temporary storage, used in a number of places .VV SKIP 1 \ Temporary storage, used in a number of places .WW SKIP 1 \ Temporary storage, used in a number of places .GG SKIP 1 \ Temporary storage, used in a number of places .HH SKIP 1 \ This byte does not appear to be used .II SKIP 1 \ Temporary storage, used in a number of places .JJ SKIP 1 \ Temporary storage, used in a number of places .edgePixelMask SKIP 0 \ The pixel mask for the previous edge .pixelMaskNoVerge SKIP 1 \ Offset within the vergePixelMask table for segments \ that are too far away to show a verge, i.e. those \ outside the verge depth of field .nextBlockNumber SKIP 0 \ The dash data block number for the next edge .LL SKIP 1 \ Temporary storage, used in a number of places .MM SKIP 1 \ Temporary storage, used in a number of places .nextEdgeCoord SKIP 0 \ The x-coordinate for the next edge .NN SKIP 1 \ Temporary storage, used in a number of places