From aaa68d2ebcb732d7d18af1a41a292c50182e7fd5 Mon Sep 17 00:00:00 2001 From: Lywx Date: Fri, 22 Mar 2024 09:59:49 -0600 Subject: Cleanup (#49) * Auto debug info generation and some cleanup * Cleaned dry code from segments * Fixed gCurrentCompressionType bss bs --- src/Companion.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'src/Companion.cpp') diff --git a/src/Companion.cpp b/src/Companion.cpp index 4b2b234..2dca649 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -250,13 +250,6 @@ void Companion::ExtractNode(YAML::Node& node, std::string& name, SWrapper* binar file.close(); break; } - case ExportType::Code: { - endptr = exporter->get()->Export(stream, result.value(), name, node, &name); - if (this->IsDebug() && endptr.has_value() && endptr->index() == 0) { - stream << "// 0x" << std::hex << std::uppercase << std::get<0>(endptr.value()) << "\n\n"; - } - break; - } default: { endptr = exporter->get()->Export(stream, result.value(), name, node, &name); break; @@ -689,7 +682,7 @@ void Companion::Process() { } else { const auto offset = assetNode["offset"].as(); if(gCurrentFileOffset) { - if (IS_SEGMENTED(offset) == false) { + if (!IS_SEGMENTED(offset)) { assetNode["offset"] = (gCurrentSegmentNumber << 24) | offset; } } @@ -765,16 +758,18 @@ void Companion::Process() { for (size_t i = 0; i < entries.size(); i++) { const auto result = entries[i]; - stream << result.buffer; + const auto hasSize = result.endptr.has_value(); + if (hasSize && this->IsDebug()) { + stream << "// 0x" << std::hex << std::uppercase << ASSET_PTR(result.addr) << "\n"; + } - if(i < entries.size() - 1 && this->gConfig.exporterType == ExportType::Code){ - auto endptr = result.endptr; - if(!endptr.has_value()){ - continue; - } + stream << result.buffer; -#define ASSET_PTR(x) IS_SEGMENTED(x) ? SEGMENT_OFFSET(x) : x + if (hasSize && this->IsDebug()) { + stream << "// 0x" << std::hex << std::uppercase << ASSET_PTR(result.endptr.value()) << "\n\n"; + } + if(hasSize && i < entries.size() - 1 && this->gConfig.exporterType == ExportType::Code){ uint32_t startptr = ASSET_PTR(result.endptr.value()); uint32_t end = ASSET_PTR(entries[i + 1].addr); -- cgit v1.2.3