#pragma once namespace vm { template class _ref_base { protected: AT m_addr; public: typedef T type; typedef typename remove_be_t::type le_type; typedef typename to_be_t::type be_type; operator T&() { return get_ref(m_addr); } operator const T&() const { return get_ref(m_addr); } AT addr() const { return m_addr; } static _ref_base make(const AT& addr) { return reinterpret_cast<_ref_base&>(addr); } _ref_base& operator = (le_type right) { get_ref(m_addr) = right; return *this; } const _ref_base& operator = (le_type right) const { get_ref(m_addr) = right; return *this; } _ref_base& operator = (be_type right) { get_ref(m_addr) = right; return *this; } const _ref_base& operator = (be_type right) const { get_ref(m_addr) = right; return *this; } }; //BE reference to LE data template struct brefl : public _ref_base::type> { using _ref_base::type>::operator=; }; //BE reference to BE data template struct brefb : public _ref_base::type, typename to_be_t::type> { using _ref_base::type, typename to_be_t::type>::operator=; }; //LE reference to BE data template struct lrefb : public _ref_base::type, AT> { using _ref_base::type, AT>::operator=; }; //LE reference to LE data template struct lrefl : public _ref_base { using _ref_base::operator=; }; namespace ps3 { //default reference for HLE functions (LE reference to BE data) template struct ref : public lrefb { using lrefb::operator=; }; //default reference for HLE structures (BE reference to BE data) template struct bref : public brefb { using brefb::operator=; }; } namespace psv { //default reference for HLE functions & structures (LE reference to LE data) template struct ref : public lrefl { using lrefl::operator=; }; } //PS3 emulation is main now, so lets it be as default using namespace ps3; } namespace fmt { // external specializations for fmt::format function template struct unveil, false> { typedef typename unveil::result_type result_type; __forceinline static result_type get_value(const vm::ps3::ref& arg) { return unveil::get_value(arg.addr()); } }; template struct unveil, false> { typedef typename unveil::result_type result_type; __forceinline static result_type get_value(const vm::ps3::bref& arg) { return unveil::get_value(arg.addr()); } }; template struct unveil, false> { typedef typename unveil::result_type result_type; __forceinline static result_type get_value(const vm::psv::ref& arg) { return unveil::get_value(arg.addr()); } }; } // external specializations for PPU GPR (SC_FUNC.h, CB_FUNC.h) template struct cast_ppu_gpr; template struct cast_ppu_gpr, false> { __forceinline static u64 to_gpr(const vm::ps3::ref& value) { return value.addr(); } __forceinline static vm::ps3::ref from_gpr(const u64 reg) { return vm::ps3::ref::make(cast_ppu_gpr::value>::from_gpr(reg)); } }; // external specializations for ARMv7 GPR template struct cast_armv7_gpr; template struct cast_armv7_gpr, false> { __forceinline static u32 to_gpr(const vm::psv::ref& value) { return value.addr(); } __forceinline static vm::psv::ref from_gpr(const u32 reg) { return vm::psv::ref::make(cast_armv7_gpr::value>::from_gpr(reg)); } };