Repository navigation
Conversation
HAL keeps its assets in .cmp containers: a 4-byte little-endian uncompressed size, then a frame (zstd, or LZ4 in the ubin/ map data). The split decompressed a zstd file by its magic at offset 0, so a frame that starts at offset 4 was read raw, and the shaders inside the BFRES archives of those containers were never seen. On Kirby and the Forgotten Land this is the difference between 121 shaders found and 27,288, and between a game that plays and one that shows a black screen: the game asked for 900 shaders the map did not have, and the log filled with "[RED] shader ... is not in the shader map". The split now opens a size-prefixed frame (unzs_bytes for zstd, unlz4_bytes for LZ4). The size prefix is checked against the decompressed length, so a file that is not a container is left alone, and a container that does not open is reported instead of being passed over in silence. - Found on: Kirby and the Forgotten Land (01004D300C5AE000, in bring-up): 7,201 .cmp files, 5,121 zstd frames with 19,364 BNSH inside (11.2 GB decompressed) and 2,080 LZ4 frames (0.3 GB, no BNSH). The split now finds 27,288 shaders: 18,476 in gfx/, 8,313 in ptcl/, 383 in lyt/, 67 in the loose shader files, 54 in main. - No other game on hand has such a file: Super Mario Bros. Wonder (v0 and v65536) and Yoshi's Crafted World (v1.0.1) have none. - The chain version is unchanged: shader_split.py is not one of the chain's tools (dm/gfx/nvn/dmsh_chain.h needs no rewrite). - The docs entry is in docs/reference/shaders.md; the symptom index is regenerated. All 15 test files in dm/tools/tests pass. Co-Authored-By: Claude Code <[email protected]>
|
fixes #156 |
…tAsset reads (#203, #238) #203 as submitted stopped the shader split of Tears of the Kingdom with a TypeError: its 1,202 Cave/.../C.crbin.<hash>/*.quad files are a 4-byte hash (the one in their folder name), then a zstd frame, so they pass the gate, and on the length mismatch the error path took len() of None. The PR checked Wonder and Yoshi only; of the RomFS of 39 games on hand, only those files have a frame at +4. - unsized: a frame whose header records a size other than the prefix is not such a container and is read as it is, without decompressing it (frame_size). A frame that records none (Kirby's LZ4 frames) must decompress to exactly the prefix's size: the whole output is compared, where the PR's max_length cut a longer frame at the prefix and let it pass. - The dictionary handling is shared with unzs (zs_dict_id, unzs_dict). A dictionary ZDICTS does not have is still reported, not fatal, as in the PR: the ID may be any bytes after a magic at +4. - unityfs.text_assets: an object shorter than the two length fields, or one whose name padding leaves no room for the script's length, is left out instead of reading past its end (struct.error, which stopped the split). Checked: - Kirby and the Forgotten Land (base and update 1.1.0): 121 shaders before, 27,288 after (27,302 with the update), no [RED] line. 5,121 zstd frames record their size, equal to the prefix; 2,080 + 354 LZ4 frames record none and decompress to the prefix's size. The PR's "383 in lyt/" is 378. - Tears of the Kingdom: the full split exits 1 with #203 alone; with this commit its package and tables are byte-identical to main's, no [RED] line. - main's split and this branch's give byte-identical packages and tables on Monster Train 2, Ace Attorney Investigations Collection, AI: THE SOMNIUM FILES, nirvanA Initiative, BALL x PIT, Advance Wars 1+2, Brain Memory Training Academy (Unity 2017.4 to 6000) and Super Mario Bros. Wonder. - New test_size_prefixed_frames.py; test_unity_text_glslc.py covers short objects (fails on #238's unityfs.py). All of dm/tools/tests pass. - Not checked here: FINAL FANTASY CRYSTAL CHRONICLES (#238's game) is not on hand; Kirby has not been run.
|
Thank you, this is on main as 7c5b0b2, with a follow-up in eb858ec. Checked here on Kirby and the Forgotten Land (base and 1.1.0): the split finds 121 shaders before and 27,288 after (27,302 with the update), with no The follow-up fixes a crash this branch caused on another game. Tears of the Kingdom has 1,202 files ( Kirby has not been run here yet, so #156 stays open. |
…tAsset reads (seedds#203, seedds#238) seedds#203 as submitted stopped the shader split of Tears of the Kingdom with a TypeError: its 1,202 Cave/.../C.crbin.<hash>/*.quad files are a 4-byte hash (the one in their folder name), then a zstd frame, so they pass the gate, and on the length mismatch the error path took len() of None. The PR checked Wonder and Yoshi only; of the RomFS of 39 games on hand, only those files have a frame at +4. - unsized: a frame whose header records a size other than the prefix is not such a container and is read as it is, without decompressing it (frame_size). A frame that records none (Kirby's LZ4 frames) must decompress to exactly the prefix's size: the whole output is compared, where the PR's max_length cut a longer frame at the prefix and let it pass. - The dictionary handling is shared with unzs (zs_dict_id, unzs_dict). A dictionary ZDICTS does not have is still reported, not fatal, as in the PR: the ID may be any bytes after a magic at +4. - unityfs.text_assets: an object shorter than the two length fields, or one whose name padding leaves no room for the script's length, is left out instead of reading past its end (struct.error, which stopped the split). Checked: - Kirby and the Forgotten Land (base and update 1.1.0): 121 shaders before, 27,288 after (27,302 with the update), no [RED] line. 5,121 zstd frames record their size, equal to the prefix; 2,080 + 354 LZ4 frames record none and decompress to the prefix's size. The PR's "383 in lyt/" is 378. - Tears of the Kingdom: the full split exits 1 with seedds#203 alone; with this commit its package and tables are byte-identical to main's, no [RED] line. - main's split and this branch's give byte-identical packages and tables on Monster Train 2, Ace Attorney Investigations Collection, AI: THE SOMNIUM FILES, nirvanA Initiative, BALL x PIT, Advance Wars 1+2, Brain Memory Training Academy (Unity 2017.4 to 6000) and Super Mario Bros. Wonder. - New test_size_prefixed_frames.py; test_unity_text_glslc.py covers short objects (fails on seedds#238's unityfs.py). All of dm/tools/tests pass. - Not checked here: FINAL FANTASY CRYSTAL CHRONICLES (seedds#238's game) is not on hand; Kirby has not been run.
… Kong Bananza speed fix, bundled font, Ocarina of Time cave walls option Fixes seedds#214, seedds#207, seedds#223, seedds#203. The Legend of Zelda: Ocarina of Time (0400486024DEC000): Keep cave walls (Qualcomm) is an option, off by default.
Summary
HAL keeps its assets in
.cmpcontainers: a 4-byte little-endian uncompressed size, then a frame (zstd, or LZ4 in theubin/map data). The split decompressed a zstd file by its magic at offset 0, so a frame that starts at offset 4 was read raw, and the shaders inside the BFRES archives of those containers were never seen.On Kirby and the Forgotten Land this is the difference between 121 shaders found and 27,288, and between a game that plays and one that shows a black screen: the game asked for 900 shaders the map did not have, and the log filled with
[RED] shader ... is not in the shader map.The split now opens a size-prefixed frame (
unzs_bytesfor zstd,unlz4_bytesfor LZ4). The size prefix is checked against the decompressed length, so a file that is not a container is left alone, and a container that does not open is reported instead of being passed over in silence.Evidence
After: the split finds 27,288 — 18,476 in
gfx/, 8,313 inptcl/, 383 inlyt/, 67 in the looseshaderfiles, 54 inmain..cmpfiles of the game's RomFS: 5,121 zstd frames with 19,364 BNSH inside (11.2 GB decompressed), 2,080 LZ4 frames (0.3 GB, no BNSH — theubin/map data). All 7,201 open; the length check holds for every one of them.shader_split.pyis not one of the chain's tools (dm/gfx/nvn/dmsh_chain.hneeds no rewrite, and no shader library is invalidated by the change).dm/tools/testspass. The docs entry is indocs/reference/shaders.mdand the symptom index is regenerated withdm/tools/docs_symptoms.py.Merge Danger
Door: two-way
Revertible tool change. A revert puts the split back to reading
.cmpcontainers raw, which is how it was.Blast Radius: the shader split
Only files whose bytes 4 to 8 are a zstd or LZ4 frame magic are looked at, and only when their first four bytes are not the zstd magic itself; the decompressed length must match the size prefix, so a file that is not a container is left alone. A container that cannot be opened (a frame that needs a zstd dictionary Pack/ZsDic.pack.zs does not have) no longer stops the split: the file is read as it is and the split says so.
No game binaries, keys, saves or raw game logs are committed.