config option to enable libc lle

This commit is contained in:
georgemoralis 2024-03-25 09:26:59 +02:00
parent 63d8d4d833
commit 540c21d382
4 changed files with 37 additions and 1 deletions

View File

@ -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<toml::boolean>(debug, "DebugDump", false);
}
}
if (data.contains("LLE")) {
auto generalResult = toml::expect<toml::value>(data.at("LLE"));
if (generalResult.is_ok()) {
auto general = generalResult.unwrap();
isLibc = toml::find_or<toml::boolean>(general, "libc", true);
}
}
}
void save(const std::filesystem::path& path) {
toml::basic_value<toml::preserve_comments> 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;

View File

@ -18,5 +18,6 @@ u32 getScreenWidth();
u32 getScreenHeight();
bool debugDump();
bool isLleLibc();
}; // namespace Config

View File

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <common/config.h>
#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);
if (!Config::isLleLibc()) {
Core::Libraries::LibC::libcSymbolsRegister(sym);
}
// new libraries folder from autogen
Libraries::UserService::RegisterlibSceUserService(sym);

View File

@ -9,6 +9,7 @@
#include <cstdio>
#include <thread>
#include <core/hle/libraries/libc/libc.h>
#include <core/hle/libraries/libkernel/thread_management.h>
#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;