From fe1ce26c02e615d6ecf2a761003ace76c6fdbd96 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Mon, 10 Jun 2024 22:03:09 -0600 Subject: Add option to process DLs with indexes instead of offsets (#131) * Update DisplayListFactory.cpp * Update gbi-otr.h * Update gbi-otr.h * Update DisplayListFactory.cpp * Update gbi-otr.h * Update DisplayListFactory.cpp * Update gbi-otr.h * Update gbi-otr.h * Update DisplayListFactory.cpp * Update gbi-otr.h * Update DisplayListFactory.cpp --- src/factories/DisplayListFactory.cpp | 20 +++++++++++++++++--- src/n64/gbi-otr.h | 8 ++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/factories/DisplayListFactory.cpp b/src/factories/DisplayListFactory.cpp index dfc3fb8..5fc8902 100644 --- a/src/factories/DisplayListFactory.cpp +++ b/src/factories/DisplayListFactory.cpp @@ -296,9 +296,23 @@ ExportResult DListBinaryExporter::Export(std::ostream &write, std::shared_ptrGetNodeByAddr(ptr); auto branch = (w0 >> 16) & G_DL_NO_PUSH; - value = gsSPDisplayListOTRHash(ptr); - w0 = value.words.w0; - w1 = value.words.w1; + Gfx value; + if (node["otr_mode"]) { + auto str = node["otr_mode"].as(); + // Too lower case + std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c){ return std::tolower(c); }); + if (str == "index") { + value = gsSPDisplayListOTRIndex(w1); + } else { + value = gsSPDisplayListOTRHash(ptr); + } + w0 = value.words.w0; + w1 = value.words.w1; + } else { + value = gsSPDisplayListOTRHash(ptr); + w0 = value.words.w0; + w1 = value.words.w1; + } writer.Write(w0); writer.Write(w1); diff --git a/src/n64/gbi-otr.h b/src/n64/gbi-otr.h index 0ee659c..a5bb09e 100644 --- a/src/n64/gbi-otr.h +++ b/src/n64/gbi-otr.h @@ -19,6 +19,7 @@ #define G_MTX_OTR 0x36 #define G_TEXRECT_WIDE 0x37 #define G_FILLWIDERECT 0x38 +#define G_DL_OTR_INDEX 0x3D #define G_MOVEMEM_OTR_HASH 0x42 // DL FLAGS @@ -162,6 +163,13 @@ _DW({ (uintptr_t)(dl) \ }} +#define gsSPDisplayListOTRIndex(dl) \ + {{ \ + (_SHIFTL((G_DL_OTR_INDEX), 24, 8) | _SHIFTL((0x00), 16, 8) | \ + _SHIFTL((0), 0, 16)), \ + (uintptr_t)((SEGMENT_NUMBER(dl) << 24) | ((SEGMENT_OFFSET(dl) / 8) & 0x00FFFFFF)) \ + }} + #define gsSPDisplayListOTRFilePath(dl) \ {{ \ (_SHIFTL((G_DL_OTR_FILEPATH), 24, 8) | _SHIFTL((0x00), 16, 8) | \ -- cgit v1.2.3