Revert back GTE usage and finalize code approach

This commit is contained in:
2024-01-29 21:24:14 -05:00
parent 493a33cff9
commit a7b5e35916
4 changed files with 115 additions and 149 deletions

View File

@@ -15,7 +15,12 @@ namespace JabyEngine {
output: Output vector
flag: flag output
*/
void rot_trans(const SVECTOR& input, VECTOR& output, int32_t& flag);
void rot_trans(const SVECTOR& input, VECTOR& output, int32_t& flag) {
ldv0(input);
rt();
stlvnl(output);
stflg(flag);
}
/*
SetRotMatrix
@@ -23,14 +28,32 @@ namespace JabyEngine {
Sets a 3x3 matrix m as a constant rotation matrix.
matrix: The rotation matrix to set
*/
void set_rot_matrix(const MATRIX& matrix);
void set_rot_matrix(const MATRIX& matrix) {
__asm__ volatile("lw $12, 0(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("lw $13, 4(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("ctc2 $12, $0" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("ctc2 $13, $1" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("lw $12, 8(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("lw $13, 12(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("lw $14, 16(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("ctc2 $12, $2" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("ctc2 $13, $3" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("ctc2 $14, $4" :: "r"(&matrix) : "$12", "$13", "$14");
}
/*
SetTransMatrix
Sets a constant parallel transfer vector specified by m
*/
void set_trans_matrix(const MATRIX& matrix);
void set_trans_matrix(const MATRIX& matrix) {
__asm__ volatile("lw $12, 20(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("lw $13, 24(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("ctc2 $12, $5" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("lw $14, 28(%0)" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("ctc2 $13, $6" :: "r"(&matrix) : "$12", "$13", "$14");
__asm__ volatile("ctc2 $14, $7" :: "r"(&matrix) : "$12", "$13", "$14");
}
/*
MulMatrix0
@@ -43,20 +66,27 @@ namespace JabyEngine {
Multiplies two matrices m0 and m1.
The function destroys the constant rotation matrix
*/
MATRIX& mult_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result);
MATRIX& multiply_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result);
/*
SetGeomOffset(ofx,ofy)
Load GTE-offset.
*/
void set_geom_offset(int32_t off_x, int32_t off_y);
void set_geom_offset(int32_t off_x, int32_t off_y) {
__asm__ volatile("sll $12, %0, 16" :: "r"(off_x), "r"(off_y) : "$12", "$13");
__asm__ volatile("sll $13, %1, 16" :: "r"(off_x), "r"(off_y) : "$12", "$13");
__asm__ volatile("ctc2 $12, $24" :: "r"(off_x), "r"(off_y) : "$12", "$13");
__asm__ volatile("ctc2 $13, $25" :: "r"(off_x), "r"(off_y) : "$12", "$13");
}
/*
SetGeomScreen(h)
Load distance from viewpoint to screen.
*/
void set_geom_screen(int32_t h);
void set_geom_screen(int32_t h) {
__asm__ volatile("ctc2 %0, $26" :: "r"(h));
}
}
}