diff --git a/CMakeLists.txt b/CMakeLists.txt index cc084d30..accac029 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,10 +30,10 @@ add_executable(shadps4 src/Core/PS4/Loader/Elf.h src/GUI/ElfViewer.cpp src/GUI/ElfViewer.h - src/Util/Log.h - src/Util/Log.cpp - "src/Core/virtual_memory.cpp" - "src/Core/virtual_memory.h" + src/Util/log.h + src/Util/log.cpp + src/Core/virtual_memory.cpp + src/Core/virtual_memory.h src/Core/PS4/Linker.cpp src/Core/PS4/Linker.h src/Lib/Threads.cpp @@ -46,6 +46,8 @@ add_executable(shadps4 src/Core/PS4/HLE/Graphics/video_out.h src/discord.h src/discord.cpp + src/Core/PS4/HLE/Kernel/event_queues.cpp + src/Core/PS4/HLE/Kernel/event_queues.h "src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceVideoOut.cpp" "src/Core/PS4/HLE/LibSceVideoOut.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h") find_package(OpenGL REQUIRED) diff --git a/src/Core/PS4/HLE/Graphics/video_out.cpp b/src/Core/PS4/HLE/Graphics/video_out.cpp index d5bcf6b7..f61466f8 100644 --- a/src/Core/PS4/HLE/Graphics/video_out.cpp +++ b/src/Core/PS4/HLE/Graphics/video_out.cpp @@ -1,7 +1,7 @@ #include "video_out.h" #include -#include +#include #include #include diff --git a/src/Core/PS4/HLE/Kernel/event_queues.cpp b/src/Core/PS4/HLE/Kernel/event_queues.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/Core/PS4/HLE/Kernel/event_queues.h b/src/Core/PS4/HLE/Kernel/event_queues.h new file mode 100644 index 00000000..c59b3075 --- /dev/null +++ b/src/Core/PS4/HLE/Kernel/event_queues.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +namespace HLE::Libs::LibKernel::EventQueues {}; \ No newline at end of file diff --git a/src/Core/PS4/HLE/Kernel/memory_management.cpp b/src/Core/PS4/HLE/Kernel/memory_management.cpp index 1840badf..4897ad38 100644 --- a/src/Core/PS4/HLE/Kernel/memory_management.cpp +++ b/src/Core/PS4/HLE/Kernel/memory_management.cpp @@ -7,7 +7,7 @@ #include #include -#include "../../../../Util/Log.h" +#include #include "../../../../Util/Singleton.h" #include "../ErrorCodes.h" #include "../Libs.h" diff --git a/src/Core/PS4/HLE/LibKernel.cpp b/src/Core/PS4/HLE/LibKernel.cpp index df66ab42..fae91318 100644 --- a/src/Core/PS4/HLE/LibKernel.cpp +++ b/src/Core/PS4/HLE/LibKernel.cpp @@ -2,7 +2,7 @@ #include "LibKernel.h" #include "Libs.h" #include -#include "../../../Util/Log.h" +#include #include "Kernel/memory_management.h" #include "../../../Util/Singleton.h" #include "Kernel/Objects/physical_memory.h" diff --git a/src/Core/PS4/Linker.cpp b/src/Core/PS4/Linker.cpp index d048054b..a11e4638 100644 --- a/src/Core/PS4/Linker.cpp +++ b/src/Core/PS4/Linker.cpp @@ -1,6 +1,6 @@ #include "Linker.h" #include "../virtual_memory.h" -#include "../../Util/Log.h" +#include #include "../../Util/Disassembler.h" #include #include "Util/aerolib.h" diff --git a/src/Core/PS4/Loader/Elf.cpp b/src/Core/PS4/Loader/Elf.cpp index 5f44a13f..c942adbc 100644 --- a/src/Core/PS4/Loader/Elf.cpp +++ b/src/Core/PS4/Loader/Elf.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "../../../Util/Log.h" +#include #ifdef _WIN64 #define DBG_BREAKPOINT __debugbreak(); diff --git a/src/Core/PS4/Loader/SymbolsResolver.cpp b/src/Core/PS4/Loader/SymbolsResolver.cpp index babce4f5..b8740836 100644 --- a/src/Core/PS4/Loader/SymbolsResolver.cpp +++ b/src/Core/PS4/Loader/SymbolsResolver.cpp @@ -1,6 +1,6 @@ #include "../../../types.h" #include "SymbolsResolver.h" -#include "../../../Util/Log.h" +#include void SymbolsResolver::AddSymbol(const SymbolRes& s, u64 virtual_addr) diff --git a/src/Util/log.cpp b/src/Util/log.cpp new file mode 100644 index 00000000..995f5892 --- /dev/null +++ b/src/Util/log.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + + + +namespace logging { + std::vector sinks; + + int init(bool use_stdout) { + sinks.clear();//clear existing sinks + if (use_stdout)//if we use stdout window then init it as well + sinks.push_back(std::make_shared()); + + return 0;//all ok + } +} \ No newline at end of file diff --git a/src/Util/log.h b/src/Util/log.h new file mode 100644 index 00000000..d825a324 --- /dev/null +++ b/src/Util/log.h @@ -0,0 +1,70 @@ +#pragma once + +#include + +namespace logging { + +#define LOG_TRACE SPDLOG_TRACE +#define LOG_DEBUG SPDLOG_DEBUG +#define LOG_INFO SPDLOG_INFO +#define LOG_WARN SPDLOG_WARN +#define LOG_ERROR SPDLOG_ERROR +#define LOG_CRITICAL SPDLOG_CRITICAL + +#define LOG_TRACE_IF(flag, ...) \ + if (flag) LOG_TRACE(__VA_ARGS__) +#define LOG_DEBUG_IF(flag, ...) \ + if (flag) LOG_DEBUG(__VA_ARGS__) +#define LOG_INFO_IF(flag, ...) \ + if (flag) LOG_INFO(__VA_ARGS__) +#define LOG_WARN_IF(flag, ...) \ + if (flag) LOG_WARN(__VA_ARGS__) +#define LOG_ERROR_IF(flag, ...) \ + if (flag) LOG_ERROR(__VA_ARGS__) +#define LOG_CRITICAL_IF(flag, ...) \ + if (flag) LOG_CRITICAL(__VA_ARGS__) + +int init(bool use_stdout); +} // namespace logging + +// copyright vita3k emu https://github.com/Vita3K/Vita3K/blob/master/vita3k/util/include/util/log.h +/* + returns: A string with the input number formatted in hexadecimal + Examples: + * `12` returns: `"0xC"` + * `1337` returns: `"0x539"` + * `72742069` returns: `"0x455F4B5"` +*/ +template +std::string log_hex(T val) { + using unsigned_type = typename std::make_unsigned::type; + std::stringstream ss; + ss << "0x"; + ss << std::hex << static_cast(val); + return ss.str(); +} + +/* + returns: A string with the input number formatted in hexadecimal with padding of the inputted type size + Examples: + * `uint8_t 5` returns: `"0x05"` + * `uint8_t 15` returns: `"0x0F"` + * `uint8_t 255` returns: `"0xFF"` + + * `uint16_t 15` returns: `"0x000F"` + * `uint16_t 1337` returns: `"0x0539"` + * `uint16_t 65535` returns: `"0xFFFF"` + + + * `uint32_t 15` returns: `"0x0000000F"` + * `uint32_t 1337` returns: `"0x00000539"` + * `uint32_t 65535` returns: `"0x0000FFFF"` + * `uint32_t 134217728` returns: `"0x08000000"` +*/ +template +std::string log_hex_full(T val) { + std::stringstream ss; + ss << "0x"; + ss << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex << val; + return ss.str(); +} diff --git a/src/main.cpp b/src/main.cpp index 7b6ce30d..20eec340 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,7 +17,7 @@ #include "spdlog/spdlog.h" #include "types.h" #include "GUI/ElfViewer.h" -#include "Util/Log.h" +#include // This example can also compile and run with Emscripten! See 'Makefile.emscripten' for details. #ifdef __EMSCRIPTEN__