| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <cstring> |
| 7 |
|
| 8 |
#include "Common/CommonTypes.h" |
| 9 |
#include "Common/Inline.h" |
| 10 |
#include "Common/Swap.h" |
| 11 |
|
| 12 |
extern const u8* g_video_buffer_read_ptr; |
| 13 |
extern u8* g_vertex_manager_write_ptr; |
| 14 |
|
| 15 |
DOLPHIN_FORCE_INLINE void DataSkip(u32 skip) |
| 16 |
{ |
| 17 |
g_video_buffer_read_ptr += skip; |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
template <int count> |
| 22 |
DOLPHIN_FORCE_INLINE void DataSkip() |
| 23 |
{ |
| 24 |
g_video_buffer_read_ptr += count; |
| 25 |
} |
| 26 |
|
| 27 |
template <typename T> |
| 28 |
DOLPHIN_FORCE_INLINE T DataPeek(int _uOffset, const u8* bufp = g_video_buffer_read_ptr) |
| 29 |
{ |
| 30 |
T result; |
| 31 |
std::memcpy(&result, &bufp[_uOffset], sizeof(T)); |
| 32 |
return Common::FromBigEndian(result); |
| 33 |
} |
| 34 |
|
| 35 |
template <typename T> |
| 36 |
DOLPHIN_FORCE_INLINE T DataRead(const u8** bufp = &g_video_buffer_read_ptr) |
| 37 |
{ |
| 38 |
auto const result = DataPeek<T>(0, *bufp); |
| 39 |
*bufp += sizeof(T); |
| 40 |
return result; |
| 41 |
} |
| 42 |
|
| 43 |
DOLPHIN_FORCE_INLINE u32 DataReadU32Unswapped() |
| 44 |
{ |
| 45 |
u32 result; |
| 46 |
std::memcpy(&result, g_video_buffer_read_ptr, sizeof(u32)); |
| 47 |
g_video_buffer_read_ptr += sizeof(u32); |
| 48 |
return result; |
| 49 |
} |
| 50 |
|
| 51 |
DOLPHIN_FORCE_INLINE const u8* DataGetPosition() |
| 52 |
{ |
| 53 |
return g_video_buffer_read_ptr; |
| 54 |
} |
| 55 |
|
| 56 |
template <typename T> |
| 57 |
DOLPHIN_FORCE_INLINE void DataWrite(T data) |
| 58 |
{ |
| 59 |
std::memcpy(g_vertex_manager_write_ptr, &data, sizeof(T)); |
| 60 |
g_vertex_manager_write_ptr += sizeof(T); |
| 61 |
} |