mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 01:25:51 +00:00
Log: Simplify macros
This commit is contained in:
parent
792717e03e
commit
4e922a34a7
|
@ -283,11 +283,11 @@ public:
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
// delete the temporary file
|
// delete the temporary file
|
||||||
if (!DeleteFileW(FileSystem::GetWin32Path(m_temporaryFileName).c_str()))
|
if (!DeleteFileW(FileSystem::GetWin32Path(m_temporaryFileName).c_str()))
|
||||||
Log_WarningFmt("Failed to delete temporary file '{}'", m_temporaryFileName);
|
WARNING_LOG("Failed to delete temporary file '{}'", m_temporaryFileName);
|
||||||
#else
|
#else
|
||||||
// delete the temporary file
|
// delete the temporary file
|
||||||
if (remove(m_temporaryFileName.c_str()) < 0)
|
if (remove(m_temporaryFileName.c_str()) < 0)
|
||||||
Log_WarningFmt("Failed to delete temporary file '{}'", m_temporaryFileName);
|
WARNING_LOG("Failed to delete temporary file '{}'", m_temporaryFileName);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (!m_committed)
|
else if (!m_committed)
|
||||||
|
@ -311,7 +311,7 @@ public:
|
||||||
if (!MoveFileExW(FileSystem::GetWin32Path(m_temporaryFileName).c_str(),
|
if (!MoveFileExW(FileSystem::GetWin32Path(m_temporaryFileName).c_str(),
|
||||||
FileSystem::GetWin32Path(m_originalFileName).c_str(), MOVEFILE_REPLACE_EXISTING))
|
FileSystem::GetWin32Path(m_originalFileName).c_str(), MOVEFILE_REPLACE_EXISTING))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Failed to rename temporary file '{}' to '{}'", m_temporaryFileName, m_originalFileName);
|
WARNING_LOG("Failed to rename temporary file '{}' to '{}'", m_temporaryFileName, m_originalFileName);
|
||||||
m_discarded = true;
|
m_discarded = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -322,7 +322,7 @@ public:
|
||||||
// move the atomic file name to the original file name
|
// move the atomic file name to the original file name
|
||||||
if (rename(m_temporaryFileName.c_str(), m_originalFileName.c_str()) < 0)
|
if (rename(m_temporaryFileName.c_str(), m_originalFileName.c_str()) < 0)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Failed to rename temporary file '{}' to '{}'", m_temporaryFileName, m_originalFileName);
|
WARNING_LOG("Failed to rename temporary file '{}' to '{}'", m_temporaryFileName, m_originalFileName);
|
||||||
m_discarded = true;
|
m_discarded = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -30,7 +30,7 @@ DynamicLibrary::DynamicLibrary(const char* filename)
|
||||||
{
|
{
|
||||||
Error error;
|
Error error;
|
||||||
if (!Open(filename, &error))
|
if (!Open(filename, &error))
|
||||||
Log_ErrorPrint(error.GetDescription());
|
ERROR_LOG(error.GetDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicLibrary::DynamicLibrary(DynamicLibrary&& move) : m_handle(move.m_handle)
|
DynamicLibrary::DynamicLibrary(DynamicLibrary&& move) : m_handle(move.m_handle)
|
||||||
|
|
|
@ -266,7 +266,7 @@ bool FileSystem::GetWin32Path(std::wstring* dest, std::string_view str)
|
||||||
}
|
}
|
||||||
else [[unlikely]]
|
else [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("PathCchCanonicalizeEx() returned {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("PathCchCanonicalizeEx() returned {:08X}", static_cast<unsigned>(hr));
|
||||||
_freea(wstr_buf);
|
_freea(wstr_buf);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2407,13 +2407,13 @@ static bool SetLock(int fd, bool lock)
|
||||||
const off_t offs = lseek(fd, 0, SEEK_CUR);
|
const off_t offs = lseek(fd, 0, SEEK_CUR);
|
||||||
if (offs < 0)
|
if (offs < 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("lseek({}) failed: {}", fd, errno);
|
ERROR_LOG("lseek({}) failed: {}", fd, errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offs != 0 && lseek(fd, 0, SEEK_SET) < 0)
|
if (offs != 0 && lseek(fd, 0, SEEK_SET) < 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("lseek({}, 0) failed: {}", fd, errno);
|
ERROR_LOG("lseek({}, 0) failed: {}", fd, errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2422,7 +2422,7 @@ static bool SetLock(int fd, bool lock)
|
||||||
Panic("Repositioning file descriptor after lock failed.");
|
Panic("Repositioning file descriptor after lock failed.");
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
Log_ErrorFmt("lockf() for {} failed: {}", lock ? "lock" : "unlock", errno);
|
ERROR_LOG("lockf() for {} failed: {}", lock ? "lock" : "unlock", errno);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ static void FormatLogMessageAndPrintW(const char* channelName, const char* funct
|
||||||
const T& callback);
|
const T& callback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char s_log_level_characters[LOGLEVEL_COUNT] = {'X', 'E', 'W', 'P', 'I', 'V', 'D', 'R', 'B', 'T'};
|
static const char s_log_level_characters[LOGLEVEL_COUNT] = {'X', 'E', 'W', 'I', 'V', 'D', 'B', 'T'};
|
||||||
|
|
||||||
static std::vector<RegisteredCallback> s_callbacks;
|
static std::vector<RegisteredCallback> s_callbacks;
|
||||||
static std::mutex s_callback_mutex;
|
static std::mutex s_callback_mutex;
|
||||||
|
@ -154,11 +154,9 @@ ALWAYS_INLINE_RELEASE void Log::FormatLogMessageForDisplay(fmt::memory_buffer& b
|
||||||
"\033[0m"sv, // NONE
|
"\033[0m"sv, // NONE
|
||||||
"\033[1;31m"sv, // ERROR
|
"\033[1;31m"sv, // ERROR
|
||||||
"\033[1;33m"sv, // WARNING
|
"\033[1;33m"sv, // WARNING
|
||||||
"\033[1;35m"sv, // PERF
|
|
||||||
"\033[1;37m"sv, // INFO
|
"\033[1;37m"sv, // INFO
|
||||||
"\033[1;32m"sv, // VERBOSE
|
"\033[1;32m"sv, // VERBOSE
|
||||||
"\033[0;37m"sv, // DEV
|
"\033[0;37m"sv, // DEV
|
||||||
"\033[1;36m"sv, // PROFILE
|
|
||||||
"\033[0;32m"sv, // DEBUG
|
"\033[0;32m"sv, // DEBUG
|
||||||
"\033[0;34m"sv, // TRACE
|
"\033[0;34m"sv, // TRACE
|
||||||
};
|
};
|
||||||
|
@ -174,7 +172,7 @@ ALWAYS_INLINE_RELEASE void Log::FormatLogMessageForDisplay(fmt::memory_buffer& b
|
||||||
// find time since start of process
|
// find time since start of process
|
||||||
const float message_time = Log::GetCurrentMessageTime();
|
const float message_time = Log::GetCurrentMessageTime();
|
||||||
|
|
||||||
if (level <= LOGLEVEL_PERF)
|
if (functionName)
|
||||||
{
|
{
|
||||||
fmt::format_to(appender, "[{:10.4f}] {}{}({}): {}{}{}", message_time, color_start, s_log_level_characters[level],
|
fmt::format_to(appender, "[{:10.4f}] {}{}({}): {}{}{}", message_time, color_start, s_log_level_characters[level],
|
||||||
functionName, message, color_end, message_end);
|
functionName, message, color_end, message_end);
|
||||||
|
@ -187,7 +185,7 @@ ALWAYS_INLINE_RELEASE void Log::FormatLogMessageForDisplay(fmt::memory_buffer& b
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (level <= LOGLEVEL_PERF)
|
if (functionName)
|
||||||
{
|
{
|
||||||
fmt::format_to(appender, "{}{}({}): {}{}{}", color_start, s_log_level_characters[level], functionName, message,
|
fmt::format_to(appender, "{}{}({}): {}{}{}", color_start, s_log_level_characters[level], functionName, message,
|
||||||
color_end, message_end);
|
color_end, message_end);
|
||||||
|
@ -480,6 +478,15 @@ ALWAYS_INLINE_RELEASE bool Log::FilterTest(LOGLEVEL level, const char* channelNa
|
||||||
return (level <= s_log_level && s_log_filter.find(channelName) == std::string::npos);
|
return (level <= s_log_level && s_log_filter.find(channelName) == std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Log::Write(const char* channelName, LOGLEVEL level, std::string_view message)
|
||||||
|
{
|
||||||
|
std::unique_lock lock(s_callback_mutex);
|
||||||
|
if (!FilterTest(level, channelName, lock))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ExecuteCallbacks(channelName, nullptr, level, message, lock);
|
||||||
|
}
|
||||||
|
|
||||||
void Log::Write(const char* channelName, const char* functionName, LOGLEVEL level, std::string_view message)
|
void Log::Write(const char* channelName, const char* functionName, LOGLEVEL level, std::string_view message)
|
||||||
{
|
{
|
||||||
std::unique_lock lock(s_callback_mutex);
|
std::unique_lock lock(s_callback_mutex);
|
||||||
|
@ -489,45 +496,16 @@ void Log::Write(const char* channelName, const char* functionName, LOGLEVEL leve
|
||||||
ExecuteCallbacks(channelName, functionName, level, message, lock);
|
ExecuteCallbacks(channelName, functionName, level, message, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::Writef(const char* channelName, const char* functionName, LOGLEVEL level, const char* format, ...)
|
void Log::WriteFmtArgs(const char* channelName, LOGLEVEL level, fmt::string_view fmt, fmt::format_args args)
|
||||||
{
|
|
||||||
std::va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
Writev(channelName, functionName, level, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Log::Writev(const char* channelName, const char* functionName, LOGLEVEL level, const char* format, va_list ap)
|
|
||||||
{
|
{
|
||||||
std::unique_lock lock(s_callback_mutex);
|
std::unique_lock lock(s_callback_mutex);
|
||||||
if (!FilterTest(level, channelName, lock))
|
if (!FilterTest(level, channelName, lock))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::va_list apCopy;
|
fmt::memory_buffer buffer;
|
||||||
va_copy(apCopy, ap);
|
fmt::vformat_to(std::back_inserter(buffer), fmt, args);
|
||||||
|
|
||||||
#ifdef _WIN32
|
ExecuteCallbacks(channelName, nullptr, level, std::string_view(buffer.data(), buffer.size()), lock);
|
||||||
u32 requiredSize = static_cast<u32>(_vscprintf(format, apCopy));
|
|
||||||
#else
|
|
||||||
u32 requiredSize = std::vsnprintf(nullptr, 0, format, apCopy);
|
|
||||||
#endif
|
|
||||||
va_end(apCopy);
|
|
||||||
|
|
||||||
if (requiredSize < 512)
|
|
||||||
{
|
|
||||||
char buffer[512];
|
|
||||||
const int len = std::vsnprintf(buffer, countof(buffer), format, ap);
|
|
||||||
if (len > 0)
|
|
||||||
ExecuteCallbacks(channelName, functionName, level, std::string_view(buffer, static_cast<size_t>(len)), lock);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char* buffer = new char[requiredSize + 1];
|
|
||||||
const int len = std::vsnprintf(buffer, requiredSize + 1, format, ap);
|
|
||||||
if (len > 0)
|
|
||||||
ExecuteCallbacks(channelName, functionName, level, std::string_view(buffer, static_cast<size_t>(len)), lock);
|
|
||||||
delete[] buffer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::WriteFmtArgs(const char* channelName, const char* functionName, LOGLEVEL level, fmt::string_view fmt,
|
void Log::WriteFmtArgs(const char* channelName, const char* functionName, LOGLEVEL level, fmt::string_view fmt,
|
||||||
|
|
121
src/common/log.h
121
src/common/log.h
|
@ -14,17 +14,16 @@
|
||||||
|
|
||||||
enum LOGLEVEL
|
enum LOGLEVEL
|
||||||
{
|
{
|
||||||
LOGLEVEL_NONE = 0, // Silences all log traffic
|
LOGLEVEL_NONE, // Silences all log traffic
|
||||||
LOGLEVEL_ERROR = 1, // "ErrorPrint"
|
LOGLEVEL_ERROR,
|
||||||
LOGLEVEL_WARNING = 2, // "WarningPrint"
|
LOGLEVEL_WARNING,
|
||||||
LOGLEVEL_PERF = 3, // "PerfPrint" // TODO: Purge
|
LOGLEVEL_INFO,
|
||||||
LOGLEVEL_INFO = 4, // "InfoPrint"
|
LOGLEVEL_VERBOSE,
|
||||||
LOGLEVEL_VERBOSE = 5, // "VerbosePrint"
|
LOGLEVEL_DEV,
|
||||||
LOGLEVEL_DEV = 6, // "DevPrint"
|
LOGLEVEL_DEBUG,
|
||||||
LOGLEVEL_PROFILE = 7, // "ProfilePrint" // TODO: Purge
|
LOGLEVEL_TRACE,
|
||||||
LOGLEVEL_DEBUG = 8, // "DebugPrint"
|
|
||||||
LOGLEVEL_TRACE = 9, // "TracePrint"
|
LOGLEVEL_COUNT
|
||||||
LOGLEVEL_COUNT = 10
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Log {
|
namespace Log {
|
||||||
|
@ -65,91 +64,57 @@ void SetLogLevel(LOGLEVEL level);
|
||||||
void SetLogFilter(std::string_view filter);
|
void SetLogFilter(std::string_view filter);
|
||||||
|
|
||||||
// writes a message to the log
|
// writes a message to the log
|
||||||
|
void Write(const char* channelName, LOGLEVEL level, std::string_view message);
|
||||||
void Write(const char* channelName, const char* functionName, LOGLEVEL level, std::string_view message);
|
void Write(const char* channelName, const char* functionName, LOGLEVEL level, std::string_view message);
|
||||||
void Writef(const char* channelName, const char* functionName, LOGLEVEL level, const char* format, ...)
|
void WriteFmtArgs(const char* channelName, LOGLEVEL level, fmt::string_view fmt, fmt::format_args args);
|
||||||
printflike(4, 5);
|
|
||||||
void Writev(const char* channelName, const char* functionName, LOGLEVEL level, const char* format, va_list ap);
|
|
||||||
void WriteFmtArgs(const char* channelName, const char* functionName, LOGLEVEL level, fmt::string_view fmt,
|
void WriteFmtArgs(const char* channelName, const char* functionName, LOGLEVEL level, fmt::string_view fmt,
|
||||||
fmt::format_args args);
|
fmt::format_args args);
|
||||||
|
|
||||||
template<typename... T>
|
ALWAYS_INLINE static void FastWrite(const char* channelName, LOGLEVEL level, std::string_view message)
|
||||||
ALWAYS_INLINE static void WriteFmt(const char* channelName, const char* functionName, LOGLEVEL level,
|
|
||||||
fmt::format_string<T...> fmt, T&&... args)
|
|
||||||
{
|
{
|
||||||
if (level <= GetLogLevel())
|
if (level <= GetLogLevel())
|
||||||
return WriteFmtArgs(channelName, functionName, level, fmt, fmt::make_format_args(args...));
|
Write(channelName, level, message);
|
||||||
|
}
|
||||||
|
ALWAYS_INLINE static void FastWrite(const char* channelName, const char* functionName, LOGLEVEL level,
|
||||||
|
std::string_view message)
|
||||||
|
{
|
||||||
|
if (level <= GetLogLevel())
|
||||||
|
Write(channelName, functionName, level, message);
|
||||||
|
}
|
||||||
|
template<typename... T>
|
||||||
|
ALWAYS_INLINE static void FastWrite(const char* channelName, LOGLEVEL level, fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
if (level <= GetLogLevel())
|
||||||
|
WriteFmtArgs(channelName, level, fmt, fmt::make_format_args(args...));
|
||||||
|
}
|
||||||
|
template<typename... T>
|
||||||
|
ALWAYS_INLINE static void FastWrite(const char* channelName, const char* functionName, LOGLEVEL level,
|
||||||
|
fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
if (level <= GetLogLevel())
|
||||||
|
WriteFmtArgs(channelName, functionName, level, fmt, fmt::make_format_args(args...));
|
||||||
}
|
}
|
||||||
} // namespace Log
|
} // namespace Log
|
||||||
|
|
||||||
// log wrappers
|
// log wrappers
|
||||||
#define Log_SetChannel(ChannelName) \
|
#define Log_SetChannel(ChannelName) [[maybe_unused]] static const char* ___LogChannel___ = #ChannelName;
|
||||||
[[maybe_unused]] [[maybe_unused]] static const char* ___LogChannel___ = #ChannelName;
|
|
||||||
#define Log_ErrorPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_ERROR, msg)
|
|
||||||
#define Log_ErrorPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_ERROR, __VA_ARGS__)
|
|
||||||
#define Log_ErrorFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_ERROR, __VA_ARGS__)
|
|
||||||
#define Log_WarningPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_WARNING, msg)
|
|
||||||
#define Log_WarningPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_WARNING, __VA_ARGS__)
|
|
||||||
#define Log_WarningFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_WARNING, __VA_ARGS__)
|
|
||||||
#define Log_PerfPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_PERF, msg)
|
|
||||||
#define Log_PerfPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_PERF, __VA_ARGS__)
|
|
||||||
#define Log_PerfFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_PERF, __VA_ARGS__)
|
|
||||||
#define Log_InfoPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_INFO, msg)
|
|
||||||
#define Log_InfoPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_INFO, __VA_ARGS__)
|
|
||||||
#define Log_InfoFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_INFO, __VA_ARGS__)
|
|
||||||
#define Log_VerbosePrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_VERBOSE, msg)
|
|
||||||
#define Log_VerbosePrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_VERBOSE, __VA_ARGS__)
|
|
||||||
#define Log_VerboseFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_VERBOSE, __VA_ARGS__)
|
|
||||||
#define Log_DevPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_DEV, msg)
|
|
||||||
#define Log_DevPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_DEV, __VA_ARGS__)
|
|
||||||
#define Log_DevFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_DEV, __VA_ARGS__)
|
|
||||||
#define Log_ProfilePrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_PROFILE, msg)
|
|
||||||
#define Log_ProfilePrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_PROFILE, __VA_ARGS__)
|
|
||||||
#define Log_ProfileFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_PROFILE, __VA_ARGS__)
|
|
||||||
|
|
||||||
#define Log_ErrorVisible() Log::IsLogVisible(LOGLEVEL_ERROR, ___LogChannel___)
|
#define ERROR_LOG(...) Log::FastWrite(___LogChannel___, __func__, LOGLEVEL_ERROR, __VA_ARGS__)
|
||||||
#define Log_WarningVisible() Log::IsLogVisible(LOGLEVEL_WARNING, ___LogChannel___)
|
#define WARNING_LOG(...) Log::FastWrite(___LogChannel___, __func__, LOGLEVEL_WARNING, __VA_ARGS__)
|
||||||
#define Log_PerfVisible() Log::IsLogVisible(LOGLEVEL_PERF, ___LogChannel___)
|
#define INFO_LOG(...) Log::FastWrite(___LogChannel___, LOGLEVEL_INFO, __VA_ARGS__)
|
||||||
#define Log_InfoVisible() Log::IsLogVisible(LOGLEVEL_INFO, ___LogChannel___)
|
#define VERBOSE_LOG(...) Log::FastWrite(___LogChannel___, LOGLEVEL_VERBOSE, __VA_ARGS__)
|
||||||
#define Log_VerboseVisible() Log::IsLogVisible(LOGLEVEL_VERBOSE, ___LogChannel___)
|
#define DEV_LOG(...) Log::FastWrite(___LogChannel___, LOGLEVEL_DEV, __VA_ARGS__)
|
||||||
#define Log_DevVisible() Log::IsLogVisible(LOGLEVEL_DEV, ___LogChannel___)
|
|
||||||
#define Log_ProfileVisible() Log::IsLogVisible(LOGLEVEL_PROFILE, ___LogChannel___)
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define Log_DebugPrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_DEBUG, msg)
|
#define DEBUG_LOG(...) Log::FastWrite(___LogChannel___, LOGLEVEL_DEBUG, __VA_ARGS__)
|
||||||
#define Log_DebugPrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_DEBUG, __VA_ARGS__)
|
#define TRACE_LOG(...) Log::FastWrite(___LogChannel___, LOGLEVEL_TRACE, __VA_ARGS__)
|
||||||
#define Log_DebugFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_DEBUG, __VA_ARGS__)
|
|
||||||
#define Log_TracePrint(msg) Log::Write(___LogChannel___, __func__, LOGLEVEL_TRACE, msg)
|
|
||||||
#define Log_TracePrintf(...) Log::Writef(___LogChannel___, __func__, LOGLEVEL_TRACE, __VA_ARGS__)
|
|
||||||
#define Log_TraceFmt(...) Log::WriteFmt(___LogChannel___, __func__, LOGLEVEL_TRACE, __VA_ARGS__)
|
|
||||||
|
|
||||||
#define Log_DebugVisible() Log::IsLogVisible(LOGLEVEL_DEBUG, ___LogChannel___)
|
|
||||||
#define Log_TraceVisible() Log::IsLogVisible(LOGLEVEL_TRACE, ___LogChannel___)
|
|
||||||
#else
|
#else
|
||||||
#define Log_DebugPrint(msg) \
|
#define DEBUG_LOG(...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define Log_DebugPrintf(...) \
|
#define TRACE_LOG(...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define Log_DebugFmt(...) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
} while (0)
|
|
||||||
#define Log_TracePrint(msg) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
} while (0)
|
|
||||||
#define Log_TracePrintf(...) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
} while (0)
|
|
||||||
#define Log_TraceFmt(...) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define Log_DebugVisible() false
|
|
||||||
#define Log_TraceVisible() false
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,7 +36,7 @@ bool MemMap::MemProtect(void* baseaddr, size_t size, PageProtect mode)
|
||||||
DWORD old_protect;
|
DWORD old_protect;
|
||||||
if (!VirtualProtect(baseaddr, size, static_cast<DWORD>(mode), &old_protect))
|
if (!VirtualProtect(baseaddr, size, static_cast<DWORD>(mode), &old_protect))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("VirtualProtect() failed with error {}", GetLastError());
|
ERROR_LOG("VirtualProtect() failed with error {}", GetLastError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ u8* SharedMemoryMappingArea::Map(void* file_handle, size_t file_offset, void* ma
|
||||||
if (!MapViewOfFile3(static_cast<HANDLE>(file_handle), GetCurrentProcess(), map_base, file_offset, map_size,
|
if (!MapViewOfFile3(static_cast<HANDLE>(file_handle), GetCurrentProcess(), map_base, file_offset, map_size,
|
||||||
MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, nullptr, 0))
|
MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, nullptr, 0))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("MapViewOfFile3() failed: {}", GetLastError());
|
ERROR_LOG("MapViewOfFile3() failed: {}", GetLastError());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ bool SharedMemoryMappingArea::Unmap(void* map_base, size_t map_size)
|
||||||
// unmap the specified range
|
// unmap the specified range
|
||||||
if (!UnmapViewOfFile2(GetCurrentProcess(), map_base, MEM_PRESERVE_PLACEHOLDER))
|
if (!UnmapViewOfFile2(GetCurrentProcess(), map_base, MEM_PRESERVE_PLACEHOLDER))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("UnmapViewOfFile2() failed: {}", GetLastError());
|
ERROR_LOG("UnmapViewOfFile2() failed: {}", GetLastError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ bool MemMap::MemProtect(void* baseaddr, size_t size, PageProtect mode)
|
||||||
const int result = mprotect(baseaddr, size, static_cast<int>(mode));
|
const int result = mprotect(baseaddr, size, static_cast<int>(mode));
|
||||||
if (result != 0) [[unlikely]]
|
if (result != 0) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("mprotect() for {} at {} failed", size, baseaddr);
|
ERROR_LOG("mprotect() for {} at {} failed", size, baseaddr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
Log_SetChannel(ProgressCallback);
|
Log_SetChannel(ProgressCallback);
|
||||||
|
|
||||||
ProgressCallback::~ProgressCallback() {}
|
ProgressCallback::~ProgressCallback()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void ProgressCallback::SetFormattedStatusText(const char* Format, ...)
|
void ProgressCallback::SetFormattedStatusText(const char* Format, ...)
|
||||||
{
|
{
|
||||||
|
@ -133,18 +135,18 @@ public:
|
||||||
void SetProgressValue(u32 value) override {}
|
void SetProgressValue(u32 value) override {}
|
||||||
void IncrementProgressValue() override {}
|
void IncrementProgressValue() override {}
|
||||||
|
|
||||||
void DisplayError(const char* message) override { Log_ErrorPrint(message); }
|
void DisplayError(const char* message) override { ERROR_LOG(message); }
|
||||||
void DisplayWarning(const char* message) override { Log_WarningPrint(message); }
|
void DisplayWarning(const char* message) override { WARNING_LOG(message); }
|
||||||
void DisplayInformation(const char* message) override { Log_InfoPrint(message); }
|
void DisplayInformation(const char* message) override { INFO_LOG(message); }
|
||||||
void DisplayDebugMessage(const char* message) override { Log_DevPrint(message); }
|
void DisplayDebugMessage(const char* message) override { DEV_LOG(message); }
|
||||||
|
|
||||||
void ModalError(const char* message) override { Log_ErrorPrint(message); }
|
void ModalError(const char* message) override { ERROR_LOG(message); }
|
||||||
bool ModalConfirmation(const char* message) override
|
bool ModalConfirmation(const char* message) override
|
||||||
{
|
{
|
||||||
Log_InfoPrint(message);
|
INFO_LOG(message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void ModalInformation(const char* message) override { Log_InfoPrint(message); }
|
void ModalInformation(const char* message) override { INFO_LOG(message); }
|
||||||
};
|
};
|
||||||
|
|
||||||
static NullProgressCallbacks s_nullProgressCallbacks;
|
static NullProgressCallbacks s_nullProgressCallbacks;
|
||||||
|
@ -365,42 +367,42 @@ void ConsoleProgressCallback::Redraw(bool update_value_only)
|
||||||
void ConsoleProgressCallback::DisplayError(const char* message)
|
void ConsoleProgressCallback::DisplayError(const char* message)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
Log_ErrorPrint(message);
|
ERROR_LOG(message);
|
||||||
Redraw(false);
|
Redraw(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleProgressCallback::DisplayWarning(const char* message)
|
void ConsoleProgressCallback::DisplayWarning(const char* message)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
Log_WarningPrint(message);
|
WARNING_LOG(message);
|
||||||
Redraw(false);
|
Redraw(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleProgressCallback::DisplayInformation(const char* message)
|
void ConsoleProgressCallback::DisplayInformation(const char* message)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
Log_InfoPrint(message);
|
INFO_LOG(message);
|
||||||
Redraw(false);
|
Redraw(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleProgressCallback::DisplayDebugMessage(const char* message)
|
void ConsoleProgressCallback::DisplayDebugMessage(const char* message)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
Log_DevPrint(message);
|
DEV_LOG(message);
|
||||||
Redraw(false);
|
Redraw(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleProgressCallback::ModalError(const char* message)
|
void ConsoleProgressCallback::ModalError(const char* message)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
Log_ErrorPrint(message);
|
ERROR_LOG(message);
|
||||||
Redraw(false);
|
Redraw(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConsoleProgressCallback::ModalConfirmation(const char* message)
|
bool ConsoleProgressCallback::ModalConfirmation(const char* message)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
Log_InfoPrint(message);
|
INFO_LOG(message);
|
||||||
Redraw(false);
|
Redraw(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -408,6 +410,6 @@ bool ConsoleProgressCallback::ModalConfirmation(const char* message)
|
||||||
void ConsoleProgressCallback::ModalInformation(const char* message)
|
void ConsoleProgressCallback::ModalInformation(const char* message)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
Log_InfoPrint(message);
|
INFO_LOG(message);
|
||||||
Redraw(false);
|
Redraw(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ const rc_client_user_game_summary_t& Achievements::GetGameSummary()
|
||||||
void Achievements::ReportError(std::string_view sv)
|
void Achievements::ReportError(std::string_view sv)
|
||||||
{
|
{
|
||||||
std::string error = fmt::format("Achievements error: {}", sv);
|
std::string error = fmt::format("Achievements error: {}", sv);
|
||||||
Log_ErrorPrint(error.c_str());
|
ERROR_LOG(error.c_str());
|
||||||
Host::AddOSDMessage(std::move(error), Host::OSD_CRITICAL_ERROR_DURATION);
|
Host::AddOSDMessage(std::move(error), Host::OSD_CRITICAL_ERROR_DURATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ std::string Achievements::GetGameHash(CDImage* image)
|
||||||
std::memcpy(&header, executable_data.data(), sizeof(header));
|
std::memcpy(&header, executable_data.data(), sizeof(header));
|
||||||
if (!BIOS::IsValidPSExeHeader(header, static_cast<u32>(executable_data.size())))
|
if (!BIOS::IsValidPSExeHeader(header, static_cast<u32>(executable_data.size())))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("PS-EXE header is invalid in '{}' ({} bytes)", executable_name, executable_data.size());
|
ERROR_LOG("PS-EXE header is invalid in '{}' ({} bytes)", executable_name, executable_data.size());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,8 +300,8 @@ std::string Achievements::GetGameHash(CDImage* image)
|
||||||
hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7], hash[8], hash[9], hash[10],
|
hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7], hash[8], hash[9], hash[10],
|
||||||
hash[11], hash[12], hash[13], hash[14], hash[15]);
|
hash[11], hash[12], hash[13], hash[14], hash[15]);
|
||||||
|
|
||||||
Log_InfoFmt("Hash for '{}' ({} bytes, {} bytes hashed): {}", executable_name, executable_data.size(), hash_size,
|
INFO_LOG("Hash for '{}' ({} bytes, {} bytes hashed): {}", executable_name, executable_data.size(), hash_size,
|
||||||
hash_str);
|
hash_str);
|
||||||
return hash_str;
|
return hash_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ void Achievements::DownloadImage(std::string url, std::string cache_filename)
|
||||||
|
|
||||||
if (!FileSystem::WriteBinaryFile(cache_filename.c_str(), data.data(), data.size()))
|
if (!FileSystem::WriteBinaryFile(cache_filename.c_str(), data.data(), data.size()))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to write badge image to '{}'", cache_filename);
|
ERROR_LOG("Failed to write badge image to '{}'", cache_filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ bool Achievements::Initialize()
|
||||||
std::string api_token = Host::GetBaseStringSettingValue("Cheevos", "Token");
|
std::string api_token = Host::GetBaseStringSettingValue("Cheevos", "Token");
|
||||||
if (!username.empty() && !api_token.empty())
|
if (!username.empty() && !api_token.empty())
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Attempting login with user '{}'...", username);
|
INFO_LOG("Attempting login with user '{}'...", username);
|
||||||
s_login_request = rc_client_begin_login_with_token(s_client, username.c_str(), api_token.c_str(),
|
s_login_request = rc_client_begin_login_with_token(s_client, username.c_str(), api_token.c_str(),
|
||||||
ClientLoginWithTokenCallback, nullptr);
|
ClientLoginWithTokenCallback, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -588,7 +588,7 @@ void Achievements::EnsureCacheDirectoriesExist()
|
||||||
|
|
||||||
void Achievements::ClientMessageCallback(const char* message, const rc_client_t* client)
|
void Achievements::ClientMessageCallback(const char* message, const rc_client_t* client)
|
||||||
{
|
{
|
||||||
Log_DevPrint(message);
|
DEV_LOG(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Achievements::ClientReadMemory(uint32_t address, uint8_t* buffer, uint32_t num_bytes, rc_client_t* client)
|
uint32_t Achievements::ClientReadMemory(uint32_t address, uint8_t* buffer, uint32_t num_bytes, rc_client_t* client)
|
||||||
|
@ -769,7 +769,7 @@ void Achievements::ClientEventHandler(const rc_client_event_t* event, rc_client_
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
[[unlikely]] Log_ErrorFmt("Unhandled event: {}", event->type);
|
[[unlikely]] ERROR_LOG("Unhandled event: {}", event->type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -793,7 +793,7 @@ void Achievements::UpdateRichPresence(std::unique_lock<std::recursive_mutex>& lo
|
||||||
|
|
||||||
s_rich_presence_string.assign(sv);
|
s_rich_presence_string.assign(sv);
|
||||||
|
|
||||||
Log_InfoFmt("Rich presence updated: {}", s_rich_presence_string);
|
INFO_LOG("Rich presence updated: {}", s_rich_presence_string);
|
||||||
Host::OnAchievementsRefreshed();
|
Host::OnAchievementsRefreshed();
|
||||||
|
|
||||||
#ifdef ENABLE_DISCORD_PRESENCE
|
#ifdef ENABLE_DISCORD_PRESENCE
|
||||||
|
@ -817,7 +817,7 @@ void Achievements::IdentifyGame(const std::string& path, CDImage* image)
|
||||||
{
|
{
|
||||||
if (s_game_path == path)
|
if (s_game_path == path)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Game path is unchanged.");
|
WARNING_LOG("Game path is unchanged.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,7 +828,7 @@ void Achievements::IdentifyGame(const std::string& path, CDImage* image)
|
||||||
temp_image = CDImage::Open(path.c_str(), g_settings.cdrom_load_image_patches, nullptr);
|
temp_image = CDImage::Open(path.c_str(), g_settings.cdrom_load_image_patches, nullptr);
|
||||||
image = temp_image.get();
|
image = temp_image.get();
|
||||||
if (!temp_image)
|
if (!temp_image)
|
||||||
Log_ErrorFmt("Failed to open temporary CD image '{}'", path);
|
ERROR_LOG("Failed to open temporary CD image '{}'", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string game_hash;
|
std::string game_hash;
|
||||||
|
@ -838,7 +838,7 @@ void Achievements::IdentifyGame(const std::string& path, CDImage* image)
|
||||||
if (s_game_hash == game_hash)
|
if (s_game_hash == game_hash)
|
||||||
{
|
{
|
||||||
// only the path has changed - different format/save state/etc.
|
// only the path has changed - different format/save state/etc.
|
||||||
Log_InfoFmt("Detected path change from '{}' to '{}'", s_game_path, path);
|
INFO_LOG("Detected path change from '{}' to '{}'", s_game_path, path);
|
||||||
s_game_path = path;
|
s_game_path = path;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ void Achievements::IdentifyGame(const std::string& path, CDImage* image)
|
||||||
// bail out if we're not logged in, just save the hash
|
// bail out if we're not logged in, just save the hash
|
||||||
if (!IsLoggedInOrLoggingIn())
|
if (!IsLoggedInOrLoggingIn())
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Skipping load game because we're not logged in.");
|
INFO_LOG("Skipping load game because we're not logged in.");
|
||||||
DisableHardcoreMode();
|
DisableHardcoreMode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -903,7 +903,7 @@ void Achievements::ClientLoadGameCallback(int result, const char* error_message,
|
||||||
if (result == RC_NO_GAME_LOADED)
|
if (result == RC_NO_GAME_LOADED)
|
||||||
{
|
{
|
||||||
// Unknown game.
|
// Unknown game.
|
||||||
Log_InfoFmt("Unknown game '%s', disabling achievements.", s_game_hash);
|
INFO_LOG("Unknown game '%s', disabling achievements.", s_game_hash);
|
||||||
DisableHardcoreMode();
|
DisableHardcoreMode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1053,7 +1053,7 @@ void Achievements::DisplayHardcoreDeferredMessage()
|
||||||
void Achievements::HandleResetEvent(const rc_client_event_t* event)
|
void Achievements::HandleResetEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
// We handle system resets ourselves, but still need to reset the client's state.
|
// We handle system resets ourselves, but still need to reset the client's state.
|
||||||
Log_InfoPrint("Resetting runtime due to reset event");
|
INFO_LOG("Resetting runtime due to reset event");
|
||||||
rc_client_reset(s_client);
|
rc_client_reset(s_client);
|
||||||
|
|
||||||
if (HasActiveGame())
|
if (HasActiveGame())
|
||||||
|
@ -1065,7 +1065,7 @@ void Achievements::HandleUnlockEvent(const rc_client_event_t* event)
|
||||||
const rc_client_achievement_t* cheevo = event->achievement;
|
const rc_client_achievement_t* cheevo = event->achievement;
|
||||||
DebugAssert(cheevo);
|
DebugAssert(cheevo);
|
||||||
|
|
||||||
Log_InfoFmt("Achievement {} ({}) for game {} unlocked", cheevo->title, cheevo->id, s_game_id);
|
INFO_LOG("Achievement {} ({}) for game {} unlocked", cheevo->title, cheevo->id, s_game_id);
|
||||||
UpdateGameSummary();
|
UpdateGameSummary();
|
||||||
|
|
||||||
if (g_settings.achievements_notifications && FullscreenUI::Initialize())
|
if (g_settings.achievements_notifications && FullscreenUI::Initialize())
|
||||||
|
@ -1089,7 +1089,7 @@ void Achievements::HandleUnlockEvent(const rc_client_event_t* event)
|
||||||
|
|
||||||
void Achievements::HandleGameCompleteEvent(const rc_client_event_t* event)
|
void Achievements::HandleGameCompleteEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Game {} complete", s_game_id);
|
INFO_LOG("Game {} complete", s_game_id);
|
||||||
UpdateGameSummary();
|
UpdateGameSummary();
|
||||||
|
|
||||||
if (g_settings.achievements_notifications && FullscreenUI::Initialize())
|
if (g_settings.achievements_notifications && FullscreenUI::Initialize())
|
||||||
|
@ -1108,7 +1108,7 @@ void Achievements::HandleGameCompleteEvent(const rc_client_event_t* event)
|
||||||
|
|
||||||
void Achievements::HandleLeaderboardStartedEvent(const rc_client_event_t* event)
|
void Achievements::HandleLeaderboardStartedEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Leaderboard {} ({}) started", event->leaderboard->id, event->leaderboard->title);
|
DEV_LOG("Leaderboard {} ({}) started", event->leaderboard->id, event->leaderboard->title);
|
||||||
|
|
||||||
if (g_settings.achievements_leaderboard_notifications && FullscreenUI::Initialize())
|
if (g_settings.achievements_leaderboard_notifications && FullscreenUI::Initialize())
|
||||||
{
|
{
|
||||||
|
@ -1123,7 +1123,7 @@ void Achievements::HandleLeaderboardStartedEvent(const rc_client_event_t* event)
|
||||||
|
|
||||||
void Achievements::HandleLeaderboardFailedEvent(const rc_client_event_t* event)
|
void Achievements::HandleLeaderboardFailedEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Leaderboard {} ({}) failed", event->leaderboard->id, event->leaderboard->title);
|
DEV_LOG("Leaderboard {} ({}) failed", event->leaderboard->id, event->leaderboard->title);
|
||||||
|
|
||||||
if (g_settings.achievements_leaderboard_notifications && FullscreenUI::Initialize())
|
if (g_settings.achievements_leaderboard_notifications && FullscreenUI::Initialize())
|
||||||
{
|
{
|
||||||
|
@ -1138,7 +1138,7 @@ void Achievements::HandleLeaderboardFailedEvent(const rc_client_event_t* event)
|
||||||
|
|
||||||
void Achievements::HandleLeaderboardSubmittedEvent(const rc_client_event_t* event)
|
void Achievements::HandleLeaderboardSubmittedEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Leaderboard {} ({}) submitted", event->leaderboard->id, event->leaderboard->title);
|
DEV_LOG("Leaderboard {} ({}) submitted", event->leaderboard->id, event->leaderboard->title);
|
||||||
|
|
||||||
if (g_settings.achievements_leaderboard_notifications && FullscreenUI::Initialize())
|
if (g_settings.achievements_leaderboard_notifications && FullscreenUI::Initialize())
|
||||||
{
|
{
|
||||||
|
@ -1167,8 +1167,8 @@ void Achievements::HandleLeaderboardSubmittedEvent(const rc_client_event_t* even
|
||||||
|
|
||||||
void Achievements::HandleLeaderboardScoreboardEvent(const rc_client_event_t* event)
|
void Achievements::HandleLeaderboardScoreboardEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Leaderboard {} scoreboard rank {} of {}", event->leaderboard_scoreboard->leaderboard_id,
|
DEV_LOG("Leaderboard {} scoreboard rank {} of {}", event->leaderboard_scoreboard->leaderboard_id,
|
||||||
event->leaderboard_scoreboard->new_rank, event->leaderboard_scoreboard->num_entries);
|
event->leaderboard_scoreboard->new_rank, event->leaderboard_scoreboard->num_entries);
|
||||||
|
|
||||||
if (g_settings.achievements_leaderboard_notifications && FullscreenUI::Initialize())
|
if (g_settings.achievements_leaderboard_notifications && FullscreenUI::Initialize())
|
||||||
{
|
{
|
||||||
|
@ -1195,8 +1195,7 @@ void Achievements::HandleLeaderboardScoreboardEvent(const rc_client_event_t* eve
|
||||||
|
|
||||||
void Achievements::HandleLeaderboardTrackerShowEvent(const rc_client_event_t* event)
|
void Achievements::HandleLeaderboardTrackerShowEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Showing leaderboard tracker: {}: {}", event->leaderboard_tracker->id,
|
DEV_LOG("Showing leaderboard tracker: {}: {}", event->leaderboard_tracker->id, event->leaderboard_tracker->display);
|
||||||
event->leaderboard_tracker->display);
|
|
||||||
|
|
||||||
TinyString width_string;
|
TinyString width_string;
|
||||||
width_string.append(ICON_FA_STOPWATCH);
|
width_string.append(ICON_FA_STOPWATCH);
|
||||||
|
@ -1219,7 +1218,7 @@ void Achievements::HandleLeaderboardTrackerHideEvent(const rc_client_event_t* ev
|
||||||
if (it == s_active_leaderboard_trackers.end())
|
if (it == s_active_leaderboard_trackers.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_DevFmt("Hiding leaderboard tracker: {}", id);
|
DEV_LOG("Hiding leaderboard tracker: {}", id);
|
||||||
it->active = false;
|
it->active = false;
|
||||||
it->show_hide_time.Reset();
|
it->show_hide_time.Reset();
|
||||||
}
|
}
|
||||||
|
@ -1232,8 +1231,7 @@ void Achievements::HandleLeaderboardTrackerUpdateEvent(const rc_client_event_t*
|
||||||
if (it == s_active_leaderboard_trackers.end())
|
if (it == s_active_leaderboard_trackers.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_DevFmt("Updating leaderboard tracker: {}: {}", event->leaderboard_tracker->id,
|
DEV_LOG("Updating leaderboard tracker: {}: {}", event->leaderboard_tracker->id, event->leaderboard_tracker->display);
|
||||||
event->leaderboard_tracker->display);
|
|
||||||
|
|
||||||
it->text = event->leaderboard_tracker->display;
|
it->text = event->leaderboard_tracker->display;
|
||||||
it->active = true;
|
it->active = true;
|
||||||
|
@ -1257,7 +1255,7 @@ void Achievements::HandleAchievementChallengeIndicatorShowEvent(const rc_client_
|
||||||
indicator.active = true;
|
indicator.active = true;
|
||||||
s_active_challenge_indicators.push_back(std::move(indicator));
|
s_active_challenge_indicators.push_back(std::move(indicator));
|
||||||
|
|
||||||
Log_DevFmt("Show challenge indicator for {} ({})", event->achievement->id, event->achievement->title);
|
DEV_LOG("Show challenge indicator for {} ({})", event->achievement->id, event->achievement->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Achievements::HandleAchievementChallengeIndicatorHideEvent(const rc_client_event_t* event)
|
void Achievements::HandleAchievementChallengeIndicatorHideEvent(const rc_client_event_t* event)
|
||||||
|
@ -1268,15 +1266,15 @@ void Achievements::HandleAchievementChallengeIndicatorHideEvent(const rc_client_
|
||||||
if (it == s_active_challenge_indicators.end())
|
if (it == s_active_challenge_indicators.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_DevFmt("Hide challenge indicator for {} ({})", event->achievement->id, event->achievement->title);
|
DEV_LOG("Hide challenge indicator for {} ({})", event->achievement->id, event->achievement->title);
|
||||||
it->show_hide_time.Reset();
|
it->show_hide_time.Reset();
|
||||||
it->active = false;
|
it->active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Achievements::HandleAchievementProgressIndicatorShowEvent(const rc_client_event_t* event)
|
void Achievements::HandleAchievementProgressIndicatorShowEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Showing progress indicator: {} ({}): {}", event->achievement->id, event->achievement->title,
|
DEV_LOG("Showing progress indicator: {} ({}): {}", event->achievement->id, event->achievement->title,
|
||||||
event->achievement->measured_progress);
|
event->achievement->measured_progress);
|
||||||
|
|
||||||
if (!s_active_progress_indicator.has_value())
|
if (!s_active_progress_indicator.has_value())
|
||||||
s_active_progress_indicator.emplace();
|
s_active_progress_indicator.emplace();
|
||||||
|
@ -1294,15 +1292,15 @@ void Achievements::HandleAchievementProgressIndicatorHideEvent(const rc_client_e
|
||||||
if (!s_active_progress_indicator.has_value())
|
if (!s_active_progress_indicator.has_value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_DevPrint("Hiding progress indicator");
|
DEV_LOG("Hiding progress indicator");
|
||||||
s_active_progress_indicator->show_hide_time.Reset();
|
s_active_progress_indicator->show_hide_time.Reset();
|
||||||
s_active_progress_indicator->active = false;
|
s_active_progress_indicator->active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Achievements::HandleAchievementProgressIndicatorUpdateEvent(const rc_client_event_t* event)
|
void Achievements::HandleAchievementProgressIndicatorUpdateEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Updating progress indicator: {} ({}): {}", event->achievement->id, event->achievement->title,
|
DEV_LOG("Updating progress indicator: {} ({}): {}", event->achievement->id, event->achievement->title,
|
||||||
event->achievement->measured_progress);
|
event->achievement->measured_progress);
|
||||||
s_active_progress_indicator->achievement = event->achievement;
|
s_active_progress_indicator->achievement = event->achievement;
|
||||||
s_active_progress_indicator->active = true;
|
s_active_progress_indicator->active = true;
|
||||||
}
|
}
|
||||||
|
@ -1313,13 +1311,13 @@ void Achievements::HandleServerErrorEvent(const rc_client_event_t* event)
|
||||||
fmt::format(TRANSLATE_FS("Achievements", "Server error in {}:\n{}"),
|
fmt::format(TRANSLATE_FS("Achievements", "Server error in {}:\n{}"),
|
||||||
event->server_error->api ? event->server_error->api : "UNKNOWN",
|
event->server_error->api ? event->server_error->api : "UNKNOWN",
|
||||||
event->server_error->error_message ? event->server_error->error_message : "UNKNOWN");
|
event->server_error->error_message ? event->server_error->error_message : "UNKNOWN");
|
||||||
Log_ErrorPrint(message.c_str());
|
ERROR_LOG(message.c_str());
|
||||||
Host::AddOSDMessage(std::move(message), Host::OSD_ERROR_DURATION);
|
Host::AddOSDMessage(std::move(message), Host::OSD_ERROR_DURATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Achievements::HandleServerDisconnectedEvent(const rc_client_event_t* event)
|
void Achievements::HandleServerDisconnectedEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Server disconnected.");
|
WARNING_LOG("Server disconnected.");
|
||||||
|
|
||||||
if (FullscreenUI::Initialize())
|
if (FullscreenUI::Initialize())
|
||||||
{
|
{
|
||||||
|
@ -1333,7 +1331,7 @@ void Achievements::HandleServerDisconnectedEvent(const rc_client_event_t* event)
|
||||||
|
|
||||||
void Achievements::HandleServerReconnectedEvent(const rc_client_event_t* event)
|
void Achievements::HandleServerReconnectedEvent(const rc_client_event_t* event)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Server reconnected.");
|
WARNING_LOG("Server reconnected.");
|
||||||
|
|
||||||
if (FullscreenUI::Initialize())
|
if (FullscreenUI::Initialize())
|
||||||
{
|
{
|
||||||
|
@ -1356,7 +1354,7 @@ void Achievements::ResetClient()
|
||||||
if (!IsActive())
|
if (!IsActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_DevPrint("Reset client");
|
DEV_LOG("Reset client");
|
||||||
rc_client_reset(s_client);
|
rc_client_reset(s_client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1474,7 +1472,7 @@ bool Achievements::DoState(StateWrapper& sw)
|
||||||
if (data_size == 0)
|
if (data_size == 0)
|
||||||
{
|
{
|
||||||
// reset runtime, no data (state might've been created without cheevos)
|
// reset runtime, no data (state might've been created without cheevos)
|
||||||
Log_DevPrint("State is missing cheevos data, resetting runtime");
|
DEV_LOG("State is missing cheevos data, resetting runtime");
|
||||||
#ifdef ENABLE_RAINTEGRATION
|
#ifdef ENABLE_RAINTEGRATION
|
||||||
if (IsUsingRAIntegration())
|
if (IsUsingRAIntegration())
|
||||||
RA_OnReset();
|
RA_OnReset();
|
||||||
|
@ -1502,7 +1500,7 @@ bool Achievements::DoState(StateWrapper& sw)
|
||||||
const int result = rc_client_deserialize_progress(s_client, data.get());
|
const int result = rc_client_deserialize_progress(s_client, data.get());
|
||||||
if (result != RC_OK)
|
if (result != RC_OK)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Failed to deserialize cheevos state ({}), resetting", result);
|
WARNING_LOG("Failed to deserialize cheevos state ({}), resetting", result);
|
||||||
rc_client_reset(s_client);
|
rc_client_reset(s_client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1526,7 +1524,7 @@ bool Achievements::DoState(StateWrapper& sw)
|
||||||
const int result = RA_CaptureState(reinterpret_cast<char*>(data.get()), static_cast<int>(data_size));
|
const int result = RA_CaptureState(reinterpret_cast<char*>(data.get()), static_cast<int>(data_size));
|
||||||
if (result != static_cast<int>(data_size))
|
if (result != static_cast<int>(data_size))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Failed to serialize cheevos state from RAIntegration.");
|
WARNING_LOG("Failed to serialize cheevos state from RAIntegration.");
|
||||||
data_size = 0;
|
data_size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1543,7 +1541,7 @@ bool Achievements::DoState(StateWrapper& sw)
|
||||||
if (result != RC_OK)
|
if (result != RC_OK)
|
||||||
{
|
{
|
||||||
// set data to zero, effectively serializing nothing
|
// set data to zero, effectively serializing nothing
|
||||||
Log_WarningFmt("Failed to serialize cheevos state ({})", result);
|
WARNING_LOG("Failed to serialize cheevos state ({})", result);
|
||||||
data_size = 0;
|
data_size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1679,7 +1677,7 @@ void Achievements::ClientLoginWithPasswordCallback(int result, const char* error
|
||||||
|
|
||||||
if (result != RC_OK)
|
if (result != RC_OK)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Login failed: {}: {}", rc_error_str(result), error_message ? error_message : "Unknown");
|
ERROR_LOG("Login failed: {}: {}", rc_error_str(result), error_message ? error_message : "Unknown");
|
||||||
Error::SetString(params->error,
|
Error::SetString(params->error,
|
||||||
fmt::format("{}: {}", rc_error_str(result), error_message ? error_message : "Unknown"));
|
fmt::format("{}: {}", rc_error_str(result), error_message ? error_message : "Unknown"));
|
||||||
params->result = false;
|
params->result = false;
|
||||||
|
@ -1690,7 +1688,7 @@ void Achievements::ClientLoginWithPasswordCallback(int result, const char* error
|
||||||
const rc_client_user_t* user = rc_client_get_user_info(client);
|
const rc_client_user_t* user = rc_client_get_user_info(client);
|
||||||
if (!user || !user->token)
|
if (!user || !user->token)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("rc_client_get_user_info() returned NULL");
|
ERROR_LOG("rc_client_get_user_info() returned NULL");
|
||||||
Error::SetString(params->error, "rc_client_get_user_info() returned NULL");
|
Error::SetString(params->error, "rc_client_get_user_info() returned NULL");
|
||||||
params->result = false;
|
params->result = false;
|
||||||
return;
|
return;
|
||||||
|
@ -1801,11 +1799,11 @@ void Achievements::Logout()
|
||||||
if (HasActiveGame())
|
if (HasActiveGame())
|
||||||
ClearGameInfo();
|
ClearGameInfo();
|
||||||
|
|
||||||
Log_InfoPrint("Logging out...");
|
INFO_LOG("Logging out...");
|
||||||
rc_client_logout(s_client);
|
rc_client_logout(s_client);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoPrint("Clearing credentials...");
|
INFO_LOG("Clearing credentials...");
|
||||||
Host::DeleteBaseSettingValue("Cheevos", "Username");
|
Host::DeleteBaseSettingValue("Cheevos", "Username");
|
||||||
Host::DeleteBaseSettingValue("Cheevos", "Token");
|
Host::DeleteBaseSettingValue("Cheevos", "Token");
|
||||||
Host::DeleteBaseSettingValue("Cheevos", "LoginTimestamp");
|
Host::DeleteBaseSettingValue("Cheevos", "LoginTimestamp");
|
||||||
|
@ -1959,7 +1957,7 @@ void Achievements::DrawGameOverlays()
|
||||||
|
|
||||||
if (!indicator.active && opacity <= 0.01f)
|
if (!indicator.active && opacity <= 0.01f)
|
||||||
{
|
{
|
||||||
Log_DevPrint("Remove challenge indicator");
|
DEV_LOG("Remove challenge indicator");
|
||||||
it = s_active_challenge_indicators.erase(it);
|
it = s_active_challenge_indicators.erase(it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2003,7 +2001,7 @@ void Achievements::DrawGameOverlays()
|
||||||
|
|
||||||
if (!indicator.active && opacity <= 0.01f)
|
if (!indicator.active && opacity <= 0.01f)
|
||||||
{
|
{
|
||||||
Log_DevPrint("Remove progress indicator");
|
DEV_LOG("Remove progress indicator");
|
||||||
s_active_progress_indicator.reset();
|
s_active_progress_indicator.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2046,7 +2044,7 @@ void Achievements::DrawGameOverlays()
|
||||||
|
|
||||||
if (!indicator.active && opacity <= 0.01f)
|
if (!indicator.active && opacity <= 0.01f)
|
||||||
{
|
{
|
||||||
Log_DevPrint("Remove tracker indicator");
|
DEV_LOG("Remove tracker indicator");
|
||||||
it = s_active_leaderboard_trackers.erase(it);
|
it = s_active_leaderboard_trackers.erase(it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2158,7 +2156,7 @@ bool Achievements::PrepareAchievementsWindow()
|
||||||
RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_PROGRESS /*RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_LOCK_STATE*/);
|
RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_PROGRESS /*RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_LOCK_STATE*/);
|
||||||
if (!s_achievement_list)
|
if (!s_achievement_list)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("rc_client_create_achievement_list() returned null");
|
ERROR_LOG("rc_client_create_achievement_list() returned null");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2499,7 +2497,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
|
||||||
if (clicked)
|
if (clicked)
|
||||||
{
|
{
|
||||||
const SmallString url = SmallString::from_format(fmt::runtime(ACHEIVEMENT_DETAILS_URL_TEMPLATE), cheevo->id);
|
const SmallString url = SmallString::from_format(fmt::runtime(ACHEIVEMENT_DETAILS_URL_TEMPLATE), cheevo->id);
|
||||||
Log_InfoFmt("Opening achievement details: {}", url);
|
INFO_LOG("Opening achievement details: {}", url);
|
||||||
Host::OpenURL(url);
|
Host::OpenURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2518,7 +2516,7 @@ bool Achievements::PrepareLeaderboardsWindow()
|
||||||
s_leaderboard_list = rc_client_create_leaderboard_list(client, RC_CLIENT_LEADERBOARD_LIST_GROUPING_NONE);
|
s_leaderboard_list = rc_client_create_leaderboard_list(client, RC_CLIENT_LEADERBOARD_LIST_GROUPING_NONE);
|
||||||
if (!s_leaderboard_list)
|
if (!s_leaderboard_list)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("rc_client_create_leaderboard_list() returned null");
|
ERROR_LOG("rc_client_create_leaderboard_list() returned null");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2974,7 +2972,7 @@ void Achievements::DrawLeaderboardListEntry(const rc_client_leaderboard_t* lboar
|
||||||
|
|
||||||
void Achievements::OpenLeaderboard(const rc_client_leaderboard_t* lboard)
|
void Achievements::OpenLeaderboard(const rc_client_leaderboard_t* lboard)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Opening leaderboard '{}' ({})", lboard->title, lboard->id);
|
DEV_LOG("Opening leaderboard '{}' ({})", lboard->title, lboard->id);
|
||||||
|
|
||||||
CloseLeaderboard();
|
CloseLeaderboard();
|
||||||
|
|
||||||
|
@ -3058,7 +3056,7 @@ void Achievements::FetchNextLeaderboardEntries()
|
||||||
for (rc_client_leaderboard_entry_list_t* list : s_leaderboard_entry_lists)
|
for (rc_client_leaderboard_entry_list_t* list : s_leaderboard_entry_lists)
|
||||||
start += list->num_entries;
|
start += list->num_entries;
|
||||||
|
|
||||||
Log_DevFmt("Fetching entries {} to {}", start, start + LEADERBOARD_ALL_FETCH_SIZE);
|
DEV_LOG("Fetching entries {} to {}", start, start + LEADERBOARD_ALL_FETCH_SIZE);
|
||||||
|
|
||||||
if (s_leaderboard_fetch_handle)
|
if (s_leaderboard_fetch_handle)
|
||||||
rc_client_abort_async(s_client, s_leaderboard_fetch_handle);
|
rc_client_abort_async(s_client, s_leaderboard_fetch_handle);
|
||||||
|
|
|
@ -296,7 +296,7 @@ void AnalogController::SetAnalogMode(bool enabled, bool show_message)
|
||||||
if (m_analog_mode == enabled)
|
if (m_analog_mode == enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_InfoFmt("Controller {} switched to {} mode.", m_index + 1u, m_analog_mode ? "analog" : "digital");
|
INFO_LOG("Controller {} switched to {} mode.", m_index + 1u, m_analog_mode ? "analog" : "digital");
|
||||||
if (show_message)
|
if (show_message)
|
||||||
{
|
{
|
||||||
Host::AddIconOSDMessage(
|
Host::AddIconOSDMessage(
|
||||||
|
@ -432,12 +432,12 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
|
||||||
|
|
||||||
if (data_in == 0x01)
|
if (data_in == 0x01)
|
||||||
{
|
{
|
||||||
Log_DebugPrint("ACK controller access");
|
DEBUG_LOG("ACK controller access");
|
||||||
m_command = Command::Ready;
|
m_command = Command::Ready;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("Unknown data_in = 0x{:02X}", data_in);
|
DEV_LOG("Unknown data_in = 0x{:02X}", data_in);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -508,7 +508,7 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_configuration_mode)
|
if (m_configuration_mode)
|
||||||
Log_ErrorFmt("Unimplemented config mode command 0x{:02X}", data_in);
|
ERROR_LOG("Unimplemented config mode command 0x{:02X}", data_in);
|
||||||
|
|
||||||
*data_out = 0xFF;
|
*data_out = 0xFF;
|
||||||
return false;
|
return false;
|
||||||
|
@ -658,7 +658,7 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
|
||||||
m_status_byte = 0x5A;
|
m_status_byte = 0x5A;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("0x{:02x}({}) config mode", m_rx_buffer[2], m_configuration_mode ? "enter" : "leave");
|
DEV_LOG("0x{:02x}({}) config mode", m_rx_buffer[2], m_configuration_mode ? "enter" : "leave");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -667,14 +667,14 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
|
||||||
{
|
{
|
||||||
if (m_command_step == 2)
|
if (m_command_step == 2)
|
||||||
{
|
{
|
||||||
Log_DevFmt("analog mode val 0x{:02x}", data_in);
|
DEV_LOG("analog mode val 0x{:02x}", data_in);
|
||||||
|
|
||||||
if (data_in == 0x00 || data_in == 0x01)
|
if (data_in == 0x00 || data_in == 0x01)
|
||||||
SetAnalogMode((data_in == 0x01), true);
|
SetAnalogMode((data_in == 0x01), true);
|
||||||
}
|
}
|
||||||
else if (m_command_step == 3)
|
else if (m_command_step == 3)
|
||||||
{
|
{
|
||||||
Log_DevFmt("analog mode lock 0x{:02x}", data_in);
|
DEV_LOG("analog mode lock 0x{:02x}", data_in);
|
||||||
|
|
||||||
if (data_in == 0x02 || data_in == 0x03)
|
if (data_in == 0x02 || data_in == 0x03)
|
||||||
m_analog_locked = (data_in == 0x03);
|
m_analog_locked = (data_in == 0x03);
|
||||||
|
@ -771,10 +771,10 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
|
||||||
{
|
{
|
||||||
m_command = Command::Idle;
|
m_command = Command::Idle;
|
||||||
|
|
||||||
Log_DebugFmt("Rx: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}", m_rx_buffer[0], m_rx_buffer[1],
|
DEBUG_LOG("Rx: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}", m_rx_buffer[0], m_rx_buffer[1],
|
||||||
m_rx_buffer[2], m_rx_buffer[3], m_rx_buffer[4], m_rx_buffer[5], m_rx_buffer[6], m_rx_buffer[7]);
|
m_rx_buffer[2], m_rx_buffer[3], m_rx_buffer[4], m_rx_buffer[5], m_rx_buffer[6], m_rx_buffer[7]);
|
||||||
Log_DebugFmt("Tx: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}", m_tx_buffer[0], m_tx_buffer[1],
|
DEBUG_LOG("Tx: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}", m_tx_buffer[0], m_tx_buffer[1],
|
||||||
m_tx_buffer[2], m_tx_buffer[3], m_tx_buffer[4], m_tx_buffer[5], m_tx_buffer[6], m_tx_buffer[7]);
|
m_tx_buffer[2], m_tx_buffer[3], m_tx_buffer[4], m_tx_buffer[5], m_tx_buffer[6], m_tx_buffer[7]);
|
||||||
|
|
||||||
m_rx_buffer.fill(0x00);
|
m_rx_buffer.fill(0x00);
|
||||||
m_tx_buffer.fill(0x00);
|
m_tx_buffer.fill(0x00);
|
||||||
|
|
|
@ -240,7 +240,7 @@ void AnalogJoystick::ToggleAnalogMode()
|
||||||
{
|
{
|
||||||
m_analog_mode = !m_analog_mode;
|
m_analog_mode = !m_analog_mode;
|
||||||
|
|
||||||
Log_InfoFmt("Joystick {} switched to {} mode.", m_index + 1u, m_analog_mode ? "analog" : "digital");
|
INFO_LOG("Joystick {} switched to {} mode.", m_index + 1u, m_analog_mode ? "analog" : "digital");
|
||||||
Host::AddIconOSDMessage(
|
Host::AddIconOSDMessage(
|
||||||
fmt::format("analog_mode_toggle_{}", m_index), ICON_FA_GAMEPAD,
|
fmt::format("analog_mode_toggle_{}", m_index), ICON_FA_GAMEPAD,
|
||||||
m_analog_mode ? fmt::format(TRANSLATE_FS("Controller", "Controller {} switched to analog mode."), m_index + 1u) :
|
m_analog_mode ? fmt::format(TRANSLATE_FS("Controller", "Controller {} switched to analog mode."), m_index + 1u) :
|
||||||
|
|
|
@ -196,7 +196,7 @@ std::optional<BIOS::Image> BIOS::LoadImageFromFile(const char* filename, Error*
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevPrint(
|
DEV_LOG(
|
||||||
fmt::format("Hash for BIOS '{}': {}", FileSystem::GetDisplayNameFromPath(filename), GetImageHash(ret).ToString())
|
fmt::format("Hash for BIOS '{}': {}", FileSystem::GetDisplayNameFromPath(filename), GetImageHash(ret).ToString())
|
||||||
.c_str());
|
.c_str());
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -223,7 +223,7 @@ const BIOS::ImageInfo* BIOS::GetInfoForImage(const Image& image, const Hash& has
|
||||||
return ⅈ
|
return ⅈ
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningFmt("Unknown BIOS hash: {}", hash.ToString());
|
WARNING_LOG("Unknown BIOS hash: {}", hash.ToString());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,14 +246,14 @@ void BIOS::PatchBIOS(u8* image, u32 image_size, u32 address, u32 value, u32 mask
|
||||||
SmallString old_disasm, new_disasm;
|
SmallString old_disasm, new_disasm;
|
||||||
CPU::DisassembleInstruction(&old_disasm, address, existing_value);
|
CPU::DisassembleInstruction(&old_disasm, address, existing_value);
|
||||||
CPU::DisassembleInstruction(&new_disasm, address, new_value);
|
CPU::DisassembleInstruction(&new_disasm, address, new_value);
|
||||||
Log_DevFmt("BIOS-Patch 0x{:08X} (+0x{:X}): 0x{:08X} {} -> {:08X} {}", address, offset, existing_value, old_disasm,
|
DEV_LOG("BIOS-Patch 0x{:08X} (+0x{:X}): 0x{:08X} {} -> {:08X} {}", address, offset, existing_value, old_disasm,
|
||||||
new_value, new_disasm);
|
new_value, new_disasm);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BIOS::PatchBIOSFastBoot(u8* image, u32 image_size)
|
bool BIOS::PatchBIOSFastBoot(u8* image, u32 image_size)
|
||||||
{
|
{
|
||||||
// Replace the shell entry point with a return back to the bootstrap.
|
// Replace the shell entry point with a return back to the bootstrap.
|
||||||
Log_InfoPrint("Patching BIOS to skip intro");
|
INFO_LOG("Patching BIOS to skip intro");
|
||||||
PatchBIOS(image, image_size, 0x1FC18000, 0x3C011F80); // lui at, 1f80
|
PatchBIOS(image, image_size, 0x1FC18000, 0x3C011F80); // lui at, 1f80
|
||||||
PatchBIOS(image, image_size, 0x1FC18004, 0x3C0A0300); // lui t2, 0300h
|
PatchBIOS(image, image_size, 0x1FC18004, 0x3C0A0300); // lui t2, 0300h
|
||||||
PatchBIOS(image, image_size, 0x1FC18008, 0xAC2A1814); // sw zero, 1814h(at) ; turn the display on
|
PatchBIOS(image, image_size, 0x1FC18008, 0xAC2A1814); // sw zero, 1814h(at) ; turn the display on
|
||||||
|
@ -308,8 +308,8 @@ bool BIOS::IsValidPSExeHeader(const PSEXEHeader& header, u32 file_size)
|
||||||
|
|
||||||
if ((header.file_size + sizeof(PSEXEHeader)) > file_size)
|
if ((header.file_size + sizeof(PSEXEHeader)) > file_size)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Incorrect file size in PS-EXE header: {} bytes should not be greater than {} bytes",
|
WARNING_LOG("Incorrect file size in PS-EXE header: {} bytes should not be greater than {} bytes", header.file_size,
|
||||||
header.file_size, static_cast<unsigned>(file_size - sizeof(PSEXEHeader)));
|
static_cast<unsigned>(file_size - sizeof(PSEXEHeader)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -369,9 +369,8 @@ std::optional<std::vector<u8>> BIOS::GetBIOSImage(ConsoleRegion region, Error* e
|
||||||
const ImageInfo* ii = GetInfoForImage(image.value());
|
const ImageInfo* ii = GetInfoForImage(image.value());
|
||||||
if (!ii || !IsValidBIOSForRegion(region, ii->region))
|
if (!ii || !IsValidBIOSForRegion(region, ii->region))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("BIOS region {} does not match requested region {}. This may cause issues.",
|
WARNING_LOG("BIOS region {} does not match requested region {}. This may cause issues.",
|
||||||
ii ? Settings::GetConsoleRegionName(ii->region) : "UNKNOWN",
|
ii ? Settings::GetConsoleRegionName(ii->region) : "UNKNOWN", Settings::GetConsoleRegionName(region));
|
||||||
Settings::GetConsoleRegionName(region));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +379,7 @@ std::optional<std::vector<u8>> BIOS::GetBIOSImage(ConsoleRegion region, Error* e
|
||||||
|
|
||||||
std::optional<std::vector<u8>> BIOS::FindBIOSImageInDirectory(ConsoleRegion region, const char* directory, Error* error)
|
std::optional<std::vector<u8>> BIOS::FindBIOSImageInDirectory(ConsoleRegion region, const char* directory, Error* error)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Searching for a {} BIOS in '{}'...", Settings::GetConsoleRegionName(region), directory);
|
INFO_LOG("Searching for a {} BIOS in '{}'...", Settings::GetConsoleRegionName(region), directory);
|
||||||
|
|
||||||
FileSystem::FindResultsArray results;
|
FileSystem::FindResultsArray results;
|
||||||
FileSystem::FindFiles(
|
FileSystem::FindFiles(
|
||||||
|
@ -394,7 +393,7 @@ std::optional<std::vector<u8>> BIOS::FindBIOSImageInDirectory(ConsoleRegion regi
|
||||||
{
|
{
|
||||||
if (fd.Size != BIOS_SIZE && fd.Size != BIOS_SIZE_PS2 && fd.Size != BIOS_SIZE_PS3)
|
if (fd.Size != BIOS_SIZE && fd.Size != BIOS_SIZE_PS2 && fd.Size != BIOS_SIZE_PS3)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Skipping '{}': incorrect size", fd.FileName.c_str());
|
WARNING_LOG("Skipping '{}': incorrect size", fd.FileName.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +405,7 @@ std::optional<std::vector<u8>> BIOS::FindBIOSImageInDirectory(ConsoleRegion regi
|
||||||
const ImageInfo* ii = GetInfoForImage(found_image.value());
|
const ImageInfo* ii = GetInfoForImage(found_image.value());
|
||||||
if (ii && IsValidBIOSForRegion(region, ii->region))
|
if (ii && IsValidBIOSForRegion(region, ii->region))
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Using BIOS '{}': {}", fd.FileName.c_str(), ii->description);
|
INFO_LOG("Using BIOS '{}': {}", fd.FileName.c_str(), ii->description);
|
||||||
fallback_image = std::move(found_image);
|
fallback_image = std::move(found_image);
|
||||||
return fallback_image;
|
return fallback_image;
|
||||||
}
|
}
|
||||||
|
@ -429,12 +428,12 @@ std::optional<std::vector<u8>> BIOS::FindBIOSImageInDirectory(ConsoleRegion regi
|
||||||
|
|
||||||
if (!fallback_info)
|
if (!fallback_info)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Using unknown BIOS '{}'. This may crash.", Path::GetFileName(fallback_path));
|
WARNING_LOG("Using unknown BIOS '{}'. This may crash.", Path::GetFileName(fallback_path));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Falling back to possibly-incompatible image '{}': {}", Path::GetFileName(fallback_path),
|
WARNING_LOG("Falling back to possibly-incompatible image '{}': {}", Path::GetFileName(fallback_path),
|
||||||
fallback_info->description);
|
fallback_info->description);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fallback_image;
|
return fallback_image;
|
||||||
|
|
|
@ -200,7 +200,7 @@ bool Bus::AllocateMemory(Error* error)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_VerboseFmt("RAM is mapped at {}.", static_cast<void*>(g_ram));
|
VERBOSE_LOG("RAM is mapped at {}.", static_cast<void*>(g_ram));
|
||||||
|
|
||||||
g_bios = static_cast<u8*>(MemMap::MapSharedMemory(s_shmem_handle, MemoryMap::BIOS_OFFSET, nullptr,
|
g_bios = static_cast<u8*>(MemMap::MapSharedMemory(s_shmem_handle, MemoryMap::BIOS_OFFSET, nullptr,
|
||||||
MemoryMap::BIOS_SIZE, PageProtect::ReadWrite));
|
MemoryMap::BIOS_SIZE, PageProtect::ReadWrite));
|
||||||
|
@ -211,7 +211,7 @@ bool Bus::AllocateMemory(Error* error)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_VerboseFmt("BIOS is mapped at {}.", static_cast<void*>(g_bios));
|
VERBOSE_LOG("BIOS is mapped at {}.", static_cast<void*>(g_bios));
|
||||||
|
|
||||||
g_memory_handlers = static_cast<void**>(MemMap::MapSharedMemory(s_shmem_handle, MemoryMap::LUT_OFFSET, nullptr,
|
g_memory_handlers = static_cast<void**>(MemMap::MapSharedMemory(s_shmem_handle, MemoryMap::LUT_OFFSET, nullptr,
|
||||||
MemoryMap::LUT_SIZE, PageProtect::ReadWrite));
|
MemoryMap::LUT_SIZE, PageProtect::ReadWrite));
|
||||||
|
@ -222,7 +222,7 @@ bool Bus::AllocateMemory(Error* error)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_VerboseFmt("LUTs are mapped at {}.", static_cast<void*>(g_memory_handlers));
|
VERBOSE_LOG("LUTs are mapped at {}.", static_cast<void*>(g_memory_handlers));
|
||||||
g_memory_handlers_isc = g_memory_handlers + MEMORY_LUT_SLOTS;
|
g_memory_handlers_isc = g_memory_handlers + MEMORY_LUT_SLOTS;
|
||||||
SetHandlers();
|
SetHandlers();
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ bool Bus::AllocateMemory(Error* error)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Fastmem base: {}", static_cast<void*>(s_fastmem_arena.BasePointer()));
|
INFO_LOG("Fastmem base: {}", static_cast<void*>(s_fastmem_arena.BasePointer()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
|
@ -351,7 +351,7 @@ void Bus::AddTTYCharacter(char ch)
|
||||||
{
|
{
|
||||||
if (!s_tty_line_buffer.empty())
|
if (!s_tty_line_buffer.empty())
|
||||||
{
|
{
|
||||||
Log::WriteFmt("TTY", "", LOGLEVEL_INFO, "\033[1;34m{}\033[0m", s_tty_line_buffer);
|
Log::FastWrite("TTY", "", LOGLEVEL_INFO, "\033[1;34m{}\033[0m", s_tty_line_buffer);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (CPU::IsTraceEnabled())
|
if (CPU::IsTraceEnabled())
|
||||||
CPU::WriteToExecutionLog("TTY: %s\n", s_tty_line_buffer.c_str());
|
CPU::WriteToExecutionLog("TTY: %s\n", s_tty_line_buffer.c_str());
|
||||||
|
@ -392,7 +392,7 @@ bool Bus::DoState(StateWrapper& sw)
|
||||||
|
|
||||||
if (sw.GetVersion() < 58)
|
if (sw.GetVersion() < 58)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Overwriting loaded BIOS with old save state.");
|
WARNING_LOG("Overwriting loaded BIOS with old save state.");
|
||||||
sw.DoBytes(g_bios, BIOS_SIZE);
|
sw.DoBytes(g_bios, BIOS_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,15 +452,15 @@ void Bus::RecalculateMemoryTimings()
|
||||||
std::tie(g_spu_access_time[0], g_spu_access_time[1], g_spu_access_time[2]) =
|
std::tie(g_spu_access_time[0], g_spu_access_time[1], g_spu_access_time[2]) =
|
||||||
CalculateMemoryTiming(s_MEMCTRL.spu_delay_size, s_MEMCTRL.common_delay);
|
CalculateMemoryTiming(s_MEMCTRL.spu_delay_size, s_MEMCTRL.common_delay);
|
||||||
|
|
||||||
Log_TraceFmt("BIOS Memory Timing: {} bit bus, byte={}, halfword={}, word={}",
|
TRACE_LOG("BIOS Memory Timing: {} bit bus, byte={}, halfword={}, word={}",
|
||||||
s_MEMCTRL.bios_delay_size.data_bus_16bit ? 16 : 8, g_bios_access_time[0] + 1, g_bios_access_time[1] + 1,
|
s_MEMCTRL.bios_delay_size.data_bus_16bit ? 16 : 8, g_bios_access_time[0] + 1, g_bios_access_time[1] + 1,
|
||||||
g_bios_access_time[2] + 1);
|
g_bios_access_time[2] + 1);
|
||||||
Log_TraceFmt("CDROM Memory Timing: {} bit bus, byte={}, halfword={}, word={}",
|
TRACE_LOG("CDROM Memory Timing: {} bit bus, byte={}, halfword={}, word={}",
|
||||||
s_MEMCTRL.cdrom_delay_size.data_bus_16bit ? 16 : 8, g_cdrom_access_time[0] + 1,
|
s_MEMCTRL.cdrom_delay_size.data_bus_16bit ? 16 : 8, g_cdrom_access_time[0] + 1, g_cdrom_access_time[1] + 1,
|
||||||
g_cdrom_access_time[1] + 1, g_cdrom_access_time[2] + 1);
|
g_cdrom_access_time[2] + 1);
|
||||||
Log_TraceFmt("SPU Memory Timing: {} bit bus, byte={}, halfword={}, word={}",
|
TRACE_LOG("SPU Memory Timing: {} bit bus, byte={}, halfword={}, word={}",
|
||||||
s_MEMCTRL.spu_delay_size.data_bus_16bit ? 16 : 8, g_spu_access_time[0] + 1, g_spu_access_time[1] + 1,
|
s_MEMCTRL.spu_delay_size.data_bus_16bit ? 16 : 8, g_spu_access_time[0] + 1, g_spu_access_time[1] + 1,
|
||||||
g_spu_access_time[2] + 1);
|
g_spu_access_time[2] + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUFastmemMode Bus::GetFastmemMode()
|
CPUFastmemMode Bus::GetFastmemMode()
|
||||||
|
@ -506,8 +506,8 @@ void Bus::UpdateFastmemViews(CPUFastmemMode mode)
|
||||||
u8* map_address = s_fastmem_arena.BasePointer() + base_address;
|
u8* map_address = s_fastmem_arena.BasePointer() + base_address;
|
||||||
if (!s_fastmem_arena.Map(s_shmem_handle, 0, map_address, g_ram_size, PageProtect::ReadWrite)) [[unlikely]]
|
if (!s_fastmem_arena.Map(s_shmem_handle, 0, map_address, g_ram_size, PageProtect::ReadWrite)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to map RAM at fastmem area {} (offset 0x{:08X})", static_cast<void*>(map_address),
|
ERROR_LOG("Failed to map RAM at fastmem area {} (offset 0x{:08X})", static_cast<void*>(map_address),
|
||||||
g_ram_size);
|
g_ram_size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ void Bus::UpdateFastmemViews(CPUFastmemMode mode)
|
||||||
u8* page_address = map_address + (i * HOST_PAGE_SIZE);
|
u8* page_address = map_address + (i * HOST_PAGE_SIZE);
|
||||||
if (!MemMap::MemProtect(page_address, HOST_PAGE_SIZE, PageProtect::ReadOnly)) [[unlikely]]
|
if (!MemMap::MemProtect(page_address, HOST_PAGE_SIZE, PageProtect::ReadOnly)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to write-protect code page at {}", static_cast<void*>(page_address));
|
ERROR_LOG("Failed to write-protect code page at {}", static_cast<void*>(page_address));
|
||||||
s_fastmem_arena.Unmap(map_address, g_ram_size);
|
s_fastmem_arena.Unmap(map_address, g_ram_size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ void Bus::UpdateFastmemViews(CPUFastmemMode mode)
|
||||||
s_fastmem_lut = static_cast<u8**>(std::malloc(sizeof(u8*) * FASTMEM_LUT_SLOTS));
|
s_fastmem_lut = static_cast<u8**>(std::malloc(sizeof(u8*) * FASTMEM_LUT_SLOTS));
|
||||||
Assert(s_fastmem_lut);
|
Assert(s_fastmem_lut);
|
||||||
|
|
||||||
Log_InfoFmt("Fastmem base (software): {}", static_cast<void*>(s_fastmem_lut));
|
INFO_LOG("Fastmem base (software): {}", static_cast<void*>(s_fastmem_lut));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This assumes the top 4KB of address space is not mapped. It shouldn't be on any sane OSes.
|
// This assumes the top 4KB of address space is not mapped. It shouldn't be on any sane OSes.
|
||||||
|
@ -637,9 +637,9 @@ void Bus::SetRAMPageWritable(u32 page_index, bool writable)
|
||||||
if (!MemMap::MemProtect(&g_ram[page_index * HOST_PAGE_SIZE], HOST_PAGE_SIZE,
|
if (!MemMap::MemProtect(&g_ram[page_index * HOST_PAGE_SIZE], HOST_PAGE_SIZE,
|
||||||
writable ? PageProtect::ReadWrite : PageProtect::ReadOnly)) [[unlikely]]
|
writable ? PageProtect::ReadWrite : PageProtect::ReadOnly)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to set RAM host page {} ({}) to {}", page_index,
|
ERROR_LOG("Failed to set RAM host page {} ({}) to {}", page_index,
|
||||||
reinterpret_cast<const void*>(&g_ram[page_index * HOST_PAGE_SIZE]),
|
reinterpret_cast<const void*>(&g_ram[page_index * HOST_PAGE_SIZE]),
|
||||||
writable ? "read-write" : "read-only");
|
writable ? "read-write" : "read-only");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MMAP_FASTMEM
|
#ifdef ENABLE_MMAP_FASTMEM
|
||||||
|
@ -653,8 +653,8 @@ void Bus::SetRAMPageWritable(u32 page_index, bool writable)
|
||||||
u8* page_address = it.first + (page_index * HOST_PAGE_SIZE);
|
u8* page_address = it.first + (page_index * HOST_PAGE_SIZE);
|
||||||
if (!MemMap::MemProtect(page_address, HOST_PAGE_SIZE, protect)) [[unlikely]]
|
if (!MemMap::MemProtect(page_address, HOST_PAGE_SIZE, protect)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to {} code page {} (0x{:08X}) @ {}", writable ? "unprotect" : "protect", page_index,
|
ERROR_LOG("Failed to {} code page {} (0x{:08X}) @ {}", writable ? "unprotect" : "protect", page_index,
|
||||||
page_index * static_cast<u32>(HOST_PAGE_SIZE), static_cast<void*>(page_address));
|
page_index * static_cast<u32>(HOST_PAGE_SIZE), static_cast<void*>(page_address));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ void Bus::ClearRAMCodePageFlags()
|
||||||
g_ram_code_bits.reset();
|
g_ram_code_bits.reset();
|
||||||
|
|
||||||
if (!MemMap::MemProtect(g_ram, RAM_8MB_SIZE, PageProtect::ReadWrite))
|
if (!MemMap::MemProtect(g_ram, RAM_8MB_SIZE, PageProtect::ReadWrite))
|
||||||
Log_ErrorPrint("Failed to restore RAM protection to read-write.");
|
ERROR_LOG("Failed to restore RAM protection to read-write.");
|
||||||
|
|
||||||
#ifdef ENABLE_MMAP_FASTMEM
|
#ifdef ENABLE_MMAP_FASTMEM
|
||||||
if (s_fastmem_mode == CPUFastmemMode::MMap)
|
if (s_fastmem_mode == CPUFastmemMode::MMap)
|
||||||
|
@ -677,7 +677,7 @@ void Bus::ClearRAMCodePageFlags()
|
||||||
for (const auto& it : s_fastmem_ram_views)
|
for (const auto& it : s_fastmem_ram_views)
|
||||||
{
|
{
|
||||||
if (!MemMap::MemProtect(it.first, it.second, PageProtect::ReadWrite))
|
if (!MemMap::MemProtect(it.first, it.second, PageProtect::ReadWrite))
|
||||||
Log_ErrorFmt("Failed to unprotect code pages for fastmem view @ %p", static_cast<void*>(it.first));
|
ERROR_LOG("Failed to unprotect code pages for fastmem view @ %p", static_cast<void*>(it.first));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -881,8 +881,8 @@ template<MemoryAccessSize size>
|
||||||
u32 Bus::UnknownReadHandler(VirtualMemoryAddress address)
|
u32 Bus::UnknownReadHandler(VirtualMemoryAddress address)
|
||||||
{
|
{
|
||||||
static constexpr const char* sizes[3] = {"byte", "halfword", "word"};
|
static constexpr const char* sizes[3] = {"byte", "halfword", "word"};
|
||||||
Log_ErrorFmt("Invalid {} read at address 0x{:08X}, pc 0x{:08X}", sizes[static_cast<u32>(size)], address,
|
ERROR_LOG("Invalid {} read at address 0x{:08X}, pc 0x{:08X}", sizes[static_cast<u32>(size)], address,
|
||||||
CPU::g_state.pc);
|
CPU::g_state.pc);
|
||||||
return 0xFFFFFFFFu;
|
return 0xFFFFFFFFu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -890,8 +890,8 @@ template<MemoryAccessSize size>
|
||||||
void Bus::UnknownWriteHandler(VirtualMemoryAddress address, u32 value)
|
void Bus::UnknownWriteHandler(VirtualMemoryAddress address, u32 value)
|
||||||
{
|
{
|
||||||
static constexpr const char* sizes[3] = {"byte", "halfword", "word"};
|
static constexpr const char* sizes[3] = {"byte", "halfword", "word"};
|
||||||
Log_ErrorFmt("Invalid {} write at address 0x{:08X}, value 0x{:08X}, pc 0x{:08X}", sizes[static_cast<u32>(size)],
|
ERROR_LOG("Invalid {} write at address 0x{:08X}, value 0x{:08X}, pc 0x{:08X}", sizes[static_cast<u32>(size)], address,
|
||||||
address, value, CPU::g_state.pc);
|
value, CPU::g_state.pc);
|
||||||
CPU::g_state.bus_error = true;
|
CPU::g_state.bus_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,7 +1042,7 @@ void Bus::CacheControlWriteHandler(VirtualMemoryAddress address, u32 value)
|
||||||
if (address != 0xFFFE0130)
|
if (address != 0xFFFE0130)
|
||||||
return UnknownWriteHandler<size>(address, value);
|
return UnknownWriteHandler<size>(address, value);
|
||||||
|
|
||||||
Log_DevFmt("Cache control <- 0x{:08X}", value);
|
DEV_LOG("Cache control <- 0x{:08X}", value);
|
||||||
CPU::g_state.cache_control.bits = value;
|
CPU::g_state.cache_control.bits = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,7 +1122,7 @@ u32 Bus::EXP1ReadHandler(VirtualMemoryAddress address)
|
||||||
template<MemoryAccessSize size>
|
template<MemoryAccessSize size>
|
||||||
void Bus::EXP1WriteHandler(VirtualMemoryAddress address, u32 value)
|
void Bus::EXP1WriteHandler(VirtualMemoryAddress address, u32 value)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("EXP1 write: 0x{:08X} <- 0x{:08X}", address, value);
|
WARNING_LOG("EXP1 write: 0x{:08X} <- 0x{:08X}", address, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<MemoryAccessSize size>
|
template<MemoryAccessSize size>
|
||||||
|
@ -1145,7 +1145,7 @@ u32 Bus::EXP2ReadHandler(VirtualMemoryAddress address)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("EXP2 read: 0x{:08X}", address);
|
WARNING_LOG("EXP2 read: 0x{:08X}", address);
|
||||||
value = UINT32_C(0xFFFFFFFF);
|
value = UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1162,11 +1162,11 @@ void Bus::EXP2WriteHandler(VirtualMemoryAddress address, u32 value)
|
||||||
}
|
}
|
||||||
else if (offset == 0x41 || offset == 0x42)
|
else if (offset == 0x41 || offset == 0x42)
|
||||||
{
|
{
|
||||||
Log_DevFmt("BIOS POST status: {:02X}", value & UINT32_C(0x0F));
|
DEV_LOG("BIOS POST status: {:02X}", value & UINT32_C(0x0F));
|
||||||
}
|
}
|
||||||
else if (offset == 0x70)
|
else if (offset == 0x70)
|
||||||
{
|
{
|
||||||
Log_DevFmt("BIOS POST2 status: {:02X}", value & UINT32_C(0x0F));
|
DEV_LOG("BIOS POST2 status: {:02X}", value & UINT32_C(0x0F));
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
// TODO: Put behind configuration variable
|
// TODO: Put behind configuration variable
|
||||||
|
@ -1187,14 +1187,14 @@ void Bus::EXP2WriteHandler(VirtualMemoryAddress address, u32 value)
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("EXP2 write: 0x{:08X} <- 0x{:08X}", address, value);
|
WARNING_LOG("EXP2 write: 0x{:08X} <- 0x{:08X}", address, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<MemoryAccessSize size>
|
template<MemoryAccessSize size>
|
||||||
u32 Bus::EXP3ReadHandler(VirtualMemoryAddress address)
|
u32 Bus::EXP3ReadHandler(VirtualMemoryAddress address)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("EXP3 read: 0x{:08X}", address);
|
WARNING_LOG("EXP3 read: 0x{:08X}", address);
|
||||||
return UINT32_C(0xFFFFFFFF);
|
return UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1203,7 +1203,7 @@ void Bus::EXP3WriteHandler(VirtualMemoryAddress address, u32 value)
|
||||||
{
|
{
|
||||||
const u32 offset = address & EXP3_MASK;
|
const u32 offset = address & EXP3_MASK;
|
||||||
if (offset == 0)
|
if (offset == 0)
|
||||||
Log_WarningFmt("BIOS POST3 status: {:02X}", value & UINT32_C(0x0F));
|
WARNING_LOG("BIOS POST3 status: {:02X}", value & UINT32_C(0x0F));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1762,7 +1762,7 @@ void** Bus::GetMemoryHandlers(bool isolate_cache, bool swap_caches)
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (swap_caches)
|
if (swap_caches)
|
||||||
Log_WarningPrint("Cache isolated and swapped, icache will be written instead of scratchpad?");
|
WARNING_LOG("Cache isolated and swapped, icache will be written instead of scratchpad?");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return g_memory_handlers_isc;
|
return g_memory_handlers_isc;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -25,7 +25,7 @@ void CDROMAsyncReader::StartThread(u32 readahead_count)
|
||||||
|
|
||||||
m_shutdown_flag.store(false);
|
m_shutdown_flag.store(false);
|
||||||
m_read_thread = std::thread(&CDROMAsyncReader::WorkerThreadEntryPoint, this);
|
m_read_thread = std::thread(&CDROMAsyncReader::WorkerThreadEntryPoint, this);
|
||||||
Log_InfoFmt("Read thread started with readahead of {} sectors", readahead_count);
|
INFO_LOG("Read thread started with readahead of {} sectors", readahead_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDROMAsyncReader::StopThread()
|
void CDROMAsyncReader::StopThread()
|
||||||
|
@ -82,7 +82,7 @@ bool CDROMAsyncReader::Precache(ProgressCallback* callback)
|
||||||
const CDImage::LBA lba = m_media->GetPositionOnDisc();
|
const CDImage::LBA lba = m_media->GetPositionOnDisc();
|
||||||
if (!memory_image->Seek(lba)) [[unlikely]]
|
if (!memory_image->Seek(lba)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to seek to LBA {} in memory image", lba);
|
ERROR_LOG("Failed to seek to LBA {} in memory image", lba);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void CDROMAsyncReader::QueueReadSector(CDImage::LBA lba)
|
||||||
const u32 buffer_front = m_buffer_front.load();
|
const u32 buffer_front = m_buffer_front.load();
|
||||||
if (m_buffers[buffer_front].lba == lba)
|
if (m_buffers[buffer_front].lba == lba)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Skipping re-reading same sector {}", lba);
|
DEBUG_LOG("Skipping re-reading same sector {}", lba);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ void CDROMAsyncReader::QueueReadSector(CDImage::LBA lba)
|
||||||
if (m_buffer_count > 1 && m_buffers[next_buffer].lba == lba)
|
if (m_buffer_count > 1 && m_buffers[next_buffer].lba == lba)
|
||||||
{
|
{
|
||||||
// great, don't need a seek, but still kick the thread to start reading ahead again
|
// great, don't need a seek, but still kick the thread to start reading ahead again
|
||||||
Log_DebugFmt("Readahead buffer hit for sector {}", lba);
|
DEBUG_LOG("Readahead buffer hit for sector {}", lba);
|
||||||
m_buffer_front.store(next_buffer);
|
m_buffer_front.store(next_buffer);
|
||||||
m_buffer_count.fetch_sub(1);
|
m_buffer_count.fetch_sub(1);
|
||||||
m_can_readahead.store(true);
|
m_can_readahead.store(true);
|
||||||
|
@ -134,7 +134,7 @@ void CDROMAsyncReader::QueueReadSector(CDImage::LBA lba)
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to toss away our readahead and start fresh
|
// we need to toss away our readahead and start fresh
|
||||||
Log_DebugFmt("Readahead buffer miss, queueing seek to {}", lba);
|
DEBUG_LOG("Readahead buffer miss, queueing seek to {}", lba);
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
m_next_position_set.store(true);
|
m_next_position_set.store(true);
|
||||||
m_next_position = lba;
|
m_next_position = lba;
|
||||||
|
@ -156,7 +156,7 @@ bool CDROMAsyncReader::ReadSectorUncached(CDImage::LBA lba, CDImage::SubChannelQ
|
||||||
const bool result = InternalReadSectorUncached(lba, subq, data);
|
const bool result = InternalReadSectorUncached(lba, subq, data);
|
||||||
if (!m_media->Seek(prev_lba)) [[unlikely]]
|
if (!m_media->Seek(prev_lba)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to re-seek to cached position {}", prev_lba);
|
ERROR_LOG("Failed to re-seek to cached position {}", prev_lba);
|
||||||
m_can_readahead.store(false);
|
m_can_readahead.store(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,13 +167,13 @@ bool CDROMAsyncReader::InternalReadSectorUncached(CDImage::LBA lba, CDImage::Sub
|
||||||
{
|
{
|
||||||
if (m_media->GetPositionOnDisc() != lba && !m_media->Seek(lba)) [[unlikely]]
|
if (m_media->GetPositionOnDisc() != lba && !m_media->Seek(lba)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Seek to LBA {} failed", lba);
|
WARNING_LOG("Seek to LBA {} failed", lba);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_media->ReadRawSector(data, subq)) [[unlikely]]
|
if (!m_media->ReadRawSector(data, subq)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Read of LBA {} failed", lba);
|
WARNING_LOG("Read of LBA {} failed", lba);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,12 +185,12 @@ bool CDROMAsyncReader::WaitForReadToComplete()
|
||||||
// Safe without locking with memory_order_seq_cst.
|
// Safe without locking with memory_order_seq_cst.
|
||||||
if (!m_next_position_set.load() && m_buffer_count.load() > 0)
|
if (!m_next_position_set.load() && m_buffer_count.load() > 0)
|
||||||
{
|
{
|
||||||
Log_TraceFmt("Returning sector {}", m_buffers[m_buffer_front.load()].lba);
|
TRACE_LOG("Returning sector {}", m_buffers[m_buffer_front.load()].lba);
|
||||||
return m_buffers[m_buffer_front.load()].result;
|
return m_buffers[m_buffer_front.load()].result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Timer wait_timer;
|
Common::Timer wait_timer;
|
||||||
Log_DebugPrint("Sector read pending, waiting");
|
DEBUG_LOG("Sector read pending, waiting");
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
m_notify_read_complete_cv.wait(
|
m_notify_read_complete_cv.wait(
|
||||||
|
@ -204,9 +204,9 @@ bool CDROMAsyncReader::WaitForReadToComplete()
|
||||||
const u32 front = m_buffer_front.load();
|
const u32 front = m_buffer_front.load();
|
||||||
const double wait_time = wait_timer.GetTimeMilliseconds();
|
const double wait_time = wait_timer.GetTimeMilliseconds();
|
||||||
if (wait_time > 1.0f) [[unlikely]]
|
if (wait_time > 1.0f) [[unlikely]]
|
||||||
Log_WarningFmt("Had to wait {:.2f} msec for LBA {}", wait_time, m_buffers[front].lba);
|
WARNING_LOG("Had to wait {:.2f} msec for LBA {}", wait_time, m_buffers[front].lba);
|
||||||
|
|
||||||
Log_TraceFmt("Returning sector {} after waiting", m_buffers[front].lba);
|
TRACE_LOG("Returning sector {} after waiting", m_buffers[front].lba);
|
||||||
return m_buffers[front].result;
|
return m_buffers[front].result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,18 +238,18 @@ bool CDROMAsyncReader::ReadSectorIntoBuffer(std::unique_lock<std::mutex>& lock)
|
||||||
m_is_reading.store(true);
|
m_is_reading.store(true);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
Log_TraceFmt("Reading LBA {}...", buffer.lba);
|
TRACE_LOG("Reading LBA {}...", buffer.lba);
|
||||||
|
|
||||||
buffer.result = m_media->ReadRawSector(buffer.data.data(), &buffer.subq);
|
buffer.result = m_media->ReadRawSector(buffer.data.data(), &buffer.subq);
|
||||||
if (buffer.result) [[likely]]
|
if (buffer.result) [[likely]]
|
||||||
{
|
{
|
||||||
const double read_time = timer.GetTimeMilliseconds();
|
const double read_time = timer.GetTimeMilliseconds();
|
||||||
if (read_time > 1.0f) [[unlikely]]
|
if (read_time > 1.0f) [[unlikely]]
|
||||||
Log_DevFmt("Read LBA {} took {:.2f} msec", buffer.lba, read_time);
|
DEV_LOG("Read LBA {} took {:.2f} msec", buffer.lba, read_time);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Read of LBA {} failed", buffer.lba);
|
ERROR_LOG("Read of LBA {} failed", buffer.lba);
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
@ -269,7 +269,7 @@ void CDROMAsyncReader::ReadSectorNonThreaded(CDImage::LBA lba)
|
||||||
|
|
||||||
if (m_media->GetPositionOnDisc() != lba && !m_media->Seek(lba))
|
if (m_media->GetPositionOnDisc() != lba && !m_media->Seek(lba))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Seek to LBA {} failed", lba);
|
WARNING_LOG("Seek to LBA {} failed", lba);
|
||||||
m_seek_error.store(true);
|
m_seek_error.store(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -277,18 +277,18 @@ void CDROMAsyncReader::ReadSectorNonThreaded(CDImage::LBA lba)
|
||||||
BufferSlot& buffer = m_buffers.front();
|
BufferSlot& buffer = m_buffers.front();
|
||||||
buffer.lba = m_media->GetPositionOnDisc();
|
buffer.lba = m_media->GetPositionOnDisc();
|
||||||
|
|
||||||
Log_TraceFmt("Reading LBA {}...", buffer.lba);
|
TRACE_LOG("Reading LBA {}...", buffer.lba);
|
||||||
|
|
||||||
buffer.result = m_media->ReadRawSector(buffer.data.data(), &buffer.subq);
|
buffer.result = m_media->ReadRawSector(buffer.data.data(), &buffer.subq);
|
||||||
if (buffer.result) [[likely]]
|
if (buffer.result) [[likely]]
|
||||||
{
|
{
|
||||||
const double read_time = timer.GetTimeMilliseconds();
|
const double read_time = timer.GetTimeMilliseconds();
|
||||||
if (read_time > 1.0f) [[unlikely]]
|
if (read_time > 1.0f) [[unlikely]]
|
||||||
Log_DevFmt("Read LBA {} took {:.2f} msec", buffer.lba, read_time);
|
DEV_LOG("Read LBA {} took {:.2f} msec", buffer.lba, read_time);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Read of LBA {} failed", buffer.lba);
|
ERROR_LOG("Read of LBA {} failed", buffer.lba);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_buffer_count.fetch_add(1);
|
m_buffer_count.fetch_add(1);
|
||||||
|
@ -296,7 +296,7 @@ void CDROMAsyncReader::ReadSectorNonThreaded(CDImage::LBA lba)
|
||||||
|
|
||||||
void CDROMAsyncReader::CancelReadahead()
|
void CDROMAsyncReader::CancelReadahead()
|
||||||
{
|
{
|
||||||
Log_DevPrint("Cancelling readahead");
|
DEV_LOG("Cancelling readahead");
|
||||||
|
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ void CDROMAsyncReader::WorkerThreadEntryPoint()
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
// seek without lock held in case it takes time
|
// seek without lock held in case it takes time
|
||||||
Log_DebugFmt("Seeking to LBA {}...", seek_location);
|
DEBUG_LOG("Seeking to LBA {}...", seek_location);
|
||||||
const bool seek_result = (m_media->GetPositionOnDisc() == seek_location || m_media->Seek(seek_location));
|
const bool seek_result = (m_media->GetPositionOnDisc() == seek_location || m_media->Seek(seek_location));
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
@ -346,7 +346,7 @@ void CDROMAsyncReader::WorkerThreadEntryPoint()
|
||||||
if (!seek_result) [[unlikely]]
|
if (!seek_result) [[unlikely]]
|
||||||
{
|
{
|
||||||
// add the error result, and don't try to read ahead
|
// add the error result, and don't try to read ahead
|
||||||
Log_WarningFmt("Seek to LBA {} failed", seek_location);
|
WARNING_LOG("Seek to LBA {} failed", seek_location);
|
||||||
m_seek_error.store(true);
|
m_seek_error.store(true);
|
||||||
m_notify_read_complete_cv.notify_all();
|
m_notify_read_complete_cv.notify_all();
|
||||||
break;
|
break;
|
||||||
|
@ -360,7 +360,7 @@ void CDROMAsyncReader::WorkerThreadEntryPoint()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// readahead time! read as many sectors as we have space for
|
// readahead time! read as many sectors as we have space for
|
||||||
Log_DebugFmt("Reading ahead {} sectors...", static_cast<u32>(m_buffers.size()) - m_buffer_count.load());
|
DEBUG_LOG("Reading ahead {} sectors...", static_cast<u32>(m_buffers.size()) - m_buffer_count.load());
|
||||||
while (m_buffer_count.load() < static_cast<u32>(m_buffers.size()))
|
while (m_buffer_count.load() < static_cast<u32>(m_buffers.size()))
|
||||||
{
|
{
|
||||||
if (m_next_position_set.load())
|
if (m_next_position_set.load())
|
||||||
|
|
|
@ -311,7 +311,7 @@ bool CheatList::LoadFromPCSXRString(const std::string& str)
|
||||||
m_codes.push_back(std::move(current_code));
|
m_codes.push_back(std::move(current_code));
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} cheats (PCSXR format)", m_codes.size());
|
INFO_LOG("Loaded {} cheats (PCSXR format)", m_codes.size());
|
||||||
return !m_codes.empty();
|
return !m_codes.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ bool CheatList::LoadFromLibretroString(const std::string& str)
|
||||||
const std::string* enable = FindKey(kvp, TinyString::from_format("cheat{}_enable", i));
|
const std::string* enable = FindKey(kvp, TinyString::from_format("cheat{}_enable", i));
|
||||||
if (!desc || !code || !enable)
|
if (!desc || !code || !enable)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Missing desc/code/enable for cheat {}", i);
|
WARNING_LOG("Missing desc/code/enable for cheat {}", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ bool CheatList::LoadFromLibretroString(const std::string& str)
|
||||||
m_codes.push_back(std::move(cc));
|
m_codes.push_back(std::move(cc));
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} cheats (libretro format)", m_codes.size());
|
INFO_LOG("Loaded {} cheats (libretro format)", m_codes.size());
|
||||||
return !m_codes.empty();
|
return !m_codes.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ bool CheatList::LoadFromEPSXeString(const std::string& str)
|
||||||
if (current_code.Valid())
|
if (current_code.Valid())
|
||||||
m_codes.push_back(std::move(current_code));
|
m_codes.push_back(std::move(current_code));
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} cheats (EPSXe format)", m_codes.size());
|
INFO_LOG("Loaded {} cheats (EPSXe format)", m_codes.size());
|
||||||
return !m_codes.empty();
|
return !m_codes.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ bool CheatList::ParseLibretroCheat(CheatCode* cc, const char* line)
|
||||||
{
|
{
|
||||||
if (!IsLibretroSeparator(*end_ptr))
|
if (!IsLibretroSeparator(*end_ptr))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Malformed code '{}'", line);
|
WARNING_LOG("Malformed code '{}'", line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ bool CheatList::ParseLibretroCheat(CheatCode* cc, const char* line)
|
||||||
{
|
{
|
||||||
if (!IsLibretroSeparator(*end_ptr))
|
if (!IsLibretroSeparator(*end_ptr))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Malformed code '{}'", line);
|
WARNING_LOG("Malformed code '{}'", line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,11 +791,11 @@ bool CheatList::LoadFromPackage(const std::string& serial)
|
||||||
if (current_code.Valid())
|
if (current_code.Valid())
|
||||||
m_codes.push_back(std::move(current_code));
|
m_codes.push_back(std::move(current_code));
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} codes from package for {}", m_codes.size(), serial);
|
INFO_LOG("Loaded {} codes from package for {}", m_codes.size(), serial);
|
||||||
return !m_codes.empty();
|
return !m_codes.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningFmt("No codes found in package for {}", serial);
|
WARNING_LOG("No codes found in package for {}", serial);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1266,7 +1266,7 @@ void CheatCode::Apply() const
|
||||||
|
|
||||||
if ((index + 4) >= instructions.size())
|
if ((index + 4) >= instructions.size())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Incomplete find/replace instruction");
|
ERROR_LOG("Incomplete find/replace instruction");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const Instruction& inst2 = instructions[index + 1];
|
const Instruction& inst2 = instructions[index + 1];
|
||||||
|
@ -1754,7 +1754,7 @@ void CheatCode::Apply() const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
Log_ErrorPrint("Incorrect conditional instruction (see chtdb.txt for supported instructions)");
|
ERROR_LOG("Incorrect conditional instruction (see chtdb.txt for supported instructions)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1866,14 +1866,14 @@ void CheatCode::Apply() const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
Log_ErrorPrint("Incorrect conditional instruction (see chtdb.txt for supported instructions)");
|
ERROR_LOG("Incorrect conditional instruction (see chtdb.txt for supported instructions)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Incomplete multi conditional instruction");
|
ERROR_LOG("Incomplete multi conditional instruction");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (conditions_check == true)
|
if (conditions_check == true)
|
||||||
|
@ -2518,7 +2518,7 @@ void CheatCode::Apply() const
|
||||||
{
|
{
|
||||||
if ((index + 1) >= instructions.size())
|
if ((index + 1) >= instructions.size())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Incomplete slide instruction");
|
ERROR_LOG("Incomplete slide instruction");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2550,7 +2550,7 @@ void CheatCode::Apply() const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid command in second slide parameter 0x{:02X}", static_cast<unsigned>(write_type));
|
ERROR_LOG("Invalid command in second slide parameter 0x{:02X}", static_cast<unsigned>(write_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
index += 2;
|
index += 2;
|
||||||
|
@ -2561,7 +2561,7 @@ void CheatCode::Apply() const
|
||||||
{
|
{
|
||||||
if ((index + 1) >= instructions.size())
|
if ((index + 1) >= instructions.size())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Incomplete slide instruction");
|
ERROR_LOG("Incomplete slide instruction");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2622,7 +2622,7 @@ void CheatCode::Apply() const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid command in second slide parameter 0x{:02X}", static_cast<unsigned>(write_type));
|
ERROR_LOG("Invalid command in second slide parameter 0x{:02X}", static_cast<unsigned>(write_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
index += 2;
|
index += 2;
|
||||||
|
@ -2633,7 +2633,7 @@ void CheatCode::Apply() const
|
||||||
{
|
{
|
||||||
if ((index + 1) >= instructions.size())
|
if ((index + 1) >= instructions.size())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Incomplete memory copy instruction");
|
ERROR_LOG("Incomplete memory copy instruction");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2656,8 +2656,8 @@ void CheatCode::Apply() const
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unhandled instruction code 0x{:02X} ({:08X} {:08X})", static_cast<u8>(inst.code.GetValue()),
|
ERROR_LOG("Unhandled instruction code 0x{:02X} ({:08X} {:08X})", static_cast<u8>(inst.code.GetValue()),
|
||||||
inst.first, inst.second);
|
inst.first, inst.second);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2757,8 +2757,8 @@ void CheatCode::ApplyOnDisable() const
|
||||||
|
|
||||||
[[unlikely]] default:
|
[[unlikely]] default:
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unhandled instruction code 0x{:02X} ({:08X} {:08X})", static_cast<u8>(inst.code.GetValue()),
|
ERROR_LOG("Unhandled instruction code 0x{:02X} ({:08X} {:08X})", static_cast<u8>(inst.code.GetValue()),
|
||||||
inst.first, inst.second);
|
inst.first, inst.second);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -483,8 +483,7 @@ CPU::CodeCache::Block* CPU::CodeCache::CreateBlock(u32 pc, const BlockInstructio
|
||||||
}
|
}
|
||||||
else if (block->compile_count >= RECOMPILE_COUNT_FOR_INTERPRETER_FALLBACK)
|
else if (block->compile_count >= RECOMPILE_COUNT_FOR_INTERPRETER_FALLBACK)
|
||||||
{
|
{
|
||||||
Log_DevFmt("{} recompiles in {} frames to block 0x{:08X}, not caching.", block->compile_count, frame_delta,
|
DEV_LOG("{} recompiles in {} frames to block 0x{:08X}, not caching.", block->compile_count, frame_delta, block->pc);
|
||||||
block->pc);
|
|
||||||
block->size = 0;
|
block->size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +530,7 @@ bool CPU::CodeCache::RevalidateBlock(Block* block)
|
||||||
if (!IsBlockCodeCurrent(block))
|
if (!IsBlockCodeCurrent(block))
|
||||||
{
|
{
|
||||||
// changed, needs recompiling
|
// changed, needs recompiling
|
||||||
Log_DebugFmt("Block at PC {:08X} has changed and needs recompiling", block->pc);
|
DEBUG_LOG("Block at PC {:08X} has changed and needs recompiling", block->pc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,8 +613,8 @@ void CPU::CodeCache::InvalidateBlocksWithPageIndex(u32 index)
|
||||||
}
|
}
|
||||||
else if (ppi.invalidate_count > INVALIDATE_COUNT_FOR_MANUAL_PROTECTION)
|
else if (ppi.invalidate_count > INVALIDATE_COUNT_FOR_MANUAL_PROTECTION)
|
||||||
{
|
{
|
||||||
Log_DevFmt("{} invalidations in {} frames to page {} [0x{:08X} -> 0x{:08X}], switching to manual protection",
|
DEV_LOG("{} invalidations in {} frames to page {} [0x{:08X} -> 0x{:08X}], switching to manual protection",
|
||||||
ppi.invalidate_count, frame_delta, index, (index * HOST_PAGE_SIZE), ((index + 1) * HOST_PAGE_SIZE));
|
ppi.invalidate_count, frame_delta, index, (index * HOST_PAGE_SIZE), ((index + 1) * HOST_PAGE_SIZE));
|
||||||
ppi.mode = PageProtectionMode::ManualCheck;
|
ppi.mode = PageProtectionMode::ManualCheck;
|
||||||
new_block_state = BlockState::NeedsRecompile;
|
new_block_state = BlockState::NeedsRecompile;
|
||||||
}
|
}
|
||||||
|
@ -727,8 +726,7 @@ PageFaultHandler::HandlerResult PageFaultHandler::HandlePageFault(void* exceptio
|
||||||
DebugAssert(is_write);
|
DebugAssert(is_write);
|
||||||
const u32 guest_address = static_cast<u32>(static_cast<const u8*>(fault_address) - Bus::g_ram);
|
const u32 guest_address = static_cast<u32>(static_cast<const u8*>(fault_address) - Bus::g_ram);
|
||||||
const u32 page_index = Bus::GetRAMCodePageIndex(guest_address);
|
const u32 page_index = Bus::GetRAMCodePageIndex(guest_address);
|
||||||
Log_DevFmt("Page fault on protected RAM @ 0x{:08X} (page #{}), invalidating code cache.", guest_address,
|
DEV_LOG("Page fault on protected RAM @ 0x{:08X} (page #{}), invalidating code cache.", guest_address, page_index);
|
||||||
page_index);
|
|
||||||
CPU::CodeCache::InvalidateBlocksWithPageIndex(page_index);
|
CPU::CodeCache::InvalidateBlocksWithPageIndex(page_index);
|
||||||
return PageFaultHandler::HandlerResult::ContinueExecution;
|
return PageFaultHandler::HandlerResult::ContinueExecution;
|
||||||
}
|
}
|
||||||
|
@ -899,7 +897,7 @@ bool CPU::CodeCache::ReadBlockInstructions(u32 start_pc, BlockInstructionList* i
|
||||||
// if we're just crossing the page and not in a branch delay slot, jump directly to the next block
|
// if we're just crossing the page and not in a branch delay slot, jump directly to the next block
|
||||||
if (!is_branch_delay_slot)
|
if (!is_branch_delay_slot)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Breaking block 0x{:08X} at 0x{:08X} due to page crossing", start_pc, pc);
|
DEV_LOG("Breaking block 0x{:08X} at 0x{:08X} due to page crossing", start_pc, pc);
|
||||||
metadata->flags |= BlockFlags::SpansPages;
|
metadata->flags |= BlockFlags::SpansPages;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -907,8 +905,8 @@ bool CPU::CodeCache::ReadBlockInstructions(u32 start_pc, BlockInstructionList* i
|
||||||
{
|
{
|
||||||
// otherwise, we need to use manual protection in case the delay slot changes.
|
// otherwise, we need to use manual protection in case the delay slot changes.
|
||||||
// may as well keep going then, since we're doing manual check anyways.
|
// may as well keep going then, since we're doing manual check anyways.
|
||||||
Log_DevFmt("Block 0x{:08X} has branch delay slot crossing page at 0x{:08X}, forcing manual protection",
|
DEV_LOG("Block 0x{:08X} has branch delay slot crossing page at 0x{:08X}, forcing manual protection", start_pc,
|
||||||
start_pc, pc);
|
pc);
|
||||||
metadata->flags |= BlockFlags::BranchDelaySpansPages;
|
metadata->flags |= BlockFlags::BranchDelaySpansPages;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -954,18 +952,18 @@ bool CPU::CodeCache::ReadBlockInstructions(u32 start_pc, BlockInstructionList* i
|
||||||
const BlockInstructionInfoPair& prev = instructions->back();
|
const BlockInstructionInfoPair& prev = instructions->back();
|
||||||
if (!prev.second.is_unconditional_branch_instruction || !prev.second.is_direct_branch_instruction)
|
if (!prev.second.is_unconditional_branch_instruction || !prev.second.is_direct_branch_instruction)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Conditional or indirect branch delay slot at {:08X}, skipping block", info.pc);
|
WARNING_LOG("Conditional or indirect branch delay slot at {:08X}, skipping block", info.pc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!IsDirectBranchInstruction(instruction))
|
if (!IsDirectBranchInstruction(instruction))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Indirect branch in delay slot at {:08X}, skipping block", info.pc);
|
WARNING_LOG("Indirect branch in delay slot at {:08X}, skipping block", info.pc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we _could_ fetch the delay slot from the first branch's target, but it's probably in a different
|
// we _could_ fetch the delay slot from the first branch's target, but it's probably in a different
|
||||||
// page, and that's an invalidation nightmare. so just fallback to the int, this is very rare anyway.
|
// page, and that's an invalidation nightmare. so just fallback to the int, this is very rare anyway.
|
||||||
Log_WarningFmt("Direct branch in delay slot at {:08X}, skipping block", info.pc);
|
WARNING_LOG("Direct branch in delay slot at {:08X}, skipping block", info.pc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -990,7 +988,7 @@ bool CPU::CodeCache::ReadBlockInstructions(u32 start_pc, BlockInstructionList* i
|
||||||
|
|
||||||
if (instructions->empty())
|
if (instructions->empty())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Empty block compiled at 0x{:08X}", start_pc);
|
WARNING_LOG("Empty block compiled at 0x{:08X}", start_pc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,12 +996,12 @@ bool CPU::CodeCache::ReadBlockInstructions(u32 start_pc, BlockInstructionList* i
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
SmallString disasm;
|
SmallString disasm;
|
||||||
Log_DebugFmt("Block at 0x{:08X}", start_pc);
|
DEBUG_LOG("Block at 0x{:08X}", start_pc);
|
||||||
for (const auto& cbi : *instructions)
|
for (const auto& cbi : *instructions)
|
||||||
{
|
{
|
||||||
CPU::DisassembleInstruction(&disasm, cbi.second.pc, cbi.first.bits);
|
CPU::DisassembleInstruction(&disasm, cbi.second.pc, cbi.first.bits);
|
||||||
Log_DebugFmt("[{} {} 0x{:08X}] {:08X} {}", cbi.second.is_branch_delay_slot ? "BD" : " ",
|
DEBUG_LOG("[{} {} 0x{:08X}] {:08X} {}", cbi.second.is_branch_delay_slot ? "BD" : " ",
|
||||||
cbi.second.is_load_delay_slot ? "LD" : " ", cbi.second.pc, cbi.first.bits, disasm);
|
cbi.second.is_load_delay_slot ? "LD" : " ", cbi.second.pc, cbi.first.bits, disasm);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1164,7 +1162,7 @@ void CPU::CodeCache::FillBlockRegInfo(Block* block)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log_ErrorFmt("Unknown funct {}", static_cast<u32>(iinst->r.funct.GetValue()));
|
ERROR_LOG("Unknown funct {}", static_cast<u32>(iinst->r.funct.GetValue()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1263,7 +1261,7 @@ void CPU::CodeCache::FillBlockRegInfo(Block* block)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log_ErrorFmt("Unknown op {}", static_cast<u32>(iinst->r.funct.GetValue()));
|
ERROR_LOG("Unknown op {}", static_cast<u32>(iinst->r.funct.GetValue()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // end switch
|
} // end switch
|
||||||
|
@ -1308,7 +1306,7 @@ void CPU::CodeCache::CompileOrRevalidateBlock(u32 start_pc)
|
||||||
BlockMetadata metadata = {};
|
BlockMetadata metadata = {};
|
||||||
if (!ReadBlockInstructions(start_pc, &s_block_instructions, &metadata))
|
if (!ReadBlockInstructions(start_pc, &s_block_instructions, &metadata))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read block at 0x{:08X}, falling back to uncached interpreter", start_pc);
|
ERROR_LOG("Failed to read block at 0x{:08X}, falling back to uncached interpreter", start_pc);
|
||||||
SetCodeLUT(start_pc, g_interpret_block);
|
SetCodeLUT(start_pc, g_interpret_block);
|
||||||
BacklinkBlocks(start_pc, g_interpret_block);
|
BacklinkBlocks(start_pc, g_interpret_block);
|
||||||
MemMap::EndCodeWrite();
|
MemMap::EndCodeWrite();
|
||||||
|
@ -1321,14 +1319,14 @@ void CPU::CodeCache::CompileOrRevalidateBlock(u32 start_pc)
|
||||||
if (s_code_buffer.GetFreeCodeSpace() < (block_size * Recompiler::MAX_NEAR_HOST_BYTES_PER_INSTRUCTION) ||
|
if (s_code_buffer.GetFreeCodeSpace() < (block_size * Recompiler::MAX_NEAR_HOST_BYTES_PER_INSTRUCTION) ||
|
||||||
s_code_buffer.GetFreeFarCodeSpace() < (block_size * Recompiler::MAX_FAR_HOST_BYTES_PER_INSTRUCTION))
|
s_code_buffer.GetFreeFarCodeSpace() < (block_size * Recompiler::MAX_FAR_HOST_BYTES_PER_INSTRUCTION))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Out of code space while compiling {:08X}. Resetting code cache.", start_pc);
|
ERROR_LOG("Out of code space while compiling {:08X}. Resetting code cache.", start_pc);
|
||||||
CodeCache::Reset();
|
CodeCache::Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((block = CreateBlock(start_pc, s_block_instructions, metadata)) == nullptr || block->size == 0 ||
|
if ((block = CreateBlock(start_pc, s_block_instructions, metadata)) == nullptr || block->size == 0 ||
|
||||||
!CompileBlock(block))
|
!CompileBlock(block))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to compile block at 0x{:08X}, falling back to uncached interpreter", start_pc);
|
ERROR_LOG("Failed to compile block at 0x{:08X}, falling back to uncached interpreter", start_pc);
|
||||||
SetCodeLUT(start_pc, g_interpret_block);
|
SetCodeLUT(start_pc, g_interpret_block);
|
||||||
BacklinkBlocks(start_pc, g_interpret_block);
|
BacklinkBlocks(start_pc, g_interpret_block);
|
||||||
MemMap::EndCodeWrite();
|
MemMap::EndCodeWrite();
|
||||||
|
@ -1344,7 +1342,7 @@ void CPU::CodeCache::DiscardAndRecompileBlock(u32 start_pc)
|
||||||
{
|
{
|
||||||
MemMap::BeginCodeWrite();
|
MemMap::BeginCodeWrite();
|
||||||
|
|
||||||
Log_DevFmt("Discard block {:08X} with manual protection", start_pc);
|
DEV_LOG("Discard block {:08X} with manual protection", start_pc);
|
||||||
Block* block = LookupBlock(start_pc);
|
Block* block = LookupBlock(start_pc);
|
||||||
DebugAssert(block && block->state == BlockState::Valid);
|
DebugAssert(block && block->state == BlockState::Valid);
|
||||||
InvalidateBlock(block, BlockState::NeedsRecompile);
|
InvalidateBlock(block, BlockState::NeedsRecompile);
|
||||||
|
@ -1380,8 +1378,8 @@ const void* CPU::CodeCache::CreateBlockLink(Block* block, void* code, u32 newpc)
|
||||||
block->exit_links[block->num_exit_links++] = iter;
|
block->exit_links[block->num_exit_links++] = iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("Linking {} with dst pc {:08X} to {}{}", code, newpc, dst,
|
DEBUG_LOG("Linking {} with dst pc {:08X} to {}{}", code, newpc, dst,
|
||||||
(dst == g_compile_or_revalidate_block) ? "[compiler]" : "");
|
(dst == g_compile_or_revalidate_block) ? "[compiler]" : "");
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1393,8 +1391,8 @@ void CPU::CodeCache::BacklinkBlocks(u32 pc, const void* dst)
|
||||||
const auto link_range = s_block_links.equal_range(pc);
|
const auto link_range = s_block_links.equal_range(pc);
|
||||||
for (auto it = link_range.first; it != link_range.second; ++it)
|
for (auto it = link_range.first; it != link_range.second; ++it)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Backlinking {} with dst pc {:08X} to {}{}", it->second, pc, dst,
|
DEBUG_LOG("Backlinking {} with dst pc {:08X} to {}{}", it->second, pc, dst,
|
||||||
(dst == g_compile_or_revalidate_block) ? "[compiler]" : "");
|
(dst == g_compile_or_revalidate_block) ? "[compiler]" : "");
|
||||||
EmitJump(it->second, dst, true);
|
EmitJump(it->second, dst, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1480,7 +1478,7 @@ bool CPU::CodeCache::CompileBlock(Block* block)
|
||||||
|
|
||||||
if (!host_code)
|
if (!host_code)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to compile host code for block at 0x{:08X}", block->pc);
|
ERROR_LOG("Failed to compile host code for block at 0x{:08X}", block->pc);
|
||||||
block->state = BlockState::FallbackToInterpreter;
|
block->state = BlockState::FallbackToInterpreter;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1574,7 +1572,7 @@ PageFaultHandler::HandlerResult CPU::CodeCache::HandleFastmemException(void* exc
|
||||||
// TODO: path for manual protection to return back to read-only pages
|
// TODO: path for manual protection to return back to read-only pages
|
||||||
if (is_write && !g_state.cop0_regs.sr.Isc && AddressInRAM(guest_address))
|
if (is_write && !g_state.cop0_regs.sr.Isc && AddressInRAM(guest_address))
|
||||||
{
|
{
|
||||||
Log_DevFmt("Ignoring fault due to RAM write @ 0x{:08X}", guest_address);
|
DEV_LOG("Ignoring fault due to RAM write @ 0x{:08X}", guest_address);
|
||||||
InvalidateBlocksWithPageIndex(Bus::GetRAMCodePageIndex(guest_address));
|
InvalidateBlocksWithPageIndex(Bus::GetRAMCodePageIndex(guest_address));
|
||||||
return PageFaultHandler::HandlerResult::ContinueExecution;
|
return PageFaultHandler::HandlerResult::ContinueExecution;
|
||||||
}
|
}
|
||||||
|
@ -1586,21 +1584,21 @@ PageFaultHandler::HandlerResult CPU::CodeCache::HandleFastmemException(void* exc
|
||||||
guest_address = std::numeric_limits<PhysicalMemoryAddress>::max();
|
guest_address = std::numeric_limits<PhysicalMemoryAddress>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("Page fault handler invoked at PC={} Address={} {}, fastmem offset {:08X}", exception_pc, fault_address,
|
DEV_LOG("Page fault handler invoked at PC={} Address={} {}, fastmem offset {:08X}", exception_pc, fault_address,
|
||||||
is_write ? "(write)" : "(read)", guest_address);
|
is_write ? "(write)" : "(read)", guest_address);
|
||||||
|
|
||||||
auto iter = s_fastmem_backpatch_info.find(exception_pc);
|
auto iter = s_fastmem_backpatch_info.find(exception_pc);
|
||||||
if (iter == s_fastmem_backpatch_info.end())
|
if (iter == s_fastmem_backpatch_info.end())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("No backpatch info found for {}", exception_pc);
|
ERROR_LOG("No backpatch info found for {}", exception_pc);
|
||||||
return PageFaultHandler::HandlerResult::ExecuteNextHandler;
|
return PageFaultHandler::HandlerResult::ExecuteNextHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadstoreBackpatchInfo& info = iter->second;
|
LoadstoreBackpatchInfo& info = iter->second;
|
||||||
Log_DevFmt("Backpatching {} at {}[{}] (pc {:08X} addr {:08X}): Bitmask {:08X} Addr {} Data {} Size {} Signed {:02X}",
|
DEV_LOG("Backpatching {} at {}[{}] (pc {:08X} addr {:08X}): Bitmask {:08X} Addr {} Data {} Size {} Signed {:02X}",
|
||||||
info.is_load ? "load" : "store", exception_pc, info.code_size, info.guest_pc, guest_address,
|
info.is_load ? "load" : "store", exception_pc, info.code_size, info.guest_pc, guest_address, info.gpr_bitmask,
|
||||||
info.gpr_bitmask, static_cast<unsigned>(info.address_register), static_cast<unsigned>(info.data_register),
|
static_cast<unsigned>(info.address_register), static_cast<unsigned>(info.data_register),
|
||||||
info.AccessSizeInBytes(), static_cast<unsigned>(info.is_signed));
|
info.AccessSizeInBytes(), static_cast<unsigned>(info.is_signed));
|
||||||
|
|
||||||
MemMap::BeginCodeWrite();
|
MemMap::BeginCodeWrite();
|
||||||
|
|
||||||
|
@ -1613,7 +1611,7 @@ PageFaultHandler::HandlerResult CPU::CodeCache::HandleFastmemException(void* exc
|
||||||
if (block)
|
if (block)
|
||||||
{
|
{
|
||||||
// This is a bit annoying, we have to remove it from the page list if it's a RAM block.
|
// This is a bit annoying, we have to remove it from the page list if it's a RAM block.
|
||||||
Log_DevFmt("Queuing block {:08X} for recompilation due to backpatch", block->pc);
|
DEV_LOG("Queuing block {:08X} for recompilation due to backpatch", block->pc);
|
||||||
RemoveBlockFromPageList(block);
|
RemoveBlockFromPageList(block);
|
||||||
InvalidateBlock(block, BlockState::NeedsRecompile);
|
InvalidateBlock(block, BlockState::NeedsRecompile);
|
||||||
|
|
||||||
|
|
|
@ -322,10 +322,10 @@ ALWAYS_INLINE_RELEASE void CPU::RaiseException(u32 CAUSE_bits, u32 EPC, u32 vect
|
||||||
if (g_state.cop0_regs.cause.Excode != Exception::INT && g_state.cop0_regs.cause.Excode != Exception::Syscall &&
|
if (g_state.cop0_regs.cause.Excode != Exception::INT && g_state.cop0_regs.cause.Excode != Exception::Syscall &&
|
||||||
g_state.cop0_regs.cause.Excode != Exception::BP)
|
g_state.cop0_regs.cause.Excode != Exception::BP)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Exception {} at 0x{:08X} (epc=0x{:08X}, BD={}, CE={})",
|
DEV_LOG("Exception {} at 0x{:08X} (epc=0x{:08X}, BD={}, CE={})",
|
||||||
static_cast<u8>(g_state.cop0_regs.cause.Excode.GetValue()), g_state.current_instruction_pc,
|
static_cast<u8>(g_state.cop0_regs.cause.Excode.GetValue()), g_state.current_instruction_pc,
|
||||||
g_state.cop0_regs.EPC, g_state.cop0_regs.cause.BD ? "true" : "false",
|
g_state.cop0_regs.EPC, g_state.cop0_regs.cause.BD ? "true" : "false",
|
||||||
g_state.cop0_regs.cause.CE.GetValue());
|
g_state.cop0_regs.cause.CE.GetValue());
|
||||||
DisassembleAndPrint(g_state.current_instruction_pc, 4u, 0u);
|
DisassembleAndPrint(g_state.current_instruction_pc, 4u, 0u);
|
||||||
if (s_trace_to_log)
|
if (s_trace_to_log)
|
||||||
{
|
{
|
||||||
|
@ -523,14 +523,14 @@ ALWAYS_INLINE_RELEASE void CPU::WriteCop0Reg(Cop0Reg reg, u32 value)
|
||||||
case Cop0Reg::BPC:
|
case Cop0Reg::BPC:
|
||||||
{
|
{
|
||||||
g_state.cop0_regs.BPC = value;
|
g_state.cop0_regs.BPC = value;
|
||||||
Log_DevFmt("COP0 BPC <- {:08X}", value);
|
DEV_LOG("COP0 BPC <- {:08X}", value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Cop0Reg::BPCM:
|
case Cop0Reg::BPCM:
|
||||||
{
|
{
|
||||||
g_state.cop0_regs.BPCM = value;
|
g_state.cop0_regs.BPCM = value;
|
||||||
Log_DevFmt("COP0 BPCM <- {:08X}", value);
|
DEV_LOG("COP0 BPCM <- {:08X}", value);
|
||||||
if (UpdateDebugDispatcherFlag())
|
if (UpdateDebugDispatcherFlag())
|
||||||
ExitExecution();
|
ExitExecution();
|
||||||
}
|
}
|
||||||
|
@ -539,20 +539,20 @@ ALWAYS_INLINE_RELEASE void CPU::WriteCop0Reg(Cop0Reg reg, u32 value)
|
||||||
case Cop0Reg::BDA:
|
case Cop0Reg::BDA:
|
||||||
{
|
{
|
||||||
g_state.cop0_regs.BDA = value;
|
g_state.cop0_regs.BDA = value;
|
||||||
Log_DevFmt("COP0 BDA <- {:08X}", value);
|
DEV_LOG("COP0 BDA <- {:08X}", value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Cop0Reg::BDAM:
|
case Cop0Reg::BDAM:
|
||||||
{
|
{
|
||||||
g_state.cop0_regs.BDAM = value;
|
g_state.cop0_regs.BDAM = value;
|
||||||
Log_DevFmt("COP0 BDAM <- {:08X}", value);
|
DEV_LOG("COP0 BDAM <- {:08X}", value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Cop0Reg::JUMPDEST:
|
case Cop0Reg::JUMPDEST:
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Ignoring write to Cop0 JUMPDEST");
|
WARNING_LOG("Ignoring write to Cop0 JUMPDEST");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ ALWAYS_INLINE_RELEASE void CPU::WriteCop0Reg(Cop0Reg reg, u32 value)
|
||||||
{
|
{
|
||||||
g_state.cop0_regs.dcic.bits =
|
g_state.cop0_regs.dcic.bits =
|
||||||
(g_state.cop0_regs.dcic.bits & ~Cop0Registers::DCIC::WRITE_MASK) | (value & Cop0Registers::DCIC::WRITE_MASK);
|
(g_state.cop0_regs.dcic.bits & ~Cop0Registers::DCIC::WRITE_MASK) | (value & Cop0Registers::DCIC::WRITE_MASK);
|
||||||
Log_DevFmt("COP0 DCIC <- {:08X} (now {:08X})", value, g_state.cop0_regs.dcic.bits);
|
DEV_LOG("COP0 DCIC <- {:08X} (now {:08X})", value, g_state.cop0_regs.dcic.bits);
|
||||||
if (UpdateDebugDispatcherFlag())
|
if (UpdateDebugDispatcherFlag())
|
||||||
ExitExecution();
|
ExitExecution();
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ ALWAYS_INLINE_RELEASE void CPU::WriteCop0Reg(Cop0Reg reg, u32 value)
|
||||||
{
|
{
|
||||||
g_state.cop0_regs.sr.bits =
|
g_state.cop0_regs.sr.bits =
|
||||||
(g_state.cop0_regs.sr.bits & ~Cop0Registers::SR::WRITE_MASK) | (value & Cop0Registers::SR::WRITE_MASK);
|
(g_state.cop0_regs.sr.bits & ~Cop0Registers::SR::WRITE_MASK) | (value & Cop0Registers::SR::WRITE_MASK);
|
||||||
Log_DebugFmt("COP0 SR <- {:08X} (now {:08X})", value, g_state.cop0_regs.sr.bits);
|
DEBUG_LOG("COP0 SR <- {:08X} (now {:08X})", value, g_state.cop0_regs.sr.bits);
|
||||||
UpdateMemoryPointers();
|
UpdateMemoryPointers();
|
||||||
CheckForPendingInterrupt();
|
CheckForPendingInterrupt();
|
||||||
}
|
}
|
||||||
|
@ -580,12 +580,12 @@ ALWAYS_INLINE_RELEASE void CPU::WriteCop0Reg(Cop0Reg reg, u32 value)
|
||||||
{
|
{
|
||||||
g_state.cop0_regs.cause.bits =
|
g_state.cop0_regs.cause.bits =
|
||||||
(g_state.cop0_regs.cause.bits & ~Cop0Registers::CAUSE::WRITE_MASK) | (value & Cop0Registers::CAUSE::WRITE_MASK);
|
(g_state.cop0_regs.cause.bits & ~Cop0Registers::CAUSE::WRITE_MASK) | (value & Cop0Registers::CAUSE::WRITE_MASK);
|
||||||
Log_DebugFmt("COP0 CAUSE <- {:08X} (now {:08X})", value, g_state.cop0_regs.cause.bits);
|
DEBUG_LOG("COP0 CAUSE <- {:08X} (now {:08X})", value, g_state.cop0_regs.cause.bits);
|
||||||
CheckForPendingInterrupt();
|
CheckForPendingInterrupt();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
[[unlikely]] default : Log_DevFmt("Unknown COP0 reg write {} ({:08X})", static_cast<u8>(reg), value);
|
[[unlikely]] default : DEV_LOG("Unknown COP0 reg write {} ({:08X})", static_cast<u8>(reg), value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -631,7 +631,7 @@ ALWAYS_INLINE_RELEASE void CPU::Cop0ExecutionBreakpointCheck()
|
||||||
if (bpcm == 0 || ((pc ^ bpc) & bpcm) != 0u)
|
if (bpcm == 0 || ((pc ^ bpc) & bpcm) != 0u)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_DevFmt("Cop0 execution breakpoint at {:08X}", pc);
|
DEV_LOG("Cop0 execution breakpoint at {:08X}", pc);
|
||||||
g_state.cop0_regs.dcic.status_any_break = true;
|
g_state.cop0_regs.dcic.status_any_break = true;
|
||||||
g_state.cop0_regs.dcic.status_bpc_code_break = true;
|
g_state.cop0_regs.dcic.status_bpc_code_break = true;
|
||||||
DispatchCop0Breakpoint();
|
DispatchCop0Breakpoint();
|
||||||
|
@ -657,7 +657,7 @@ ALWAYS_INLINE_RELEASE void CPU::Cop0DataBreakpointCheck(VirtualMemoryAddress add
|
||||||
if (bdam == 0 || ((address ^ bda) & bdam) != 0u)
|
if (bdam == 0 || ((address ^ bda) & bdam) != 0u)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_DevFmt("Cop0 data breakpoint for {:08X} at {:08X}", address, g_state.current_instruction_pc);
|
DEV_LOG("Cop0 data breakpoint for {:08X} at {:08X}", address, g_state.current_instruction_pc);
|
||||||
|
|
||||||
g_state.cop0_regs.dcic.status_any_break = true;
|
g_state.cop0_regs.dcic.status_any_break = true;
|
||||||
g_state.cop0_regs.dcic.status_bda_data_break = true;
|
g_state.cop0_regs.dcic.status_bda_data_break = true;
|
||||||
|
@ -710,7 +710,7 @@ void CPU::PrintInstruction(u32 bits, u32 pc, bool regs, const char* prefix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("{}{:08x}: {:08x} %s", prefix, pc, bits, instr);
|
DEV_LOG("{}{:08x}: {:08x} %s", prefix, pc, bits, instr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPU::LogInstruction(u32 bits, u32 pc, bool regs)
|
void CPU::LogInstruction(u32 bits, u32 pc, bool regs)
|
||||||
|
@ -1744,7 +1744,7 @@ restart_instruction:
|
||||||
{
|
{
|
||||||
if (InUserMode() && !g_state.cop0_regs.sr.CU0)
|
if (InUserMode() && !g_state.cop0_regs.sr.CU0)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Coprocessor 0 not present in user mode");
|
WARNING_LOG("Coprocessor 0 not present in user mode");
|
||||||
RaiseException(Exception::CpU);
|
RaiseException(Exception::CpU);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1774,8 +1774,8 @@ restart_instruction:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
[[unlikely]] Log_ErrorFmt("Unhandled instruction at {:08X}: {:08X}", g_state.current_instruction_pc,
|
[[unlikely]] ERROR_LOG("Unhandled instruction at {:08X}: {:08X}", g_state.current_instruction_pc,
|
||||||
inst.bits);
|
inst.bits);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1800,8 +1800,8 @@ restart_instruction:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
[[unlikely]] Log_ErrorFmt("Unhandled instruction at {:08X}: {:08X}", g_state.current_instruction_pc,
|
[[unlikely]] ERROR_LOG("Unhandled instruction at {:08X}: {:08X}", g_state.current_instruction_pc,
|
||||||
inst.bits);
|
inst.bits);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1812,7 +1812,7 @@ restart_instruction:
|
||||||
{
|
{
|
||||||
if (!g_state.cop0_regs.sr.CE2)
|
if (!g_state.cop0_regs.sr.CE2)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Coprocessor 2 not enabled");
|
WARNING_LOG("Coprocessor 2 not enabled");
|
||||||
RaiseException(Exception::CpU);
|
RaiseException(Exception::CpU);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1865,8 +1865,8 @@ restart_instruction:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
[[unlikely]] Log_ErrorFmt("Unhandled instruction at {:08X}: {:08X}", g_state.current_instruction_pc,
|
[[unlikely]] ERROR_LOG("Unhandled instruction at {:08X}: {:08X}", g_state.current_instruction_pc,
|
||||||
inst.bits);
|
inst.bits);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1881,7 +1881,7 @@ restart_instruction:
|
||||||
{
|
{
|
||||||
if (!g_state.cop0_regs.sr.CE2)
|
if (!g_state.cop0_regs.sr.CE2)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Coprocessor 2 not enabled");
|
WARNING_LOG("Coprocessor 2 not enabled");
|
||||||
RaiseException(Exception::CpU);
|
RaiseException(Exception::CpU);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1903,7 +1903,7 @@ restart_instruction:
|
||||||
{
|
{
|
||||||
if (!g_state.cop0_regs.sr.CE2)
|
if (!g_state.cop0_regs.sr.CE2)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Coprocessor 2 not enabled");
|
WARNING_LOG("Coprocessor 2 not enabled");
|
||||||
RaiseException(Exception::CpU);
|
RaiseException(Exception::CpU);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1939,8 +1939,8 @@ restart_instruction:
|
||||||
if (SafeReadInstruction(g_state.current_instruction_pc, &ram_value) &&
|
if (SafeReadInstruction(g_state.current_instruction_pc, &ram_value) &&
|
||||||
ram_value != g_state.current_instruction.bits) [[unlikely]]
|
ram_value != g_state.current_instruction.bits) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Stale icache at 0x{:08X} - ICache: {:08X} RAM: {:08X}", g_state.current_instruction_pc,
|
ERROR_LOG("Stale icache at 0x{:08X} - ICache: {:08X} RAM: {:08X}", g_state.current_instruction_pc,
|
||||||
g_state.current_instruction.bits, ram_value);
|
g_state.current_instruction.bits, ram_value);
|
||||||
g_state.current_instruction.bits = ram_value;
|
g_state.current_instruction.bits = ram_value;
|
||||||
goto restart_instruction;
|
goto restart_instruction;
|
||||||
}
|
}
|
||||||
|
@ -1986,7 +1986,7 @@ bool CPU::UpdateDebugDispatcherFlag()
|
||||||
if (use_debug_dispatcher == g_state.use_debug_dispatcher)
|
if (use_debug_dispatcher == g_state.use_debug_dispatcher)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Log_DevFmt("{} debug dispatcher", use_debug_dispatcher ? "Now using" : "No longer using");
|
DEV_LOG("{} debug dispatcher", use_debug_dispatcher ? "Now using" : "No longer using");
|
||||||
g_state.use_debug_dispatcher = use_debug_dispatcher;
|
g_state.use_debug_dispatcher = use_debug_dispatcher;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2061,8 +2061,8 @@ bool CPU::AddBreakpoint(BreakpointType type, VirtualMemoryAddress address, bool
|
||||||
if (HasBreakpointAtAddress(type, address))
|
if (HasBreakpointAtAddress(type, address))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Log_InfoFmt("Adding {} breakpoint at {:08X}, auto clear = %u", GetBreakpointTypeName(type), address,
|
INFO_LOG("Adding {} breakpoint at {:08X}, auto clear = %u", GetBreakpointTypeName(type), address,
|
||||||
static_cast<unsigned>(auto_clear));
|
static_cast<unsigned>(auto_clear));
|
||||||
|
|
||||||
Breakpoint bp{address, nullptr, auto_clear ? 0 : s_breakpoint_counter++, 0, type, auto_clear, enabled};
|
Breakpoint bp{address, nullptr, auto_clear ? 0 : s_breakpoint_counter++, 0, type, auto_clear, enabled};
|
||||||
GetBreakpointList(type).push_back(std::move(bp));
|
GetBreakpointList(type).push_back(std::move(bp));
|
||||||
|
@ -2082,7 +2082,7 @@ bool CPU::AddBreakpointWithCallback(BreakpointType type, VirtualMemoryAddress ad
|
||||||
if (HasBreakpointAtAddress(type, address))
|
if (HasBreakpointAtAddress(type, address))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Log_InfoFmt("Adding {} breakpoint with callback at {:08X}", GetBreakpointTypeName(type), address);
|
INFO_LOG("Adding {} breakpoint with callback at {:08X}", GetBreakpointTypeName(type), address);
|
||||||
|
|
||||||
Breakpoint bp{address, callback, 0, 0, type, false, true};
|
Breakpoint bp{address, callback, 0, 0, type, false, true};
|
||||||
GetBreakpointList(type).push_back(std::move(bp));
|
GetBreakpointList(type).push_back(std::move(bp));
|
||||||
|
@ -2382,7 +2382,7 @@ void CPU::Execute()
|
||||||
if (!SafeReadInstruction(g_state.pc, &g_state.next_instruction.bits)) [[unlikely]]
|
if (!SafeReadInstruction(g_state.pc, &g_state.next_instruction.bits)) [[unlikely]]
|
||||||
{
|
{
|
||||||
g_state.next_instruction.bits = 0;
|
g_state.next_instruction.bits = 0;
|
||||||
Log_ErrorFmt("Failed to read current instruction from 0x{:08X}", g_state.pc);
|
ERROR_LOG("Failed to read current instruction from 0x{:08X}", g_state.pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_state.npc = g_state.pc + sizeof(Instruction);
|
g_state.npc = g_state.pc + sizeof(Instruction);
|
||||||
|
|
|
@ -71,7 +71,7 @@ void CPU::NewRec::Compiler::BeginBlock()
|
||||||
|
|
||||||
if (m_block->protection == CodeCache::PageProtectionMode::ManualCheck)
|
if (m_block->protection == CodeCache::PageProtectionMode::ManualCheck)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Generate manual protection for PC {:08X}", m_block->pc);
|
DEBUG_LOG("Generate manual protection for PC {:08X}", m_block->pc);
|
||||||
const u8* ram_ptr = Bus::g_ram + VirtualAddressToPhysical(m_block->pc);
|
const u8* ram_ptr = Bus::g_ram + VirtualAddressToPhysical(m_block->pc);
|
||||||
const u8* shadow_ptr = reinterpret_cast<const u8*>(m_block->Instructions());
|
const u8* shadow_ptr = reinterpret_cast<const u8*>(m_block->Instructions());
|
||||||
GenerateBlockProtectCheck(ram_ptr, shadow_ptr, m_block->size * sizeof(Instruction));
|
GenerateBlockProtectCheck(ram_ptr, shadow_ptr, m_block->size * sizeof(Instruction));
|
||||||
|
@ -103,7 +103,7 @@ const void* CPU::NewRec::Compiler::CompileBlock(CodeCache::Block* block, u32* ho
|
||||||
Reset(block, buffer.GetFreeCodePointer(), buffer.GetFreeCodeSpace(), buffer.GetFreeFarCodePointer(),
|
Reset(block, buffer.GetFreeCodePointer(), buffer.GetFreeCodeSpace(), buffer.GetFreeFarCodePointer(),
|
||||||
buffer.GetFreeFarCodeSpace());
|
buffer.GetFreeFarCodeSpace());
|
||||||
|
|
||||||
Log_DebugFmt("Block range: {:08X} -> {:08X}", block->pc, block->pc + block->size * 4);
|
DEBUG_LOG("Block range: {:08X} -> {:08X}", block->pc, block->pc + block->size * 4);
|
||||||
|
|
||||||
BeginBlock();
|
BeginBlock();
|
||||||
|
|
||||||
|
@ -167,8 +167,8 @@ void CPU::NewRec::Compiler::SetConstantReg(Reg r, u32 v)
|
||||||
|
|
||||||
if (const std::optional<u32> hostreg = CheckHostReg(0, HR_TYPE_CPU_REG, r); hostreg.has_value())
|
if (const std::optional<u32> hostreg = CheckHostReg(0, HR_TYPE_CPU_REG, r); hostreg.has_value())
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Discarding guest register {} in host register {} due to constant set", GetRegName(r),
|
DEBUG_LOG("Discarding guest register {} in host register {} due to constant set", GetRegName(r),
|
||||||
GetHostRegName(hostreg.value()));
|
GetHostRegName(hostreg.value()));
|
||||||
FreeHostReg(hostreg.value());
|
FreeHostReg(hostreg.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ void CPU::NewRec::Compiler::CancelLoadDelaysToReg(Reg reg)
|
||||||
if (m_load_delay_register != reg)
|
if (m_load_delay_register != reg)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_DebugFmt("Cancelling load delay to {}", GetRegName(reg));
|
DEBUG_LOG("Cancelling load delay to {}", GetRegName(reg));
|
||||||
m_load_delay_register = Reg::count;
|
m_load_delay_register = Reg::count;
|
||||||
if (m_load_delay_value_register != NUM_HOST_REGS)
|
if (m_load_delay_value_register != NUM_HOST_REGS)
|
||||||
ClearHostReg(m_load_delay_value_register);
|
ClearHostReg(m_load_delay_value_register);
|
||||||
|
@ -196,7 +196,7 @@ void CPU::NewRec::Compiler::UpdateLoadDelay()
|
||||||
// thankfully since this only happens on the first instruction, we can get away with just killing anything which
|
// thankfully since this only happens on the first instruction, we can get away with just killing anything which
|
||||||
// isn't in write mode, because nothing could've been written before it, and the new value overwrites any
|
// isn't in write mode, because nothing could've been written before it, and the new value overwrites any
|
||||||
// load-delayed value
|
// load-delayed value
|
||||||
Log_DebugPrint("Invalidating non-dirty registers, and flushing load delay from state");
|
DEBUG_LOG("Invalidating non-dirty registers, and flushing load delay from state");
|
||||||
|
|
||||||
constexpr u32 req_flags = (HR_ALLOCATED | HR_MODE_WRITE);
|
constexpr u32 req_flags = (HR_ALLOCATED | HR_MODE_WRITE);
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ void CPU::NewRec::Compiler::UpdateLoadDelay()
|
||||||
if (ra.type != HR_TYPE_CPU_REG || !IsHostRegAllocated(i) || ((ra.flags & req_flags) == req_flags))
|
if (ra.type != HR_TYPE_CPU_REG || !IsHostRegAllocated(i) || ((ra.flags & req_flags) == req_flags))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Log_DebugFmt("Freeing non-dirty cached register {} in {}", GetRegName(ra.reg), GetHostRegName(i));
|
DEBUG_LOG("Freeing non-dirty cached register {} in {}", GetRegName(ra.reg), GetHostRegName(i));
|
||||||
DebugAssert(!(ra.flags & HR_MODE_WRITE));
|
DebugAssert(!(ra.flags & HR_MODE_WRITE));
|
||||||
ClearHostReg(i);
|
ClearHostReg(i);
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ void CPU::NewRec::Compiler::UpdateLoadDelay()
|
||||||
if (!HasConstantReg(static_cast<Reg>(i)) || HasDirtyConstantReg(static_cast<Reg>(i)))
|
if (!HasConstantReg(static_cast<Reg>(i)) || HasDirtyConstantReg(static_cast<Reg>(i)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Log_DebugFmt("Clearing non-dirty constant {}", GetRegName(static_cast<Reg>(i)));
|
DEBUG_LOG("Clearing non-dirty constant {}", GetRegName(static_cast<Reg>(i)));
|
||||||
ClearConstantReg(static_cast<Reg>(i));
|
ClearConstantReg(static_cast<Reg>(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,8 +264,8 @@ void CPU::NewRec::Compiler::FinishLoadDelay()
|
||||||
// kill any (old) cached value for this register
|
// kill any (old) cached value for this register
|
||||||
DeleteMIPSReg(m_load_delay_register, false);
|
DeleteMIPSReg(m_load_delay_register, false);
|
||||||
|
|
||||||
Log_DebugFmt("Finished delayed load to {} in host register {}", GetRegName(m_load_delay_register),
|
DEBUG_LOG("Finished delayed load to {} in host register {}", GetRegName(m_load_delay_register),
|
||||||
GetHostRegName(m_load_delay_value_register));
|
GetHostRegName(m_load_delay_value_register));
|
||||||
|
|
||||||
// and swap the mode over so it gets written back later
|
// and swap the mode over so it gets written back later
|
||||||
HostRegAlloc& ra = m_host_regs[m_load_delay_value_register];
|
HostRegAlloc& ra = m_host_regs[m_load_delay_value_register];
|
||||||
|
@ -275,7 +275,7 @@ void CPU::NewRec::Compiler::FinishLoadDelay()
|
||||||
ra.type = HR_TYPE_CPU_REG;
|
ra.type = HR_TYPE_CPU_REG;
|
||||||
|
|
||||||
// constants are gone
|
// constants are gone
|
||||||
Log_DebugFmt("Clearing constant in {} due to load delay", GetRegName(m_load_delay_register));
|
DEBUG_LOG("Clearing constant in {} due to load delay", GetRegName(m_load_delay_register));
|
||||||
ClearConstantReg(m_load_delay_register);
|
ClearConstantReg(m_load_delay_register);
|
||||||
|
|
||||||
m_load_delay_register = Reg::count;
|
m_load_delay_register = Reg::count;
|
||||||
|
@ -490,7 +490,7 @@ bool CPU::NewRec::Compiler::TrySwapDelaySlot(Reg rs, Reg rt, Reg rd)
|
||||||
|
|
||||||
is_safe:
|
is_safe:
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
Log_DebugFmt("Swapping delay slot {:08X} {}", m_current_instruction_pc + 4, disasm);
|
DEBUG_LOG("Swapping delay slot {:08X} {}", m_current_instruction_pc + 4, disasm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CompileBranchDelaySlot();
|
CompileBranchDelaySlot();
|
||||||
|
@ -502,7 +502,7 @@ is_safe:
|
||||||
|
|
||||||
is_unsafe:
|
is_unsafe:
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
Log_DebugFmt("NOT swapping delay slot {:08X} {}", m_current_instruction_pc + 4, disasm);
|
DEBUG_LOG("NOT swapping delay slot {:08X} {}", m_current_instruction_pc + 4, disasm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -598,8 +598,8 @@ u32 CPU::NewRec::Compiler::GetFreeHostReg(u32 flags)
|
||||||
|
|
||||||
if (caller_saved_lowest_count < lowest_count)
|
if (caller_saved_lowest_count < lowest_count)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Moving caller-saved host register {} with MIPS register {} to {} for allocation",
|
DEBUG_LOG("Moving caller-saved host register {} with MIPS register {} to {} for allocation",
|
||||||
GetHostRegName(lowest), GetRegName(ra.reg), GetHostRegName(caller_saved_lowest));
|
GetHostRegName(lowest), GetRegName(ra.reg), GetHostRegName(caller_saved_lowest));
|
||||||
if (IsHostRegAllocated(caller_saved_lowest))
|
if (IsHostRegAllocated(caller_saved_lowest))
|
||||||
FreeHostReg(caller_saved_lowest);
|
FreeHostReg(caller_saved_lowest);
|
||||||
CopyHostReg(caller_saved_lowest, lowest);
|
CopyHostReg(caller_saved_lowest, lowest);
|
||||||
|
@ -609,20 +609,19 @@ u32 CPU::NewRec::Compiler::GetFreeHostReg(u32 flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("Freeing register {} in host register {} for allocation", GetRegName(ra.reg),
|
DEBUG_LOG("Freeing register {} in host register {} for allocation", GetRegName(ra.reg), GetHostRegName(lowest));
|
||||||
GetHostRegName(lowest));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HR_TYPE_LOAD_DELAY_VALUE:
|
case HR_TYPE_LOAD_DELAY_VALUE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Freeing load delay register {} in host register {} for allocation", GetHostRegName(lowest),
|
DEBUG_LOG("Freeing load delay register {} in host register {} for allocation", GetHostRegName(lowest),
|
||||||
GetRegName(ra.reg));
|
GetRegName(ra.reg));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HR_TYPE_NEXT_LOAD_DELAY_VALUE:
|
case HR_TYPE_NEXT_LOAD_DELAY_VALUE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Freeing next load delay register {} in host register {} due for allocation", GetRegName(ra.reg),
|
DEBUG_LOG("Freeing next load delay register {} in host register {} due for allocation", GetRegName(ra.reg),
|
||||||
GetHostRegName(lowest));
|
GetHostRegName(lowest));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -680,8 +679,8 @@ u32 CPU::NewRec::Compiler::AllocateHostReg(u32 flags, HostRegAllocType type /* =
|
||||||
{
|
{
|
||||||
DebugAssert(reg != Reg::zero);
|
DebugAssert(reg != Reg::zero);
|
||||||
|
|
||||||
Log_DebugFmt("Allocate host reg {} to guest reg {} in {} mode", GetHostRegName(hreg), GetRegName(reg),
|
DEBUG_LOG("Allocate host reg {} to guest reg {} in {} mode", GetHostRegName(hreg), GetRegName(reg),
|
||||||
GetReadWriteModeString(flags));
|
GetReadWriteModeString(flags));
|
||||||
|
|
||||||
if (flags & HR_MODE_READ)
|
if (flags & HR_MODE_READ)
|
||||||
{
|
{
|
||||||
|
@ -690,7 +689,7 @@ u32 CPU::NewRec::Compiler::AllocateHostReg(u32 flags, HostRegAllocType type /* =
|
||||||
if (HasConstantReg(reg))
|
if (HasConstantReg(reg))
|
||||||
{
|
{
|
||||||
// may as well flush it now
|
// may as well flush it now
|
||||||
Log_DebugFmt("Flush constant register in guest reg {} to host reg {}", GetRegName(reg), GetHostRegName(hreg));
|
DEBUG_LOG("Flush constant register in guest reg {} to host reg {}", GetRegName(reg), GetHostRegName(hreg));
|
||||||
LoadHostRegWithConstant(hreg, GetConstantRegU32(reg));
|
LoadHostRegWithConstant(hreg, GetConstantRegU32(reg));
|
||||||
m_constant_regs_dirty.reset(static_cast<u8>(reg));
|
m_constant_regs_dirty.reset(static_cast<u8>(reg));
|
||||||
ra.flags |= HR_MODE_WRITE;
|
ra.flags |= HR_MODE_WRITE;
|
||||||
|
@ -704,8 +703,8 @@ u32 CPU::NewRec::Compiler::AllocateHostReg(u32 flags, HostRegAllocType type /* =
|
||||||
if (flags & HR_MODE_WRITE && HasConstantReg(reg))
|
if (flags & HR_MODE_WRITE && HasConstantReg(reg))
|
||||||
{
|
{
|
||||||
DebugAssert(reg != Reg::zero);
|
DebugAssert(reg != Reg::zero);
|
||||||
Log_DebugFmt("Clearing constant register in guest reg {} due to write mode in {}", GetRegName(reg),
|
DEBUG_LOG("Clearing constant register in guest reg {} due to write mode in {}", GetRegName(reg),
|
||||||
GetHostRegName(hreg));
|
GetHostRegName(hreg));
|
||||||
|
|
||||||
ClearConstantReg(reg);
|
ClearConstantReg(reg);
|
||||||
}
|
}
|
||||||
|
@ -715,8 +714,8 @@ u32 CPU::NewRec::Compiler::AllocateHostReg(u32 flags, HostRegAllocType type /* =
|
||||||
case HR_TYPE_LOAD_DELAY_VALUE:
|
case HR_TYPE_LOAD_DELAY_VALUE:
|
||||||
{
|
{
|
||||||
DebugAssert(!m_load_delay_dirty && (!HasLoadDelay() || !(flags & HR_MODE_WRITE)));
|
DebugAssert(!m_load_delay_dirty && (!HasLoadDelay() || !(flags & HR_MODE_WRITE)));
|
||||||
Log_DebugFmt("Allocating load delayed guest register {} in host reg {} in {} mode", GetRegName(reg),
|
DEBUG_LOG("Allocating load delayed guest register {} in host reg {} in {} mode", GetRegName(reg),
|
||||||
GetHostRegName(hreg), GetReadWriteModeString(flags));
|
GetHostRegName(hreg), GetReadWriteModeString(flags));
|
||||||
m_load_delay_register = reg;
|
m_load_delay_register = reg;
|
||||||
m_load_delay_value_register = hreg;
|
m_load_delay_value_register = hreg;
|
||||||
if (flags & HR_MODE_READ)
|
if (flags & HR_MODE_READ)
|
||||||
|
@ -726,8 +725,8 @@ u32 CPU::NewRec::Compiler::AllocateHostReg(u32 flags, HostRegAllocType type /* =
|
||||||
|
|
||||||
case HR_TYPE_NEXT_LOAD_DELAY_VALUE:
|
case HR_TYPE_NEXT_LOAD_DELAY_VALUE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Allocating next load delayed guest register {} in host reg {} in {} mode", GetRegName(reg),
|
DEBUG_LOG("Allocating next load delayed guest register {} in host reg {} in {} mode", GetRegName(reg),
|
||||||
GetHostRegName(hreg), GetReadWriteModeString(flags));
|
GetHostRegName(hreg), GetReadWriteModeString(flags));
|
||||||
m_next_load_delay_register = reg;
|
m_next_load_delay_register = reg;
|
||||||
m_next_load_delay_value_register = hreg;
|
m_next_load_delay_value_register = hreg;
|
||||||
if (flags & HR_MODE_READ)
|
if (flags & HR_MODE_READ)
|
||||||
|
@ -738,7 +737,7 @@ u32 CPU::NewRec::Compiler::AllocateHostReg(u32 flags, HostRegAllocType type /* =
|
||||||
case HR_TYPE_TEMP:
|
case HR_TYPE_TEMP:
|
||||||
{
|
{
|
||||||
DebugAssert(!(flags & (HR_MODE_READ | HR_MODE_WRITE)));
|
DebugAssert(!(flags & (HR_MODE_READ | HR_MODE_WRITE)));
|
||||||
Log_DebugFmt("Allocate host reg {} as temporary", GetHostRegName(hreg));
|
DEBUG_LOG("Allocate host reg {} as temporary", GetHostRegName(hreg));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -764,13 +763,13 @@ std::optional<u32> CPU::NewRec::Compiler::CheckHostReg(u32 flags, HostRegAllocTy
|
||||||
{
|
{
|
||||||
DebugAssert(type == HR_TYPE_CPU_REG);
|
DebugAssert(type == HR_TYPE_CPU_REG);
|
||||||
if (!(ra.flags & HR_MODE_WRITE))
|
if (!(ra.flags & HR_MODE_WRITE))
|
||||||
Log_DebugFmt("Switch guest reg {} from read to read-write in host reg {}", GetRegName(reg), GetHostRegName(i));
|
DEBUG_LOG("Switch guest reg {} from read to read-write in host reg {}", GetRegName(reg), GetHostRegName(i));
|
||||||
|
|
||||||
if (HasConstantReg(reg))
|
if (HasConstantReg(reg))
|
||||||
{
|
{
|
||||||
DebugAssert(reg != Reg::zero);
|
DebugAssert(reg != Reg::zero);
|
||||||
Log_DebugFmt("Clearing constant register in guest reg {} due to write mode in {}", GetRegName(reg),
|
DEBUG_LOG("Clearing constant register in guest reg {} due to write mode in {}", GetRegName(reg),
|
||||||
GetHostRegName(i));
|
GetHostRegName(i));
|
||||||
|
|
||||||
ClearConstantReg(reg);
|
ClearConstantReg(reg);
|
||||||
}
|
}
|
||||||
|
@ -784,7 +783,7 @@ std::optional<u32> CPU::NewRec::Compiler::CheckHostReg(u32 flags, HostRegAllocTy
|
||||||
{
|
{
|
||||||
// Need to move it to one which is
|
// Need to move it to one which is
|
||||||
const u32 new_reg = GetFreeHostReg(HR_CALLEE_SAVED);
|
const u32 new_reg = GetFreeHostReg(HR_CALLEE_SAVED);
|
||||||
Log_DebugFmt("Rename host reg {} to {} for callee saved", GetHostRegName(i), GetHostRegName(new_reg));
|
DEBUG_LOG("Rename host reg {} to {} for callee saved", GetHostRegName(i), GetHostRegName(new_reg));
|
||||||
|
|
||||||
CopyHostReg(new_reg, i);
|
CopyHostReg(new_reg, i);
|
||||||
SwapHostRegAlloc(i, new_reg);
|
SwapHostRegAlloc(i, new_reg);
|
||||||
|
@ -826,7 +825,7 @@ void CPU::NewRec::Compiler::FlushHostReg(u32 reg)
|
||||||
case HR_TYPE_CPU_REG:
|
case HR_TYPE_CPU_REG:
|
||||||
{
|
{
|
||||||
DebugAssert(ra.reg > Reg::zero && ra.reg < Reg::count);
|
DebugAssert(ra.reg > Reg::zero && ra.reg < Reg::count);
|
||||||
Log_DebugFmt("Flushing register {} in host register {} to state", GetRegName(ra.reg), GetHostRegName(reg));
|
DEBUG_LOG("Flushing register {} in host register {} to state", GetRegName(ra.reg), GetHostRegName(reg));
|
||||||
StoreHostRegToCPUPointer(reg, &g_state.regs.r[static_cast<u8>(ra.reg)]);
|
StoreHostRegToCPUPointer(reg, &g_state.regs.r[static_cast<u8>(ra.reg)]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -834,8 +833,8 @@ void CPU::NewRec::Compiler::FlushHostReg(u32 reg)
|
||||||
case HR_TYPE_LOAD_DELAY_VALUE:
|
case HR_TYPE_LOAD_DELAY_VALUE:
|
||||||
{
|
{
|
||||||
DebugAssert(m_load_delay_value_register == reg);
|
DebugAssert(m_load_delay_value_register == reg);
|
||||||
Log_DebugFmt("Flushing load delayed register {} in host register {} to state", GetRegName(ra.reg),
|
DEBUG_LOG("Flushing load delayed register {} in host register {} to state", GetRegName(ra.reg),
|
||||||
GetHostRegName(reg));
|
GetHostRegName(reg));
|
||||||
|
|
||||||
StoreHostRegToCPUPointer(reg, &g_state.load_delay_value);
|
StoreHostRegToCPUPointer(reg, &g_state.load_delay_value);
|
||||||
m_load_delay_value_register = NUM_HOST_REGS;
|
m_load_delay_value_register = NUM_HOST_REGS;
|
||||||
|
@ -845,8 +844,8 @@ void CPU::NewRec::Compiler::FlushHostReg(u32 reg)
|
||||||
case HR_TYPE_NEXT_LOAD_DELAY_VALUE:
|
case HR_TYPE_NEXT_LOAD_DELAY_VALUE:
|
||||||
{
|
{
|
||||||
DebugAssert(m_next_load_delay_value_register == reg);
|
DebugAssert(m_next_load_delay_value_register == reg);
|
||||||
Log_WarningFmt("Flushing NEXT load delayed register {} in host register {} to state", GetRegName(ra.reg),
|
WARNING_LOG("Flushing NEXT load delayed register {} in host register {} to state", GetRegName(ra.reg),
|
||||||
GetHostRegName(reg));
|
GetHostRegName(reg));
|
||||||
|
|
||||||
StoreHostRegToCPUPointer(reg, &g_state.next_load_delay_value);
|
StoreHostRegToCPUPointer(reg, &g_state.next_load_delay_value);
|
||||||
m_next_load_delay_value_register = NUM_HOST_REGS;
|
m_next_load_delay_value_register = NUM_HOST_REGS;
|
||||||
|
@ -864,7 +863,7 @@ void CPU::NewRec::Compiler::FlushHostReg(u32 reg)
|
||||||
void CPU::NewRec::Compiler::FreeHostReg(u32 reg)
|
void CPU::NewRec::Compiler::FreeHostReg(u32 reg)
|
||||||
{
|
{
|
||||||
DebugAssert(IsHostRegAllocated(reg));
|
DebugAssert(IsHostRegAllocated(reg));
|
||||||
Log_DebugFmt("Freeing host register {}", GetHostRegName(reg));
|
DEBUG_LOG("Freeing host register {}", GetHostRegName(reg));
|
||||||
FlushHostReg(reg);
|
FlushHostReg(reg);
|
||||||
ClearHostReg(reg);
|
ClearHostReg(reg);
|
||||||
}
|
}
|
||||||
|
@ -906,18 +905,18 @@ void CPU::NewRec::Compiler::RenameHostReg(u32 reg, u32 new_flags, HostRegAllocTy
|
||||||
|
|
||||||
if (new_type == HR_TYPE_CPU_REG)
|
if (new_type == HR_TYPE_CPU_REG)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Renaming host reg {} to guest reg {}", GetHostRegName(reg), GetRegName(new_reg));
|
DEBUG_LOG("Renaming host reg {} to guest reg {}", GetHostRegName(reg), GetRegName(new_reg));
|
||||||
}
|
}
|
||||||
else if (new_type == HR_TYPE_NEXT_LOAD_DELAY_VALUE)
|
else if (new_type == HR_TYPE_NEXT_LOAD_DELAY_VALUE)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Renaming host reg {} to load delayed guest reg {}", GetHostRegName(reg), GetRegName(new_reg));
|
DEBUG_LOG("Renaming host reg {} to load delayed guest reg {}", GetHostRegName(reg), GetRegName(new_reg));
|
||||||
DebugAssert(m_next_load_delay_register == Reg::count && m_next_load_delay_value_register == NUM_HOST_REGS);
|
DebugAssert(m_next_load_delay_register == Reg::count && m_next_load_delay_value_register == NUM_HOST_REGS);
|
||||||
m_next_load_delay_register = new_reg;
|
m_next_load_delay_register = new_reg;
|
||||||
m_next_load_delay_value_register = reg;
|
m_next_load_delay_value_register = reg;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Renaming host reg {} to temp", GetHostRegName(reg));
|
DEBUG_LOG("Renaming host reg {} to temp", GetHostRegName(reg));
|
||||||
}
|
}
|
||||||
|
|
||||||
HostRegAlloc& ra = m_host_regs[reg];
|
HostRegAlloc& ra = m_host_regs[reg];
|
||||||
|
@ -983,7 +982,7 @@ bool CPU::NewRec::Compiler::TryRenameMIPSReg(Reg to, Reg from, u32 fromhost, Reg
|
||||||
if (to == from || to == other || !iinfo->RenameTest(from))
|
if (to == from || to == other || !iinfo->RenameTest(from))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Log_DebugFmt("Renaming MIPS register {} to {}", GetRegName(from), GetRegName(to));
|
DEBUG_LOG("Renaming MIPS register {} to {}", GetRegName(from), GetRegName(to));
|
||||||
|
|
||||||
if (iinfo->LiveTest(from))
|
if (iinfo->LiveTest(from))
|
||||||
FlushHostReg(fromhost);
|
FlushHostReg(fromhost);
|
||||||
|
@ -1090,8 +1089,8 @@ void CPU::NewRec::Compiler::Flush(u32 flags)
|
||||||
void CPU::NewRec::Compiler::FlushConstantReg(Reg r)
|
void CPU::NewRec::Compiler::FlushConstantReg(Reg r)
|
||||||
{
|
{
|
||||||
DebugAssert(m_constant_regs_valid.test(static_cast<u32>(r)));
|
DebugAssert(m_constant_regs_valid.test(static_cast<u32>(r)));
|
||||||
Log_DebugFmt("Writing back register {} with constant value 0x{:08X}", GetRegName(r),
|
DEBUG_LOG("Writing back register {} with constant value 0x{:08X}", GetRegName(r),
|
||||||
m_constant_reg_values[static_cast<u32>(r)]);
|
m_constant_reg_values[static_cast<u32>(r)]);
|
||||||
StoreConstantToCPUPointer(m_constant_reg_values[static_cast<u32>(r)], &g_state.regs.r[static_cast<u32>(r)]);
|
StoreConstantToCPUPointer(m_constant_reg_values[static_cast<u32>(r)], &g_state.regs.r[static_cast<u32>(r)]);
|
||||||
m_constant_regs_dirty.reset(static_cast<u32>(r));
|
m_constant_regs_dirty.reset(static_cast<u32>(r));
|
||||||
}
|
}
|
||||||
|
@ -1179,8 +1178,8 @@ void CPU::NewRec::Compiler::CompileInstruction()
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
TinyString str;
|
TinyString str;
|
||||||
DisassembleInstruction(&str, m_current_instruction_pc, inst->bits);
|
DisassembleInstruction(&str, m_current_instruction_pc, inst->bits);
|
||||||
Log_DebugFmt("Compiling{} {:08X}: {}", m_current_instruction_branch_delay_slot ? " branch delay slot" : "",
|
DEBUG_LOG("Compiling{} {:08X}: {}", m_current_instruction_branch_delay_slot ? " branch delay slot" : "",
|
||||||
m_current_instruction_pc, str);
|
m_current_instruction_pc, str);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_cycles++;
|
m_cycles++;
|
||||||
|
@ -1390,7 +1389,7 @@ void CPU::NewRec::Compiler::CompileTemplate(void (Compiler::*const_func)(Compile
|
||||||
if (!(tflags & TF_NO_NOP) && (!g_settings.cpu_recompiler_memory_exceptions || !(tflags & TF_CAN_OVERFLOW)) &&
|
if (!(tflags & TF_NO_NOP) && (!g_settings.cpu_recompiler_memory_exceptions || !(tflags & TF_CAN_OVERFLOW)) &&
|
||||||
((tflags & TF_WRITES_T && rt == Reg::zero) || (tflags & TF_WRITES_D && rd == Reg::zero)))
|
((tflags & TF_WRITES_T && rt == Reg::zero) || (tflags & TF_WRITES_D && rd == Reg::zero)))
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Skipping instruction because it writes to zero");
|
DEBUG_LOG("Skipping instruction because it writes to zero");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1437,7 +1436,7 @@ void CPU::NewRec::Compiler::CompileTemplate(void (Compiler::*const_func)(Compile
|
||||||
if (tflags & TF_COMMUTATIVE && !(tflags & TF_WRITES_T) &&
|
if (tflags & TF_COMMUTATIVE && !(tflags & TF_WRITES_T) &&
|
||||||
((HasConstantReg(rs) && !HasConstantReg(rt)) || (tflags & TF_WRITES_D && rd == rt)))
|
((HasConstantReg(rs) && !HasConstantReg(rt)) || (tflags & TF_WRITES_D && rd == rt)))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Swapping S:{} and T:{} due to commutative op and constants", GetRegName(rs), GetRegName(rt));
|
DEBUG_LOG("Swapping S:{} and T:{} due to commutative op and constants", GetRegName(rs), GetRegName(rt));
|
||||||
std::swap(rs, rt);
|
std::swap(rs, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1638,7 +1637,7 @@ void CPU::NewRec::Compiler::CompileLoadStoreTemplate(void (Compiler::*func)(Comp
|
||||||
|
|
||||||
if (!Bus::CanUseFastmemForAddress(addr.value()))
|
if (!Bus::CanUseFastmemForAddress(addr.value()))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Not using fastmem for {:08X}", addr.value());
|
DEBUG_LOG("Not using fastmem for {:08X}", addr.value());
|
||||||
use_fastmem = false;
|
use_fastmem = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1647,7 +1646,7 @@ void CPU::NewRec::Compiler::CompileLoadStoreTemplate(void (Compiler::*func)(Comp
|
||||||
spec_addr = SpecExec_LoadStoreAddr();
|
spec_addr = SpecExec_LoadStoreAddr();
|
||||||
if (use_fastmem && spec_addr.has_value() && !Bus::CanUseFastmemForAddress(spec_addr.value()))
|
if (use_fastmem && spec_addr.has_value() && !Bus::CanUseFastmemForAddress(spec_addr.value()))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Not using fastmem for speculative {:08X}", spec_addr.value());
|
DEBUG_LOG("Not using fastmem for speculative {:08X}", spec_addr.value());
|
||||||
use_fastmem = false;
|
use_fastmem = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1707,9 +1706,9 @@ void CPU::NewRec::Compiler::CompileLoadStoreTemplate(void (Compiler::*func)(Comp
|
||||||
if (phys_spec_addr >= VirtualAddressToPhysical(m_block->pc) &&
|
if (phys_spec_addr >= VirtualAddressToPhysical(m_block->pc) &&
|
||||||
phys_spec_addr < VirtualAddressToPhysical(m_block->pc + (m_block->size * sizeof(Instruction))))
|
phys_spec_addr < VirtualAddressToPhysical(m_block->pc + (m_block->size * sizeof(Instruction))))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Instruction {:08X} speculatively writes to {:08X} inside block {:08X}-{:08X}. Truncating block.",
|
WARNING_LOG("Instruction {:08X} speculatively writes to {:08X} inside block {:08X}-{:08X}. Truncating block.",
|
||||||
m_current_instruction_pc, phys_spec_addr, m_block->pc,
|
m_current_instruction_pc, phys_spec_addr, m_block->pc,
|
||||||
m_block->pc + (m_block->size * sizeof(Instruction)));
|
m_block->pc + (m_block->size * sizeof(Instruction)));
|
||||||
TruncateBlock();
|
TruncateBlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2198,7 +2197,7 @@ void CPU::NewRec::Compiler::Compile_mfc0(CompileFlags cf)
|
||||||
const u32* ptr = GetCop0RegPtr(r);
|
const u32* ptr = GetCop0RegPtr(r);
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Read from unknown cop0 reg {}", static_cast<u32>(r));
|
ERROR_LOG("Read from unknown cop0 reg {}", static_cast<u32>(r));
|
||||||
Compile_Fallback();
|
Compile_Fallback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2304,7 +2303,7 @@ void CPU::NewRec::Compiler::AddGTETicks(TickCount ticks)
|
||||||
{
|
{
|
||||||
// TODO: check, int has +1 here
|
// TODO: check, int has +1 here
|
||||||
m_gte_done_cycle = m_cycles + ticks;
|
m_gte_done_cycle = m_cycles + ticks;
|
||||||
Log_DebugFmt("Adding {} GTE ticks", ticks);
|
DEBUG_LOG("Adding {} GTE ticks", ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPU::NewRec::Compiler::StallUntilGTEComplete()
|
void CPU::NewRec::Compiler::StallUntilGTEComplete()
|
||||||
|
@ -2319,14 +2318,14 @@ void CPU::NewRec::Compiler::StallUntilGTEComplete()
|
||||||
// simple case - in block scheduling
|
// simple case - in block scheduling
|
||||||
if (m_gte_done_cycle > m_cycles)
|
if (m_gte_done_cycle > m_cycles)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Stalling for {} ticks from GTE", m_gte_done_cycle - m_cycles);
|
DEBUG_LOG("Stalling for {} ticks from GTE", m_gte_done_cycle - m_cycles);
|
||||||
m_cycles += (m_gte_done_cycle - m_cycles);
|
m_cycles += (m_gte_done_cycle - m_cycles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// switch to in block scheduling
|
// switch to in block scheduling
|
||||||
Log_DebugPrint("Flushing GTE stall from state");
|
DEBUG_LOG("Flushing GTE stall from state");
|
||||||
Flush(FLUSH_GTE_STALL_FROM_STATE);
|
Flush(FLUSH_GTE_STALL_FROM_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -438,7 +438,7 @@ void CPU::NewRec::AArch32Compiler::EndAndLinkBlock(const std::optional<u32>& new
|
||||||
if (newpc.value() == m_block->pc)
|
if (newpc.value() == m_block->pc)
|
||||||
{
|
{
|
||||||
// Special case: ourselves! No need to backlink then.
|
// Special case: ourselves! No need to backlink then.
|
||||||
Log_DebugFmt("Linking block at {:08X} to self", m_block->pc);
|
DEBUG_LOG("Linking block at {:08X} to self", m_block->pc);
|
||||||
armEmitJmp(armAsm, armAsm->GetBuffer()->GetStartAddress<const void*>(), true);
|
armEmitJmp(armAsm, armAsm->GetBuffer()->GetStartAddress<const void*>(), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -575,7 +575,7 @@ void CPU::NewRec::AArch32Compiler::MoveSToReg(const vixl::aarch32::Register& dst
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Hit memory path in MoveSToReg() for {}", GetRegName(cf.MipsS()));
|
WARNING_LOG("Hit memory path in MoveSToReg() for {}", GetRegName(cf.MipsS()));
|
||||||
armAsm->ldr(dst, PTR(&g_state.regs.r[cf.mips_s]));
|
armAsm->ldr(dst, PTR(&g_state.regs.r[cf.mips_s]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -594,7 +594,7 @@ void CPU::NewRec::AArch32Compiler::MoveTToReg(const vixl::aarch32::Register& dst
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Hit memory path in MoveTToReg() for {}", GetRegName(cf.MipsT()));
|
WARNING_LOG("Hit memory path in MoveTToReg() for {}", GetRegName(cf.MipsT()));
|
||||||
armAsm->ldr(dst, PTR(&g_state.regs.r[cf.mips_t]));
|
armAsm->ldr(dst, PTR(&g_state.regs.r[cf.mips_t]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1927,7 +1927,7 @@ void CPU::NewRec::AArch32Compiler::Compile_mtc0(CompileFlags cf)
|
||||||
if (mask == 0)
|
if (mask == 0)
|
||||||
{
|
{
|
||||||
// if it's a read-only register, ignore
|
// if it's a read-only register, ignore
|
||||||
Log_DebugFmt("Ignoring write to read-only cop0 reg {}", static_cast<u32>(reg));
|
DEBUG_LOG("Ignoring write to read-only cop0 reg {}", static_cast<u32>(reg));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1984,7 +1984,7 @@ void CPU::NewRec::AArch32Compiler::Compile_mtc0(CompileFlags cf)
|
||||||
if (reg == Cop0Reg::DCIC && g_settings.cpu_recompiler_memory_exceptions)
|
if (reg == Cop0Reg::DCIC && g_settings.cpu_recompiler_memory_exceptions)
|
||||||
{
|
{
|
||||||
// TODO: DCIC handling for debug breakpoints
|
// TODO: DCIC handling for debug breakpoints
|
||||||
Log_WarningPrint("TODO: DCIC handling for debug breakpoints");
|
WARNING_LOG("TODO: DCIC handling for debug breakpoints");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -410,7 +410,7 @@ void CPU::NewRec::AArch64Compiler::EndAndLinkBlock(const std::optional<u32>& new
|
||||||
if (newpc.value() == m_block->pc)
|
if (newpc.value() == m_block->pc)
|
||||||
{
|
{
|
||||||
// Special case: ourselves! No need to backlink then.
|
// Special case: ourselves! No need to backlink then.
|
||||||
Log_DebugFmt("Linking block at {:08X} to self", m_block->pc);
|
DEBUG_LOG("Linking block at {:08X} to self", m_block->pc);
|
||||||
armEmitJmp(armAsm, armAsm->GetBuffer()->GetStartAddress<const void*>(), true);
|
armEmitJmp(armAsm, armAsm->GetBuffer()->GetStartAddress<const void*>(), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -542,7 +542,7 @@ void CPU::NewRec::AArch64Compiler::MoveSToReg(const vixl::aarch64::WRegister& ds
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Hit memory path in MoveSToReg() for {}", GetRegName(cf.MipsS()));
|
WARNING_LOG("Hit memory path in MoveSToReg() for {}", GetRegName(cf.MipsS()));
|
||||||
armAsm->ldr(dst, PTR(&g_state.regs.r[cf.mips_s]));
|
armAsm->ldr(dst, PTR(&g_state.regs.r[cf.mips_s]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,7 +564,7 @@ void CPU::NewRec::AArch64Compiler::MoveTToReg(const vixl::aarch64::WRegister& ds
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Hit memory path in MoveTToReg() for {}", GetRegName(cf.MipsT()));
|
WARNING_LOG("Hit memory path in MoveTToReg() for {}", GetRegName(cf.MipsT()));
|
||||||
armAsm->ldr(dst, PTR(&g_state.regs.r[cf.mips_t]));
|
armAsm->ldr(dst, PTR(&g_state.regs.r[cf.mips_t]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1906,7 +1906,7 @@ void CPU::NewRec::AArch64Compiler::Compile_mtc0(CompileFlags cf)
|
||||||
if (mask == 0)
|
if (mask == 0)
|
||||||
{
|
{
|
||||||
// if it's a read-only register, ignore
|
// if it's a read-only register, ignore
|
||||||
Log_DebugFmt("Ignoring write to read-only cop0 reg {}", static_cast<u32>(reg));
|
DEBUG_LOG("Ignoring write to read-only cop0 reg {}", static_cast<u32>(reg));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1961,7 +1961,7 @@ void CPU::NewRec::AArch64Compiler::Compile_mtc0(CompileFlags cf)
|
||||||
if (reg == Cop0Reg::DCIC && g_settings.cpu_recompiler_memory_exceptions)
|
if (reg == Cop0Reg::DCIC && g_settings.cpu_recompiler_memory_exceptions)
|
||||||
{
|
{
|
||||||
// TODO: DCIC handling for debug breakpoints
|
// TODO: DCIC handling for debug breakpoints
|
||||||
Log_WarningPrint("TODO: DCIC handling for debug breakpoints");
|
WARNING_LOG("TODO: DCIC handling for debug breakpoints");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,11 +173,11 @@ void CPU::CodeCache::DisassembleAndLogHostCode(const void* start, u32 size)
|
||||||
size_t instlen;
|
size_t instlen;
|
||||||
inst_fetch(cur, &inst, &instlen);
|
inst_fetch(cur, &inst, &instlen);
|
||||||
disasm_inst(buf, std::size(buf), rv64, static_cast<u64>(reinterpret_cast<uintptr_t>(cur)), inst);
|
disasm_inst(buf, std::size(buf), rv64, static_cast<u64>(reinterpret_cast<uintptr_t>(cur)), inst);
|
||||||
Log_DebugFmt("\t0x{:016X}\t{}", static_cast<u64>(reinterpret_cast<uintptr_t>(cur)), buf);
|
DEBUG_LOG("\t0x{:016X}\t{}", static_cast<u64>(reinterpret_cast<uintptr_t>(cur)), buf);
|
||||||
cur += instlen;
|
cur += instlen;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Log_ErrorPrint("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
ERROR_LOG("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ u32 CPU::CodeCache::GetHostInstructionCount(const void* start, u32 size)
|
||||||
}
|
}
|
||||||
return icount;
|
return icount;
|
||||||
#else
|
#else
|
||||||
Log_ErrorPrint("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
ERROR_LOG("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -665,7 +665,7 @@ void CPU::NewRec::RISCV64Compiler::EndAndLinkBlock(const std::optional<u32>& new
|
||||||
if (newpc.value() == m_block->pc)
|
if (newpc.value() == m_block->pc)
|
||||||
{
|
{
|
||||||
// Special case: ourselves! No need to backlink then.
|
// Special case: ourselves! No need to backlink then.
|
||||||
Log_DebugFmt("Linking block at {:08X} to self", m_block->pc);
|
DEBUG_LOG("Linking block at {:08X} to self", m_block->pc);
|
||||||
rvEmitJmp(rvAsm, rvAsm->GetBufferPointer(0));
|
rvEmitJmp(rvAsm, rvAsm->GetBufferPointer(0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -754,7 +754,7 @@ biscuit::GPR CPU::NewRec::RISCV64Compiler::CFGetSafeRegS(CompileFlags cf, const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Hit memory path in CFGetSafeRegS() for {}", GetRegName(cf.MipsS()));
|
WARNING_LOG("Hit memory path in CFGetSafeRegS() for {}", GetRegName(cf.MipsS()));
|
||||||
rvAsm->LW(temp_reg, PTR(&g_state.regs.r[cf.mips_s]));
|
rvAsm->LW(temp_reg, PTR(&g_state.regs.r[cf.mips_s]));
|
||||||
return temp_reg;
|
return temp_reg;
|
||||||
}
|
}
|
||||||
|
@ -776,7 +776,7 @@ biscuit::GPR CPU::NewRec::RISCV64Compiler::CFGetSafeRegT(CompileFlags cf, const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Hit memory path in CFGetSafeRegT() for {}", GetRegName(cf.MipsT()));
|
WARNING_LOG("Hit memory path in CFGetSafeRegT() for {}", GetRegName(cf.MipsT()));
|
||||||
rvAsm->LW(temp_reg, PTR(&g_state.regs.r[cf.mips_t]));
|
rvAsm->LW(temp_reg, PTR(&g_state.regs.r[cf.mips_t]));
|
||||||
return temp_reg;
|
return temp_reg;
|
||||||
}
|
}
|
||||||
|
@ -825,7 +825,7 @@ void CPU::NewRec::RISCV64Compiler::MoveSToReg(const biscuit::GPR& dst, CompileFl
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Hit memory path in MoveSToReg() for {}", GetRegName(cf.MipsS()));
|
WARNING_LOG("Hit memory path in MoveSToReg() for {}", GetRegName(cf.MipsS()));
|
||||||
rvAsm->LW(dst, PTR(&g_state.regs.r[cf.mips_s]));
|
rvAsm->LW(dst, PTR(&g_state.regs.r[cf.mips_s]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -843,7 +843,7 @@ void CPU::NewRec::RISCV64Compiler::MoveTToReg(const biscuit::GPR& dst, CompileFl
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Hit memory path in MoveTToReg() for {}", GetRegName(cf.MipsT()));
|
WARNING_LOG("Hit memory path in MoveTToReg() for {}", GetRegName(cf.MipsT()));
|
||||||
rvAsm->LW(dst, PTR(&g_state.regs.r[cf.mips_t]));
|
rvAsm->LW(dst, PTR(&g_state.regs.r[cf.mips_t]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2214,7 +2214,7 @@ void CPU::NewRec::RISCV64Compiler::Compile_mtc0(CompileFlags cf)
|
||||||
if (mask == 0)
|
if (mask == 0)
|
||||||
{
|
{
|
||||||
// if it's a read-only register, ignore
|
// if it's a read-only register, ignore
|
||||||
Log_DebugFmt("Ignoring write to read-only cop0 reg {}", static_cast<u32>(reg));
|
DEBUG_LOG("Ignoring write to read-only cop0 reg {}", static_cast<u32>(reg));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2273,7 +2273,7 @@ void CPU::NewRec::RISCV64Compiler::Compile_mtc0(CompileFlags cf)
|
||||||
if (reg == Cop0Reg::DCIC && g_settings.cpu_recompiler_memory_exceptions)
|
if (reg == Cop0Reg::DCIC && g_settings.cpu_recompiler_memory_exceptions)
|
||||||
{
|
{
|
||||||
// TODO: DCIC handling for debug breakpoints
|
// TODO: DCIC handling for debug breakpoints
|
||||||
Log_WarningPrint("TODO: DCIC handling for debug breakpoints");
|
WARNING_LOG("TODO: DCIC handling for debug breakpoints");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,7 @@ void CPU::NewRec::X64Compiler::EndAndLinkBlock(const std::optional<u32>& newpc,
|
||||||
if (newpc.value() == m_block->pc)
|
if (newpc.value() == m_block->pc)
|
||||||
{
|
{
|
||||||
// Special case: ourselves! No need to backlink then.
|
// Special case: ourselves! No need to backlink then.
|
||||||
Log_DebugFmt("Linking block at {:08X} to self", m_block->pc);
|
DEBUG_LOG("Linking block at {:08X} to self", m_block->pc);
|
||||||
cg->jmp(cg->getCode());
|
cg->jmp(cg->getCode());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1877,7 +1877,7 @@ void CPU::NewRec::X64Compiler::Compile_mtc0(CompileFlags cf)
|
||||||
if (mask == 0)
|
if (mask == 0)
|
||||||
{
|
{
|
||||||
// if it's a read-only register, ignore
|
// if it's a read-only register, ignore
|
||||||
Log_DebugFmt("Ignoring write to read-only cop0 reg {}", static_cast<u32>(reg));
|
DEBUG_LOG("Ignoring write to read-only cop0 reg {}", static_cast<u32>(reg));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1940,7 +1940,7 @@ void CPU::NewRec::X64Compiler::Compile_mtc0(CompileFlags cf)
|
||||||
if (reg == Cop0Reg::DCIC && g_settings.cpu_recompiler_memory_exceptions)
|
if (reg == Cop0Reg::DCIC && g_settings.cpu_recompiler_memory_exceptions)
|
||||||
{
|
{
|
||||||
// TODO: DCIC handling for debug breakpoints
|
// TODO: DCIC handling for debug breakpoints
|
||||||
Log_WarningPrint("TODO: DCIC handling for debug breakpoints");
|
WARNING_LOG("TODO: DCIC handling for debug breakpoints");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ void CPU::PGXP::Initialize()
|
||||||
s_vertex_cache = static_cast<PGXP_value*>(std::calloc(VERTEX_CACHE_SIZE, sizeof(PGXP_value)));
|
s_vertex_cache = static_cast<PGXP_value*>(std::calloc(VERTEX_CACHE_SIZE, sizeof(PGXP_value)));
|
||||||
if (!s_vertex_cache)
|
if (!s_vertex_cache)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate memory for vertex cache, disabling.");
|
ERROR_LOG("Failed to allocate memory for vertex cache, disabling.");
|
||||||
g_settings.gpu_pgxp_vertex_cache = false;
|
g_settings.gpu_pgxp_vertex_cache = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -980,7 +980,7 @@ void CodeGenerator::BlockPrologue()
|
||||||
|
|
||||||
if (m_block->protection == CodeCache::PageProtectionMode::ManualCheck)
|
if (m_block->protection == CodeCache::PageProtectionMode::ManualCheck)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Generate manual protection for PC {:08X}", m_block->pc);
|
DEBUG_LOG("Generate manual protection for PC {:08X}", m_block->pc);
|
||||||
const u8* ram_ptr = Bus::g_ram + VirtualAddressToPhysical(m_block->pc);
|
const u8* ram_ptr = Bus::g_ram + VirtualAddressToPhysical(m_block->pc);
|
||||||
const u8* shadow_ptr = reinterpret_cast<const u8*>(m_block->Instructions());
|
const u8* shadow_ptr = reinterpret_cast<const u8*>(m_block->Instructions());
|
||||||
EmitBlockProtectCheck(ram_ptr, shadow_ptr, m_block->size * sizeof(Instruction));
|
EmitBlockProtectCheck(ram_ptr, shadow_ptr, m_block->size * sizeof(Instruction));
|
||||||
|
@ -1079,7 +1079,7 @@ void CodeGenerator::InstructionEpilogue(Instruction instruction, const CodeCache
|
||||||
if (m_load_delay_dirty)
|
if (m_load_delay_dirty)
|
||||||
{
|
{
|
||||||
// we have to invalidate the register cache, since the load delayed register might've been cached
|
// we have to invalidate the register cache, since the load delayed register might've been cached
|
||||||
Log_DebugPrint("Emitting delay slot flush");
|
DEBUG_LOG("Emitting delay slot flush");
|
||||||
EmitFlushInterpreterLoadDelay();
|
EmitFlushInterpreterLoadDelay();
|
||||||
m_register_cache.InvalidateAllNonDirtyGuestRegisters();
|
m_register_cache.InvalidateAllNonDirtyGuestRegisters();
|
||||||
m_load_delay_dirty = false;
|
m_load_delay_dirty = false;
|
||||||
|
@ -1088,7 +1088,7 @@ void CodeGenerator::InstructionEpilogue(Instruction instruction, const CodeCache
|
||||||
// copy if the previous instruction was a load, reset the current value on the next instruction
|
// copy if the previous instruction was a load, reset the current value on the next instruction
|
||||||
if (m_next_load_delay_dirty)
|
if (m_next_load_delay_dirty)
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Emitting delay slot flush (with move next)");
|
DEBUG_LOG("Emitting delay slot flush (with move next)");
|
||||||
EmitMoveNextInterpreterLoadDelay();
|
EmitMoveNextInterpreterLoadDelay();
|
||||||
m_next_load_delay_dirty = false;
|
m_next_load_delay_dirty = false;
|
||||||
m_load_delay_dirty = true;
|
m_load_delay_dirty = true;
|
||||||
|
@ -1097,7 +1097,7 @@ void CodeGenerator::InstructionEpilogue(Instruction instruction, const CodeCache
|
||||||
|
|
||||||
void CodeGenerator::TruncateBlockAtCurrentInstruction()
|
void CodeGenerator::TruncateBlockAtCurrentInstruction()
|
||||||
{
|
{
|
||||||
Log_DevFmt("Truncating block {:08X} at {:08X}", m_block->pc, m_current_instruction.info->pc);
|
DEV_LOG("Truncating block {:08X} at {:08X}", m_block->pc, m_current_instruction.info->pc);
|
||||||
m_block_end.instruction = m_current_instruction.instruction + 1;
|
m_block_end.instruction = m_current_instruction.instruction + 1;
|
||||||
m_block_end.info = m_current_instruction.info + 1;
|
m_block_end.info = m_current_instruction.info + 1;
|
||||||
WriteNewPC(CalculatePC(), true);
|
WriteNewPC(CalculatePC(), true);
|
||||||
|
@ -1141,7 +1141,7 @@ void CodeGenerator::AddPendingCycles(bool commit)
|
||||||
void CodeGenerator::AddGTETicks(TickCount ticks)
|
void CodeGenerator::AddGTETicks(TickCount ticks)
|
||||||
{
|
{
|
||||||
m_gte_done_cycle = m_delayed_cycles_add + ticks;
|
m_gte_done_cycle = m_delayed_cycles_add + ticks;
|
||||||
Log_DebugFmt("Adding {} GTE ticks", ticks);
|
DEBUG_LOG("Adding {} GTE ticks", ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeGenerator::StallUntilGTEComplete()
|
void CodeGenerator::StallUntilGTEComplete()
|
||||||
|
@ -1151,7 +1151,7 @@ void CodeGenerator::StallUntilGTEComplete()
|
||||||
// simple case - in block scheduling
|
// simple case - in block scheduling
|
||||||
if (m_gte_done_cycle > m_delayed_cycles_add)
|
if (m_gte_done_cycle > m_delayed_cycles_add)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Stalling for {} ticks from GTE", m_gte_done_cycle - m_delayed_cycles_add);
|
DEBUG_LOG("Stalling for {} ticks from GTE", m_gte_done_cycle - m_delayed_cycles_add);
|
||||||
m_delayed_cycles_add += (m_gte_done_cycle - m_delayed_cycles_add);
|
m_delayed_cycles_add += (m_gte_done_cycle - m_delayed_cycles_add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1667,9 +1667,8 @@ bool CodeGenerator::Compile_Store(Instruction instruction, const CodeCache::Inst
|
||||||
VirtualAddressToPhysical(m_block->pc + (m_block->size * sizeof(Instruction)));
|
VirtualAddressToPhysical(m_block->pc + (m_block->size * sizeof(Instruction)));
|
||||||
if (phys_addr >= block_start && phys_addr < block_end)
|
if (phys_addr >= block_start && phys_addr < block_end)
|
||||||
{
|
{
|
||||||
Log_WarningFmt(
|
WARNING_LOG("Instruction {:08X} speculatively writes to {:08X} inside block {:08X}-{:08X}. Truncating block.",
|
||||||
"Instruction {:08X} speculatively writes to {:08X} inside block {:08X}-{:08X}. Truncating block.", info.pc,
|
info.pc, phys_addr, block_start, block_end);
|
||||||
phys_addr, block_start, block_end);
|
|
||||||
TruncateBlockAtCurrentInstruction();
|
TruncateBlockAtCurrentInstruction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1710,7 +1709,7 @@ bool CodeGenerator::Compile_LoadLeftRight(Instruction instruction, const CodeCac
|
||||||
// we don't actually care if it's our target reg or not, if it's not, it won't affect anything
|
// we don't actually care if it's our target reg or not, if it's not, it won't affect anything
|
||||||
if (m_load_delay_dirty)
|
if (m_load_delay_dirty)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Flushing interpreter load delay for lwl/lwr instruction at 0x{:08X}", info.pc);
|
DEV_LOG("Flushing interpreter load delay for lwl/lwr instruction at 0x{:08X}", info.pc);
|
||||||
EmitFlushInterpreterLoadDelay();
|
EmitFlushInterpreterLoadDelay();
|
||||||
m_register_cache.InvalidateGuestRegister(instruction.r.rt);
|
m_register_cache.InvalidateGuestRegister(instruction.r.rt);
|
||||||
m_load_delay_dirty = false;
|
m_load_delay_dirty = false;
|
||||||
|
@ -2387,8 +2386,8 @@ bool CodeGenerator::Compile_Branch(Instruction instruction, const CodeCache::Ins
|
||||||
|
|
||||||
if (branch_target.IsConstant())
|
if (branch_target.IsConstant())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Misaligned constant target branch 0x{:08X}, this is strange",
|
WARNING_LOG("Misaligned constant target branch 0x{:08X}, this is strange",
|
||||||
Truncate32(branch_target.constant_value));
|
Truncate32(branch_target.constant_value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -123,7 +123,8 @@ void CPU::Recompiler::armEmitCall(vixl::aarch32::Assembler* armAsm, const void*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPU::Recompiler::armEmitCondBranch(vixl::aarch32::Assembler* armAsm, vixl::aarch32::Condition cond, const void* ptr)
|
void CPU::Recompiler::armEmitCondBranch(vixl::aarch32::Assembler* armAsm, vixl::aarch32::Condition cond,
|
||||||
|
const void* ptr)
|
||||||
{
|
{
|
||||||
const s32 displacement = armGetPCDisplacement(armAsm->GetCursorAddress<const void*>(), ptr);
|
const s32 displacement = armGetPCDisplacement(armAsm->GetCursorAddress<const void*>(), ptr);
|
||||||
if (!armIsPCDisplacementInImmediateRange(displacement))
|
if (!armIsPCDisplacementInImmediateRange(displacement))
|
||||||
|
@ -145,7 +146,7 @@ void CPU::CodeCache::DisassembleAndLogHostCode(const void* start, u32 size)
|
||||||
dis.SetCodeAddress(reinterpret_cast<uintptr_t>(start));
|
dis.SetCodeAddress(reinterpret_cast<uintptr_t>(start));
|
||||||
dis.DisassembleA32Buffer(static_cast<const u32*>(start), size);
|
dis.DisassembleA32Buffer(static_cast<const u32*>(start), size);
|
||||||
#else
|
#else
|
||||||
Log_ErrorPrint("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
ERROR_LOG("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1766,7 +1767,7 @@ void CodeGenerator::EmitStoreGuestMemorySlowmem(Instruction instruction, const C
|
||||||
|
|
||||||
void CodeGenerator::BackpatchLoadStore(void* host_pc, const CodeCache::LoadstoreBackpatchInfo& lbi)
|
void CodeGenerator::BackpatchLoadStore(void* host_pc, const CodeCache::LoadstoreBackpatchInfo& lbi)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Backpatching {} (guest PC 0x{:08X}) to slowmem at {}", host_pc, lbi.guest_pc, lbi.thunk_address);
|
DEV_LOG("Backpatching {} (guest PC 0x{:08X}) to slowmem at {}", host_pc, lbi.guest_pc, lbi.thunk_address);
|
||||||
|
|
||||||
// turn it into a jump to the slowmem handler
|
// turn it into a jump to the slowmem handler
|
||||||
vixl::aarch32::MacroAssembler emit(static_cast<vixl::byte*>(host_pc), lbi.code_size, a32::A32);
|
vixl::aarch32::MacroAssembler emit(static_cast<vixl::byte*>(host_pc), lbi.code_size, a32::A32);
|
||||||
|
|
|
@ -279,8 +279,7 @@ void CPU::CodeCache::DisassembleAndLogHostCode(const void* start, u32 size)
|
||||||
protected:
|
protected:
|
||||||
void ProcessOutput(const a64::Instruction* instr) override
|
void ProcessOutput(const a64::Instruction* instr) override
|
||||||
{
|
{
|
||||||
Log_DebugFmt("0x{:016X} {:08X}\t\t{}", reinterpret_cast<uint64_t>(instr), instr->GetInstructionBits(),
|
DEBUG_LOG("0x{:016X} {:08X}\t\t{}", reinterpret_cast<uint64_t>(instr), instr->GetInstructionBits(), GetOutput());
|
||||||
GetOutput());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -290,7 +289,7 @@ void CPU::CodeCache::DisassembleAndLogHostCode(const void* start, u32 size)
|
||||||
decoder.Decode(static_cast<const a64::Instruction*>(start),
|
decoder.Decode(static_cast<const a64::Instruction*>(start),
|
||||||
reinterpret_cast<const a64::Instruction*>(static_cast<const u8*>(start) + size));
|
reinterpret_cast<const a64::Instruction*>(static_cast<const u8*>(start) + size));
|
||||||
#else
|
#else
|
||||||
Log_ErrorPrint("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
ERROR_LOG("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2059,7 +2058,7 @@ void CodeGenerator::EmitUpdateFastmemBase()
|
||||||
|
|
||||||
void CodeGenerator::BackpatchLoadStore(void* host_pc, const CodeCache::LoadstoreBackpatchInfo& lbi)
|
void CodeGenerator::BackpatchLoadStore(void* host_pc, const CodeCache::LoadstoreBackpatchInfo& lbi)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Backpatching {} (guest PC 0x{:08X}) to slowmem at {}", host_pc, lbi.guest_pc, lbi.thunk_address);
|
DEV_LOG("Backpatching {} (guest PC 0x{:08X}) to slowmem at {}", host_pc, lbi.guest_pc, lbi.thunk_address);
|
||||||
|
|
||||||
// check jump distance
|
// check jump distance
|
||||||
const s64 jump_distance =
|
const s64 jump_distance =
|
||||||
|
|
|
@ -70,14 +70,14 @@ Value CodeGenerator::EmitLoadGuestMemory(Instruction instruction, const CodeCach
|
||||||
{
|
{
|
||||||
if (!use_fastmem)
|
if (!use_fastmem)
|
||||||
{
|
{
|
||||||
Log_ProfileFmt("Non-constant load at 0x{:08X}, speculative address 0x{:08X}, using fastmem = {}", info.pc,
|
DEBUG_LOG("Non-constant load at 0x{:08X}, speculative address 0x{:08X}, using fastmem = {}", info.pc,
|
||||||
*address_spec, use_fastmem ? "yes" : "no");
|
*address_spec, use_fastmem ? "yes" : "no");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ProfileFmt("Non-constant load at 0x{:08X}, speculative address UNKNOWN, using fastmem = {}", info.pc,
|
DEBUG_LOG("Non-constant load at 0x{:08X}, speculative address UNKNOWN, using fastmem = {}", info.pc,
|
||||||
use_fastmem ? "yes" : "no");
|
use_fastmem ? "yes" : "no");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CodeCache::IsUsingFastmem() && use_fastmem)
|
if (CodeCache::IsUsingFastmem() && use_fastmem)
|
||||||
|
@ -145,14 +145,14 @@ void CodeGenerator::EmitStoreGuestMemory(Instruction instruction, const CodeCach
|
||||||
{
|
{
|
||||||
if (!use_fastmem)
|
if (!use_fastmem)
|
||||||
{
|
{
|
||||||
Log_ProfileFmt("Non-constant store at 0x{:08X}, speculative address 0x{:08X}, using fastmem = {}", info.pc,
|
DEBUG_LOG("Non-constant store at 0x{:08X}, speculative address 0x{:08X}, using fastmem = {}", info.pc,
|
||||||
*address_spec, use_fastmem ? "yes" : "no");
|
*address_spec, use_fastmem ? "yes" : "no");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ProfileFmt("Non-constant store at 0x{:08X}, speculative address UNKNOWN, using fastmem = {}", info.pc,
|
DEBUG_LOG("Non-constant store at 0x{:08X}, speculative address UNKNOWN, using fastmem = {}", info.pc,
|
||||||
use_fastmem ? "yes" : "no");
|
use_fastmem ? "yes" : "no");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CodeCache::IsUsingFastmem() && use_fastmem)
|
if (CodeCache::IsUsingFastmem() && use_fastmem)
|
||||||
|
|
|
@ -259,8 +259,8 @@ void CPU::CodeCache::DisassembleAndLogHostCode(const void* start, u32 size)
|
||||||
else
|
else
|
||||||
hex.append(" ");
|
hex.append(" ");
|
||||||
}
|
}
|
||||||
Log::WriteFmt("HostCode", "", LOGLEVEL_DEBUG, " {:016X} {} {}",
|
Log::FastWrite("HostCode", "", LOGLEVEL_DEBUG, " {:016X} {} {}",
|
||||||
static_cast<u64>(reinterpret_cast<uintptr_t>(ptr)), hex, buffer);
|
static_cast<u64>(reinterpret_cast<uintptr_t>(ptr)), hex, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr += disas_instruction.length;
|
ptr += disas_instruction.length;
|
||||||
|
@ -293,12 +293,12 @@ u32 CPU::CodeCache::GetHostInstructionCount(const void* start, u32 size)
|
||||||
|
|
||||||
void CPU::CodeCache::DisassembleAndLogHostCode(const void* start, u32 size)
|
void CPU::CodeCache::DisassembleAndLogHostCode(const void* start, u32 size)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
ERROR_LOG("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CPU::CodeCache::GetHostInstructionCount(const void* start, u32 size)
|
u32 CPU::CodeCache::GetHostInstructionCount(const void* start, u32 size)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
ERROR_LOG("Not compiled with ENABLE_HOST_DISASSEMBLY.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2518,7 +2518,7 @@ void CodeGenerator::EmitUpdateFastmemBase()
|
||||||
|
|
||||||
void CodeGenerator::BackpatchLoadStore(void* host_pc, const CodeCache::LoadstoreBackpatchInfo& lbi)
|
void CodeGenerator::BackpatchLoadStore(void* host_pc, const CodeCache::LoadstoreBackpatchInfo& lbi)
|
||||||
{
|
{
|
||||||
Log_ProfileFmt("Backpatching {} (guest PC 0x{:08X}) to slowmem", host_pc, lbi.guest_pc);
|
DEV_LOG("Backpatching {} (guest PC 0x{:08X}) to slowmem", host_pc, lbi.guest_pc);
|
||||||
|
|
||||||
// turn it into a jump to the slowmem handler
|
// turn it into a jump to the slowmem handler
|
||||||
Xbyak::CodeGenerator cg(lbi.code_size, host_pc);
|
Xbyak::CodeGenerator cg(lbi.code_size, host_pc);
|
||||||
|
|
|
@ -231,21 +231,21 @@ bool RegisterCache::AllocateHostReg(HostReg reg, HostRegState state /*= HostRegS
|
||||||
void RegisterCache::DiscardHostReg(HostReg reg)
|
void RegisterCache::DiscardHostReg(HostReg reg)
|
||||||
{
|
{
|
||||||
DebugAssert(IsHostRegInUse(reg));
|
DebugAssert(IsHostRegInUse(reg));
|
||||||
Log_DebugFmt("Discarding host register {}", m_code_generator.GetHostRegName(reg));
|
DEBUG_LOG("Discarding host register {}", m_code_generator.GetHostRegName(reg));
|
||||||
m_state.host_reg_state[reg] |= HostRegState::Discarded;
|
m_state.host_reg_state[reg] |= HostRegState::Discarded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterCache::UndiscardHostReg(HostReg reg)
|
void RegisterCache::UndiscardHostReg(HostReg reg)
|
||||||
{
|
{
|
||||||
DebugAssert(IsHostRegInUse(reg));
|
DebugAssert(IsHostRegInUse(reg));
|
||||||
Log_DebugFmt("Undiscarding host register {}", m_code_generator.GetHostRegName(reg));
|
DEBUG_LOG("Undiscarding host register {}", m_code_generator.GetHostRegName(reg));
|
||||||
m_state.host_reg_state[reg] &= ~HostRegState::Discarded;
|
m_state.host_reg_state[reg] &= ~HostRegState::Discarded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterCache::FreeHostReg(HostReg reg)
|
void RegisterCache::FreeHostReg(HostReg reg)
|
||||||
{
|
{
|
||||||
DebugAssert(IsHostRegInUse(reg));
|
DebugAssert(IsHostRegInUse(reg));
|
||||||
Log_DebugFmt("Freeing host register {}", m_code_generator.GetHostRegName(reg));
|
DEBUG_LOG("Freeing host register {}", m_code_generator.GetHostRegName(reg));
|
||||||
m_state.host_reg_state[reg] &= ~HostRegState::InUse;
|
m_state.host_reg_state[reg] &= ~HostRegState::InUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ Value RegisterCache::AllocateScratch(RegSize size, HostReg reg /* = HostReg_Inva
|
||||||
Panic("Failed to allocate specific host register");
|
Panic("Failed to allocate specific host register");
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("Allocating host register {} as scratch", m_code_generator.GetHostRegName(reg));
|
DEBUG_LOG("Allocating host register {} as scratch", m_code_generator.GetHostRegName(reg));
|
||||||
return Value::FromScratch(this, reg, size);
|
return Value::FromScratch(this, reg, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,8 +542,8 @@ Value RegisterCache::ReadGuestRegister(Reg guest_reg, bool cache /* = true */, b
|
||||||
host_reg = forced_host_reg;
|
host_reg = forced_host_reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("Allocated host register {} for constant guest register {} (0x{:X})",
|
DEBUG_LOG("Allocated host register {} for constant guest register {} (0x{:X})",
|
||||||
m_code_generator.GetHostRegName(host_reg), GetRegName(guest_reg), cache_value.constant_value);
|
m_code_generator.GetHostRegName(host_reg), GetRegName(guest_reg), cache_value.constant_value);
|
||||||
|
|
||||||
m_code_generator.EmitCopyValue(host_reg, cache_value);
|
m_code_generator.EmitCopyValue(host_reg, cache_value);
|
||||||
cache_value.AddHostReg(this, host_reg);
|
cache_value.AddHostReg(this, host_reg);
|
||||||
|
@ -576,8 +576,8 @@ Value RegisterCache::ReadGuestRegister(Reg guest_reg, bool cache /* = true */, b
|
||||||
|
|
||||||
m_code_generator.EmitLoadGuestRegister(host_reg, guest_reg);
|
m_code_generator.EmitLoadGuestRegister(host_reg, guest_reg);
|
||||||
|
|
||||||
Log_DebugFmt("Loading guest register {} to host register {}{}", GetRegName(guest_reg),
|
DEBUG_LOG("Loading guest register {} to host register {}{}", GetRegName(guest_reg),
|
||||||
m_code_generator.GetHostRegName(host_reg, RegSize_32), cache ? " (cached)" : "");
|
m_code_generator.GetHostRegName(host_reg, RegSize_32), cache ? " (cached)" : "");
|
||||||
|
|
||||||
if (cache)
|
if (cache)
|
||||||
{
|
{
|
||||||
|
@ -604,23 +604,22 @@ Value RegisterCache::ReadGuestRegisterToScratch(Reg guest_reg)
|
||||||
|
|
||||||
if (cache_value.IsConstant())
|
if (cache_value.IsConstant())
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Copying guest register {} from constant 0x{:08X} to scratch host register {}",
|
DEBUG_LOG("Copying guest register {} from constant 0x{:08X} to scratch host register {}", GetRegName(guest_reg),
|
||||||
GetRegName(guest_reg), static_cast<u32>(cache_value.constant_value),
|
static_cast<u32>(cache_value.constant_value), m_code_generator.GetHostRegName(host_reg, RegSize_32));
|
||||||
m_code_generator.GetHostRegName(host_reg, RegSize_32));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Copying guest register {} from {} to scratch host register {}", GetRegName(guest_reg),
|
DEBUG_LOG("Copying guest register {} from {} to scratch host register {}", GetRegName(guest_reg),
|
||||||
m_code_generator.GetHostRegName(cache_value.host_reg, RegSize_32),
|
m_code_generator.GetHostRegName(cache_value.host_reg, RegSize_32),
|
||||||
m_code_generator.GetHostRegName(host_reg, RegSize_32));
|
m_code_generator.GetHostRegName(host_reg, RegSize_32));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_code_generator.EmitLoadGuestRegister(host_reg, guest_reg);
|
m_code_generator.EmitLoadGuestRegister(host_reg, guest_reg);
|
||||||
|
|
||||||
Log_DebugFmt("Loading guest register {} to scratch host register {}", GetRegName(guest_reg),
|
DEBUG_LOG("Loading guest register {} to scratch host register {}", GetRegName(guest_reg),
|
||||||
m_code_generator.GetHostRegName(host_reg, RegSize_32));
|
m_code_generator.GetHostRegName(host_reg, RegSize_32));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Value::FromScratch(this, host_reg, RegSize_32);
|
return Value::FromScratch(this, host_reg, RegSize_32);
|
||||||
|
@ -636,7 +635,7 @@ Value RegisterCache::WriteGuestRegister(Reg guest_reg, Value&& value)
|
||||||
// cancel any load delay delay
|
// cancel any load delay delay
|
||||||
if (m_state.load_delay_register == guest_reg)
|
if (m_state.load_delay_register == guest_reg)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Cancelling load delay of register {} because of non-delayed write", GetRegName(guest_reg));
|
DEBUG_LOG("Cancelling load delay of register {} because of non-delayed write", GetRegName(guest_reg));
|
||||||
m_state.load_delay_register = Reg::count;
|
m_state.load_delay_register = Reg::count;
|
||||||
m_state.load_delay_value.ReleaseAndClear();
|
m_state.load_delay_value.ReleaseAndClear();
|
||||||
}
|
}
|
||||||
|
@ -645,8 +644,8 @@ Value RegisterCache::WriteGuestRegister(Reg guest_reg, Value&& value)
|
||||||
if (cache_value.IsInHostRegister() && value.IsInHostRegister() && cache_value.host_reg == value.host_reg)
|
if (cache_value.IsInHostRegister() && value.IsInHostRegister() && cache_value.host_reg == value.host_reg)
|
||||||
{
|
{
|
||||||
// updating the register value.
|
// updating the register value.
|
||||||
Log_DebugFmt("Updating guest register {} (in host register {})", GetRegName(guest_reg),
|
DEBUG_LOG("Updating guest register {} (in host register {})", GetRegName(guest_reg),
|
||||||
m_code_generator.GetHostRegName(value.host_reg, RegSize_32));
|
m_code_generator.GetHostRegName(value.host_reg, RegSize_32));
|
||||||
cache_value = std::move(value);
|
cache_value = std::move(value);
|
||||||
cache_value.SetDirty();
|
cache_value.SetDirty();
|
||||||
return cache_value;
|
return cache_value;
|
||||||
|
@ -668,8 +667,8 @@ Value RegisterCache::WriteGuestRegister(Reg guest_reg, Value&& value)
|
||||||
// If it's a temporary, we can bind that to the guest register.
|
// If it's a temporary, we can bind that to the guest register.
|
||||||
if (value.IsScratch())
|
if (value.IsScratch())
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Binding scratch register {} to guest register {}",
|
DEBUG_LOG("Binding scratch register {} to guest register {}",
|
||||||
m_code_generator.GetHostRegName(value.host_reg, RegSize_32), GetRegName(guest_reg));
|
m_code_generator.GetHostRegName(value.host_reg, RegSize_32), GetRegName(guest_reg));
|
||||||
|
|
||||||
cache_value = std::move(value);
|
cache_value = std::move(value);
|
||||||
cache_value.flags &= ~ValueFlags::Scratch;
|
cache_value.flags &= ~ValueFlags::Scratch;
|
||||||
|
@ -683,9 +682,9 @@ Value RegisterCache::WriteGuestRegister(Reg guest_reg, Value&& value)
|
||||||
cache_value.SetHostReg(this, host_reg, RegSize_32);
|
cache_value.SetHostReg(this, host_reg, RegSize_32);
|
||||||
cache_value.SetDirty();
|
cache_value.SetDirty();
|
||||||
|
|
||||||
Log_DebugFmt("Copying non-scratch register {} to {} to guest register {}",
|
DEBUG_LOG("Copying non-scratch register {} to {} to guest register {}",
|
||||||
m_code_generator.GetHostRegName(value.host_reg, RegSize_32),
|
m_code_generator.GetHostRegName(value.host_reg, RegSize_32),
|
||||||
m_code_generator.GetHostRegName(host_reg, RegSize_32), GetRegName(guest_reg));
|
m_code_generator.GetHostRegName(host_reg, RegSize_32), GetRegName(guest_reg));
|
||||||
|
|
||||||
return Value::FromHostReg(this, cache_value.host_reg, RegSize_32);
|
return Value::FromHostReg(this, cache_value.host_reg, RegSize_32);
|
||||||
}
|
}
|
||||||
|
@ -700,7 +699,7 @@ void RegisterCache::WriteGuestRegisterDelayed(Reg guest_reg, Value&& value)
|
||||||
// two load delays in a row? cancel the first one.
|
// two load delays in a row? cancel the first one.
|
||||||
if (guest_reg == m_state.load_delay_register)
|
if (guest_reg == m_state.load_delay_register)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Cancelling load delay of register {} due to new load delay", GetRegName(guest_reg));
|
DEBUG_LOG("Cancelling load delay of register {} due to new load delay", GetRegName(guest_reg));
|
||||||
m_state.load_delay_register = Reg::count;
|
m_state.load_delay_register = Reg::count;
|
||||||
m_state.load_delay_value.ReleaseAndClear();
|
m_state.load_delay_value.ReleaseAndClear();
|
||||||
}
|
}
|
||||||
|
@ -716,8 +715,8 @@ void RegisterCache::WriteGuestRegisterDelayed(Reg guest_reg, Value&& value)
|
||||||
// If it's a temporary, we can bind that to the guest register.
|
// If it's a temporary, we can bind that to the guest register.
|
||||||
if (value.IsScratch())
|
if (value.IsScratch())
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Binding scratch register {} to load-delayed guest register {}",
|
DEBUG_LOG("Binding scratch register {} to load-delayed guest register {}",
|
||||||
m_code_generator.GetHostRegName(value.host_reg, RegSize_32), GetRegName(guest_reg));
|
m_code_generator.GetHostRegName(value.host_reg, RegSize_32), GetRegName(guest_reg));
|
||||||
|
|
||||||
cache_value = std::move(value);
|
cache_value = std::move(value);
|
||||||
return;
|
return;
|
||||||
|
@ -727,9 +726,9 @@ void RegisterCache::WriteGuestRegisterDelayed(Reg guest_reg, Value&& value)
|
||||||
cache_value = AllocateScratch(RegSize_32);
|
cache_value = AllocateScratch(RegSize_32);
|
||||||
m_code_generator.EmitCopyValue(cache_value.host_reg, value);
|
m_code_generator.EmitCopyValue(cache_value.host_reg, value);
|
||||||
|
|
||||||
Log_DebugFmt("Copying non-scratch register {} to {} to load-delayed guest register {}",
|
DEBUG_LOG("Copying non-scratch register {} to {} to load-delayed guest register {}",
|
||||||
m_code_generator.GetHostRegName(value.host_reg, RegSize_32),
|
m_code_generator.GetHostRegName(value.host_reg, RegSize_32),
|
||||||
m_code_generator.GetHostRegName(cache_value.host_reg, RegSize_32), GetRegName(guest_reg));
|
m_code_generator.GetHostRegName(cache_value.host_reg, RegSize_32), GetRegName(guest_reg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterCache::UpdateLoadDelay()
|
void RegisterCache::UpdateLoadDelay()
|
||||||
|
@ -758,7 +757,7 @@ void RegisterCache::CancelLoadDelay()
|
||||||
if (m_state.load_delay_register == Reg::count)
|
if (m_state.load_delay_register == Reg::count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_DebugFmt("Cancelling load delay of register {}", GetRegName(m_state.load_delay_register));
|
DEBUG_LOG("Cancelling load delay of register {}", GetRegName(m_state.load_delay_register));
|
||||||
m_state.load_delay_register = Reg::count;
|
m_state.load_delay_register = Reg::count;
|
||||||
m_state.load_delay_value.ReleaseAndClear();
|
m_state.load_delay_value.ReleaseAndClear();
|
||||||
}
|
}
|
||||||
|
@ -769,7 +768,7 @@ void RegisterCache::WriteLoadDelayToCPU(bool clear)
|
||||||
Assert(m_state.next_load_delay_register == Reg::count);
|
Assert(m_state.next_load_delay_register == Reg::count);
|
||||||
if (m_state.load_delay_register != Reg::count)
|
if (m_state.load_delay_register != Reg::count)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Flushing pending load delay of {}", GetRegName(m_state.load_delay_register));
|
DEBUG_LOG("Flushing pending load delay of {}", GetRegName(m_state.load_delay_register));
|
||||||
m_code_generator.EmitStoreInterpreterLoadDelay(m_state.load_delay_register, m_state.load_delay_value);
|
m_code_generator.EmitStoreInterpreterLoadDelay(m_state.load_delay_register, m_state.load_delay_value);
|
||||||
if (clear)
|
if (clear)
|
||||||
{
|
{
|
||||||
|
@ -804,13 +803,12 @@ void RegisterCache::FlushGuestRegister(Reg guest_reg, bool invalidate, bool clea
|
||||||
{
|
{
|
||||||
if (cache_value.IsInHostRegister())
|
if (cache_value.IsInHostRegister())
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Flushing guest register {} from host register {}", GetRegName(guest_reg),
|
DEBUG_LOG("Flushing guest register {} from host register {}", GetRegName(guest_reg),
|
||||||
m_code_generator.GetHostRegName(cache_value.host_reg, RegSize_32));
|
m_code_generator.GetHostRegName(cache_value.host_reg, RegSize_32));
|
||||||
}
|
}
|
||||||
else if (cache_value.IsConstant())
|
else if (cache_value.IsConstant())
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Flushing guest register {} from constant 0x{:X}", GetRegName(guest_reg),
|
DEBUG_LOG("Flushing guest register {} from constant 0x{:X}", GetRegName(guest_reg), cache_value.constant_value);
|
||||||
cache_value.constant_value);
|
|
||||||
}
|
}
|
||||||
m_code_generator.EmitStoreGuestRegister(guest_reg, cache_value);
|
m_code_generator.EmitStoreGuestRegister(guest_reg, cache_value);
|
||||||
if (clear_dirty)
|
if (clear_dirty)
|
||||||
|
@ -833,7 +831,7 @@ void RegisterCache::InvalidateGuestRegister(Reg guest_reg)
|
||||||
ClearRegisterFromOrder(guest_reg);
|
ClearRegisterFromOrder(guest_reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("Invalidating guest register {}", GetRegName(guest_reg));
|
DEBUG_LOG("Invalidating guest register {}", GetRegName(guest_reg));
|
||||||
cache_value.Clear();
|
cache_value.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,7 +873,7 @@ bool RegisterCache::EvictOneGuestRegister()
|
||||||
|
|
||||||
// evict the register used the longest time ago
|
// evict the register used the longest time ago
|
||||||
Reg evict_reg = m_state.guest_reg_order[m_state.guest_reg_order_count - 1];
|
Reg evict_reg = m_state.guest_reg_order[m_state.guest_reg_order_count - 1];
|
||||||
Log_DebugFmt("Evicting guest register {}", GetRegName(evict_reg));
|
DEBUG_LOG("Evicting guest register {}", GetRegName(evict_reg));
|
||||||
FlushGuestRegister(evict_reg, true, true);
|
FlushGuestRegister(evict_reg, true, true);
|
||||||
|
|
||||||
return HasFreeHostRegister();
|
return HasFreeHostRegister();
|
||||||
|
|
|
@ -307,20 +307,20 @@ u32 DMA::ReadRegister(u32 offset)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
{
|
{
|
||||||
Log_TraceFmt("DMA[{}] base address -> 0x{:08X}", static_cast<Channel>(channel_index),
|
TRACE_LOG("DMA[{}] base address -> 0x{:08X}", static_cast<Channel>(channel_index),
|
||||||
s_state[channel_index].base_address);
|
s_state[channel_index].base_address);
|
||||||
return s_state[channel_index].base_address;
|
return s_state[channel_index].base_address;
|
||||||
}
|
}
|
||||||
case 0x04:
|
case 0x04:
|
||||||
{
|
{
|
||||||
Log_TraceFmt("DMA[{}] block control -> 0x{:08X}", static_cast<Channel>(channel_index),
|
TRACE_LOG("DMA[{}] block control -> 0x{:08X}", static_cast<Channel>(channel_index),
|
||||||
s_state[channel_index].block_control.bits);
|
s_state[channel_index].block_control.bits);
|
||||||
return s_state[channel_index].block_control.bits;
|
return s_state[channel_index].block_control.bits;
|
||||||
}
|
}
|
||||||
case 0x08:
|
case 0x08:
|
||||||
{
|
{
|
||||||
Log_TraceFmt("DMA[{}] channel control -> 0x{:08X}", static_cast<Channel>(channel_index),
|
TRACE_LOG("DMA[{}] channel control -> 0x{:08X}", static_cast<Channel>(channel_index),
|
||||||
s_state[channel_index].channel_control.bits);
|
s_state[channel_index].channel_control.bits);
|
||||||
return s_state[channel_index].channel_control.bits;
|
return s_state[channel_index].channel_control.bits;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -331,17 +331,17 @@ u32 DMA::ReadRegister(u32 offset)
|
||||||
{
|
{
|
||||||
if (offset == 0x70)
|
if (offset == 0x70)
|
||||||
{
|
{
|
||||||
Log_TraceFmt("DPCR -> 0x{:08X}", s_DPCR.bits);
|
TRACE_LOG("DPCR -> 0x{:08X}", s_DPCR.bits);
|
||||||
return s_DPCR.bits;
|
return s_DPCR.bits;
|
||||||
}
|
}
|
||||||
else if (offset == 0x74)
|
else if (offset == 0x74)
|
||||||
{
|
{
|
||||||
Log_TraceFmt("DICR -> 0x{:08X}", s_DICR.bits);
|
TRACE_LOG("DICR -> 0x{:08X}", s_DICR.bits);
|
||||||
return s_DICR.bits;
|
return s_DICR.bits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_ErrorFmt("Unhandled register read: {:02X}", offset);
|
ERROR_LOG("Unhandled register read: {:02X}", offset);
|
||||||
return UINT32_C(0xFFFFFFFF);
|
return UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,13 +356,12 @@ void DMA::WriteRegister(u32 offset, u32 value)
|
||||||
case 0x00:
|
case 0x00:
|
||||||
{
|
{
|
||||||
state.base_address = value & BASE_ADDRESS_MASK;
|
state.base_address = value & BASE_ADDRESS_MASK;
|
||||||
Log_TraceFmt("DMA channel {} base address <- 0x{:08X}", static_cast<Channel>(channel_index),
|
TRACE_LOG("DMA channel {} base address <- 0x{:08X}", static_cast<Channel>(channel_index), state.base_address);
|
||||||
state.base_address);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case 0x04:
|
case 0x04:
|
||||||
{
|
{
|
||||||
Log_TraceFmt("DMA channel {} block control <- 0x{:08X}", static_cast<Channel>(channel_index), value);
|
TRACE_LOG("DMA channel {} block control <- 0x{:08X}", static_cast<Channel>(channel_index), value);
|
||||||
state.block_control.bits = value;
|
state.block_control.bits = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -377,8 +376,8 @@ void DMA::WriteRegister(u32 offset, u32 value)
|
||||||
|
|
||||||
state.channel_control.bits = (state.channel_control.bits & ~ChannelState::ChannelControl::WRITE_MASK) |
|
state.channel_control.bits = (state.channel_control.bits & ~ChannelState::ChannelControl::WRITE_MASK) |
|
||||||
(value & ChannelState::ChannelControl::WRITE_MASK);
|
(value & ChannelState::ChannelControl::WRITE_MASK);
|
||||||
Log_TraceFmt("DMA channel {} channel control <- 0x{:08X}", static_cast<Channel>(channel_index),
|
TRACE_LOG("DMA channel {} channel control <- 0x{:08X}", static_cast<Channel>(channel_index),
|
||||||
state.channel_control.bits);
|
state.channel_control.bits);
|
||||||
|
|
||||||
// start/trigger bit must be enabled for OTC
|
// start/trigger bit must be enabled for OTC
|
||||||
if (static_cast<Channel>(channel_index) == Channel::OTC)
|
if (static_cast<Channel>(channel_index) == Channel::OTC)
|
||||||
|
@ -399,8 +398,8 @@ void DMA::WriteRegister(u32 offset, u32 value)
|
||||||
const TickCount delay_cycles = std::min(static_cast<TickCount>(cpu_cycles_per_block * blocks), 500);
|
const TickCount delay_cycles = std::min(static_cast<TickCount>(cpu_cycles_per_block * blocks), 500);
|
||||||
if (delay_cycles > 1 && true)
|
if (delay_cycles > 1 && true)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Delaying {} transfer by {} cycles due to chopping", static_cast<Channel>(channel_index),
|
DEV_LOG("Delaying {} transfer by {} cycles due to chopping", static_cast<Channel>(channel_index),
|
||||||
delay_cycles);
|
delay_cycles);
|
||||||
HaltTransfer(delay_cycles);
|
HaltTransfer(delay_cycles);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -426,7 +425,7 @@ void DMA::WriteRegister(u32 offset, u32 value)
|
||||||
{
|
{
|
||||||
case 0x70:
|
case 0x70:
|
||||||
{
|
{
|
||||||
Log_TraceFmt("DPCR <- 0x{:08X}", value);
|
TRACE_LOG("DPCR <- 0x{:08X}", value);
|
||||||
s_DPCR.bits = value;
|
s_DPCR.bits = value;
|
||||||
|
|
||||||
for (u32 i = 0; i < NUM_CHANNELS; i++)
|
for (u32 i = 0; i < NUM_CHANNELS; i++)
|
||||||
|
@ -443,7 +442,7 @@ void DMA::WriteRegister(u32 offset, u32 value)
|
||||||
|
|
||||||
case 0x74:
|
case 0x74:
|
||||||
{
|
{
|
||||||
Log_TraceFmt("DICR <- 0x{:08X}", value);
|
TRACE_LOG("DICR <- 0x{:08X}", value);
|
||||||
s_DICR.bits = (s_DICR.bits & ~DICR_WRITE_MASK) | (value & DICR_WRITE_MASK);
|
s_DICR.bits = (s_DICR.bits & ~DICR_WRITE_MASK) | (value & DICR_WRITE_MASK);
|
||||||
s_DICR.bits = s_DICR.bits & ~(value & DICR_RESET_MASK);
|
s_DICR.bits = s_DICR.bits & ~(value & DICR_RESET_MASK);
|
||||||
UpdateIRQ();
|
UpdateIRQ();
|
||||||
|
@ -455,7 +454,7 @@ void DMA::WriteRegister(u32 offset, u32 value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_ErrorFmt("Unhandled register write: {:02X} <- {:08X}", offset, value);
|
ERROR_LOG("Unhandled register write: {:02X} <- {:08X}", offset, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMA::SetRequest(Channel channel, bool request)
|
void DMA::SetRequest(Channel channel, bool request)
|
||||||
|
@ -504,7 +503,7 @@ void DMA::UpdateIRQ()
|
||||||
[[maybe_unused]] const auto old_dicr = s_DICR;
|
[[maybe_unused]] const auto old_dicr = s_DICR;
|
||||||
s_DICR.UpdateMasterFlag();
|
s_DICR.UpdateMasterFlag();
|
||||||
if (!old_dicr.master_flag && s_DICR.master_flag)
|
if (!old_dicr.master_flag && s_DICR.master_flag)
|
||||||
Log_TracePrint("Firing DMA master interrupt");
|
TRACE_LOG("Firing DMA master interrupt");
|
||||||
InterruptController::SetLineState(InterruptController::IRQ::DMA, s_DICR.master_flag);
|
InterruptController::SetLineState(InterruptController::IRQ::DMA, s_DICR.master_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +518,7 @@ ALWAYS_INLINE_RELEASE bool DMA::CheckForBusError(Channel channel, ChannelState&
|
||||||
// Relying on a transfer partially happening at the end of RAM, then hitting a bus error would be pretty silly.
|
// Relying on a transfer partially happening at the end of RAM, then hitting a bus error would be pretty silly.
|
||||||
if ((address + size) > Bus::RAM_8MB_SIZE) [[unlikely]]
|
if ((address + size) > Bus::RAM_8MB_SIZE) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_DebugFmt("DMA bus error on channel {} at address 0x{:08X} size {}", channel, address, size);
|
DEBUG_LOG("DMA bus error on channel {} at address 0x{:08X} size {}", channel, address, size);
|
||||||
cs.channel_control.enable_busy = false;
|
cs.channel_control.enable_busy = false;
|
||||||
s_DICR.bus_error = true;
|
s_DICR.bus_error = true;
|
||||||
s_DICR.SetIRQFlag(channel);
|
s_DICR.SetIRQFlag(channel);
|
||||||
|
@ -533,11 +532,11 @@ ALWAYS_INLINE_RELEASE bool DMA::CheckForBusError(Channel channel, ChannelState&
|
||||||
ALWAYS_INLINE_RELEASE void DMA::CompleteTransfer(Channel channel, ChannelState& cs)
|
ALWAYS_INLINE_RELEASE void DMA::CompleteTransfer(Channel channel, ChannelState& cs)
|
||||||
{
|
{
|
||||||
// start/busy bit is cleared on end of transfer
|
// start/busy bit is cleared on end of transfer
|
||||||
Log_DebugFmt("DMA transfer for channel {} complete", channel);
|
DEBUG_LOG("DMA transfer for channel {} complete", channel);
|
||||||
cs.channel_control.enable_busy = false;
|
cs.channel_control.enable_busy = false;
|
||||||
if (s_DICR.ShouldSetIRQFlag(channel))
|
if (s_DICR.ShouldSetIRQFlag(channel))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Setting DMA interrupt for channel {}", channel);
|
DEBUG_LOG("Setting DMA interrupt for channel {}", channel);
|
||||||
s_DICR.SetIRQFlag(channel);
|
s_DICR.SetIRQFlag(channel);
|
||||||
UpdateIRQ();
|
UpdateIRQ();
|
||||||
}
|
}
|
||||||
|
@ -571,8 +570,8 @@ bool DMA::TransferChannel()
|
||||||
case SyncMode::Manual:
|
case SyncMode::Manual:
|
||||||
{
|
{
|
||||||
const u32 word_count = cs.block_control.manual.GetWordCount();
|
const u32 word_count = cs.block_control.manual.GetWordCount();
|
||||||
Log_DebugFmt("DMA[{}]: Copying {} words {} 0x{:08X}", channel, word_count, copy_to_device ? "from" : "to",
|
DEBUG_LOG("DMA[{}]: Copying {} words {} 0x{:08X}", channel, word_count, copy_to_device ? "from" : "to",
|
||||||
current_address);
|
current_address);
|
||||||
|
|
||||||
const PhysicalMemoryAddress transfer_addr = current_address & TRANSFER_ADDRESS_MASK;
|
const PhysicalMemoryAddress transfer_addr = current_address & TRANSFER_ADDRESS_MASK;
|
||||||
if (CheckForBusError(channel, cs, transfer_addr, word_count * sizeof(u32))) [[unlikely]]
|
if (CheckForBusError(channel, cs, transfer_addr, word_count * sizeof(u32))) [[unlikely]]
|
||||||
|
@ -597,7 +596,7 @@ bool DMA::TransferChannel()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("DMA[{}]: Copying linked list starting at 0x{:08X} to device", channel, current_address);
|
DEBUG_LOG("DMA[{}]: Copying linked list starting at 0x{:08X} to device", channel, current_address);
|
||||||
|
|
||||||
// Prove to the compiler that nothing's going to modify these.
|
// Prove to the compiler that nothing's going to modify these.
|
||||||
const u8* const ram_ptr = Bus::g_ram;
|
const u8* const ram_ptr = Bus::g_ram;
|
||||||
|
@ -618,8 +617,8 @@ bool DMA::TransferChannel()
|
||||||
std::memcpy(&header, &ram_ptr[transfer_addr & mask], sizeof(header));
|
std::memcpy(&header, &ram_ptr[transfer_addr & mask], sizeof(header));
|
||||||
const u32 word_count = header >> 24;
|
const u32 word_count = header >> 24;
|
||||||
const u32 next_address = header & 0x00FFFFFFu;
|
const u32 next_address = header & 0x00FFFFFFu;
|
||||||
Log_TraceFmt(" .. linked list entry at 0x{:08X} size={}({} words) next=0x{:08X}", current_address,
|
TRACE_LOG(" .. linked list entry at 0x{:08X} size={}({} words) next=0x{:08X}", current_address, word_count * 4,
|
||||||
word_count * 4, word_count, next_address);
|
word_count, next_address);
|
||||||
|
|
||||||
const TickCount setup_ticks = (word_count > 0) ?
|
const TickCount setup_ticks = (word_count > 0) ?
|
||||||
(LINKED_LIST_HEADER_READ_TICKS + LINKED_LIST_BLOCK_SETUP_TICKS) :
|
(LINKED_LIST_HEADER_READ_TICKS + LINKED_LIST_BLOCK_SETUP_TICKS) :
|
||||||
|
@ -660,10 +659,10 @@ bool DMA::TransferChannel()
|
||||||
|
|
||||||
case SyncMode::Request:
|
case SyncMode::Request:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("DMA[{}]: Copying {} blocks of size {} ({} total words) {} 0x{:08X}", channel,
|
DEBUG_LOG("DMA[{}]: Copying {} blocks of size {} ({} total words) {} 0x{:08X}", channel,
|
||||||
cs.block_control.request.GetBlockCount(), cs.block_control.request.GetBlockSize(),
|
cs.block_control.request.GetBlockCount(), cs.block_control.request.GetBlockSize(),
|
||||||
cs.block_control.request.GetBlockCount() * cs.block_control.request.GetBlockSize(),
|
cs.block_control.request.GetBlockCount() * cs.block_control.request.GetBlockSize(),
|
||||||
copy_to_device ? "from" : "to", current_address);
|
copy_to_device ? "from" : "to", current_address);
|
||||||
|
|
||||||
const u32 block_size = cs.block_control.request.GetBlockSize();
|
const u32 block_size = cs.block_control.request.GetBlockSize();
|
||||||
u32 blocks_remaining = cs.block_control.request.GetBlockCount();
|
u32 blocks_remaining = cs.block_control.request.GetBlockCount();
|
||||||
|
@ -744,7 +743,7 @@ bool DMA::TransferChannel()
|
||||||
void DMA::HaltTransfer(TickCount duration)
|
void DMA::HaltTransfer(TickCount duration)
|
||||||
{
|
{
|
||||||
s_halt_ticks_remaining += duration;
|
s_halt_ticks_remaining += duration;
|
||||||
Log_DebugFmt("Halting DMA for {} ticks", s_halt_ticks_remaining);
|
DEBUG_LOG("Halting DMA for {} ticks", s_halt_ticks_remaining);
|
||||||
if (s_unhalt_event->IsActive())
|
if (s_unhalt_event->IsActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -754,7 +753,7 @@ void DMA::HaltTransfer(TickCount duration)
|
||||||
|
|
||||||
void DMA::UnhaltTransfer(void*, TickCount ticks, TickCount ticks_late)
|
void DMA::UnhaltTransfer(void*, TickCount ticks, TickCount ticks_late)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Resuming DMA after {} ticks, {} ticks late", ticks, -(s_halt_ticks_remaining - ticks));
|
DEBUG_LOG("Resuming DMA after {} ticks, {} ticks late", ticks, -(s_halt_ticks_remaining - ticks));
|
||||||
s_halt_ticks_remaining -= ticks;
|
s_halt_ticks_remaining -= ticks;
|
||||||
s_unhalt_event->Deactivate();
|
s_unhalt_event->Deactivate();
|
||||||
|
|
||||||
|
@ -779,7 +778,7 @@ TickCount DMA::TransferMemoryToDevice(u32 address, u32 increment, u32 word_count
|
||||||
const u32 mask = Bus::g_ram_mask;
|
const u32 mask = Bus::g_ram_mask;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if ((address & mask) != address)
|
if ((address & mask) != address)
|
||||||
Log_DebugFmt("DMA TO {} from masked RAM address 0x{:08X} => 0x{:08X}", channel, address, (address & mask));
|
DEBUG_LOG("DMA TO {} from masked RAM address 0x{:08X} => 0x{:08X}", channel, address, (address & mask));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
address &= mask;
|
address &= mask;
|
||||||
|
@ -834,7 +833,7 @@ TickCount DMA::TransferMemoryToDevice(u32 address, u32 increment, u32 word_count
|
||||||
case Channel::MDECout:
|
case Channel::MDECout:
|
||||||
case Channel::PIO:
|
case Channel::PIO:
|
||||||
default:
|
default:
|
||||||
Log_ErrorFmt("Unhandled DMA channel {} for device write", static_cast<u32>(channel));
|
ERROR_LOG("Unhandled DMA channel {} for device write", static_cast<u32>(channel));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,7 +846,7 @@ TickCount DMA::TransferDeviceToMemory(u32 address, u32 increment, u32 word_count
|
||||||
const u32 mask = Bus::g_ram_mask;
|
const u32 mask = Bus::g_ram_mask;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if ((address & mask) != address)
|
if ((address & mask) != address)
|
||||||
Log_DebugFmt("DMA FROM {} to masked RAM address 0x{:08X} => 0x{:08X}", channel, address, (address & mask));
|
DEBUG_LOG("DMA FROM {} to masked RAM address 0x{:08X} => 0x{:08X}", channel, address, (address & mask));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: This might not be correct for OTC.
|
// TODO: This might not be correct for OTC.
|
||||||
|
@ -899,7 +898,7 @@ TickCount DMA::TransferDeviceToMemory(u32 address, u32 increment, u32 word_count
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log_ErrorFmt("Unhandled DMA channel {} for device read", static_cast<u32>(channel));
|
ERROR_LOG("Unhandled DMA channel {} for device read", static_cast<u32>(channel));
|
||||||
std::fill_n(dest_pointer, word_count, UINT32_C(0xFFFFFFFF));
|
std::fill_n(dest_pointer, word_count, UINT32_C(0xFFFFFFFF));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5491,7 +5491,7 @@ void FullscreenUI::PopulateSaveStateScreenshot(SaveStateListEntry* li, const Ext
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!li->preview_texture)
|
if (!li->preview_texture)
|
||||||
Log_ErrorPrint("Failed to upload save state image to GPU");
|
ERROR_LOG("Failed to upload save state image to GPU");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullscreenUI::ClearSaveStateEntryList()
|
void FullscreenUI::ClearSaveStateEntryList()
|
||||||
|
|
|
@ -165,14 +165,14 @@ static bool GetUIntFromObject(const ryml::ConstNodeRef& object, std::string_view
|
||||||
const c4::csubstr val = member.val();
|
const c4::csubstr val = member.val();
|
||||||
if (val.empty())
|
if (val.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unexpected empty value in {}", key);
|
ERROR_LOG("Unexpected empty value in {}", key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::optional<T> opt_value = StringUtil::FromChars<T>(to_stringview(val));
|
const std::optional<T> opt_value = StringUtil::FromChars<T>(to_stringview(val));
|
||||||
if (!opt_value.has_value())
|
if (!opt_value.has_value())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unexpected non-uint value in {}", key);
|
ERROR_LOG("Unexpected non-uint value in {}", key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,14 +195,14 @@ static std::optional<T> GetOptionalTFromObject(const ryml::ConstNodeRef& object,
|
||||||
if (!ret.has_value())
|
if (!ret.has_value())
|
||||||
{
|
{
|
||||||
if constexpr (std::is_floating_point_v<T>)
|
if constexpr (std::is_floating_point_v<T>)
|
||||||
Log_ErrorFmt("Unexpected non-float value in {}", key);
|
ERROR_LOG("Unexpected non-float value in {}", key);
|
||||||
else if constexpr (std::is_integral_v<T>)
|
else if constexpr (std::is_integral_v<T>)
|
||||||
Log_ErrorFmt("Unexpected non-int value in {}", key);
|
ERROR_LOG("Unexpected non-int value in {}", key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unexpected empty value in {}", key);
|
ERROR_LOG("Unexpected empty value in {}", key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,11 +223,11 @@ static std::optional<T> ParseOptionalTFromObject(const ryml::ConstNodeRef& objec
|
||||||
{
|
{
|
||||||
ret = from_string_function(TinyString(to_stringview(val)));
|
ret = from_string_function(TinyString(to_stringview(val)));
|
||||||
if (!ret.has_value())
|
if (!ret.has_value())
|
||||||
Log_ErrorFmt("Unknown value for {}: {}", key, to_stringview(val));
|
ERROR_LOG("Unknown value for {}: {}", key, to_stringview(val));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unexpected empty value in {}", key);
|
ERROR_LOG("Unexpected empty value in {}", key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ void GameDatabase::EnsureLoaded()
|
||||||
SaveToCache();
|
SaveToCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Database load of {} entries took {:.0f}ms.", s_entries.size(), timer.GetTimeMilliseconds());
|
INFO_LOG("Database load of {} entries took {:.0f}ms.", s_entries.size(), timer.GetTimeMilliseconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameDatabase::Unload()
|
void GameDatabase::Unload()
|
||||||
|
@ -307,7 +307,7 @@ const GameDatabase::Entry* GameDatabase::GetEntryForDisc(CDImage* image)
|
||||||
if (entry)
|
if (entry)
|
||||||
return entry;
|
return entry;
|
||||||
|
|
||||||
Log_WarningFmt("No entry found for disc '{}'", id);
|
WARNING_LOG("No entry found for disc '{}'", id);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,19 +636,19 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
|
||||||
|
|
||||||
if (HasTrait(Trait::ForceRecompilerMemoryExceptions))
|
if (HasTrait(Trait::ForceRecompilerMemoryExceptions))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Memory exceptions for recompiler forced by compatibility settings.");
|
WARNING_LOG("Memory exceptions for recompiler forced by compatibility settings.");
|
||||||
settings.cpu_recompiler_memory_exceptions = true;
|
settings.cpu_recompiler_memory_exceptions = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasTrait(Trait::ForceRecompilerICache))
|
if (HasTrait(Trait::ForceRecompilerICache))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("ICache for recompiler forced by compatibility settings.");
|
WARNING_LOG("ICache for recompiler forced by compatibility settings.");
|
||||||
settings.cpu_recompiler_icache = true;
|
settings.cpu_recompiler_icache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.cpu_fastmem_mode == CPUFastmemMode::MMap && HasTrait(Trait::ForceRecompilerLUTFastmem))
|
if (settings.cpu_fastmem_mode == CPUFastmemMode::MMap && HasTrait(Trait::ForceRecompilerLUTFastmem))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("LUT fastmem for recompiler forced by compatibility settings.");
|
WARNING_LOG("LUT fastmem for recompiler forced by compatibility settings.");
|
||||||
settings.cpu_fastmem_mode = CPUFastmemMode::LUT;
|
settings.cpu_fastmem_mode = CPUFastmemMode::LUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,7 +861,7 @@ bool GameDatabase::LoadFromCache()
|
||||||
ByteStream::OpenFile(GetCacheFile().c_str(), BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_STREAMED));
|
ByteStream::OpenFile(GetCacheFile().c_str(), BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_STREAMED));
|
||||||
if (!stream)
|
if (!stream)
|
||||||
{
|
{
|
||||||
Log_DevPrint("Cache does not exist, loading full database.");
|
DEV_LOG("Cache does not exist, loading full database.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,13 +873,13 @@ bool GameDatabase::LoadFromCache()
|
||||||
!stream->ReadU32(&num_entries) || !stream->ReadU32(&num_codes) || signature != GAME_DATABASE_CACHE_SIGNATURE ||
|
!stream->ReadU32(&num_entries) || !stream->ReadU32(&num_codes) || signature != GAME_DATABASE_CACHE_SIGNATURE ||
|
||||||
version != GAME_DATABASE_CACHE_VERSION)
|
version != GAME_DATABASE_CACHE_VERSION)
|
||||||
{
|
{
|
||||||
Log_DevPrint("Cache header is corrupted or version mismatch.");
|
DEV_LOG("Cache header is corrupted or version mismatch.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamedb_ts != file_gamedb_ts)
|
if (gamedb_ts != file_gamedb_ts)
|
||||||
{
|
{
|
||||||
Log_DevPrint("Cache is out of date, recreating.");
|
DEV_LOG("Cache is out of date, recreating.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -917,7 +917,7 @@ bool GameDatabase::LoadFromCache()
|
||||||
!ReadOptionalFromStream(stream.get(), &entry.gpu_line_detect_mode) ||
|
!ReadOptionalFromStream(stream.get(), &entry.gpu_line_detect_mode) ||
|
||||||
!stream->ReadSizePrefixedString(&entry.disc_set_name) || !stream->ReadU32(&num_disc_set_serials))
|
!stream->ReadSizePrefixedString(&entry.disc_set_name) || !stream->ReadU32(&num_disc_set_serials))
|
||||||
{
|
{
|
||||||
Log_DevPrint("Cache entry is corrupted.");
|
DEV_LOG("Cache entry is corrupted.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,7 +928,7 @@ bool GameDatabase::LoadFromCache()
|
||||||
{
|
{
|
||||||
if (!stream->ReadSizePrefixedString(&entry.disc_set_serials.emplace_back()))
|
if (!stream->ReadSizePrefixedString(&entry.disc_set_serials.emplace_back()))
|
||||||
{
|
{
|
||||||
Log_DevPrint("Cache entry is corrupted.");
|
DEV_LOG("Cache entry is corrupted.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -950,7 +950,7 @@ bool GameDatabase::LoadFromCache()
|
||||||
if (!stream->ReadSizePrefixedString(&code) || !stream->ReadU32(&index) ||
|
if (!stream->ReadSizePrefixedString(&code) || !stream->ReadU32(&index) ||
|
||||||
index >= static_cast<u32>(s_entries.size()))
|
index >= static_cast<u32>(s_entries.size()))
|
||||||
{
|
{
|
||||||
Log_DevPrint("Cache code entry is corrupted.");
|
DEV_LOG("Cache code entry is corrupted.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1037,11 +1037,11 @@ void GameDatabase::SetRymlCallbacks()
|
||||||
{
|
{
|
||||||
ryml::Callbacks callbacks = ryml::get_callbacks();
|
ryml::Callbacks callbacks = ryml::get_callbacks();
|
||||||
callbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location loc, void* userdata) {
|
callbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location loc, void* userdata) {
|
||||||
Log_ErrorFmt("Parse error at {}:{} (bufpos={}): {}", loc.line, loc.col, loc.offset, std::string_view(msg, msg_len));
|
ERROR_LOG("Parse error at {}:{} (bufpos={}): {}", loc.line, loc.col, loc.offset, std::string_view(msg, msg_len));
|
||||||
};
|
};
|
||||||
ryml::set_callbacks(callbacks);
|
ryml::set_callbacks(callbacks);
|
||||||
c4::set_error_callback(
|
c4::set_error_callback(
|
||||||
[](const char* msg, size_t msg_size) { Log_ErrorFmt("C4 error: {}", std::string_view(msg, msg_size)); });
|
[](const char* msg, size_t msg_size) { ERROR_LOG("C4 error: {}", std::string_view(msg, msg_size)); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameDatabase::LoadGameDBYaml()
|
bool GameDatabase::LoadGameDBYaml()
|
||||||
|
@ -1049,7 +1049,7 @@ bool GameDatabase::LoadGameDBYaml()
|
||||||
const std::optional<std::string> gamedb_data = Host::ReadResourceFileToString(GAMEDB_YAML_FILENAME, false);
|
const std::optional<std::string> gamedb_data = Host::ReadResourceFileToString(GAMEDB_YAML_FILENAME, false);
|
||||||
if (!gamedb_data.has_value())
|
if (!gamedb_data.has_value())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read game database");
|
ERROR_LOG("Failed to read game database");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1082,7 +1082,7 @@ bool GameDatabase::ParseYamlEntry(Entry* entry, const ryml::ConstNodeRef& value)
|
||||||
entry->serial = to_stringview(value.key());
|
entry->serial = to_stringview(value.key());
|
||||||
if (entry->serial.empty())
|
if (entry->serial.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Missing serial for entry.");
|
ERROR_LOG("Missing serial for entry.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1131,14 +1131,14 @@ bool GameDatabase::ParseYamlEntry(Entry* entry, const ryml::ConstNodeRef& value)
|
||||||
const std::string_view controller_str = to_stringview(controller.val());
|
const std::string_view controller_str = to_stringview(controller.val());
|
||||||
if (controller_str.empty())
|
if (controller_str.empty())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("controller is not a string in {}", entry->serial);
|
WARNING_LOG("controller is not a string in {}", entry->serial);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Controller::ControllerInfo* cinfo = Controller::GetControllerInfo(controller_str);
|
const Controller::ControllerInfo* cinfo = Controller::GetControllerInfo(controller_str);
|
||||||
if (!cinfo)
|
if (!cinfo)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Invalid controller type {} in {}", controller_str, entry->serial);
|
WARNING_LOG("Invalid controller type {} in {}", controller_str, entry->serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1169,7 +1169,7 @@ bool GameDatabase::ParseYamlEntry(Entry* entry, const ryml::ConstNodeRef& value)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Unknown compatibility rating {} in {}", rating_str, entry->serial);
|
WARNING_LOG("Unknown compatibility rating {} in {}", rating_str, entry->serial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1184,14 +1184,14 @@ bool GameDatabase::ParseYamlEntry(Entry* entry, const ryml::ConstNodeRef& value)
|
||||||
const std::string_view trait_str = to_stringview(trait.val());
|
const std::string_view trait_str = to_stringview(trait.val());
|
||||||
if (trait_str.empty())
|
if (trait_str.empty())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Empty trait in {}", entry->serial);
|
WARNING_LOG("Empty trait in {}", entry->serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto iter = std::find(s_trait_names.begin(), s_trait_names.end(), trait_str);
|
const auto iter = std::find(s_trait_names.begin(), s_trait_names.end(), trait_str);
|
||||||
if (iter == s_trait_names.end())
|
if (iter == s_trait_names.end())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Unknown trait {} in {}", trait_str, entry->serial);
|
WARNING_LOG("Unknown trait {} in {}", trait_str, entry->serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1210,7 +1210,7 @@ bool GameDatabase::ParseYamlEntry(Entry* entry, const ryml::ConstNodeRef& value)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Invalid libcrypt value in {}", entry->serial);
|
WARNING_LOG("Invalid libcrypt value in {}", entry->serial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1244,14 +1244,14 @@ bool GameDatabase::ParseYamlEntry(Entry* entry, const ryml::ConstNodeRef& value)
|
||||||
const std::string_view serial_str = to_stringview(serial.val());
|
const std::string_view serial_str = to_stringview(serial.val());
|
||||||
if (serial_str.empty())
|
if (serial_str.empty())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Empty disc set serial in {}", entry->serial);
|
WARNING_LOG("Empty disc set serial in {}", entry->serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find(entry->disc_set_serials.begin(), entry->disc_set_serials.end(), serial_str) !=
|
if (std::find(entry->disc_set_serials.begin(), entry->disc_set_serials.end(), serial_str) !=
|
||||||
entry->disc_set_serials.end())
|
entry->disc_set_serials.end())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Duplicate serial {} in disc set serials for {}", serial_str, entry->serial);
|
WARNING_LOG("Duplicate serial {} in disc set serials for {}", serial_str, entry->serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,7 +1272,7 @@ bool GameDatabase::ParseYamlCodes(u32 index, const ryml::ConstNodeRef& value, st
|
||||||
auto iter = s_code_lookup.find(serial);
|
auto iter = s_code_lookup.find(serial);
|
||||||
if (iter != s_code_lookup.end())
|
if (iter != s_code_lookup.end())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Duplicate code '{}'", serial);
|
WARNING_LOG("Duplicate code '{}'", serial);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1286,14 +1286,14 @@ bool GameDatabase::ParseYamlCodes(u32 index, const ryml::ConstNodeRef& value, st
|
||||||
const std::string_view current_code_str = to_stringview(current_code.val());
|
const std::string_view current_code_str = to_stringview(current_code.val());
|
||||||
if (current_code_str.empty())
|
if (current_code_str.empty())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("code is not a string in {}", serial);
|
WARNING_LOG("code is not a string in {}", serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto iter = s_code_lookup.find(current_code_str);
|
auto iter = s_code_lookup.find(current_code_str);
|
||||||
if (iter != s_code_lookup.end())
|
if (iter != s_code_lookup.end())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Duplicate code '{}' in {}", current_code_str, serial);
|
WARNING_LOG("Duplicate code '{}' in {}", current_code_str, serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1320,7 +1320,7 @@ bool GameDatabase::LoadTrackHashes()
|
||||||
std::optional<std::string> gamedb_data(Host::ReadResourceFileToString(DISCDB_YAML_FILENAME, false));
|
std::optional<std::string> gamedb_data(Host::ReadResourceFileToString(DISCDB_YAML_FILENAME, false));
|
||||||
if (!gamedb_data.has_value())
|
if (!gamedb_data.has_value())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read game database");
|
ERROR_LOG("Failed to read game database");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1338,14 +1338,14 @@ bool GameDatabase::LoadTrackHashes()
|
||||||
const std::string_view serial = to_stringview(current.key());
|
const std::string_view serial = to_stringview(current.key());
|
||||||
if (serial.empty() || !current.has_children())
|
if (serial.empty() || !current.has_children())
|
||||||
{
|
{
|
||||||
Log_WarningPrint("entry is not an object");
|
WARNING_LOG("entry is not an object");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ryml::ConstNodeRef track_data = current.find_child(to_csubstr("trackData"));
|
const ryml::ConstNodeRef track_data = current.find_child(to_csubstr("trackData"));
|
||||||
if (!track_data.valid() || !track_data.has_children())
|
if (!track_data.valid() || !track_data.has_children())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("trackData is missing in {}", serial);
|
WARNING_LOG("trackData is missing in {}", serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1355,7 +1355,7 @@ bool GameDatabase::LoadTrackHashes()
|
||||||
const ryml::ConstNodeRef tracks = track_revisions.find_child(to_csubstr("tracks"));
|
const ryml::ConstNodeRef tracks = track_revisions.find_child(to_csubstr("tracks"));
|
||||||
if (!tracks.valid() || !tracks.has_children())
|
if (!tracks.valid() || !tracks.has_children())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("tracks member is missing in {}", serial);
|
WARNING_LOG("tracks member is missing in {}", serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1368,7 +1368,7 @@ bool GameDatabase::LoadTrackHashes()
|
||||||
std::string_view md5_str;
|
std::string_view md5_str;
|
||||||
if (!md5.valid() || (md5_str = to_stringview(md5.val())).empty())
|
if (!md5.valid() || (md5_str = to_stringview(md5.val())).empty())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("md5 is missing in track in {}", serial);
|
WARNING_LOG("md5 is missing in track in {}", serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1380,7 +1380,7 @@ bool GameDatabase::LoadTrackHashes()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("invalid md5 in {}", serial);
|
WARNING_LOG("invalid md5 in {}", serial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
revision++;
|
revision++;
|
||||||
|
@ -1390,8 +1390,8 @@ bool GameDatabase::LoadTrackHashes()
|
||||||
}
|
}
|
||||||
|
|
||||||
ryml::reset_callbacks();
|
ryml::reset_callbacks();
|
||||||
Log_InfoFmt("Loaded {} track hashes from {} serials in {:.0f}ms.", s_track_hashes_map.size(), serials,
|
INFO_LOG("Loaded {} track hashes from {} serials in {:.0f}ms.", s_track_hashes_map.size(), serials,
|
||||||
load_timer.GetTimeMilliseconds());
|
load_timer.GetTimeMilliseconds());
|
||||||
return !s_track_hashes_map.empty();
|
return !s_track_hashes_map.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ bool GameList::GetExeListEntry(const std::string& path, GameList::Entry* entry)
|
||||||
|
|
||||||
if (!BIOS::IsValidPSExeHeader(header, file_size))
|
if (!BIOS::IsValidPSExeHeader(header, file_size))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("{} is not a valid PS-EXE", path);
|
WARNING_LOG("{} is not a valid PS-EXE", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ bool GameList::GetDiscListEntry(const std::string& path, Entry* entry)
|
||||||
{
|
{
|
||||||
if (!cdi->SwitchSubImage(i, nullptr))
|
if (!cdi->SwitchSubImage(i, nullptr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to switch to subimage {} in '{}'", i, entry->path);
|
ERROR_LOG("Failed to switch to subimage {} in '{}'", i, entry->path);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ bool GameList::LoadEntriesFromCache(ByteStream* stream)
|
||||||
if (!stream->ReadU32(&file_signature) || !stream->ReadU32(&file_version) ||
|
if (!stream->ReadU32(&file_signature) || !stream->ReadU32(&file_version) ||
|
||||||
file_signature != GAME_LIST_CACHE_SIGNATURE || file_version != GAME_LIST_CACHE_VERSION)
|
file_signature != GAME_LIST_CACHE_SIGNATURE || file_version != GAME_LIST_CACHE_VERSION)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Game list cache is corrupted");
|
WARNING_LOG("Game list cache is corrupted");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ bool GameList::LoadEntriesFromCache(ByteStream* stream)
|
||||||
region >= static_cast<u8>(DiscRegion::Count) || type >= static_cast<u8>(EntryType::Count) ||
|
region >= static_cast<u8>(DiscRegion::Count) || type >= static_cast<u8>(EntryType::Count) ||
|
||||||
compatibility_rating >= static_cast<u8>(GameDatabase::CompatibilityRating::Count))
|
compatibility_rating >= static_cast<u8>(GameDatabase::CompatibilityRating::Count))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Game list cache entry is corrupted");
|
WARNING_LOG("Game list cache entry is corrupted");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ void GameList::LoadCache()
|
||||||
|
|
||||||
if (!LoadEntriesFromCache(stream.get()))
|
if (!LoadEntriesFromCache(stream.get()))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Deleting corrupted cache file '{}'", Path::GetFileName(filename));
|
WARNING_LOG("Deleting corrupted cache file '{}'", Path::GetFileName(filename));
|
||||||
stream.reset();
|
stream.reset();
|
||||||
s_cache_map.clear();
|
s_cache_map.clear();
|
||||||
DeleteCacheFile();
|
DeleteCacheFile();
|
||||||
|
@ -438,7 +438,7 @@ bool GameList::OpenCacheForWriting()
|
||||||
s_cache_write_stream.reset();
|
s_cache_write_stream.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Creating new game list cache file: '{}'", Path::GetFileName(cache_filename));
|
INFO_LOG("Creating new game list cache file: '{}'", Path::GetFileName(cache_filename));
|
||||||
|
|
||||||
s_cache_write_stream = ByteStream::OpenFile(
|
s_cache_write_stream = ByteStream::OpenFile(
|
||||||
cache_filename.c_str(), BYTESTREAM_OPEN_CREATE | BYTESTREAM_OPEN_TRUNCATE | BYTESTREAM_OPEN_WRITE);
|
cache_filename.c_str(), BYTESTREAM_OPEN_CREATE | BYTESTREAM_OPEN_TRUNCATE | BYTESTREAM_OPEN_WRITE);
|
||||||
|
@ -449,7 +449,7 @@ bool GameList::OpenCacheForWriting()
|
||||||
if (!s_cache_write_stream->WriteU32(GAME_LIST_CACHE_SIGNATURE) ||
|
if (!s_cache_write_stream->WriteU32(GAME_LIST_CACHE_SIGNATURE) ||
|
||||||
!s_cache_write_stream->WriteU32(GAME_LIST_CACHE_VERSION))
|
!s_cache_write_stream->WriteU32(GAME_LIST_CACHE_VERSION))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to write game list cache header");
|
ERROR_LOG("Failed to write game list cache header");
|
||||||
s_cache_write_stream.reset();
|
s_cache_write_stream.reset();
|
||||||
FileSystem::DeleteFile(cache_filename.c_str());
|
FileSystem::DeleteFile(cache_filename.c_str());
|
||||||
return false;
|
return false;
|
||||||
|
@ -477,9 +477,9 @@ void GameList::DeleteCacheFile()
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
if (FileSystem::DeleteFile(filename.c_str(), &error))
|
if (FileSystem::DeleteFile(filename.c_str(), &error))
|
||||||
Log_InfoFmt("Deleted game list cache '{}'", Path::GetFileName(filename));
|
INFO_LOG("Deleted game list cache '{}'", Path::GetFileName(filename));
|
||||||
else
|
else
|
||||||
Log_WarningFmt("Failed to delete game list cache '{}': {}", Path::GetFileName(filename), error.GetDescription());
|
WARNING_LOG("Failed to delete game list cache '{}': {}", Path::GetFileName(filename), error.GetDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsPathExcluded(const std::vector<std::string>& excluded_paths, const std::string& path)
|
static bool IsPathExcluded(const std::vector<std::string>& excluded_paths, const std::string& path)
|
||||||
|
@ -492,7 +492,7 @@ void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache,
|
||||||
const std::vector<std::string>& excluded_paths, const PlayedTimeMap& played_time_map,
|
const std::vector<std::string>& excluded_paths, const PlayedTimeMap& played_time_map,
|
||||||
ProgressCallback* progress)
|
ProgressCallback* progress)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Scanning {}{}", path, recursive ? " (recursively)" : "");
|
INFO_LOG("Scanning {}{}", path, recursive ? " (recursively)" : "");
|
||||||
|
|
||||||
progress->SetStatusText(SmallString::from_format(TRANSLATE_FS("GameList", "Scanning directory '{}'..."), path));
|
progress->SetStatusText(SmallString::from_format(TRANSLATE_FS("GameList", "Scanning directory '{}'..."), path));
|
||||||
|
|
||||||
|
@ -559,7 +559,7 @@ bool GameList::ScanFile(std::string path, std::time_t timestamp, std::unique_loc
|
||||||
// don't block UI while scanning
|
// don't block UI while scanning
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
Log_DevFmt("Scanning '{}'...", path);
|
DEV_LOG("Scanning '{}'...", path);
|
||||||
|
|
||||||
Entry entry;
|
Entry entry;
|
||||||
if (!PopulateEntryFromPath(path, &entry))
|
if (!PopulateEntryFromPath(path, &entry))
|
||||||
|
@ -571,7 +571,7 @@ bool GameList::ScanFile(std::string path, std::time_t timestamp, std::unique_loc
|
||||||
if (s_cache_write_stream || OpenCacheForWriting())
|
if (s_cache_write_stream || OpenCacheForWriting())
|
||||||
{
|
{
|
||||||
if (!WriteEntryToCache(&entry)) [[unlikely]]
|
if (!WriteEntryToCache(&entry)) [[unlikely]]
|
||||||
Log_WarningFmt("Failed to write entry '{}' to cache", entry.path);
|
WARNING_LOG("Failed to write entry '{}' to cache", entry.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto iter = played_time_map.find(entry.serial);
|
auto iter = played_time_map.find(entry.serial);
|
||||||
|
@ -781,7 +781,7 @@ void GameList::CreateDiscSetEntries(const PlayedTimeMap& played_time_map)
|
||||||
}
|
}
|
||||||
if (!found_another_disc)
|
if (!found_another_disc)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Not creating disc set {}, only one disc found", disc_set_name);
|
DEV_LOG("Not creating disc set {}, only one disc found", disc_set_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -834,7 +834,7 @@ void GameList::CreateDiscSetEntries(const PlayedTimeMap& played_time_map)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("Adding {} to disc set {}", Path::GetFileName(other_entry.path), disc_set_name);
|
DEV_LOG("Adding {} to disc set {}", Path::GetFileName(other_entry.path), disc_set_name);
|
||||||
other_entry.disc_set_member = true;
|
other_entry.disc_set_member = true;
|
||||||
set_entry.last_modified_time = std::min(set_entry.last_modified_time, other_entry.last_modified_time);
|
set_entry.last_modified_time = std::min(set_entry.last_modified_time, other_entry.last_modified_time);
|
||||||
set_entry.file_size += other_entry.file_size;
|
set_entry.file_size += other_entry.file_size;
|
||||||
|
@ -842,7 +842,7 @@ void GameList::CreateDiscSetEntries(const PlayedTimeMap& played_time_map)
|
||||||
num_parts++;
|
num_parts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("Created disc set {} from {} entries", disc_set_name, num_parts);
|
DEV_LOG("Created disc set {} from {} entries", disc_set_name, num_parts);
|
||||||
|
|
||||||
// entry is done :)
|
// entry is done :)
|
||||||
s_entries.push_back(std::move(set_entry));
|
s_entries.push_back(std::move(set_entry));
|
||||||
|
@ -947,7 +947,7 @@ bool GameList::ParsePlayedTimeLine(char* line, std::string& serial, PlayedTimeEn
|
||||||
size_t len = std::strlen(line);
|
size_t len = std::strlen(line);
|
||||||
if (len != (PLAYED_TIME_LINE_LENGTH + 1)) // \n
|
if (len != (PLAYED_TIME_LINE_LENGTH + 1)) // \n
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Malformed line: '{}'", line);
|
WARNING_LOG("Malformed line: '{}'", line);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,7 +961,7 @@ bool GameList::ParsePlayedTimeLine(char* line, std::string& serial, PlayedTimeEn
|
||||||
const std::optional<u64> last_played_time(StringUtil::FromChars<u64>(last_played_time_tok));
|
const std::optional<u64> last_played_time(StringUtil::FromChars<u64>(last_played_time_tok));
|
||||||
if (serial_tok.empty() || !last_played_time.has_value() || !total_played_time.has_value())
|
if (serial_tok.empty() || !last_played_time.has_value() || !total_played_time.has_value())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Malformed line: '{}'", line);
|
WARNING_LOG("Malformed line: '{}'", line);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1010,7 +1010,7 @@ GameList::PlayedTimeMap GameList::LoadPlayedTimeMap(const std::string& path)
|
||||||
|
|
||||||
if (ret.find(serial) != ret.end())
|
if (ret.find(serial) != ret.end())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Duplicate entry: '%s'", serial);
|
WARNING_LOG("Duplicate entry: '%s'", serial);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,7 +1043,7 @@ GameList::PlayedTimeEntry GameList::UpdatePlayedTimeFile(const std::string& path
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open '{}' for update.", path);
|
ERROR_LOG("Failed to open '{}' for update.", path);
|
||||||
return new_entry;
|
return new_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1074,7 +1074,7 @@ GameList::PlayedTimeEntry GameList::UpdatePlayedTimeFile(const std::string& path
|
||||||
if (FileSystem::FSeek64(fp.get(), line_pos, SEEK_SET) != 0 ||
|
if (FileSystem::FSeek64(fp.get(), line_pos, SEEK_SET) != 0 ||
|
||||||
std::fwrite(new_line.data(), new_line.length(), 1, fp.get()) != 1)
|
std::fwrite(new_line.data(), new_line.length(), 1, fp.get()) != 1)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to update '%s'.", path);
|
ERROR_LOG("Failed to update '%s'.", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return line_entry;
|
return line_entry;
|
||||||
|
@ -1087,7 +1087,7 @@ GameList::PlayedTimeEntry GameList::UpdatePlayedTimeFile(const std::string& path
|
||||||
if (FileSystem::FSeek64(fp.get(), 0, SEEK_END) != 0 ||
|
if (FileSystem::FSeek64(fp.get(), 0, SEEK_END) != 0 ||
|
||||||
std::fwrite(new_line.data(), new_line.length(), 1, fp.get()) != 1)
|
std::fwrite(new_line.data(), new_line.length(), 1, fp.get()) != 1)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to write '%s'.", path);
|
ERROR_LOG("Failed to write '%s'.", path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1100,8 +1100,8 @@ void GameList::AddPlayedTimeForSerial(const std::string& serial, std::time_t las
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const PlayedTimeEntry pt(UpdatePlayedTimeFile(GetPlayedTimeFile(), serial, last_time, add_time));
|
const PlayedTimeEntry pt(UpdatePlayedTimeFile(GetPlayedTimeFile(), serial, last_time, add_time));
|
||||||
Log_VerboseFmt("Add {} seconds play time to {} -> now {}", static_cast<unsigned>(add_time), serial.c_str(),
|
VERBOSE_LOG("Add {} seconds play time to {} -> now {}", static_cast<unsigned>(add_time), serial.c_str(),
|
||||||
static_cast<unsigned>(pt.total_played_time));
|
static_cast<unsigned>(pt.total_played_time));
|
||||||
|
|
||||||
std::unique_lock<std::recursive_mutex> lock(s_mutex);
|
std::unique_lock<std::recursive_mutex> lock(s_mutex);
|
||||||
for (GameList::Entry& entry : s_entries)
|
for (GameList::Entry& entry : s_entries)
|
||||||
|
|
|
@ -167,7 +167,7 @@ static std::optional<std::string> Cmd$G(std::string_view data)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Wrong payload size for 'G' command, expected {} got {}", NUM_GDB_REGISTERS * 8, data.size());
|
ERROR_LOG("Wrong payload size for 'G' command, expected {} got {}", NUM_GDB_REGISTERS * 8, data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
return {""};
|
return {""};
|
||||||
|
@ -308,7 +308,7 @@ std::string ProcessPacket(std::string_view data)
|
||||||
{
|
{
|
||||||
if (trimmedData[0] == '-')
|
if (trimmedData[0] == '-')
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Received negative ack");
|
ERROR_LOG("Received negative ack");
|
||||||
}
|
}
|
||||||
trimmedData = trimmedData.substr(1);
|
trimmedData = trimmedData.substr(1);
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ std::string ProcessPacket(std::string_view data)
|
||||||
auto packet = DeserializePacket(trimmedData);
|
auto packet = DeserializePacket(trimmedData);
|
||||||
if (!packet)
|
if (!packet)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Malformed packet '{}'", trimmedData);
|
ERROR_LOG("Malformed packet '{}'", trimmedData);
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ std::string ProcessPacket(std::string_view data)
|
||||||
{
|
{
|
||||||
if (packet->starts_with(command.first))
|
if (packet->starts_with(command.first))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Processing command '{}'", command.first);
|
DEBUG_LOG("Processing command '{}'", command.first);
|
||||||
|
|
||||||
// Invoke command, remove command name from payload.
|
// Invoke command, remove command name from payload.
|
||||||
reply = command.second(packet->substr(strlen(command.first)));
|
reply = command.second(packet->substr(strlen(command.first)));
|
||||||
|
@ -339,7 +339,7 @@ std::string ProcessPacket(std::string_view data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!processed)
|
if (!processed)
|
||||||
Log_WarningFmt("Failed to process packet '{}'", trimmedData);
|
WARNING_LOG("Failed to process packet '{}'", trimmedData);
|
||||||
|
|
||||||
return reply ? "+" + SerializePacket(*reply) : "+";
|
return reply ? "+" + SerializePacket(*reply) : "+";
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,7 +486,7 @@ u32 GPU::ReadRegister(u32 offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log_ErrorFmt("Unhandled register read: {:02X}", offset);
|
ERROR_LOG("Unhandled register read: {:02X}", offset);
|
||||||
return UINT32_C(0xFFFFFFFF);
|
return UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ void GPU::WriteRegister(u32 offset, u32 value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log_ErrorFmt("Unhandled register write: {:02X} <- {:08X}", offset, value);
|
ERROR_LOG("Unhandled register write: {:02X} <- {:08X}", offset, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,7 @@ void GPU::DMARead(u32* words, u32 word_count)
|
||||||
{
|
{
|
||||||
if (m_GPUSTAT.dma_direction != DMADirection::GPUREADtoCPU)
|
if (m_GPUSTAT.dma_direction != DMADirection::GPUREADtoCPU)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid DMA direction from GPU DMA read");
|
ERROR_LOG("Invalid DMA direction from GPU DMA read");
|
||||||
std::fill_n(words, word_count, UINT32_C(0xFFFFFFFF));
|
std::fill_n(words, word_count, UINT32_C(0xFFFFFFFF));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1017,7 @@ void GPU::CRTCTickEvent(TickCount ticks)
|
||||||
{
|
{
|
||||||
if (new_vblank)
|
if (new_vblank)
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Now in v-blank");
|
DEBUG_LOG("Now in v-blank");
|
||||||
|
|
||||||
// flush any pending draws and "scan out" the image
|
// flush any pending draws and "scan out" the image
|
||||||
// TODO: move present in here I guess
|
// TODO: move present in here I guess
|
||||||
|
@ -1038,8 +1038,8 @@ void GPU::CRTCTickEvent(TickCount ticks)
|
||||||
static_cast<double>(s_active_gpu_cycles) /
|
static_cast<double>(s_active_gpu_cycles) /
|
||||||
static_cast<double>(SystemTicksToGPUTicks(System::ScaleTicksToOverclock(System::MASTER_CLOCK)) *
|
static_cast<double>(SystemTicksToGPUTicks(System::ScaleTicksToOverclock(System::MASTER_CLOCK)) *
|
||||||
(ComputeVerticalFrequency() / 60.0f));
|
(ComputeVerticalFrequency() / 60.0f));
|
||||||
Log_DevFmt("PSX GPU Usage: {:.2f}% [{:.0f} cycles avg per frame]", busy_frac * 100,
|
DEV_LOG("PSX GPU Usage: {:.2f}% [{:.0f} cycles avg per frame]", busy_frac * 100,
|
||||||
static_cast<double>(s_active_gpu_cycles) / static_cast<double>(s_active_gpu_cycles_frames));
|
static_cast<double>(s_active_gpu_cycles) / static_cast<double>(s_active_gpu_cycles_frames));
|
||||||
s_active_gpu_cycles = 0;
|
s_active_gpu_cycles = 0;
|
||||||
s_active_gpu_cycles_frames = 0;
|
s_active_gpu_cycles_frames = 0;
|
||||||
}
|
}
|
||||||
|
@ -1123,10 +1123,10 @@ void GPU::ConvertScreenCoordinatesToDisplayCoordinates(float window_x, float win
|
||||||
*display_x = scaled_display_x * static_cast<float>(m_crtc_state.display_width);
|
*display_x = scaled_display_x * static_cast<float>(m_crtc_state.display_width);
|
||||||
*display_y = scaled_display_y * static_cast<float>(m_crtc_state.display_height);
|
*display_y = scaled_display_y * static_cast<float>(m_crtc_state.display_height);
|
||||||
|
|
||||||
Log_DevFmt("win {:.0f},{:.0f} -> local {:.0f},{:.0f}, disp {:.2f},{:.2f} (size {},{} frac {},{})", window_x, window_y,
|
DEV_LOG("win {:.0f},{:.0f} -> local {:.0f},{:.0f}, disp {:.2f},{:.2f} (size {},{} frac {},{})", window_x, window_y,
|
||||||
window_x - draw_rc.left, window_y - draw_rc.top, *display_x, *display_y, m_crtc_state.display_width,
|
window_x - draw_rc.left, window_y - draw_rc.top, *display_x, *display_y, m_crtc_state.display_width,
|
||||||
m_crtc_state.display_height, *display_x / static_cast<float>(m_crtc_state.display_width),
|
m_crtc_state.display_height, *display_x / static_cast<float>(m_crtc_state.display_width),
|
||||||
*display_y / static_cast<float>(m_crtc_state.display_height));
|
*display_y / static_cast<float>(m_crtc_state.display_height));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPU::ConvertDisplayCoordinatesToBeamTicksAndLines(float display_x, float display_y, float x_scale, u32* out_tick,
|
bool GPU::ConvertDisplayCoordinatesToBeamTicksAndLines(float display_x, float display_y, float x_scale, u32* out_tick,
|
||||||
|
@ -1207,7 +1207,7 @@ u32 GPU::ReadGPUREAD()
|
||||||
|
|
||||||
if (++m_vram_transfer.row == m_vram_transfer.height)
|
if (++m_vram_transfer.row == m_vram_transfer.height)
|
||||||
{
|
{
|
||||||
Log_DebugPrint("End of VRAM->CPU transfer");
|
DEBUG_LOG("End of VRAM->CPU transfer");
|
||||||
m_vram_transfer = {};
|
m_vram_transfer = {};
|
||||||
m_blitter_state = BlitterState::Idle;
|
m_blitter_state = BlitterState::Idle;
|
||||||
|
|
||||||
|
@ -1230,7 +1230,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
{
|
{
|
||||||
case 0x00: // Reset GPU
|
case 0x00: // Reset GPU
|
||||||
{
|
{
|
||||||
Log_DebugPrint("GP1 reset GPU");
|
DEBUG_LOG("GP1 reset GPU");
|
||||||
m_command_tick_event->InvokeEarly();
|
m_command_tick_event->InvokeEarly();
|
||||||
SynchronizeCRTC();
|
SynchronizeCRTC();
|
||||||
SoftReset();
|
SoftReset();
|
||||||
|
@ -1239,7 +1239,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
|
|
||||||
case 0x01: // Clear FIFO
|
case 0x01: // Clear FIFO
|
||||||
{
|
{
|
||||||
Log_DebugPrint("GP1 clear FIFO");
|
DEBUG_LOG("GP1 clear FIFO");
|
||||||
m_command_tick_event->InvokeEarly();
|
m_command_tick_event->InvokeEarly();
|
||||||
SynchronizeCRTC();
|
SynchronizeCRTC();
|
||||||
|
|
||||||
|
@ -1262,7 +1262,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
|
|
||||||
case 0x02: // Acknowledge Interrupt
|
case 0x02: // Acknowledge Interrupt
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Acknowledge interrupt");
|
DEBUG_LOG("Acknowledge interrupt");
|
||||||
m_GPUSTAT.interrupt_request = false;
|
m_GPUSTAT.interrupt_request = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1270,7 +1270,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
case 0x03: // Display on/off
|
case 0x03: // Display on/off
|
||||||
{
|
{
|
||||||
const bool disable = ConvertToBoolUnchecked(value & 0x01);
|
const bool disable = ConvertToBoolUnchecked(value & 0x01);
|
||||||
Log_DebugFmt("Display {}", disable ? "disabled" : "enabled");
|
DEBUG_LOG("Display {}", disable ? "disabled" : "enabled");
|
||||||
SynchronizeCRTC();
|
SynchronizeCRTC();
|
||||||
|
|
||||||
if (!m_GPUSTAT.display_disable && disable && m_GPUSTAT.vertical_interlace && !m_force_progressive_scan)
|
if (!m_GPUSTAT.display_disable && disable && m_GPUSTAT.vertical_interlace && !m_force_progressive_scan)
|
||||||
|
@ -1282,7 +1282,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
|
|
||||||
case 0x04: // DMA Direction
|
case 0x04: // DMA Direction
|
||||||
{
|
{
|
||||||
Log_DebugFmt("DMA direction <- 0x{:02X}", static_cast<u32>(param));
|
DEBUG_LOG("DMA direction <- 0x{:02X}", static_cast<u32>(param));
|
||||||
if (m_GPUSTAT.dma_direction != static_cast<DMADirection>(param))
|
if (m_GPUSTAT.dma_direction != static_cast<DMADirection>(param))
|
||||||
{
|
{
|
||||||
m_GPUSTAT.dma_direction = static_cast<DMADirection>(param);
|
m_GPUSTAT.dma_direction = static_cast<DMADirection>(param);
|
||||||
|
@ -1294,7 +1294,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
case 0x05: // Set display start address
|
case 0x05: // Set display start address
|
||||||
{
|
{
|
||||||
const u32 new_value = param & CRTCState::Regs::DISPLAY_ADDRESS_START_MASK;
|
const u32 new_value = param & CRTCState::Regs::DISPLAY_ADDRESS_START_MASK;
|
||||||
Log_DebugFmt("Display address start <- 0x{:08X}", new_value);
|
DEBUG_LOG("Display address start <- 0x{:08X}", new_value);
|
||||||
|
|
||||||
System::IncrementInternalFrameNumber();
|
System::IncrementInternalFrameNumber();
|
||||||
if (m_crtc_state.regs.display_address_start != new_value)
|
if (m_crtc_state.regs.display_address_start != new_value)
|
||||||
|
@ -1309,7 +1309,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
case 0x06: // Set horizontal display range
|
case 0x06: // Set horizontal display range
|
||||||
{
|
{
|
||||||
const u32 new_value = param & CRTCState::Regs::HORIZONTAL_DISPLAY_RANGE_MASK;
|
const u32 new_value = param & CRTCState::Regs::HORIZONTAL_DISPLAY_RANGE_MASK;
|
||||||
Log_DebugFmt("Horizontal display range <- 0x{:08X}", new_value);
|
DEBUG_LOG("Horizontal display range <- 0x{:08X}", new_value);
|
||||||
|
|
||||||
if (m_crtc_state.regs.horizontal_display_range != new_value)
|
if (m_crtc_state.regs.horizontal_display_range != new_value)
|
||||||
{
|
{
|
||||||
|
@ -1323,7 +1323,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
case 0x07: // Set vertical display range
|
case 0x07: // Set vertical display range
|
||||||
{
|
{
|
||||||
const u32 new_value = param & CRTCState::Regs::VERTICAL_DISPLAY_RANGE_MASK;
|
const u32 new_value = param & CRTCState::Regs::VERTICAL_DISPLAY_RANGE_MASK;
|
||||||
Log_DebugFmt("Vertical display range <- 0x{:08X}", new_value);
|
DEBUG_LOG("Vertical display range <- 0x{:08X}", new_value);
|
||||||
|
|
||||||
if (m_crtc_state.regs.vertical_display_range != new_value)
|
if (m_crtc_state.regs.vertical_display_range != new_value)
|
||||||
{
|
{
|
||||||
|
@ -1358,7 +1358,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
new_GPUSTAT.vertical_interlace = dm.vertical_interlace;
|
new_GPUSTAT.vertical_interlace = dm.vertical_interlace;
|
||||||
new_GPUSTAT.horizontal_resolution_2 = dm.horizontal_resolution_2;
|
new_GPUSTAT.horizontal_resolution_2 = dm.horizontal_resolution_2;
|
||||||
new_GPUSTAT.reverse_flag = dm.reverse_flag;
|
new_GPUSTAT.reverse_flag = dm.reverse_flag;
|
||||||
Log_DebugFmt("Set display mode <- 0x{:08X}", dm.bits);
|
DEBUG_LOG("Set display mode <- 0x{:08X}", dm.bits);
|
||||||
|
|
||||||
if (!m_GPUSTAT.vertical_interlace && dm.vertical_interlace && !m_force_progressive_scan)
|
if (!m_GPUSTAT.vertical_interlace && dm.vertical_interlace && !m_force_progressive_scan)
|
||||||
{
|
{
|
||||||
|
@ -1381,7 +1381,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
case 0x09: // Allow texture disable
|
case 0x09: // Allow texture disable
|
||||||
{
|
{
|
||||||
m_set_texture_disable_mask = ConvertToBoolUnchecked(param & 0x01);
|
m_set_texture_disable_mask = ConvertToBoolUnchecked(param & 0x01);
|
||||||
Log_DebugFmt("Set texture disable mask <- {}", m_set_texture_disable_mask ? "allowed" : "ignored");
|
DEBUG_LOG("Set texture disable mask <- {}", m_set_texture_disable_mask ? "allowed" : "ignored");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1406,7 +1406,7 @@ void GPU::WriteGP1(u32 value)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
[[unlikely]] default : Log_ErrorFmt("Unimplemented GP1 command 0x{:02X}", command);
|
[[unlikely]] default : ERROR_LOG("Unimplemented GP1 command 0x{:02X}", command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1425,14 +1425,14 @@ void GPU::HandleGetGPUInfoCommand(u32 value)
|
||||||
|
|
||||||
case 0x02: // Get Texture Window
|
case 0x02: // Get Texture Window
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Get texture window");
|
DEBUG_LOG("Get texture window");
|
||||||
m_GPUREAD_latch = m_draw_mode.texture_window_value;
|
m_GPUREAD_latch = m_draw_mode.texture_window_value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x03: // Get Draw Area Top Left
|
case 0x03: // Get Draw Area Top Left
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Get drawing area top left");
|
DEBUG_LOG("Get drawing area top left");
|
||||||
m_GPUREAD_latch =
|
m_GPUREAD_latch =
|
||||||
((m_drawing_area.left & UINT32_C(0b1111111111)) | ((m_drawing_area.top & UINT32_C(0b1111111111)) << 10));
|
((m_drawing_area.left & UINT32_C(0b1111111111)) | ((m_drawing_area.top & UINT32_C(0b1111111111)) << 10));
|
||||||
}
|
}
|
||||||
|
@ -1440,7 +1440,7 @@ void GPU::HandleGetGPUInfoCommand(u32 value)
|
||||||
|
|
||||||
case 0x04: // Get Draw Area Bottom Right
|
case 0x04: // Get Draw Area Bottom Right
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Get drawing area bottom right");
|
DEBUG_LOG("Get drawing area bottom right");
|
||||||
m_GPUREAD_latch =
|
m_GPUREAD_latch =
|
||||||
((m_drawing_area.right & UINT32_C(0b1111111111)) | ((m_drawing_area.bottom & UINT32_C(0b1111111111)) << 10));
|
((m_drawing_area.right & UINT32_C(0b1111111111)) | ((m_drawing_area.bottom & UINT32_C(0b1111111111)) << 10));
|
||||||
}
|
}
|
||||||
|
@ -1448,13 +1448,13 @@ void GPU::HandleGetGPUInfoCommand(u32 value)
|
||||||
|
|
||||||
case 0x05: // Get Drawing Offset
|
case 0x05: // Get Drawing Offset
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Get drawing offset");
|
DEBUG_LOG("Get drawing offset");
|
||||||
m_GPUREAD_latch =
|
m_GPUREAD_latch =
|
||||||
((m_drawing_offset.x & INT32_C(0b11111111111)) | ((m_drawing_offset.y & INT32_C(0b11111111111)) << 11));
|
((m_drawing_offset.x & INT32_C(0b11111111111)) | ((m_drawing_offset.y & INT32_C(0b11111111111)) << 11));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
[[unlikely]] default : Log_WarningFmt("Unhandled GetGPUInfo(0x{:02X})", subcommand);
|
[[unlikely]] default : WARNING_LOG("Unhandled GetGPUInfo(0x{:02X})", subcommand);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1467,7 +1467,7 @@ void GPU::UpdateCLUTIfNeeded(GPUTextureMode texmode, GPUTexturePaletteReg clut)
|
||||||
const bool needs_8bit = (texmode == GPUTextureMode::Palette8Bit);
|
const bool needs_8bit = (texmode == GPUTextureMode::Palette8Bit);
|
||||||
if ((clut.bits != m_current_clut_reg_bits) || BoolToUInt8(needs_8bit) > BoolToUInt8(m_current_clut_is_8bit))
|
if ((clut.bits != m_current_clut_reg_bits) || BoolToUInt8(needs_8bit) > BoolToUInt8(m_current_clut_is_8bit))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Reloading CLUT from {},{}, {}", clut.GetXBase(), clut.GetYBase(), needs_8bit ? "8-bit" : "4-bit");
|
DEBUG_LOG("Reloading CLUT from {},{}, {}", clut.GetXBase(), clut.GetYBase(), needs_8bit ? "8-bit" : "4-bit");
|
||||||
UpdateCLUT(clut, needs_8bit);
|
UpdateCLUT(clut, needs_8bit);
|
||||||
m_current_clut_reg_bits = clut.bits;
|
m_current_clut_reg_bits = clut.bits;
|
||||||
m_current_clut_is_8bit = needs_8bit;
|
m_current_clut_is_8bit = needs_8bit;
|
||||||
|
@ -1697,7 +1697,7 @@ void GPU::SetTextureWindow(u32 value)
|
||||||
const u8 mask_y = Truncate8((value >> 5) & UINT32_C(0x1F));
|
const u8 mask_y = Truncate8((value >> 5) & UINT32_C(0x1F));
|
||||||
const u8 offset_x = Truncate8((value >> 10) & UINT32_C(0x1F));
|
const u8 offset_x = Truncate8((value >> 10) & UINT32_C(0x1F));
|
||||||
const u8 offset_y = Truncate8((value >> 15) & UINT32_C(0x1F));
|
const u8 offset_y = Truncate8((value >> 15) & UINT32_C(0x1F));
|
||||||
Log_DebugFmt("Set texture window {:02X} {:02X} {:02X} {:02X}", mask_x, mask_y, offset_x, offset_y);
|
DEBUG_LOG("Set texture window {:02X} {:02X} {:02X} {:02X}", mask_x, mask_y, offset_x, offset_y);
|
||||||
|
|
||||||
m_draw_mode.texture_window.and_x = ~(mask_x * 8);
|
m_draw_mode.texture_window.and_x = ~(mask_x * 8);
|
||||||
m_draw_mode.texture_window.and_y = ~(mask_y * 8);
|
m_draw_mode.texture_window.and_y = ~(mask_y * 8);
|
||||||
|
@ -2462,7 +2462,7 @@ bool CompressAndWriteTextureToFile(u32 width, u32 height, std::string filename,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unknown extension in filename '{}' or save error: '{}'", filename, extension);
|
ERROR_LOG("Unknown extension in filename '{}' or save error: '{}'", filename, extension);
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2473,7 +2473,7 @@ bool CompressAndWriteTextureToFile(u32 width, u32 height, std::string filename,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unable to determine file extension for '{}'", filename);
|
ERROR_LOG("Unable to determine file extension for '{}'", filename);
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2556,8 +2556,8 @@ bool GPU::WriteDisplayTextureToFile(std::string filename, bool compress_on_threa
|
||||||
{
|
{
|
||||||
if (!(dltex = g_gpu_device->CreateDownloadTexture(read_width, read_height, m_display_texture->GetFormat())))
|
if (!(dltex = g_gpu_device->CreateDownloadTexture(read_width, read_height, m_display_texture->GetFormat())))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to create {}x{} {} download texture", read_width, read_height,
|
ERROR_LOG("Failed to create {}x{} {} download texture", read_width, read_height,
|
||||||
GPUTexture::GetFormatName(m_display_texture->GetFormat()));
|
GPUTexture::GetFormatName(m_display_texture->GetFormat()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2575,7 +2575,7 @@ bool GPU::WriteDisplayTextureToFile(std::string filename, bool compress_on_threa
|
||||||
auto fp = FileSystem::OpenManagedCFile(filename.c_str(), "wb", &error);
|
auto fp = FileSystem::OpenManagedCFile(filename.c_str(), "wb", &error);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Can't open file '{}': {}", Path::GetFileName(filename), error.GetDescription());
|
ERROR_LOG("Can't open file '{}': {}", Path::GetFileName(filename), error.GetDescription());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2616,7 +2616,7 @@ bool GPU::RenderScreenshotToBuffer(u32 width, u32 height, const Common::Rectangl
|
||||||
{
|
{
|
||||||
if (!(dltex = g_gpu_device->CreateDownloadTexture(width, height, hdformat)))
|
if (!(dltex = g_gpu_device->CreateDownloadTexture(width, height, hdformat)))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to create {}x{} download texture", width, height);
|
ERROR_LOG("Failed to create {}x{} download texture", width, height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2702,7 +2702,7 @@ bool GPU::RenderScreenshotToFile(std::string filename, DisplayScreenshotMode mod
|
||||||
if (!RenderScreenshotToBuffer(width, height, draw_rect, !internal_resolution, &pixels, &pixels_stride,
|
if (!RenderScreenshotToBuffer(width, height, draw_rect, !internal_resolution, &pixels, &pixels_stride,
|
||||||
&pixels_format))
|
&pixels_format))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to render {}x{} screenshot", width, height);
|
ERROR_LOG("Failed to render {}x{} screenshot", width, height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2710,7 +2710,7 @@ bool GPU::RenderScreenshotToFile(std::string filename, DisplayScreenshotMode mod
|
||||||
auto fp = FileSystem::OpenManagedCFile(filename.c_str(), "wb", &error);
|
auto fp = FileSystem::OpenManagedCFile(filename.c_str(), "wb", &error);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Can't open file '{}': {}", Path::GetFileName(filename), error.GetDescription());
|
ERROR_LOG("Can't open file '{}': {}", Path::GetFileName(filename), error.GetDescription());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2734,7 +2734,7 @@ bool GPU::DumpVRAMToFile(const char* filename)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unknown extension: '{}'", filename);
|
ERROR_LOG("Unknown extension: '{}'", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ void GPUBackend::StartGPUThread()
|
||||||
m_gpu_loop_done.store(false);
|
m_gpu_loop_done.store(false);
|
||||||
m_use_gpu_thread = true;
|
m_use_gpu_thread = true;
|
||||||
m_gpu_thread.Start([this]() { RunGPULoop(); });
|
m_gpu_thread.Start([this]() { RunGPULoop(); });
|
||||||
Log_InfoPrint("GPU thread started.");
|
INFO_LOG("GPU thread started.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUBackend::StopGPUThread()
|
void GPUBackend::StopGPUThread()
|
||||||
|
@ -195,7 +195,7 @@ void GPUBackend::StopGPUThread()
|
||||||
WakeGPUThread();
|
WakeGPUThread();
|
||||||
m_gpu_thread.Join();
|
m_gpu_thread.Join();
|
||||||
m_use_gpu_thread = false;
|
m_use_gpu_thread = false;
|
||||||
Log_InfoPrint("GPU thread stopped.");
|
INFO_LOG("GPU thread stopped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUBackend::Sync(bool allow_sleep)
|
void GPUBackend::Sync(bool allow_sleep)
|
||||||
|
|
|
@ -49,7 +49,7 @@ void GPU::TryExecuteCommands()
|
||||||
m_blit_buffer.push_back(FifoPop());
|
m_blit_buffer.push_back(FifoPop());
|
||||||
m_blit_remaining_words -= words_to_copy;
|
m_blit_remaining_words -= words_to_copy;
|
||||||
|
|
||||||
Log_DebugFmt("VRAM write burst of {} words, {} words remaining", words_to_copy, m_blit_remaining_words);
|
DEBUG_LOG("VRAM write burst of {} words, {} words remaining", words_to_copy, m_blit_remaining_words);
|
||||||
if (m_blit_remaining_words == 0)
|
if (m_blit_remaining_words == 0)
|
||||||
FinishVRAMWrite();
|
FinishVRAMWrite();
|
||||||
|
|
||||||
|
@ -84,12 +84,12 @@ void GPU::TryExecuteCommands()
|
||||||
m_blit_buffer.push_back(FifoPop());
|
m_blit_buffer.push_back(FifoPop());
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("Added {} words to polyline", words_to_copy);
|
DEBUG_LOG("Added {} words to polyline", words_to_copy);
|
||||||
if (found_terminator)
|
if (found_terminator)
|
||||||
{
|
{
|
||||||
// drop terminator
|
// drop terminator
|
||||||
m_fifo.RemoveOne();
|
m_fifo.RemoveOne();
|
||||||
Log_DebugFmt("Drawing poly-line with {} vertices", GetPolyLineVertexCount());
|
DEBUG_LOG("Drawing poly-line with {} vertices", GetPolyLineVertexCount());
|
||||||
DispatchRenderCommand();
|
DispatchRenderCommand();
|
||||||
m_blit_buffer.clear();
|
m_blit_buffer.clear();
|
||||||
EndCommand();
|
EndCommand();
|
||||||
|
@ -175,12 +175,12 @@ GPU::GP0CommandHandlerTable GPU::GenerateGP0CommandHandlerTable()
|
||||||
bool GPU::HandleUnknownGP0Command()
|
bool GPU::HandleUnknownGP0Command()
|
||||||
{
|
{
|
||||||
const u32 command = FifoPeek() >> 24;
|
const u32 command = FifoPeek() >> 24;
|
||||||
Log_ErrorFmt("Unimplemented GP0 command 0x{:02X}", command);
|
ERROR_LOG("Unimplemented GP0 command 0x{:02X}", command);
|
||||||
|
|
||||||
SmallString dump;
|
SmallString dump;
|
||||||
for (u32 i = 0; i < m_fifo.GetSize(); i++)
|
for (u32 i = 0; i < m_fifo.GetSize(); i++)
|
||||||
dump.append_format("{}{:08X}", (i > 0) ? " " : "", FifoPeek(i));
|
dump.append_format("{}{:08X}", (i > 0) ? " " : "", FifoPeek(i));
|
||||||
Log_ErrorFmt("FIFO: {}", dump);
|
ERROR_LOG("FIFO: {}", dump);
|
||||||
|
|
||||||
m_fifo.RemoveOne();
|
m_fifo.RemoveOne();
|
||||||
EndCommand();
|
EndCommand();
|
||||||
|
@ -196,7 +196,7 @@ bool GPU::HandleNOPCommand()
|
||||||
|
|
||||||
bool GPU::HandleClearCacheCommand()
|
bool GPU::HandleClearCacheCommand()
|
||||||
{
|
{
|
||||||
Log_DebugPrint("GP0 clear cache");
|
DEBUG_LOG("GP0 clear cache");
|
||||||
m_draw_mode.SetTexturePageChanged();
|
m_draw_mode.SetTexturePageChanged();
|
||||||
InvalidateCLUT();
|
InvalidateCLUT();
|
||||||
m_fifo.RemoveOne();
|
m_fifo.RemoveOne();
|
||||||
|
@ -207,7 +207,7 @@ bool GPU::HandleClearCacheCommand()
|
||||||
|
|
||||||
bool GPU::HandleInterruptRequestCommand()
|
bool GPU::HandleInterruptRequestCommand()
|
||||||
{
|
{
|
||||||
Log_DebugPrint("GP0 interrupt request");
|
DEBUG_LOG("GP0 interrupt request");
|
||||||
|
|
||||||
m_GPUSTAT.interrupt_request = true;
|
m_GPUSTAT.interrupt_request = true;
|
||||||
InterruptController::SetLineState(InterruptController::IRQ::GPU, m_GPUSTAT.interrupt_request);
|
InterruptController::SetLineState(InterruptController::IRQ::GPU, m_GPUSTAT.interrupt_request);
|
||||||
|
@ -221,7 +221,7 @@ bool GPU::HandleInterruptRequestCommand()
|
||||||
bool GPU::HandleSetDrawModeCommand()
|
bool GPU::HandleSetDrawModeCommand()
|
||||||
{
|
{
|
||||||
const u32 param = FifoPop() & 0x00FFFFFFu;
|
const u32 param = FifoPop() & 0x00FFFFFFu;
|
||||||
Log_DebugFmt("Set draw mode {:08X}", param);
|
DEBUG_LOG("Set draw mode {:08X}", param);
|
||||||
SetDrawMode(Truncate16(param));
|
SetDrawMode(Truncate16(param));
|
||||||
AddCommandTicks(1);
|
AddCommandTicks(1);
|
||||||
EndCommand();
|
EndCommand();
|
||||||
|
@ -242,7 +242,7 @@ bool GPU::HandleSetDrawingAreaTopLeftCommand()
|
||||||
const u32 param = FifoPop() & 0x00FFFFFFu;
|
const u32 param = FifoPop() & 0x00FFFFFFu;
|
||||||
const u32 left = param & DRAWING_AREA_COORD_MASK;
|
const u32 left = param & DRAWING_AREA_COORD_MASK;
|
||||||
const u32 top = (param >> 10) & DRAWING_AREA_COORD_MASK;
|
const u32 top = (param >> 10) & DRAWING_AREA_COORD_MASK;
|
||||||
Log_DebugFmt("Set drawing area top-left: ({}, {})", left, top);
|
DEBUG_LOG("Set drawing area top-left: ({}, {})", left, top);
|
||||||
if (m_drawing_area.left != left || m_drawing_area.top != top)
|
if (m_drawing_area.left != left || m_drawing_area.top != top)
|
||||||
{
|
{
|
||||||
FlushRender();
|
FlushRender();
|
||||||
|
@ -263,7 +263,7 @@ bool GPU::HandleSetDrawingAreaBottomRightCommand()
|
||||||
|
|
||||||
const u32 right = param & DRAWING_AREA_COORD_MASK;
|
const u32 right = param & DRAWING_AREA_COORD_MASK;
|
||||||
const u32 bottom = (param >> 10) & DRAWING_AREA_COORD_MASK;
|
const u32 bottom = (param >> 10) & DRAWING_AREA_COORD_MASK;
|
||||||
Log_DebugFmt("Set drawing area bottom-right: ({}, {})", m_drawing_area.right, m_drawing_area.bottom);
|
DEBUG_LOG("Set drawing area bottom-right: ({}, {})", m_drawing_area.right, m_drawing_area.bottom);
|
||||||
if (m_drawing_area.right != right || m_drawing_area.bottom != bottom)
|
if (m_drawing_area.right != right || m_drawing_area.bottom != bottom)
|
||||||
{
|
{
|
||||||
FlushRender();
|
FlushRender();
|
||||||
|
@ -283,7 +283,7 @@ bool GPU::HandleSetDrawingOffsetCommand()
|
||||||
const u32 param = FifoPop() & 0x00FFFFFFu;
|
const u32 param = FifoPop() & 0x00FFFFFFu;
|
||||||
const s32 x = SignExtendN<11, s32>(param & 0x7FFu);
|
const s32 x = SignExtendN<11, s32>(param & 0x7FFu);
|
||||||
const s32 y = SignExtendN<11, s32>((param >> 11) & 0x7FFu);
|
const s32 y = SignExtendN<11, s32>((param >> 11) & 0x7FFu);
|
||||||
Log_DebugFmt("Set drawing offset ({}, {})", m_drawing_offset.x, m_drawing_offset.y);
|
DEBUG_LOG("Set drawing offset ({}, {})", m_drawing_offset.x, m_drawing_offset.y);
|
||||||
if (m_drawing_offset.x != x || m_drawing_offset.y != y)
|
if (m_drawing_offset.x != x || m_drawing_offset.y != y)
|
||||||
{
|
{
|
||||||
FlushRender();
|
FlushRender();
|
||||||
|
@ -308,8 +308,8 @@ bool GPU::HandleSetMaskBitCommand()
|
||||||
FlushRender();
|
FlushRender();
|
||||||
m_GPUSTAT.bits = (m_GPUSTAT.bits & ~gpustat_mask) | gpustat_bits;
|
m_GPUSTAT.bits = (m_GPUSTAT.bits & ~gpustat_mask) | gpustat_bits;
|
||||||
}
|
}
|
||||||
Log_DebugFmt("Set mask bit {} {}", BoolToUInt32(m_GPUSTAT.set_mask_while_drawing),
|
DEBUG_LOG("Set mask bit {} {}", BoolToUInt32(m_GPUSTAT.set_mask_while_drawing),
|
||||||
BoolToUInt32(m_GPUSTAT.check_mask_before_draw));
|
BoolToUInt32(m_GPUSTAT.check_mask_before_draw));
|
||||||
|
|
||||||
AddCommandTicks(1);
|
AddCommandTicks(1);
|
||||||
EndCommand();
|
EndCommand();
|
||||||
|
@ -335,10 +335,10 @@ bool GPU::HandleRenderPolygonCommand()
|
||||||
s_setup_time[BoolToUInt8(rc.quad_polygon)][BoolToUInt8(rc.shading_enable)][BoolToUInt8(rc.texture_enable)]));
|
s_setup_time[BoolToUInt8(rc.quad_polygon)][BoolToUInt8(rc.shading_enable)][BoolToUInt8(rc.texture_enable)]));
|
||||||
AddCommandTicks(setup_ticks);
|
AddCommandTicks(setup_ticks);
|
||||||
|
|
||||||
Log_TraceFmt("Render {} {} {} {} polygon ({} verts, {} words per vert), {} setup ticks",
|
TRACE_LOG("Render {} {} {} {} polygon ({} verts, {} words per vert), {} setup ticks",
|
||||||
rc.quad_polygon ? "four-point" : "three-point", rc.transparency_enable ? "semi-transparent" : "opaque",
|
rc.quad_polygon ? "four-point" : "three-point", rc.transparency_enable ? "semi-transparent" : "opaque",
|
||||||
rc.texture_enable ? "textured" : "non-textured", rc.shading_enable ? "shaded" : "monochrome",
|
rc.texture_enable ? "textured" : "non-textured", rc.shading_enable ? "shaded" : "monochrome", num_vertices,
|
||||||
num_vertices, words_per_vertex, setup_ticks);
|
words_per_vertex, setup_ticks);
|
||||||
|
|
||||||
// set draw state up
|
// set draw state up
|
||||||
if (rc.texture_enable)
|
if (rc.texture_enable)
|
||||||
|
@ -380,9 +380,9 @@ bool GPU::HandleRenderRectangleCommand()
|
||||||
const TickCount setup_ticks = 16;
|
const TickCount setup_ticks = 16;
|
||||||
AddCommandTicks(setup_ticks);
|
AddCommandTicks(setup_ticks);
|
||||||
|
|
||||||
Log_TraceFmt("Render {} {} {} rectangle ({} words), {} setup ticks",
|
TRACE_LOG("Render {} {} {} rectangle ({} words), {} setup ticks",
|
||||||
rc.transparency_enable ? "semi-transparent" : "opaque", rc.texture_enable ? "textured" : "non-textured",
|
rc.transparency_enable ? "semi-transparent" : "opaque", rc.texture_enable ? "textured" : "non-textured",
|
||||||
rc.shading_enable ? "shaded" : "monochrome", total_words, setup_ticks);
|
rc.shading_enable ? "shaded" : "monochrome", total_words, setup_ticks);
|
||||||
|
|
||||||
m_counters.num_vertices++;
|
m_counters.num_vertices++;
|
||||||
m_counters.num_primitives++;
|
m_counters.num_primitives++;
|
||||||
|
@ -403,8 +403,8 @@ bool GPU::HandleRenderLineCommand()
|
||||||
if (IsInterlacedRenderingEnabled() && IsCRTCScanlinePending())
|
if (IsInterlacedRenderingEnabled() && IsCRTCScanlinePending())
|
||||||
SynchronizeCRTC();
|
SynchronizeCRTC();
|
||||||
|
|
||||||
Log_TraceFmt("Render {} {} line ({} total words)", rc.transparency_enable ? "semi-transparent" : "opaque",
|
TRACE_LOG("Render {} {} line ({} total words)", rc.transparency_enable ? "semi-transparent" : "opaque",
|
||||||
rc.shading_enable ? "shaded" : "monochrome", total_words);
|
rc.shading_enable ? "shaded" : "monochrome", total_words);
|
||||||
|
|
||||||
m_counters.num_vertices += 2;
|
m_counters.num_vertices += 2;
|
||||||
m_counters.num_primitives++;
|
m_counters.num_primitives++;
|
||||||
|
@ -429,8 +429,8 @@ bool GPU::HandleRenderPolyLineCommand()
|
||||||
const TickCount setup_ticks = 16;
|
const TickCount setup_ticks = 16;
|
||||||
AddCommandTicks(setup_ticks);
|
AddCommandTicks(setup_ticks);
|
||||||
|
|
||||||
Log_TraceFmt("Render {} {} poly-line, {} setup ticks", rc.transparency_enable ? "semi-transparent" : "opaque",
|
TRACE_LOG("Render {} {} poly-line, {} setup ticks", rc.transparency_enable ? "semi-transparent" : "opaque",
|
||||||
rc.shading_enable ? "shaded" : "monochrome", setup_ticks);
|
rc.shading_enable ? "shaded" : "monochrome", setup_ticks);
|
||||||
|
|
||||||
m_render_command.bits = rc.bits;
|
m_render_command.bits = rc.bits;
|
||||||
m_fifo.RemoveOne();
|
m_fifo.RemoveOne();
|
||||||
|
@ -463,7 +463,7 @@ bool GPU::HandleFillRectangleCommand()
|
||||||
const u32 width = ((FifoPeek() & VRAM_WIDTH_MASK) + 0xF) & ~0xF;
|
const u32 width = ((FifoPeek() & VRAM_WIDTH_MASK) + 0xF) & ~0xF;
|
||||||
const u32 height = (FifoPop() >> 16) & VRAM_HEIGHT_MASK;
|
const u32 height = (FifoPop() >> 16) & VRAM_HEIGHT_MASK;
|
||||||
|
|
||||||
Log_DebugFmt("Fill VRAM rectangle offset=({},{}), size=({},{})", dst_x, dst_y, width, height);
|
DEBUG_LOG("Fill VRAM rectangle offset=({},{}), size=({},{})", dst_x, dst_y, width, height);
|
||||||
|
|
||||||
if (width > 0 && height > 0)
|
if (width > 0 && height > 0)
|
||||||
FillVRAM(dst_x, dst_y, width, height, color);
|
FillVRAM(dst_x, dst_y, width, height, color);
|
||||||
|
@ -486,7 +486,7 @@ bool GPU::HandleCopyRectangleCPUToVRAMCommand()
|
||||||
const u32 num_pixels = copy_width * copy_height;
|
const u32 num_pixels = copy_width * copy_height;
|
||||||
const u32 num_words = ((num_pixels + 1) / 2);
|
const u32 num_words = ((num_pixels + 1) / 2);
|
||||||
|
|
||||||
Log_DebugFmt("Copy rectangle from CPU to VRAM offset=({},{}), size=({},{})", dst_x, dst_y, copy_width, copy_height);
|
DEBUG_LOG("Copy rectangle from CPU to VRAM offset=({},{}), size=({},{})", dst_x, dst_y, copy_width, copy_height);
|
||||||
|
|
||||||
EndCommand();
|
EndCommand();
|
||||||
|
|
||||||
|
@ -533,8 +533,8 @@ void GPU::FinishVRAMWrite()
|
||||||
const u32 transferred_full_rows = transferred_pixels / m_vram_transfer.width;
|
const u32 transferred_full_rows = transferred_pixels / m_vram_transfer.width;
|
||||||
const u32 transferred_width_last_row = transferred_pixels % m_vram_transfer.width;
|
const u32 transferred_width_last_row = transferred_pixels % m_vram_transfer.width;
|
||||||
|
|
||||||
Log_WarningFmt("Partial VRAM write - transfer finished with {} of {} words remaining ({} full rows, {} last row)",
|
WARNING_LOG("Partial VRAM write - transfer finished with {} of {} words remaining ({} full rows, {} last row)",
|
||||||
m_blit_remaining_words, num_words, transferred_full_rows, transferred_width_last_row);
|
m_blit_remaining_words, num_words, transferred_full_rows, transferred_width_last_row);
|
||||||
|
|
||||||
const u8* blit_ptr = reinterpret_cast<const u8*>(m_blit_buffer.data());
|
const u8* blit_ptr = reinterpret_cast<const u8*>(m_blit_buffer.data());
|
||||||
if (transferred_full_rows > 0)
|
if (transferred_full_rows > 0)
|
||||||
|
@ -566,8 +566,8 @@ bool GPU::HandleCopyRectangleVRAMToCPUCommand()
|
||||||
m_vram_transfer.width = ((Truncate16(FifoPeek()) - 1) & VRAM_WIDTH_MASK) + 1;
|
m_vram_transfer.width = ((Truncate16(FifoPeek()) - 1) & VRAM_WIDTH_MASK) + 1;
|
||||||
m_vram_transfer.height = ((Truncate16(FifoPop() >> 16) - 1) & VRAM_HEIGHT_MASK) + 1;
|
m_vram_transfer.height = ((Truncate16(FifoPop() >> 16) - 1) & VRAM_HEIGHT_MASK) + 1;
|
||||||
|
|
||||||
Log_DebugFmt("Copy rectangle from VRAM to CPU offset=({},{}), size=({},{})", m_vram_transfer.x, m_vram_transfer.y,
|
DEBUG_LOG("Copy rectangle from VRAM to CPU offset=({},{}), size=({},{})", m_vram_transfer.x, m_vram_transfer.y,
|
||||||
m_vram_transfer.width, m_vram_transfer.height);
|
m_vram_transfer.width, m_vram_transfer.height);
|
||||||
DebugAssert(m_vram_transfer.col == 0 && m_vram_transfer.row == 0);
|
DebugAssert(m_vram_transfer.col == 0 && m_vram_transfer.row == 0);
|
||||||
|
|
||||||
// all rendering should be done first...
|
// all rendering should be done first...
|
||||||
|
@ -602,8 +602,8 @@ bool GPU::HandleCopyRectangleVRAMToVRAMCommand()
|
||||||
const u32 width = ReplaceZero(FifoPeek() & VRAM_WIDTH_MASK, 0x400);
|
const u32 width = ReplaceZero(FifoPeek() & VRAM_WIDTH_MASK, 0x400);
|
||||||
const u32 height = ReplaceZero((FifoPop() >> 16) & VRAM_HEIGHT_MASK, 0x200);
|
const u32 height = ReplaceZero((FifoPop() >> 16) & VRAM_HEIGHT_MASK, 0x200);
|
||||||
|
|
||||||
Log_DebugFmt("Copy rectangle from VRAM to VRAM src=({},{}), dst=({},{}), size=({},{})", src_x, src_y, dst_x, dst_y,
|
DEBUG_LOG("Copy rectangle from VRAM to VRAM src=({},{}), dst=({},{}), size=({},{})", src_x, src_y, dst_x, dst_y,
|
||||||
width, height);
|
width, height);
|
||||||
|
|
||||||
// Some VRAM copies aren't going to do anything. Most games seem to send a 2x2 VRAM copy at the end of a frame.
|
// Some VRAM copies aren't going to do anything. Most games seem to send a 2x2 VRAM copy at the end of a frame.
|
||||||
const bool skip_copy =
|
const bool skip_copy =
|
||||||
|
|
|
@ -216,13 +216,13 @@ bool GPU_HW::Initialize()
|
||||||
|
|
||||||
if (!CompilePipelines())
|
if (!CompilePipelines())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to compile pipelines");
|
ERROR_LOG("Failed to compile pipelines");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CreateBuffers())
|
if (!CreateBuffers())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create framebuffer");
|
ERROR_LOG("Failed to create framebuffer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ void GPU_HW::CheckSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!features.noperspective_interpolation && !ShouldDisableColorPerspective())
|
if (!features.noperspective_interpolation && !ShouldDisableColorPerspective())
|
||||||
Log_WarningPrint("Disable color perspective not supported, but should be used.");
|
WARNING_LOG("Disable color perspective not supported, but should be used.");
|
||||||
|
|
||||||
if (!features.geometry_shaders && m_wireframe_mode != GPUWireframeMode::Disabled)
|
if (!features.geometry_shaders && m_wireframe_mode != GPUWireframeMode::Disabled)
|
||||||
{
|
{
|
||||||
|
@ -546,7 +546,7 @@ u32 GPU_HW::CalculateResolutionScale() const
|
||||||
|
|
||||||
const s32 preferred_scale =
|
const s32 preferred_scale =
|
||||||
static_cast<s32>(std::ceil(static_cast<float>(g_gpu_device->GetWindowHeight() * widescreen_multiplier) / height));
|
static_cast<s32>(std::ceil(static_cast<float>(g_gpu_device->GetWindowHeight() * widescreen_multiplier) / height));
|
||||||
Log_VerboseFmt("Height = {}, preferred scale = {}", height, preferred_scale);
|
VERBOSE_LOG("Height = {}, preferred scale = {}", height, preferred_scale);
|
||||||
|
|
||||||
scale = static_cast<u32>(std::clamp<s32>(preferred_scale, 1, max_resolution_scale));
|
scale = static_cast<u32>(std::clamp<s32>(preferred_scale, 1, max_resolution_scale));
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ u32 GPU_HW::CalculateResolutionScale() const
|
||||||
if (g_settings.gpu_downsample_mode == GPUDownsampleMode::Adaptive && scale > 1 && !Common::IsPow2(scale))
|
if (g_settings.gpu_downsample_mode == GPUDownsampleMode::Adaptive && scale > 1 && !Common::IsPow2(scale))
|
||||||
{
|
{
|
||||||
const u32 new_scale = Common::PreviousPow2(scale);
|
const u32 new_scale = Common::PreviousPow2(scale);
|
||||||
Log_WarningFmt("Resolution scale {}x not supported for adaptive downsampling, using {}x", scale, new_scale);
|
WARNING_LOG("Resolution scale {}x not supported for adaptive downsampling, using {}x", scale, new_scale);
|
||||||
|
|
||||||
if (g_settings.gpu_resolution_scale != 0)
|
if (g_settings.gpu_resolution_scale != 0)
|
||||||
{
|
{
|
||||||
|
@ -641,19 +641,18 @@ std::tuple<u32, u32> GPU_HW::GetFullDisplayResolution(bool scaled /* = true */)
|
||||||
|
|
||||||
void GPU_HW::PrintSettingsToLog()
|
void GPU_HW::PrintSettingsToLog()
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Resolution Scale: {} ({}x{}), maximum {}", m_resolution_scale, VRAM_WIDTH * m_resolution_scale,
|
INFO_LOG("Resolution Scale: {} ({}x{}), maximum {}", m_resolution_scale, VRAM_WIDTH * m_resolution_scale,
|
||||||
VRAM_HEIGHT * m_resolution_scale, GetMaxResolutionScale());
|
VRAM_HEIGHT * m_resolution_scale, GetMaxResolutionScale());
|
||||||
Log_InfoFmt("Multisampling: {}x{}", m_multisamples, m_per_sample_shading ? " (per sample shading)" : "");
|
INFO_LOG("Multisampling: {}x{}", m_multisamples, m_per_sample_shading ? " (per sample shading)" : "");
|
||||||
Log_InfoFmt("Dithering: {}{}", m_true_color ? "Disabled" : "Enabled",
|
INFO_LOG("Dithering: {}{}", m_true_color ? "Disabled" : "Enabled",
|
||||||
(!m_true_color && m_scaled_dithering) ? " (Scaled)" :
|
(!m_true_color && m_scaled_dithering) ? " (Scaled)" : ((m_true_color && m_debanding) ? " (Debanding)" : ""));
|
||||||
((m_true_color && m_debanding) ? " (Debanding)" : ""));
|
INFO_LOG("Texture Filtering: {}", Settings::GetTextureFilterDisplayName(m_texture_filtering));
|
||||||
Log_InfoFmt("Texture Filtering: {}", Settings::GetTextureFilterDisplayName(m_texture_filtering));
|
INFO_LOG("Dual-source blending: {}", m_supports_dual_source_blend ? "Supported" : "Not supported");
|
||||||
Log_InfoFmt("Dual-source blending: {}", m_supports_dual_source_blend ? "Supported" : "Not supported");
|
INFO_LOG("Clamping UVs: {}", m_clamp_uvs ? "YES" : "NO");
|
||||||
Log_InfoFmt("Clamping UVs: {}", m_clamp_uvs ? "YES" : "NO");
|
INFO_LOG("Depth buffer: {}", m_pgxp_depth_buffer ? "YES" : "NO");
|
||||||
Log_InfoFmt("Depth buffer: {}", m_pgxp_depth_buffer ? "YES" : "NO");
|
INFO_LOG("Downsampling: {}", Settings::GetDownsampleModeDisplayName(m_downsample_mode));
|
||||||
Log_InfoFmt("Downsampling: {}", Settings::GetDownsampleModeDisplayName(m_downsample_mode));
|
INFO_LOG("Wireframe rendering: {}", Settings::GetGPUWireframeModeDisplayName(m_wireframe_mode));
|
||||||
Log_InfoFmt("Wireframe rendering: {}", Settings::GetGPUWireframeModeDisplayName(m_wireframe_mode));
|
INFO_LOG("Using software renderer for readbacks: {}", m_sw_renderer ? "YES" : "NO");
|
||||||
Log_InfoFmt("Using software renderer for readbacks: {}", m_sw_renderer ? "YES" : "NO");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPU_HW::NeedsDepthBuffer() const
|
bool GPU_HW::NeedsDepthBuffer() const
|
||||||
|
@ -671,7 +670,7 @@ bool GPU_HW::CreateBuffers()
|
||||||
const u32 texture_height = VRAM_HEIGHT * m_resolution_scale;
|
const u32 texture_height = VRAM_HEIGHT * m_resolution_scale;
|
||||||
const u8 samples = static_cast<u8>(m_multisamples);
|
const u8 samples = static_cast<u8>(m_multisamples);
|
||||||
const bool needs_depth_buffer = NeedsDepthBuffer();
|
const bool needs_depth_buffer = NeedsDepthBuffer();
|
||||||
Log_DevFmt("Depth buffer is {}needed", needs_depth_buffer ? "" : "NOT ");
|
DEV_LOG("Depth buffer is {}needed", needs_depth_buffer ? "" : "NOT ");
|
||||||
|
|
||||||
// Needed for Metal resolve.
|
// Needed for Metal resolve.
|
||||||
const GPUTexture::Type read_texture_type = (g_gpu_device->GetRenderAPI() == RenderAPI::Metal && m_multisamples > 1) ?
|
const GPUTexture::Type read_texture_type = (g_gpu_device->GetRenderAPI() == RenderAPI::Metal && m_multisamples > 1) ?
|
||||||
|
@ -699,12 +698,12 @@ bool GPU_HW::CreateBuffers()
|
||||||
|
|
||||||
if (g_gpu_device->GetFeatures().memory_import)
|
if (g_gpu_device->GetFeatures().memory_import)
|
||||||
{
|
{
|
||||||
Log_DevPrint("Trying to import guest VRAM buffer for downloads...");
|
DEV_LOG("Trying to import guest VRAM buffer for downloads...");
|
||||||
m_vram_readback_download_texture = g_gpu_device->CreateDownloadTexture(
|
m_vram_readback_download_texture = g_gpu_device->CreateDownloadTexture(
|
||||||
m_vram_readback_texture->GetWidth(), m_vram_readback_texture->GetHeight(), m_vram_readback_texture->GetFormat(),
|
m_vram_readback_texture->GetWidth(), m_vram_readback_texture->GetHeight(), m_vram_readback_texture->GetFormat(),
|
||||||
g_vram, sizeof(g_vram), VRAM_WIDTH * sizeof(u16));
|
g_vram, sizeof(g_vram), VRAM_WIDTH * sizeof(u16));
|
||||||
if (!m_vram_readback_download_texture)
|
if (!m_vram_readback_download_texture)
|
||||||
Log_ErrorPrint("Failed to create imported readback buffer");
|
ERROR_LOG("Failed to create imported readback buffer");
|
||||||
}
|
}
|
||||||
if (!m_vram_readback_download_texture)
|
if (!m_vram_readback_download_texture)
|
||||||
{
|
{
|
||||||
|
@ -712,7 +711,7 @@ bool GPU_HW::CreateBuffers()
|
||||||
m_vram_readback_texture->GetWidth(), m_vram_readback_texture->GetHeight(), m_vram_readback_texture->GetFormat());
|
m_vram_readback_texture->GetWidth(), m_vram_readback_texture->GetHeight(), m_vram_readback_texture->GetFormat());
|
||||||
if (!m_vram_readback_download_texture)
|
if (!m_vram_readback_download_texture)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create readback download texture");
|
ERROR_LOG("Failed to create readback download texture");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -728,7 +727,7 @@ bool GPU_HW::CreateBuffers()
|
||||||
GL_OBJECT_NAME(m_vram_upload_buffer, "VRAM Upload Buffer");
|
GL_OBJECT_NAME(m_vram_upload_buffer, "VRAM Upload Buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Created HW framebuffer of {}x{}", texture_width, texture_height);
|
INFO_LOG("Created HW framebuffer of {}x{}", texture_width, texture_height);
|
||||||
|
|
||||||
if (m_downsample_mode == GPUDownsampleMode::Adaptive)
|
if (m_downsample_mode == GPUDownsampleMode::Adaptive)
|
||||||
m_downsample_scale_or_levels = GetAdaptiveDownsamplingMipLevels();
|
m_downsample_scale_or_levels = GetAdaptiveDownsamplingMipLevels();
|
||||||
|
@ -2033,9 +2032,9 @@ void GPU_HW::LoadVertices()
|
||||||
|
|
||||||
if (first_tri_culled)
|
if (first_tri_culled)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Culling too-large polygon: {},{} {},{} {},{}", native_vertex_positions[0][0],
|
DEBUG_LOG("Culling too-large polygon: {},{} {},{} {},{}", native_vertex_positions[0][0],
|
||||||
native_vertex_positions[0][1], native_vertex_positions[1][0], native_vertex_positions[1][1],
|
native_vertex_positions[0][1], native_vertex_positions[1][0], native_vertex_positions[1][1],
|
||||||
native_vertex_positions[2][0], native_vertex_positions[2][1]);
|
native_vertex_positions[2][0], native_vertex_positions[2][1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2066,9 +2065,9 @@ void GPU_HW::LoadVertices()
|
||||||
// Cull polygons which are too large.
|
// Cull polygons which are too large.
|
||||||
if ((max_x_123 - min_x_123) >= MAX_PRIMITIVE_WIDTH || (max_y_123 - min_y_123) >= MAX_PRIMITIVE_HEIGHT)
|
if ((max_x_123 - min_x_123) >= MAX_PRIMITIVE_WIDTH || (max_y_123 - min_y_123) >= MAX_PRIMITIVE_HEIGHT)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Culling too-large polygon (quad second half): {},{} {},{} {},{}", native_vertex_positions[2][0],
|
DEBUG_LOG("Culling too-large polygon (quad second half): {},{} {},{} {},{}", native_vertex_positions[2][0],
|
||||||
native_vertex_positions[2][1], native_vertex_positions[1][0], native_vertex_positions[1][1],
|
native_vertex_positions[2][1], native_vertex_positions[1][0], native_vertex_positions[1][1],
|
||||||
native_vertex_positions[0][0], native_vertex_positions[0][1]);
|
native_vertex_positions[0][0], native_vertex_positions[0][1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2148,7 +2147,7 @@ void GPU_HW::LoadVertices()
|
||||||
|
|
||||||
if (rectangle_width >= MAX_PRIMITIVE_WIDTH || rectangle_height >= MAX_PRIMITIVE_HEIGHT)
|
if (rectangle_width >= MAX_PRIMITIVE_WIDTH || rectangle_height >= MAX_PRIMITIVE_HEIGHT)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Culling too-large rectangle: {},{} {}x{}", pos_x, pos_y, rectangle_width, rectangle_height);
|
DEBUG_LOG("Culling too-large rectangle: {},{} {}x{}", pos_x, pos_y, rectangle_width, rectangle_height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2265,7 +2264,7 @@ void GPU_HW::LoadVertices()
|
||||||
const auto [min_y, max_y] = MinMax(start_y, end_y);
|
const auto [min_y, max_y] = MinMax(start_y, end_y);
|
||||||
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
|
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Culling too-large line: {},{} - {},{}", start_x, start_y, end_x, end_y);
|
DEBUG_LOG("Culling too-large line: {},{} - {},{}", start_x, start_y, end_x, end_y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2325,7 +2324,7 @@ void GPU_HW::LoadVertices()
|
||||||
const auto [min_y, max_y] = MinMax(start_y, end_y);
|
const auto [min_y, max_y] = MinMax(start_y, end_y);
|
||||||
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
|
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Culling too-large line: {},{} - {},{}", start_x, start_y, end_x, end_y);
|
DEBUG_LOG("Culling too-large line: {},{} - {},{}", start_x, start_y, end_x, end_y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2376,7 +2375,7 @@ bool GPU_HW::BlitVRAMReplacementTexture(const TextureReplacementTexture* tex, u3
|
||||||
{
|
{
|
||||||
if (!m_vram_replacement_texture->Update(0, 0, tex->GetWidth(), tex->GetHeight(), tex->GetPixels(), tex->GetPitch()))
|
if (!m_vram_replacement_texture->Update(0, 0, tex->GetWidth(), tex->GetHeight(), tex->GetPixels(), tex->GetPitch()))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Update {}x{} texture failed.", width, height);
|
ERROR_LOG("Update {}x{} texture failed.", width, height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2556,7 +2555,7 @@ void GPU_HW::EnsureVertexBufferSpaceForCurrentCommand()
|
||||||
|
|
||||||
void GPU_HW::ResetBatchVertexDepth()
|
void GPU_HW::ResetBatchVertexDepth()
|
||||||
{
|
{
|
||||||
Log_DevPrint("Resetting batch vertex depth");
|
DEV_LOG("Resetting batch vertex depth");
|
||||||
|
|
||||||
if (m_vram_depth_texture && !m_pgxp_depth_buffer)
|
if (m_vram_depth_texture && !m_pgxp_depth_buffer)
|
||||||
UpdateDepthBufferFromMaskBit();
|
UpdateDepthBufferFromMaskBit();
|
||||||
|
@ -2796,7 +2795,7 @@ void GPU_HW::UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data, b
|
||||||
GPUTexture::Format::R16U, data, width * sizeof(u16));
|
GPUTexture::Format::R16U, data, width * sizeof(u16));
|
||||||
if (!upload_texture)
|
if (!upload_texture)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to get {}x{} upload texture. Things are gonna break.", width, height);
|
ERROR_LOG("Failed to get {}x{} upload texture. Things are gonna break.", width, height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3343,7 +3342,7 @@ void GPU_HW::DownsampleFramebufferAdaptive(GPUTexture* source, u32 left, u32 top
|
||||||
GPUTexture::Type::RenderTarget, GPUTexture::Format::R8);
|
GPUTexture::Type::RenderTarget, GPUTexture::Format::R8);
|
||||||
if (!m_downsample_texture || !level_texture || !weight_texture)
|
if (!m_downsample_texture || !level_texture || !weight_texture)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to create {}x{} RTs for adaptive downsampling", width, height);
|
ERROR_LOG("Failed to create {}x{} RTs for adaptive downsampling", width, height);
|
||||||
SetDisplayTexture(source, left, top, width, height);
|
SetDisplayTexture(source, left, top, width, height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3453,7 +3452,7 @@ void GPU_HW::DownsampleFramebufferBoxFilter(GPUTexture* source, u32 left, u32 to
|
||||||
}
|
}
|
||||||
if (!m_downsample_texture)
|
if (!m_downsample_texture)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to create {}x{} RT for box downsampling", width, height);
|
ERROR_LOG("Failed to create {}x{} RT for box downsampling", width, height);
|
||||||
SetDisplayTexture(source, left, top, width, height);
|
SetDisplayTexture(source, left, top, width, height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ GPUTexture* GPU_SW::GetDisplayTexture(u32 width, u32 height, GPUTexture::Format
|
||||||
m_upload_texture =
|
m_upload_texture =
|
||||||
g_gpu_device->FetchTexture(width, height, 1, 1, 1, GPUTexture::Type::DynamicTexture, format, nullptr, 0);
|
g_gpu_device->FetchTexture(width, height, 1, 1, 1, GPUTexture::Type::DynamicTexture, format, nullptr, 0);
|
||||||
if (!m_upload_texture) [[unlikely]]
|
if (!m_upload_texture) [[unlikely]]
|
||||||
Log_ErrorFmt("Failed to create {}x{} {} texture", width, height, static_cast<u32>(format));
|
ERROR_LOG("Failed to create {}x{} {} texture", width, height, static_cast<u32>(format));
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_upload_texture.get();
|
return m_upload_texture.get();
|
||||||
|
@ -586,8 +586,8 @@ void GPU_SW::DispatchRenderCommand()
|
||||||
|
|
||||||
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
|
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Culling too-large polygon: {},{} {},{} {},{}", cmd->vertices[0].x, cmd->vertices[0].y,
|
DEBUG_LOG("Culling too-large polygon: {},{} {},{} {},{}", cmd->vertices[0].x, cmd->vertices[0].y,
|
||||||
cmd->vertices[1].x, cmd->vertices[1].y, cmd->vertices[2].x, cmd->vertices[2].y);
|
cmd->vertices[1].x, cmd->vertices[1].y, cmd->vertices[2].x, cmd->vertices[2].y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -607,9 +607,8 @@ void GPU_SW::DispatchRenderCommand()
|
||||||
// Cull polygons which are too large.
|
// Cull polygons which are too large.
|
||||||
if ((max_x_123 - min_x_123) >= MAX_PRIMITIVE_WIDTH || (max_y_123 - min_y_123) >= MAX_PRIMITIVE_HEIGHT)
|
if ((max_x_123 - min_x_123) >= MAX_PRIMITIVE_WIDTH || (max_y_123 - min_y_123) >= MAX_PRIMITIVE_HEIGHT)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Culling too-large polygon (quad second half): {},{} {},{} {},{}", cmd->vertices[2].x,
|
DEBUG_LOG("Culling too-large polygon (quad second half): {},{} {},{} {},{}", cmd->vertices[2].x,
|
||||||
cmd->vertices[2].y, cmd->vertices[1].x, cmd->vertices[1].y, cmd->vertices[0].x,
|
cmd->vertices[2].y, cmd->vertices[1].x, cmd->vertices[1].y, cmd->vertices[0].x, cmd->vertices[0].y);
|
||||||
cmd->vertices[0].y);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -667,7 +666,7 @@ void GPU_SW::DispatchRenderCommand()
|
||||||
|
|
||||||
if (cmd->width >= MAX_PRIMITIVE_WIDTH || cmd->height >= MAX_PRIMITIVE_HEIGHT)
|
if (cmd->width >= MAX_PRIMITIVE_WIDTH || cmd->height >= MAX_PRIMITIVE_HEIGHT)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Culling too-large rectangle: {},{} {}x{}", cmd->x, cmd->y, cmd->width, cmd->height);
|
DEBUG_LOG("Culling too-large rectangle: {},{} {}x{}", cmd->x, cmd->y, cmd->width, cmd->height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -724,8 +723,8 @@ void GPU_SW::DispatchRenderCommand()
|
||||||
const auto [min_y, max_y] = MinMax(cmd->vertices[0].y, cmd->vertices[1].y);
|
const auto [min_y, max_y] = MinMax(cmd->vertices[0].y, cmd->vertices[1].y);
|
||||||
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
|
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Culling too-large line: {},{} - {},{}", cmd->vertices[0].y, cmd->vertices[0].y,
|
DEBUG_LOG("Culling too-large line: {},{} - {},{}", cmd->vertices[0].y, cmd->vertices[0].y, cmd->vertices[1].x,
|
||||||
cmd->vertices[1].x, cmd->vertices[1].y);
|
cmd->vertices[1].y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -759,8 +758,8 @@ void GPU_SW::DispatchRenderCommand()
|
||||||
const auto [min_y, max_y] = MinMax(cmd->vertices[i - 1].y, cmd->vertices[i].y);
|
const auto [min_y, max_y] = MinMax(cmd->vertices[i - 1].y, cmd->vertices[i].y);
|
||||||
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
|
if ((max_x - min_x) >= MAX_PRIMITIVE_WIDTH || (max_y - min_y) >= MAX_PRIMITIVE_HEIGHT)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Culling too-large line: {},{} - {},{}", cmd->vertices[i - 1].x, cmd->vertices[i - 1].y,
|
DEBUG_LOG("Culling too-large line: {},{} - {},{}", cmd->vertices[i - 1].x, cmd->vertices[i - 1].y,
|
||||||
cmd->vertices[i].x, cmd->vertices[i].y);
|
cmd->vertices[i].x, cmd->vertices[i].y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -217,7 +217,7 @@ void GunCon::UpdatePosition()
|
||||||
!g_gpu->ConvertDisplayCoordinatesToBeamTicksAndLines(display_x, display_y, m_x_scale, &tick, &line) ||
|
!g_gpu->ConvertDisplayCoordinatesToBeamTicksAndLines(display_x, display_y, m_x_scale, &tick, &line) ||
|
||||||
m_shoot_offscreen)
|
m_shoot_offscreen)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Lightgun out of range for window coordinates {:.0f},{:.0f}", window_x, window_y);
|
DEBUG_LOG("Lightgun out of range for window coordinates {:.0f},{:.0f}", window_x, window_y);
|
||||||
m_position_x = 0x01;
|
m_position_x = 0x01;
|
||||||
m_position_y = 0x0A;
|
m_position_y = 0x0A;
|
||||||
return;
|
return;
|
||||||
|
@ -227,8 +227,8 @@ void GunCon::UpdatePosition()
|
||||||
const double divider = static_cast<double>(g_gpu->GetCRTCFrequency()) / 8000000.0;
|
const double divider = static_cast<double>(g_gpu->GetCRTCFrequency()) / 8000000.0;
|
||||||
m_position_x = static_cast<u16>(static_cast<float>(tick) / static_cast<float>(divider));
|
m_position_x = static_cast<u16>(static_cast<float>(tick) / static_cast<float>(divider));
|
||||||
m_position_y = static_cast<u16>(line);
|
m_position_y = static_cast<u16>(line);
|
||||||
Log_DebugFmt("Lightgun window coordinates {:.0f},{:.0f} -> tick {} line {} 8mhz ticks {}", display_x, display_y, tick,
|
DEBUG_LOG("Lightgun window coordinates {:.0f},{:.0f} -> tick {} line {} 8mhz ticks {}", display_x, display_y, tick,
|
||||||
line, m_position_x);
|
line, m_position_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<float, float> GunCon::GetAbsolutePositionFromRelativeAxes() const
|
std::pair<float, float> GunCon::GetAbsolutePositionFromRelativeAxes() const
|
||||||
|
|
|
@ -264,7 +264,7 @@ bool Host::CreateGPUDevice(RenderAPI api, Error* error)
|
||||||
{
|
{
|
||||||
DebugAssert(!g_gpu_device);
|
DebugAssert(!g_gpu_device);
|
||||||
|
|
||||||
Log_InfoFmt("Trying to create a {} GPU device...", GPUDevice::RenderAPIToString(api));
|
INFO_LOG("Trying to create a {} GPU device...", GPUDevice::RenderAPIToString(api));
|
||||||
g_gpu_device = GPUDevice::CreateDeviceForAPI(api);
|
g_gpu_device = GPUDevice::CreateDeviceForAPI(api);
|
||||||
|
|
||||||
std::optional<bool> exclusive_fullscreen_control;
|
std::optional<bool> exclusive_fullscreen_control;
|
||||||
|
@ -293,7 +293,7 @@ bool Host::CreateGPUDevice(RenderAPI api, Error* error)
|
||||||
g_settings.gpu_threaded_presentation, exclusive_fullscreen_control,
|
g_settings.gpu_threaded_presentation, exclusive_fullscreen_control,
|
||||||
static_cast<GPUDevice::FeatureMask>(disabled_features), &create_error))
|
static_cast<GPUDevice::FeatureMask>(disabled_features), &create_error))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to create GPU device: {}", create_error.GetDescription());
|
ERROR_LOG("Failed to create GPU device: {}", create_error.GetDescription());
|
||||||
if (g_gpu_device)
|
if (g_gpu_device)
|
||||||
g_gpu_device->Destroy();
|
g_gpu_device->Destroy();
|
||||||
g_gpu_device.reset();
|
g_gpu_device.reset();
|
||||||
|
@ -309,7 +309,7 @@ bool Host::CreateGPUDevice(RenderAPI api, Error* error)
|
||||||
if (!ImGuiManager::Initialize(g_settings.display_osd_scale / 100.0f, g_settings.display_show_osd_messages,
|
if (!ImGuiManager::Initialize(g_settings.display_osd_scale / 100.0f, g_settings.display_show_osd_messages,
|
||||||
&create_error))
|
&create_error))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to initialize ImGuiManager: {}", create_error.GetDescription());
|
ERROR_LOG("Failed to initialize ImGuiManager: {}", create_error.GetDescription());
|
||||||
Error::SetStringFmt(error, "Failed to initialize ImGuiManager: {}", create_error.GetDescription());
|
Error::SetStringFmt(error, "Failed to initialize ImGuiManager: {}", create_error.GetDescription());
|
||||||
g_gpu_device->Destroy();
|
g_gpu_device->Destroy();
|
||||||
g_gpu_device.reset();
|
g_gpu_device.reset();
|
||||||
|
@ -348,7 +348,7 @@ void Host::ResizeDisplayWindow(s32 width, s32 height, float scale)
|
||||||
if (!g_gpu_device)
|
if (!g_gpu_device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_DevFmt("Display window resized to {}x{}", width, height);
|
DEV_LOG("Display window resized to {}x{}", width, height);
|
||||||
|
|
||||||
g_gpu_device->ResizeWindow(width, height, scale);
|
g_gpu_device->ResizeWindow(width, height, scale);
|
||||||
ImGuiManager::WindowResized();
|
ImGuiManager::WindowResized();
|
||||||
|
@ -377,7 +377,7 @@ void Host::ReleaseGPUDevice()
|
||||||
FullscreenUI::Shutdown();
|
FullscreenUI::Shutdown();
|
||||||
ImGuiManager::Shutdown();
|
ImGuiManager::Shutdown();
|
||||||
|
|
||||||
Log_InfoFmt("Destroying {} GPU device...", GPUDevice::RenderAPIToString(g_gpu_device->GetRenderAPI()));
|
INFO_LOG("Destroying {} GPU device...", GPUDevice::RenderAPIToString(g_gpu_device->GetRenderAPI()));
|
||||||
g_gpu_device->Destroy();
|
g_gpu_device->Destroy();
|
||||||
g_gpu_device.reset();
|
g_gpu_device.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,37 +75,37 @@ void HostInterfaceProgressCallback::Redraw(bool force)
|
||||||
|
|
||||||
void HostInterfaceProgressCallback::DisplayError(const char* message)
|
void HostInterfaceProgressCallback::DisplayError(const char* message)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint(message);
|
ERROR_LOG(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostInterfaceProgressCallback::DisplayWarning(const char* message)
|
void HostInterfaceProgressCallback::DisplayWarning(const char* message)
|
||||||
{
|
{
|
||||||
Log_WarningPrint(message);
|
WARNING_LOG(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostInterfaceProgressCallback::DisplayInformation(const char* message)
|
void HostInterfaceProgressCallback::DisplayInformation(const char* message)
|
||||||
{
|
{
|
||||||
Log_InfoPrint(message);
|
INFO_LOG(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostInterfaceProgressCallback::DisplayDebugMessage(const char* message)
|
void HostInterfaceProgressCallback::DisplayDebugMessage(const char* message)
|
||||||
{
|
{
|
||||||
Log_DevPrint(message);
|
DEV_LOG(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostInterfaceProgressCallback::ModalError(const char* message)
|
void HostInterfaceProgressCallback::ModalError(const char* message)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint(message);
|
ERROR_LOG(message);
|
||||||
Host::ReportErrorAsync("Error", message);
|
Host::ReportErrorAsync("Error", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HostInterfaceProgressCallback::ModalConfirmation(const char* message)
|
bool HostInterfaceProgressCallback::ModalConfirmation(const char* message)
|
||||||
{
|
{
|
||||||
Log_InfoPrint(message);
|
INFO_LOG(message);
|
||||||
return Host::ConfirmMessage("Confirm", message);
|
return Host::ConfirmMessage("Confirm", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostInterfaceProgressCallback::ModalInformation(const char* message)
|
void HostInterfaceProgressCallback::ModalInformation(const char* message)
|
||||||
{
|
{
|
||||||
Log_InfoPrint(message);
|
INFO_LOG(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ void Host::DisplayLoadingScreen(const char* message, int progress_min /*= -1*/,
|
||||||
{
|
{
|
||||||
if (!g_gpu_device)
|
if (!g_gpu_device)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("{}: {}/{}", message, progress_value, progress_max);
|
INFO_LOG("{}: {}/{}", message, progress_value, progress_max);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,14 +187,14 @@ void Host::DisplayLoadingScreen(const char* message, int progress_min /*= -1*/,
|
||||||
|
|
||||||
ImGui::ProgressBar(static_cast<float>(progress_value) / static_cast<float>(progress_max - progress_min),
|
ImGui::ProgressBar(static_cast<float>(progress_value) / static_cast<float>(progress_max - progress_min),
|
||||||
ImVec2(-1.0f, 0.0f), "");
|
ImVec2(-1.0f, 0.0f), "");
|
||||||
Log_InfoFmt("{}: {}", message, buf);
|
INFO_LOG("{}: {}", message, buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const ImVec2 text_size(ImGui::CalcTextSize(message));
|
const ImVec2 text_size(ImGui::CalcTextSize(message));
|
||||||
ImGui::SetCursorPosX((width - text_size.x) / 2.0f);
|
ImGui::SetCursorPosX((width - text_size.x) / 2.0f);
|
||||||
ImGui::TextUnformatted(message);
|
ImGui::TextUnformatted(message);
|
||||||
Log_InfoPrint(message);
|
INFO_LOG(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
@ -927,7 +927,7 @@ void SaveStateSelectorUI::InitializeListEntry(ListEntry* li, ExtendedSaveStateIn
|
||||||
ssi->screenshot_width, ssi->screenshot_height, 1, 1, 1, GPUTexture::Type::Texture, GPUTexture::Format::RGBA8,
|
ssi->screenshot_width, ssi->screenshot_height, 1, 1, 1, GPUTexture::Type::Texture, GPUTexture::Format::RGBA8,
|
||||||
ssi->screenshot_data.data(), sizeof(u32) * ssi->screenshot_width);
|
ssi->screenshot_data.data(), sizeof(u32) * ssi->screenshot_width);
|
||||||
if (!li->preview_texture) [[unlikely]]
|
if (!li->preview_texture) [[unlikely]]
|
||||||
Log_ErrorPrint("Failed to upload save state image to GPU");
|
ERROR_LOG("Failed to upload save state image to GPU");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,9 +53,9 @@ void InterruptController::SetLineState(IRQ irq, bool state)
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (!(prev_state & bit) && state)
|
if (!(prev_state & bit) && state)
|
||||||
Log_DebugFmt("{} IRQ triggered", s_irq_names[static_cast<size_t>(irq)]);
|
DEBUG_LOG("{} IRQ triggered", s_irq_names[static_cast<size_t>(irq)]);
|
||||||
else if ((prev_state & bit) && !state)
|
else if ((prev_state & bit) && !state)
|
||||||
Log_DebugFmt("{} IRQ line inactive", s_irq_names[static_cast<size_t>(irq)]);
|
DEBUG_LOG("{} IRQ line inactive", s_irq_names[static_cast<size_t>(irq)]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s_interrupt_status_register |= (state ? (prev_state ^ s_interrupt_line_state) : 0u) & s_interrupt_line_state;
|
s_interrupt_status_register |= (state ? (prev_state ^ s_interrupt_line_state) : 0u) & s_interrupt_line_state;
|
||||||
|
@ -72,8 +72,8 @@ u32 InterruptController::ReadRegister(u32 offset)
|
||||||
case 0x04: // I_MASK
|
case 0x04: // I_MASK
|
||||||
return s_interrupt_mask_register;
|
return s_interrupt_mask_register;
|
||||||
|
|
||||||
default: [[unlikely]]
|
[[unlikely]] default:
|
||||||
Log_ErrorFmt("Invalid read at offset 0x{:08X}", offset);
|
ERROR_LOG("Invalid read at offset 0x{:08X}", offset);
|
||||||
return UINT32_C(0xFFFFFFFF);
|
return UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ void InterruptController::WriteRegister(u32 offset, u32 value)
|
||||||
for (u32 i = 0; i < static_cast<u32>(IRQ::MaxCount); i++)
|
for (u32 i = 0; i < static_cast<u32>(IRQ::MaxCount); i++)
|
||||||
{
|
{
|
||||||
if (cleared_bits & (1u << i))
|
if (cleared_bits & (1u << i))
|
||||||
Log_DebugFmt("{} IRQ cleared", s_irq_names[i]);
|
DEBUG_LOG("{} IRQ cleared", s_irq_names[i]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -100,14 +100,14 @@ void InterruptController::WriteRegister(u32 offset, u32 value)
|
||||||
|
|
||||||
case 0x04: // I_MASK
|
case 0x04: // I_MASK
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Interrupt mask <- 0x{:08X}", value);
|
DEBUG_LOG("Interrupt mask <- 0x{:08X}", value);
|
||||||
s_interrupt_mask_register = value & REGISTER_WRITE_MASK;
|
s_interrupt_mask_register = value & REGISTER_WRITE_MASK;
|
||||||
UpdateCPUInterruptRequest();
|
UpdateCPUInterruptRequest();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: [[unlikely]]
|
default:
|
||||||
Log_ErrorFmt("Invalid write at offset 0x{:08X}", offset);
|
[[unlikely]] ERROR_LOG("Invalid write at offset 0x{:08X}", offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ void Justifier::UpdatePosition()
|
||||||
!g_gpu->ConvertDisplayCoordinatesToBeamTicksAndLines(display_x, display_y, m_x_scale, &tick, &line) ||
|
!g_gpu->ConvertDisplayCoordinatesToBeamTicksAndLines(display_x, display_y, m_x_scale, &tick, &line) ||
|
||||||
m_shoot_offscreen)
|
m_shoot_offscreen)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Lightgun out of range for window coordinates {:.0f},{:.0f}", window_x, window_y);
|
DEV_LOG("Lightgun out of range for window coordinates {:.0f},{:.0f}", window_x, window_y);
|
||||||
m_position_valid = false;
|
m_position_valid = false;
|
||||||
UpdateIRQEvent();
|
UpdateIRQEvent();
|
||||||
return;
|
return;
|
||||||
|
@ -236,8 +236,8 @@ void Justifier::UpdatePosition()
|
||||||
static_cast<s32>(g_gpu->GetCRTCActiveStartLine()),
|
static_cast<s32>(g_gpu->GetCRTCActiveStartLine()),
|
||||||
static_cast<s32>(g_gpu->GetCRTCActiveEndLine())));
|
static_cast<s32>(g_gpu->GetCRTCActiveEndLine())));
|
||||||
|
|
||||||
Log_DevFmt("Lightgun window coordinates {},{} -> dpy {},{} -> tick {} line {} [{}-{}]", window_x, window_y, display_x,
|
DEV_LOG("Lightgun window coordinates {},{} -> dpy {},{} -> tick {} line {} [{}-{}]", window_x, window_y, display_x,
|
||||||
display_y, tick, line, m_irq_first_line, m_irq_last_line);
|
display_y, tick, line, m_irq_first_line, m_irq_last_line);
|
||||||
|
|
||||||
UpdateIRQEvent();
|
UpdateIRQEvent();
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ void Justifier::UpdateIRQEvent()
|
||||||
target_line = current_line + 1;
|
target_line = current_line + 1;
|
||||||
|
|
||||||
const TickCount ticks_until_pos = g_gpu->GetSystemTicksUntilTicksAndLine(m_irq_tick, target_line);
|
const TickCount ticks_until_pos = g_gpu->GetSystemTicksUntilTicksAndLine(m_irq_tick, target_line);
|
||||||
Log_DebugFmt("Triggering IRQ in {} ticks @ tick {} line {}", ticks_until_pos, m_irq_tick, target_line);
|
DEBUG_LOG("Triggering IRQ in {} ticks @ tick {} line {}", ticks_until_pos, m_irq_tick, target_line);
|
||||||
m_irq_event->Schedule(ticks_until_pos);
|
m_irq_event->Schedule(ticks_until_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,13 +272,13 @@ void Justifier::IRQEvent()
|
||||||
|
|
||||||
const u32 expected_line = (s_irq_current_line == m_irq_last_line) ? m_irq_first_line : (s_irq_current_line + 1);
|
const u32 expected_line = (s_irq_current_line == m_irq_last_line) ? m_irq_first_line : (s_irq_current_line + 1);
|
||||||
if (line < expected_line)
|
if (line < expected_line)
|
||||||
Log_WarningFmt("IRQ event fired {} lines too early", expected_line - line);
|
WARNING_LOG("IRQ event fired {} lines too early", expected_line - line);
|
||||||
else if (line > expected_line)
|
else if (line > expected_line)
|
||||||
Log_WarningFmt("IRQ event fired {} lines too late", line - expected_line);
|
WARNING_LOG("IRQ event fired {} lines too late", line - expected_line);
|
||||||
if (ticks < m_irq_tick)
|
if (ticks < m_irq_tick)
|
||||||
Log_WarningFmt("IRQ event fired {} ticks too early", m_irq_tick - ticks);
|
WARNING_LOG("IRQ event fired {} ticks too early", m_irq_tick - ticks);
|
||||||
else if (ticks > m_irq_tick)
|
else if (ticks > m_irq_tick)
|
||||||
Log_WarningFmt("IRQ event fired {} ticks too late", ticks - m_irq_tick);
|
WARNING_LOG("IRQ event fired {} ticks too late", ticks - m_irq_tick);
|
||||||
s_irq_current_line = line;
|
s_irq_current_line = line;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -202,13 +202,13 @@ u32 MDEC::ReadRegister(u32 offset)
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
Log_TraceFmt("MDEC status register -> 0x{:08X}", s_status.bits);
|
TRACE_LOG("MDEC status register -> 0x{:08X}", s_status.bits);
|
||||||
return s_status.bits;
|
return s_status.bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[unlikely]] default:
|
[[unlikely]] default:
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unknown MDEC register read: 0x{:08X}", offset);
|
ERROR_LOG("Unknown MDEC register read: 0x{:08X}", offset);
|
||||||
return UINT32_C(0xFFFFFFFF);
|
return UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ void MDEC::WriteRegister(u32 offset, u32 value)
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("MDEC control register <- 0x{:08X}", value);
|
DEBUG_LOG("MDEC control register <- 0x{:08X}", value);
|
||||||
|
|
||||||
const ControlRegister cr{value};
|
const ControlRegister cr{value};
|
||||||
if (cr.reset)
|
if (cr.reset)
|
||||||
|
@ -240,7 +240,7 @@ void MDEC::WriteRegister(u32 offset, u32 value)
|
||||||
|
|
||||||
[[unlikely]] default:
|
[[unlikely]] default:
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unknown MDEC register write: 0x{:08X} <- 0x{:08X}", offset, value);
|
ERROR_LOG("Unknown MDEC register write: 0x{:08X} <- 0x{:08X}", offset, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ void MDEC::DMARead(u32* words, u32 word_count)
|
||||||
{
|
{
|
||||||
if (s_data_out_fifo.GetSize() < word_count) [[unlikely]]
|
if (s_data_out_fifo.GetSize() < word_count) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Insufficient data in output FIFO (requested {}, have {})", word_count, s_data_out_fifo.GetSize());
|
WARNING_LOG("Insufficient data in output FIFO (requested {}, have {})", word_count, s_data_out_fifo.GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 words_to_read = std::min(word_count, s_data_out_fifo.GetSize());
|
const u32 words_to_read = std::min(word_count, s_data_out_fifo.GetSize());
|
||||||
|
@ -261,7 +261,7 @@ void MDEC::DMARead(u32* words, u32 word_count)
|
||||||
word_count -= words_to_read;
|
word_count -= words_to_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("DMA read complete, {} bytes left", s_data_out_fifo.GetSize() * sizeof(u32));
|
DEBUG_LOG("DMA read complete, {} bytes left", s_data_out_fifo.GetSize() * sizeof(u32));
|
||||||
if (s_data_out_fifo.IsEmpty())
|
if (s_data_out_fifo.IsEmpty())
|
||||||
Execute();
|
Execute();
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ void MDEC::DMAWrite(const u32* words, u32 word_count)
|
||||||
{
|
{
|
||||||
if (s_data_in_fifo.GetSpace() < (word_count * 2)) [[unlikely]]
|
if (s_data_in_fifo.GetSpace() < (word_count * 2)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Input FIFO overflow (writing {}, space {})", word_count * 2, s_data_in_fifo.GetSpace());
|
WARNING_LOG("Input FIFO overflow (writing {}, space {})", word_count * 2, s_data_in_fifo.GetSpace());
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 halfwords_to_write = std::min(word_count * 2, s_data_in_fifo.GetSpace() & ~u32(2));
|
const u32 halfwords_to_write = std::min(word_count * 2, s_data_in_fifo.GetSpace() & ~u32(2));
|
||||||
|
@ -333,12 +333,12 @@ u32 MDEC::ReadDataRegister()
|
||||||
// Stall the CPU until we're done processing.
|
// Stall the CPU until we're done processing.
|
||||||
if (HasPendingBlockCopyOut())
|
if (HasPendingBlockCopyOut())
|
||||||
{
|
{
|
||||||
Log_DevPrint("MDEC data out FIFO empty on read - stalling CPU");
|
DEV_LOG("MDEC data out FIFO empty on read - stalling CPU");
|
||||||
CPU::AddPendingTicks(s_block_copy_out_event->GetTicksUntilNextExecution());
|
CPU::AddPendingTicks(s_block_copy_out_event->GetTicksUntilNextExecution());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningPrint("MDEC data out FIFO empty on read and no data processing");
|
WARNING_LOG("MDEC data out FIFO empty on read and no data processing");
|
||||||
return UINT32_C(0xFFFFFFFF);
|
return UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ u32 MDEC::ReadDataRegister()
|
||||||
|
|
||||||
void MDEC::WriteCommandRegister(u32 value)
|
void MDEC::WriteCommandRegister(u32 value)
|
||||||
{
|
{
|
||||||
Log_TraceFmt("MDEC command/data register <- 0x{:08X}", value);
|
TRACE_LOG("MDEC command/data register <- 0x{:08X}", value);
|
||||||
|
|
||||||
s_data_in_fifo.Push(Truncate16(value));
|
s_data_in_fifo.Push(Truncate16(value));
|
||||||
s_data_in_fifo.Push(Truncate16(value >> 16));
|
s_data_in_fifo.Push(Truncate16(value >> 16));
|
||||||
|
@ -401,14 +401,14 @@ void MDEC::Execute()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
[[unlikely]] Log_DevFmt("Invalid MDEC command 0x{:08X}", cw.bits);
|
[[unlikely]] DEV_LOG("Invalid MDEC command 0x{:08X}", cw.bits);
|
||||||
num_words = cw.parameter_word_count.GetValue();
|
num_words = cw.parameter_word_count.GetValue();
|
||||||
new_state = State::NoCommand;
|
new_state = State::NoCommand;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("MDEC command: 0x{:08X} ({}, {} words in parameter, {} expected)", cw.bits,
|
DEBUG_LOG("MDEC command: 0x{:08X} ({}, {} words in parameter, {} expected)", cw.bits,
|
||||||
static_cast<u8>(cw.command.GetValue()), cw.parameter_word_count.GetValue(), num_words);
|
static_cast<u8>(cw.command.GetValue()), cw.parameter_word_count.GetValue(), num_words);
|
||||||
|
|
||||||
s_remaining_halfwords = num_words * 2;
|
s_remaining_halfwords = num_words * 2;
|
||||||
s_state = new_state;
|
s_state = new_state;
|
||||||
|
@ -508,7 +508,7 @@ bool MDEC::DecodeMonoMacroblock()
|
||||||
|
|
||||||
IDCT(s_blocks[0].data());
|
IDCT(s_blocks[0].data());
|
||||||
|
|
||||||
Log_DebugFmt("Decoded mono macroblock, {} words remaining", s_remaining_halfwords / 2);
|
DEBUG_LOG("Decoded mono macroblock, {} words remaining", s_remaining_halfwords / 2);
|
||||||
ResetDecoder();
|
ResetDecoder();
|
||||||
s_state = State::WritingMacroblock;
|
s_state = State::WritingMacroblock;
|
||||||
|
|
||||||
|
@ -534,7 +534,7 @@ bool MDEC::DecodeColoredMacroblock()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// done decoding
|
// done decoding
|
||||||
Log_DebugFmt("Decoded colored macroblock, {} words remaining", s_remaining_halfwords / 2);
|
DEBUG_LOG("Decoded colored macroblock, {} words remaining", s_remaining_halfwords / 2);
|
||||||
ResetDecoder();
|
ResetDecoder();
|
||||||
s_state = State::WritingMacroblock;
|
s_state = State::WritingMacroblock;
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ bool MDEC::DecodeColoredMacroblock()
|
||||||
void MDEC::ScheduleBlockCopyOut(TickCount ticks)
|
void MDEC::ScheduleBlockCopyOut(TickCount ticks)
|
||||||
{
|
{
|
||||||
DebugAssert(!HasPendingBlockCopyOut());
|
DebugAssert(!HasPendingBlockCopyOut());
|
||||||
Log_DebugFmt("Scheduling block copy out in {} ticks", ticks);
|
DEBUG_LOG("Scheduling block copy out in {} ticks", ticks);
|
||||||
|
|
||||||
s_block_copy_out_event->SetIntervalAndSchedule(ticks);
|
s_block_copy_out_event->SetIntervalAndSchedule(ticks);
|
||||||
}
|
}
|
||||||
|
@ -685,8 +685,8 @@ void MDEC::CopyOutBlock(void* param, TickCount ticks, TickCount ticks_late)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("Block copied out, fifo size = {} ({} bytes)", s_data_out_fifo.GetSize(),
|
DEBUG_LOG("Block copied out, fifo size = {} ({} bytes)", s_data_out_fifo.GetSize(),
|
||||||
s_data_out_fifo.GetSize() * sizeof(u32));
|
s_data_out_fifo.GetSize() * sizeof(u32));
|
||||||
|
|
||||||
// if we've copied out all blocks, command is complete
|
// if we've copied out all blocks, command is complete
|
||||||
s_state = (s_remaining_halfwords == 0) ? State::Idle : State::DecodingMacroblock;
|
s_state = (s_remaining_halfwords == 0) ? State::Idle : State::DecodingMacroblock;
|
||||||
|
|
|
@ -143,7 +143,7 @@ bool MemoryCard::Transfer(const u8 data_in, u8* data_out)
|
||||||
const u8 bits = m_data[ZeroExtend32(m_address) * MemoryCardImage::FRAME_SIZE + m_sector_offset];
|
const u8 bits = m_data[ZeroExtend32(m_address) * MemoryCardImage::FRAME_SIZE + m_sector_offset];
|
||||||
if (m_sector_offset == 0)
|
if (m_sector_offset == 0)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Reading memory card sector {}", m_address);
|
DEV_LOG("Reading memory card sector {}", m_address);
|
||||||
m_checksum = Truncate8(m_address >> 8) ^ Truncate8(m_address) ^ bits;
|
m_checksum = Truncate8(m_address >> 8) ^ Truncate8(m_address) ^ bits;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -177,7 +177,7 @@ bool MemoryCard::Transfer(const u8 data_in, u8* data_out)
|
||||||
{
|
{
|
||||||
if (m_sector_offset == 0)
|
if (m_sector_offset == 0)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Writing memory card sector {}", m_address);
|
INFO_LOG("Writing memory card sector {}", m_address);
|
||||||
m_checksum = Truncate8(m_address >> 8) ^ Truncate8(m_address) ^ data_in;
|
m_checksum = Truncate8(m_address >> 8) ^ Truncate8(m_address) ^ data_in;
|
||||||
m_FLAG.no_write_yet = false;
|
m_FLAG.no_write_yet = false;
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ bool MemoryCard::Transfer(const u8 data_in, u8* data_out)
|
||||||
default:
|
default:
|
||||||
[[unlikely]]
|
[[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid command 0x{:02X}", data_in);
|
ERROR_LOG("Invalid command 0x{:02X}", data_in);
|
||||||
*data_out = m_FLAG.bits;
|
*data_out = m_FLAG.bits;
|
||||||
ack = false;
|
ack = false;
|
||||||
m_state = State::Idle;
|
m_state = State::Idle;
|
||||||
|
@ -265,8 +265,8 @@ bool MemoryCard::Transfer(const u8 data_in, u8* data_out)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("Transfer, old_state={}, new_state={}, data_in=0x{:02X}, data_out=0x{:02X}, ack={}",
|
DEBUG_LOG("Transfer, old_state={}, new_state={}, data_in=0x{:02X}, data_out=0x{:02X}, ack={}",
|
||||||
static_cast<u32>(old_state), static_cast<u32>(m_state), data_in, *data_out, ack ? "true" : "false");
|
static_cast<u32>(old_state), static_cast<u32>(m_state), data_in, *data_out, ack ? "true" : "false");
|
||||||
m_last_byte = data_in;
|
m_last_byte = data_in;
|
||||||
return ack;
|
return ack;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ std::unique_ptr<MemoryCard> MemoryCard::Open(std::string_view filename)
|
||||||
mc->m_filename = filename;
|
mc->m_filename = filename;
|
||||||
if (!mc->LoadFromFile())
|
if (!mc->LoadFromFile())
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Memory card at '{}' could not be read, formatting.", mc->m_filename);
|
INFO_LOG("Memory card at '{}' could not be read, formatting.", mc->m_filename);
|
||||||
Host::AddIconOSDMessage(fmt::format("memory_card_{}", filename), ICON_FA_SD_CARD,
|
Host::AddIconOSDMessage(fmt::format("memory_card_{}", filename), ICON_FA_SD_CARD,
|
||||||
fmt::format(TRANSLATE_FS("OSDMessage", "Memory card '{}' could not be read, formatting."),
|
fmt::format(TRANSLATE_FS("OSDMessage", "Memory card '{}' could not be read, formatting."),
|
||||||
Path::GetFileName(filename), Host::OSD_INFO_DURATION));
|
Path::GetFileName(filename), Host::OSD_INFO_DURATION));
|
||||||
|
|
|
@ -110,11 +110,11 @@ bool MemoryCardImage::LoadFromFile(DataArray* data, const char* filename)
|
||||||
const size_t num_read = stream->Read(data->data(), DATA_SIZE);
|
const size_t num_read = stream->Read(data->data(), DATA_SIZE);
|
||||||
if (num_read != DATA_SIZE)
|
if (num_read != DATA_SIZE)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Only read {} of {} sectors from '{}'", num_read / FRAME_SIZE, static_cast<u32>(NUM_FRAMES), filename);
|
ERROR_LOG("Only read {} of {} sectors from '{}'", num_read / FRAME_SIZE, static_cast<u32>(NUM_FRAMES), filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_VerboseFmt("Loaded memory card from {}", filename);
|
VERBOSE_LOG("Loaded memory card from {}", filename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,18 +125,18 @@ bool MemoryCardImage::SaveToFile(const DataArray& data, const char* filename)
|
||||||
BYTESTREAM_OPEN_ATOMIC_UPDATE | BYTESTREAM_OPEN_STREAMED);
|
BYTESTREAM_OPEN_ATOMIC_UPDATE | BYTESTREAM_OPEN_STREAMED);
|
||||||
if (!stream)
|
if (!stream)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open '{}' for writing.", filename);
|
ERROR_LOG("Failed to open '{}' for writing.", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stream->Write2(data.data(), DATA_SIZE) || !stream->Commit())
|
if (!stream->Write2(data.data(), DATA_SIZE) || !stream->Commit())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to write sectors to '{}'", filename);
|
ERROR_LOG("Failed to write sectors to '{}'", filename);
|
||||||
stream->Discard();
|
stream->Discard();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_VerboseFmt("Saved memory card to '{}'", filename);
|
VERBOSE_LOG("Saved memory card to '{}'", filename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ std::vector<MemoryCardImage::FileInfo> MemoryCardImage::EnumerateFiles(const Dat
|
||||||
if (fi.num_blocks == FRAMES_PER_BLOCK)
|
if (fi.num_blocks == FRAMES_PER_BLOCK)
|
||||||
{
|
{
|
||||||
// invalid
|
// invalid
|
||||||
Log_WarningFmt("Invalid block chain in block {}", dir_frame);
|
WARNING_LOG("Invalid block chain in block {}", dir_frame);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ std::vector<MemoryCardImage::FileInfo> MemoryCardImage::EnumerateFiles(const Dat
|
||||||
num_icon_frames = 3;
|
num_icon_frames = 3;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Unknown icon flag 0x{:02X}", tf->icon_flag);
|
WARNING_LOG("Unknown icon flag 0x{:02X}", tf->icon_flag);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,13 +385,13 @@ bool MemoryCardImage::WriteFile(DataArray* data, std::string_view filename, cons
|
||||||
std::memset(data_block + size_to_copy, 0, size_to_zero);
|
std::memset(data_block + size_to_copy, 0, size_to_zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Wrote {} byte ({} block) file to memory card", buffer.size(), num_blocks);
|
INFO_LOG("Wrote {} byte ({} block) file to memory card", buffer.size(), num_blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MemoryCardImage::DeleteFile(DataArray* data, const FileInfo& fi, bool clear_sectors)
|
bool MemoryCardImage::DeleteFile(DataArray* data, const FileInfo& fi, bool clear_sectors)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Deleting '{}' from memory card ({} blocks)", fi.filename, fi.num_blocks);
|
INFO_LOG("Deleting '{}' from memory card ({} blocks)", fi.filename, fi.num_blocks);
|
||||||
|
|
||||||
u32 block_number = fi.first_block;
|
u32 block_number = fi.first_block;
|
||||||
for (u32 i = 0; i < fi.num_blocks && (block_number > 0 && block_number < NUM_BLOCKS); i++)
|
for (u32 i = 0; i < fi.num_blocks && (block_number > 0 && block_number < NUM_BLOCKS); i++)
|
||||||
|
@ -424,11 +424,11 @@ bool MemoryCardImage::UndeleteFile(DataArray* data, const FileInfo& fi)
|
||||||
{
|
{
|
||||||
if (!fi.deleted)
|
if (!fi.deleted)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("File '{}' is not deleted", fi.filename);
|
ERROR_LOG("File '{}' is not deleted", fi.filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Undeleting '{}' from memory card ({} blocks)", fi.filename, fi.num_blocks);
|
INFO_LOG("Undeleting '{}' from memory card ({} blocks)", fi.filename, fi.num_blocks);
|
||||||
|
|
||||||
// check that all blocks are present first
|
// check that all blocks are present first
|
||||||
u32 block_number = fi.first_block;
|
u32 block_number = fi.first_block;
|
||||||
|
@ -442,8 +442,8 @@ bool MemoryCardImage::UndeleteFile(DataArray* data, const FileInfo& fi)
|
||||||
{
|
{
|
||||||
if (df->block_allocation_state != 0xA1)
|
if (df->block_allocation_state != 0xA1)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Incorrect block state for {}, expected 0xA1 got 0x{:02X}", this_block_number,
|
ERROR_LOG("Incorrect block state for {}, expected 0xA1 got 0x{:02X}", this_block_number,
|
||||||
df->block_allocation_state);
|
df->block_allocation_state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -451,8 +451,8 @@ bool MemoryCardImage::UndeleteFile(DataArray* data, const FileInfo& fi)
|
||||||
{
|
{
|
||||||
if (df->block_allocation_state != 0xA3)
|
if (df->block_allocation_state != 0xA3)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Incorrect block state for %u, expected 0xA3 got 0x{:02X}", this_block_number,
|
ERROR_LOG("Incorrect block state for %u, expected 0xA3 got 0x{:02X}", this_block_number,
|
||||||
df->block_allocation_state);
|
df->block_allocation_state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,8 +460,8 @@ bool MemoryCardImage::UndeleteFile(DataArray* data, const FileInfo& fi)
|
||||||
{
|
{
|
||||||
if (df->block_allocation_state != 0xA2)
|
if (df->block_allocation_state != 0xA2)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Incorrect block state for {}, expected 0xA2 got 0x{:02X}", this_block_number,
|
ERROR_LOG("Incorrect block state for {}, expected 0xA2 got 0x{:02X}", this_block_number,
|
||||||
df->block_allocation_state);
|
df->block_allocation_state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -532,8 +532,8 @@ bool MemoryCardImage::ImportCardGME(DataArray* data, const char* filename, std::
|
||||||
const u32 expected_size = sizeof(GMEHeader) + DATA_SIZE;
|
const u32 expected_size = sizeof(GMEHeader) + DATA_SIZE;
|
||||||
if (file_data.size() < expected_size)
|
if (file_data.size() < expected_size)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("GME memory card '{}' is too small (got {} expected {}), padding with zeroes", filename,
|
WARNING_LOG("GME memory card '{}' is too small (got {} expected {}), padding with zeroes", filename,
|
||||||
file_data.size(), expected_size);
|
file_data.size(), expected_size);
|
||||||
file_data.resize(expected_size);
|
file_data.resize(expected_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ bool Multitap::Transfer(const u8 data_in, u8* data_out)
|
||||||
|
|
||||||
if (!ack)
|
if (!ack)
|
||||||
{
|
{
|
||||||
Log_DevPrint("Memory card transfer ended");
|
DEV_LOG("Memory card transfer ended");
|
||||||
m_transfer_state = TransferState::Idle;
|
m_transfer_state = TransferState::Idle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ bool Multitap::Transfer(const u8 data_in, u8* data_out)
|
||||||
|
|
||||||
if (!ack)
|
if (!ack)
|
||||||
{
|
{
|
||||||
Log_DevPrint("Controller transfer ended");
|
DEV_LOG("Controller transfer ended");
|
||||||
m_transfer_state = TransferState::Idle;
|
m_transfer_state = TransferState::Idle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ void NeGconRumble::SetAnalogMode(bool enabled, bool show_message)
|
||||||
if (m_analog_mode == enabled)
|
if (m_analog_mode == enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_InfoFmt("Controller {} switched to {} mode.", m_index + 1u, m_analog_mode ? "analog" : "digital");
|
INFO_LOG("Controller {} switched to {} mode.", m_index + 1u, m_analog_mode ? "analog" : "digital");
|
||||||
if (show_message)
|
if (show_message)
|
||||||
{
|
{
|
||||||
Host::AddIconOSDMessage(
|
Host::AddIconOSDMessage(
|
||||||
|
@ -361,12 +361,12 @@ bool NeGconRumble::Transfer(const u8 data_in, u8* data_out)
|
||||||
|
|
||||||
if (data_in == 0x01)
|
if (data_in == 0x01)
|
||||||
{
|
{
|
||||||
Log_DebugPrint("ACK controller access");
|
DEBUG_LOG("ACK controller access");
|
||||||
m_command = Command::Ready;
|
m_command = Command::Ready;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("Unknown data_in = 0x{:02X}", data_in);
|
DEV_LOG("Unknown data_in = 0x{:02X}", data_in);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -437,7 +437,7 @@ bool NeGconRumble::Transfer(const u8 data_in, u8* data_out)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_configuration_mode)
|
if (m_configuration_mode)
|
||||||
Log_ErrorFmt("Unimplemented config mode command 0x{:02X}", data_in);
|
ERROR_LOG("Unimplemented config mode command 0x{:02X}", data_in);
|
||||||
|
|
||||||
*data_out = 0xFF;
|
*data_out = 0xFF;
|
||||||
return false;
|
return false;
|
||||||
|
@ -587,7 +587,7 @@ bool NeGconRumble::Transfer(const u8 data_in, u8* data_out)
|
||||||
m_status_byte = 0x5A;
|
m_status_byte = 0x5A;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("0x{:02x}({}) config mode", m_rx_buffer[2], m_configuration_mode ? "enter" : "leave");
|
DEV_LOG("0x{:02x}({}) config mode", m_rx_buffer[2], m_configuration_mode ? "enter" : "leave");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -596,14 +596,14 @@ bool NeGconRumble::Transfer(const u8 data_in, u8* data_out)
|
||||||
{
|
{
|
||||||
if (m_command_step == 2)
|
if (m_command_step == 2)
|
||||||
{
|
{
|
||||||
Log_DevFmt("analog mode val 0x{:02x}", data_in);
|
DEV_LOG("analog mode val 0x{:02x}", data_in);
|
||||||
|
|
||||||
if (data_in == 0x00 || data_in == 0x01)
|
if (data_in == 0x00 || data_in == 0x01)
|
||||||
SetAnalogMode((data_in == 0x01), true);
|
SetAnalogMode((data_in == 0x01), true);
|
||||||
}
|
}
|
||||||
else if (m_command_step == 3)
|
else if (m_command_step == 3)
|
||||||
{
|
{
|
||||||
Log_DevFmt("analog mode lock 0x{:02x}", data_in);
|
DEV_LOG("analog mode lock 0x{:02x}", data_in);
|
||||||
|
|
||||||
if (data_in == 0x02 || data_in == 0x03)
|
if (data_in == 0x02 || data_in == 0x03)
|
||||||
m_analog_locked = (data_in == 0x03);
|
m_analog_locked = (data_in == 0x03);
|
||||||
|
@ -700,10 +700,10 @@ bool NeGconRumble::Transfer(const u8 data_in, u8* data_out)
|
||||||
{
|
{
|
||||||
m_command = Command::Idle;
|
m_command = Command::Idle;
|
||||||
|
|
||||||
Log_DebugFmt("Rx: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}", m_rx_buffer[0], m_rx_buffer[1],
|
DEBUG_LOG("Rx: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}", m_rx_buffer[0], m_rx_buffer[1],
|
||||||
m_rx_buffer[2], m_rx_buffer[3], m_rx_buffer[4], m_rx_buffer[5], m_rx_buffer[6], m_rx_buffer[7]);
|
m_rx_buffer[2], m_rx_buffer[3], m_rx_buffer[4], m_rx_buffer[5], m_rx_buffer[6], m_rx_buffer[7]);
|
||||||
Log_DebugFmt("Tx: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}", m_tx_buffer[0], m_tx_buffer[1],
|
DEBUG_LOG("Tx: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}", m_tx_buffer[0], m_tx_buffer[1],
|
||||||
m_tx_buffer[2], m_tx_buffer[3], m_tx_buffer[4], m_tx_buffer[5], m_tx_buffer[6], m_tx_buffer[7]);
|
m_tx_buffer[2], m_tx_buffer[3], m_tx_buffer[4], m_tx_buffer[5], m_tx_buffer[6], m_tx_buffer[7]);
|
||||||
|
|
||||||
m_rx_buffer.fill(0x00);
|
m_rx_buffer.fill(0x00);
|
||||||
m_tx_buffer.fill(0x00);
|
m_tx_buffer.fill(0x00);
|
||||||
|
|
|
@ -214,10 +214,10 @@ bool Pad::DoStateController(StateWrapper& sw, u32 i)
|
||||||
state_cinfo ? state_cinfo->GetDisplayName() : "", i + 1u);
|
state_cinfo ? state_cinfo->GetDisplayName() : "", i + 1u);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("Controller type mismatch in slot {}: state={}({}) ui={}({}) load_from_state={}", i + 1u,
|
DEV_LOG("Controller type mismatch in slot {}: state={}({}) ui={}({}) load_from_state={}", i + 1u,
|
||||||
state_cinfo ? state_cinfo->name : "", static_cast<unsigned>(state_controller_type),
|
state_cinfo ? state_cinfo->name : "", static_cast<unsigned>(state_controller_type),
|
||||||
Controller::GetControllerInfo(controller_type)->name, static_cast<unsigned>(controller_type),
|
Controller::GetControllerInfo(controller_type)->name, static_cast<unsigned>(controller_type),
|
||||||
g_settings.load_devices_from_save_states ? "yes" : "no");
|
g_settings.load_devices_from_save_states ? "yes" : "no");
|
||||||
|
|
||||||
if (g_settings.load_devices_from_save_states)
|
if (g_settings.load_devices_from_save_states)
|
||||||
{
|
{
|
||||||
|
@ -295,7 +295,7 @@ bool Pad::DoStateMemcard(StateWrapper& sw, u32 i, bool is_memory_state)
|
||||||
{
|
{
|
||||||
if (s_memory_cards[i]->GetData() == card_ptr->GetData())
|
if (s_memory_cards[i]->GetData() == card_ptr->GetData())
|
||||||
{
|
{
|
||||||
Log_DevFmt("Card {} data matches, copying state", i + 1u);
|
DEV_LOG("Card {} data matches, copying state", i + 1u);
|
||||||
s_memory_cards[i]->CopyState(card_ptr);
|
s_memory_cards[i]->CopyState(card_ptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -314,7 +314,7 @@ bool Pad::DoStateMemcard(StateWrapper& sw, u32 i, bool is_memory_state)
|
||||||
// for the game to decide it was removed and purge its cache. Once implemented, this could be
|
// for the game to decide it was removed and purge its cache. Once implemented, this could be
|
||||||
// described as deferred re-plugging in the log.
|
// described as deferred re-plugging in the log.
|
||||||
|
|
||||||
Log_WarningFmt("Memory card {} data mismatch. Using current data via instant-replugging.", i + 1u);
|
WARNING_LOG("Memory card {} data mismatch. Using current data via instant-replugging.", i + 1u);
|
||||||
s_memory_cards[i]->Reset();
|
s_memory_cards[i]->Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,7 +365,7 @@ MemoryCard* Pad::GetDummyMemcard()
|
||||||
|
|
||||||
void Pad::BackupMemoryCardState()
|
void Pad::BackupMemoryCardState()
|
||||||
{
|
{
|
||||||
Log_DevPrint("Backing up memory card state.");
|
DEV_LOG("Backing up memory card state.");
|
||||||
|
|
||||||
if (!s_memory_card_backup)
|
if (!s_memory_card_backup)
|
||||||
{
|
{
|
||||||
|
@ -388,7 +388,7 @@ void Pad::RestoreMemoryCardState()
|
||||||
{
|
{
|
||||||
DebugAssert(s_memory_card_backup);
|
DebugAssert(s_memory_card_backup);
|
||||||
|
|
||||||
Log_VerbosePrint("Restoring backed up memory card state.");
|
VERBOSE_LOG("Restoring backed up memory card state.");
|
||||||
|
|
||||||
s_memory_card_backup->SeekAbsolute(0);
|
s_memory_card_backup->SeekAbsolute(0);
|
||||||
StateWrapper sw(s_memory_card_backup.get(), StateWrapper::Mode::Read, SAVE_STATE_VERSION);
|
StateWrapper sw(s_memory_card_backup.get(), StateWrapper::Mode::Read, SAVE_STATE_VERSION);
|
||||||
|
@ -558,8 +558,8 @@ MemoryCard* Pad::GetMemoryCard(u32 slot)
|
||||||
|
|
||||||
void Pad::SetMemoryCard(u32 slot, std::unique_ptr<MemoryCard> dev)
|
void Pad::SetMemoryCard(u32 slot, std::unique_ptr<MemoryCard> dev)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Memory card slot {}: {}", slot,
|
INFO_LOG("Memory card slot {}: {}", slot,
|
||||||
dev ? (dev->GetFilename().empty() ? "<no file configured>" : dev->GetFilename().c_str()) : "<unplugged>");
|
dev ? (dev->GetFilename().empty() ? "<no file configured>" : dev->GetFilename().c_str()) : "<unplugged>");
|
||||||
|
|
||||||
s_memory_cards[slot] = std::move(dev);
|
s_memory_cards[slot] = std::move(dev);
|
||||||
}
|
}
|
||||||
|
@ -587,7 +587,7 @@ u32 Pad::ReadRegister(u32 offset)
|
||||||
s_transfer_event->InvokeEarly();
|
s_transfer_event->InvokeEarly();
|
||||||
|
|
||||||
const u8 value = s_receive_buffer_full ? s_receive_buffer : 0xFF;
|
const u8 value = s_receive_buffer_full ? s_receive_buffer : 0xFF;
|
||||||
Log_DebugFmt("JOY_DATA (R) -> 0x{:02X}{}", value, s_receive_buffer_full ? "" : "(EMPTY)");
|
DEBUG_LOG("JOY_DATA (R) -> 0x{:02X}{}", value, s_receive_buffer_full ? "" : "(EMPTY)");
|
||||||
s_receive_buffer_full = false;
|
s_receive_buffer_full = false;
|
||||||
UpdateJoyStat();
|
UpdateJoyStat();
|
||||||
|
|
||||||
|
@ -615,7 +615,7 @@ u32 Pad::ReadRegister(u32 offset)
|
||||||
return ZeroExtend32(s_JOY_BAUD);
|
return ZeroExtend32(s_JOY_BAUD);
|
||||||
|
|
||||||
[[unlikely]] default:
|
[[unlikely]] default:
|
||||||
Log_ErrorFmt("Unknown register read: 0x{:X}", offset);
|
ERROR_LOG("Unknown register read: 0x{:X}", offset);
|
||||||
return UINT32_C(0xFFFFFFFF);
|
return UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,10 +626,10 @@ void Pad::WriteRegister(u32 offset, u32 value)
|
||||||
{
|
{
|
||||||
case 0x00: // JOY_DATA
|
case 0x00: // JOY_DATA
|
||||||
{
|
{
|
||||||
Log_DebugFmt("JOY_DATA (W) <- 0x{:02X}", value);
|
DEBUG_LOG("JOY_DATA (W) <- 0x{:02X}", value);
|
||||||
|
|
||||||
if (s_transmit_buffer_full)
|
if (s_transmit_buffer_full)
|
||||||
Log_WarningPrint("TX FIFO overrun");
|
WARNING_LOG("TX FIFO overrun");
|
||||||
|
|
||||||
s_transmit_buffer = Truncate8(value);
|
s_transmit_buffer = Truncate8(value);
|
||||||
s_transmit_buffer_full = true;
|
s_transmit_buffer_full = true;
|
||||||
|
@ -642,7 +642,7 @@ void Pad::WriteRegister(u32 offset, u32 value)
|
||||||
|
|
||||||
case 0x0A: // JOY_CTRL
|
case 0x0A: // JOY_CTRL
|
||||||
{
|
{
|
||||||
Log_DebugFmt("JOY_CTRL <- 0x{:04X}", value);
|
DEBUG_LOG("JOY_CTRL <- 0x{:04X}", value);
|
||||||
|
|
||||||
s_JOY_CTRL.bits = Truncate16(value);
|
s_JOY_CTRL.bits = Truncate16(value);
|
||||||
if (s_JOY_CTRL.RESET)
|
if (s_JOY_CTRL.RESET)
|
||||||
|
@ -675,21 +675,21 @@ void Pad::WriteRegister(u32 offset, u32 value)
|
||||||
|
|
||||||
case 0x08: // JOY_MODE
|
case 0x08: // JOY_MODE
|
||||||
{
|
{
|
||||||
Log_DebugFmt("JOY_MODE <- 0x{:08X}", value);
|
DEBUG_LOG("JOY_MODE <- 0x{:08X}", value);
|
||||||
s_JOY_MODE.bits = Truncate16(value);
|
s_JOY_MODE.bits = Truncate16(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x0E:
|
case 0x0E:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("JOY_BAUD <- 0x{:08X}", value);
|
DEBUG_LOG("JOY_BAUD <- 0x{:08X}", value);
|
||||||
s_JOY_BAUD = Truncate16(value);
|
s_JOY_BAUD = Truncate16(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[unlikely]] default:
|
[[unlikely]] default:
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unknown register write: 0x{:X} <- 0x{:08X}", offset, value);
|
ERROR_LOG("Unknown register write: 0x{:X} <- 0x{:08X}", offset, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -744,7 +744,7 @@ void Pad::TransferEvent(void*, TickCount ticks, TickCount ticks_late)
|
||||||
void Pad::BeginTransfer()
|
void Pad::BeginTransfer()
|
||||||
{
|
{
|
||||||
DebugAssert(s_state == State::Idle && CanTransfer());
|
DebugAssert(s_state == State::Idle && CanTransfer());
|
||||||
Log_DebugPrint("Starting transfer");
|
DEBUG_LOG("Starting transfer");
|
||||||
|
|
||||||
s_JOY_CTRL.RXEN = true;
|
s_JOY_CTRL.RXEN = true;
|
||||||
s_transmit_value = s_transmit_buffer;
|
s_transmit_value = s_transmit_buffer;
|
||||||
|
@ -771,7 +771,7 @@ void Pad::BeginTransfer()
|
||||||
|
|
||||||
void Pad::DoTransfer(TickCount ticks_late)
|
void Pad::DoTransfer(TickCount ticks_late)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Transferring slot {}", s_JOY_CTRL.SLOT.GetValue());
|
DEBUG_LOG("Transferring slot {}", s_JOY_CTRL.SLOT.GetValue());
|
||||||
|
|
||||||
const u8 device_index = s_multitaps[0].IsEnabled() ? 4u : s_JOY_CTRL.SLOT;
|
const u8 device_index = s_multitaps[0].IsEnabled() ? 4u : s_JOY_CTRL.SLOT;
|
||||||
Controller* const controller = s_controllers[device_index].get();
|
Controller* const controller = s_controllers[device_index].get();
|
||||||
|
@ -793,8 +793,8 @@ void Pad::DoTransfer(TickCount ticks_late)
|
||||||
{
|
{
|
||||||
if ((ack = s_multitaps[s_JOY_CTRL.SLOT].Transfer(data_out, &data_in)) == true)
|
if ((ack = s_multitaps[s_JOY_CTRL.SLOT].Transfer(data_out, &data_in)) == true)
|
||||||
{
|
{
|
||||||
Log_TraceFmt("Active device set to tap {}, sent 0x{:02X}, received 0x{:02X}",
|
TRACE_LOG("Active device set to tap {}, sent 0x{:02X}, received 0x{:02X}", static_cast<int>(s_JOY_CTRL.SLOT),
|
||||||
static_cast<int>(s_JOY_CTRL.SLOT), data_out, data_in);
|
data_out, data_in);
|
||||||
s_active_device = ActiveDevice::Multitap;
|
s_active_device = ActiveDevice::Multitap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -805,12 +805,12 @@ void Pad::DoTransfer(TickCount ticks_late)
|
||||||
if (!memory_card || (ack = memory_card->Transfer(data_out, &data_in)) == false)
|
if (!memory_card || (ack = memory_card->Transfer(data_out, &data_in)) == false)
|
||||||
{
|
{
|
||||||
// nothing connected to this port
|
// nothing connected to this port
|
||||||
Log_TracePrint("Nothing connected or ACK'ed");
|
TRACE_LOG("Nothing connected or ACK'ed");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// memory card responded, make it the active device until non-ack
|
// memory card responded, make it the active device until non-ack
|
||||||
Log_TraceFmt("Transfer to memory card, data_out=0x{:02X}, data_in=0x{:02X}", data_out, data_in);
|
TRACE_LOG("Transfer to memory card, data_out=0x{:02X}, data_in=0x{:02X}", data_out, data_in);
|
||||||
s_active_device = ActiveDevice::MemoryCard;
|
s_active_device = ActiveDevice::MemoryCard;
|
||||||
|
|
||||||
// back up memory card state in case we roll back to before this transfer begun
|
// back up memory card state in case we roll back to before this transfer begun
|
||||||
|
@ -827,7 +827,7 @@ void Pad::DoTransfer(TickCount ticks_late)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// controller responded, make it the active device until non-ack
|
// controller responded, make it the active device until non-ack
|
||||||
Log_TraceFmt("Transfer to controller, data_out=0x{:02X}, data_in=0x{:02X}", data_out, data_in);
|
TRACE_LOG("Transfer to controller, data_out=0x{:02X}, data_in=0x{:02X}", data_out, data_in);
|
||||||
s_active_device = ActiveDevice::Controller;
|
s_active_device = ActiveDevice::Controller;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -839,7 +839,7 @@ void Pad::DoTransfer(TickCount ticks_late)
|
||||||
if (controller)
|
if (controller)
|
||||||
{
|
{
|
||||||
ack = controller->Transfer(data_out, &data_in);
|
ack = controller->Transfer(data_out, &data_in);
|
||||||
Log_TraceFmt("Transfer to controller, data_out=0x{:02X}, data_in=0x{:02X}", data_out, data_in);
|
TRACE_LOG("Transfer to controller, data_out=0x{:02X}, data_in=0x{:02X}", data_out, data_in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -850,7 +850,7 @@ void Pad::DoTransfer(TickCount ticks_late)
|
||||||
{
|
{
|
||||||
s_last_memory_card_transfer_frame = System::GetFrameNumber();
|
s_last_memory_card_transfer_frame = System::GetFrameNumber();
|
||||||
ack = memory_card->Transfer(data_out, &data_in);
|
ack = memory_card->Transfer(data_out, &data_in);
|
||||||
Log_TraceFmt("Transfer to memory card, data_out=0x{:02X}, data_in=0x{:02X}", data_out, data_in);
|
TRACE_LOG("Transfer to memory card, data_out=0x{:02X}, data_in=0x{:02X}", data_out, data_in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -860,8 +860,8 @@ void Pad::DoTransfer(TickCount ticks_late)
|
||||||
if (s_multitaps[s_JOY_CTRL.SLOT].IsEnabled())
|
if (s_multitaps[s_JOY_CTRL.SLOT].IsEnabled())
|
||||||
{
|
{
|
||||||
ack = s_multitaps[s_JOY_CTRL.SLOT].Transfer(data_out, &data_in);
|
ack = s_multitaps[s_JOY_CTRL.SLOT].Transfer(data_out, &data_in);
|
||||||
Log_TraceFmt("Transfer tap {}, sent 0x{:02X}, received 0x{:02X}, acked: {}", static_cast<int>(s_JOY_CTRL.SLOT),
|
TRACE_LOG("Transfer tap {}, sent 0x{:02X}, received 0x{:02X}, acked: {}", static_cast<int>(s_JOY_CTRL.SLOT),
|
||||||
data_out, data_in, ack ? "true" : "false");
|
data_out, data_in, ack ? "true" : "false");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -883,7 +883,7 @@ void Pad::DoTransfer(TickCount ticks_late)
|
||||||
(s_active_device == ActiveDevice::Multitap && s_multitaps[s_JOY_CTRL.SLOT].IsReadingMemoryCard());
|
(s_active_device == ActiveDevice::Multitap && s_multitaps[s_JOY_CTRL.SLOT].IsReadingMemoryCard());
|
||||||
|
|
||||||
const TickCount ack_timer = GetACKTicks(memcard_transfer);
|
const TickCount ack_timer = GetACKTicks(memcard_transfer);
|
||||||
Log_DebugFmt("Delaying ACK for {} ticks", ack_timer);
|
DEBUG_LOG("Delaying ACK for {} ticks", ack_timer);
|
||||||
s_state = State::WaitingForACK;
|
s_state = State::WaitingForACK;
|
||||||
s_transfer_event->SetPeriodAndSchedule(ack_timer);
|
s_transfer_event->SetPeriodAndSchedule(ack_timer);
|
||||||
}
|
}
|
||||||
|
@ -897,7 +897,7 @@ void Pad::DoACK()
|
||||||
|
|
||||||
if (s_JOY_CTRL.ACKINTEN)
|
if (s_JOY_CTRL.ACKINTEN)
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Triggering ACK interrupt");
|
DEBUG_LOG("Triggering ACK interrupt");
|
||||||
s_JOY_STAT.INTR = true;
|
s_JOY_STAT.INTR = true;
|
||||||
InterruptController::SetLineState(InterruptController::IRQ::PAD, true);
|
InterruptController::SetLineState(InterruptController::IRQ::PAD, true);
|
||||||
}
|
}
|
||||||
|
@ -912,7 +912,7 @@ void Pad::DoACK()
|
||||||
void Pad::EndTransfer()
|
void Pad::EndTransfer()
|
||||||
{
|
{
|
||||||
DebugAssert(s_state == State::Transmitting || s_state == State::WaitingForACK);
|
DebugAssert(s_state == State::Transmitting || s_state == State::WaitingForACK);
|
||||||
Log_DebugPrint("Ending transfer");
|
DEBUG_LOG("Ending transfer");
|
||||||
|
|
||||||
s_state = State::Idle;
|
s_state = State::Idle;
|
||||||
s_transfer_event->Deactivate();
|
s_transfer_event->Deactivate();
|
||||||
|
|
|
@ -33,7 +33,7 @@ static s32 GetFreeFileHandle()
|
||||||
|
|
||||||
if (s_files.size() >= MAX_FILES)
|
if (s_files.size() >= MAX_FILES)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Too many open files.");
|
ERROR_LOG("Too many open files.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ static s32 GetFreeFileHandle()
|
||||||
static void CloseAllFiles()
|
static void CloseAllFiles()
|
||||||
{
|
{
|
||||||
if (!s_files.empty())
|
if (!s_files.empty())
|
||||||
Log_DevFmt("Closing {} open files.", s_files.size());
|
DEV_LOG("Closing {} open files.", s_files.size());
|
||||||
|
|
||||||
s_files.clear();
|
s_files.clear();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ static FILE* GetFileFromHandle(u32 handle)
|
||||||
{
|
{
|
||||||
if (handle >= static_cast<u32>(s_files.size()) || !s_files[handle])
|
if (handle >= static_cast<u32>(s_files.size()) || !s_files[handle])
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid file handle {}", static_cast<s32>(handle));
|
ERROR_LOG("Invalid file handle {}", static_cast<s32>(handle));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ static bool CloseFileHandle(u32 handle)
|
||||||
{
|
{
|
||||||
if (handle >= static_cast<u32>(s_files.size()) || !s_files[handle])
|
if (handle >= static_cast<u32>(s_files.size()) || !s_files[handle])
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid file handle {}", static_cast<s32>(handle));
|
ERROR_LOG("Invalid file handle {}", static_cast<s32>(handle));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,9 +85,9 @@ static std::string ResolveHostPath(const std::string& path)
|
||||||
!canonicalized_path.starts_with(root) || // and start with the host root,
|
!canonicalized_path.starts_with(root) || // and start with the host root,
|
||||||
canonicalized_path[root.length()] != FS_OSPATH_SEPARATOR_CHARACTER) // and we can't access a sibling.
|
canonicalized_path[root.length()] != FS_OSPATH_SEPARATOR_CHARACTER) // and we can't access a sibling.
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Denying access to path outside of PCDrv directory. Requested path: '{}', "
|
ERROR_LOG("Denying access to path outside of PCDrv directory. Requested path: '{}', "
|
||||||
"Resolved path: '{}', Root directory: '{}'",
|
"Resolved path: '{}', Root directory: '{}'",
|
||||||
path, root, canonicalized_path);
|
path, root, canonicalized_path);
|
||||||
canonicalized_path.clear();
|
canonicalized_path.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +99,8 @@ void PCDrv::Initialize()
|
||||||
if (!g_settings.pcdrv_enable)
|
if (!g_settings.pcdrv_enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_WarningFmt("{} PCDrv is enabled at '{}'", g_settings.pcdrv_enable_writes ? "Read/Write" : "Read-Only",
|
WARNING_LOG("{} PCDrv is enabled at '{}'", g_settings.pcdrv_enable_writes ? "Read/Write" : "Read-Only",
|
||||||
g_settings.pcdrv_root);
|
g_settings.pcdrv_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCDrv::Reset()
|
void PCDrv::Reset()
|
||||||
|
@ -126,7 +126,7 @@ bool PCDrv::HandleSyscall(u32 instruction_bits, CPU::Registers& regs)
|
||||||
{
|
{
|
||||||
case 0x101: // PCinit
|
case 0x101: // PCinit
|
||||||
{
|
{
|
||||||
Log_DevPrint("PCinit");
|
DEV_LOG("PCinit");
|
||||||
CloseAllFiles();
|
CloseAllFiles();
|
||||||
regs.v0 = 0;
|
regs.v0 = 0;
|
||||||
regs.v1 = 0;
|
regs.v1 = 0;
|
||||||
|
@ -142,11 +142,11 @@ bool PCDrv::HandleSyscall(u32 instruction_bits, CPU::Registers& regs)
|
||||||
std::string filename;
|
std::string filename;
|
||||||
if (!CPU::SafeReadMemoryCString(regs.a1, &filename))
|
if (!CPU::SafeReadMemoryCString(regs.a1, &filename))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("{}: Invalid string", func);
|
ERROR_LOG("{}: Invalid string", func);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("{}: '{}' mode {}", func, filename, mode);
|
DEBUG_LOG("{}: '{}' mode {}", func, filename, mode);
|
||||||
if ((filename = ResolveHostPath(filename)).empty())
|
if ((filename = ResolveHostPath(filename)).empty())
|
||||||
{
|
{
|
||||||
RETURN_ERROR();
|
RETURN_ERROR();
|
||||||
|
@ -155,7 +155,7 @@ bool PCDrv::HandleSyscall(u32 instruction_bits, CPU::Registers& regs)
|
||||||
|
|
||||||
if (!is_open && !g_settings.pcdrv_enable_writes)
|
if (!is_open && !g_settings.pcdrv_enable_writes)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("{}: Writes are not enabled", func);
|
ERROR_LOG("{}: Writes are not enabled", func);
|
||||||
RETURN_ERROR();
|
RETURN_ERROR();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ bool PCDrv::HandleSyscall(u32 instruction_bits, CPU::Registers& regs)
|
||||||
// Directories are unsupported for now, ignore other attributes
|
// Directories are unsupported for now, ignore other attributes
|
||||||
if (mode & PCDRV_ATTRIBUTE_DIRECTORY)
|
if (mode & PCDRV_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("{}: Directories are unsupported", func);
|
ERROR_LOG("{}: Directories are unsupported", func);
|
||||||
RETURN_ERROR();
|
RETURN_ERROR();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -180,12 +180,12 @@ bool PCDrv::HandleSyscall(u32 instruction_bits, CPU::Registers& regs)
|
||||||
is_open ? (g_settings.pcdrv_enable_writes ? "r+b" : "rb") : "w+b");
|
is_open ? (g_settings.pcdrv_enable_writes ? "r+b" : "rb") : "w+b");
|
||||||
if (!s_files[handle])
|
if (!s_files[handle])
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("{}: Failed to open '{}'", func, filename);
|
ERROR_LOG("{}: Failed to open '{}'", func, filename);
|
||||||
RETURN_ERROR();
|
RETURN_ERROR();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_ErrorFmt("PCDrv: Opened '{}' => {}", filename, handle);
|
ERROR_LOG("PCDrv: Opened '{}' => {}", filename, handle);
|
||||||
regs.v0 = 0;
|
regs.v0 = 0;
|
||||||
regs.v1 = static_cast<u32>(handle);
|
regs.v1 = static_cast<u32>(handle);
|
||||||
return true;
|
return true;
|
||||||
|
@ -193,7 +193,7 @@ bool PCDrv::HandleSyscall(u32 instruction_bits, CPU::Registers& regs)
|
||||||
|
|
||||||
case 0x104: // PCclose
|
case 0x104: // PCclose
|
||||||
{
|
{
|
||||||
Log_DebugFmt("PCclose({})", regs.a1);
|
DEBUG_LOG("PCclose({})", regs.a1);
|
||||||
|
|
||||||
if (!CloseFileHandle(regs.a1))
|
if (!CloseFileHandle(regs.a1))
|
||||||
{
|
{
|
||||||
|
@ -208,7 +208,7 @@ bool PCDrv::HandleSyscall(u32 instruction_bits, CPU::Registers& regs)
|
||||||
|
|
||||||
case 0x105: // PCread
|
case 0x105: // PCread
|
||||||
{
|
{
|
||||||
Log_DebugFmt("PCread({}, {}, 0x{:08X})", regs.a1, regs.a2, regs.a3);
|
DEBUG_LOG("PCread({}, {}, 0x{:08X})", regs.a1, regs.a2, regs.a3);
|
||||||
|
|
||||||
std::FILE* fp = GetFileFromHandle(regs.a1);
|
std::FILE* fp = GetFileFromHandle(regs.a1);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
|
@ -246,7 +246,7 @@ bool PCDrv::HandleSyscall(u32 instruction_bits, CPU::Registers& regs)
|
||||||
|
|
||||||
case 0x106: // PCwrite
|
case 0x106: // PCwrite
|
||||||
{
|
{
|
||||||
Log_DebugFmt("PCwrite({}, {}, 0x{:08x})", regs.a1, regs.a2, regs.a3);
|
DEBUG_LOG("PCwrite({}, {}, 0x{:08x})", regs.a1, regs.a2, regs.a3);
|
||||||
|
|
||||||
std::FILE* fp = GetFileFromHandle(regs.a1);
|
std::FILE* fp = GetFileFromHandle(regs.a1);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
|
@ -281,7 +281,7 @@ bool PCDrv::HandleSyscall(u32 instruction_bits, CPU::Registers& regs)
|
||||||
|
|
||||||
case 0x107: // PClseek
|
case 0x107: // PClseek
|
||||||
{
|
{
|
||||||
Log_DebugFmt("PClseek({}, {}, {})", regs.a1, regs.a2, regs.a3);
|
DEBUG_LOG("PClseek({}, {}, {})", regs.a1, regs.a2, regs.a3);
|
||||||
|
|
||||||
std::FILE* fp = GetFileFromHandle(regs.a1);
|
std::FILE* fp = GetFileFromHandle(regs.a1);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
|
@ -311,7 +311,7 @@ bool PCDrv::HandleSyscall(u32 instruction_bits, CPU::Registers& regs)
|
||||||
|
|
||||||
if (FileSystem::FSeek64(fp, offset, hmode) != 0)
|
if (FileSystem::FSeek64(fp, offset, hmode) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("FSeek for PCDrv failed: {} {}", offset, hmode);
|
ERROR_LOG("FSeek for PCDrv failed: {} {}", offset, hmode);
|
||||||
RETURN_ERROR();
|
RETURN_ERROR();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ bool File::Load(const char* path)
|
||||||
std::optional<std::vector<u8>> file_data(FileSystem::ReadBinaryFile(path));
|
std::optional<std::vector<u8>> file_data(FileSystem::ReadBinaryFile(path));
|
||||||
if (!file_data.has_value() || file_data->empty())
|
if (!file_data.has_value() || file_data->empty())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open/read PSF file '{}'", path);
|
ERROR_LOG("Failed to open/read PSF file '{}'", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ bool File::Load(const char* path)
|
||||||
header.compressed_program_size == 0 ||
|
header.compressed_program_size == 0 ||
|
||||||
(sizeof(header) + header.reserved_area_size + header.compressed_program_size) > file_size)
|
(sizeof(header) + header.reserved_area_size + header.compressed_program_size) > file_size)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid or incompatible header in PSF '{}'", path);
|
ERROR_LOG("Invalid or incompatible header in PSF '{}'", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ bool File::Load(const char* path)
|
||||||
int err = inflateInit(&strm);
|
int err = inflateInit(&strm);
|
||||||
if (err != Z_OK)
|
if (err != Z_OK)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("inflateInit() failed: {}", err);
|
ERROR_LOG("inflateInit() failed: {}", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,14 +106,14 @@ bool File::Load(const char* path)
|
||||||
err = inflate(&strm, Z_NO_FLUSH);
|
err = inflate(&strm, Z_NO_FLUSH);
|
||||||
if (err != Z_STREAM_END)
|
if (err != Z_STREAM_END)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("inflate() failed: {}", err);
|
ERROR_LOG("inflate() failed: {}", err);
|
||||||
inflateEnd(&strm);
|
inflateEnd(&strm);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (strm.total_in != header.compressed_program_size)
|
else if (strm.total_in != header.compressed_program_size)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Mismatch between compressed size in header and stream {}/{}", header.compressed_program_size,
|
WARNING_LOG("Mismatch between compressed size in header and stream {}/{}", header.compressed_program_size,
|
||||||
static_cast<u32>(strm.total_in));
|
static_cast<u32>(strm.total_in));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_program_data.resize(strm.total_out);
|
m_program_data.resize(strm.total_out);
|
||||||
|
@ -147,7 +147,7 @@ bool File::Load(const char* path)
|
||||||
|
|
||||||
if (!tag_key.empty())
|
if (!tag_key.empty())
|
||||||
{
|
{
|
||||||
Log_DevFmt("PSF Tag: '{}' = '{}'", tag_key, tag_value);
|
DEV_LOG("PSF Tag: '{}' = '{}'", tag_key, tag_value);
|
||||||
m_tags.emplace(std::move(tag_key), std::move(tag_value));
|
m_tags.emplace(std::move(tag_key), std::move(tag_value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,14 +171,14 @@ static bool LoadLibraryPSF(const char* path, bool use_pc_sp, u32 depth = 0)
|
||||||
// don't recurse past 10 levels just in case of broken files
|
// don't recurse past 10 levels just in case of broken files
|
||||||
if (depth >= 10)
|
if (depth >= 10)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Recursion depth exceeded when loading PSF '{}'", path);
|
ERROR_LOG("Recursion depth exceeded when loading PSF '{}'", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file;
|
File file;
|
||||||
if (!file.Load(path))
|
if (!file.Load(path))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to load main PSF '{}'", path);
|
ERROR_LOG("Failed to load main PSF '{}'", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,13 +187,13 @@ static bool LoadLibraryPSF(const char* path, bool use_pc_sp, u32 depth = 0)
|
||||||
if (lib_name.has_value())
|
if (lib_name.has_value())
|
||||||
{
|
{
|
||||||
const std::string lib_path(Path::BuildRelativePath(path, lib_name.value()));
|
const std::string lib_path(Path::BuildRelativePath(path, lib_name.value()));
|
||||||
Log_InfoFmt("Loading main parent PSF '{}'", lib_path);
|
INFO_LOG("Loading main parent PSF '{}'", lib_path);
|
||||||
|
|
||||||
// We should use the initial SP/PC from the **first** parent lib.
|
// We should use the initial SP/PC from the **first** parent lib.
|
||||||
const bool lib_use_pc_sp = (depth == 0);
|
const bool lib_use_pc_sp = (depth == 0);
|
||||||
if (!LoadLibraryPSF(lib_path.c_str(), lib_use_pc_sp, depth + 1))
|
if (!LoadLibraryPSF(lib_path.c_str(), lib_use_pc_sp, depth + 1))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to load main parent PSF '{}'", lib_path);
|
ERROR_LOG("Failed to load main parent PSF '{}'", lib_path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ static bool LoadLibraryPSF(const char* path, bool use_pc_sp, u32 depth = 0)
|
||||||
if (!System::InjectEXEFromBuffer(file.GetProgramData().data(), static_cast<u32>(file.GetProgramData().size()),
|
if (!System::InjectEXEFromBuffer(file.GetProgramData().data(), static_cast<u32>(file.GetProgramData().size()),
|
||||||
use_pc_sp))
|
use_pc_sp))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to parse EXE from PSF '{}'", path);
|
ERROR_LOG("Failed to parse EXE from PSF '{}'", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,10 +219,10 @@ static bool LoadLibraryPSF(const char* path, bool use_pc_sp, u32 depth = 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const std::string lib_path(Path::BuildRelativePath(path, lib_name.value()));
|
const std::string lib_path(Path::BuildRelativePath(path, lib_name.value()));
|
||||||
Log_InfoFmt("Loading parent PSF '{}'", lib_path);
|
INFO_LOG("Loading parent PSF '{}'", lib_path);
|
||||||
if (!LoadLibraryPSF(lib_path.c_str(), false, depth + 1))
|
if (!LoadLibraryPSF(lib_path.c_str(), false, depth + 1))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to load parent PSF '{}'", lib_path);
|
ERROR_LOG("Failed to load parent PSF '{}'", lib_path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ static bool LoadLibraryPSF(const char* path, bool use_pc_sp, u32 depth = 0)
|
||||||
|
|
||||||
bool Load(const char* path)
|
bool Load(const char* path)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Loading PSF file from '{}'", path);
|
INFO_LOG("Loading PSF file from '{}'", path);
|
||||||
return LoadLibraryPSF(path, true);
|
return LoadLibraryPSF(path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -735,7 +735,7 @@ void Settings::FixIncompatibleSettings(bool display_osd_messages)
|
||||||
#ifndef ENABLE_MMAP_FASTMEM
|
#ifndef ENABLE_MMAP_FASTMEM
|
||||||
if (g_settings.cpu_fastmem_mode == CPUFastmemMode::MMap)
|
if (g_settings.cpu_fastmem_mode == CPUFastmemMode::MMap)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("mmap fastmem is not available on this platform, using LUT instead.");
|
WARNING_LOG("mmap fastmem is not available on this platform, using LUT instead.");
|
||||||
g_settings.cpu_fastmem_mode = CPUFastmemMode::LUT;
|
g_settings.cpu_fastmem_mode = CPUFastmemMode::LUT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -770,7 +770,7 @@ void Settings::FixIncompatibleSettings(bool display_osd_messages)
|
||||||
// be unlinked. Which would be thousands of blocks.
|
// be unlinked. Which would be thousands of blocks.
|
||||||
if (g_settings.cpu_recompiler_block_linking)
|
if (g_settings.cpu_recompiler_block_linking)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Disabling block linking due to runahead.");
|
WARNING_LOG("Disabling block linking due to runahead.");
|
||||||
g_settings.cpu_recompiler_block_linking = false;
|
g_settings.cpu_recompiler_block_linking = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -844,14 +844,15 @@ void Settings::SetDefaultControllerConfig(SettingsInterface& si)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr const std::array s_log_level_names = {"None", "Error", "Warning", "Perf", "Info",
|
static constexpr const std::array s_log_level_names = {
|
||||||
"Verbose", "Dev", "Profile", "Debug", "Trace"};
|
"None", "Error", "Warning", "Info", "Verbose", "Dev", "Debug", "Trace",
|
||||||
|
};
|
||||||
static constexpr const std::array s_log_level_display_names = {
|
static constexpr const std::array s_log_level_display_names = {
|
||||||
TRANSLATE_NOOP("LogLevel", "None"), TRANSLATE_NOOP("LogLevel", "Error"),
|
TRANSLATE_NOOP("LogLevel", "None"), TRANSLATE_NOOP("LogLevel", "Error"),
|
||||||
TRANSLATE_NOOP("LogLevel", "Warning"), TRANSLATE_NOOP("LogLevel", "Performance"),
|
TRANSLATE_NOOP("LogLevel", "Warning"), TRANSLATE_NOOP("LogLevel", "Information"),
|
||||||
TRANSLATE_NOOP("LogLevel", "Information"), TRANSLATE_NOOP("LogLevel", "Verbose"),
|
TRANSLATE_NOOP("LogLevel", "Verbose"), TRANSLATE_NOOP("LogLevel", "Developer"),
|
||||||
TRANSLATE_NOOP("LogLevel", "Developer"), TRANSLATE_NOOP("LogLevel", "Profile"),
|
TRANSLATE_NOOP("LogLevel", "Debug"), TRANSLATE_NOOP("LogLevel", "Trace"),
|
||||||
TRANSLATE_NOOP("LogLevel", "Debug"), TRANSLATE_NOOP("LogLevel", "Trace")};
|
};
|
||||||
|
|
||||||
std::optional<LOGLEVEL> Settings::ParseLogLevelName(const char* str)
|
std::optional<LOGLEVEL> Settings::ParseLogLevelName(const char* str)
|
||||||
{
|
{
|
||||||
|
@ -1418,11 +1419,7 @@ const char* Settings::GetDisplayAlignmentDisplayName(DisplayAlignment alignment)
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr const std::array s_display_scaling_names = {
|
static constexpr const std::array s_display_scaling_names = {
|
||||||
"Nearest",
|
"Nearest", "NearestInteger", "BilinearSmooth", "BilinearSharp", "BilinearInteger",
|
||||||
"NearestInteger",
|
|
||||||
"BilinearSmooth",
|
|
||||||
"BilinearSharp",
|
|
||||||
"BilinearInteger",
|
|
||||||
};
|
};
|
||||||
static constexpr const std::array s_display_scaling_display_names = {
|
static constexpr const std::array s_display_scaling_display_names = {
|
||||||
TRANSLATE_NOOP("DisplayScalingMode", "Nearest-Neighbor"),
|
TRANSLATE_NOOP("DisplayScalingMode", "Nearest-Neighbor"),
|
||||||
|
@ -1752,20 +1749,20 @@ void EmuFolders::LoadConfig(SettingsInterface& si)
|
||||||
Textures = LoadPathFromSettings(si, DataRoot, "Folders", "Textures", "textures");
|
Textures = LoadPathFromSettings(si, DataRoot, "Folders", "Textures", "textures");
|
||||||
UserResources = LoadPathFromSettings(si, DataRoot, "Folders", "UserResources", "resources");
|
UserResources = LoadPathFromSettings(si, DataRoot, "Folders", "UserResources", "resources");
|
||||||
|
|
||||||
Log_DevFmt("BIOS Directory: {}", Bios);
|
DEV_LOG("BIOS Directory: {}", Bios);
|
||||||
Log_DevFmt("Cache Directory: {}", Cache);
|
DEV_LOG("Cache Directory: {}", Cache);
|
||||||
Log_DevFmt("Cheats Directory: {}", Cheats);
|
DEV_LOG("Cheats Directory: {}", Cheats);
|
||||||
Log_DevFmt("Covers Directory: {}", Covers);
|
DEV_LOG("Covers Directory: {}", Covers);
|
||||||
Log_DevFmt("Dumps Directory: {}", Dumps);
|
DEV_LOG("Dumps Directory: {}", Dumps);
|
||||||
Log_DevFmt("Game Settings Directory: {}", GameSettings);
|
DEV_LOG("Game Settings Directory: {}", GameSettings);
|
||||||
Log_DevFmt("Input Profile Directory: {}", InputProfiles);
|
DEV_LOG("Input Profile Directory: {}", InputProfiles);
|
||||||
Log_DevFmt("MemoryCards Directory: {}", MemoryCards);
|
DEV_LOG("MemoryCards Directory: {}", MemoryCards);
|
||||||
Log_DevFmt("Resources Directory: {}", Resources);
|
DEV_LOG("Resources Directory: {}", Resources);
|
||||||
Log_DevFmt("SaveStates Directory: {}", SaveStates);
|
DEV_LOG("SaveStates Directory: {}", SaveStates);
|
||||||
Log_DevFmt("Screenshots Directory: {}", Screenshots);
|
DEV_LOG("Screenshots Directory: {}", Screenshots);
|
||||||
Log_DevFmt("Shaders Directory: {}", Shaders);
|
DEV_LOG("Shaders Directory: {}", Shaders);
|
||||||
Log_DevFmt("Textures Directory: {}", Textures);
|
DEV_LOG("Textures Directory: {}", Textures);
|
||||||
Log_DevFmt("User Resources Directory: {}", UserResources);
|
DEV_LOG("User Resources Directory: {}", UserResources);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuFolders::Save(SettingsInterface& si)
|
void EmuFolders::Save(SettingsInterface& si)
|
||||||
|
@ -1841,7 +1838,7 @@ std::string EmuFolders::GetOverridableResourcePath(std::string_view name)
|
||||||
if (FileSystem::FileExists(upath.c_str()))
|
if (FileSystem::FileExists(upath.c_str()))
|
||||||
{
|
{
|
||||||
if (UserResources != Resources)
|
if (UserResources != Resources)
|
||||||
Log_WarningFmt("Using user-provided resource file {}", name);
|
WARNING_LOG("Using user-provided resource file {}", name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,7 +106,7 @@ u32 SIO::ReadRegister(u32 offset)
|
||||||
{
|
{
|
||||||
case 0x00: // SIO_DATA
|
case 0x00: // SIO_DATA
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Read SIO_DATA");
|
ERROR_LOG("Read SIO_DATA");
|
||||||
|
|
||||||
const u8 value = 0xFF;
|
const u8 value = 0xFF;
|
||||||
return (ZeroExtend32(value) | (ZeroExtend32(value) << 8) | (ZeroExtend32(value) << 16) |
|
return (ZeroExtend32(value) | (ZeroExtend32(value) << 8) | (ZeroExtend32(value) << 16) |
|
||||||
|
@ -129,7 +129,7 @@ u32 SIO::ReadRegister(u32 offset)
|
||||||
return ZeroExtend32(s_SIO_BAUD);
|
return ZeroExtend32(s_SIO_BAUD);
|
||||||
|
|
||||||
[[unlikely]] default:
|
[[unlikely]] default:
|
||||||
Log_ErrorFmt("Unknown register read: 0x{:X}", offset);
|
ERROR_LOG("Unknown register read: 0x{:X}", offset);
|
||||||
return UINT32_C(0xFFFFFFFF);
|
return UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,13 +140,13 @@ void SIO::WriteRegister(u32 offset, u32 value)
|
||||||
{
|
{
|
||||||
case 0x00: // SIO_DATA
|
case 0x00: // SIO_DATA
|
||||||
{
|
{
|
||||||
Log_WarningFmt("SIO_DATA (W) <- 0x{:02X}", value);
|
WARNING_LOG("SIO_DATA (W) <- 0x{:02X}", value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x0A: // SIO_CTRL
|
case 0x0A: // SIO_CTRL
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SIO_CTRL <- 0x{:04X}", value);
|
DEBUG_LOG("SIO_CTRL <- 0x{:04X}", value);
|
||||||
|
|
||||||
s_SIO_CTRL.bits = Truncate16(value);
|
s_SIO_CTRL.bits = Truncate16(value);
|
||||||
if (s_SIO_CTRL.RESET)
|
if (s_SIO_CTRL.RESET)
|
||||||
|
@ -157,20 +157,20 @@ void SIO::WriteRegister(u32 offset, u32 value)
|
||||||
|
|
||||||
case 0x08: // SIO_MODE
|
case 0x08: // SIO_MODE
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SIO_MODE <- 0x{:08X}", value);
|
DEBUG_LOG("SIO_MODE <- 0x{:08X}", value);
|
||||||
s_SIO_MODE.bits = Truncate16(value);
|
s_SIO_MODE.bits = Truncate16(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x0E:
|
case 0x0E:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SIO_BAUD <- 0x{:08X}", value);
|
DEBUG_LOG("SIO_BAUD <- 0x{:08X}", value);
|
||||||
s_SIO_BAUD = Truncate16(value);
|
s_SIO_BAUD = Truncate16(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log_ErrorFmt("Unknown register write: 0x{:X} <- 0x{:08X}", offset, value);
|
ERROR_LOG("Unknown register write: 0x{:X} <- 0x{:08X}", offset, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
149
src/core/spu.cpp
149
src/core/spu.cpp
|
@ -430,13 +430,12 @@ void SPU::Initialize()
|
||||||
|
|
||||||
void SPU::CreateOutputStream()
|
void SPU::CreateOutputStream()
|
||||||
{
|
{
|
||||||
Log_InfoFmt(
|
INFO_LOG("Creating '{}' audio stream, sample rate = {}, expansion = {}, buffer = {}, latency = {}{}, stretching = {}",
|
||||||
"Creating '{}' audio stream, sample rate = {}, expansion = {}, buffer = {}, latency = {}{}, stretching = {}",
|
AudioStream::GetBackendName(g_settings.audio_backend), static_cast<u32>(SAMPLE_RATE),
|
||||||
AudioStream::GetBackendName(g_settings.audio_backend), static_cast<u32>(SAMPLE_RATE),
|
AudioStream::GetExpansionModeName(g_settings.audio_stream_parameters.expansion_mode),
|
||||||
AudioStream::GetExpansionModeName(g_settings.audio_stream_parameters.expansion_mode),
|
g_settings.audio_stream_parameters.buffer_ms, g_settings.audio_stream_parameters.output_latency_ms,
|
||||||
g_settings.audio_stream_parameters.buffer_ms, g_settings.audio_stream_parameters.output_latency_ms,
|
g_settings.audio_stream_parameters.output_latency_minimal ? " (or minimal)" : "",
|
||||||
g_settings.audio_stream_parameters.output_latency_minimal ? " (or minimal)" : "",
|
AudioStream::GetStretchModeName(g_settings.audio_stream_parameters.stretch_mode));
|
||||||
AudioStream::GetStretchModeName(g_settings.audio_stream_parameters.stretch_mode));
|
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
s_audio_stream =
|
s_audio_stream =
|
||||||
|
@ -665,28 +664,28 @@ u16 SPU::ReadRegister(u32 offset)
|
||||||
return s_reverb_registers.mBASE;
|
return s_reverb_registers.mBASE;
|
||||||
|
|
||||||
case 0x1F801DA4 - SPU_BASE:
|
case 0x1F801DA4 - SPU_BASE:
|
||||||
Log_TraceFmt("SPU IRQ address -> 0x{:04X}", s_irq_address);
|
TRACE_LOG("SPU IRQ address -> 0x{:04X}", s_irq_address);
|
||||||
return s_irq_address;
|
return s_irq_address;
|
||||||
|
|
||||||
case 0x1F801DA6 - SPU_BASE:
|
case 0x1F801DA6 - SPU_BASE:
|
||||||
Log_TraceFmt("SPU transfer address register -> 0x{:04X}", s_transfer_address_reg);
|
TRACE_LOG("SPU transfer address register -> 0x{:04X}", s_transfer_address_reg);
|
||||||
return s_transfer_address_reg;
|
return s_transfer_address_reg;
|
||||||
|
|
||||||
case 0x1F801DA8 - SPU_BASE:
|
case 0x1F801DA8 - SPU_BASE:
|
||||||
Log_TraceFmt("SPU transfer data register read");
|
TRACE_LOG("SPU transfer data register read");
|
||||||
return UINT16_C(0xFFFF);
|
return UINT16_C(0xFFFF);
|
||||||
|
|
||||||
case 0x1F801DAA - SPU_BASE:
|
case 0x1F801DAA - SPU_BASE:
|
||||||
Log_TraceFmt("SPU control register -> 0x{:04X}", s_SPUCNT.bits);
|
TRACE_LOG("SPU control register -> 0x{:04X}", s_SPUCNT.bits);
|
||||||
return s_SPUCNT.bits;
|
return s_SPUCNT.bits;
|
||||||
|
|
||||||
case 0x1F801DAC - SPU_BASE:
|
case 0x1F801DAC - SPU_BASE:
|
||||||
Log_TraceFmt("SPU transfer control register -> 0x{:04X}", s_transfer_control.bits);
|
TRACE_LOG("SPU transfer control register -> 0x{:04X}", s_transfer_control.bits);
|
||||||
return s_transfer_control.bits;
|
return s_transfer_control.bits;
|
||||||
|
|
||||||
case 0x1F801DAE - SPU_BASE:
|
case 0x1F801DAE - SPU_BASE:
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
Log_TraceFmt("SPU status register -> 0x{:04X}", s_SPUCNT.bits);
|
TRACE_LOG("SPU status register -> 0x{:04X}", s_SPUCNT.bits);
|
||||||
return s_SPUSTAT.bits;
|
return s_SPUSTAT.bits;
|
||||||
|
|
||||||
case 0x1F801DB0 - SPU_BASE:
|
case 0x1F801DB0 - SPU_BASE:
|
||||||
|
@ -727,7 +726,7 @@ u16 SPU::ReadRegister(u32 offset)
|
||||||
return s_voices[voice_index].right_volume.current_level;
|
return s_voices[voice_index].right_volume.current_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("Unknown SPU register read: offset 0x{:X} (address 0x{:08X})", offset, offset | SPU_BASE);
|
DEV_LOG("Unknown SPU register read: offset 0x{:X} (address 0x{:08X})", offset, offset | SPU_BASE);
|
||||||
return UINT16_C(0xFFFF);
|
return UINT16_C(0xFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -739,7 +738,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
{
|
{
|
||||||
case 0x1F801D80 - SPU_BASE:
|
case 0x1F801D80 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU main volume left <- 0x{:04X}", value);
|
DEBUG_LOG("SPU main volume left <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_main_volume_left_reg.bits = value;
|
s_main_volume_left_reg.bits = value;
|
||||||
s_main_volume_left.Reset(s_main_volume_left_reg);
|
s_main_volume_left.Reset(s_main_volume_left_reg);
|
||||||
|
@ -748,7 +747,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801D82 - SPU_BASE:
|
case 0x1F801D82 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU main volume right <- 0x{:04X}", value);
|
DEBUG_LOG("SPU main volume right <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_main_volume_right_reg.bits = value;
|
s_main_volume_right_reg.bits = value;
|
||||||
s_main_volume_right.Reset(s_main_volume_right_reg);
|
s_main_volume_right.Reset(s_main_volume_right_reg);
|
||||||
|
@ -757,7 +756,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801D84 - SPU_BASE:
|
case 0x1F801D84 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU reverb output volume left <- 0x{:04X}", value);
|
DEBUG_LOG("SPU reverb output volume left <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_reverb_registers.vLOUT = value;
|
s_reverb_registers.vLOUT = value;
|
||||||
return;
|
return;
|
||||||
|
@ -765,7 +764,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801D86 - SPU_BASE:
|
case 0x1F801D86 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU reverb output volume right <- 0x{:04X}", value);
|
DEBUG_LOG("SPU reverb output volume right <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_reverb_registers.vROUT = value;
|
s_reverb_registers.vROUT = value;
|
||||||
return;
|
return;
|
||||||
|
@ -773,7 +772,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801D88 - SPU_BASE:
|
case 0x1F801D88 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU key on low <- 0x{:04X}", value);
|
DEBUG_LOG("SPU key on low <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_key_on_register = (s_key_on_register & 0xFFFF0000) | ZeroExtend32(value);
|
s_key_on_register = (s_key_on_register & 0xFFFF0000) | ZeroExtend32(value);
|
||||||
}
|
}
|
||||||
|
@ -781,7 +780,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801D8A - SPU_BASE:
|
case 0x1F801D8A - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU key on high <- 0x{:04X}", value);
|
DEBUG_LOG("SPU key on high <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_key_on_register = (s_key_on_register & 0x0000FFFF) | (ZeroExtend32(value) << 16);
|
s_key_on_register = (s_key_on_register & 0x0000FFFF) | (ZeroExtend32(value) << 16);
|
||||||
}
|
}
|
||||||
|
@ -789,7 +788,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801D8C - SPU_BASE:
|
case 0x1F801D8C - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU key off low <- 0x{:04X}", value);
|
DEBUG_LOG("SPU key off low <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_key_off_register = (s_key_off_register & 0xFFFF0000) | ZeroExtend32(value);
|
s_key_off_register = (s_key_off_register & 0xFFFF0000) | ZeroExtend32(value);
|
||||||
}
|
}
|
||||||
|
@ -797,7 +796,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801D8E - SPU_BASE:
|
case 0x1F801D8E - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU key off high <- 0x{:04X}", value);
|
DEBUG_LOG("SPU key off high <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_key_off_register = (s_key_off_register & 0x0000FFFF) | (ZeroExtend32(value) << 16);
|
s_key_off_register = (s_key_off_register & 0x0000FFFF) | (ZeroExtend32(value) << 16);
|
||||||
}
|
}
|
||||||
|
@ -807,7 +806,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
{
|
{
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_pitch_modulation_enable_register = (s_pitch_modulation_enable_register & 0xFFFF0000) | ZeroExtend32(value);
|
s_pitch_modulation_enable_register = (s_pitch_modulation_enable_register & 0xFFFF0000) | ZeroExtend32(value);
|
||||||
Log_DebugFmt("SPU pitch modulation enable register <- 0x{:08X}", s_pitch_modulation_enable_register);
|
DEBUG_LOG("SPU pitch modulation enable register <- 0x{:08X}", s_pitch_modulation_enable_register);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -816,13 +815,13 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_pitch_modulation_enable_register =
|
s_pitch_modulation_enable_register =
|
||||||
(s_pitch_modulation_enable_register & 0x0000FFFF) | (ZeroExtend32(value) << 16);
|
(s_pitch_modulation_enable_register & 0x0000FFFF) | (ZeroExtend32(value) << 16);
|
||||||
Log_DebugFmt("SPU pitch modulation enable register <- 0x{:08X}", s_pitch_modulation_enable_register);
|
DEBUG_LOG("SPU pitch modulation enable register <- 0x{:08X}", s_pitch_modulation_enable_register);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x1F801D94 - SPU_BASE:
|
case 0x1F801D94 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU noise mode register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU noise mode register <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_noise_mode_register = (s_noise_mode_register & 0xFFFF0000) | ZeroExtend32(value);
|
s_noise_mode_register = (s_noise_mode_register & 0xFFFF0000) | ZeroExtend32(value);
|
||||||
}
|
}
|
||||||
|
@ -830,7 +829,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801D96 - SPU_BASE:
|
case 0x1F801D96 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU noise mode register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU noise mode register <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_noise_mode_register = (s_noise_mode_register & 0x0000FFFF) | (ZeroExtend32(value) << 16);
|
s_noise_mode_register = (s_noise_mode_register & 0x0000FFFF) | (ZeroExtend32(value) << 16);
|
||||||
}
|
}
|
||||||
|
@ -838,7 +837,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801D98 - SPU_BASE:
|
case 0x1F801D98 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU reverb on register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU reverb on register <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_reverb_on_register = (s_reverb_on_register & 0xFFFF0000) | ZeroExtend32(value);
|
s_reverb_on_register = (s_reverb_on_register & 0xFFFF0000) | ZeroExtend32(value);
|
||||||
}
|
}
|
||||||
|
@ -846,7 +845,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801D9A - SPU_BASE:
|
case 0x1F801D9A - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU reverb on register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU reverb on register <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_reverb_on_register = (s_reverb_on_register & 0x0000FFFF) | (ZeroExtend32(value) << 16);
|
s_reverb_on_register = (s_reverb_on_register & 0x0000FFFF) | (ZeroExtend32(value) << 16);
|
||||||
}
|
}
|
||||||
|
@ -854,7 +853,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801DA2 - SPU_BASE:
|
case 0x1F801DA2 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU reverb base address < 0x{:04X}", value);
|
DEBUG_LOG("SPU reverb base address < 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_reverb_registers.mBASE = value;
|
s_reverb_registers.mBASE = value;
|
||||||
s_reverb_base_address = ZeroExtend32(value << 2) & 0x3FFFFu;
|
s_reverb_base_address = ZeroExtend32(value << 2) & 0x3FFFFu;
|
||||||
|
@ -864,7 +863,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801DA4 - SPU_BASE:
|
case 0x1F801DA4 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU IRQ address register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU IRQ address register <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_irq_address = value;
|
s_irq_address = value;
|
||||||
|
|
||||||
|
@ -876,14 +875,14 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801DA6 - SPU_BASE:
|
case 0x1F801DA6 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU transfer address register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU transfer address register <- 0x{:04X}", value);
|
||||||
s_transfer_event->InvokeEarly();
|
s_transfer_event->InvokeEarly();
|
||||||
s_transfer_address_reg = value;
|
s_transfer_address_reg = value;
|
||||||
s_transfer_address = ZeroExtend32(value) * 8;
|
s_transfer_address = ZeroExtend32(value) * 8;
|
||||||
if (IsRAMIRQTriggerable() && CheckRAMIRQ(s_transfer_address))
|
if (IsRAMIRQTriggerable() && CheckRAMIRQ(s_transfer_address))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Trigger IRQ @ {:08X} {:04X} from transfer address reg set", s_transfer_address,
|
DEBUG_LOG("Trigger IRQ @ {:08X} {:04X} from transfer address reg set", s_transfer_address,
|
||||||
s_transfer_address / 8);
|
s_transfer_address / 8);
|
||||||
TriggerRAMIRQ();
|
TriggerRAMIRQ();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -891,8 +890,8 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801DA8 - SPU_BASE:
|
case 0x1F801DA8 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_TraceFmt("SPU transfer data register <- 0x{:04X} (RAM offset 0x{:08X})", ZeroExtend32(value),
|
TRACE_LOG("SPU transfer data register <- 0x{:04X} (RAM offset 0x{:08X})", ZeroExtend32(value),
|
||||||
s_transfer_address);
|
s_transfer_address);
|
||||||
|
|
||||||
ManualTransferWrite(value);
|
ManualTransferWrite(value);
|
||||||
return;
|
return;
|
||||||
|
@ -900,7 +899,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801DAA - SPU_BASE:
|
case 0x1F801DAA - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU control register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU control register <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
|
|
||||||
const SPUCNT new_value{value};
|
const SPUCNT new_value{value};
|
||||||
|
@ -914,14 +913,14 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
{
|
{
|
||||||
// I would guess on the console it would gradually write the FIFO out. Hopefully nothing relies on this
|
// I would guess on the console it would gradually write the FIFO out. Hopefully nothing relies on this
|
||||||
// level of timing granularity if we force it all out here.
|
// level of timing granularity if we force it all out here.
|
||||||
Log_WarningFmt("Draining write SPU transfer FIFO with {} bytes left", s_transfer_fifo.GetSize());
|
WARNING_LOG("Draining write SPU transfer FIFO with {} bytes left", s_transfer_fifo.GetSize());
|
||||||
TickCount ticks = std::numeric_limits<TickCount>::max();
|
TickCount ticks = std::numeric_limits<TickCount>::max();
|
||||||
ExecuteFIFOWriteToRAM(ticks);
|
ExecuteFIFOWriteToRAM(ticks);
|
||||||
DebugAssert(s_transfer_fifo.IsEmpty());
|
DebugAssert(s_transfer_fifo.IsEmpty());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Clearing read SPU transfer FIFO with {} bytes left", s_transfer_fifo.GetSize());
|
DEBUG_LOG("Clearing read SPU transfer FIFO with {} bytes left", s_transfer_fifo.GetSize());
|
||||||
s_transfer_fifo.Clear();
|
s_transfer_fifo.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -956,14 +955,14 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801DAC - SPU_BASE:
|
case 0x1F801DAC - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU transfer control register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU transfer control register <- 0x{:04X}", value);
|
||||||
s_transfer_control.bits = value;
|
s_transfer_control.bits = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x1F801DB0 - SPU_BASE:
|
case 0x1F801DB0 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU left cd audio register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU left cd audio register <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_cd_audio_volume_left = value;
|
s_cd_audio_volume_left = value;
|
||||||
}
|
}
|
||||||
|
@ -971,7 +970,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x1F801DB2 - SPU_BASE:
|
case 0x1F801DB2 - SPU_BASE:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU right cd audio register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU right cd audio register <- 0x{:04X}", value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_cd_audio_volume_right = value;
|
s_cd_audio_volume_right = value;
|
||||||
}
|
}
|
||||||
|
@ -980,7 +979,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
case 0x1F801DB4 - SPU_BASE:
|
case 0x1F801DB4 - SPU_BASE:
|
||||||
{
|
{
|
||||||
// External volumes aren't used, so don't bother syncing.
|
// External volumes aren't used, so don't bother syncing.
|
||||||
Log_DebugFmt("SPU left external volume register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU left external volume register <- 0x{:04X}", value);
|
||||||
s_external_volume_left = value;
|
s_external_volume_left = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -988,7 +987,7 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
case 0x1F801DB6 - SPU_BASE:
|
case 0x1F801DB6 - SPU_BASE:
|
||||||
{
|
{
|
||||||
// External volumes aren't used, so don't bother syncing.
|
// External volumes aren't used, so don't bother syncing.
|
||||||
Log_DebugFmt("SPU right external volume register <- 0x{:04X}", value);
|
DEBUG_LOG("SPU right external volume register <- 0x{:04X}", value);
|
||||||
s_external_volume_right = value;
|
s_external_volume_right = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1010,14 +1009,14 @@ void SPU::WriteRegister(u32 offset, u16 value)
|
||||||
if (offset >= (0x1F801DC0 - SPU_BASE) && offset < (0x1F801E00 - SPU_BASE))
|
if (offset >= (0x1F801DC0 - SPU_BASE) && offset < (0x1F801E00 - SPU_BASE))
|
||||||
{
|
{
|
||||||
const u32 reg = (offset - (0x1F801DC0 - SPU_BASE)) / 2;
|
const u32 reg = (offset - (0x1F801DC0 - SPU_BASE)) / 2;
|
||||||
Log_DebugFmt("SPU reverb register {} <- 0x{:04X}", reg, value);
|
DEBUG_LOG("SPU reverb register {} <- 0x{:04X}", reg, value);
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
s_reverb_registers.rev[reg] = value;
|
s_reverb_registers.rev[reg] = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("Unknown SPU register write: offset 0x{:X} (address 0x{:08X}) value 0x{:04X}", offset,
|
DEV_LOG("Unknown SPU register write: offset 0x{:X} (address 0x{:08X}) value 0x{:04X}", offset, offset | SPU_BASE,
|
||||||
offset | SPU_BASE, value);
|
value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1034,7 +1033,7 @@ u16 SPU::ReadVoiceRegister(u32 offset)
|
||||||
if (reg_index >= 6 && (voice.IsOn() || s_key_on_register & (1u << voice_index)))
|
if (reg_index >= 6 && (voice.IsOn() || s_key_on_register & (1u << voice_index)))
|
||||||
GeneratePendingSamples();
|
GeneratePendingSamples();
|
||||||
|
|
||||||
Log_TraceFmt("Read voice {} register {} -> 0x{:02X}", voice_index, reg_index, voice.regs.index[reg_index]);
|
TRACE_LOG("Read voice {} register {} -> 0x{:02X}", voice_index, reg_index, voice.regs.index[reg_index]);
|
||||||
return voice.regs.index[reg_index];
|
return voice.regs.index[reg_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1053,7 +1052,7 @@ void SPU::WriteVoiceRegister(u32 offset, u16 value)
|
||||||
{
|
{
|
||||||
case 0x00: // volume left
|
case 0x00: // volume left
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU voice {} volume left <- 0x{:04X}", voice_index, value);
|
DEBUG_LOG("SPU voice {} volume left <- 0x{:04X}", voice_index, value);
|
||||||
voice.regs.volume_left.bits = value;
|
voice.regs.volume_left.bits = value;
|
||||||
voice.left_volume.Reset(voice.regs.volume_left);
|
voice.left_volume.Reset(voice.regs.volume_left);
|
||||||
}
|
}
|
||||||
|
@ -1061,7 +1060,7 @@ void SPU::WriteVoiceRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x02: // volume right
|
case 0x02: // volume right
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU voice {} volume right <- 0x{:04X}", voice_index, value);
|
DEBUG_LOG("SPU voice {} volume right <- 0x{:04X}", voice_index, value);
|
||||||
voice.regs.volume_right.bits = value;
|
voice.regs.volume_right.bits = value;
|
||||||
voice.right_volume.Reset(voice.regs.volume_right);
|
voice.right_volume.Reset(voice.regs.volume_right);
|
||||||
}
|
}
|
||||||
|
@ -1069,21 +1068,21 @@ void SPU::WriteVoiceRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x04: // sample rate
|
case 0x04: // sample rate
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU voice {} ADPCM sample rate <- 0x{:04X}", voice_index, value);
|
DEBUG_LOG("SPU voice {} ADPCM sample rate <- 0x{:04X}", voice_index, value);
|
||||||
voice.regs.adpcm_sample_rate = value;
|
voice.regs.adpcm_sample_rate = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x06: // start address
|
case 0x06: // start address
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU voice {} ADPCM start address <- 0x{:04X}", voice_index, value);
|
DEBUG_LOG("SPU voice {} ADPCM start address <- 0x{:04X}", voice_index, value);
|
||||||
voice.regs.adpcm_start_address = value;
|
voice.regs.adpcm_start_address = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x08: // adsr low
|
case 0x08: // adsr low
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU voice {} ADSR low <- 0x{:04X} (was 0x{:04X})", voice_index, value, voice.regs.adsr.bits_low);
|
DEBUG_LOG("SPU voice {} ADSR low <- 0x{:04X} (was 0x{:04X})", voice_index, value, voice.regs.adsr.bits_low);
|
||||||
voice.regs.adsr.bits_low = value;
|
voice.regs.adsr.bits_low = value;
|
||||||
if (voice.IsOn())
|
if (voice.IsOn())
|
||||||
voice.UpdateADSREnvelope();
|
voice.UpdateADSREnvelope();
|
||||||
|
@ -1092,7 +1091,7 @@ void SPU::WriteVoiceRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x0A: // adsr high
|
case 0x0A: // adsr high
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU voice {} ADSR high <- 0x{:04X} (was 0x{:04X})", voice_index, value, voice.regs.adsr.bits_low);
|
DEBUG_LOG("SPU voice {} ADSR high <- 0x{:04X} (was 0x{:04X})", voice_index, value, voice.regs.adsr.bits_low);
|
||||||
voice.regs.adsr.bits_high = value;
|
voice.regs.adsr.bits_high = value;
|
||||||
if (voice.IsOn())
|
if (voice.IsOn())
|
||||||
voice.UpdateADSREnvelope();
|
voice.UpdateADSREnvelope();
|
||||||
|
@ -1101,7 +1100,7 @@ void SPU::WriteVoiceRegister(u32 offset, u16 value)
|
||||||
|
|
||||||
case 0x0C: // adsr volume
|
case 0x0C: // adsr volume
|
||||||
{
|
{
|
||||||
Log_DebugFmt("SPU voice {} ADSR volume <- 0x{:04X} (was 0x{:04X})", voice_index, value, voice.regs.adsr_volume);
|
DEBUG_LOG("SPU voice {} ADSR volume <- 0x{:04X} (was 0x{:04X})", voice_index, value, voice.regs.adsr_volume);
|
||||||
voice.regs.adsr_volume = value;
|
voice.regs.adsr_volume = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1115,22 +1114,22 @@ void SPU::WriteVoiceRegister(u32 offset, u16 value)
|
||||||
// - Valkyrie Profile
|
// - Valkyrie Profile
|
||||||
|
|
||||||
const bool ignore_loop_address = voice.IsOn() && !voice.is_first_block;
|
const bool ignore_loop_address = voice.IsOn() && !voice.is_first_block;
|
||||||
Log_DebugFmt("SPU voice {} ADPCM repeat address <- 0x{:04X}", voice_index, value);
|
DEBUG_LOG("SPU voice {} ADPCM repeat address <- 0x{:04X}", voice_index, value);
|
||||||
voice.regs.adpcm_repeat_address = value;
|
voice.regs.adpcm_repeat_address = value;
|
||||||
voice.ignore_loop_address |= ignore_loop_address;
|
voice.ignore_loop_address |= ignore_loop_address;
|
||||||
|
|
||||||
if (!ignore_loop_address)
|
if (!ignore_loop_address)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Not ignoring loop address, the ADPCM repeat address of 0x{:04X} for voice {} will be overwritten",
|
DEV_LOG("Not ignoring loop address, the ADPCM repeat address of 0x{:04X} for voice {} will be overwritten",
|
||||||
value, voice_index);
|
value, voice_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unknown SPU voice {} register write: offset 0x%X (address 0x{:08X}) value 0x{:04X}", offset,
|
ERROR_LOG("Unknown SPU voice {} register write: offset 0x%X (address 0x{:08X}) value 0x{:04X}", offset,
|
||||||
voice_index, offset | SPU_BASE, ZeroExtend32(value));
|
voice_index, offset | SPU_BASE, ZeroExtend32(value));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1177,7 +1176,7 @@ void SPU::CheckForLateRAMIRQs()
|
||||||
{
|
{
|
||||||
if (CheckRAMIRQ(s_transfer_address))
|
if (CheckRAMIRQ(s_transfer_address))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Trigger IRQ @ {:08X} {:04X} from late transfer", s_transfer_address, s_transfer_address / 8);
|
DEBUG_LOG("Trigger IRQ @ {:08X} {:04X} from late transfer", s_transfer_address, s_transfer_address / 8);
|
||||||
TriggerRAMIRQ();
|
TriggerRAMIRQ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1193,7 +1192,7 @@ void SPU::CheckForLateRAMIRQs()
|
||||||
const u32 address = v.current_address * 8;
|
const u32 address = v.current_address * 8;
|
||||||
if (CheckRAMIRQ(address) || CheckRAMIRQ((address + 8) & RAM_MASK))
|
if (CheckRAMIRQ(address) || CheckRAMIRQ((address + 8) & RAM_MASK))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Trigger IRQ @ {:08X} ({:04X}) from late", address, address / 8);
|
DEBUG_LOG("Trigger IRQ @ {:08X} ({:04X}) from late", address, address / 8);
|
||||||
TriggerRAMIRQ();
|
TriggerRAMIRQ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1207,7 +1206,7 @@ void SPU::WriteToCaptureBuffer(u32 index, s16 value)
|
||||||
std::memcpy(&s_ram[ram_address], &value, sizeof(value));
|
std::memcpy(&s_ram[ram_address], &value, sizeof(value));
|
||||||
if (IsRAMIRQTriggerable() && CheckRAMIRQ(ram_address))
|
if (IsRAMIRQTriggerable() && CheckRAMIRQ(ram_address))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Trigger IRQ @ {:08X} ({:04X}) from capture buffer", ram_address, ram_address / 8);
|
DEBUG_LOG("Trigger IRQ @ {:08X} ({:04X}) from capture buffer", ram_address, ram_address / 8);
|
||||||
TriggerRAMIRQ();
|
TriggerRAMIRQ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1231,7 +1230,7 @@ ALWAYS_INLINE_RELEASE void SPU::ExecuteFIFOReadFromRAM(TickCount& ticks)
|
||||||
|
|
||||||
if (IsRAMIRQTriggerable() && CheckRAMIRQ(s_transfer_address))
|
if (IsRAMIRQTriggerable() && CheckRAMIRQ(s_transfer_address))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Trigger IRQ @ {:08X} ({:04X}) from transfer read", s_transfer_address, s_transfer_address / 8);
|
DEBUG_LOG("Trigger IRQ @ {:08X} ({:04X}) from transfer read", s_transfer_address, s_transfer_address / 8);
|
||||||
TriggerRAMIRQ();
|
TriggerRAMIRQ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1248,7 +1247,7 @@ ALWAYS_INLINE_RELEASE void SPU::ExecuteFIFOWriteToRAM(TickCount& ticks)
|
||||||
|
|
||||||
if (IsRAMIRQTriggerable() && CheckRAMIRQ(s_transfer_address))
|
if (IsRAMIRQTriggerable() && CheckRAMIRQ(s_transfer_address))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Trigger IRQ @ {:08X} ({:04X}) from transfer write", s_transfer_address, s_transfer_address / 8);
|
DEBUG_LOG("Trigger IRQ @ {:08X} ({:04X}) from transfer write", s_transfer_address, s_transfer_address / 8);
|
||||||
TriggerRAMIRQ();
|
TriggerRAMIRQ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1312,7 +1311,7 @@ void SPU::ManualTransferWrite(u16 value)
|
||||||
{
|
{
|
||||||
if (!s_transfer_fifo.IsEmpty() && s_SPUCNT.ram_transfer_mode != RAMTransferMode::DMARead)
|
if (!s_transfer_fifo.IsEmpty() && s_SPUCNT.ram_transfer_mode != RAMTransferMode::DMARead)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("FIFO not empty on manual SPU write, draining to hopefully avoid corruption. Game is silly.");
|
WARNING_LOG("FIFO not empty on manual SPU write, draining to hopefully avoid corruption. Game is silly.");
|
||||||
if (s_SPUCNT.ram_transfer_mode != RAMTransferMode::Stopped)
|
if (s_SPUCNT.ram_transfer_mode != RAMTransferMode::Stopped)
|
||||||
ExecuteTransfer(nullptr, std::numeric_limits<s32>::max(), 0);
|
ExecuteTransfer(nullptr, std::numeric_limits<s32>::max(), 0);
|
||||||
}
|
}
|
||||||
|
@ -1322,7 +1321,7 @@ void SPU::ManualTransferWrite(u16 value)
|
||||||
|
|
||||||
if (IsRAMIRQTriggerable() && CheckRAMIRQ(s_transfer_address))
|
if (IsRAMIRQTriggerable() && CheckRAMIRQ(s_transfer_address))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Trigger IRQ @ {:08X} ({:04X}) from manual write", s_transfer_address, s_transfer_address / 8);
|
DEBUG_LOG("Trigger IRQ @ {:08X} ({:04X}) from manual write", s_transfer_address, s_transfer_address / 8);
|
||||||
TriggerRAMIRQ();
|
TriggerRAMIRQ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1440,7 +1439,7 @@ void SPU::DMARead(u32* words, u32 word_count)
|
||||||
fill_value = halfwords[size - 1];
|
fill_value = halfwords[size - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningFmt("Transfer FIFO underflow, filling with 0x{:04X}", fill_value);
|
WARNING_LOG("Transfer FIFO underflow, filling with 0x{:04X}", fill_value);
|
||||||
std::fill_n(&halfwords[size], halfword_count - size, fill_value);
|
std::fill_n(&halfwords[size], halfword_count - size, fill_value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1461,7 +1460,7 @@ void SPU::DMAWrite(const u32* words, u32 word_count)
|
||||||
s_transfer_fifo.PushRange(halfwords, words_to_transfer);
|
s_transfer_fifo.PushRange(halfwords, words_to_transfer);
|
||||||
|
|
||||||
if (words_to_transfer != halfword_count) [[unlikely]]
|
if (words_to_transfer != halfword_count) [[unlikely]]
|
||||||
Log_WarningFmt("Transfer FIFO overflow, dropping {} halfwords", halfword_count - words_to_transfer);
|
WARNING_LOG("Transfer FIFO overflow, dropping {} halfwords", halfword_count - words_to_transfer);
|
||||||
|
|
||||||
UpdateDMARequest();
|
UpdateDMARequest();
|
||||||
UpdateTransferEvent();
|
UpdateTransferEvent();
|
||||||
|
@ -1500,7 +1499,7 @@ bool SPU::StartDumpingAudio(const char* filename)
|
||||||
s_dump_writer = std::make_unique<WAVWriter>();
|
s_dump_writer = std::make_unique<WAVWriter>();
|
||||||
if (!s_dump_writer->Open(filename, SAMPLE_RATE, 2))
|
if (!s_dump_writer->Open(filename, SAMPLE_RATE, 2))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open '{}'", filename);
|
ERROR_LOG("Failed to open '{}'", filename);
|
||||||
s_dump_writer.reset();
|
s_dump_writer.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1520,7 +1519,7 @@ bool SPU::StartDumpingAudio(const char* filename)
|
||||||
const std::string voice_filename = Path::ReplaceExtension(filename, new_suffix);
|
const std::string voice_filename = Path::ReplaceExtension(filename, new_suffix);
|
||||||
if (!s_voice_dump_writers[i]->Open(voice_filename.c_str(), SAMPLE_RATE, 2))
|
if (!s_voice_dump_writers[i]->Open(voice_filename.c_str(), SAMPLE_RATE, 2))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open voice dump filename '{}'", voice_filename.c_str());
|
ERROR_LOG("Failed to open voice dump filename '{}'", voice_filename.c_str());
|
||||||
s_voice_dump_writers[i].reset();
|
s_voice_dump_writers[i].reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1925,7 +1924,7 @@ void SPU::ReadADPCMBlock(u16 address, ADPCMBlock* block)
|
||||||
u32 ram_address = (ZeroExtend32(address) * 8) & RAM_MASK;
|
u32 ram_address = (ZeroExtend32(address) * 8) & RAM_MASK;
|
||||||
if (IsRAMIRQTriggerable() && (CheckRAMIRQ(ram_address) || CheckRAMIRQ((ram_address + 8) & RAM_MASK)))
|
if (IsRAMIRQTriggerable() && (CheckRAMIRQ(ram_address) || CheckRAMIRQ((ram_address + 8) & RAM_MASK)))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Trigger IRQ @ {:08X} ({:04X}) from ADPCM reader", ram_address, ram_address / 8);
|
DEBUG_LOG("Trigger IRQ @ {:08X} ({:04X}) from ADPCM reader", ram_address, ram_address / 8);
|
||||||
TriggerRAMIRQ();
|
TriggerRAMIRQ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1974,7 +1973,7 @@ ALWAYS_INLINE_RELEASE std::tuple<s32, s32> SPU::SampleVoice(u32 voice_index)
|
||||||
|
|
||||||
if (voice.current_block_flags.loop_start && !voice.ignore_loop_address)
|
if (voice.current_block_flags.loop_start && !voice.ignore_loop_address)
|
||||||
{
|
{
|
||||||
Log_TraceFmt("Voice {} loop start @ 0x{:08X}", voice_index, voice.current_address);
|
TRACE_LOG("Voice {} loop start @ 0x{:08X}", voice_index, voice.current_address);
|
||||||
voice.regs.adpcm_repeat_address = voice.current_address;
|
voice.regs.adpcm_repeat_address = voice.current_address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2036,17 +2035,17 @@ ALWAYS_INLINE_RELEASE std::tuple<s32, s32> SPU::SampleVoice(u32 voice_index)
|
||||||
// End+Mute flags are ignored when noise is enabled. ADPCM data is still decoded.
|
// End+Mute flags are ignored when noise is enabled. ADPCM data is still decoded.
|
||||||
if (!IsVoiceNoiseEnabled(voice_index))
|
if (!IsVoiceNoiseEnabled(voice_index))
|
||||||
{
|
{
|
||||||
Log_TraceFmt("Voice {} loop end+mute @ 0x{:04X}", voice_index, voice.current_address);
|
TRACE_LOG("Voice {} loop end+mute @ 0x{:04X}", voice_index, voice.current_address);
|
||||||
voice.ForceOff();
|
voice.ForceOff();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_TraceFmt("IGNORING voice {} loop end+mute @ 0x{:04X}", voice_index, voice.current_address);
|
TRACE_LOG("IGNORING voice {} loop end+mute @ 0x{:04X}", voice_index, voice.current_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_TraceFmt("Voice {} loop end+repeat @ 0x{:04X}", voice_index, voice.current_address);
|
TRACE_LOG("Voice {} loop end+repeat @ 0x{:04X}", voice_index, voice.current_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,13 +288,13 @@ void System::CheckCacheLineSize()
|
||||||
const size_t runtime_cache_line_size = PlatformMisc::GetRuntimeCacheLineSize();
|
const size_t runtime_cache_line_size = PlatformMisc::GetRuntimeCacheLineSize();
|
||||||
if (runtime_cache_line_size == 0)
|
if (runtime_cache_line_size == 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Cannot determine size of cache line. Continuing with expectation of {} byte lines.",
|
ERROR_LOG("Cannot determine size of cache line. Continuing with expectation of {} byte lines.",
|
||||||
runtime_cache_line_size);
|
runtime_cache_line_size);
|
||||||
}
|
}
|
||||||
else if (HOST_CACHE_LINE_SIZE != runtime_cache_line_size)
|
else if (HOST_CACHE_LINE_SIZE != runtime_cache_line_size)
|
||||||
{
|
{
|
||||||
// Not fatal, but does have performance implications.
|
// Not fatal, but does have performance implications.
|
||||||
Log_WarningFmt(
|
WARNING_LOG(
|
||||||
"Cache line size mismatch. This build was compiled with {} byte lines, but the system has {} byte lines.",
|
"Cache line size mismatch. This build was compiled with {} byte lines, but the system has {} byte lines.",
|
||||||
HOST_CACHE_LINE_SIZE, runtime_cache_line_size);
|
HOST_CACHE_LINE_SIZE, runtime_cache_line_size);
|
||||||
}
|
}
|
||||||
|
@ -680,7 +680,7 @@ bool System::GetGameDetailsFromImage(CDImage* cdi, std::string* out_id, GameHash
|
||||||
XXH64_update(state, &track_1_length, sizeof(track_1_length));
|
XXH64_update(state, &track_1_length, sizeof(track_1_length));
|
||||||
const GameHash hash = XXH64_digest(state);
|
const GameHash hash = XXH64_digest(state);
|
||||||
XXH64_freeState(state);
|
XXH64_freeState(state);
|
||||||
Log_DevFmt("Hash for '{}' - {:016X}", exe_name, hash);
|
DEV_LOG("Hash for '{}' - {:016X}", exe_name, hash);
|
||||||
|
|
||||||
if (exe_name != FALLBACK_EXE_NAME)
|
if (exe_name != FALLBACK_EXE_NAME)
|
||||||
{
|
{
|
||||||
|
@ -798,7 +798,7 @@ std::string System::GetExecutableNameForImage(IsoReader& iso, bool strip_subdire
|
||||||
if (code.compare(0, 6, "cdrom:") == 0)
|
if (code.compare(0, 6, "cdrom:") == 0)
|
||||||
code.erase(0, 6);
|
code.erase(0, 6);
|
||||||
else
|
else
|
||||||
Log_WarningFmt("Unknown prefix in executable path: '{}'", code);
|
WARNING_LOG("Unknown prefix in executable path: '{}'", code);
|
||||||
|
|
||||||
// remove leading slashes
|
// remove leading slashes
|
||||||
while (code[0] == '/' || code[0] == '\\')
|
while (code[0] == '/' || code[0] == '\\')
|
||||||
|
@ -836,12 +836,12 @@ bool System::ReadExecutableFromImage(IsoReader& iso, std::string* out_executable
|
||||||
std::vector<u8>* out_executable_data)
|
std::vector<u8>* out_executable_data)
|
||||||
{
|
{
|
||||||
const std::string executable_path = GetExecutableNameForImage(iso, false);
|
const std::string executable_path = GetExecutableNameForImage(iso, false);
|
||||||
Log_DevFmt("Executable path: '{}'", executable_path);
|
DEV_LOG("Executable path: '{}'", executable_path);
|
||||||
if (!executable_path.empty() && out_executable_data)
|
if (!executable_path.empty() && out_executable_data)
|
||||||
{
|
{
|
||||||
if (!iso.ReadFile(executable_path.c_str(), out_executable_data))
|
if (!iso.ReadFile(executable_path.c_str(), out_executable_data))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read executable '{}' from disc", executable_path);
|
ERROR_LOG("Failed to read executable '{}' from disc", executable_path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -979,7 +979,7 @@ bool System::RecreateGPU(GPURenderer renderer, bool force_recreate_device, bool
|
||||||
StateWrapper sw(state_stream.get(), StateWrapper::Mode::Write, SAVE_STATE_VERSION);
|
StateWrapper sw(state_stream.get(), StateWrapper::Mode::Write, SAVE_STATE_VERSION);
|
||||||
const bool state_valid = g_gpu->DoState(sw, nullptr, false) && TimingEvents::DoState(sw);
|
const bool state_valid = g_gpu->DoState(sw, nullptr, false) && TimingEvents::DoState(sw);
|
||||||
if (!state_valid)
|
if (!state_valid)
|
||||||
Log_ErrorPrint("Failed to save old GPU state when switching renderers");
|
ERROR_LOG("Failed to save old GPU state when switching renderers");
|
||||||
|
|
||||||
// create new renderer
|
// create new renderer
|
||||||
g_gpu.reset();
|
g_gpu.reset();
|
||||||
|
@ -1119,7 +1119,7 @@ void System::SetDefaultSettings(SettingsInterface& si)
|
||||||
|
|
||||||
void System::ApplySettings(bool display_osd_messages)
|
void System::ApplySettings(bool display_osd_messages)
|
||||||
{
|
{
|
||||||
Log_DevPrint("Applying settings...");
|
DEV_LOG("Applying settings...");
|
||||||
|
|
||||||
const Settings old_config(std::move(g_settings));
|
const Settings old_config(std::move(g_settings));
|
||||||
g_settings = Settings();
|
g_settings = Settings();
|
||||||
|
@ -1160,17 +1160,17 @@ bool System::UpdateGameSettingsLayer()
|
||||||
std::string filename(GetGameSettingsPath(s_running_game_serial));
|
std::string filename(GetGameSettingsPath(s_running_game_serial));
|
||||||
if (FileSystem::FileExists(filename.c_str()))
|
if (FileSystem::FileExists(filename.c_str()))
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Loading game settings from '%s'...", Path::GetFileName(filename));
|
INFO_LOG("Loading game settings from '%s'...", Path::GetFileName(filename));
|
||||||
new_interface = std::make_unique<INISettingsInterface>(std::move(filename));
|
new_interface = std::make_unique<INISettingsInterface>(std::move(filename));
|
||||||
if (!new_interface->Load())
|
if (!new_interface->Load())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to parse game settings ini '%s'", new_interface->GetFileName());
|
ERROR_LOG("Failed to parse game settings ini '%s'", new_interface->GetFileName());
|
||||||
new_interface.reset();
|
new_interface.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_InfoFmt("No game settings found (tried '%s')", Path::GetFileName(filename));
|
INFO_LOG("No game settings found (tried '%s')", Path::GetFileName(filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1194,18 +1194,18 @@ bool System::UpdateGameSettingsLayer()
|
||||||
const std::string filename(GetInputProfilePath(input_profile_name));
|
const std::string filename(GetInputProfilePath(input_profile_name));
|
||||||
if (FileSystem::FileExists(filename.c_str()))
|
if (FileSystem::FileExists(filename.c_str()))
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Loading input profile from '{}'...", Path::GetFileName(filename));
|
INFO_LOG("Loading input profile from '{}'...", Path::GetFileName(filename));
|
||||||
input_interface = std::make_unique<INISettingsInterface>(std::move(filename));
|
input_interface = std::make_unique<INISettingsInterface>(std::move(filename));
|
||||||
if (!input_interface->Load())
|
if (!input_interface->Load())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to parse input profile ini '{}'", Path::GetFileName(input_interface->GetFileName()));
|
ERROR_LOG("Failed to parse input profile ini '{}'", Path::GetFileName(input_interface->GetFileName()));
|
||||||
input_interface.reset();
|
input_interface.reset();
|
||||||
input_profile_name = {};
|
input_profile_name = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("No input profile found (tried '{}')", Path::GetFileName(filename));
|
WARNING_LOG("No input profile found (tried '{}')", Path::GetFileName(filename));
|
||||||
input_profile_name = {};
|
input_profile_name = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1310,7 +1310,7 @@ bool System::LoadState(const char* filename, Error* error)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loading state from '{}'...", filename);
|
INFO_LOG("Loading state from '{}'...", filename);
|
||||||
|
|
||||||
{
|
{
|
||||||
const std::string display_name(FileSystem::GetDisplayNameFromPath(filename));
|
const std::string display_name(FileSystem::GetDisplayNameFromPath(filename));
|
||||||
|
@ -1335,7 +1335,7 @@ bool System::LoadState(const char* filename, Error* error)
|
||||||
if (IsPaused())
|
if (IsPaused())
|
||||||
InvalidateDisplay();
|
InvalidateDisplay();
|
||||||
|
|
||||||
Log_VerboseFmt("Loading state took {:.2f} msec", load_timer.GetTimeMilliseconds());
|
VERBOSE_LOG("Loading state took {:.2f} msec", load_timer.GetTimeMilliseconds());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1347,8 +1347,8 @@ bool System::SaveState(const char* filename, Error* error, bool backup_existing_
|
||||||
const std::string backup_filename = Path::ReplaceExtension(filename, "bak");
|
const std::string backup_filename = Path::ReplaceExtension(filename, "bak");
|
||||||
if (!FileSystem::RenamePath(filename, backup_filename.c_str(), &backup_error))
|
if (!FileSystem::RenamePath(filename, backup_filename.c_str(), &backup_error))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to rename save state backup '{}': {}", Path::GetFileName(backup_filename),
|
ERROR_LOG("Failed to rename save state backup '{}': {}", Path::GetFileName(backup_filename),
|
||||||
backup_error.GetDescription());
|
backup_error.GetDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1365,7 +1365,7 @@ bool System::SaveState(const char* filename, Error* error, bool backup_existing_
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Saving state to '{}'...", filename);
|
INFO_LOG("Saving state to '{}'...", filename);
|
||||||
|
|
||||||
const u32 screenshot_size = 256;
|
const u32 screenshot_size = 256;
|
||||||
const bool result = SaveStateToStream(stream.get(), error, screenshot_size,
|
const bool result = SaveStateToStream(stream.get(), error, screenshot_size,
|
||||||
|
@ -1384,7 +1384,7 @@ bool System::SaveState(const char* filename, Error* error, bool backup_existing_
|
||||||
stream->Commit();
|
stream->Commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_VerboseFmt("Saving state took {:.2f} msec", save_timer.GetTimeMilliseconds());
|
VERBOSE_LOG("Saving state took {:.2f} msec", save_timer.GetTimeMilliseconds());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1411,9 +1411,9 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.filename.empty())
|
if (parameters.filename.empty())
|
||||||
Log_InfoPrint("Boot Filename: <BIOS/Shell>");
|
INFO_LOG("Boot Filename: <BIOS/Shell>");
|
||||||
else
|
else
|
||||||
Log_InfoFmt("Boot Filename: {}", parameters.filename);
|
INFO_LOG("Boot Filename: {}", parameters.filename);
|
||||||
|
|
||||||
Assert(s_state == State::Shutdown);
|
Assert(s_state == State::Shutdown);
|
||||||
s_state = State::Starting;
|
s_state = State::Starting;
|
||||||
|
@ -1437,7 +1437,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
||||||
{
|
{
|
||||||
const DiscRegion file_region =
|
const DiscRegion file_region =
|
||||||
(do_exe_boot ? GetRegionForExe(parameters.filename.c_str()) : GetRegionForPsf(parameters.filename.c_str()));
|
(do_exe_boot ? GetRegionForExe(parameters.filename.c_str()) : GetRegionForPsf(parameters.filename.c_str()));
|
||||||
Log_InfoFmt("EXE/PSF Region: {}", Settings::GetDiscRegionDisplayName(file_region));
|
INFO_LOG("EXE/PSF Region: {}", Settings::GetDiscRegionDisplayName(file_region));
|
||||||
s_region = GetConsoleRegionForDiscRegion(file_region);
|
s_region = GetConsoleRegionForDiscRegion(file_region);
|
||||||
}
|
}
|
||||||
if (do_psf_boot)
|
if (do_psf_boot)
|
||||||
|
@ -1447,7 +1447,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Loading CD image '{}'...", Path::GetFileName(parameters.filename));
|
INFO_LOG("Loading CD image '{}'...", Path::GetFileName(parameters.filename));
|
||||||
disc = CDImage::Open(parameters.filename.c_str(), g_settings.cdrom_load_image_patches, error);
|
disc = CDImage::Open(parameters.filename.c_str(), g_settings.cdrom_load_image_patches, error);
|
||||||
if (!disc)
|
if (!disc)
|
||||||
{
|
{
|
||||||
|
@ -1464,14 +1464,14 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
||||||
if (disc_region != DiscRegion::Other)
|
if (disc_region != DiscRegion::Other)
|
||||||
{
|
{
|
||||||
s_region = GetConsoleRegionForDiscRegion(disc_region);
|
s_region = GetConsoleRegionForDiscRegion(disc_region);
|
||||||
Log_InfoFmt("Auto-detected console {} region for '{}' (region {})", Settings::GetConsoleRegionName(s_region),
|
INFO_LOG("Auto-detected console {} region for '{}' (region {})", Settings::GetConsoleRegionName(s_region),
|
||||||
parameters.filename, Settings::GetDiscRegionName(disc_region));
|
parameters.filename, Settings::GetDiscRegionName(disc_region));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_region = ConsoleRegion::NTSC_U;
|
s_region = ConsoleRegion::NTSC_U;
|
||||||
Log_WarningFmt("Could not determine console region for disc region {}. Defaulting to {}.",
|
WARNING_LOG("Could not determine console region for disc region {}. Defaulting to {}.",
|
||||||
Settings::GetDiscRegionName(disc_region), Settings::GetConsoleRegionName(s_region));
|
Settings::GetDiscRegionName(disc_region), Settings::GetConsoleRegionName(s_region));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1483,7 +1483,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
||||||
s_region = ConsoleRegion::NTSC_U;
|
s_region = ConsoleRegion::NTSC_U;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Console Region: {}", Settings::GetConsoleRegionDisplayName(s_region));
|
INFO_LOG("Console Region: {}", Settings::GetConsoleRegionDisplayName(s_region));
|
||||||
|
|
||||||
// Switch subimage.
|
// Switch subimage.
|
||||||
if (disc && parameters.media_playlist_index != 0 && !disc->SwitchSubImage(parameters.media_playlist_index, error))
|
if (disc && parameters.media_playlist_index != 0 && !disc->SwitchSubImage(parameters.media_playlist_index, error))
|
||||||
|
@ -1511,7 +1511,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Overriding boot executable: '{}'", parameters.override_exe);
|
INFO_LOG("Overriding boot executable: '{}'", parameters.override_exe);
|
||||||
exe_boot = std::move(parameters.override_exe);
|
exe_boot = std::move(parameters.override_exe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1607,11 +1607,11 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
||||||
{
|
{
|
||||||
if (!CDROM::IsMediaPS1Disc())
|
if (!CDROM::IsMediaPS1Disc())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Not fast booting non-PS1 disc.");
|
ERROR_LOG("Not fast booting non-PS1 disc.");
|
||||||
}
|
}
|
||||||
else if (!s_bios_image_info || !s_bios_image_info->patch_compatible)
|
else if (!s_bios_image_info || !s_bios_image_info->patch_compatible)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Not patching fast boot, as BIOS is not patch compatible.");
|
ERROR_LOG("Not patching fast boot, as BIOS is not patch compatible.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2006,7 +2006,7 @@ void System::FrameDone()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Skipping displaying frame");
|
DEBUG_LOG("Skipping displaying frame");
|
||||||
s_skipped_frame_count++;
|
s_skipped_frame_count++;
|
||||||
if (s_throttler_enabled)
|
if (s_throttler_enabled)
|
||||||
Throttle(current_time);
|
Throttle(current_time);
|
||||||
|
@ -2171,8 +2171,8 @@ bool System::CreateGPU(GPURenderer renderer, bool is_switching, Error* error)
|
||||||
{
|
{
|
||||||
if (g_gpu_device)
|
if (g_gpu_device)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Recreating GPU device, expecting {} got {}", GPUDevice::RenderAPIToString(api),
|
WARNING_LOG("Recreating GPU device, expecting {} got {}", GPUDevice::RenderAPIToString(api),
|
||||||
GPUDevice::RenderAPIToString(g_gpu_device->GetRenderAPI()));
|
GPUDevice::RenderAPIToString(g_gpu_device->GetRenderAPI()));
|
||||||
PostProcessing::Shutdown();
|
PostProcessing::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2194,8 +2194,8 @@ bool System::CreateGPU(GPURenderer renderer, bool is_switching, Error* error)
|
||||||
|
|
||||||
if (!g_gpu)
|
if (!g_gpu)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to initialize {} renderer, falling back to software renderer",
|
ERROR_LOG("Failed to initialize {} renderer, falling back to software renderer",
|
||||||
Settings::GetRendererName(renderer));
|
Settings::GetRendererName(renderer));
|
||||||
Host::AddFormattedOSDMessage(
|
Host::AddFormattedOSDMessage(
|
||||||
30.0f, TRANSLATE("OSDMessage", "Failed to initialize %s renderer, falling back to software renderer."),
|
30.0f, TRANSLATE("OSDMessage", "Failed to initialize %s renderer, falling back to software renderer."),
|
||||||
Settings::GetRendererName(renderer));
|
Settings::GetRendererName(renderer));
|
||||||
|
@ -2203,7 +2203,7 @@ bool System::CreateGPU(GPURenderer renderer, bool is_switching, Error* error)
|
||||||
g_gpu = GPU::CreateSoftwareRenderer();
|
g_gpu = GPU::CreateSoftwareRenderer();
|
||||||
if (!g_gpu)
|
if (!g_gpu)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create fallback software renderer.");
|
ERROR_LOG("Failed to create fallback software renderer.");
|
||||||
if (!s_keep_gpu_device_on_shutdown)
|
if (!s_keep_gpu_device_on_shutdown)
|
||||||
{
|
{
|
||||||
PostProcessing::Shutdown();
|
PostProcessing::Shutdown();
|
||||||
|
@ -2233,7 +2233,7 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
|
||||||
sw.DoBytesEx(bios_hash.bytes, sizeof(bios_hash.bytes), 58, s_bios_hash.bytes);
|
sw.DoBytesEx(bios_hash.bytes, sizeof(bios_hash.bytes), 58, s_bios_hash.bytes);
|
||||||
if (bios_hash != s_bios_hash)
|
if (bios_hash != s_bios_hash)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("BIOS hash mismatch: System: {} | State: {}", s_bios_hash.ToString(), bios_hash.ToString());
|
WARNING_LOG("BIOS hash mismatch: System: {} | State: {}", s_bios_hash.ToString(), bios_hash.ToString());
|
||||||
Host::AddKeyedOSDMessage("StateBIOSMismatch",
|
Host::AddKeyedOSDMessage("StateBIOSMismatch",
|
||||||
TRANSLATE_STR("OSDMessage",
|
TRANSLATE_STR("OSDMessage",
|
||||||
"This save state was created with a different BIOS version or patch "
|
"This save state was created with a different BIOS version or patch "
|
||||||
|
@ -2344,9 +2344,9 @@ bool System::LoadBIOS(Error* error)
|
||||||
s_bios_hash = BIOS::GetImageHash(bios_image.value());
|
s_bios_hash = BIOS::GetImageHash(bios_image.value());
|
||||||
s_bios_image_info = BIOS::GetInfoForImage(bios_image.value(), s_bios_hash);
|
s_bios_image_info = BIOS::GetInfoForImage(bios_image.value(), s_bios_hash);
|
||||||
if (s_bios_image_info)
|
if (s_bios_image_info)
|
||||||
Log_InfoFmt("Using BIOS: {}", s_bios_image_info->description);
|
INFO_LOG("Using BIOS: {}", s_bios_image_info->description);
|
||||||
else
|
else
|
||||||
Log_WarningFmt("Using an unknown BIOS: {}", s_bios_hash.ToString());
|
WARNING_LOG("Using an unknown BIOS: {}", s_bios_hash.ToString());
|
||||||
|
|
||||||
std::memcpy(Bus::g_bios, bios_image->data(), Bus::BIOS_SIZE);
|
std::memcpy(Bus::g_bios, bios_image->data(), Bus::BIOS_SIZE);
|
||||||
return true;
|
return true;
|
||||||
|
@ -2451,7 +2451,7 @@ bool System::LoadStateFromStream(ByteStream* state, Error* error, bool update_di
|
||||||
std::unique_ptr<CDImage> old_media = CDROM::RemoveMedia(false);
|
std::unique_ptr<CDImage> old_media = CDROM::RemoveMedia(false);
|
||||||
if (old_media && old_media->GetFileName() == media_filename)
|
if (old_media && old_media->GetFileName() == media_filename)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Re-using same media '{}'", media_filename);
|
INFO_LOG("Re-using same media '{}'", media_filename);
|
||||||
media = std::move(old_media);
|
media = std::move(old_media);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2498,7 +2498,7 @@ bool System::LoadStateFromStream(ByteStream* state, Error* error, bool update_di
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Switched to subimage {} in '{}'", header.media_subimage_index, media_filename.c_str());
|
INFO_LOG("Switched to subimage {} in '{}'", header.media_subimage_index, media_filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2600,7 +2600,7 @@ bool System::SaveStateToStream(ByteStream* state, Error* error, u32 screenshot_s
|
||||||
const u32 screenshot_height =
|
const u32 screenshot_height =
|
||||||
std::max(1u, static_cast<u32>(static_cast<float>(screenshot_width) /
|
std::max(1u, static_cast<u32>(static_cast<float>(screenshot_width) /
|
||||||
((display_aspect_ratio > 0.0f) ? display_aspect_ratio : 1.0f)));
|
((display_aspect_ratio > 0.0f) ? display_aspect_ratio : 1.0f)));
|
||||||
Log_VerboseFmt("Saving {}x{} screenshot for state", screenshot_width, screenshot_height);
|
VERBOSE_LOG("Saving {}x{} screenshot for state", screenshot_width, screenshot_height);
|
||||||
|
|
||||||
std::vector<u32> screenshot_buffer;
|
std::vector<u32> screenshot_buffer;
|
||||||
u32 screenshot_stride;
|
u32 screenshot_stride;
|
||||||
|
@ -2613,8 +2613,8 @@ bool System::SaveStateToStream(ByteStream* state, Error* error, u32 screenshot_s
|
||||||
{
|
{
|
||||||
if (screenshot_stride != (screenshot_width * sizeof(u32)))
|
if (screenshot_stride != (screenshot_width * sizeof(u32)))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Failed to save {}x{} screenshot for save state due to incorrect stride(%u)", screenshot_width,
|
WARNING_LOG("Failed to save {}x{} screenshot for save state due to incorrect stride(%u)", screenshot_width,
|
||||||
screenshot_height, screenshot_stride);
|
screenshot_height, screenshot_stride);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2634,8 +2634,8 @@ bool System::SaveStateToStream(ByteStream* state, Error* error, u32 screenshot_s
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Failed to save {}x{} screenshot for save state due to render/conversion failure",
|
WARNING_LOG("Failed to save {}x{} screenshot for save state due to render/conversion failure", screenshot_width,
|
||||||
screenshot_width, screenshot_height);
|
screenshot_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2758,9 +2758,8 @@ void System::UpdatePerformanceCounters()
|
||||||
if (s_pre_frame_sleep)
|
if (s_pre_frame_sleep)
|
||||||
UpdatePreFrameSleepTime();
|
UpdatePreFrameSleepTime();
|
||||||
|
|
||||||
Log_VerboseFmt("FPS: {:.2f} VPS: {:.2f} CPU: {:.2f} GPU: {:.2f} Average: {:.2f}ms Min: {:.2f}ms Max: {:.2f}ms", s_fps,
|
VERBOSE_LOG("FPS: {:.2f} VPS: {:.2f} CPU: {:.2f} GPU: {:.2f} Average: {:.2f}ms Min: {:.2f}ms Max: {:.2f}ms", s_fps,
|
||||||
s_vps, s_cpu_thread_usage, s_gpu_usage, s_average_frame_time, s_minimum_frame_time,
|
s_vps, s_cpu_thread_usage, s_gpu_usage, s_average_frame_time, s_minimum_frame_time, s_maximum_frame_time);
|
||||||
s_maximum_frame_time);
|
|
||||||
|
|
||||||
Host::OnPerformanceCountersUpdated();
|
Host::OnPerformanceCountersUpdated();
|
||||||
}
|
}
|
||||||
|
@ -2797,9 +2796,9 @@ void System::AccumulatePreFrameSleepTime()
|
||||||
{
|
{
|
||||||
s_pre_frame_sleep_time = Common::AlignDown(max_sleep_time_for_this_frame,
|
s_pre_frame_sleep_time = Common::AlignDown(max_sleep_time_for_this_frame,
|
||||||
static_cast<unsigned int>(Common::Timer::ConvertMillisecondsToValue(1)));
|
static_cast<unsigned int>(Common::Timer::ConvertMillisecondsToValue(1)));
|
||||||
Log_DevFmt("Adjust pre-frame time to {} ms due to overrun of {} ms",
|
DEV_LOG("Adjust pre-frame time to {} ms due to overrun of {} ms",
|
||||||
Common::Timer::ConvertValueToMilliseconds(s_pre_frame_sleep_time),
|
Common::Timer::ConvertValueToMilliseconds(s_pre_frame_sleep_time),
|
||||||
Common::Timer::ConvertValueToMilliseconds(s_last_active_frame_time));
|
Common::Timer::ConvertValueToMilliseconds(s_last_active_frame_time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2811,9 +2810,9 @@ void System::UpdatePreFrameSleepTime()
|
||||||
s_max_active_frame_time + Common::Timer::ConvertMillisecondsToValue(g_settings.display_pre_frame_sleep_buffer);
|
s_max_active_frame_time + Common::Timer::ConvertMillisecondsToValue(g_settings.display_pre_frame_sleep_buffer);
|
||||||
s_pre_frame_sleep_time = Common::AlignDown(s_frame_period - std::min(expected_frame_time, s_frame_period),
|
s_pre_frame_sleep_time = Common::AlignDown(s_frame_period - std::min(expected_frame_time, s_frame_period),
|
||||||
static_cast<unsigned int>(Common::Timer::ConvertMillisecondsToValue(1)));
|
static_cast<unsigned int>(Common::Timer::ConvertMillisecondsToValue(1)));
|
||||||
Log_DevFmt("Set pre-frame time to {} ms (expected frame time of {} ms)",
|
DEV_LOG("Set pre-frame time to {} ms (expected frame time of {} ms)",
|
||||||
Common::Timer::ConvertValueToMilliseconds(s_pre_frame_sleep_time),
|
Common::Timer::ConvertValueToMilliseconds(s_pre_frame_sleep_time),
|
||||||
Common::Timer::ConvertValueToMilliseconds(expected_frame_time));
|
Common::Timer::ConvertValueToMilliseconds(expected_frame_time));
|
||||||
|
|
||||||
s_max_active_frame_time = 0;
|
s_max_active_frame_time = 0;
|
||||||
}
|
}
|
||||||
|
@ -2856,8 +2855,8 @@ void System::UpdateSpeedLimiterState()
|
||||||
{
|
{
|
||||||
const float ratio = host_refresh_rate.value() / System::GetThrottleFrequency();
|
const float ratio = host_refresh_rate.value() / System::GetThrottleFrequency();
|
||||||
s_syncing_to_host = (ratio >= 0.95f && ratio <= 1.05f);
|
s_syncing_to_host = (ratio >= 0.95f && ratio <= 1.05f);
|
||||||
Log_InfoFmt("Refresh rate: Host={}hz Guest={}hz Ratio={} - {}", host_refresh_rate.value(),
|
INFO_LOG("Refresh rate: Host={}hz Guest={}hz Ratio={} - {}", host_refresh_rate.value(),
|
||||||
System::GetThrottleFrequency(), ratio, s_syncing_to_host ? "can sync" : "can't sync");
|
System::GetThrottleFrequency(), ratio, s_syncing_to_host ? "can sync" : "can't sync");
|
||||||
if (s_syncing_to_host)
|
if (s_syncing_to_host)
|
||||||
s_target_speed *= ratio;
|
s_target_speed *= ratio;
|
||||||
}
|
}
|
||||||
|
@ -2867,11 +2866,11 @@ void System::UpdateSpeedLimiterState()
|
||||||
s_syncing_to_host_with_vsync = (s_syncing_to_host && IsHostVSyncEffectivelyEnabled());
|
s_syncing_to_host_with_vsync = (s_syncing_to_host && IsHostVSyncEffectivelyEnabled());
|
||||||
if (s_syncing_to_host_with_vsync)
|
if (s_syncing_to_host_with_vsync)
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Using host vsync for throttling.");
|
INFO_LOG("Using host vsync for throttling.");
|
||||||
s_throttler_enabled = false;
|
s_throttler_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_VerboseFmt("Target speed: {}%", s_target_speed * 100.0f);
|
VERBOSE_LOG("Target speed: {}%", s_target_speed * 100.0f);
|
||||||
|
|
||||||
// Update audio output.
|
// Update audio output.
|
||||||
AudioStream* stream = SPU::GetOutputStream();
|
AudioStream* stream = SPU::GetOutputStream();
|
||||||
|
@ -2890,10 +2889,10 @@ void System::UpdateDisplaySync()
|
||||||
{
|
{
|
||||||
const bool vsync_enabled = IsHostVSyncEffectivelyEnabled();
|
const bool vsync_enabled = IsHostVSyncEffectivelyEnabled();
|
||||||
const float max_display_fps = (s_throttler_enabled || s_syncing_to_host) ? 0.0f : g_settings.display_max_fps;
|
const float max_display_fps = (s_throttler_enabled || s_syncing_to_host) ? 0.0f : g_settings.display_max_fps;
|
||||||
Log_VerboseFmt("VSync: {}{}", vsync_enabled ? "Enabled" : "Disabled",
|
VERBOSE_LOG("VSync: {}{}", vsync_enabled ? "Enabled" : "Disabled",
|
||||||
s_syncing_to_host_with_vsync ? " (for throttling)" : "");
|
s_syncing_to_host_with_vsync ? " (for throttling)" : "");
|
||||||
Log_VerboseFmt("Max display fps: {}", max_display_fps);
|
VERBOSE_LOG("Max display fps: {}", max_display_fps);
|
||||||
Log_VerboseFmt("Preset timing: {}", s_optimal_frame_pacing ? "consistent" : "immediate");
|
VERBOSE_LOG("Preset timing: {}", s_optimal_frame_pacing ? "consistent" : "immediate");
|
||||||
|
|
||||||
g_gpu_device->SetDisplayMaxFPS(max_display_fps);
|
g_gpu_device->SetDisplayMaxFPS(max_display_fps);
|
||||||
g_gpu_device->SetVSyncEnabled(vsync_enabled, vsync_enabled && !IsHostVSyncUsedForTiming());
|
g_gpu_device->SetVSyncEnabled(vsync_enabled, vsync_enabled && !IsHostVSyncUsedForTiming());
|
||||||
|
@ -3015,7 +3014,7 @@ static bool LoadEXEToRAM(const char* filename, bool patch_bios)
|
||||||
std::FILE* fp = FileSystem::OpenCFile(filename, "rb");
|
std::FILE* fp = FileSystem::OpenCFile(filename, "rb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open exe file '{}'", filename);
|
ERROR_LOG("Failed to open exe file '{}'", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3026,7 +3025,7 @@ static bool LoadEXEToRAM(const char* filename, bool patch_bios)
|
||||||
BIOS::PSEXEHeader header;
|
BIOS::PSEXEHeader header;
|
||||||
if (std::fread(&header, sizeof(header), 1, fp) != 1 || !BIOS::IsValidPSExeHeader(header, file_size))
|
if (std::fread(&header, sizeof(header), 1, fp) != 1 || !BIOS::IsValidPSExeHeader(header, file_size))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("'{}' is not a valid PS-EXE", filename);
|
ERROR_LOG("'{}' is not a valid PS-EXE", filename);
|
||||||
std::fclose(fp);
|
std::fclose(fp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3076,7 +3075,7 @@ bool System::LoadEXE(const char* filename)
|
||||||
const std::string libps_path(Path::BuildRelativePath(filename, "libps.exe"));
|
const std::string libps_path(Path::BuildRelativePath(filename, "libps.exe"));
|
||||||
if (!libps_path.empty() && FileSystem::FileExists(libps_path.c_str()) && !LoadEXEToRAM(libps_path.c_str(), false))
|
if (!libps_path.empty() && FileSystem::FileExists(libps_path.c_str()) && !LoadEXEToRAM(libps_path.c_str(), false))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to load libps.exe from '{}'", libps_path.c_str());
|
ERROR_LOG("Failed to load libps.exe from '{}'", libps_path.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3359,7 +3358,7 @@ void System::UpdateMemoryCardTypes()
|
||||||
if (card)
|
if (card)
|
||||||
{
|
{
|
||||||
if (const std::string& filename = card->GetFilename(); !filename.empty())
|
if (const std::string& filename = card->GetFilename(); !filename.empty())
|
||||||
Log_InfoFmt("Memory Card Slot {}: {}", i + 1, filename);
|
INFO_LOG("Memory Card Slot {}: {}", i + 1, filename);
|
||||||
|
|
||||||
Pad::SetMemoryCard(i, std::move(card));
|
Pad::SetMemoryCard(i, std::move(card));
|
||||||
}
|
}
|
||||||
|
@ -3380,7 +3379,7 @@ void System::UpdatePerGameMemoryCards()
|
||||||
if (card)
|
if (card)
|
||||||
{
|
{
|
||||||
if (const std::string& filename = card->GetFilename(); !filename.empty())
|
if (const std::string& filename = card->GetFilename(); !filename.empty())
|
||||||
Log_InfoFmt("Memory Card Slot {}: {}", i + 1, filename);
|
INFO_LOG("Memory Card Slot {}: {}", i + 1, filename);
|
||||||
|
|
||||||
Pad::SetMemoryCard(i, std::move(card));
|
Pad::SetMemoryCard(i, std::move(card));
|
||||||
}
|
}
|
||||||
|
@ -3528,7 +3527,7 @@ bool System::InsertMedia(const char* path)
|
||||||
const DiscRegion region = GetRegionForImage(image.get());
|
const DiscRegion region = GetRegionForImage(image.get());
|
||||||
UpdateRunningGame(path, image.get(), false);
|
UpdateRunningGame(path, image.get(), false);
|
||||||
CDROM::InsertMedia(std::move(image), region);
|
CDROM::InsertMedia(std::move(image), region);
|
||||||
Log_InfoFmt("Inserted media from {} ({}, {})", s_running_game_path, s_running_game_serial, s_running_game_title);
|
INFO_LOG("Inserted media from {} ({}, {})", s_running_game_path, s_running_game_serial, s_running_game_title);
|
||||||
if (g_settings.cdrom_load_image_to_ram)
|
if (g_settings.cdrom_load_image_to_ram)
|
||||||
CDROM::PrecacheMedia();
|
CDROM::PrecacheMedia();
|
||||||
|
|
||||||
|
@ -3641,7 +3640,7 @@ bool System::CheckForSBIFile(CDImage* image, Error* error)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningFmt("SBI file missing but required for {} ({})", s_running_game_serial, s_running_game_title);
|
WARNING_LOG("SBI file missing but required for {} ({})", s_running_game_serial, s_running_game_title);
|
||||||
|
|
||||||
if (Host::GetBoolSettingValue("CDROM", "AllowBootingWithoutSBIFile", false))
|
if (Host::GetBoolSettingValue("CDROM", "AllowBootingWithoutSBIFile", false))
|
||||||
{
|
{
|
||||||
|
@ -4133,7 +4132,7 @@ void System::LogUnsafeSettingsToConsole(const SmallStringBase& messages)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log_WarningPrint(console_messages);
|
WARNING_LOG(console_messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::CalculateRewindMemoryUsage(u32 num_saves, u32 resolution_scale, u64* ram_usage, u64* vram_usage)
|
void System::CalculateRewindMemoryUsage(u32 num_saves, u32 resolution_scale, u64* ram_usage, u64* vram_usage)
|
||||||
|
@ -4163,9 +4162,9 @@ void System::UpdateMemorySaveStateSettings()
|
||||||
|
|
||||||
u64 ram_usage, vram_usage;
|
u64 ram_usage, vram_usage;
|
||||||
CalculateRewindMemoryUsage(g_settings.rewind_save_slots, g_settings.gpu_resolution_scale, &ram_usage, &vram_usage);
|
CalculateRewindMemoryUsage(g_settings.rewind_save_slots, g_settings.gpu_resolution_scale, &ram_usage, &vram_usage);
|
||||||
Log_InfoFmt("Rewind is enabled, saving every {} frames, with {} slots and {}MB RAM and {}MB VRAM usage",
|
INFO_LOG("Rewind is enabled, saving every {} frames, with {} slots and {}MB RAM and {}MB VRAM usage",
|
||||||
std::max(s_rewind_save_frequency, 1), g_settings.rewind_save_slots, ram_usage / 1048576,
|
std::max(s_rewind_save_frequency, 1), g_settings.rewind_save_slots, ram_usage / 1048576,
|
||||||
vram_usage / 1048576);
|
vram_usage / 1048576);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4179,7 +4178,7 @@ void System::UpdateMemorySaveStateSettings()
|
||||||
s_runahead_frames = g_settings.runahead_frames;
|
s_runahead_frames = g_settings.runahead_frames;
|
||||||
s_runahead_replay_pending = false;
|
s_runahead_replay_pending = false;
|
||||||
if (s_runahead_frames > 0)
|
if (s_runahead_frames > 0)
|
||||||
Log_InfoFmt("Runahead is active with {} frames", s_runahead_frames);
|
INFO_LOG("Runahead is active with {} frames", s_runahead_frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool System::LoadMemoryState(const MemorySaveState& mss)
|
bool System::LoadMemoryState(const MemorySaveState& mss)
|
||||||
|
@ -4209,7 +4208,7 @@ bool System::SaveMemoryState(MemorySaveState* mss)
|
||||||
StateWrapper sw(mss->state_stream.get(), StateWrapper::Mode::Write, SAVE_STATE_VERSION);
|
StateWrapper sw(mss->state_stream.get(), StateWrapper::Mode::Write, SAVE_STATE_VERSION);
|
||||||
if (!DoState(sw, &host_texture, false, true))
|
if (!DoState(sw, &host_texture, false, true))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create rewind state.");
|
ERROR_LOG("Failed to create rewind state.");
|
||||||
delete host_texture;
|
delete host_texture;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -4239,8 +4238,8 @@ bool System::SaveRewindState()
|
||||||
s_rewind_states.push_back(std::move(mss));
|
s_rewind_states.push_back(std::move(mss));
|
||||||
|
|
||||||
#ifdef PROFILE_MEMORY_SAVE_STATES
|
#ifdef PROFILE_MEMORY_SAVE_STATES
|
||||||
Log_DevFmt("Saved rewind state ({} bytes, took {:.4f} ms)", s_rewind_states.back().state_stream->GetSize(),
|
DEV_LOG("Saved rewind state ({} bytes, took {:.4f} ms)", s_rewind_states.back().state_stream->GetSize(),
|
||||||
save_timer.GetTimeMilliseconds());
|
save_timer.GetTimeMilliseconds());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -4269,7 +4268,7 @@ bool System::LoadRewindState(u32 skip_saves /*= 0*/, bool consume_state /*=true
|
||||||
s_rewind_states.pop_back();
|
s_rewind_states.pop_back();
|
||||||
|
|
||||||
#ifdef PROFILE_MEMORY_SAVE_STATES
|
#ifdef PROFILE_MEMORY_SAVE_STATES
|
||||||
Log_DevFmt("Rewind load took {:.4f} ms", load_timer.GetTimeMilliseconds());
|
DEV_LOG("Rewind load took {:.4f} ms", load_timer.GetTimeMilliseconds());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -4336,7 +4335,7 @@ void System::SaveRunaheadState()
|
||||||
|
|
||||||
if (!SaveMemoryState(&mss))
|
if (!SaveMemoryState(&mss))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to save runahead state.");
|
ERROR_LOG("Failed to save runahead state.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4352,7 +4351,7 @@ bool System::DoRunahead()
|
||||||
if (s_runahead_replay_pending)
|
if (s_runahead_replay_pending)
|
||||||
{
|
{
|
||||||
#ifdef PROFILE_MEMORY_SAVE_STATES
|
#ifdef PROFILE_MEMORY_SAVE_STATES
|
||||||
Log_DevFmt("runahead starting at frame {}", s_frame_number);
|
DEV_LOG("runahead starting at frame {}", s_frame_number);
|
||||||
replay_timer.Reset();
|
replay_timer.Reset();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4374,7 +4373,7 @@ bool System::DoRunahead()
|
||||||
SPU::SetAudioOutputMuted(true);
|
SPU::SetAudioOutputMuted(true);
|
||||||
|
|
||||||
#ifdef PROFILE_MEMORY_SAVE_STATES
|
#ifdef PROFILE_MEMORY_SAVE_STATES
|
||||||
Log_VerboseFmt("Rewound to frame {}, took {:.2f} ms", s_frame_number, replay_timer.GetTimeMilliseconds());
|
VERBOSE_LOG("Rewound to frame {}, took {:.2f} ms", s_frame_number, replay_timer.GetTimeMilliseconds());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// we don't want to save the frame we just loaded. but we are "one frame ahead", because the frame we just tossed
|
// we don't want to save the frame we just loaded. but we are "one frame ahead", because the frame we just tossed
|
||||||
|
@ -4395,14 +4394,14 @@ bool System::DoRunahead()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PROFILE_MEMORY_SAVE_STATES
|
#ifdef PROFILE_MEMORY_SAVE_STATES
|
||||||
Log_VerboseFmt("Running {} frames to catch up took {:.2f} ms", s_runahead_frames, replay_timer.GetTimeMilliseconds());
|
VERBOSE_LOG("Running {} frames to catch up took {:.2f} ms", s_runahead_frames, replay_timer.GetTimeMilliseconds());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// we're all caught up. this frame gets saved in DoMemoryStates().
|
// we're all caught up. this frame gets saved in DoMemoryStates().
|
||||||
SPU::SetAudioOutputMuted(false);
|
SPU::SetAudioOutputMuted(false);
|
||||||
|
|
||||||
#ifdef PROFILE_MEMORY_SAVE_STATES
|
#ifdef PROFILE_MEMORY_SAVE_STATES
|
||||||
Log_DevFmt("runahead ending at frame {}, took {:.2f} ms", s_frame_number, replay_timer.GetTimeMilliseconds());
|
DEV_LOG("runahead ending at frame {}, took {:.2f} ms", s_frame_number, replay_timer.GetTimeMilliseconds());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -4414,7 +4413,7 @@ void System::SetRunaheadReplayFlag()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef PROFILE_MEMORY_SAVE_STATES
|
#ifdef PROFILE_MEMORY_SAVE_STATES
|
||||||
Log_DevPrint("Runahead rewind pending...");
|
DEV_LOG("Runahead rewind pending...");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s_runahead_replay_pending = true;
|
s_runahead_replay_pending = true;
|
||||||
|
@ -4480,7 +4479,7 @@ bool System::UndoLoadState()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoPrint("Loaded undo save state.");
|
INFO_LOG("Loaded undo save state.");
|
||||||
m_undo_load_state.reset();
|
m_undo_load_state.reset();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4501,7 +4500,7 @@ bool System::SaveUndoLoadState()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Saved undo load state: {} bytes", m_undo_load_state->GetSize());
|
INFO_LOG("Saved undo load state: {} bytes", m_undo_load_state->GetSize());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4737,11 +4736,11 @@ void System::DeleteSaveStates(const char* serial, bool resume)
|
||||||
if (si.global || (!resume && si.slot < 0))
|
if (si.global || (!resume && si.slot < 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Log_InfoFmt("Removing save state '{}'", Path::GetFileName(si.path));
|
INFO_LOG("Removing save state '{}'", Path::GetFileName(si.path));
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
if (!FileSystem::DeleteFile(si.path.c_str(), &error)) [[unlikely]]
|
if (!FileSystem::DeleteFile(si.path.c_str(), &error)) [[unlikely]]
|
||||||
Log_ErrorFmt("Failed to delete save state file '{}': {}", Path::GetFileName(si.path), error.GetDescription());
|
ERROR_LOG("Failed to delete save state file '{}': {}", Path::GetFileName(si.path), error.GetDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4903,7 +4902,7 @@ bool System::LoadCheatListFromDatabase()
|
||||||
if (!cl->LoadFromPackage(s_running_game_serial))
|
if (!cl->LoadFromPackage(s_running_game_serial))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} cheats from database.", cl->GetCodeCount());
|
INFO_LOG("Loaded {} cheats from database.", cl->GetCodeCount());
|
||||||
SetCheatList(std::move(cl));
|
SetCheatList(std::move(cl));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,9 +113,9 @@ void TextureReplacements::DumpVRAMWrite(u32 width, u32 height, const void* pixel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Dumping {}x{} VRAM write to '{}'", width, height, Path::GetFileName(filename));
|
INFO_LOG("Dumping {}x{} VRAM write to '{}'", width, height, Path::GetFileName(filename));
|
||||||
if (!image.SaveToFile(filename.c_str())) [[unlikely]]
|
if (!image.SaveToFile(filename.c_str())) [[unlikely]]
|
||||||
Log_ErrorFmt("Failed to dump {}x{} VRAM write to '{}'", width, height, filename);
|
ERROR_LOG("Failed to dump {}x{} VRAM write to '{}'", width, height, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureReplacements::Shutdown()
|
void TextureReplacements::Shutdown()
|
||||||
|
@ -255,7 +255,7 @@ void TextureReplacements::FindTextures(const std::string& dir)
|
||||||
auto it = m_vram_write_replacements.find(hash);
|
auto it = m_vram_write_replacements.find(hash);
|
||||||
if (it != m_vram_write_replacements.end())
|
if (it != m_vram_write_replacements.end())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Duplicate VRAM write replacement: '{}' and '{}'", it->second, fd.FileName);
|
WARNING_LOG("Duplicate VRAM write replacement: '{}' and '{}'", it->second, fd.FileName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ void TextureReplacements::FindTextures(const std::string& dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Found {} replacement VRAM writes for '{}'", m_vram_write_replacements.size(), m_game_id);
|
INFO_LOG("Found {} replacement VRAM writes for '{}'", m_vram_write_replacements.size(), m_game_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TextureReplacementTexture* TextureReplacements::LoadTexture(const std::string& filename)
|
const TextureReplacementTexture* TextureReplacements::LoadTexture(const std::string& filename)
|
||||||
|
@ -277,11 +277,11 @@ const TextureReplacementTexture* TextureReplacements::LoadTexture(const std::str
|
||||||
RGBA8Image image;
|
RGBA8Image image;
|
||||||
if (!image.LoadFromFile(filename.c_str()))
|
if (!image.LoadFromFile(filename.c_str()))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to load '%s'", Path::GetFileName(filename));
|
ERROR_LOG("Failed to load '%s'", Path::GetFileName(filename));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loaded '{}': {}x{}", Path::GetFileName(filename), image.GetWidth(), image.GetHeight());
|
INFO_LOG("Loaded '{}': {}x{}", Path::GetFileName(filename), image.GetWidth(), image.GetHeight());
|
||||||
it = m_texture_cache.emplace(filename, std::move(image)).first;
|
it = m_texture_cache.emplace(filename, std::move(image)).first;
|
||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,7 @@ void Timers::CheckForIRQ(u32 timer, u32 old_counter)
|
||||||
if (!cs.irq_done || cs.mode.irq_repeat)
|
if (!cs.irq_done || cs.mode.irq_repeat)
|
||||||
{
|
{
|
||||||
// this is actually low for a few cycles
|
// this is actually low for a few cycles
|
||||||
Log_DebugFmt("Raising timer {} pulse IRQ", timer);
|
DEBUG_LOG("Raising timer {} pulse IRQ", timer);
|
||||||
InterruptController::SetLineState(irqnum, false);
|
InterruptController::SetLineState(irqnum, false);
|
||||||
InterruptController::SetLineState(irqnum, true);
|
InterruptController::SetLineState(irqnum, true);
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ void Timers::CheckForIRQ(u32 timer, u32 old_counter)
|
||||||
// TODO: How does the non-repeat mode work here?
|
// TODO: How does the non-repeat mode work here?
|
||||||
cs.mode.interrupt_request_n ^= true;
|
cs.mode.interrupt_request_n ^= true;
|
||||||
if (!cs.mode.interrupt_request_n)
|
if (!cs.mode.interrupt_request_n)
|
||||||
Log_DebugFmt("Raising timer {} alternate IRQ", timer);
|
DEBUG_LOG("Raising timer {} alternate IRQ", timer);
|
||||||
|
|
||||||
InterruptController::SetLineState(irqnum, !cs.mode.interrupt_request_n);
|
InterruptController::SetLineState(irqnum, !cs.mode.interrupt_request_n);
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ u32 Timers::ReadRegister(u32 offset)
|
||||||
const u32 port_offset = offset & u32(0x0F);
|
const u32 port_offset = offset & u32(0x0F);
|
||||||
if (timer_index >= 3) [[unlikely]]
|
if (timer_index >= 3) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Timer read out of range: offset 0x{:02X}", offset);
|
ERROR_LOG("Timer read out of range: offset 0x{:02X}", offset);
|
||||||
return UINT32_C(0xFFFFFFFF);
|
return UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ u32 Timers::ReadRegister(u32 offset)
|
||||||
return cs.target;
|
return cs.target;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
[[unlikely]] Log_ErrorFmt("Read unknown register in timer {} (offset 0x{:02X})", timer_index, offset);
|
[[unlikely]] ERROR_LOG("Read unknown register in timer {} (offset 0x{:02X})", timer_index, offset);
|
||||||
return UINT32_C(0xFFFFFFFF);
|
return UINT32_C(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ void Timers::WriteRegister(u32 offset, u32 value)
|
||||||
const u32 port_offset = offset & u32(0x0F);
|
const u32 port_offset = offset & u32(0x0F);
|
||||||
if (timer_index >= 3) [[unlikely]]
|
if (timer_index >= 3) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Timer write out of range: offset 0{:02X} value 0x{:08X}", offset, value);
|
ERROR_LOG("Timer write out of range: offset 0{:02X} value 0x{:08X}", offset, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ void Timers::WriteRegister(u32 offset, u32 value)
|
||||||
case 0x00:
|
case 0x00:
|
||||||
{
|
{
|
||||||
const u32 old_counter = cs.counter;
|
const u32 old_counter = cs.counter;
|
||||||
Log_DebugFmt("Timer {} write counter {}", timer_index, value);
|
DEBUG_LOG("Timer {} write counter {}", timer_index, value);
|
||||||
cs.counter = value & u32(0xFFFF);
|
cs.counter = value & u32(0xFFFF);
|
||||||
CheckForIRQ(timer_index, old_counter);
|
CheckForIRQ(timer_index, old_counter);
|
||||||
if (timer_index == 2 || !cs.external_counting_enabled)
|
if (timer_index == 2 || !cs.external_counting_enabled)
|
||||||
|
@ -384,7 +384,7 @@ void Timers::WriteRegister(u32 offset, u32 value)
|
||||||
{
|
{
|
||||||
static constexpr u32 WRITE_MASK = 0b1110001111111111;
|
static constexpr u32 WRITE_MASK = 0b1110001111111111;
|
||||||
|
|
||||||
Log_DebugFmt("Timer {} write mode register 0x{:04X}", timer_index, value);
|
DEBUG_LOG("Timer {} write mode register 0x{:04X}", timer_index, value);
|
||||||
cs.mode.bits = (value & WRITE_MASK) | (cs.mode.bits & ~WRITE_MASK);
|
cs.mode.bits = (value & WRITE_MASK) | (cs.mode.bits & ~WRITE_MASK);
|
||||||
cs.use_external_clock = (cs.mode.clock_source & (timer_index == 2 ? 2 : 1)) != 0;
|
cs.use_external_clock = (cs.mode.clock_source & (timer_index == 2 ? 2 : 1)) != 0;
|
||||||
cs.counter = 0;
|
cs.counter = 0;
|
||||||
|
@ -400,7 +400,7 @@ void Timers::WriteRegister(u32 offset, u32 value)
|
||||||
|
|
||||||
case 0x08:
|
case 0x08:
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Timer %u write target 0x{:04X}", timer_index, ZeroExtend32(Truncate16(value)));
|
DEBUG_LOG("Timer %u write target 0x{:04X}", timer_index, ZeroExtend32(Truncate16(value)));
|
||||||
cs.target = value & u32(0xFFFF);
|
cs.target = value & u32(0xFFFF);
|
||||||
CheckForIRQ(timer_index, cs.counter);
|
CheckForIRQ(timer_index, cs.counter);
|
||||||
if (timer_index == 2 || !cs.external_counting_enabled)
|
if (timer_index == 2 || !cs.external_counting_enabled)
|
||||||
|
@ -409,7 +409,7 @@ void Timers::WriteRegister(u32 offset, u32 value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log_ErrorFmt("Write unknown register in timer {} (offset 0x{:02X}, value 0x{:X})", timer_index, offset, value);
|
ERROR_LOG("Write unknown register in timer {} (offset 0x{:02X}, value 0x{:X})", timer_index, offset, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,7 @@ bool DoState(StateWrapper& sw)
|
||||||
TimingEvent* event = FindActiveEvent(event_name.c_str());
|
TimingEvent* event = FindActiveEvent(event_name.c_str());
|
||||||
if (!event)
|
if (!event)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Save state has event '{}', but couldn't find this event when loading.", event_name);
|
WARNING_LOG("Save state has event '{}', but couldn't find this event when loading.", event_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ bool DoState(StateWrapper& sw)
|
||||||
sw.Do(&last_event_run_time);
|
sw.Do(&last_event_run_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("Loaded {} events from save state.", event_count);
|
DEBUG_LOG("Loaded {} events from save state.", event_count);
|
||||||
SortEvents();
|
SortEvents();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -408,7 +408,7 @@ bool DoState(StateWrapper& sw)
|
||||||
sw.Do(&event->m_interval);
|
sw.Do(&event->m_interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DebugFmt("Wrote {} events to save state.", s_active_event_count);
|
DEBUG_LOG("Wrote {} events to save state.", s_active_event_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !sw.HasError();
|
return !sw.HasError();
|
||||||
|
|
|
@ -74,7 +74,7 @@ AutoUpdaterDialog::AutoUpdaterDialog(QWidget* parent /* = nullptr */) : QDialog(
|
||||||
|
|
||||||
m_http = HTTPDownloader::Create(Host::GetHTTPUserAgent());
|
m_http = HTTPDownloader::Create(Host::GetHTTPUserAgent());
|
||||||
if (!m_http)
|
if (!m_http)
|
||||||
Log_ErrorPrint("Failed to create HTTP downloader, auto updater will not be available.");
|
ERROR_LOG("Failed to create HTTP downloader, auto updater will not be available.");
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoUpdaterDialog::~AutoUpdaterDialog() = default;
|
AutoUpdaterDialog::~AutoUpdaterDialog() = default;
|
||||||
|
@ -86,7 +86,7 @@ bool AutoUpdaterDialog::isSupported()
|
||||||
// For Linux, we need to check whether we're running from the appimage.
|
// For Linux, we need to check whether we're running from the appimage.
|
||||||
if (!std::getenv("APPIMAGE"))
|
if (!std::getenv("APPIMAGE"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("We're a CI release, but not running from an AppImage. Disabling automatic updater.");
|
INFO_LOG("We're a CI release, but not running from an AppImage. Disabling automatic updater.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ void AutoUpdaterDialog::httpPollTimerPoll()
|
||||||
|
|
||||||
if (!m_http->HasAnyRequests())
|
if (!m_http->HasAnyRequests())
|
||||||
{
|
{
|
||||||
Log_VerbosePrint("All HTTP requests done.");
|
VERBOSE_LOG("All HTTP requests done.");
|
||||||
m_http_poll_timer->stop();
|
m_http_poll_timer->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,16 +465,16 @@ bool AutoUpdaterDialog::updateNeeded() const
|
||||||
{
|
{
|
||||||
QString last_checked_sha = QString::fromStdString(Host::GetBaseStringSettingValue("AutoUpdater", "LastVersion"));
|
QString last_checked_sha = QString::fromStdString(Host::GetBaseStringSettingValue("AutoUpdater", "LastVersion"));
|
||||||
|
|
||||||
Log_InfoFmt("Current SHA: {}", g_scm_hash_str);
|
INFO_LOG("Current SHA: {}", g_scm_hash_str);
|
||||||
Log_InfoFmt("Latest SHA: {}", m_latest_sha.toUtf8().constData());
|
INFO_LOG("Latest SHA: {}", m_latest_sha.toUtf8().constData());
|
||||||
Log_InfoFmt("Last Checked SHA: {}", last_checked_sha.toUtf8().constData());
|
INFO_LOG("Last Checked SHA: {}", last_checked_sha.toUtf8().constData());
|
||||||
if (m_latest_sha == g_scm_hash_str || m_latest_sha == last_checked_sha)
|
if (m_latest_sha == g_scm_hash_str || m_latest_sha == last_checked_sha)
|
||||||
{
|
{
|
||||||
Log_InfoPrint("No update needed.");
|
INFO_LOG("No update needed.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoPrint("Update needed.");
|
INFO_LOG("Update needed.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,8 +697,8 @@ bool AutoUpdaterDialog::processUpdate(const std::vector<u8>& update_data)
|
||||||
zip_file.close();
|
zip_file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Beginning update:\nUpdater path: {}\nZip path: {}\nStaging directory: {}\nOutput directory: {}",
|
INFO_LOG("Beginning update:\nUpdater path: {}\nZip path: {}\nStaging directory: {}\nOutput directory: {}",
|
||||||
updater_app, zip_path, staging_directory, bundle_path.value());
|
updater_app, zip_path, staging_directory, bundle_path.value());
|
||||||
|
|
||||||
const std::string_view args[] = {
|
const std::string_view args[] = {
|
||||||
zip_path,
|
zip_path,
|
||||||
|
@ -735,9 +735,9 @@ bool AutoUpdaterDialog::processUpdate(const std::vector<u8>& update_data)
|
||||||
|
|
||||||
const QString new_appimage_path(qappimage_path + QStringLiteral(".new"));
|
const QString new_appimage_path(qappimage_path + QStringLiteral(".new"));
|
||||||
const QString backup_appimage_path(qappimage_path + QStringLiteral(".backup"));
|
const QString backup_appimage_path(qappimage_path + QStringLiteral(".backup"));
|
||||||
Log_InfoFmt("APPIMAGE = {}", appimage_path);
|
INFO_LOG("APPIMAGE = {}", appimage_path);
|
||||||
Log_InfoFmt("Backup AppImage path = {}", backup_appimage_path.toUtf8().constData());
|
INFO_LOG("Backup AppImage path = {}", backup_appimage_path.toUtf8().constData());
|
||||||
Log_InfoFmt("New AppImage path = {}", new_appimage_path.toUtf8().constData());
|
INFO_LOG("New AppImage path = {}", new_appimage_path.toUtf8().constData());
|
||||||
|
|
||||||
// Remove old "new" appimage and existing backup appimage.
|
// Remove old "new" appimage and existing backup appimage.
|
||||||
if (QFile::exists(new_appimage_path) && !QFile::remove(new_appimage_path))
|
if (QFile::exists(new_appimage_path) && !QFile::remove(new_appimage_path))
|
||||||
|
@ -809,11 +809,10 @@ void AutoUpdaterDialog::cleanupAfterUpdate()
|
||||||
if (!QFile::exists(backup_appimage_path))
|
if (!QFile::exists(backup_appimage_path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_InfoPrint(QStringLiteral("Removing backup AppImage %1").arg(backup_appimage_path).toStdString().c_str());
|
INFO_LOG(QStringLiteral("Removing backup AppImage %1").arg(backup_appimage_path).toStdString().c_str());
|
||||||
if (!QFile::remove(backup_appimage_path))
|
if (!QFile::remove(backup_appimage_path))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint(
|
ERROR_LOG(QStringLiteral("Failed to remove backup AppImage %1").arg(backup_appimage_path).toStdString().c_str());
|
||||||
QStringLiteral("Failed to remove backup AppImage %1").arg(backup_appimage_path).toStdString().c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -481,7 +481,7 @@ void ControllerBindingWidget::bindBindingWidgets(QWidget* parent)
|
||||||
InputBindingWidget* widget = parent->findChild<InputBindingWidget*>(QString::fromUtf8(bi.name));
|
InputBindingWidget* widget = parent->findChild<InputBindingWidget*>(QString::fromUtf8(bi.name));
|
||||||
if (!widget)
|
if (!widget)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("No widget found for '{}' ({})", bi.name, m_controller_info->name);
|
ERROR_LOG("No widget found for '{}' ({})", bi.name, m_controller_info->name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ void DisplayWidget::updateRelativeMode(bool enabled)
|
||||||
if (m_relative_mouse_enabled == enabled && m_clip_mouse_enabled == clip_cursor)
|
if (m_relative_mouse_enabled == enabled && m_clip_mouse_enabled == clip_cursor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_InfoFmt("updateRelativeMode(): relative={}, clip={}", enabled ? "yes" : "no", clip_cursor ? "yes" : "no");
|
INFO_LOG("updateRelativeMode(): relative={}, clip={}", enabled ? "yes" : "no", clip_cursor ? "yes" : "no");
|
||||||
|
|
||||||
if (!clip_cursor && m_clip_mouse_enabled)
|
if (!clip_cursor && m_clip_mouse_enabled)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ void DisplayWidget::updateRelativeMode(bool enabled)
|
||||||
if (m_relative_mouse_enabled == enabled)
|
if (m_relative_mouse_enabled == enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log_InfoFmt("updateRelativeMode(): relative={}", enabled ? "yes" : "no");
|
INFO_LOG("updateRelativeMode(): relative={}", enabled ? "yes" : "no");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
|
@ -126,12 +126,12 @@ void DisplayWidget::updateCursor(bool hidden)
|
||||||
m_cursor_hidden = hidden;
|
m_cursor_hidden = hidden;
|
||||||
if (hidden)
|
if (hidden)
|
||||||
{
|
{
|
||||||
Log_DevPrint("updateCursor(): Cursor is now hidden");
|
DEV_LOG("updateCursor(): Cursor is now hidden");
|
||||||
setCursor(Qt::BlankCursor);
|
setCursor(Qt::BlankCursor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_DevPrint("updateCursor(): Cursor is now shown");
|
DEV_LOG("updateCursor(): Cursor is now shown");
|
||||||
unsetCursor();
|
unsetCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ GDBConnection::GDBConnection(GDBServer* parent, intptr_t descriptor) : QTcpSocke
|
||||||
{
|
{
|
||||||
if (!setSocketDescriptor(descriptor))
|
if (!setSocketDescriptor(descriptor))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("{} failed to set socket descriptor: {}", descriptor, errorString().toStdString());
|
ERROR_LOG("{} failed to set socket descriptor: {}", descriptor, errorString().toStdString());
|
||||||
deleteLater();
|
deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ GDBConnection::GDBConnection(GDBServer* parent, intptr_t descriptor) : QTcpSocke
|
||||||
connect(this, &QTcpSocket::readyRead, this, &GDBConnection::receivedData);
|
connect(this, &QTcpSocket::readyRead, this, &GDBConnection::receivedData);
|
||||||
connect(this, &QTcpSocket::disconnected, this, &GDBConnection::gotDisconnected);
|
connect(this, &QTcpSocket::disconnected, this, &GDBConnection::gotDisconnected);
|
||||||
|
|
||||||
Log_InfoFmt("{} client connected", m_descriptor);
|
INFO_LOG("{} client connected", m_descriptor);
|
||||||
|
|
||||||
m_seen_resume = System::IsPaused();
|
m_seen_resume = System::IsPaused();
|
||||||
g_emu_thread->setSystemPaused(true);
|
g_emu_thread->setSystemPaused(true);
|
||||||
|
@ -29,7 +29,7 @@ GDBConnection::GDBConnection(GDBServer* parent, intptr_t descriptor) : QTcpSocke
|
||||||
|
|
||||||
void GDBConnection::gotDisconnected()
|
void GDBConnection::gotDisconnected()
|
||||||
{
|
{
|
||||||
Log_InfoFmt("{} client disconnected", m_descriptor);
|
INFO_LOG("{} client disconnected", m_descriptor);
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,19 +46,19 @@ void GDBConnection::receivedData()
|
||||||
|
|
||||||
if (GDBProtocol::IsPacketInterrupt(m_readBuffer))
|
if (GDBProtocol::IsPacketInterrupt(m_readBuffer))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("{} > Interrupt request", m_descriptor);
|
DEBUG_LOG("{} > Interrupt request", m_descriptor);
|
||||||
g_emu_thread->setSystemPaused(true);
|
g_emu_thread->setSystemPaused(true);
|
||||||
m_readBuffer.erase();
|
m_readBuffer.erase();
|
||||||
}
|
}
|
||||||
else if (GDBProtocol::IsPacketContinue(m_readBuffer))
|
else if (GDBProtocol::IsPacketContinue(m_readBuffer))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("{} > Continue request", m_descriptor);
|
DEBUG_LOG("{} > Continue request", m_descriptor);
|
||||||
g_emu_thread->setSystemPaused(false);
|
g_emu_thread->setSystemPaused(false);
|
||||||
m_readBuffer.erase();
|
m_readBuffer.erase();
|
||||||
}
|
}
|
||||||
else if (GDBProtocol::IsPacketComplete(m_readBuffer))
|
else if (GDBProtocol::IsPacketComplete(m_readBuffer))
|
||||||
{
|
{
|
||||||
Log_DebugFmt("{} > %s", m_descriptor, m_readBuffer.c_str());
|
DEBUG_LOG("{} > %s", m_descriptor, m_readBuffer.c_str());
|
||||||
writePacket(GDBProtocol::ProcessPacket(m_readBuffer));
|
writePacket(GDBProtocol::ProcessPacket(m_readBuffer));
|
||||||
m_readBuffer.erase();
|
m_readBuffer.erase();
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ void GDBConnection::receivedData()
|
||||||
}
|
}
|
||||||
if (bytesRead == -1)
|
if (bytesRead == -1)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("{} failed to read from socket: %s", m_descriptor, errorString().toStdString());
|
ERROR_LOG("{} failed to read from socket: %s", m_descriptor, errorString().toStdString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ void GDBConnection::onEmulationResumed()
|
||||||
|
|
||||||
void GDBConnection::writePacket(std::string_view packet)
|
void GDBConnection::writePacket(std::string_view packet)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("{} < {}", m_descriptor, packet);
|
DEBUG_LOG("{} < {}", m_descriptor, packet);
|
||||||
if (write(packet.data(), packet.length()) == -1)
|
if (write(packet.data(), packet.length()) == -1)
|
||||||
Log_ErrorFmt("{} failed to write to socket: {}", m_descriptor, errorString().toStdString());
|
ERROR_LOG("{} failed to write to socket: {}", m_descriptor, errorString().toStdString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ void GDBServer::start(quint16 port)
|
||||||
|
|
||||||
if (!listen(QHostAddress::LocalHost, port))
|
if (!listen(QHostAddress::LocalHost, port))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to listen on TCP port {} for GDB server: {}", port, errorString().toUtf8().constData());
|
ERROR_LOG("Failed to listen on TCP port {} for GDB server: {}", port, errorString().toUtf8().constData());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("GDB server listening on TCP port {}", port);
|
INFO_LOG("GDB server listening on TCP port {}", port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDBServer::stop()
|
void GDBServer::stop()
|
||||||
|
@ -37,7 +37,7 @@ void GDBServer::stop()
|
||||||
if (isListening())
|
if (isListening())
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
Log_InfoPrint("GDB server stopped");
|
INFO_LOG("GDB server stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QObject* connection : children())
|
for (QObject* connection : children())
|
||||||
|
|
|
@ -292,7 +292,7 @@ void LogWindow::logCallback(void* pUserParam, const char* channelName, const cha
|
||||||
qmessage.append(QUtf8StringView(message.data(), message.length()));
|
qmessage.append(QUtf8StringView(message.data(), message.length()));
|
||||||
qmessage.append(QChar('\n'));
|
qmessage.append(QChar('\n'));
|
||||||
|
|
||||||
const QLatin1StringView qchannel((level <= LOGLEVEL_PERF) ? functionName : channelName);
|
const QLatin1StringView qchannel((level <= LOGLEVEL_WARNING) ? functionName : channelName);
|
||||||
|
|
||||||
if (g_emu_thread->isOnUIThread())
|
if (g_emu_thread->isOnUIThread())
|
||||||
{
|
{
|
||||||
|
@ -331,16 +331,14 @@ void LogWindow::appendMessage(const QLatin1StringView& channel, quint32 level, c
|
||||||
temp_cursor.movePosition(QTextCursor::End);
|
temp_cursor.movePosition(QTextCursor::End);
|
||||||
|
|
||||||
{
|
{
|
||||||
static constexpr const QChar level_characters[LOGLEVEL_COUNT] = {'X', 'E', 'W', 'P', 'I', 'V', 'D', 'R', 'B', 'T'};
|
static constexpr const QChar level_characters[LOGLEVEL_COUNT] = {'X', 'E', 'W', 'I', 'V', 'D', 'B', 'T'};
|
||||||
static constexpr const QColor level_colors[LOGLEVEL_COUNT] = {
|
static constexpr const QColor level_colors[LOGLEVEL_COUNT] = {
|
||||||
QColor(255, 255, 255), // NONE
|
QColor(255, 255, 255), // NONE
|
||||||
QColor(0xE7, 0x48, 0x56), // ERROR, Red Intensity
|
QColor(0xE7, 0x48, 0x56), // ERROR, Red Intensity
|
||||||
QColor(0xF9, 0xF1, 0xA5), // WARNING, Yellow Intensity
|
QColor(0xF9, 0xF1, 0xA5), // WARNING, Yellow Intensity
|
||||||
QColor(0xB4, 0x00, 0x9E), // PERF, Purple Intensity
|
|
||||||
QColor(0xF2, 0xF2, 0xF2), // INFO, White Intensity
|
QColor(0xF2, 0xF2, 0xF2), // INFO, White Intensity
|
||||||
QColor(0x16, 0xC6, 0x0C), // VERBOSE, Green Intensity
|
QColor(0x16, 0xC6, 0x0C), // VERBOSE, Green Intensity
|
||||||
QColor(0xCC, 0xCC, 0xCC), // DEV, White
|
QColor(0xCC, 0xCC, 0xCC), // DEV, White
|
||||||
QColor(0x61, 0xD6, 0xD6), // PROFILE, Cyan Intensity
|
|
||||||
QColor(0x13, 0xA1, 0x0E), // DEBUG, Green
|
QColor(0x13, 0xA1, 0x0E), // DEBUG, Green
|
||||||
QColor(0x00, 0x37, 0xDA), // TRACE, Blue
|
QColor(0x00, 0x37, 0xDA), // TRACE, Blue
|
||||||
};
|
};
|
||||||
|
@ -358,7 +356,7 @@ void LogWindow::appendMessage(const QLatin1StringView& channel, quint32 level, c
|
||||||
temp_cursor.insertText(qtimestamp);
|
temp_cursor.insertText(qtimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString qchannel = (level <= LOGLEVEL_PERF) ?
|
const QString qchannel = (level <= LOGLEVEL_WARNING) ?
|
||||||
QStringLiteral("%1(%2): ").arg(level_characters[level]).arg(channel) :
|
QStringLiteral("%1(%2): ").arg(level_characters[level]).arg(channel) :
|
||||||
QStringLiteral("%1/%2: ").arg(level_characters[level]).arg(channel);
|
QStringLiteral("%1/%2: ").arg(level_characters[level]).arg(channel);
|
||||||
format.setForeground(QBrush(channel_color));
|
format.setForeground(QBrush(channel_color));
|
||||||
|
|
|
@ -246,10 +246,9 @@ bool MainWindow::nativeEvent(const QByteArray& eventType, void* message, qintptr
|
||||||
std::optional<WindowInfo> MainWindow::acquireRenderWindow(bool recreate_window, bool fullscreen, bool render_to_main,
|
std::optional<WindowInfo> MainWindow::acquireRenderWindow(bool recreate_window, bool fullscreen, bool render_to_main,
|
||||||
bool surfaceless, bool use_main_window_pos)
|
bool surfaceless, bool use_main_window_pos)
|
||||||
{
|
{
|
||||||
Log_DevFmt(
|
DEV_LOG("acquireRenderWindow() recreate={} fullscreen={} render_to_main={} surfaceless={} use_main_window_pos={}",
|
||||||
"acquireRenderWindow() recreate={} fullscreen={} render_to_main={} surfaceless={} use_main_window_pos={}",
|
recreate_window ? "true" : "false", fullscreen ? "true" : "false", render_to_main ? "true" : "false",
|
||||||
recreate_window ? "true" : "false", fullscreen ? "true" : "false", render_to_main ? "true" : "false",
|
surfaceless ? "true" : "false", use_main_window_pos ? "true" : "false");
|
||||||
surfaceless ? "true" : "false", use_main_window_pos ? "true" : "false");
|
|
||||||
|
|
||||||
QWidget* container =
|
QWidget* container =
|
||||||
m_display_container ? static_cast<QWidget*>(m_display_container) : static_cast<QWidget*>(m_display_widget);
|
m_display_container ? static_cast<QWidget*>(m_display_container) : static_cast<QWidget*>(m_display_widget);
|
||||||
|
@ -269,7 +268,7 @@ std::optional<WindowInfo> MainWindow::acquireRenderWindow(bool recreate_window,
|
||||||
if (m_display_created && !recreate_window && !is_rendering_to_main && !render_to_main &&
|
if (m_display_created && !recreate_window && !is_rendering_to_main && !render_to_main &&
|
||||||
has_container == needs_container && !needs_container && !changing_surfaceless)
|
has_container == needs_container && !needs_container && !changing_surfaceless)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Toggling to {} without recreating surface", (fullscreen ? "fullscreen" : "windowed"));
|
DEV_LOG("Toggling to {} without recreating surface", (fullscreen ? "fullscreen" : "windowed"));
|
||||||
|
|
||||||
// since we don't destroy the display widget, we need to save it here
|
// since we don't destroy the display widget, we need to save it here
|
||||||
if (!is_fullscreen && !is_rendering_to_main)
|
if (!is_fullscreen && !is_rendering_to_main)
|
||||||
|
|
|
@ -202,7 +202,7 @@ bool QtHost::SaveGameSettings(SettingsInterface* sif, bool delete_if_empty)
|
||||||
// if there's no keys, just toss the whole thing out
|
// if there's no keys, just toss the whole thing out
|
||||||
if (delete_if_empty && ini->IsEmpty())
|
if (delete_if_empty && ini->IsEmpty())
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Removing empty gamesettings ini {}", Path::GetFileName(ini->GetFileName()));
|
INFO_LOG("Removing empty gamesettings ini {}", Path::GetFileName(ini->GetFileName()));
|
||||||
if (FileSystem::FileExists(ini->GetFileName().c_str()) &&
|
if (FileSystem::FileExists(ini->GetFileName().c_str()) &&
|
||||||
!FileSystem::DeleteFile(ini->GetFileName().c_str(), &error))
|
!FileSystem::DeleteFile(ini->GetFileName().c_str(), &error))
|
||||||
{
|
{
|
||||||
|
@ -297,7 +297,7 @@ std::optional<bool> QtHost::DownloadFile(QWidget* parent, const QString& title,
|
||||||
|
|
||||||
bool QtHost::DownloadFile(QWidget* parent, const QString& title, std::string url, const char* path)
|
bool QtHost::DownloadFile(QWidget* parent, const QString& title, std::string url, const char* path)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Download from {}, saving to {}.", url, path);
|
INFO_LOG("Download from {}, saving to {}.", url, path);
|
||||||
|
|
||||||
std::vector<u8> data;
|
std::vector<u8> data;
|
||||||
if (!DownloadFile(parent, title, std::move(url), &data).value_or(false) || data.empty())
|
if (!DownloadFile(parent, title, std::move(url), &data).value_or(false) || data.empty())
|
||||||
|
@ -320,7 +320,7 @@ bool QtHost::DownloadFile(QWidget* parent, const QString& title, std::string url
|
||||||
bool QtHost::DownloadFileFromZip(QWidget* parent, const QString& title, std::string url, const char* zip_filename,
|
bool QtHost::DownloadFileFromZip(QWidget* parent, const QString& title, std::string url, const char* zip_filename,
|
||||||
const char* output_path)
|
const char* output_path)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Download {} from {}, saving to {}.", zip_filename, url, output_path);
|
INFO_LOG("Download {} from {}, saving to {}.", zip_filename, url, output_path);
|
||||||
|
|
||||||
std::vector<u8> data;
|
std::vector<u8> data;
|
||||||
if (!DownloadFile(parent, title, std::move(url), &data).value_or(false) || data.empty())
|
if (!DownloadFile(parent, title, std::move(url), &data).value_or(false) || data.empty())
|
||||||
|
@ -401,7 +401,7 @@ bool QtHost::InitializeConfig(std::string settings_filename)
|
||||||
settings_filename = Path::Combine(EmuFolders::DataRoot, "settings.ini");
|
settings_filename = Path::Combine(EmuFolders::DataRoot, "settings.ini");
|
||||||
|
|
||||||
const bool settings_exists = FileSystem::FileExists(settings_filename.c_str());
|
const bool settings_exists = FileSystem::FileExists(settings_filename.c_str());
|
||||||
Log_InfoFmt("Loading config from {}.", settings_filename);
|
INFO_LOG("Loading config from {}.", settings_filename);
|
||||||
s_base_settings_interface = std::make_unique<INISettingsInterface>(std::move(settings_filename));
|
s_base_settings_interface = std::make_unique<INISettingsInterface>(std::move(settings_filename));
|
||||||
Host::Internal::SetBaseSettingsLayer(s_base_settings_interface.get());
|
Host::Internal::SetBaseSettingsLayer(s_base_settings_interface.get());
|
||||||
|
|
||||||
|
@ -465,9 +465,9 @@ bool QtHost::SetCriticalFolders()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// logging of directories in case something goes wrong super early
|
// logging of directories in case something goes wrong super early
|
||||||
Log_DevFmt("AppRoot Directory: {}", EmuFolders::AppRoot);
|
DEV_LOG("AppRoot Directory: {}", EmuFolders::AppRoot);
|
||||||
Log_DevFmt("DataRoot Directory: {}", EmuFolders::DataRoot);
|
DEV_LOG("DataRoot Directory: {}", EmuFolders::DataRoot);
|
||||||
Log_DevFmt("Resources Directory: {}", EmuFolders::Resources);
|
DEV_LOG("Resources Directory: {}", EmuFolders::Resources);
|
||||||
|
|
||||||
// Write crash dumps to the data directory, since that'll be accessible for certain.
|
// Write crash dumps to the data directory, since that'll be accessible for certain.
|
||||||
CrashHandler::SetWriteDirectory(EmuFolders::DataRoot);
|
CrashHandler::SetWriteDirectory(EmuFolders::DataRoot);
|
||||||
|
@ -493,7 +493,7 @@ bool QtHost::ShouldUsePortableMode()
|
||||||
void QtHost::SetAppRoot()
|
void QtHost::SetAppRoot()
|
||||||
{
|
{
|
||||||
const std::string program_path = FileSystem::GetProgramPath();
|
const std::string program_path = FileSystem::GetProgramPath();
|
||||||
Log_InfoFmt("Program Path: {}", program_path.c_str());
|
INFO_LOG("Program Path: {}", program_path.c_str());
|
||||||
|
|
||||||
EmuFolders::AppRoot = Path::Canonicalize(Path::GetDirectory(program_path));
|
EmuFolders::AppRoot = Path::Canonicalize(Path::GetDirectory(program_path));
|
||||||
}
|
}
|
||||||
|
@ -1813,9 +1813,9 @@ void Host::ReportFatalError(std::string_view title, std::string_view message)
|
||||||
void Host::ReportErrorAsync(std::string_view title, std::string_view message)
|
void Host::ReportErrorAsync(std::string_view title, std::string_view message)
|
||||||
{
|
{
|
||||||
if (!title.empty() && !message.empty())
|
if (!title.empty() && !message.empty())
|
||||||
Log_ErrorFmt("ReportErrorAsync: {}: {}", title, message);
|
ERROR_LOG("ReportErrorAsync: {}: {}", title, message);
|
||||||
else if (!message.empty())
|
else if (!message.empty())
|
||||||
Log_ErrorFmt("ReportErrorAsync: {}", message);
|
ERROR_LOG("ReportErrorAsync: {}", message);
|
||||||
|
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(
|
||||||
g_main_window, "reportError", Qt::QueuedConnection,
|
g_main_window, "reportError", Qt::QueuedConnection,
|
||||||
|
@ -1913,7 +1913,7 @@ std::optional<std::vector<u8>> Host::ReadResourceFile(std::string_view filename,
|
||||||
const std::string path = QtHost::GetResourcePath(filename, allow_override);
|
const std::string path = QtHost::GetResourcePath(filename, allow_override);
|
||||||
std::optional<std::vector<u8>> ret(FileSystem::ReadBinaryFile(path.c_str()));
|
std::optional<std::vector<u8>> ret(FileSystem::ReadBinaryFile(path.c_str()));
|
||||||
if (!ret.has_value())
|
if (!ret.has_value())
|
||||||
Log_ErrorFmt("Failed to read resource file '{}'", filename);
|
ERROR_LOG("Failed to read resource file '{}'", filename);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1922,7 +1922,7 @@ std::optional<std::string> Host::ReadResourceFileToString(std::string_view filen
|
||||||
const std::string path = QtHost::GetResourcePath(filename, allow_override);
|
const std::string path = QtHost::GetResourcePath(filename, allow_override);
|
||||||
std::optional<std::string> ret(FileSystem::ReadFileToString(path.c_str()));
|
std::optional<std::string> ret(FileSystem::ReadFileToString(path.c_str()));
|
||||||
if (!ret.has_value())
|
if (!ret.has_value())
|
||||||
Log_ErrorFmt("Failed to read resource file to string '{}'", filename);
|
ERROR_LOG("Failed to read resource file to string '{}'", filename);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1933,7 +1933,7 @@ std::optional<std::time_t> Host::GetResourceFileTimestamp(std::string_view filen
|
||||||
FILESYSTEM_STAT_DATA sd;
|
FILESYSTEM_STAT_DATA sd;
|
||||||
if (!FileSystem::StatFile(path.c_str(), &sd))
|
if (!FileSystem::StatFile(path.c_str(), &sd))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to stat resource file '{}'", filename);
|
ERROR_LOG("Failed to stat resource file '{}'", filename);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2055,7 +2055,7 @@ void QtHost::SaveSettings()
|
||||||
Error error;
|
Error error;
|
||||||
auto lock = Host::GetSettingsLock();
|
auto lock = Host::GetSettingsLock();
|
||||||
if (!s_base_settings_interface->Save(&error))
|
if (!s_base_settings_interface->Save(&error))
|
||||||
Log_ErrorFmt("Failed to save settings: {}", error.GetDescription());
|
ERROR_LOG("Failed to save settings: {}", error.GetDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_settings_save_timer)
|
if (s_settings_save_timer)
|
||||||
|
@ -2287,88 +2287,88 @@ bool QtHost::ParseCommandLineParametersAndInitializeConfig(QApplication& app,
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-batch"))
|
else if (CHECK_ARG("-batch"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Command Line: Using batch mode.");
|
INFO_LOG("Command Line: Using batch mode.");
|
||||||
s_batch_mode = true;
|
s_batch_mode = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-nogui"))
|
else if (CHECK_ARG("-nogui"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Command Line: Using NoGUI mode.");
|
INFO_LOG("Command Line: Using NoGUI mode.");
|
||||||
s_nogui_mode = true;
|
s_nogui_mode = true;
|
||||||
s_batch_mode = true;
|
s_batch_mode = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-bios"))
|
else if (CHECK_ARG("-bios"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Command Line: Starting BIOS.");
|
INFO_LOG("Command Line: Starting BIOS.");
|
||||||
AutoBoot(autoboot);
|
AutoBoot(autoboot);
|
||||||
starting_bios = true;
|
starting_bios = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-fastboot"))
|
else if (CHECK_ARG("-fastboot"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Command Line: Forcing fast boot.");
|
INFO_LOG("Command Line: Forcing fast boot.");
|
||||||
AutoBoot(autoboot)->override_fast_boot = true;
|
AutoBoot(autoboot)->override_fast_boot = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-slowboot"))
|
else if (CHECK_ARG("-slowboot"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Command Line: Forcing slow boot.");
|
INFO_LOG("Command Line: Forcing slow boot.");
|
||||||
AutoBoot(autoboot)->override_fast_boot = false;
|
AutoBoot(autoboot)->override_fast_boot = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-resume"))
|
else if (CHECK_ARG("-resume"))
|
||||||
{
|
{
|
||||||
state_index = -1;
|
state_index = -1;
|
||||||
Log_InfoPrint("Command Line: Loading resume state.");
|
INFO_LOG("Command Line: Loading resume state.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG_PARAM("-state"))
|
else if (CHECK_ARG_PARAM("-state"))
|
||||||
{
|
{
|
||||||
state_index = args[++i].toInt();
|
state_index = args[++i].toInt();
|
||||||
Log_InfoFmt("Command Line: Loading state index: {}", state_index.value());
|
INFO_LOG("Command Line: Loading state index: {}", state_index.value());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG_PARAM("-statefile"))
|
else if (CHECK_ARG_PARAM("-statefile"))
|
||||||
{
|
{
|
||||||
AutoBoot(autoboot)->save_state = args[++i].toStdString();
|
AutoBoot(autoboot)->save_state = args[++i].toStdString();
|
||||||
Log_InfoFmt("Command Line: Loading state file: '{}'", autoboot->save_state);
|
INFO_LOG("Command Line: Loading state file: '{}'", autoboot->save_state);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG_PARAM("-exe"))
|
else if (CHECK_ARG_PARAM("-exe"))
|
||||||
{
|
{
|
||||||
AutoBoot(autoboot)->override_exe = args[++i].toStdString();
|
AutoBoot(autoboot)->override_exe = args[++i].toStdString();
|
||||||
Log_InfoFmt("Command Line: Overriding EXE file: '{}'", autoboot->override_exe);
|
INFO_LOG("Command Line: Overriding EXE file: '{}'", autoboot->override_exe);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-fullscreen"))
|
else if (CHECK_ARG("-fullscreen"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Command Line: Using fullscreen.");
|
INFO_LOG("Command Line: Using fullscreen.");
|
||||||
AutoBoot(autoboot)->override_fullscreen = true;
|
AutoBoot(autoboot)->override_fullscreen = true;
|
||||||
s_start_fullscreen_ui_fullscreen = true;
|
s_start_fullscreen_ui_fullscreen = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-nofullscreen"))
|
else if (CHECK_ARG("-nofullscreen"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Command Line: Not using fullscreen.");
|
INFO_LOG("Command Line: Not using fullscreen.");
|
||||||
AutoBoot(autoboot)->override_fullscreen = false;
|
AutoBoot(autoboot)->override_fullscreen = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-portable"))
|
else if (CHECK_ARG("-portable"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Command Line: Using portable mode.");
|
INFO_LOG("Command Line: Using portable mode.");
|
||||||
EmuFolders::DataRoot = EmuFolders::AppRoot;
|
EmuFolders::DataRoot = EmuFolders::AppRoot;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG_PARAM("-settings"))
|
else if (CHECK_ARG_PARAM("-settings"))
|
||||||
{
|
{
|
||||||
settings_filename = args[++i].toStdString();
|
settings_filename = args[++i].toStdString();
|
||||||
Log_InfoFmt("Command Line: Overriding settings filename: {}", settings_filename);
|
INFO_LOG("Command Line: Overriding settings filename: {}", settings_filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-bigpicture"))
|
else if (CHECK_ARG("-bigpicture"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Command Line: Starting big picture mode.");
|
INFO_LOG("Command Line: Starting big picture mode.");
|
||||||
s_start_fullscreen_ui = true;
|
s_start_fullscreen_ui = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ void QtHost::InstallTranslator(QWidget* dialog_parent)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loaded translation file for language {}", language.toUtf8().constData());
|
INFO_LOG("Loaded translation file for language {}", language.toUtf8().constData());
|
||||||
qApp->installTranslator(translator);
|
qApp->installTranslator(translator);
|
||||||
s_translators.push_back(translator);
|
s_translators.push_back(translator);
|
||||||
|
|
||||||
|
|
|
@ -622,7 +622,7 @@ void SettingsWindow::openGamePropertiesDialog(const std::string& path, const std
|
||||||
if (image)
|
if (image)
|
||||||
dentry = GameDatabase::GetEntryForDisc(image.get());
|
dentry = GameDatabase::GetEntryForDisc(image.get());
|
||||||
else
|
else
|
||||||
Log_ErrorFmt("Failed to open '{}' for game properties: {}", path, error.GetDescription());
|
ERROR_LOG("Failed to open '{}' for game properties: {}", path, error.GetDescription());
|
||||||
|
|
||||||
if (!dentry)
|
if (!dentry)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,7 @@ static std::string s_dump_game_directory;
|
||||||
bool RegTestHost::SetFolders()
|
bool RegTestHost::SetFolders()
|
||||||
{
|
{
|
||||||
std::string program_path(FileSystem::GetProgramPath());
|
std::string program_path(FileSystem::GetProgramPath());
|
||||||
Log_InfoFmt("Program Path: {}", program_path);
|
INFO_LOG("Program Path: {}", program_path);
|
||||||
|
|
||||||
EmuFolders::AppRoot = Path::Canonicalize(Path::GetDirectory(program_path));
|
EmuFolders::AppRoot = Path::Canonicalize(Path::GetDirectory(program_path));
|
||||||
EmuFolders::DataRoot = EmuFolders::AppRoot;
|
EmuFolders::DataRoot = EmuFolders::AppRoot;
|
||||||
|
@ -67,9 +67,9 @@ bool RegTestHost::SetFolders()
|
||||||
// On Windows/Linux, these are in the binary directory.
|
// On Windows/Linux, these are in the binary directory.
|
||||||
EmuFolders::Resources = Path::Combine(EmuFolders::AppRoot, "resources");
|
EmuFolders::Resources = Path::Combine(EmuFolders::AppRoot, "resources");
|
||||||
|
|
||||||
Log_DevFmt("AppRoot Directory: {}", EmuFolders::AppRoot);
|
DEV_LOG("AppRoot Directory: {}", EmuFolders::AppRoot);
|
||||||
Log_DevFmt("DataRoot Directory: {}", EmuFolders::DataRoot);
|
DEV_LOG("DataRoot Directory: {}", EmuFolders::DataRoot);
|
||||||
Log_DevFmt("Resources Directory: {}", EmuFolders::Resources);
|
DEV_LOG("Resources Directory: {}", EmuFolders::Resources);
|
||||||
|
|
||||||
// Write crash dumps to the data directory, since that'll be accessible for certain.
|
// Write crash dumps to the data directory, since that'll be accessible for certain.
|
||||||
CrashHandler::SetWriteDirectory(EmuFolders::DataRoot);
|
CrashHandler::SetWriteDirectory(EmuFolders::DataRoot);
|
||||||
|
@ -77,7 +77,7 @@ bool RegTestHost::SetFolders()
|
||||||
// the resources directory should exist, bail out if not
|
// the resources directory should exist, bail out if not
|
||||||
if (!FileSystem::DirectoryExists(EmuFolders::Resources.c_str()))
|
if (!FileSystem::DirectoryExists(EmuFolders::Resources.c_str()))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Resources directory is missing, your installation is incomplete.");
|
ERROR_LOG("Resources directory is missing, your installation is incomplete.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,31 +119,31 @@ bool RegTestHost::InitializeConfig()
|
||||||
|
|
||||||
void Host::ReportFatalError(std::string_view title, std::string_view message)
|
void Host::ReportFatalError(std::string_view title, std::string_view message)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("ReportFatalError: {}", message);
|
ERROR_LOG("ReportFatalError: {}", message);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::ReportErrorAsync(std::string_view title, std::string_view message)
|
void Host::ReportErrorAsync(std::string_view title, std::string_view message)
|
||||||
{
|
{
|
||||||
if (!title.empty() && !message.empty())
|
if (!title.empty() && !message.empty())
|
||||||
Log_ErrorFmt("ReportErrorAsync: {}: {}", title, message);
|
ERROR_LOG("ReportErrorAsync: {}: {}", title, message);
|
||||||
else if (!message.empty())
|
else if (!message.empty())
|
||||||
Log_ErrorFmt("ReportErrorAsync: {}", message);
|
ERROR_LOG("ReportErrorAsync: {}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Host::ConfirmMessage(std::string_view title, std::string_view message)
|
bool Host::ConfirmMessage(std::string_view title, std::string_view message)
|
||||||
{
|
{
|
||||||
if (!title.empty() && !message.empty())
|
if (!title.empty() && !message.empty())
|
||||||
Log_ErrorFmt("ConfirmMessage: {}: {}", title, message);
|
ERROR_LOG("ConfirmMessage: {}: {}", title, message);
|
||||||
else if (!message.empty())
|
else if (!message.empty())
|
||||||
Log_ErrorFmt("ConfirmMessage: {}", message);
|
ERROR_LOG("ConfirmMessage: {}", message);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::ReportDebuggerMessage(std::string_view message)
|
void Host::ReportDebuggerMessage(std::string_view message)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("ReportDebuggerMessage: {}", message);
|
ERROR_LOG("ReportDebuggerMessage: {}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::span<const std::pair<const char*, const char*>> Host::GetAvailableLanguageList()
|
std::span<const std::pair<const char*, const char*>> Host::GetAvailableLanguageList()
|
||||||
|
@ -209,7 +209,7 @@ std::optional<std::vector<u8>> Host::ReadResourceFile(std::string_view filename,
|
||||||
const std::string path(Path::Combine(EmuFolders::Resources, filename));
|
const std::string path(Path::Combine(EmuFolders::Resources, filename));
|
||||||
std::optional<std::vector<u8>> ret(FileSystem::ReadBinaryFile(path.c_str()));
|
std::optional<std::vector<u8>> ret(FileSystem::ReadBinaryFile(path.c_str()));
|
||||||
if (!ret.has_value())
|
if (!ret.has_value())
|
||||||
Log_ErrorFmt("Failed to read resource file '{}'", filename);
|
ERROR_LOG("Failed to read resource file '{}'", filename);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ std::optional<std::string> Host::ReadResourceFileToString(std::string_view filen
|
||||||
const std::string path(Path::Combine(EmuFolders::Resources, filename));
|
const std::string path(Path::Combine(EmuFolders::Resources, filename));
|
||||||
std::optional<std::string> ret(FileSystem::ReadFileToString(path.c_str()));
|
std::optional<std::string> ret(FileSystem::ReadFileToString(path.c_str()));
|
||||||
if (!ret.has_value())
|
if (!ret.has_value())
|
||||||
Log_ErrorFmt("Failed to read resource file to string '{}'", filename);
|
ERROR_LOG("Failed to read resource file to string '{}'", filename);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ std::optional<std::time_t> Host::GetResourceFileTimestamp(std::string_view filen
|
||||||
FILESYSTEM_STAT_DATA sd;
|
FILESYSTEM_STAT_DATA sd;
|
||||||
if (!FileSystem::StatFile(path.c_str(), &sd))
|
if (!FileSystem::StatFile(path.c_str(), &sd))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to stat resource file '{}'", filename);
|
ERROR_LOG("Failed to stat resource file '{}'", filename);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,21 +272,21 @@ void Host::OnPerformanceCountersUpdated()
|
||||||
|
|
||||||
void Host::OnGameChanged(const std::string& disc_path, const std::string& game_serial, const std::string& game_name)
|
void Host::OnGameChanged(const std::string& disc_path, const std::string& game_serial, const std::string& game_name)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Disc Path: {}", disc_path);
|
INFO_LOG("Disc Path: {}", disc_path);
|
||||||
Log_InfoFmt("Game Serial: {}", game_serial);
|
INFO_LOG("Game Serial: {}", game_serial);
|
||||||
Log_InfoFmt("Game Name: {}", game_name);
|
INFO_LOG("Game Name: {}", game_name);
|
||||||
|
|
||||||
if (!s_dump_base_directory.empty())
|
if (!s_dump_base_directory.empty())
|
||||||
{
|
{
|
||||||
s_dump_game_directory = Path::Combine(s_dump_base_directory, game_name);
|
s_dump_game_directory = Path::Combine(s_dump_base_directory, game_name);
|
||||||
if (!FileSystem::DirectoryExists(s_dump_game_directory.c_str()))
|
if (!FileSystem::DirectoryExists(s_dump_game_directory.c_str()))
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Creating directory '{}'...", s_dump_game_directory);
|
INFO_LOG("Creating directory '{}'...", s_dump_game_directory);
|
||||||
if (!FileSystem::CreateDirectory(s_dump_game_directory.c_str(), false))
|
if (!FileSystem::CreateDirectory(s_dump_game_directory.c_str(), false))
|
||||||
Panic("Failed to create dump directory.");
|
Panic("Failed to create dump directory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Dumping frames to '{}'...", s_dump_game_directory);
|
INFO_LOG("Dumping frames to '{}'...", s_dump_game_directory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +540,7 @@ bool RegTestHost::ParseCommandLineParameters(int argc, char* argv[], std::option
|
||||||
s_dump_base_directory = argv[++i];
|
s_dump_base_directory = argv[++i];
|
||||||
if (s_dump_base_directory.empty())
|
if (s_dump_base_directory.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid dump directory specified.");
|
ERROR_LOG("Invalid dump directory specified.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ bool RegTestHost::ParseCommandLineParameters(int argc, char* argv[], std::option
|
||||||
s_frame_dump_interval = StringUtil::FromChars<u32>(argv[++i]).value_or(0);
|
s_frame_dump_interval = StringUtil::FromChars<u32>(argv[++i]).value_or(0);
|
||||||
if (s_frames_to_run <= 0)
|
if (s_frames_to_run <= 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid dump interval specified: {}", argv[i]);
|
ERROR_LOG("Invalid dump interval specified: {}", argv[i]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ bool RegTestHost::ParseCommandLineParameters(int argc, char* argv[], std::option
|
||||||
s_frames_to_run = StringUtil::FromChars<u32>(argv[++i]).value_or(0);
|
s_frames_to_run = StringUtil::FromChars<u32>(argv[++i]).value_or(0);
|
||||||
if (s_frames_to_run == 0)
|
if (s_frames_to_run == 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid frame count specified: {}", argv[i]);
|
ERROR_LOG("Invalid frame count specified: {}", argv[i]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ bool RegTestHost::ParseCommandLineParameters(int argc, char* argv[], std::option
|
||||||
std::optional<LOGLEVEL> level = Settings::ParseLogLevelName(argv[++i]);
|
std::optional<LOGLEVEL> level = Settings::ParseLogLevelName(argv[++i]);
|
||||||
if (!level.has_value())
|
if (!level.has_value())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid log level specified.");
|
ERROR_LOG("Invalid log level specified.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ bool RegTestHost::ParseCommandLineParameters(int argc, char* argv[], std::option
|
||||||
std::optional<GPURenderer> renderer = Settings::ParseRendererName(argv[++i]);
|
std::optional<GPURenderer> renderer = Settings::ParseRendererName(argv[++i]);
|
||||||
if (!renderer.has_value())
|
if (!renderer.has_value())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid renderer specified.");
|
ERROR_LOG("Invalid renderer specified.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,11 +598,11 @@ bool RegTestHost::ParseCommandLineParameters(int argc, char* argv[], std::option
|
||||||
const u32 upscale = StringUtil::FromChars<u32>(argv[++i]).value_or(0);
|
const u32 upscale = StringUtil::FromChars<u32>(argv[++i]).value_or(0);
|
||||||
if (upscale == 0)
|
if (upscale == 0)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid upscale value.");
|
ERROR_LOG("Invalid upscale value.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Setting upscale to {}.", upscale);
|
INFO_LOG("Setting upscale to {}.", upscale);
|
||||||
s_base_settings_interface->SetIntValue("GPU", "ResolutionScale", static_cast<s32>(upscale));
|
s_base_settings_interface->SetIntValue("GPU", "ResolutionScale", static_cast<s32>(upscale));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -611,24 +611,24 @@ bool RegTestHost::ParseCommandLineParameters(int argc, char* argv[], std::option
|
||||||
const std::optional<CPUExecutionMode> cpu = Settings::ParseCPUExecutionMode(argv[++i]);
|
const std::optional<CPUExecutionMode> cpu = Settings::ParseCPUExecutionMode(argv[++i]);
|
||||||
if (!cpu.has_value())
|
if (!cpu.has_value())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid CPU execution mode.");
|
ERROR_LOG("Invalid CPU execution mode.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Setting CPU execution mode to {}.", Settings::GetCPUExecutionModeName(cpu.value()));
|
INFO_LOG("Setting CPU execution mode to {}.", Settings::GetCPUExecutionModeName(cpu.value()));
|
||||||
s_base_settings_interface->SetStringValue("CPU", "ExecutionMode",
|
s_base_settings_interface->SetStringValue("CPU", "ExecutionMode",
|
||||||
Settings::GetCPUExecutionModeName(cpu.value()));
|
Settings::GetCPUExecutionModeName(cpu.value()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-pgxp"))
|
else if (CHECK_ARG("-pgxp"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Enabling PGXP.");
|
INFO_LOG("Enabling PGXP.");
|
||||||
s_base_settings_interface->SetBoolValue("GPU", "PGXPEnable", true);
|
s_base_settings_interface->SetBoolValue("GPU", "PGXPEnable", true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (CHECK_ARG("-pgxp-cpu"))
|
else if (CHECK_ARG("-pgxp-cpu"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Enabling PGXP CPU mode.");
|
INFO_LOG("Enabling PGXP CPU mode.");
|
||||||
s_base_settings_interface->SetBoolValue("GPU", "PGXPEnable", true);
|
s_base_settings_interface->SetBoolValue("GPU", "PGXPEnable", true);
|
||||||
s_base_settings_interface->SetBoolValue("GPU", "PGXPCPU", true);
|
s_base_settings_interface->SetBoolValue("GPU", "PGXPCPU", true);
|
||||||
continue;
|
continue;
|
||||||
|
@ -640,7 +640,7 @@ bool RegTestHost::ParseCommandLineParameters(int argc, char* argv[], std::option
|
||||||
}
|
}
|
||||||
else if (argv[i][0] == '-')
|
else if (argv[i][0] == '-')
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unknown parameter: '{}'", argv[i]);
|
ERROR_LOG("Unknown parameter: '{}'", argv[i]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,7 +674,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
if (!autoboot || autoboot->filename.empty())
|
if (!autoboot || autoboot->filename.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("No boot path specified.");
|
ERROR_LOG("No boot path specified.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,7 +683,7 @@ int main(int argc, char* argv[])
|
||||||
if (!System::Internal::PerformEarlyHardwareChecks(&startup_error) ||
|
if (!System::Internal::PerformEarlyHardwareChecks(&startup_error) ||
|
||||||
!System::Internal::CPUThreadInitialize(&startup_error))
|
!System::Internal::CPUThreadInitialize(&startup_error))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CPUThreadInitialize() failed: {}", startup_error.GetDescription());
|
ERROR_LOG("CPUThreadInitialize() failed: {}", startup_error.GetDescription());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -692,10 +692,10 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
Log_InfoFmt("Trying to boot '{}'...", autoboot->filename);
|
INFO_LOG("Trying to boot '{}'...", autoboot->filename);
|
||||||
if (!System::BootSystem(std::move(autoboot.value()), &error))
|
if (!System::BootSystem(std::move(autoboot.value()), &error))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to boot system: {}", error.GetDescription());
|
ERROR_LOG("Failed to boot system: {}", error.GetDescription());
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,17 +703,17 @@ int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (s_dump_base_directory.empty())
|
if (s_dump_base_directory.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Dump directory not specified.");
|
ERROR_LOG("Dump directory not specified.");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Dumping every {}th frame to '{}'.", s_frame_dump_interval, s_dump_base_directory);
|
INFO_LOG("Dumping every {}th frame to '{}'.", s_frame_dump_interval, s_dump_base_directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Running for %d frames...", s_frames_to_run);
|
INFO_LOG("Running for %d frames...", s_frames_to_run);
|
||||||
System::Execute();
|
System::Execute();
|
||||||
|
|
||||||
Log_InfoPrint("Exiting with success.");
|
INFO_LOG("Exiting with success.");
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
|
@ -150,19 +150,19 @@ void CocoaProgressCallback::UpdateProgress()
|
||||||
|
|
||||||
void CocoaProgressCallback::DisplayError(const char* message)
|
void CocoaProgressCallback::DisplayError(const char* message)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint(message);
|
ERROR_LOG(message);
|
||||||
AppendMessage(message);
|
AppendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CocoaProgressCallback::DisplayWarning(const char* message)
|
void CocoaProgressCallback::DisplayWarning(const char* message)
|
||||||
{
|
{
|
||||||
Log_WarningPrint(message);
|
WARNING_LOG(message);
|
||||||
AppendMessage(message);
|
AppendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CocoaProgressCallback::DisplayInformation(const char* message)
|
void CocoaProgressCallback::DisplayInformation(const char* message)
|
||||||
{
|
{
|
||||||
Log_InfoPrint(message);
|
INFO_LOG(message);
|
||||||
AppendMessage(message);
|
AppendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ void CocoaProgressCallback::AppendMessage(const char* message)
|
||||||
|
|
||||||
void CocoaProgressCallback::DisplayDebugMessage(const char* message)
|
void CocoaProgressCallback::DisplayDebugMessage(const char* message)
|
||||||
{
|
{
|
||||||
Log_DevPrint(message);
|
DEV_LOG(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CocoaProgressCallback::ModalError(const char* message)
|
void CocoaProgressCallback::ModalError(const char* message)
|
||||||
|
|
|
@ -71,7 +71,7 @@ bool Win32ProgressCallback::Create()
|
||||||
wc.lpszClassName = CLASS_NAME;
|
wc.lpszClassName = CLASS_NAME;
|
||||||
if (!RegisterClassExA(&wc))
|
if (!RegisterClassExA(&wc))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to register window class");
|
ERROR_LOG("Failed to register window class");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ bool Win32ProgressCallback::Create()
|
||||||
CW_USEDEFAULT, WINDOW_WIDTH, WINDOW_HEIGHT, nullptr, nullptr, GetModuleHandle(nullptr), this);
|
CW_USEDEFAULT, WINDOW_WIDTH, WINDOW_HEIGHT, nullptr, nullptr, GetModuleHandle(nullptr), this);
|
||||||
if (!m_window_hwnd)
|
if (!m_window_hwnd)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create window");
|
ERROR_LOG("Failed to create window");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ LRESULT CALLBACK Win32ProgressCallback::WndProc(HWND hwnd, UINT msg, WPARAM wpar
|
||||||
|
|
||||||
void Win32ProgressCallback::DisplayError(const char* message)
|
void Win32ProgressCallback::DisplayError(const char* message)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint(message);
|
ERROR_LOG(message);
|
||||||
SendMessageA(m_list_box_hwnd, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(message));
|
SendMessageA(m_list_box_hwnd, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(message));
|
||||||
SendMessageA(m_list_box_hwnd, WM_VSCROLL, SB_BOTTOM, 0);
|
SendMessageA(m_list_box_hwnd, WM_VSCROLL, SB_BOTTOM, 0);
|
||||||
PumpMessages();
|
PumpMessages();
|
||||||
|
@ -195,7 +195,7 @@ void Win32ProgressCallback::DisplayError(const char* message)
|
||||||
|
|
||||||
void Win32ProgressCallback::DisplayWarning(const char* message)
|
void Win32ProgressCallback::DisplayWarning(const char* message)
|
||||||
{
|
{
|
||||||
Log_WarningPrint(message);
|
WARNING_LOG(message);
|
||||||
SendMessageA(m_list_box_hwnd, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(message));
|
SendMessageA(m_list_box_hwnd, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(message));
|
||||||
SendMessageA(m_list_box_hwnd, WM_VSCROLL, SB_BOTTOM, 0);
|
SendMessageA(m_list_box_hwnd, WM_VSCROLL, SB_BOTTOM, 0);
|
||||||
PumpMessages();
|
PumpMessages();
|
||||||
|
@ -203,7 +203,7 @@ void Win32ProgressCallback::DisplayWarning(const char* message)
|
||||||
|
|
||||||
void Win32ProgressCallback::DisplayInformation(const char* message)
|
void Win32ProgressCallback::DisplayInformation(const char* message)
|
||||||
{
|
{
|
||||||
Log_InfoPrint(message);
|
INFO_LOG(message);
|
||||||
SendMessageA(m_list_box_hwnd, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(message));
|
SendMessageA(m_list_box_hwnd, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(message));
|
||||||
SendMessageA(m_list_box_hwnd, WM_VSCROLL, SB_BOTTOM, 0);
|
SendMessageA(m_list_box_hwnd, WM_VSCROLL, SB_BOTTOM, 0);
|
||||||
PumpMessages();
|
PumpMessages();
|
||||||
|
@ -211,7 +211,7 @@ void Win32ProgressCallback::DisplayInformation(const char* message)
|
||||||
|
|
||||||
void Win32ProgressCallback::DisplayDebugMessage(const char* message)
|
void Win32ProgressCallback::DisplayDebugMessage(const char* message)
|
||||||
{
|
{
|
||||||
Log_DevPrint(message);
|
DEV_LOG(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32ProgressCallback::ModalError(const char* message)
|
void Win32ProgressCallback::ModalError(const char* message)
|
||||||
|
|
|
@ -290,7 +290,7 @@ void AudioStream::ReadFrames(SampleType* samples, u32 num_frames)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_filling = false;
|
m_filling = false;
|
||||||
Log_VerboseFmt("Underrun compensation done ({} frames buffered)", toFill);
|
VERBOSE_LOG("Underrun compensation done ({} frames buffered)", toFill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ void AudioStream::ReadFrames(SampleType* samples, u32 num_frames)
|
||||||
resample_subpos %= 65536u;
|
resample_subpos %= 65536u;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_VerboseFmt("Audio buffer underflow, resampled {} frames to {}", frames_to_read, num_frames);
|
VERBOSE_LOG("Audio buffer underflow, resampled {} frames to {}", frames_to_read, num_frames);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -441,7 +441,7 @@ void AudioStream::InternalWriteFrames(s16* data, u32 num_frames)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_DebugPrint("Buffer overrun, chunk dropped");
|
DEBUG_LOG("Buffer overrun, chunk dropped");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ void AudioStream::AllocateBuffer()
|
||||||
if (IsExpansionEnabled())
|
if (IsExpansionEnabled())
|
||||||
m_expand_buffer = std::make_unique<float[]>(m_parameters.expand_block_size * NUM_INPUT_CHANNELS);
|
m_expand_buffer = std::make_unique<float[]>(m_parameters.expand_block_size * NUM_INPUT_CHANNELS);
|
||||||
|
|
||||||
Log_DevFmt(
|
DEV_LOG(
|
||||||
"Allocated buffer of {} frames for buffer of {} ms [expansion {} (block size {}), stretch {}, target size {}].",
|
"Allocated buffer of {} frames for buffer of {} ms [expansion {} (block size {}), stretch {}, target size {}].",
|
||||||
m_buffer_size, m_parameters.buffer_ms, GetExpansionModeName(m_parameters.expansion_mode),
|
m_buffer_size, m_parameters.buffer_ms, GetExpansionModeName(m_parameters.expansion_mode),
|
||||||
m_parameters.expand_block_size, GetStretchModeName(m_parameters.stretch_mode), m_target_buffer_size);
|
m_parameters.expand_block_size, GetStretchModeName(m_parameters.stretch_mode), m_target_buffer_size);
|
||||||
|
@ -891,7 +891,7 @@ void AudioStream::UpdateStretchTempo()
|
||||||
// state vars
|
// state vars
|
||||||
if (m_stretch_reset >= STRETCH_RESET_THRESHOLD)
|
if (m_stretch_reset >= STRETCH_RESET_THRESHOLD)
|
||||||
{
|
{
|
||||||
Log_VerbosePrint("___ Stretcher is being reset.");
|
VERBOSE_LOG("___ Stretcher is being reset.");
|
||||||
m_stretch_inactive = false;
|
m_stretch_inactive = false;
|
||||||
m_stretch_ok_count = 0;
|
m_stretch_ok_count = 0;
|
||||||
m_dynamic_target_usage = base_target_usage;
|
m_dynamic_target_usage = base_target_usage;
|
||||||
|
@ -928,13 +928,13 @@ void AudioStream::UpdateStretchTempo()
|
||||||
|
|
||||||
if (m_stretch_ok_count >= INACTIVE_MIN_OK_COUNT)
|
if (m_stretch_ok_count >= INACTIVE_MIN_OK_COUNT)
|
||||||
{
|
{
|
||||||
Log_VerbosePrint("=== Stretcher is now inactive.");
|
VERBOSE_LOG("=== Stretcher is now inactive.");
|
||||||
m_stretch_inactive = true;
|
m_stretch_inactive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!IsInRange(tempo, 1.0f / INACTIVE_BAD_FACTOR, INACTIVE_BAD_FACTOR))
|
else if (!IsInRange(tempo, 1.0f / INACTIVE_BAD_FACTOR, INACTIVE_BAD_FACTOR))
|
||||||
{
|
{
|
||||||
Log_VerboseFmt("~~~ Stretcher is now active @ tempo {}.", tempo);
|
VERBOSE_LOG("~~~ Stretcher is now active @ tempo {}.", tempo);
|
||||||
m_stretch_inactive = false;
|
m_stretch_inactive = false;
|
||||||
m_stretch_ok_count = 0;
|
m_stretch_ok_count = 0;
|
||||||
}
|
}
|
||||||
|
@ -951,9 +951,9 @@ void AudioStream::UpdateStretchTempo()
|
||||||
|
|
||||||
if (Common::Timer::ConvertValueToSeconds(now - last_log_time) > 1.0f)
|
if (Common::Timer::ConvertValueToSeconds(now - last_log_time) > 1.0f)
|
||||||
{
|
{
|
||||||
Log_VerboseFmt("buffers: {:4d} ms ({:3.0f}%), tempo: {}, comp: {:2.3f}, iters: {}, reset:{}",
|
VERBOSE_LOG("buffers: {:4d} ms ({:3.0f}%), tempo: {}, comp: {:2.3f}, iters: {}, reset:{}",
|
||||||
(ibuffer_usage * 1000u) / m_sample_rate, 100.0f * buffer_usage / base_target_usage, tempo,
|
(ibuffer_usage * 1000u) / m_sample_rate, 100.0f * buffer_usage / base_target_usage, tempo,
|
||||||
m_dynamic_target_usage / base_target_usage, iterations, m_stretch_reset);
|
m_dynamic_target_usage / base_target_usage, iterations, m_stretch_reset);
|
||||||
|
|
||||||
last_log_time = now;
|
last_log_time = now;
|
||||||
iterations = 0;
|
iterations = 0;
|
||||||
|
|
|
@ -302,7 +302,7 @@ bool CDImage::ReadRawSector(void* buffer, SubChannelQ* subq)
|
||||||
// TODO: This is where we'd reconstruct the header for other mode tracks.
|
// TODO: This is where we'd reconstruct the header for other mode tracks.
|
||||||
if (!ReadSectorFromIndex(buffer, *m_current_index, m_position_in_index))
|
if (!ReadSectorFromIndex(buffer, *m_current_index, m_position_in_index))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Read of LBA {} failed", m_position_on_disc);
|
ERROR_LOG("Read of LBA {} failed", m_position_on_disc);
|
||||||
Seek(m_position_on_disc);
|
Seek(m_position_on_disc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ bool CDImage::ReadRawSector(void* buffer, SubChannelQ* subq)
|
||||||
|
|
||||||
if (subq && !ReadSubChannelQ(subq, *m_current_index, m_position_in_index))
|
if (subq && !ReadSubChannelQ(subq, *m_current_index, m_position_in_index))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Subchannel read of LBA {} failed", m_position_on_disc);
|
ERROR_LOG("Subchannel read of LBA {} failed", m_position_on_disc);
|
||||||
Seek(m_position_on_disc);
|
Seek(m_position_on_disc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,14 +116,14 @@ chd_file* CDImageCHD::OpenCHD(std::string_view filename, FileSystem::ManagedCFil
|
||||||
}
|
}
|
||||||
else if (err != CHDERR_REQUIRES_PARENT)
|
else if (err != CHDERR_REQUIRES_PARENT)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open CHD '{}': {}", filename, chd_error_string(err));
|
ERROR_LOG("Failed to open CHD '{}': {}", filename, chd_error_string(err));
|
||||||
Error::SetString(error, chd_error_string(err));
|
Error::SetString(error, chd_error_string(err));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recursion_level >= MAX_PARENTS)
|
if (recursion_level >= MAX_PARENTS)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open CHD '{}': Too many parent files", filename);
|
ERROR_LOG("Failed to open CHD '{}': Too many parent files", filename);
|
||||||
Error::SetString(error, "Too many parent files");
|
Error::SetString(error, "Too many parent files");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ chd_file* CDImageCHD::OpenCHD(std::string_view filename, FileSystem::ManagedCFil
|
||||||
err = chd_read_header_file(fp.get(), &header);
|
err = chd_read_header_file(fp.get(), &header);
|
||||||
if (err != CHDERR_NONE)
|
if (err != CHDERR_NONE)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read CHD header '{}': {}", filename, chd_error_string(err));
|
ERROR_LOG("Failed to read CHD header '{}': {}", filename, chd_error_string(err));
|
||||||
Error::SetString(error, chd_error_string(err));
|
Error::SetString(error, chd_error_string(err));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -166,8 +166,8 @@ chd_file* CDImageCHD::OpenCHD(std::string_view filename, FileSystem::ManagedCFil
|
||||||
parent_chd = OpenCHD(filename_to_open, std::move(parent_fp), error, recursion_level + 1);
|
parent_chd = OpenCHD(filename_to_open, std::move(parent_fp), error, recursion_level + 1);
|
||||||
if (parent_chd)
|
if (parent_chd)
|
||||||
{
|
{
|
||||||
Log_VerboseFmt("Using parent CHD '{}' from cache for '{}'.", Path::GetFileName(filename_to_open),
|
VERBOSE_LOG("Using parent CHD '{}' from cache for '{}'.", Path::GetFileName(filename_to_open),
|
||||||
Path::GetFileName(filename));
|
Path::GetFileName(filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,14 +208,14 @@ chd_file* CDImageCHD::OpenCHD(std::string_view filename, FileSystem::ManagedCFil
|
||||||
parent_chd = OpenCHD(fd.FileName, std::move(parent_fp), error, recursion_level + 1);
|
parent_chd = OpenCHD(fd.FileName, std::move(parent_fp), error, recursion_level + 1);
|
||||||
if (parent_chd)
|
if (parent_chd)
|
||||||
{
|
{
|
||||||
Log_VerboseFmt("Using parent CHD '{}' for '{}'.", Path::GetFileName(fd.FileName), Path::GetFileName(filename));
|
VERBOSE_LOG("Using parent CHD '{}' for '{}'.", Path::GetFileName(fd.FileName), Path::GetFileName(filename));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!parent_chd)
|
if (!parent_chd)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open CHD '{}': Failed to find parent CHD, it must be in the same directory.", filename);
|
ERROR_LOG("Failed to open CHD '{}': Failed to find parent CHD, it must be in the same directory.", filename);
|
||||||
Error::SetString(error, "Failed to find parent CHD, it must be in the same directory.");
|
Error::SetString(error, "Failed to find parent CHD, it must be in the same directory.");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ chd_file* CDImageCHD::OpenCHD(std::string_view filename, FileSystem::ManagedCFil
|
||||||
err = chd_open_file(fp.get(), CHD_OPEN_READ | CHD_OPEN_TRANSFER_FILE, parent_chd, &chd);
|
err = chd_open_file(fp.get(), CHD_OPEN_READ | CHD_OPEN_TRANSFER_FILE, parent_chd, &chd);
|
||||||
if (err != CHDERR_NONE)
|
if (err != CHDERR_NONE)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open CHD '{}': {}", filename, chd_error_string(err));
|
ERROR_LOG("Failed to open CHD '{}': {}", filename, chd_error_string(err));
|
||||||
Error::SetString(error, chd_error_string(err));
|
Error::SetString(error, chd_error_string(err));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||||
auto fp = FileSystem::OpenManagedSharedCFile(filename, "rb", FileSystem::FileShareMode::DenyWrite);
|
auto fp = FileSystem::OpenManagedSharedCFile(filename, "rb", FileSystem::FileShareMode::DenyWrite);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open CHD '{}': errno {}", filename, errno);
|
ERROR_LOG("Failed to open CHD '{}': errno {}", filename, errno);
|
||||||
if (error)
|
if (error)
|
||||||
error->SetErrno(errno);
|
error->SetErrno(errno);
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||||
m_hunk_size = header->hunkbytes;
|
m_hunk_size = header->hunkbytes;
|
||||||
if ((m_hunk_size % CHD_CD_SECTOR_DATA_SIZE) != 0)
|
if ((m_hunk_size % CHD_CD_SECTOR_DATA_SIZE) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Hunk size ({}) is not a multiple of {}", m_hunk_size, CHD_CD_SECTOR_DATA_SIZE);
|
ERROR_LOG("Hunk size ({}) is not a multiple of {}", m_hunk_size, CHD_CD_SECTOR_DATA_SIZE);
|
||||||
Error::SetString(error, fmt::format("Hunk size ({}) is not a multiple of {}", m_hunk_size,
|
Error::SetString(error, fmt::format("Hunk size ({}) is not a multiple of {}", m_hunk_size,
|
||||||
static_cast<u32>(CHD_CD_SECTOR_DATA_SIZE)));
|
static_cast<u32>(CHD_CD_SECTOR_DATA_SIZE)));
|
||||||
return false;
|
return false;
|
||||||
|
@ -286,7 +286,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||||
if (std::sscanf(metadata_str, CDROM_TRACK_METADATA2_FORMAT, &track_num, type_str, subtype_str, &frames,
|
if (std::sscanf(metadata_str, CDROM_TRACK_METADATA2_FORMAT, &track_num, type_str, subtype_str, &frames,
|
||||||
&pregap_frames, pgtype_str, pgsub_str, &postgap_frames) != 8)
|
&pregap_frames, pgtype_str, pgsub_str, &postgap_frames) != 8)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid track v2 metadata: '{}'", metadata_str);
|
ERROR_LOG("Invalid track v2 metadata: '{}'", metadata_str);
|
||||||
Error::SetString(error, fmt::format("Invalid track v2 metadata: '{}'", metadata_str));
|
Error::SetString(error, fmt::format("Invalid track v2 metadata: '{}'", metadata_str));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (std::sscanf(metadata_str, CDROM_TRACK_METADATA_FORMAT, &track_num, type_str, subtype_str, &frames) != 4)
|
if (std::sscanf(metadata_str, CDROM_TRACK_METADATA_FORMAT, &track_num, type_str, subtype_str, &frames) != 4)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid track metadata: '{}'", metadata_str);
|
ERROR_LOG("Invalid track metadata: '{}'", metadata_str);
|
||||||
Error::SetString(error, fmt::format("Invalid track v2 metadata: '{}'", metadata_str));
|
Error::SetString(error, fmt::format("Invalid track v2 metadata: '{}'", metadata_str));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (track_num != (num_tracks + 1))
|
if (track_num != (num_tracks + 1))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Incorrect track number at index {}, expected {} got {}", num_tracks, (num_tracks + 1), track_num);
|
ERROR_LOG("Incorrect track number at index {}, expected {} got {}", num_tracks, (num_tracks + 1), track_num);
|
||||||
Error::SetString(error, fmt::format("Incorrect track number at index {}, expected {} got {}", num_tracks,
|
Error::SetString(error, fmt::format("Incorrect track number at index {}, expected {} got {}", num_tracks,
|
||||||
(num_tracks + 1), track_num));
|
(num_tracks + 1), track_num));
|
||||||
return false;
|
return false;
|
||||||
|
@ -328,7 +328,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||||
std::optional<TrackMode> mode = ParseTrackModeString(type_str);
|
std::optional<TrackMode> mode = ParseTrackModeString(type_str);
|
||||||
if (!mode.has_value())
|
if (!mode.has_value())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid track mode: '{}'", type_str);
|
ERROR_LOG("Invalid track mode: '{}'", type_str);
|
||||||
Error::SetString(error, fmt::format("Invalid track mode: '{}'", type_str));
|
Error::SetString(error, fmt::format("Invalid track mode: '{}'", type_str));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||||
{
|
{
|
||||||
if (pregap_frames > frames)
|
if (pregap_frames > frames)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Pregap length {} exceeds track length {}", pregap_frames, frames);
|
ERROR_LOG("Pregap length {} exceeds track length {}", pregap_frames, frames);
|
||||||
Error::SetString(error, fmt::format("Pregap length {} exceeds track length {}", pregap_frames, frames));
|
Error::SetString(error, fmt::format("Pregap length {} exceeds track length {}", pregap_frames, frames));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -407,7 +407,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (m_tracks.empty())
|
if (m_tracks.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
ERROR_LOG("File '{}' contains no tracks", filename);
|
||||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -561,7 +561,7 @@ ALWAYS_INLINE_RELEASE bool CDImageCHD::UpdateHunkBuffer(const Index& index, LBA
|
||||||
const chd_error err = chd_read(m_chd, hunk_index, m_hunk_buffer.data());
|
const chd_error err = chd_read(m_chd, hunk_index, m_hunk_buffer.data());
|
||||||
if (err != CHDERR_NONE)
|
if (err != CHDERR_NONE)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("chd_read({}) failed: %s", hunk_index, chd_error_string(err));
|
ERROR_LOG("chd_read({}) failed: %s", hunk_index, chd_error_string(err));
|
||||||
|
|
||||||
// data might have been partially written
|
// data might have been partially written
|
||||||
m_current_hunk_index = static_cast<u32>(-1);
|
m_current_hunk_index = static_cast<u32>(-1);
|
||||||
|
|
|
@ -110,15 +110,15 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error)
|
||||||
track_fp = FileSystem::OpenCFile(alternative_filename.c_str(), "rb");
|
track_fp = FileSystem::OpenCFile(alternative_filename.c_str(), "rb");
|
||||||
if (track_fp)
|
if (track_fp)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Your cue sheet references an invalid file '{}', but this was found at '{}' instead.",
|
WARNING_LOG("Your cue sheet references an invalid file '{}', but this was found at '{}' instead.",
|
||||||
track_filename, alternative_filename);
|
track_filename, alternative_filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!track_fp)
|
if (!track_fp)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open track filename '{}' (from '{}' and '{}'): {}", track_full_filename, track_filename,
|
ERROR_LOG("Failed to open track filename '{}' (from '{}' and '{}'): {}", track_full_filename, track_filename,
|
||||||
filename, track_error.GetDescription());
|
filename, track_error.GetDescription());
|
||||||
Error::SetStringFmt(error, "Failed to open track filename '{}' (from '{}' and '{}'): {}", track_full_filename,
|
Error::SetStringFmt(error, "Failed to open track filename '{}' (from '{}' and '{}'): {}", track_full_filename,
|
||||||
track_filename, Path::GetFileName(filename), track_error.GetDescription());
|
track_filename, Path::GetFileName(filename), track_error.GetDescription());
|
||||||
return false;
|
return false;
|
||||||
|
@ -149,8 +149,8 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error)
|
||||||
file_size /= track_sector_size;
|
file_size /= track_sector_size;
|
||||||
if (track_start >= file_size)
|
if (track_start >= file_size)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open track {} in '{}': track start is out of range ({} vs {})", track_num, filename,
|
ERROR_LOG("Failed to open track {} in '{}': track start is out of range ({} vs {})", track_num, filename,
|
||||||
track_start, file_size);
|
track_start, file_size);
|
||||||
Error::SetStringFmt(error, "Failed to open track {} in '{}': track start is out of range ({} vs {}))",
|
Error::SetStringFmt(error, "Failed to open track {} in '{}': track start is out of range ({} vs {}))",
|
||||||
track_num, Path::GetFileName(filename), track_start, file_size);
|
track_num, Path::GetFileName(filename), track_start, file_size);
|
||||||
return false;
|
return false;
|
||||||
|
@ -285,7 +285,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error)
|
||||||
|
|
||||||
if (m_tracks.empty())
|
if (m_tracks.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
ERROR_LOG("File '{}' contains no tracks", filename);
|
||||||
Error::SetStringFmt(error, "File '{}' contains no tracks", Path::GetFileName(filename));
|
Error::SetStringFmt(error, "File '{}' contains no tracks", Path::GetFileName(filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ enum class SCSIReadMode : u8
|
||||||
const u32 expected_size = SCSIReadCommandOutputSize(mode);
|
const u32 expected_size = SCSIReadCommandOutputSize(mode);
|
||||||
if (buffer.size() != expected_size)
|
if (buffer.size() != expected_size)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("SCSI returned {} bytes, expected {}", buffer.size(), expected_size);
|
ERROR_LOG("SCSI returned {} bytes, expected {}", buffer.size(), expected_size);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,14 +115,14 @@ enum class SCSIReadMode : u8
|
||||||
CDImage::DeinterleaveSubcode(buffer.data() + CDImage::RAW_SECTOR_SIZE, deinterleaved_subcode);
|
CDImage::DeinterleaveSubcode(buffer.data() + CDImage::RAW_SECTOR_SIZE, deinterleaved_subcode);
|
||||||
std::memcpy(&subq, &deinterleaved_subcode[CDImage::SUBCHANNEL_BYTES_PER_FRAME], sizeof(subq));
|
std::memcpy(&subq, &deinterleaved_subcode[CDImage::SUBCHANNEL_BYTES_PER_FRAME], sizeof(subq));
|
||||||
|
|
||||||
Log_DevFmt("SCSI full subcode read returned [{}] for {:02d}:{:02d}:{:02d}",
|
DEV_LOG("SCSI full subcode read returned [{}] for {:02d}:{:02d}:{:02d}",
|
||||||
StringUtil::EncodeHex(subq.data.data(), static_cast<int>(subq.data.size())), expected_pos.minute,
|
StringUtil::EncodeHex(subq.data.data(), static_cast<int>(subq.data.size())), expected_pos.minute,
|
||||||
expected_pos.second, expected_pos.frame);
|
expected_pos.second, expected_pos.frame);
|
||||||
|
|
||||||
if (!subq.IsCRCValid())
|
if (!subq.IsCRCValid())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("SCSI full subcode read returned invalid SubQ CRC (got {:02X} expected {:02X})", subq.crc,
|
WARNING_LOG("SCSI full subcode read returned invalid SubQ CRC (got {:02X} expected {:02X})", subq.crc,
|
||||||
CDImage::SubChannelQ::ComputeCRC(subq.data));
|
CDImage::SubChannelQ::ComputeCRC(subq.data));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ enum class SCSIReadMode : u8
|
||||||
CDImage::Position::FromBCD(subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd);
|
CDImage::Position::FromBCD(subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd);
|
||||||
if (expected_pos != got_pos)
|
if (expected_pos != got_pos)
|
||||||
{
|
{
|
||||||
Log_WarningFmt(
|
WARNING_LOG(
|
||||||
"SCSI full subcode read returned invalid MSF (got {:02x}:{:02x}:{:02x}, expected {:02d}:{:02d}:{:02d})",
|
"SCSI full subcode read returned invalid MSF (got {:02x}:{:02x}:{:02x}, expected {:02d}:{:02d}:{:02d})",
|
||||||
subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd, expected_pos.minute,
|
subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd, expected_pos.minute,
|
||||||
expected_pos.second, expected_pos.frame);
|
expected_pos.second, expected_pos.frame);
|
||||||
|
@ -143,14 +143,14 @@ enum class SCSIReadMode : u8
|
||||||
{
|
{
|
||||||
CDImage::SubChannelQ subq;
|
CDImage::SubChannelQ subq;
|
||||||
std::memcpy(&subq, buffer.data() + CDImage::RAW_SECTOR_SIZE, sizeof(subq));
|
std::memcpy(&subq, buffer.data() + CDImage::RAW_SECTOR_SIZE, sizeof(subq));
|
||||||
Log_DevFmt("SCSI subq read returned [{}] for {:02d}:{:02d}:{:02d}",
|
DEV_LOG("SCSI subq read returned [{}] for {:02d}:{:02d}:{:02d}",
|
||||||
StringUtil::EncodeHex(subq.data.data(), static_cast<int>(subq.data.size())), expected_pos.minute,
|
StringUtil::EncodeHex(subq.data.data(), static_cast<int>(subq.data.size())), expected_pos.minute,
|
||||||
expected_pos.second, expected_pos.frame);
|
expected_pos.second, expected_pos.frame);
|
||||||
|
|
||||||
if (!subq.IsCRCValid())
|
if (!subq.IsCRCValid())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("SCSI subq read returned invalid SubQ CRC (got {:02X} expected {:02X})", subq.crc,
|
WARNING_LOG("SCSI subq read returned invalid SubQ CRC (got {:02X} expected {:02X})", subq.crc,
|
||||||
CDImage::SubChannelQ::ComputeCRC(subq.data));
|
CDImage::SubChannelQ::ComputeCRC(subq.data));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,9 +158,9 @@ enum class SCSIReadMode : u8
|
||||||
CDImage::Position::FromBCD(subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd);
|
CDImage::Position::FromBCD(subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd);
|
||||||
if (expected_pos != got_pos)
|
if (expected_pos != got_pos)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("SCSI subq read returned invalid MSF (got {:02x}:{:02x}:{:02x}, expected {:02d}:{:02d}:{:02d})",
|
WARNING_LOG("SCSI subq read returned invalid MSF (got {:02x}:{:02x}:{:02x}, expected {:02d}:{:02d}:{:02d})",
|
||||||
subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd, expected_pos.minute,
|
subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd, expected_pos.minute,
|
||||||
expected_pos.second, expected_pos.frame);
|
expected_pos.second, expected_pos.frame);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,12 +257,12 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||||
m_hDevice = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, NULL);
|
m_hDevice = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, NULL);
|
||||||
if (m_hDevice != INVALID_HANDLE_VALUE)
|
if (m_hDevice != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Could not open '{}' as read/write, can't use SPTD", filename);
|
WARNING_LOG("Could not open '{}' as read/write, can't use SPTD", filename);
|
||||||
try_sptd = false;
|
try_sptd = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateFile('{}') failed: %08X", filename, GetLastError());
|
ERROR_LOG("CreateFile('{}') failed: %08X", filename, GetLastError());
|
||||||
if (error)
|
if (error)
|
||||||
error->SetWin32(GetLastError());
|
error->SetWin32(GetLastError());
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||||
static constexpr u32 READ_SPEED_KBS = (DATA_SECTOR_SIZE * FRAMES_PER_SECOND * READ_SPEED_MULTIPLIER) / 1024;
|
static constexpr u32 READ_SPEED_KBS = (DATA_SECTOR_SIZE * FRAMES_PER_SECOND * READ_SPEED_MULTIPLIER) / 1024;
|
||||||
CDROM_SET_SPEED set_speed = {CdromSetSpeed, READ_SPEED_KBS, 0, CdromDefaultRotation};
|
CDROM_SET_SPEED set_speed = {CdromSetSpeed, READ_SPEED_KBS, 0, CdromDefaultRotation};
|
||||||
if (!DeviceIoControl(m_hDevice, IOCTL_CDROM_SET_SPEED, &set_speed, sizeof(set_speed), nullptr, 0, nullptr, nullptr))
|
if (!DeviceIoControl(m_hDevice, IOCTL_CDROM_SET_SPEED, &set_speed, sizeof(set_speed), nullptr, 0, nullptr, nullptr))
|
||||||
Log_WarningFmt("DeviceIoControl(IOCTL_CDROM_SET_SPEED) failed: {:08X}", GetLastError());
|
WARNING_LOG("DeviceIoControl(IOCTL_CDROM_SET_SPEED) failed: {:08X}", GetLastError());
|
||||||
|
|
||||||
CDROM_READ_TOC_EX read_toc_ex = {};
|
CDROM_READ_TOC_EX read_toc_ex = {};
|
||||||
read_toc_ex.Format = CDROM_READ_TOC_EX_FORMAT_TOC;
|
read_toc_ex.Format = CDROM_READ_TOC_EX_FORMAT_TOC;
|
||||||
|
@ -290,7 +290,7 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||||
&bytes_returned, nullptr) ||
|
&bytes_returned, nullptr) ||
|
||||||
toc.LastTrack < toc.FirstTrack)
|
toc.LastTrack < toc.FirstTrack)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("DeviceIoCtl(IOCTL_CDROM_READ_TOC_EX) failed: {:08X}", GetLastError());
|
ERROR_LOG("DeviceIoCtl(IOCTL_CDROM_READ_TOC_EX) failed: {:08X}", GetLastError());
|
||||||
if (error)
|
if (error)
|
||||||
error->SetWin32(GetLastError());
|
error->SetWin32(GetLastError());
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
DWORD last_track_address = 0;
|
DWORD last_track_address = 0;
|
||||||
LBA disc_lba = 0;
|
LBA disc_lba = 0;
|
||||||
Log_DevFmt("FirstTrack={}, LastTrack={}", toc.FirstTrack, toc.LastTrack);
|
DEV_LOG("FirstTrack={}, LastTrack={}", toc.FirstTrack, toc.LastTrack);
|
||||||
|
|
||||||
const u32 num_tracks_to_check = (toc.LastTrack - toc.FirstTrack) + 1 + 1;
|
const u32 num_tracks_to_check = (toc.LastTrack - toc.FirstTrack) + 1 + 1;
|
||||||
for (u32 track_index = 0; track_index < num_tracks_to_check; track_index++)
|
for (u32 track_index = 0; track_index < num_tracks_to_check; track_index++)
|
||||||
|
@ -307,14 +307,14 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||||
const TRACK_DATA& td = toc.TrackData[track_index];
|
const TRACK_DATA& td = toc.TrackData[track_index];
|
||||||
const u8 track_num = td.TrackNumber;
|
const u8 track_num = td.TrackNumber;
|
||||||
const DWORD track_address = BEToU32(td.Address);
|
const DWORD track_address = BEToU32(td.Address);
|
||||||
Log_DevFmt(" [{}]: Num={:02X}, Address={}", track_index, track_num, track_address);
|
DEV_LOG(" [{}]: Num={:02X}, Address={}", track_index, track_num, track_address);
|
||||||
|
|
||||||
// fill in the previous track's length
|
// fill in the previous track's length
|
||||||
if (!m_tracks.empty())
|
if (!m_tracks.empty())
|
||||||
{
|
{
|
||||||
if (track_num < m_tracks.back().track_number)
|
if (track_num < m_tracks.back().track_number)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid TOC, track {} less than {}", track_num, m_tracks.back().track_number);
|
ERROR_LOG("Invalid TOC, track {} less than {}", track_num, m_tracks.back().track_number);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,29 +382,29 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (m_tracks.empty())
|
if (m_tracks.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
ERROR_LOG("File '{}' contains no tracks", filename);
|
||||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lba_count = disc_lba;
|
m_lba_count = disc_lba;
|
||||||
|
|
||||||
Log_DevFmt("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
DEV_LOG("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||||
for (u32 i = 0; i < m_tracks.size(); i++)
|
for (u32 i = 0; i < m_tracks.size(); i++)
|
||||||
{
|
{
|
||||||
Log_DevFmt(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
DEV_LOG(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
||||||
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
||||||
}
|
}
|
||||||
for (u32 i = 0; i < m_indices.size(); i++)
|
for (u32 i = 0; i < m_indices.size(); i++)
|
||||||
{
|
{
|
||||||
Log_DevFmt(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
DEV_LOG(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
||||||
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc,
|
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc, m_indices[i].length,
|
||||||
m_indices[i].length, m_indices[i].file_sector_size, m_indices[i].file_offset);
|
m_indices[i].file_sector_size, m_indices[i].file_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DetermineReadMode(try_sptd))
|
if (!DetermineReadMode(try_sptd))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Could not determine read mode");
|
ERROR_LOG("Could not determine read mode");
|
||||||
Error::SetString(error, "Could not determine read mode");
|
Error::SetString(error, "Could not determine read mode");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -479,18 +479,18 @@ std::optional<u32> CDImageDeviceWin32::DoSCSICommand(u8 cmd[SCSI_CMD_LENGTH], st
|
||||||
if (!DeviceIoControl(m_hDevice, IOCTL_SCSI_PASS_THROUGH_DIRECT, &sptd, sizeof(sptd), &sptd, sizeof(sptd),
|
if (!DeviceIoControl(m_hDevice, IOCTL_SCSI_PASS_THROUGH_DIRECT, &sptd, sizeof(sptd), &sptd, sizeof(sptd),
|
||||||
&bytes_returned, nullptr))
|
&bytes_returned, nullptr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("DeviceIoControl() for SCSI 0x{:02X} failed: {}", cmd[0], GetLastError());
|
ERROR_LOG("DeviceIoControl() for SCSI 0x{:02X} failed: {}", cmd[0], GetLastError());
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sptd.cmd.ScsiStatus != 0)
|
if (sptd.cmd.ScsiStatus != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("SCSI command 0x{:02X} failed: {}", cmd[0], sptd.cmd.ScsiStatus);
|
ERROR_LOG("SCSI command 0x{:02X} failed: {}", cmd[0], sptd.cmd.ScsiStatus);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sptd.cmd.DataTransferLength != out_buffer.size())
|
if (sptd.cmd.DataTransferLength != out_buffer.size())
|
||||||
Log_WarningFmt("Only read {} of {} bytes", sptd.cmd.DataTransferLength, out_buffer.size());
|
WARNING_LOG("Only read {} of {} bytes", sptd.cmd.DataTransferLength, out_buffer.size());
|
||||||
|
|
||||||
return sptd.cmd.DataTransferLength;
|
return sptd.cmd.DataTransferLength;
|
||||||
}
|
}
|
||||||
|
@ -524,12 +524,12 @@ bool CDImageDeviceWin32::DoRawRead(LBA lba)
|
||||||
if (!DeviceIoControl(m_hDevice, IOCTL_CDROM_RAW_READ, &rri, sizeof(rri), m_buffer.data(),
|
if (!DeviceIoControl(m_hDevice, IOCTL_CDROM_RAW_READ, &rri, sizeof(rri), m_buffer.data(),
|
||||||
static_cast<DWORD>(m_buffer.size()), &bytes_returned, nullptr))
|
static_cast<DWORD>(m_buffer.size()), &bytes_returned, nullptr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("DeviceIoControl(IOCTL_CDROM_RAW_READ) for LBA {} failed: {:08X}", lba, GetLastError());
|
ERROR_LOG("DeviceIoControl(IOCTL_CDROM_RAW_READ) for LBA {} failed: {:08X}", lba, GetLastError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes_returned != expected_size)
|
if (bytes_returned != expected_size)
|
||||||
Log_WarningFmt("Only read {} of {} bytes", bytes_returned, expected_size);
|
WARNING_LOG("Only read {} of {} bytes", bytes_returned, expected_size);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -542,7 +542,7 @@ bool CDImageDeviceWin32::ReadSectorToBuffer(LBA lba)
|
||||||
const u32 expected_size = SCSIReadCommandOutputSize(m_scsi_read_mode);
|
const u32 expected_size = SCSIReadCommandOutputSize(m_scsi_read_mode);
|
||||||
if (size.value_or(0) != expected_size)
|
if (size.value_or(0) != expected_size)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Read of LBA {} failed: only got {} of {} bytes", lba, size.value(), expected_size);
|
ERROR_LOG("Read of LBA {} failed: only got {} of {} bytes", lba, size.value(), expected_size);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -568,26 +568,26 @@ bool CDImageDeviceWin32::DetermineReadMode(bool try_sptd)
|
||||||
{
|
{
|
||||||
std::optional<u32> transfer_size;
|
std::optional<u32> transfer_size;
|
||||||
|
|
||||||
Log_DevPrint("Trying SCSI read with full subcode...");
|
DEV_LOG("Trying SCSI read with full subcode...");
|
||||||
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Full)).has_value())
|
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Full)).has_value())
|
||||||
{
|
{
|
||||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Full,
|
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Full,
|
||||||
track_1_subq_lba))
|
track_1_subq_lba))
|
||||||
{
|
{
|
||||||
Log_VerbosePrint("Using SCSI reads with subcode");
|
VERBOSE_LOG("Using SCSI reads with subcode");
|
||||||
m_scsi_read_mode = SCSIReadMode::Full;
|
m_scsi_read_mode = SCSIReadMode::Full;
|
||||||
m_has_valid_subcode = true;
|
m_has_valid_subcode = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningPrint("Full subcode failed, trying SCSI read with only subq...");
|
WARNING_LOG("Full subcode failed, trying SCSI read with only subq...");
|
||||||
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::SubQOnly)).has_value())
|
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::SubQOnly)).has_value())
|
||||||
{
|
{
|
||||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::SubQOnly,
|
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::SubQOnly,
|
||||||
track_1_subq_lba))
|
track_1_subq_lba))
|
||||||
{
|
{
|
||||||
Log_VerbosePrint("Using SCSI reads with subq only");
|
VERBOSE_LOG("Using SCSI reads with subq only");
|
||||||
m_scsi_read_mode = SCSIReadMode::SubQOnly;
|
m_scsi_read_mode = SCSIReadMode::SubQOnly;
|
||||||
m_has_valid_subcode = true;
|
m_has_valid_subcode = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -595,13 +595,13 @@ bool CDImageDeviceWin32::DetermineReadMode(bool try_sptd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// As a last ditch effort, try SCSI without subcode.
|
// As a last ditch effort, try SCSI without subcode.
|
||||||
Log_WarningPrint("Subq only failed failed, trying SCSI without subcode...");
|
WARNING_LOG("Subq only failed failed, trying SCSI without subcode...");
|
||||||
if ((transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Raw)).has_value())
|
if ((transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Raw)).has_value())
|
||||||
{
|
{
|
||||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Raw,
|
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Raw,
|
||||||
track_1_subq_lba))
|
track_1_subq_lba))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Using SCSI raw reads, libcrypt games will not run correctly");
|
WARNING_LOG("Using SCSI raw reads, libcrypt games will not run correctly");
|
||||||
m_scsi_read_mode = SCSIReadMode::Raw;
|
m_scsi_read_mode = SCSIReadMode::Raw;
|
||||||
m_has_valid_subcode = false;
|
m_has_valid_subcode = false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -609,26 +609,26 @@ bool CDImageDeviceWin32::DetermineReadMode(bool try_sptd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningPrint("SCSI reads failed, trying raw read...");
|
WARNING_LOG("SCSI reads failed, trying raw read...");
|
||||||
if (DoRawRead(track_1_lba))
|
if (DoRawRead(track_1_lba))
|
||||||
{
|
{
|
||||||
// verify subcode
|
// verify subcode
|
||||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), SCSIReadCommandOutputSize(SCSIReadMode::Full)),
|
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), SCSIReadCommandOutputSize(SCSIReadMode::Full)),
|
||||||
SCSIReadMode::Full, track_1_subq_lba))
|
SCSIReadMode::Full, track_1_subq_lba))
|
||||||
{
|
{
|
||||||
Log_VerbosePrint("Using raw reads with full subcode");
|
VERBOSE_LOG("Using raw reads with full subcode");
|
||||||
m_scsi_read_mode = SCSIReadMode::None;
|
m_scsi_read_mode = SCSIReadMode::None;
|
||||||
m_has_valid_subcode = true;
|
m_has_valid_subcode = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningPrint("Using raw reads without subcode, libcrypt games will not run correctly");
|
WARNING_LOG("Using raw reads without subcode, libcrypt games will not run correctly");
|
||||||
m_scsi_read_mode = SCSIReadMode::None;
|
m_scsi_read_mode = SCSIReadMode::None;
|
||||||
m_has_valid_subcode = false;
|
m_has_valid_subcode = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_ErrorPrint("No read modes were successful, cannot use device.");
|
ERROR_LOG("No read modes were successful, cannot use device.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,7 +751,7 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||||
// Set it to 4x speed. A good balance between readahead and spinning up way too high.
|
// Set it to 4x speed. A good balance between readahead and spinning up way too high.
|
||||||
const int read_speed = 4;
|
const int read_speed = 4;
|
||||||
if (!DoSetSpeed(read_speed) && ioctl(m_fd, CDROM_SELECT_SPEED, &read_speed) != 0)
|
if (!DoSetSpeed(read_speed) && ioctl(m_fd, CDROM_SELECT_SPEED, &read_speed) != 0)
|
||||||
Log_WarningFmt("ioctl(CDROM_SELECT_SPEED) failed: {}", errno);
|
WARNING_LOG("ioctl(CDROM_SELECT_SPEED) failed: {}", errno);
|
||||||
|
|
||||||
// Read ToC
|
// Read ToC
|
||||||
cdrom_tochdr toc_hdr = {};
|
cdrom_tochdr toc_hdr = {};
|
||||||
|
@ -761,7 +761,7 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt("FirstTrack={}, LastTrack={}", toc_hdr.cdth_trk0, toc_hdr.cdth_trk1);
|
DEV_LOG("FirstTrack={}, LastTrack={}", toc_hdr.cdth_trk0, toc_hdr.cdth_trk1);
|
||||||
if (toc_hdr.cdth_trk1 < toc_hdr.cdth_trk0)
|
if (toc_hdr.cdth_trk1 < toc_hdr.cdth_trk0)
|
||||||
{
|
{
|
||||||
Error::SetStringFmt(error, "Last track {} is before first track {}", toc_hdr.cdth_trk1, toc_hdr.cdth_trk0);
|
Error::SetStringFmt(error, "Last track {} is before first track {}", toc_hdr.cdth_trk1, toc_hdr.cdth_trk0);
|
||||||
|
@ -785,14 +785,14 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_DevFmt(" [{}]: Num={}, LBA={}", track_index, track_num, toc_ent.cdte_addr.lba);
|
DEV_LOG(" [{}]: Num={}, LBA={}", track_index, track_num, toc_ent.cdte_addr.lba);
|
||||||
|
|
||||||
// fill in the previous track's length
|
// fill in the previous track's length
|
||||||
if (!m_tracks.empty())
|
if (!m_tracks.empty())
|
||||||
{
|
{
|
||||||
if (track_num < m_tracks.back().track_number)
|
if (track_num < m_tracks.back().track_number)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid TOC, track {} less than {}", track_num, m_tracks.back().track_number);
|
ERROR_LOG("Invalid TOC, track {} less than {}", track_num, m_tracks.back().track_number);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,7 +855,7 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (m_tracks.empty())
|
if (m_tracks.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
ERROR_LOG("File '{}' contains no tracks", filename);
|
||||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -884,17 +884,17 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
m_lba_count = disc_lba;
|
m_lba_count = disc_lba;
|
||||||
|
|
||||||
Log_DevFmt("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
DEV_LOG("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||||
for (u32 i = 0; i < m_tracks.size(); i++)
|
for (u32 i = 0; i < m_tracks.size(); i++)
|
||||||
{
|
{
|
||||||
Log_DevFmt(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
DEV_LOG(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
||||||
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
||||||
}
|
}
|
||||||
for (u32 i = 0; i < m_indices.size(); i++)
|
for (u32 i = 0; i < m_indices.size(); i++)
|
||||||
{
|
{
|
||||||
Log_DevFmt(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
DEV_LOG(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
||||||
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc,
|
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc, m_indices[i].length,
|
||||||
m_indices[i].length, m_indices[i].file_sector_size, m_indices[i].file_offset);
|
m_indices[i].file_sector_size, m_indices[i].file_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DetermineReadMode(error))
|
if (!DetermineReadMode(error))
|
||||||
|
@ -964,12 +964,12 @@ std::optional<u32> CDImageDeviceLinux::DoSCSICommand(u8 cmd[SCSI_CMD_LENGTH], st
|
||||||
|
|
||||||
if (ioctl(m_fd, SG_IO, &hdr) != 0)
|
if (ioctl(m_fd, SG_IO, &hdr) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("ioctl(SG_IO) for command {:02X} failed: {}", cmd[0], errno);
|
ERROR_LOG("ioctl(SG_IO) for command {:02X} failed: {}", cmd[0], errno);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
else if (hdr.status != 0)
|
else if (hdr.status != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("SCSI command {:02X} failed with status {}", cmd[0], hdr.status);
|
ERROR_LOG("SCSI command {:02X} failed with status {}", cmd[0], hdr.status);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,7 +998,7 @@ bool CDImageDeviceLinux::DoRawRead(LBA lba)
|
||||||
std::memcpy(m_buffer.data(), &msf, sizeof(msf));
|
std::memcpy(m_buffer.data(), &msf, sizeof(msf));
|
||||||
if (ioctl(m_fd, CDROMREADRAW, m_buffer.data()) != 0)
|
if (ioctl(m_fd, CDROMREADRAW, m_buffer.data()) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CDROMREADRAW for LBA {} (MSF {}:{}:{}) failed: {}", lba, msf.minute, msf.second, msf.frame, errno);
|
ERROR_LOG("CDROMREADRAW for LBA {} (MSF {}:{}:{}) failed: {}", lba, msf.minute, msf.second, msf.frame, errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1013,7 +1013,7 @@ bool CDImageDeviceLinux::ReadSectorToBuffer(LBA lba)
|
||||||
const u32 expected_size = SCSIReadCommandOutputSize(m_scsi_read_mode);
|
const u32 expected_size = SCSIReadCommandOutputSize(m_scsi_read_mode);
|
||||||
if (size.value_or(0) != expected_size)
|
if (size.value_or(0) != expected_size)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Read of LBA {} failed: only got {} of {} bytes", lba, size.value(), expected_size);
|
ERROR_LOG("Read of LBA {} failed: only got {} of {} bytes", lba, size.value(), expected_size);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1034,50 +1034,50 @@ bool CDImageDeviceLinux::DetermineReadMode(Error* error)
|
||||||
const bool check_subcode = ShouldTryReadingSubcode();
|
const bool check_subcode = ShouldTryReadingSubcode();
|
||||||
std::optional<u32> transfer_size;
|
std::optional<u32> transfer_size;
|
||||||
|
|
||||||
Log_DevPrint("Trying SCSI read with full subcode...");
|
DEV_LOG("Trying SCSI read with full subcode...");
|
||||||
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Full)).has_value())
|
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Full)).has_value())
|
||||||
{
|
{
|
||||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Full, track_1_subq_lba))
|
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Full, track_1_subq_lba))
|
||||||
{
|
{
|
||||||
Log_VerbosePrint("Using SCSI reads with subcode");
|
VERBOSE_LOG("Using SCSI reads with subcode");
|
||||||
m_scsi_read_mode = SCSIReadMode::Full;
|
m_scsi_read_mode = SCSIReadMode::Full;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningPrint("Full subcode failed, trying SCSI read with only subq...");
|
WARNING_LOG("Full subcode failed, trying SCSI read with only subq...");
|
||||||
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::SubQOnly)).has_value())
|
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::SubQOnly)).has_value())
|
||||||
{
|
{
|
||||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::SubQOnly,
|
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::SubQOnly,
|
||||||
track_1_subq_lba))
|
track_1_subq_lba))
|
||||||
{
|
{
|
||||||
Log_VerbosePrint("Using SCSI reads with subq only");
|
VERBOSE_LOG("Using SCSI reads with subq only");
|
||||||
m_scsi_read_mode = SCSIReadMode::SubQOnly;
|
m_scsi_read_mode = SCSIReadMode::SubQOnly;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningPrint("SCSI subcode reads failed, trying CDROMREADRAW...");
|
WARNING_LOG("SCSI subcode reads failed, trying CDROMREADRAW...");
|
||||||
if (DoRawRead(track_1_lba))
|
if (DoRawRead(track_1_lba))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Using CDROMREADRAW, libcrypt games will not run correctly");
|
WARNING_LOG("Using CDROMREADRAW, libcrypt games will not run correctly");
|
||||||
m_scsi_read_mode = SCSIReadMode::None;
|
m_scsi_read_mode = SCSIReadMode::None;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// As a last ditch effort, try SCSI without subcode.
|
// As a last ditch effort, try SCSI without subcode.
|
||||||
Log_WarningPrint("CDROMREADRAW failed, trying SCSI without subcode...");
|
WARNING_LOG("CDROMREADRAW failed, trying SCSI without subcode...");
|
||||||
if ((transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Raw)).has_value())
|
if ((transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Raw)).has_value())
|
||||||
{
|
{
|
||||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Raw, track_1_subq_lba))
|
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Raw, track_1_subq_lba))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Using SCSI raw reads, libcrypt games will not run correctly");
|
WARNING_LOG("Using SCSI raw reads, libcrypt games will not run correctly");
|
||||||
m_scsi_read_mode = SCSIReadMode::Raw;
|
m_scsi_read_mode = SCSIReadMode::Raw;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_ErrorPrint("No read modes were successful, cannot use device.");
|
ERROR_LOG("No read modes were successful, cannot use device.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1200,7 +1200,7 @@ static io_service_t GetDeviceMediaService(std::string_view devname)
|
||||||
kern_return_t ret = IOServiceGetMatchingServices(0, IOBSDNameMatching(0, 0, rdevname.c_str()), &iterator);
|
kern_return_t ret = IOServiceGetMatchingServices(0, IOBSDNameMatching(0, 0, rdevname.c_str()), &iterator);
|
||||||
if (ret != KERN_SUCCESS)
|
if (ret != KERN_SUCCESS)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("IOServiceGetMatchingService() returned {}", ret);
|
ERROR_LOG("IOServiceGetMatchingService() returned {}", ret);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1259,7 +1259,7 @@ bool CDImageDeviceMacOS::Open(const char* filename, Error* error)
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 desc_count = CDTOCGetDescriptorCount(toc.get());
|
const u32 desc_count = CDTOCGetDescriptorCount(toc.get());
|
||||||
Log_DevFmt("sessionFirst={}, sessionLast={}, count={}", toc->sessionFirst, toc->sessionLast, desc_count);
|
DEV_LOG("sessionFirst={}, sessionLast={}, count={}", toc->sessionFirst, toc->sessionLast, desc_count);
|
||||||
if (toc->sessionLast < toc->sessionFirst)
|
if (toc->sessionLast < toc->sessionFirst)
|
||||||
{
|
{
|
||||||
Error::SetStringFmt(error, "Last track {} is before first track {}", toc->sessionLast, toc->sessionFirst);
|
Error::SetStringFmt(error, "Last track {} is before first track {}", toc->sessionLast, toc->sessionFirst);
|
||||||
|
@ -1273,8 +1273,8 @@ bool CDImageDeviceMacOS::Open(const char* filename, Error* error)
|
||||||
for (u32 i = 0; i < desc_count; i++)
|
for (u32 i = 0; i < desc_count; i++)
|
||||||
{
|
{
|
||||||
const CDTOCDescriptor& desc = toc->descriptors[i];
|
const CDTOCDescriptor& desc = toc->descriptors[i];
|
||||||
Log_DevFmt(" [{}]: Num={}, Point=0x{:02X} ADR={} MSF={}:{}:{}", i, desc.tno, desc.point, desc.adr, desc.p.minute,
|
DEV_LOG(" [{}]: Num={}, Point=0x{:02X} ADR={} MSF={}:{}:{}", i, desc.tno, desc.point, desc.adr, desc.p.minute,
|
||||||
desc.p.second, desc.p.frame);
|
desc.p.second, desc.p.frame);
|
||||||
|
|
||||||
// Why does MacOS use 0xA2 instead of 0xAA for leadout??
|
// Why does MacOS use 0xA2 instead of 0xAA for leadout??
|
||||||
if (desc.point == 0xA2)
|
if (desc.point == 0xA2)
|
||||||
|
@ -1374,7 +1374,7 @@ bool CDImageDeviceMacOS::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (m_tracks.empty())
|
if (m_tracks.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
ERROR_LOG("File '{}' contains no tracks", filename);
|
||||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1392,17 +1392,17 @@ bool CDImageDeviceMacOS::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
m_lba_count = disc_lba;
|
m_lba_count = disc_lba;
|
||||||
|
|
||||||
Log_DevFmt("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
DEV_LOG("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||||
for (u32 i = 0; i < m_tracks.size(); i++)
|
for (u32 i = 0; i < m_tracks.size(); i++)
|
||||||
{
|
{
|
||||||
Log_DevFmt(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
DEV_LOG(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
||||||
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
||||||
}
|
}
|
||||||
for (u32 i = 0; i < m_indices.size(); i++)
|
for (u32 i = 0; i < m_indices.size(); i++)
|
||||||
{
|
{
|
||||||
Log_DevFmt(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
DEV_LOG(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
||||||
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc,
|
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc, m_indices[i].length,
|
||||||
m_indices[i].length, m_indices[i].file_sector_size, m_indices[i].file_offset);
|
m_indices[i].file_sector_size, m_indices[i].file_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DetermineReadMode(error))
|
if (!DetermineReadMode(error))
|
||||||
|
@ -1462,7 +1462,7 @@ bool CDImageDeviceMacOS::DoSetSpeed(u32 speed_multiplier)
|
||||||
const u16 speed = static_cast<u16>((FRAMES_PER_SECOND * RAW_SECTOR_SIZE * speed_multiplier) / 1024);
|
const u16 speed = static_cast<u16>((FRAMES_PER_SECOND * RAW_SECTOR_SIZE * speed_multiplier) / 1024);
|
||||||
if (ioctl(m_fd, DKIOCCDSETSPEED, &speed) != 0)
|
if (ioctl(m_fd, DKIOCCDSETSPEED, &speed) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("DKIOCCDSETSPEED for speed {} failed: {}", speed, errno);
|
ERROR_LOG("DKIOCCDSETSPEED for speed {} failed: {}", speed, errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1473,7 +1473,7 @@ bool CDImageDeviceMacOS::ReadSectorToBuffer(LBA lba)
|
||||||
{
|
{
|
||||||
if (lba < RAW_READ_OFFSET)
|
if (lba < RAW_READ_OFFSET)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Out of bounds LBA {}", lba);
|
ERROR_LOG("Out of bounds LBA {}", lba);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1493,7 +1493,7 @@ bool CDImageDeviceMacOS::ReadSectorToBuffer(LBA lba)
|
||||||
if (ioctl(m_fd, DKIOCCDREAD, &desc) != 0)
|
if (ioctl(m_fd, DKIOCCDREAD, &desc) != 0)
|
||||||
{
|
{
|
||||||
const Position msf = Position::FromLBA(lba);
|
const Position msf = Position::FromLBA(lba);
|
||||||
Log_ErrorFmt("DKIOCCDREAD for LBA {} (MSF {}:{}:{}) failed: {}", lba, msf.minute, msf.second, msf.frame, errno);
|
ERROR_LOG("DKIOCCDREAD for LBA {} (MSF {}:{}:{}) failed: {}", lba, msf.minute, msf.second, msf.frame, errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1506,7 +1506,7 @@ bool CDImageDeviceMacOS::DetermineReadMode(Error* error)
|
||||||
const LBA track_1_lba = static_cast<LBA>(m_indices[m_tracks[0].first_index].file_offset);
|
const LBA track_1_lba = static_cast<LBA>(m_indices[m_tracks[0].first_index].file_offset);
|
||||||
const bool check_subcode = ShouldTryReadingSubcode();
|
const bool check_subcode = ShouldTryReadingSubcode();
|
||||||
|
|
||||||
Log_DevPrint("Trying read with full subcode...");
|
DEV_LOG("Trying read with full subcode...");
|
||||||
m_read_mode = SCSIReadMode::Full;
|
m_read_mode = SCSIReadMode::Full;
|
||||||
m_current_lba = m_lba_count;
|
m_current_lba = m_lba_count;
|
||||||
if (check_subcode && ReadSectorToBuffer(track_1_lba))
|
if (check_subcode && ReadSectorToBuffer(track_1_lba))
|
||||||
|
@ -1514,7 +1514,7 @@ bool CDImageDeviceMacOS::DetermineReadMode(Error* error)
|
||||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), RAW_SECTOR_SIZE + ALL_SUBCODE_SIZE), SCSIReadMode::Full,
|
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), RAW_SECTOR_SIZE + ALL_SUBCODE_SIZE), SCSIReadMode::Full,
|
||||||
track_1_lba))
|
track_1_lba))
|
||||||
{
|
{
|
||||||
Log_VerbosePrint("Using reads with subcode");
|
VERBOSE_LOG("Using reads with subcode");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1535,16 +1535,16 @@ bool CDImageDeviceMacOS::DetermineReadMode(Error* error)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Log_WarningPrint("SCSI reads failed, trying without subcode...");
|
WARNING_LOG("SCSI reads failed, trying without subcode...");
|
||||||
m_read_mode = SCSIReadMode::Raw;
|
m_read_mode = SCSIReadMode::Raw;
|
||||||
m_current_lba = m_lba_count;
|
m_current_lba = m_lba_count;
|
||||||
if (ReadSectorToBuffer(track_1_lba))
|
if (ReadSectorToBuffer(track_1_lba))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Using non-subcode reads, libcrypt games will not run correctly");
|
WARNING_LOG("Using non-subcode reads, libcrypt games will not run correctly");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_ErrorPrint("No read modes were successful, cannot use device.");
|
ERROR_LOG("No read modes were successful, cannot use device.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||||
if (FileSystem::FSeek64(m_fp, 0, SEEK_END) != 0 || (file_size = FileSystem::FTell64(m_fp)) <= 0 ||
|
if (FileSystem::FSeek64(m_fp, 0, SEEK_END) != 0 || (file_size = FileSystem::FTell64(m_fp)) <= 0 ||
|
||||||
FileSystem::FSeek64(m_fp, 0, SEEK_SET) != 0)
|
FileSystem::FSeek64(m_fp, 0, SEEK_SET) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Get file size failed: errno {}", errno);
|
ERROR_LOG("Get file size failed: errno {}", errno);
|
||||||
if (error)
|
if (error)
|
||||||
error->SetErrno(errno);
|
error->SetErrno(errno);
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||||
if (std::fread(header, sizeof(header), 1, m_fp) != 1 || header[0] != 'E' || header[1] != 'C' || header[2] != 'M' ||
|
if (std::fread(header, sizeof(header), 1, m_fp) != 1 || header[0] != 'E' || header[1] != 'C' || header[2] != 'M' ||
|
||||||
header[3] != 0)
|
header[3] != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read/invalid header");
|
ERROR_LOG("Failed to read/invalid header");
|
||||||
Error::SetStringView(error, "Failed to read/invalid header");
|
Error::SetStringView(error, "Failed to read/invalid header");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||||
int bits = std::fgetc(m_fp);
|
int bits = std::fgetc(m_fp);
|
||||||
if (bits == EOF)
|
if (bits == EOF)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unexpected EOF after {} chunks", m_data_map.size());
|
ERROR_LOG("Unexpected EOF after {} chunks", m_data_map.size());
|
||||||
Error::SetStringFmt(error, "Unexpected EOF after {} chunks", m_data_map.size());
|
Error::SetStringFmt(error, "Unexpected EOF after {} chunks", m_data_map.size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||||
bits = std::fgetc(m_fp);
|
bits = std::fgetc(m_fp);
|
||||||
if (bits == EOF)
|
if (bits == EOF)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unexpected EOF after {} chunks", m_data_map.size());
|
ERROR_LOG("Unexpected EOF after {} chunks", m_data_map.size());
|
||||||
Error::SetStringFmt(error, "Unexpected EOF after {} chunks", m_data_map.size());
|
Error::SetStringFmt(error, "Unexpected EOF after {} chunks", m_data_map.size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (count >= 0x80000000u)
|
if (count >= 0x80000000u)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Corrupted header after {} chunks", m_data_map.size());
|
ERROR_LOG("Corrupted header after {} chunks", m_data_map.size());
|
||||||
Error::SetStringFmt(error, "Corrupted header after {} chunks", m_data_map.size());
|
Error::SetStringFmt(error, "Corrupted header after {} chunks", m_data_map.size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (static_cast<s64>(file_offset) > file_size)
|
if (static_cast<s64>(file_offset) > file_size)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Out of file bounds after {} chunks", m_data_map.size());
|
ERROR_LOG("Out of file bounds after {} chunks", m_data_map.size());
|
||||||
Error::SetStringFmt(error, "Out of file bounds after {} chunks", m_data_map.size());
|
Error::SetStringFmt(error, "Out of file bounds after {} chunks", m_data_map.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (static_cast<s64>(file_offset) > file_size)
|
if (static_cast<s64>(file_offset) > file_size)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Out of file bounds after {} chunks", m_data_map.size());
|
ERROR_LOG("Out of file bounds after {} chunks", m_data_map.size());
|
||||||
Error::SetStringFmt(error, "Out of file bounds after {} chunks", m_data_map.size());
|
Error::SetStringFmt(error, "Out of file bounds after {} chunks", m_data_map.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (std::fseek(m_fp, file_offset, SEEK_SET) != 0)
|
if (std::fseek(m_fp, file_offset, SEEK_SET) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to seek to offset {} after {} chunks", file_offset, m_data_map.size());
|
ERROR_LOG("Failed to seek to offset {} after {} chunks", file_offset, m_data_map.size());
|
||||||
Error::SetStringFmt(error, "Failed to seek to offset {} after {} chunks", file_offset, m_data_map.size());
|
Error::SetStringFmt(error, "Failed to seek to offset {} after {} chunks", file_offset, m_data_map.size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -353,14 +353,14 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (m_data_map.empty())
|
if (m_data_map.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("No data in image '{}'", filename);
|
ERROR_LOG("No data in image '{}'", filename);
|
||||||
Error::SetStringFmt(error, "No data in image '{}'", filename);
|
Error::SetStringFmt(error, "No data in image '{}'", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lba_count = disc_offset / RAW_SECTOR_SIZE;
|
m_lba_count = disc_offset / RAW_SECTOR_SIZE;
|
||||||
if ((disc_offset % RAW_SECTOR_SIZE) != 0)
|
if ((disc_offset % RAW_SECTOR_SIZE) != 0)
|
||||||
Log_WarningFmt("ECM image is misaligned with offset {}", disc_offset);
|
WARNING_LOG("ECM image is misaligned with offset {}", disc_offset);
|
||||||
if (m_lba_count == 0)
|
if (m_lba_count == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -107,11 +107,11 @@ bool CDImageM3u::Open(const char* path, bool apply_patches, Error* error)
|
||||||
else
|
else
|
||||||
entry.filename = std::move(entry_filename);
|
entry.filename = std::move(entry_filename);
|
||||||
|
|
||||||
Log_DevFmt("Read path from m3u: '{}'", entry.filename);
|
DEV_LOG("Read path from m3u: '{}'", entry.filename);
|
||||||
m_entries.push_back(std::move(entry));
|
m_entries.push_back(std::move(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} paths from m3u '{}'", m_entries.size(), path);
|
INFO_LOG("Loaded {} paths from m3u '{}'", m_entries.size(), path);
|
||||||
return !m_entries.empty() && SwitchSubImage(0, error);
|
return !m_entries.empty() && SwitchSubImage(0, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ bool CDImageM3u::SwitchSubImage(u32 index, Error* error)
|
||||||
std::unique_ptr<CDImage> new_image = CDImage::Open(entry.filename.c_str(), m_apply_patches, error);
|
std::unique_ptr<CDImage> new_image = CDImage::Open(entry.filename.c_str(), m_apply_patches, error);
|
||||||
if (!new_image)
|
if (!new_image)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to load subimage {} ({})", index, entry.filename);
|
ERROR_LOG("Failed to load subimage {} ({})", index, entry.filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||||
std::fclose(mds_fp);
|
std::fclose(mds_fp);
|
||||||
if (!mds_data_opt.has_value() || mds_data_opt->size() < 0x54)
|
if (!mds_data_opt.has_value() || mds_data_opt->size() < 0x54)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read mds file '{}'", Path::GetFileName(filename));
|
ERROR_LOG("Failed to read mds file '{}'", Path::GetFileName(filename));
|
||||||
Error::SetStringFmt(error, "Failed to read mds file '{}'", filename);
|
Error::SetStringFmt(error, "Failed to read mds file '{}'", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||||
static constexpr char expected_signature[] = "MEDIA DESCRIPTOR";
|
static constexpr char expected_signature[] = "MEDIA DESCRIPTOR";
|
||||||
if (std::memcmp(&mds[0], expected_signature, sizeof(expected_signature) - 1) != 0)
|
if (std::memcmp(&mds[0], expected_signature, sizeof(expected_signature) - 1) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Incorrect signature in '{}'", Path::GetFileName(filename));
|
ERROR_LOG("Incorrect signature in '{}'", Path::GetFileName(filename));
|
||||||
Error::SetStringFmt(error, "Incorrect signature in '{}'", Path::GetFileName(filename));
|
Error::SetStringFmt(error, "Incorrect signature in '{}'", Path::GetFileName(filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||||
std::memcpy(&session_offset, &mds[0x50], sizeof(session_offset));
|
std::memcpy(&session_offset, &mds[0x50], sizeof(session_offset));
|
||||||
if ((session_offset + 24) > mds.size())
|
if ((session_offset + 24) > mds.size())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid session offset in '{}'", Path::GetFileName(filename));
|
ERROR_LOG("Invalid session offset in '{}'", Path::GetFileName(filename));
|
||||||
Error::SetStringFmt(error, "Invalid session offset in '{}'", Path::GetFileName(filename));
|
Error::SetStringFmt(error, "Invalid session offset in '{}'", Path::GetFileName(filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||||
std::memcpy(&track_offset, &mds[session_offset + 20], sizeof(track_offset));
|
std::memcpy(&track_offset, &mds[session_offset + 20], sizeof(track_offset));
|
||||||
if (track_count > 99 || track_offset >= mds.size())
|
if (track_count > 99 || track_offset >= mds.size())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid track count/block offset {}/{} in '{}'", track_count, track_offset, Path::GetFileName(filename));
|
ERROR_LOG("Invalid track count/block offset {}/{} in '{}'", track_count, track_offset, Path::GetFileName(filename));
|
||||||
Error::SetStringFmt(error, "Invalid track count/block offset {}/{} in '{}'", track_count, track_offset,
|
Error::SetStringFmt(error, "Invalid track count/block offset {}/{} in '{}'", track_count, track_offset,
|
||||||
Path::GetFileName(filename));
|
Path::GetFileName(filename));
|
||||||
return false;
|
return false;
|
||||||
|
@ -139,7 +139,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||||
{
|
{
|
||||||
if ((track_offset + sizeof(TrackEntry)) > mds.size())
|
if ((track_offset + sizeof(TrackEntry)) > mds.size())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("End of file in '{}' at track {}", Path::GetFileName(filename), track_number);
|
ERROR_LOG("End of file in '{}' at track {}", Path::GetFileName(filename), track_number);
|
||||||
Error::SetStringFmt(error, "End of file in '{}' at track {}", Path::GetFileName(filename), track_number);
|
Error::SetStringFmt(error, "End of file in '{}' at track {}", Path::GetFileName(filename), track_number);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||||
|
|
||||||
if (PackedBCDToBinary(track.track_number) != track_number)
|
if (PackedBCDToBinary(track.track_number) != track_number)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unexpected track number 0x{:02X} in track {}", track.track_number, track_number);
|
ERROR_LOG("Unexpected track number 0x{:02X} in track {}", track.track_number, track_number);
|
||||||
Error::SetStringFmt(error, "Unexpected track number 0x{:02X} in track {}", track.track_number, track_number);
|
Error::SetStringFmt(error, "Unexpected track number 0x{:02X} in track {}", track.track_number, track_number);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||||
|
|
||||||
if ((track.extra_offset + sizeof(u32) + sizeof(u32)) > mds.size())
|
if ((track.extra_offset + sizeof(u32) + sizeof(u32)) > mds.size())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid extra offset {} in track {}", track.extra_offset, track_number);
|
ERROR_LOG("Invalid extra offset {} in track {}", track.extra_offset, track_number);
|
||||||
Error::SetStringFmt(error, "Invalid extra offset {} in track {}", track.extra_offset, track_number);
|
Error::SetStringFmt(error, "Invalid extra offset {} in track {}", track.extra_offset, track_number);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||||
{
|
{
|
||||||
if (track_pregap > track_start_lba)
|
if (track_pregap > track_start_lba)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Track pregap {} is too large for start lba {}", track_pregap, track_start_lba);
|
ERROR_LOG("Track pregap {} is too large for start lba {}", track_pregap, track_start_lba);
|
||||||
Error::SetStringFmt(error, "Track pregap {} is too large for start lba {}", track_pregap, track_start_lba);
|
Error::SetStringFmt(error, "Track pregap {} is too large for start lba {}", track_pregap, track_start_lba);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||||
|
|
||||||
if (m_tracks.empty())
|
if (m_tracks.empty())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("File '{}' contains no tracks", Path::GetFileName(filename));
|
ERROR_LOG("File '{}' contains no tracks", Path::GetFileName(filename));
|
||||||
Error::SetStringFmt(error, "File '{}' contains no tracks", Path::GetFileName(filename));
|
Error::SetStringFmt(error, "File '{}' contains no tracks", Path::GetFileName(filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ bool CDImageMemory::CopyImage(CDImage* image, ProgressCallback* progress)
|
||||||
{
|
{
|
||||||
if (!image->ReadSectorFromIndex(memory_ptr, index, lba))
|
if (!image->ReadSectorFromIndex(memory_ptr, index, lba))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read LBA {} in index {}", lba, i);
|
ERROR_LOG("Failed to read LBA {} in index {}", lba, i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,13 +225,13 @@ bool CDImagePBP::LoadPBPHeader()
|
||||||
|
|
||||||
if (std::fread(&m_pbp_header, sizeof(PBPHeader), 1, m_file) != 1)
|
if (std::fread(&m_pbp_header, sizeof(PBPHeader), 1, m_file) != 1)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Unable to read PBP header");
|
ERROR_LOG("Unable to read PBP header");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::strncmp((char*)m_pbp_header.magic, "\0PBP", 4) != 0)
|
if (std::strncmp((char*)m_pbp_header.magic, "\0PBP", 4) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("PBP magic number mismatch");
|
ERROR_LOG("PBP magic number mismatch");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ bool CDImagePBP::LoadSFOHeader()
|
||||||
|
|
||||||
if (std::strncmp((char*)m_sfo_header.magic, "\0PSF", 4) != 0)
|
if (std::strncmp((char*)m_sfo_header.magic, "\0PSF", 4) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("SFO magic number mismatch");
|
ERROR_LOG("SFO magic number mismatch");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ bool CDImagePBP::LoadSFOTable()
|
||||||
|
|
||||||
if (FileSystem::FSeek64(m_file, abs_key_offset, SEEK_SET) != 0)
|
if (FileSystem::FSeek64(m_file, abs_key_offset, SEEK_SET) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed seek to key for SFO table entry {}", i);
|
ERROR_LOG("Failed seek to key for SFO table entry {}", i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,19 +306,19 @@ bool CDImagePBP::LoadSFOTable()
|
||||||
char key_cstr[20] = {};
|
char key_cstr[20] = {};
|
||||||
if (std::fgets(key_cstr, sizeof(key_cstr), m_file) == nullptr)
|
if (std::fgets(key_cstr, sizeof(key_cstr), m_file) == nullptr)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read key string for SFO table entry {}", i);
|
ERROR_LOG("Failed to read key string for SFO table entry {}", i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileSystem::FSeek64(m_file, abs_data_offset, SEEK_SET) != 0)
|
if (FileSystem::FSeek64(m_file, abs_data_offset, SEEK_SET) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed seek to data for SFO table entry {}", i);
|
ERROR_LOG("Failed seek to data for SFO table entry {}", i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_sfo_index_table[i].data_type == 0x0004) // "special mode" UTF-8 (not null terminated)
|
if (m_sfo_index_table[i].data_type == 0x0004) // "special mode" UTF-8 (not null terminated)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unhandled special mode UTF-8 type found in SFO table for entry {}", i);
|
ERROR_LOG("Unhandled special mode UTF-8 type found in SFO table for entry {}", i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (m_sfo_index_table[i].data_type == 0x0204) // null-terminated UTF-8 character string
|
else if (m_sfo_index_table[i].data_type == 0x0204) // null-terminated UTF-8 character string
|
||||||
|
@ -326,7 +326,7 @@ bool CDImagePBP::LoadSFOTable()
|
||||||
std::vector<char> data_cstr(m_sfo_index_table[i].data_size);
|
std::vector<char> data_cstr(m_sfo_index_table[i].data_size);
|
||||||
if (fgets(data_cstr.data(), static_cast<int>(data_cstr.size() * sizeof(char)), m_file) == nullptr)
|
if (fgets(data_cstr.data(), static_cast<int>(data_cstr.size() * sizeof(char)), m_file) == nullptr)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read data string for SFO table entry {}", i);
|
ERROR_LOG("Failed to read data string for SFO table entry {}", i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ bool CDImagePBP::LoadSFOTable()
|
||||||
u32 val;
|
u32 val;
|
||||||
if (std::fread(&val, sizeof(u32), 1, m_file) != 1)
|
if (std::fread(&val, sizeof(u32), 1, m_file) != 1)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read unsigned data value for SFO table entry {}", i);
|
ERROR_LOG("Failed to read unsigned data value for SFO table entry {}", i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,8 +345,7 @@ bool CDImagePBP::LoadSFOTable()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unhandled SFO data type 0x{:04X} found in SFO table for entry {}", m_sfo_index_table[i].data_type,
|
ERROR_LOG("Unhandled SFO data type 0x{:04X} found in SFO table for entry {}", m_sfo_index_table[i].data_type, i);
|
||||||
i);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,14 +367,14 @@ bool CDImagePBP::IsValidEboot(Error* error)
|
||||||
SFOTableDataValue data_value = a_it->second;
|
SFOTableDataValue data_value = a_it->second;
|
||||||
if (!std::holds_alternative<u32>(data_value) || std::get<u32>(data_value) != 1)
|
if (!std::holds_alternative<u32>(data_value) || std::get<u32>(data_value) != 1)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid BOOTABLE value");
|
ERROR_LOG("Invalid BOOTABLE value");
|
||||||
Error::SetString(error, "Invalid BOOTABLE value");
|
Error::SetString(error, "Invalid BOOTABLE value");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("No BOOTABLE value found");
|
ERROR_LOG("No BOOTABLE value found");
|
||||||
Error::SetString(error, "No BOOTABLE value found");
|
Error::SetString(error, "No BOOTABLE value found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -386,14 +385,14 @@ bool CDImagePBP::IsValidEboot(Error* error)
|
||||||
SFOTableDataValue data_value = a_it->second;
|
SFOTableDataValue data_value = a_it->second;
|
||||||
if (!std::holds_alternative<std::string>(data_value) || std::get<std::string>(data_value) != "ME")
|
if (!std::holds_alternative<std::string>(data_value) || std::get<std::string>(data_value) != "ME")
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid CATEGORY value");
|
ERROR_LOG("Invalid CATEGORY value");
|
||||||
Error::SetString(error, "Invalid CATEGORY value");
|
Error::SetString(error, "Invalid CATEGORY value");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("No CATEGORY value found");
|
ERROR_LOG("No CATEGORY value found");
|
||||||
Error::SetString(error, "No CATEGORY value found");
|
Error::SetString(error, "No CATEGORY value found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -415,7 +414,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||||
// Read in PBP header
|
// Read in PBP header
|
||||||
if (!LoadPBPHeader())
|
if (!LoadPBPHeader())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to load PBP header");
|
ERROR_LOG("Failed to load PBP header");
|
||||||
Error::SetString(error, "Failed to load PBP header");
|
Error::SetString(error, "Failed to load PBP header");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -423,7 +422,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||||
// Read in SFO header
|
// Read in SFO header
|
||||||
if (!LoadSFOHeader())
|
if (!LoadSFOHeader())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to load SFO header");
|
ERROR_LOG("Failed to load SFO header");
|
||||||
Error::SetString(error, "Failed to load SFO header");
|
Error::SetString(error, "Failed to load SFO header");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -431,7 +430,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||||
// Read in SFO index table
|
// Read in SFO index table
|
||||||
if (!LoadSFOIndexTable())
|
if (!LoadSFOIndexTable())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to load SFO index table");
|
ERROR_LOG("Failed to load SFO index table");
|
||||||
Error::SetString(error, "Failed to load SFO index table");
|
Error::SetString(error, "Failed to load SFO index table");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -439,7 +438,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||||
// Read in SFO table
|
// Read in SFO table
|
||||||
if (!LoadSFOTable())
|
if (!LoadSFOTable())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to load SFO table");
|
ERROR_LOG("Failed to load SFO table");
|
||||||
Error::SetString(error, "Failed to load SFO table");
|
Error::SetString(error, "Failed to load SFO table");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -447,7 +446,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||||
// Since PBP files can store things that aren't PS1 CD images, make sure we're loading the right kind
|
// Since PBP files can store things that aren't PS1 CD images, make sure we're loading the right kind
|
||||||
if (!IsValidEboot(error))
|
if (!IsValidEboot(error))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Couldn't validate EBOOT");
|
ERROR_LOG("Couldn't validate EBOOT");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +475,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||||
// Ignore encrypted files
|
// Ignore encrypted files
|
||||||
if (disc_table[0] == 0x44475000) // "\0PGD"
|
if (disc_table[0] == 0x44475000) // "\0PGD"
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Encrypted PBP images are not supported, skipping %s", m_filename);
|
ERROR_LOG("Encrypted PBP images are not supported, skipping %s", m_filename);
|
||||||
Error::SetString(error, "Encrypted PBP images are not supported");
|
Error::SetString(error, "Encrypted PBP images are not supported");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -492,7 +491,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||||
|
|
||||||
if (m_disc_offsets.size() < 1)
|
if (m_disc_offsets.size() < 1)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid number of discs ({}) in multi-disc PBP file", m_disc_offsets.size());
|
ERROR_LOG("Invalid number of discs ({}) in multi-disc PBP file", m_disc_offsets.size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -509,7 +508,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||||
{
|
{
|
||||||
if (index >= m_disc_offsets.size())
|
if (index >= m_disc_offsets.size())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("File does not contain disc {}", index + 1);
|
ERROR_LOG("File does not contain disc {}", index + 1);
|
||||||
Error::SetString(error, fmt::format("File does not contain disc {}", index + 1));
|
Error::SetString(error, fmt::format("File does not contain disc {}", index + 1));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -531,7 +530,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||||
|
|
||||||
if (std::strncmp(iso_header_magic, "PSISOIMG0000", 12) != 0)
|
if (std::strncmp(iso_header_magic, "PSISOIMG0000", 12) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("ISO header magic number mismatch");
|
ERROR_LOG("ISO header magic number mismatch");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +544,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||||
|
|
||||||
if (pgd_magic == 0x44475000) // "\0PGD"
|
if (pgd_magic == 0x44475000) // "\0PGD"
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Encrypted PBP images are not supported, skipping {}", m_filename);
|
ERROR_LOG("Encrypted PBP images are not supported, skipping {}", m_filename);
|
||||||
Error::SetString(error, "Encrypted PBP images are not supported");
|
Error::SetString(error, "Encrypted PBP images are not supported");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -594,7 +593,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||||
// valid. Not sure what m_toc[0].userdata_start.s encodes on homebrew EBOOTs though, so ignore that
|
// valid. Not sure what m_toc[0].userdata_start.s encodes on homebrew EBOOTs though, so ignore that
|
||||||
if (m_toc[0].point != 0xA0 || m_toc[1].point != 0xA1 || m_toc[2].point != 0xA2)
|
if (m_toc[0].point != 0xA0 || m_toc[1].point != 0xA1 || m_toc[2].point != 0xA2)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid points on information tracks");
|
ERROR_LOG("Invalid points on information tracks");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,7 +604,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||||
|
|
||||||
if (first_track != 1 || last_track < first_track)
|
if (first_track != 1 || last_track < first_track)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid starting track number or track count");
|
ERROR_LOG("Invalid starting track number or track count");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,7 +622,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||||
const TOCEntry& t = m_toc[static_cast<size_t>(curr_track) + 2];
|
const TOCEntry& t = m_toc[static_cast<size_t>(curr_track) + 2];
|
||||||
const u8 track_num = PackedBCDToBinary(t.point);
|
const u8 track_num = PackedBCDToBinary(t.point);
|
||||||
if (track_num != curr_track)
|
if (track_num != curr_track)
|
||||||
Log_WarningFmt("Mismatched TOC track number, expected {} but got {}", curr_track, track_num);
|
WARNING_LOG("Mismatched TOC track number, expected {} but got {}", curr_track, track_num);
|
||||||
|
|
||||||
const bool is_audio_track = t.type == 0x01;
|
const bool is_audio_track = t.type == 0x01;
|
||||||
const bool is_first_track = curr_track == 1;
|
const bool is_first_track = curr_track == 1;
|
||||||
|
@ -643,12 +642,12 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||||
{
|
{
|
||||||
if (!is_first_track || is_audio_track)
|
if (!is_first_track || is_audio_track)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid TOC entry at index {}, user data ({}) should not start before pregap ({})", curr_track,
|
ERROR_LOG("Invalid TOC entry at index {}, user data ({}) should not start before pregap ({})", curr_track,
|
||||||
userdata_start, pregap_start);
|
userdata_start, pregap_start);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningFmt(
|
WARNING_LOG(
|
||||||
"Invalid TOC entry at index {}, user data ({}) should not start before pregap ({}), assuming not in file.",
|
"Invalid TOC entry at index {}, user data ({}) should not start before pregap ({}), assuming not in file.",
|
||||||
curr_track, userdata_start, pregap_start);
|
curr_track, userdata_start, pregap_start);
|
||||||
pregap_start = 0;
|
pregap_start = 0;
|
||||||
|
@ -701,7 +700,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||||
{
|
{
|
||||||
if (userdata_start >= m_lba_count)
|
if (userdata_start >= m_lba_count)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Last user data index on disc for TOC entry {} should not be 0 or less in length", curr_track);
|
ERROR_LOG("Last user data index on disc for TOC entry {} should not be 0 or less in length", curr_track);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
userdata_index.length = m_lba_count - userdata_start;
|
userdata_index.length = m_lba_count - userdata_start;
|
||||||
|
@ -715,7 +714,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||||
|
|
||||||
if (next_track_num != curr_track + 1 || next_track_start < userdata_start)
|
if (next_track_num != curr_track + 1 || next_track_start < userdata_start)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Unable to calculate user data index length for TOC entry {}", curr_track);
|
ERROR_LOG("Unable to calculate user data index length for TOC entry {}", curr_track);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,7 +733,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||||
// Initialize zlib stream
|
// Initialize zlib stream
|
||||||
if (!InitDecompressionStream())
|
if (!InitDecompressionStream())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to initialize zlib decompression stream");
|
ERROR_LOG("Failed to initialize zlib decompression stream");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,7 +809,7 @@ bool CDImagePBP::DecompressBlock(const BlockInfo& block_info)
|
||||||
int err = inflate(&m_inflate_stream, Z_FINISH);
|
int err = inflate(&m_inflate_stream, Z_FINISH);
|
||||||
if (err != Z_STREAM_END) [[unlikely]]
|
if (err != Z_STREAM_END) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Inflate error {}", err);
|
ERROR_LOG("Inflate error {}", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -840,13 +839,13 @@ bool CDImagePBP::ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_i
|
||||||
|
|
||||||
if (bi.size == 0) [[unlikely]]
|
if (bi.size == 0) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid block {} requested", requested_block);
|
ERROR_LOG("Invalid block {} requested", requested_block);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_current_block != requested_block && !DecompressBlock(bi)) [[unlikely]]
|
if (m_current_block != requested_block && !DecompressBlock(bi)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to decompress block {}", requested_block);
|
ERROR_LOG("Failed to decompress block {}", requested_block);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ bool CDImagePPF::Open(const char* filename, std::unique_ptr<CDImage> parent_imag
|
||||||
auto fp = FileSystem::OpenManagedSharedCFile(filename, "rb", FileSystem::FileShareMode::DenyWrite);
|
auto fp = FileSystem::OpenManagedSharedCFile(filename, "rb", FileSystem::FileShareMode::DenyWrite);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to open '%s'", filename);
|
ERROR_LOG("Failed to open '%s'", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ bool CDImagePPF::Open(const char* filename, std::unique_ptr<CDImage> parent_imag
|
||||||
u32 magic;
|
u32 magic;
|
||||||
if (std::fread(&magic, sizeof(magic), 1, fp.get()) != 1)
|
if (std::fread(&magic, sizeof(magic), 1, fp.get()) != 1)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read magic from '%s'", filename);
|
ERROR_LOG("Failed to read magic from '%s'", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ bool CDImagePPF::Open(const char* filename, std::unique_ptr<CDImage> parent_imag
|
||||||
else if (magic == 0x31465050) // PPF1
|
else if (magic == 0x31465050) // PPF1
|
||||||
return ReadV1Patch(fp.get());
|
return ReadV1Patch(fp.get());
|
||||||
|
|
||||||
Log_ErrorFmt("Unknown PPF magic {:08X}", magic);
|
ERROR_LOG("Unknown PPF magic {:08X}", magic);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ u32 CDImagePPF::ReadFileIDDiz(std::FILE* fp, u32 version)
|
||||||
u32 magic;
|
u32 magic;
|
||||||
if (std::fseek(fp, -(lenidx + 4), SEEK_END) != 0 || std::fread(&magic, sizeof(magic), 1, fp) != 1) [[unlikely]]
|
if (std::fseek(fp, -(lenidx + 4), SEEK_END) != 0 || std::fread(&magic, sizeof(magic), 1, fp) != 1) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Failed to read diz magic");
|
WARNING_LOG("Failed to read diz magic");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,13 +121,13 @@ u32 CDImagePPF::ReadFileIDDiz(std::FILE* fp, u32 version)
|
||||||
u32 dlen = 0;
|
u32 dlen = 0;
|
||||||
if (std::fseek(fp, -lenidx, SEEK_END) != 0 || std::fread(&dlen, lenidx, 1, fp) != 1) [[unlikely]]
|
if (std::fseek(fp, -lenidx, SEEK_END) != 0 || std::fread(&dlen, lenidx, 1, fp) != 1) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Failed to read diz length");
|
WARNING_LOG("Failed to read diz length");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dlen > static_cast<u32>(std::ftell(fp))) [[unlikely]]
|
if (dlen > static_cast<u32>(std::ftell(fp))) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_WarningPrint("diz length out of range");
|
WARNING_LOG("diz length out of range");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,11 +136,11 @@ u32 CDImagePPF::ReadFileIDDiz(std::FILE* fp, u32 version)
|
||||||
if (std::fseek(fp, -(lenidx + 16 + static_cast<int>(dlen)), SEEK_END) != 0 ||
|
if (std::fseek(fp, -(lenidx + 16 + static_cast<int>(dlen)), SEEK_END) != 0 ||
|
||||||
std::fread(fdiz.data(), 1, dlen, fp) != dlen) [[unlikely]]
|
std::fread(fdiz.data(), 1, dlen, fp) != dlen) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Failed to read fdiz");
|
WARNING_LOG("Failed to read fdiz");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("File_Id.diz: %s", fdiz);
|
INFO_LOG("File_Id.diz: %s", fdiz);
|
||||||
return dlen;
|
return dlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ bool CDImagePPF::ReadV1Patch(std::FILE* fp)
|
||||||
char desc[DESC_SIZE + 1] = {};
|
char desc[DESC_SIZE + 1] = {};
|
||||||
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE) [[unlikely]]
|
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read description");
|
ERROR_LOG("Failed to read description");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ bool CDImagePPF::ReadV1Patch(std::FILE* fp)
|
||||||
if (std::fseek(fp, 0, SEEK_END) != 0 || (filelen = static_cast<u32>(std::ftell(fp))) == 0 || filelen < 56)
|
if (std::fseek(fp, 0, SEEK_END) != 0 || (filelen = static_cast<u32>(std::ftell(fp))) == 0 || filelen < 56)
|
||||||
[[unlikely]]
|
[[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid ppf file");
|
ERROR_LOG("Invalid ppf file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,14 +176,14 @@ bool CDImagePPF::ReadV1Patch(std::FILE* fp)
|
||||||
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
||||||
[[unlikely]]
|
[[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Incomplete ppf");
|
ERROR_LOG("Incomplete ppf");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp.resize(chunk_size);
|
temp.resize(chunk_size);
|
||||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size) [[unlikely]]
|
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read patch data");
|
ERROR_LOG("Failed to read patch data");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ bool CDImagePPF::ReadV1Patch(std::FILE* fp)
|
||||||
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} replacement sectors from version 1 PPF", m_replacement_map.size());
|
INFO_LOG("Loaded {} replacement sectors from version 1 PPF", m_replacement_map.size());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,18 +202,18 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||||
char desc[DESC_SIZE + 1] = {};
|
char desc[DESC_SIZE + 1] = {};
|
||||||
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE) [[unlikely]]
|
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read description");
|
ERROR_LOG("Failed to read description");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Patch description: %s", desc);
|
INFO_LOG("Patch description: %s", desc);
|
||||||
|
|
||||||
const u32 idlen = ReadFileIDDiz(fp, 2);
|
const u32 idlen = ReadFileIDDiz(fp, 2);
|
||||||
|
|
||||||
u32 origlen;
|
u32 origlen;
|
||||||
if (std::fseek(fp, 56, SEEK_SET) != 0 || std::fread(&origlen, sizeof(origlen), 1, fp) != 1) [[unlikely]]
|
if (std::fseek(fp, 56, SEEK_SET) != 0 || std::fread(&origlen, sizeof(origlen), 1, fp) != 1) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read size");
|
ERROR_LOG("Failed to read size");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||||
temp.resize(BLOCKCHECK_SIZE);
|
temp.resize(BLOCKCHECK_SIZE);
|
||||||
if (std::fread(temp.data(), 1, BLOCKCHECK_SIZE, fp) != BLOCKCHECK_SIZE) [[unlikely]]
|
if (std::fread(temp.data(), 1, BLOCKCHECK_SIZE, fp) != BLOCKCHECK_SIZE) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read blockcheck data");
|
ERROR_LOG("Failed to read blockcheck data");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,11 +234,11 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||||
if (m_parent_image->Seek(blockcheck_src_sector) && m_parent_image->ReadRawSector(src_sector.data(), nullptr))
|
if (m_parent_image->Seek(blockcheck_src_sector) && m_parent_image->ReadRawSector(src_sector.data(), nullptr))
|
||||||
{
|
{
|
||||||
if (std::memcmp(&src_sector[blockcheck_src_offset], temp.data(), BLOCKCHECK_SIZE) != 0)
|
if (std::memcmp(&src_sector[blockcheck_src_offset], temp.data(), BLOCKCHECK_SIZE) != 0)
|
||||||
Log_WarningPrint("Blockcheck failed. The patch may not apply correctly.");
|
WARNING_LOG("Blockcheck failed. The patch may not apply correctly.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Failed to read blockcheck sector {}", blockcheck_src_sector);
|
WARNING_LOG("Failed to read blockcheck sector {}", blockcheck_src_sector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||||
if (std::fseek(fp, 0, SEEK_END) != 0 || (filelen = static_cast<u32>(std::ftell(fp))) == 0 || filelen < 1084)
|
if (std::fseek(fp, 0, SEEK_END) != 0 || (filelen = static_cast<u32>(std::ftell(fp))) == 0 || filelen < 1084)
|
||||||
[[unlikely]]
|
[[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Invalid ppf file");
|
ERROR_LOG("Invalid ppf file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,14 +267,14 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||||
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
||||||
[[unlikely]]
|
[[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Incomplete ppf");
|
ERROR_LOG("Incomplete ppf");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp.resize(chunk_size);
|
temp.resize(chunk_size);
|
||||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size) [[unlikely]]
|
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read patch data");
|
ERROR_LOG("Failed to read patch data");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||||
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} replacement sectors from version 2 PPF", m_replacement_map.size());
|
INFO_LOG("Loaded {} replacement sectors from version 2 PPF", m_replacement_map.size());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,11 +293,11 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||||
char desc[DESC_SIZE + 1] = {};
|
char desc[DESC_SIZE + 1] = {};
|
||||||
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE)
|
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read description");
|
ERROR_LOG("Failed to read description");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Patch description: {}", desc);
|
INFO_LOG("Patch description: {}", desc);
|
||||||
|
|
||||||
u32 idlen = ReadFileIDDiz(fp, 3);
|
u32 idlen = ReadFileIDDiz(fp, 3);
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||||
if (std::fseek(fp, 56, SEEK_SET) != 0 || std::fread(&image_type, sizeof(image_type), 1, fp) != 1 ||
|
if (std::fseek(fp, 56, SEEK_SET) != 0 || std::fread(&image_type, sizeof(image_type), 1, fp) != 1 ||
|
||||||
std::fread(&block_check, sizeof(block_check), 1, fp) != 1 || std::fread(&undo, sizeof(undo), 1, fp) != 1)
|
std::fread(&block_check, sizeof(block_check), 1, fp) != 1 || std::fread(&undo, sizeof(undo), 1, fp) != 1)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read headers");
|
ERROR_LOG("Failed to read headers");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||||
u32 seekpos = (block_check) ? 1084 : 60;
|
u32 seekpos = (block_check) ? 1084 : 60;
|
||||||
if (seekpos >= count)
|
if (seekpos >= count)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("File is too short");
|
ERROR_LOG("File is too short");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||||
const u32 extralen = idlen + 18 + 16 + 2;
|
const u32 extralen = idlen + 18 + 16 + 2;
|
||||||
if (count < extralen)
|
if (count < extralen)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("File is too short (diz)");
|
ERROR_LOG("File is too short (diz)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,14 +347,14 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||||
u8 chunk_size;
|
u8 chunk_size;
|
||||||
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Incomplete ppf");
|
ERROR_LOG("Incomplete ppf");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp.resize(chunk_size);
|
temp.resize(chunk_size);
|
||||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size)
|
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to read patch data");
|
ERROR_LOG("Failed to read patch data");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,13 +364,13 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||||
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} replacement sectors from version 3 PPF", m_replacement_map.size());
|
INFO_LOG("Loaded {} replacement sectors from version 3 PPF", m_replacement_map.size());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDImagePPF::AddPatch(u64 offset, const u8* patch, u32 patch_size)
|
bool CDImagePPF::AddPatch(u64 offset, const u8* patch, u32 patch_size)
|
||||||
{
|
{
|
||||||
Log_DebugFmt("Starting applying patch of {} bytes at at offset {}", patch_size, offset);
|
DEBUG_LOG("Starting applying patch of {} bytes at at offset {}", patch_size, offset);
|
||||||
|
|
||||||
while (patch_size > 0)
|
while (patch_size > 0)
|
||||||
{
|
{
|
||||||
|
@ -378,7 +378,7 @@ bool CDImagePPF::AddPatch(u64 offset, const u8* patch, u32 patch_size)
|
||||||
const u32 sector_offset = Truncate32(offset % RAW_SECTOR_SIZE);
|
const u32 sector_offset = Truncate32(offset % RAW_SECTOR_SIZE);
|
||||||
if (sector_index >= m_parent_image->GetLBACount())
|
if (sector_index >= m_parent_image->GetLBACount())
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Sector {} in patch is out of range", sector_index);
|
ERROR_LOG("Sector {} in patch is out of range", sector_index);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ bool CDImagePPF::AddPatch(u64 offset, const u8* patch, u32 patch_size)
|
||||||
if (!m_parent_image->Seek(sector_index) ||
|
if (!m_parent_image->Seek(sector_index) ||
|
||||||
!m_parent_image->ReadRawSector(&m_replacement_data[replacement_buffer_start], nullptr))
|
!m_parent_image->ReadRawSector(&m_replacement_data[replacement_buffer_start], nullptr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read sector {} from parent image", sector_index);
|
ERROR_LOG("Failed to read sector {} from parent image", sector_index);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ bool CDImagePPF::AddPatch(u64 offset, const u8* patch, u32 patch_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
// patch it!
|
// patch it!
|
||||||
Log_DebugFmt(" Patching {} bytes at sector {} offset {}", bytes_to_patch, sector_index, sector_offset);
|
DEBUG_LOG(" Patching {} bytes at sector {} offset {}", bytes_to_patch, sector_index, sector_offset);
|
||||||
std::memcpy(&m_replacement_data[iter->second + sector_offset], patch, bytes_to_patch);
|
std::memcpy(&m_replacement_data[iter->second + sector_offset], patch, bytes_to_patch);
|
||||||
offset += bytes_to_patch;
|
offset += bytes_to_patch;
|
||||||
patch += bytes_to_patch;
|
patch += bytes_to_patch;
|
||||||
|
|
|
@ -50,14 +50,14 @@ bool CDSubChannelReplacement::LoadSBI(const std::string& path)
|
||||||
char header[4];
|
char header[4];
|
||||||
if (std::fread(header, sizeof(header), 1, fp.get()) != 1)
|
if (std::fread(header, sizeof(header), 1, fp.get()) != 1)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to read header for '{}'", path);
|
ERROR_LOG("Failed to read header for '{}'", path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr char expected_header[] = {'S', 'B', 'I', '\0'};
|
static constexpr char expected_header[] = {'S', 'B', 'I', '\0'};
|
||||||
if (std::memcmp(header, expected_header, sizeof(header)) != 0)
|
if (std::memcmp(header, expected_header, sizeof(header)) != 0)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid header in '{}'", path);
|
ERROR_LOG("Invalid header in '{}'", path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,14 +69,14 @@ bool CDSubChannelReplacement::LoadSBI(const std::string& path)
|
||||||
if (!IsValidPackedBCD(entry.minute_bcd) || !IsValidPackedBCD(entry.second_bcd) ||
|
if (!IsValidPackedBCD(entry.minute_bcd) || !IsValidPackedBCD(entry.second_bcd) ||
|
||||||
!IsValidPackedBCD(entry.frame_bcd))
|
!IsValidPackedBCD(entry.frame_bcd))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid position [{:02x}:{:02x}:{:02x}] in '{}'", entry.minute_bcd, entry.second_bcd,
|
ERROR_LOG("Invalid position [{:02x}:{:02x}:{:02x}] in '{}'", entry.minute_bcd, entry.second_bcd, entry.frame_bcd,
|
||||||
entry.frame_bcd, path);
|
path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.type != 1)
|
if (entry.type != 1)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid type 0x{:02X} in '{}'", entry.type, path);
|
ERROR_LOG("Invalid type 0x{:02X} in '{}'", entry.type, path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ bool CDSubChannelReplacement::LoadSBI(const std::string& path)
|
||||||
m_replacement_subq.emplace(lba, subq);
|
m_replacement_subq.emplace(lba, subq);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} replacement sectors from SBI '{}'", m_replacement_subq.size(), path);
|
INFO_LOG("Loaded {} replacement sectors from SBI '{}'", m_replacement_subq.size(), path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,8 +111,8 @@ bool CDSubChannelReplacement::LoadLSD(const std::string& path)
|
||||||
if (!IsValidPackedBCD(entry.minute_bcd) || !IsValidPackedBCD(entry.second_bcd) ||
|
if (!IsValidPackedBCD(entry.minute_bcd) || !IsValidPackedBCD(entry.second_bcd) ||
|
||||||
!IsValidPackedBCD(entry.frame_bcd))
|
!IsValidPackedBCD(entry.frame_bcd))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Invalid position [{:02x}:{:02x}:{:02x}] in '{}'", entry.minute_bcd, entry.second_bcd,
|
ERROR_LOG("Invalid position [{:02x}:{:02x}:{:02x}] in '{}'", entry.minute_bcd, entry.second_bcd, entry.frame_bcd,
|
||||||
entry.frame_bcd, path);
|
path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,12 +121,12 @@ bool CDSubChannelReplacement::LoadLSD(const std::string& path)
|
||||||
CDImage::SubChannelQ subq;
|
CDImage::SubChannelQ subq;
|
||||||
std::copy_n(entry.data, countof(entry.data), subq.data.data());
|
std::copy_n(entry.data, countof(entry.data), subq.data.data());
|
||||||
|
|
||||||
Log_DebugFmt("{:02x}:{:02x}:{:02x}: CRC {}", entry.minute_bcd, entry.second_bcd, entry.frame_bcd,
|
DEBUG_LOG("{:02x}:{:02x}:{:02x}: CRC {}", entry.minute_bcd, entry.second_bcd, entry.frame_bcd,
|
||||||
subq.IsCRCValid() ? "VALID" : "INVALID");
|
subq.IsCRCValid() ? "VALID" : "INVALID");
|
||||||
m_replacement_subq.emplace(lba, subq);
|
m_replacement_subq.emplace(lba, subq);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Loaded {} replacement sectors from LSD '{}'", m_replacement_subq.size(), path);
|
INFO_LOG("Loaded {} replacement sectors from LSD '{}'", m_replacement_subq.size(), path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ void CubebAudioStream::LogCallback(const char* fmt, ...)
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
str.vsprintf(fmt, ap);
|
str.vsprintf(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
Log_DevPrint(str);
|
DEV_LOG(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CubebAudioStream::DestroyContextAndStream()
|
void CubebAudioStream::DestroyContextAndStream()
|
||||||
|
@ -172,8 +172,8 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
||||||
rv = cubeb_get_min_latency(m_context, ¶ms, &min_latency_frames);
|
rv = cubeb_get_min_latency(m_context, ¶ms, &min_latency_frames);
|
||||||
if (rv == CUBEB_ERROR_NOT_SUPPORTED)
|
if (rv == CUBEB_ERROR_NOT_SUPPORTED)
|
||||||
{
|
{
|
||||||
Log_DevFmt("Cubeb backend does not support latency queries, using latency of {} ms ({} frames).",
|
DEV_LOG("Cubeb backend does not support latency queries, using latency of {} ms ({} frames).",
|
||||||
m_parameters.buffer_ms, latency_frames);
|
m_parameters.buffer_ms, latency_frames);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -185,7 +185,7 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 minimum_latency_ms = GetMSForBufferSize(m_sample_rate, min_latency_frames);
|
const u32 minimum_latency_ms = GetMSForBufferSize(m_sample_rate, min_latency_frames);
|
||||||
Log_DevFmt("Minimum latency: {} ms ({} audio frames)", minimum_latency_ms, min_latency_frames);
|
DEV_LOG("Minimum latency: {} ms ({} audio frames)", minimum_latency_ms, min_latency_frames);
|
||||||
if (m_parameters.output_latency_minimal)
|
if (m_parameters.output_latency_minimal)
|
||||||
{
|
{
|
||||||
// use minimum
|
// use minimum
|
||||||
|
@ -193,8 +193,8 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
||||||
}
|
}
|
||||||
else if (minimum_latency_ms > m_parameters.output_latency_ms)
|
else if (minimum_latency_ms > m_parameters.output_latency_ms)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Minimum latency is above requested latency: {} vs {}, adjusting to compensate.",
|
WARNING_LOG("Minimum latency is above requested latency: {} vs {}, adjusting to compensate.", min_latency_frames,
|
||||||
min_latency_frames, latency_frames);
|
latency_frames);
|
||||||
latency_frames = min_latency_frames;
|
latency_frames = min_latency_frames;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,8 +214,7 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
||||||
const cubeb_device_info& di = devices.device[i];
|
const cubeb_device_info& di = devices.device[i];
|
||||||
if (di.device_id && selected_device_name == di.device_id)
|
if (di.device_id && selected_device_name == di.device_id)
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Using output device '{}' ({}).", di.device_id,
|
INFO_LOG("Using output device '{}' ({}).", di.device_id, di.friendly_name ? di.friendly_name : di.device_id);
|
||||||
di.friendly_name ? di.friendly_name : di.device_id);
|
|
||||||
selected_device = di.devid;
|
selected_device = di.devid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +228,7 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("cubeb_enumerate_devices() returned {}, using default device.", GetCubebErrorString(rv));
|
WARNING_LOG("cubeb_enumerate_devices() returned {}, using default device.", GetCubebErrorString(rv));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +281,7 @@ void CubebAudioStream::SetPaused(bool paused)
|
||||||
const int rv = paused ? cubeb_stream_stop(stream) : cubeb_stream_start(stream);
|
const int rv = paused ? cubeb_stream_stop(stream) : cubeb_stream_start(stream);
|
||||||
if (rv != CUBEB_OK)
|
if (rv != CUBEB_OK)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Could not {} stream: {}", paused ? "pause" : "resume", rv);
|
ERROR_LOG("Could not {} stream: {}", paused ? "pause" : "resume", rv);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +319,7 @@ std::vector<AudioStream::DeviceInfo> AudioStream::GetCubebOutputDevices(const ch
|
||||||
int rv = cubeb_init(&context, "DuckStation", (driver && *driver) ? driver : nullptr);
|
int rv = cubeb_init(&context, "DuckStation", (driver && *driver) ? driver : nullptr);
|
||||||
if (rv != CUBEB_OK)
|
if (rv != CUBEB_OK)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("cubeb_init() failed: {}", GetCubebErrorString(rv));
|
ERROR_LOG("cubeb_init() failed: {}", GetCubebErrorString(rv));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +329,7 @@ std::vector<AudioStream::DeviceInfo> AudioStream::GetCubebOutputDevices(const ch
|
||||||
rv = cubeb_enumerate_devices(context, CUBEB_DEVICE_TYPE_OUTPUT, &devices);
|
rv = cubeb_enumerate_devices(context, CUBEB_DEVICE_TYPE_OUTPUT, &devices);
|
||||||
if (rv != CUBEB_OK)
|
if (rv != CUBEB_OK)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("cubeb_enumerate_devices() failed: {}", GetCubebErrorString(rv));
|
ERROR_LOG("cubeb_enumerate_devices() failed: {}", GetCubebErrorString(rv));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ void CueParser::File::SetError(u32 line_number, Error* error, const char* format
|
||||||
str.vsprintf(format, ap);
|
str.vsprintf(format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
Log_ErrorFmt("Cue parse error at line {}: {}", line_number, str.c_str());
|
ERROR_LOG("Cue parse error at line {}: {}", line_number, str.c_str());
|
||||||
Error::SetString(error, fmt::format("Cue parse error at line {}: {}", line_number, str));
|
Error::SetString(error, fmt::format("Cue parse error at line {}: {}", line_number, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ bool CueParser::File::ParseLine(const char* line, u32 line_number, Error* error)
|
||||||
|
|
||||||
if (TokenMatch(command, "POSTGAP"))
|
if (TokenMatch(command, "POSTGAP"))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Ignoring '{}' command", command);
|
WARNING_LOG("Ignoring '{}' command", command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ bool CueParser::File::HandleFileCommand(const char* line, u32 line_number, Error
|
||||||
}
|
}
|
||||||
|
|
||||||
m_current_file = filename;
|
m_current_file = filename;
|
||||||
Log_DebugFmt("File '{}'", filename);
|
DEBUG_LOG("File '{}'", filename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ bool CueParser::File::HandleFlagCommand(const char* line, u32 line_number, Error
|
||||||
else if (TokenMatch(token, "SCMS"))
|
else if (TokenMatch(token, "SCMS"))
|
||||||
m_current_track->SetFlag(TrackFlag::SerialCopyManagement);
|
m_current_track->SetFlag(TrackFlag::SerialCopyManagement);
|
||||||
else
|
else
|
||||||
Log_WarningFmt("Unknown track flag '{}'", token);
|
WARNING_LOG("Unknown track flag '{}'", token);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -428,7 +428,7 @@ bool CueParser::File::CompleteLastTrack(u32 line_number, Error* error)
|
||||||
const MSF* index0 = m_current_track->GetIndex(0);
|
const MSF* index0 = m_current_track->GetIndex(0);
|
||||||
if (index0 && m_current_track->zero_pregap.has_value())
|
if (index0 && m_current_track->zero_pregap.has_value())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Zero pregap and index 0 specified in track {}, ignoring zero pregap", m_current_track->number);
|
WARNING_LOG("Zero pregap and index 0 specified in track {}, ignoring zero pregap", m_current_track->number);
|
||||||
m_current_track->zero_pregap.reset();
|
m_current_track->zero_pregap.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,10 +126,10 @@ bool D3D11Device::CreateDevice(std::string_view adapter, bool threaded_presentat
|
||||||
ComPtr<IDXGIDevice> dxgi_device;
|
ComPtr<IDXGIDevice> dxgi_device;
|
||||||
if (SUCCEEDED(m_device.As(&dxgi_device)) &&
|
if (SUCCEEDED(m_device.As(&dxgi_device)) &&
|
||||||
SUCCEEDED(dxgi_device->GetParent(IID_PPV_ARGS(dxgi_adapter.GetAddressOf()))))
|
SUCCEEDED(dxgi_device->GetParent(IID_PPV_ARGS(dxgi_adapter.GetAddressOf()))))
|
||||||
Log_InfoFmt("D3D Adapter: %s", D3DCommon::GetAdapterName(dxgi_adapter.Get()));
|
INFO_LOG("D3D Adapter: %s", D3DCommon::GetAdapterName(dxgi_adapter.Get()));
|
||||||
else
|
else
|
||||||
Log_ErrorPrint("Failed to obtain D3D adapter name.");
|
ERROR_LOG("Failed to obtain D3D adapter name.");
|
||||||
Log_InfoFmt("Max device feature level: {}", D3DCommon::GetFeatureLevelString(m_max_feature_level));
|
INFO_LOG("Max device feature level: {}", D3DCommon::GetFeatureLevelString(m_max_feature_level));
|
||||||
|
|
||||||
BOOL allow_tearing_supported = false;
|
BOOL allow_tearing_supported = false;
|
||||||
hr = m_dxgi_factory->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allow_tearing_supported,
|
hr = m_dxgi_factory->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allow_tearing_supported,
|
||||||
|
@ -263,12 +263,12 @@ bool D3D11Device::CreateSwapChain()
|
||||||
fs_desc.Scaling = fullscreen_mode.Scaling;
|
fs_desc.Scaling = fullscreen_mode.Scaling;
|
||||||
fs_desc.Windowed = FALSE;
|
fs_desc.Windowed = FALSE;
|
||||||
|
|
||||||
Log_VerboseFmt("Creating a {}x{} exclusive fullscreen swap chain", fs_sd_desc.Width, fs_sd_desc.Height);
|
VERBOSE_LOG("Creating a {}x{} exclusive fullscreen swap chain", fs_sd_desc.Width, fs_sd_desc.Height);
|
||||||
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_device.Get(), window_hwnd, &fs_sd_desc, &fs_desc,
|
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_device.Get(), window_hwnd, &fs_sd_desc, &fs_desc,
|
||||||
fullscreen_output.Get(), m_swap_chain.ReleaseAndGetAddressOf());
|
fullscreen_output.Get(), m_swap_chain.ReleaseAndGetAddressOf());
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Failed to create fullscreen swap chain, trying windowed.");
|
WARNING_LOG("Failed to create fullscreen swap chain, trying windowed.");
|
||||||
m_is_exclusive_fullscreen = false;
|
m_is_exclusive_fullscreen = false;
|
||||||
m_using_allow_tearing = m_allow_tearing_supported && m_using_flip_model_swap_chain;
|
m_using_allow_tearing = m_allow_tearing_supported && m_using_flip_model_swap_chain;
|
||||||
}
|
}
|
||||||
|
@ -276,15 +276,15 @@ bool D3D11Device::CreateSwapChain()
|
||||||
|
|
||||||
if (!m_is_exclusive_fullscreen)
|
if (!m_is_exclusive_fullscreen)
|
||||||
{
|
{
|
||||||
Log_VerboseFmt("Creating a {}x{} {} windowed swap chain", swap_chain_desc.Width, swap_chain_desc.Height,
|
VERBOSE_LOG("Creating a {}x{} {} windowed swap chain", swap_chain_desc.Width, swap_chain_desc.Height,
|
||||||
m_using_flip_model_swap_chain ? "flip-discard" : "discard");
|
m_using_flip_model_swap_chain ? "flip-discard" : "discard");
|
||||||
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_device.Get(), window_hwnd, &swap_chain_desc, nullptr, nullptr,
|
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_device.Get(), window_hwnd, &swap_chain_desc, nullptr, nullptr,
|
||||||
m_swap_chain.ReleaseAndGetAddressOf());
|
m_swap_chain.ReleaseAndGetAddressOf());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr) && m_using_flip_model_swap_chain)
|
if (FAILED(hr) && m_using_flip_model_swap_chain)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Failed to create a flip-discard swap chain, trying discard.");
|
WARNING_LOG("Failed to create a flip-discard swap chain, trying discard.");
|
||||||
swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||||
swap_chain_desc.Flags = 0;
|
swap_chain_desc.Flags = 0;
|
||||||
m_using_flip_model_swap_chain = false;
|
m_using_flip_model_swap_chain = false;
|
||||||
|
@ -294,7 +294,7 @@ bool D3D11Device::CreateSwapChain()
|
||||||
m_swap_chain.ReleaseAndGetAddressOf());
|
m_swap_chain.ReleaseAndGetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateSwapChainForHwnd failed: 0x{:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateSwapChainForHwnd failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ bool D3D11Device::CreateSwapChain()
|
||||||
if (FAILED(m_swap_chain->GetParent(IID_PPV_ARGS(parent_factory.GetAddressOf()))) ||
|
if (FAILED(m_swap_chain->GetParent(IID_PPV_ARGS(parent_factory.GetAddressOf()))) ||
|
||||||
FAILED(parent_factory->MakeWindowAssociation(window_hwnd, DXGI_MWA_NO_WINDOW_CHANGES)))
|
FAILED(parent_factory->MakeWindowAssociation(window_hwnd, DXGI_MWA_NO_WINDOW_CHANGES)))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("MakeWindowAssociation() to disable ALT+ENTER failed");
|
WARNING_LOG("MakeWindowAssociation() to disable ALT+ENTER failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CreateSwapChainRTV())
|
if (!CreateSwapChainRTV())
|
||||||
|
@ -325,7 +325,7 @@ bool D3D11Device::CreateSwapChainRTV()
|
||||||
HRESULT hr = m_swap_chain->GetBuffer(0, IID_PPV_ARGS(backbuffer.GetAddressOf()));
|
HRESULT hr = m_swap_chain->GetBuffer(0, IID_PPV_ARGS(backbuffer.GetAddressOf()));
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("GetBuffer for RTV failed: 0x{:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("GetBuffer for RTV failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ bool D3D11Device::CreateSwapChainRTV()
|
||||||
hr = m_device->CreateRenderTargetView(backbuffer.Get(), &rtv_desc, m_swap_chain_rtv.ReleaseAndGetAddressOf());
|
hr = m_device->CreateRenderTargetView(backbuffer.Get(), &rtv_desc, m_swap_chain_rtv.ReleaseAndGetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateRenderTargetView for swap chain failed: 0x{:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateRenderTargetView for swap chain failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
m_swap_chain_rtv.Reset();
|
m_swap_chain_rtv.Reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ bool D3D11Device::CreateSwapChainRTV()
|
||||||
m_window_info.surface_width = backbuffer_desc.Width;
|
m_window_info.surface_width = backbuffer_desc.Width;
|
||||||
m_window_info.surface_height = backbuffer_desc.Height;
|
m_window_info.surface_height = backbuffer_desc.Height;
|
||||||
m_window_info.surface_format = s_swap_chain_format;
|
m_window_info.surface_format = s_swap_chain_format;
|
||||||
Log_VerboseFmt("Swap chain buffer size: {}x{}", m_window_info.surface_width, m_window_info.surface_height);
|
VERBOSE_LOG("Swap chain buffer size: {}x{}", m_window_info.surface_width, m_window_info.surface_height);
|
||||||
|
|
||||||
if (m_window_info.type == WindowInfo::Type::Win32)
|
if (m_window_info.type == WindowInfo::Type::Win32)
|
||||||
{
|
{
|
||||||
|
@ -391,7 +391,7 @@ bool D3D11Device::UpdateWindow()
|
||||||
|
|
||||||
if (m_window_info.type != WindowInfo::Type::Surfaceless && !CreateSwapChain())
|
if (m_window_info.type != WindowInfo::Type::Surfaceless && !CreateSwapChain())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create swap chain on updated window");
|
ERROR_LOG("Failed to create swap chain on updated window");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ void D3D11Device::ResizeWindow(s32 new_window_width, s32 new_window_height, floa
|
||||||
HRESULT hr = m_swap_chain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN,
|
HRESULT hr = m_swap_chain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN,
|
||||||
m_using_allow_tearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0);
|
m_using_allow_tearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0);
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
Log_ErrorFmt("ResizeBuffers() failed: 0x{:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("ResizeBuffers() failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
|
|
||||||
if (!CreateSwapChainRTV())
|
if (!CreateSwapChainRTV())
|
||||||
Panic("Failed to recreate swap chain RTV after resize");
|
Panic("Failed to recreate swap chain RTV after resize");
|
||||||
|
@ -470,7 +470,7 @@ bool D3D11Device::CreateBuffers()
|
||||||
!m_index_buffer.Create(D3D11_BIND_INDEX_BUFFER, INDEX_BUFFER_SIZE, INDEX_BUFFER_SIZE) ||
|
!m_index_buffer.Create(D3D11_BIND_INDEX_BUFFER, INDEX_BUFFER_SIZE, INDEX_BUFFER_SIZE) ||
|
||||||
!m_uniform_buffer.Create(D3D11_BIND_CONSTANT_BUFFER, MIN_UNIFORM_BUFFER_SIZE, MAX_UNIFORM_BUFFER_SIZE))
|
!m_uniform_buffer.Create(D3D11_BIND_CONSTANT_BUFFER, MIN_UNIFORM_BUFFER_SIZE, MAX_UNIFORM_BUFFER_SIZE))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create vertex/index/uniform buffers.");
|
ERROR_LOG("Failed to create vertex/index/uniform buffers.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,7 +600,7 @@ std::optional<float> D3D11Device::GetHostRefreshRate()
|
||||||
if (SUCCEEDED(m_swap_chain->GetDesc(&desc)) && desc.BufferDesc.RefreshRate.Numerator > 0 &&
|
if (SUCCEEDED(m_swap_chain->GetDesc(&desc)) && desc.BufferDesc.RefreshRate.Numerator > 0 &&
|
||||||
desc.BufferDesc.RefreshRate.Denominator > 0)
|
desc.BufferDesc.RefreshRate.Denominator > 0)
|
||||||
{
|
{
|
||||||
Log_DevFmt("using fs rr: {} {}", desc.BufferDesc.RefreshRate.Numerator, desc.BufferDesc.RefreshRate.Denominator);
|
DEV_LOG("using fs rr: {} {}", desc.BufferDesc.RefreshRate.Numerator, desc.BufferDesc.RefreshRate.Denominator);
|
||||||
return static_cast<float>(desc.BufferDesc.RefreshRate.Numerator) /
|
return static_cast<float>(desc.BufferDesc.RefreshRate.Numerator) /
|
||||||
static_cast<float>(desc.BufferDesc.RefreshRate.Denominator);
|
static_cast<float>(desc.BufferDesc.RefreshRate.Denominator);
|
||||||
}
|
}
|
||||||
|
@ -776,7 +776,7 @@ void D3D11Device::PopTimestampQuery()
|
||||||
|
|
||||||
if (disjoint.Disjoint)
|
if (disjoint.Disjoint)
|
||||||
{
|
{
|
||||||
Log_VerbosePrint("GPU timing disjoint, resetting.");
|
VERBOSE_LOG("GPU timing disjoint, resetting.");
|
||||||
m_read_timestamp_query = 0;
|
m_read_timestamp_query = 0;
|
||||||
m_write_timestamp_query = 0;
|
m_write_timestamp_query = 0;
|
||||||
m_waiting_timestamp_queries = 0;
|
m_waiting_timestamp_queries = 0;
|
||||||
|
@ -1078,7 +1078,7 @@ void D3D11Device::UnbindTexture(D3D11Texture* tex)
|
||||||
{
|
{
|
||||||
if (m_current_render_targets[i] == tex)
|
if (m_current_render_targets[i] == tex)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Unbinding current RT");
|
WARNING_LOG("Unbinding current RT");
|
||||||
SetRenderTargets(nullptr, 0, m_current_depth_target);
|
SetRenderTargets(nullptr, 0, m_current_depth_target);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1086,7 +1086,7 @@ void D3D11Device::UnbindTexture(D3D11Texture* tex)
|
||||||
}
|
}
|
||||||
else if (m_current_depth_target == tex)
|
else if (m_current_depth_target == tex)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Unbinding current DS");
|
WARNING_LOG("Unbinding current DS");
|
||||||
SetRenderTargets(nullptr, 0, nullptr);
|
SetRenderTargets(nullptr, 0, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ D3D11Device::ComPtr<ID3D11RasterizerState> D3D11Device::GetRasterizationState(co
|
||||||
|
|
||||||
HRESULT hr = m_device->CreateRasterizerState(&desc, drs.GetAddressOf());
|
HRESULT hr = m_device->CreateRasterizerState(&desc, drs.GetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
Log_ErrorFmt("Failed to create depth state with {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Failed to create depth state with {:08X}", static_cast<unsigned>(hr));
|
||||||
|
|
||||||
m_rasterization_states.emplace(rs.key, drs);
|
m_rasterization_states.emplace(rs.key, drs);
|
||||||
return drs;
|
return drs;
|
||||||
|
@ -188,7 +188,7 @@ D3D11Device::ComPtr<ID3D11DepthStencilState> D3D11Device::GetDepthState(const GP
|
||||||
|
|
||||||
HRESULT hr = m_device->CreateDepthStencilState(&desc, dds.GetAddressOf());
|
HRESULT hr = m_device->CreateDepthStencilState(&desc, dds.GetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
Log_ErrorFmt("Failed to create depth state with {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Failed to create depth state with {:08X}", static_cast<unsigned>(hr));
|
||||||
|
|
||||||
m_depth_states.emplace(ds.key, dds);
|
m_depth_states.emplace(ds.key, dds);
|
||||||
return dds;
|
return dds;
|
||||||
|
@ -246,7 +246,7 @@ D3D11Device::ComPtr<ID3D11BlendState> D3D11Device::GetBlendState(const GPUPipeli
|
||||||
|
|
||||||
HRESULT hr = m_device->CreateBlendState(&blend_desc, dbs.GetAddressOf());
|
HRESULT hr = m_device->CreateBlendState(&blend_desc, dbs.GetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
Log_ErrorFmt("Failed to create blend state with {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Failed to create blend state with {:08X}", static_cast<unsigned>(hr));
|
||||||
|
|
||||||
m_blend_states.emplace(bs.key, dbs);
|
m_blend_states.emplace(bs.key, dbs);
|
||||||
return dbs;
|
return dbs;
|
||||||
|
@ -298,7 +298,7 @@ D3D11Device::ComPtr<ID3D11InputLayout> D3D11Device::GetInputLayout(const GPUPipe
|
||||||
HRESULT hr = m_device->CreateInputLayout(elems, static_cast<UINT>(il.vertex_attributes.size()),
|
HRESULT hr = m_device->CreateInputLayout(elems, static_cast<UINT>(il.vertex_attributes.size()),
|
||||||
vs->GetBytecode().data(), vs->GetBytecode().size(), dil.GetAddressOf());
|
vs->GetBytecode().data(), vs->GetBytecode().size(), dil.GetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
Log_ErrorFmt("Failed to create input layout with {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Failed to create input layout with {:08X}", static_cast<unsigned>(hr));
|
||||||
|
|
||||||
m_input_layouts.emplace(il, dil);
|
m_input_layouts.emplace(il, dil);
|
||||||
return dil;
|
return dil;
|
||||||
|
|
|
@ -40,7 +40,7 @@ bool D3D11StreamBuffer::Create(D3D11_BIND_FLAG bind_flags, u32 min_size, u32 max
|
||||||
m_use_map_no_overwrite = options.MapNoOverwriteOnDynamicConstantBuffer;
|
m_use_map_no_overwrite = options.MapNoOverwriteOnDynamicConstantBuffer;
|
||||||
if (m_use_map_no_overwrite && D3D11Device::GetMaxFeatureLevel() < D3D_FEATURE_LEVEL_12_0)
|
if (m_use_map_no_overwrite && D3D11Device::GetMaxFeatureLevel() < D3D_FEATURE_LEVEL_12_0)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Ignoring MapNoOverwriteOnDynamicConstantBuffer on driver due to feature level.");
|
WARNING_LOG("Ignoring MapNoOverwriteOnDynamicConstantBuffer on driver due to feature level.");
|
||||||
m_use_map_no_overwrite = false;
|
m_use_map_no_overwrite = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@ bool D3D11StreamBuffer::Create(D3D11_BIND_FLAG bind_flags, u32 min_size, u32 max
|
||||||
|
|
||||||
if (!m_use_map_no_overwrite)
|
if (!m_use_map_no_overwrite)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Unable to use MAP_NO_OVERWRITE on buffer with bind flag {}, this may affect performance. "
|
WARNING_LOG("Unable to use MAP_NO_OVERWRITE on buffer with bind flag {}, this may affect performance. "
|
||||||
"Update your driver/operating system.",
|
"Update your driver/operating system.",
|
||||||
static_cast<unsigned>(bind_flags));
|
static_cast<unsigned>(bind_flags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("ID3D11Device::CheckFeatureSupport() failed: {}", Error::CreateHResult(hr).GetDescription());
|
WARNING_LOG("ID3D11Device::CheckFeatureSupport() failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||||
m_use_map_no_overwrite = false;
|
m_use_map_no_overwrite = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ bool D3D11StreamBuffer::Create(D3D11_BIND_FLAG bind_flags, u32 min_size, u32 max
|
||||||
hr = D3D11Device::GetD3DDevice()->CreateBuffer(&desc, nullptr, &buffer);
|
hr = D3D11Device::GetD3DDevice()->CreateBuffer(&desc, nullptr, &buffer);
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Creating buffer failed: {}", Error::CreateHResult(hr).GetDescription());
|
ERROR_LOG("Creating buffer failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ D3D11StreamBuffer::MappingResult D3D11StreamBuffer::Map(ID3D11DeviceContext1* co
|
||||||
Assert(min_size < m_max_size);
|
Assert(min_size < m_max_size);
|
||||||
|
|
||||||
const u32 new_size = std::min(m_max_size, Common::AlignUp(std::max(m_size * 2, min_size), alignment));
|
const u32 new_size = std::min(m_max_size, Common::AlignUp(std::max(m_size * 2, min_size), alignment));
|
||||||
Log_WarningFmt("Growing buffer from {} bytes to {} bytes", m_size, new_size);
|
WARNING_LOG("Growing buffer from {} bytes to {} bytes", m_size, new_size);
|
||||||
|
|
||||||
D3D11_BUFFER_DESC new_desc;
|
D3D11_BUFFER_DESC new_desc;
|
||||||
m_buffer->GetDesc(&new_desc);
|
m_buffer->GetDesc(&new_desc);
|
||||||
|
@ -115,7 +115,7 @@ D3D11StreamBuffer::MappingResult D3D11StreamBuffer::Map(ID3D11DeviceContext1* co
|
||||||
hr = D3D11Device::GetD3DDevice()->CreateBuffer(&new_desc, nullptr, m_buffer.ReleaseAndGetAddressOf());
|
hr = D3D11Device::GetD3DDevice()->CreateBuffer(&new_desc, nullptr, m_buffer.ReleaseAndGetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Creating buffer failed: {}", Error::CreateHResult(hr).GetDescription());
|
ERROR_LOG("Creating buffer failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||||
Panic("Failed to grow buffer");
|
Panic("Failed to grow buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ D3D11StreamBuffer::MappingResult D3D11StreamBuffer::Map(ID3D11DeviceContext1* co
|
||||||
hr = context->Map(m_buffer.Get(), 0, map_type, 0, &sr);
|
hr = context->Map(m_buffer.Get(), 0, map_type, 0, &sr);
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Map failed: 0x{:08X} (alignment {}, minsize {}, size {}, position [], map type {})",
|
ERROR_LOG("Map failed: 0x{:08X} (alignment {}, minsize {}, size {}, position [], map type {})",
|
||||||
static_cast<unsigned>(hr), alignment, min_size, m_size, m_position, static_cast<u32>(map_type));
|
static_cast<unsigned>(hr), alignment, min_size, m_size, m_position, static_cast<u32>(map_type));
|
||||||
Panic("Map failed");
|
Panic("Map failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ std::unique_ptr<GPUSampler> D3D11Device::CreateSampler(const GPUSampler::Config&
|
||||||
const HRESULT hr = m_device->CreateSamplerState(&desc, ss.GetAddressOf());
|
const HRESULT hr = m_device->CreateSamplerState(&desc, ss.GetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateSamplerState() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateSamplerState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ bool D3D11Texture::Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32
|
||||||
HRESULT hr = context->Map(m_texture.Get(), srnum, discard ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_READ_WRITE, 0, &sr);
|
HRESULT hr = context->Map(m_texture.Get(), srnum, discard ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_READ_WRITE, 0, &sr);
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Map pixels texture failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Map pixels texture failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,10 +267,9 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||||
const HRESULT tex_hr = device->CreateTexture2D(&desc, initial_data ? &srd : nullptr, texture.GetAddressOf());
|
const HRESULT tex_hr = device->CreateTexture2D(&desc, initial_data ? &srd : nullptr, texture.GetAddressOf());
|
||||||
if (FAILED(tex_hr))
|
if (FAILED(tex_hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt(
|
ERROR_LOG("Create texture failed: 0x{:08X} ({}x{} levels:{} samples:{} format:{} bind_flags:{:X} initial_data:{})",
|
||||||
"Create texture failed: 0x{:08X} ({}x{} levels:{} samples:{} format:{} bind_flags:{:X} initial_data:{})",
|
static_cast<unsigned>(tex_hr), width, height, levels, samples, static_cast<unsigned>(format), bind_flags,
|
||||||
static_cast<unsigned>(tex_hr), width, height, levels, samples, static_cast<unsigned>(format), bind_flags,
|
initial_data);
|
||||||
initial_data);
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +290,7 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||||
const HRESULT hr = device->CreateShaderResourceView(texture.Get(), &srv_desc, srv.GetAddressOf());
|
const HRESULT hr = device->CreateShaderResourceView(texture.Get(), &srv_desc, srv.GetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Create SRV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Create SRV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,7 +305,7 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||||
const HRESULT hr = device->CreateRenderTargetView(texture.Get(), &rtv_desc, rtv.GetAddressOf());
|
const HRESULT hr = device->CreateRenderTargetView(texture.Get(), &rtv_desc, rtv.GetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Create RTV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Create RTV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +320,7 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||||
const HRESULT hr = device->CreateDepthStencilView(texture.Get(), &dsv_desc, dsv.GetAddressOf());
|
const HRESULT hr = device->CreateDepthStencilView(texture.Get(), &dsv_desc, dsv.GetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Create DSV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Create DSV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +353,7 @@ bool D3D11TextureBuffer::CreateBuffer()
|
||||||
D3D11Device::GetD3DDevice()->CreateShaderResourceView(m_buffer.GetD3DBuffer(), &srv_desc, m_srv.GetAddressOf());
|
D3D11Device::GetD3DDevice()->CreateShaderResourceView(m_buffer.GetD3DBuffer(), &srv_desc, m_srv.GetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateShaderResourceView() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateShaderResourceView() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +420,7 @@ std::unique_ptr<D3D11DownloadTexture> D3D11DownloadTexture::Create(u32 width, u3
|
||||||
HRESULT hr = D3D11Device::GetD3DDevice()->CreateTexture2D(&desc, nullptr, tex.GetAddressOf());
|
HRESULT hr = D3D11Device::GetD3DDevice()->CreateTexture2D(&desc, nullptr, tex.GetAddressOf());
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateTexture2D() failed: {:08X}", hr);
|
ERROR_LOG("CreateTexture2D() failed: {:08X}", hr);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +470,7 @@ bool D3D11DownloadTexture::Map(u32 x, u32 y, u32 width, u32 height)
|
||||||
HRESULT hr = D3D11Device::GetD3DContext()->Map(m_texture.Get(), 0, D3D11_MAP_READ, 0, &sr);
|
HRESULT hr = D3D11Device::GetD3DContext()->Map(m_texture.Get(), 0, D3D11_MAP_READ, 0, &sr);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Map() failed: {:08X}", hr);
|
ERROR_LOG("Map() failed: {:08X}", hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,6 +516,6 @@ std::unique_ptr<GPUDownloadTexture> D3D11Device::CreateDownloadTexture(u32 width
|
||||||
void* memory, size_t memory_size,
|
void* memory, size_t memory_size,
|
||||||
u32 memory_stride)
|
u32 memory_stride)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("D3D11 cannot import memory for download textures");
|
ERROR_LOG("D3D11 cannot import memory for download textures");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ Microsoft::WRL::ComPtr<ID3D12PipelineState> D3D12::GraphicsPipelineBuilder::Crea
|
||||||
HRESULT hr = device->CreateGraphicsPipelineState(&m_desc, IID_PPV_ARGS(ps.GetAddressOf()));
|
HRESULT hr = device->CreateGraphicsPipelineState(&m_desc, IID_PPV_ARGS(ps.GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateGraphicsPipelineState() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateGraphicsPipelineState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ Microsoft::WRL::ComPtr<ID3D12PipelineState> D3D12::ComputePipelineBuilder::Creat
|
||||||
HRESULT hr = device->CreateComputePipelineState(&m_desc, IID_PPV_ARGS(ps.GetAddressOf()));
|
HRESULT hr = device->CreateComputePipelineState(&m_desc, IID_PPV_ARGS(ps.GetAddressOf()));
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateComputePipelineState() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateComputePipelineState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,14 @@ D3D12DescriptorHeapManager::~D3D12DescriptorHeapManager() = default;
|
||||||
bool D3D12DescriptorHeapManager::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYPE type, u32 num_descriptors,
|
bool D3D12DescriptorHeapManager::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYPE type, u32 num_descriptors,
|
||||||
bool shader_visible)
|
bool shader_visible)
|
||||||
{
|
{
|
||||||
D3D12_DESCRIPTOR_HEAP_DESC desc = {type, static_cast<UINT>(num_descriptors),
|
D3D12_DESCRIPTOR_HEAP_DESC desc = {
|
||||||
shader_visible ? D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE :
|
type, static_cast<UINT>(num_descriptors),
|
||||||
D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0u};
|
shader_visible ? D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE : D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0u};
|
||||||
|
|
||||||
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(m_descriptor_heap.ReleaseAndGetAddressOf()));
|
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(m_descriptor_heap.ReleaseAndGetAddressOf()));
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateDescriptorHeap() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateDescriptorHeap() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ bool D3D12DescriptorAllocator::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEA
|
||||||
const HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(m_descriptor_heap.ReleaseAndGetAddressOf()));
|
const HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(m_descriptor_heap.ReleaseAndGetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateDescriptorHeap() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateDescriptorHeap() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,9 @@ D3D12Device::ComPtr<ID3DBlob> D3D12Device::SerializeRootSignature(const D3D12_RO
|
||||||
D3D12SerializeRootSignature(desc, D3D_ROOT_SIGNATURE_VERSION_1, blob.GetAddressOf(), error_blob.GetAddressOf());
|
D3D12SerializeRootSignature(desc, D3D_ROOT_SIGNATURE_VERSION_1, blob.GetAddressOf(), error_blob.GetAddressOf());
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("D3D12SerializeRootSignature() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("D3D12SerializeRootSignature() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
if (error_blob)
|
if (error_blob)
|
||||||
Log_ErrorPrint(static_cast<const char*>(error_blob->GetBufferPointer()));
|
ERROR_LOG(static_cast<const char*>(error_blob->GetBufferPointer()));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ D3D12Device::ComPtr<ID3D12RootSignature> D3D12Device::CreateRootSignature(const
|
||||||
m_device->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(), IID_PPV_ARGS(rs.GetAddressOf()));
|
m_device->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(), IID_PPV_ARGS(rs.GetAddressOf()));
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateRootSignature() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateRootSignature() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ bool D3D12Device::CreateDevice(std::string_view adapter, bool threaded_presentat
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Debug layer requested but not available.");
|
ERROR_LOG("Debug layer requested but not available.");
|
||||||
m_debug_device = false;
|
m_debug_device = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ bool D3D12Device::CreateDevice(std::string_view adapter, bool threaded_presentat
|
||||||
{
|
{
|
||||||
const LUID luid(m_device->GetAdapterLuid());
|
const LUID luid(m_device->GetAdapterLuid());
|
||||||
if (FAILED(m_dxgi_factory->EnumAdapterByLuid(luid, IID_PPV_ARGS(m_adapter.GetAddressOf()))))
|
if (FAILED(m_dxgi_factory->EnumAdapterByLuid(luid, IID_PPV_ARGS(m_adapter.GetAddressOf()))))
|
||||||
Log_ErrorPrint("Failed to get lookup adapter by device LUID");
|
ERROR_LOG("Failed to get lookup adapter by device LUID");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_debug_device)
|
if (m_debug_device)
|
||||||
|
@ -303,22 +303,22 @@ bool D3D12Device::ReadPipelineCache(const std::string& filename)
|
||||||
// Try without the cache data.
|
// Try without the cache data.
|
||||||
if (data.has_value())
|
if (data.has_value())
|
||||||
{
|
{
|
||||||
Log_WarningFmt("CreatePipelineLibrary() failed, trying without cache data. Error: {}",
|
WARNING_LOG("CreatePipelineLibrary() failed, trying without cache data. Error: {}",
|
||||||
Error::CreateHResult(hr).GetDescription());
|
Error::CreateHResult(hr).GetDescription());
|
||||||
|
|
||||||
hr = m_device->CreatePipelineLibrary(nullptr, 0, IID_PPV_ARGS(m_pipeline_library.ReleaseAndGetAddressOf()));
|
hr = m_device->CreatePipelineLibrary(nullptr, 0, IID_PPV_ARGS(m_pipeline_library.ReleaseAndGetAddressOf()));
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
// Delete cache file, it's no longer relevant.
|
// Delete cache file, it's no longer relevant.
|
||||||
Log_InfoFmt("Deleting pipeline cache file {}", filename);
|
INFO_LOG("Deleting pipeline cache file {}", filename);
|
||||||
FileSystem::DeleteFile(filename.c_str());
|
FileSystem::DeleteFile(filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_WarningFmt("CreatePipelineLibrary() failed, pipeline caching will not be available. Error: {}",
|
WARNING_LOG("CreatePipelineLibrary() failed, pipeline caching will not be available. Error: {}",
|
||||||
Error::CreateHResult(hr).GetDescription());
|
Error::CreateHResult(hr).GetDescription());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ bool D3D12Device::GetPipelineCacheData(DynamicHeapArray<u8>* data)
|
||||||
const size_t size = m_pipeline_library->GetSerializedSize();
|
const size_t size = m_pipeline_library->GetSerializedSize();
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Empty serialized pipeline state returned.");
|
WARNING_LOG("Empty serialized pipeline state returned.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ bool D3D12Device::GetPipelineCacheData(DynamicHeapArray<u8>* data)
|
||||||
const HRESULT hr = m_pipeline_library->Serialize(data->data(), data->size());
|
const HRESULT hr = m_pipeline_library->Serialize(data->data(), data->size());
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Serialize() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Serialize() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||||
data->deallocate();
|
data->deallocate();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ bool D3D12Device::CreateCommandLists()
|
||||||
IID_PPV_ARGS(res.command_allocators[j].GetAddressOf()));
|
IID_PPV_ARGS(res.command_allocators[j].GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateCommandAllocator() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateCommandAllocator() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ bool D3D12Device::CreateCommandLists()
|
||||||
IID_PPV_ARGS(res.command_lists[j].GetAddressOf()));
|
IID_PPV_ARGS(res.command_lists[j].GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateCommandList() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateCommandList() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ bool D3D12Device::CreateCommandLists()
|
||||||
hr = res.command_lists[j]->Close();
|
hr = res.command_lists[j]->Close();
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Close() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Close() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,13 +386,13 @@ bool D3D12Device::CreateCommandLists()
|
||||||
if (!res.descriptor_allocator.Create(m_device.Get(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
if (!res.descriptor_allocator.Create(m_device.Get(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
||||||
MAX_DESCRIPTORS_PER_FRAME))
|
MAX_DESCRIPTORS_PER_FRAME))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create per frame descriptor allocator");
|
ERROR_LOG("Failed to create per frame descriptor allocator");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res.sampler_allocator.Create(m_device.Get(), MAX_SAMPLERS_PER_FRAME))
|
if (!res.sampler_allocator.Create(m_device.Get(), MAX_SAMPLERS_PER_FRAME))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create per frame sampler allocator");
|
ERROR_LOG("Failed to create per frame sampler allocator");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ void D3D12Device::MoveToNextCommandList()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Map() for timestamp query failed: {:08X}", static_cast<unsigned>(hr));
|
WARNING_LOG("Map() for timestamp query failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ bool D3D12Device::CreateDescriptorHeaps()
|
||||||
|
|
||||||
if (!m_descriptor_heap_manager.Allocate(&m_null_srv_descriptor))
|
if (!m_descriptor_heap_manager.Allocate(&m_null_srv_descriptor))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate null descriptor");
|
ERROR_LOG("Failed to allocate null descriptor");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ void D3D12Device::SubmitCommandList(bool wait_for_completion)
|
||||||
hr = res.command_lists[0]->Close();
|
hr = res.command_lists[0]->Close();
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Closing init command list failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Closing init command list failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||||
Panic("TODO cannot continue");
|
Panic("TODO cannot continue");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -560,7 +560,7 @@ void D3D12Device::SubmitCommandList(bool wait_for_completion)
|
||||||
hr = res.command_lists[1]->Close();
|
hr = res.command_lists[1]->Close();
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Closing main command list failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Closing main command list failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||||
Panic("TODO cannot continue");
|
Panic("TODO cannot continue");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,7 +592,7 @@ void D3D12Device::SubmitCommandList(bool wait_for_completion, const char* reason
|
||||||
const std::string reason_str(StringUtil::StdStringFromFormatV(reason, ap));
|
const std::string reason_str(StringUtil::StdStringFromFormatV(reason, ap));
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
Log_WarningFmt("Executing command buffer due to '{}'", reason_str);
|
WARNING_LOG("Executing command buffer due to '{}'", reason_str);
|
||||||
SubmitCommandList(wait_for_completion);
|
SubmitCommandList(wait_for_completion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ bool D3D12Device::CreateTimestampQuery()
|
||||||
HRESULT hr = m_device->CreateQueryHeap(&desc, IID_PPV_ARGS(m_timestamp_query_heap.GetAddressOf()));
|
HRESULT hr = m_device->CreateQueryHeap(&desc, IID_PPV_ARGS(m_timestamp_query_heap.GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateQueryHeap() for timestamp failed with {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateQueryHeap() for timestamp failed with {:08X}", static_cast<unsigned>(hr));
|
||||||
m_features.gpu_timing = false;
|
m_features.gpu_timing = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -669,7 +669,7 @@ bool D3D12Device::CreateTimestampQuery()
|
||||||
IID_PPV_ARGS(m_timestamp_query_buffer.GetAddressOf()));
|
IID_PPV_ARGS(m_timestamp_query_buffer.GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateResource() for timestamp failed with {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateResource() for timestamp failed with {:08X}", static_cast<unsigned>(hr));
|
||||||
m_features.gpu_timing = false;
|
m_features.gpu_timing = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -678,7 +678,7 @@ bool D3D12Device::CreateTimestampQuery()
|
||||||
hr = m_command_queue->GetTimestampFrequency(&frequency);
|
hr = m_command_queue->GetTimestampFrequency(&frequency);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("GetTimestampFrequency() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("GetTimestampFrequency() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
m_features.gpu_timing = false;
|
m_features.gpu_timing = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -860,12 +860,12 @@ bool D3D12Device::CreateSwapChain()
|
||||||
fs_desc.Scaling = fullscreen_mode.Scaling;
|
fs_desc.Scaling = fullscreen_mode.Scaling;
|
||||||
fs_desc.Windowed = FALSE;
|
fs_desc.Windowed = FALSE;
|
||||||
|
|
||||||
Log_VerboseFmt("Creating a {}x{} exclusive fullscreen swap chain", fs_sd_desc.Width, fs_sd_desc.Height);
|
VERBOSE_LOG("Creating a {}x{} exclusive fullscreen swap chain", fs_sd_desc.Width, fs_sd_desc.Height);
|
||||||
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_command_queue.Get(), window_hwnd, &fs_sd_desc, &fs_desc,
|
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_command_queue.Get(), window_hwnd, &fs_sd_desc, &fs_desc,
|
||||||
fullscreen_output.Get(), m_swap_chain.ReleaseAndGetAddressOf());
|
fullscreen_output.Get(), m_swap_chain.ReleaseAndGetAddressOf());
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Failed to create fullscreen swap chain, trying windowed.");
|
WARNING_LOG("Failed to create fullscreen swap chain, trying windowed.");
|
||||||
m_is_exclusive_fullscreen = false;
|
m_is_exclusive_fullscreen = false;
|
||||||
m_using_allow_tearing = m_allow_tearing_supported;
|
m_using_allow_tearing = m_allow_tearing_supported;
|
||||||
}
|
}
|
||||||
|
@ -873,14 +873,14 @@ bool D3D12Device::CreateSwapChain()
|
||||||
|
|
||||||
if (!m_is_exclusive_fullscreen)
|
if (!m_is_exclusive_fullscreen)
|
||||||
{
|
{
|
||||||
Log_VerboseFmt("Creating a {}x{} windowed swap chain", swap_chain_desc.Width, swap_chain_desc.Height);
|
VERBOSE_LOG("Creating a {}x{} windowed swap chain", swap_chain_desc.Width, swap_chain_desc.Height);
|
||||||
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_command_queue.Get(), window_hwnd, &swap_chain_desc, nullptr, nullptr,
|
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_command_queue.Get(), window_hwnd, &swap_chain_desc, nullptr, nullptr,
|
||||||
m_swap_chain.ReleaseAndGetAddressOf());
|
m_swap_chain.ReleaseAndGetAddressOf());
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = m_dxgi_factory->MakeWindowAssociation(window_hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
|
hr = m_dxgi_factory->MakeWindowAssociation(window_hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
Log_WarningPrint("MakeWindowAssociation() to disable ALT+ENTER failed");
|
WARNING_LOG("MakeWindowAssociation() to disable ALT+ENTER failed");
|
||||||
|
|
||||||
if (!CreateSwapChainRTV())
|
if (!CreateSwapChainRTV())
|
||||||
{
|
{
|
||||||
|
@ -908,7 +908,7 @@ bool D3D12Device::CreateSwapChainRTV()
|
||||||
hr = m_swap_chain->GetBuffer(i, IID_PPV_ARGS(backbuffer.GetAddressOf()));
|
hr = m_swap_chain->GetBuffer(i, IID_PPV_ARGS(backbuffer.GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("GetBuffer for RTV failed: 0x{:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("GetBuffer for RTV failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
DestroySwapChainRTVs();
|
DestroySwapChainRTVs();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -918,7 +918,7 @@ bool D3D12Device::CreateSwapChainRTV()
|
||||||
D3D12DescriptorHandle rtv;
|
D3D12DescriptorHandle rtv;
|
||||||
if (!m_rtv_heap_manager.Allocate(&rtv))
|
if (!m_rtv_heap_manager.Allocate(&rtv))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate RTV handle");
|
ERROR_LOG("Failed to allocate RTV handle");
|
||||||
DestroySwapChainRTVs();
|
DestroySwapChainRTVs();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -930,7 +930,7 @@ bool D3D12Device::CreateSwapChainRTV()
|
||||||
m_window_info.surface_width = swap_chain_desc.BufferDesc.Width;
|
m_window_info.surface_width = swap_chain_desc.BufferDesc.Width;
|
||||||
m_window_info.surface_height = swap_chain_desc.BufferDesc.Height;
|
m_window_info.surface_height = swap_chain_desc.BufferDesc.Height;
|
||||||
m_window_info.surface_format = s_swap_chain_format;
|
m_window_info.surface_format = s_swap_chain_format;
|
||||||
Log_VerboseFmt("Swap chain buffer size: {}x{}", m_window_info.surface_width, m_window_info.surface_height);
|
VERBOSE_LOG("Swap chain buffer size: {}x{}", m_window_info.surface_width, m_window_info.surface_height);
|
||||||
|
|
||||||
if (m_window_info.type == WindowInfo::Type::Win32)
|
if (m_window_info.type == WindowInfo::Type::Win32)
|
||||||
{
|
{
|
||||||
|
@ -1014,7 +1014,7 @@ bool D3D12Device::UpdateWindow()
|
||||||
|
|
||||||
if (!CreateSwapChain())
|
if (!CreateSwapChain())
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create swap chain on updated window");
|
ERROR_LOG("Failed to create swap chain on updated window");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,7 +1040,7 @@ void D3D12Device::ResizeWindow(s32 new_window_width, s32 new_window_height, floa
|
||||||
HRESULT hr = m_swap_chain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN,
|
HRESULT hr = m_swap_chain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN,
|
||||||
m_using_allow_tearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0);
|
m_using_allow_tearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
Log_ErrorFmt("ResizeBuffers() failed: 0x{:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("ResizeBuffers() failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
|
|
||||||
if (!CreateSwapChainRTV())
|
if (!CreateSwapChainRTV())
|
||||||
Panic("Failed to recreate swap chain RTV after resize");
|
Panic("Failed to recreate swap chain RTV after resize");
|
||||||
|
@ -1096,7 +1096,7 @@ std::optional<float> D3D12Device::GetHostRefreshRate()
|
||||||
if (SUCCEEDED(m_swap_chain->GetDesc(&desc)) && desc.BufferDesc.RefreshRate.Numerator > 0 &&
|
if (SUCCEEDED(m_swap_chain->GetDesc(&desc)) && desc.BufferDesc.RefreshRate.Numerator > 0 &&
|
||||||
desc.BufferDesc.RefreshRate.Denominator > 0)
|
desc.BufferDesc.RefreshRate.Denominator > 0)
|
||||||
{
|
{
|
||||||
Log_DevFmt("using fs rr: {} {}", desc.BufferDesc.RefreshRate.Numerator, desc.BufferDesc.RefreshRate.Denominator);
|
DEV_LOG("using fs rr: {} {}", desc.BufferDesc.RefreshRate.Numerator, desc.BufferDesc.RefreshRate.Denominator);
|
||||||
return static_cast<float>(desc.BufferDesc.RefreshRate.Numerator) /
|
return static_cast<float>(desc.BufferDesc.RefreshRate.Numerator) /
|
||||||
static_cast<float>(desc.BufferDesc.RefreshRate.Denominator);
|
static_cast<float>(desc.BufferDesc.RefreshRate.Denominator);
|
||||||
}
|
}
|
||||||
|
@ -1426,25 +1426,25 @@ bool D3D12Device::CreateBuffers()
|
||||||
{
|
{
|
||||||
if (!m_vertex_buffer.Create(VERTEX_BUFFER_SIZE))
|
if (!m_vertex_buffer.Create(VERTEX_BUFFER_SIZE))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate vertex buffer");
|
ERROR_LOG("Failed to allocate vertex buffer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_index_buffer.Create(INDEX_BUFFER_SIZE))
|
if (!m_index_buffer.Create(INDEX_BUFFER_SIZE))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate index buffer");
|
ERROR_LOG("Failed to allocate index buffer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_uniform_buffer.Create(VERTEX_UNIFORM_BUFFER_SIZE))
|
if (!m_uniform_buffer.Create(VERTEX_UNIFORM_BUFFER_SIZE))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate uniform buffer");
|
ERROR_LOG("Failed to allocate uniform buffer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_texture_upload_buffer.Create(TEXTURE_BUFFER_SIZE))
|
if (!m_texture_upload_buffer.Create(TEXTURE_BUFFER_SIZE))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate texture upload buffer");
|
ERROR_LOG("Failed to allocate texture upload buffer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ std::unique_ptr<GPUPipeline> D3D12Device::CreatePipeline(const GPUPipeline::Grap
|
||||||
{
|
{
|
||||||
// E_INVALIDARG = not found.
|
// E_INVALIDARG = not found.
|
||||||
if (hr != E_INVALIDARG)
|
if (hr != E_INVALIDARG)
|
||||||
Log_ErrorFmt("LoadGraphicsPipeline() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("LoadGraphicsPipeline() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||||
|
|
||||||
// Need to create it normally.
|
// Need to create it normally.
|
||||||
pipeline = gpb.Create(m_device.Get(), false);
|
pipeline = gpb.Create(m_device.Get(), false);
|
||||||
|
@ -241,7 +241,7 @@ std::unique_ptr<GPUPipeline> D3D12Device::CreatePipeline(const GPUPipeline::Grap
|
||||||
{
|
{
|
||||||
hr = m_pipeline_library->StorePipeline(name.c_str(), pipeline.Get());
|
hr = m_pipeline_library->StorePipeline(name.c_str(), pipeline.Get());
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
Log_ErrorFmt("StorePipeline() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("StorePipeline() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ bool D3D12StreamBuffer::Create(u32 size)
|
||||||
IID_PPV_ARGS(buffer.GetAddressOf()));
|
IID_PPV_ARGS(buffer.GetAddressOf()));
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateResource() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateResource() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ bool D3D12StreamBuffer::Create(u32 size)
|
||||||
hr = buffer->Map(0, &read_range, reinterpret_cast<void**>(&host_pointer));
|
hr = buffer->Map(0, &read_range, reinterpret_cast<void**>(&host_pointer));
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Map() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Map() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ bool D3D12StreamBuffer::ReserveMemory(u32 num_bytes, u32 alignment)
|
||||||
// Check for sane allocations
|
// Check for sane allocations
|
||||||
if (num_bytes > m_size) [[unlikely]]
|
if (num_bytes > m_size) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Attempting to allocate {} bytes from a {} byte stream buffer", static_cast<u32>(num_bytes),
|
ERROR_LOG("Attempting to allocate {} bytes from a {} byte stream buffer", static_cast<u32>(num_bytes),
|
||||||
static_cast<u32>(m_size));
|
static_cast<u32>(m_size));
|
||||||
Panic("Stream buffer overflow");
|
Panic("Stream buffer overflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ std::unique_ptr<GPUTexture> D3D12Device::CreateTexture(u32 width, u32 height, u3
|
||||||
{
|
{
|
||||||
// OOM isn't fatal.
|
// OOM isn't fatal.
|
||||||
if (hr != E_OUTOFMEMORY)
|
if (hr != E_OUTOFMEMORY)
|
||||||
Log_ErrorFmt("Create texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Create texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ bool D3D12Device::CreateSRVDescriptor(ID3D12Resource* resource, u32 layers, u32
|
||||||
{
|
{
|
||||||
if (!m_descriptor_heap_manager.Allocate(dh))
|
if (!m_descriptor_heap_manager.Allocate(dh))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate SRV descriptor");
|
ERROR_LOG("Failed to allocate SRV descriptor");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ bool D3D12Device::CreateRTVDescriptor(ID3D12Resource* resource, u32 samples, DXG
|
||||||
{
|
{
|
||||||
if (!m_rtv_heap_manager.Allocate(dh))
|
if (!m_rtv_heap_manager.Allocate(dh))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate SRV descriptor");
|
ERROR_LOG("Failed to allocate SRV descriptor");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ bool D3D12Device::CreateDSVDescriptor(ID3D12Resource* resource, u32 samples, DXG
|
||||||
{
|
{
|
||||||
if (!m_dsv_heap_manager.Allocate(dh))
|
if (!m_dsv_heap_manager.Allocate(dh))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate SRV descriptor");
|
ERROR_LOG("Failed to allocate SRV descriptor");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ bool D3D12Device::CreateUAVDescriptor(ID3D12Resource* resource, u32 samples, DXG
|
||||||
{
|
{
|
||||||
if (!m_descriptor_heap_manager.Allocate(dh))
|
if (!m_descriptor_heap_manager.Allocate(dh))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to allocate UAV descriptor");
|
ERROR_LOG("Failed to allocate UAV descriptor");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,9 +358,9 @@ ID3D12Resource* D3D12Texture::AllocateUploadStagingBuffer(const void* data, u32
|
||||||
HRESULT hr = D3D12Device::GetInstance().GetAllocator()->CreateResource(
|
HRESULT hr = D3D12Device::GetInstance().GetAllocator()->CreateResource(
|
||||||
&allocation_desc, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, allocation.GetAddressOf(),
|
&allocation_desc, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, allocation.GetAddressOf(),
|
||||||
IID_PPV_ARGS(resource.GetAddressOf()));
|
IID_PPV_ARGS(resource.GetAddressOf()));
|
||||||
if (FAILED(hr))[[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateResource() failed with {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("CreateResource() failed with {:08X}", static_cast<unsigned>(hr));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ ID3D12Resource* D3D12Texture::AllocateUploadStagingBuffer(const void* data, u32
|
||||||
hr = resource->Map(0, nullptr, &map_ptr);
|
hr = resource->Map(0, nullptr, &map_ptr);
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Map() failed with {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Map() failed with {:08X}", static_cast<unsigned>(hr));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ bool D3D12Texture::Update(u32 x, u32 y, u32 width, u32 height, const void* data,
|
||||||
required_size);
|
required_size);
|
||||||
if (!sbuffer.ReserveMemory(required_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
if (!sbuffer.ReserveMemory(required_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to reserve texture upload memory ({} bytes).", required_size);
|
ERROR_LOG("Failed to reserve texture upload memory ({} bytes).", required_size);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -872,7 +872,7 @@ std::unique_ptr<D3D12DownloadTexture> D3D12DownloadTexture::Create(u32 width, u3
|
||||||
IID_PPV_ARGS(buffer.GetAddressOf()));
|
IID_PPV_ARGS(buffer.GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("CreateResource() failed with HRESULT {:08X}", hr);
|
ERROR_LOG("CreateResource() failed with HRESULT {:08X}", hr);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -954,7 +954,7 @@ bool D3D12DownloadTexture::Map(u32 x, u32 y, u32 width, u32 height)
|
||||||
const HRESULT hr = m_buffer->Map(0, &read_range, reinterpret_cast<void**>(const_cast<u8**>(&m_map_pointer)));
|
const HRESULT hr = m_buffer->Map(0, &read_range, reinterpret_cast<void**>(const_cast<u8**>(&m_map_pointer)));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Map() failed with HRESULT {:08X}", hr);
|
ERROR_LOG("Map() failed with HRESULT {:08X}", hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,6 +1006,6 @@ std::unique_ptr<GPUDownloadTexture> D3D12Device::CreateDownloadTexture(u32 width
|
||||||
void* memory, size_t memory_size,
|
void* memory, size_t memory_size,
|
||||||
u32 memory_stride)
|
u32 memory_stride)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("D3D12 cannot import memory for download textures");
|
ERROR_LOG("D3D12 cannot import memory for download textures");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ D3D_FEATURE_LEVEL D3DCommon::GetDeviceMaxFeatureLevel(IDXGIAdapter1* adapter)
|
||||||
requested_feature_levels.data(), static_cast<UINT>(requested_feature_levels.size()),
|
requested_feature_levels.data(), static_cast<UINT>(requested_feature_levels.size()),
|
||||||
D3D11_SDK_VERSION, nullptr, &max_supported_level, nullptr);
|
D3D11_SDK_VERSION, nullptr, &max_supported_level, nullptr);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
Log_WarningFmt("D3D11CreateDevice() for getting max feature level failed: 0x{:08X}", static_cast<unsigned>(hr));
|
WARNING_LOG("D3D11CreateDevice() for getting max feature level failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||||
|
|
||||||
return max_supported_level;
|
return max_supported_level;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ std::vector<std::string> D3DCommon::GetAdapterNames(IDXGIFactory5* factory)
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("IDXGIFactory2::EnumAdapters() returned {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("IDXGIFactory2::EnumAdapters() returned {:08X}", static_cast<unsigned>(hr));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,21 +146,21 @@ std::vector<std::string> D3DCommon::GetFullscreenModes(IDXGIFactory5* factory, s
|
||||||
Microsoft::WRL::ComPtr<IDXGIOutput> output;
|
Microsoft::WRL::ComPtr<IDXGIOutput> output;
|
||||||
if (FAILED(hr = adapter->EnumOutputs(0, &output)))
|
if (FAILED(hr = adapter->EnumOutputs(0, &output)))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("EnumOutputs() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("EnumOutputs() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return modes;
|
return modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT num_modes = 0;
|
UINT num_modes = 0;
|
||||||
if (FAILED(hr = output->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, 0, &num_modes, nullptr)))
|
if (FAILED(hr = output->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, 0, &num_modes, nullptr)))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("GetDisplayModeList() failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("GetDisplayModeList() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return modes;
|
return modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<DXGI_MODE_DESC> dmodes(num_modes);
|
std::vector<DXGI_MODE_DESC> dmodes(num_modes);
|
||||||
if (FAILED(hr = output->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, 0, &num_modes, dmodes.data())))
|
if (FAILED(hr = output->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, 0, &num_modes, dmodes.data())))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("GetDisplayModeList() (2) failed: {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("GetDisplayModeList() (2) failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
return modes;
|
return modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,11 +223,11 @@ bool D3DCommon::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory,
|
||||||
{
|
{
|
||||||
if (!first_output)
|
if (!first_output)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("No DXGI output found. Can't use exclusive fullscreen.");
|
ERROR_LOG("No DXGI output found. Can't use exclusive fullscreen.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningPrint("No DXGI output found for window, using first.");
|
WARNING_LOG("No DXGI output found for window, using first.");
|
||||||
intersecting_output = std::move(first_output);
|
intersecting_output = std::move(first_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ bool D3DCommon::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory,
|
||||||
if (FAILED(hr = intersecting_output->FindClosestMatchingMode(&request_mode, fullscreen_mode, nullptr)) ||
|
if (FAILED(hr = intersecting_output->FindClosestMatchingMode(&request_mode, fullscreen_mode, nullptr)) ||
|
||||||
request_mode.Format != format)
|
request_mode.Format != format)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to find closest matching mode, hr={:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("Failed to find closest matching mode, hr={:08X}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,21 +268,21 @@ Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetAdapterByName(IDXGIFactory5*
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("IDXGIFactory2::EnumAdapters() returned {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("IDXGIFactory2::EnumAdapters() returned {:08X}", static_cast<unsigned>(hr));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string adapter_name = FixupDuplicateAdapterNames(adapter_names, GetAdapterName(adapter.Get()));
|
std::string adapter_name = FixupDuplicateAdapterNames(adapter_names, GetAdapterName(adapter.Get()));
|
||||||
if (adapter_name == name)
|
if (adapter_name == name)
|
||||||
{
|
{
|
||||||
Log_VerboseFmt("Found adapter '{}'", adapter_name);
|
VERBOSE_LOG("Found adapter '{}'", adapter_name);
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter_names.push_back(std::move(adapter_name));
|
adapter_names.push_back(std::move(adapter_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_ErrorFmt("Adapter '{}' not found.", name);
|
ERROR_LOG("Adapter '{}' not found.", name);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetFirstAdapter(IDXGIFactory5*
|
||||||
Microsoft::WRL::ComPtr<IDXGIAdapter1> adapter;
|
Microsoft::WRL::ComPtr<IDXGIAdapter1> adapter;
|
||||||
HRESULT hr = factory->EnumAdapters1(0, adapter.GetAddressOf());
|
HRESULT hr = factory->EnumAdapters1(0, adapter.GetAddressOf());
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
Log_ErrorFmt("IDXGIFactory2::EnumAdapters() for first adapter returned {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("IDXGIFactory2::EnumAdapters() for first adapter returned {:08X}", static_cast<unsigned>(hr));
|
||||||
|
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ std::string D3DCommon::GetAdapterName(IDXGIAdapter1* adapter)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("IDXGIAdapter1::GetDesc() returned {:08X}", static_cast<unsigned>(hr));
|
ERROR_LOG("IDXGIAdapter1::GetDesc() returned {:08X}", static_cast<unsigned>(hr));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret.empty())
|
if (ret.empty())
|
||||||
|
@ -429,13 +429,13 @@ std::optional<DynamicHeapArray<u8>> D3DCommon::CompileShader(D3D_FEATURE_LEVEL f
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to compile '{}':\n{}", target, error_string);
|
ERROR_LOG("Failed to compile '{}':\n{}", target, error_string);
|
||||||
GPUDevice::DumpBadShader(source, error_string);
|
GPUDevice::DumpBadShader(source, error_string);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error_string.empty())
|
if (!error_string.empty())
|
||||||
Log_WarningFmt("'{}' compiled with warnings:\n{}", target, error_string);
|
WARNING_LOG("'{}' compiled with warnings:\n{}", target, error_string);
|
||||||
|
|
||||||
error_blob.Reset();
|
error_blob.Reset();
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
|
||||||
m_dinput_module = LoadLibraryW(L"dinput8");
|
m_dinput_module = LoadLibraryW(L"dinput8");
|
||||||
if (!m_dinput_module)
|
if (!m_dinput_module)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to load DInput module.");
|
ERROR_LOG("Failed to load DInput module.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
|
||||||
reinterpret_cast<PFNGETDFDIJOYSTICK>(GetProcAddress(m_dinput_module, "GetdfDIJoystick"));
|
reinterpret_cast<PFNGETDFDIJOYSTICK>(GetProcAddress(m_dinput_module, "GetdfDIJoystick"));
|
||||||
if (!create || !get_joystick_data_format)
|
if (!create || !get_joystick_data_format)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to get DInput function pointers.");
|
ERROR_LOG("Failed to get DInput function pointers.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
|
||||||
m_joystick_data_format = get_joystick_data_format();
|
m_joystick_data_format = get_joystick_data_format();
|
||||||
if (FAILED(hr) || !m_joystick_data_format)
|
if (FAILED(hr) || !m_joystick_data_format)
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("DirectInput8Create() failed: {}", static_cast<unsigned>(hr));
|
ERROR_LOG("DirectInput8Create() failed: {}", static_cast<unsigned>(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
|
||||||
|
|
||||||
if (!toplevel_wi.has_value() || toplevel_wi->type != WindowInfo::Type::Win32)
|
if (!toplevel_wi.has_value() || toplevel_wi->type != WindowInfo::Type::Win32)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Missing top level window, cannot add DInput devices.");
|
ERROR_LOG("Missing top level window, cannot add DInput devices.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ bool DInputSource::ReloadDevices()
|
||||||
std::vector<DIDEVICEINSTANCEW> devices;
|
std::vector<DIDEVICEINSTANCEW> devices;
|
||||||
m_dinput->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumCallback, &devices, DIEDFL_ATTACHEDONLY);
|
m_dinput->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumCallback, &devices, DIEDFL_ATTACHEDONLY);
|
||||||
|
|
||||||
Log_VerboseFmt("Enumerated {} devices", devices.size());
|
VERBOSE_LOG("Enumerated {} devices", devices.size());
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for (DIDEVICEINSTANCEW inst : devices)
|
for (DIDEVICEINSTANCEW inst : devices)
|
||||||
|
@ -141,9 +141,9 @@ bool DInputSource::ReloadDevices()
|
||||||
HRESULT hr = m_dinput->CreateDevice(inst.guidInstance, cd.device.GetAddressOf(), nullptr);
|
HRESULT hr = m_dinput->CreateDevice(inst.guidInstance, cd.device.GetAddressOf(), nullptr);
|
||||||
if (FAILED(hr)) [[unlikely]]
|
if (FAILED(hr)) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_WarningFmt("Failed to create instance of device [{}, {}]",
|
WARNING_LOG("Failed to create instance of device [{}, {}]",
|
||||||
StringUtil::WideStringToUTF8String(inst.tszProductName),
|
StringUtil::WideStringToUTF8String(inst.tszProductName),
|
||||||
StringUtil::WideStringToUTF8String(inst.tszInstanceName));
|
StringUtil::WideStringToUTF8String(inst.tszInstanceName));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,24 +179,24 @@ bool DInputSource::AddDevice(ControllerData& cd, const std::string& name)
|
||||||
hr = cd.device->SetCooperativeLevel(m_toplevel_window, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE);
|
hr = cd.device->SetCooperativeLevel(m_toplevel_window, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to set cooperative level for '{}'", name);
|
ERROR_LOG("Failed to set cooperative level for '{}'", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_WarningFmt("Failed to set exclusive mode for '{}'", name);
|
WARNING_LOG("Failed to set exclusive mode for '{}'", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = cd.device->SetDataFormat(m_joystick_data_format);
|
hr = cd.device->SetDataFormat(m_joystick_data_format);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to set data format for '{}'", name);
|
ERROR_LOG("Failed to set data format for '{}'", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = cd.device->Acquire();
|
hr = cd.device->Acquire();
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to acquire device '{}'", name);
|
ERROR_LOG("Failed to acquire device '{}'", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ bool DInputSource::AddDevice(ControllerData& cd, const std::string& name)
|
||||||
hr = cd.device->GetCapabilities(&caps);
|
hr = cd.device->GetCapabilities(&caps);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to get capabilities for '{}'", name);
|
ERROR_LOG("Failed to get capabilities for '{}'", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,14 +239,14 @@ bool DInputSource::AddDevice(ControllerData& cd, const std::string& name)
|
||||||
if (hr == DI_NOEFFECT)
|
if (hr == DI_NOEFFECT)
|
||||||
cd.needs_poll = false;
|
cd.needs_poll = false;
|
||||||
else if (hr != DI_OK)
|
else if (hr != DI_OK)
|
||||||
Log_WarningFmt("Polling device '{}' failed: {:08X}", name, static_cast<unsigned>(hr));
|
WARNING_LOG("Polling device '{}' failed: {:08X}", name, static_cast<unsigned>(hr));
|
||||||
|
|
||||||
hr = cd.device->GetDeviceState(sizeof(cd.last_state), &cd.last_state);
|
hr = cd.device->GetDeviceState(sizeof(cd.last_state), &cd.last_state);
|
||||||
if (hr != DI_OK)
|
if (hr != DI_OK)
|
||||||
Log_WarningFmt("GetDeviceState() for '{}' failed: {:08X}", name, static_cast<unsigned>(hr));
|
WARNING_LOG("GetDeviceState() for '{}' failed: {:08X}", name, static_cast<unsigned>(hr));
|
||||||
|
|
||||||
Log_InfoFmt("{} has {} buttons, {} axes, {} hats", name, cd.num_buttons, static_cast<u32>(cd.axis_offsets.size()),
|
INFO_LOG("{} has {} buttons, {} axes, {} hats", name, cd.num_buttons, static_cast<u32>(cd.axis_offsets.size()),
|
||||||
cd.num_hats);
|
cd.num_hats);
|
||||||
|
|
||||||
return (cd.num_buttons > 0 || !cd.axis_offsets.empty() || cd.num_hats > 0);
|
return (cd.num_buttons > 0 || !cd.axis_offsets.empty() || cd.num_hats > 0);
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ void DInputSource::PollEvents()
|
||||||
}
|
}
|
||||||
else if (hr != DI_OK)
|
else if (hr != DI_OK)
|
||||||
{
|
{
|
||||||
Log_WarningFmt("GetDeviceState() failed: {:08X}", static_cast<unsigned>(hr));
|
WARNING_LOG("GetDeviceState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ RenderAPI GPUDevice::GetPreferredAPI()
|
||||||
preferred_renderer = RenderAPI::Vulkan;
|
preferred_renderer = RenderAPI::Vulkan;
|
||||||
#else
|
#else
|
||||||
// Uhhh, what?
|
// Uhhh, what?
|
||||||
Log_ErrorPrint("Somehow don't have any renderers available...");
|
ERROR_LOG("Somehow don't have any renderers available...");
|
||||||
preferred_renderer = RenderAPI::None;
|
preferred_renderer = RenderAPI::None;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ bool GPUDevice::Create(std::string_view adapter, std::string_view shader_cache_p
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_InfoFmt("Graphics Driver Info:\n{}", GetDriverInfo());
|
INFO_LOG("Graphics Driver Info:\n{}", GetDriverInfo());
|
||||||
|
|
||||||
OpenShaderCache(shader_cache_path, shader_cache_version);
|
OpenShaderCache(shader_cache_path, shader_cache_version);
|
||||||
|
|
||||||
|
@ -332,9 +332,9 @@ void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version)
|
||||||
const std::string filename = Path::Combine(base_path, basename);
|
const std::string filename = Path::Combine(base_path, basename);
|
||||||
if (!m_shader_cache.Open(filename.c_str(), version))
|
if (!m_shader_cache.Open(filename.c_str(), version))
|
||||||
{
|
{
|
||||||
Log_WarningPrint("Failed to open shader cache. Creating new cache.");
|
WARNING_LOG("Failed to open shader cache. Creating new cache.");
|
||||||
if (!m_shader_cache.Create())
|
if (!m_shader_cache.Create())
|
||||||
Log_ErrorPrint("Failed to create new shader cache.");
|
ERROR_LOG("Failed to create new shader cache.");
|
||||||
|
|
||||||
// Squish the pipeline cache too, it's going to be stale.
|
// Squish the pipeline cache too, it's going to be stale.
|
||||||
if (m_features.pipeline_cache)
|
if (m_features.pipeline_cache)
|
||||||
|
@ -343,7 +343,7 @@ void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version)
|
||||||
Path::Combine(base_path, TinyString::from_format("{}.bin", GetShaderCacheBaseName("pipelines")));
|
Path::Combine(base_path, TinyString::from_format("{}.bin", GetShaderCacheBaseName("pipelines")));
|
||||||
if (FileSystem::FileExists(pc_filename.c_str()))
|
if (FileSystem::FileExists(pc_filename.c_str()))
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Removing old pipeline cache '{}'", Path::GetFileName(pc_filename));
|
INFO_LOG("Removing old pipeline cache '{}'", Path::GetFileName(pc_filename));
|
||||||
FileSystem::DeleteFile(pc_filename.c_str());
|
FileSystem::DeleteFile(pc_filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version)
|
||||||
if (ReadPipelineCache(filename))
|
if (ReadPipelineCache(filename))
|
||||||
s_pipeline_cache_path = std::move(filename);
|
s_pipeline_cache_path = std::move(filename);
|
||||||
else
|
else
|
||||||
Log_WarningPrint("Failed to read pipeline cache.");
|
WARNING_LOG("Failed to read pipeline cache.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,14 +380,13 @@ void GPUDevice::CloseShaderCache()
|
||||||
FILESYSTEM_STAT_DATA sd;
|
FILESYSTEM_STAT_DATA sd;
|
||||||
if (!FileSystem::StatFile(s_pipeline_cache_path.c_str(), &sd) || sd.Size != static_cast<s64>(data.size()))
|
if (!FileSystem::StatFile(s_pipeline_cache_path.c_str(), &sd) || sd.Size != static_cast<s64>(data.size()))
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Writing {} bytes to '{}'", data.size(), Path::GetFileName(s_pipeline_cache_path));
|
INFO_LOG("Writing {} bytes to '{}'", data.size(), Path::GetFileName(s_pipeline_cache_path));
|
||||||
if (!FileSystem::WriteBinaryFile(s_pipeline_cache_path.c_str(), data.data(), data.size()))
|
if (!FileSystem::WriteBinaryFile(s_pipeline_cache_path.c_str(), data.data(), data.size()))
|
||||||
Log_ErrorFmt("Failed to write pipeline cache to '{}'", Path::GetFileName(s_pipeline_cache_path));
|
ERROR_LOG("Failed to write pipeline cache to '{}'", Path::GetFileName(s_pipeline_cache_path));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_InfoFmt("Skipping updating pipeline cache '{}' due to no changes.",
|
INFO_LOG("Skipping updating pipeline cache '{}' due to no changes.", Path::GetFileName(s_pipeline_cache_path));
|
||||||
Path::GetFileName(s_pipeline_cache_path));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,7 +454,7 @@ bool GPUDevice::AcquireWindow(bool recreate_window)
|
||||||
if (!wi.has_value())
|
if (!wi.has_value())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Log_InfoFmt("Render window is {}x{}.", wi->surface_width, wi->surface_height);
|
INFO_LOG("Render window is {}x{}.", wi->surface_width, wi->surface_height);
|
||||||
m_window_info = wi.value();
|
m_window_info = wi.value();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +505,7 @@ bool GPUDevice::CreateResources()
|
||||||
m_imgui_pipeline = CreatePipeline(plconfig);
|
m_imgui_pipeline = CreatePipeline(plconfig);
|
||||||
if (!m_imgui_pipeline)
|
if (!m_imgui_pipeline)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to compile ImGui pipeline.");
|
ERROR_LOG("Failed to compile ImGui pipeline.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GL_OBJECT_NAME(m_imgui_pipeline, "ImGui Pipeline");
|
GL_OBJECT_NAME(m_imgui_pipeline, "ImGui Pipeline");
|
||||||
|
@ -666,7 +665,7 @@ std::unique_ptr<GPUShader> GPUDevice::CreateShader(GPUShaderStage stage, std::st
|
||||||
if (shader)
|
if (shader)
|
||||||
return shader;
|
return shader;
|
||||||
|
|
||||||
Log_ErrorPrint("Failed to create shader from binary (driver changed?). Clearing cache.");
|
ERROR_LOG("Failed to create shader from binary (driver changed?). Clearing cache.");
|
||||||
m_shader_cache.Clear();
|
m_shader_cache.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,7 +873,7 @@ std::unique_ptr<GPUTexture> GPUDevice::FetchTexture(u32 width, u32 height, u32 l
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This shouldn't happen...
|
// This shouldn't happen...
|
||||||
Log_ErrorFmt("Failed to upload {}x{} to pooled texture", width, height);
|
ERROR_LOG("Failed to upload {}x{} to pooled texture", width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -913,7 +912,7 @@ void GPUDevice::RecycleTexture(std::unique_ptr<GPUTexture> texture)
|
||||||
const u32 max_size = is_texture ? MAX_TEXTURE_POOL_SIZE : MAX_TARGET_POOL_SIZE;
|
const u32 max_size = is_texture ? MAX_TEXTURE_POOL_SIZE : MAX_TARGET_POOL_SIZE;
|
||||||
while (pool.size() > max_size)
|
while (pool.size() > max_size)
|
||||||
{
|
{
|
||||||
Log_ProfileFmt("Trim {}x{} texture from pool", pool.front().texture->GetWidth(), pool.front().texture->GetHeight());
|
DEBUG_LOG("Trim {}x{} texture from pool", pool.front().texture->GetWidth(), pool.front().texture->GetHeight());
|
||||||
pool.pop_front();
|
pool.pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -931,8 +930,8 @@ void GPUDevice::TrimTexturePool()
|
||||||
GL_INS_FMT("Target Pool Size: {}", m_target_pool.size());
|
GL_INS_FMT("Target Pool Size: {}", m_target_pool.size());
|
||||||
GL_INS_FMT("VRAM Usage: {:.2f} MB", s_total_vram_usage / 1048576.0);
|
GL_INS_FMT("VRAM Usage: {:.2f} MB", s_total_vram_usage / 1048576.0);
|
||||||
|
|
||||||
Log_DebugFmt("Texture Pool Size: {} Target Pool Size: {} VRAM: {:.2f} MB", m_texture_pool.size(),
|
DEBUG_LOG("Texture Pool Size: {} Target Pool Size: {} VRAM: {:.2f} MB", m_texture_pool.size(), m_target_pool.size(),
|
||||||
m_target_pool.size(), s_total_vram_usage / 1048756.0);
|
s_total_vram_usage / 1048756.0);
|
||||||
|
|
||||||
if (m_texture_pool.empty() && m_target_pool.empty())
|
if (m_texture_pool.empty() && m_target_pool.empty())
|
||||||
return;
|
return;
|
||||||
|
@ -947,7 +946,7 @@ void GPUDevice::TrimTexturePool()
|
||||||
if (delta < POOL_PURGE_DELAY)
|
if (delta < POOL_PURGE_DELAY)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Log_ProfileFmt("Trim {}x{} texture from pool", it->texture->GetWidth(), it->texture->GetHeight());
|
DEBUG_LOG("Trim {}x{} texture from pool", it->texture->GetWidth(), it->texture->GetHeight());
|
||||||
it = pool.erase(it);
|
it = pool.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -990,7 +989,7 @@ bool GPUDevice::ResizeTexture(std::unique_ptr<GPUTexture>* tex, u32 new_width, u
|
||||||
std::unique_ptr<GPUTexture> new_tex = FetchTexture(new_width, new_height, 1, 1, 1, type, format);
|
std::unique_ptr<GPUTexture> new_tex = FetchTexture(new_width, new_height, 1, 1, 1, type, format);
|
||||||
if (!new_tex) [[unlikely]]
|
if (!new_tex) [[unlikely]]
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to create new {}x{} texture", new_width, new_height);
|
ERROR_LOG("Failed to create new {}x{} texture", new_width, new_height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,14 +1156,14 @@ bool dyn_shaderc::Open()
|
||||||
#endif
|
#endif
|
||||||
if (!s_library.Open(libname.c_str(), &error))
|
if (!s_library.Open(libname.c_str(), &error))
|
||||||
{
|
{
|
||||||
Log_ErrorFmt("Failed to load shaderc: {}", error.GetDescription());
|
ERROR_LOG("Failed to load shaderc: {}", error.GetDescription());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOAD_FUNC(F) \
|
#define LOAD_FUNC(F) \
|
||||||
if (!s_library.GetSymbol(#F, &F)) \
|
if (!s_library.GetSymbol(#F, &F)) \
|
||||||
{ \
|
{ \
|
||||||
Log_ErrorFmt("Failed to find function {}", #F); \
|
ERROR_LOG("Failed to find function {}", #F); \
|
||||||
Close(); \
|
Close(); \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
@ -1175,7 +1174,7 @@ bool dyn_shaderc::Open()
|
||||||
s_compiler = shaderc_compiler_initialize();
|
s_compiler = shaderc_compiler_initialize();
|
||||||
if (!s_compiler)
|
if (!s_compiler)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("shaderc_compiler_initialize() failed");
|
ERROR_LOG("shaderc_compiler_initialize() failed");
|
||||||
Close();
|
Close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1233,15 +1232,15 @@ bool GPUDevice::CompileGLSLShaderToVulkanSpv(GPUShaderStage stage, std::string_v
|
||||||
{
|
{
|
||||||
const std::string_view errors(result ? dyn_shaderc::shaderc_result_get_error_message(result) :
|
const std::string_view errors(result ? dyn_shaderc::shaderc_result_get_error_message(result) :
|
||||||
"null result object");
|
"null result object");
|
||||||
Log_ErrorFmt("Failed to compile shader to SPIR-V: {}\n{}",
|
ERROR_LOG("Failed to compile shader to SPIR-V: {}\n{}", dyn_shaderc::shaderc_compilation_status_to_string(status),
|
||||||
dyn_shaderc::shaderc_compilation_status_to_string(status), errors);
|
errors);
|
||||||
DumpBadShader(source, errors);
|
DumpBadShader(source, errors);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const size_t num_warnings = dyn_shaderc::shaderc_result_get_num_warnings(result);
|
const size_t num_warnings = dyn_shaderc::shaderc_result_get_num_warnings(result);
|
||||||
if (num_warnings > 0)
|
if (num_warnings > 0)
|
||||||
Log_WarningFmt("Shader compiled with warnings:\n{}", dyn_shaderc::shaderc_result_get_error_message(result));
|
WARNING_LOG("Shader compiled with warnings:\n{}", dyn_shaderc::shaderc_result_get_error_message(result));
|
||||||
|
|
||||||
const size_t spirv_size = dyn_shaderc::shaderc_result_get_length(result);
|
const size_t spirv_size = dyn_shaderc::shaderc_result_get_length(result);
|
||||||
DebugAssert(spirv_size > 0);
|
DebugAssert(spirv_size > 0);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue