mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Added first multiversion support
This commit is contained in:
+10
-3
@@ -57,6 +57,11 @@ void Companion::Process() {
|
||||
|
||||
auto wrapper = SWrapper(otr);
|
||||
|
||||
auto vWriter = LUS::BinaryWriter();
|
||||
vWriter.SetEndianness(LUS::Endianness::Big);
|
||||
vWriter.Write((uint8_t) LUS::Endianness::Big);
|
||||
vWriter.Write(cartridge.GetCRC());
|
||||
|
||||
for (const auto & entry : fs::directory_iterator(path)){
|
||||
std::cout << "Processing " << entry.path() << '\n';
|
||||
YAML::Node root = YAML::LoadFile(entry.path());
|
||||
@@ -73,11 +78,10 @@ void Companion::Process() {
|
||||
|
||||
auto buffer = write.ToVector();
|
||||
auto output = entry.path().stem() / asset->first.as<std::string>();
|
||||
std::cout << "Writing " << output << '\n';
|
||||
wrapper.CreateFile(output, buffer);
|
||||
|
||||
if(type != "TEXTURE") {
|
||||
std::string dpath = "debug/" + path;
|
||||
std::string dpath = "debug/" + output.string();
|
||||
if(!fs::exists(fs::path(dpath).parent_path())){
|
||||
fs::create_directories(fs::path(dpath).parent_path());
|
||||
}
|
||||
@@ -86,12 +90,15 @@ void Companion::Process() {
|
||||
stream.close();
|
||||
}
|
||||
|
||||
std::cout << "Processed " << path << std::endl;
|
||||
std::cout << "Processed " << output << std::endl;
|
||||
|
||||
write.Close();
|
||||
}
|
||||
}
|
||||
|
||||
wrapper.CreateFile("version", vWriter.ToVector());
|
||||
vWriter.Close();
|
||||
|
||||
MIO0Decoder::ClearCache();
|
||||
wrapper.Close();
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ bool AnimFactory::process(LUS::BinaryWriter* writer, YAML::Node& data, std::vect
|
||||
auto index = data["indices"];
|
||||
|
||||
WriteAnimationHeader(writer, header, buffer);
|
||||
WriteAnimationIndex(writer, values, buffer);
|
||||
WriteAnimationValues(writer, index, buffer);
|
||||
WriteAnimationIndex(writer, index, buffer);
|
||||
WriteAnimationValues(writer, values, buffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "RawFactory.h"
|
||||
|
||||
void RawFactory::WriteHeader(LUS::BinaryWriter* writer, LUS::ResourceType resType, int32_t version, bool bigEndian) {
|
||||
writer->Write((uint8_t)(bigEndian ? LUS::Endianness::Big : LUS::Endianness::Little)); // 0x00
|
||||
void RawFactory::WriteHeader(LUS::BinaryWriter* writer, LUS::ResourceType resType, int32_t version) {
|
||||
writer->Write((uint8_t)(LUS::Endianness::Native)); // 0x00
|
||||
writer->Write((uint8_t)0); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
|
||||
@@ -22,5 +22,5 @@ class RawFactory {
|
||||
public:
|
||||
RawFactory() = default;
|
||||
virtual bool process(LUS::BinaryWriter* write, YAML::Node& data, std::vector<uint8_t>& buffer) = 0;
|
||||
void WriteHeader(LUS::BinaryWriter* write, LUS::ResourceType resType, int32_t version, bool bigEndian = false);
|
||||
void WriteHeader(LUS::BinaryWriter* write, LUS::ResourceType resType, int32_t version);
|
||||
};
|
||||
@@ -6,6 +6,8 @@
|
||||
void N64::Cartridge::Initialize() {
|
||||
LUS::BinaryReader reader((char*) this->gRomData.data(), this->gRomData.size());
|
||||
reader.SetEndianness(LUS::Endianness::Big);
|
||||
reader.Seek(0x10, LUS::SeekOffsetType::Start);
|
||||
this->gRomCRC = BSWAP32(reader.ReadUInt32());
|
||||
reader.Seek(0x20, LUS::SeekOffsetType::Start);
|
||||
this->gGameTitle = std::string(reader.ReadCString());
|
||||
reader.Seek(0x3E, LUS::SeekOffsetType::Start);
|
||||
@@ -57,3 +59,7 @@ std::string N64::Cartridge::GetCountryCode() {
|
||||
return "unk";
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t N64::Cartridge::GetCRC() {
|
||||
return this->gRomCRC;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,13 @@ public:
|
||||
CountryCode GetCountry();
|
||||
uint8_t GetVersion() const;
|
||||
std::string GetHash();
|
||||
uint32_t GetCRC();
|
||||
private:
|
||||
std::vector<uint8_t> gRomData;
|
||||
CountryCode gCountryCode;
|
||||
uint8_t gVersion;
|
||||
std::string gGameTitle;
|
||||
std::string gHash;
|
||||
uint32_t gRomCRC;
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const data = require('../assets.json');
|
||||
const data = require('./assets.json');
|
||||
|
||||
const header = [
|
||||
'#pragma once',
|
||||
@@ -9,10 +9,10 @@ const header = [
|
||||
const samples = []
|
||||
|
||||
async function main(){
|
||||
const files = Object.keys(data).filter(f => f.endsWith(".aiff") && data[f][1]['us'] != undefined).map(m => {
|
||||
const files = Object.keys(data).filter(f => f.endsWith(".aiff") && data[f][1]['jp'] != undefined).map(m => {
|
||||
return {
|
||||
file: m,
|
||||
offset: data[m][1]['us'][1]
|
||||
offset: data[m][1]['jp'][1]
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user