From e1542e9267c8ded58eed2375fabaf8420254106c Mon Sep 17 00:00:00 2001 From: Nemoumbra Date: Wed, 12 Feb 2025 19:26:33 +0300 Subject: [PATCH] Added the HLE implementations to the table + new wrappers --- Core/HLE/FunctionWrappers.h | 35 +++++++++++++++++++++ Core/HLE/sceNet_lib.cpp | 61 ++++++++++++++++++------------------- 2 files changed, 65 insertions(+), 31 deletions(-) diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index 7480e2f881..c420fa2a4a 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -513,6 +513,11 @@ template void WrapI_CUI() { RETURN(retval); } +template void WrapU_CUI() { + u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); + RETURN(retval); +} + template void WrapI_ICIU() { int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3)); RETURN(retval); @@ -864,3 +869,33 @@ template void WrapI_VUI(){ u32 retval = func(Memory::GetPointerWrite(PARAM(0)), PARAM(1), PARAM(2)); RETURN(retval); } + +template void WrapU_VUU() { + u32 retval = func(Memory::GetPointerWrite(PARAM(0)), PARAM(1), PARAM(2)); + RETURN(retval); +} + +template void WrapU_VC() { + u32 retval = func(Memory::GetPointerWrite(PARAM(0)), Memory::GetCharPointer(PARAM(1))); + RETURN(retval); +} + +template void WrapI_CCU() { + int retval = func(Memory::GetCharPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1)), PARAM(2)); + RETURN(retval); +} + +template void WrapI_CC() { + int retval = func(Memory::GetCharPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1))); + RETURN(retval); +} + +template void WrapU_VCU() { + u32 retval = func(Memory::GetPointerWrite(PARAM(0)), Memory::GetCharPointer(PARAM(1)), PARAM(2)); + RETURN(retval); +} + +template void WrapU_VI() { + u32 retval = func(Memory::GetPointerWrite(PARAM(0)), PARAM(1)); + RETURN(retval); +} diff --git a/Core/HLE/sceNet_lib.cpp b/Core/HLE/sceNet_lib.cpp index b90c336ef8..b287b8488d 100644 --- a/Core/HLE/sceNet_lib.cpp +++ b/Core/HLE/sceNet_lib.cpp @@ -28,8 +28,6 @@ u32 sceNetStrtoul(const char *str, u32 strEndAddrPtr, int base) { - // WrapU_CUI? - // Redirect that to libc char* str_end = nullptr; u32 res = std::strtoul(str, &str_end, base); @@ -42,8 +40,6 @@ u32 sceNetStrtoul(const char *str, u32 strEndAddrPtr, int base) { } u32 sceNetMemmove(void* dest, u32 srcPtr, u32 count) { - // WrapU_VUU? - // Redirect that to libc void* host_ptr = std::memmove( dest, Memory::GetPointer(srcPtr), count @@ -55,8 +51,6 @@ u32 sceNetMemmove(void* dest, u32 srcPtr, u32 count) { } u32 sceNetStrcpy(void* dest, const char *src) { - // WrapU_VC? - // Redirect that to libc char* host_ptr = std::strcpy(static_cast(dest), src); @@ -66,8 +60,6 @@ u32 sceNetStrcpy(void* dest, const char *src) { } s32 sceNetStrncmp(const char *lhs, const char *rhs, u32 count) { - // WrapI_CCU? - // Redirect that to libc s32 res = std::strncmp(lhs, rhs, count); @@ -75,8 +67,6 @@ s32 sceNetStrncmp(const char *lhs, const char *rhs, u32 count) { } s32 sceNetStrcasecmp(const char *lhs, const char *rhs) { - // WrapI_CC? - // Redirect that to eh... what is this, a libc extension? s32 res = strcasecmp(lhs, rhs); @@ -84,8 +74,6 @@ s32 sceNetStrcasecmp(const char *lhs, const char *rhs) { } s32 sceNetStrcmp(const char *lhs, const char *rhs) { - // WrapI_CC? - // Redirect that to libc s32 res = std::strcmp(lhs, rhs); @@ -93,8 +81,6 @@ s32 sceNetStrcmp(const char *lhs, const char *rhs) { } u32 sceNetStrncpy(void *dest, const char *src, u32 count) { - // WrapU_VCU? - // Redirect that to libc char* host_ptr = std::strncpy(static_cast(dest), src, count); @@ -103,33 +89,46 @@ u32 sceNetStrncpy(void *dest, const char *src, u32 count) { return res; } -u32 sceNetStrchr(char *str, int ch) { - // For some reason doesn't build for me if I make 'str' a const char - - // Wrap_CI +u32 sceNetStrchr(void *str, int ch) { + // For some reason it doesn't build for me if I make 'str' a const char * + // At the same time I can't make it char *, because then WrapU_CI won't work // Redirect that to libc - char* host_ptr = std::strchr(str, ch); + char* host_ptr = std::strchr(static_cast(str), ch); // Remap the pointer u32 res = Memory::GetAddressFromHostPointer(host_ptr); return res; } +u32 sceNetStrlen(const char* str) { + // Redirect that to libc + u32 res = std::strlen(str); + + return res; +} + +s32 sceNetMemcmp(u32 lhsPtr, u32 rhsPtr, u32 count) { + // Redirect that to libc + s32 res = std::memcmp(Memory::GetPointer(lhsPtr), Memory::GetPointer(rhsPtr), count); + + return res; +} + const HLEFunction sceNet_lib[] = { - {0X1858883D, nullptr, "sceNetRand", 'i', "" }, - {0X2A73ADDC, nullptr, "sceNetStrtoul", 'i', "" }, - {0X4753D878, nullptr, "sceNetMemmove", 'i', "" }, - {0X80C9F02A, nullptr, "sceNetStrcpy", 'i', "" }, - {0X94DCA9F0, nullptr, "sceNetStrncmp", 'i', "" }, - {0X9CFBC7E3, nullptr, "sceNetStrcasecmp", 'i', "" }, - {0XA0F16ABD, nullptr, "sceNetStrcmp", 'i', "" }, - {0XB5CE388A, nullptr, "sceNetStrncpy", 'i', "" }, - {0XBCBE14CF, nullptr, "sceNetStrchr", 'i', "" }, - {0XCF705E46, nullptr, "sceNetSprintf", 'i', "" }, - {0XD8722983, nullptr, "sceNetStrlen", 'i', "" }, - {0XE0A81C7C, nullptr, "sceNetMemcmp", 'i', "" }, + {0X1858883D, nullptr, "sceNetRand", 'i', "" }, + {0X2A73ADDC, &WrapU_CUI, "sceNetStrtoul", 'i', "" }, + {0X4753D878, &WrapU_VUU, "sceNetMemmove", 'i', "" }, + {0X80C9F02A, &WrapU_VC, "sceNetStrcpy", 'i', "" }, + {0X94DCA9F0, &WrapI_CCU, "sceNetStrncmp", 'i', "" }, + {0X9CFBC7E3, &WrapI_CC, "sceNetStrcasecmp", 'i', "" }, + {0XA0F16ABD, &WrapI_CC, "sceNetStrcmp", 'i', "" }, + {0XB5CE388A, &WrapU_VCU, "sceNetStrncpy", 'i', "" }, + {0XBCBE14CF, &WrapU_VI, "sceNetStrchr", 'i', "" }, + {0XCF705E46, nullptr, "sceNetSprintf", 'i', "" }, + {0XD8722983, &WrapU_C, "sceNetStrlen", 'i', "" }, + {0XE0A81C7C, &WrapI_UUU, "sceNetMemcmp", 'i', "" }, };