From 35e0bfeaccccb59dfdfba80369928d03cbcdb12a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 12 Apr 2022 09:23:36 +0200 Subject: [PATCH] Fix DeIndexTexture --- GPU/Common/TextureCacheCommon.cpp | 2 +- GPU/Common/TextureDecoder.h | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index dd15638db8..a8ea77346c 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -1313,7 +1313,7 @@ static void ReverseColors(void *dstBuf, const void *srcBuf, GETextureFormat fmt, case GE_TFMT_4444: ConvertRGBA4444ToABGR4444((u16 *)dstBuf, (const u16 *)srcBuf, numPixels); break; - // Final Fantasy 2 uses this heavily in animated textures. + // Final Fantasy 2 uses this heavily in animated textures. case GE_TFMT_5551: ConvertRGBA5551ToABGR1555((u16 *)dstBuf, (const u16 *)srcBuf, numPixels); break; diff --git a/GPU/Common/TextureDecoder.h b/GPU/Common/TextureDecoder.h index f85adbec55..51f879d721 100644 --- a/GPU/Common/TextureDecoder.h +++ b/GPU/Common/TextureDecoder.h @@ -109,17 +109,21 @@ inline void DeIndexTexture(/*WRITEONLY*/ ClutT *dest, const IndexT *indexed, int if (sizeof(IndexT) == 1) { for (int i = 0; i < length; ++i) { ClutT color = clut[*indexed++]; + alphaSum &= color; *dest++ = color; - } } else { for (int i = 0; i < length; ++i) { - *dest++ = clut[(*indexed++) & 0xFF]; + ClutT color = (*indexed++) & 0xFF; + alphaSum &= color; + *dest++ = color; } } } else { for (int i = 0; i < length; ++i) { - *dest++ = clut[gstate.transformClutIndex(*indexed++)]; + ClutT color = clut[gstate.transformClutIndex(*indexed++)]; + alphaSum &= color; + *dest++ = color; } } }