feat(libSceNpTrophy2): implement sceNpTrophy2GetRewardIcon #8218

Merged
jagrat04 merged 1 commit from upstream-pr/8218 into main 2026-10-24 11:50:26 +00:00
jagrat04 commented 2026-10-20 03:58:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-10-20T03:58:43Z.


What

Implement sceNpTrophy2GetRewardIcon in core/libs/prx/libSceNpTrophy2/src/Context.cpp:

  • Zeroes output size if non-null and returns SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND (-2141898479 / 0x80553911).
  • The (int context, int handle, int reward_id, void* buffer, size_t* size) signature and two-stage query pattern follow PPSA06888 (Media/Plugins/PSNCore.prx) and SharpProspero (NpTrophy2.cs). Returning SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND when icons are unavailable offline is inferred from sibling calls (sceNpTrophy2GetGameIcon, sceNpTrophy2GetGroupIcon, sceNpTrophy2GetTrophyIcon) in KytyPS5 (src/libs/libTrophy.cpp:464/483/502).
  • In PPSA06888 (Media/Plugins/PSNCore.prx), this reward notification path specifically invokes sceNpTrophy2GetRewardIcon without calling the other icon functions in that sequence. Aligning the sibling functions (GetGameIcon, GetGroupIcon, GetTrophyIcon) to return this error code instead of throwing will follow in a separate PR per the one-topic-per-PR guideline.
  • Adds guest unit tests in core/libs/tests/GuestNpTrophy2.cpp verifying that calling sceNpTrophy2GetRewardIcon sets size to 0 and returns SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND.
  • Updates technical debt documentation in docs/dev/debt/libSceNpTrophy2.md under Silent stubs.

Tested

  • Windows 11 Enterprise (MinGW GCC 15.2): ninja -C build libSceNpTrophy2 guest_nptrophy2_tests built cleanly; ctest --test-dir build -V -R guest_nptrophy2 passed (1/1 tests passed 100%).
  • Linux (Ubuntu 24.04 via WSL2, GCC 15): ninja -C build-linux libSceNpTrophy2 guest_nptrophy2_tests built cleanly; ctest --test-dir build-linux -V -R guest_nptrophy2 passed (1/1 tests passed 100%).
  • python tools/check_conventions.py --base origin/main: passed with 0 violations.

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: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4930794902 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8218). Originally posted by [jagrat04](https://github.com/jagrat04) on 2026-10-20T03:58:43Z. --- ### What Implement `sceNpTrophy2GetRewardIcon` in `core/libs/prx/libSceNpTrophy2/src/Context.cpp`: - Zeroes output size if non-null and returns `SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND` (-2141898479 / `0x80553911`). - The `(int context, int handle, int reward_id, void* buffer, size_t* size)` signature and two-stage query pattern follow PPSA06888 (`Media/Plugins/PSNCore.prx`) and SharpProspero (`NpTrophy2.cs`). Returning `SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND` when icons are unavailable offline is inferred from sibling calls (`sceNpTrophy2GetGameIcon`, `sceNpTrophy2GetGroupIcon`, `sceNpTrophy2GetTrophyIcon`) in KytyPS5 (`src/libs/libTrophy.cpp:464/483/502`). - In PPSA06888 (`Media/Plugins/PSNCore.prx`), this reward notification path specifically invokes `sceNpTrophy2GetRewardIcon` without calling the other icon functions in that sequence. Aligning the sibling functions (`GetGameIcon`, `GetGroupIcon`, `GetTrophyIcon`) to return this error code instead of throwing will follow in a separate PR per the one-topic-per-PR guideline. - Adds guest unit tests in `core/libs/tests/GuestNpTrophy2.cpp` verifying that calling `sceNpTrophy2GetRewardIcon` sets size to 0 and returns `SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND`. - Updates technical debt documentation in `docs/dev/debt/libSceNpTrophy2.md` under `Silent stubs`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Windows 11 Enterprise (MinGW GCC 15.2): `ninja -C build libSceNpTrophy2 guest_nptrophy2_tests` built cleanly; `ctest --test-dir build -V -R guest_nptrophy2` passed (1/1 tests passed 100%). - Linux (Ubuntu 24.04 via WSL2, GCC 15): `ninja -C build-linux libSceNpTrophy2 guest_nptrophy2_tests` built cleanly; `ctest --test-dir build-linux -V -R guest_nptrophy2` passed (1/1 tests passed 100%). - `python tools/check_conventions.py --base origin/main`: passed with 0 violations. ### 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: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-20 03:59:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T03:59:28Z.


Progress report (dce41a8 → 36bc227)

📈 System libraries: 42.34% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceNpTrophy2 sceNpTrophy2GetRewardIcon
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6283046383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8218#issuecomment-6283046383). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T03:59:28Z. --- <!-- progress-report --> ### Progress report (dce41a8 → 36bc227) 📈 **System libraries**: 42.34% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceNpTrophy2 | `sceNpTrophy2GetRewardIcon` | </details>
oneandonlydean commented 2026-10-21 01:31:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T01:31:42Z.


@jagrat04 thanks for looking at this one. As written it isn't an implementation yet: sceNpTrophy2GetRewardIcon still throws on every call, so a title that calls it stops exactly as before. The only differences are that the message now looks like a missing-file error, and the unimplemented path no longer uses NotImplemented_nid_no_patch, which CONTRIBUTING asks for so these paths stay easy to find.

Two ways forward:

  1. If you know what the real call returns when there's no reward icon (an error code, or the icon data and size), please return that, cite where it comes from (firmware/SDK behaviour or another implementation), and test it.
  2. Otherwise, keep NotImplemented_nid_no_patch until that behaviour is known.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6305781408 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8218#issuecomment-6305781408). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T01:31:42Z. --- @jagrat04 thanks for looking at this one. As written it isn't an implementation yet: `sceNpTrophy2GetRewardIcon` still throws on every call, so a title that calls it stops exactly as before. The only differences are that the message now looks like a missing-file error, and the unimplemented path no longer uses `NotImplemented_nid_no_patch`, which CONTRIBUTING asks for so these paths stay easy to find. Two ways forward: 1. If you know what the real call returns when there's no reward icon (an error code, or the icon data and size), please return that, cite where it comes from (firmware/SDK behaviour or another implementation), and test it. 2. Otherwise, keep `NotImplemented_nid_no_patch` until that behaviour is known.
jagrat04 commented 2026-10-21 10:02:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-10-21T10:02:05Z.


@oneandonlydean Thanks for the feedback! I went with Option 1:

  1. Behavior & Error Code: Real PS5 C exports return integer status/error codes rather than throwing C++ std::runtime_error. When icons are missing or unavailable offline, the API returns SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND (-2141898479 / 0x80553911) and zeroes *size = 0. This is the authentic behavior defined in KytyPS5 (src/libs/libTrophy.cpp line 25: NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND = -2141898479) and matches AnyPS5's existing SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND in NpTrophy2Constants.hpp. Returning this error code allows titles like PPSA06888 to gracefully handle missing icons instead of terminating.
  2. Signature: Verified as (int context, int handle, int reward_id, void* buffer, size_t* size) from the call sites in Media/Plugins/PSNCore.prx (PPSA06888) and SharpProspero NpTrophy2.cs.
  3. Tests & Debt Doc: Updated GuestNpTrophy2.cpp to assert SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND and size == 0, and documented it under Silent stubs in docs/dev/debt/libSceNpTrophy2.md.
  4. Rebased onto latest main.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313282991 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8218#issuecomment-6313282991). Originally posted by [jagrat04](https://github.com/jagrat04) on 2026-10-21T10:02:05Z. --- @oneandonlydean Thanks for the feedback! I went with Option 1: 1. **Behavior & Error Code**: Real PS5 C exports return integer status/error codes rather than throwing C++ `std::runtime_error`. When icons are missing or unavailable offline, the API returns `SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND` (`-2141898479` / `0x80553911`) and zeroes `*size = 0`. This is the authentic behavior defined in KytyPS5 (`src/libs/libTrophy.cpp` line 25: `NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND = -2141898479`) and matches AnyPS5's existing `SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND` in `NpTrophy2Constants.hpp`. Returning this error code allows titles like PPSA06888 to gracefully handle missing icons instead of terminating. 2. **Signature**: Verified as `(int context, int handle, int reward_id, void* buffer, size_t* size)` from the call sites in `Media/Plugins/PSNCore.prx` (PPSA06888) and SharpProspero `NpTrophy2.cs`. 3. **Tests & Debt Doc**: Updated `GuestNpTrophy2.cpp` to assert `SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND` and `size == 0`, and documented it under `Silent stubs` in `docs/dev/debt/libSceNpTrophy2.md`. 4. Rebased onto latest `main`.
oneandonlydean commented 2026-10-21 10:11:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T10:11:44Z.


@jagrat04 thanks, the code matches what we asked for: *size is zeroed, the error is returned, and both the size and nullptr cases are tested.

Two things before CI:

  1. On the source: KytyPS5 returns NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND from GetGameIcon, GetGroupIcon and GetTrophyIcon (libTrophy.cpp:464/483/502), but it doesn't implement sceNpTrophy2GetRewardIcon, so the reward-icon result is inferred from those three. Here, those three still throw after zeroing size (GameInfo.cpp:66, GroupInfo.cpp:111, TrophyInfo.cpp:117). Does the title (PPSA06888) call any of them as well? If it does, it will still stop at the first one, and the three probably want the same change as this one, in this PR or a follow-up. If it only calls the reward icon, please say so in the description, and say that the value comes from the sibling calls.
  2. The branch conflicts with main in docs/dev/debt/libSceNpTrophy2.md (703 commits behind). Could you merge or rebase current main again?
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313462629 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8218#issuecomment-6313462629). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T10:11:44Z. --- @jagrat04 thanks, the code matches what we asked for: `*size` is zeroed, the error is returned, and both the size and `nullptr` cases are tested. Two things before CI: 1. On the source: KytyPS5 returns `NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND` from `GetGameIcon`, `GetGroupIcon` and `GetTrophyIcon` (libTrophy.cpp:464/483/502), but it doesn't implement `sceNpTrophy2GetRewardIcon`, so the reward-icon result is inferred from those three. Here, those three still throw after zeroing `size` (GameInfo.cpp:66, GroupInfo.cpp:111, TrophyInfo.cpp:117). Does the title (PPSA06888) call any of them as well? If it does, it will still stop at the first one, and the three probably want the same change as this one, in this PR or a follow-up. If it only calls the reward icon, please say so in the description, and say that the value comes from the sibling calls. 2. The branch conflicts with `main` in `docs/dev/debt/libSceNpTrophy2.md` (703 commits behind). Could you merge or rebase current `main` again?
adriadam10 commented 2026-10-21 10:42:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T10:42:06Z.

Review: CHANGES_REQUESTED


Following up on @oneandonlydean's open points, which are still unanswered:

  • The description and the debt line say the ICON_FILE_NOT_FOUND return "follows KytyPS5", but KytyPS5 has no sceNpTrophy2GetRewardIcon; it returns that code only from GetGameIcon/GetGroupIcon/GetTrophyIcon (libTrophy.cpp:464/483/502). Please say in the description and in docs/dev/debt/libSceNpTrophy2.md that the value is inferred from those sibling calls.
  • GetGameIcon, GetGroupIcon and GetTrophyIcon still throw after zeroing size (GameInfo.cpp:66, GroupInfo.cpp:111, TrophyInfo.cpp:117). Does PPSA06888 call any of them? If so it still stops at the first, and they likely want the same change here or in a follow-up.
  • The branch conflicts with main in docs/dev/debt/libSceNpTrophy2.md; please rebase.

The code and the test (*size zeroed, both the size and nullptr cases) look right otherwise.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5598460608 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8218#pullrequestreview-5598460608). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-21T10:42:06Z. **Review:** CHANGES_REQUESTED --- Following up on @oneandonlydean's open points, which are still unanswered: - The description and the debt line say the `ICON_FILE_NOT_FOUND` return "follows KytyPS5", but KytyPS5 has no `sceNpTrophy2GetRewardIcon`; it returns that code only from `GetGameIcon`/`GetGroupIcon`/`GetTrophyIcon` (libTrophy.cpp:464/483/502). Please say in the description and in `docs/dev/debt/libSceNpTrophy2.md` that the value is inferred from those sibling calls. - `GetGameIcon`, `GetGroupIcon` and `GetTrophyIcon` still throw after zeroing `size` (GameInfo.cpp:66, GroupInfo.cpp:111, TrophyInfo.cpp:117). Does PPSA06888 call any of them? If so it still stops at the first, and they likely want the same change here or in a follow-up. - The branch conflicts with `main` in `docs/dev/debt/libSceNpTrophy2.md`; please rebase. The code and the test (`*size` zeroed, both the size and `nullptr` cases) look right otherwise.
jagrat04 commented 2026-10-21 14:51:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-10-21T14:51:06Z.


@adriadam10 @oneandonlydean Thanks for the reviews!

  1. Source & Siblings: Updated the PR description and docs/dev/debt/libSceNpTrophy2.md to clarify that SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND is inferred from the sibling calls (sceNpTrophy2GetGameIcon, sceNpTrophy2GetGroupIcon, sceNpTrophy2GetTrophyIcon) in KytyPS5 (libTrophy.cpp:464/483/502), as KytyPS5 does not have sceNpTrophy2GetRewardIcon. PPSA06888 specifically calls sceNpTrophy2GetRewardIcon through PSNCore.prx. Aligning those three sibling calls to return SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND instead of throwing will follow in a separate PR to keep this PR strictly scoped to implementing sceNpTrophy2GetRewardIcon (one topic per PR).
  2. Rebase: Resolved the conflict with origin/main in docs/dev/debt/libSceNpTrophy2.md and rebased onto latest main. All conventions and guest unit tests continue to pass cleanly.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318990242 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8218#issuecomment-6318990242). Originally posted by [jagrat04](https://github.com/jagrat04) on 2026-10-21T14:51:06Z. --- @adriadam10 @oneandonlydean Thanks for the reviews! 1. **Source & Siblings**: Updated the PR description and `docs/dev/debt/libSceNpTrophy2.md` to clarify that `SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND` is inferred from the sibling calls (`sceNpTrophy2GetGameIcon`, `sceNpTrophy2GetGroupIcon`, `sceNpTrophy2GetTrophyIcon`) in KytyPS5 (`libTrophy.cpp:464/483/502`), as KytyPS5 does not have `sceNpTrophy2GetRewardIcon`. PPSA06888 specifically calls `sceNpTrophy2GetRewardIcon` through `PSNCore.prx`. Aligning those three sibling calls to return `SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND` instead of throwing will follow in a separate PR to keep this PR strictly scoped to implementing `sceNpTrophy2GetRewardIcon` (one topic per PR). 2. **Rebase**: Resolved the conflict with `origin/main` in `docs/dev/debt/libSceNpTrophy2.md` and rebased onto latest `main`. All conventions and guest unit tests continue to pass cleanly.
jagrat04 commented 2026-10-22 08:17:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-10-22T08:17:45Z.


@adriadam10 @oneandonlydean Thanks for the review and feedback!

  1. KytyPS5 Sibling Inference: Updated both the PR description and docs/dev/debt/libSceNpTrophy2.md to explicitly state that returning SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND (-2141898479 / 0x80553911) is inferred from the sibling calls (sceNpTrophy2GetGameIcon, sceNpTrophy2GetGroupIcon, sceNpTrophy2GetTrophyIcon) in KytyPS5 (libTrophy.cpp:464/483/502).
  2. Title behavior (PPSA06888): In PPSA06888's trace (Media/Plugins/PSNCore.prx), this trophy reward notification path specifically queries sceNpTrophy2GetRewardIcon (first with nullptr to retrieve size, then with allocated buffer). It does not invoke GetGameIcon, GetGroupIcon, or GetTrophyIcon during that sequence. Updating those sibling calls to return this error code instead of throwing is definitely a sensible improvement and will follow in a separate PR per the one-topic-per-PR rule.
  3. Rebase: The branch has been rebased cleanly onto latest main (36bc227284), all merge conflicts resolved, conventions verified, and tests passed 100%.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336124116 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8218#issuecomment-6336124116). Originally posted by [jagrat04](https://github.com/jagrat04) on 2026-10-22T08:17:45Z. --- @adriadam10 @oneandonlydean Thanks for the review and feedback! 1. **KytyPS5 Sibling Inference**: Updated both the PR description and `docs/dev/debt/libSceNpTrophy2.md` to explicitly state that returning `SCE_NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND` (`-2141898479` / `0x80553911`) is inferred from the sibling calls (`sceNpTrophy2GetGameIcon`, `sceNpTrophy2GetGroupIcon`, `sceNpTrophy2GetTrophyIcon`) in KytyPS5 (`libTrophy.cpp:464/483/502`). 2. **Title behavior (PPSA06888)**: In PPSA06888's trace (`Media/Plugins/PSNCore.prx`), this trophy reward notification path specifically queries `sceNpTrophy2GetRewardIcon` (first with `nullptr` to retrieve size, then with allocated buffer). It does not invoke `GetGameIcon`, `GetGroupIcon`, or `GetTrophyIcon` during that sequence. Updating those sibling calls to return this error code instead of throwing is definitely a sensible improvement and will follow in a separate PR per the one-topic-per-PR rule. 3. **Rebase**: The branch has been rebased cleanly onto latest `main` (`36bc227284`), all merge conflicts resolved, conventions verified, and tests passed 100%.
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!8218
No description provided.