diff --git a/src/core/libraries/error_codes.h b/src/core/libraries/error_codes.h index 094ea6603..b9896b6c3 100644 --- a/src/core/libraries/error_codes.h +++ b/src/core/libraries/error_codes.h @@ -440,11 +440,47 @@ constexpr int ORBIS_USER_SERVICE_ERROR_BUFFER_TOO_SHORT = 0x8096000A; constexpr int ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER = 0x80A10003; // NpTrophy library +constexpr int ORBIS_NP_TROPHY_ERROR_UNKNOWN = 0x80551600; +constexpr int ORBIS_NP_TROPHY_ERROR_NOT_INITIALIZED = 0x80551601; +constexpr int ORBIS_NP_TROPHY_ERROR_ALREADY_INITIALIZED = 0x80551602; +constexpr int ORBIS_NP_TROPHY_ERROR_OUT_OF_MEMORY = 0x80551603; constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT = 0x80551604; +constexpr int ORBIS_NP_TROPHY_ERROR_INSUFFICIENT_BUFFER = 0x80551605; +constexpr int ORBIS_NP_TROPHY_ERROR_EXCEEDS_MAX = 0x80551606; +constexpr int ORBIS_NP_TROPHY_ERROR_ABORT = 0x80551607; constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_HANDLE = 0x80551608; -constexpr int ORBIS_NP_TROPHY_ERROR_HANDLE_EXCEEDS_MAX = 0x80551624; +constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_CONTEXT = 0x80551609; +constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_TROPHY_ID = 0x8055160A; +constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_GROUP_ID = 0x8055160B; +constexpr int ORBIS_NP_TROPHY_ERROR_TROPHY_ALREADY_UNLOCKED = 0x8055160C; +constexpr int ORBIS_NP_TROPHY_ERROR_PLATINUM_CANNOT_UNLOCK = 0x8055160D; +constexpr int ORBIS_NP_TROPHY_ERROR_ACCOUNTID_NOT_MATCH = 0x8055160E; +constexpr int ORBIS_NP_TROPHY_ERROR_NOT_REGISTERED = 0x8055160F; +constexpr int ORBIS_NP_TROPHY_ERROR_ALREADY_REGISTERED = 0x80551610; +constexpr int ORBIS_NP_TROPHY_ERROR_BROKEN_DATA = 0x80551611; +constexpr int ORBIS_NP_TROPHY_ERROR_INSUFFICIENT_SPACE = 0x80551612; constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_ALREADY_EXISTS = 0x80551613; -constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_EXCEEDS_MAX = 0x80551622; +constexpr int ORBIS_NP_TROPHY_ERROR_ICON_FILE_NOT_FOUND = 0x80551614; +constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_TRP_FILE_FORMAT = 0x80551616; +constexpr int ORBIS_NP_TROPHY_ERROR_UNSUPPORTED_TRP_FILE = 0x80551617; +constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_TROPHY_CONF_FORMAT = 0x80551618; +constexpr int ORBIS_NP_TROPHY_ERROR_UNSUPPORTED_TROPHY_CONF = 0x80551619; +constexpr int ORBIS_NP_TROPHY_ERROR_TROPHY_NOT_UNLOCKED = 0x8055161A; +constexpr int ORBIS_NP_TROPHY_ERROR_USER_NOT_FOUND = 0x8055161C; +constexpr int ORBIS_NP_TROPHY_ERROR_USER_NOT_LOGGED_IN = 0x8055161D; +constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_USER_LOGOUT = 0x8055161E; +constexpr int ORBIS_NP_TROPHY_ERROR_USE_TRP_FOR_DEVELOPMENT = 0x8055161F; +constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_NP_SERVICE_LABEL = 0x80551621; +constexpr int ORBIS_NP_TROPHY_ERROR_NOT_SUPPORTED = 0x80551622; +constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_EXCEEDS_MAX = 0x80551623; +constexpr int ORBIS_NP_TROPHY_ERROR_HANDLE_EXCEEDS_MAX = 0x80551624; +constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_USER_ID = 0x80551625; +constexpr int ORBIS_NP_TROPHY_ERROR_TITLE_CONF_NOT_INSTALLED = 0x80551626; +constexpr int ORBIS_NP_TROPHY_ERROR_BROKEN_TITLE_CONF = 0x80551627; +constexpr int ORBIS_NP_TROPHY_ERROR_INCONSISTENT_TITLE_CONF = 0x80551628; +constexpr int ORBIS_NP_TROPHY_ERROR_TITLE_BACKGROUND = 0x80551629; +constexpr int ORBIS_NP_TROPHY_ERROR_SCREENSHOT_DISABLED = 0x8055162B; +constexpr int ORBIS_NP_TROPHY_ERROR_SCREENSHOT_DISPLAY_BUFFER_NOT_IN_USE = 0x8055162D; // AvPlayer library constexpr int ORBIS_AVPLAYER_ERROR_INVALID_PARAMS = 0x806A0001; diff --git a/src/core/libraries/np_trophy/np_trophy.cpp b/src/core/libraries/np_trophy/np_trophy.cpp index ed25322b4..9f4c8a54a 100644 --- a/src/core/libraries/np_trophy/np_trophy.cpp +++ b/src/core/libraries/np_trophy/np_trophy.cpp @@ -4,13 +4,17 @@ #include #include "common/logging/log.h" +#include "common/path_util.h" #include "common/slot_vector.h" #include "core/libraries/error_codes.h" #include "core/libraries/libs.h" +#include "externals/pugixml/src/pugixml.hpp" #include "np_trophy.h" namespace Libraries::NpTrophy { +std::string game_serial; + static constexpr auto MaxTrophyHandles = 4u; static constexpr auto MaxTrophyContexts = 8u; @@ -24,11 +28,11 @@ struct ContextKeyHash { struct TrophyContext { u32 context_id; }; -static Common::SlotVector trophy_handles{}; +static Common::SlotVector trophy_handles{}; static Common::SlotVector trophy_contexts{}; static std::unordered_map contexts_internal{}; -int PS4_SYSV_ABI sceNpTrophyAbortHandle() { +int PS4_SYSV_ABI sceNpTrophyAbortHandle(OrbisNpTrophyHandle handle) { LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); return ORBIS_OK; } @@ -83,8 +87,8 @@ int PS4_SYSV_ABI sceNpTrophyConfigHasGroupFeature() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceNpTrophyCreateContext(u32* context, u32 user_id, u32 service_label, - u64 options) { +s32 PS4_SYSV_ABI sceNpTrophyCreateContext(OrbisNpTrophyContext* context, int32_t user_id, + uint32_t service_label, uint64_t options) { ASSERT(options == 0ull); if (!context) { return ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT; @@ -107,7 +111,7 @@ s32 PS4_SYSV_ABI sceNpTrophyCreateContext(u32* context, u32 user_id, u32 service return ORBIS_OK; } -s32 PS4_SYSV_ABI sceNpTrophyCreateHandle(u32* handle) { +s32 PS4_SYSV_ABI sceNpTrophyCreateHandle(OrbisNpTrophyHandle* handle) { if (!handle) { return ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT; } @@ -122,54 +126,90 @@ s32 PS4_SYSV_ABI sceNpTrophyCreateHandle(u32* handle) { return ORBIS_OK; } -int PS4_SYSV_ABI sceNpTrophyDestroyContext() { - LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); +int PS4_SYSV_ABI sceNpTrophyDestroyContext(OrbisNpTrophyContext context) { + LOG_INFO(Lib_NpTrophy, "Destroyed Context {}", context); + + if (context == ORBIS_NP_TROPHY_INVALID_CONTEXT) + return ORBIS_NP_TROPHY_ERROR_INVALID_CONTEXT; + + Common::SlotId contextId; + contextId.index = context; + + ContextKey contextkey = trophy_contexts[contextId]; + trophy_contexts.erase(contextId); + contexts_internal.erase(contextkey); + return ORBIS_OK; } -s32 PS4_SYSV_ABI sceNpTrophyDestroyHandle(u32 handle) { - if (!trophy_handles.is_allocated({handle})) { +s32 PS4_SYSV_ABI sceNpTrophyDestroyHandle(OrbisNpTrophyHandle handle) { + if (handle == ORBIS_NP_TROPHY_INVALID_HANDLE) + return ORBIS_NP_TROPHY_ERROR_INVALID_HANDLE; + + if (!trophy_handles.is_allocated({static_cast(handle)})) { return ORBIS_NP_TROPHY_ERROR_INVALID_HANDLE; } - trophy_handles.erase({handle}); + trophy_handles.erase({static_cast(handle)}); LOG_INFO(Lib_NpTrophy, "Handle {} destroyed", handle); return ORBIS_OK; } -int PS4_SYSV_ABI sceNpTrophyGetGameIcon() { +int PS4_SYSV_ABI sceNpTrophyGetGameIcon(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + void* buffer, size_t* size) { LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceNpTrophyGetGameInfo() { +int PS4_SYSV_ABI sceNpTrophyGetGameInfo(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyGameDetails* details, + OrbisNpTrophyGameData* data) { LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceNpTrophyGetGroupIcon() { +int PS4_SYSV_ABI sceNpTrophyGetGroupIcon(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyGroupId groupId, void* buffer, size_t* size) { LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceNpTrophyGetGroupInfo() { +int PS4_SYSV_ABI sceNpTrophyGetGroupInfo(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyGroupId groupId, + OrbisNpTrophyGroupDetails* details, + OrbisNpTrophyGroupData* data) { LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceNpTrophyGetTrophyIcon() { +int PS4_SYSV_ABI sceNpTrophyGetTrophyIcon(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyId trophyId, void* buffer, size_t* size) { LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceNpTrophyGetTrophyInfo() { +int PS4_SYSV_ABI sceNpTrophyGetTrophyInfo(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyId trophyId, OrbisNpTrophyDetails* details, + OrbisNpTrophyData* data) { LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); return ORBIS_OK; } -s32 PS4_SYSV_ABI sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, u32* flags, u32* count) { +s32 PS4_SYSV_ABI sceNpTrophyGetTrophyUnlockState(OrbisNpTrophyContext context, + OrbisNpTrophyHandle handle, + OrbisNpTrophyFlagArray* flags, u32* count) { LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); - *flags = 0u; + + if (context == ORBIS_NP_TROPHY_INVALID_CONTEXT) + return ORBIS_NP_TROPHY_ERROR_INVALID_CONTEXT; + + if (handle == ORBIS_NP_TROPHY_INVALID_HANDLE) + return ORBIS_NP_TROPHY_ERROR_INVALID_HANDLE; + + if (flags == nullptr || count == nullptr) + return ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT; + + // flags->flag_bits = 0u; *count = 0; return ORBIS_OK; } @@ -239,8 +279,16 @@ int PS4_SYSV_ABI sceNpTrophyNumInfoGetTotal() { return ORBIS_OK; } -int PS4_SYSV_ABI sceNpTrophyRegisterContext() { +int PS4_SYSV_ABI sceNpTrophyRegisterContext(OrbisNpTrophyContext context, + OrbisNpTrophyHandle handle, uint64_t options) { LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); + + if (context == ORBIS_NP_TROPHY_INVALID_CONTEXT) + return ORBIS_NP_TROPHY_ERROR_INVALID_CONTEXT; + + if (handle == ORBIS_NP_TROPHY_INVALID_HANDLE) + return ORBIS_NP_TROPHY_ERROR_INVALID_HANDLE; + return ORBIS_OK; } @@ -254,7 +302,8 @@ int PS4_SYSV_ABI sceNpTrophySetInfoGetTrophyNum() { return ORBIS_OK; } -int PS4_SYSV_ABI sceNpTrophyShowTrophyList() { +int PS4_SYSV_ABI sceNpTrophyShowTrophyList(OrbisNpTrophyContext context, + OrbisNpTrophyHandle handle) { LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); return ORBIS_OK; } @@ -474,8 +523,73 @@ int PS4_SYSV_ABI sceNpTrophySystemSetDbgParamInt() { return ORBIS_OK; } -int PS4_SYSV_ABI sceNpTrophyUnlockTrophy() { - LOG_ERROR(Lib_NpTrophy, "(STUBBED) called"); +int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyId trophyId, OrbisNpTrophyId* platinumId) { + LOG_INFO(Lib_NpTrophy, "Unlocking trophy id {}", trophyId); + + if (context == ORBIS_NP_TROPHY_INVALID_CONTEXT) + return ORBIS_NP_TROPHY_ERROR_INVALID_CONTEXT; + + if (handle == ORBIS_NP_TROPHY_INVALID_HANDLE) + return ORBIS_NP_TROPHY_ERROR_INVALID_HANDLE; + + if (trophyId >= 127) + return ORBIS_NP_TROPHY_ERROR_INVALID_TROPHY_ID; + + if (platinumId == nullptr) + return ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT; + +#ifdef _WIN32 + const auto trophyDir = + Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) / game_serial / "TrophyFiles"; +#else + const auto trophyDir = + Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) / game_serial / "TrophyFiles"; +#endif + + pugi::xml_document doc; + pugi::xml_parse_result result = + doc.load_file((trophyDir.string() + "\\trophy00\\Xml\\TROP.XML").c_str()); + + // only do this if platinum is not unlocked + *platinumId = ORBIS_NP_TROPHY_INVALID_TROPHY_ID; + // check if all trophies are unlocked and if they are unlock plat and set its ID + + if (result) { + bool foundTrophy = false; + auto trophyconf = doc.child("trophyconf"); + for (pugi::xml_node_iterator it = trophyconf.children().begin(); + it != trophyconf.children().end() && !foundTrophy; ++it) { + + std::string childTrophyId = reinterpret_cast(it->attribute("id").value()); + std::string childTrophyName = reinterpret_cast(it->name()); + std::string childTrophyType = + reinterpret_cast(it->attribute("ttype").value()); + std::string childTrophyUnlockState = + reinterpret_cast(it->attribute("unlockstate").value()); + + if (std::string(childTrophyName) == "trophy" && std::stoi(childTrophyId) == trophyId) { + LOG_INFO(Lib_NpTrophy, "Found trophy to unlock {} : {}", + it->child("name").text().as_string(), + it->child("detail").text().as_string()); + if (childTrophyUnlockState == "unlocked") { + LOG_INFO(Lib_NpTrophy, "Trophy already unlocked"); + return ORBIS_NP_TROPHY_ERROR_TROPHY_ALREADY_UNLOCKED; + } else { + if (std::string(it->attribute("unlockstate").value()).empty()) { + it->append_attribute("unlockstate") = "unlocked"; + } else { + it->attribute("unlockstate").set_value("unlocked"); + } + + doc.save_file((trophyDir.string() + "\\trophy00\\Xml\\TROP.XML").c_str()); + } + foundTrophy = true; + } + } + } else + LOG_INFO(Lib_NpTrophy, "couldnt parse xml : {}", result.description()); + return ORBIS_OK; } diff --git a/src/core/libraries/np_trophy/np_trophy.h b/src/core/libraries/np_trophy/np_trophy.h index d05d353f1..8062ec6d9 100644 --- a/src/core/libraries/np_trophy/np_trophy.h +++ b/src/core/libraries/np_trophy/np_trophy.h @@ -4,6 +4,7 @@ #pragma once #include "common/types.h" +#include "core/libraries/rtc/rtc.h" namespace Core::Loader { class SymbolsResolver; @@ -11,7 +12,110 @@ class SymbolsResolver; namespace Libraries::NpTrophy { -int PS4_SYSV_ABI sceNpTrophyAbortHandle(); +extern std::string game_serial; + +constexpr int ORBIS_NP_TROPHY_FLAG_SETSIZE = 128; +constexpr int ORBIS_NP_TROPHY_FLAG_BITS_SHIFT = 5; + +constexpr int ORBIS_NP_TROPHY_GAME_TITLE_MAX_SIZE = 128; +constexpr int ORBIS_NP_TROPHY_GAME_DESCR_MAX_SIZE = 1024; +constexpr int ORBIS_NP_TROPHY_GROUP_TITLE_MAX_SIZE = 128; +constexpr int ORBIS_NP_TROPHY_GROUP_DESCR_MAX_SIZE = 1024; +constexpr int ORBIS_NP_TROPHY_NAME_MAX_SIZE = 128; +constexpr int ORBIS_NP_TROPHY_DESCR_MAX_SIZE = 1024; +constexpr int ORBIS_NP_TROPHY_NUM_MAX = 128; + +constexpr int ORBIS_NP_TROPHY_INVALID_HANDLE = -1; +constexpr int ORBIS_NP_TROPHY_INVALID_CONTEXT = -1; +constexpr int ORBIS_NP_TROPHY_INVALID_TROPHY_ID = -1; + +typedef int32_t OrbisNpTrophyHandle; +typedef int32_t OrbisNpTrophyContext; +typedef int32_t OrbisNpTrophyId; +typedef uint32_t OrbisNpTrophyFlagMask; + +struct OrbisNpTrophyFlagArray { + OrbisNpTrophyFlagMask + flag_bits[ORBIS_NP_TROPHY_FLAG_SETSIZE >> ORBIS_NP_TROPHY_FLAG_BITS_SHIFT]; +}; + +struct OrbisNpTrophyData { + size_t size; + OrbisNpTrophyId trophyId; + bool unlocked; + uint8_t reserved[3]; + Rtc::OrbisRtcTick timestamp; +}; + +typedef int32_t OrbisNpTrophyGrade; +constexpr int ORBIS_NP_TROPHY_GRADE_UNKNOWN = 0; +constexpr int ORBIS_NP_TROPHY_GRADE_PLATINUM = 1; +constexpr int ORBIS_NP_TROPHY_GRADE_GOLD = 2; +constexpr int ORBIS_NP_TROPHY_GRADE_SILVER = 3; +constexpr int ORBIS_NP_TROPHY_GRADE_BRONZE = 4; + +typedef int32_t OrbisNpTrophyGroupId; +constexpr int ORBIS_NP_TROPHY_BASE_GAME_GROUP_ID = -1; +constexpr int ORBIS_NP_TROPHY_INVALID_GROUP_ID = -2; + +struct OrbisNpTrophyDetails { + size_t size; + OrbisNpTrophyId trophyId; + OrbisNpTrophyGrade trophyGrade; + OrbisNpTrophyGroupId groupId; + bool hidden; + uint8_t reserved[3]; + char name[ORBIS_NP_TROPHY_NAME_MAX_SIZE]; + char description[ORBIS_NP_TROPHY_DESCR_MAX_SIZE]; +}; + +struct OrbisNpTrophyGameData { + size_t size; + uint32_t unlockedTrophies; + uint32_t unlockedPlatinum; + uint32_t unlockedGold; + uint32_t unlockedSilver; + uint32_t unlockedBronze; + uint32_t progressPercentage; +}; + +struct OrbisNpTrophyGameDetails { + size_t size; + uint32_t numGroups; + uint32_t numTrophies; + uint32_t numPlatinum; + uint32_t numGold; + uint32_t numSilver; + uint32_t numBronze; + char title[ORBIS_NP_TROPHY_GAME_TITLE_MAX_SIZE]; + char description[ORBIS_NP_TROPHY_GAME_DESCR_MAX_SIZE]; +}; + +struct OrbisNpTrophyGroupData { + size_t size; + OrbisNpTrophyGroupId groupId; + uint32_t unlockedTrophies; + uint32_t unlockedPlatinum; + uint32_t unlockedGold; + uint32_t unlockedSilver; + uint32_t unlockedBronze; + uint32_t progressPercentage; + uint8_t reserved[4]; +}; + +struct OrbisNpTrophyGroupDetails { + size_t size; + OrbisNpTrophyGroupId groupId; + uint32_t numTrophies; + uint32_t numPlatinum; + uint32_t numGold; + uint32_t numSilver; + uint32_t numBronze; + char title[ORBIS_NP_TROPHY_GROUP_TITLE_MAX_SIZE]; + char description[ORBIS_NP_TROPHY_GROUP_DESCR_MAX_SIZE]; +}; + +int PS4_SYSV_ABI sceNpTrophyAbortHandle(OrbisNpTrophyHandle handle); int PS4_SYSV_ABI sceNpTrophyCaptureScreenshot(); int PS4_SYSV_ABI sceNpTrophyConfigGetTrophyDetails(); int PS4_SYSV_ABI sceNpTrophyConfigGetTrophyFlagArray(); @@ -22,18 +126,30 @@ int PS4_SYSV_ABI sceNpTrophyConfigGetTrophySetInfoInGroup(); int PS4_SYSV_ABI sceNpTrophyConfigGetTrophySetVersion(); int PS4_SYSV_ABI sceNpTrophyConfigGetTrophyTitleDetails(); int PS4_SYSV_ABI sceNpTrophyConfigHasGroupFeature(); -s32 PS4_SYSV_ABI sceNpTrophyCreateContext(u32* context, u32 user_id, u32 service_label, - u64 options); -s32 PS4_SYSV_ABI sceNpTrophyCreateHandle(u32* handle); -int PS4_SYSV_ABI sceNpTrophyDestroyContext(); -s32 PS4_SYSV_ABI sceNpTrophyDestroyHandle(u32 handle); -int PS4_SYSV_ABI sceNpTrophyGetGameIcon(); -int PS4_SYSV_ABI sceNpTrophyGetGameInfo(); -int PS4_SYSV_ABI sceNpTrophyGetGroupIcon(); -int PS4_SYSV_ABI sceNpTrophyGetGroupInfo(); -int PS4_SYSV_ABI sceNpTrophyGetTrophyIcon(); -int PS4_SYSV_ABI sceNpTrophyGetTrophyInfo(); -s32 PS4_SYSV_ABI sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, u32* flags, u32* count); +s32 PS4_SYSV_ABI sceNpTrophyCreateContext(OrbisNpTrophyContext* context, int32_t user_id, + uint32_t service_label, uint64_t options); +s32 PS4_SYSV_ABI sceNpTrophyCreateHandle(OrbisNpTrophyHandle* handle); +int PS4_SYSV_ABI sceNpTrophyDestroyContext(OrbisNpTrophyContext context); +s32 PS4_SYSV_ABI sceNpTrophyDestroyHandle(OrbisNpTrophyHandle handle); +int PS4_SYSV_ABI sceNpTrophyGetGameIcon(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + void* buffer, size_t* size); +int PS4_SYSV_ABI sceNpTrophyGetGameInfo(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyGameDetails* details, + OrbisNpTrophyGameData* data); +int PS4_SYSV_ABI sceNpTrophyGetGroupIcon(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyGroupId groupId, void* buffer, size_t* size); +int PS4_SYSV_ABI sceNpTrophyGetGroupInfo(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyGroupId groupId, + OrbisNpTrophyGroupDetails* details, + OrbisNpTrophyGroupData* data); +int PS4_SYSV_ABI sceNpTrophyGetTrophyIcon(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyId trophyId, void* buffer, size_t* size); +int PS4_SYSV_ABI sceNpTrophyGetTrophyInfo(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyId trophyId, OrbisNpTrophyDetails* details, + OrbisNpTrophyData* data); +s32 PS4_SYSV_ABI sceNpTrophyGetTrophyUnlockState(OrbisNpTrophyContext context, + OrbisNpTrophyHandle handle, + OrbisNpTrophyFlagArray* flags, u32* count); int PS4_SYSV_ABI sceNpTrophyGroupArrayGetNum(); int PS4_SYSV_ABI sceNpTrophyIntAbortHandle(); int PS4_SYSV_ABI sceNpTrophyIntCheckNetSyncTitles(); @@ -47,10 +163,12 @@ int PS4_SYSV_ABI sceNpTrophyIntGetTrpIconByUri(); int PS4_SYSV_ABI sceNpTrophyIntNetSyncTitle(); int PS4_SYSV_ABI sceNpTrophyIntNetSyncTitles(); int PS4_SYSV_ABI sceNpTrophyNumInfoGetTotal(); -int PS4_SYSV_ABI sceNpTrophyRegisterContext(); +int PS4_SYSV_ABI sceNpTrophyRegisterContext(OrbisNpTrophyContext context, + OrbisNpTrophyHandle handle, uint64_t options); int PS4_SYSV_ABI sceNpTrophySetInfoGetTrophyFlagArray(); int PS4_SYSV_ABI sceNpTrophySetInfoGetTrophyNum(); -int PS4_SYSV_ABI sceNpTrophyShowTrophyList(); +int PS4_SYSV_ABI sceNpTrophyShowTrophyList(OrbisNpTrophyContext context, + OrbisNpTrophyHandle handle); int PS4_SYSV_ABI sceNpTrophySystemAbortHandle(); int PS4_SYSV_ABI sceNpTrophySystemBuildGroupIconUri(); int PS4_SYSV_ABI sceNpTrophySystemBuildNetTrophyIconUri(); @@ -94,7 +212,8 @@ int PS4_SYSV_ABI sceNpTrophySystemRemoveTitleData(); int PS4_SYSV_ABI sceNpTrophySystemRemoveUserData(); int PS4_SYSV_ABI sceNpTrophySystemSetDbgParam(); int PS4_SYSV_ABI sceNpTrophySystemSetDbgParamInt(); -int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(); +int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(OrbisNpTrophyContext context, OrbisNpTrophyHandle handle, + OrbisNpTrophyId trophyId, OrbisNpTrophyId* platinumId); int PS4_SYSV_ABI Func_149656DA81D41C59(); int PS4_SYSV_ABI Func_9F80071876FFA5F6(); int PS4_SYSV_ABI Func_F8EF6F5350A91990(); diff --git a/src/emulator.cpp b/src/emulator.cpp index a469a31ce..2203b1129 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -25,6 +25,7 @@ #include "core/libraries/libc_internal/libc_internal.h" #include "core/libraries/libs.h" #include "core/libraries/ngs2/ngs2.h" +#include "core/libraries/np_trophy/np_trophy.h" #include "core/libraries/rtc/rtc.h" #include "core/libraries/videoout/video_out.h" #include "core/linker.h" @@ -99,6 +100,7 @@ void Emulator::Run(const std::filesystem::path& file) { auto* param_sfo = Common::Singleton::Instance(); param_sfo->open(sce_sys_folder.string() + "/param.sfo", {}); id = std::string(param_sfo->GetString("CONTENT_ID"), 7, 9); + Libraries::NpTrophy::game_serial = id; #ifdef ENABLE_QT_GUI MemoryPatcher::g_game_serial = id; #endif