Skip to content

feat(tools): texpack build writes the New 3DS texture pack - #61

Merged
endercodezz merged 2 commits into
masterfrom
feat/texpack-build-56
Nov 5, 2026
Merged

endercodezz merged 2 commits into
masterfrom
feat/texpack-build-56

Conversation

@endercodezz

Copy link
Copy Markdown
Owner

Second step of #56: p3p-texpack build <pack dir> <out dir> [--max-size 512] [--format auto|<fmt>] converts a PPSSPP pack into the New 3DS pack format.

  • index.bin: magic P3TXPACK, version 1, ignoreAddress flag, 32-byte entries sorted by PPSSPP key (data offset and size, power-of-two width/height, citro3d GPU_TEXCOLOR). An entry with width 0 means "keep the original". Format documented in tools/texpack/src/build.rs.
  • textures.bin: PICA200 tiled data, 128-byte aligned. Rows are bottom-up like the 3DS renderer's own uploads (tiled_row in platform/3ds/gpu_renderer.cpp).
  • Box downscale with premultiplied alpha to at most --max-size per side, keeping the power-of-two aspect ratio. Pixel format chosen from alpha: RGB565 if opaque, RGBA5551 for 0/255 alpha, else RGBA4. Uses all cores (std threads, no new dependency).

Verified (Windows) with the Community Expansion 3x v3.0 pack:

  • Replacements matched on the battle route are uniform multiples of the full PSP texture (166 at 3x, 23 at 2x, 3 at 4.5x). So storing at any power-of-two size with the same aspect ratio and sampling with normalised coordinates is valid.
  • 4,580 textures converted in 52 s; 10 skipped because their files are missing from the pack. Size: 872 MB at --max-size 512, 302 MB at 256. Formats: RGBA4 2,813, RGB565 1,673, RGBA5551 94.
  • The ATLUS logo entry decodes back to the expected 512x256 image.
  • cargo test 14/14 (target sizes, box filter, alpha-based format, index layout and sort order, alignment, row order), clippy -D warnings clean.

[UNVERIFIED] Not loaded by the runtime yet: that is the next step of #23.

Part of #56.

`p3p-texpack build <pack> <out>` converts a PPSSPP pack into the P3P3DS
3DS pack: index.bin (entries sorted by PPSSPP key: offset, size,
power-of-two size, citro3d format) and textures.bin (PICA200 data,
rows bottom-up like the 3DS renderer's uploads). Images are box-
downscaled with premultiplied alpha to at most --max-size texels per
side; the format follows the alpha channel (RGB565, RGBA5551, RGBA4).

Verified: the Community Expansion 3x pack converts in 52 s (4,580
textures, 10 missing from the pack itself; 872 MB at max 512, 302 MB at
256); replacements on the battle route are uniform 2x/3x/4.5x multiples
of the PSP texture; the ATLUS entry decodes back correctly; cargo test
14/14, clippy clean.
@endercodezz
endercodezz enabled auto-merge November 5, 2026 18:51
@endercodezz
endercodezz merged commit 8090e42 into master Nov 5, 2026
6 checks passed
@endercodezz
endercodezz deleted the feat/texpack-build-56 branch November 6, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant