diff --git a/Utilities/BEType.h b/Utilities/BEType.h index b209874096..51c5e8e082 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -294,38 +294,49 @@ public: return ToLE(); } + be_t& operator = (const be_t& value) = default; + + be_t& operator = (T value) + { + m_data = se_t::func(value); + + return *this; + } + template operator const be_t() const { - if (sizeof(T1) > sizeof(T) || std::is_floating_point::value || std::is_floating_point::value) + template + struct _convert { - T1 res = se_t::func(ToLE()); - return (be_t&)res; - } - else if (sizeof(T1) < sizeof(T)) + static __forceinline be_t& func(Tfrom& be_value) + { + Tto res = be_value; + return (be_t&)res; + } + }; + + template + struct _convert { - T1 res = ToBE() >> ((sizeof(T) - sizeof(T1)) * 8); - return (be_t&)res; - } - else + static __forceinline be_t& func(Tfrom& be_value) + { + Tto res = se_t::func(se_t::func(be_value);); + return (be_t&)res; + } + }; + + template + struct _convert { - T1 res = ToBE(); - return (be_t&)res; - } - } + static __forceinline be_t& func(Tfrom& be_value) + { + Tto res = be_value >> ((sizeof(Tfrom)-sizeof(Tto)) * 8); + return (be_t&)res; + } + }; - be_t& operator = (const T& right) - { - m_data = se_t::func(right); - return *this; - } - - be_t& operator = (const be_t& right) = default; - - be_t& operator = (const be_t& right) - { - m_data = right.ToBE(); - return *this; + return _convert sizeof(T)) ? 1 : (sizeof(T1) < sizeof(T) ? 2 : 0))>::func(m_data); } template be_t& operator += (T1 right) { return *this = T(*this) + right; } @@ -482,7 +493,7 @@ class to_be_t public: //true if need swap endianes for be - static const bool value = (sizeof(T2) > 1) && std::is_arithmetic::value; + static const bool value = (sizeof(T2) > 1) && (std::is_arithmetic::value || std::is_enum::value); //be_t if need swap endianes, T otherwise typedef typename _be_type_selector< T, T2, value >::type type; @@ -530,24 +541,6 @@ template struct _se, T1, value> : pub #define se32(x) _se::value #define se64(x) _se::value -// template that helps to define be_t arrays in unions -template -class be_array_t -{ - be_t data[size]; - -public: - __forceinline be_t& operator [] (size_t index) - { - return data[index]; - } - - __forceinline const be_t& operator [] (size_t index) const - { - return data[index]; - } -}; - template __forceinline static u8 Read8(T& f) { u8 ret; diff --git a/rpcs3/Emu/SysCalls/CB_FUNC.h b/rpcs3/Emu/SysCalls/CB_FUNC.h index 8a233ef973..8a5eda1dc1 100644 --- a/rpcs3/Emu/SysCalls/CB_FUNC.h +++ b/rpcs3/Emu/SysCalls/CB_FUNC.h @@ -146,13 +146,25 @@ namespace cb_detail { __forceinline static RT call(PPUThread& CPU, u32 pc, u32 rtoc, T... args) { - const bool stack = _bind_func_args<0, 0, 0>(CPU, args...); + const bool stack = _bind_func_args<0, 0, 0, T...>(CPU, args...); if (stack) CPU.GPR[1] -= FIXED_STACK_FRAME_SIZE; CPU.FastCall2(pc, rtoc); if (stack) CPU.GPR[1] += FIXED_STACK_FRAME_SIZE; return _func_res::get_value(CPU); } }; + + template + struct _func_caller + { + __forceinline static void call(PPUThread& CPU, u32 pc, u32 rtoc, T... args) + { + const bool stack = _bind_func_args<0, 0, 0, T...>(CPU, args...); + if (stack) CPU.GPR[1] -= FIXED_STACK_FRAME_SIZE; + CPU.FastCall2(pc, rtoc); + if (stack) CPU.GPR[1] += FIXED_STACK_FRAME_SIZE; + } + }; } namespace vm @@ -174,6 +186,13 @@ namespace vm } template -struct cb_caller : public cb_detail::_func_caller +RT cb_call(PPUThread& CPU, u32 pc, u32 rtoc, T... args) { -}; + return cb_detail::_func_caller::call(CPU, pc, rtoc, args...); +} + +template +void cb_call(PPUThread& CPU, u32 pc, u32 rtoc, T... args) +{ + cb_detail::_func_caller::call(CPU, pc, rtoc, args...); +} \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp index 102caccaf0..7a364deb36 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp @@ -68,18 +68,17 @@ int cellCameraGetDeviceGUID() return CELL_OK; } -int cellCameraGetType(s32 dev_num, CellCameraType type) +int cellCameraGetType(s32 dev_num, vm::ptr type) { cellCamera->Warning("cellCameraGetType(dev_num=%d, type_addr=0x%x)", dev_num, type); - if (Ini.CameraType.GetValue() == 1) - type = CELL_CAMERA_EYETOY; - else if (Ini.CameraType.GetValue() == 2) - type = CELL_CAMERA_EYETOY2; - else if (Ini.CameraType.GetValue() == 3) - type == CELL_CAMERA_USBVIDEOCLASS; - else - type = CELL_CAMERA_TYPE_UNKNOWN; + switch (Ini.CameraType.GetValue()) + { + case 1: *type = CELL_CAMERA_EYETOY; break; + case 2: *type = CELL_CAMERA_EYETOY2; break; + case 3: *type = CELL_CAMERA_USBVIDEOCLASS; break; + default: *type = CELL_CAMERA_TYPE_UNKNOWN; break; + } return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.h b/rpcs3/Emu/SysCalls/Modules/cellSpurs.h index d51ebf732a..bfa1520751 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.h @@ -93,14 +93,14 @@ struct CellSpurs2 struct CellSpursAttribute { - static const auto align = 8; - static const auto size = 512; + static const uint align = 8; + static const uint size = 512; union { // raw data u8 _u8[size]; - be_array_t _u32; + struct { be_t _u32[size / sizeof(u32)]; }; // real structure struct