diff options
| author | inspectredc <inspectredc@gmail.com> | 2025-06-19 12:21:07 +0100 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2025-07-04 17:41:27 -0600 |
| commit | 5e334dc8c7dfc055a7a6bfadaee43735d4ab6692 (patch) | |
| tree | 4da2a435b109a99c70bb3b6636813000c3af8992 /src/Companion.cpp | |
| parent | 8b5ef9129c2106564f0cfbc7f6dd934b5b5884ae (diff) | |
Support virtual addrs lookup
Diffstat (limited to 'src/Companion.cpp')
| -rw-r--r-- | src/Companion.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Companion.cpp b/src/Companion.cpp index 7a4ee09..e16a99f 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -405,6 +405,11 @@ void Companion::ParseCurrentFileConfig(YAML::Node node) { } } + if (node["virtual"]) { + auto virtualAddrMap = node["virtual"]; + gVirtualAddrMap[gCurrentFile] = std::make_tuple<uint32_t, uint32_t>(virtualAddrMap[0].as<uint32_t>(), virtualAddrMap[1].as<uint32_t>()); + } + if(node["header"]) { auto header = node["header"]; switch (this->gConfig.exporterType) { @@ -1400,11 +1405,19 @@ std::optional<std::uint32_t> Companion::GetFileOffsetFromSegmentedAddr(const uin return std::nullopt; } -std::optional<std::tuple<std::string, YAML::Node>> Companion::GetNodeByAddr(const uint32_t addr){ +std::optional<std::tuple<std::string, YAML::Node>> Companion::GetNodeByAddr(uint32_t addr){ if(!this->gAddrMap.contains(this->gCurrentFile)){ return std::nullopt; } + // HACK: Adjust address to rom address if virtual address + if (addr & 0x80000000) { + if (gVirtualAddrMap.contains(gCurrentFile)) { + addr -= std::get<0>(gVirtualAddrMap[gCurrentFile]); + addr += std::get<1>(gVirtualAddrMap[gCurrentFile]); + } + } + if(!this->gAddrMap[this->gCurrentFile].contains(addr)){ for (auto &file : this->gCurrentExternalFiles) { if (!this->gAddrMap.contains(file)) { |
