diff --git a/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp b/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp index 368454fd..8d860602 100644 --- a/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp +++ b/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp @@ -30,7 +30,7 @@ namespace GTETest { return true; } - auto matrix = GTE::MATRIX::rotation(0, rotation, rotation); + auto matrix = GTE::MATRIX::rotation(0, 0, rotation); matrix.trans[0] = (Assets::Main::DoenerFishInfo.size.width/2); matrix.trans[1] = (Assets::Main::DoenerFishInfo.size.height/2); diff --git a/examples/PoolBox/application/src/Overlay/GTETest/include/GTE_Sprite.hpp b/examples/PoolBox/application/src/Overlay/GTETest/include/GTE_Sprite.hpp index 44121684..256ec8fa 100644 --- a/examples/PoolBox/application/src/Overlay/GTETest/include/GTE_Sprite.hpp +++ b/examples/PoolBox/application/src/Overlay/GTETest/include/GTE_Sprite.hpp @@ -27,7 +27,8 @@ namespace GTETest { move_back.trans[1] = -matrix.trans[1]; move_back.trans[2] = -matrix.trans[2]; - return GTE::apply_matrix(matrix, GTE::apply_matrix(move_back, vector, output), output).to(); + GTE::comp_matrix(matrix, move_back, move_back); + return GTE::apply_matrix(move_back, vector, output).to(); }; const auto& area = this->area; diff --git a/include/PSX/GTE/gte.hpp b/include/PSX/GTE/gte.hpp index 2bedda8d..e911657a 100644 --- a/include/PSX/GTE/gte.hpp +++ b/include/PSX/GTE/gte.hpp @@ -115,6 +115,24 @@ namespace JabyEngine { */ MATRIX& multiply_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result); + /* + CompMatrix + + m0: first input + m1: second input + result: result of computing m0 and m1 + return: returns result + */ + static MATRIX& comp_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result) { + multiply_matrix(m0, m1, result); + set_trans_matrix(m0); + GTE::ldlv0(reinterpret_cast(m1.trans)); + GTE::rt(); + GTE::stlvnl(reinterpret_cast(result.trans)); + + return result; + } + /* matrix: first input diff --git a/include/PSX/GTE/gte_instruction.hpp b/include/PSX/GTE/gte_instruction.hpp index 0cc51473..44cb42d6 100644 --- a/include/PSX/GTE/gte_instruction.hpp +++ b/include/PSX/GTE/gte_instruction.hpp @@ -21,6 +21,17 @@ namespace JabyEngine { __asm__ volatile("lwc2 $5, 4(%0)" :: "r"(&vector)); } + // Load LS 16 bits of VECTOR to 16 bit universal vector. + static __always_inline void ldlv0(const VECTOR& vector) { + __asm__ volatile("lhu $13, 4(%0)" :: "r"(&vector) : "$12", "$13"); + __asm__ volatile("lhu $12, 0(%0)" :: "r"(&vector) : "$12", "$13"); + __asm__ volatile("sll $13, $13, 16" :: "r"(&vector) : "$12", "$13"); + __asm__ volatile("or $12, $12, $13" :: "r"(&vector) : "$12", "$13"); + __asm__ volatile("mtc2 $12, $0" :: "r"(&vector) : "$12", "$13"); + __asm__ volatile("lwc2 $1, 8(%0)" :: "r"(&vector) : "$12", "$13"); + + } + // Load column vector of MATRIX to universal register static __always_inline void ldclmv(const MATRIX& matrix, size_t col) { __asm__ volatile("lhu $12, 0(%0)" :: "r"(reinterpret_cast(&matrix) + (col << 1)) : "$12", "$13", "$14");