Repository navigation
Add a first-class .xtf texture decoder - #14
Merged
Merged
Conversation
Promotes the hard-coded 256x256 hazard-texture path to a first-class XtfFile decoder in GunBoundFile that parses the 9-byte header ([width u32][height u32][format u8]) and decodes the body as ARGB4444 (format 1) or RGB565, so any dimensions/format decode. AssetLibrary's xtfTexture now delegates to it. Header layout confirmed against every .xtf in graphics.xfs.
Decodes a .xtf texture surface to PNG via XtfFile, mirroring the 'image' command — verified against the real TornadoTexture/A_smoke (real content) and AvataTexture (blank runtime target).
Rewrites the decoder to the library convention — the ParserSpan overload is primary and the array entry point wraps withParserSpan, with truncation surfacing as parsing errors and a dimension bound guarding corrupt headers against huge allocations. Adds the real TornadoTexture.xtf from graphics.xfs as a fixture, pinning its exact 256x256 ARGB4444 decode (35609 alpha pixels) so a pixel-interpretation regression can't slip by.
1 task done
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.
Summary
XtfFilejoinsGunBoundFileas a first-class format: parses the 9-byte header ([width u32 LE][height u32 LE][format u8]) and decodes the 16-bit body as ARGB4444 (format 1) or RGB565 into anImgFile.Frame, so any dimensions/format flow through the existing texture pipeline. Replaces the previous hard-coded 256×256 hazard-texture path inAssetLibrary, which now delegates to it.ParserSpanoverload is primary, the array entry point wrapswithParserSpan, truncation surfaces as parsing errors, and a dimension bound rejects corrupt headers before any large allocation.GunBoundExtract xtfsubcommand decodes a.xtfentry to PNG, mirroringimage..xtfingraphics.xfs(all 256×256, format 1). The hazard/smoke surfaces decode to real art (TornadoTexture renders the swirl sprite correctly);AvataTexture1decodes to 0 alpha pixels, corroborating the decomp's finding that those are blank runtime render targets. The.xtfstring never appears in the original binary, so the format is documented as empirical rather than decomp-confirmed.Tests
Six unit tests: exact-pixel ARGB4444/RGB565 decodes, non-square dimensions, span/array agreement, truncation, invalid/absurd dimensions — plus the real
TornadoTexture.xtfchecked in as a fixture with its decode pinned exactly (256×256, 35,609 alpha pixels) so a pixel-interpretation regression can't slip by.Test plan
swift test— 560 tests passingGunBoundExtract xtfverified against real archive entries