x86/microVU: Fix incorrect VI being backed up when uncached

Fixes hang going ingame in Gitaroo Man.
This commit is contained in:
Stenzek 2023-01-01 14:25:02 +10:00 committed by refractionpcsx2
parent 26d5ee0c93
commit 265afcec7e
2 changed files with 12 additions and 1 deletions

View File

@ -484,6 +484,7 @@ void SaveStateBase::vuJITFreeze()
void DumpVUState(u32 n, u32 pc)
{
const VURegs& r = vuRegs[n];
const microVU& mVU = (n == 0) ? microVU0 : microVU1;
static FILE* fp = nullptr;
static bool fp_opened = false;
static u32 counter = 0;
@ -509,7 +510,7 @@ void DumpVUState(u32 n, u32 pc)
if (fp)
{
const microVU& m = (n == 0) ? microVU0 : microVU1;
fprintf(fp, "%08d VU%u SPC:%04X xPC:%04X", counter, n, r.start_pc, pc);
fprintf(fp, "%08d VU%u SPC:%04X xPC:%04X BRANCH:%04X VIBACKUP:%04X", counter, n, r.start_pc, pc, mVU.branch, mVU.VIbackup);
#if 1
//fprintf(fp, " MEM:%08X", crc32(0, (Bytef*)r.Mem, (n == 0) ? VU0_MEMSIZE : VU1_MEMSIZE));
fprintf(fp, " MAC %08X %08X %08X %08X [%08X %08X %08X %08X]", r.micro_macflags[3], r.micro_macflags[2], r.micro_macflags[1], r.micro_macflags[0], m.macFlag[3], m.macFlag[2], m.macFlag[1], m.macFlag[0]);

View File

@ -1081,6 +1081,16 @@ public:
const xRegister32& gprX = xRegister32::GetInstance(x);
writeBackReg(gprX, true);
// Special case: we need to back up the destination register, but it might not have already
// been cached. If so, we need to load the old value from state and back it up. Otherwise,
// it's going to get lost when we eventually write this register back.
if (backup && viLoadReg >= 0 && viWriteReg > 0 && viLoadReg != viWriteReg)
{
xMOVZX(gprX, ptr16[&getVI(viWriteReg)]);
writeVIBackup(gprX);
backup = false;
}
if (viLoadReg > 0)
xMOVZX(gprX, ptr16[&getVI(viLoadReg)]);
else if (viLoadReg == 0)