mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-27 01:03:31 -04:00
93e221feaa
* feat: remove memory and pad from stub section * feat: add support for resume entry targets in CodeGenerator (this allow jumps in address outside function) feat: refactor entry point discovery one more try to reduce big generated file * feat: optmizations for release build * feat: remove unused file * feat: added some test cases for code gen * feat: added log macro and remove win specific code * feat: refactor runtime folder structure feat: added reset sound driver RPC state and compatibility layout feat: rename and added new test feat: update RPC calls to use defined constants feat: added more PSMC(16, 32) feat: change cd read to try find the asset ignoring case sensitive fix: fix some render problems feat: add logs on pad feat: added more RPC handles * feat: added game override for code veronica * feat: apply vita patch * feat: flags to disable build * feat: fix merges feat: break a lot of tests * feat: better throw error on empty cd path feat: remove recompiler unusde function feat: apply missing patch * feat: gamedp is now part of lib feat: missing file * feat: small cleanup * feat: missing vita changes * feat: fix more merge * feat: fix tests * feat: last missing feature * feat: added missing import * feat: rename test local functions * feat: init syscall on ps2 list * feat: added DMA helpers * feat: faster builds feat: more implement for darkcloud * feat: back missing file * feat: added missing includes * feat: remove test * feat: missing include * feat: read register funtion * feat: build fix * feat: force exit on detach thread
93 lines
2.1 KiB
C++
93 lines
2.1 KiB
C++
#ifndef PS2_LOG_H
|
|
#define PS2_LOG_H
|
|
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <filesystem>
|
|
|
|
#if defined(AGRESSIVE_LOGS)
|
|
#define PS2_AGRESSIVE_LOGS_ENABLED 1
|
|
#else
|
|
#define PS2_AGRESSIVE_LOGS_ENABLED 0
|
|
#endif
|
|
|
|
#if defined(_DEBUG)
|
|
#define RUNTIME_LOG(x) do { std::cout << x; } while (0)
|
|
#else
|
|
#define RUNTIME_LOG(x) do {} while(0)
|
|
#endif
|
|
|
|
#ifdef neverDone
|
|
|
|
namespace ps2_log
|
|
{
|
|
inline constexpr bool agressive_logs_enabled = PS2_AGRESSIVE_LOGS_ENABLED != 0;
|
|
|
|
inline std::string log_path()
|
|
{
|
|
static std::string path;
|
|
if (path.empty())
|
|
{
|
|
path = (std::filesystem::current_path() / "ps2_log.txt").string();
|
|
}
|
|
return path;
|
|
}
|
|
inline std::ostream &log_stream()
|
|
{
|
|
static std::ofstream f(log_path(), std::ios::out);
|
|
return f.is_open() ? f : std::cerr;
|
|
}
|
|
inline int &depth()
|
|
{
|
|
static thread_local int d = 0;
|
|
return d;
|
|
}
|
|
inline void log_entry(const char *name)
|
|
{
|
|
for (int i = 0; i < depth(); ++i)
|
|
log_stream() << '\t';
|
|
log_stream() << ">> " << name << " enter\n";
|
|
log_stream().flush();
|
|
depth()++;
|
|
}
|
|
inline void log_exit(const char *name)
|
|
{
|
|
depth()--;
|
|
for (int i = 0; i < depth(); ++i)
|
|
log_stream() << '\t';
|
|
log_stream() << "<< " << name << " exit\n";
|
|
log_stream().flush();
|
|
}
|
|
inline void print_saved_location()
|
|
{
|
|
std::cout << "[PS2 LOG] Logs saved at " << log_path() << std::endl;
|
|
}
|
|
}
|
|
|
|
#define PS_LOG_ENTRY(name) \
|
|
ps2_log::log_entry(name); \
|
|
struct _ps2_log_guard_ { const char *_n; _ps2_log_guard_(const char *n) : _n(n) {} \
|
|
~_ps2_log_guard_() { ps2_log::log_exit(_n); } } _ps2_log_guard_(name)
|
|
#define PS2_IF_AGRESSIVE_LOGS(code) \
|
|
do \
|
|
{ \
|
|
if constexpr (ps2_log::agressive_logs_enabled) \
|
|
{ \
|
|
code; \
|
|
} \
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
namespace ps2_log
|
|
{
|
|
inline constexpr bool agressive_logs_enabled = false;
|
|
inline void print_saved_location() {}
|
|
}
|
|
#define PS_LOG_ENTRY(name) ((void)0)
|
|
#define PS2_IF_AGRESSIVE_LOGS(code) ((void)0)
|
|
|
|
#endif
|
|
|
|
#endif
|