Decode the tkmk00 textures instead of writing compressed bytes - #775
Open
quarrel07 wants to merge 1 commit into
Open
Decode the tkmk00 textures instead of writing compressed bytes#775quarrel07 wants to merge 1 commit into
quarrel07 wants to merge 1 commit into
Conversation
A tkmk00 block is described twice in assets.json at the same ROM offset: the .tkmk00 blob under bin/ is the build input, and the .png beside it under textures/ is a decoded copy. Extraction groups entries by offset and then decided whether to decode by looking at the first one in the group, so whichever was listed first won. The .tkmk00 entries come first in the file, so all 63 of the textures/ PNGs were written straight from the compressed bytes and came out as noise. They only ever looked right on an incremental run that already had the blob on disk. Decode alongside instead: the blob keeps the compressed bytes it needs and the png gets the decoded image. Nothing in the build consumes those PNGs, so no ROM changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MegaMech
approved these changes
Aug 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 63 PNGs extracted to
textures/*.rgba16.pngare noise. They have never been correct on a clean checkout.Each tkmk00 block is described twice in
assets.jsonat the same ROM offset - the.tkmk00blob underbin/, which is the build input, and a decoded.pngundertextures/:Extraction groups entries by ROM offset, then decides whether to decode by looking only at the first entry in the group:
The
.tkmk00entries are listed first inassets.json, soassets[0][0]never ends in.png, the branch is skipped, and the PNG is written straight from the compressed bytes.The underlying issue is that both entries share one buffer, so whichever ordering wins, the other gets the wrong bytes: the blob needs the compressed data, the png needs the decoded data. Reordering
assets.jsonwould just swap which one is broken.This decodes alongside instead. The blob keeps the compressed bytes it is
.incbin'd from, and the png gets the decoded image.Verified on a cold extraction (
textures/,bin/*.tkmk00and.assets-local.txtall removed first):assets.jsondeclares. 'background_blue_sky' is 108,512 bytes and is the title screen artwork.bin/*.tkmk00blobs still begin withTKMKmagic and still match the cartridge byte for byte.mk64.us: OK- unchanged, as expected. Nothing in the build consumes these PNGs;TEXTURE_DIRSistextures/commonandMakefile.splitusestextures/standaloneandtextures/raw.That last point is why this went unnoticed: the output is decorative until a byte-matching tkmk00 compressor exists, so nothing depended on it being right. It also only ever looked correct on an incremental run that already had the blob on disk.
Before:

After:
