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