summaryrefslogtreecommitdiff
path: root/src/factories/DisplayListFactory.cpp
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2025-01-25 14:03:07 -0600
committerKiritoDv <kiritodev01@gmail.com>2025-01-25 14:03:07 -0600
commit7bb9feddd8275fd5417d0ff0d2300ba688fa89b7 (patch)
tree60520889dd6017df4b357dec9ec1d46b44b2f52d /src/factories/DisplayListFactory.cpp
parent37258535fe2cde3e00149314778f135adf76d42b (diff)
Added support for dlist matrix opcode
Diffstat (limited to 'src/factories/DisplayListFactory.cpp')
-rw-r--r--src/factories/DisplayListFactory.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/factories/DisplayListFactory.cpp b/src/factories/DisplayListFactory.cpp
index c64fab8..86f311e 100644
--- a/src/factories/DisplayListFactory.cpp
+++ b/src/factories/DisplayListFactory.cpp
@@ -16,6 +16,7 @@
std::unordered_map<std::string, uint8_t> gF3DTable = {
{ "G_VTX", 0x04 },
{ "G_DL", 0x06 },
+ { "G_MTX", 0x1 },
{ "G_ENDDL", 0xB8 },
{ "G_SETTIMG", 0xFD },
{ "G_MOVEMEM", 0x03 },
@@ -29,6 +30,7 @@ std::unordered_map<std::string, uint8_t> gF3DTable = {
std::unordered_map<std::string, uint8_t> gF3DExTable = {
{ "G_VTX", 0x04 },
{ "G_DL", 0x06 },
+ { "G_MTX", 0x1 },
{ "G_ENDDL", 0xB8 },
{ "G_SETTIMG", 0xFD },
{ "G_MOVEMEM", 0x03 },
@@ -42,6 +44,7 @@ std::unordered_map<std::string, uint8_t> gF3DExTable = {
std::unordered_map<std::string, uint8_t> gF3DEx2Table = {
{ "G_VTX", 0x01 },
{ "G_DL", 0xDE },
+ { "G_MTX", 0xDA },
{ "G_ENDDL", 0xDF },
{ "G_SETTIMG", 0xFD },
{ "G_MOVEMEM", 0xDC },
@@ -143,6 +146,7 @@ ExportResult DListCodeExporter::Export(std::ostream &write, std::shared_ptr<IPar
gfxd_lightsn_callback(GFXDOverride::Lights);
gfxd_light_callback(GFXDOverride::Light);
gfxd_vp_callback(GFXDOverride::Viewport);
+ gfxd_mtx_callback(GFXDOverride::Matrix);
GFXDSetGBIVersion();
if(searchTable.has_value()){
@@ -442,7 +446,6 @@ ExportResult DListBinaryExporter::Export(std::ostream &write, std::shared_ptr<IP
N64Gfx value = gsDPSetTextureOTRImage(C0(21, 3), C0(19, 2), C0(0, 10), ptr);
w0 = value.words.w0;
w1 = value.words.w1;
-
writer.Write(w0);
writer.Write(w1);
@@ -463,6 +466,32 @@ ExportResult DListBinaryExporter::Export(std::ostream &write, std::shared_ptr<IP
}
}
+ if(opcode == GBI(G_MTX)) {
+ auto ptr = w1;
+ auto dec = Companion::Instance->GetNodeByAddr(ptr);
+
+ w0 &= 0x00FFFFFF;
+ w0 += G_MTX_OTR << 24;
+ w1 = 0;
+
+ writer.Write(w0);
+ writer.Write(w1);
+
+ if(dec.has_value()){
+ uint64_t hash = CRC64(std::get<0>(dec.value()).c_str());
+
+ if(hash == 0){
+ throw std::runtime_error("Matrix hash is 0 for " + std::get<0>(dec.value()));
+ }
+
+ SPDLOG_INFO("Found matrix: 0x{:X} Hash: 0x{:X} Path: {}", ptr, hash, std::get<0>(dec.value()));
+ w0 = hash >> 32;
+ w1 = hash & 0xFFFFFFFF;
+ } else {
+ SPDLOG_WARN("Could not find matrix at 0x{:X}", ptr);
+ }
+ }
+
writer.Write(w0);
writer.Write(w1);
}