Skip to content

Commit

Permalink
Revert yay0 change that broke mk64 (#156)
Browse files Browse the repository at this point in the history
* Revert breakage

* Update Decompressor.cpp
  • Loading branch information
MegaMech authored Nov 11, 2024
1 parent ff8c2d1 commit 6edf65b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/utils/Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,23 @@ DecompressedData Decompressor::AutoDecode(YAML::Node& node, std::vector<uint8_t>

auto fileOffset = TranslateAddr(offset, true);

// Extract compressed assets.
if (node["mio0"] || node["yay0"]) {
auto foffset = TranslateAddr(offset, true);
auto decoded = Decode(buffer, foffset, node["mio0"] ? CompressionType::MIO0 : CompressionType::YAY0);
// Check if an asset in a yaml file is mio0 compressed and extract.
if (node["mio0"]) {
auto assetPtr = ASSET_PTR(offset);
auto gameSize = Companion::Instance->GetRomData().size();

auto fileOffset = TranslateAddr(offset, true);
offset = ASSET_PTR(offset);

auto decoded = Decode(buffer, fileOffset + offset, CompressionType::MIO0);
auto size = node["size"] ? node["size"].as<size_t>() : manualSize.value_or(decoded->size);
return {
.root = decoded,
.segment = { decoded->data, size }
.root = decoded,
.segment = { decoded->data, size }
};
}

// Extract compressed tkmk00 assets in mk64.
// Check if an asset in a yaml file is tkmk00 compressed and extract (mk64).
if (node["tkmk00"]) {
const auto alpha = GetSafeNode<uint32_t>(node, "alpha");
const auto width = GetSafeNode<uint32_t>(node, "width");
Expand All @@ -98,7 +103,7 @@ DecompressedData Decompressor::AutoDecode(YAML::Node& node, std::vector<uint8_t>
};
}

// Extract compressed files that contain many assets.
// Extract a compressed file which contains many assets.
switch(type) {
case CompressionType::YAY0:
case CompressionType::MIO0: {
Expand Down

0 comments on commit 6edf65b

Please sign in to comment.