Merge pull request #1119 from Nekotekina/master

be_t, vm::ptr, vm::ref improved
This commit is contained in:
Hykem 2015-06-16 15:00:30 +01:00
commit de9a2fd556
52 changed files with 1063 additions and 992 deletions

View File

@ -556,52 +556,49 @@ template<u64 _value> struct const_se_t<u64, _value, 8>
((_value << 56) & 0xff00000000000000);
};
template<typename T, size_t size = sizeof(T)>
struct be_storage_t
template<typename T, size_t size = sizeof(T)> struct be_storage
{
static_assert(!size, "Bad be_storage_t type");
static_assert(!size, "Bad be_storage_t<> type");
};
template<typename T> struct be_storage<T, 2>
{
using type = u16;
};
template<typename T> struct be_storage<T, 4>
{
using type = u32;
};
template<typename T> struct be_storage<T, 8>
{
using type = u64;
};
template<typename T> struct be_storage<T, 16>
{
using type = u128;
};
template<typename T> using be_storage_t = typename be_storage<T>::type;
template<typename T>
struct be_storage_t<T, 1>
struct be_t
{
typedef u8 type;
};
using type = std::remove_cv_t<T>;
using stype = be_storage_t<std::remove_cv_t<T>>;
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;
};
template<typename T, typename T2 = T>
class be_t
{
public:
typedef typename std::remove_cv<T>::type type;
typedef typename be_storage_t<T2>::type stype;
private:
stype m_data;
static_assert(!std::is_class<type>::value, "be_t<> error: invalid type (class or structure)");
static_assert(!std::is_union<type>::value || std::is_same<type, u128>::value, "be_t<> error: invalid type (union)");
static_assert(!std::is_pointer<type>::value, "be_t<> error: invalid type (pointer)");
static_assert(!std::is_reference<type>::value, "be_t<> error: invalid type (reference)");
static_assert(!std::is_array<type>::value, "be_t<> error: invalid type (array)");
static_assert(__alignof(type) == __alignof(stype), "be_t<> error: unexpected alignment");
private:
template<typename Tto, typename Tfrom, int mode>
struct _convert
{
@ -639,7 +636,7 @@ private:
type ToLE() const
{
return se_t<type, sizeof(T2)>::from_be(m_data);
return se_t<type, sizeof(stype)>::from_be(m_data);
}
void FromBE(const stype& value)
@ -649,13 +646,12 @@ private:
void FromLE(const type& value)
{
m_data = se_t<type, sizeof(T2)>::to_be(value);
m_data = se_t<type, sizeof(stype)>::to_be(value);
}
public:
static be_t MakeFromLE(const type& value)
{
stype data = se_t<type, sizeof(T2)>::to_be(value);
stype data = se_t<type, sizeof(stype)>::to_be(value);
return (be_t&)data;
}
@ -664,6 +660,7 @@ public:
return (be_t&)value;
}
public:
//make be_t from current machine byte ordering
static be_t make(const type& value)
{
@ -689,37 +686,44 @@ public:
return ToBE();
}
be_t& operator = (const be_t& value) = default;
be_t& operator =(const be_t& value) = default;
be_t& operator = (const type& value)
template<typename CT> std::enable_if_t<std::is_assignable<type&, CT>::value, be_t&> operator =(const CT& value)
{
m_data = se_t<type, sizeof(T2)>::to_be(value);
m_data = se_t<type, sizeof(stype)>::to_be(value);
return *this;
}
//template<typename CT, std::enable_if_t<std::is_convertible<type, CT>::value>> operator CT() const
//{
// return value();
//}
operator type() const
{
return value();
}
template<typename T1>
operator const be_t<T1>() const
// conversion to another be_t type
template<typename T1> operator be_t<T1>() const
{
return be_t<T1>::make(value());
// TODO (complicated cases like int-float conversions are not handled correctly)
//return _convert<T1, T, ((sizeof(T1) > sizeof(T)) ? 1 : (sizeof(T1) < sizeof(T) ? 2 : 0))>::func(m_data);
}
template<typename T1> be_t& operator += (T1 right) { return *this = T(*this) + right; }
template<typename T1> be_t& operator -= (T1 right) { return *this = T(*this) - right; }
template<typename T1> be_t& operator *= (T1 right) { return *this = T(*this) * right; }
template<typename T1> be_t& operator /= (T1 right) { return *this = T(*this) / right; }
template<typename T1> be_t& operator %= (T1 right) { return *this = T(*this) % right; }
template<typename T1> be_t& operator &= (T1 right) { return *this = T(*this) & right; }
template<typename T1> be_t& operator |= (T1 right) { return *this = T(*this) | right; }
template<typename T1> be_t& operator ^= (T1 right) { return *this = T(*this) ^ right; }
template<typename T1> be_t& operator <<= (T1 right) { return *this = T(*this) << right; }
template<typename T1> be_t& operator >>= (T1 right) { return *this = T(*this) >> right; }
template<typename T1> be_t& operator += (T1 right) { return *this = value() + right; }
template<typename T1> be_t& operator -= (T1 right) { return *this = value() - right; }
template<typename T1> be_t& operator *= (T1 right) { return *this = value() * right; }
template<typename T1> be_t& operator /= (T1 right) { return *this = value() / right; }
template<typename T1> be_t& operator %= (T1 right) { return *this = value() % right; }
template<typename T1> be_t& operator &= (T1 right) { return *this = value() & right; }
template<typename T1> be_t& operator |= (T1 right) { return *this = value() | right; }
template<typename T1> be_t& operator ^= (T1 right) { return *this = value() ^ right; }
template<typename T1> be_t& operator <<= (T1 right) { return *this = value() << right; }
template<typename T1> be_t& operator >>= (T1 right) { return *this = value() >> right; }
template<typename T1> be_t& operator += (const be_t<T1>& right) { return *this = ToLE() + right.ToLE(); }
template<typename T1> be_t& operator -= (const be_t<T1>& right) { return *this = ToLE() - right.ToLE(); }
@ -730,9 +734,9 @@ public:
template<typename T1> be_t& operator |= (const be_t<T1>& right) { return *this = ToBE() | right.ToBE(); }
template<typename T1> be_t& operator ^= (const be_t<T1>& right) { return *this = ToBE() ^ right.ToBE(); }
template<typename T1> be_t operator & (const be_t<T1>& right) const { be_t<T> res; res.FromBE(ToBE() & right.ToBE()); return res; }
template<typename T1> be_t operator | (const be_t<T1>& right) const { be_t<T> res; res.FromBE(ToBE() | right.ToBE()); return res; }
template<typename T1> be_t operator ^ (const be_t<T1>& right) const { be_t<T> res; res.FromBE(ToBE() ^ right.ToBE()); return res; }
template<typename T1> be_t operator & (const be_t<T1>& right) const { be_t res; res.FromBE(ToBE() & right.ToBE()); return res; }
template<typename T1> be_t operator | (const be_t<T1>& right) const { be_t res; res.FromBE(ToBE() | right.ToBE()); return res; }
template<typename T1> be_t operator ^ (const be_t<T1>& right) const { be_t res; res.FromBE(ToBE() ^ right.ToBE()); return res; }
template<typename T1> bool operator == (T1 right) const { return (T1)ToLE() == right; }
template<typename T1> bool operator != (T1 right) const { return !(*this == right); }
@ -754,114 +758,48 @@ public:
be_t& operator-- () { *this -= 1; return *this; }
};
template<typename T, typename T2 = T>
struct is_be_t : public std::integral_constant<bool, false> {};
template<typename T, typename T2>
struct is_be_t<be_t<T, T2>, T2> : public std::integral_constant<bool, true> {};
template<typename T, typename T2 = T>
struct remove_be_t
template<typename T> struct is_be_t : public std::integral_constant<bool, false>
{
typedef T type;
};
template<typename T, typename T2>
struct remove_be_t<be_t<T, T2>>
template<typename T> struct is_be_t<be_t<T>> : public std::integral_constant<bool, true>
{
typedef T type;
};
template<typename T, typename T2 = T>
class to_be_t
template<typename T> struct is_be_t<const T> : public std::integral_constant<bool, is_be_t<T>::value>
{
template<typename TT, typename TT2, bool is_need_swap>
struct _be_type_selector
{
typedef TT type;
};
template<typename TT, typename TT2>
struct _be_type_selector<TT, TT2, true>
{
typedef be_t<TT, TT2> type;
};
public:
//true if need swap endianes for be
static const bool value = std::is_arithmetic<T>::value || std::is_enum<T>::value;
//be_t<T, size> if need swap endianes, T otherwise
typedef typename _be_type_selector< T, T2, value >::type type;
typedef typename _be_type_selector< T, T2, !is_be_t<T, T2>::value >::type forced_type;
};
template<typename T, typename T2>
class to_be_t<T, const T2>
template<typename T> struct is_be_t<volatile T> : public std::integral_constant<bool, is_be_t<T>::value>
{
public:
static const bool value = to_be_t<T, T2>::value;
typedef const typename to_be_t<T, T2>::type type;
typedef const typename to_be_t<T, T2>::forced_type forced_type;
};
template<typename T>
class to_be_t<T, void>
// to_be_t helper struct
template<typename T> struct to_be
{
public:
static const bool value = false;
typedef void type;
typedef void forced_type;
using type = std::conditional_t<std::is_arithmetic<T>::value || std::is_enum<T>::value || std::is_same<T, u128>::value, be_t<T>, T>;
};
template<typename T>
class to_be_t<T, u8>
// be_t<T> if possible, T otherwise
template<typename T> using to_be_t = typename to_be<T>::type;
template<typename T> struct to_be<const T>
{
public:
static const bool value = false;
typedef u8 type;
typedef u8 forced_type;
// move const qualifier
using type = const to_be_t<T>;
};
template<typename T>
class to_be_t<T, s8>
template<typename T> struct to_be<volatile T>
{
public:
static const bool value = false;
typedef s8 type;
typedef s8 forced_type;
// move volatile qualifier
using type = volatile to_be_t<T>;
};
template<typename T>
class to_be_t<T, char>
{
public:
static const bool value = false;
typedef char type;
typedef char forced_type;
};
template<typename T>
class to_be_t<T, bool>
{
public:
static const bool value = false;
typedef bool type;
typedef bool forced_type;
};
template<typename T, typename T2 = T>
struct invert_be_t
{
typedef typename to_be_t<T, T2>::type type;
};
template<typename T, typename T2>
struct invert_be_t<be_t<T, T2>>
{
typedef T type;
};
template<> struct to_be<void> { using type = void; };
template<> struct to_be<bool> { using type = bool; };
template<> struct to_be<char> { using type = char; };
template<> struct to_be<u8> { using type = u8; };
template<> struct to_be<s8> { using type = s8; };
template<typename T, typename T1, T1 value> struct _se : public const_se_t<T, value> {};
template<typename T, typename T1, T1 value> struct _se<be_t<T>, T1, value> : public const_se_t<T, value> {};
@ -880,28 +818,28 @@ struct convert_le_be_t
}
};
template<typename Tt, typename Tt1, typename Tfrom>
struct convert_le_be_t<be_t<Tt, Tt1>, Tfrom>
template<typename Tt, typename Tfrom>
struct convert_le_be_t<be_t<Tt>, Tfrom>
{
static be_t<Tt, Tt1> func(Tfrom value)
static be_t<Tt> func(Tfrom value)
{
return be_t<Tt, Tt1>::make(value);
return be_t<Tt>::make(value);
}
};
template<typename Tt, typename Tt1, typename Tf, typename Tf1>
struct convert_le_be_t<be_t<Tt, Tt1>, be_t<Tf, Tf1>>
template<typename Tt, typename Tf>
struct convert_le_be_t<be_t<Tt>, be_t<Tf>>
{
static be_t<Tt, Tt1> func(be_t<Tf, Tf1> value)
static be_t<Tt> func(be_t<Tf> value)
{
return value;
}
};
template<typename Tto, typename Tf, typename Tf1>
struct convert_le_be_t<Tto, be_t<Tf, Tf1>>
template<typename Tto, typename Tf>
struct convert_le_be_t<Tto, be_t<Tf>>
{
static Tto func(be_t<Tf, Tf1> value)
static Tto func(be_t<Tf> value)
{
return value.value();
}
@ -919,6 +857,113 @@ force_inline void convert_le_be(Tto& dst, Tfrom src)
dst = convert_le_be_t<Tto, Tfrom>::func(src);
}
template<typename T> using le_t = T;
template<typename T> struct le_t
{
using type = std::remove_cv_t<T>;
using stype = be_storage_t<std::remove_cv_t<T>>;
template<typename T> struct to_le_t { using type = T; };
stype m_data;
type value() const
{
return reinterpret_cast<const type&>(m_data);
}
le_t& operator =(const le_t& value) = default;
template<typename CT> std::enable_if_t<std::is_assignable<type&, CT>::value, le_t&> operator =(const CT& value)
{
m_data = reinterpret_cast<const stype&>(value);
return *this;
}
//template<typename CT> operator std::enable_if_t<std::is_convertible<type, CT>::value, CT>() const
//{
// return value();
//}
operator type() const
{
return value();
}
// conversion to another le_t type
//template<typename T1> operator const le_t<T1>() const
//{
// return le_t<T1>::make(value());
//}
};
template<typename T> struct is_le_t : public std::integral_constant<bool, false>
{
};
template<typename T> struct is_le_t<le_t<T>> : public std::integral_constant<bool, true>
{
};
template<typename T> struct is_le_t<const T> : public std::integral_constant<bool, is_le_t<T>::value>
{
};
template<typename T> struct is_le_t<volatile T> : public std::integral_constant<bool, is_le_t<T>::value>
{
};
template<typename T> struct to_le
{
using type = std::conditional_t<std::is_arithmetic<T>::value || std::is_enum<T>::value || std::is_same<T, u128>::value, le_t<T>, T>;
};
// le_t<T> if possible, T otherwise
template<typename T> using to_le_t = typename to_le<T>::type;
template<typename T> struct to_le<const T>
{
// move const qualifier
using type = const to_le_t<T>;
};
template<typename T> struct to_le<volatile T>
{
// move volatile qualifier
using type = volatile to_le_t<T>;
};
template<> struct to_le<void> { using type = void; };
template<> struct to_le<bool> { using type = bool; };
template<> struct to_le<char> { using type = char; };
template<> struct to_le<u8> { using type = u8; };
template<> struct to_le<s8> { using type = s8; };
// to_ne_t helper struct
template<typename T> struct to_ne
{
using type = T;
};
template<typename T> struct to_ne<be_t<T>>
{
using type = T;
};
template<typename T> struct to_ne<le_t<T>>
{
using type = T;
};
// restore native endianness for T: returns T for be_t<T> or le_t<T>, T otherwise
template<typename T> using to_ne_t = typename to_ne<T>::type;
template<typename T> struct to_ne<const T>
{
// move const qualifier
using type = const to_ne_t<T>;
};
template<typename T> struct to_ne<volatile T>
{
// move volatile qualifier
using type = volatile to_ne_t<T>;
};

View File

@ -82,42 +82,42 @@ int clock_gettime(int foo, struct timespec *ts);
#endif /* __APPLE__ */
template<typename T, typename T2> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_val_compare_and_swap(volatile T* dest, T2 comp, T2 exch)
template<typename T, typename T2> static inline std::enable_if_t<std::is_arithmetic<T>::value, T> sync_val_compare_and_swap(volatile T* dest, T2 comp, T2 exch)
{
return __sync_val_compare_and_swap(dest, comp, exch);
}
template<typename T, typename T2> static inline typename std::enable_if<std::is_arithmetic<T>::value, bool>::type sync_bool_compare_and_swap(volatile T* dest, T2 comp, T2 exch)
template<typename T, typename T2> static inline std::enable_if_t<std::is_arithmetic<T>::value, bool> sync_bool_compare_and_swap(volatile T* dest, T2 comp, T2 exch)
{
return __sync_bool_compare_and_swap(dest, comp, exch);
}
template<typename T, typename T2> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_lock_test_and_set(volatile T* dest, T2 value)
template<typename T, typename T2> static inline std::enable_if_t<std::is_arithmetic<T>::value, T> sync_lock_test_and_set(volatile T* dest, T2 value)
{
return __sync_lock_test_and_set(dest, value);
}
template<typename T, typename T2> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_fetch_and_add(volatile T* dest, T2 value)
template<typename T, typename T2> static inline std::enable_if_t<std::is_arithmetic<T>::value, T> sync_fetch_and_add(volatile T* dest, T2 value)
{
return __sync_fetch_and_add(dest, value);
}
template<typename T, typename T2> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_fetch_and_sub(volatile T* dest, T2 value)
template<typename T, typename T2> static inline std::enable_if_t<std::is_arithmetic<T>::value, T> sync_fetch_and_sub(volatile T* dest, T2 value)
{
return __sync_fetch_and_sub(dest, value);
}
template<typename T, typename T2> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_fetch_and_or(volatile T* dest, T2 value)
template<typename T, typename T2> static inline std::enable_if_t<std::is_arithmetic<T>::value, T> sync_fetch_and_or(volatile T* dest, T2 value)
{
return __sync_fetch_and_or(dest, value);
}
template<typename T, typename T2> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_fetch_and_and(volatile T* dest, T2 value)
template<typename T, typename T2> static inline std::enable_if_t<std::is_arithmetic<T>::value, T> sync_fetch_and_and(volatile T* dest, T2 value)
{
return __sync_fetch_and_and(dest, value);
}
template<typename T, typename T2> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_fetch_and_xor(volatile T* dest, T2 value)
template<typename T, typename T2> static inline std::enable_if_t<std::is_arithmetic<T>::value, T> sync_fetch_and_xor(volatile T* dest, T2 value)
{
return __sync_fetch_and_xor(dest, value);
}

View File

@ -179,7 +179,7 @@ namespace fmt
template<typename T, bool is_enum = std::is_enum<T>::value>
struct unveil
{
typedef T result_type;
using result_type = T;
force_inline static result_type get_value(const T& arg)
{
@ -190,7 +190,7 @@ namespace fmt
template<>
struct unveil<char*, false>
{
typedef const char* result_type;
using result_type = const char*;
force_inline static result_type get_value(const char* arg)
{
@ -201,7 +201,7 @@ namespace fmt
template<size_t N>
struct unveil<const char[N], false>
{
typedef const char* result_type;
using result_type = const char*;
force_inline static result_type get_value(const char(&arg)[N])
{
@ -212,7 +212,7 @@ namespace fmt
template<>
struct unveil<std::string, false>
{
typedef const char* result_type;
using result_type = const char*;
force_inline static result_type get_value(const std::string& arg)
{
@ -223,7 +223,7 @@ namespace fmt
template<typename T>
struct unveil<T, true>
{
typedef typename std::underlying_type<T>::type result_type;
using result_type = std::underlying_type_t<T>;
force_inline static result_type get_value(const T& arg)
{
@ -231,12 +231,12 @@ namespace fmt
}
};
template<typename T, typename T2>
struct unveil<be_t<T, T2>, false>
template<typename T>
struct unveil<be_t<T>, false>
{
typedef typename unveil<T>::result_type result_type;
using result_type = typename unveil<T>::result_type;
force_inline static result_type get_value(const be_t<T, T2>& arg)
force_inline static result_type get_value(const be_t<T>& arg)
{
return unveil<T>::get_value(arg.value());
}

View File

@ -25,7 +25,7 @@ endif()
if (NOT MSVC)
add_definitions(-DwxGUI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fexceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fexceptions")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -D_NDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O1 -D_NDEBUG")

View File

@ -5,7 +5,7 @@
namespace vm
{
template<typename AT, typename RT, typename... T>
force_inline RT _ptr_base<RT(T...), 1, AT>::operator()(ARMv7Context& context, T... args) const
force_inline RT _ptr_base<RT(T...), AT>::operator()(ARMv7Context& context, T... args) const
{
return psv_func_detail::func_caller<RT, T...>::call(context, vm::cast(this->addr()), args...);
}

View File

@ -187,16 +187,14 @@ struct cast_armv7_gpr
{
static_assert(is_enum, "Invalid type for cast_armv7_gpr");
typedef typename std::underlying_type<T>::type underlying_type;
force_inline static u32 to_gpr(const T& value)
{
return cast_armv7_gpr<underlying_type>::to_gpr(static_cast<underlying_type>(value));
return cast_armv7_gpr<std::underlying_type_t<T>>::to_gpr(static_cast<std::underlying_type_t<T>>(value));
}
force_inline static T from_gpr(const u32 reg)
{
return static_cast<T>(cast_armv7_gpr<underlying_type>::from_gpr(reg));
return static_cast<T>(cast_armv7_gpr<std::underlying_type_t<T>>::from_gpr(reg));
}
};

View File

@ -9,7 +9,7 @@ s32 sceGzipIsValid(vm::psv::ptr<const void> pSrcGzip)
throw __FUNCTION__;
}
s32 sceGzipGetInfo(vm::psv::ptr<const void> pSrcGzip, vm::psv::ptr<vm::psv::ptr<const void>> ppvExtra, vm::psv::ptr<vm::psv::ptr<const char>> ppszName, vm::psv::ptr<vm::psv::ptr<const char>> ppszComment, vm::psv::ptr<u16> pusCrc, vm::psv::ptr<vm::psv::ptr<const void>> ppvData)
s32 sceGzipGetInfo(vm::psv::ptr<const void> pSrcGzip, vm::psv::pptr<const void> ppvExtra, vm::psv::pptr<const char> ppszName, vm::psv::pptr<const char> ppszComment, vm::psv::ptr<u16> pusCrc, vm::psv::pptr<const void> ppvData)
{
throw __FUNCTION__;
}
@ -39,7 +39,7 @@ s32 sceZlibIsValid(vm::psv::ptr<const void> pSrcZlib)
throw __FUNCTION__;
}
s32 sceZlibGetInfo(vm::psv::ptr<const void> pSrcZlib, vm::psv::ptr<u8> pbCmf, vm::psv::ptr<u8> pbFlg, vm::psv::ptr<u32> puiDictId, vm::psv::ptr<vm::psv::ptr<const void>> ppvData)
s32 sceZlibGetInfo(vm::psv::ptr<const void> pSrcZlib, vm::psv::ptr<u8> pbCmf, vm::psv::ptr<u8> pbFlg, vm::psv::ptr<u32> puiDictId, vm::psv::pptr<const void> ppvData)
{
throw __FUNCTION__;
}
@ -59,12 +59,12 @@ u32 sceZlibAdler32(u32 uiAdler, vm::psv::ptr<const u8> pSrc, u32 uiSize)
throw __FUNCTION__;
}
s32 sceDeflateDecompress(vm::psv::ptr<void> pDst, u32 uiBufSize, vm::psv::ptr<const void> pSrcDeflate, vm::psv::ptr<vm::psv::ptr<const void>> ppNext)
s32 sceDeflateDecompress(vm::psv::ptr<void> pDst, u32 uiBufSize, vm::psv::ptr<const void> pSrcDeflate, vm::psv::pptr<const void> ppNext)
{
throw __FUNCTION__;
}
s32 sceZipGetInfo(vm::psv::ptr<const void> pSrc, vm::psv::ptr<vm::psv::ptr<const void>> ppvExtra, vm::psv::ptr<u32> puiCrc, vm::psv::ptr<vm::psv::ptr<const void>> ppvData)
s32 sceZipGetInfo(vm::psv::ptr<const void> pSrc, vm::psv::pptr<const void> ppvExtra, vm::psv::ptr<u32> puiCrc, vm::psv::pptr<const void> ppvData)
{
throw __FUNCTION__;
}

View File

@ -65,7 +65,7 @@ s32 sceFiberSwitch(vm::psv::ptr<SceFiber> fiber, u32 argOnRunTo, vm::psv::ptr<u3
throw __FUNCTION__;
}
s32 sceFiberGetSelf(vm::psv::ptr<vm::psv::ptr<SceFiber>> fiber)
s32 sceFiberGetSelf(vm::psv::pptr<SceFiber> fiber)
{
throw __FUNCTION__;
}

View File

@ -787,7 +787,7 @@ s32 sceFiosIOFilterAdd(s32 index, SceFiosIOFilterCallback pFilterCallback, vm::p
throw __FUNCTION__;
}
s32 sceFiosIOFilterGetInfo(s32 index, vm::psv::ptr<SceFiosIOFilterCallback> pOutFilterCallback, vm::psv::ptr<vm::psv::ptr<void>> pOutFilterContext)
s32 sceFiosIOFilterGetInfo(s32 index, vm::psv::ptr<SceFiosIOFilterCallback> pOutFilterCallback, vm::psv::pptr<void> pOutFilterContext)
{
throw __FUNCTION__;
}

View File

@ -64,7 +64,7 @@ s32 sceGxmDisplayQueueFinish()
throw __FUNCTION__;
}
s32 sceGxmSyncObjectCreate(vm::psv::ptr<vm::psv::ptr<SceGxmSyncObject>> syncObject)
s32 sceGxmSyncObjectCreate(vm::psv::pptr<SceGxmSyncObject> syncObject)
{
throw __FUNCTION__;
}
@ -75,7 +75,7 @@ s32 sceGxmSyncObjectDestroy(vm::psv::ptr<SceGxmSyncObject> syncObject)
}
s32 sceGxmCreateContext(vm::psv::ptr<const SceGxmContextParams> params, vm::psv::ptr<vm::psv::ptr<SceGxmContext>> context)
s32 sceGxmCreateContext(vm::psv::ptr<const SceGxmContextParams> params, vm::psv::pptr<SceGxmContext> context)
{
throw __FUNCTION__;
}
@ -101,12 +101,12 @@ void sceGxmSetFragmentProgram(vm::psv::ptr<SceGxmContext> context, vm::psv::ptr<
throw __FUNCTION__;
}
s32 sceGxmReserveVertexDefaultUniformBuffer(vm::psv::ptr<SceGxmContext> context, vm::psv::ptr<vm::psv::ptr<void>> uniformBuffer)
s32 sceGxmReserveVertexDefaultUniformBuffer(vm::psv::ptr<SceGxmContext> context, vm::psv::pptr<void> uniformBuffer)
{
throw __FUNCTION__;
}
s32 sceGxmReserveFragmentDefaultUniformBuffer(vm::psv::ptr<SceGxmContext> context, vm::psv::ptr<vm::psv::ptr<void>> uniformBuffer)
s32 sceGxmReserveFragmentDefaultUniformBuffer(vm::psv::ptr<SceGxmContext> context, vm::psv::pptr<void> uniformBuffer)
{
throw __FUNCTION__;
}
@ -650,7 +650,7 @@ vm::psv::ptr<const SceGxmProgram> sceGxmVertexProgramGetProgram(vm::psv::ptr<con
}
s32 sceGxmShaderPatcherCreate(vm::psv::ptr<const SceGxmShaderPatcherParams> params, vm::psv::ptr<vm::psv::ptr<SceGxmShaderPatcher>> shaderPatcher)
s32 sceGxmShaderPatcherCreate(vm::psv::ptr<const SceGxmShaderPatcherParams> params, vm::psv::pptr<SceGxmShaderPatcher> shaderPatcher)
{
throw __FUNCTION__;
}
@ -690,12 +690,12 @@ s32 sceGxmShaderPatcherSetAuxiliarySurface(vm::psv::ptr<SceGxmShaderPatcher> sha
throw __FUNCTION__;
}
s32 sceGxmShaderPatcherCreateVertexProgram(vm::psv::ptr<SceGxmShaderPatcher> shaderPatcher, SceGxmShaderPatcherId programId, vm::psv::ptr<const SceGxmVertexAttribute> attributes, u32 attributeCount, vm::psv::ptr<const SceGxmVertexStream> streams, u32 streamCount, vm::psv::ptr<vm::psv::ptr<SceGxmVertexProgram>> vertexProgram)
s32 sceGxmShaderPatcherCreateVertexProgram(vm::psv::ptr<SceGxmShaderPatcher> shaderPatcher, SceGxmShaderPatcherId programId, vm::psv::ptr<const SceGxmVertexAttribute> attributes, u32 attributeCount, vm::psv::ptr<const SceGxmVertexStream> streams, u32 streamCount, vm::psv::pptr<SceGxmVertexProgram> vertexProgram)
{
throw __FUNCTION__;
}
s32 sceGxmShaderPatcherCreateFragmentProgram(vm::psv::ptr<SceGxmShaderPatcher> shaderPatcher, SceGxmShaderPatcherId programId, SceGxmOutputRegisterFormat outputFormat, SceGxmMultisampleMode multisampleMode, vm::psv::ptr<const SceGxmBlendInfo> blendInfo, vm::psv::ptr<const SceGxmProgram> vertexProgram, vm::psv::ptr<vm::psv::ptr<SceGxmFragmentProgram>> fragmentProgram)
s32 sceGxmShaderPatcherCreateFragmentProgram(vm::psv::ptr<SceGxmShaderPatcher> shaderPatcher, SceGxmShaderPatcherId programId, SceGxmOutputRegisterFormat outputFormat, SceGxmMultisampleMode multisampleMode, vm::psv::ptr<const SceGxmBlendInfo> blendInfo, vm::psv::ptr<const SceGxmProgram> vertexProgram, vm::psv::pptr<SceGxmFragmentProgram> fragmentProgram)
{
throw __FUNCTION__;
}
@ -1041,12 +1041,12 @@ s32 sceGxmGetRenderTargetMemSizes(vm::psv::ptr<const SceGxmRenderTargetParams> p
throw __FUNCTION__;
}
s32 sceGxmCreateRenderTarget(vm::psv::ptr<const SceGxmRenderTargetParams> params, vm::psv::ptr<vm::psv::ptr<SceGxmRenderTarget>> renderTarget)
s32 sceGxmCreateRenderTarget(vm::psv::ptr<const SceGxmRenderTargetParams> params, vm::psv::pptr<SceGxmRenderTarget> renderTarget)
{
throw __FUNCTION__;
}
s32 sceGxmRenderTargetGetHostMem(vm::psv::ptr<const SceGxmRenderTarget> renderTarget, vm::psv::ptr<vm::psv::ptr<void>> hostMem)
s32 sceGxmRenderTargetGetHostMem(vm::psv::ptr<const SceGxmRenderTarget> renderTarget, vm::psv::pptr<void> hostMem)
{
throw __FUNCTION__;
}

View File

@ -33,7 +33,7 @@ enum SceHttpAuthType : s32
SCE_HTTP_AUTH_RESERVED2
};
typedef vm::psv::ptr<s32(s32 request, SceHttpAuthType authType, vm::psv::ptr<const char> realm, vm::psv::ptr<char> username, vm::psv::ptr<char> password, s32 needEntity, vm::psv::ptr<vm::psv::ptr<u8>> entityBody, vm::psv::ptr<u32> entitySize, vm::psv::ptr<s32> save, vm::psv::ptr<void> userArg)> SceHttpAuthInfoCallback;
typedef vm::psv::ptr<s32(s32 request, SceHttpAuthType authType, vm::psv::ptr<const char> realm, vm::psv::ptr<char> username, vm::psv::ptr<char> password, s32 needEntity, vm::psv::pptr<u8> entityBody, vm::psv::ptr<u32> entitySize, vm::psv::ptr<s32> save, vm::psv::ptr<void> userArg)> SceHttpAuthInfoCallback;
typedef vm::psv::ptr<s32(s32 request, s32 statusCode, vm::psv::ptr<s32> method, vm::psv::ptr<const char> location, vm::psv::ptr<void> userArg)> SceHttpRedirectCallback;
@ -71,7 +71,7 @@ struct SceHttpsData
struct SceHttpsCaList
{
vm::psv::ptr<vm::psv::ptr<SceSslCert>> caCerts;
vm::psv::lpptr<SceSslCert> caCerts;
s32 caNum;
};
@ -167,7 +167,7 @@ s32 sceHttpGetStatusCode(s32 reqId, vm::psv::ptr<s32> statusCode)
throw __FUNCTION__;
}
s32 sceHttpGetAllResponseHeaders(s32 reqId, vm::psv::ptr<vm::psv::ptr<char>> header, vm::psv::ptr<u32> headerSize)
s32 sceHttpGetAllResponseHeaders(s32 reqId, vm::psv::pptr<char> header, vm::psv::ptr<u32> headerSize)
{
throw __FUNCTION__;
}
@ -187,12 +187,12 @@ s32 sceHttpRemoveRequestHeader(s32 id, vm::psv::ptr<const char> name)
throw __FUNCTION__;
}
s32 sceHttpParseResponseHeader(vm::psv::ptr<const char> header, u32 headerLen, vm::psv::ptr<const char> fieldStr, vm::psv::ptr<vm::psv::ptr<const char>> fieldValue, vm::psv::ptr<u32> valueLen)
s32 sceHttpParseResponseHeader(vm::psv::ptr<const char> header, u32 headerLen, vm::psv::ptr<const char> fieldStr, vm::psv::pptr<const char> fieldValue, vm::psv::ptr<u32> valueLen)
{
throw __FUNCTION__;
}
s32 sceHttpParseStatusLine(vm::psv::ptr<const char> statusLine, u32 lineLen, vm::psv::ptr<s32> httpMajorVer, vm::psv::ptr<s32> httpMinorVer, vm::psv::ptr<s32> responseCode, vm::psv::ptr<vm::psv::ptr<const char>> reasonPhrase, vm::psv::ptr<u32> phraseLen)
s32 sceHttpParseStatusLine(vm::psv::ptr<const char> statusLine, u32 lineLen, vm::psv::ptr<s32> httpMajorVer, vm::psv::ptr<s32> httpMinorVer, vm::psv::ptr<s32> responseCode, vm::psv::pptr<const char> reasonPhrase, vm::psv::ptr<u32> phraseLen)
{
throw __FUNCTION__;
}
@ -312,7 +312,7 @@ s32 sceHttpSetCookieSendCallback(s32 id, SceHttpCookieSendCallback cbfunc, vm::p
throw __FUNCTION__;
}
s32 sceHttpsLoadCert(s32 caCertNum, vm::psv::ptr<vm::psv::ptr<const SceHttpsData>> caList, vm::psv::ptr<const SceHttpsData> cert, vm::psv::ptr<const SceHttpsData> privKey)
s32 sceHttpsLoadCert(s32 caCertNum, vm::psv::pptr<const SceHttpsData> caList, vm::psv::ptr<const SceHttpsData> cert, vm::psv::ptr<const SceHttpsData> privKey)
{
throw __FUNCTION__;
}

View File

@ -25,7 +25,7 @@ s32 sceKernelFreeMemBlock(s32 uid)
throw __FUNCTION__;
}
s32 sceKernelGetMemBlockBase(s32 uid, vm::psv::ptr<vm::psv::ptr<void>> ppBase)
s32 sceKernelGetMemBlockBase(s32 uid, vm::psv::pptr<void> ppBase)
{
throw __FUNCTION__;
}

View File

@ -245,7 +245,7 @@ u32 scePerfGetTimebaseFrequency()
return 1;
}
s32 _sceRazorCpuInit(vm::psv::ptr<const void> pBufferBase, u32 bufferSize, u32 numPerfCounters, vm::psv::ptr<vm::psv::ptr<u32>> psceRazorVars)
s32 _sceRazorCpuInit(vm::psv::ptr<const void> pBufferBase, u32 bufferSize, u32 numPerfCounters, vm::psv::pptr<u32> psceRazorVars)
{
throw __FUNCTION__;
}

View File

@ -19,7 +19,7 @@ s32 sceSasInitWithGrain(vm::psv::ptr<const char> config, u32 grain, vm::psv::ptr
throw __FUNCTION__;
}
s32 sceSasExit(vm::psv::ptr<vm::psv::ptr<void>> outBuffer, vm::psv::ptr<u32> outBufferSize)
s32 sceSasExit(vm::psv::pptr<void> outBuffer, vm::psv::ptr<u32> outBufferSize)
{
throw __FUNCTION__;
}

View File

@ -19,7 +19,7 @@ s32 sceSslGetMemoryPoolStats(vm::psv::ptr<SceSslMemoryPoolStats> currentStat)
throw __FUNCTION__;
}
s32 sceSslGetSerialNumber(vm::psv::ptr<SceSslCert> sslCert, vm::psv::ptr<vm::psv::ptr<const u8>> sboData, vm::psv::ptr<u32> sboLen)
s32 sceSslGetSerialNumber(vm::psv::ptr<SceSslCert> sslCert, vm::psv::pptr<const u8> sboData, vm::psv::ptr<u32> sboLen)
{
throw __FUNCTION__;
}

View File

@ -536,7 +536,7 @@ s32 sceUltUlthreadTryJoin(vm::psv::ptr<SceUltUlthread> ulthread, vm::psv::ptr<s3
throw __FUNCTION__;
}
s32 sceUltUlthreadGetSelf(vm::psv::ptr<vm::psv::ptr<SceUltUlthread>> ulthread)
s32 sceUltUlthreadGetSelf(vm::psv::pptr<SceUltUlthread> ulthread)
{
throw __FUNCTION__;
}

View File

@ -126,7 +126,7 @@ struct SceAvcdecArrayPicture
{
u32 numOfOutput;
u32 numOfElm;
vm::psv::ptr<vm::psv::ptr<SceAvcdecPicture>> pPicture;
vm::psv::lpptr<SceAvcdecPicture> pPicture;
};

View File

@ -307,7 +307,7 @@ namespace psv_func_detail
template <typename RT, typename F, typename Tuple>
force_inline RT call(F f, Tuple && t)
{
typedef typename std::decay<Tuple>::type ttype;
using ttype = std::decay_t<Tuple>;
return psv_func_detail::call_impl<RT, F, Tuple, 0 == std::tuple_size<ttype>::value, std::tuple_size<ttype>::value>::call(f, std::forward<Tuple>(t));
}

View File

@ -845,16 +845,14 @@ struct cast_ppu_gpr
{
static_assert(is_enum, "Invalid type for cast_ppu_gpr");
typedef typename std::underlying_type<T>::type underlying_type;
force_inline static u64 to_gpr(const T& value)
{
return cast_ppu_gpr<underlying_type>::to_gpr(static_cast<underlying_type>(value));
return cast_ppu_gpr<std::underlying_type_t<T>>::to_gpr(static_cast<std::underlying_type_t<T>>(value));
}
force_inline static T from_gpr(const u64 reg)
{
return static_cast<T>(cast_ppu_gpr<underlying_type>::from_gpr(reg));
return static_cast<T>(cast_ppu_gpr<std::underlying_type_t<T>>::from_gpr(reg));
}
};

View File

@ -1,46 +1,41 @@
#pragma once
template<typename T, size_t size = sizeof(T)>
struct _to_atomic_subtype
template<typename T, size_t size = sizeof(T)> struct _to_atomic_subtype
{
static_assert(size == 1 || size == 2 || size == 4 || size == 8 || size == 16, "Invalid atomic type");
};
template<typename T>
struct _to_atomic_subtype<T, 1>
template<typename T> struct _to_atomic_subtype<T, 1>
{
using type = uint8_t;
using type = u8;
};
template<typename T>
struct _to_atomic_subtype<T, 2>
template<typename T> struct _to_atomic_subtype<T, 2>
{
using type = uint16_t;
using type = u16;
};
template<typename T>
struct _to_atomic_subtype<T, 4>
template<typename T> struct _to_atomic_subtype<T, 4>
{
using type = uint32_t;
using type = u32;
};
template<typename T>
struct _to_atomic_subtype<T, 8>
template<typename T> struct _to_atomic_subtype<T, 8>
{
using type = uint64_t;
using type = u64;
};
template<typename T>
struct _to_atomic_subtype<T, 16>
template<typename T> struct _to_atomic_subtype<T, 16>
{
using type = u128;
};
template<typename T>
union _atomic_base
template<typename T> using atomic_subtype_t = typename _to_atomic_subtype<T>::type;
template<typename T> union _atomic_base
{
using type = typename std::remove_cv<T>::type;
using subtype = typename _to_atomic_subtype<type, sizeof(type)>::type;
using type = std::remove_cv_t<T>;
using subtype = atomic_subtype_t<type>;
type data; // unsafe direct access
subtype sub_data; // unsafe direct access to substitute type
@ -195,42 +190,40 @@ public:
}
};
// Helper definitions
template<typename T, typename T2 = T> using if_integral_le_t = std::enable_if_t<std::is_integral<T>::value && std::is_integral<T2>::value, le_t<T>>;
template<typename T, typename T2 = T> using if_integral_be_t = std::enable_if_t<std::is_integral<T>::value && std::is_integral<T2>::value, be_t<T>>;
template<typename T, typename T2 = T> using if_arithmetic_le_t = const typename std::enable_if<std::is_arithmetic<T>::value && std::is_arithmetic<T2>::value, le_t<T>>::type;
template<typename T, typename T2 = T> using if_arithmetic_be_t = const typename std::enable_if<std::is_arithmetic<T>::value && std::is_arithmetic<T2>::value, be_t<T>>::type;
template<typename T> inline static if_arithmetic_le_t<T> operator ++(_atomic_base<le_t<T>>& left)
template<typename T> inline if_integral_le_t<T> operator ++(_atomic_base<le_t<T>>& left)
{
return left.from_subtype(sync_fetch_and_add(&left.sub_data, 1) + 1);
}
template<typename T> inline static if_arithmetic_le_t<T> operator --(_atomic_base<le_t<T>>& left)
template<typename T> inline if_integral_le_t<T> operator --(_atomic_base<le_t<T>>& left)
{
return left.from_subtype(sync_fetch_and_sub(&left.sub_data, 1) - 1);
}
template<typename T> inline static if_arithmetic_le_t<T> operator ++(_atomic_base<le_t<T>>& left, int)
template<typename T> inline if_integral_le_t<T> operator ++(_atomic_base<le_t<T>>& left, int)
{
return left.from_subtype(sync_fetch_and_add(&left.sub_data, 1));
}
template<typename T> inline static if_arithmetic_le_t<T> operator --(_atomic_base<le_t<T>>& left, int)
template<typename T> inline if_integral_le_t<T> operator --(_atomic_base<le_t<T>>& left, int)
{
return left.from_subtype(sync_fetch_and_sub(&left.sub_data, 1));
}
template<typename T, typename T2> inline static if_arithmetic_le_t<T, T2> operator +=(_atomic_base<le_t<T>>& left, T2 right)
template<typename T, typename T2> inline if_integral_le_t<T, T2> operator +=(_atomic_base<le_t<T>>& left, T2 right)
{
return left.from_subtype(sync_fetch_and_add(&left.sub_data, right) + right);
}
template<typename T, typename T2> inline static if_arithmetic_le_t<T, T2> operator -=(_atomic_base<le_t<T>>& left, T2 right)
template<typename T, typename T2> inline if_integral_le_t<T, T2> operator -=(_atomic_base<le_t<T>>& left, T2 right)
{
return left.from_subtype(sync_fetch_and_sub(&left.sub_data, right) - right);
}
template<typename T> inline static if_arithmetic_be_t<T> operator ++(_atomic_base<be_t<T>>& left)
template<typename T> inline if_integral_be_t<T> operator ++(_atomic_base<be_t<T>>& left)
{
be_t<T> result;
@ -242,7 +235,7 @@ template<typename T> inline static if_arithmetic_be_t<T> operator ++(_atomic_bas
return result;
}
template<typename T> inline static if_arithmetic_be_t<T> operator --(_atomic_base<be_t<T>>& left)
template<typename T> inline if_integral_be_t<T> operator --(_atomic_base<be_t<T>>& left)
{
be_t<T> result;
@ -254,7 +247,7 @@ template<typename T> inline static if_arithmetic_be_t<T> operator --(_atomic_bas
return result;
}
template<typename T> inline static if_arithmetic_be_t<T> operator ++(_atomic_base<be_t<T>>& left, int)
template<typename T> inline if_integral_be_t<T> operator ++(_atomic_base<be_t<T>>& left, int)
{
be_t<T> result;
@ -266,7 +259,7 @@ template<typename T> inline static if_arithmetic_be_t<T> operator ++(_atomic_bas
return result;
}
template<typename T> inline static if_arithmetic_be_t<T> operator --(_atomic_base<be_t<T>>& left, int)
template<typename T> inline if_integral_be_t<T> operator --(_atomic_base<be_t<T>>& left, int)
{
be_t<T> result;
@ -278,7 +271,7 @@ template<typename T> inline static if_arithmetic_be_t<T> operator --(_atomic_bas
return result;
}
template<typename T, typename T2> inline static if_arithmetic_be_t<T, T2> operator +=(_atomic_base<be_t<T>>& left, T2 right)
template<typename T, typename T2> inline if_integral_be_t<T, T2> operator +=(_atomic_base<be_t<T>>& left, T2 right)
{
be_t<T> result;
@ -290,7 +283,7 @@ template<typename T, typename T2> inline static if_arithmetic_be_t<T, T2> operat
return result;
}
template<typename T, typename T2> inline static if_arithmetic_be_t<T, T2> operator -=(_atomic_base<be_t<T>>& left, T2 right)
template<typename T, typename T2> inline if_integral_be_t<T, T2> operator -=(_atomic_base<be_t<T>>& left, T2 right)
{
be_t<T> result;
@ -304,6 +297,6 @@ template<typename T, typename T2> inline static if_arithmetic_be_t<T, T2> operat
template<typename T> using atomic = _atomic_base<T>; // Atomic Type with native endianness (for emulator memory)
template<typename T> using atomic_be_t = _atomic_base<typename to_be_t<T>::type>; // Atomic BE Type (for PS3 virtual memory)
template<typename T> using atomic_be_t = _atomic_base<to_be_t<T>>; // Atomic BE Type (for PS3 virtual memory)
template<typename T> using atomic_le_t = _atomic_base<typename to_le_t<T>::type>; // Atomic LE Type (for PSV virtual memory)
template<typename T> using atomic_le_t = _atomic_base<to_le_t<T>>; // Atomic LE Type (for PSV virtual memory)

View File

@ -127,10 +127,10 @@ namespace vm
}
};
template<typename T, typename T2>
struct cast_ptr<be_t<T, T2>>
template<typename T>
struct cast_ptr<be_t<T>>
{
force_inline static u32 cast(const be_t<T, T2>& addr, const char* func)
force_inline static u32 cast(const be_t<T>& addr, const char* func)
{
return cast_ptr<T>::cast(addr.value(), func);
}

View File

@ -5,209 +5,29 @@ struct ARMv7Context;
namespace vm
{
template<typename T, int lvl = 1, typename AT = u32>
template<typename T, typename AT = u32>
struct _ptr_base
{
AT m_addr;
typedef typename std::remove_cv<T>::type type;
static const u32 address_size = sizeof(AT);
using type = T;
_ptr_base operator++ (int)
{
AT result = m_addr;
m_addr += address_size;
return make(result);
}
_ptr_base& operator++ ()
{
m_addr += address_size;
return *this;
}
_ptr_base operator-- (int)
{
AT result = m_addr;
m_addr -= address_size;
return make(result);
}
_ptr_base& operator-- ()
{
m_addr -= address_size;
return *this;
}
_ptr_base& operator += (AT count)
{
m_addr += count * address_size;
return *this;
}
_ptr_base& operator -= (AT count)
{
m_addr -= count * address_size;
return *this;
}
_ptr_base operator + (typename remove_be_t<AT>::type count) const { return make(m_addr + count * address_size); }
_ptr_base operator + (typename to_be_t<AT>::type count) const { return make(m_addr + count * address_size); }
_ptr_base operator - (typename remove_be_t<AT>::type count) const { return make(m_addr - count * address_size); }
_ptr_base operator - (typename to_be_t<AT>::type count) const { return make(m_addr - count * address_size); }
force_inline bool operator <(const _ptr_base& right) const { return m_addr < right.m_addr; }
force_inline bool operator <=(const _ptr_base& right) const { return m_addr <= right.m_addr; }
force_inline bool operator >(const _ptr_base& right) const { return m_addr > right.m_addr; }
force_inline bool operator >=(const _ptr_base& right) const { return m_addr >= right.m_addr; }
force_inline bool operator ==(const _ptr_base& right) const { return m_addr == right.m_addr; }
force_inline bool operator !=(const _ptr_base& right) const { return m_addr != right.m_addr; }
force_inline bool operator ==(const nullptr_t& right) const { return m_addr == 0; }
force_inline bool operator !=(const nullptr_t& right) const { return m_addr != 0; }
explicit operator bool() const { return m_addr != 0; }
force_inline _ptr_base<T, lvl - 1, typename std::conditional<is_be_t<T>::value, typename to_be_t<AT>::type, AT>::type> operator *() const
{
AT addr = convert_le_be<AT>(read64(convert_le_be<u32>(m_addr)));
return (_ptr_base<T, lvl - 1, typename std::conditional<is_be_t<T>::value, typename to_be_t<AT>::type, AT>::type>&)addr;
}
force_inline _ptr_base<T, lvl - 1, typename std::conditional<is_be_t<T>::value, typename to_be_t<AT>::type, AT>::type> operator [](AT index) const
{
AT addr = convert_le_be<AT>(read64(convert_le_be<u32>(m_addr + 8 * index)));
return (_ptr_base<T, lvl - 1, typename std::conditional<is_be_t<T>::value, typename to_be_t<AT>::type, AT>::type>&)addr;
}
template<typename AT2>
operator _ptr_base<T, lvl, AT2>() const
{
AT2 addr = convert_le_be<AT2>(m_addr);
return reinterpret_cast<_ptr_base<T, lvl, AT2>&>(addr);
}
AT addr() const
{
return m_addr;
}
template<typename U>
void set(U&& value)
{
m_addr = convert_le_be<AT>(value);
}
static _ptr_base make(const AT& addr)
{
return reinterpret_cast<const _ptr_base&>(addr);
}
_ptr_base& operator = (const _ptr_base& right) = default;
};
template<typename T, typename AT>
struct _ptr_base<T, 1, AT>
{
AT m_addr;
static_assert(!std::is_pointer<T>::value, "vm::_ptr_base<> error: invalid type (pointer)");
static_assert(!std::is_reference<T>::value, "vm::_ptr_base<> error: invalid type (reference)");
typedef typename std::remove_cv<T>::type type;
force_inline static const u32 data_size()
{
return convert_le_be<AT>(sizeof(T));
}
force_inline T* const operator -> () const
{
return vm::get_ptr<T>(vm::cast(m_addr));
}
_ptr_base operator++ (int)
{
AT result = m_addr;
m_addr += data_size();
return make(result);
}
_ptr_base& operator++ ()
{
m_addr += data_size();
return *this;
}
_ptr_base operator-- (int)
{
AT result = m_addr;
m_addr -= data_size();
return make(result);
}
_ptr_base& operator-- ()
{
m_addr -= data_size();
return *this;
}
_ptr_base& operator += (AT count)
{
m_addr += count * data_size();
return *this;
}
_ptr_base& operator -= (AT count)
{
m_addr -= count * data_size();
return *this;
}
_ptr_base operator + (typename remove_be_t<AT>::type count) const { return make(convert_le_be<AT>(convert_le_be<decltype(count)>(m_addr) + count * convert_le_be<decltype(count)>(data_size()))); }
_ptr_base operator + (typename to_be_t<AT>::type count) const { return make(convert_le_be<AT>(convert_le_be<decltype(count)>(m_addr) + count * convert_le_be<decltype(count)>(data_size()))); }
_ptr_base operator - (typename remove_be_t<AT>::type count) const { return make(convert_le_be<AT>(convert_le_be<decltype(count)>(m_addr) - count * convert_le_be<decltype(count)>(data_size()))); }
_ptr_base operator - (typename to_be_t<AT>::type count) const { return make(convert_le_be<AT>(convert_le_be<decltype(count)>(m_addr) - count * convert_le_be<decltype(count)>(data_size()))); }
force_inline T& operator *() const
{
return vm::get_ref<T>(vm::cast(m_addr));
}
force_inline T& operator [](typename remove_be_t<AT>::type index) const
{
return vm::get_ref<T>(vm::cast(m_addr + data_size() * index));
}
force_inline T& operator [](typename to_be_t<AT>::forced_type index) const
{
return vm::get_ref<T>(vm::cast(m_addr + data_size() * index));
}
force_inline bool operator <(const _ptr_base& right) const { return m_addr < right.m_addr; }
force_inline bool operator <=(const _ptr_base& right) const { return m_addr <= right.m_addr; }
force_inline bool operator >(const _ptr_base& right) const { return m_addr > right.m_addr; }
force_inline bool operator >=(const _ptr_base& right) const { return m_addr >= right.m_addr; }
force_inline bool operator ==(const _ptr_base& right) const { return m_addr == right.m_addr; }
force_inline bool operator !=(const _ptr_base& right) const { return m_addr != right.m_addr; }
force_inline bool operator ==(const nullptr_t& right) const { return m_addr == 0; }
force_inline bool operator !=(const nullptr_t& right) const { return m_addr != 0; }
explicit operator bool() const { return m_addr != 0; }
explicit operator T*() const { return get_ptr(); }
AT addr() const
{
return m_addr;
}
template<typename U>
void set(U&& value)
template<typename CT> std::enable_if_t<std::is_assignable<AT&, CT>::value> set(const CT& value)
{
m_addr = convert_le_be<AT>(value);
m_addr = value;
}
template<typename AT2>
operator _ptr_base<T, 1, AT2>() const
template<typename AT2 = AT> static _ptr_base make(const AT2& addr)
{
AT2 addr = convert_le_be<AT2>(m_addr);
return reinterpret_cast<_ptr_base<T, 1, AT2>&>(addr);
return{ convert_le_be<AT>(addr) };
}
T* get_ptr() const
@ -219,140 +39,59 @@ namespace vm
{
return vm::priv_ptr<T>(vm::cast(m_addr));
}
static const _ptr_base make(const AT& addr)
{
return reinterpret_cast<const _ptr_base&>(addr);
}
_ptr_base& operator = (const _ptr_base& right) = default;
};
template<typename AT>
struct _ptr_base<void, 1, AT>
{
AT m_addr;
AT addr() const
{
return m_addr;
}
template<typename U>
void set(U&& value)
{
m_addr = convert_le_be<AT>(value);
}
void* get_ptr() const
{
return vm::get_ptr<void>(vm::cast(m_addr));
}
void* priv_ptr() const
{
return vm::priv_ptr<void>(vm::cast(m_addr));
}
explicit operator void*() const
T* operator ->() const
{
return get_ptr();
}
force_inline bool operator <(const _ptr_base& right) const { return m_addr < right.m_addr; }
force_inline bool operator <=(const _ptr_base& right) const { return m_addr <= right.m_addr; }
force_inline bool operator >(const _ptr_base& right) const { return m_addr > right.m_addr; }
force_inline bool operator >=(const _ptr_base& right) const { return m_addr >= right.m_addr; }
force_inline bool operator ==(const _ptr_base& right) const { return m_addr == right.m_addr; }
force_inline bool operator !=(const _ptr_base& right) const { return m_addr != right.m_addr; }
force_inline bool operator ==(const nullptr_t& right) const { return m_addr == 0; }
force_inline bool operator !=(const nullptr_t& right) const { return m_addr != 0; }
explicit operator bool() const { return m_addr != 0; }
template<typename AT2>
operator _ptr_base<void, 1, AT2>() const
std::add_lvalue_reference_t<T> operator [](u32 index) const
{
AT2 addr = convert_le_be<AT2>(m_addr);
return reinterpret_cast<_ptr_base<void, 1, AT2>&>(addr);
static_assert(!std::is_void<T>::value, "vm::_ptr_base<> error: operator[] is not available for void pointers");
return vm::get_ref<T>(vm::cast(m_addr + sizeof32(T) * index));
}
template<typename AT2>
operator _ptr_base<const void, 1, AT2>() const
// enable only the conversions which are originally possible between pointer types
template<typename T2, typename AT2, typename dummy = std::enable_if_t<std::is_convertible<T*, T2*>::value>> operator _ptr_base<T2, AT2>() const
{
AT2 addr = convert_le_be<AT2>(m_addr);
return reinterpret_cast<_ptr_base<const void, 1, AT2>&>(addr);
return{ convert_le_be<AT2>(vm::cast(m_addr)) };
}
static const _ptr_base make(const AT& addr)
{
return reinterpret_cast<const _ptr_base&>(addr);
}
_ptr_base& operator = (const _ptr_base& right) = default;
};
template<typename AT>
struct _ptr_base<const void, 1, AT>
{
AT m_addr;
AT addr() const
{
return m_addr;
}
template<typename U>
void set(U&& value)
{
m_addr = convert_le_be<AT>(value);
}
const void* get_ptr() const
{
return vm::get_ptr<const void>(vm::cast(m_addr));
}
const void* priv_ptr() const
{
return vm::priv_ptr<const void>(vm::cast(m_addr));
}
explicit operator const void*() const
template<typename T2, typename dummy = std::enable_if_t<std::is_convertible<T*, T2*>::value>> explicit operator T2*() const
{
return get_ptr();
}
force_inline bool operator <(const _ptr_base& right) const { return m_addr < right.m_addr; }
force_inline bool operator <=(const _ptr_base& right) const { return m_addr <= right.m_addr; }
force_inline bool operator >(const _ptr_base& right) const { return m_addr > right.m_addr; }
force_inline bool operator >=(const _ptr_base& right) const { return m_addr >= right.m_addr; }
force_inline bool operator ==(const _ptr_base& right) const { return m_addr == right.m_addr; }
force_inline bool operator !=(const _ptr_base& right) const { return m_addr != right.m_addr; }
force_inline bool operator ==(const nullptr_t& right) const { return m_addr == 0; }
force_inline bool operator !=(const nullptr_t& right) const { return m_addr != 0; }
explicit operator bool() const { return m_addr != 0; }
template<typename AT2>
operator _ptr_base<const void, 1, AT2>() const
explicit operator bool() const
{
AT2 addr = convert_le_be<AT2>(m_addr);
return reinterpret_cast<_ptr_base<const void, 1, AT2>&>(addr);
return m_addr != 0;
}
static const _ptr_base make(const AT& addr)
{
return reinterpret_cast<const _ptr_base&>(addr);
}
_ptr_base& operator = (const _ptr_base& right) = default;
_ptr_base& operator =(const _ptr_base&) = default;
};
template<typename AT, typename RT, typename ...T>
struct _ptr_base<RT(T...), 1, AT>
struct _ptr_base<RT(T...), AT>
{
AT m_addr;
typedef RT(type)(T...);
using type = func_def<RT(T...)>;
AT addr() const
{
return m_addr;
}
template<typename CT> std::enable_if_t<std::is_assignable<AT&, CT>::value> set(const CT& value)
{
m_addr = value;
}
template<typename AT2 = AT> static _ptr_base make(const AT2& addr)
{
return{ convert_le_be<AT>(addr) };
}
// defined in CB_FUNC.h, call using specified PPU thread context
RT operator()(PPUThread& CPU, T... args) const;
@ -363,50 +102,33 @@ namespace vm
// defined in CB_FUNC.h, call using current PPU thread context
RT operator()(T... args) const;
AT addr() const
// conversion to function object
operator std::function<type>() const
{
return m_addr;
const u32 addr = vm::cast(m_addr);
return [addr](T... args) -> RT
{
return _ptr_base<RT(T...)>{ addr }(args...);
};
}
template<typename U>
void set(U&& value)
// conversion to another function pointer
template<typename AT2> operator _ptr_base<type, AT2>() const
{
m_addr = convert_le_be<AT>(value);
return{ convert_le_be<AT2>(vm::cast(m_addr)) };
}
force_inline bool operator <(const _ptr_base& right) const { return m_addr < right.m_addr; }
force_inline bool operator <=(const _ptr_base& right) const { return m_addr <= right.m_addr; }
force_inline bool operator >(const _ptr_base& right) const { return m_addr > right.m_addr; }
force_inline bool operator >=(const _ptr_base& right) const { return m_addr >= right.m_addr; }
force_inline bool operator ==(const _ptr_base& right) const { return m_addr == right.m_addr; }
force_inline bool operator !=(const _ptr_base& right) const { return m_addr != right.m_addr; }
force_inline bool operator ==(const nullptr_t& right) const { return m_addr == 0; }
force_inline bool operator !=(const nullptr_t& right) const { return m_addr != 0; }
explicit operator bool() const { return m_addr != 0; }
template<typename AT2>
operator _ptr_base<type, 1, AT2>() const
explicit operator bool() const
{
AT2 addr = convert_le_be<AT2>(m_addr);
return reinterpret_cast<_ptr_base<type, 1, AT2>&>(addr);
return m_addr != 0;
}
static const _ptr_base make(const AT& addr)
{
return reinterpret_cast<const _ptr_base&>(addr);
}
operator const std::function<type>() const
{
const AT addr = convert_le_be<AT>(m_addr);
return [addr](T... args) -> RT { return make(addr)(args...); };
}
_ptr_base& operator = (const _ptr_base& right) = default;
_ptr_base& operator =(const _ptr_base&) = default;
};
template<typename AT, typename RT, typename ...T>
struct _ptr_base<RT(*)(T...), 1, AT>
struct _ptr_base<RT(*)(T...), AT>
{
AT m_addr;
@ -414,39 +136,51 @@ namespace vm
};
// Native endianness pointer to LE data
template<typename T, int lvl = 1, typename AT = u32> using ptrl = _ptr_base<typename to_le_t<T>::type, lvl, AT>;
template<typename T, typename AT = u32> using ptrl = _ptr_base<to_le_t<T>, AT>;
// Native endianness pointer to BE data
template<typename T, int lvl = 1, typename AT = u32> using ptrb = _ptr_base<typename to_be_t<T>::type, lvl, AT>;
template<typename T, typename AT = u32> using ptrb = _ptr_base<to_be_t<T>, AT>;
// BE pointer to LE data
template<typename T, int lvl = 1, typename AT = u32> using bptrl = _ptr_base<typename to_le_t<T>::type, lvl, typename to_be_t<AT>::type>;
template<typename T, typename AT = u32> using bptrl = _ptr_base<to_le_t<T>, to_be_t<AT>>;
// BE pointer to BE data
template<typename T, int lvl = 1, typename AT = u32> using bptrb = _ptr_base<typename to_be_t<T>::type, lvl, typename to_be_t<AT>::type>;
template<typename T, typename AT = u32> using bptrb = _ptr_base<to_be_t<T>, to_be_t<AT>>;
// LE pointer to LE data
template<typename T, int lvl = 1, typename AT = u32> using lptrl = _ptr_base<typename to_le_t<T>::type, lvl, typename to_le_t<AT>::type>;
template<typename T, typename AT = u32> using lptrl = _ptr_base<to_le_t<T>, to_le_t<AT>>;
// LE pointer to BE data
template<typename T, int lvl = 1, typename AT = u32> using lptrb = _ptr_base<typename to_be_t<T>::type, lvl, typename to_le_t<AT>::type>;
template<typename T, typename AT = u32> using lptrb = _ptr_base<to_be_t<T>, to_le_t<AT>>;
namespace ps3
{
// default pointer for PS3 HLE functions (Native endianness pointer to BE data)
template<typename T, int lvl = 1, typename AT = u32> using ptr = ptrb<T, lvl, AT>;
template<typename T, typename AT = u32> using ptr = ptrb<T, AT>;
// default pointer to pointer for PS3 HLE functions (Native endianness pointer to BE pointer to BE data)
template<typename T, typename AT = u32, typename AT2 = u32> using pptr = ptr<ptr<T, AT2>, AT>;
// default pointer for PS3 HLE structures (BE pointer to BE data)
template<typename T, int lvl = 1, typename AT = u32> using bptr = bptrb<T, lvl, AT>;
template<typename T, typename AT = u32> using bptr = bptrb<T, AT>;
// default pointer to pointer for PS3 HLE structures (BE pointer to BE pointer to BE data)
template<typename T, typename AT = u32, typename AT2 = u32> using bpptr = bptr<ptr<T, AT2>, AT>;
}
namespace psv
{
// default pointer for PSV HLE functions (Native endianness pointer to LE data)
template<typename T, int lvl = 1, typename AT = u32> using ptr = ptrl<T, lvl, AT>;
template<typename T> using ptr = ptrl<T>;
// default pointer to pointer for PSV HLE functions (Native endianness pointer to LE pointer to LE data)
template<typename T> using pptr = ptr<ptr<T>>;
// default pointer for PSV HLE structures (LE pointer to LE data)
template<typename T, int lvl = 1, typename AT = u32> using lptr = lptrl<T, lvl, AT>;
template<typename T> using lptr = lptrl<T>;
// default pointer to pointer for PSV HLE structures (LE pointer to LE pointer to LE data)
template<typename T> using lpptr = lptr<ptr<T>>;
}
// PS3 emulation is main now, so lets it be as default
@ -454,27 +188,198 @@ namespace vm
struct null_t
{
template<typename T, int lvl, typename AT> operator _ptr_base<T, lvl, AT>() const
template<typename T, typename AT> operator _ptr_base<T, AT>() const
{
const std::array<AT, 1> value = {};
return _ptr_base<T, lvl, AT>::make(value[0]);
return{};
}
};
// vm::null is convertible to any vm::ptr type as null pointer in virtual memory
static null_t null;
// helper SFINAE type for vm::_ptr_base comparison operators (enables comparison between equal types and between any type and void*)
template<typename T1, typename T2, typename RT> using if_comparable_t = std::enable_if_t<
std::is_void<T1>::value ||
std::is_void<T2>::value ||
std::is_same<std::remove_cv_t<T1>, std::remove_cv_t<T2>>::value,
RT>;
// helper SFINAE type for vm::_ptr_base pointer arithmetic operators and indirection (disabled for void and function pointers)
template<typename T, typename RT> using if_arithmetical_t = std::enable_if_t<
!std::is_void<T>::value && !std::is_function<T>::value,
RT>;
}
// unary plus operator for vm::_ptr_base (always available)
template<typename T, typename AT> inline vm::_ptr_base<T, AT> operator +(const vm::_ptr_base<T, AT>& ptr)
{
return ptr;
}
// indirection operator for vm::_ptr_base
template<typename T, typename AT> inline vm::if_arithmetical_t<T, T&> operator *(const vm::_ptr_base<T, AT>& ptr)
{
return vm::get_ref<T>(vm::cast(ptr.m_addr));
}
// postfix increment operator for vm::_ptr_base
template<typename T, typename AT> inline vm::if_arithmetical_t<T, vm::_ptr_base<T, AT>> operator ++(vm::_ptr_base<T, AT>& ptr, int)
{
const AT result = ptr.m_addr;
ptr.m_addr += sizeof32(T);
return{ result };
}
// prefix increment operator for vm::_ptr_base
template<typename T, typename AT> inline vm::if_arithmetical_t<T, vm::_ptr_base<T, AT>&> operator ++(vm::_ptr_base<T, AT>& ptr)
{
ptr.m_addr += sizeof32(T);
return ptr;
}
// postfix decrement operator for vm::_ptr_base
template<typename T, typename AT> inline vm::if_arithmetical_t<T, vm::_ptr_base<T, AT>> operator --(vm::_ptr_base<T, AT>& ptr, int)
{
const AT result = ptr.m_addr;
ptr.m_addr -= sizeof32(T);
return{ result };
}
// prefix decrement operator for vm::_ptr_base
template<typename T, typename AT> inline vm::if_arithmetical_t<T, vm::_ptr_base<T, AT>&> operator --(vm::_ptr_base<T, AT>& ptr)
{
ptr.m_addr -= sizeof32(T);
return ptr;
}
// addition assignment operator for vm::_ptr_base (pointer += integer)
template<typename T, typename AT> inline vm::if_arithmetical_t<T, vm::_ptr_base<T, AT>&> operator +=(vm::_ptr_base<T, AT>& ptr, to_ne_t<AT> count)
{
ptr.m_addr += count * sizeof32(T);
return ptr;
}
// subtraction assignment operator for vm::_ptr_base (pointer -= integer)
template<typename T, typename AT> inline vm::if_arithmetical_t<T, vm::_ptr_base<T, AT>&> operator -=(vm::_ptr_base<T, AT>& ptr, to_ne_t<AT> count)
{
ptr.m_addr -= count * sizeof32(T);
return ptr;
}
// addition operator for vm::_ptr_base (pointer + integer)
template<typename T, typename AT> inline vm::if_arithmetical_t<T, vm::_ptr_base<T, AT>> operator +(const vm::_ptr_base<T, AT>& ptr, to_ne_t<AT> count)
{
return{ convert_le_be<AT>(ptr.m_addr + count * sizeof32(T)) };
}
// addition operator for vm::_ptr_base (integer + pointer)
template<typename T, typename AT> inline vm::if_arithmetical_t<T, vm::_ptr_base<T, AT>> operator +(to_ne_t<AT> count, const vm::_ptr_base<T, AT>& ptr)
{
return{ convert_le_be<AT>(ptr.m_addr + count * sizeof32(T)) };
}
// subtraction operator for vm::_ptr_base (pointer - integer)
template<typename T, typename AT> inline vm::if_arithmetical_t<T, vm::_ptr_base<T, AT>> operator -(const vm::_ptr_base<T, AT>& ptr, to_ne_t<AT> count)
{
return{ convert_le_be<AT>(ptr.m_addr - count * sizeof32(T)) };
}
// pointer difference operator for vm::_ptr_base
template<typename T1, typename AT1, typename T2, typename AT2> inline std::enable_if_t<
!std::is_void<T1>::value &&
!std::is_void<T2>::value &&
!std::is_function<T1>::value &&
!std::is_function<T2>::value &&
std::is_same<std::remove_cv_t<T1>, std::remove_cv_t<T2>>::value,
u32> operator -(const vm::_ptr_base<T1, AT1>& left, const vm::_ptr_base<T2, AT2>& right)
{
return static_cast<u32>((left.m_addr - right.m_addr) / sizeof32(T1));
}
// comparison operator for vm::_ptr_base (pointer1 == pointer2)
template<typename T1, typename AT1, typename T2, typename AT2> vm::if_comparable_t<T1, T2, bool> operator ==(const vm::_ptr_base<T1, AT1>& left, const vm::_ptr_base<T2, AT2>& right)
{
return left.m_addr == right.m_addr;
}
// comparison operator for vm::_ptr_base (pointer1 != pointer2)
template<typename T1, typename AT1, typename T2, typename AT2> vm::if_comparable_t<T1, T2, bool> operator !=(const vm::_ptr_base<T1, AT1>& left, const vm::_ptr_base<T2, AT2>& right)
{
return left.m_addr != right.m_addr;
}
// comparison operator for vm::_ptr_base (pointer1 < pointer2)
template<typename T1, typename AT1, typename T2, typename AT2> vm::if_comparable_t<T1, T2, bool> operator <(const vm::_ptr_base<T1, AT1>& left, const vm::_ptr_base<T2, AT2>& right)
{
return left.m_addr < right.m_addr;
}
// comparison operator for vm::_ptr_base (pointer1 <= pointer2)
template<typename T1, typename AT1, typename T2, typename AT2> vm::if_comparable_t<T1, T2, bool> operator <=(const vm::_ptr_base<T1, AT1>& left, const vm::_ptr_base<T2, AT2>& right)
{
return left.m_addr <= right.m_addr;
}
// comparison operator for vm::_ptr_base (pointer1 > pointer2)
template<typename T1, typename AT1, typename T2, typename AT2> vm::if_comparable_t<T1, T2, bool> operator >(const vm::_ptr_base<T1, AT1>& left, const vm::_ptr_base<T2, AT2>& right)
{
return left.m_addr > right.m_addr;
}
// comparison operator for vm::_ptr_base (pointer1 >= pointer2)
template<typename T1, typename AT1, typename T2, typename AT2> vm::if_comparable_t<T1, T2, bool> operator >=(const vm::_ptr_base<T1, AT1>& left, const vm::_ptr_base<T2, AT2>& right)
{
return left.m_addr >= right.m_addr;
}
// external specialization for is_be_t<> (true if AT is be_t<>)
template<typename T, typename AT>
struct is_be_t<vm::_ptr_base<T, AT>> : public std::integral_constant<bool, is_be_t<AT>::value>
{
};
// external specialization for is_le_t<> (true if AT is le_t<>)
template<typename T, typename AT>
struct is_le_t<vm::_ptr_base<T, AT>> : public std::integral_constant<bool, is_le_t<AT>::value>
{
};
// external specialization for to_ne_t<> (change AT endianness to native)
template<typename T, typename AT>
struct to_ne<vm::_ptr_base<T, AT>>
{
using type = vm::_ptr_base<T, to_ne_t<AT>>;
};
// external specialization for to_be_t<> (change AT endianness to BE)
template<typename T, typename AT>
struct to_be<vm::_ptr_base<T, AT>>
{
using type = vm::_ptr_base<T, to_be_t<AT>>;
};
// external specialization for to_le_t<> (change AT endianness to LE)
template<typename T, typename AT>
struct to_le<vm::_ptr_base<T, AT>>
{
using type = vm::_ptr_base<T, to_le_t<AT>>;
};
namespace fmt
{
// external specialization for fmt::format function
template<typename T, int lvl, typename AT>
struct unveil<vm::_ptr_base<T, lvl, AT>, false>
template<typename T, typename AT>
struct unveil<vm::_ptr_base<T, AT>, false>
{
typedef typename unveil<AT>::result_type result_type;
using result_type = typename unveil<AT>::result_type;
force_inline static result_type get_value(const vm::_ptr_base<T, lvl, AT>& arg)
force_inline static result_type get_value(const vm::_ptr_base<T, AT>& arg)
{
return unveil<AT>::get_value(arg.addr());
}
@ -486,17 +391,17 @@ namespace fmt
template<typename T, bool is_enum>
struct cast_ppu_gpr;
template<typename T, int lvl, typename AT>
struct cast_ppu_gpr<vm::_ptr_base<T, lvl, AT>, false>
template<typename T, typename AT>
struct cast_ppu_gpr<vm::_ptr_base<T, AT>, false>
{
force_inline static u64 to_gpr(const vm::_ptr_base<T, lvl, AT>& value)
force_inline static u64 to_gpr(const vm::_ptr_base<T, AT>& value)
{
return cast_ppu_gpr<AT, std::is_enum<AT>::value>::to_gpr(value.addr());
}
force_inline static vm::_ptr_base<T, lvl, AT> from_gpr(const u64 reg)
force_inline static vm::_ptr_base<T, AT> from_gpr(const u64 reg)
{
return vm::_ptr_base<T, lvl, AT>::make(cast_ppu_gpr<AT, std::is_enum<AT>::value>::from_gpr(reg));
return vm::_ptr_base<T, AT>::make(cast_ppu_gpr<AT, std::is_enum<AT>::value>::from_gpr(reg));
}
};
@ -505,16 +410,16 @@ struct cast_ppu_gpr<vm::_ptr_base<T, lvl, AT>, false>
template<typename T, bool is_enum>
struct cast_armv7_gpr;
template<typename T, int lvl, typename AT>
struct cast_armv7_gpr<vm::_ptr_base<T, lvl, AT>, false>
template<typename T, typename AT>
struct cast_armv7_gpr<vm::_ptr_base<T, AT>, false>
{
force_inline static u32 to_gpr(const vm::_ptr_base<T, lvl, AT>& value)
force_inline static u32 to_gpr(const vm::_ptr_base<T, AT>& value)
{
return cast_armv7_gpr<AT, std::is_enum<AT>::value>::to_gpr(value.addr());
}
force_inline static vm::_ptr_base<T, lvl, AT> from_gpr(const u32 reg)
force_inline static vm::_ptr_base<T, AT> from_gpr(const u32 reg)
{
return vm::_ptr_base<T, lvl, AT>::make(cast_armv7_gpr<AT, std::is_enum<AT>::value>::from_gpr(reg));
return vm::_ptr_base<T, AT>::make(cast_armv7_gpr<AT, std::is_enum<AT>::value>::from_gpr(reg));
}
};

View File

@ -3,80 +3,88 @@
namespace vm
{
template<typename T, typename AT = u32>
class _ref_base
struct _ref_base
{
protected:
AT m_addr;
public:
typedef T type;
static_assert(!std::is_pointer<T>::value, "vm::_ref_base<> error: invalid type (pointer)");
static_assert(!std::is_reference<T>::value, "vm::_ref_base<> error: invalid type (reference)");
typedef typename remove_be_t<T>::type le_type;
typedef typename to_be_t<T>::type be_type;
operator T&()
{
return get_ref<T>(m_addr);
}
operator const T&() const
{
return get_ref<const T>(m_addr);
}
static_assert(!std::is_function<T>::value, "vm::_ref_base<> error: invalid type (function)");
static_assert(!std::is_void<T>::value, "vm::_ref_base<> error: invalid type (void)");
AT addr() const
{
return m_addr;
}
static _ref_base make(const AT& addr)
template<typename AT2 = AT> static _ref_base make(const AT2& addr)
{
return reinterpret_cast<_ref_base&>(addr);
return{ convert_le_be<AT>(addr) };
}
_ref_base& operator = (le_type right)
T& get_ref() const
{
get_ref<T>(m_addr) = right;
return *this;
return vm::get_ref<T>(vm::cast(m_addr));
}
const _ref_base& operator = (le_type right) const
T& priv_ref() const
{
get_ref<T>(m_addr) = right;
return *this;
return vm::priv_ref<T>(vm::cast(m_addr));
}
_ref_base& operator = (be_type right)
// TODO: conversion operator (seems hard to define it correctly)
//template<typename CT, typename dummy = std::enable_if_t<std::is_convertible<T, CT>::value || std::is_convertible<to_ne_t<T>, CT>::value>> operator CT() const
//{
// return get_ref();
//}
operator to_ne_t<T>() const
{
get_ref<T>(m_addr) = right;
return *this;
return get_ref();
}
const _ref_base& operator = (be_type right) const
explicit operator T&() const
{
get_ref<T>(m_addr) = right;
return *this;
return get_ref();
}
// copy assignment operator:
// returns T& by default, this may be wrong if called assignment operator has different return type
T& operator =(const _ref_base& right)
{
static_assert(!std::is_const<T>::value, "vm::_ref_base<> error: operator= is not available for const reference");
return get_ref() = right.get_ref();
}
template<typename CT, typename AT2> auto operator =(const _ref_base<CT, AT2>& right) const -> decltype(std::declval<T&>() = std::declval<CT>())
{
return get_ref() = right.get_ref();
}
template<typename CT> auto operator =(const CT& right) const -> decltype(std::declval<T&>() = std::declval<CT>())
{
return get_ref() = right;
}
};
// Native endianness reference to LE data
template<typename T, typename AT = u32> using refl = _ref_base<typename to_le_t<T>::type, AT>;
template<typename T, typename AT = u32> using refl = _ref_base<to_le_t<T>, AT>;
// Native endianness reference to BE data
template<typename T, typename AT = u32> using refb = _ref_base<typename to_be_t<T>::type, AT>;
template<typename T, typename AT = u32> using refb = _ref_base<to_be_t<T>, AT>;
// BE reference to LE data
template<typename T, typename AT = u32> using brefl = _ref_base<typename to_le_t<T>::type, typename to_be_t<AT>::type>;
template<typename T, typename AT = u32> using brefl = _ref_base<to_le_t<T>, to_be_t<AT>>;
// BE reference to BE data
template<typename T, typename AT = u32> using brefb = _ref_base<typename to_be_t<T>::type, typename to_be_t<AT>::type>;
template<typename T, typename AT = u32> using brefb = _ref_base<to_be_t<T>, to_be_t<AT>>;
// LE reference to LE data
template<typename T, typename AT = u32> using lrefl = _ref_base<typename to_le_t<T>::type, typename to_le_t<AT>::type>;
template<typename T, typename AT = u32> using lrefl = _ref_base<to_le_t<T>, to_le_t<AT>>;
// LE reference to BE data
template<typename T, typename AT = u32> using lrefb = _ref_base<typename to_be_t<T>::type, typename to_le_t<AT>::type>;
template<typename T, typename AT = u32> using lrefb = _ref_base<to_be_t<T>, to_le_t<AT>>;
namespace ps3
{
@ -90,16 +98,138 @@ namespace vm
namespace psv
{
// default reference for PSV HLE functions (Native endianness reference to LE data)
template<typename T, typename AT = u32> using ref = refl<T, AT>;
template<typename T> using ref = refl<T>;
// default reference for PSV HLE structures (LE reference to LE data)
template<typename T, typename AT = u32> using lref = lrefl<T, AT>;
template<typename T> using lref = lrefl<T>;
}
//PS3 emulation is main now, so lets it be as default
using namespace ps3;
}
// postfix increment operator for vm::_ref_base
template<typename T, typename AT> inline auto operator ++(const vm::_ref_base<T, AT>& ref, int) -> decltype(std::declval<T&>()++)
{
return ref.get_ref()++;
}
// prefix increment operator for vm::_ref_base
template<typename T, typename AT> inline auto operator ++(const vm::_ref_base<T, AT>& ref) -> decltype(++std::declval<T&>())
{
return ++ref.get_ref();
}
// postfix decrement operator for vm::_ref_base
template<typename T, typename AT> inline auto operator --(const vm::_ref_base<T, AT>& ref, int) -> decltype(std::declval<T&>()--)
{
return ref.get_ref()--;
}
// prefix decrement operator for vm::_ref_base
template<typename T, typename AT> inline auto operator --(const vm::_ref_base<T, AT>& ref) -> decltype(--std::declval<T&>())
{
return --ref.get_ref();
}
// addition assignment operator for vm::_ref_base
template<typename T, typename AT, typename T2> inline auto operator +=(const vm::_ref_base<T, AT>& ref, const T2& right) -> decltype(std::declval<T&>() += std::declval<T2>())
{
return ref.get_ref() += right;
}
// subtraction assignment operator for vm::_ref_base
template<typename T, typename AT, typename T2> inline auto operator -=(const vm::_ref_base<T, AT>& ref, const T2& right) -> decltype(std::declval<T&>() -= std::declval<T2>())
{
return ref.get_ref() -= right;
}
// multiplication assignment operator for vm::_ref_base
template<typename T, typename AT, typename T2> inline auto operator *=(const vm::_ref_base<T, AT>& ref, const T2& right) -> decltype(std::declval<T&>() *= std::declval<T2>())
{
return ref.get_ref() *= right;
}
// division assignment operator for vm::_ref_base
template<typename T, typename AT, typename T2> inline auto operator /=(const vm::_ref_base<T, AT>& ref, const T2& right) -> decltype(std::declval<T&>() /= std::declval<T2>())
{
return ref.get_ref() /= right;
}
// modulo assignment operator for vm::_ref_base
template<typename T, typename AT, typename T2> inline auto operator %=(const vm::_ref_base<T, AT>& ref, const T2& right) -> decltype(std::declval<T&>() %= std::declval<T2>())
{
return ref.get_ref() %= right;
}
// bitwise AND assignment operator for vm::_ref_base
template<typename T, typename AT, typename T2> inline auto operator &=(const vm::_ref_base<T, AT>& ref, const T2& right) -> decltype(std::declval<T&>() &= std::declval<T2>())
{
return ref.get_ref() &= right;
}
// bitwise OR assignment operator for vm::_ref_base
template<typename T, typename AT, typename T2> inline auto operator |=(const vm::_ref_base<T, AT>& ref, const T2& right) -> decltype(std::declval<T&>() |= std::declval<T2>())
{
return ref.get_ref() |= right;
}
// bitwise XOR assignment operator for vm::_ref_base
template<typename T, typename AT, typename T2> inline auto operator ^=(const vm::_ref_base<T, AT>& ref, const T2& right) -> decltype(std::declval<T&>() ^= std::declval<T2>())
{
return ref.get_ref() ^= right;
}
// bitwise left shift assignment operator for vm::_ref_base
template<typename T, typename AT, typename T2> inline auto operator <<=(const vm::_ref_base<T, AT>& ref, const T2& right) -> decltype(std::declval<T&>() <<= std::declval<T2>())
{
return ref.get_ref() <<= right;
}
// bitwise right shift assignment operator for vm::_ref_base
template<typename T, typename AT, typename T2> inline auto operator >>=(const vm::_ref_base<T, AT>& ref, const T2& right) -> decltype(std::declval<T&>() >>= std::declval<T2>())
{
return ref.get_ref() >>= right;
}
// external specialization for is_be_t<> (true if AT's endianness is BE)
template<typename T, typename AT>
struct is_be_t<vm::_ref_base<T, AT>> : public std::integral_constant<bool, is_be_t<AT>::value>
{
};
// external specialization for is_le_t<> (true if AT's endianness is LE)
template<typename T, typename AT>
struct is_le_t<vm::_ref_base<T, AT>> : public std::integral_constant<bool, is_le_t<AT>::value>
{
};
// external specialization for to_ne_t<> (change AT's endianness to native)
template<typename T, typename AT>
struct to_ne<vm::_ref_base<T, AT>>
{
using type = vm::_ref_base<T, to_ne_t<AT>>;
};
// external specialization for to_be_t<> (change AT's endianness to BE)
template<typename T, typename AT>
struct to_be<vm::_ref_base<T, AT>>
{
using type = vm::_ref_base<T, to_be_t<AT>>;
};
// external specialization for to_le_t<> (change AT's endianness to LE)
template<typename T, typename AT>
struct to_le<vm::_ref_base<T, AT>>
{
using type = vm::_ref_base<T, to_le_t<AT>>;
};
namespace fmt
{
// external specialization for fmt::format function
@ -107,7 +237,7 @@ namespace fmt
template<typename T, typename AT>
struct unveil<vm::_ref_base<T, AT>, false>
{
typedef typename unveil<AT>::result_type result_type;
using result_type = typename unveil<AT>::result_type;
force_inline static result_type get_value(const vm::_ref_base<T, AT>& arg)
{

View File

@ -108,24 +108,24 @@ namespace vm
}
*/
template<typename AT> operator _ptr_base<T, 1, AT>() const
template<typename AT> operator _ptr_base<T, AT>() const
{
return _ptr_base<T, 1, AT>::make(m_addr);
return _ptr_base<T, AT>::make(m_addr);
}
template<typename AT> operator _ptr_base<const T, 1, AT>() const
template<typename AT> operator _ptr_base<const T, AT>() const
{
return _ptr_base<const T, 1, AT>::make(m_addr);
return _ptr_base<const T, AT>::make(m_addr);
}
template<typename AT> operator _ptr_base<void, 1, AT>() const
template<typename AT> operator _ptr_base<void, AT>() const
{
return _ptr_base<void, 1, AT>::make(m_addr);
return _ptr_base<void, AT>::make(m_addr);
}
template<typename AT> operator _ptr_base<const void, 1, AT>() const
template<typename AT> operator _ptr_base<const void, AT>() const
{
return _ptr_base<const void, 1, AT>::make(m_addr);
return _ptr_base<const void, AT>::make(m_addr);
}
operator T&()
@ -614,24 +614,24 @@ namespace vm
}
*/
template<typename AT> operator _ptr_base<T, 1, AT>() const
template<typename AT> operator _ptr_base<T, AT>() const
{
return _ptr_base<T, 1, AT>::make(m_data.addr);
return _ptr_base<T, AT>::make(m_data.addr);
}
template<typename AT> operator _ptr_base<const T, 1, AT>() const
template<typename AT> operator _ptr_base<const T, AT>() const
{
return _ptr_base<const T, 1, AT>::make(m_data.addr);
return _ptr_base<const T, AT>::make(m_data.addr);
}
template<typename AT> operator _ptr_base<void, 1, AT>() const
template<typename AT> operator _ptr_base<void, AT>() const
{
return _ptr_base<void, 1, AT>::make(m_data.addr);
return _ptr_base<void, AT>::make(m_data.addr);
}
template<typename AT> operator _ptr_base<const void, 1, AT>() const
template<typename AT> operator _ptr_base<const void, AT>() const
{
return _ptr_base<const void, 1, AT>::make(m_data.addr);
return _ptr_base<const void, AT>::make(m_data.addr);
}
operator T&()

View File

@ -301,7 +301,7 @@ public:
m_arb_shader += fmt::format("#%d ", i) + param_type + param_name + param_semantic + param_const + "\n";
offset += sizeof(CgBinaryParameter);
offset += sizeof32(CgBinaryParameter);
}
m_arb_shader += "\n";
@ -355,7 +355,7 @@ public:
m_arb_shader += fmt::format("#%d ", i) + param_type + param_name + param_semantic + param_const + "\n";
offset += sizeof(CgBinaryParameter);
offset += sizeof32(CgBinaryParameter);
}
m_arb_shader += "\n";

View File

@ -162,7 +162,7 @@ namespace cb_detail
namespace vm
{
template<typename AT, typename RT, typename... T>
force_inline RT _ptr_base<RT(T...), 1, AT>::operator()(PPUThread& CPU, T... args) const
force_inline RT _ptr_base<RT(T...), AT>::operator()(PPUThread& CPU, T... args) const
{
const auto data = vm::get_ptr<be_t<u32>>(vm::cast(m_addr));
const u32 pc = data[0];
@ -172,7 +172,7 @@ namespace vm
}
template<typename AT, typename RT, typename... T>
force_inline RT _ptr_base<RT(T...), 1, AT>::operator()(T... args) const
force_inline RT _ptr_base<RT(T...), AT>::operator()(T... args) const
{
return operator()(GetCurrentPPUThread(), args...);
}

View File

@ -119,16 +119,19 @@ void execute_ppu_func_by_index(PPUThread& CPU, u32 index)
if (old_last_syscall)
{
CPU.m_last_syscall = func->id;
throw "Unfortunately, this function cannot be called from the callback.";
}
if (!func->lle_func)
{
CPU.m_last_syscall = func->id;
throw "Wrong usage: LLE function not set.";
}
if (func->flags & MFF_FORCED_HLE)
{
CPU.m_last_syscall = func->id;
throw "Wrong usage: Forced HLE enabled.";
}
@ -139,6 +142,7 @@ void execute_ppu_func_by_index(PPUThread& CPU, u32 index)
if (index & EIF_PERFORM_BLR)
{
CPU.m_last_syscall = func->id;
throw "TODO: Branch with link";
// CPU.LR = CPU.PC + 4;
}

View File

@ -792,7 +792,7 @@ s32 cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
return CELL_OK;
}
s32 cellAdecGetPcmItem(u32 handle, vm::ptr<vm::bptr<CellAdecPcmItem>> pcmItem)
s32 cellAdecGetPcmItem(u32 handle, vm::pptr<CellAdecPcmItem> pcmItem)
{
cellAdec.Log("cellAdecGetPcmItem(handle=0x%x, pcmItem=**0x%x)", handle, pcmItem);
@ -821,7 +821,7 @@ s32 cellAdecGetPcmItem(u32 handle, vm::ptr<vm::bptr<CellAdecPcmItem>> pcmItem)
}
pcm->pcmHandle = 0; // ???
pcm->pcmAttr.bsiInfo_addr = pcm.addr() + sizeof(CellAdecPcmItem);
pcm->pcmAttr.bsiInfo_addr = pcm.addr() + sizeof32(CellAdecPcmItem);
pcm->startAddr = 0x00000312; // invalid address (no output)
pcm->size = af.size;
pcm->status = CELL_OK;
@ -833,7 +833,7 @@ s32 cellAdecGetPcmItem(u32 handle, vm::ptr<vm::bptr<CellAdecPcmItem>> pcmItem)
if (adecIsAtracX(adec->type))
{
auto atx = vm::ptr<CellAdecAtracXInfo>::make(pcm.addr() + sizeof(CellAdecPcmItem));
auto atx = vm::ptr<CellAdecAtracXInfo>::make(pcm.addr() + sizeof32(CellAdecPcmItem));
atx->samplingFreq = frame->sample_rate;
atx->nbytes = frame->nb_samples * sizeof(float);
@ -861,7 +861,7 @@ s32 cellAdecGetPcmItem(u32 handle, vm::ptr<vm::bptr<CellAdecPcmItem>> pcmItem)
}
else if (adec->type == CELL_ADEC_TYPE_MP3)
{
auto mp3 = vm::ptr<CellAdecMP3Info>::make(pcm.addr() + sizeof(CellAdecPcmItem));
auto mp3 = vm::ptr<CellAdecMP3Info>::make(pcm.addr() + sizeof32(CellAdecPcmItem));
// TODO
memset(mp3.get_ptr(), 0, sizeof(CellAdecMP3Info));

View File

@ -18,23 +18,35 @@ extern "C"
extern Module cellGifDec;
s32 cellGifDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam)
s32 cellGifDecCreate(
vm::ptr<CellGifDecMainHandle> mainHandle,
vm::ptr<const CellGifDecThreadInParam> threadInParam,
vm::ptr<CellGifDecThreadOutParam> threadOutParam)
{
UNIMPLEMENTED_FUNC(cellGifDec);
return CELL_OK;
}
s32 cellGifDecExtCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam, u32 extThreadInParam, u32 extThreadOutParam)
s32 cellGifDecExtCreate(
vm::ptr<CellGifDecMainHandle> mainHandle,
vm::ptr<const CellGifDecThreadInParam> threadInParam,
vm::ptr<CellGifDecThreadOutParam> threadOutParam,
vm::ptr<const CellGifDecExtThreadInParam> extThreadInParam,
vm::ptr<CellGifDecExtThreadOutParam> extThreadOutParam)
{
UNIMPLEMENTED_FUNC(cellGifDec);
return CELL_OK;
}
s32 cellGifDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellGifDecSrc> src, vm::ptr<CellGifDecOpnInfo> openInfo)
s32 cellGifDecOpen(
CellGifDecMainHandle mainHandle,
vm::ptr<CellGifDecSubHandle> subHandle,
vm::ptr<const CellGifDecSrc> src,
vm::ptr<CellGifDecOpnInfo> openInfo)
{
cellGifDec.Warning("cellGifDecOpen(mainHandle=0x%x, subHandle=*0x%x, src=*0x%x, openInfo=*0x%x)", mainHandle, subHandle, src, openInfo);
auto current_subHandle = std::make_shared<CellGifDecSubHandle>();
auto current_subHandle = std::make_shared<GifStream>();
current_subHandle->fd = 0;
current_subHandle->src = *src;
@ -62,11 +74,14 @@ s32 cellGifDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellGifDecSrc
return CELL_OK;
}
s32 cellGifDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellGifDecInfo> info)
s32 cellGifDecReadHeader(
CellGifDecMainHandle mainHandle,
CellGifDecSubHandle subHandle,
vm::ptr<CellGifDecInfo> info)
{
cellGifDec.Warning("cellGifDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info=*0x%x)", mainHandle, subHandle, info);
const auto subHandle_data = Emu.GetIdManager().get<CellGifDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<GifStream>(subHandle);
if (!subHandle_data)
{
@ -83,7 +98,7 @@ s32 cellGifDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellGifDecInfo>
switch(subHandle_data->src.srcSelect.data())
{
case se32(CELL_GIFDEC_BUFFER):
memmove(buffer.begin(), vm::get_ptr<void>(subHandle_data->src.streamPtr), buffer.size());
memmove(buffer.begin(), subHandle_data->src.streamPtr.get_ptr(), buffer.size());
break;
case se32(CELL_GIFDEC_FILE):
@ -116,11 +131,15 @@ s32 cellGifDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellGifDecInfo>
return CELL_OK;
}
s32 cellGifDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellGifDecInParam> inParam, vm::ptr<CellGifDecOutParam> outParam)
s32 cellGifDecSetParameter(
CellGifDecMainHandle mainHandle,
CellGifDecSubHandle subHandle,
vm::ptr<const CellGifDecInParam> inParam,
vm::ptr<CellGifDecOutParam> outParam)
{
cellGifDec.Warning("cellGifDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam=*0x%x, outParam=*0x%x)", mainHandle, subHandle, inParam, outParam);
const auto subHandle_data = Emu.GetIdManager().get<CellGifDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<GifStream>(subHandle);
if (!subHandle_data)
{
@ -148,13 +167,18 @@ s32 cellGifDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellGifD
return CELL_OK;
}
s32 cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::ptr<const CellGifDecDataCtrlParam> dataCtrlParam, vm::ptr<CellGifDecDataOutInfo> dataOutInfo)
s32 cellGifDecDecodeData(
CellGifDecMainHandle mainHandle,
CellGifDecSubHandle subHandle,
vm::ptr<u8> data,
vm::ptr<const CellGifDecDataCtrlParam> dataCtrlParam,
vm::ptr<CellGifDecDataOutInfo> dataOutInfo)
{
cellGifDec.Warning("cellGifDecDecodeData(mainHandle=0x%x, subHandle=0x%x, data=*0x%x, dataCtrlParam=*0x%x, dataOutInfo=*0x%x)", mainHandle, subHandle, data, dataCtrlParam, dataOutInfo);
dataOutInfo->status = CELL_GIFDEC_DEC_STATUS_STOP;
const auto subHandle_data = Emu.GetIdManager().get<CellGifDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<GifStream>(subHandle);
if (!subHandle_data)
{
@ -171,7 +195,7 @@ s32 cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::pt
switch(subHandle_data->src.srcSelect.data())
{
case se32(CELL_GIFDEC_BUFFER):
memmove(gif.begin(), vm::get_ptr<void>(subHandle_data->src.streamPtr), gif.size());
memmove(gif.begin(), subHandle_data->src.streamPtr.get_ptr(), gif.size());
break;
case se32(CELL_GIFDEC_FILE):
@ -269,11 +293,11 @@ s32 cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::pt
return CELL_OK;
}
s32 cellGifDecClose(u32 mainHandle, u32 subHandle)
s32 cellGifDecClose(CellGifDecMainHandle mainHandle, CellGifDecSubHandle subHandle)
{
cellGifDec.Warning("cellGifDecClose(mainHandle=0x%x, subHandle=0x%x)", mainHandle, subHandle);
const auto subHandle_data = Emu.GetIdManager().get<CellGifDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<GifStream>(subHandle);
if (!subHandle_data)
{
@ -286,7 +310,7 @@ s32 cellGifDecClose(u32 mainHandle, u32 subHandle)
return CELL_OK;
}
s32 cellGifDecDestroy(u32 mainHandle)
s32 cellGifDecDestroy(CellGifDecMainHandle mainHandle)
{
UNIMPLEMENTED_FUNC(cellGifDec);
return CELL_OK;

View File

@ -1,6 +1,6 @@
#pragma once
//Return Codes
// Return Codes
enum
{
CELL_GIFDEC_ERROR_OPEN_FILE = 0x80611300,
@ -13,29 +13,94 @@ enum
CELL_GIFDEC_ERROR_CB_PARAM = 0x80611307,
};
enum CellGifDecStreamSrcSel
enum CellGifDecStreamSrcSel : s32
{
CELL_GIFDEC_FILE = 0, // Input from a file
CELL_GIFDEC_BUFFER = 1, // Input from a buffer
};
enum CellGifDecColorSpace
enum CellGifDecSpuThreadEna : s32
{
CELL_GIFDEC_RGBA = 10,
CELL_GIFDEC_ARGB = 20,
CELL_GIFDEC_SPU_THREAD_DISABLE = 0, // Do not use SPU threads
CELL_GIFDEC_SPU_THREAD_ENABLE = 1, // Use SPU threads
};
enum CellGifDecRecordType
enum CellGifDecRecordType : s32
{
CELL_GIFDEC_RECORD_TYPE_IMAGE_DESC = 1, // Image data block
CELL_GIFDEC_RECORD_TYPE_EXTENSION = 2, // Extension block
CELL_GIFDEC_RECORD_TYPE_TERMINATE = 3, // Trailer block
};
enum CellGifDecDecodeStatus
enum CellGifDecColorSpace : s32
{
CELL_GIFDEC_DEC_STATUS_FINISH = 0, //Decoding finished
CELL_GIFDEC_DEC_STATUS_STOP = 1, //Decoding halted
CELL_GIFDEC_RGBA = 10, // RGBA
CELL_GIFDEC_ARGB = 20, // ARGB
};
enum CellGifDecCommand : s32
{
CELL_GIFDEC_CONTINUE = 0, // Continue decoding
CELL_GIFDEC_STOP = 1, // Force decoding to stop
};
enum CellGifDecDecodeStatus : s32
{
CELL_GIFDEC_DEC_STATUS_FINISH = 0, // Decoding finished
CELL_GIFDEC_DEC_STATUS_STOP = 1, // Decoding was stopped
};
// Handles
using CellGifDecMainHandle = vm::ptr<struct GifDecoder>;
using CellGifDecSubHandle = u32; // vm::ptr<struct GifStream>;
// Callbacks for memory management
using CellGifDecCbControlMalloc = func_def<vm::ptr<void>(u32 size, vm::ptr<void> cbCtrlMallocArg)>;
using CellGifDecCbControlFree = func_def<s32(vm::ptr<void> ptr, vm::ptr<void> cbCtrlFreeArg)>;
// Structs
struct CellGifDecThreadInParam
{
be_t<s32> spuThreadEnable; // CellGifDecSpuThreadEna
be_t<u32> ppuThreadPriority;
be_t<u32> spuThreadPriority;
vm::bptr<CellGifDecCbControlMalloc> cbCtrlMallocFunc;
vm::bptr<void> cbCtrlMallocArg;
vm::bptr<CellGifDecCbControlFree> cbCtrlFreeFunc;
vm::bptr<void> cbCtrlFreeArg;
};
struct CellGifDecThreadOutParam
{
be_t<u32> gifCodecVersion;
};
struct CellGifDecExtThreadInParam
{
vm::bptr<struct CellSpurs> spurs;
u8 priority[8];
be_t<u32> maxContention;
};
struct CellGifDecExtThreadOutParam
{
be_t<u64> reserved;
};
struct CellGifDecSrc
{
be_t<s32> srcSelect; // CellGifDecStreamSrcSel
vm::bptr<const char> fileName;
be_t<s64> fileOffset;
be_t<u32> fileSize;
vm::bptr<void> streamPtr;
be_t<u32> streamSize;
be_t<s32> spuThreadEnable; // CellGifDecSpuThreadEna
};
struct CellGifDecOpnInfo
{
be_t<u32> initSpaceAllocated;
};
struct CellGifDecInfo
@ -50,24 +115,13 @@ struct CellGifDecInfo
be_t<u32> SPixelAspectRatio;
};
struct CellGifDecSrc
{
be_t<u32> srcSelect;
vm::bptr<const char> fileName;
be_t<s64> fileOffset;
be_t<u64> fileSize;
be_t<u32> streamPtr;
be_t<u32> streamSize;
be_t<u32> spuThreadEnable;
};
struct CellGifDecInParam
{
be_t<u32> commandPtr;
be_t<u32> colorSpace; // CellGifDecColorSpace
be_t<u8> outputColorAlpha1;
be_t<u8> outputColorAlpha2;
be_t<u8> reserved[2];
vm::bptr<volatile s32> commandPtr; // CellGifDecCommand
be_t<s32> colorSpace; // CellGifDecColorSpace
u8 outputColorAlpha1;
u8 outputColorAlpha2;
u8 reserved[2];
};
struct CellGifDecOutParam
@ -77,26 +131,21 @@ struct CellGifDecOutParam
be_t<u32> outputHeight;
be_t<u32> outputComponents;
be_t<u32> outputBitDepth;
be_t<u32> outputColorSpace; // CellGifDecColorSpace
be_t<s32> outputColorSpace; // CellGifDecColorSpace
be_t<u32> useMemorySpace;
};
struct CellGifDecExtension
{
be_t<u8> label;
be_t<u32> data;
u8 label;
vm::ptr<u8> data;
};
struct CellGifDecDataOutInfo
{
be_t<u32> recordType;
be_t<s32> recordType; // CellGifDecRecordType
CellGifDecExtension outExtension;
be_t<u32> status;
};
struct CellGifDecOpnInfo
{
be_t<u32> initSpaceAllocated;
be_t<s32> status; // CellGifDecDecodeStatus
};
struct CellGifDecDataCtrlParam
@ -104,8 +153,12 @@ struct CellGifDecDataCtrlParam
be_t<u64> outputBytesPerLine;
};
//Custom structs
struct CellGifDecSubHandle
// Custom structs
struct GifDecoder
{
};
struct GifStream
{
u32 fd;
u64 fileSize;

View File

@ -71,8 +71,8 @@ struct CellJpgDecInParam
be_t<u32> method; // CellJpgDecMethod
be_t<u32> outputMode; // CellJpgDecOutputMode
be_t<u32> outputColorSpace; // CellJpgDecColorSpace
be_t<u8> outputColorAlpha;
be_t<u8> reserved[3];
u8 outputColorAlpha;
u8 reserved[3];
};
struct CellJpgDecOutParam

View File

@ -2,44 +2,60 @@
#include "Emu/Memory/Memory.h"
#include "Emu/SysCalls/Modules.h"
#include "cellL10n.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef _MSC_VER
#include <windows.h>
#include <wchar.h>
#include <codecvt>
#else
#include <iconv.h>
#endif
//#include <codecvt>
#include "cellL10n.h"
extern Module cellL10n;
int UTF16stoUTF8s(vm::lptrl<const char16_t> utf16, vm::ptr<u32> utf16_len, vm::ptr<char> utf8, vm::ptr<u32> utf8_len)
s32 UTF16stoUTF8s(vm::ptr<const char16_t> utf16, vm::ref<u32> utf16_len, vm::ptr<char> utf8, vm::ref<u32> utf8_len)
{
cellL10n.Warning("UTF16stoUTF8s(utf16_addr=0x%x, utf16_len_addr=0x%x, utf8_addr=0x%x, utf8_len_addr=0x%x)",
utf16.addr(), utf16_len.addr(), utf8.addr(), utf8_len.addr());
cellL10n.Todo("UTF16stoUTF8s(utf16=*0x%x, utf16_len=*0x%x, utf8=*0x%x, utf8_len=*0x%x)", utf16, utf16_len, utf8, utf8_len);
std::u16string wstr = utf16.get_ptr(); // ???
wstr.resize(*utf16_len); // TODO: Is this really the role of utf16_len in this function?
#ifdef _MSC_VER
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert;
std::string str = convert.to_bytes(wstr);
const u32 max_len = utf8_len; utf8_len = 0;
if (*utf8_len < str.size())
for (u32 i = 0, len = 0; i < utf16_len; i++, utf8_len = len)
{
*utf8_len = str.size();
return DSTExhausted;
const char16_t ch = utf16[i];
// increase required length (TODO)
len = len + 1;
// validate character (TODO)
//if ()
//{
// utf16_len -= i;
// return SRCIllegal;
//}
if (utf8)
{
if (len > max_len)
{
utf16_len -= i;
return DSTExhausted;
}
if (ch <= 0x7f)
{
*utf8++ = static_cast<char>(ch);
}
else
{
*utf8++ = '?'; // TODO
}
}
}
*utf8_len = str.size();
memcpy(utf8.get_ptr(), str.c_str(), str.size());
#endif
return ConversionOK;
}
int jstrchk(vm::ptr<const char> jstr)
s32 jstrchk(vm::ptr<const char> jstr)
{
cellL10n.Warning("jstrchk(jstr_addr=0x%x) -> utf8", jstr.addr());
@ -48,7 +64,7 @@ int jstrchk(vm::ptr<const char> jstr)
//translate code id to code name. some codepage may has another name.
//If this makes your compilation fail, try replace the string code with one in "iconv -l"
bool _L10nCodeParse(int code, std::string& retCode)
bool _L10nCodeParse(s32 code, std::string& retCode)
{
if ((code >= _L10N_CODE_) || (code < 0)) return false;
switch (code)
@ -113,7 +129,7 @@ bool _L10nCodeParse(int code, std::string& retCode)
//translate code id to code name.
//If this makes your compilation fail, try replace the string code with one in "iconv -l"
bool _L10nCodeParse(int code, unsigned int & retCode)
bool _L10nCodeParse(s32 code, u32& retCode)
{
retCode = 0;
if ((code >= _L10N_CODE_) || (code < 0)) return false;
@ -182,10 +198,10 @@ bool _L10nCodeParse(int code, unsigned int & retCode)
#ifdef _MSC_VER
//Use code page to transform std::string to std::wstring.
int _OEM2Wide(unsigned int oem_code, const std::string src, std::wstring& dst)
s32 _OEM2Wide(u32 oem_code, const std::string src, std::wstring& dst)
{
//Such length returned should include the '\0' character.
int length = MultiByteToWideChar(oem_code, 0, src.c_str(), -1, NULL, 0);
s32 length = MultiByteToWideChar(oem_code, 0, src.c_str(), -1, NULL, 0);
wchar_t *store = new wchar_t[length]();
MultiByteToWideChar(oem_code, 0, src.c_str(), -1, (LPWSTR)store, length);
@ -199,10 +215,10 @@ int _OEM2Wide(unsigned int oem_code, const std::string src, std::wstring& dst)
}
//Use Code page to transform std::wstring to std::string.
int _Wide2OEM(unsigned int oem_code, const std::wstring src, std::string& dst)
s32 _Wide2OEM(u32 oem_code, const std::wstring src, std::string& dst)
{
//Such length returned should include the '\0' character.
int length = WideCharToMultiByte(oem_code, 0, src.c_str(), -1, NULL, 0, NULL, NULL);
s32 length = WideCharToMultiByte(oem_code, 0, src.c_str(), -1, NULL, 0, NULL, NULL);
char *store = new char[length]();
WideCharToMultiByte(oem_code, 0, src.c_str(), -1, store, length, NULL, NULL);
@ -216,7 +232,7 @@ int _Wide2OEM(unsigned int oem_code, const std::wstring src, std::string& dst)
}
//Convert Codepage to Codepage (all char*)
std::string _OemToOem(unsigned int src_code, unsigned int dst_code, const std::string str)
std::string _OemToOem(u32 src_code, u32 dst_code, const std::string str)
{
std::wstring wide; std::string result;
_OEM2Wide(src_code, str, wide);
@ -227,9 +243,9 @@ std::string _OemToOem(unsigned int src_code, unsigned int dst_code, const std::s
/*
//Original piece of code. and this is for windows using with _OEM2Wide,_Wide2OEM,_OemToOem.
//The Char -> Char Execution of this function has already been tested using VS and CJK text with encoding.
int _L10nConvertStr(int src_code, const void *src, size_t * src_len, int dst_code, void *dst, size_t * dst_len)
s32 _L10nConvertStr(s32 src_code, const void *src, size_t * src_len, s32 dst_code, void *dst, size_t * dst_len)
{
unsigned int srcCode = 0, dstCode = 0; //OEM code pages
u32 srcCode = 0, dstCode = 0; //OEM code pages
bool src_page_converted = _L10nCodeParse(src_code, srcCode); //Check if code is in list.
bool dst_page_converted = _L10nCodeParse(dst_code, dstCode);
@ -251,10 +267,10 @@ int _L10nConvertStr(int src_code, const void *src, size_t * src_len, int dst_cod
}
//This is the one used with iconv library for linux/mac. Also char->char.
//I've tested the code with console apps using codeblocks.
int _L10nConvertStr(int src_code, const void* src, size_t * src_len, int dst_code, void * dst, size_t * dst_len)
s32 _L10nConvertStr(s32 src_code, const void* src, size_t * src_len, s32 dst_code, void * dst, size_t * dst_len)
{
std::string srcCode, dstCode;
int retValue = ConversionOK;
s32 retValue = ConversionOK;
if ((_L10nCodeParse(src_code, srcCode)) && (_L10nCodeParse(dst_code, dstCode)))
{
iconv_t ict = iconv_open(srcCode.c_str(), dstCode.c_str());
@ -281,13 +297,13 @@ int _L10nConvertStr(int src_code, const void* src, size_t * src_len, int dst_cod
#endif
//TODO: Check the code in emulation. If support for UTF8/UTF16/UTF32/UCS2/UCS4 should use wider chars.. awful.
int L10nConvertStr(int src_code, vm::ptr<const void> src, vm::ptr<u32> src_len, int dst_code, vm::ptr<void> dst, vm::ptr<u32> dst_len)
s32 L10nConvertStr(s32 src_code, vm::ptr<const void> src, vm::ptr<u32> src_len, s32 dst_code, vm::ptr<void> dst, vm::ptr<u32> dst_len)
{
cellL10n.Error("L10nConvertStr(src_code=%d, srca_addr=0x%x, src_len_addr=0x%x, dst_code=%d, dst_addr=0x%x, dst_len_addr=0x%x)",
src_code, src.addr(), src_len.addr(), dst_code, dst.addr(), dst_len.addr());
//cellL10n.Todo("L10nConvertStr: 1st char at dst: 0x%x", *((char*)src.get_ptr()));
#ifdef _MSC_VER
unsigned int srcCode = 0, dstCode = 0; //OEM code pages
u32 srcCode = 0, dstCode = 0; //OEM code pages
bool src_page_converted = _L10nCodeParse(src_code, srcCode); //Check if code is in list.
bool dst_page_converted = _L10nCodeParse(dst_code, dstCode);
@ -308,7 +324,7 @@ int L10nConvertStr(int src_code, vm::ptr<const void> src, vm::ptr<u32> src_len,
return ConversionOK;
#else
std::string srcCode, dstCode;
int retValue = ConversionOK;
s32 retValue = ConversionOK;
if ((_L10nCodeParse(src_code, srcCode)) && (_L10nCodeParse(dst_code, dstCode)))
{
iconv_t ict = iconv_open(srcCode.c_str(), dstCode.c_str());
@ -490,7 +506,7 @@ Module cellL10n("cellL10n", []()
// REG_FUNC(cellL10n, UTF8stoHZs);
// REG_FUNC(cellL10n, eucjp2kuten);
// REG_FUNC(cellL10n, UTF8toBIG5);
// REG_FUNC(cellL10n, UTF16stoUTF8s);
REG_FUNC(cellL10n, UTF16stoUTF8s);
// REG_FUNC(cellL10n, JISstoUCS2s);
// REG_FUNC(cellL10n, GB18030toUTF8);
// REG_FUNC(cellL10n, UTF8toSJIS);

View File

@ -1,9 +1,4 @@
#include "stdafx.h"
// Requires GCC 4.10 apparently..
#ifdef _MSC_VER
#include <codecvt>
#endif
#pragma once
// L10nResult
enum

View File

@ -162,7 +162,7 @@ struct CellPngPCAL
be_t<u32> equationType;
be_t<u32> numberOfParameters;
vm::bptr<char> unitName;
vm::bptr<char, 2> parameter;
vm::bpptr<char> parameter;
};
struct CellPngUnknownChunk

View File

@ -18,7 +18,7 @@ extern "C"
extern Module cellPngDec;
s32 pngDecCreate(
vm::ptr<u32> mainHandle,
vm::ptr<CellPngDecMainHandle> mainHandle,
vm::ptr<const CellPngDecThreadInParam> param,
vm::ptr<const CellPngDecExtThreadInParam> ext = vm::null)
{
@ -41,7 +41,7 @@ s32 pngDecCreate(
}
// use virtual memory address as a handle
*mainHandle = dec.addr();
*mainHandle = dec;
return CELL_OK;
}
@ -58,7 +58,7 @@ s32 pngDecDestroy(CellPngDecMainHandle dec)
s32 pngDecOpen(
CellPngDecMainHandle dec,
vm::ptr<u32> subHandle,
vm::ptr<CellPngDecSubHandle> subHandle,
vm::ptr<const CellPngDecSrc> src,
vm::ptr<CellPngDecOpnInfo> openInfo,
vm::ptr<const CellPngDecCbCtrlStrm> cb = vm::null,
@ -105,7 +105,7 @@ s32 pngDecOpen(
}
// use virtual memory address as a handle
*subHandle = stream.addr();
*subHandle = stream;
// set memory info
openInfo->initSpaceAllocated = 4096;
@ -366,7 +366,10 @@ s32 pngDecodeData(
return CELL_OK;
}
s32 cellPngDecCreate(vm::ptr<u32> mainHandle, vm::ptr<const CellPngDecThreadInParam> threadInParam, vm::ptr<CellPngDecThreadOutParam> threadOutParam)
s32 cellPngDecCreate(
vm::ptr<CellPngDecMainHandle> mainHandle,
vm::ptr<const CellPngDecThreadInParam> threadInParam,
vm::ptr<CellPngDecThreadOutParam> threadOutParam)
{
cellPngDec.Warning("cellPngDecCreate(mainHandle=**0x%x, threadInParam=*0x%x, threadOutParam=*0x%x)", mainHandle, threadInParam, threadOutParam);
@ -380,7 +383,7 @@ s32 cellPngDecCreate(vm::ptr<u32> mainHandle, vm::ptr<const CellPngDecThreadInPa
}
s32 cellPngDecExtCreate(
vm::ptr<u32> mainHandle,
vm::ptr<CellPngDecMainHandle> mainHandle,
vm::ptr<const CellPngDecThreadInParam> threadInParam,
vm::ptr<CellPngDecThreadOutParam> threadOutParam,
vm::ptr<const CellPngDecExtThreadInParam> extThreadInParam,
@ -410,7 +413,7 @@ s32 cellPngDecDestroy(CellPngDecMainHandle mainHandle)
s32 cellPngDecOpen(
CellPngDecMainHandle mainHandle,
vm::ptr<u32> subHandle,
vm::ptr<CellPngDecSubHandle> subHandle,
vm::ptr<const CellPngDecSrc> src,
vm::ptr<CellPngDecOpnInfo> openInfo)
{
@ -422,7 +425,7 @@ s32 cellPngDecOpen(
s32 cellPngDecExtOpen(
CellPngDecMainHandle mainHandle,
vm::ptr<u32> subHandle,
vm::ptr<CellPngDecSubHandle> subHandle,
vm::ptr<const CellPngDecSrc> src,
vm::ptr<CellPngDecOpnInfo> openInfo,
vm::ptr<const CellPngDecCbCtrlStrm> cbCtrlStrm,
@ -514,7 +517,7 @@ s32 cellPngDecExtDecodeData(
s32 cellPngDecGetUnknownChunks(
CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle,
vm::ptr<vm::bptr<CellPngUnknownChunk>> unknownChunk,
vm::pptr<CellPngUnknownChunk> unknownChunk,
vm::ptr<u32> unknownChunkNumber)
{
UNIMPLEMENTED_FUNC(cellPngDec);
@ -615,7 +618,7 @@ s32 cellPngDecGetTextChunk(
CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle,
vm::ptr<u32> textInfoNum,
vm::ptr<vm::bptr<CellPngTextInfo>> textInfo)
vm::pptr<CellPngTextInfo> textInfo)
{
UNIMPLEMENTED_FUNC(cellPngDec);
return CELL_OK;

View File

@ -6,12 +6,6 @@ enum : u32
PNGDEC_CODEC_VERSION = 0x00420000,
};
struct PngDecoder;
struct PngStream;
typedef vm::ptr<PngDecoder> CellPngDecMainHandle;
typedef vm::ptr<PngStream> CellPngDecSubHandle;
// Return Codes
enum
{
@ -28,7 +22,7 @@ enum
};
// Consts
enum CellPngDecColorSpace : u32
enum CellPngDecColorSpace : s32
{
CELL_PNGDEC_GRAYSCALE = 1,
CELL_PNGDEC_RGB = 2,
@ -38,62 +32,66 @@ enum CellPngDecColorSpace : u32
CELL_PNGDEC_ARGB = 20,
};
enum CellPngDecSpuThreadEna : u32
enum CellPngDecSpuThreadEna : s32
{
CELL_PNGDEC_SPU_THREAD_DISABLE = 0,
CELL_PNGDEC_SPU_THREAD_ENABLE = 1,
};
enum CellPngDecStreamSrcSel : u32
enum CellPngDecStreamSrcSel : s32
{
CELL_PNGDEC_FILE = 0,
CELL_PNGDEC_BUFFER = 1,
};
enum CellPngDecInterlaceMode : u32
enum CellPngDecInterlaceMode : s32
{
CELL_PNGDEC_NO_INTERLACE = 0,
CELL_PNGDEC_ADAM7_INTERLACE = 1,
};
enum CellPngDecOutputMode : u32
enum CellPngDecOutputMode : s32
{
CELL_PNGDEC_TOP_TO_BOTTOM = 0,
CELL_PNGDEC_BOTTOM_TO_TOP = 1,
};
enum CellPngDecPackFlag : u32
enum CellPngDecPackFlag : s32
{
CELL_PNGDEC_1BYTE_PER_NPIXEL = 0,
CELL_PNGDEC_1BYTE_PER_1PIXEL = 1,
};
enum CellPngDecAlphaSelect : u32
enum CellPngDecAlphaSelect : s32
{
CELL_PNGDEC_STREAM_ALPHA = 0,
CELL_PNGDEC_FIX_ALPHA = 1,
};
enum CellPngDecCommand : u32
enum CellPngDecCommand : s32
{
CELL_PNGDEC_CONTINUE = 0,
CELL_PNGDEC_STOP = 1,
};
enum CellPngDecDecodeStatus : u32
enum CellPngDecDecodeStatus : s32
{
CELL_PNGDEC_DEC_STATUS_FINISH = 0,
CELL_PNGDEC_DEC_STATUS_STOP = 1,
};
// Callbacks
typedef vm::ptr<void>(CellPngDecCbControlMalloc)(u32 size, vm::ptr<void> cbCtrlMallocArg);
typedef s32(CellPngDecCbControlFree)(vm::ptr<void> ptr, vm::ptr<void> cbCtrlFreeArg);
// Handles
using CellPngDecMainHandle = vm::ptr<struct PngDecoder>;
using CellPngDecSubHandle = vm::ptr<struct PngStream>;
// Callbacks for memory management
using CellPngDecCbControlMalloc = func_def<vm::ptr<void>(u32 size, vm::ptr<void> cbCtrlMallocArg)>;
using CellPngDecCbControlFree = func_def<s32(vm::ptr<void> ptr, vm::ptr<void> cbCtrlFreeArg)>;
// Structs
struct CellPngDecThreadInParam
{
be_t<CellPngDecSpuThreadEna> spuThreadEnable;
be_t<s32> spuThreadEnable; // CellPngDecSpuThreadEna
be_t<u32> ppuThreadPriority;
be_t<u32> spuThreadPriority;
vm::bptr<CellPngDecCbControlMalloc> cbCtrlMallocFunc;
@ -104,7 +102,7 @@ struct CellPngDecThreadInParam
struct CellPngDecExtThreadInParam
{
be_t<u32> spurs_addr; // it could be vm::bptr<CellSpurs>, but nobody will use SPURS in HLE implementation
vm::bptr<struct CellSpurs> spurs;
u8 priority[8];
be_t<u32> maxContention;
};
@ -121,13 +119,13 @@ struct CellPngDecExtThreadOutParam
struct CellPngDecSrc
{
be_t<CellPngDecStreamSrcSel> srcSelect;
be_t<s32> srcSelect; // CellPngDecStreamSrcSel
vm::bptr<const char> fileName;
be_t<s64> fileOffset;
be_t<u32> fileSize;
vm::bptr<void> streamPtr;
be_t<u32> streamSize;
be_t<CellPngDecSpuThreadEna> spuThreadEnable;
be_t<s32> spuThreadEnable; // CellGifDecSpuThreadEna
};
struct CellPngDecOpnInfo
@ -140,20 +138,20 @@ struct CellPngDecInfo
be_t<u32> imageWidth;
be_t<u32> imageHeight;
be_t<u32> numComponents;
be_t<CellPngDecColorSpace> colorSpace;
be_t<s32> colorSpace; // CellPngDecColorSpace
be_t<u32> bitDepth;
be_t<CellPngDecInterlaceMode> interlaceMethod;
be_t<s32> interlaceMethod; // CellPngDecInterlaceMode
be_t<u32> chunkInformation;
};
struct CellPngDecInParam
{
vm::bptr<volatile CellPngDecCommand> commandPtr;
be_t<CellPngDecOutputMode> outputMode;
be_t<CellPngDecColorSpace> outputColorSpace;
vm::bptr<volatile s32> commandPtr; // CellPngDecCommand
be_t<s32> outputMode; // CellPngDecOutputMode
be_t<s32> outputColorSpace; // CellPngDecColorSpace
be_t<u32> outputBitDepth;
be_t<CellPngDecPackFlag> outputPackFlag;
be_t<CellPngDecAlphaSelect> outputAlphaSelect;
be_t<s32> outputPackFlag; // CellPngDecPackFlag
be_t<s32> outputAlphaSelect; // CellPngDecAlphaSelect
be_t<u32> outputColorAlpha;
};
@ -164,8 +162,8 @@ struct CellPngDecOutParam
be_t<u32> outputHeight;
be_t<u32> outputComponents;
be_t<u32> outputBitDepth;
be_t<CellPngDecOutputMode> outputMode;
be_t<CellPngDecColorSpace> outputColorSpace;
be_t<s32> outputMode; // CellPngDecOutputMode
be_t<s32> outputColorSpace; // CellPngDecOutputMode
be_t<u32> useMemorySpace;
};
@ -179,99 +177,22 @@ struct CellPngDecDataOutInfo
be_t<u32> chunkInformation;
be_t<u32> numText;
be_t<u32> numUnknownChunk;
be_t<CellPngDecDecodeStatus> status;
be_t<s32> status; // CellPngDecDecodeStatus
};
// Functions
s32 cellPngDecCreate(vm::ptr<u32> mainHandle, vm::ptr<const CellPngDecThreadInParam> threadInParam, vm::ptr<CellPngDecThreadOutParam> threadOutParam);
s32 cellPngDecExtCreate(
vm::ptr<u32> mainHandle,
vm::ptr<const CellPngDecThreadInParam> threadInParam,
vm::ptr<CellPngDecThreadOutParam> threadOutParam,
vm::ptr<const CellPngDecExtThreadInParam> extThreadInParam,
vm::ptr<CellPngDecExtThreadOutParam> extThreadOutParam);
s32 cellPngDecOpen(
CellPngDecMainHandle mainHandle,
vm::ptr<u32> subHandle,
vm::ptr<const CellPngDecSrc> src,
vm::ptr<CellPngDecOpnInfo> openInfo);
s32 cellPngDecReadHeader(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngDecInfo> info);
s32 cellPngDecSetParameter(
CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle,
vm::ptr<const CellPngDecInParam> inParam,
vm::ptr<CellPngDecOutParam> outParam);
s32 cellPngDecDecodeData(
CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle,
vm::ptr<u8> data,
vm::ptr<const CellPngDecDataCtrlParam> dataCtrlParam,
vm::ptr<CellPngDecDataOutInfo> dataOutInfo);
s32 cellPngDecClose(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle);
s32 cellPngDecDestroy(CellPngDecMainHandle mainHandle);
s32 cellPngDecGetTextChunk(
CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle,
vm::ptr<u32> textInfoNum,
vm::ptr<vm::bptr<CellPngTextInfo>> textInfo);
s32 cellPngDecGetPLTE(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngPLTE> plte);
s32 cellPngDecGetgAMA(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngGAMA> gama);
s32 cellPngDecGetsRGB(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngSRGB> srgb);
s32 cellPngDecGetiCCP(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngICCP> iccp);
s32 cellPngDecGetsBIT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngSBIT> sbit);
s32 cellPngDecGettRNS(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngTRNS> trns);
s32 cellPngDecGethIST(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngHIST> hist);
s32 cellPngDecGettIME(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngTIME> time);
s32 cellPngDecGetbKGD(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngBKGD> bkgd);
s32 cellPngDecGetsPLT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngSPLT> splt);
s32 cellPngDecGetoFFs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngOFFS> offs);
s32 cellPngDecGetpHYs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngPHYS> phys);
s32 cellPngDecGetsCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngSCAL> scal);
s32 cellPngDecGetcHRM(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngCHRM> chrm);
s32 cellPngDecGetpCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngPCAL> pcal);
s32 cellPngDecGetUnknownChunks(
CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle,
vm::ptr<vm::bptr<CellPngUnknownChunk>> unknownChunk,
vm::ptr<u32> unknownChunkNumber);
enum CellPngDecBufferMode
// Defines for decoding partial streams
enum CellPngDecBufferMode : s32
{
CELL_PNGDEC_LINE_MODE = 1,
};
enum CellPngDecSpuMode
enum CellPngDecSpuMode : s32
{
CELL_PNGDEC_RECEIVE_EVENT = 0,
CELL_PNGDEC_TRYRECEIVE_EVENT = 1,
};
// Structs
// Structs for decoding partial streams
struct CellPngDecStrmInfo
{
be_t<u32> decodedStrmSize;
@ -283,8 +204,6 @@ struct CellPngDecStrmParam
be_t<u32> strmSize;
};
typedef s32(CellPngDecCbControlStream)(vm::ptr<CellPngDecStrmInfo> strmInfo, vm::ptr<CellPngDecStrmParam> strmParam, vm::ptr<void> cbCtrlStrmArg);
struct CellPngDecDispInfo
{
be_t<u64> outputFrameWidthByte;
@ -305,21 +224,11 @@ struct CellPngDecDispParam
vm::bptr<void> nextOutputImage;
};
// Callback
typedef s32(CellPngDecCbControlDisp)(vm::ptr<CellPngDecDispInfo> dispInfo, vm::ptr<CellPngDecDispParam> dispParam, vm::ptr<void> cbCtrlDispArg);
// Structs
struct CellPngDecOpnParam
{
be_t<u32> selectChunk;
};
struct CellPngDecCbCtrlStrm
{
vm::bptr<CellPngDecCbControlStream> cbCtrlStrmFunc;
be_t<vm::ptr<void>> cbCtrlStrmArg;
};
struct CellPngDecExtInfo
{
be_t<u64> reserved;
@ -327,9 +236,9 @@ struct CellPngDecExtInfo
struct CellPngDecExtInParam
{
be_t<CellPngDecBufferMode> bufferMode;
be_t<s32> bufferMode; // CellPngDecBufferMode
be_t<u32> outputCounts;
be_t<CellPngDecSpuMode> spuMode;
be_t<s32> spuMode; // CellPngDecSpuMode
};
struct CellPngDecExtOutParam
@ -338,44 +247,22 @@ struct CellPngDecExtOutParam
be_t<u32> outputHeight;
};
// Callbacks for decoding partial streams
using CellPngDecCbControlStream = func_def<s32(vm::ptr<CellPngDecStrmInfo> strmInfo, vm::ptr<CellPngDecStrmParam> strmParam, vm::ptr<void> cbCtrlStrmArg)>;
using CellPngDecCbControlDisp = func_def<s32(vm::ptr<CellPngDecDispInfo> dispInfo, vm::ptr<CellPngDecDispParam> dispParam, vm::ptr<void> cbCtrlDispArg)>;
struct CellPngDecCbCtrlStrm
{
vm::bptr<CellPngDecCbControlStream> cbCtrlStrmFunc;
vm::bptr<void> cbCtrlStrmArg;
};
struct CellPngDecCbCtrlDisp
{
vm::bptr<CellPngDecCbControlDisp> cbCtrlDispFunc;
be_t<vm::ptr<void>> cbCtrlDispArg;
vm::bptr<void> cbCtrlDispArg;
};
// Functions
s32 cellPngDecExtOpen(
CellPngDecMainHandle mainHandle,
vm::ptr<u32> subHandle,
vm::ptr<const CellPngDecSrc> src,
vm::ptr<CellPngDecOpnInfo> openInfo,
vm::ptr<const CellPngDecCbCtrlStrm> cbCtrlStrm,
vm::ptr<const CellPngDecOpnParam> opnParam);
s32 cellPngDecExtReadHeader(
CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle,
vm::ptr<CellPngDecInfo> info,
vm::ptr<CellPngDecExtInfo> extInfo);
s32 cellPngDecExtSetParameter(
CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle,
vm::ptr<const CellPngDecInParam> inParam,
vm::ptr<CellPngDecOutParam> outParam,
vm::ptr<const CellPngDecExtInParam> extInParam,
vm::ptr<CellPngDecExtOutParam> extOutParam);
s32 cellPngDecExtDecodeData(
CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle,
vm::ptr<u8> data,
vm::ptr<const CellPngDecDataCtrlParam> dataCtrlParam,
vm::ptr<CellPngDecDataOutInfo> dataOutInfo,
vm::ptr<const CellPngDecCbCtrlDisp> cbCtrlDisp,
vm::ptr<CellPngDecDispParam> dispParam);
// Custom structs
struct PngDecoder
{
@ -398,4 +285,4 @@ struct PngStream
CellPngDecStrmInfo streamInfo;
CellPngDecStrmParam streamParam;
};
};

View File

@ -24,8 +24,6 @@ enum
CELL_SEARCH_ERROR_GENERIC = 0x8002C8FF,
};
typedef be_t<s32> CellSearchId;
// Constants
enum
{
@ -173,7 +171,7 @@ struct CellSearchContentId
struct CellSearchResultParam
{
be_t<CellSearchId> searchId;
be_t<s32> searchId;
be_t<u32> resultNum;
};
@ -271,7 +269,7 @@ struct CellSearchVideoSceneInfo
be_t<CellSearchSceneType> sceneType;
be_t<s64> startTime_ms;
be_t<s64> endTime_ms;
be_t<CellSearchContentId> videoId;
CellSearchContentId videoId;
char title[CELL_SEARCH_TITLE_LEN_MAX + 1];
char reserved[3];
char tags[CELL_SEARCH_TAG_NUM_MAX][CELL_SEARCH_TAG_LEN_MAX];

View File

@ -1263,7 +1263,7 @@ s32 _cellSpursWorkloadFlagReceiver(vm::ptr<CellSpurs> spurs, u32 wid, u32 is_set
return CELL_OK;
}
s32 cellSpursGetWorkloadFlag(vm::ptr<CellSpurs> spurs, vm::ptr<vm::bptr<CellSpursWorkloadFlag>> flag)
s32 cellSpursGetWorkloadFlag(vm::ptr<CellSpurs> spurs, vm::pptr<CellSpursWorkloadFlag> flag)
{
cellSpurs.Warning("%s(spurs_addr=0x%x, flag_addr=0x%x)", __FUNCTION__, spurs.addr(), flag.addr());
@ -2736,7 +2736,7 @@ s32 cellSpursTasksetSetExceptionEventHandler(vm::ptr<CellSpursTaskset> taskset,
return CELL_SPURS_TASK_ERROR_INVAL;
}
if (taskset->m.exception_handler != 0)
if (taskset->m.exception_handler)
{
return CELL_SPURS_TASK_ERROR_BUSY;
}
@ -2996,7 +2996,7 @@ s32 spursTraceInitialize(vm::ptr<CellSpurs> spurs, vm::ptr<CellSpursTraceInfo> b
return CELL_SPURS_CORE_ERROR_INVAL;
}
if (spurs->m.traceBuffer != 0)
if (spurs->m.traceBuffer)
{
return CELL_SPURS_CORE_ERROR_STAT;
}

View File

@ -388,8 +388,8 @@ struct CellSpurs
u8 unk0[0x20]; // 0x00 - SPU exceptionh handler 0x08 - SPU exception handler args
be_t<u64> sem; // 0x20
u8 unk1[0x8];
vm::bptr<CellSpursShutdownCompletionEventHook, 1, u64> hook; // 0x30
vm::bptr<void, 1, u64> hookArg; // 0x38
vm::bptr<CellSpursShutdownCompletionEventHook, u64> hook; // 0x30
vm::bptr<void, u64> hookArg; // 0x38
u8 unk2[0x40];
};
@ -409,7 +409,7 @@ struct CellSpurs
struct WorkloadInfo
{
vm::bptr<const void, 1, u64> addr; // Address of the executable
vm::bptr<const void, u64> addr; // Address of the executable
be_t<u64> arg; // spu argument
be_t<u32> size;
atomic_be_t<u8> uniqueId; // The unique id is the same for all workloads with the same addr
@ -423,8 +423,8 @@ struct CellSpurs
{
static const uint size = 0x10;
vm::bptr<const char, 1, u64> nameClass;
vm::bptr<const char, 1, u64> nameInstance;
vm::bptr<const char, u64> nameClass;
vm::bptr<const char, u64> nameInstance;
};
union
@ -475,7 +475,7 @@ struct CellSpurs
u8 wklStatus2[0x10]; // 0xE0
u8 wklEvent2[0x10]; // 0xF0
_sub_str1 wklF1[0x10]; // 0x100
vm::bptr<CellSpursTraceInfo, 1, u64> traceBuffer; // 0x900
vm::bptr<CellSpursTraceInfo, u64> traceBuffer; // 0x900
be_t<u32> traceStartIndex[6]; // 0x908
u8 unknown7[0x948 - 0x920]; // 0x920
be_t<u64> traceDataSize; // 0x948
@ -641,7 +641,7 @@ struct CellSpursTaskset
struct TaskInfo
{
CellSpursTaskArgument args; // 0x00
vm::bptr<u64, 1, u64> elf_addr; // 0x10
vm::bptr<u64, u64> elf_addr; // 0x10
be_t<u64> context_save_storage_and_alloc_ls_blocks; // 0x18 This is (context_save_storage_addr | allocated_ls_blocks)
CellSpursTaskLsPattern ls_pattern; // 0x20
};
@ -662,7 +662,7 @@ struct CellSpursTaskset
be_t<u128> enabled; // 0x30
be_t<u128> signalled; // 0x40
be_t<u128> waiting; // 0x50
vm::bptr<CellSpurs, 1, u64> spurs; // 0x60
vm::bptr<CellSpurs, u64> spurs; // 0x60
be_t<u64> args; // 0x68
u8 enable_clear_ls; // 0x70
u8 x71; // 0x71
@ -671,8 +671,8 @@ struct CellSpursTaskset
be_t<u32> wid; // 0x74
be_t<u64> x78; // 0x78
TaskInfo task_info[128]; // 0x80
vm::bptr<u64, 1, u64> exception_handler; // 0x1880
vm::bptr<u64, 1, u64> exception_handler_arg; // 0x1888
vm::bptr<u64, u64> exception_handler; // 0x1880
vm::bptr<u64, u64> exception_handler_arg; // 0x1888
be_t<u32> size; // 0x1890
u32 unk2; // 0x1894
u32 event_flag_id1; // 0x1898
@ -750,8 +750,8 @@ struct CellSpursTaskset2
struct TaskInfo
{
CellSpursTaskArgument args;
vm::bptr<u64, 1, u64> elf_addr;
vm::bptr<u64, 1, u64> context_save_storage; // This is (context_save_storage_addr | allocated_ls_blocks)
vm::bptr<u64, u64> elf_addr;
vm::bptr<u64, u64> context_save_storage; // This is (context_save_storage_addr | allocated_ls_blocks)
CellSpursTaskLsPattern ls_pattern;
};
@ -771,7 +771,7 @@ struct CellSpursTaskset2
be_t<u32> enabled_set[4]; // 0x30
be_t<u32> signal_received_set[4]; // 0x40
be_t<u32> waiting_set[4]; // 0x50
vm::bptr<CellSpurs, 1, u64> spurs; // 0x60
vm::bptr<CellSpurs, u64> spurs; // 0x60
be_t<u64> args; // 0x68
u8 enable_clear_ls; // 0x70
u8 x71; // 0x71
@ -780,8 +780,8 @@ struct CellSpursTaskset2
be_t<u32> wid; // 0x74
be_t<u64> x78; // 0x78
TaskInfo task_info[128]; // 0x80
vm::bptr<u64, 1, u64> exception_handler; // 0x1880
vm::bptr<u64, 1, u64> exception_handler_arg; // 0x1888
vm::bptr<u64, u64> exception_handler; // 0x1880
vm::bptr<u64, u64> exception_handler_arg; // 0x1888
be_t<u32> size; // 0x1890
u32 unk2; // 0x1894
u32 event_flag_id1; // 0x1898
@ -872,8 +872,8 @@ struct CellSpursTaskInfo
const be_t<u32> eaElf_addr; //void *eaElf
const be_t<u32> eaContext_addr; //void *eaContext
be_t<u32> sizeContext;
be_t<u8> state;
be_t<u8> hasSignal;
u8 state;
u8 hasSignal;
const be_t<u32> CellSpursTaskExitCode_addr;
u8 guid[8];
//be_t<u8> reserved[];
@ -895,10 +895,10 @@ struct SpursKernelContext
u8 wklLocPendingContention[0x10]; // 0x190
u8 priority[0x10]; // 0x1A0
u8 x1B0[0x10]; // 0x1B0
vm::bptr<CellSpurs, 1, u64> spurs; // 0x1C0
vm::bptr<CellSpurs, u64> spurs; // 0x1C0
be_t<u32> spuNum; // 0x1C8
be_t<u32> dmaTagId; // 0x1CC
vm::bptr<const void, 1, u64> wklCurrentAddr; // 0x1D0
vm::bptr<const void, u64> wklCurrentAddr; // 0x1D0
be_t<u32> wklCurrentUniqueId; // 0x1D8
be_t<u32> wklCurrentId; // 0x1DC
be_t<u32> exitToKernelAddr; // 0x1E0
@ -932,7 +932,7 @@ struct SpursTasksetContext
u8 tempAreaTaskset[0x80]; // 0x2700
u8 tempAreaTaskInfo[0x30]; // 0x2780
be_t<u64> x27B0; // 0x27B0
vm::bptr<CellSpursTaskset, 1, u64> taskset; // 0x27B8
vm::bptr<CellSpursTaskset, u64> taskset; // 0x27B8
be_t<u32> kernelMgmtAddr; // 0x27C0
be_t<u32> syscallAddr; // 0x27C4
be_t<u32> x27C8; // 0x27C8

View File

@ -1811,7 +1811,7 @@ s32 cellSyncLFQueueDepth(vm::ptr<CellSyncLFQueue> queue, vm::ptr<u32> depth)
return CELL_OK;
}
s32 _cellSyncLFQueueGetSignalAddress(vm::ptr<const CellSyncLFQueue> queue, vm::ptr<vm::bptr<void>> ppSignal)
s32 _cellSyncLFQueueGetSignalAddress(vm::ptr<const CellSyncLFQueue> queue, vm::pptr<void> ppSignal)
{
cellSync.Log("_cellSyncLFQueueGetSignalAddress(queue=*0x%x, ppSignal=**0x%x)", queue, ppSignal);

View File

@ -71,7 +71,7 @@ struct CellSyncRwm
atomic_be_t<data_t> data;
be_t<u32> m_size;
vm::bptr<void, 1, u64> m_buffer;
vm::bptr<void, u64> m_buffer;
};
static_assert(sizeof(CellSyncRwm) == 16, "CellSyncRwm: wrong size");
@ -87,7 +87,7 @@ struct CellSyncQueue
atomic_be_t<data_t> data;
be_t<u32> m_size;
be_t<u32> m_depth;
vm::bptr<u8, 1, u64> m_buffer;
vm::bptr<u8, u64> m_buffer;
be_t<u64> reserved;
};
@ -155,7 +155,7 @@ struct CellSyncLFQueue
be_t<u32> m_size; // 0x10
be_t<u32> m_depth; // 0x14
vm::bptr<u8, 1, u64> m_buffer; // 0x18
vm::bptr<u8, u64> m_buffer; // 0x18
u8 m_bs[4]; // 0x20
be_t<CellSyncQueueDirection> m_direction; // 0x24
be_t<u32> m_v1; // 0x28
@ -164,7 +164,7 @@ struct CellSyncLFQueue
be_t<u16> m_hs1[15]; // 0x32
atomic_be_t<pop2_t> pop2; // 0x50
be_t<u16> m_hs2[15]; // 0x52
vm::bptr<void, 1, u64> m_eaSignal; // 0x70
vm::bptr<void, u64> m_eaSignal; // 0x70
be_t<u32> m_v2; // 0x78
be_t<u32> m_eq_id; // 0x7C

View File

@ -795,7 +795,7 @@ s32 _nid_a21aa896(PPUThread& CPU, u32 handle, vm::ptr<const CellVdecPicFormat2>
return cellVdecGetPicture(handle, format, outBuff);
}
s32 cellVdecGetPicItem(u32 handle, vm::ptr<vm::bptr<CellVdecPicItem>> picItem)
s32 cellVdecGetPicItem(u32 handle, vm::pptr<CellVdecPicItem> picItem)
{
cellVdec.Log("cellVdecGetPicItem(handle=0x%x, picItem=**0x%x)", handle, picItem);

View File

@ -368,7 +368,7 @@ int cellSurMixerCreate(vm::ptr<const CellSurMixerConfig> config)
for (auto& p : ssp) if (p.m_active && p.m_created)
{
auto v = vm::lptrl<s16>::make(p.m_addr); // 16-bit LE audio data
auto v = vm::ptrl<s16>::make(p.m_addr); // 16-bit LE audio data
float left = 0.0f;
float right = 0.0f;
float speed = fabs(p.m_speed);

View File

@ -377,7 +377,7 @@ int sceNpClansPostChallenge(vm::ptr<SceNpClansRequestHandle> handle, u32 clanId,
if (!sceNpClansInstance.m_bSceNpClansInitialized)
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
if (data != 0)
if (data)
return SCE_NP_CLANS_ERROR_NOT_SUPPORTED;
//todo

View File

@ -108,8 +108,7 @@ enum
};
// Request handle for clan API
struct SceNpClansRequest;
typedef vm::ptr<SceNpClansRequest> SceNpClansRequestHandle;
using SceNpClansRequestHandle = vm::ptr<struct SceNpClansRequest>;
// Paging request structure
struct SceNpClansPagingRequest

View File

@ -897,9 +897,20 @@ s32 sys_raw_spu_image_load(s32 id, vm::ptr<sys_spu_image> img)
sysPrxForUser.Warning("sys_raw_spu_image_load(id=%d, img=*0x%x)", id, img);
// TODO: use segment info
const auto stamp0 = get_system_time();
memcpy(vm::get_ptr<void>(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id), vm::get_ptr<void>(img->addr), 256 * 1024);
const auto stamp1 = get_system_time();
vm::write32(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id + RAW_SPU_PROB_OFFSET + SPU_NPC_offs, img->entry_point | be_t<u32>::make(1));
const auto stamp2 = get_system_time();
LOG_ERROR(GENERAL, "memcpy() latency: %lldus", (stamp1 - stamp0));
LOG_ERROR(GENERAL, "MMIO latency: %lldus", (stamp2 - stamp1));
return CELL_OK;
}

View File

@ -136,7 +136,7 @@ namespace ppu_func_detail
template <typename RT, typename F, typename Tuple>
force_inline RT call(F f, Tuple && t)
{
typedef typename std::decay<Tuple>::type ttype;
using ttype = std::decay_t<Tuple>;
return ppu_func_detail::call_impl<RT, F, Tuple, 0 == std::tuple_size<ttype>::value, std::tuple_size<ttype>::value>::call(f, std::forward<Tuple>(t));
}

View File

@ -80,7 +80,7 @@ void sys_game_process_exitspawn(vm::ptr<const char> path, u32 argv_addr, u32 env
if (argv_addr)
{
auto argvp = vm::ptr<vm::bptr<const char>>::make(argv_addr);
auto argvp = vm::pptr<const char>::make(argv_addr);
while (argvp && *argvp)
{
argv.push_back(argvp[0].get_ptr());
@ -94,7 +94,7 @@ void sys_game_process_exitspawn(vm::ptr<const char> path, u32 argv_addr, u32 env
if (envp_addr)
{
auto envp = vm::ptr<vm::bptr<const char>>::make(envp_addr);
auto envp = vm::pptr<const char>::make(envp_addr);
while (envp && *envp)
{
env.push_back(envp[0].get_ptr());
@ -154,7 +154,7 @@ void sys_game_process_exitspawn2(vm::ptr<const char> path, u32 argv_addr, u32 en
if (argv_addr)
{
auto argvp = vm::ptr<vm::bptr<const char>>::make(argv_addr);
auto argvp = vm::pptr<const char>::make(argv_addr);
while (argvp && *argvp)
{
argv.push_back(argvp[0].get_ptr());
@ -169,7 +169,7 @@ void sys_game_process_exitspawn2(vm::ptr<const char> path, u32 argv_addr, u32 en
if (envp_addr)
{
auto envp = vm::ptr<vm::bptr<const char>>::make(envp_addr);
auto envp = vm::pptr<const char>::make(envp_addr);
while (envp && *envp)
{
env.push_back(envp[0].get_ptr());

View File

@ -140,7 +140,7 @@ s32 sys_prx_load_module(vm::ptr<const char> path, u64 flags, vm::ptr<sys_prx_loa
return prx_load_module(path.get_ptr(), flags, pOpt);
}
s32 sys_prx_load_module_list(s32 count, vm::ptr<const char, 2> path_list, u64 flags, vm::ptr<sys_prx_load_module_option_t> pOpt, vm::ptr<u32> id_list)
s32 sys_prx_load_module_list(s32 count, vm::pptr<const char> path_list, u64 flags, vm::ptr<sys_prx_load_module_option_t> pOpt, vm::ptr<u32> id_list)
{
sys_prx.Warning("sys_prx_load_module_list(count=%d, path_list=*0x%x, flags=0x%llx, pOpt=*0x%x, id_list=*0x%x)", count, path_list, flags, pOpt, id_list);

View File

@ -87,7 +87,7 @@ struct sys_prx_relocation_info_t
u8 index_value;
u8 index_addr;
be_t<u32> type;
vm::bptr<void, 1, u64> ptr;
vm::bptr<void, u64> ptr;
};
@ -102,14 +102,14 @@ struct sys_prx_start_module_option_t
{
be_t<u64> size;
be_t<u64> put;
vm::bptr<s32(int argc, vm::ptr<void> argv), 1, u64> entry_point;
vm::bptr<s32(int argc, vm::ptr<void> argv), u64> entry_point;
};
struct sys_prx_stop_module_option_t
{
be_t<u64> size;
be_t<u64> put;
vm::bptr<s32(int argc, vm::ptr<void> argv), 1, u64> entry_point;
vm::bptr<s32(int argc, vm::ptr<void> argv), u64> entry_point;
};
struct sys_prx_unload_module_option_t
@ -135,7 +135,7 @@ REG_ID_TYPE(lv2_prx_t, 0x23); // SYS_PRX_OBJECT
// SysCalls
s32 sys_prx_load_module(vm::ptr<const char> path, u64 flags, vm::ptr<sys_prx_load_module_option_t> pOpt);
s32 sys_prx_load_module_list(s32 count, vm::ptr<const char, 2> path_list, u64 flags, vm::ptr<sys_prx_load_module_option_t> pOpt, vm::ptr<u32> id_list);
s32 sys_prx_load_module_list(s32 count, vm::pptr<const char> path_list, u64 flags, vm::ptr<sys_prx_load_module_option_t> pOpt, vm::ptr<u32> id_list);
s32 sys_prx_load_module_on_memcontainer();
s32 sys_prx_load_module_by_fd();
s32 sys_prx_load_module_on_memcontainer_by_fd();

View File

@ -40,8 +40,8 @@ namespace loader
be_t<u32> p_type;
be_t<u32> p_flags;
be_t<u64> p_offset;
bptr<void, 1, u64> p_vaddr;
bptr<void, 1, u64> p_paddr;
bptr<void, u64> p_vaddr;
bptr<void, u64> p_paddr;
be_t<u64> p_filesz;
be_t<u64> p_memsz;
be_t<u64> p_align;
@ -52,7 +52,7 @@ namespace loader
be_t<u32> sh_name;
be_t<u32> sh_type;
be_t<u64> sh_flags;
bptr<void, 1, u64> sh_addr;
bptr<void, u64> sh_addr;
be_t<u64> sh_offset;
be_t<u64> sh_size;
be_t<u32> sh_link;

View File

@ -57,6 +57,18 @@ template<typename T> force_inline T align(const T addr, int align)
return (addr + (align - 1)) & ~(align - 1);
}
template<typename T> struct sizeof32_t
{
static const u32 value = static_cast<u32>(sizeof(T));
static_assert(value == sizeof(T), "sizeof32() error: sizeof() is too big");
};
// return 32 bit sizeof() to avoid widening/narrowing conversions with size_t
#define sizeof32(type) sizeof32_t<type>::value
template<typename T> using func_def = T; // workaround for MSVC bug: `using X = func_def<void()>;` instead of `using X = void();`
#include "Utilities/BEType.h"
#include "Utilities/StrFmt.h"