.ApplySpinYaw LDA spinYawAngleHi \ Set T = spinYawAngleHi to use as the low byte in (A T) STA T LDY #88 \ Set Y = 88 LDA spinYawAngleTop \ Set (A T) = (spinYawAngleTop spinYawAngleHi) JSR Multiply8x16Signed \ Set: \ \ (A T) = (A T) * abs(A) * Y / 256 \ = spinYawAngle * abs(spinYawAngle) * 88 / 256 \ = spinYawAngle * 88 / 256 \ = spinYawAngle * 0.34 STA U \ Set (U T) = (A T) \ = spinYawAngle * 0.34 LDA xVelocityLo \ Set (xVelocityHi xVelocityLo) SEC \ = (xVelocityHi xVelocityLo) - (U T) SBC T \ = xVelocity - (spinYawAngle * 0.34) STA xVelocityLo \ \ starting with the low bytes LDA xVelocityHi \ And then the high bytes SBC U STA xVelocityHi JSR MultiplyBy1Point5 \ Set (A T) = (U T) * 1.5 \ = spinYawAngle * 0.34 * 1.5 \ = spinYawAngle * 0.52 STA xSpinVelocityHi \ Set (xSpinVelocityHi xSpinVelocityLo) = (A T) LDA T \ = spinYawAngle * 0.52 STA xSpinVelocityLo RTS \ Return from the subroutineName: ApplySpinYaw [Show more] Type: Subroutine Category: Driving model Summary: Calculate variables based on the spin yaw angle Deep dive: The core driving modelContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ApplyDrivingModel calls ApplySpinYaw
Calculate the following: xVelocity = xVelocity - (spinYawAngle * 0.34) xSpinVelocity = spinYawAngle * 0.52
[X]
Subroutine Multiply8x16Signed (category: Maths (Arithmetic))
Multiply an 8-bit and a 16-bit number and apply a sign to the result
[X]
Subroutine MultiplyBy1Point5 (category: Maths (Arithmetic))
Multiply a 16-bit signed number by 1.5
[X]
Variable spinYawAngleHi (category: Car geometry)
High byte of the amount of yaw angle spin that is being applied to the player's car
[X]
Variable spinYawAngleTop (category: Car geometry)
Top byte of the amount of yaw angle spin that is being applied to the player's car
[X]
Variable xSpinVelocityHi in workspace Zero page
Used to store the high byte of the scaled spin yaw angle during the driving model calculations
[X]
Variable xSpinVelocityLo in workspace Zero page
Used to store the low byte of the scaled spin yaw angle during the driving model calculations
[X]
Variable xVelocityHi (category: Driving model)
High byte of the x-coordinate of the player's velocity vector, from the player's frame of reference
[X]
Variable xVelocityLo (category: Driving model)
Low byte of the x-coordinate of the player's velocity vector, from the player's frame of reference