Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
3 changed files with 120 additions and 17 deletions
Showing only changes of commit c720136e15 - Show all commits

View File

@ -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)

View File

@ -104,10 +104,45 @@ namespace JabyEngine {
printf("Cos of %i = %i (%i)\n", angle, cos_value, wanna_be_float(cos_value));
};
static const auto print_matrix = [](const GTE::MATRIX& matrix) {
printf("{%i, %i, %i}\n", matrix.rot[0][0], matrix.rot[0][1], matrix.rot[0][2]);
printf("{%i, %i, %i}\n", matrix.rot[1][0], matrix.rot[1][1], matrix.rot[1][2]);
printf("{%i, %i, %i}\n", matrix.rot[2][0], matrix.rot[2][1], matrix.rot[2][2]);
printf("{%i, %i, %i}\n", matrix.trans[0], matrix.trans[1], matrix.trans[2]);
};
display_stuff(25);
display_stuff(45);
display_stuff(75);
display_stuff(90);
auto rot_mat = []() -> GTE::MATRIX {
auto rot = GTE::MATRIX::identity();
rot.rot[0][0] = 123;
rot.rot[0][1] = 456;
rot.rot[0][2] = 789;
rot.rot[1][0] = 1123;
rot.rot[1][1] = 1456;
rot.rot[1][2] = 1789;
rot.rot[2][0] = 2123;
rot.rot[2][1] = 2456;
rot.rot[2][2] = 2789;
rot.trans[0] = 9;
rot.trans[1] = 8;
rot.trans[2] = 7;
return rot;
}();
print_matrix(rot_mat);
printf("---\n");
GTE::set_matrix(rot_mat);
rot_mat = GTE::get_matrix();
print_matrix(rot_mat);
printf("---\n");
}
void start() {

View File

@ -43,5 +43,31 @@ namespace JabyEngine {
return result;
}
void set_matrix(const MATRIX& matrix) {
set_rot_matrix(matrix);
set_trans_matrix(matrix);
}
MATRIX get_matrix() {
MATRIX matrix;
get_rot_matrix(matrix);
get_trans_matrix(matrix);
return matrix;
}
void push_matrix() {
// FIXME: Implement this
}
void push_matrix(const MATRIX& matrix) {
push_matrix();
set_matrix(matrix);
}
void pop_matrix() {
// FIXME: Implement this
}
}
}