Skip to navigation

Revs on the BBC Micro

Maths (Geometry): SubtractCoords

Name: SubtractCoords [Show more] Type: Subroutine Category: Maths (Geometry) Summary: Subtract from a specified coordinate variable
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ApplyWingBalance calls SubtractCoords

This routine subtracts (U T) from the specified 16-bit variable. Specifically, it calculates: variableY = variableY - (U T) * abs(A) where A is the last variable to be loaded before the subroutine call. So if the call follows an LDA instruction, for example, the following is calculated if A is positive: variableY = variableY - (U T) and the following is calculated if A is negative: variableY = variableY + (U T)
Arguments: N flag Determines the action: * If positive, subtract (U T) * If negative, add (U T)
.SubtractCoords BMI AddCoords \ If A is negative, jump to AddCoords to calculate: \ \ variableY = variableY + (U T) JSR Negate16Bit+2 \ Set (A T) = -(U T) STA U \ Set (U T) = (A T) \ = -(U T) \ Fall through into AddCoords to calculate: \ \ variableY = variableY - (U T)