Skip to navigation


Driving model: ApplySpinYaw

Name: ApplySpinYaw [Show more] Type: Subroutine Category: Driving model Summary: Calculate variables based on the spin yaw angle Deep dive: The core driving model
Context: 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
.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 subroutine