2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2014-11-28 19:39:24 -07:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-12-07 13:51:45 -07:00
|
|
|
#pragma once
|
2014-11-28 19:39:24 -07:00
|
|
|
|
2015-09-17 12:24:06 -06:00
|
|
|
#include <cstring>
|
2016-01-17 14:54:31 -07:00
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2020-05-03 11:42:12 -06:00
|
|
|
#include "Common/Inline.h"
|
2014-11-28 19:39:24 -07:00
|
|
|
|
|
|
|
extern u8* g_video_buffer_read_ptr;
|
2014-12-09 00:30:38 -07:00
|
|
|
extern u8* g_vertex_manager_write_ptr;
|
2014-11-28 19:39:24 -07:00
|
|
|
|
2018-06-09 09:47:01 -06:00
|
|
|
DOLPHIN_FORCE_INLINE void DataSkip(u32 skip)
|
2014-11-28 19:39:24 -07:00
|
|
|
{
|
|
|
|
g_video_buffer_read_ptr += skip;
|
|
|
|
}
|
|
|
|
|
|
|
|
// probably unnecessary
|
|
|
|
template <int count>
|
2018-06-09 09:47:01 -06:00
|
|
|
DOLPHIN_FORCE_INLINE void DataSkip()
|
2014-11-28 19:39:24 -07:00
|
|
|
{
|
|
|
|
g_video_buffer_read_ptr += count;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2018-06-09 09:47:01 -06:00
|
|
|
DOLPHIN_FORCE_INLINE T DataPeek(int _uOffset, u8* bufp = g_video_buffer_read_ptr)
|
2014-11-28 19:39:24 -07:00
|
|
|
{
|
2015-09-17 12:24:06 -06:00
|
|
|
T result;
|
|
|
|
std::memcpy(&result, &bufp[_uOffset], sizeof(T));
|
|
|
|
return Common::FromBigEndian(result);
|
2014-11-28 19:39:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2018-06-09 09:47:01 -06:00
|
|
|
DOLPHIN_FORCE_INLINE T DataRead(u8** bufp = &g_video_buffer_read_ptr)
|
2014-11-28 19:39:24 -07:00
|
|
|
{
|
2015-09-17 12:24:06 -06:00
|
|
|
auto const result = DataPeek<T>(0, *bufp);
|
2014-11-28 19:39:24 -07:00
|
|
|
*bufp += sizeof(T);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-06-09 09:47:01 -06:00
|
|
|
DOLPHIN_FORCE_INLINE u32 DataReadU32Unswapped()
|
2014-11-28 19:39:24 -07:00
|
|
|
{
|
2015-09-17 12:24:06 -06:00
|
|
|
u32 result;
|
|
|
|
std::memcpy(&result, g_video_buffer_read_ptr, sizeof(u32));
|
|
|
|
g_video_buffer_read_ptr += sizeof(u32);
|
|
|
|
return result;
|
2014-11-28 19:39:24 -07:00
|
|
|
}
|
|
|
|
|
2018-06-09 09:47:01 -06:00
|
|
|
DOLPHIN_FORCE_INLINE u8* DataGetPosition()
|
2014-11-28 19:39:24 -07:00
|
|
|
{
|
|
|
|
return g_video_buffer_read_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2018-06-09 09:47:01 -06:00
|
|
|
DOLPHIN_FORCE_INLINE void DataWrite(T data)
|
2014-11-28 19:39:24 -07:00
|
|
|
{
|
2015-09-17 12:24:06 -06:00
|
|
|
std::memcpy(g_vertex_manager_write_ptr, &data, sizeof(T));
|
2014-12-09 00:30:38 -07:00
|
|
|
g_vertex_manager_write_ptr += sizeof(T);
|
2014-11-28 19:39:24 -07:00
|
|
|
}
|