Support getting and setting of matrix
This commit is contained in:
@@ -41,24 +41,23 @@ namespace JabyEngine {
|
||||
__asm__ volatile("ctc2 $14, $4" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
}
|
||||
|
||||
static MATRIX get_rot_matrix() {
|
||||
MATRIX matrix = {0};
|
||||
/*
|
||||
GetRotMatrix
|
||||
|
||||
// TODO: v why is this needed?
|
||||
// TODO: v what is this? v
|
||||
// TODO: v v what exactly is this register?
|
||||
__asm__ volatile("cfc2 $12, $0" :: "r"(&matrix) : "$12", "$13", "$14", "memory");
|
||||
__asm__ volatile("cfc2 $13, $1" :: "r"(&matrix) : "$12", "$13", "$14", "memory");
|
||||
__asm__ volatile("sw $12, 0(%0)" :: "r"(&matrix) : "$12", "$13", "$14", "memory");
|
||||
__asm__ volatile("sw $13, 4(%0)" :: "r"(&matrix) : "$12", "$13", "$14", "memory");
|
||||
__asm__ volatile("cfc2 $12, $2" :: "r"(&matrix) : "$12", "$13", "$14", "memory");
|
||||
__asm__ volatile("cfc2 $13, $3" :: "r"(&matrix) : "$12", "$13", "$14", "memory");
|
||||
__asm__ volatile("cfc2 $14, $4" :: "r"(&matrix) : "$12", "$13", "$14", "memory");
|
||||
__asm__ volatile("sw $12, 8(%0)" :: "r"(&matrix) : "$12", "$13", "$14", "memory");
|
||||
__asm__ volatile("sw $13, 12(%0)" :: "r"(&matrix) : "$12", "$13", "$14", "memory");
|
||||
__asm__ volatile("sw $14, 16(%0)" :: "r"(&matrix) : "$12", "$13", "$14", "memory");
|
||||
|
||||
return matrix;
|
||||
Writes the current 3x3 constant rotation matrix to matrix
|
||||
(This doesn't require us to use memory clobber)
|
||||
*/
|
||||
static void get_rot_matrix(MATRIX &matrix) {
|
||||
__asm__ volatile("cfc2 $12, $0" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("cfc2 $13, $1" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("sw $12, 0(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("sw $13, 4(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("cfc2 $12, $2" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("cfc2 $13, $3" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("cfc2 $14, $4" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("sw $12, 8(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("sw $13, 12(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("sw $14, 16(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -75,6 +74,21 @@ namespace JabyEngine {
|
||||
__asm__ volatile("ctc2 $14, $7" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
}
|
||||
|
||||
/*
|
||||
GetTransMatrix
|
||||
|
||||
Writes the current constant parallel transfer vector to matrix
|
||||
(This doesn't require us to use memory clobber)
|
||||
*/
|
||||
static void get_trans_matrix(MATRIX& matrix) {
|
||||
__asm__ volatile("cfc2 $14, $7" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("cfc2 $13, $6" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("sw $14, 28(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("cfc2 $12, $5" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("sw $13, 24(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
__asm__ volatile("sw $12, 20(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
|
||||
}
|
||||
|
||||
/*
|
||||
MulMatrix0
|
||||
|
||||
@@ -88,6 +102,34 @@ namespace JabyEngine {
|
||||
*/
|
||||
MATRIX& multiply_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result);
|
||||
|
||||
/*
|
||||
matrix: first input
|
||||
|
||||
Sets the 3x3 constant rotation matrix and the parallel transfer vector from input
|
||||
*/
|
||||
void set_matrix(const MATRIX& matrix);
|
||||
|
||||
/*
|
||||
returns: current matrix
|
||||
|
||||
Gets the current 3x3 constant rotation matrix and the parallel transfer vector
|
||||
*/
|
||||
MATRIX get_matrix();
|
||||
|
||||
/*
|
||||
matrix: optional input
|
||||
|
||||
Pushes the current matrix (rotation and parallel) to an internal stack
|
||||
Optional: replaces current matrix (rotation and parallel) with input
|
||||
*/
|
||||
void push_matrix();
|
||||
void push_matrix(const MATRIX& matrix);
|
||||
|
||||
/*
|
||||
Restores the previous stored matrix (rotation and parallel)
|
||||
*/
|
||||
void pop_matrix();
|
||||
|
||||
/*
|
||||
SetGeomOffset(ofx,ofy)
|
||||
|
||||
|
Reference in New Issue
Block a user