summaryrefslogtreecommitdiff
path: root/src/Companion.cpp
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2024-03-10 23:41:36 -0600
committerLywx <kiritodev01@gmail.com>2024-03-11 00:05:16 -0600
commit0277b06b4787f099ed0289eb95ceab98175cc8c4 (patch)
tree7d305d5f8cfe57cbef73c1d1cc3fcf8519b16c47 /src/Companion.cpp
parent595f7512d49b582e9ef2c4d082aa775d2ae600f4 (diff)
Fully implemented tables and message factories
Diffstat (limited to 'src/Companion.cpp')
-rw-r--r--src/Companion.cpp24
1 files changed, 24 insertions, 0 deletions
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<std::string>();
+ auto range = table->second["range"].as<std::vector<uint32_t>>();
+ auto start = gCurrentSegmentNumber ? gCurrentSegmentNumber << 24 | range[0] : range[0];
+ auto end = gCurrentSegmentNumber ? gCurrentSegmentNumber << 24 | range[1] : range[1];
+ auto mode = GetSafeNode<std::string>(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<uint8_t>& buffer, cons
return CompressionType::None;
}
+std::optional<Table> Companion::SearchTable(uint32_t addr){
+ for(auto& table : this->gTables){
+ if(addr >= table.start || addr <= table.end){
+ return table;
+ }
+ }
+
+ return std::nullopt;
+}
+
std::optional<std::uint32_t> Companion::GetFileOffsetFromSegmentedAddr(const uint8_t segment) const {
auto segments = this->gConfig.segment;