summaryrefslogtreecommitdiff
path: root/src/Companion.cpp
diff options
context:
space:
mode:
authorLywx <kiritodev01@gmail.com>2024-03-22 09:59:49 -0600
committerGitHub <noreply@github.com>2024-03-22 09:59:49 -0600
commitaaa68d2ebcb732d7d18af1a41a292c50182e7fd5 (patch)
tree4b93c2a1899e6b2ebfcfe7cf4c2c06e8461c6aa4 /src/Companion.cpp
parent6e9f82312178d1fbc002a04ce97cf8b5add1f402 (diff)
Cleanup (#49)
* Auto debug info generation and some cleanup * Cleaned dry code from segments * Fixed gCurrentCompressionType bss bs
Diffstat (limited to 'src/Companion.cpp')
-rw-r--r--src/Companion.cpp25
1 files changed, 10 insertions, 15 deletions
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<uint32_t>();
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);