.GetMoments LDX #1 \ Set a counter in X to work through the x- and y-axes .torq1 LDA #125 \ Set R = 125 STA R LDA xTurnHi,X \ Set (Q P) = (xTurnTop xTurnHi) STA P \ = xTurn LDA xTurnTop,X STA Q ASL P \ Set (Q P) = (Q P) * 2 ROL Q \ = xTurn * 2 JSR Multiply8x16-2 \ Store X in VV and set: \ \ (G W V) = (Q P) * R \ = xTurn * 2 * 125 \ = xTurn * 250 LDA VV \ Set A and X to the axis number that the above call TAX \ stored in VV, which is the same as the axis counter X \ (so it's 0 for the x-axis and 1 for the y-axis) EOR #1 \ Set Y to the opposite axis number to X, so when we are TAY \ calculating xTemp3 in the following and X = 0, Y = 1 \ so we use yLiftDrag, and when we are calculating \ yTemp3, X = 1 and Y = 0, so we use xLiftDrag SEC \ Set xTemp3 = yLiftDrag - (G W) LDA xLiftDragLo,Y \ = yLiftDrag - (xTurn * 250 / 256) SBC W STA xTemp3Lo,X LDA xLiftDragHi,Y SBC G STA xTemp3Hi,X DEX \ Decrement the loop counter to move to the next axis BPL torq1 \ Loop back until we have processed both axes SEC \ Set (A zTemp3Lo) = 0 - (zTurnTop zTurnHi) LDA #0 \ = -zTurn SBC zTurnHi \ STA zTemp3Lo \ starting with the high bytes LDA #0 \ And then the low bytes SBC zTurnTop ASL zTemp3Lo \ Set (zTemp3Hi zTemp3Lo) = (A zTemp3Lo) << 1 ROL A \ = -zTurn * 2 STA zTemp3Hi RTS \ Return from the subroutineName: GetMoments [Show more] Type: Subroutine Category: Flight model Summary: Calculate the pitching, rolling and yawing moments due to the current pitch, roll and yaw ratesContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ApplyAerodynamics (Part 3 of 3) calls GetMoments * Multiply8x16 calls via GetMoments-1
This routine calculates: xTemp3 = yLiftDrag - (xTurn * 250 / 256) yTemp3 = xLiftDrag - (yTurn * 250 / 256) zTemp3 = -zTurn * 2 which contain the moments due to the plane's current movement. These then get scaled by altitude and put into (xMoments yMoments zMoments).
Other entry points: GetMoments-1 Contains an RTS
[X]
Entry point Multiply8x16-2 in subroutine Multiply8x16 (category: Maths)
Store X in VV before doing the calculation Multiply8x16-6 Store X in VV and calculate (G W V) = (A Y) * R
[X]
Label torq1 is local to this routine
[X]
Variable xLiftDragHi in workspace Main variable workspace
Linear force due to lift in the x-axis (high byte)
[X]
Variable xLiftDragLo in workspace Main variable workspace
Linear force due to lift in the x-axis (low byte)
[X]
Variable xTemp3Hi in workspace Main variable workspace
The high byte of the xTemp3 temporary variable
[X]
Variable xTemp3Lo in workspace Main variable workspace
The low byte of the xTemp3 temporary variable
[X]
Variable xTurnHi in workspace Main variable workspace
Turn rate around the x-axis (high byte)
[X]
Variable xTurnTop in workspace Main variable workspace
Turn rate around the x-axis (top byte)
[X]
Variable zTemp3Hi in workspace Main variable workspace
The high byte of the zTemp3 temporary variable
[X]
Variable zTemp3Lo in workspace Main variable workspace
The low byte of the zTemp3 temporary variable
[X]
Variable zTurnHi in workspace Main variable workspace
Turn rate around the z-axis (high byte)
[X]
Variable zTurnTop in workspace Main variable workspace
Turn rate around the z-axis (top byte)