From ecad6cd1a70d6b79846a00eb038e7d8b701e70b6 Mon Sep 17 00:00:00 2001 From: raziel1000 Date: Wed, 10 Jul 2024 23:57:58 -0600 Subject: [PATCH 1/9] - sceSaveDataDirNameSearch wip, needs testing and more work. --- src/core/libraries/save_data/savedata.cpp | 37 ++++++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/core/libraries/save_data/savedata.cpp b/src/core/libraries/save_data/savedata.cpp index 7d12ed81..7fa6c7c0 100644 --- a/src/core/libraries/save_data/savedata.cpp +++ b/src/core/libraries/save_data/savedata.cpp @@ -177,12 +177,39 @@ int PS4_SYSV_ABI sceSaveDataDeleteUser() { int PS4_SYSV_ABI sceSaveDataDirNameSearch(const OrbisSaveDataDirNameSearchCond* cond, OrbisSaveDataDirNameSearchResult* result) { - if (cond == nullptr || cond->dirName == nullptr) + if (cond == nullptr) return ORBIS_SAVE_DATA_ERROR_PARAMETER; - LOG_ERROR(Lib_SaveData, - "TODO sceSaveDataDirNameSearch: search_dir_name = {}, key = {}, result = {}", - cond->dirName->data, (int)cond->key, (result->infos == nullptr)); - + LOG_ERROR(Lib_SaveData, "TODO sceSaveDataDirNameSearch: Add params"); + const auto& mount_dir = Common::FS::GetUserPath(Common::FS::PathType::SaveDataDir) / + std::to_string(cond->userId) / game_serial; + if (!mount_dir.empty() && std::filesystem::exists(mount_dir)) { + if (cond->dirName == nullptr) { // look for all dirs if no dir is provided. + for (int i = 0; const auto& entry : std::filesystem::directory_iterator(mount_dir)) { + if (std::filesystem::is_directory(entry.path())) { + i++; + result->dirNamesNum = 0; // why is it 1024? is it max? + // copy dir name to be used by sceSaveDataMount in read mode. + strncpy(result->dirNames[i].data, entry.path().filename().string().c_str(), 32); + result->hitNum = i + 1; + result->dirNamesNum = i + 1; // to confirm + result->setNum = i + 1; // to confirm + } + } + } else { // Need a game to test. + strncpy(result->dirNames[0].data, cond->dirName->data, 32); + result->hitNum = 1; + result->dirNamesNum = 1; // to confirm + result->setNum = 1; // to confirm + } + } else { + result->hitNum = 0; + result->dirNamesNum = 0; + result->setNum = 0; + } + if (result->infos != nullptr) { + result->infos->blocks = ORBIS_SAVE_DATA_BLOCK_SIZE; + result->infos->freeBlocks = ORBIS_SAVE_DATA_BLOCK_SIZE; + } return ORBIS_OK; } From 4de9d9cf0d82893190f31bd434a977915bc3a573 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Thu, 11 Jul 2024 19:31:39 +0300 Subject: [PATCH 2/9] dataformat used by DMC4 --- src/video_core/renderer_vulkan/liverpool_to_vk.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video_core/renderer_vulkan/liverpool_to_vk.cpp b/src/video_core/renderer_vulkan/liverpool_to_vk.cpp index 4280e6e6..74c4ffe8 100644 --- a/src/video_core/renderer_vulkan/liverpool_to_vk.cpp +++ b/src/video_core/renderer_vulkan/liverpool_to_vk.cpp @@ -441,6 +441,10 @@ vk::Format SurfaceFormat(AmdGpu::DataFormat data_format, AmdGpu::NumberFormat nu num_format == AmdGpu::NumberFormat::Unorm) { return vk::Format::eR16G16B16A16Unorm; } + if (data_format == AmdGpu::DataFormat::Format16_16 && + num_format == AmdGpu::NumberFormat::Uint) { + return vk::Format::eR16G16Uint; + } UNREACHABLE_MSG("Unknown data_format={} and num_format={}", u32(data_format), u32(num_format)); } From b07bbecab4f9cacc8566c04a376296c0018aa93d Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 12 Jul 2024 15:19:41 +0300 Subject: [PATCH 3/9] replace unreachable with default return in sceKernelClockGettime --- src/core/libraries/kernel/time_management.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/libraries/kernel/time_management.cpp b/src/core/libraries/kernel/time_management.cpp index fbbcfdcf..d0c0a1e4 100644 --- a/src/core/libraries/kernel/time_management.cpp +++ b/src/core/libraries/kernel/time_management.cpp @@ -97,7 +97,8 @@ int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) { pclock_id = CLOCK_MONOTONIC; break; default: - UNREACHABLE(); + LOG_ERROR(Lib_Kernel, "unsupported = {} using CLOCK_REALTIME", clock_id); + break; } timespec t{}; From 056dcf52ca973dc8cfce2e552a098a3fc653d696 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 12 Jul 2024 16:27:50 +0300 Subject: [PATCH 4/9] initial ime dialog handling --- src/core/libraries/dialogs/ime_dialog.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/libraries/dialogs/ime_dialog.cpp b/src/core/libraries/dialogs/ime_dialog.cpp index 89136a03..5e2c2ffc 100644 --- a/src/core/libraries/dialogs/ime_dialog.cpp +++ b/src/core/libraries/dialogs/ime_dialog.cpp @@ -9,6 +9,8 @@ namespace Libraries::ImeDialog { +static OrbisImeDialogStatus g_ime_dlg_status = OrbisImeDialogStatus::ORBIS_IME_DIALOG_STATUS_NONE; + int PS4_SYSV_ABI sceImeDialogAbort() { LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); return ORBIS_OK; @@ -45,18 +47,22 @@ int PS4_SYSV_ABI sceImeDialogGetPanelSizeExtended() { } int PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result) { + result->endstatus = OrbisImeDialogEndStatus::ORBIS_IME_DIALOG_END_STATUS_OK; LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); return ORBIS_OK; } int PS4_SYSV_ABI sceImeDialogGetStatus() { - LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); - return ORBIS_OK; + if (g_ime_dlg_status == OrbisImeDialogStatus::ORBIS_IME_DIALOG_STATUS_RUNNING) { + return OrbisImeDialogStatus::ORBIS_IME_DIALOG_STATUS_FINISHED; + } + return g_ime_dlg_status; } int PS4_SYSV_ABI sceImeDialogInit(const OrbisImeDialogParam* param, const OrbisImeParamExtended* extended) { LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); + g_ime_dlg_status = OrbisImeDialogStatus::ORBIS_IME_DIALOG_STATUS_RUNNING; return ORBIS_OK; } @@ -82,6 +88,7 @@ int PS4_SYSV_ABI sceImeDialogSetPanelPosition() { int PS4_SYSV_ABI sceImeDialogTerm() { LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); + g_ime_dlg_status = OrbisImeDialogStatus::ORBIS_IME_DIALOG_STATUS_NONE; return ORBIS_OK; } From 02cba0100d08b84963bd6536e4b3239a8664970b Mon Sep 17 00:00:00 2001 From: raziel1000 Date: Sun, 14 Jul 2024 00:34:48 -0600 Subject: [PATCH 5/9] Some functions called by Stardew Valley --- src/core/libraries/kernel/file_system.cpp | 1 + src/core/libraries/kernel/libkernel.cpp | 5 ++++ .../libraries/kernel/thread_management.cpp | 25 +++++++++++++++++++ src/core/libraries/kernel/thread_management.h | 1 + 4 files changed, 32 insertions(+) diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index eb6248d0..466399e1 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -464,6 +464,7 @@ void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen); LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open); LIB_FUNCTION("UK2Tl2DWUns", "libkernel", 1, "libkernel", 1, 1, sceKernelClose); + LIB_FUNCTION("bY-PO6JhzhQ", "libkernel", 1, "libkernel", 1, 1, posix_close); LIB_FUNCTION("bY-PO6JhzhQ", "libScePosix", 1, "libkernel", 1, 1, posix_close); LIB_FUNCTION("4wSze92BhLI", "libkernel", 1, "libkernel", 1, 1, sceKernelWrite); diff --git a/src/core/libraries/kernel/libkernel.cpp b/src/core/libraries/kernel/libkernel.cpp index 9f57ff53..fbf86cdf 100644 --- a/src/core/libraries/kernel/libkernel.cpp +++ b/src/core/libraries/kernel/libkernel.cpp @@ -351,6 +351,10 @@ int PS4_SYSV_ABI _sigprocmask() { return ORBIS_OK; } +int PS4_SYSV_ABI posix_getpagesize() { + return 4096; +} + void LibKernel_Register(Core::Loader::SymbolsResolver* sym) { service_thread = std::jthread{KernelServiceThread}; @@ -414,6 +418,7 @@ void LibKernel_Register(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("-o5uEDpN+oY", "libkernel", 1, "libkernel", 1, 1, sceKernelConvertUtcToLocaltime); LIB_FUNCTION("WB66evu8bsU", "libkernel", 1, "libkernel", 1, 1, sceKernelGetCompiledSdkVersion); LIB_FUNCTION("DRuBt2pvICk", "libkernel", 1, "libkernel", 1, 1, ps4__read); + LIB_FUNCTION("k+AXqu2-eBc", "libScePosix", 1, "libkernel", 1, 1, posix_getpagesize); Libraries::Kernel::fileSystemSymbolsRegister(sym); Libraries::Kernel::timeSymbolsRegister(sym); diff --git a/src/core/libraries/kernel/thread_management.cpp b/src/core/libraries/kernel/thread_management.cpp index b31e777d..a0e0e8f2 100644 --- a/src/core/libraries/kernel/thread_management.cpp +++ b/src/core/libraries/kernel/thread_management.cpp @@ -1331,6 +1331,26 @@ int PS4_SYSV_ABI scePthreadSetprio(ScePthread thread, int prio) { return ORBIS_OK; } +int PS4_SYSV_ABI posix_pthread_condattr_init(ScePthreadCondattr* attr) { + int result = scePthreadCondattrInit(attr); + LOG_INFO(Kernel_Pthread, + "posix_pthread_condattr_init redirect to scePthreadCondattrInit, result = {}", result); + return result; +} + +int PS4_SYSV_ABI posix_pthread_condattr_destroy(ScePthreadCondattr* attr) { + int result = scePthreadCondattrDestroy(attr); + LOG_INFO(Kernel_Pthread, + "posix_pthread_condattr_destroy redirect to scePthreadCondattrDestroy, result = {}", + result); + return result; +} + +int PS4_SYSV_ABI posix_pthread_condattr_setclock(ScePthreadCondattr* attr, clockid_t clock) { + (*attr)->clock = clock; + return SCE_OK; +} + void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("lZzFeSxPl08", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_setcancelstate); LIB_FUNCTION("0TyVk4MSLt0", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_cond_init); @@ -1418,6 +1438,11 @@ void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) { posix_pthread_mutexattr_setprotocol); LIB_FUNCTION("HF7lK46xzjY", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutexattr_destroy); + LIB_FUNCTION("mKoTx03HRWA", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_condattr_init); + LIB_FUNCTION("dJcuQVn6-Iw", "libScePosix", 1, "libkernel", 1, 1, + posix_pthread_condattr_destroy); + LIB_FUNCTION("EjllaAqAPZo", "libScePosix", 1, "libkernel", 1, 1, + posix_pthread_condattr_setclock); // openorbis weird functions LIB_FUNCTION("7H0iTOciTLo", "libkernel", 1, "libkernel", 1, 1, posix_pthread_mutex_lock); diff --git a/src/core/libraries/kernel/thread_management.h b/src/core/libraries/kernel/thread_management.h index 9926b379..8303c9ef 100644 --- a/src/core/libraries/kernel/thread_management.h +++ b/src/core/libraries/kernel/thread_management.h @@ -92,6 +92,7 @@ struct PthreadCondInternal { struct PthreadCondAttrInternal { u8 reserved[64]; pthread_condattr_t cond_attr; + clockid_t clock; }; struct PthreadRwLockAttrInternal { From 250bfbb494e4719cdb71e5a2cefc8781c80b95ea Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Thu, 18 Jul 2024 18:19:46 +0300 Subject: [PATCH 6/9] Update liverpool_to_vk.cpp --- src/video_core/renderer_vulkan/liverpool_to_vk.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/video_core/renderer_vulkan/liverpool_to_vk.cpp b/src/video_core/renderer_vulkan/liverpool_to_vk.cpp index a59fad08..954b6870 100644 --- a/src/video_core/renderer_vulkan/liverpool_to_vk.cpp +++ b/src/video_core/renderer_vulkan/liverpool_to_vk.cpp @@ -448,6 +448,7 @@ vk::Format SurfaceFormat(AmdGpu::DataFormat data_format, AmdGpu::NumberFormat nu if (data_format == AmdGpu::DataFormat::Format16_16 && num_format == AmdGpu::NumberFormat::Uint) { return vk::Format::eR16G16Uint; + } if (data_format == AmdGpu::DataFormat::Format8 && num_format == AmdGpu::NumberFormat::Uint) { return vk::Format::eR8Uint; } From c578ccc435e9995bdaf4dbf689cbcca9be380d1f Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Thu, 18 Jul 2024 18:34:08 +0300 Subject: [PATCH 7/9] load every available prx from sce_module folder of game --- src/emulator.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/emulator.cpp b/src/emulator.cpp index 91d92cd6..4e669e08 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -114,15 +114,11 @@ void Emulator::Run(const std::filesystem::path& file) { std::filesystem::path sce_module_folder = file.parent_path() / "sce_module"; if (std::filesystem::is_directory(sce_module_folder)) { for (const auto& entry : std::filesystem::directory_iterator(sce_module_folder)) { - if (entry.path().filename() == "libc.prx" || - entry.path().filename() == "libSceFios2.prx" || - entry.path().filename() == "libSceAudioLatencyEstimation.prx" || - entry.path().filename() == "libSceJobManager.prx" || - entry.path().filename() == "libSceS3DConversion.prx") { + if (entry.path().filename() == "libc.prx") { found = true; - LOG_INFO(Loader, "Loading {}", entry.path().string().c_str()); - linker->LoadModule(entry.path()); } + LOG_INFO(Loader, "Loading {}", entry.path().string().c_str()); + linker->LoadModule(entry.path()); } } } From d00a2465d53ad276a7ee2ecb31d429d759cf12e5 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 19 Jul 2024 08:50:55 +0300 Subject: [PATCH 8/9] update fixes for winpthreads --- externals/winpthreads | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/winpthreads b/externals/winpthreads index d937b600..f00c973a 160000 --- a/externals/winpthreads +++ b/externals/winpthreads @@ -1 +1 @@ -Subproject commit d937b60055aaea313422672ebd5cc8bfa87a1682 +Subproject commit f00c973a6ab2a23573708568b8ef4acc20a9d36b From fcc931956e0dae29f3eec4d554190aa016ba785e Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 19 Jul 2024 09:02:36 +0300 Subject: [PATCH 9/9] submodules updated --- externals/fmt | 2 +- externals/glslang | 2 +- externals/magic_enum | 2 +- externals/vma | 2 +- externals/vulkan-headers | 2 +- externals/xxhash | 2 +- externals/zydis | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/externals/fmt b/externals/fmt index a9625970..bc8d32e9 160000 --- a/externals/fmt +++ b/externals/fmt @@ -1 +1 @@ -Subproject commit a96259701e1d16e2f8c8299c668e863ec0ac0119 +Subproject commit bc8d32e9643d2be5fc070abf2a50bc021544545d diff --git a/externals/glslang b/externals/glslang index 5939e32b..52f68dc6 160000 --- a/externals/glslang +++ b/externals/glslang @@ -1 +1 @@ -Subproject commit 5939e32b87487fa9c72ab336ebfcc5ae26d9ab6d +Subproject commit 52f68dc6b2a9d017b43161f31f13a6f44636ee7c diff --git a/externals/magic_enum b/externals/magic_enum index ec1adc57..664ee62c 160000 --- a/externals/magic_enum +++ b/externals/magic_enum @@ -1 +1 @@ -Subproject commit ec1adc5763f684e0f32888b157bfc0b86021b8e9 +Subproject commit 664ee62c12570948b0e025d15b42d641fba8d54a diff --git a/externals/vma b/externals/vma index 257138b8..871913da 160000 --- a/externals/vma +++ b/externals/vma @@ -1 +1 @@ -Subproject commit 257138b8f5686ae84491a3df9f90a77d5660c3bd +Subproject commit 871913da6a4b132b567d7b65c509600363c0041e diff --git a/externals/vulkan-headers b/externals/vulkan-headers index 190d2cb2..b379292b 160000 --- a/externals/vulkan-headers +++ b/externals/vulkan-headers @@ -1 +1 @@ -Subproject commit 190d2cb24e90e5bf2bec0a75604a9b3586485b6d +Subproject commit b379292b2ab6df5771ba9870d53cf8b2c9295daf diff --git a/externals/xxhash b/externals/xxhash index 805c00b6..a57f6cce 160000 --- a/externals/xxhash +++ b/externals/xxhash @@ -1 +1 @@ -Subproject commit 805c00b68fa754200ada0c207ffeaa7a4409377c +Subproject commit a57f6cce2698049863af8c25787084ae0489d849 diff --git a/externals/zydis b/externals/zydis index 5a68f639..16c6a369 160000 --- a/externals/zydis +++ b/externals/zydis @@ -1 +1 @@ -Subproject commit 5a68f639e4f01604cc7bfc8d313f583a8137e3d3 +Subproject commit 16c6a369c193981e9cf314126589eaa8763f92c3