summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Companion.cpp2
-rw-r--r--src/Companion.h4
-rw-r--r--src/factories/CompressedTextureFactory.cpp44
-rw-r--r--src/factories/TextureFactory.cpp12
4 files changed, 38 insertions, 24 deletions
diff --git a/src/Companion.cpp b/src/Companion.cpp
index 7e9744d..a70f715 100644
--- a/src/Companion.cpp
+++ b/src/Companion.cpp
@@ -1158,6 +1158,8 @@ void Companion::Process() {
}
}
+ this->gConfig.textureDefines = cfg["textures"] && (cfg["textures"].as<std::string>() == "ADDITIONAL_DEFINES");
+
this->ParseHash();
SPDLOG_INFO("------------------------------------------------");
diff --git a/src/Companion.h b/src/Companion.h
index 069a6e4..2807d8d 100644
--- a/src/Companion.h
+++ b/src/Companion.h
@@ -90,6 +90,7 @@ struct TorchConfig {
ArchiveType otrMode;
bool debug;
bool modding;
+ bool textureDefines;
};
struct ParseResultData {
@@ -116,6 +117,7 @@ public:
this->gConfig.otrMode = otr;
this->gConfig.debug = debug;
this->gConfig.modding = modding;
+ this->gConfig.textureDefines = false;
}
explicit Companion(std::vector<uint8_t> rom, const ArchiveType otr, const bool debug, const bool modding = false) : gCartridge(nullptr) {
@@ -123,6 +125,7 @@ public:
this->gConfig.otrMode = otr;
this->gConfig.debug = debug;
this->gConfig.modding = modding;
+ this->gConfig.textureDefines = false;
}
void Init(ExportType type);
@@ -133,6 +136,7 @@ public:
bool IsOTRMode() const { return (this->gConfig.otrMode != ArchiveType::None); }
bool IsDebug() const { return this->gConfig.debug; }
+ bool AddTextureDefines() const { return this->gConfig.textureDefines; }
N64::Cartridge* GetCartridge() const { return this->gCartridge.get(); }
std::vector<uint8_t>& GetRomData() { return this->gRomData; }
diff --git a/src/factories/CompressedTextureFactory.cpp b/src/factories/CompressedTextureFactory.cpp
index 3fab3ef..1c8a974 100644
--- a/src/factories/CompressedTextureFactory.cpp
+++ b/src/factories/CompressedTextureFactory.cpp
@@ -68,29 +68,33 @@ ExportResult CompressedTextureHeaderExporter::Export(std::ostream &write, std::s
} else {
if(isOTR){
write << "static const ALIGN_ASSET(2) char " << symbol << "[] = \"__OTR__" << (*replacement) << "\";\n\n";
- write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
- write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
+ if (Companion::Instance->AddTextureDefines()) {
+ write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
+ write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
+ }
} else {
write << "extern " << "u8 " << symbol << "[];\n";
- // Allocate worse case size
- uint8_t* compressedData;
- size_t compressedSize;
- size_t worstSize;
-
- switch (texture->mCompressionType) {
- case CompressionType::MIO0:
- worstSize = MIO0_HEADER_LENGTH + ((data.size()+7)/8) + data.size();
- compressedData = static_cast<uint8_t*>(std::calloc(worstSize, sizeof(uint8_t)));
- compressedSize = mio0_encode(data.data(), data.size(), compressedData);
- break;
- default:
- // UNIMPLEMENTED
- throw std::runtime_error("Unsupported Compressed Texture Type");
- break;
+ if (Companion::Instance->AddTextureDefines()) {
+ // Allocate worse case size
+ uint8_t* compressedData;
+ size_t compressedSize;
+ size_t worstSize;
+
+ switch (texture->mCompressionType) {
+ case CompressionType::MIO0:
+ worstSize = MIO0_HEADER_LENGTH + ((data.size()+7)/8) + data.size();
+ compressedData = static_cast<uint8_t*>(std::calloc(worstSize, sizeof(uint8_t)));
+ compressedSize = mio0_encode(data.data(), data.size(), compressedData);
+ break;
+ default:
+ // UNIMPLEMENTED
+ throw std::runtime_error("Unsupported Compressed Texture Type");
+ break;
+ }
+ write << "#define _" << symbol << "_COMPRESSED_SIZE 0x" << std::hex << compressedSize << std::dec << "\n";
+ write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
+ write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
}
- write << "#define _" << symbol << "_COMPRESSED_SIZE 0x" << std::hex << compressedSize << std::dec << "\n";
- write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
- write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
}
}
diff --git a/src/factories/TextureFactory.cpp b/src/factories/TextureFactory.cpp
index ca88fcb..75b6796 100644
--- a/src/factories/TextureFactory.cpp
+++ b/src/factories/TextureFactory.cpp
@@ -61,12 +61,16 @@ ExportResult TextureHeaderExporter::Export(std::ostream &write, std::shared_ptr<
} else {
if(isOTR){
write << "static const ALIGN_ASSET(2) char " << symbol << "[] = \"__OTR__" << (*replacement) << "\";\n\n";
- write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
- write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
+ if (Companion::Instance->AddTextureDefines()) {
+ write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
+ write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
+ }
} else {
write << "extern " << GetSafeNode<std::string>(node, "ctype", "u8") << " " << symbol << "[];\n";
- write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
- write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
+ if (Companion::Instance->AddTextureDefines()) {
+ write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
+ write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
+ }
}
}