mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Added support to extract skyboxes and cake
This commit is contained in:
+4
-1
@@ -3,4 +3,7 @@ build-*/
|
||||
cmake-build-*/
|
||||
*.otr
|
||||
*.log
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
debug/
|
||||
*.z64
|
||||
*.n64
|
||||
+1
-1
@@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD 20)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
file(GLOB CXX_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/**/*.cpp)
|
||||
file(GLOB C_FILES ${CMAKE_CURRENT_SOURCE_DIR}/lib/**/*.c)
|
||||
file(GLOB C_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c ${CMAKE_CURRENT_SOURCE_DIR}/src/**/*.c ${CMAKE_CURRENT_SOURCE_DIR}/lib/**/*.c)
|
||||
set(SRC_DIR ${CXX_FILES} ${C_FILES})
|
||||
|
||||
set(VPKTOOL_BUILD_GUI OFF)
|
||||
|
||||
+13
-11
@@ -525,6 +525,8 @@
|
||||
"actors/yoshi_egg/yoshi_egg_5_unused.rgba16.png": [32,32,2048,{"jp":[1215456,32696],"us":[1222624,32696],"eu":[1094592,32696],"sh":[1071104,32696]}],
|
||||
"actors/yoshi_egg/yoshi_egg_6_unused.rgba16.png": [32,32,2048,{"jp":[1215456,34744],"us":[1222624,34744],"eu":[1094592,34744],"sh":[1071104,34744]}],
|
||||
"actors/yoshi_egg/yoshi_egg_7_unused.rgba16.png": [32,32,2048,{"jp":[1215456,36792],"us":[1222624,36792],"eu":[1094592,36792],"sh":[1071104,36792]}],
|
||||
"sound/sequences.bin": [114432, { "us": [8063072] }],
|
||||
"sound/bank_sets.bin": [159, { "us": [8177185] }],
|
||||
"assets/demos/bbh.bin": [988,{"jp":[5733368],"us":[5741664],"eu":[5620584],"sh":[5589632]}],
|
||||
"assets/demos/bitdw.bin": [1412,{"us":[5747100],"sh":[5595068]}],
|
||||
"assets/demos/ccm.bin": [1320,{"jp":[5734356],"us":[5742652],"eu":[5621572],"sh":[5590620]}],
|
||||
@@ -634,7 +636,7 @@
|
||||
"levels/ddd/2.rgba16.png": [32,32,2048,{"jp":[4765904,6144],"us":[4774192,6144],"eu":[4647792,6144],"sh":[4622160,6144]}],
|
||||
"levels/ddd/3.rgba16.png": [64,32,4096,{"jp":[4765904,8192],"us":[4774192,8192],"eu":[4647792,8192],"sh":[4622160,8192]}],
|
||||
"levels/ddd/4.rgba16.png": [32,32,2048,{"jp":[4765904,12288],"us":[4774192,12288],"eu":[4647792,12288],"sh":[4622160,12288]}],
|
||||
"levels/ending/cake.png": [153600,{"jp":[4834992,0],"us":[4843280,0],"sh":[4691248,0]}],
|
||||
"levels/ending/cake.sbox": [153600,{"jp":[4834992,0],"us":[4843280,0],"sh":[4691248,0]}],
|
||||
"levels/ending/cake_eu.png": [143360,{"eu":[4716880,0]}],
|
||||
"levels/ending/eu_023000.rgba16.png": [64,32,4096,{"eu":[4716880,143360]}],
|
||||
"levels/ending/eu_024000.rgba16.png": [64,32,4096,{"eu":[4716880,147456]}],
|
||||
@@ -1137,16 +1139,16 @@
|
||||
"textures/cave/hmc_textures.0A800.rgba16.png": [32,64,4096,{"jp":[3432432,43008],"us":[3439184,43008],"eu":[3312784,43008],"sh":[3287152,43008]}],
|
||||
"textures/cave/hmc_textures.0B800.ia16.png": [32,32,2048,{"jp":[3432432,47104],"us":[3439184,47104],"eu":[3312784,47104],"sh":[3287152,47104]}],
|
||||
"textures/cave/hmc_textures.0C000.ia16.png": [32,32,2048,{"jp":[3298272,43008],"us":[3305024,43008],"eu":[3178624,43008],"sh":[3152992,43008]}],
|
||||
"textures/skyboxes/bbh.png": [84288,{"jp":[3118928,0],"us":[3125680,0],"eu":[2999280,0],"sh":[2973648,0]}],
|
||||
"textures/skyboxes/bidw.png": [131392,{"jp":[3146352,0],"us":[3153104,0],"eu":[3026704,0],"sh":[3001072,0]}],
|
||||
"textures/skyboxes/bitfs.png": [102720,{"jp":[2942432,0],"us":[2949184,0],"eu":[2822784,0],"sh":[2797152,0]}],
|
||||
"textures/skyboxes/bits.png": [131392,{"jp":[3191904,0],"us":[3198656,0],"eu":[3072256,0],"sh":[3046624,0]}],
|
||||
"textures/skyboxes/ccm.png": [131392,{"jp":[2847920,0],"us":[2854672,0],"eu":[2728272,0],"sh":[2702640,0]}],
|
||||
"textures/skyboxes/cloud_floor.png": [131392,{"jp":[3038752,0],"us":[3045504,0],"eu":[2919104,0],"sh":[2893472,0]}],
|
||||
"textures/skyboxes/clouds.png": [84288,{"jp":[2906480,0],"us":[2913232,0],"eu":[2786832,0],"sh":[2761200,0]}],
|
||||
"textures/skyboxes/ssl.png": [131392,{"jp":[3078784,0],"us":[3085536,0],"eu":[2959136,0],"sh":[2933504,0]}],
|
||||
"textures/skyboxes/water.png": [131392,{"jp":[2796624,0],"us":[2803376,0],"eu":[2676976,0],"sh":[2651344,0]}],
|
||||
"textures/skyboxes/wdw.png": [131392,{"jp":[2968208,0],"us":[2974960,0],"eu":[2848560,0],"sh":[2822928,0]}],
|
||||
"textures/skyboxes/bbh.sbox": [84288,{"jp":[3118928,0],"us":[3125680,0],"eu":[2999280,0],"sh":[2973648,0]}],
|
||||
"textures/skyboxes/bidw.sbox": [131392,{"jp":[3146352,0],"us":[3153104,0],"eu":[3026704,0],"sh":[3001072,0]}],
|
||||
"textures/skyboxes/bitfs.sbox": [102720,{"jp":[2942432,0],"us":[2949184,0],"eu":[2822784,0],"sh":[2797152,0]}],
|
||||
"textures/skyboxes/bits.sbox": [131392,{"jp":[3191904,0],"us":[3198656,0],"eu":[3072256,0],"sh":[3046624,0]}],
|
||||
"textures/skyboxes/ccm.sbox": [131392,{"jp":[2847920,0],"us":[2854672,0],"eu":[2728272,0],"sh":[2702640,0]}],
|
||||
"textures/skyboxes/cloud_floor.sbox": [131392,{"jp":[3038752,0],"us":[3045504,0],"eu":[2919104,0],"sh":[2893472,0]}],
|
||||
"textures/skyboxes/clouds.sbox": [84288,{"jp":[2906480,0],"us":[2913232,0],"eu":[2786832,0],"sh":[2761200,0]}],
|
||||
"textures/skyboxes/ssl.sbox": [131392,{"jp":[3078784,0],"us":[3085536,0],"eu":[2959136,0],"sh":[2933504,0]}],
|
||||
"textures/skyboxes/water.sbox": [131392,{"jp":[2796624,0],"us":[2803376,0],"eu":[2676976,0],"sh":[2651344,0]}],
|
||||
"textures/skyboxes/wdw.sbox": [131392,{"jp":[2968208,0],"us":[2974960,0],"eu":[2848560,0],"sh":[2822928,0]}],
|
||||
"textures/effect/bubble.06048.rgba16.png": [32,32,2048,{"jp":[3594960,24648],"us":[3601712,24648],"eu":[3475312,24648],"sh":[3449680,24648]}],
|
||||
"textures/effect/flower.00008.rgba16.png": [32,32,2048,{"jp":[3594960,8],"us":[3601712,8],"eu":[3475312,8],"sh":[3449680,8]}],
|
||||
"textures/effect/flower.00808.rgba16.png": [32,32,2048,{"jp":[3594960,2056],"us":[3601712,2056],"eu":[3475312,2056],"sh":[3449680,2056]}],
|
||||
|
||||
+21
-3
@@ -3,6 +3,7 @@
|
||||
#include "storm/SWrapper.h"
|
||||
#include "utils/MIODecoder.h"
|
||||
#include "factories/RawFactory.h"
|
||||
#include "factories/BlobFactory.h"
|
||||
#include "factories/TextureFactory.h"
|
||||
|
||||
#include <fstream>
|
||||
@@ -14,7 +15,9 @@ using json = nlohmann::json;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
static const std::unordered_map<std::string, RawFactory*> gFactories = {
|
||||
{ ".png", new TextureFactory() }
|
||||
{ ".png", new TextureFactory() },
|
||||
{ ".bin", new BlobFactory(LUS::ResourceType::Blob) },
|
||||
{ ".sbox", new BlobFactory(LUS::ResourceType::Blob, true) },
|
||||
};
|
||||
|
||||
void Companion::Start() {
|
||||
@@ -48,14 +51,29 @@ void Companion::ProcessAssets() {
|
||||
{ "path", path },
|
||||
{ "offsets", data }
|
||||
};
|
||||
if(!gFactories.at(extension)->process(&write, entry, this->gRomData)){
|
||||
RawFactory* factory = gFactories.at(extension);
|
||||
|
||||
if(!factory->process(&write, entry, this->gRomData)){
|
||||
std::cout << "Failed to process " << asset << '\n';
|
||||
continue;
|
||||
}
|
||||
|
||||
std::cout << "Processed " << path << std::endl;
|
||||
bool isTexture = typeid(*factory) == typeid(TextureFactory);
|
||||
|
||||
auto buffer = write.ToVector();
|
||||
// TODO: Change this that we all know its going to crash with other assets
|
||||
wrapper.CreateFile(path.substr(0, path.find_last_of('.')), buffer);
|
||||
wrapper.CreateFile(isTexture ? path.substr(0, path.find_last_of('.')) : path, buffer);
|
||||
|
||||
if(!isTexture) {
|
||||
// Write to file too
|
||||
std::string dpath = "debug/" + path;
|
||||
fs::create_directories(fs::path(dpath).parent_path());
|
||||
std::ofstream output(dpath, std::ios::binary);
|
||||
output.write((char*)buffer.data(), buffer.size());
|
||||
output.close();
|
||||
}
|
||||
|
||||
write.Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "BlobFactory.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include "Companion.h"
|
||||
#include "utils/MIODecoder.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
bool BlobFactory::process(LUS::BinaryWriter* writer, nlohmann::json& data, std::vector<uint8_t>& buffer) {
|
||||
auto metadata = data["offsets"];
|
||||
if(!metadata[1].contains("us")){
|
||||
return false;
|
||||
}
|
||||
|
||||
WRITE_HEADER(this->type, 0);
|
||||
|
||||
size_t size = metadata[0];
|
||||
auto offsets = metadata[1]["us"];
|
||||
|
||||
auto* blob = new uint8_t[size];
|
||||
if(this->isMIOChunk){
|
||||
auto mio0 = MIO0Decoder::Decode(buffer, offsets[0]);
|
||||
memcpy(blob, mio0.data() + offsets[1], size);
|
||||
} else {
|
||||
memcpy(blob, buffer.data() + offsets[0], size);
|
||||
}
|
||||
|
||||
WRITE_U32(size); // Blob Data Size
|
||||
WRITE_ARRAY(blob, size); // Blob Data
|
||||
|
||||
delete[] blob;
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "RawFactory.h"
|
||||
|
||||
class BlobFactory : public RawFactory {
|
||||
public:
|
||||
BlobFactory(LUS::ResourceType type, bool isMIOChunk = false) : type(type), isMIOChunk(isMIOChunk) {}
|
||||
bool process(LUS::BinaryWriter* write, nlohmann::json& data, std::vector<uint8_t>& buffer) override;
|
||||
private:
|
||||
bool isMIOChunk = false;
|
||||
LUS::ResourceType type = LUS::ResourceType::Blob;
|
||||
};
|
||||
@@ -14,5 +14,9 @@ enum class ResourceType {
|
||||
Array = 0x4F415252, // OARR
|
||||
Blob = 0x4F424C42, // OBLB
|
||||
Texture = 0x4F544558, // OTEX
|
||||
|
||||
// CubeOS
|
||||
Demo = 0x44454D4F, // DEMO
|
||||
Skybox = 0x534B5942, // SKYB
|
||||
};
|
||||
} // namespace LUS
|
||||
|
||||
Reference in New Issue
Block a user