2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2014-11-29 02:39:24 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
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
|
|
|
|
2014-11-29 02:39:24 +00:00
|
|
|
#include "Common/Common.h"
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-11-29 02:39:24 +00:00
|
|
|
|
|
|
|
extern 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
|
|
|
|
|
|
|
__forceinline void DataSkip(u32 skip)
|
|
|
|
{
|
|
|
|
g_video_buffer_read_ptr += skip;
|
|
|
|
}
|
|
|
|
|
|
|
|
// probably unnecessary
|
|
|
|
template <int count>
|
|
|
|
__forceinline void DataSkip()
|
|
|
|
{
|
|
|
|
g_video_buffer_read_ptr += count;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2015-09-17 18:24:06 +00:00
|
|
|
__forceinline T DataPeek(int _uOffset, 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>
|
|
|
|
__forceinline T DataRead(u8** bufp = &g_video_buffer_read_ptr)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline u32 DataReadU32Unswapped()
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline u8* DataGetPosition()
|
|
|
|
{
|
|
|
|
return g_video_buffer_read_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
__forceinline void DataWrite(T data)
|
|
|
|
{
|
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
|
|
|
}
|