mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 12:42:41 +01:00
Merge pull request #959 from Nekotekina/master
Experimental function fmt::format
This commit is contained in:
commit
f4c712dafc
@ -284,15 +284,9 @@ union _CRT_ALIGN(16) u128
|
|||||||
_u64[1] = _u64[0] = 0;
|
_u64[1] = _u64[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string to_hex() const
|
std::string to_hex() const;
|
||||||
{
|
|
||||||
return fmt::Format("%016llx%016llx", _u64[1], _u64[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string to_xyzw() 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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __forceinline u128 byteswap(const u128 val)
|
static __forceinline u128 byteswap(const u128 val)
|
||||||
{
|
{
|
||||||
@ -378,65 +372,97 @@ template<typename T, int size = sizeof(T)> struct se_t;
|
|||||||
|
|
||||||
template<typename T> struct se_t<T, 1>
|
template<typename T> struct se_t<T, 1>
|
||||||
{
|
{
|
||||||
static __forceinline T func(const T src)
|
static __forceinline u8 to_be(const T& src)
|
||||||
{
|
{
|
||||||
return src;
|
return (u8&)src;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __forceinline T from_be(const u8 src)
|
||||||
|
{
|
||||||
|
return (T&)src;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct se_t<T, 2>
|
template<typename T> struct se_t<T, 2>
|
||||||
{
|
{
|
||||||
static __forceinline T func(const T src)
|
static __forceinline u16 to_be(const T& src)
|
||||||
{
|
{
|
||||||
const u16 res = _byteswap_ushort((u16&)src);
|
return _byteswap_ushort((u16&)src);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __forceinline T from_be(const u16 src)
|
||||||
|
{
|
||||||
|
const u16 res = _byteswap_ushort(src);
|
||||||
return (T&)res;
|
return (T&)res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct se_t<T, 4>
|
template<typename T> struct se_t<T, 4>
|
||||||
{
|
{
|
||||||
static __forceinline T func(const T src)
|
static __forceinline u32 to_be(const T& src)
|
||||||
{
|
{
|
||||||
const u32 res = _byteswap_ulong((u32&)src);
|
return _byteswap_ulong((u32&)src);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __forceinline T from_be(const u32 src)
|
||||||
|
{
|
||||||
|
const u32 res = _byteswap_ulong(src);
|
||||||
return (T&)res;
|
return (T&)res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct se_t<T, 8>
|
template<typename T> struct se_t<T, 8>
|
||||||
{
|
{
|
||||||
static __forceinline T func(const T src)
|
static __forceinline u64 to_be(const T& src)
|
||||||
{
|
{
|
||||||
const u64 res = _byteswap_uint64((u64&)src);
|
return _byteswap_uint64((u64&)src);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __forceinline T from_be(const u64 src)
|
||||||
|
{
|
||||||
|
const u64 res = _byteswap_uint64(src);
|
||||||
return (T&)res;
|
return (T&)res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//template<typename T> T re(const T val) { T res; se_t<T>::func(res, val); return res; }
|
template<typename T> struct se_t<T, 16>
|
||||||
//template<typename T1, typename T2> void re(T1& dst, const T2 val) { se_t<T1>::func(dst, val); }
|
|
||||||
|
|
||||||
template<typename T, u64 _value, int size = sizeof(T)> struct const_se_t;
|
|
||||||
template<typename T, u64 _value> struct const_se_t<T, _value, 1>
|
|
||||||
{
|
{
|
||||||
static const T value = (T)_value;
|
static __forceinline u128 to_be(const T& src)
|
||||||
|
{
|
||||||
|
return u128::byteswap((u128&)src);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __forceinline T from_be(const u128& src)
|
||||||
|
{
|
||||||
|
const u128 res = u128::byteswap(src);
|
||||||
|
return (T&)res;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, u64 _value> struct const_se_t<T, _value, 2>
|
template<typename T, T _value, size_t size = sizeof(T)> struct const_se_t;
|
||||||
|
|
||||||
|
template<u8 _value> struct const_se_t<u8, _value, 1>
|
||||||
{
|
{
|
||||||
static const T value = ((_value >> 8) & 0xff) | ((_value << 8) & 0xff00);
|
static const u8 value = _value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, u64 _value> struct const_se_t<T, _value, 4>
|
template<u16 _value> struct const_se_t<u16, _value, 2>
|
||||||
{
|
{
|
||||||
static const T value =
|
static const u16 value = ((_value >> 8) & 0xff) | ((_value << 8) & 0xff00);
|
||||||
|
};
|
||||||
|
|
||||||
|
template<u32 _value> struct const_se_t<u32, _value, 4>
|
||||||
|
{
|
||||||
|
static const u32 value =
|
||||||
((_value >> 24) & 0x000000ff) |
|
((_value >> 24) & 0x000000ff) |
|
||||||
((_value >> 8) & 0x0000ff00) |
|
((_value >> 8) & 0x0000ff00) |
|
||||||
((_value << 8) & 0x00ff0000) |
|
((_value << 8) & 0x00ff0000) |
|
||||||
((_value << 24) & 0xff000000);
|
((_value << 24) & 0xff000000);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, u64 _value> struct const_se_t<T, _value, 8>
|
template<u64 _value> struct const_se_t<u64, _value, 8>
|
||||||
{
|
{
|
||||||
static const T value =
|
static const u64 value =
|
||||||
((_value >> 56) & 0x00000000000000ff) |
|
((_value >> 56) & 0x00000000000000ff) |
|
||||||
((_value >> 40) & 0x000000000000ff00) |
|
((_value >> 40) & 0x000000000000ff00) |
|
||||||
((_value >> 24) & 0x0000000000ff0000) |
|
((_value >> 24) & 0x0000000000ff0000) |
|
||||||
@ -447,17 +473,53 @@ template<typename T, u64 _value> struct const_se_t<T, _value, 8>
|
|||||||
((_value << 56) & 0xff00000000000000);
|
((_value << 56) & 0xff00000000000000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T, size_t size = sizeof(T)>
|
||||||
|
struct be_storage_t
|
||||||
|
{
|
||||||
|
static_assert(!size, "Bad be_storage_t type");
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct be_storage_t<T, 1>
|
||||||
|
{
|
||||||
|
typedef u8 type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct be_storage_t<T, 2>
|
||||||
|
{
|
||||||
|
typedef u16 type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct be_storage_t<T, 4>
|
||||||
|
{
|
||||||
|
typedef u32 type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct be_storage_t<T, 8>
|
||||||
|
{
|
||||||
|
typedef u64 type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct be_storage_t<T, 16>
|
||||||
|
{
|
||||||
|
typedef u128 type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define IS_LE_MACHINE
|
||||||
|
|
||||||
template<typename T, typename T2 = T>
|
template<typename T, typename T2 = T>
|
||||||
class be_t
|
class be_t
|
||||||
{
|
{
|
||||||
static_assert(sizeof(T2) == 1 || sizeof(T2) == 2 || sizeof(T2) == 4 || sizeof(T2) == 8, "Bad be_t type");
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename std::remove_cv<T>::type type;
|
typedef typename std::remove_cv<T>::type type;
|
||||||
static const bool is_le_machine = true;
|
typedef typename be_storage_t<T2>::type stype;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type m_data;
|
stype m_data;
|
||||||
|
|
||||||
template<typename Tto, typename Tfrom, int mode>
|
template<typename Tto, typename Tfrom, int mode>
|
||||||
struct _convert
|
struct _convert
|
||||||
@ -490,62 +552,71 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const type& ToBE() const
|
const stype& ToBE() const
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
type ToLE() const
|
type ToLE() const
|
||||||
{
|
{
|
||||||
return se_t<type, sizeof(T2)>::func(m_data);
|
return se_t<type, sizeof(T2)>::from_be(m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FromBE(const type& value)
|
void FromBE(const stype& value)
|
||||||
{
|
{
|
||||||
m_data = value;
|
m_data = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FromLE(const type& value)
|
void FromLE(const type& value)
|
||||||
{
|
{
|
||||||
m_data = se_t<type, sizeof(T2)>::func(value);
|
m_data = se_t<type, sizeof(T2)>::to_be(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static be_t MakeFromLE(const type value)
|
static be_t MakeFromLE(const type& value)
|
||||||
{
|
{
|
||||||
type data = se_t<type, sizeof(T2)>::func(value);
|
stype data = se_t<type, sizeof(T2)>::to_be(value);
|
||||||
return (be_t&)data;
|
return (be_t&)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static be_t MakeFromBE(const type value)
|
static be_t MakeFromBE(const stype& value)
|
||||||
{
|
{
|
||||||
return (be_t&)value;
|
return (be_t&)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//make be_t from current machine byte ordering
|
//make be_t from current machine byte ordering
|
||||||
static be_t make(const type value)
|
static be_t make(const type& value)
|
||||||
{
|
{
|
||||||
return is_le_machine ? MakeFromLE(value) : MakeFromBE(value);
|
#ifdef IS_LE_MACHINE
|
||||||
|
return MakeFromLE(value);
|
||||||
|
#else
|
||||||
|
return MakeFromBE(value);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//get value in current machine byte ordering
|
//get value in current machine byte ordering
|
||||||
__forceinline type value() const
|
__forceinline type value() const
|
||||||
{
|
{
|
||||||
return is_le_machine ? ToLE() : ToBE();
|
#ifdef IS_LE_MACHINE
|
||||||
|
return ToLE();
|
||||||
|
#else
|
||||||
|
return ToBE();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//be_t() = default;
|
const stype& data() const
|
||||||
//be_t(const be_t& value) = default;
|
{
|
||||||
|
#ifdef IS_LE_MACHINE
|
||||||
//be_t(type value)
|
return ToBE();
|
||||||
//{
|
#else
|
||||||
// m_data = se_t<type, sizeof(T2)>::func(value);
|
return ToLE();
|
||||||
//}
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
be_t& operator = (const be_t& value) = default;
|
be_t& operator = (const be_t& value) = default;
|
||||||
|
|
||||||
be_t& operator = (type value)
|
be_t& operator = (const type& value)
|
||||||
{
|
{
|
||||||
m_data = se_t<type, sizeof(T2)>::func(value);
|
m_data = se_t<type, sizeof(T2)>::to_be(value);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -289,9 +289,7 @@ static __forceinline uint64_t InterlockedXor(volatile uint64_t* dest, uint64_t v
|
|||||||
|
|
||||||
static __forceinline uint32_t cntlz32(uint32_t arg)
|
static __forceinline uint32_t cntlz32(uint32_t arg)
|
||||||
{
|
{
|
||||||
#if defined(__GNUG__)
|
#if defined(_MSC_VER)
|
||||||
return __builtin_clzl(arg);
|
|
||||||
#else
|
|
||||||
unsigned long res;
|
unsigned long res;
|
||||||
if (!_BitScanReverse(&res, arg))
|
if (!_BitScanReverse(&res, arg))
|
||||||
{
|
{
|
||||||
@ -301,14 +299,21 @@ static __forceinline uint32_t cntlz32(uint32_t arg)
|
|||||||
{
|
{
|
||||||
return res ^ 31;
|
return res ^ 31;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (arg)
|
||||||
|
{
|
||||||
|
return __builtin_clzll((uint64_t)arg) - 32;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static __forceinline uint64_t cntlz64(uint64_t arg)
|
static __forceinline uint64_t cntlz64(uint64_t arg)
|
||||||
{
|
{
|
||||||
#if defined(__GNUG__)
|
#if defined(_MSC_VER)
|
||||||
return __builtin_clzll(arg);
|
|
||||||
#else
|
|
||||||
unsigned long res;
|
unsigned long res;
|
||||||
if (!_BitScanReverse64(&res, arg))
|
if (!_BitScanReverse64(&res, arg))
|
||||||
{
|
{
|
||||||
@ -318,6 +323,15 @@ static __forceinline uint64_t cntlz64(uint64_t arg)
|
|||||||
{
|
{
|
||||||
return res ^ 63;
|
return res ^ 63;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (arg)
|
||||||
|
{
|
||||||
|
return __builtin_clzll(arg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +138,6 @@ inline void log_message(Log::LogType type, Log::LogSeverity sev, const char* tex
|
|||||||
template<typename T, typename... Ts>
|
template<typename T, typename... Ts>
|
||||||
inline void log_message(Log::LogType type, Log::LogSeverity sev, const char* text, T arg, Ts... args)
|
inline void log_message(Log::LogType type, Log::LogSeverity sev, const char* text, 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);
|
Log::LogManager::getInstance().log(msg);
|
||||||
}
|
}
|
@ -1,7 +1,16 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "StrFmt.h"
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.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]);
|
||||||
|
}
|
||||||
|
|
||||||
extern const std::string fmt::placeholder = "???";
|
extern const std::string fmt::placeholder = "???";
|
||||||
|
|
||||||
std::string replace_first(const std::string& src, const std::string& from, const std::string& to)
|
std::string replace_first(const std::string& src, const std::string& from, const std::string& to)
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class wxString;
|
class wxString;
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace fmt{
|
namespace fmt
|
||||||
using std::string;
|
{
|
||||||
using std::ostream;
|
|
||||||
using std::ostringstream;
|
|
||||||
|
|
||||||
struct empty_t{};
|
struct empty_t{};
|
||||||
|
|
||||||
extern const string placeholder;
|
extern const std::string placeholder;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::string AfterLast(const std::string& source, T searchstr)
|
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
|
// `fmt::placeholder` after `pos` everything in `fmt` after pos is written
|
||||||
// to `os`. Then `arg` is written to `os` after appending a space character
|
// to `os`. Then `arg` is written to `os` after appending a space character
|
||||||
template<typename T>
|
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.write(fmt.data() + pos, fmt.size() - pos);
|
||||||
os << ' ' << arg;
|
os << ' ' << arg;
|
||||||
@ -77,10 +75,10 @@ namespace fmt{
|
|||||||
// inserted use `fmt::placeholder`. If there's not enough placeholders
|
// inserted use `fmt::placeholder`. If there's not enough placeholders
|
||||||
// the rest of the arguments are appended at the end, seperated by spaces
|
// the rest of the arguments are appended at the end, seperated by spaces
|
||||||
template<typename ... Args>
|
template<typename ... Args>
|
||||||
string SFormat(const string &fmt, Args&& ... parameters)
|
std::string SFormat(const std::string &fmt, Args&& ... parameters)
|
||||||
{
|
{
|
||||||
ostringstream os;
|
std::ostringstream os;
|
||||||
string::size_type pos = 0;
|
std::string::size_type pos = 0;
|
||||||
std::initializer_list<empty_t> { write(fmt, os, pos, parameters)... };
|
std::initializer_list<empty_t> { write(fmt, os, pos, parameters)... };
|
||||||
|
|
||||||
if (!fmt.empty())
|
if (!fmt.empty())
|
||||||
@ -88,7 +86,7 @@ namespace fmt{
|
|||||||
os.write(fmt.data() + pos, fmt.size() - pos);
|
os.write(fmt.data() + pos, fmt.size() - pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
string result = os.str();
|
std::string result = os.str();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,10 +96,10 @@ namespace fmt{
|
|||||||
|
|
||||||
//wrapper to deal with advance sprintf formating options with automatic length finding
|
//wrapper to deal with advance sprintf formating options with automatic length finding
|
||||||
template<typename ... Args>
|
template<typename ... Args>
|
||||||
string Format(const char* fmt, Args ... parameters)
|
std::string Format(const char* fmt, Args ... parameters)
|
||||||
{
|
{
|
||||||
size_t length = 256;
|
size_t length = 256;
|
||||||
string str;
|
std::string str;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -116,7 +114,7 @@ namespace fmt{
|
|||||||
#endif
|
#endif
|
||||||
if (printlen < length)
|
if (printlen < length)
|
||||||
{
|
{
|
||||||
str = string(buffptr.data(), printlen);
|
str = std::string(buffptr.data(), printlen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
length *= 2;
|
length *= 2;
|
||||||
@ -175,13 +173,509 @@ namespace fmt{
|
|||||||
return src;
|
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<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 (char[size])";
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 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{};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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...);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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*, std::string (%s)
|
||||||
|
be_t<> of any appropriate type in this list
|
||||||
|
enum 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
|
//convert a wxString to a std::string encoded in utf8
|
||||||
//CAUTION, only use this to interface with wxWidgets classes
|
//CAUTION, only use this to interface with wxWidgets classes
|
||||||
std::string ToUTF8(const wxString& right);
|
std::string ToUTF8(const wxString& right);
|
||||||
|
|
||||||
//convert a std::string encoded in utf8 to a wxString
|
//convert a std::string encoded in utf8 to a wxString
|
||||||
//CAUTION, only use this to interface with wxWidgets classes
|
//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
|
//TODO: remove this after every snippet that uses it is gone
|
||||||
//WARNING: not fully compatible with CmpNoCase from wxString
|
//WARNING: not fully compatible with CmpNoCase from wxString
|
||||||
|
@ -14,8 +14,10 @@
|
|||||||
|
|
||||||
void SetCurrentThreadDebugName(const char* threadName)
|
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)
|
#pragma pack(push,8)
|
||||||
|
|
||||||
struct THREADNAME_INFO
|
struct THREADNAME_INFO
|
||||||
{
|
{
|
||||||
DWORD dwType;
|
DWORD dwType;
|
||||||
@ -23,6 +25,7 @@ void SetCurrentThreadDebugName(const char* threadName)
|
|||||||
DWORD dwThreadID;
|
DWORD dwThreadID;
|
||||||
DWORD dwFlags;
|
DWORD dwFlags;
|
||||||
} info;
|
} info;
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
info.dwType = 0x1000;
|
info.dwType = 0x1000;
|
||||||
@ -37,6 +40,7 @@ void SetCurrentThreadDebugName(const char* threadName)
|
|||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ bool rRmdir(const std::string &dir)
|
|||||||
if (int err = rmdir(dir.c_str()))
|
if (int err = rmdir(dir.c_str()))
|
||||||
#endif
|
#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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -149,7 +149,7 @@ bool rRemoveFile(const std::string &file)
|
|||||||
if (int err = unlink(file.c_str()))
|
if (int err = unlink(file.c_str()))
|
||||||
#endif
|
#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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -288,7 +288,7 @@ int decrypt_data(rFile *in, rFile *out, EDAT_HEADER *edat, NPD_HEADER *npd, unsi
|
|||||||
if (!decrypt(hash_mode, crypto_mode, (npd->version == 4), enc_data, dec_data, length, key_result, iv, hash, hash_result))
|
if (!decrypt(hash_mode, crypto_mode, (npd->version == 4), enc_data, dec_data, length, key_result, iv, hash, hash_result))
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
LOG_WARNING(LOADER, "EDAT: Block at offset 0x%llx has invalid hash!", offset);
|
LOG_WARNING(LOADER, "EDAT: Block at offset 0x%llx has invalid hash!", (u64)offset);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -695,7 +695,7 @@ bool extract_data(rFile *input, rFile *output, const char* input_file_name, unsi
|
|||||||
LOG_NOTICE(LOADER, "SDAT HEADER");
|
LOG_NOTICE(LOADER, "SDAT HEADER");
|
||||||
LOG_NOTICE(LOADER, "SDAT flags: 0x%08X", EDAT->flags);
|
LOG_NOTICE(LOADER, "SDAT flags: 0x%08X", EDAT->flags);
|
||||||
LOG_NOTICE(LOADER, "SDAT block size: 0x%08X", EDAT->block_size);
|
LOG_NOTICE(LOADER, "SDAT block size: 0x%08X", EDAT->block_size);
|
||||||
LOG_NOTICE(LOADER, "SDAT file size: 0x%08X", EDAT->file_size);
|
LOG_NOTICE(LOADER, "SDAT file size: 0x%08X", (u64)EDAT->file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate SDAT key.
|
// Generate SDAT key.
|
||||||
@ -708,7 +708,7 @@ bool extract_data(rFile *input, rFile *output, const char* input_file_name, unsi
|
|||||||
LOG_NOTICE(LOADER, "EDAT HEADER");
|
LOG_NOTICE(LOADER, "EDAT HEADER");
|
||||||
LOG_NOTICE(LOADER, "EDAT flags: 0x%08X", EDAT->flags);
|
LOG_NOTICE(LOADER, "EDAT flags: 0x%08X", EDAT->flags);
|
||||||
LOG_NOTICE(LOADER, "EDAT block size: 0x%08X", EDAT->block_size);
|
LOG_NOTICE(LOADER, "EDAT block size: 0x%08X", EDAT->block_size);
|
||||||
LOG_NOTICE(LOADER, "EDAT file size: 0x%08X", EDAT->file_size);
|
LOG_NOTICE(LOADER, "EDAT file size: 0x%08X", (u64)EDAT->file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform header validation (EDAT only).
|
// Perform header validation (EDAT only).
|
||||||
|
@ -164,12 +164,12 @@ bool UnpackEntry(rFile& dec_pkg_f, const PKGEntry& entry, std::string dir)
|
|||||||
dec_pkg_f.Read(buf, entry.name_size);
|
dec_pkg_f.Read(buf, entry.name_size);
|
||||||
buf[entry.name_size] = 0;
|
buf[entry.name_size] = 0;
|
||||||
|
|
||||||
switch (entry.type.ToBE() >> 24)
|
switch (entry.type.data())
|
||||||
{
|
{
|
||||||
case PKG_FILE_ENTRY_NPDRM:
|
case se32(PKG_FILE_ENTRY_NPDRM):
|
||||||
case PKG_FILE_ENTRY_NPDRMEDAT:
|
case se32(PKG_FILE_ENTRY_NPDRMEDAT):
|
||||||
case PKG_FILE_ENTRY_SDAT:
|
case se32(PKG_FILE_ENTRY_SDAT):
|
||||||
case PKG_FILE_ENTRY_REGULAR:
|
case se32(PKG_FILE_ENTRY_REGULAR):
|
||||||
{
|
{
|
||||||
rFile out;
|
rFile out;
|
||||||
auto path = dir + std::string(buf, entry.name_size);
|
auto path = dir + std::string(buf, entry.name_size);
|
||||||
@ -199,7 +199,7 @@ bool UnpackEntry(rFile& dec_pkg_f, const PKGEntry& entry, std::string dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case PKG_FILE_ENTRY_FOLDER:
|
case se32(PKG_FILE_ENTRY_FOLDER):
|
||||||
{
|
{
|
||||||
auto path = dir + std::string(buf, entry.name_size);
|
auto path = dir + std::string(buf, entry.name_size);
|
||||||
if (!rExists(path) && !rMkdir(path))
|
if (!rExists(path) && !rMkdir(path))
|
||||||
@ -213,7 +213,7 @@ bool UnpackEntry(rFile& dec_pkg_f, const PKGEntry& entry, std::string dir)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
LOG_ERROR(LOADER, "PKG Loader: unknown PKG file entry: 0x%x", entry.type.ToLE());
|
LOG_ERROR(LOADER, "PKG Loader: unknown PKG file entry: 0x%x", entry.type);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ s32 sceKernelCreateThread(
|
|||||||
new_thread.SetStackSize(stackSize);
|
new_thread.SetStackSize(stackSize);
|
||||||
new_thread.SetName(name);
|
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();
|
new_thread.Run();
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ void XAudio2Thread::Init()
|
|||||||
hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
LOG_ERROR(GENERAL, "XAudio2Thread : CoInitializeEx() failed(0x%08x)", hr);
|
LOG_ERROR(GENERAL, "XAudio2Thread : CoInitializeEx() failed(0x%08x)", (u32)hr);
|
||||||
Emu.Pause();
|
Emu.Pause();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ void XAudio2Thread::Init()
|
|||||||
hr = XAudio2Create(&m_xaudio2_instance, 0, XAUDIO2_DEFAULT_PROCESSOR);
|
hr = XAudio2Create(&m_xaudio2_instance, 0, XAUDIO2_DEFAULT_PROCESSOR);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
LOG_ERROR(GENERAL, "XAudio2Thread : XAudio2Create() failed(0x%08x)", hr);
|
LOG_ERROR(GENERAL, "XAudio2Thread : XAudio2Create() failed(0x%08x)", (u32)hr);
|
||||||
Emu.Pause();
|
Emu.Pause();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ void XAudio2Thread::Init()
|
|||||||
hr = m_xaudio2_instance->CreateMasteringVoice(&m_master_voice);
|
hr = m_xaudio2_instance->CreateMasteringVoice(&m_master_voice);
|
||||||
if (FAILED(hr))
|
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();
|
m_xaudio2_instance->Release();
|
||||||
Emu.Pause();
|
Emu.Pause();
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ void XAudio2Thread::Play()
|
|||||||
HRESULT hr = m_source_voice->Start();
|
HRESULT hr = m_source_voice->Start();
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
LOG_ERROR(GENERAL, "XAudio2Thread : Start() failed(0x%08x)", hr);
|
LOG_ERROR(GENERAL, "XAudio2Thread : Start() failed(0x%08x)", (u32)hr);
|
||||||
Emu.Pause();
|
Emu.Pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ void XAudio2Thread::Close()
|
|||||||
HRESULT hr = m_source_voice->FlushSourceBuffers();
|
HRESULT hr = m_source_voice->FlushSourceBuffers();
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
LOG_ERROR(GENERAL, "XAudio2Thread : FlushSourceBuffers() failed(0x%08x)", hr);
|
LOG_ERROR(GENERAL, "XAudio2Thread : FlushSourceBuffers() failed(0x%08x)", (u32)hr);
|
||||||
Emu.Pause();
|
Emu.Pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ void XAudio2Thread::Stop()
|
|||||||
HRESULT hr = m_source_voice->Stop();
|
HRESULT hr = m_source_voice->Stop();
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
LOG_ERROR(GENERAL, "XAudio2Thread : Stop() failed(0x%08x)", hr);
|
LOG_ERROR(GENERAL, "XAudio2Thread : Stop() failed(0x%08x)", (u32)hr);
|
||||||
Emu.Pause();
|
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);
|
hr = m_xaudio2_instance->CreateSourceVoice(&m_source_voice, &waveformatex, 0, XAUDIO2_DEFAULT_FREQ_RATIO);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
LOG_ERROR(GENERAL, "XAudio2Thread : CreateSourceVoice() failed(0x%08x)", hr);
|
LOG_ERROR(GENERAL, "XAudio2Thread : CreateSourceVoice() failed(0x%08x)", (u32)hr);
|
||||||
Emu.Pause();
|
Emu.Pause();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ void XAudio2Thread::AddData(const void* src, int size)
|
|||||||
HRESULT hr = m_source_voice->SubmitSourceBuffer(&buffer);
|
HRESULT hr = m_source_voice->SubmitSourceBuffer(&buffer);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
LOG_ERROR(GENERAL, "XAudio2Thread : AddData() failed(0x%08x)", hr);
|
LOG_ERROR(GENERAL, "XAudio2Thread : AddData() failed(0x%08x)", (u32)hr);
|
||||||
Emu.Pause();
|
Emu.Pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4623,7 +4623,7 @@ private:
|
|||||||
Emu.Pause();
|
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, "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());
|
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, "CR = 0x%08x", CPU.CR.CR);
|
||||||
LOG_NOTICE(PPU, "LR = 0x%llx", CPU.LR);
|
LOG_NOTICE(PPU, "LR = 0x%llx", CPU.LR);
|
||||||
|
@ -141,7 +141,7 @@ bool RawSPUThread::Write32(const u64 addr, const u32 value)
|
|||||||
{
|
{
|
||||||
// calling Exec() directly in SIGSEGV handler may cause problems
|
// calling Exec() directly in SIGSEGV handler may cause problems
|
||||||
// (probably because Exec() creates new thread, faults of this thread aren't handled by this handler anymore)
|
// (probably because Exec() creates new thread, faults of this thread aren't handled by this handler anymore)
|
||||||
Emu.GetCallbackManager().Async([this]()
|
Emu.GetCallbackManager().Async([this](PPUThread& PPU)
|
||||||
{
|
{
|
||||||
SPU.Status.SetValue(SPU_STATUS_RUNNING);
|
SPU.Status.SetValue(SPU_STATUS_RUNNING);
|
||||||
Exec();
|
Exec();
|
||||||
|
@ -111,7 +111,7 @@ void XInputPadHandler::Close()
|
|||||||
{
|
{
|
||||||
active = false;
|
active = false;
|
||||||
if (WaitForSingleObject(thread, THREAD_TIMEOUT) != WAIT_OBJECT_0)
|
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;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ namespace vm
|
|||||||
public:
|
public:
|
||||||
typedef RT(*type)(T...);
|
typedef RT(*type)(T...);
|
||||||
|
|
||||||
RT call(CPUThread& CPU, T... args) const; // defined in CB_FUNC.h, call using specified CPU thread context
|
RT operator()(CPUThread& CPU, T... args) const; // defined in CB_FUNC.h, call using specified CPU thread context
|
||||||
|
|
||||||
RT operator()(T... args) const; // defined in CB_FUNC.h, call using current CPU thread context
|
RT operator()(T... args) const; // defined in CB_FUNC.h, call using current CPU thread context
|
||||||
|
|
||||||
|
@ -289,9 +289,9 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
|
|||||||
if (m_flip_handler)
|
if (m_flip_handler)
|
||||||
{
|
{
|
||||||
auto cb = m_flip_handler;
|
auto cb = m_flip_handler;
|
||||||
Emu.GetCallbackManager().Async([cb]()
|
Emu.GetCallbackManager().Async([cb](PPUThread& CPU)
|
||||||
{
|
{
|
||||||
cb(1);
|
cb(CPU, 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2201,9 +2201,9 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
|
|||||||
{
|
{
|
||||||
const u32 cause = ARGS(0);
|
const u32 cause = ARGS(0);
|
||||||
auto cb = m_user_handler;
|
auto cb = m_user_handler;
|
||||||
Emu.GetCallbackManager().Async([cb, cause]()
|
Emu.GetCallbackManager().Async([cb, cause](PPUThread& CPU)
|
||||||
{
|
{
|
||||||
cb(cause);
|
cb(CPU, cause);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2370,9 +2370,9 @@ void RSXThread::Task()
|
|||||||
if (m_vblank_handler)
|
if (m_vblank_handler)
|
||||||
{
|
{
|
||||||
auto cb = m_vblank_handler;
|
auto cb = m_vblank_handler;
|
||||||
Emu.GetCallbackManager().Async([cb]()
|
Emu.GetCallbackManager().Async([cb](PPUThread& CPU)
|
||||||
{
|
{
|
||||||
cb(1);
|
cb(CPU, 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -163,18 +163,19 @@ namespace cb_detail
|
|||||||
namespace vm
|
namespace vm
|
||||||
{
|
{
|
||||||
template<typename AT, typename RT, typename... T>
|
template<typename AT, typename RT, typename... T>
|
||||||
__forceinline RT _ptr_base<RT(*)(T...), 1, AT>::call(CPUThread& CPU, T... args) const
|
__forceinline RT _ptr_base<RT(*)(T...), 1, AT>::operator()(CPUThread& CPU, T... args) const
|
||||||
{
|
{
|
||||||
const u32 pc = vm::get_ref<be_t<u32>>((u32)m_addr);
|
const u32 pc = vm::get_ref<be_t<u32>>((u32)m_addr);
|
||||||
const u32 rtoc = vm::get_ref<be_t<u32>>((u32)m_addr + 4);
|
const u32 rtoc = vm::get_ref<be_t<u32>>((u32)m_addr + 4);
|
||||||
|
|
||||||
|
assert(CPU.GetType() == CPU_THREAD_PPU);
|
||||||
return cb_detail::_func_caller<RT, T...>::call(static_cast<PPUThread&>(CPU), pc, rtoc, args...);
|
return cb_detail::_func_caller<RT, T...>::call(static_cast<PPUThread&>(CPU), pc, rtoc, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename AT, typename RT, typename... T>
|
template<typename AT, typename RT, typename... T>
|
||||||
__forceinline RT _ptr_base<RT(*)(T...), 1, AT>::operator()(T... args) const
|
__forceinline RT _ptr_base<RT(*)(T...), 1, AT>::operator()(T... args) const
|
||||||
{
|
{
|
||||||
return call(GetCurrentPPUThread(), args...);
|
return operator()(GetCurrentPPUThread(), args...);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,25 +7,33 @@
|
|||||||
#include "Emu/ARMv7/ARMv7Thread.h"
|
#include "Emu/ARMv7/ARMv7Thread.h"
|
||||||
#include "Callback.h"
|
#include "Callback.h"
|
||||||
|
|
||||||
void CallbackManager::Register(const std::function<s32()>& func)
|
void CallbackManager::Register(const std::function<s32(PPUThread& PPU)>& func)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
m_cb_list.push_back(func);
|
m_cb_list.push_back([=](CPUThread& CPU) -> s32
|
||||||
|
{
|
||||||
|
assert(CPU.GetType() == CPU_THREAD_PPU);
|
||||||
|
return func(static_cast<PPUThread&>(CPU));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallbackManager::Async(const std::function<void()>& func)
|
void CallbackManager::Async(const std::function<void(PPUThread& PPU)>& func)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
m_async_list.push_back(func);
|
m_async_list.push_back([=](CPUThread& CPU)
|
||||||
|
{
|
||||||
|
assert(CPU.GetType() == CPU_THREAD_PPU);
|
||||||
|
func(static_cast<PPUThread&>(CPU));
|
||||||
|
});
|
||||||
|
|
||||||
m_cb_thread->Notify();
|
m_cb_thread->Notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CallbackManager::Check(s32& result)
|
bool CallbackManager::Check(CPUThread& CPU, s32& result)
|
||||||
{
|
{
|
||||||
std::function<s32()> func = nullptr;
|
std::function<s32(CPUThread& CPU)> func;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
@ -38,7 +46,7 @@ bool CallbackManager::Check(s32& result)
|
|||||||
|
|
||||||
if (func)
|
if (func)
|
||||||
{
|
{
|
||||||
result = func();
|
result = func(CPU);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -80,7 +88,7 @@ void CallbackManager::Init()
|
|||||||
|
|
||||||
while (!Emu.IsStopped())
|
while (!Emu.IsStopped())
|
||||||
{
|
{
|
||||||
std::function<void()> func = nullptr;
|
std::function<void(CPUThread& CPU)> func;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
@ -93,9 +101,10 @@ void CallbackManager::Init()
|
|||||||
|
|
||||||
if (func)
|
if (func)
|
||||||
{
|
{
|
||||||
func();
|
func(*m_cb_thread);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cb_thread->WaitForAnySignal();
|
m_cb_thread->WaitForAnySignal();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class CPUThread;
|
class CPUThread;
|
||||||
|
class PPUThread;
|
||||||
|
|
||||||
class CallbackManager
|
class CallbackManager
|
||||||
{
|
{
|
||||||
std::vector<std::function<s32()>> m_cb_list;
|
std::vector<std::function<s32(CPUThread& CPU)>> m_cb_list;
|
||||||
std::vector<std::function<void()>> m_async_list;
|
std::vector<std::function<void(CPUThread& CPU)>> m_async_list;
|
||||||
CPUThread* m_cb_thread;
|
CPUThread* m_cb_thread;
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Register(const std::function<s32()>& func); // register callback (called in Check() method)
|
void Register(const std::function<s32(PPUThread& PPU)>& func); // register callback (called in Check() method)
|
||||||
|
|
||||||
void Async(const std::function<void()>& func); // register callback for callback thread (called immediately)
|
void Async(const std::function<void(PPUThread& PPU)>& func); // register callback for callback thread (called immediately)
|
||||||
|
|
||||||
bool Check(s32& result); // call one callback registered by Register() method
|
bool Check(CPUThread& CPU, s32& result); // call one callback registered by Register() method
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@ public:
|
|||||||
|
|
||||||
template<typename... Targs> __noinline void Notice(const u32 id, const char* fmt, Targs... args) const
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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...));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ next:
|
|||||||
buf_size -= adec.reader.size;
|
buf_size -= adec.reader.size;
|
||||||
res += adec.reader.size;
|
res += adec.reader.size;
|
||||||
|
|
||||||
adec.cbFunc.call(*adec.adecCb, adec.id, CELL_ADEC_MSG_TYPE_AUDONE, adec.task.au.auInfo_addr, adec.cbArg);
|
adec.cbFunc(*adec.adecCb, adec.id, CELL_ADEC_MSG_TYPE_AUDONE, adec.task.au.auInfo_addr, adec.cbArg);
|
||||||
|
|
||||||
adec.job.pop(adec.task);
|
adec.job.pop(adec.task);
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ u32 adecOpen(AudioDecoder* adec_ptr)
|
|||||||
{
|
{
|
||||||
// TODO: finalize
|
// TODO: finalize
|
||||||
cellAdec->Warning("adecEndSeq:");
|
cellAdec->Warning("adecEndSeq:");
|
||||||
adec.cbFunc.call(*adec.adecCb, adec.id, CELL_ADEC_MSG_TYPE_SEQDONE, CELL_OK, adec.cbArg);
|
adec.cbFunc(*adec.adecCb, adec.id, CELL_ADEC_MSG_TYPE_SEQDONE, CELL_OK, adec.cbArg);
|
||||||
|
|
||||||
adec.just_finished = true;
|
adec.just_finished = true;
|
||||||
break;
|
break;
|
||||||
@ -455,12 +455,12 @@ u32 adecOpen(AudioDecoder* adec_ptr)
|
|||||||
if (adec.frames.push(frame, &adec.is_closed))
|
if (adec.frames.push(frame, &adec.is_closed))
|
||||||
{
|
{
|
||||||
frame.data = nullptr; // to prevent destruction
|
frame.data = nullptr; // to prevent destruction
|
||||||
adec.cbFunc.call(*adec.adecCb, adec.id, CELL_ADEC_MSG_TYPE_PCMOUT, CELL_OK, adec.cbArg);
|
adec.cbFunc(*adec.adecCb, adec.id, CELL_ADEC_MSG_TYPE_PCMOUT, CELL_OK, adec.cbArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adec.cbFunc.call(*adec.adecCb, adec.id, CELL_ADEC_MSG_TYPE_AUDONE, task.au.auInfo_addr, adec.cbArg);
|
adec.cbFunc(*adec.adecCb, adec.id, CELL_ADEC_MSG_TYPE_AUDONE, task.au.auInfo_addr, adec.cbArg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ int cellCameraGetDeviceGUID()
|
|||||||
|
|
||||||
int cellCameraGetType(s32 dev_num, vm::ptr<CellCameraType> type)
|
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)
|
if (!cellCameraInstance.m_bInitialized)
|
||||||
return CELL_CAMERA_ERROR_NOT_INIT;
|
return CELL_CAMERA_ERROR_NOT_INIT;
|
||||||
|
@ -83,7 +83,7 @@ PesHeader::PesHeader(DemuxerStream& stream)
|
|||||||
|
|
||||||
ElementaryStream::ElementaryStream(Demuxer* dmux, u32 addr, u32 size, u32 fidMajor, u32 fidMinor, u32 sup1, u32 sup2, vm::ptr<CellDmuxCbEsMsg> cbFunc, u32 cbArg, u32 spec)
|
ElementaryStream::ElementaryStream(Demuxer* dmux, u32 addr, u32 size, u32 fidMajor, u32 fidMinor, u32 sup1, u32 sup2, vm::ptr<CellDmuxCbEsMsg> cbFunc, u32 cbArg, u32 spec)
|
||||||
: dmux(dmux)
|
: dmux(dmux)
|
||||||
, memAddr(a128(addr))
|
, memAddr(align(addr, 128))
|
||||||
, memSize(size - (addr - memAddr))
|
, memSize(size - (addr - memAddr))
|
||||||
, fidMajor(fidMajor)
|
, fidMajor(fidMajor)
|
||||||
, fidMinor(fidMinor)
|
, fidMinor(fidMinor)
|
||||||
@ -92,7 +92,7 @@ ElementaryStream::ElementaryStream(Demuxer* dmux, u32 addr, u32 size, u32 fidMaj
|
|||||||
, cbFunc(cbFunc)
|
, cbFunc(cbFunc)
|
||||||
, cbArg(cbArg)
|
, cbArg(cbArg)
|
||||||
, spec(spec)
|
, spec(spec)
|
||||||
, put(a128(addr))
|
, put(align(addr, 128))
|
||||||
, put_count(0)
|
, put_count(0)
|
||||||
, got_count(0)
|
, got_count(0)
|
||||||
, released(0)
|
, released(0)
|
||||||
@ -184,7 +184,7 @@ void ElementaryStream::push_au(u32 size, u64 dts, u64 pts, u64 userdata, bool ra
|
|||||||
|
|
||||||
addr = put;
|
addr = put;
|
||||||
|
|
||||||
put = a128(put + 128 + size);
|
put = align(put + 128 + size, 128);
|
||||||
|
|
||||||
put_count++;
|
put_count++;
|
||||||
}
|
}
|
||||||
@ -317,7 +317,7 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
|
|||||||
thread t("Demuxer[" + std::to_string(dmux_id) + "] Thread", [dmux_ptr, sptr]()
|
thread t("Demuxer[" + std::to_string(dmux_id) + "] Thread", [dmux_ptr, sptr]()
|
||||||
{
|
{
|
||||||
Demuxer& dmux = *dmux_ptr;
|
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;
|
DemuxerTask task;
|
||||||
DemuxerStream stream = {};
|
DemuxerStream stream = {};
|
||||||
@ -347,10 +347,10 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
|
|||||||
if (!stream.peek(code))
|
if (!stream.peek(code))
|
||||||
{
|
{
|
||||||
// demuxing finished
|
// demuxing finished
|
||||||
auto dmuxMsg = vm::ptr<CellDmuxMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
|
auto dmuxMsg = vm::ptr<CellDmuxMsg>::make(dmux.memAddr + (cb_add ^= 16));
|
||||||
dmuxMsg->msgType = CELL_DMUX_MSG_TYPE_DEMUX_DONE;
|
dmuxMsg->msgType = CELL_DMUX_MSG_TYPE_DEMUX_DONE;
|
||||||
dmuxMsg->supplementalInfo = stream.userdata;
|
dmuxMsg->supplementalInfo = stream.userdata;
|
||||||
dmux.cbFunc.call(*dmux.dmuxCb, dmux.id, dmuxMsg, dmux.cbArg);
|
dmux.cbFunc(*dmux.dmuxCb, dmux.id, dmuxMsg, dmux.cbArg);
|
||||||
|
|
||||||
dmux.is_running = false;
|
dmux.is_running = false;
|
||||||
continue;
|
continue;
|
||||||
@ -497,10 +497,10 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
|
|||||||
|
|
||||||
//cellDmux->Notice("ATX AU pushed (ats=0x%llx, frame_size=%d)", ((be_t<u64>*)data)->ToLE(), frame_size);
|
//cellDmux->Notice("ATX AU pushed (ats=0x%llx, frame_size=%d)", ((be_t<u64>*)data)->ToLE(), frame_size);
|
||||||
|
|
||||||
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
|
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(dmux.memAddr + (cb_add ^= 16));
|
||||||
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_AU_FOUND;
|
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_AU_FOUND;
|
||||||
esMsg->supplementalInfo = stream.userdata;
|
esMsg->supplementalInfo = stream.userdata;
|
||||||
es.cbFunc.call(*dmux.dmuxCb, dmux.id, es.id, esMsg, es.cbArg);
|
es.cbFunc(*dmux.dmuxCb, dmux.id, es.id, esMsg, es.cbArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -562,10 +562,10 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
|
|||||||
es.push_au(old_size, es.last_dts, es.last_pts, stream.userdata, false /* TODO: set correct value */, 0);
|
es.push_au(old_size, es.last_dts, es.last_pts, stream.userdata, false /* TODO: set correct value */, 0);
|
||||||
|
|
||||||
// callback
|
// callback
|
||||||
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
|
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(dmux.memAddr + (cb_add ^= 16));
|
||||||
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_AU_FOUND;
|
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_AU_FOUND;
|
||||||
esMsg->supplementalInfo = stream.userdata;
|
esMsg->supplementalInfo = stream.userdata;
|
||||||
es.cbFunc.call(*dmux.dmuxCb, dmux.id, es.id, esMsg, es.cbArg);
|
es.cbFunc(*dmux.dmuxCb, dmux.id, es.id, esMsg, es.cbArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pes.has_ts)
|
if (pes.has_ts)
|
||||||
@ -634,10 +634,10 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
|
|||||||
case dmuxResetStream:
|
case dmuxResetStream:
|
||||||
case dmuxResetStreamAndWaitDone:
|
case dmuxResetStreamAndWaitDone:
|
||||||
{
|
{
|
||||||
auto dmuxMsg = vm::ptr<CellDmuxMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
|
auto dmuxMsg = vm::ptr<CellDmuxMsg>::make(dmux.memAddr + (cb_add ^= 16));
|
||||||
dmuxMsg->msgType = CELL_DMUX_MSG_TYPE_DEMUX_DONE;
|
dmuxMsg->msgType = CELL_DMUX_MSG_TYPE_DEMUX_DONE;
|
||||||
dmuxMsg->supplementalInfo = stream.userdata;
|
dmuxMsg->supplementalInfo = stream.userdata;
|
||||||
dmux.cbFunc.call(*dmux.dmuxCb, dmux.id, dmuxMsg, dmux.cbArg);
|
dmux.cbFunc(*dmux.dmuxCb, dmux.id, dmuxMsg, dmux.cbArg);
|
||||||
|
|
||||||
stream = {};
|
stream = {};
|
||||||
dmux.is_running = false;
|
dmux.is_running = false;
|
||||||
@ -722,10 +722,10 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
|
|||||||
es.push_au(old_size, es.last_dts, es.last_pts, stream.userdata, false, 0);
|
es.push_au(old_size, es.last_dts, es.last_pts, stream.userdata, false, 0);
|
||||||
|
|
||||||
// callback
|
// callback
|
||||||
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
|
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(dmux.memAddr + (cb_add ^= 16));
|
||||||
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_AU_FOUND;
|
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_AU_FOUND;
|
||||||
esMsg->supplementalInfo = stream.userdata;
|
esMsg->supplementalInfo = stream.userdata;
|
||||||
es.cbFunc.call(*dmux.dmuxCb, dmux.id, es.id, esMsg, es.cbArg);
|
es.cbFunc(*dmux.dmuxCb, dmux.id, es.id, esMsg, es.cbArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (es.raw_data.size())
|
if (es.raw_data.size())
|
||||||
@ -734,10 +734,10 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// callback
|
// callback
|
||||||
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
|
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(dmux.memAddr + (cb_add ^= 16));
|
||||||
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_FLUSH_DONE;
|
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_FLUSH_DONE;
|
||||||
esMsg->supplementalInfo = stream.userdata;
|
esMsg->supplementalInfo = stream.userdata;
|
||||||
es.cbFunc.call(*dmux.dmuxCb, dmux.id, es.id, esMsg, es.cbArg);
|
es.cbFunc(*dmux.dmuxCb, dmux.id, es.id, esMsg, es.cbArg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1000,7 +1000,7 @@ int cellDmuxEnableEs(u32 demuxerHandle, vm::ptr<const CellCodecEsFilterId> esFil
|
|||||||
*esHandle = id;
|
*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",
|
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);
|
DemuxerTask task(dmuxEnableEs);
|
||||||
task.es.es = id;
|
task.es.es = id;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// align size or address to 128
|
|
||||||
#define a128(x) ((x + 127) & (~127))
|
|
||||||
|
|
||||||
// Error Codes
|
// Error Codes
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@ int cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr<CellFontConfig> co
|
|||||||
if (config->FileCache.size < 24)
|
if (config->FileCache.size < 24)
|
||||||
return CELL_FONT_ERROR_INVALID_PARAMETER;
|
return CELL_FONT_ERROR_INVALID_PARAMETER;
|
||||||
if (config->flags != 0)
|
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_addr = config->FileCache.buffer_addr;
|
||||||
s_fontInternalInstance->m_buffer_size = config->FileCache.size;
|
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_RSANS2_SET:
|
||||||
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_VAGR2_SET:
|
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_VAGR2_SET:
|
||||||
case CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_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";
|
file = "/dev_flash/data/font/SCE-PS3-RD-R-LATIN.TTF";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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;
|
return CELL_FONT_ERROR_NO_SUPPORT_FONTSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ int cellGameDataCheckCreate2(PPUThread& CPU, u32 version, vm::ptr<const char> di
|
|||||||
if (cbSet->setParam)
|
if (cbSet->setParam)
|
||||||
{
|
{
|
||||||
// TODO: write PARAM.SFO from cbSet
|
// 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)
|
switch ((s32)cbResult->result)
|
||||||
|
@ -190,10 +190,9 @@ int cellGemGetInfo()
|
|||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should int be used, even when type is int_32t (s32)?
|
s32 cellGemGetMemorySize(s32 max_connect)
|
||||||
s32 cellGemGetMemorySize(be_t<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)
|
if (max_connect > CELL_GEM_MAX_NUM)
|
||||||
return CELL_GEM_ERROR_INVALID_PARAMETER;
|
return CELL_GEM_ERROR_INVALID_PARAMETER;
|
||||||
|
@ -171,10 +171,10 @@ s32 cellMsgDialogOpen2(u32 type, vm::ptr<const char> msgString, vm::ptr<CellMsgD
|
|||||||
|
|
||||||
if (callback && (g_msg_dialog_state != msgDialogAbort))
|
if (callback && (g_msg_dialog_state != msgDialogAbort))
|
||||||
{
|
{
|
||||||
s32 status = (s32)g_msg_dialog_status;
|
const s32 status = (s32)g_msg_dialog_status;
|
||||||
Emu.GetCallbackManager().Register([callback, userData, status]() -> s32
|
Emu.GetCallbackManager().Register([callback, userData, status](PPUThread& PPU) -> s32
|
||||||
{
|
{
|
||||||
callback(status, userData);
|
callback(PPU, status, userData);
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ s64 pngDecOpen(
|
|||||||
stream->fd = 0;
|
stream->fd = 0;
|
||||||
stream->src = *src;
|
stream->src = *src;
|
||||||
|
|
||||||
switch ((u32)src->srcSelect.ToBE())
|
switch (src->srcSelect.ToBE())
|
||||||
{
|
{
|
||||||
case se32(CELL_PNGDEC_BUFFER):
|
case se32(CELL_PNGDEC_BUFFER):
|
||||||
stream->fileSize = src->streamSize.ToLE();
|
stream->fileSize = src->streamSize.ToLE();
|
||||||
@ -145,7 +145,7 @@ s64 pngReadHeader(
|
|||||||
auto buffer_32 = buffer.To<be_t<u32>>();
|
auto buffer_32 = buffer.To<be_t<u32>>();
|
||||||
vm::var<be_t<u64>> pos, nread;
|
vm::var<be_t<u64>> pos, nread;
|
||||||
|
|
||||||
switch ((u32)stream->src.srcSelect.ToBE())
|
switch (stream->src.srcSelect.ToBE())
|
||||||
{
|
{
|
||||||
case se32(CELL_PNGDEC_BUFFER):
|
case se32(CELL_PNGDEC_BUFFER):
|
||||||
memmove(buffer.begin(), stream->src.streamPtr.get_ptr(), buffer.size());
|
memmove(buffer.begin(), stream->src.streamPtr.get_ptr(), buffer.size());
|
||||||
@ -206,7 +206,7 @@ s64 pngDecSetParameter(
|
|||||||
current_outParam.outputHeight = current_info.imageHeight;
|
current_outParam.outputHeight = current_info.imageHeight;
|
||||||
current_outParam.outputColorSpace = inParam->outputColorSpace;
|
current_outParam.outputColorSpace = inParam->outputColorSpace;
|
||||||
|
|
||||||
switch ((u32)current_outParam.outputColorSpace.ToBE())
|
switch (current_outParam.outputColorSpace.ToBE())
|
||||||
{
|
{
|
||||||
case se32(CELL_PNGDEC_PALETTE):
|
case se32(CELL_PNGDEC_PALETTE):
|
||||||
case se32(CELL_PNGDEC_GRAYSCALE):
|
case se32(CELL_PNGDEC_GRAYSCALE):
|
||||||
@ -254,7 +254,7 @@ s64 pngDecodeData(
|
|||||||
vm::var<unsigned char[]> png((u32)fileSize);
|
vm::var<unsigned char[]> png((u32)fileSize);
|
||||||
vm::var<be_t<u64>> pos, nread;
|
vm::var<be_t<u64>> pos, nread;
|
||||||
|
|
||||||
switch ((u32)stream->src.srcSelect.ToBE())
|
switch (stream->src.srcSelect.ToBE())
|
||||||
{
|
{
|
||||||
case se32(CELL_PNGDEC_BUFFER):
|
case se32(CELL_PNGDEC_BUFFER):
|
||||||
memmove(png.begin(), stream->src.streamPtr.get_ptr(), png.size());
|
memmove(png.begin(), stream->src.streamPtr.get_ptr(), png.size());
|
||||||
@ -283,7 +283,7 @@ s64 pngDecodeData(
|
|||||||
const int bytesPerLine = (u32)dataCtrlParam->outputBytesPerLine;
|
const int bytesPerLine = (u32)dataCtrlParam->outputBytesPerLine;
|
||||||
uint image_size = width * height;
|
uint image_size = width * height;
|
||||||
|
|
||||||
switch ((u32)current_outParam.outputColorSpace.ToBE())
|
switch (current_outParam.outputColorSpace.ToBE())
|
||||||
{
|
{
|
||||||
case se32(CELL_PNGDEC_RGB):
|
case se32(CELL_PNGDEC_RGB):
|
||||||
case se32(CELL_PNGDEC_RGBA):
|
case se32(CELL_PNGDEC_RGBA):
|
||||||
|
@ -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)
|
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)
|
if (!s_rescInternalInstance->m_bInitialized)
|
||||||
{
|
{
|
||||||
|
@ -382,7 +382,7 @@ int cellRtcSetTime_t(vm::ptr<CellRtcDateTime> pDateTime, u64 iTime)
|
|||||||
|
|
||||||
int cellRtcSetWin32FileTime(vm::ptr<CellRtcDateTime> pDateTime, u64 ulWin32FileTime)
|
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);
|
rDateTime date_time = rDateTime((time_t)ulWin32FileTime);
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ int cellSailDescriptorIsAutoSelection(vm::ptr<CellSailDescriptor> pSelf)
|
|||||||
return CELL_OK;
|
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);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
cellSail->Error("Unhandled stream type: %d", pSelf->streamType);
|
cellSail->Error("Unhandled stream type: %d", pSelf->streamType.ToLE());
|
||||||
}
|
}
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
|
@ -316,23 +316,23 @@ void sysutilSendSystemCommand(u64 status, u64 param)
|
|||||||
{
|
{
|
||||||
if (cb.func)
|
if (cb.func)
|
||||||
{
|
{
|
||||||
Emu.GetCallbackManager().Register([=]() -> s32
|
Emu.GetCallbackManager().Register([=](PPUThread& PPU) -> s32
|
||||||
{
|
{
|
||||||
cb.func(status, param, cb.arg);
|
cb.func(PPU, status, param, cb.arg);
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 cellSysutilCheckCallback()
|
s32 cellSysutilCheckCallback(PPUThread& CPU)
|
||||||
{
|
{
|
||||||
cellSysutil->Log("cellSysutilCheckCallback()");
|
cellSysutil->Log("cellSysutilCheckCallback()");
|
||||||
|
|
||||||
s32 res;
|
s32 res;
|
||||||
u32 count = 0;
|
u32 count = 0;
|
||||||
|
|
||||||
while (Emu.GetCallbackManager().Check(res))
|
while (Emu.GetCallbackManager().Check(CPU, res))
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ next:
|
|||||||
buf_size -= vdec.reader.size;
|
buf_size -= vdec.reader.size;
|
||||||
res += vdec.reader.size;
|
res += vdec.reader.size;
|
||||||
|
|
||||||
vdec.cbFunc.call(*vdec.vdecCb, vdec.id, CELL_VDEC_MSG_TYPE_AUDONE, CELL_OK, vdec.cbArg);
|
vdec.cbFunc(*vdec.vdecCb, vdec.id, CELL_VDEC_MSG_TYPE_AUDONE, CELL_OK, vdec.cbArg);
|
||||||
|
|
||||||
vdec.job.pop(vdec.task);
|
vdec.job.pop(vdec.task);
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ u32 vdecOpen(VideoDecoder* vdec_ptr)
|
|||||||
// TODO: finalize
|
// TODO: finalize
|
||||||
cellVdec->Warning("vdecEndSeq:");
|
cellVdec->Warning("vdecEndSeq:");
|
||||||
|
|
||||||
vdec.cbFunc.call(*vdec.vdecCb, vdec.id, CELL_VDEC_MSG_TYPE_SEQDONE, CELL_OK, vdec.cbArg);
|
vdec.cbFunc(*vdec.vdecCb, vdec.id, CELL_VDEC_MSG_TYPE_SEQDONE, CELL_OK, vdec.cbArg);
|
||||||
|
|
||||||
vdec.just_finished = true;
|
vdec.just_finished = true;
|
||||||
break;
|
break;
|
||||||
@ -516,12 +516,12 @@ u32 vdecOpen(VideoDecoder* vdec_ptr)
|
|||||||
if (vdec.frames.push(frame, &vdec.is_closed))
|
if (vdec.frames.push(frame, &vdec.is_closed))
|
||||||
{
|
{
|
||||||
frame.data = nullptr; // to prevent destruction
|
frame.data = nullptr; // to prevent destruction
|
||||||
vdec.cbFunc.call(*vdec.vdecCb, vdec.id, CELL_VDEC_MSG_TYPE_PICOUT, CELL_OK, vdec.cbArg);
|
vdec.cbFunc(*vdec.vdecCb, vdec.id, CELL_VDEC_MSG_TYPE_PICOUT, CELL_OK, vdec.cbArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vdec.cbFunc.call(*vdec.vdecCb, vdec.id, CELL_VDEC_MSG_TYPE_AUDONE, CELL_OK, vdec.cbArg);
|
vdec.cbFunc(*vdec.vdecCb, vdec.id, CELL_VDEC_MSG_TYPE_AUDONE, CELL_OK, vdec.cbArg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,7 +693,7 @@ int cellVdecGetPicture(u32 handle, vm::ptr<const CellVdecPicFormat> format, vm::
|
|||||||
|
|
||||||
if (outBuff)
|
if (outBuff)
|
||||||
{
|
{
|
||||||
u32 buf_size = a128(av_image_get_buffer_size(vdec->ctx->pix_fmt, vdec->ctx->width, vdec->ctx->height, 1));
|
const u32 buf_size = align(av_image_get_buffer_size(vdec->ctx->pix_fmt, vdec->ctx->width, vdec->ctx->height, 1), 128);
|
||||||
|
|
||||||
if (format->formatType != CELL_VDEC_PICFMT_YUV420_PLANAR)
|
if (format->formatType != CELL_VDEC_PICFMT_YUV420_PLANAR)
|
||||||
{
|
{
|
||||||
@ -753,7 +753,7 @@ int cellVdecGetPicItem(u32 handle, vm::ptr<u32> picItem_ptr)
|
|||||||
|
|
||||||
info->codecType = vdec->type;
|
info->codecType = vdec->type;
|
||||||
info->startAddr = 0x00000123; // invalid value (no address for picture)
|
info->startAddr = 0x00000123; // invalid value (no address for picture)
|
||||||
info->size = a128(av_image_get_buffer_size(vdec->ctx->pix_fmt, vdec->ctx->width, vdec->ctx->height, 1));
|
info->size = align(av_image_get_buffer_size(vdec->ctx->pix_fmt, vdec->ctx->width, vdec->ctx->height, 1), 128);
|
||||||
info->auNum = 1;
|
info->auNum = 1;
|
||||||
info->auPts[0].lower = (u32)vf.pts;
|
info->auPts[0].lower = (u32)vf.pts;
|
||||||
info->auPts[0].upper = vf.pts >> 32;
|
info->auPts[0].upper = vf.pts >> 32;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define a128(x) ((x + 127) & (~127))
|
|
||||||
|
|
||||||
// Error Codes
|
// Error Codes
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -23,8 +23,7 @@ std::vector<SSPlayer> ssp;
|
|||||||
|
|
||||||
int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, vm::ptr<float> addr, u32 samples)
|
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)",
|
libmixer->Log("cellAANAddData(handle=%d, port=%d, offset=0x%x, addr_addr=0x%x, samples=%d)", aan_handle, aan_port, offset, addr.addr(), samples);
|
||||||
aan_handle, aan_port, offset, addr.addr(), samples);
|
|
||||||
|
|
||||||
u32 type = aan_port >> 16;
|
u32 type = aan_port >> 16;
|
||||||
u32 port = aan_port & 0xffff;
|
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)
|
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",
|
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);
|
||||||
aan_handle, aan_port, offset, addr, samples);
|
|
||||||
return CELL_LIBMIXER_ERROR_INVALID_PARAMATER;
|
return CELL_LIBMIXER_ERROR_INVALID_PARAMATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +356,7 @@ int cellSurMixerCreate(vm::ptr<const CellSurMixerConfig> config)
|
|||||||
memset(mixdata, 0, sizeof(mixdata));
|
memset(mixdata, 0, sizeof(mixdata));
|
||||||
if (surMixerCb)
|
if (surMixerCb)
|
||||||
{
|
{
|
||||||
surMixerCb.call(cb_thread, surMixerCbArg, (u32)mixcount, 256);
|
surMixerCb(cb_thread, surMixerCbArg, (u32)mixcount, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
//u64 stamp1 = get_system_time();
|
//u64 stamp1 = get_system_time();
|
||||||
|
@ -311,7 +311,7 @@ int sceNpBasicAddFriend()
|
|||||||
|
|
||||||
int sceNpBasicGetFriendListEntryCount(vm::ptr<u32> count)
|
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)
|
if (!sceNpInstance.m_bSceNpInitialized)
|
||||||
return SCE_NP_BASIC_ERROR_NOT_INITIALIZED;
|
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)
|
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)
|
if (!sceNpInstance.m_bSceNpInitialized)
|
||||||
return SCE_NP_BASIC_ERROR_NOT_INITIALIZED;
|
return SCE_NP_BASIC_ERROR_NOT_INITIALIZED;
|
||||||
@ -984,7 +984,7 @@ int sceNpManagerGetAccountAge()
|
|||||||
|
|
||||||
int sceNpManagerGetContentRatingFlag(vm::ptr<u32> isRestricted, vm::ptr<u32> age)
|
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)
|
if (!sceNpInstance.m_bSceNpInitialized)
|
||||||
return SCE_NP_ERROR_NOT_INITIALIZED;
|
return SCE_NP_ERROR_NOT_INITIALIZED;
|
||||||
|
@ -295,7 +295,7 @@ s32 _sys_spu_printf_attach_group(PPUThread& CPU, u32 group)
|
|||||||
return CELL_ESTAT;
|
return CELL_ESTAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spu_printf_agcb.call(CPU, group);
|
return spu_printf_agcb(CPU, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 _sys_spu_printf_detach_group(PPUThread& CPU, u32 group)
|
s32 _sys_spu_printf_detach_group(PPUThread& CPU, u32 group)
|
||||||
@ -307,7 +307,7 @@ s32 _sys_spu_printf_detach_group(PPUThread& CPU, u32 group)
|
|||||||
return CELL_ESTAT;
|
return CELL_ESTAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spu_printf_dgcb.call(CPU, group);
|
return spu_printf_dgcb(CPU, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 _sys_spu_printf_attach_thread(PPUThread& CPU, u32 thread)
|
s32 _sys_spu_printf_attach_thread(PPUThread& CPU, u32 thread)
|
||||||
@ -319,7 +319,7 @@ s32 _sys_spu_printf_attach_thread(PPUThread& CPU, u32 thread)
|
|||||||
return CELL_ESTAT;
|
return CELL_ESTAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spu_printf_atcb.call(CPU, thread);
|
return spu_printf_atcb(CPU, thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 _sys_spu_printf_detach_thread(PPUThread& CPU, u32 thread)
|
s32 _sys_spu_printf_detach_thread(PPUThread& CPU, u32 thread)
|
||||||
@ -331,7 +331,7 @@ s32 _sys_spu_printf_detach_thread(PPUThread& CPU, u32 thread)
|
|||||||
return CELL_ESTAT;
|
return CELL_ESTAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spu_printf_dtcb.call(CPU, thread);
|
return spu_printf_dtcb(CPU, thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 _sys_snprintf(vm::ptr<char> dst, u32 count, vm::ptr<const char> fmt) // va_args...
|
s32 _sys_snprintf(vm::ptr<char> dst, u32 count, vm::ptr<const char> fmt) // va_args...
|
||||||
|
@ -784,13 +784,13 @@ int sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil
|
|||||||
|
|
||||||
if (!packed_stream || !packed_stream->IsOpened())
|
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;
|
return CELL_ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!unpacked_stream || !unpacked_stream->IsOpened())
|
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;
|
return CELL_ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -919,7 +919,6 @@ void fsAioRead(u32 fd, vm::ptr<CellFsAio> aio, int xid, vm::ptr<void(*)(vm::ptr<
|
|||||||
const u64 old_pos = file.Tell();
|
const u64 old_pos = file.Tell();
|
||||||
file.Seek((u64)aio->offset);
|
file.Seek((u64)aio->offset);
|
||||||
|
|
||||||
// TODO: use code from cellFsRead or something
|
|
||||||
if (nbytes != (u32)nbytes)
|
if (nbytes != (u32)nbytes)
|
||||||
{
|
{
|
||||||
error = CELL_ENOMEM;
|
error = CELL_ENOMEM;
|
||||||
@ -932,14 +931,14 @@ void fsAioRead(u32 fd, vm::ptr<CellFsAio> aio, int xid, vm::ptr<void(*)(vm::ptr<
|
|||||||
file.Seek(old_pos);
|
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)",
|
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) // start callback thread
|
if (func)
|
||||||
{
|
{
|
||||||
Emu.GetCallbackManager().Async([func, aio, error, xid, res]()
|
Emu.GetCallbackManager().Async([func, aio, error, xid, res](PPUThread& CPU)
|
||||||
{
|
{
|
||||||
func(aio, error, xid, res);
|
func(CPU, aio, error, xid, res);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@ s32 lwmutex_create(sys_lwmutex_t& lwmutex, u32 protocol, u32 recursive, u64 name
|
|||||||
lwmutex.sleep_queue = sq_id;
|
lwmutex.sleep_queue = sq_id;
|
||||||
sq->set_full_name(fmt::Format("Lwmutex(%d, addr=0x%x)", sq_id, Memory.RealToVirtualAddr(&lwmutex)));
|
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;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,12 +16,12 @@ Mutex::~Mutex()
|
|||||||
{
|
{
|
||||||
if (u32 tid = owner.read_sync())
|
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())
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ void sys_ppu_thread_once(PPUThread& CPU, vm::ptr<atomic_t<u32>> once_ctrl, vm::p
|
|||||||
be_t<u32> cmp = be_t<u32>::make(SYS_PPU_THREAD_ONCE_INIT);
|
be_t<u32> cmp = be_t<u32>::make(SYS_PPU_THREAD_ONCE_INIT);
|
||||||
if (once_ctrl->compare_and_swap(cmp, be_t<u32>::make(SYS_PPU_THREAD_DONE_INIT)) == cmp)
|
if (once_ctrl->compare_and_swap(cmp, be_t<u32>::make(SYS_PPU_THREAD_DONE_INIT)) == cmp)
|
||||||
{
|
{
|
||||||
init.call(CPU);
|
init(CPU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ struct sys_prx_module_info_t
|
|||||||
{
|
{
|
||||||
be_t<u16> attributes;
|
be_t<u16> attributes;
|
||||||
be_t<u16> version;
|
be_t<u16> version;
|
||||||
s8 name[28];
|
char name[28];
|
||||||
be_t<u32> toc;
|
be_t<u32> toc;
|
||||||
vm::bptr<sys_prx_library_info_t> exports_start;
|
vm::bptr<sys_prx_library_info_t> exports_start;
|
||||||
vm::bptr<sys_prx_library_info_t> exports_end;
|
vm::bptr<sys_prx_library_info_t> exports_end;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "Emu/Cell/SPUThread.h"
|
#include "Emu/Cell/SPUThread.h"
|
||||||
#include "Emu/Cell/PPUInstrTable.h"
|
#include "Emu/Cell/PPUInstrTable.h"
|
||||||
#include "Emu/FS/vfsFile.h"
|
#include "Emu/FS/vfsFile.h"
|
||||||
|
#include "Emu/FS/vfsLocalFile.h"
|
||||||
#include "Emu/FS/vfsDeviceLocalFile.h"
|
#include "Emu/FS/vfsDeviceLocalFile.h"
|
||||||
#include "Emu/DbgCommand.h"
|
#include "Emu/DbgCommand.h"
|
||||||
|
|
||||||
@ -261,7 +262,7 @@ void Emulator::Load()
|
|||||||
|
|
||||||
if (!m_loader.load(f))
|
if (!m_loader.load(f))
|
||||||
{
|
{
|
||||||
LOG_ERROR(LOADER, "Loading '%s' failed", m_elf_path.c_str());
|
LOG_ERROR(LOADER, "Loading '%s' failed", m_path.c_str());
|
||||||
vm::close();
|
vm::close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event))
|
|||||||
}
|
}
|
||||||
else
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ void VHDDExplorer::OnDropFiles(wxDropFilesEvent& event)
|
|||||||
|
|
||||||
for(int i=0; i<count; ++i)
|
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()));
|
Import(fmt::ToUTF8(dropped[i]), fmt::ToUTF8(wxFileName(dropped[i]).GetFullName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ namespace loader
|
|||||||
m_stream->Seek(handler::get_stream_offset() + phdr.p_paddr.addr());
|
m_stream->Seek(handler::get_stream_offset() + phdr.p_paddr.addr());
|
||||||
m_stream->Read(&module_info, sizeof(module_info));
|
m_stream->Read(&module_info, sizeof(module_info));
|
||||||
LOG_ERROR(LOADER, "%s (%x):", module_info.name, (u32)module_info.toc);
|
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;
|
info.rtoc = module_info.toc;
|
||||||
|
|
||||||
int import_count = (module_info.imports_end - module_info.imports_start) / sizeof(sys_prx_library_info_t);
|
int import_count = (module_info.imports_end - module_info.imports_start) / sizeof(sys_prx_library_info_t);
|
||||||
@ -406,7 +406,8 @@ namespace loader
|
|||||||
{
|
{
|
||||||
if (!vm::alloc(phdr.p_vaddr.addr(), (u32)phdr.p_memsz, vm::main))
|
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;
|
return loading_error;
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ template<typename T> __forceinline T align(const T addr, int align)
|
|||||||
return (addr + (align - 1)) & ~(align - 1);
|
return (addr + (align - 1)) & ~(align - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "Utilities/StrFmt.h"
|
|
||||||
#include "Utilities/BEType.h"
|
#include "Utilities/BEType.h"
|
||||||
|
#include "Utilities/StrFmt.h"
|
||||||
|
|
||||||
#define _PRGNAME_ "RPCS3"
|
#define _PRGNAME_ "RPCS3"
|
||||||
#define _PRGVER_ "0.0.0.5"
|
#define _PRGVER_ "0.0.0.5"
|
||||||
|
Loading…
Reference in New Issue
Block a user