From 62446c7ba4ca9b89198d92ccc86420de078ee5c1 Mon Sep 17 00:00:00 2001 From: inspectredc Date: Tue, 26 Nov 2024 15:59:38 +0000 Subject: Compressed Texture Factory --- src/Companion.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Companion.cpp') diff --git a/src/Companion.cpp b/src/Companion.cpp index e16c670..a86e64a 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -25,6 +25,7 @@ #include "factories/Vec3sFactory.h" #include "factories/AssetArrayFactory.h" #include "factories/ViewportFactory.h" +#include "factories/CompressedTextureFactory.h" #include "factories/sm64/AnimationFactory.h" #include "factories/sm64/BehaviorScriptFactory.h" @@ -105,6 +106,7 @@ void Companion::Init(const ExportType type) { this->RegisterFactory("ARRAY", std::make_shared()); this->RegisterFactory("ASSET_ARRAY", std::make_shared()); this->RegisterFactory("VP", std::make_shared()); + this->RegisterFactory("COMPRESSED_TEXTURE", std::make_shared()); // SM64 specific this->RegisterFactory("SM64:DIALOG", std::make_shared()); -- cgit v1.2.3 From e466f58b2cff026c37201154cc74096b1f7ac0ce Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Fri, 29 Nov 2024 22:11:39 -0600 Subject: Fixed aiff sample extraction and sample name --- src/Companion.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/Companion.cpp') diff --git a/src/Companion.cpp b/src/Companion.cpp index a86e64a..0589c84 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -573,7 +573,7 @@ void Companion::ProcessFile(YAML::Node root) { if(assetNode["type"]){ const auto type = GetSafeNode(assetNode, "type"); - if(type == "SAMPLE"){ + if(type == "NAUDIO:V0:SAMPLE"){ AudioManager::Instance->bind_sample(assetNode, output); } } @@ -597,10 +597,9 @@ void Companion::ProcessFile(YAML::Node root) { auto output = (this->gCurrentDirectory / entryName).string(); std::replace(output.begin(), output.end(), '\\', '/'); - if(node["type"]){ const auto type = GetSafeNode(node, "type"); - if(type == "SAMPLE"){ + if(type == "NAUDIO:V0:SAMPLE"){ AudioManager::Instance->bind_sample(node, output); } } -- cgit v1.2.3 From 4bbd836d63937317b0164d3efb82c2d18be7a808 Mon Sep 17 00:00:00 2001 From: inspectredc Date: Wed, 27 Nov 2024 20:53:14 +0000 Subject: Pad Warning Fix --- src/Companion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Companion.cpp') diff --git a/src/Companion.cpp b/src/Companion.cpp index 0589c84..7461dc6 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -906,7 +906,7 @@ void Companion::ProcessFile(YAML::Node root) { } else { stream << "\n"; } - } else if(gap > 0x10) { + } else if(gap >= 0x10) { stream << "// WARNING: Gap detected between 0x" << std::hex << startptr << " and 0x" << end << " with size 0x" << gap << "\n"; } } -- cgit v1.2.3 From 09ade8bb7fc85f35dcabb2def2e2694f29739765 Mon Sep 17 00:00:00 2001 From: inspectredc Date: Wed, 27 Nov 2024 21:37:31 +0000 Subject: pad autogen happens between all aligned assets --- src/Companion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Companion.cpp') diff --git a/src/Companion.cpp b/src/Companion.cpp index 7461dc6..3fca4e3 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -888,7 +888,7 @@ void Companion::ProcessFile(YAML::Node root) { if(gap < 0) { stream << "// WARNING: Overlap detected between 0x" << std::hex << startptr << " and 0x" << end << " with size 0x" << std::abs(gap) << "\n"; SPDLOG_WARN("Overlap detected between 0x{:X} and 0x{:X} with size 0x{:X} on file {}", startptr, end, gap, this->gCurrentFile); - } else if(gap < 0x10 && gap >= alignment && end % 0x10 == 0 && this->gEnablePadGen) { + } else if(gap < 0x10 && gap >= alignment && end % alignment == 0 && this->gEnablePadGen) { SPDLOG_WARN("Gap detected between 0x{:X} and 0x{:X} with size 0x{:X} on file {}", startptr, end, gap, this->gCurrentFile); SPDLOG_WARN("Creating pad of 0x{:X} bytes", gap); const auto padfile = this->gCurrentDirectory.filename().string(); -- cgit v1.2.3 From ed4ee26fe6d6ec113efc54d188c5864f44c1e14d Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Fri, 6 Dec 2024 14:44:36 -0600 Subject: Implemented rom preprocessing system and comptool support --- src/Companion.cpp | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'src/Companion.cpp') diff --git a/src/Companion.cpp b/src/Companion.cpp index 3fca4e3..199d649 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -79,6 +79,8 @@ #include "factories/naudio/v1/BookFactory.h" #include "factories/naudio/v1/SequenceFactory.h" +#include "preprocess/CompTool.h" + using namespace std::chrono; namespace fs = std::filesystem; @@ -1013,8 +1015,44 @@ void Companion::Process() { } auto rom = !isDirectoryMode ? config[this->gCartridge->GetHash()] : config; - auto cfg = rom["config"]; + if(rom["preprocess"]) { + auto preprocess = rom["preprocess"]; + for(auto job = preprocess.begin(); job != preprocess.end(); job++) { + auto name = job->first.as(); + auto item = job->second; + auto method = GetSafeNode(item, "method"); + if (method == "mio0-comptool") { + auto type = GetSafeNode(item, "type"); + auto target = GetSafeNode(item, "target"); + auto restart = GetSafeNode(item, "restart"); + + if (type == "decompress") { + this->gRomData = CompTool::Decompress(this->gRomData); + this->gCartridge = std::make_shared(this->gRomData); + this->gCartridge->Initialize(); + + auto hash = this->gCartridge->GetHash(); + + SPDLOG_INFO("ROM decompressed to {}", hash); + + if (hash != target) { + throw std::runtime_error("Hash mismatch"); + } + + if(restart){ + rom = config[this->gCartridge->GetHash()]; + } + } else { + throw std::runtime_error("Only decompression is supported"); + } + } else { + throw std::runtime_error("Invalid preprocess method"); + } + } + } + + auto cfg = rom["config"]; if(!cfg) { SPDLOG_ERROR("No config found for {}", !isDirectoryMode ? this->gCartridge->GetHash() : GetSafeNode(config, "folder")); return; -- cgit v1.2.3