diff options
| author | inspectredc <inspectredc@gmail.com> | 2025-07-02 18:55:50 +0100 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2025-07-04 17:40:01 -0600 |
| commit | 8b5ef9129c2106564f0cfbc7f6dd934b5b5884ae (patch) | |
| tree | eeae600d95c2a2b2c3e2aeea75937a2b9a2b8c83 /src/factories/CompressedTextureFactory.cpp | |
| parent | bc2736adb1b3b3fc7e110cb3a518a7bbe8af65d8 (diff) | |
ma2d1 support
Diffstat (limited to 'src/factories/CompressedTextureFactory.cpp')
| -rw-r--r-- | src/factories/CompressedTextureFactory.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/factories/CompressedTextureFactory.cpp b/src/factories/CompressedTextureFactory.cpp index 1c8a974..6b507e4 100644 --- a/src/factories/CompressedTextureFactory.cpp +++ b/src/factories/CompressedTextureFactory.cpp @@ -9,6 +9,8 @@ extern "C" { #include "n64graphics/n64graphics.h" #include "BaseFactory.h" #include <libmio0/mio0.h> +#include <libyay0/yay0.h> +#include <libyay0/yay1.h> } static bool isTable = false; @@ -31,6 +33,7 @@ static const std::unordered_map <std::string, TextureFormat> sTextureFormats = { static const std::unordered_map <std::string, CompressionType> sCompressionTypes = { { "MIO0", CompressionType::MIO0 }, { "YAY0", CompressionType::YAY0 }, + { "YAY1", CompressionType::YAY1 }, { "YAZ0", CompressionType::YAZ0 }, }; @@ -86,6 +89,16 @@ ExportResult CompressedTextureHeaderExporter::Export(std::ostream &write, std::s compressedData = static_cast<uint8_t*>(std::calloc(worstSize, sizeof(uint8_t))); compressedSize = mio0_encode(data.data(), data.size(), compressedData); break; + case CompressionType::YAY0: + worstSize = YAY0_HEADER_LENGTH + ((data.size()+7)/8) + data.size(); + compressedData = static_cast<uint8_t*>(std::calloc(worstSize, sizeof(uint8_t))); + compressedSize = yay0_encode(data.data(), data.size(), compressedData); + break; + case CompressionType::YAY1: + worstSize = YAY1_HEADER_LENGTH + ((data.size()+7)/8) + data.size(); + compressedData = static_cast<uint8_t*>(std::calloc(worstSize, sizeof(uint8_t))); + compressedSize = yay1_encode(data.data(), data.size(), compressedData); + break; default: // UNIMPLEMENTED throw std::runtime_error("Unsupported Compressed Texture Type"); @@ -151,6 +164,16 @@ ExportResult CompressedTextureCodeExporter::Export(std::ostream &write, std::sha compressedData = static_cast<uint8_t*>(std::calloc(worstSize, sizeof(uint8_t))); compressedSize = mio0_encode(data.data(), data.size(), compressedData); break; + case CompressionType::YAY0: + worstSize = YAY0_HEADER_LENGTH + ((data.size()+7)/8) + data.size(); + compressedData = static_cast<uint8_t*>(std::calloc(worstSize, sizeof(uint8_t))); + compressedSize = yay0_encode(data.data(), data.size(), compressedData); + break; + case CompressionType::YAY1: + worstSize = YAY1_HEADER_LENGTH + ((data.size()+7)/8) + data.size(); + compressedData = static_cast<uint8_t*>(std::calloc(worstSize, sizeof(uint8_t))); + compressedSize = yay1_encode(data.data(), data.size(), compressedData); + break; default: // UNIMPLEMENTED throw std::runtime_error("Unsupported Compressed Texture Type"); @@ -329,6 +352,8 @@ std::string getcomptype(CompressionType type) { return "MIO0"; case CompressionType::YAY0: return "YAY0"; + case CompressionType::YAY1: + return "YAY1"; case CompressionType::YAZ0: return "YAZ0"; default: @@ -350,7 +375,7 @@ std::optional<std::shared_ptr<IParsedData>> CompressedTextureFactory::parse(std: if (!sCompressionTypes.contains(compression)) { SPDLOG_ERROR("Compresed Texture entry at {:X} in yaml missing compression type\n\ Please add one of the following compression types\n\ - MIO0, YAY0 (Unsupported), YAZ0 (Unsupported)", offset); + MIO0, YAY0, YAY1, YAZ0 (Unsupported)", offset); return std::nullopt; } compressionType = sCompressionTypes.at(compression); @@ -447,7 +472,7 @@ std::optional<std::shared_ptr<IParsedData>> CompressedTextureFactory::parse_modd if (!sCompressionTypes.contains(compression)) { SPDLOG_ERROR("Compresed Texture entry at {:X} in yaml missing compression type\n\ Please add one of the following compression types\n\ - MIO0, YAY0 (Unsupported), YAZ0 (Unsupported)", offset); + MIO0, YAY0, YAY1, YAZ0 (Unsupported)", offset); return std::nullopt; } compressionType = sCompressionTypes.at(compression); |
