2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-11-29 02:39:24 +00:00
|
|
|
|
2014-12-07 20:51:45 +00:00
|
|
|
#pragma once
|
2014-11-29 02:39:24 +00:00
|
|
|
|
2015-09-17 18:24:06 +00:00
|
|
|
#include <cstring>
|
2016-01-17 21:54:31 +00:00
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2020-05-03 17:42:12 +00:00
|
|
|
#include "Common/Inline.h"
|
2022-11-23 00:54:05 +00:00
|
|
|
#include "Common/Swap.h"
|
2014-11-29 02:39:24 +00:00
|
|
|
|
2022-11-23 00:54:05 +00:00
|
|
|
extern const u8* g_video_buffer_read_ptr;
|
2014-12-09 07:30:38 +00:00
|
|
|
extern u8* g_vertex_manager_write_ptr;
|
2014-11-29 02:39:24 +00:00
|
|
|
|
2018-06-09 15:47:01 +00:00
|
|
|
DOLPHIN_FORCE_INLINE void DataSkip(u32 skip)
|
2014-11-29 02:39:24 +00:00
|
|
|
{
|
|
|
|
g_video_buffer_read_ptr += skip;
|
|
|
|
}
|
|
|
|
|
|
|
|
// probably unnecessary
|
|
|
|
template <int count>
|
2018-06-09 15:47:01 +00:00
|
|
|
DOLPHIN_FORCE_INLINE void DataSkip()
|
2014-11-29 02:39:24 +00:00
|
|
|
{
|
|
|
|
g_video_buffer_read_ptr += count;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2022-11-23 00:54:05 +00:00
|
|
|
DOLPHIN_FORCE_INLINE T DataPeek(int _uOffset, const u8* bufp = g_video_buffer_read_ptr)
|
2014-11-29 02:39:24 +00:00
|
|
|
{
|
2015-09-17 18:24:06 +00:00
|
|
|
T result;
|
|
|
|
std::memcpy(&result, &bufp[_uOffset], sizeof(T));
|
|
|
|
return Common::FromBigEndian(result);
|
2014-11-29 02:39:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2022-11-23 00:54:05 +00:00
|
|
|
DOLPHIN_FORCE_INLINE T DataRead(const u8** bufp = &g_video_buffer_read_ptr)
|
2014-11-29 02:39:24 +00:00
|
|
|
{
|
2015-09-17 18:24:06 +00:00
|
|
|
auto const result = DataPeek<T>(0, *bufp);
|
2014-11-29 02:39:24 +00:00
|
|
|
*bufp += sizeof(T);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-06-09 15:47:01 +00:00
|
|
|
DOLPHIN_FORCE_INLINE u32 DataReadU32Unswapped()
|
2014-11-29 02:39:24 +00:00
|
|
|
{
|
2015-09-17 18:24:06 +00:00
|
|
|
u32 result;
|
|
|
|
std::memcpy(&result, g_video_buffer_read_ptr, sizeof(u32));
|
|
|
|
g_video_buffer_read_ptr += sizeof(u32);
|
|
|
|
return result;
|
2014-11-29 02:39:24 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 00:54:05 +00:00
|
|
|
DOLPHIN_FORCE_INLINE const u8* DataGetPosition()
|
2014-11-29 02:39:24 +00:00
|
|
|
{
|
|
|
|
return g_video_buffer_read_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2018-06-09 15:47:01 +00:00
|
|
|
DOLPHIN_FORCE_INLINE void DataWrite(T data)
|
2014-11-29 02:39:24 +00:00
|
|
|
{
|
2015-09-17 18:24:06 +00:00
|
|
|
std::memcpy(g_vertex_manager_write_ptr, &data, sizeof(T));
|
2014-12-09 07:30:38 +00:00
|
|
|
g_vertex_manager_write_ptr += sizeof(T);
|
2014-11-29 02:39:24 +00:00
|
|
|
}
|