From 13cd22aea6753bc529228602d82bf23a1aba1637 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 10 Jun 2024 14:04:32 +0300 Subject: [PATCH 1/9] depedencies updates and fixes --- externals/cryptopp | 2 +- externals/cryptopp-cmake | 2 +- externals/fmt | 2 +- externals/glslang | 2 +- externals/magic_enum | 2 +- externals/sdl3 | 2 +- externals/sirit | 2 +- externals/vma | 2 +- externals/vulkan-headers | 2 +- externals/zlib-ng | 2 +- src/audio_core/sdl_audio.cpp | 3 +++ src/audio_core/sdl_audio.h | 3 +-- src/sdl_window.cpp | 6 +++++- 13 files changed, 19 insertions(+), 13 deletions(-) diff --git a/externals/cryptopp b/externals/cryptopp index 782057f5..9bb6680c 160000 --- a/externals/cryptopp +++ b/externals/cryptopp @@ -1 +1 @@ -Subproject commit 782057f5f18fbdad2bd2b291fb1ec558a8ab8225 +Subproject commit 9bb6680cfaedd3d46eff082ede8d0c76be6a2145 diff --git a/externals/cryptopp-cmake b/externals/cryptopp-cmake index 19cd13af..2c384c28 160000 --- a/externals/cryptopp-cmake +++ b/externals/cryptopp-cmake @@ -1 +1 @@ -Subproject commit 19cd13af5f7fa4904b174b81e98852283dbe8c1f +Subproject commit 2c384c28265a93358a2455e610e76393358794df diff --git a/externals/fmt b/externals/fmt index d2473b7b..18a325f3 160000 --- a/externals/fmt +++ b/externals/fmt @@ -1 +1 @@ -Subproject commit d2473b7b73c0af2a3ed34c99e50ace0a1040581a +Subproject commit 18a325f370ffd5ec1eda0087d2efc3dc9b3faf56 diff --git a/externals/glslang b/externals/glslang index 2b19bf7e..73eccd4b 160000 --- a/externals/glslang +++ b/externals/glslang @@ -1 +1 @@ -Subproject commit 2b19bf7e1bc0b60cf2fe9d33e5ba6b37dfc1cc83 +Subproject commit 73eccd4b67985d344578cade8958214cee0a3f6e diff --git a/externals/magic_enum b/externals/magic_enum index db0b726c..bf3c74ab 160000 --- a/externals/magic_enum +++ b/externals/magic_enum @@ -1 +1 @@ -Subproject commit db0b726c051f2d631b85793038677caf467a7cfe +Subproject commit bf3c74ab7eded2a7183a3729f5cd36bc367edb08 diff --git a/externals/sdl3 b/externals/sdl3 index bcbf09ac..4fc68a48 160000 --- a/externals/sdl3 +++ b/externals/sdl3 @@ -1 +1 @@ -Subproject commit bcbf09acdef71b550e837c8aaca67b08b6a38f0f +Subproject commit 4fc68a48f20574326eb18022eed0b7c0fa52a10e diff --git a/externals/sirit b/externals/sirit index 8c281cc0..fc65ebb5 160000 --- a/externals/sirit +++ b/externals/sirit @@ -1 +1 @@ -Subproject commit 8c281cc0b7cd638d3853a5aa2fc35b969fcbb599 +Subproject commit fc65ebb5b56b849b1205d5baa2ca38440096652d diff --git a/externals/vma b/externals/vma index eaf8fc27..7942b798 160000 --- a/externals/vma +++ b/externals/vma @@ -1 +1 @@ -Subproject commit eaf8fc27eeadf6f21b11183651b829e897f01957 +Subproject commit 7942b798289f752dc23b0a79516fd8545febd718 diff --git a/externals/vulkan-headers b/externals/vulkan-headers index 192d051d..d192041a 160000 --- a/externals/vulkan-headers +++ b/externals/vulkan-headers @@ -1 +1 @@ -Subproject commit 192d051db3382e213f8bd9d8048fc9eaa78ed6ab +Subproject commit d192041a2fc9c9fd8ae67d8ae3f32c5511541f04 diff --git a/externals/zlib-ng b/externals/zlib-ng index 1007e7a9..2e3e5f30 160000 --- a/externals/zlib-ng +++ b/externals/zlib-ng @@ -1 +1 @@ -Subproject commit 1007e7a9c74148fe915384d7cc44921559500241 +Subproject commit 2e3e5f30a05ee7b113c755ad9a075304e02bc328 diff --git a/src/audio_core/sdl_audio.cpp b/src/audio_core/sdl_audio.cpp index 59e83f8f..3d40e69d 100644 --- a/src/audio_core/sdl_audio.cpp +++ b/src/audio_core/sdl_audio.cpp @@ -4,6 +4,9 @@ #include #include #include "sdl_audio.h" +#include +#include +#include namespace Audio { diff --git a/src/audio_core/sdl_audio.h b/src/audio_core/sdl_audio.h index 4ca7d263..4bd16cbf 100644 --- a/src/audio_core/sdl_audio.h +++ b/src/audio_core/sdl_audio.h @@ -4,8 +4,7 @@ #pragma once #include -#include - +#include #include "core/libraries/audio/audioout.h" namespace Audio { diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index 51369c79..35f9073c 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include + #include "common/assert.h" #include "common/config.h" @@ -9,6 +9,10 @@ #include "core/libraries/pad/pad.h" #include "input/controller.h" #include "sdl_window.h" +#include +#include +#include +#include namespace Frontend { From dfc4f1c35b75716a51140734c9030ceaed32a6b2 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 10 Jun 2024 14:04:59 +0300 Subject: [PATCH 2/9] don't make fullscreen default --- src/common/config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index ca271316..63dd4c13 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -10,7 +10,7 @@ namespace Config { static bool isNeo = false; -static bool isFullscreen = true; +static bool isFullscreen = false; static u32 screenWidth = 1280; static u32 screenHeight = 720; static s32 gpuId = -1; // Vulkan physical device index. Set to negative for auto select From d89e4463e7687c86c9216132b5bc6c30cf62245d Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 10 Jun 2024 15:18:42 +0300 Subject: [PATCH 3/9] moved main code , to emulator,cpp , emulator.h class --- CMakeLists.txt | 2 + src/emulator.cpp | 136 +++++++++++++++++++++++++++++++++++++++++++++++ src/emulator.h | 30 +++++++++++ src/main.cpp | 116 ++-------------------------------------- 4 files changed, 171 insertions(+), 113 deletions(-) create mode 100644 src/emulator.cpp create mode 100644 src/emulator.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b4006dd8..71c32157 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -486,6 +486,8 @@ else() ${SHADER_RECOMPILER} ${VIDEO_CORE} src/main.cpp + src/emulator.cpp + src/emulator.h src/sdl_window.h src/sdl_window.cpp ) diff --git a/src/emulator.cpp b/src/emulator.cpp new file mode 100644 index 00000000..05a21240 --- /dev/null +++ b/src/emulator.cpp @@ -0,0 +1,136 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include +#include "common/config.h" +#include "common/logging/backend.h" +#include "common/path_util.h" +#include "common/singleton.h" +#include "core/file_sys/fs.h" +#include "core/libraries/kernel/thread_management.h" +#include "core/libraries/libs.h" +#include "core/linker.h" +#include "core/memory.h" +#include "emulator.h" + +Frontend::WindowSDL* g_window = nullptr; + +namespace Core { + +static constexpr s32 WindowWidth = 1280; +static constexpr s32 WindowHeight = 720; + +Emulator::Emulator() : window{WindowWidth, WindowHeight, controller} { + g_window = &window; + + // Initialize memory system as early as possible to reserve mappings. + [[maybe_unused]] const auto* memory = Core::Memory::Instance(); + + // Read configuration file. + const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); + Config::load(config_dir / "config.toml"); + + // Start logger. + Common::Log::Initialize(); + Common::Log::Start(); + + // Start discord integration + discord_rpc.init(); + discord_rpc.update(Discord::RPCStatus::Idling, ""); + + // Initialize kernel and library facilities. + Libraries::Kernel::init_pthreads(); +} + +Emulator::~Emulator() { + const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); + Config::save(config_dir / "config.toml"); + discord_rpc.stop(); +} + +void Emulator::Run(const std::filesystem::path& file) { + // Initialize linker + auto linker = Common::Singleton::Instance(); + Libraries::InitHLELibs(&linker->GetHLESymbols()); + + // Applications expect to be run from /app0 so mount the file's parent path as app0. + auto* mnt = Common::Singleton::Instance(); + mnt->Mount(file.parent_path(), "/app0"); + + // Loading param.sfo file if exists + std::filesystem::path sce_sys_folder = file.parent_path() / "sce_sys"; + if (std::filesystem::is_directory(sce_sys_folder)) { + for (const auto& entry : std::filesystem::directory_iterator(sce_sys_folder)) { + if (entry.path().filename() == "param.sfo") { + auto* param_sfo = Common::Singleton::Instance(); + param_sfo->open(sce_sys_folder.string() + "/param.sfo"); + std::string id(param_sfo->GetString("CONTENT_ID"), 7, 9); + std::string title(param_sfo->GetString("TITLE")); + LOG_INFO(Loader, "Game id: {} Title: {}", id, title); + u32 fw_version = param_sfo->GetInteger("SYSTEM_VER"); + std::string app_version = param_sfo->GetString("APP_VER"); + LOG_INFO(Loader, "Fw: {:#x} App Version: {}", fw_version, app_version); + } else if (entry.path().filename() == "pic0.png" || + entry.path().filename() == "pic1.png") { + auto* splash = Common::Singleton::Instance(); + if (splash->IsLoaded()) { + continue; + } + if (!splash->Open(entry.path().string())) { + LOG_ERROR(Loader, "Game splash: unable to open file"); + } + } + } + } + + // Load the module with the linker + linker->LoadModule(file); + + // check if we have system modules to load + const auto& sys_module_path = Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir); + for (const auto& entry : std::filesystem::directory_iterator(sys_module_path)) { + if (entry.path().filename() == "libSceNgs2.sprx") { + LOG_INFO(Loader, "Loading {}", entry.path().string().c_str()); + linker->LoadModule(entry.path().string().c_str()); + } + } + // Check if there is a libc.prx in sce_module folder + bool found = false; + if (Config::isLleLibc()) { + 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") { + found = true; + LOG_INFO(Loader, "Loading {}", entry.path().string().c_str()); + linker->LoadModule(entry.path().string().c_str()); + } + } + } + } + if (!found) { + Libraries::LibC::libcSymbolsRegister(&linker->GetHLESymbols()); + } + + // start execution + std::thread mainthread([linker]() { linker->Execute(); }); + + // Begin main window loop until the application exits + static constexpr std::chrono::microseconds FlipPeriod{100000}; + + while (window.isOpen()) { + window.waitEvent(); + Libraries::VideoOut::Flip(FlipPeriod); + Libraries::VideoOut::Vblank(); + } + + std::exit(0); +} + +} // namespace Core \ No newline at end of file diff --git a/src/emulator.h b/src/emulator.h new file mode 100644 index 00000000..ade76044 --- /dev/null +++ b/src/emulator.h @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include + +#include +#include "common/discord.h" +#include "core/linker.h" +#include "input/controller.h" +#include "sdl_window.h" + +namespace Core { + +class Emulator { +public: + Emulator(); + ~Emulator(); + + void Run(const std::filesystem::path& file); + +private: + Discord::RPC discord_rpc; + Input::GameController* controller = Common::Singleton::Instance(); + Frontend::WindowSDL window; +}; + +} // namespace Core \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 2a97780d..c7210ac5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,126 +1,16 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include -#include -#include +#include #include -#include -#include "common/config.h" -#include "common/discord.h" -#include "common/logging/backend.h" -#include "common/logging/log.h" -#include "common/path_util.h" -#include "common/singleton.h" -#include "core/file_format/splash.h" -#include "core/file_sys/fs.h" -#include "core/libraries/kernel/thread_management.h" -#include "core/libraries/libc/libc.h" -#include "core/libraries/libs.h" -#include "core/libraries/videoout/video_out.h" -#include "core/linker.h" -#include "core/memory.h" -#include "input/controller.h" -#include "sdl_window.h" - -Frontend::WindowSDL* g_window; - int main(int argc, char* argv[]) { if (argc == 1) { fmt::print("Usage: {} \n", argv[0]); return -1; } - // Initialize memory system as early as possible to reserve mappings. - [[maybe_unused]] const auto* memory = Core::Memory::Instance(); - const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); - Config::load(config_dir / "config.toml"); - Common::Log::Initialize(); - Common::Log::Start(); - Libraries::Kernel::init_pthreads(); - s32 width = Config::getScreenWidth(); - s32 height = Config::getScreenHeight(); - auto* controller = Common::Singleton::Instance(); - Frontend::WindowSDL window{width, height, controller}; - g_window = &window; - - // Argument 1 is the path of self file to boot - const char* const path = argv[1]; - - auto* mnt = Common::Singleton::Instance(); - std::filesystem::path p = std::string(path); - mnt->Mount(p.parent_path(), "/app0"); - - // Loading param.sfo file if exists - std::filesystem::path sce_sys_folder = p.parent_path() / "sce_sys"; - if (std::filesystem::is_directory(sce_sys_folder)) { - for (const auto& entry : std::filesystem::directory_iterator(sce_sys_folder)) { - if (entry.path().filename() == "param.sfo") { - auto* param_sfo = Common::Singleton::Instance(); - param_sfo->open(sce_sys_folder.string() + "/param.sfo"); - std::string id(param_sfo->GetString("CONTENT_ID"), 7, 9); - std::string title(param_sfo->GetString("TITLE")); - LOG_INFO(Loader, "Game id: {} Title: {}", id, title); - u32 fw_version = param_sfo->GetInteger("SYSTEM_VER"); - std::string app_version = param_sfo->GetString("APP_VER"); - LOG_INFO(Loader, "Fw: {:#x} App Version: {}", fw_version, app_version); - } else if (entry.path().filename() == "pic0.png" || - entry.path().filename() == "pic1.png") { - auto* splash = Common::Singleton::Instance(); - if (splash->IsLoaded()) { - continue; - } - if (!splash->Open(entry.path().string())) { - LOG_ERROR(Loader, "Game splash: unable to open file"); - } - } - } - } - - auto linker = Common::Singleton::Instance(); - Libraries::InitHLELibs(&linker->GetHLESymbols()); - linker->LoadModule(path); - - // check if we have system modules to load - const auto& sys_module_path = Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir); - for (const auto& entry : std::filesystem::directory_iterator(sys_module_path)) { - if (entry.path().filename() == "libSceNgs2.sprx") { - LOG_INFO(Loader, "Loading {}", entry.path().string().c_str()); - linker->LoadModule(entry.path().string().c_str()); - } - } - // Check if there is a libc.prx in sce_module folder - bool found = false; - if (Config::isLleLibc()) { - std::filesystem::path sce_module_folder = p.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") { - found = true; - LOG_INFO(Loader, "Loading {}", entry.path().string().c_str()); - linker->LoadModule(entry.path().string().c_str()); - } - } - } - } - if (!found) { - Libraries::LibC::libcSymbolsRegister(&linker->GetHLESymbols()); - } - std::thread mainthread([linker]() { linker->Execute(); }); - Discord::RPC discordRPC; - discordRPC.init(); - discordRPC.update(Discord::RPCStatus::Idling, ""); - - static constexpr std::chrono::microseconds FlipPeriod{100000}; - - while (window.isOpen()) { - window.waitEvent(); - Libraries::VideoOut::Flip(FlipPeriod); - Libraries::VideoOut::Vblank(); - } - - discordRPC.stop(); + Core::Emulator emulator; + emulator.Run(argv[1]); return 0; } From deda3026d8628a98f21d871934a9604af5ca45c2 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 10 Jun 2024 15:21:50 +0300 Subject: [PATCH 4/9] clang fix --- src/audio_core/sdl_audio.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio_core/sdl_audio.cpp b/src/audio_core/sdl_audio.cpp index 3d40e69d..6507d694 100644 --- a/src/audio_core/sdl_audio.cpp +++ b/src/audio_core/sdl_audio.cpp @@ -1,12 +1,12 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include +#include #include #include #include "sdl_audio.h" -#include -#include -#include namespace Audio { From 81a1cbf6b14cb5ab999616c219239896ada3d3db Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 10 Jun 2024 15:24:34 +0300 Subject: [PATCH 5/9] more clang fix --- src/sdl_window.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index 35f9073c..255946fc 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -1,18 +1,16 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later - - +#include +#include +#include +#include #include "common/assert.h" #include "common/config.h" #include "common/version.h" #include "core/libraries/pad/pad.h" #include "input/controller.h" #include "sdl_window.h" -#include -#include -#include -#include namespace Frontend { From 3318f126390cdd3e08a7abc43f1b200048d5af04 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 10 Jun 2024 18:01:50 +0300 Subject: [PATCH 6/9] fixed possible nullptr crash on rwlock create --- src/core/libraries/kernel/threads/kernel_threads_rwlock.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/libraries/kernel/threads/kernel_threads_rwlock.cpp b/src/core/libraries/kernel/threads/kernel_threads_rwlock.cpp index cbedb7cb..c8bf3724 100644 --- a/src/core/libraries/kernel/threads/kernel_threads_rwlock.cpp +++ b/src/core/libraries/kernel/threads/kernel_threads_rwlock.cpp @@ -201,7 +201,9 @@ int PS4_SYSV_ABI scePthreadRwlockInit(OrbisPthreadRwlock* rwlock, if (attr == nullptr || *attr == nullptr) { attr = g_pthread_cxt->getDefaultRwattr(); } - (*rwlock)->name = name; + if (name != nullptr) { + (*rwlock)->name = name; + } int result = pthread_rwlock_init(&(*rwlock)->pth_rwlock, &(*attr)->attr_rwlock); if (result != 0) { LOG_ERROR(Kernel_Pthread, "scePthreadRwlockInit: error = {}", result); From 6f8d99fbf26f515359a300822efde0c9768f3c9b Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 10 Jun 2024 18:09:22 +0300 Subject: [PATCH 7/9] fixed posix_stat error return --- src/core/libraries/kernel/file_system.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 5357f69c..b2000055 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -208,10 +208,11 @@ int PS4_SYSV_ABI sceKernelStat(const char* path, OrbisKernelStat* sb) { int PS4_SYSV_ABI posix_stat(const char* path, OrbisKernelStat* sb) { int result = sceKernelStat(path, sb); - if (result < 0) { - UNREACHABLE(); // TODO + if (result != 0) { + LOG_ERROR(Kernel_Pthread, "posix_stat: error = {}", result); + result += ORBIS_KERNEL_ERROR_UNKNOWN; } - return ORBIS_OK; + return result; } s64 PS4_SYSV_ABI sceKernelPread(int d, void* buf, size_t nbytes, s64 offset) { From beb631607a8c5d1d1859c5489a44b0bb00aba2d2 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 10 Jun 2024 18:26:37 +0300 Subject: [PATCH 8/9] review fixes --- src/emulator.cpp | 30 +++++++++++++++++------------- src/emulator.h | 2 ++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/emulator.cpp b/src/emulator.cpp index 05a21240..be13ba7b 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -1,3 +1,4 @@ +#include "emulator.h" // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -45,6 +46,7 @@ Emulator::Emulator() : window{WindowWidth, WindowHeight, controller} { // Initialize kernel and library facilities. Libraries::Kernel::init_pthreads(); + Libraries::InitHLELibs(&linker->GetHLESymbols()); } Emulator::~Emulator() { @@ -54,10 +56,6 @@ Emulator::~Emulator() { } void Emulator::Run(const std::filesystem::path& file) { - // Initialize linker - auto linker = Common::Singleton::Instance(); - Libraries::InitHLELibs(&linker->GetHLESymbols()); - // Applications expect to be run from /app0 so mount the file's parent path as app0. auto* mnt = Common::Singleton::Instance(); mnt->Mount(file.parent_path(), "/app0"); @@ -92,13 +90,8 @@ void Emulator::Run(const std::filesystem::path& file) { linker->LoadModule(file); // check if we have system modules to load - const auto& sys_module_path = Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir); - for (const auto& entry : std::filesystem::directory_iterator(sys_module_path)) { - if (entry.path().filename() == "libSceNgs2.sprx") { - LOG_INFO(Loader, "Loading {}", entry.path().string().c_str()); - linker->LoadModule(entry.path().string().c_str()); - } - } + LoadSystemModules(file); + // Check if there is a libc.prx in sce_module folder bool found = false; if (Config::isLleLibc()) { @@ -109,7 +102,7 @@ void Emulator::Run(const std::filesystem::path& file) { entry.path().filename() == "libSceFios2.prx") { found = true; LOG_INFO(Loader, "Loading {}", entry.path().string().c_str()); - linker->LoadModule(entry.path().string().c_str()); + linker->LoadModule(entry.path()); } } } @@ -119,7 +112,8 @@ void Emulator::Run(const std::filesystem::path& file) { } // start execution - std::thread mainthread([linker]() { linker->Execute(); }); + std::jthread mainthread = + std::jthread([this](std::stop_token stop_token) { linker->Execute(); }); // Begin main window loop until the application exits static constexpr std::chrono::microseconds FlipPeriod{100000}; @@ -133,4 +127,14 @@ void Emulator::Run(const std::filesystem::path& file) { std::exit(0); } +void Emulator::LoadSystemModules(const std::filesystem::path& file) { + const auto& sys_module_path = Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir); + for (const auto& entry : std::filesystem::directory_iterator(sys_module_path)) { + if (entry.path().filename() == "libSceNgs2.sprx") { + LOG_INFO(Loader, "Loading {}", entry.path().string().c_str()); + linker->LoadModule(entry.path()); + } + } +} + } // namespace Core \ No newline at end of file diff --git a/src/emulator.h b/src/emulator.h index ade76044..7364af8c 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -22,8 +22,10 @@ public: void Run(const std::filesystem::path& file); private: + void LoadSystemModules(const std::filesystem::path& file); Discord::RPC discord_rpc; Input::GameController* controller = Common::Singleton::Instance(); + Core::Linker* linker = Common::Singleton::Instance(); Frontend::WindowSDL window; }; From e84d2cf9cf210fd2c366e725b3d25b1d22f9c853 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 10 Jun 2024 18:36:18 +0300 Subject: [PATCH 9/9] wrong spdx --- src/emulator.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/emulator.cpp b/src/emulator.cpp index be13ba7b..dd8de3a7 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -1,4 +1,3 @@ -#include "emulator.h" // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later