feat(libSceNpCommerce): implement sceNpCommerceDialogOpen2 #3607

Merged
itsbo5 merged 2 commits from upstream-pr/3607 into main 2026-10-14 19:19:19 +00:00
itsbo5 commented 2026-10-11 14:10:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by itsbo5 on 2026-10-11T14:10:08Z.


What

Implements sceNpCommerceDialogOpen2 following sceNpCommerceDialogOpen.

  • Finishes immediately as cancelled like sibling commerce dialog calls
  • Completes 100% of libSceNpCommerce (11/11 exports done)
  • Documents inferred signature in TechnicalDebt.md

Tested

Linux build; guest_np_commerce_dialog (ctest) covers not-initialized, null and zero parameters, status and result after the call.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819663233 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607). Originally posted by [itsbo5](https://github.com/itsbo5) on 2026-10-11T14:10:08Z. --- ### What Implements `sceNpCommerceDialogOpen2` following `sceNpCommerceDialogOpen`. - Finishes immediately as cancelled like sibling commerce dialog calls - Completes 100% of libSceNpCommerce (11/11 exports done) - Documents inferred signature in TechnicalDebt.md ### Tested Linux build; `guest_np_commerce_dialog` (ctest) covers not-initialized, null and zero parameters, status and result after the call. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
adriadam10 commented 2026-10-11 14:14:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T14:14:00Z.

Review: DISMISSED


Thanks for the PR. Points to address:

  • core/libs/prx/libSceNpCommerce/Export.cpp:82: sceNpCommerceDialogOpen2 now forwards to sceNpCommerceDialogOpen, which returns COMMON_DIALOG_ERROR_NOT_INITIALIZED / ARG_NULL. The only reference we found (prosper, src/hle/np/np.cpp:1224, tests/hle/np/test_np_sublibs.cpp:347) calls sceNpCommerceDialogOpen2 with all-zero arguments and expects 0. Please say which source the param type and the validation come from, or follow prosper; if neither is known, the unverified part should throw.
  • No test is added. Please add a guest test (registered in ctest) pinning the returned values, including the status afterwards.
  • docs/dev/TechnicalDebt.md conflicts with main; please rebase. Keep the new line away from the end of the section.
  • The PR body does not follow the template (conventions is red: What, Tested, Checklist empty). Please fill them in; "Tested" should list what you ran.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5483623280 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#pullrequestreview-5483623280). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T14:14:00Z. **Review:** DISMISSED --- Thanks for the PR. Points to address: - `core/libs/prx/libSceNpCommerce/Export.cpp:82`: `sceNpCommerceDialogOpen2` now forwards to `sceNpCommerceDialogOpen`, which returns `COMMON_DIALOG_ERROR_NOT_INITIALIZED` / `ARG_NULL`. The only reference we found (prosper, `src/hle/np/np.cpp:1224`, `tests/hle/np/test_np_sublibs.cpp:347`) calls `sceNpCommerceDialogOpen2` with all-zero arguments and expects 0. Please say which source the param type and the validation come from, or follow prosper; if neither is known, the unverified part should throw. - No test is added. Please add a guest test (registered in ctest) pinning the returned values, including the status afterwards. - `docs/dev/TechnicalDebt.md` conflicts with `main`; please rebase. Keep the new line away from the end of the section. - The PR body does not follow the template (`conventions` is red: `What`, `Tested`, `Checklist` empty). Please fill them in; "Tested" should list what you ran.
github-actions[bot] commented 2026-10-11 14:37:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T14:37:04Z.


Progress report (bebff8b → 68bddf8)

📈 System libraries: 88.88% (+0.02%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceNpCommerce sceNpCommerceDialogOpen2
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110131482 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6110131482). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T14:37:04Z. --- <!-- progress-report --> ### Progress report (bebff8b → 68bddf8) 📈 **System libraries**: 88.88% (+0.02%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceNpCommerce | `sceNpCommerceDialogOpen2` | </details>
itsbo5 commented 2026-10-11 14:39:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by itsbo5 on 2026-10-11T14:39:06Z.


done

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110149542 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6110149542). Originally posted by [itsbo5](https://github.com/itsbo5) on 2026-10-11T14:39:06Z. --- done
blawesom commented 2026-10-11 15:20:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T15:20:07Z.


Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Builds; tools/check_conventions.py --base origin/main passes.
  • Full suite: 833/833 passed (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110520728 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6110520728). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T15:20:07Z. --- Independent pre-review on **Linux** (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`. - Builds; `tools/check_conventions.py --base origin/main` passes. - Full suite: **833/833 passed** (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).
oneandonlydean commented 2026-10-11 23:15:33 +00:00 (Migrated from github.com)

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


Which title calls sceNpCommerceDialogOpen2 on main? With the title ID and the log line where it stops this can go in after a rebase (core/libs/CMakeLists.txt, docs/dev/TechnicalDebt.md); otherwise I'll close it until one does.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114991868 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6114991868). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T23:15:33Z. --- Which title calls `sceNpCommerceDialogOpen2` on main? With the title ID and the log line where it stops this can go in after a rebase (`core/libs/CMakeLists.txt`, `docs/dev/TechnicalDebt.md`); otherwise I'll close it until one does.
adriadam10 commented 2026-10-12 20:44:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T20:44:59Z.

Review: DISMISSED


Thanks for the update. Still open from the previous review, plus the question above:

  • core/libs/prx/libSceNpCommerce/Export.cpp:84: the COMMON_DIALOG_ERROR_NOT_INITIALIZED check has no source. The only reference we found (prosper, src/hle/np/np.cpp:500, s_commerce_open registered for sceNpCommerceDialogOpen2 too) ignores every argument, validates nothing and returns 0. Please cite where the validation and the const void* parameter come from, or follow prosper; whatever is not known should throw.
  • core/libs/tests/GuestNpCommerceDialog.cpp:44: the test pins the unsourced NOT_INITIALIZED result, so it only checks the PR's own choice.
  • @oneandonlydean's question is unanswered: which title calls sceNpCommerceDialogOpen2 (title ID, and the log line where it stops on main)? docs/dev/TechnicalDebt.md only says PPSA23566 imports it.
  • The branch conflicts with main (core/libs/CMakeLists.txt, docs/dev/TechnicalDebt.md); please rebase.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5495775790 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#pullrequestreview-5495775790). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T20:44:59Z. **Review:** DISMISSED --- Thanks for the update. Still open from the previous review, plus the question above: - `core/libs/prx/libSceNpCommerce/Export.cpp:84`: the `COMMON_DIALOG_ERROR_NOT_INITIALIZED` check has no source. The only reference we found (prosper, `src/hle/np/np.cpp:500`, `s_commerce_open` registered for `sceNpCommerceDialogOpen2` too) ignores every argument, validates nothing and returns 0. Please cite where the validation and the `const void*` parameter come from, or follow prosper; whatever is not known should throw. - `core/libs/tests/GuestNpCommerceDialog.cpp:44`: the test pins the unsourced `NOT_INITIALIZED` result, so it only checks the PR's own choice. - @oneandonlydean's question is unanswered: which title calls `sceNpCommerceDialogOpen2` (title ID, and the log line where it stops on main)? `docs/dev/TechnicalDebt.md` only says PPSA23566 imports it. - The branch conflicts with `main` (`core/libs/CMakeLists.txt`, `docs/dev/TechnicalDebt.md`); please rebase.
MarcZX10 commented 2026-10-13 21:12:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T21:12:34Z.


There is now concrete title evidence in the newer overlapping PR #5416: Call of Duty: Black Ops (PPSA34501), on the games/blackops bring-up discussion #5389, throws sceNpCommerceDialogOpen2 not implemented when selecting Zombies → Online. The report includes the stopping log and says the title continues past it with the implementation. This appears to answer the title-ID/log question from your earlier comment. #5416 overlaps this PR, so maintainers will need to choose or coordinate the implementation.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6155297835 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6155297835). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T21:12:34Z. --- There is now concrete title evidence in the newer overlapping PR #5416: Call of Duty: Black Ops (PPSA34501), on the `games/blackops` bring-up discussion #5389, throws `sceNpCommerceDialogOpen2 not implemented` when selecting Zombies → Online. The report includes the stopping log and says the title continues past it with the implementation. This appears to answer the title-ID/log question from your earlier comment. #5416 overlaps this PR, so maintainers will need to choose or coordinate the implementation.
alexpournaras commented 2026-10-13 21:40:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alexpournaras on 2026-10-13T21:40:03Z.


I tested this PR with Call of Duty: Black Ops (PPSA34501) on Windows 11.

Using my games/blackops branch, Zombies → Online previously crashed with sceNpCommerceDialogOpen2 not implemented. With the changes from this PR, the game successfully continues past that exception.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6155768235 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6155768235). Originally posted by [alexpournaras](https://github.com/alexpournaras) on 2026-10-13T21:40:03Z. --- I tested this PR with [**Call of Duty: Black Ops (PPSA34501)**](https://github.com/boykopovar/AnyPS5/discussions/5389) on Windows 11. Using my `games/blackops` branch, **Zombies → Online** previously crashed with `sceNpCommerceDialogOpen2 not implemented`. With the changes from this PR, the game successfully continues past that exception.
MarcZX10 commented 2026-10-13 21:42:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T21:42:39Z.


Thanks for the Windows 11 test. It confirms that Call of Duty: Black Ops (PPSA34501) reaches sceNpCommerceDialogOpen2 at Zombies → Online and continues past the exception with this implementation, which answers the requested title and repro evidence. The same call is implemented in open PR #5416, so the two PRs now have matching title-level validation and need coordination around their overlapping change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6155810225 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6155810225). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T21:42:39Z. --- Thanks for the Windows 11 test. It confirms that Call of Duty: Black Ops (PPSA34501) reaches sceNpCommerceDialogOpen2 at Zombies → Online and continues past the exception with this implementation, which answers the requested title and repro evidence. The same call is implemented in open PR #5416, so the two PRs now have matching title-level validation and need coordination around their overlapping change.
MarcZX10 commented 2026-10-13 21:46:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T21:46:31Z.


Thanks for the Windows validation. #5416 is now closed in favor of this PR, so that duplicate is resolved. GitHub currently reports #3607 as DIRTY against main; the earlier review also requested a rebase. Please rebase and rerun the relevant checks when ready.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6155874160 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6155874160). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T21:46:31Z. --- Thanks for the Windows validation. #5416 is now closed in favor of this PR, so that duplicate is resolved. GitHub currently reports #3607 as DIRTY against `main`; the earlier review also requested a rebase. Please rebase and rerun the relevant checks when ready.
nikowolf123 commented 2026-10-14 17:12:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-14T17:12:48Z.


@itsbo5 here is a rebase of this PR that follows prosper, as @adriadam10's review asked. cc @oneandonlydean, since you're assigned.

What the sources show:

  • prosper uses its sceNpCommerceDialogOpen handler for sceNpCommerceDialogOpen2 too (np.cpp#L1223-L1224). That handler, s_commerce_open, does three things: it logs its arguments, sets the status to 3 (FINISHED) and returns 0. It checks neither the state nor the param. Its test calls Open2 with all-zero arguments after Initialize and Open, and expects 0 and status 3 (test_np_sublibs.cpp#L341-L348).
  • On main, the sibling calls already end that way. sceNpCommerceDialogOpen sets FINISHED (Export.cpp#L31-L36). After that, sceNpCommerceDialogGetResult writes result 1 (USER_CANCELED) and authorized 0 (#L46-L55). So Open2 needs nothing more than g_status = COMMON_DIALOG_STATUS_FINISHED; return 0; to give the same cancelled result.

Changes on top of 556ed4f78, rebased onto 763ad20fc:

  1. Export.cpp: keep main's sceNpCommerceDialogOpen2(void), and drop the NOT_INITIALIZED check and the const void* parameter.
  2. The core/libs/CMakeLists.txt conflict: instead of resolving the hunk, the test is registered in a new core/libs/prx/libSceNpCommerce/CMakeLists.txt, the way #5817 did for libSceVoice, so core/libs/CMakeLists.txt stays untouched.
  3. Test: Open2 is called after Initialize and again after Open; each time it returns 0, the status is 3 and the result is cancelled. The not-initialized case is no longer pinned. The checks of the other calls (their error codes and the store icon calls) are left out too, since this PR does not change them.
  4. The docs/dev/TechnicalDebt.md conflict: the PPSA23566 list now lives in docs/dev/debt/libSceAudioOut.md#L5. sceNpCommerceDialogOpen2 is removed from that list, and docs/dev/debt/libSceNpCommerce.md gets an Unknown function info entry that cites prosper.

The PR body's What and Tested still describe the NOT_INITIALIZED check and TechnicalDebt.md, so they need updating too.

Tested with a WSL Ubuntu GCC Release build at the branch head:

  • guest_np_commerce_dialog passes.
  • With main's Export.cpp swapped in, the same test aborts with sceNpCommerceDialogOpen2 not implemented.
  • main's tools/check_conventions.py (with this PR's title and body) and tools/check_test_registration.py both pass.

The branch is nikowolf123/AnyPS5 help/h7-np-commerce-open2. It has two commits: yours, rebased with your authorship, then the prosper change. To take it:

git fetch https://github.com/nikowolf123/AnyPS5 help/h7-np-commerce-open2
git reset --hard FETCH_HEAD
git push --force-with-lease <your fork remote> HEAD:feat/libSceNpCommerce-dialog-open2

Maintainer edits are enabled on your branch, so a maintainer could also push it there.

@alexpournaras could you rerun Zombies > Online on this head? Compared with the 556ed4f78 change you ran, one thing differs: before sceNpCommerceDialogInitialize, or after Terminate, Open2 now returns 0 and finishes the dialog instead of returning NOT_INITIALIZED.

Diff against main (763ad20fc), without the one-line removal in libSceAudioOut.md
diff --git a/core/libs/prx/libSceNpCommerce/CMakeLists.txt b/core/libs/prx/libSceNpCommerce/CMakeLists.txt
new file mode 100644
index 000000000..ec34bf123
--- /dev/null
+++ b/core/libs/prx/libSceNpCommerce/CMakeLists.txt
@@ -0,0 +1,15 @@
+add_library(libSceNpCommerce SHARED EXCLUDE_FROM_ALL Export.cpp)
+target_include_directories(libSceNpCommerce PRIVATE ${LIBS_INCLUDE_DIR})
+configure_windows_unwind(libSceNpCommerce)
+
+if(BUILD_TESTING)
+    add_test_executable(guest_np_commerce_dialog_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCommerceDialog.cpp)
+    target_include_directories(guest_np_commerce_dialog_tests PRIVATE ${LIBS_INCLUDE_DIR})
+    target_link_libraries(guest_np_commerce_dialog_tests PRIVATE libSceNpCommerce libc)
+    configure_windows_unwind(guest_np_commerce_dialog_tests)
+    add_test(NAME guest_np_commerce_dialog COMMAND guest_np_commerce_dialog_tests)
+    if(WIN32)
+        set_tests_properties(guest_np_commerce_dialog PROPERTIES ENVIRONMENT_MODIFICATION
+            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceNpCommerce>")
+    endif()
+endif()
diff --git a/core/libs/prx/libSceNpCommerce/Export.cpp b/core/libs/prx/libSceNpCommerce/Export.cpp
index 525178f39..39fecd0fc 100644
--- a/core/libs/prx/libSceNpCommerce/Export.cpp
+++ b/core/libs/prx/libSceNpCommerce/Export.cpp
@@ -80,8 +80,8 @@ int APS5_VABI sceNpCommerceSetPsStoreIconLayout(int layout) {
 }
 
 int APS5_VABI sceNpCommerceDialogOpen2(void) {
-    NotImplemented_nid_no_patch(__func__);
-    return 0;
+ g_status = COMMON_DIALOG_STATUS_FINISHED;
+ return 0;
 }
 
 }
diff --git a/core/libs/tests/GuestNpCommerceDialog.cpp b/core/libs/tests/GuestNpCommerceDialog.cpp
new file mode 100644
index 000000000..7b7239959
--- /dev/null
+++ b/core/libs/tests/GuestNpCommerceDialog.cpp
@@ -0,0 +1,64 @@
+#include "SceTypes.hpp"
+
+#include <cstdint>
+#include <cstdlib>
+#include <cstring>
+
+extern "C" {
+int APS5_VABI sceNpCommerceDialogInitialize();
+int APS5_VABI sceNpCommerceDialogOpen(const void* param);
+int APS5_VABI sceNpCommerceDialogOpen2(void);
+int APS5_VABI sceNpCommerceDialogUpdateStatus(void);
+int APS5_VABI sceNpCommerceDialogGetStatus(void);
+int APS5_VABI sceNpCommerceDialogGetResult(void* result);
+int APS5_VABI sceNpCommerceDialogClose(void);
+int APS5_VABI sceNpCommerceDialogTerminate();
+}
+
+namespace {
+
+void Require(bool value) { if (!value) std::abort(); }
+
+constexpr int statusNone = 0;
+constexpr int statusInitialized = 1;
+constexpr int statusFinished = 3;
+constexpr std::int32_t resultUserCanceled = 1;
+
+void RequireCanceledResult() {
+    std::uint8_t result[0x20];
+    std::memset(result, 0x33, sizeof(result));
+    Require(sceNpCommerceDialogGetResult(result) == 0);
+    std::int32_t value = 0;
+    std::memcpy(&value, result, sizeof(value));
+    Require(value == resultUserCanceled);
+    Require(result[4] == 0);
+    Require(result[5] == 0x33);
+}
+
+}
+
+int main() {
+    Require(sceNpCommerceDialogGetStatus() == statusNone);
+    Require(sceNpCommerceDialogInitialize() == 0);
+    Require(sceNpCommerceDialogGetStatus() == statusInitialized);
+
+    Require(sceNpCommerceDialogOpen2() == 0);
+    Require(sceNpCommerceDialogUpdateStatus() == statusFinished);
+    Require(sceNpCommerceDialogGetStatus() == statusFinished);
+    RequireCanceledResult();
+
+    Require(sceNpCommerceDialogClose() == 0);
+    Require(sceNpCommerceDialogGetStatus() == statusFinished);
+    Require(sceNpCommerceDialogTerminate() == 0);
+    Require(sceNpCommerceDialogGetStatus() == statusNone);
+
+    alignas(8) std::uint8_t param[0x40] = {};
+    Require(sceNpCommerceDialogInitialize() == 0);
+    Require(sceNpCommerceDialogOpen(param) == 0);
+    Require(sceNpCommerceDialogOpen2() == 0);
+    Require(sceNpCommerceDialogUpdateStatus() == statusFinished);
+    RequireCanceledResult();
+    Require(sceNpCommerceDialogTerminate() == 0);
+    Require(sceNpCommerceDialogGetStatus() == statusNone);
+    return 0;
+}
diff --git a/docs/dev/debt/libSceNpCommerce.md b/docs/dev/debt/libSceNpCommerce.md
index a3a899c13..7a9d0ec64 100644
--- a/docs/dev/debt/libSceNpCommerce.md
+++ b/docs/dev/debt/libSceNpCommerce.md
@@ -3,3 +3,7 @@
 ### Silent stubs
 
 - [libSceNpCommerce](../../../core/libs/prx/libSceNpCommerce/Export.cpp) - the PS Store icon show/hide calls and `sceNpCommerceSetPsStoreIconLayout` do nothing
+
+### Unknown function info
+
+- [sceNpCommerceDialogOpen2](../../../core/libs/prx/libSceNpCommerce/Export.cpp) (libSceNpCommerce) - declared without parameters; follows [prosper](https://github.com/mattias800/prosper/blob/73413cb445b0364bb49c4d2478e9ee1614b9f7d9/prosper/src/hle/np/np.cpp#L500-L504), which serves it with its `sceNpCommerceDialogOpen` handler: every argument is ignored, nothing is validated, it returns 0 and the dialog finishes at once, so `sceNpCommerceDialogGetResult` reports it cancelled. The parameters and the console's error results are unknown. Call of Duty: Black Ops (PPSA34501) calls it at Zombies > Online

AI-assisted: written with Claude Code. I checked prosper's np.cpp and test_np_sublibs.cpp at 73413cb4, main's libSceNpCommerce, its debt files and #5817's registration at 763ad20fc, and this thread. I ran the rebase, guest_np_commerce_dialog on the branch and with main's Export.cpp (WSL Ubuntu, GCC), and main's check_conventions.py and check_test_registration.py.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6173996210 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6173996210). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-14T17:12:48Z. --- @itsbo5 here is a rebase of this PR that follows prosper, as [@adriadam10's review](https://github.com/boykopovar/AnyPS5/pull/3607#pullrequestreview-5495775790) asked. cc @oneandonlydean, since you're assigned. What the sources show: - prosper uses its `sceNpCommerceDialogOpen` handler for `sceNpCommerceDialogOpen2` too ([np.cpp#L1223-L1224](https://github.com/mattias800/prosper/blob/73413cb445b0364bb49c4d2478e9ee1614b9f7d9/prosper/src/hle/np/np.cpp#L1223-L1224)). That handler, [`s_commerce_open`](https://github.com/mattias800/prosper/blob/73413cb445b0364bb49c4d2478e9ee1614b9f7d9/prosper/src/hle/np/np.cpp#L500-L504), does three things: it logs its arguments, sets the status to 3 (FINISHED) and returns 0. It checks neither the state nor the param. Its test calls `Open2` with all-zero arguments after `Initialize` and `Open`, and expects 0 and status 3 ([test_np_sublibs.cpp#L341-L348](https://github.com/mattias800/prosper/blob/73413cb445b0364bb49c4d2478e9ee1614b9f7d9/prosper/tests/hle/np/test_np_sublibs.cpp#L341-L348)). - On `main`, the sibling calls already end that way. `sceNpCommerceDialogOpen` sets FINISHED ([Export.cpp#L31-L36](https://github.com/boykopovar/AnyPS5/blob/763ad20fc1927a3f677d544537618b17e061fc9f/core/libs/prx/libSceNpCommerce/Export.cpp#L31-L36)). After that, `sceNpCommerceDialogGetResult` writes result 1 (USER_CANCELED) and `authorized` 0 ([#L46-L55](https://github.com/boykopovar/AnyPS5/blob/763ad20fc1927a3f677d544537618b17e061fc9f/core/libs/prx/libSceNpCommerce/Export.cpp#L46-L55)). So `Open2` needs nothing more than `g_status = COMMON_DIALOG_STATUS_FINISHED; return 0;` to give the same cancelled result. Changes on top of 556ed4f78, rebased onto `763ad20fc`: 1. `Export.cpp`: keep `main`'s `sceNpCommerceDialogOpen2(void)`, and drop the `NOT_INITIALIZED` check and the `const void*` parameter. 2. The `core/libs/CMakeLists.txt` conflict: instead of resolving the hunk, the test is registered in a new `core/libs/prx/libSceNpCommerce/CMakeLists.txt`, the way #5817 did for [libSceVoice](https://github.com/boykopovar/AnyPS5/blob/763ad20fc1927a3f677d544537618b17e061fc9f/core/libs/prx/libSceVoice/CMakeLists.txt), so `core/libs/CMakeLists.txt` stays untouched. 3. Test: `Open2` is called after `Initialize` and again after `Open`; each time it returns 0, the status is 3 and the result is cancelled. The not-initialized case is no longer pinned. The checks of the other calls (their error codes and the store icon calls) are left out too, since this PR does not change them. 4. The `docs/dev/TechnicalDebt.md` conflict: the PPSA23566 list now lives in [docs/dev/debt/libSceAudioOut.md#L5](https://github.com/boykopovar/AnyPS5/blob/763ad20fc1927a3f677d544537618b17e061fc9f/docs/dev/debt/libSceAudioOut.md#L5). `sceNpCommerceDialogOpen2` is removed from that list, and `docs/dev/debt/libSceNpCommerce.md` gets an `Unknown function info` entry that cites prosper. The PR body's What and Tested still describe the `NOT_INITIALIZED` check and `TechnicalDebt.md`, so they need updating too. Tested with a WSL Ubuntu GCC Release build at the branch head: - `guest_np_commerce_dialog` passes. - With `main`'s `Export.cpp` swapped in, the same test aborts with `sceNpCommerceDialogOpen2 not implemented`. - `main`'s `tools/check_conventions.py` (with this PR's title and body) and `tools/check_test_registration.py` both pass. The branch is [nikowolf123/AnyPS5 `help/h7-np-commerce-open2`](https://github.com/nikowolf123/AnyPS5/commits/help/h7-np-commerce-open2). It has two commits: yours, rebased with your authorship, then the prosper change. To take it: ``` git fetch https://github.com/nikowolf123/AnyPS5 help/h7-np-commerce-open2 git reset --hard FETCH_HEAD git push --force-with-lease <your fork remote> HEAD:feat/libSceNpCommerce-dialog-open2 ``` Maintainer edits are enabled on your branch, so a maintainer could also push it there. @alexpournaras could you rerun Zombies > Online on this head? Compared with the 556ed4f78 change you ran, one thing differs: before `sceNpCommerceDialogInitialize`, or after `Terminate`, `Open2` now returns 0 and finishes the dialog instead of returning `NOT_INITIALIZED`. <details><summary>Diff against main (763ad20fc), without the one-line removal in libSceAudioOut.md</summary> ```diff diff --git a/core/libs/prx/libSceNpCommerce/CMakeLists.txt b/core/libs/prx/libSceNpCommerce/CMakeLists.txt new file mode 100644 index 000000000..ec34bf123 --- /dev/null +++ b/core/libs/prx/libSceNpCommerce/CMakeLists.txt @@ -0,0 +1,15 @@ +add_library(libSceNpCommerce SHARED EXCLUDE_FROM_ALL Export.cpp) +target_include_directories(libSceNpCommerce PRIVATE ${LIBS_INCLUDE_DIR}) +configure_windows_unwind(libSceNpCommerce) + +if(BUILD_TESTING) + add_test_executable(guest_np_commerce_dialog_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCommerceDialog.cpp) + target_include_directories(guest_np_commerce_dialog_tests PRIVATE ${LIBS_INCLUDE_DIR}) + target_link_libraries(guest_np_commerce_dialog_tests PRIVATE libSceNpCommerce libc) + configure_windows_unwind(guest_np_commerce_dialog_tests) + add_test(NAME guest_np_commerce_dialog COMMAND guest_np_commerce_dialog_tests) + if(WIN32) + set_tests_properties(guest_np_commerce_dialog PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceNpCommerce>") + endif() +endif() diff --git a/core/libs/prx/libSceNpCommerce/Export.cpp b/core/libs/prx/libSceNpCommerce/Export.cpp index 525178f39..39fecd0fc 100644 --- a/core/libs/prx/libSceNpCommerce/Export.cpp +++ b/core/libs/prx/libSceNpCommerce/Export.cpp @@ -80,8 +80,8 @@ int APS5_VABI sceNpCommerceSetPsStoreIconLayout(int layout) { } int APS5_VABI sceNpCommerceDialogOpen2(void) { - NotImplemented_nid_no_patch(__func__); - return 0; + g_status = COMMON_DIALOG_STATUS_FINISHED; + return 0; } } diff --git a/core/libs/tests/GuestNpCommerceDialog.cpp b/core/libs/tests/GuestNpCommerceDialog.cpp new file mode 100644 index 000000000..7b7239959 --- /dev/null +++ b/core/libs/tests/GuestNpCommerceDialog.cpp @@ -0,0 +1,64 @@ +#include "SceTypes.hpp" + +#include <cstdint> +#include <cstdlib> +#include <cstring> + +extern "C" { +int APS5_VABI sceNpCommerceDialogInitialize(); +int APS5_VABI sceNpCommerceDialogOpen(const void* param); +int APS5_VABI sceNpCommerceDialogOpen2(void); +int APS5_VABI sceNpCommerceDialogUpdateStatus(void); +int APS5_VABI sceNpCommerceDialogGetStatus(void); +int APS5_VABI sceNpCommerceDialogGetResult(void* result); +int APS5_VABI sceNpCommerceDialogClose(void); +int APS5_VABI sceNpCommerceDialogTerminate(); +} + +namespace { + +void Require(bool value) { if (!value) std::abort(); } + +constexpr int statusNone = 0; +constexpr int statusInitialized = 1; +constexpr int statusFinished = 3; +constexpr std::int32_t resultUserCanceled = 1; + +void RequireCanceledResult() { + std::uint8_t result[0x20]; + std::memset(result, 0x33, sizeof(result)); + Require(sceNpCommerceDialogGetResult(result) == 0); + std::int32_t value = 0; + std::memcpy(&value, result, sizeof(value)); + Require(value == resultUserCanceled); + Require(result[4] == 0); + Require(result[5] == 0x33); +} + +} + +int main() { + Require(sceNpCommerceDialogGetStatus() == statusNone); + Require(sceNpCommerceDialogInitialize() == 0); + Require(sceNpCommerceDialogGetStatus() == statusInitialized); + + Require(sceNpCommerceDialogOpen2() == 0); + Require(sceNpCommerceDialogUpdateStatus() == statusFinished); + Require(sceNpCommerceDialogGetStatus() == statusFinished); + RequireCanceledResult(); + + Require(sceNpCommerceDialogClose() == 0); + Require(sceNpCommerceDialogGetStatus() == statusFinished); + Require(sceNpCommerceDialogTerminate() == 0); + Require(sceNpCommerceDialogGetStatus() == statusNone); + + alignas(8) std::uint8_t param[0x40] = {}; + Require(sceNpCommerceDialogInitialize() == 0); + Require(sceNpCommerceDialogOpen(param) == 0); + Require(sceNpCommerceDialogOpen2() == 0); + Require(sceNpCommerceDialogUpdateStatus() == statusFinished); + RequireCanceledResult(); + Require(sceNpCommerceDialogTerminate() == 0); + Require(sceNpCommerceDialogGetStatus() == statusNone); + return 0; +} diff --git a/docs/dev/debt/libSceNpCommerce.md b/docs/dev/debt/libSceNpCommerce.md index a3a899c13..7a9d0ec64 100644 --- a/docs/dev/debt/libSceNpCommerce.md +++ b/docs/dev/debt/libSceNpCommerce.md @@ -3,3 +3,7 @@ ### Silent stubs - [libSceNpCommerce](../../../core/libs/prx/libSceNpCommerce/Export.cpp) - the PS Store icon show/hide calls and `sceNpCommerceSetPsStoreIconLayout` do nothing + +### Unknown function info + +- [sceNpCommerceDialogOpen2](../../../core/libs/prx/libSceNpCommerce/Export.cpp) (libSceNpCommerce) - declared without parameters; follows [prosper](https://github.com/mattias800/prosper/blob/73413cb445b0364bb49c4d2478e9ee1614b9f7d9/prosper/src/hle/np/np.cpp#L500-L504), which serves it with its `sceNpCommerceDialogOpen` handler: every argument is ignored, nothing is validated, it returns 0 and the dialog finishes at once, so `sceNpCommerceDialogGetResult` reports it cancelled. The parameters and the console's error results are unknown. Call of Duty: Black Ops (PPSA34501) calls it at Zombies > Online ``` </details> AI-assisted: written with Claude Code. I checked prosper's `np.cpp` and `test_np_sublibs.cpp` at 73413cb4, `main`'s libSceNpCommerce, its debt files and #5817's registration at 763ad20fc, and this thread. I ran the rebase, `guest_np_commerce_dialog` on the branch and with `main`'s `Export.cpp` (WSL Ubuntu, GCC), and `main`'s `check_conventions.py` and `check_test_registration.py`.
oneandonlydean commented 2026-10-14 17:45:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T17:45:08Z.


Pushed @nikowolf123's rebase here, onto current main (the libSceAudioOut.md line conflicted again after #4778): your commit, then his change that follows prosper. guest_np_commerce_dialog passes. @itsbo5 please update What/Tested in the description to match (no NOT_INITIALIZED check, test in libSceNpCommerce/CMakeLists.txt).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174610764 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6174610764). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T17:45:08Z. --- Pushed @nikowolf123's rebase here, onto current main (the `libSceAudioOut.md` line conflicted again after #4778): your commit, then his change that follows prosper. `guest_np_commerce_dialog` passes. @itsbo5 please update What/Tested in the description to match (no `NOT_INITIALIZED` check, test in `libSceNpCommerce/CMakeLists.txt`).
alexpournaras commented 2026-10-14 18:36:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alexpournaras on 2026-10-14T18:36:06Z.


@nikowolf123 I only copied the relevant change (sceNpCommerceDialogOpen2) into my branch and confirmed Zombies → Online continued past the exception.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175569125 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3607#issuecomment-6175569125). Originally posted by [alexpournaras](https://github.com/alexpournaras) on 2026-10-14T18:36:06Z. --- @nikowolf123 I only copied the relevant change (`sceNpCommerceDialogOpen2`) into my branch and confirmed Zombies → Online continued past the exception.
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!3607
No description provided.