From 3b2b6a20aa5bdb5dea9aa737556fb4aaca04e697 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sat, 4 Jun 2016 12:57:14 +0100 Subject: [PATCH] eeCache: Flush cache entries on DXLTG -SYNC.L should be called before this command forcing the cache to writeback to memory, but that would be slow to do every time, so we will do it on this command. --- pcsx2/Cache.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pcsx2/Cache.cpp b/pcsx2/Cache.cpp index 1692226be..d61273ff3 100644 --- a/pcsx2/Cache.cpp +++ b/pcsx2/Cache.cpp @@ -432,7 +432,27 @@ void CACHE() { { int index = (addr >> 6) & 0x3F; int way = addr & 0x1; - + + //DXLTG demands that SYNC.L is called before this command, which forces the cache to write back, so presumably games are checking the cache has updated the memory + //For speed, we will do it here. + u32 pfnaddr = (pCache[index].tag[way] & ~0x80000fff) | (addr & 0xfc0); + u32 vmv = vtlbdata.vmap[pfnaddr >> VTLB_PAGE_BITS]; + s32 ppf = (pfnaddr + vmv) & ~0x3F; + if ((pCache[index].tag[way] & (DIRTY_FLAG | VALID_FLAG)) == (DIRTY_FLAG | VALID_FLAG)) // Dirty + { + CACHE_LOG("DXLTG Dirty WriteBack! PPF %x", ppf); + *reinterpret_cast(ppf) = pCache[index].data[way][0].b8._u64[0]; + *reinterpret_cast(ppf + 8) = pCache[index].data[way][0].b8._u64[1]; + *reinterpret_cast(ppf + 16) = pCache[index].data[way][1].b8._u64[0]; + *reinterpret_cast(ppf + 24) = pCache[index].data[way][1].b8._u64[1]; + *reinterpret_cast(ppf + 32) = pCache[index].data[way][2].b8._u64[0]; + *reinterpret_cast(ppf + 40) = pCache[index].data[way][2].b8._u64[1]; + *reinterpret_cast(ppf + 48) = pCache[index].data[way][3].b8._u64[0]; + *reinterpret_cast(ppf + 56) = pCache[index].data[way][3].b8._u64[1]; + + pCache[index].tag[way] &= ~DIRTY_FLAG; + } + //DevCon.Warning("DXLTG way %x index %x addr %x tagdata=%x", way, index, addr, pCache[index].tag[way]); cpuRegs.CP0.n.TagLo = pCache[index].tag[way]; CACHE_LOG("CACHE DXLTG addr %x, index %d, way %d, DATA %x OP %x ",addr,index,way,cpuRegs.CP0.r[28], cpuRegs.code);