mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Implemented rom preprocessing system and comptool support
This commit is contained in:
+39
-1
@@ -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<std::string>();
|
||||
auto item = job->second;
|
||||
auto method = GetSafeNode<std::string>(item, "method");
|
||||
if (method == "mio0-comptool") {
|
||||
auto type = GetSafeNode<std::string>(item, "type");
|
||||
auto target = GetSafeNode<std::string>(item, "target");
|
||||
auto restart = GetSafeNode<bool>(item, "restart");
|
||||
|
||||
if (type == "decompress") {
|
||||
this->gRomData = CompTool::Decompress(this->gRomData);
|
||||
this->gCartridge = std::make_shared<N64::Cartridge>(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<std::string>(config, "folder"));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user