summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2024-07-24 15:53:50 -0600
committerGitHub <noreply@github.com>2024-07-24 15:53:50 -0600
commit5c7f8f8b27887fe4aeaa342f45593d39a88e6455 (patch)
tree546e4831e8924fd47d0bcd8bba974646fb5b0368
parent84266f904943688579558a1925c82f4f58d55fe6 (diff)
Fix Spaghetti texture loading for segments 3 & 5 (#144)
* Update DisplayListFactory.cpp * Update DisplayListFactory.cpp
-rw-r--r--src/factories/DisplayListFactory.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/factories/DisplayListFactory.cpp b/src/factories/DisplayListFactory.cpp
index b544d9d..a596ab4 100644
--- a/src/factories/DisplayListFactory.cpp
+++ b/src/factories/DisplayListFactory.cpp
@@ -376,25 +376,33 @@ ExportResult DListBinaryExporter::Export(std::ostream &write, std::shared_ptr<IP
auto ptr = w1;
auto dec = Companion::Instance->GetNodeByAddr(ptr);
- Gfx value = gsDPSetTextureOTRImage(C0(21, 3), C0(19, 2), C0(0, 10), ptr);
- w0 = value.words.w0;
- w1 = value.words.w1;
+ // Export texture segment addresses as segmented addresses
+ if ((Companion::Instance->GetGBIMinorVersion() == GBIMinorVersion::Mk64) && ((SEGMENT_NUMBER(w1) == 0x03) || (SEGMENT_NUMBER(w1) == 0x05))) {
+ w1 |= 1;
+ writer.Write(w0);
+ writer.Write(w1);
+ } else {
+ Gfx 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);
+ writer.Write(w0);
+ writer.Write(w1);
- if(dec.has_value()){
- uint64_t hash = CRC64(std::get<0>(dec.value()).c_str());
+ if(dec.has_value()){
+ uint64_t hash = CRC64(std::get<0>(dec.value()).c_str());
- if(hash == 0){
- throw std::runtime_error("Texture hash is 0 for " + std::get<0>(dec.value()));
- }
+ if(hash == 0){
+ throw std::runtime_error("Texture hash is 0 for " + std::get<0>(dec.value()));
+ }
- SPDLOG_INFO("Found texture: 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 texture at 0x{:X}", ptr);
+ SPDLOG_INFO("Found texture: 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 texture at 0x{:X}", ptr);
+ }
}
}