1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Experimental template formatting with be_t<> support

This commit is contained in:
Nekotekina 2015-01-12 21:12:06 +03:00
parent ad2b2c9c62
commit b6ec618f97
29 changed files with 577 additions and 86 deletions

View File

@ -284,15 +284,9 @@ union _CRT_ALIGN(16) u128
_u64[1] = _u64[0] = 0;
}
std::string to_hex() const
{
return fmt::Format("%016llx%016llx", _u64[1], _u64[0]);
}
std::string to_hex() const;
std::string to_xyzw() const
{
return fmt::Format("x: %g y: %g z: %g w: %g", _f[3], _f[2], _f[1], _f[0]);
}
std::string to_xyzw() const;
static __forceinline u128 byteswap(const u128 val)
{
@ -608,6 +602,15 @@ public:
return ToBE();
#endif
}
const stype& data() const
{
#ifdef IS_LE_MACHINE
return ToBE();
#else
return ToLE();
#endif
}
be_t& operator = (const be_t& value) = default;

View File

@ -135,9 +135,9 @@ inline void log_message(Log::LogType type, Log::LogSeverity sev, const char* tex
Log::LogManager::getInstance().log(msg);
}
template<typename T, typename ...Ts>
inline void log_message(Log::LogType type, Log::LogSeverity sev, const char* text, T arg, Ts... args)
template<typename T, size_t N, typename ...Ts>
inline void log_message(Log::LogType type, Log::LogSeverity sev, const char(&text)[N], T arg, Ts... args)
{
Log::LogMessage msg{type, sev, fmt::Format(text, arg, args...)};
Log::LogMessage msg{type, sev, fmt::format(text, arg, args...)};
Log::LogManager::getInstance().log(msg);
}

View File

@ -1,18 +1,16 @@
#pragma once
class wxString;
#if defined(_MSC_VER)
#define snprintf _snprintf
#endif
namespace fmt{
using std::string;
using std::ostream;
using std::ostringstream;
namespace fmt
{
struct empty_t{};
extern const string placeholder;
extern const std::string placeholder;
template <typename T>
std::string AfterLast(const std::string& source, T searchstr)
@ -51,11 +49,11 @@ namespace fmt{
// `fmt::placeholder` after `pos` everything in `fmt` after pos is written
// to `os`. Then `arg` is written to `os` after appending a space character
template<typename T>
empty_t write(const string &fmt, ostream &os, string::size_type &pos, T &&arg)
empty_t write(const std::string &fmt, std::ostream &os, std::string::size_type &pos, T &&arg)
{
string::size_type ins = fmt.find(placeholder, pos);
std::string::size_type ins = fmt.find(placeholder, pos);
if (ins == string::npos)
if (ins == std::string::npos)
{
os.write(fmt.data() + pos, fmt.size() - pos);
os << ' ' << arg;
@ -77,10 +75,10 @@ namespace fmt{
// inserted use `fmt::placeholder`. If there's not enough placeholders
// the rest of the arguments are appended at the end, seperated by spaces
template<typename ... Args>
string SFormat(const string &fmt, Args&& ... parameters)
std::string SFormat(const std::string &fmt, Args&& ... parameters)
{
ostringstream os;
string::size_type pos = 0;
std::ostringstream os;
std::string::size_type pos = 0;
std::initializer_list<empty_t> { write(fmt, os, pos, parameters)... };
if (!fmt.empty())
@ -88,7 +86,7 @@ namespace fmt{
os.write(fmt.data() + pos, fmt.size() - pos);
}
string result = os.str();
std::string result = os.str();
return result;
}
@ -98,10 +96,10 @@ namespace fmt{
//wrapper to deal with advance sprintf formating options with automatic length finding
template<typename ... Args>
string Format(const char* fmt, Args ... parameters)
std::string Format(const char* fmt, Args ... parameters)
{
size_t length = 256;
string str;
std::string str;
for (;;)
{
@ -116,7 +114,7 @@ namespace fmt{
#endif
if (printlen < length)
{
str = string(buffptr.data(), printlen);
str = std::string(buffptr.data(), printlen);
break;
}
length *= 2;
@ -175,13 +173,490 @@ namespace fmt{
return src;
}
namespace detail
{
static std::string to_hex(u64 value, size_t count = 1)
{
assert(count - 1 < 16);
count = std::max<u64>(count, 16 - cntlz64(value) / 4);
char res[16] = {};
for (size_t i = count - 1; ~i; i--, value /= 16)
{
res[i] = "0123456789abcdef"[value % 16];
}
return std::string(res, count);
}
static size_t get_fmt_start(const char* fmt, size_t len)
{
for (size_t i = 0; i < len; i++)
{
if (fmt[i] == '%')
{
return i;
}
}
return len;
}
static size_t get_fmt_len(const char* fmt, size_t len)
{
assert(len >= 2 && fmt[0] == '%');
size_t res = 2;
if (fmt[1] == '.' || fmt[1] == '0')
{
assert(len >= 4 && fmt[2] - '1' < 9);
res += 2;
fmt += 2;
len -= 2;
if (fmt[1] == '1')
{
assert(len >= 3 && fmt[2] - '0' < 7);
res++;
fmt++;
len--;
}
}
if (fmt[1] == 'l')
{
assert(len >= 3);
res++;
fmt++;
len--;
}
if (fmt[1] == 'l')
{
assert(len >= 3);
res++;
fmt++;
len--;
}
return res;
}
static size_t get_fmt_precision(const char* fmt, size_t len)
{
assert(len >= 2);
if (fmt[1] == '.' || fmt[1] == '0')
{
assert(len >= 4 && fmt[2] - '1' < 9);
if (fmt[2] == '1')
{
assert(len >= 5 && fmt[3] - '0' < 7);
return 10 + fmt[3] - '0';
}
return fmt[2] - '0';
}
return 1;
}
template<typename T, bool is_enum = std::is_enum<T>::value>
struct get_fmt
{
static_assert(is_enum, "Unsupported fmt::format argument");
typedef typename std::underlying_type<T>::type underlying_type;
static std::string text(const char* fmt, size_t len, const T& arg)
{
return get_fmt<underlying_type>::text(fmt, len, (underlying_type)arg);
}
};
template<typename T, typename T2>
struct get_fmt<be_t<T, T2>, false>
{
static std::string text(const char* fmt, size_t len, const be_t<T, T2>& arg)
{
return get_fmt<T>::text(fmt, len, arg.value());
}
};
template<>
struct get_fmt<u8>
{
static std::string text(const char* fmt, size_t len, u8 arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex(arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'd')
{
return std::to_string((u32)arg);
}
else
{
throw "Invalid formatting (u8)";
}
return{};
}
};
template<>
struct get_fmt<u16>
{
static std::string text(const char* fmt, size_t len, u16 arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex(arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'd')
{
return std::to_string((u32)arg);
}
else
{
throw "Invalid formatting (u16)";
}
return{};
}
};
template<>
struct get_fmt<u32>
{
static std::string text(const char* fmt, size_t len, u32 arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex(arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'd')
{
return std::to_string(arg);
}
else
{
throw "Invalid formatting (u32)";
}
return{};
}
};
template<>
struct get_fmt<u64>
{
static std::string text(const char* fmt, size_t len, u64 arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex(arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'd')
{
return std::to_string(arg);
}
else
{
throw "Invalid formatting (u64)";
}
return{};
}
};
template<>
struct get_fmt<s8>
{
static std::string text(const char* fmt, size_t len, s8 arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex((u8)arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'd')
{
return std::to_string((s32)arg);
}
else
{
throw "Invalid formatting (s8)";
}
return{};
}
};
template<>
struct get_fmt<s16>
{
static std::string text(const char* fmt, size_t len, s16 arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex((u16)arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'd')
{
return std::to_string((s32)arg);
}
else
{
throw "Invalid formatting (s16)";
}
return{};
}
};
template<>
struct get_fmt<s32>
{
static std::string text(const char* fmt, size_t len, s32 arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex((u32)arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'd')
{
return std::to_string(arg);
}
else
{
throw "Invalid formatting (s32)";
}
return{};
}
};
template<>
struct get_fmt<s64>
{
static std::string text(const char* fmt, size_t len, s64 arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex((u64)arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'd')
{
return std::to_string(arg);
}
else
{
throw "Invalid formatting (s64)";
}
return{};
}
};
template<>
struct get_fmt<float>
{
static std::string text(const char* fmt, size_t len, float arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex((u32&)arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'f')
{
return std::to_string(arg);
}
else
{
throw "Invalid formatting (float)";
}
return{};
}
};
template<>
struct get_fmt<double>
{
static std::string text(const char* fmt, size_t len, double arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex((u64&)arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'f')
{
return std::to_string(arg);
}
else
{
throw "Invalid formatting (double)";
}
return{};
}
};
template<>
struct get_fmt<bool>
{
static std::string text(const char* fmt, size_t len, bool arg)
{
if (fmt[len - 1] == 'x')
{
return to_hex(arg, get_fmt_precision(fmt, len));
}
else if (fmt[len - 1] == 'd')
{
return arg ? "1" : "0";
}
else if (fmt[len - 1] == 's')
{
return arg ? "true" : "false";
}
else
{
throw "Invalid formatting (bool)";
}
return{};
}
};
template<>
struct get_fmt<char*>
{
static std::string text(const char* fmt, size_t len, char* arg)
{
if (fmt[len - 1] == 's')
{
return arg;
}
else
{
throw "Invalid formatting (char*)";
}
return{};
}
};
template<>
struct get_fmt<const char*>
{
static std::string text(const char* fmt, size_t len, const char* arg)
{
if (fmt[len - 1] == 's')
{
return arg;
}
else
{
throw "Invalid formatting (const char*)";
}
return{};
}
};
template<size_t size>
struct get_fmt<const char[size], false>
{
static std::string text(const char* fmt, size_t len, const char(&arg)[size])
{
if (fmt[len - 1] == 's')
{
return std::string(arg, size);
}
else
{
throw "Invalid formatting (const char[size])";
}
return{};
}
};
template<>
struct get_fmt<std::string>
{
static std::string text(const char* fmt, size_t len, const std::string& arg)
{
if (fmt[len - 1] == 's')
{
return arg;
}
else
{
throw "Invalid formatting (std::string)";
}
return{};
}
};
template<typename T, typename... Args>
static std::string format(const char* fmt, size_t len, const T& arg, Args... args)
{
const size_t fmt_start = get_fmt_start(fmt, len);
const size_t fmt_len = get_fmt_len(fmt + fmt_start, len - fmt_start);
const size_t fmt_end = fmt_start + fmt_len;
return std::string(fmt, fmt_start) + get_fmt<T>::text(fmt + fmt_start, fmt_len, arg) + format(fmt + fmt_end, len - fmt_end, args...);
}
static std::string format(const char* fmt, size_t len)
{
const size_t fmt_start = get_fmt_start(fmt, len);
assert(fmt_start == len);
return std::string(fmt, len);
}
};
// formatting function with very limited functionality (compared to printf-like formatting) and be_t<> support
/*
Supported types:
u8, s8 (%x, %d)
u16, s16 (%x, %d)
u32, s32 (%x, %d)
u64, s64 (%x, %d)
float (%x, %f)
double (%x, %f)
bool (%x, %d, %s)
char*, const char*, const char[N], std::string (%s)
be_t<> of any appropriate type in this list
Supported formatting:
%d - decimal; only basic std::to_string() functionality
%x - hexadecimal; %.8x - hexadecimal with the precision (from .2 to .16)
%s - string; generates "true" or "false" for bool
%f - floating point; only basic std::to_string() functionality
Other features are not supported.
*/
template<typename... Args>
__forceinline static std::string format(const char* fmt, Args... args)
{
return detail::format(fmt, strlen(fmt), args...);
}
//convert a wxString to a std::string encoded in utf8
//CAUTION, only use this to interface with wxWidgets classes
std::string ToUTF8(const wxString& right);
//convert a std::string encoded in utf8 to a wxString
//CAUTION, only use this to interface with wxWidgets classes
wxString FromUTF8(const string& right);
wxString FromUTF8(const std::string& right);
//TODO: remove this after every snippet that uses it is gone
//WARNING: not fully compatible with CmpNoCase from wxString

View File

@ -14,8 +14,10 @@
void SetCurrentThreadDebugName(const char* threadName)
{
#ifdef _WIN32 // this is VS-specific way to set thread names for the debugger
#if defined(_MSC_VER) // this is VS-specific way to set thread names for the debugger
#pragma pack(push,8)
struct THREADNAME_INFO
{
DWORD dwType;
@ -23,6 +25,7 @@ void SetCurrentThreadDebugName(const char* threadName)
DWORD dwThreadID;
DWORD dwFlags;
} info;
#pragma pack(pop)
info.dwType = 0x1000;
@ -37,6 +40,7 @@ void SetCurrentThreadDebugName(const char* threadName)
__except (EXCEPTION_EXECUTE_HANDLER)
{
}
#endif
}

View File

@ -114,7 +114,7 @@ bool rRmdir(const std::string &dir)
if (int err = rmdir(dir.c_str()))
#endif
{
LOG_ERROR(GENERAL, "Error deleting directory %s: %i", dir.c_str(), GET_API_ERROR);
LOG_ERROR(GENERAL, "Error deleting directory %s: 0x%llx", dir.c_str(), (u64)GET_API_ERROR);
return false;
}
return true;
@ -149,7 +149,7 @@ bool rRemoveFile(const std::string &file)
if (int err = unlink(file.c_str()))
#endif
{
LOG_ERROR(GENERAL, "Error deleting %s: %i", file.c_str(), GET_API_ERROR);
LOG_ERROR(GENERAL, "Error deleting file %s: 0x%llx", file.c_str(), (u64)GET_API_ERROR);
return false;
}
return true;

View File

@ -108,7 +108,7 @@ s32 sceKernelCreateThread(
new_thread.SetStackSize(stackSize);
new_thread.SetName(name);
sceLibKernel.Error("*** New ARMv7 Thread [%s] (entry=0x%x): id = %d", name.c_str(), entry, id);
sceLibKernel.Error("*** New ARMv7 Thread [%s] (entry_addr=0x%x): id = %d", name.c_str(), entry.addr(), id);
new_thread.Run();

View File

@ -18,7 +18,7 @@ void XAudio2Thread::Init()
hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
if (FAILED(hr))
{
LOG_ERROR(GENERAL, "XAudio2Thread : CoInitializeEx() failed(0x%08x)", hr);
LOG_ERROR(GENERAL, "XAudio2Thread : CoInitializeEx() failed(0x%08x)", (u32)hr);
Emu.Pause();
return;
}
@ -26,7 +26,7 @@ void XAudio2Thread::Init()
hr = XAudio2Create(&m_xaudio2_instance, 0, XAUDIO2_DEFAULT_PROCESSOR);
if (FAILED(hr))
{
LOG_ERROR(GENERAL, "XAudio2Thread : XAudio2Create() failed(0x%08x)", hr);
LOG_ERROR(GENERAL, "XAudio2Thread : XAudio2Create() failed(0x%08x)", (u32)hr);
Emu.Pause();
return;
}
@ -34,7 +34,7 @@ void XAudio2Thread::Init()
hr = m_xaudio2_instance->CreateMasteringVoice(&m_master_voice);
if (FAILED(hr))
{
LOG_ERROR(GENERAL, "XAudio2Thread : CreateMasteringVoice() failed(0x%08x)", hr);
LOG_ERROR(GENERAL, "XAudio2Thread : CreateMasteringVoice() failed(0x%08x)", (u32)hr);
m_xaudio2_instance->Release();
Emu.Pause();
}
@ -57,7 +57,7 @@ void XAudio2Thread::Play()
HRESULT hr = m_source_voice->Start();
if (FAILED(hr))
{
LOG_ERROR(GENERAL, "XAudio2Thread : Start() failed(0x%08x)", hr);
LOG_ERROR(GENERAL, "XAudio2Thread : Start() failed(0x%08x)", (u32)hr);
Emu.Pause();
}
}
@ -68,7 +68,7 @@ void XAudio2Thread::Close()
HRESULT hr = m_source_voice->FlushSourceBuffers();
if (FAILED(hr))
{
LOG_ERROR(GENERAL, "XAudio2Thread : FlushSourceBuffers() failed(0x%08x)", hr);
LOG_ERROR(GENERAL, "XAudio2Thread : FlushSourceBuffers() failed(0x%08x)", (u32)hr);
Emu.Pause();
}
}
@ -78,7 +78,7 @@ void XAudio2Thread::Stop()
HRESULT hr = m_source_voice->Stop();
if (FAILED(hr))
{
LOG_ERROR(GENERAL, "XAudio2Thread : Stop() failed(0x%08x)", hr);
LOG_ERROR(GENERAL, "XAudio2Thread : Stop() failed(0x%08x)", (u32)hr);
Emu.Pause();
}
}
@ -99,7 +99,7 @@ void XAudio2Thread::Open(const void* src, int size)
hr = m_xaudio2_instance->CreateSourceVoice(&m_source_voice, &waveformatex, 0, XAUDIO2_DEFAULT_FREQ_RATIO);
if (FAILED(hr))
{
LOG_ERROR(GENERAL, "XAudio2Thread : CreateSourceVoice() failed(0x%08x)", hr);
LOG_ERROR(GENERAL, "XAudio2Thread : CreateSourceVoice() failed(0x%08x)", (u32)hr);
Emu.Pause();
return;
}
@ -125,7 +125,7 @@ void XAudio2Thread::AddData(const void* src, int size)
HRESULT hr = m_source_voice->SubmitSourceBuffer(&buffer);
if (FAILED(hr))
{
LOG_ERROR(GENERAL, "XAudio2Thread : AddData() failed(0x%08x)", hr);
LOG_ERROR(GENERAL, "XAudio2Thread : AddData() failed(0x%08x)", (u32)hr);
Emu.Pause();
}
}

View File

@ -4623,7 +4623,7 @@ private:
Emu.Pause();
for(uint i=0; i<32; ++i) LOG_NOTICE(PPU, "r%d = 0x%llx", i, CPU.GPR[i]);
for(uint i=0; i<32; ++i) LOG_NOTICE(PPU, "f%d = %llf", i, CPU.FPR[i]);
for(uint i=0; i<32; ++i) LOG_NOTICE(PPU, "f%d = %llf", i, CPU.FPR[i]._double);
for(uint i=0; i<32; ++i) LOG_NOTICE(PPU, "v%d = 0x%s [%s]", i, CPU.VPR[i].to_hex().c_str(), CPU.VPR[i].to_xyzw().c_str());
LOG_NOTICE(PPU, "CR = 0x%08x", CPU.CR.CR);
LOG_NOTICE(PPU, "LR = 0x%llx", CPU.LR);

View File

@ -111,7 +111,7 @@ void XInputPadHandler::Close()
{
active = false;
if (WaitForSingleObject(thread, THREAD_TIMEOUT) != WAIT_OBJECT_0)
LOG_ERROR(HLE, "XInput thread could not stop within %d milliseconds", THREAD_TIMEOUT);
LOG_ERROR(HLE, "XInput thread could not stop within %d milliseconds", (u32)THREAD_TIMEOUT);
thread = nullptr;
}

View File

@ -31,12 +31,12 @@ public:
template<typename... Targs> __noinline void Notice(const u32 id, const char* fmt, Targs... args) const
{
LogOutput(LogNotice, id, " : ", fmt::Format(fmt, args...));
LogOutput(LogNotice, id, " : ", fmt::format(fmt, args...));
}
template<typename... Targs> __noinline void Notice(const char* fmt, Targs... args) const
{
LogOutput(LogNotice, ": ", fmt::Format(fmt, args...));
LogOutput(LogNotice, ": ", fmt::format(fmt, args...));
}
template<typename... Targs> __forceinline void Log(const char* fmt, Targs... args) const
@ -57,42 +57,42 @@ public:
template<typename... Targs> __noinline void Success(const u32 id, const char* fmt, Targs... args) const
{
LogOutput(LogSuccess, id, " : ", fmt::Format(fmt, args...));
LogOutput(LogSuccess, id, " : ", fmt::format(fmt, args...));
}
template<typename... Targs> __noinline void Success(const char* fmt, Targs... args) const
{
LogOutput(LogSuccess, ": ", fmt::Format(fmt, args...));
LogOutput(LogSuccess, ": ", fmt::format(fmt, args...));
}
template<typename... Targs> __noinline void Warning(const u32 id, const char* fmt, Targs... args) const
{
LogOutput(LogWarning, id, " warning: ", fmt::Format(fmt, args...));
LogOutput(LogWarning, id, " warning: ", fmt::format(fmt, args...));
}
template<typename... Targs> __noinline void Warning(const char* fmt, Targs... args) const
{
LogOutput(LogWarning, " warning: ", fmt::Format(fmt, args...));
LogOutput(LogWarning, " warning: ", fmt::format(fmt, args...));
}
template<typename... Targs> __noinline void Error(const u32 id, const char* fmt, Targs... args) const
{
LogOutput(LogError, id, " error: ", fmt::Format(fmt, args...));
LogOutput(LogError, id, " error: ", fmt::format(fmt, args...));
}
template<typename... Targs> __noinline void Error(const char* fmt, Targs... args) const
{
LogOutput(LogError, " error: ", fmt::Format(fmt, args...));
LogOutput(LogError, " error: ", fmt::format(fmt, args...));
}
template<typename... Targs> __noinline void Todo(const u32 id, const char* fmt, Targs... args) const
{
LogOutput(LogError, id, " TODO: ", fmt::Format(fmt, args...));
LogOutput(LogError, id, " TODO: ", fmt::format(fmt, args...));
}
template<typename... Targs> __noinline void Todo(const char* fmt, Targs... args) const
{
LogOutput(LogError, " TODO: ", fmt::Format(fmt, args...));
LogOutput(LogError, " TODO: ", fmt::format(fmt, args...));
}
};

View File

@ -82,7 +82,7 @@ int cellCameraGetDeviceGUID()
int cellCameraGetType(s32 dev_num, vm::ptr<CellCameraType> type)
{
cellCamera->Warning("cellCameraGetType(dev_num=%d, type_addr=0x%x)", dev_num, type);
cellCamera->Warning("cellCameraGetType(dev_num=%d, type_addr=0x%x)", dev_num, type.addr());
if (!cellCameraInstance.m_bInitialized)
return CELL_CAMERA_ERROR_NOT_INIT;

View File

@ -317,7 +317,7 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
thread t("Demuxer[" + std::to_string(dmux_id) + "] Thread", [dmux_ptr, sptr]()
{
Demuxer& dmux = *dmux_ptr;
cellDmux->Notice("Demuxer thread started (mem=0x%x, size=0x%x, cb=0x%x, arg=0x%x)", dmux.memAddr, dmux.memSize, dmux.cbFunc, dmux.cbArg);
cellDmux->Notice("Demuxer thread started (mem=0x%x, size=0x%x, cb_addr=0x%x, arg=0x%x)", dmux.memAddr, dmux.memSize, dmux.cbFunc.addr(), dmux.cbArg);
DemuxerTask task;
DemuxerStream stream = {};
@ -1000,7 +1000,7 @@ int cellDmuxEnableEs(u32 demuxerHandle, vm::ptr<const CellCodecEsFilterId> esFil
*esHandle = id;
cellDmux->Warning("*** New ES(dmux=%d, addr=0x%x, size=0x%x, filter(0x%x, 0x%x, 0x%x, 0x%x), cb=0x%x(arg=0x%x), spec=0x%x): id = %d",
demuxerHandle, es->memAddr, es->memSize, es->fidMajor, es->fidMinor, es->sup1, es->sup2, esCb->cbEsMsgFunc.addr(), es->cbArg, es->spec, id);
demuxerHandle, es->memAddr, es->memSize, es->fidMajor, es->fidMinor, es->sup1, es->sup2, esCb->cbEsMsgFunc.addr().ToLE(), es->cbArg, es->spec, id);
DemuxerTask task(dmuxEnableEs);
task.es.es = id;

View File

@ -20,7 +20,7 @@ int cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr<CellFontConfig> co
if (config->FileCache.size < 24)
return CELL_FONT_ERROR_INVALID_PARAMETER;
if (config->flags != 0)
cellFont->Warning("cellFontInitializeWithRevision: Unknown flags (0x%x)", config->flags);
cellFont->Warning("cellFontInitializeWithRevision: Unknown flags (0x%x)", config->flags.ToLE());
s_fontInternalInstance->m_buffer_addr = config->FileCache.buffer_addr;
s_fontInternalInstance->m_buffer_size = config->FileCache.size;
@ -168,12 +168,12 @@ int cellFontOpenFontset(PPUThread& CPU, vm::ptr<CellFontLibrary> library, vm::pt
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_RSANS2_SET:
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_VAGR2_SET:
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_VAGR2_SET:
cellFont->Warning("cellFontOpenFontset: fontType->type = %d not supported yet. RD-R-LATIN.TTF will be used instead.", fontType->type);
cellFont->Warning("cellFontOpenFontset: fontType->type = %d not supported yet. RD-R-LATIN.TTF will be used instead.", fontType->type.ToLE());
file = "/dev_flash/data/font/SCE-PS3-RD-R-LATIN.TTF";
break;
default:
cellFont->Warning("cellFontOpenFontset: fontType->type = %d not supported.", fontType->type);
cellFont->Warning("cellFontOpenFontset: fontType->type = %d not supported.", fontType->type.ToLE());
return CELL_FONT_ERROR_NO_SUPPORT_FONTSET;
}

View File

@ -272,7 +272,7 @@ int cellGameDataCheckCreate2(PPUThread& CPU, u32 version, vm::ptr<const char> di
if (cbSet->setParam)
{
// TODO: write PARAM.SFO from cbSet
cellGame->Todo("cellGameDataCheckCreate(2)(): writing PARAM.SFO parameters (addr=0x%x)", cbSet->setParam.addr());
cellGame->Todo("cellGameDataCheckCreate(2)(): writing PARAM.SFO parameters (addr=0x%x)", cbSet->setParam.addr().ToLE());
}
switch ((s32)cbResult->result)

View File

@ -190,10 +190,9 @@ int cellGemGetInfo()
return CELL_OK;
}
// Should int be used, even when type is int_32t (s32)?
s32 cellGemGetMemorySize(be_t<s32> max_connect)
s32 cellGemGetMemorySize(s32 max_connect)
{
cellGem->Warning("cellGemGetMemorySize(max_connect=%i)", max_connect);
cellGem->Warning("cellGemGetMemorySize(max_connect=%d)", max_connect);
if (max_connect > CELL_GEM_MAX_NUM)
return CELL_GEM_ERROR_INVALID_PARAMETER;

View File

@ -1212,7 +1212,7 @@ int CreateInterlaceTable(u32 ea_addr, float srcH, float dstH, CellRescTableEleme
int cellRescCreateInterlaceTable(u32 ea_addr, float srcH, CellRescTableElement depth, int length)
{
cellResc->Warning("cellRescCreateInterlaceTable(ea_addr=0x%x, depth = %i, length = %i)", ea_addr, depth, length);
cellResc->Warning("cellRescCreateInterlaceTable(ea_addr=0x%x, srcH=%f, depth=%d, length=%d)", ea_addr, srcH, depth, length);
if (!s_rescInternalInstance->m_bInitialized)
{

View File

@ -382,7 +382,7 @@ int cellRtcSetTime_t(vm::ptr<CellRtcDateTime> pDateTime, u64 iTime)
int cellRtcSetWin32FileTime(vm::ptr<CellRtcDateTime> pDateTime, u64 ulWin32FileTime)
{
cellRtc->Log("cellRtcSetWin32FileTime(pDateTime=0x%x, ulWin32FileTime=0x%llx)", pDateTime, ulWin32FileTime);
cellRtc->Log("cellRtcSetWin32FileTime(pDateTime_addr=0x%x, ulWin32FileTime=0x%llx)", pDateTime.addr(), ulWin32FileTime);
rDateTime date_time = rDateTime((time_t)ulWin32FileTime);

View File

@ -94,7 +94,7 @@ int cellSailDescriptorIsAutoSelection(vm::ptr<CellSailDescriptor> pSelf)
return CELL_OK;
}
int cellSailDescriptorCreateDatabase(vm::ptr<CellSailDescriptor> pSelf, vm::ptr<void> pDatabase, be_t<u32> size, be_t<u64> arg)
int cellSailDescriptorCreateDatabase(vm::ptr<CellSailDescriptor> pSelf, vm::ptr<void> pDatabase, u32 size, u64 arg)
{
cellSail->Warning("cellSailDescriptorCreateDatabase(pSelf=0x%x, pDatabase=0x%x, size=0x%x, arg=0x%x", pSelf.addr(), pDatabase.addr(), size, arg);
@ -107,7 +107,7 @@ int cellSailDescriptorCreateDatabase(vm::ptr<CellSailDescriptor> pSelf, vm::ptr<
break;
}
default:
cellSail->Error("Unhandled stream type: %d", pSelf->streamType);
cellSail->Error("Unhandled stream type: %d", pSelf->streamType.ToLE());
}
return CELL_OK;

View File

@ -23,8 +23,7 @@ std::vector<SSPlayer> ssp;
int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, vm::ptr<float> addr, u32 samples)
{
libmixer->Log("cellAANAddData(handle=%d, port=%d, offset=0x%x, addr=0x%x, samples=%d)",
aan_handle, aan_port, offset, addr.addr(), samples);
libmixer->Log("cellAANAddData(handle=%d, port=%d, offset=0x%x, addr_addr=0x%x, samples=%d)", aan_handle, aan_port, offset, addr.addr(), samples);
u32 type = aan_port >> 16;
u32 port = aan_port & 0xffff;
@ -45,8 +44,7 @@ int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, vm::ptr<float> addr
if (aan_handle != 0x11111111 || samples != 256 || !type || offset != 0)
{
libmixer->Error("cellAANAddData(handle=%d, port=%d, offset=0x%x, addr=0x%x, samples=%d): invalid parameters",
aan_handle, aan_port, offset, addr, samples);
libmixer->Error("cellAANAddData(handle=%d, port=%d, offset=0x%x, addr_addr=0x%x, samples=%d): invalid parameters", aan_handle, aan_port, offset, addr.addr(), samples);
return CELL_LIBMIXER_ERROR_INVALID_PARAMATER;
}

View File

@ -311,7 +311,7 @@ int sceNpBasicAddFriend()
int sceNpBasicGetFriendListEntryCount(vm::ptr<u32> count)
{
sceNp->Warning("sceNpBasicGetFriendListEntryCount(count=%d)", count);
sceNp->Warning("sceNpBasicGetFriendListEntryCount(count_addr=0x%x)", count.addr());
if (!sceNpInstance.m_bSceNpInitialized)
return SCE_NP_BASIC_ERROR_NOT_INITIALIZED;
@ -476,7 +476,7 @@ int sceNpBasicGetClanMessageEntry(u32 index, vm::ptr<SceNpUserInfo> from)
int sceNpBasicGetMessageEntryCount(u32 type, vm::ptr<u32> count)
{
sceNp->Warning("sceNpBasicGetMessageEntryCount(type=%d, count=%d)", type, count);
sceNp->Warning("sceNpBasicGetMessageEntryCount(type=%d, count_addr=0x%x)", type, count.addr());
if (!sceNpInstance.m_bSceNpInitialized)
return SCE_NP_BASIC_ERROR_NOT_INITIALIZED;
@ -984,7 +984,7 @@ int sceNpManagerGetAccountAge()
int sceNpManagerGetContentRatingFlag(vm::ptr<u32> isRestricted, vm::ptr<u32> age)
{
sceNp->Warning("sceNpManagerGetContentRatingFlag(isRestricted=%d, age=%d)", isRestricted, age);
sceNp->Warning("sceNpManagerGetContentRatingFlag(isRestricted_addr=0x%x, age_addr=0x%x)", isRestricted.addr(), age.addr());
if (!sceNpInstance.m_bSceNpInitialized)
return SCE_NP_ERROR_NOT_INITIALIZED;

View File

@ -784,13 +784,13 @@ int sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil
if (!packed_stream || !packed_stream->IsOpened())
{
sys_fs->Error("'%s' not found! flags: 0x%08x", packed_file.c_str(), vfsRead);
sys_fs->Error("'%s' not found! flags: 0x%02x", packed_file.c_str(), vfsRead);
return CELL_ENOENT;
}
if (!unpacked_stream || !unpacked_stream->IsOpened())
{
sys_fs->Error("'%s' couldn't be created! flags: 0x%08x", unpacked_file.c_str(), vfsWrite);
sys_fs->Error("'%s' couldn't be created! flags: 0x%02x", unpacked_file.c_str(), vfsWrite);
return CELL_ENOENT;
}
@ -931,7 +931,7 @@ void fsAioRead(u32 fd, vm::ptr<CellFsAio> aio, int xid, vm::ptr<void(*)(vm::ptr<
file.Seek(old_pos);
sys_fs->Log("*** fsAioRead(fd=%d, offset=0x%llx, buf_addr=0x%x, size=0x%x, error=0x%x, res=0x%x, xid=0x%x)",
fd, (u64)aio->offset, aio->buf.addr(), (u64)aio->size, error, res, xid);
fd, (u64)aio->offset, aio->buf.addr().ToLE(), (u64)aio->size, error, res, xid);
}
if (func)

View File

@ -24,7 +24,8 @@ s32 lwmutex_create(sys_lwmutex_t& lwmutex, u32 protocol, u32 recursive, u64 name
lwmutex.sleep_queue = sq_id;
sq->set_full_name(fmt::Format("Lwmutex(%d, addr=0x%x)", sq_id, Memory.RealToVirtualAddr(&lwmutex)));
sys_lwmutex.Notice("*** lwmutex created [%s] (attribute=0x%x): sq_id = %d", std::string((const char*)&name_u64, 8).c_str(), protocol | recursive, sq_id);
// passing be_t<u32> (test)
sys_lwmutex.Notice("*** lwmutex created [%s] (attribute=0x%x): sq_id = %d", std::string((const char*)&name_u64, 8).c_str(), lwmutex.attribute, sq_id);
return CELL_OK;
}

View File

@ -16,12 +16,12 @@ Mutex::~Mutex()
{
if (u32 tid = owner.read_sync())
{
sys_mutex.Notice("Mutex(%d) was owned by thread %d (recursive=%d)", id, tid, recursive_count.load());
sys_mutex.Notice("Mutex(%d) was owned by thread %d (recursive=%d)", id.read_relaxed(), tid, recursive_count.load());
}
if (u32 count = queue.count())
{
sys_mutex.Notice("Mutex(%d) was waited by %d threads", id, count);
sys_mutex.Notice("Mutex(%d) was waited by %d threads", id.read_relaxed(), count);
}
}

View File

@ -71,7 +71,7 @@ struct sys_prx_module_info_t
{
be_t<u16> attributes;
be_t<u16> version;
s8 name[28];
char name[28];
be_t<u32> toc;
vm::bptr<sys_prx_library_info_t> exports_start;
vm::bptr<sys_prx_library_info_t> exports_end;

View File

@ -221,7 +221,7 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event))
}
else
{
LOG_ERROR(HLE, "PS3 executable not found in selected folder (%s)", ctrl.GetPath().wx_str());
LOG_ERROR(HLE, "PS3 executable not found in selected folder (%s)", fmt::ToUTF8(ctrl.GetPath())); // passing std::string (test)
}
}

View File

@ -190,7 +190,7 @@ void VHDDExplorer::OnDropFiles(wxDropFilesEvent& event)
for(int i=0; i<count; ++i)
{
LOG_NOTICE(HLE, "Importing '%s'", dropped[i].wx_str());
LOG_NOTICE(HLE, "Importing '%s'", fmt::ToUTF8(dropped[i]).c_str());
Import(fmt::ToUTF8(dropped[i]), fmt::ToUTF8(wxFileName(dropped[i]).GetFullName()));
}

View File

@ -125,14 +125,14 @@ namespace loader
m_stream->Seek(handler::get_stream_offset() + phdr.p_paddr.addr());
m_stream->Read(&module_info, sizeof(module_info));
LOG_ERROR(LOADER, "%s (%x):", module_info.name, (u32)module_info.toc);
info.name = std::string((const char*)module_info.name, 28);
info.name = std::string(module_info.name, 28);
info.rtoc = module_info.toc;
int import_count = (module_info.imports_end - module_info.imports_start) / sizeof(sys_prx_library_info_t);
if (import_count)
{
LOG_ERROR(LOADER, "**** Lib '%s'has %d imports!", module_info.name, import_count);
LOG_ERROR(LOADER, "**** Lib '%s' has %d imports!", module_info.name, import_count);
}
sys_prx_library_info_t lib;
@ -406,7 +406,8 @@ namespace loader
{
if (!vm::alloc(phdr.p_vaddr.addr(), (u32)phdr.p_memsz, vm::main))
{
LOG_ERROR(LOADER, "%s(): AllocFixed(0x%llx, 0x%x) failed", __FUNCTION__, phdr.p_vaddr, (u32)phdr.p_memsz);
// addr() has be_t<> type (test)
LOG_ERROR(LOADER, "%s(): AllocFixed(0x%llx, 0x%x) failed", __FUNCTION__, phdr.p_vaddr.addr(), (u32)phdr.p_memsz);
return loading_error;
}

View File

@ -1 +1,11 @@
#include "stdafx.h"
std::string u128::to_hex() const
{
return fmt::Format("%016llx%016llx", _u64[1], _u64[0]);
}
std::string u128::to_xyzw() const
{
return fmt::Format("x: %g y: %g z: %g w: %g", _f[3], _f[2], _f[1], _f[0]);
}

View File

@ -55,8 +55,8 @@ template<typename T> __forceinline T align(const T addr, int align)
return (addr + (align - 1)) & ~(align - 1);
}
#include "Utilities/StrFmt.h"
#include "Utilities/BEType.h"
#include "Utilities/StrFmt.h"
#define _PRGNAME_ "RPCS3"
#define _PRGVER_ "0.0.0.5"