diff --git a/Source/Core/VideoCommon/Src/VertexLoader.cpp b/Source/Core/VideoCommon/Src/VertexLoader.cpp index 006df2fbea..180d7b3eb3 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader.cpp @@ -315,9 +315,9 @@ void VertexLoader::CompileVertexTranslator() case FORMAT_UBYTE: case FORMAT_BYTE: { - vtx_decl.normal_gl_type = (vtx_attr.NormalFormat == FORMAT_BYTE)? VAR_BYTE : VAR_UNSIGNED_BYTE; + vtx_decl.normal_gl_type = VAR_BYTE; int native_size = 4; - if (vtx_attr.NormalFormat == FORMAT_BYTE && !g_Config.backend_info.bAllowSignedBytes) + if (!g_Config.backend_info.bAllowSignedBytes) { vtx_decl.normal_gl_type = VAR_SHORT; native_size = 8; @@ -335,7 +335,7 @@ void VertexLoader::CompileVertexTranslator() } case FORMAT_USHORT: case FORMAT_SHORT: - vtx_decl.normal_gl_type = (vtx_attr.NormalFormat == FORMAT_SHORT)? VAR_SHORT : VAR_UNSIGNED_SHORT; + vtx_decl.normal_gl_type = VAR_SHORT; vtx_decl.normal_gl_size = 4; vtx_decl.normal_offset[0] = nat_offset; nat_offset += 8; diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp b/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp index 323eb2783e..f8cf0fcc97 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp @@ -159,9 +159,12 @@ void LOADERDECL VertexLoader_Normal::Normal_DirectByte() void LOADERDECL VertexLoader_Normal::Normal_DirectByte_Expand16() { - ((s16*)VertexManager::s_pCurBufferPointer)[0] = DataReadS8() << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[1] = DataReadS8() << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[2] = DataReadS8() << 8; + s8 temp = DataReadS8(); + ((s16*)VertexManager::s_pCurBufferPointer)[0] = (((s16)temp) << 8) | (temp & 0x7F); + temp = DataReadS8(); + ((s16*)VertexManager::s_pCurBufferPointer)[1] = (((s16)temp) << 8) | (temp & 0x7F); + temp = DataReadS8(); + ((s16*)VertexManager::s_pCurBufferPointer)[2] = (((s16)temp) << 8) | (temp & 0x7F); ((s16*)VertexManager::s_pCurBufferPointer)[3] = 0; VertexManager::s_pCurBufferPointer += 8; LOG_NORM16(); @@ -202,9 +205,12 @@ void LOADERDECL VertexLoader_Normal::Normal_DirectByte3_Expand16() { for (int i = 0; i < 3; i++) { - ((u16*)VertexManager::s_pCurBufferPointer)[0] = DataReadS8() << 8; - ((u16*)VertexManager::s_pCurBufferPointer)[1] = DataReadS8() << 8; - ((u16*)VertexManager::s_pCurBufferPointer)[2] = DataReadS8() << 8; + s8 temp = DataReadS8(); + ((u16*)VertexManager::s_pCurBufferPointer)[0] = (((s16)temp) << 8) | (temp & 0x7F); + temp = DataReadS8(); + ((u16*)VertexManager::s_pCurBufferPointer)[1] = (((s16)temp) << 8) | (temp & 0x7F); + temp = DataReadS8(); + ((u16*)VertexManager::s_pCurBufferPointer)[2] = (((s16)temp) << 8) | (temp & 0x7F); ((u16*)VertexManager::s_pCurBufferPointer)[3] = 0; VertexManager::s_pCurBufferPointer += 8; LOG_NORM16(); @@ -254,9 +260,9 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte_Expand16() { u8 Index = DataReadU8(); const s8* pData = (const s8 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL])); - ((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[0] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[1] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[2] << 8; + ((s16*)VertexManager::s_pCurBufferPointer)[0] = (((s16)pData[0]) << 8) | (pData[0] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[1] = (((s16)pData[1]) << 8) | (pData[1] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[2] = (((s16)pData[2]) << 8) | (pData[2] & 0x7F); ((s16*)VertexManager::s_pCurBufferPointer)[3] = 0; VertexManager::s_pCurBufferPointer += 8; LOG_NORM16(); @@ -305,9 +311,9 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte3_Indices1_Expand16() const s8* pData = (const s8*)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL])); for (int i = 0; i < 3; i++) { - ((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[3 * i] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[3 * i + 1] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[3 * i + 2] << 8; + ((s16*)VertexManager::s_pCurBufferPointer)[0] = (((s16)pData[3 * i]) << 8) | (pData[3 * i] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[1] = (((s16)pData[3 * i + 1]) << 8) | (pData[3 * i + 1] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[2] = (((s16)pData[3 * i + 2]) << 8) | (pData[3 * i + 2] & 0x7F); ((s16*)VertexManager::s_pCurBufferPointer)[3] = 0; VertexManager::s_pCurBufferPointer += 8; LOG_NORM16(); @@ -363,9 +369,9 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte3_Indices3_Expand16() { u8 Index = DataReadU8(); const s8* pData = (const s8 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i); - ((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[0] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[1] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[2] << 8; + ((s16*)VertexManager::s_pCurBufferPointer)[0] = (((s16)pData[0]) << 8) | (pData[0] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[1] = (((s16)pData[1]) << 8) | (pData[1] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[2] = (((s16)pData[2]) << 8) | (pData[2] & 0x7F); ((s16*)VertexManager::s_pCurBufferPointer)[3] = 0; VertexManager::s_pCurBufferPointer += 8; LOG_NORM16(); @@ -420,9 +426,9 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte_Expand16() { u16 Index = DataReadU16(); const s8* pData = (const s8 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL])); - ((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[0] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[1] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[2] << 8; + ((s16*)VertexManager::s_pCurBufferPointer)[0] = (((s16)pData[0]) << 8) | (pData[0] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[1] = (((s16)pData[1]) << 8) | (pData[1] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[2] = (((s16)pData[2]) << 8) | (pData[3] & 0x7F); ((s16*)VertexManager::s_pCurBufferPointer)[3] = 0; VertexManager::s_pCurBufferPointer += 8; LOG_NORM16(); @@ -487,9 +493,9 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte3_Indices1_Expand16() for (int i = 0; i < 3; i++) { - ((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[3 * i] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[3 * i + 1] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[3 * i + 2] << 8; + ((s16*)VertexManager::s_pCurBufferPointer)[0] = (((s16)pData[3 * i]) << 8) | (pData[3 * i] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[1] = (((s16)pData[3 * i + 1]) << 8) | (pData[3 * i + 1] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[2] = (((s16)pData[3 * i + 2]) << 8) | (pData[3 * i + 2] & 0x7F); ((s16*)VertexManager::s_pCurBufferPointer)[3] = 0; VertexManager::s_pCurBufferPointer += 8; LOG_NORM16(); @@ -547,9 +553,9 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte3_Indices3_Expand16() { u16 Index = DataReadU16(); const s8* pData = (const s8 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i); - ((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[0] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[1] << 8; - ((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[2] << 8; + ((s16*)VertexManager::s_pCurBufferPointer)[0] = (((s16)pData[0]) << 8) | (pData[0] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[1] = (((s16)pData[1]) << 8) | (pData[1] & 0x7F); + ((s16*)VertexManager::s_pCurBufferPointer)[2] = (((s16)pData[2]) << 8) | (pData[3] & 0x7F); ((s16*)VertexManager::s_pCurBufferPointer)[3] = 0; VertexManager::s_pCurBufferPointer += 8; LOG_NORM16();