fix(libScePlayGo): read the chunk count of a PS4 plgo chunk table #8079

Merged
savvaniss merged 1 commit from upstream-pr/8079 into main 2026-10-21 04:48:01 +00:00
savvaniss commented 2026-10-19 20:13:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T20:13:27Z.


What

scePlayGo read sce_sys/playgo-chunk.dat only when it starts with the PS5 magic plgx, so every PS4 title that ships a chunk table threw "is not a chunk table this library reads". A PS4 table starts with plgo instead. Up to the chunk count the two headers have the same layout: a 32-bit magic, then 16-bit version major, version minor, image count and chunk count. So the count is the little-endian 16-bit word at 0x0A in both, where ReadPackageChunks already reads it. The PS4 layout is the one in shadPS4's playgo_chunk.h (PLAYGO_MAGIC = 0x6F676C70, then the u16 fields in that order).

The table is now read for either magic. A zero chunk count is still refused, and the message names both magics.

GuestPlayGo runs the package-table layout with a plgo header (3 chunks: ids 0 to 2 are local, 3 is a bad chunk id). It also checks that a plgo header with no chunks is refused like any unreadable table.

Tested

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, main e80325a4c.

main this PR
guest_playgo aborts on the new plgo layout: expected a plgx header with a nonzero chunk count passes
guest_playgo_dialog passes passes

A PS4 dump (my own) of CUSA03312 has a playgo-chunk.dat whose header reads plgo, version 0.0, 1 image, 1 chunk, 1 mchunk, 2 scenarios. With this change, the converted Risk from that package reads it and gets past scePlayGo, on a local stack with #6977's PS4 path. tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py lists only #6044, which shares the test file but conflicts with main, so it could not be compared; it does not touch these lines.

  • Risk (CUSA03312), 20 Oct: with this change in the stack of #7198 (on an RX 9070 XT), Risk reads its PS4 chunk table, starts, and plays a local match against the AI.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: CUSA03312 #7198 (Risk, through #6977's PS4 path)
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4926795806 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8079). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-19T20:13:27Z. --- ### What `scePlayGo` read `sce_sys/playgo-chunk.dat` only when it starts with the PS5 magic `plgx`, so every PS4 title that ships a chunk table threw "is not a chunk table this library reads". A PS4 table starts with `plgo` instead. Up to the chunk count the two headers have the same layout: a 32-bit magic, then 16-bit version major, version minor, image count and chunk count. So the count is the little-endian 16-bit word at 0x0A in both, where `ReadPackageChunks` already reads it. The PS4 layout is the one in shadPS4's [`playgo_chunk.h`](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/file_format/playgo_chunk.h) (`PLAYGO_MAGIC = 0x6F676C70`, then the `u16` fields in that order). The table is now read for either magic. A zero chunk count is still refused, and the message names both magics. `GuestPlayGo` runs the package-table layout with a `plgo` header (3 chunks: ids 0 to 2 are local, 3 is a bad chunk id). It also checks that a `plgo` header with no chunks is refused like any unreadable table. ### Tested Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, `main` `e80325a4c`. | | `main` | this PR | |---|---|---| | `guest_playgo` | aborts on the new `plgo` layout: `expected a plgx header with a nonzero chunk count` | passes | | `guest_playgo_dialog` | passes | passes | A PS4 dump (my own) of CUSA03312 has a `playgo-chunk.dat` whose header reads `plgo`, version 0.0, 1 image, 1 chunk, 1 mchunk, 2 scenarios. With this change, the converted Risk from that package reads it and gets past `scePlayGo`, on a local stack with #6977's PS4 path. `tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py` lists only #6044, which shares the test file but conflicts with `main`, so it could not be compared; it does not touch these lines. - **Risk (CUSA03312), 20 Oct:** with this change in the stack of #7198 (on an RX 9070 XT), Risk reads its PS4 chunk table, starts, and plays a local match against the AI. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: CUSA03312 #7198 (Risk, through #6977's PS4 path) - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-19 20:24:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T20:24:33Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestPlayGo.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6276539489 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8079#issuecomment-6276539489). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T20:24:33Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestPlayGo.cpp` |
wachi35676 commented 2026-10-19 22:26:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T22:26:52Z.


Linux run (the description has Windows only): WSL Ubuntu 24.04, GCC 13.3, Release, BUILD_TESTING=ON, this PR merged onto main 9127ea36d.

  • guest_playgo and guest_playgo_dialog pass 3/3.
  • Negative control (libScePlayGo/Export.cpp from main, new test kept): guest_playgo aborts, guest_playgo_dialog passes.
  • Windows (same base, Windows 11 Home 26300, Ryzen 5 9600X, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON): same result, 3/3 pass, the reverted control aborts guest_playgo (0xc0000409).

The offset matches shadPS4's playgo_chunk.h: PLAYGO_MAGIC = 0x6F676C70 ("plgo" little-endian), then u16 version_major, version_minor, image_count, chunk_count, so chunk_count is at 0x0A.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278740806 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8079#issuecomment-6278740806). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-19T22:26:52Z. --- Linux run (the description has Windows only): WSL Ubuntu 24.04, GCC 13.3, Release, BUILD_TESTING=ON, this PR merged onto `main` 9127ea36d. - `guest_playgo` and `guest_playgo_dialog` pass 3/3. - Negative control (`libScePlayGo/Export.cpp` from `main`, new test kept): `guest_playgo` aborts, `guest_playgo_dialog` passes. - Windows (same base, Windows 11 Home 26300, Ryzen 5 9600X, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON): same result, 3/3 pass, the reverted control aborts `guest_playgo` (0xc0000409). The offset matches shadPS4's [`playgo_chunk.h`](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/file_format/playgo_chunk.h): `PLAYGO_MAGIC = 0x6F676C70` ("plgo" little-endian), then `u16 version_major, version_minor, image_count, chunk_count`, so `chunk_count` is at 0x0A. AI-assisted: yes (Claude Code); results above were run on this machine.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8079
No description provided.