Skip to navigation


Flight model: AdjustTurn

Name: AdjustTurn [Show more] Type: Subroutine Category: Flight model Summary: Adjust the plane's turn rate
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ApplyFlightModel (Part 6 of 7) calls AdjustTurn

This routine adjusts the plane's turn rate by adding a 24-bit unsigned vector to each axis of the plane's turn rate. Specifically, it does the following for each of the three axes (x, y and z): (xTurnTop xTurnHi xTurnLo) += (dxTurnTop dxTurnHi dxTurnLo) so that's: [ xTurn ] [ xTurn ] [ dxTurn ] [ yTurn ] = [ yTurn ] + [ dyTurn ] [ zTurn ] [ zTurn ] [ dzTurn ] where (dxTurn dyTurn dzTurn) and (xTurn yTurn zTurn) are vectors made up of unsigned 24-bit numbers representing angles.
.AdjustTurn LDX #2 \ Set a counter in X to work through the three axes (the \ comments below cover the iteration for the x-axis) .atur1 LDA dxTurnLo,X \ Set xTurn = xTurn + dxTurn CLC \ ADC xTurnLo,X \ starting with the low bytes STA xTurnLo,X LDA dxTurnHi,X \ And then the high bytes ADC xTurnHi,X STA xTurnHi,X LDA dxTurnTop,X \ And then the top bytes ADC xTurnTop,X STA xTurnTop,X DEX \ Decrement the loop counter to move to the next axis BPL atur1 \ Loop back until we have processed all three axes RTS \ Return from the subroutine