From d0a7239f15966b90e34ac4ddad4ff8677e0892d7 Mon Sep 17 00:00:00 2001 From: Jakly <102590697+Jaklyy@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:44:04 -0400 Subject: [PATCH] fix some bugs with compressed texture look up (#2051) --- src/GPU3D_Soft.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp index e2526069..1221ed59 100644 --- a/src/GPU3D_Soft.cpp +++ b/src/GPU3D_Soft.cpp @@ -242,13 +242,20 @@ void SoftRenderer::TextureLookup(const GPU& gpu, u32 texparam, u32 texpal, s16 s { vramaddr += ((t & 0x3FC) * (width>>2)) + (s & 0x3FC); vramaddr += (t & 0x3); + vramaddr &= 0x7FFFF; // address used for all calcs wraps around after slot 3 u32 slot1addr = 0x20000 + ((vramaddr & 0x1FFFC) >> 1); if (vramaddr >= 0x40000) slot1addr += 0x10000; - u8 val = ReadVRAM_Texture(vramaddr, gpu); - val >>= (2 * (s & 0x3)); + u8 val; + if (vramaddr >= 0x20000 && vramaddr < 0x40000) // reading slot 1 for texels should always read 0 + val = 0; + else + { + val = ReadVRAM_Texture(vramaddr, gpu); + val >>= (2 * (s & 0x3)); + } u16 palinfo = ReadVRAM_Texture(slot1addr, gpu); u32 paloffset = (palinfo & 0x3FFF) << 2;