From f3e783b6cb1971fbda219580338e85bd8da73f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Mon, 5 Oct 2026 19:14:49 +0200 Subject: [PATCH] feat(libs): implement sceNpTrophy2UnregisterUnlockCallback Co-Authored-By: Claude --- core/libs/prx/libSceNpTrophy2/CMakeLists.txt | 18 +++++++++++++++++ core/libs/prx/libSceNpTrophy2/src/Context.cpp | 3 +-- core/libs/tests/GuestNpTrophy2.cpp | 20 +++++++++++++++++++ docs/dev/TechnicalDebt.md | 2 +- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 core/libs/tests/GuestNpTrophy2.cpp diff --git a/core/libs/prx/libSceNpTrophy2/CMakeLists.txt b/core/libs/prx/libSceNpTrophy2/CMakeLists.txt index c86b204c3..06ccd898a 100644 --- a/core/libs/prx/libSceNpTrophy2/CMakeLists.txt +++ b/core/libs/prx/libSceNpTrophy2/CMakeLists.txt @@ -11,3 +11,21 @@ target_include_directories(libSceNpTrophy2 PRIVATE ) target_link_libraries(libSceNpTrophy2 PRIVATE libc) configure_windows_unwind(libSceNpTrophy2) + +if(MINGW) + foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static) + string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + endforeach() +endif() + +if(BUILD_TESTING) + add_test_executable(guest_nptrophy2_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpTrophy2.cpp) + target_include_directories(guest_nptrophy2_tests PRIVATE ${LIBS_INCLUDE_DIR}) + target_link_libraries(guest_nptrophy2_tests PRIVATE libSceNpTrophy2 libc) + configure_windows_unwind(guest_nptrophy2_tests) + add_test(NAME guest_nptrophy2 COMMAND guest_nptrophy2_tests) + if(WIN32) + set_tests_properties(guest_nptrophy2 PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() +endif() diff --git a/core/libs/prx/libSceNpTrophy2/src/Context.cpp b/core/libs/prx/libSceNpTrophy2/src/Context.cpp index 097a8fe0d..e259afb73 100644 --- a/core/libs/prx/libSceNpTrophy2/src/Context.cpp +++ b/core/libs/prx/libSceNpTrophy2/src/Context.cpp @@ -31,8 +31,7 @@ int APS5_VABI sceNpTrophy2RegisterContext(int context, int handle, uint64_t opti } int APS5_VABI sceNpTrophy2UnregisterUnlockCallback() { - NotImplemented_nid_no_patch(__func__); - return 0; + return SCE_NP_TROPHY2_OK; } } diff --git a/core/libs/tests/GuestNpTrophy2.cpp b/core/libs/tests/GuestNpTrophy2.cpp new file mode 100644 index 000000000..5a286ab35 --- /dev/null +++ b/core/libs/tests/GuestNpTrophy2.cpp @@ -0,0 +1,20 @@ +#include "prx/libc/include/general/VabiMacros.hpp" +#include + +extern "C" { +int APS5_VABI sceNpTrophy2RegisterUnlockCallback(void*, void*); +int APS5_VABI sceNpTrophy2UnregisterUnlockCallback(); +} + +static void Require(bool value) { if (!value) std::abort(); } + +static void APS5_VABI OnUnlock(int, int, void*) {} + +int main() { + int userdata = 0; + Require(sceNpTrophy2UnregisterUnlockCallback() == 0); + Require(sceNpTrophy2RegisterUnlockCallback(reinterpret_cast(&OnUnlock), &userdata) == 0); + Require(sceNpTrophy2UnregisterUnlockCallback() == 0); + Require(sceNpTrophy2RegisterUnlockCallback(reinterpret_cast(&OnUnlock), &userdata) == 0); + Require(sceNpTrophy2UnregisterUnlockCallback() == 0); +} diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index 02ea84a84..d01404406 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -20,6 +20,7 @@ Throughout the project, every function at every stage either **does exactly what - [sceVideoOutOpen](../../core/libs/prx/libSceVideoOut/src/Output.cpp) validates the priority and CPU affinity that the open param requests for the VideoOut service thread but does not apply them: the port's present and vblank threads are host threads, and guest priorities and affinities do not reach host scheduling - The shader recompiler [skips baryctric coordinates](../../core/shader/recompiler/Recompiler.cpp) (is not even passed to SpirvTargetOptions at row 212). - [libSceAvPlayer](../../core/libs/prx/libSceAvPlayer/Export.cpp): `sceAvPlayerSetLogCallback` accepts a callback that is never called, as the player produces no log messages, and `sceAvPlayerSetAvailableBandwidth` has no effect, as it governs HLS sources, which `sceAvPlayerAddSource` does not implement. +- [libSceNpTrophy2](../../core/libs/prx/libSceNpTrophy2/src/GameInfo.cpp): `sceNpTrophy2RegisterUnlockCallback` accepts a callback that is never called, as no trophy is ever unlocked, and `sceNpTrophy2UnregisterUnlockCallback` only returns success. - [sceAvPlayerSetTrickSpeed](../../core/libs/prx/libSceAvPlayer/src/Source.cpp) (libSceAvPlayer) with a negative speed runs the clock backwards but delivers no frames; when a forward speed is set again, playback resumes from the rewound time. ### Unknown function info @@ -74,7 +75,6 @@ Throughout the project, every function at every stage either **does exactly what - [sceNpSessionSignalingGetMemoryInfo](../../core/libs/prx/libSceNpSessionSignaling/Export.cpp) (libSceNpSessionSignaling) - unknown signature - [sceNpSessionSignalingGetConnectionStatistics](../../core/libs/prx/libSceNpSessionSignaling/Export.cpp) (libSceNpSessionSignaling) - unknown signature - [sce::Np::CppWebApi::Common::String](../../core/libs/prx/libSceNpCppWebApi/Export.cpp) (libSceNpCppWebApi) - the 0x20-byte layout (32-bit reference count, buffer at 0x08, buffer size at 0x10, `LibContext*` at 0x18) comes from the module bundled with one title (PPSA21564); other SDK versions are not checked. The destructor throws for a non-null buffer: releasing it needs the `LibContext` allocator, which is not implemented -- [sceNpTrophy2UnregisterUnlockCallback](../../core/libs/prx/libSceNpTrophy2/src/Context.cpp) (libSceNpTrophy2) - unknown signature - [sceSystemServiceDisableMediaPlay](../../core/libs/prx/libSceSystemService/Export.cpp) (libSceSystemService) - unknown signature - [sceSystemServiceReenableMediaPlay](../../core/libs/prx/libSceSystemService/Export.cpp) (libSceSystemService) - unknown signature - [sceVoiceSetMuteFlag](../../core/libs/prx/libSceVoice/Export.cpp) (libSceVoice) - unknown signature