mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 17:02:40 +00:00
Implement sceNpCmp functions
Adds sceNpCmpNpId, sceNpCmpNpIdInOrder, and sceNpCmpOnlineId based on decomp
This commit is contained in:
parent
f2c3010eb4
commit
2337c4a685
@ -1,26 +1,88 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "np_common.h"
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/libraries/error_codes.h"
|
||||
#include "core/libraries/libs.h"
|
||||
#include "core/libraries/np_common/np_common.h"
|
||||
|
||||
namespace Libraries::NpCommon {
|
||||
|
||||
int PS4_SYSV_ABI sceNpCmpNpId(const char* np_id1, const char* np_id2) {
|
||||
LOG_ERROR(Lib_NpCommon, "(STUBBED) called");
|
||||
int PS4_SYSV_ABI sceNpCmpNpId(OrbisNpId* np_id1, OrbisNpId* np_id2) {
|
||||
if (np_id1 == nullptr || np_id2 == nullptr) {
|
||||
return ORBIS_NP_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
//Compare data
|
||||
if (std::strncmp(np_id1->handle.data, np_id2->handle.data, ORBIS_NP_ONLINEID_MAX_LENGTH) != 0) {
|
||||
return ORBIS_NP_UTIL_ERROR_NOT_MATCH;
|
||||
}
|
||||
|
||||
//Compare opt
|
||||
for (u32 i = 0; i < 8; i++) {
|
||||
if (np_id1->opt[i] != np_id2->opt[i]) {
|
||||
return ORBIS_NP_UTIL_ERROR_NOT_MATCH;
|
||||
}
|
||||
}
|
||||
|
||||
//Compare reserved
|
||||
for (u32 i = 0; i < 8; i++) {
|
||||
if (np_id1->reserved[i] != np_id2->reserved[i]) {
|
||||
return ORBIS_NP_UTIL_ERROR_NOT_MATCH;
|
||||
}
|
||||
}
|
||||
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceNpCmpNpIdInOrder(const char* np_id1, const char* np_id2, u32* out_result) {
|
||||
LOG_ERROR(Lib_NpCommon, "(STUBBED) called");
|
||||
int PS4_SYSV_ABI sceNpCmpNpIdInOrder(OrbisNpId* np_id1, OrbisNpId* np_id2, u32* out_result) {
|
||||
if (np_id1 == nullptr || np_id2 == nullptr || out_result == nullptr) {
|
||||
return ORBIS_NP_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
//Compare data
|
||||
u32 compare = std::strncmp(np_id1->handle.data, np_id2->handle.data, ORBIS_NP_ONLINEID_MAX_LENGTH);
|
||||
if (compare < 0) {
|
||||
*out_result = -1;
|
||||
return ORBIS_OK;
|
||||
} else if (compare > 0) {
|
||||
*out_result = 1;
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
//Compare opt
|
||||
for (u32 i = 0; i < 8; i++) {
|
||||
if (np_id1->opt[i] < np_id2->opt[i]) {
|
||||
*out_result = -1;
|
||||
return ORBIS_OK;
|
||||
} else if (np_id1->opt[i] > np_id2->opt[i]) {
|
||||
*out_result = 1;
|
||||
return ORBIS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
//Compare reserved
|
||||
for (u32 i = 0; i < 8; i++) {
|
||||
if (np_id1->reserved[i] < np_id2->reserved[i]) {
|
||||
*out_result = -1;
|
||||
return ORBIS_OK;
|
||||
} else if (np_id1->reserved[i] > np_id2->reserved[i]) {
|
||||
*out_result = 1;
|
||||
return ORBIS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceNpCmpOnlineId(const char* online_id1, const char* online_id2) {
|
||||
LOG_ERROR(Lib_NpCommon, "(STUBBED) called");
|
||||
int PS4_SYSV_ABI sceNpCmpOnlineId(OrbisNpOnlineId* online_id1, OrbisNpOnlineId* online_id2) {
|
||||
if (online_id1 == nullptr || online_id2 == nullptr) {
|
||||
return ORBIS_NP_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (std::strncmp(online_id1->data, online_id2->data, ORBIS_NP_ONLINEID_MAX_LENGTH) != 0) {
|
||||
return ORBIS_NP_UTIL_ERROR_NOT_MATCH;
|
||||
}
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/types.h"
|
||||
#include "common/types.h"
|
||||
|
||||
namespace Core::Loader {
|
||||
class SymbolsResolver;
|
||||
@ -11,9 +11,26 @@ class SymbolsResolver;
|
||||
|
||||
namespace Libraries::NpCommon {
|
||||
|
||||
int PS4_SYSV_ABI sceNpCmpNpId(const char* np_id1, const char* np_id2);
|
||||
int PS4_SYSV_ABI sceNpCmpNpIdInOrder(const char* np_id1, const char* np_id2, u32* out_result);
|
||||
int PS4_SYSV_ABI sceNpCmpOnlineId(const char* online_id1, const char* online_id2);
|
||||
constexpr int ORBIS_NP_ERROR_INVALID_ARGUMENT = 0x80550003;
|
||||
constexpr int ORBIS_NP_UTIL_ERROR_NOT_MATCH = 0x80550609;
|
||||
|
||||
constexpr int ORBIS_NP_ONLINEID_MAX_LENGTH = 16;
|
||||
|
||||
struct OrbisNpOnlineId {
|
||||
char data[ORBIS_NP_ONLINEID_MAX_LENGTH];
|
||||
char term;
|
||||
char dummy[3];
|
||||
};
|
||||
|
||||
struct OrbisNpId {
|
||||
OrbisNpOnlineId handle;
|
||||
u8 opt[8];
|
||||
u8 reserved[8];
|
||||
};
|
||||
|
||||
int PS4_SYSV_ABI sceNpCmpNpId(OrbisNpId* np_id1, OrbisNpId* np_id2);
|
||||
int PS4_SYSV_ABI sceNpCmpNpIdInOrder(OrbisNpId* np_id1, OrbisNpId* np_id2, u32* out_result);
|
||||
int PS4_SYSV_ABI sceNpCmpOnlineId(OrbisNpOnlineId* online_id1, OrbisNpOnlineId* online_id2);
|
||||
int PS4_SYSV_ABI _sceNpAllocatorExConvertAllocator();
|
||||
int PS4_SYSV_ABI _sceNpAllocatorExFree();
|
||||
int PS4_SYSV_ABI _sceNpAllocatorExMalloc();
|
||||
|
@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/config.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/libraries/error_codes.h"
|
||||
#include "core/libraries/libs.h"
|
||||
|
Loading…
Reference in New Issue
Block a user