CPU/CodeCache: Fix DMA writes not invalidating code blocks

Fixes Crash Team Racing and Spyro in Cached Interpreter/Recompiler
modes.
This commit is contained in:
Connor McLaughlin
2019-11-26 19:45:36 +10:00
parent 47cbe75b48
commit 519dbc818d
3 changed files with 11 additions and 6 deletions

View File

@ -165,6 +165,14 @@ TickCount Bus::WriteWords(PhysicalMemoryAddress address, const u32* words, u32 w
return total_ticks;
}
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++)
{
if (m_ram_code_bits[page])
DoInvalidateCodeCache(page);
}
std::memcpy(&m_ram[address], words, sizeof(u32) * word_count);
return static_cast<TickCount>(word_count + ((word_count + 15) / 16));
}