/** ****************************************************************************** * Xenia : Xbox 360 Emulator Research Project * ****************************************************************************** * Copyright 2020 Ben Vanik. All rights reserved. * * Released under the BSD license - see LICENSE in the root for more details. * ****************************************************************************** */ #ifndef XENIA_GUEST_POINTERS_H_ #define XENIA_GUEST_POINTERS_H_ namespace xe { template struct ShiftedPointer { using this_type = ShiftedPointer; TBase* m_base; inline TBase* operator->() { return m_base; } inline TBase& operator*() { return *m_base; } inline this_type& operator=(TBase* base) { m_base = base; return *this; } inline this_type& operator=(this_type other) { m_base = other.m_base; return *this; } TAdj* GetAdjacent() { return reinterpret_cast( &reinterpret_cast(m_base)[-static_cast(offset)]); } }; template struct TypedGuestPointer { xe::be m_ptr; inline TypedGuestPointer& operator=(uint32_t ptr) { m_ptr = ptr; return *this; } inline bool operator==(uint32_t ptr) const { return m_ptr == ptr; } inline bool operator!=(uint32_t ptr) const { return m_ptr != ptr; } // use value directly, no endian swap needed inline bool operator!() const { return !m_ptr.value; } }; } // namespace xe #endif // XENIA_GUEST_POINTERS_H_