EOR #%00111111 \ We know bits 6 and 7 of A are clear, as we know A is \ in the range 0 to 63, so this flips bits 0 to 5, so \ the range 0 to 63 gets flipped around to 63 to 0, to \ give this in A: \ \ 63 \ | 32 \ | / \ | / \ |/ \ +----- 0 \ |\ \ | \ \ | \ \ | 32 \ 63 STA T \ Store the flipped range in T LSR A \ Set A = A / 2 + T CLC \ = 1.5 * T ADC T \ \ So we now have this in A, depending on the heading of \ the player within the segment: \ \ 94 \ | 48 \ | / \ | / \ |/ \ +----- 0 \ |\ \ | \ \ | \ \ | 48 \ 94 JSR MultiplyHeight \ Set: \ \ A = A * yTrackSegmentI \ \ flipping the sign if we are facing backwards \ \ The value given in yTrackSegmentI is the y-coordinate \ of the segment vector, i.e. the vector from this \ segment to the next, which is the same as the change \ in height as we move through the segment \ \ The calculation above effectively works out the \ difference in elevation of the car within the segment \ with respect to its heading, and puts it in A CLC \ Set A = A + bumpyGrassHeight + liftFromTorque ADC bumpyGrassHeight \ + yJumpHeight + playerPitchAngle CLC ADC liftFromTorque CLC ADC yJumpHeight CLC ADC playerPitchAngle CLC \ Clear the C flag, to use when A is positive BPL elev13 \ If A is positive, jump to elev13 SEC \ Set to C flag, so it contains the correct sign bit \ for the value of A .elev13 ROR A \ Set A = A / 2, keeping the sign of A intact STA playerPitchAngle \ Set playerPitchAngle = A SEC \ Set spinPitchAngle = A - V SBC V \ = playerPitchAngle - V STA spinPitchAngle \ \ We set V to the original value of playerPitchAngle \ above, so spinPitchAngle now contains the change in \ elevation of the carName: ApplyElevation (Part 3 of 5) [Show more] Type: Subroutine Category: Driving model Summary: Calculate player's elevation above the track Deep dive: The core driving model Jumps and dropsContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
Calculate the following: * Set A to the elevation change of the car due to the sideways angle of the car in the current segment * playerPitchAngle = (A + bumpyGrassHeight + liftFromTorque + yJumpHeight + playerPitchAngle) / 2 * spinPitchAngle = playerPitchAngle - original value of playerPitchAngle
[X]
Subroutine MultiplyHeight (category: Track geometry)
Multiply the height above ground of a specified track segment by A
[X]
Variable bumpyGrassHeight in workspace Zero page
The height of the bumps when driving over grass, which fluctuates randomly in the range 1 to 7
[X]
Label elev13 is local to this routine
[X]
Variable liftFromTorque (category: Driving model)
The lift of the front of the car caused by acceleration or braking
[X]
Variable playerPitchAngle in workspace Zero page
The player's pitch angle
[X]
Variable spinPitchAngle in workspace Zero page
The amount of pitch angle spin that is being applied to the player's car
[X]
Variable yJumpHeight in workspace Zero page
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