.SetMatrixEntry TXA \ Set X = matrixAxis + X CLC \ ADC matrixAxis \ This has no effect when matrixAxis = 0, which is the TAX \ only value that this routine is called with LDA mx1Lo,X \ Set R = the low byte from the matrix entry to read STA R .smen1 LDA mx1Hi,X \ Set (S R) = the matrix entry to read STA S JMP smen2 \ Jump down to smen2 to do the calculation .SetMatrixEntry3 TXA \ Set X = matrixAxis + X CLC \ ADC matrixAxis \ This has no effect when matrixAxis = 0, which is the TAX \ only value that this routine is called with LDA mx1Lo,X \ Set R = the low byte from the matrix entry to read, EOR #1 \ with the sign in bit 0 flipped STA R JMP smen1 \ Jump up to smen1 to set the high byte .SetMatrixEntry2 TXA \ Set X = matrixAxis + X CLC \ ADC matrixAxis \ This has no effect when matrixAxis = 0, which is the TAX \ only value that this routine is called with LDA mx1Lo,X \ Set (J I) = the matrix entry to read STA I LDA mx1Hi,X STA J .smen2 TYA \ Set N = Y + matrixNumber CLC \ ADC matrixNumber \ This sets N = Y when matrixNumber = 0, which is the STA N \ only value that this routine is called with JSR Multiply16x16Bit0 \ Set (H G) = (J I) * (S R) >> 16 LDY N \ Fetch the index of the matrix entry to write that we \ stored in N above LDA G \ Store (H G) in the matrix entry to write STA matrix1Lo,Y LDA H STA matrix1Hi,Y RTS \ Return from the subroutineName: SetMatrixEntry [Show more] Type: Subroutine Category: 3D geometry Summary: Calculate a matrix entryContext: See this subroutine in context in the source code References: This subroutine is called as follows: * SetMatrices calls SetMatrixEntry * SetMatrices calls via SetMatrixEntry2 * SetMatrices calls via SetMatrixEntry3
This routine reads one of the projected coordinate values that we calculated in ProjectAxisAngle (in mx1 to mz2), performs a multiplication, and writes the result to the specified entry in matrix 1. If mRead is the matrix entry in X (from mx1 to mz2) and mWrite is the matrix entry in Y (from m0 to m8), then it calculates the following: mWrite = (J I) * mRead >> 16
Arguments: X The matrix entry to read (mRead): * 0 = mx1 * 1 = my1 * 2 = mz1 * 3 = mx2 * 4 = my2 * 5 = mz2 Y The matrix entry to write (mWrite) in matrix 1: * 0 = m0 * 1 = m1 * 2 = m2 ... * 7 = m7 * 8 = m8 matrixNumber The routine is only ever called with matrixNumber = 0, so it only ever writes to matrix 1, but calling the routine with a different value would allow us to write to a different matrix matrixAxis The routine is only ever called with matrixAxis = 0, which has no effect on the calculation, but calling the routine with a non-zero value of matrixAxis would allow different mRead values to be used, i.e. matrixAxis+X
Returns: mWrite Set to (J I) * mRead >> 16 (S R) The value of mRead (H G) The value written to mWrite
Other entry points: SetMatrixEntry2 Set mWrite = (S R) * mRead >> 16 and (J I) = mRead SetMatrixEntry3 Set mWrite = (J I) * -mRead >> 16 and (S R) = -mRead
[X]
Subroutine Multiply16x16Bit0 (category: Maths)
Multiply two 16-bit numbers that have their signs in bit 0
[X]
Variable matrix1Hi (category: Maths)
The high bytes of matrix 1
[X]
Variable matrix1Lo (category: Maths)
The low bytes of matrix 1
[X]
Variable matrixAxis in workspace Main variable workspace
The axis to be processed by the matrix routines, specifically those that populate the matrices
[X]
Variable matrixNumber in workspace Main variable workspace
The matrix used in matrix operations
[X]
Variable mx1Hi in workspace Stack variables
The value of mx1, used when constructing the rotation matrices (high byte)
[X]
Variable mx1Lo in workspace Stack variables
The value of mx1, used when constructing the rotation matrices (low byte)
[X]
Label smen1 is local to this routine
[X]
Label smen2 is local to this routine