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

@@ -85,11 +85,9 @@ namespace JabyEngine {
const auto m1 = GTE::MATRIX::identity();
auto m2 = GTE::MATRIX::identity();
GTE::mult_matrix(m0, m1, m2);
asm("# THEIR PLANSCHI START");
gte_MulMatrix0(&m0, &m1, &m2);
asm("# THEIR PLANSCHI END");
asm("# PLANSCHI START");
JabyEngine::GTE::multiply_matrix(m0, m1, m2);
asm("# PLANSCHI END");
}
void start() {

View File

@@ -2,68 +2,22 @@
namespace JabyEngine {
namespace GTE {
void rot_trans(const SVECTOR& input, VECTOR& output, int32_t& flag) {
__jaby_engine_gte_ldv0(input);
__jaby_engine_gte_rt();
__jaby_engine_gte_stlvnl(output);
__jaby_engine_gte_stflg(flag);
}
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");
}
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");
}
MATRIX& mult_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result) {
/*
Jaby: Somehow this code creates stack usage.... Investigate!!
Jaby: Reimplement all of this with the original code and see how it goes?!
*/
asm("# MY PLANSCHI START");
MATRIX& multiply_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result) {
set_rot_matrix(m0);
__jaby_engine_gte_ldclmv(m1, 0);
__jaby_engine_gte_rtir();
__jaby_engine_gte_stclmv(result, 0);
JabyEngine::GTE::ldclmv(m1, 0);
JabyEngine::GTE::rtir();
JabyEngine::GTE::stclmv(result, 0);
__jaby_engine_gte_ldclmv(m1, 1);
__jaby_engine_gte_rtir();
__jaby_engine_gte_stclmv(result, 1);
JabyEngine::GTE::ldclmv(m1, 1);
JabyEngine::GTE::rtir();
JabyEngine::GTE::stclmv(result, 1);
__jaby_engine_gte_ldclmv(m1, 2);
__jaby_engine_gte_rtir();
__jaby_engine_gte_stclmv(result, 2);
JabyEngine::GTE::ldclmv(m1, 2);
JabyEngine::GTE::rtir();
JabyEngine::GTE::stclmv(result, 2);
return result;
asm("# MY PLANSCHI END");
}
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");
}
void set_geom_screen(int32_t h) {
__asm__ volatile("ctc2 %0, $26" :: "r"(h));
}
}
}