diff --git a/CMakeLists.txt b/CMakeLists.txt index 00ec2d40..12ebc4f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,6 +120,8 @@ set(LIBRARIES src/core/libraries/library_common.h src/core/libraries/libsceposix.h src/core/libraries/libscesavedata.cpp src/core/libraries/libscesavedata.h + src/core/libraries/libscesavedatadialog.cpp + src/core/libraries/libscesavedatadialog.h src/core/libraries/libscessl.cpp src/core/libraries/libscessl.h src/core/libraries/libscesysmodule.cpp diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 32ffd245..042d0f9c 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -92,6 +92,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Lib, Net) \ SUB(Lib, NetCtl) \ SUB(Lib, SaveData) \ + SUB(Lib, SaveDataDialog) \ SUB(Lib, Http) \ SUB(Lib, Ssl) \ SUB(Lib, SysModule) \ diff --git a/src/common/logging/types.h b/src/common/logging/types.h index 0287a198..840d3d04 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -29,46 +29,47 @@ enum class Level : u8 { * filter.cpp. */ enum class Class : u8 { - Log, ///< Messages about the log system itself - Common, ///< Library routines - Common_Filesystem, ///< Filesystem interface library - Common_Memory, ///< Memory mapping and management functions - Core, ///< LLE emulation core - Core_Linker, ///< The module linker - Config, ///< Emulator configuration (including commandline) - Debug, ///< Debugging tools - Kernel, ///< The HLE implementation of the PS4 kernel. - Kernel_Pthread, ///< The pthread implementation of the kernel. - Kernel_Fs, ///< The filesystem implementation of the kernel. - Kernel_Vmm, ///< The virtual memory implementation of the kernel. - Kernel_Event, ///< The event management implementation of the kernel. - Kernel_Sce, ///< The sony specific interfaces provided by the kernel. - Lib, ///< HLE implementation of system library. Each major library - ///< should have its own subclass. - Lib_LibC, ///< The LibC implementation. - Lib_Kernel, ///< The LibKernel implementation. - Lib_Pad, ///< The LibScePad implementation. - Lib_GnmDriver, ///< The LibSceGnmDriver implementation. - Lib_SystemService, ///< The LibSceSystemService implementation. - Lib_UserService, ///< The LibSceUserService implementation. - Lib_VideoOut, ///< The LibSceVideoOut implementation. - Lib_CommonDlg, ///< The LibSceCommonDialog implementation. - Lib_MsgDlg, ///< The LibSceMsgDialog implementation. - Lib_AudioOut, ///< The LibSceAudioOut implementation. - Lib_AudioIn, ///< The LibSceAudioIn implementation. - Lib_Net, ///< The LibSceNet implementation. - Lib_NetCtl, ///< The LibSecNetCtl implementation. - Lib_SaveData, ///< The LibSceSaveData implementation. - Lib_Ssl, ///< The LibSceSsl implementation. - Lib_Http, ///< The LibSceHttp implementation. - Lib_SysModule, ///< The LibSceSysModule implementation - Frontend, ///< Emulator UI - Render, ///< Video Core - Render_Vulkan, ///< Vulkan backend - Loader, ///< ROM loader - Input, ///< Input emulation - Tty, ///< Debug output from emu - Count ///< Total number of logging classes + Log, ///< Messages about the log system itself + Common, ///< Library routines + Common_Filesystem, ///< Filesystem interface library + Common_Memory, ///< Memory mapping and management functions + Core, ///< LLE emulation core + Core_Linker, ///< The module linker + Config, ///< Emulator configuration (including commandline) + Debug, ///< Debugging tools + Kernel, ///< The HLE implementation of the PS4 kernel. + Kernel_Pthread, ///< The pthread implementation of the kernel. + Kernel_Fs, ///< The filesystem implementation of the kernel. + Kernel_Vmm, ///< The virtual memory implementation of the kernel. + Kernel_Event, ///< The event management implementation of the kernel. + Kernel_Sce, ///< The sony specific interfaces provided by the kernel. + Lib, ///< HLE implementation of system library. Each major library + ///< should have its own subclass. + Lib_LibC, ///< The LibC implementation. + Lib_Kernel, ///< The LibKernel implementation. + Lib_Pad, ///< The LibScePad implementation. + Lib_GnmDriver, ///< The LibSceGnmDriver implementation. + Lib_SystemService, ///< The LibSceSystemService implementation. + Lib_UserService, ///< The LibSceUserService implementation. + Lib_VideoOut, ///< The LibSceVideoOut implementation. + Lib_CommonDlg, ///< The LibSceCommonDialog implementation. + Lib_MsgDlg, ///< The LibSceMsgDialog implementation. + Lib_AudioOut, ///< The LibSceAudioOut implementation. + Lib_AudioIn, ///< The LibSceAudioIn implementation. + Lib_Net, ///< The LibSceNet implementation. + Lib_NetCtl, ///< The LibSecNetCtl implementation. + Lib_SaveData, ///< The LibSceSaveData implementation. + Lib_SaveDataDialog, ///< The LibSceSaveDataDialog implementation. + Lib_Ssl, ///< The LibSceSsl implementation. + Lib_Http, ///< The LibSceHttp implementation. + Lib_SysModule, ///< The LibSceSysModule implementation + Frontend, ///< Emulator UI + Render, ///< Video Core + Render_Vulkan, ///< Vulkan backend + Loader, ///< ROM loader + Input, ///< Input emulation + Tty, ///< Debug output from emu + Count ///< Total number of logging classes }; } // namespace Common::Log diff --git a/src/core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp b/src/core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp index f150df40..34339649 100644 --- a/src/core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp +++ b/src/core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp @@ -56,6 +56,18 @@ void VideoOutCtx::Close(s32 handle) { m_video_out_ctx.buffers_registration_index = 0; } +void VideoOutCtx::Vblank() { + std::scoped_lock lock{m_mutex}; + + if (m_video_out_ctx.isOpened) { + m_video_out_ctx.m_mutex.lock(); + m_video_out_ctx.m_vblank_status.count++; + m_video_out_ctx.m_vblank_status.processTime = + Core::Libraries::LibKernel::sceKernelGetProcessTime(); + m_video_out_ctx.m_vblank_status.tsc = Core::Libraries::LibKernel::sceKernelReadTsc(); + m_video_out_ctx.m_mutex.unlock(); + } +} VideoConfigInternal* VideoOutCtx::getCtx(int handle) { if (handle != 1) [[unlikely]] { return nullptr; diff --git a/src/core/PS4/HLE/Graphics/Objects/video_out_ctx.h b/src/core/PS4/HLE/Graphics/Objects/video_out_ctx.h index 83e30ec3..6e801b35 100644 --- a/src/core/PS4/HLE/Graphics/Objects/video_out_ctx.h +++ b/src/core/PS4/HLE/Graphics/Objects/video_out_ctx.h @@ -78,6 +78,7 @@ public: return m_graphic_ctx; } + void Vblank(); private: std::mutex m_mutex; diff --git a/src/core/PS4/HLE/Graphics/video_out.cpp b/src/core/PS4/HLE/Graphics/video_out.cpp index 82c789bb..536c7215 100644 --- a/src/core/PS4/HLE/Graphics/video_out.cpp +++ b/src/core/PS4/HLE/Graphics/video_out.cpp @@ -32,6 +32,10 @@ bool videoOutFlip(u32 micros) { auto* videoOut = Common::Singleton::Instance(); return videoOut->getFlipQueue().flip(micros); } +void VideoOutVblank() { + auto* videoOut = Common::Singleton::Instance(); + return videoOut->Vblank(); +} std::string getPixelFormatString(s32 format) { switch (format) { @@ -127,9 +131,22 @@ s32 PS4_SYSV_ABI sceVideoOutAddFlipEvent(Core::Kernel::SceKernelEqueue eq, s32 h return result; } -s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* const* addresses, - s32 bufferNum, - const SceVideoOutBufferAttribute* attribute) { +s32 PS4_SYSV_ABI sceVideoOutGetVblankStatus(int handle, SceVideoOutVblankStatus* status) { + if (status == nullptr) { + return SCE_VIDEO_OUT_ERROR_INVALID_ADDRESS; + } + + auto* videoOut = Common::Singleton::Instance(); + auto* ctx = videoOut->getCtx(handle); + + ctx->m_mutex.lock(); + *status = ctx->m_vblank_status; + ctx->m_mutex.unlock(); + return SCE_OK; +} + +s32 sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* const* addresses, s32 bufferNum, + const SceVideoOutBufferAttribute* attribute) { auto* videoOut = Common::Singleton::Instance(); auto* ctx = videoOut->getCtx(handle); @@ -346,6 +363,8 @@ void videoOutRegisterLib(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("N5KDtkIjjJ4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutUnregisterBuffers); LIB_FUNCTION("uquVH4-Du78", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutClose); + LIB_FUNCTION("1FZBKy8HeNU", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, + sceVideoOutGetVblankStatus); // openOrbis appears to have libSceVideoOut_v1 module libSceVideoOut_v1.1 LIB_FUNCTION("Up36PTk687E", "libSceVideoOut", 1, "libSceVideoOut", 1, 1, sceVideoOutOpen); diff --git a/src/core/PS4/HLE/Graphics/video_out.h b/src/core/PS4/HLE/Graphics/video_out.h index 3a0e41ac..2086f798 100644 --- a/src/core/PS4/HLE/Graphics/video_out.h +++ b/src/core/PS4/HLE/Graphics/video_out.h @@ -110,6 +110,7 @@ void videoOutInit(u32 width, u32 height); std::string getPixelFormatString(s32 format); void videoOutRegisterLib(Core::Loader::SymbolsResolver* sym); bool videoOutFlip(u32 micros); +void VideoOutVblank(); void PS4_SYSV_ABI sceVideoOutSetBufferAttribute(SceVideoOutBufferAttribute* attribute, u32 pixelFormat, u32 tilingMode, u32 aspectRatio, diff --git a/src/core/hle/libraries/libs.cpp b/src/core/hle/libraries/libs.cpp index 1e28e100..c06d634e 100644 --- a/src/core/hle/libraries/libs.cpp +++ b/src/core/hle/libraries/libs.cpp @@ -18,6 +18,7 @@ #include "src/core/libraries/libscenetctl.h" #include "src/core/libraries/libsceposix.h" #include "src/core/libraries/libscesavedata.h" +#include "src/core/libraries/libscesavedatadialog.h" #include "src/core/libraries/libscessl.h" #include "src/core/libraries/libscesysmodule.h" #include "src/core/libraries/libscesystemservice.h" @@ -49,6 +50,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::Kernel::Registerlibkernel(sym); Libraries::Posix::Registerlibsceposix(sym); Libraries::AudioIn::RegisterlibSceAudioIn(sym); + Libraries::SaveDataDialog::RegisterlibSceSaveDataDialog(sym); } } // namespace OldLibraries diff --git a/src/core/libraries/libscesavedatadialog.cpp b/src/core/libraries/libscesavedatadialog.cpp new file mode 100644 index 00000000..8d53e73e --- /dev/null +++ b/src/core/libraries/libscesavedatadialog.cpp @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +// Generated By moduleGenerator +#include "common/logging/log.h" +#include "error_codes.h" +#include "libscesavedatadialog.h" + +namespace Libraries::SaveDataDialog { + +int PS4_SYSV_ABI sceSaveDataDialogClose() { + LOG_ERROR(Lib_SaveDataDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSaveDataDialogGetResult() { + LOG_ERROR(Lib_SaveDataDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSaveDataDialogGetStatus() { + LOG_ERROR(Lib_SaveDataDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSaveDataDialogInitialize() { + LOG_ERROR(Lib_SaveDataDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSaveDataDialogIsReadyToDisplay() { + LOG_ERROR(Lib_SaveDataDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSaveDataDialogOpen() { + LOG_ERROR(Lib_SaveDataDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSaveDataDialogProgressBarInc() { + LOG_ERROR(Lib_SaveDataDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSaveDataDialogProgressBarSetValue() { + LOG_ERROR(Lib_SaveDataDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSaveDataDialogTerminate() { + LOG_ERROR(Lib_SaveDataDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceSaveDataDialogUpdateStatus() { + LOG_ERROR(Lib_SaveDataDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +void RegisterlibSceSaveDataDialog(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("fH46Lag88XY", "libSceSaveDataDialog", 1, "libSceSaveDataDialog", 1, 1, + sceSaveDataDialogClose); + LIB_FUNCTION("yEiJ-qqr6Cg", "libSceSaveDataDialog", 1, "libSceSaveDataDialog", 1, 1, + sceSaveDataDialogGetResult); + LIB_FUNCTION("ERKzksauAJA", "libSceSaveDataDialog", 1, "libSceSaveDataDialog", 1, 1, + sceSaveDataDialogGetStatus); + LIB_FUNCTION("s9e3+YpRnzw", "libSceSaveDataDialog", 1, "libSceSaveDataDialog", 1, 1, + sceSaveDataDialogInitialize); + LIB_FUNCTION("en7gNVnh878", "libSceSaveDataDialog", 1, "libSceSaveDataDialog", 1, 1, + sceSaveDataDialogIsReadyToDisplay); + LIB_FUNCTION("4tPhsP6FpDI", "libSceSaveDataDialog", 1, "libSceSaveDataDialog", 1, 1, + sceSaveDataDialogOpen); + LIB_FUNCTION("V-uEeFKARJU", "libSceSaveDataDialog", 1, "libSceSaveDataDialog", 1, 1, + sceSaveDataDialogProgressBarInc); + LIB_FUNCTION("hay1CfTmLyA", "libSceSaveDataDialog", 1, "libSceSaveDataDialog", 1, 1, + sceSaveDataDialogProgressBarSetValue); + LIB_FUNCTION("YuH2FA7azqQ", "libSceSaveDataDialog", 1, "libSceSaveDataDialog", 1, 1, + sceSaveDataDialogTerminate); + LIB_FUNCTION("KK3Bdg1RWK0", "libSceSaveDataDialog", 1, "libSceSaveDataDialog", 1, 1, + sceSaveDataDialogUpdateStatus); +}; + +} // namespace Libraries::SaveDataDialog \ No newline at end of file diff --git a/src/core/libraries/libscesavedatadialog.h b/src/core/libraries/libscesavedatadialog.h new file mode 100644 index 00000000..f13978b8 --- /dev/null +++ b/src/core/libraries/libscesavedatadialog.h @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "library_common.h" + +namespace Libraries::SaveDataDialog { + +int PS4_SYSV_ABI sceSaveDataDialogClose(); +int PS4_SYSV_ABI sceSaveDataDialogGetResult(); +int PS4_SYSV_ABI sceSaveDataDialogGetStatus(); +int PS4_SYSV_ABI sceSaveDataDialogInitialize(); +int PS4_SYSV_ABI sceSaveDataDialogIsReadyToDisplay(); +int PS4_SYSV_ABI sceSaveDataDialogOpen(); +int PS4_SYSV_ABI sceSaveDataDialogProgressBarInc(); +int PS4_SYSV_ABI sceSaveDataDialogProgressBarSetValue(); +int PS4_SYSV_ABI sceSaveDataDialogTerminate(); +int PS4_SYSV_ABI sceSaveDataDialogUpdateStatus(); + +void RegisterlibSceSaveDataDialog(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::SaveDataDialog \ No newline at end of file diff --git a/src/emulator.cpp b/src/emulator.cpp index 3600f0bc..a4e37976 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -203,6 +203,7 @@ void emuRun() { calculateFps(0); // TODO: Proper fps } } + HLE::Libs::Graphics::VideoOut::VideoOutVblank(); } } }