Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/p3p-modding-vfs/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Do **not** assume all mods are purely asset replacements. For every modification

- `p3p/p3p-patches/ULUS10512.ini` — Verified memory offsets for intro skip and mod loader string pointers.
- `p3p/Persona-3-Portable-Mod-Menu/` — Field script hooks (`.flow` / `.bf`) and menu initialization.
- `tools/cpk/` — Our Zig CLI: lists and extracts a CPK from the ISO or a loose `mod.cpk`, which also checks that the archive is readable, and `diff` shows which game files a mod, a `bind/` folder or an Aemulus package replaces (`build/cpk/bin/p3p-cpk --help`).
- `tools/cpk/` — Our Zig CLI: lists and extracts a CPK from the ISO or a loose `mod.cpk`, which also checks that the archive is readable, `diff` shows which game files a mod, a `bind/` folder or an Aemulus package replaces, `bind` builds a `bind/` folder from such a package, and `patch` applies an EBOOT xdelta (`build/cpk/bin/p3p-cpk --help`).
- `tools/CriFsV2Lib/` — Modern C# library for reading and parsing CriWare CPK archives.
- `tools/CriPakTools/` — C# CLI tool for unpacking and repacking CPK files with CRILAYLA compression.
- `tools/AtlusFileSystemLibrary/` — Comprehensive library for Atlus PAC, BIN, GIM, and TMX containers.
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/p3p-modding-vfs/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Do **not** assume all mods are purely asset replacements. For every modification

- `p3p/p3p-patches/ULUS10512.ini` — Verified memory offsets for intro skip and mod loader string pointers.
- `p3p/Persona-3-Portable-Mod-Menu/` — Field script hooks (`.flow` / `.bf`) and menu initialization.
- `tools/cpk/` — Our Zig CLI: lists and extracts a CPK from the ISO or a loose `mod.cpk`, which also checks that the archive is readable, and `diff` shows which game files a mod, a `bind/` folder or an Aemulus package replaces (`build/cpk/bin/p3p-cpk --help`).
- `tools/cpk/` — Our Zig CLI: lists and extracts a CPK from the ISO or a loose `mod.cpk`, which also checks that the archive is readable, `diff` shows which game files a mod, a `bind/` folder or an Aemulus package replaces, `bind` builds a `bind/` folder from such a package, and `patch` applies an EBOOT xdelta (`build/cpk/bin/p3p-cpk --help`).
- `tools/CriFsV2Lib/` — Modern C# library for reading and parsing CriWare CPK archives.
- `tools/CriPakTools/` — C# CLI tool for unpacking and repacking CPK files with CRILAYLA compression.
- `tools/AtlusFileSystemLibrary/` — Comprehensive library for Atlus PAC, BIN, GIM, and TMX containers.
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,18 @@ build/cpk/bin/p3p-cpk list mods/mod.cpk
build/cpk/bin/p3p-cpk extract game.iso /PSP_GAME/USRDIR/umd0.cpk data/battle .tmp/extract
build/cpk/bin/p3p-cpk diff mods/mod.cpk game.iso /PSP_GAME/USRDIR/umd0.cpk /PSP_GAME/USRDIR/umd1.cpk
build/cpk/bin/p3p-cpk diff mods/bind game.iso /PSP_GAME/USRDIR/umd0.cpk /PSP_GAME/USRDIR/umd1.cpk
build/cpk/bin/p3p-cpk bind mods/bind my-mod game.iso /PSP_GAME/USRDIR/umd0.cpk /PSP_GAME/USRDIR/umd1.cpk
build/cpk/bin/p3p-cpk check-trace game.iso .tmp/io-trace.csv ms0:/PSP/P3P=.tmp/mods
```

- `list` prints directory and name, offset, stored and extracted size, and whether the file is CRILAYLA-compressed; the optional last argument is a case-insensitive substring of `dir/name`. An archive it can't read fully is an error, which makes it a quick check of a community `mod.cpk`.
- `extract` writes files under their CPK directories and decompresses them. All output paths are checked before the first write: `..`, absolute paths and names that are unsafe on Windows stop the extraction.
- `diff` shows what a `mod.cpk`, a `bind/` folder or an Aemulus package does to the game's archives: each file is `added`, `changed` or `same`, by extracted content, so a stored copy of a compressed file counts as the same. A file under a folder named after a game file, such as `data/init/a.tmx` for `data/init.bin`, is `in-container`: a mod manager has to build it into that file first. Names match without regard to case, and a match that differs in case is marked `case-differs`.
- `bind` makes a mod usable without Aemulus: it writes a `bind/` folder with the changed files and rebuilds the game's containers around the `in-container` files. A file it can't place, such as one inside an `.spr`, is listed as `unresolved`, and the exit code is 1.
- `patch <source> <patch.xdelta> <output>` applies the VCDIFF patches that mods ship, such as an EBOOT patch, and checks their checksums; `p3p-bindiff --elf` then shows what changed.
- `check-trace` verifies `p3p_pc_bootstrap --io-trace`: each read of a `.cpk` must be metadata or lie inside one file with the same FNV-1a 64.

Exit codes: **0** success, **1** `check-trace` found differences or `diff` found anything but `same`, **2** usage/input/output error. On Windows use `p3p-cpk.exe`. Keep game files and extracts under `.tmp/`.
Exit codes: **0** success, **1** `check-trace` found differences, `diff` found anything but `same`, or `bind` left files `unresolved`, **2** usage/input/output error. On Windows use `p3p-cpk.exe`. Keep game files and extracts under `.tmp/`.

### Continuous integration and releases (GitHub Actions)

Expand Down
17 changes: 14 additions & 3 deletions docs/CURRENT_STATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,27 @@

This is the current source of truth, newest entries first. Evidence concerns ULUS-10512; each section says whether it was measured on the PC runner, in Azahar or on a real New 3DS.

## Russian translation runs on the PC runner, without Aemulus (#87, #23, 2026-11-06)

- `tools/cpk`: `bind <out dir> <mod> <base...>` writes a `bind/` folder: changed files, and the game's containers (nested ones too) with the mod's files put in. `tools/cpk/src/pak.zig` reads and rebuilds the two PAK layouts of the game.
- [VERIFIED] Containers: 252-byte names, data padded to 64 bytes, zero tail; or a 32-bit count, 32-byte names, unpadded. The padding is not always zeros (`data/init_2.bin`). Game files can share a name with another extension (`f021_000.fpc`, `f021_000.pac`), and a folder belongs to the one that holds the file.
- [VERIFIED] The folder rule of `in-container` is Aemulus' own: `Utilities/BinMerging/BinMerger.cs`, `Path.ChangeExtension(file, null)`.
- [VERIFIED] Round trip: 185 of 185 real containers rebuild byte for byte when a file's own data is put back.
- [VERIFIED] Translation v0.8.3: 1,369 changed files and 183 containers written, 266 of 336 in-container files placed. The other 70 are `.tmx` inside `.spr` (interface graphics): `bind` lists them as `unresolved`, and `.spr` is not supported yet.
- [VERIFIED] PC runner, `--mods` with that folder, `profiles/p3p/input/new_game.txt`, stopped at vblank 9600: the game reads `ms0:/PSP/P3P/bind/data/init.bin`, `init_free.bin` and `title/sex_select.bin`, and the first dialogue shows in Russian in Cyrillic, with no runtime change and the original EBOOT.
- [VERIFIED] The two `.text` words of the EBOOT patch are `addiu a0,a0,imm` with another immediate, which fits a moved string. [INFERRED] Not logic.
- [UNVERIFIED] Menus with the patched EBOOT, and anything past the first dialogue. New 3DS: not run.

## First real translation compared: Russian v0.8.3 (#80, #23, 2026-11-06)

- [VERIFIED] [P3P Russian Translation (PSP Version)](https://gamebanana.com/mods/449730) v0.8.3 by Kotone Team, MD5 `5fc0fa81f932311d0988ec4385c0b3b6`: an Aemulus package (`Package.xml`, 1,705 files under `data/`), `texture_override/ULUS10512` (126 files) and an EBOOT patch (`rus_eboot_patch_v0.8.2.xdelta`, source `EBOOT_DEC.BIN`). Not a `mod.cpk`. Game data, kept under `.tmp/` only.
- `tools/cpk`: `diff` accepts a directory as the mod, and a file under a folder named after a game file is `in-container`, not `added`.
- [VERIFIED] `diff` of the package against `umd0.cpk` and `umd1.cpk`: 1,369 `changed` (1,258 `.bf`, 98 `.abin`), 336 `in-container` (229 `.bf`, 72 `.tmx`, 20 `.bmd`, `data/init/font/font0.fnt` under `data/init.bin`), 128 `added` (the texture folder, `Package.xml`, `Preview.png`).
- [INFERRED] The `in-container` files must first be built into their containers, which Aemulus does, so the package can't simply be copied to `mods/bind/`. Not yet checked against Aemulus or run.
- [VERIFIED] The `in-container` files must first be built into their containers (`p3p-cpk bind`), so the package can't simply be copied to `mods/bind/`.
- [WRONG] A translation needs no EBOOT patch: the mod's description says the menu text is in the EBOOT.
- `tools/cpk`: `patch` applies xdelta (VCDIFF) patches (#83).
- [VERIFIED] `rus_eboot_patch_v0.8.2.xdelta` applies to `profiles/p3p/game/eboot.elf` with its Adler-32 matching, so this is its source. It changes 47,707 of 5,849,468 bytes in 611 ranges, size unchanged: 29,798 in `.rodata`, 17,907 in `.data`, 2 in `.text` (file offsets 0x154578: 0x2484E8C0 -> 0x2484E8BF; 0x154688: 0x2484E8B0 -> 0x2484E8AE). P3P3DS generates its AOT code from the EBOOT, so those 2 bytes need the generated code to change, or a profile patch. [UNVERIFIED] What the two instructions do.
- [INFERRED] Cyrillic is drawn through a replaced font with Latin character codes: the patch holds `Kluwka dlq lakrossa` ("lacrosse stick" in Russian). One string only.
- [VERIFIED] `rus_eboot_patch_v0.8.2.xdelta` applies to `profiles/p3p/game/eboot.elf` with its Adler-32 matching, so this is its source. It changes 47,707 of 5,849,468 bytes in 611 ranges, size unchanged: 29,798 in `.rodata`, 17,907 in `.data`, 2 in `.text` (file offsets 0x154578: 0x2484E8C0 -> 0x2484E8BF; 0x154688: 0x2484E8B0 -> 0x2484E8AE). P3P3DS generates its AOT code from the EBOOT, so those 2 bytes need the generated code to change, or a profile patch.
- [INFERRED] Cyrillic comes from a replaced font on Latin character codes: the patch holds `Kluwka dlq lakrossa` ("lacrosse stick" in Russian). One string only.

## `p3p-cpk diff`: what a mod changes in the game's archives (#76, 2026-11-06)

Expand Down
1 change: 1 addition & 0 deletions tools/cpk/src/cpk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ const testing = std.testing;

test {
_ = @import("vcdiff.zig");
_ = @import("pak.zig");
}

test "literal and copy blocks decompress from the end" {
Expand Down
Loading