From e80921f29dded10835df842ad0d9a4d437b51965 Mon Sep 17 00:00:00 2001 From: SarahW Date: Wed, 22 Nov 2017 21:00:42 +0000 Subject: [PATCH] Fix Voodoo caching of textures ending at the exact end of texture memory. Fixes FMV in Return to Castle Wolfenstein. --- src/vid_voodoo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vid_voodoo.c b/src/vid_voodoo.c index 73c6824..319170c 100644 --- a/src/vid_voodoo.c +++ b/src/vid_voodoo.c @@ -1628,7 +1628,12 @@ static void flush_texture_cache(voodoo_t *voodoo, uint32_t dirty_addr, int tmu) if (addr_end != 0) { - if (dirty_addr >= (addr_start & voodoo->texture_mask & ~0x3ff) && dirty_addr < (((addr_end & voodoo->texture_mask) + 0x3ff) & ~0x3ff)) + int addr_start_masked = addr_start & voodoo->texture_mask & ~0x3ff; + int addr_end_masked = ((addr_end & voodoo->texture_mask) + 0x3ff) & ~0x3ff; + + if (addr_end_masked < addr_start_masked) + addr_end_masked = voodoo->texture_mask+1; + if (dirty_addr >= addr_start_masked && dirty_addr < addr_end_masked) { // pclog(" Evict texture %i %08x\n", c, voodoo->texture_cache[tmu][c].base);