summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2009-02-15 13:08:21 +0000
committerhrydgard <hrydgard@gmail.com>2009-02-15 13:08:21 +0000
commit4f471ffeb6230d28223455c527ec810fb4986a93 (patch)
treeebaa9e20cc7fb2f4e32d84f174845d114b77d480 /Source/Core/VideoCommon
parent232e961b6f703b2c8b83b04841acecec105f0819 (diff)
color vertexloader: make read24 safer, speedup direct 8888 a tiny bit
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2253 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/DataReader.h34
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoader_Color.cpp19
2 files changed, 42 insertions, 11 deletions
diff --git a/Source/Core/VideoCommon/Src/DataReader.h b/Source/Core/VideoCommon/Src/DataReader.h
index af604fafb3..97340c2928 100644
--- a/Source/Core/VideoCommon/Src/DataReader.h
+++ b/Source/Core/VideoCommon/Src/DataReader.h
@@ -54,6 +54,40 @@ inline u32 DataReadU32()
return tmp;
}
+inline u32 DataReadU32Unswapped()
+{
+ u32 tmp = *(u32*)g_pVideoData;
+ g_pVideoData += 4;
+ return tmp;
+}
+
+
+// These are not used yet. If they don't build under Linux, delete them and let me know. -ector
+template<class T>
+inline T DataRead()
+{
+ T tmp = *(T*)g_pVideoData;
+ g_pVideoData += sizeof(T);
+ return tmp;
+}
+
+template <>
+inline u16 DataRead()
+{
+ u16 tmp = Common::swap16(*(u16*)g_pVideoData);
+ g_pVideoData += 2;
+ return tmp;
+}
+
+template <>
+inline u32 DataRead()
+{
+ u32 tmp = Common::swap32(*(u32*)g_pVideoData);
+ g_pVideoData += 4;
+ return tmp;
+}
+
+
inline float DataReadF32()
{
union {u32 i; float f;} temp;
diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp b/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp
index 8ef382c353..ec76f05e6e 100644
--- a/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp
+++ b/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp
@@ -67,14 +67,14 @@ void _SetCol565(u16 val)
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-inline u32 _Read24(const u8 *iAddress)
+inline u32 _Read24(const u8 *addr)
{
- return *(const u32 *)iAddress | 0xFF000000;
+ return addr[0] | (addr[1] << 8) | (addr[2] << 16) | 0xFF000000;
}
-inline u32 _Read32(const u8 *iAddress)
+inline u32 _Read32(const u8 *addr)
{
- return *(const u32 *)iAddress;
+ return *(const u32 *)addr;
}
//////////////////////////////////////////////////////////////////////////
@@ -105,9 +105,9 @@ void LOADERDECL Color_ReadDirect_16b_4444()
}
void LOADERDECL Color_ReadDirect_24b_6666()
{
- u32 val = DataReadU8()<<16;
- val|=DataReadU8()<<8;
- val|=DataReadU8();
+ u32 val = DataReadU8() << 16;
+ val |= DataReadU8() << 8;
+ val |= DataReadU8();
_SetCol6666(val);
}
@@ -121,10 +121,7 @@ void LOADERDECL Color_ReadDirect_24b_6666()
void LOADERDECL Color_ReadDirect_32b_8888()
{
// TODO (mb2): check this
- u32 col = DataReadU8()<<RSHIFT;
- col |= DataReadU8()<<GSHIFT;
- col |= DataReadU8()<<BSHIFT;
- col |= DataReadU8()<<ASHIFT;
+ u32 col = DataReadU32Unswapped();
// "kill" the alpha
if (!colElements[colIndex])