diff --git a/src/Companion.cpp b/src/Companion.cpp index 3bede42f..a9a5897a 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -597,6 +597,8 @@ void Companion::ParseCurrentFileConfig(YAML::Node node, std::atomic& ass } } + this->gCurrentFileConfig.reset(node); + if (node["directory"]) { this->gCurrentDirectory = node["directory"].as(); } @@ -1295,6 +1297,7 @@ void Companion::ProcessFile(YAML::Node root, std::atomic& assetCount) { this->gCurrentExternalFiles.clear(); this->gSubFileList.clear(); this->gManualSegments.clear(); + this->gCurrentFileConfig.reset(YAML::Node()); GFXDOverride::ClearVtx(); if (root[":config"]) { @@ -1447,7 +1450,11 @@ void Companion::Process(std::atomic& assetCount) { } } this->gAssetPath = (this->gSourceDirectory / rom["path"].as()).string(); - this->gCommonAssetPath = (this->gSourceDirectory / rom["common_path"].as()).string(); + // Optional: a rom that keeps all its ymls under one tree has no common dir, and + // getRecursiveEntries already treats an empty path as "nothing to add". + if (rom["common_path"]) { + this->gCommonAssetPath = (this->gSourceDirectory / rom["common_path"].as()).string(); + } if (rom["filelist"]) { const std::string filelistPath = (this->gSourceDirectory / rom["filelist"].as()).string(); diff --git a/src/factories/bk64/ModelFactory.cpp b/src/factories/bk64/ModelFactory.cpp index 565f06c8..ab5d6d70 100644 --- a/src/factories/bk64/ModelFactory.cpp +++ b/src/factories/bk64/ModelFactory.cpp @@ -483,9 +483,10 @@ std::optional> ModelFactory::parse(std::vector(width); @@ -495,7 +496,7 @@ std::optional> ModelFactory::parse(std::vector> ModelFactory::parse(std::vectormTexDataSize = textureDataSize; - // Now disambiguate the type 0x1 textures. 0x1 means "has TLUT", which is either CI4 - // (16-entry palette) or CI8 (256-entry palette) — the header doesn't say which. Trick is - // to measure the gap to the next texture: if it's big enough for a full CI8 payload - // (0x200 TLUT + W*H pixels), call it CI8, otherwise CI4. The last texture in a list can be - // padded, hence >= instead of ==. CI8 always needs more room than CI4 at the same W*H - // (delta = 0x1E0 - W*H/2 > 0 for any BK texture up to 64x64), so there's no overlap to - // worry about. - for (uint16_t i = 0; i < textureCount; i++) { - auto& tex = modelData->mTexInfos[i]; - if (tex.type != 0x1) { - continue; - } - - uint32_t nextOffset = - (i + 1 < textureCount) ? modelData->mTexInfos[i + 1].textureDataOffset : textureDataSize; - uint32_t gap = nextOffset - tex.textureDataOffset; - uint32_t ci4Size = 0x20 + ((uint32_t)tex.width * tex.height) / 2; // 16-entry TLUT + CI4 pixels - uint32_t ci8Size = 0x200 + (uint32_t)tex.width * tex.height; // 256-entry TLUT + CI8 pixels - - if (gap >= ci8Size) { - tex.type = 0x2; // CI8 - tex.tlutColors = 0x100; - if (gap != ci8Size) { - SPDLOG_INFO("[BK64::Model] tex[{}] {}x{}: gap=0x{:X} >= CI8 (0x{:X}), classified CI8 (pad=0x{:X})", - i, tex.width, tex.height, gap, ci8Size, gap - ci8Size); - } - } else { - tex.tlutColors = 0x10; // CI4 - if (gap < ci4Size) { - SPDLOG_WARN("[BK64::Model] tex[{}] {}x{}: gap=0x{:X} smaller than CI4 (0x{:X}), data may be " - "truncated", - i, tex.width, tex.height, gap, ci4Size); - } else if (gap != ci4Size) { - SPDLOG_INFO("[BK64::Model] tex[{}] {}x{}: gap=0x{:X} (CI4 0x{:X}, pad=0x{:X})", i, tex.width, - tex.height, gap, ci4Size, gap - ci4Size); - } - } - } - // [port] Grab the entire raw texture area so animated frames and any unlisted bytes // between textures survive into the binary. if (textureDataSize > 0 && texDataStart + textureDataSize <= segment.size) {