#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(AT addr) { return (_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; }