Skip to navigation


Driving model: ApplyLimitAndSign

Name: ApplyLimitAndSign [Show more] Type: Subroutine Category: Driving model Summary: Apply a maximum limit and a sign to a 16-bit number
Context: 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)
.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 subroutine