.ApplyLimitAndSign CMP NN \ If A < NN, jump to lims1 to skip the following BCC lims1 LDA MM \ Set (A T) = (NN MM) STA T LDA NN .lims1 BIT H \ Set the N flag to the sign of H, so the call to \ Absolute16Bit sets the sign of (A T) to abs(H) JSR Absolute16Bit \ Set the sign of (A T) to match the sign bit in H LDY G \ Set Y to the offset in G STA xTyreForceNoseHi,Y \ Store (A T) LDA T STA xTyreForceNoseLo,Y RTS \ Return from the subroutineName: ApplyLimitAndSign [Show more] Type: Subroutine Category: Driving model Summary: Apply a maximum limit and a sign to a 16-bit numberContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ApplySkidForces calls ApplyLimitAndSign * ApplyLimitThrottle calls via lims1
Set the variable specified in G (let's call it variableG) as follows: variableG = max((A T), (NN MM)) * abs(H)
Arguments: G Offset of the variable to set: * 0 = xTyreForceNose * 1 = xTyreForceRear * 2 = zTyreForceNose * 3 = zTyreForceRear
Other entry points: lims1 Skip applying the maximum value to variableG, so we set: variableG = (A T) * abs(H)
[X]
Subroutine Absolute16Bit (category: Maths (Arithmetic))
Calculate the absolute value (modulus) of a 16-bit number
[X]
Entry point lims1 in subroutine ApplyLimitAndSign (category: Driving model)
Skip applying the maximum value to variableG, so we set: variableG = (A T) * abs(H)
[X]
Variable xTyreForceNoseHi (category: Driving model)
High byte of the x-coordinate of the force vector produced by the front tyres in the nose of the car
[X]
Variable xTyreForceNoseLo (category: Driving model)
Low byte of the x-coordinate of the force vector produced by the front tyres in the nose of the car