diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index 161c3d6acb..e64e5adbf6 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -436,14 +436,17 @@ PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, in } return PC_TEX_FMT_BGRA32; case GX_TF_RGB565: - { - for (int y = 0; y < height; y += 4) - for (int x = 0; x < width; x += 4) - for (int iy = 0; iy < 4; iy++, src += 8) - //decodebytesRGB565((u32*)dst+(y+iy)*width+x, (u16*)src, 4); - decodebytesRGB565((u32*)dst+(y+iy)*width+x, (u16*)src); - } - return PC_TEX_FMT_BGRA32; + { + for (int y = 0; y < height; y += 4) + for (int x = 0; x < width; x += 4) + for (int iy = 0; iy < 4; iy++, src += 8) { + u16 *ptr = (u16 *)dst+(y+iy)*width+x; + u16 *s = (u16 *)src; + for(int j = 0; j < 4; j++) + *ptr++ = Common::swap16(*s++); + } + } + return PC_TEX_FMT_RGB565; case GX_TF_RGB5A3: { for (int y = 0; y < height; y += 4) diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.h b/Source/Core/VideoCommon/Src/TextureDecoder.h index f41da1b77e..be37a08a24 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.h +++ b/Source/Core/VideoCommon/Src/TextureDecoder.h @@ -74,6 +74,7 @@ enum PC_TexFormat PC_TEX_FMT_NONE = 0, PC_TEX_FMT_BGRA32, PC_TEX_FMT_I8, + PC_TEX_FMT_RGB565, }; PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp index a24604a211..c28315b94a 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp @@ -58,6 +58,17 @@ LPDIRECT3DTEXTURE9 CreateTexture2D(const u8* buffer, const int width, const int } } break; + case D3DFMT_R5G6B5: + { + const u16 *pIn = (u16*)buffer; + for (int y = 0; y < height; y++) + { + u16* pBits = (u16*)((u8*)Lock.pBits + (y * Lock.Pitch)); + memcpy(pBits, pIn, width * 2); + pIn += pitch; + } + } + break; case D3DFMT_A8L8: { const u8 *pIn = buffer; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp index 0457f0bd21..fe8b446780 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp @@ -176,9 +176,9 @@ void TextureCache::Load(int stage, u32 address, int width, int height, int forma case PC_TEX_FMT_BGRA32: d3d_fmt = D3DFMT_A8R8G8B8; break; - /*case PC_TEX_FMT_BGRA16: is this of any use? - d3d_fmt = D3DFMT_A4R4G4B4; - break;*/ + case PC_TEX_FMT_RGB565: + d3d_fmt = D3DFMT_R5G6B5; + break; case PC_TEX_FMT_I8: d3d_fmt = D3DFMT_A8L8; break; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp index ec228f2001..c1075d2258 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp @@ -358,6 +358,11 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width gl_iformat = GL_INTENSITY; gl_type = GL_UNSIGNED_BYTE; break; + case PC_TEX_FMT_RGB565: + gl_format = GL_RGB; + gl_iformat = GL_RGB; + gl_type = GL_UNSIGNED_SHORT_5_6_5; + break; } if (!entry.isNonPow2 && ((tm0.min_filter & 3) == 1 || (tm0.min_filter & 3) == 2)) { glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);