Support comp_matrix

This commit is contained in:
Jaby 2024-04-02 17:47:41 -05:00
parent 101baed5da
commit 3449bb4b28
4 changed files with 32 additions and 2 deletions

View File

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

View File

@ -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<GPU::Vertex>();
GTE::comp_matrix(matrix, move_back, move_back);
return GTE::apply_matrix(move_back, vector, output).to<GPU::Vertex>();
};
const auto& area = this->area;

View File

@ -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<const VECTOR&>(m1.trans));
GTE::rt();
GTE::stlvnl(reinterpret_cast<VECTOR&>(result.trans));
return result;
}
/*
matrix: first input

View File

@ -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<uintptr_t>(&matrix) + (col << 1)) : "$12", "$13", "$14");