From a8171405b150a951c043455638133ce023bcaf3d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 29 Oct 2020 01:29:56 +1000 Subject: [PATCH] CPU/CodeCache: Fix incorrect invalidation on non-page-crossing DMA writes Fixes recompiler mode for Breath of Fire III, probably others. --- src/core/cpu_code_cache.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/cpu_code_cache.h b/src/core/cpu_code_cache.h index d251779ef..963559c50 100644 --- a/src/core/cpu_code_cache.h +++ b/src/core/cpu_code_cache.h @@ -130,8 +130,8 @@ void InterpretUncachedBlock(); ALWAYS_INLINE void InvalidateCodePages(PhysicalMemoryAddress address, u32 word_count) { const u32 start_page = address / CPU_CODE_CACHE_PAGE_SIZE; - const u32 end_page = (address + word_count * sizeof(u32)) / CPU_CODE_CACHE_PAGE_SIZE; - for (u32 page = start_page; page < end_page; page++) + const u32 end_page = (address + word_count * sizeof(u32) - sizeof(u32)) / CPU_CODE_CACHE_PAGE_SIZE; + for (u32 page = start_page; page <= end_page; page++) { if (Bus::m_ram_code_bits[page]) CPU::CodeCache::InvalidateBlocksWithPageIndex(page);