From fa76a723adeef84b4ca51ede771b600f2ad7a1cf Mon Sep 17 00:00:00 2001 From: raziel1000 Date: Thu, 25 Jul 2024 01:13:14 -0600 Subject: [PATCH] Applied feedback from @raphaelthegreat --- src/core/libraries/kernel/memory_management.cpp | 5 +++-- src/core/libraries/kernel/memory_management.h | 8 ++++++++ src/core/libraries/kernel/thread_management.cpp | 5 +++++ src/emulator.cpp | 3 ++- src/sdl_window.cpp | 6 +++--- src/sdl_window.h | 3 +-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/core/libraries/kernel/memory_management.cpp b/src/core/libraries/kernel/memory_management.cpp index e0509fb4..7ba85de2 100644 --- a/src/core/libraries/kernel/memory_management.cpp +++ b/src/core/libraries/kernel/memory_management.cpp @@ -228,7 +228,8 @@ int PS4_SYSV_ABI sceKernelGetDirectMemoryType(u64 addr, int* directMemoryTypeOut s32 PS4_SYSV_ABI sceKernelBatchMap(OrbisKernelBatchMapEntry* entries, int numEntries, int* numEntriesOut) { - return sceKernelBatchMap2(entries, numEntries, numEntriesOut, 0x10); // 0x10 : Fixed / 0x410 + return sceKernelBatchMap2(entries, numEntries, numEntriesOut, + MemoryFlags::SCE_KERNEL_MAP_FIXED); // 0x10, 0x410? } int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len); @@ -243,7 +244,7 @@ s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, int numEn break; // break and assign a value to numEntriesOut. } - if (entries[i].operation == 0) { // MAP_DIRECT + if (entries[i].operation == MemoryOpTypes::SCE_KERNEL_MAP_OP_MAP_DIRECT) { result = sceKernelMapNamedDirectMemory(&entries[i].start, entries[i].length, entries[i].protection, flags, static_cast(entries[i].offset), 0, ""); diff --git a/src/core/libraries/kernel/memory_management.h b/src/core/libraries/kernel/memory_management.h index 25434ecb..df94e677 100644 --- a/src/core/libraries/kernel/memory_management.h +++ b/src/core/libraries/kernel/memory_management.h @@ -31,6 +31,14 @@ enum MemoryProtection : u32 { SCE_KERNEL_PROT_GPU_RW = 0x30 // Permit reads/writes from the GPU }; +enum MemoryOpTypes : u32 { + SCE_KERNEL_MAP_OP_MAP_DIRECT = 0, + SCE_KERNEL_MAP_OP_UNMAP = 1, + SCE_KERNEL_MAP_OP_PROTECT = 2, + SCE_KERNEL_MAP_OP_MAP_FLEXIBLE = 3, + SCE_KERNEL_MAP_OP_TYPE_PROTECT = 4 +}; + struct OrbisQueryInfo { uintptr_t start; uintptr_t end; diff --git a/src/core/libraries/kernel/thread_management.cpp b/src/core/libraries/kernel/thread_management.cpp index bbd926d0..b18bb043 100644 --- a/src/core/libraries/kernel/thread_management.cpp +++ b/src/core/libraries/kernel/thread_management.cpp @@ -1336,6 +1336,10 @@ int PS4_SYSV_ABI posix_sem_wait(sem_t* sem) { return sem_wait(sem); } +int PS4_SYSV_ABI posix_sem_timedwait(sem_t* sem, const timespec* t) { + return sem_timedwait(sem, t); +} + int PS4_SYSV_ABI posix_sem_post(sem_t* sem) { return sem_post(sem); } @@ -1543,6 +1547,7 @@ void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("Xs9hdiD7sAA", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_setschedparam); LIB_FUNCTION("pDuPEf3m4fI", "libScePosix", 1, "libkernel", 1, 1, posix_sem_init); LIB_FUNCTION("YCV5dGGBcCo", "libScePosix", 1, "libkernel", 1, 1, posix_sem_wait); + LIB_FUNCTION("w5IHyvahg-o", "libScePosix", 1, "libkernel", 1, 1, posix_sem_timedwait); LIB_FUNCTION("IKP8typ0QUk", "libScePosix", 1, "libkernel", 1, 1, posix_sem_post); LIB_FUNCTION("cDW233RAwWo", "libScePosix", 1, "libkernel", 1, 1, posix_sem_destroy); LIB_FUNCTION("Bq+LRV-N6Hk", "libScePosix", 1, "libkernel", 1, 1, posix_sem_getvalue); diff --git a/src/emulator.cpp b/src/emulator.cpp index e8c53725..e617a975 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -95,7 +95,8 @@ void Emulator::Run(const std::filesystem::path& file) { } } } - std::string game_title = id + " - " + title + " <" + app_version + ">"; + std::string game_title = fmt::format("{} - {} <{}>", id, title, app_version); + window = std::make_unique(WindowWidth, WindowHeight, controller, game_title); diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index c0e9afdd..6d3e6848 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -19,14 +19,14 @@ namespace Frontend { WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_, - std::string game_title_) - : width{width_}, height{height_}, controller{controller_}, game_title{game_title_} { + std::string_view game_title) + : width{width_}, height{height_}, controller{controller_}{ if (SDL_Init(SDL_INIT_VIDEO) < 0) { UNREACHABLE_MSG("Failed to initialize SDL video subsystem: {}", SDL_GetError()); } SDL_InitSubSystem(SDL_INIT_AUDIO); - const std::string title = "shadPS4 v" + std::string(Common::VERSION) + " | " + game_title; + const std::string title = fmt::format("shadPS4 v{} | {}", Common::VERSION, game_title); SDL_PropertiesID props = SDL_CreateProperties(); SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, title.c_str()); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, SDL_WINDOWPOS_CENTERED); diff --git a/src/sdl_window.h b/src/sdl_window.h index 688a4407..89b2a877 100644 --- a/src/sdl_window.h +++ b/src/sdl_window.h @@ -42,7 +42,7 @@ struct WindowSystemInfo { class WindowSDL { public: explicit WindowSDL(s32 width, s32 height, Input::GameController* controller, - std::string game_title); + std::string_view game_title); ~WindowSDL(); s32 getWidth() const { @@ -70,7 +70,6 @@ private: private: s32 width; s32 height; - std::string game_title; Input::GameController* controller; WindowSystemInfo window_info{}; SDL_Window* window{};