.ScaleByAltitude STY Q \ Set (Q P) = (Y X) STX P LDA yPlaneHi \ Set R = ~yPlaneHi EOR #&FF STA R JSR Multiply8x16 \ Set (G W V) = (Q P) * R \ = (Y X) * ~yPlaneHi \ \ and also set A to the high byte of the result TAY \ Set (Y X V) = (G W V) LDX W RTS \ Return from the subroutineName: ScaleByAltitude [Show more] Type: Subroutine Category: Flight model Summary: Multiply the high byte of the plane's altitude by a 16-bit numberContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ApplyAerodynamics (Part 1 of 3) calls ScaleByAltitude * ApplyTurnAndThrust (Part 2 of 2) calls ScaleByAltitude * ApplyBumpyRide calls via ScaleByAltitude-1
Calculate: (Y X V) = (Y X) * ~yPlaneHi
Arguments: (Y X) A signed 16-bit number
Returns: (Y X V) The result, (Y X) * ~yPlaneHi
Other entry points: ScaleByAltitude-1 Contains an RTS
[X]
Subroutine Multiply8x16 (category: Maths)
Multiply an 8-bit and a 16-bit number
[X]
Variable yPlaneHi in workspace Main variable workspace
Plane altitude/y-coordinate (high byte)