diff options
| author | Lioncash <mathew1800@gmail.com> | 2015-08-31 17:24:53 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2015-08-31 17:31:11 -0400 |
| commit | ec42be79f3fd0ee53ab472651cc1e6689341bf36 (patch) | |
| tree | 20a5e456aa2f6c87051e0a6c94d18e9748813bdd /Source/Core/VideoCommon | |
| parent | cc5eb6d00b4b1e17addec73bd07b7d09c312da2e (diff) | |
VertexLoader_Color: Get rid of some pointer casts
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoader_Color.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/Source/Core/VideoCommon/VertexLoader_Color.cpp b/Source/Core/VideoCommon/VertexLoader_Color.cpp index ea65b3bb4c..2306a32c22 100644 --- a/Source/Core/VideoCommon/VertexLoader_Color.cpp +++ b/Source/Core/VideoCommon/VertexLoader_Color.cpp @@ -2,7 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Common/Common.h" +#include <cstring> +#include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" #include "VideoCommon/VertexLoader.h" @@ -57,17 +58,18 @@ __forceinline void _SetCol565(VertexLoader* loader, u16 val_) _SetCol(loader, col | AMASK); } -__forceinline u32 _Read24(const u8 *addr) +__forceinline u32 _Read32(const u8 *addr) { - return (*(const u32 *)addr) | AMASK; + u32 value; + std::memcpy(&value, addr, sizeof(u32)); + return value; } -__forceinline u32 _Read32(const u8 *addr) +__forceinline u32 _Read24(const u8 *addr) { - return *(const u32 *)addr; + return _Read32(addr) | AMASK; } - void Color_ReadDirect_24b_888(VertexLoader* loader) { _SetCol(loader, _Read24(DataGetPosition())); @@ -85,7 +87,10 @@ void Color_ReadDirect_16b_565(VertexLoader* loader) } void Color_ReadDirect_16b_4444(VertexLoader* loader) { - _SetCol4444(loader, *(u16*)DataGetPosition()); + u16 value; + std::memcpy(&value, DataGetPosition(), sizeof(u16)); + + _SetCol4444(loader, value); DataSkip(2); } void Color_ReadDirect_24b_6666(VertexLoader* loader) @@ -102,8 +107,12 @@ template <typename I> void Color_ReadIndex_16b_565(VertexLoader* loader) { auto const Index = DataRead<I>(); - u16 val = Common::swap16(*(const u16 *)(VertexLoaderManager::cached_arraybases[ARRAY_COLOR + loader->m_colIndex] + (Index * g_main_cp_state.array_strides[ARRAY_COLOR + loader->m_colIndex]))); - _SetCol565(loader, val); + const u8* const address = VertexLoaderManager::cached_arraybases[ARRAY_COLOR + loader->m_colIndex] + (Index * g_main_cp_state.array_strides[ARRAY_COLOR + loader->m_colIndex]); + + u16 value; + std::memcpy(&value, address, sizeof(u16)); + + _SetCol565(loader, Common::swap16(value)); } template <typename I> @@ -126,8 +135,12 @@ template <typename I> void Color_ReadIndex_16b_4444(VertexLoader* loader) { auto const Index = DataRead<I>(); - u16 val = *(const u16 *)(VertexLoaderManager::cached_arraybases[ARRAY_COLOR + loader->m_colIndex] + (Index * g_main_cp_state.array_strides[ARRAY_COLOR + loader->m_colIndex])); - _SetCol4444(loader, val); + const u8* const address = VertexLoaderManager::cached_arraybases[ARRAY_COLOR + loader->m_colIndex] + (Index * g_main_cp_state.array_strides[ARRAY_COLOR + loader->m_colIndex]); + + u16 value; + std::memcpy(&value, address, sizeof(u16)); + + _SetCol4444(loader, value); } template <typename I> |
