feat(np-tus): add libSceNpTus with offline title user storage #6592

Merged
LuisAguilarDev merged 2 commits from upstream-pr/6592 into main 2026-10-19 07:37:33 +00:00
LuisAguilarDev commented 2026-10-15 21:40:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LuisAguilarDev on 2026-10-15T21:40:21Z.


What

Add libSceNpTus. A title that imports it fails to load: Failed to load module: libSceNpTus.prx GetLastError: 126.

Implemented exports: sceNpTusCreateNpTitleCtxA, sceNpTusCreateRequest, sceNpTusDeleteRequest, sceNpTusAbortRequest, sceNpTusPollAsync, sceNpTusGetMultiSlotVariableAAsync, sceNpTusSetMultiSlotVariableAAsync, sceNpTusDeleteMultiSlotVariableAAsync, sceNpTusAddAndGetVariableAAsync.

PSN is not emulated, so the library follows libSceNpManager:

  • Title contexts and requests are tracked. An unknown ID returns SCE_NP_COMMUNITY_ERROR_INVALID_ID. More than 32 contexts or 256 requests returns TOO_MANY_OBJECTS.

  • The async calls validate their arguments:

    • null arrays return INSUFFICIENT_ARGUMENT
    • arrayLen < 1, a negative slot ID or a non-null option returns INVALID_ARGUMENT
    • more than 64 slots returns TOO_MANY_SLOTID

    A valid call starts the request.

  • A started request finishes with SCE_NP_ERROR_SIGNED_OUT, the same result sceNpPollAsync reports. An aborted request finishes with ABORTED.

  • sceNpTusPollAsync returns 1 while no operation has started. After one has, it returns 0 and writes that operation's result.

Signatures and community error codes come from shadPS4 (src/core/libraries/np/np_tus/, np_error.h), and fpPS4 agrees on the context and request calls. Two choices differ from shadPS4:

  • Context creation: sceNpTusCreateNpTitleCtxA creates a context without checking sign-in. shadPS4 returns the sceNpGetNpId error instead.
  • Signed-out result: the signed-out state is reported per operation, through the poll result.

The SceNpTusVariableA layout is not verified, so output arrays are never written and variableArraySize is not checked.

Tested

  • Windows 11, MinGW-w64 GCC 16.2.0, Release:
    • The new guest_np_tus test passes in 0.11 s. It covers argument validation, the poll states, the signed-out and aborted results, and stale IDs after delete.
    • tools/check_conventions.py --base origin/main and git diff --check pass.
  • Dragon Ball Xenoverse 2 (PPSA08587), RTX 3070 Ti: the title loads its modules and renders its first frames. It then stops in the AGC driver (stencil clear requires a writable stencil plane), which is a separate topic and not part of this PR. The title has not called the TUS functions yet.

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
  • Unblocks: PPSA08587 #6591
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4880219126 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6592). Originally posted by [LuisAguilarDev](https://github.com/LuisAguilarDev) on 2026-10-15T21:40:21Z. --- ### What Add libSceNpTus. A title that imports it fails to load: `Failed to load module: libSceNpTus.prx GetLastError: 126`. Implemented exports: `sceNpTusCreateNpTitleCtxA`, `sceNpTusCreateRequest`, `sceNpTusDeleteRequest`, `sceNpTusAbortRequest`, `sceNpTusPollAsync`, `sceNpTusGetMultiSlotVariableAAsync`, `sceNpTusSetMultiSlotVariableAAsync`, `sceNpTusDeleteMultiSlotVariableAAsync`, `sceNpTusAddAndGetVariableAAsync`. PSN is not emulated, so the library follows libSceNpManager: - Title contexts and requests are tracked. An unknown ID returns `SCE_NP_COMMUNITY_ERROR_INVALID_ID`. More than 32 contexts or 256 requests returns `TOO_MANY_OBJECTS`. - The async calls validate their arguments: - null arrays return `INSUFFICIENT_ARGUMENT` - `arrayLen < 1`, a negative slot ID or a non-null option returns `INVALID_ARGUMENT` - more than 64 slots returns `TOO_MANY_SLOTID` A valid call starts the request. - A started request finishes with `SCE_NP_ERROR_SIGNED_OUT`, the same result `sceNpPollAsync` reports. An aborted request finishes with `ABORTED`. - `sceNpTusPollAsync` returns 1 while no operation has started. After one has, it returns 0 and writes that operation's result. Signatures and community error codes come from shadPS4 (`src/core/libraries/np/np_tus/`, `np_error.h`), and fpPS4 agrees on the context and request calls. Two choices differ from shadPS4: - **Context creation:** `sceNpTusCreateNpTitleCtxA` creates a context without checking sign-in. shadPS4 returns the `sceNpGetNpId` error instead. - **Signed-out result:** the signed-out state is reported per operation, through the poll result. The `SceNpTusVariableA` layout is not verified, so output arrays are never written and `variableArraySize` is not checked. ### Tested - Windows 11, MinGW-w64 GCC 16.2.0, Release: - The new `guest_np_tus` test passes in 0.11 s. It covers argument validation, the poll states, the signed-out and aborted results, and stale IDs after delete. - `tools/check_conventions.py --base origin/main` and `git diff --check` pass. - Dragon Ball Xenoverse 2 (PPSA08587), RTX 3070 Ti: the title loads its modules and renders its first frames. It then stops in the AGC driver (`stencil clear requires a writable stencil plane`), which is a separate topic and not part of this PR. The title has not called the TUS functions yet. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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] Unblocks: PPSA08587 #6591 - [x] GPUs tested: n/a - [x] AI-assisted: yes
jotitadev commented 2026-10-15 23:01:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T23:01:33Z.

Review: COMMENTED


Linux run: head 6f109b887 merged onto main 5d9dcc42d (clean merge, CMake reconfigured for the new library), in one tree with seven other library PRs that share no files with this one. The description lists Windows only.

Machine: Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, Release, BUILD_TESTING=ON.

  • libSceNpTus builds, and guest_np_tus passes, 5/5 with --repeat until-fail:5.
  • Non-GPU suite (ctest -E "^agc|gpu|vulkan|video_out"): no regressions. The only failures are file_writer_binary and file_writer_text, which also fail on main on this machine.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5540957185 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6592#pullrequestreview-5540957185). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T23:01:33Z. **Review:** COMMENTED --- **Linux run: head `6f109b887` merged onto `main` `5d9dcc42d` (clean merge, CMake reconfigured for the new library), in one tree with seven other library PRs that share no files with this one.** The description lists Windows only. Machine: Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, Release, `BUILD_TESTING=ON`. - `libSceNpTus` builds, and `guest_np_tus` passes, 5/5 with `--repeat until-fail:5`. - **Non-GPU suite** (`ctest -E "^agc|gpu|vulkan|video_out"`): no regressions. The only failures are `file_writer_binary` and `file_writer_text`, which also fail on `main` on this machine. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
github-actions[bot] commented 2026-10-17 00:36:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T00:36:33Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6977 sceNpTusCreateRequest
sceNpTusDeleteRequest
core/libs/prx/libSceNpTus/Export.cpp

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 6977 core/libs/prx/libSceNpTus/Export.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6227421481 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6592#issuecomment-6227421481). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T00:36:33Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | | `sceNpTusCreateRequest`<br>`sceNpTusDeleteRequest` | `core/libs/prx/libSceNpTus/Export.cpp` | 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 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libSceNpTus/Export.cpp` |
github-actions[bot] commented 2026-10-19 06:26:24 +00:00 (Migrated from github.com)

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


Progress report (feb74b6 → 6093e8c)

📈 System libraries: 91.42% (+0.02%, +9 implemented functions)

✅ 9 implemented
Library Name
libSceNpTus sceNpTusAbortRequest
libSceNpTus sceNpTusAddAndGetVariableAAsync
libSceNpTus sceNpTusCreateNpTitleCtxA
libSceNpTus sceNpTusCreateRequest
libSceNpTus sceNpTusDeleteMultiSlotVariableAAsync
libSceNpTus sceNpTusDeleteRequest
libSceNpTus sceNpTusGetMultiSlotVariableAAsync
libSceNpTus sceNpTusPollAsync
libSceNpTus sceNpTusSetMultiSlotVariableAAsync
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6261102615 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6592#issuecomment-6261102615). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T06:26:24Z. --- <!-- progress-report --> ### Progress report (feb74b6 → 6093e8c) 📈 **System libraries**: 91.42% (+0.02%, +9 implemented functions) <details> <summary>✅ 9 implemented</summary> | Library | Name | | - | - | | libSceNpTus | `sceNpTusAbortRequest` | | libSceNpTus | `sceNpTusAddAndGetVariableAAsync` | | libSceNpTus | `sceNpTusCreateNpTitleCtxA` | | libSceNpTus | `sceNpTusCreateRequest` | | libSceNpTus | `sceNpTusDeleteMultiSlotVariableAAsync` | | libSceNpTus | `sceNpTusDeleteRequest` | | libSceNpTus | `sceNpTusGetMultiSlotVariableAAsync` | | libSceNpTus | `sceNpTusPollAsync` | | libSceNpTus | `sceNpTusSetMultiSlotVariableAAsync` | </details>
adriadam10 commented 2026-10-19 07:38:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T07:38:38Z.


Checked the error codes and the poll/abort/delete semantics against shadPS4; the test pins values that only the code produces.

Added by us (own commit on your branch): docs/dev/debt/libSceNpTus.md, recording the unverified SceNpTusVariableA layout, the context creation without a sign-in check (shadPS4 returns the sceNpGetNpId error) and the always-signed-out request result. guest_np_tus and the scoped ctest pass on the rebased head.

Merging through the queue once its Build run is green. Thanks @jotitadev for the Linux run.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6262179834 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6592#issuecomment-6262179834). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T07:38:38Z. --- Checked the error codes and the poll/abort/delete semantics against shadPS4; the test pins values that only the code produces. Added by us (own commit on your branch): `docs/dev/debt/libSceNpTus.md`, recording the unverified `SceNpTusVariableA` layout, the context creation without a sign-in check (shadPS4 returns the `sceNpGetNpId` error) and the always-signed-out request result. `guest_np_tus` and the scoped ctest pass on the rebased head. Merging through the queue once its Build run is green. Thanks @jotitadev for the Linux run.
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!6592
No description provided.