From 19ab48c28049b9dd15286c76e43d4006ed2ddb2e Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Thu, 10 Sep 2020 11:52:47 +0100 Subject: [PATCH] VU: Copy CLIP flag instance back to VU0 int and microVU when COP2 modifies it Fixes Soul Calibur 3 hair --- pcsx2/VU0micro.cpp | 2 ++ pcsx2/x86/microVU_Alloc.inl | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/pcsx2/VU0micro.cpp b/pcsx2/VU0micro.cpp index 651ed8102d..3be6664d0b 100644 --- a/pcsx2/VU0micro.cpp +++ b/pcsx2/VU0micro.cpp @@ -42,6 +42,8 @@ void __fastcall vu0ExecMicro(u32 addr) { vu0Finish(); } + // Need to copy the clip flag back to the interpreter in case COP2 has edited it + VU0.clipflag = VU0.VI[REG_CLIP_FLAG].UL; VU0.VI[REG_VPU_STAT].UL &= ~0xFF; VU0.VI[REG_VPU_STAT].UL |= 0x01; VU0.cycle = cpuRegs.cycle; diff --git a/pcsx2/x86/microVU_Alloc.inl b/pcsx2/x86/microVU_Alloc.inl index 2c8a9d799d..fa65645b61 100644 --- a/pcsx2/x86/microVU_Alloc.inl +++ b/pcsx2/x86/microVU_Alloc.inl @@ -109,6 +109,14 @@ __fi void mVUallocCFLAGb(mV, const x32& reg, int fInstance) { if (fInstance < 4) xMOV(ptr32[&mVU.clipFlag[fInstance]], reg); // microVU else xMOV(ptr32[&mVU.regs().VI[REG_CLIP_FLAG].UL], reg); // macroVU + + // On COP2 modifying the CLIP flag we need to update the microVU version for when it's restored on new program + if (fInstance == 0xff) + { + xMOVDZX(xmmT1, reg); + xSHUF.PS(xmmT1, xmmT1, 0); + xMOVAPS(ptr128[&mVU.regs().micro_clipflags], xmmT1); + } } //------------------------------------------------------------------