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 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, and `diff` shows which game files a mod, a `bind/` folder or an Aemulus package replaces (`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 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, and `diff` shows which game files a mod, a `bind/` folder or an Aemulus package replaces (`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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,16 @@ build/cpk/bin/p3p-cpk list game.iso /PSP_GAME/USRDIR/umd0.cpk .bmd
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 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` does to the game's archives: each of its files is `added`, `changed` or `same`, by extracted content, so a stored copy of a compressed file counts as the same. Names match without regard to case, and a match that differs in case is marked `case-differs`.
- `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`.
- `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 a file added or changed, **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 or `diff` found anything but `same`, **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
9 changes: 9 additions & 0 deletions docs/CURRENT_STATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

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.

## 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.
- [WRONG] A translation needs no EBOOT patch: the mod's description says the menu text is in the EBOOT. P3P3DS generates its AOT code from the EBOOT, so a patch that touches code has to reach the Builder. [UNVERIFIED] What it changes: not applied yet, no xdelta tool here.
- [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.

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

- `tools/cpk`: `diff <mod.cpk> <base.cpk>` or `diff <mod.cpk> <image.iso> <cpk path>...` reports each file of the mod as `added`, `changed` or `same` by extracted content. It is the first step of #23: which files a fan translation replaces.
Expand Down
2 changes: 1 addition & 1 deletion docs/P3P_RESEARCH.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ In **P3P3DS**, the HLE `IoFileMgr` subsystem will intercept all game file reques
```

### 6.2. Russification & Font Handling
Russian fan translations for Persona 3 Portable (such as the translation by The Miracle / DniweTamp):
Russian fan translations for Persona 3 Portable (such as the translation by Kotone Team, measured in `docs/CURRENT_STATE.md`):
1. **Text Encoding:** `[UNVERIFIED]` expected to map Cyrillic onto a custom 1-byte table used by the replaced font; the real translation package has not been examined.
2. **Font Textures:** `[INFERRED]` modifies the game font; `umd0.cpk` contains exactly one `.fnt` file (CPK listing via `experiments/cpk-check`).
3. **Dialogue Scripts:** `[INFERRED]` modified `.bf` (1,272 in `umd0.cpk`, flow scripts with embedded messages) and `.bmd` files.
Expand Down
2 changes: 1 addition & 1 deletion docs/VERIFICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Local ULUS-10512 ISO, Windows, Zig 0.17.1 `-Doptimize=safe`, oracle `experiments
| Execution frontier advances through ten proven guest functions to `0x08B1C594` | `[VERIFIED]` | `profiles/p3p/config/p3p_functions.csv`; `build/generated/p3p_generated.cpp`; `logs/p3p_bootstrap_latest.log`; executable disassembly at `0x08AB315C` and `0x08B1C594` | The final run reaches executable word `0x0E2C7165` (`jal 0x08B1C594`) at `0x08AB315C` with `$ra = 0x08AB3164`. The target is a distinct, currently unregistered function boundary. Runtime, HLE, and codegen semantics are unchanged; graphics counters remain zero. |
| P3P is 100% viable for static recompilation | `[INFERRED]` | Clean relocation handling + entry point execution milestone | Bootstrap and entry point succeed; viability of remaining complex subsystems (VFPU, overlays, indirect jumps) requires incremental verification. |
| A new PSP thread starts with VFPU source/target prefixes `0xE4` and destination prefix 0 | `[VERIFIED]` | pspautotests `cpu/vfpu/{callout,convert_scaled,minmax}.expected` match exactly only with this initial state (`tests/autotest_baseline.txt`, 2026-10-08) | Before: all-zero `vfpu_ctrl`, every lane read X on a thread's first prefixed VFPU op. |
| Russian fan translation is 100% asset-only with no EBOOT patches | `[UNVERIFIED]` | Community packaging analysis | While scripts (`.bmd`) and fonts are asset-level, potential EBOOT localization patches (character spacing, glyph width) need empirical testing. |
| Russian fan translation is 100% asset-only with no EBOOT patches | `[WRONG]`: v0.8.3 ships an EBOOT xdelta patch for the menu text (#80) | Community packaging analysis | While scripts (`.bmd`) and fonts are asset-level, potential EBOOT localization patches (character spacing, glyph width) need empirical testing. |

---

Expand Down
11 changes: 11 additions & 0 deletions tools/cpk/src/cpk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,17 @@ fn isCompressed(source: Source, file: File) !bool {
return std.mem.eql(u8, &magic, "CRILAYLA");
}

/// A file outside any archive, such as one in a `bind/` folder: all of `source`.
pub fn looseFile(source: Source, dir: []const u8, name: []const u8) !File {
var file: File = .{ .dir = dir, .name = name, .offset = 0, .size = source.size, .extract_size = source.size };
if (try isCompressed(source, file)) {
var header: [layla_header]u8 = undefined;
try source.read(0, &header);
file.extract_size = @as(u64, std.mem.readInt(u32, header[8..12], .little)) + layla_prefix;
}
return file;
}

/// The file's content, decompressed when it is CRILAYLA. Caller frees.
pub fn extract(allocator: std.mem.Allocator, source: Source, file: File) ![]u8 {
if (file.size == 0) return allocator.alloc(u8, 0);
Expand Down
Loading