From c4bb1ad8ee74a2ae4659926717ed7de9ee1e0c69 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sat, 9 Mar 2024 22:42:25 -0700 Subject: Update IsDebug (#25) Co-authored-by: = <=> --- src/Companion.cpp | 6 +++--- src/factories/DisplayListFactory.cpp | 15 ++++++++++++++- src/factories/VtxFactory.cpp | 7 +++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Companion.cpp b/src/Companion.cpp index 7cf9b50..441f596 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -219,7 +219,7 @@ void Companion::ParseCurrentFileConfig(YAML::Node node) { gCurrentFileOffset = segments[0][1].as(); gCurrentCompressionType = GetCompressionType(this->gRomData, gCurrentFileOffset); } else { - throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [, ]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]"); + throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [, ]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]"); } } @@ -232,7 +232,7 @@ void Companion::ParseCurrentFileConfig(YAML::Node node) { this->gConfig.segment.local[id] = replacement; SPDLOG_DEBUG("Segment {} replaced with 0x{:X}", id, replacement); } else { - throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [, ]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]"); + throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [, ]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]"); } } } @@ -414,7 +414,7 @@ void Companion::Process() { gCurrentFileOffset = segments[0][1].as(); gCurrentCompressionType = GetCompressionType(this->gRomData, gCurrentFileOffset); } else { - throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [, ]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]"); + throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [, ]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]"); } } } diff --git a/src/factories/DisplayListFactory.cpp b/src/factories/DisplayListFactory.cpp index d5197cc..59e0321 100644 --- a/src/factories/DisplayListFactory.cpp +++ b/src/factories/DisplayListFactory.cpp @@ -123,7 +123,20 @@ void DListCodeExporter::Export(std::ostream &write, std::shared_ptr gfxd_execute(); write << std::string(out); - write << "}; // size = 0x" << std::hex << std::uppercase << (sizeof(uint32_t) * cmds.size()) << "\n\n"; + write << "};\n"; + + if (Companion::Instance->IsDebug()) { + + std::string str = ((sizeof(uint32_t) * cmds.size()) / 8) == 1 ? " displaylist" : " displaylists"; + + write << "// " << std::hex << std::uppercase << ((sizeof(uint32_t) * cmds.size()) / 8) << str << "\n"; + if (IS_SEGMENTED(offset)) { + offset = SEGMENT_OFFSET(offset); + } + write << "// 0x" << std::hex << std::uppercase << (offset + (sizeof(uint32_t) * (cmds.size()))) << "\n"; + } + + write << "\n"; } void DebugDisplayList(uint32_t w0, uint32_t w1){ diff --git a/src/factories/VtxFactory.cpp b/src/factories/VtxFactory.cpp index b8d4d79..2c225f9 100644 --- a/src/factories/VtxFactory.cpp +++ b/src/factories/VtxFactory.cpp @@ -58,11 +58,14 @@ void VtxCodeExporter::Export(std::ostream &write, std::shared_ptr r write << "{{{" << NUM(x) << ", " << NUM(y) << ", " << NUM(z) << "}, " << flag << ", {" << NUM(tc1) << ", " << NUM(tc2) << "}, {" << COL(c1) << ", " << COL(c2) << ", " << COL(c3) << ", " << COL(c4) << "}}},\n"; } + write << "};\n"; + if (Companion::Instance->IsDebug()) { - write << fourSpaceTab << "// 0x" << std::hex << std::uppercase << (offset + (sizeof(VtxRaw) * vtx.size())) << "\n"; + write << "// " << vtx.size() << " vertices\n"; + write << "// 0x" << std::hex << std::uppercase << (offset + (sizeof(VtxRaw) * vtx.size())) << "\n"; } - write << "}; // size = 0x" << std::hex << std::uppercase << (sizeof(VtxRaw) * vtx.size()) << "\n\n"; + write << "\n"; } void VtxBinaryExporter::Export(std::ostream &write, std::shared_ptr raw, std::string& entryName, YAML::Node &node, std::string* replacement ) { -- cgit v1.2.3