From 0277b06b4787f099ed0289eb95ceab98175cc8c4 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sun, 10 Mar 2024 23:41:36 -0600 Subject: Fully implemented tables and message factories --- src/Companion.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/Companion.cpp') diff --git a/src/Companion.cpp b/src/Companion.cpp index f9cfa8d..b63c67a 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -245,6 +245,7 @@ void Companion::ParseCurrentFileConfig(YAML::Node node) { } } } + if(node["header"]) { auto header = node["header"]; switch (this->gConfig.exporterType) { @@ -267,6 +268,18 @@ void Companion::ParseCurrentFileConfig(YAML::Node node) { default: break; } } + + if(node["tables"]){ + for(auto table = node["tables"].begin(); table != node["tables"].end(); ++table){ + auto name = table->first.as(); + auto range = table->second["range"].as>(); + auto start = gCurrentSegmentNumber ? gCurrentSegmentNumber << 24 | range[0] : range[0]; + auto end = gCurrentSegmentNumber ? gCurrentSegmentNumber << 24 | range[1] : range[1]; + auto mode = GetSafeNode(table->second, "mode", "APPEND"); + TableMode tMode = mode == "REFERENCE" ? TableMode::Reference : TableMode::Append; + this->gTables.push_back({name, start, end, tMode}); + } + } } void Companion::Process() { @@ -491,6 +504,7 @@ void Companion::Process() { this->gConfig.segment.local.clear(); this->gFileHeader.clear(); this->gCurrentPad = 0; + this->gTables.clear(); GFXDOverride::ClearVtx(); if(root[":config"]) { @@ -762,6 +776,16 @@ CompressionType Companion::GetCompressionType(std::vector& buffer, cons return CompressionType::None; } +std::optional Companion::SearchTable(uint32_t addr){ + for(auto& table : this->gTables){ + if(addr >= table.start || addr <= table.end){ + return table; + } + } + + return std::nullopt; +} + std::optional Companion::GetFileOffsetFromSegmentedAddr(const uint8_t segment) const { auto segments = this->gConfig.segment; -- cgit v1.2.3