From 540c21d38239a1ed70ff42db7208d40e4afe1122 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 25 Mar 2024 09:26:59 +0200 Subject: [PATCH] config option to enable libc lle --- src/common/config.cpp | 13 +++++++++++++ src/common/config.h | 1 + src/core/hle/libraries/libs.cpp | 5 ++++- src/main.cpp | 19 +++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 96c71c4f..72a46ddf 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -15,7 +15,11 @@ u32 screenHeight = 720; std::string logFilter; std::string logType = "sync"; bool isDebugDump = false; +bool isLibc = true; +bool isLleLibc() { + return isLibc; +} bool isNeoMode() { return isNeo; } @@ -84,6 +88,14 @@ void load(const std::filesystem::path& path) { isDebugDump = toml::find_or(debug, "DebugDump", false); } } + if (data.contains("LLE")) { + auto generalResult = toml::expect(data.at("LLE")); + if (generalResult.is_ok()) { + auto general = generalResult.unwrap(); + + isLibc = toml::find_or(general, "libc", true); + } + } } void save(const std::filesystem::path& path) { toml::basic_value data; @@ -110,6 +122,7 @@ void save(const std::filesystem::path& path) { data["GPU"]["screenWidth"] = screenWidth; data["GPU"]["screenHeight"] = screenHeight; data["Debug"]["DebugDump"] = isDebugDump; + data["LLE"]["libc"] = isLibc; std::ofstream file(path, std::ios::out); file << data; diff --git a/src/common/config.h b/src/common/config.h index 114ef55f..b69c43b4 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -18,5 +18,6 @@ u32 getScreenWidth(); u32 getScreenHeight(); bool debugDump(); +bool isLleLibc(); }; // namespace Config diff --git a/src/core/hle/libraries/libs.cpp b/src/core/hle/libraries/libs.cpp index 28594471..88184fe9 100644 --- a/src/core/hle/libraries/libs.cpp +++ b/src/core/hle/libraries/libs.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "core/PS4/HLE/Graphics/video_out.h" #include "core/hle/libraries/libc/libc.h" #include "core/hle/libraries/libkernel/libkernel.h" @@ -20,7 +21,9 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { HLE::Libs::Graphics::VideoOut::videoOutRegisterLib(sym); Core::Libraries::LibSceGnmDriver::LibSceGnmDriver_Register(sym); OldLibraries::LibPad::padSymbolsRegister(sym); - Core::Libraries::LibC::libcSymbolsRegister(sym); + if (!Config::isLleLibc()) { + Core::Libraries::LibC::libcSymbolsRegister(sym); + } // new libraries folder from autogen Libraries::UserService::RegisterlibSceUserService(sym); diff --git a/src/main.cpp b/src/main.cpp index ec236bd3..b43252bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include "common/config.h" #include "common/discord.h" @@ -49,6 +50,24 @@ int main(int argc, char* argv[]) { OldLibraries::InitHLELibs(&linker->getHLESymbols()); Core::InstallTlsHandler(); linker->LoadModule(path); + // check if there is a libc.prx in sce_module folder + bool found = false; + if (Config::isLleLibc()) { + std::filesystem::path sce_module_folder = + std::string(p.parent_path().string() + "\\sce_module"); + if (std::filesystem::exists(sce_module_folder)) { + for (const auto& entry : std::filesystem::directory_iterator(sce_module_folder)) { + if (entry.path().filename() == "libc.prx") { + // found = true; + printf("%s\n", entry.path().string().c_str()); + } + } + } + } + if (!found) // load HLE libc + { + Core::Libraries::LibC::libcSymbolsRegister(&linker->getHLESymbols()); + } std::jthread mainthread([linker](std::stop_token stop_token, void*) { linker->Execute(); }, nullptr); Discord::RPC discordRPC;