Skip to content

Commit

Permalink
GIF: Correctly delay FINISH interrupts/flags
Browse files Browse the repository at this point in the history
[SAVEVERSION+]
  • Loading branch information
refractionpcsx2 committed Sep 13, 2023
1 parent d57902f commit de1a74d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pcsx2/GS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static __fi void gsCSRwrite( const tGS_CSR& csr )
//gifUnit.Reset(true); // Don't think gif should be reset...
gifUnit.gsSIGNAL.queued = false;
gifUnit.gsFINISH.gsFINISHFired = true;
gifUnit.gsFINISH.gsFINISHPending = false;
// Privilage registers also reset.
std::memset(g_RealGSMem, 0, sizeof(g_RealGSMem));
GSIMR.reset();
Expand Down Expand Up @@ -84,6 +85,7 @@ static __fi void gsCSRwrite( const tGS_CSR& csr )
if (csr.FINISH) {
CSRreg.FINISH = false;
gifUnit.gsFINISH.gsFINISHFired = false; //Clear the previously fired FINISH (YS, Indiecar 2005, MGS3)
gifUnit.gsFINISH.gsFINISHPending = false;
}
if(csr.HSINT) CSRreg.HSINT = false;
if(csr.VSINT) CSRreg.VSINT = false;
Expand Down
7 changes: 6 additions & 1 deletion pcsx2/Gif_Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ bool Gif_HandlerAD(u8* pMem)
else if (reg == GIF_A_D_REG_FINISH)
{ // FINISH
GUNIT_WARN("GIF Handler - FINISH");
CSRreg.FINISH = true;
gifUnit.gsFINISH.gsFINISHFired = false;
gifUnit.gsFINISH.gsFINISHPending = true;
}
else if (reg == GIF_A_D_REG_LABEL)
{ // LABEL
Expand Down Expand Up @@ -188,6 +188,11 @@ bool Gif_HandlerAD_Debug(u8* pMem)

void Gif_FinishIRQ()
{
if (gifUnit.gsFINISH.gsFINISHPending)
{
CSRreg.FINISH = true;
gifUnit.gsFINISH.gsFINISHPending = false;
}
if (CSRreg.FINISH && !GSIMR.FINISHMSK && !gifUnit.gsFINISH.gsFINISHFired)
{
gsIrq();
Expand Down
4 changes: 3 additions & 1 deletion pcsx2/Gif_Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ struct GS_SIGNAL
struct GS_FINISH
{
bool gsFINISHFired;
bool gsFINISHPending;

void Reset() { std::memset(this, 0, sizeof(*this)); }
};
Expand Down Expand Up @@ -838,7 +839,8 @@ struct Gif_Unit
FlushToMTGS();
}

Gif_FinishIRQ();
if(!checkPaths(true, true, true, true))
Gif_FinishIRQ();

//Path3 can rewind the DMA, so we send back the amount we go back!
if (isPath3)
Expand Down
4 changes: 2 additions & 2 deletions pcsx2/MTVU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ void VU_Thread::Get_MTVUChanges()
{
mtvuInterrupts.fetch_and(~InterruptFlagFinish, std::memory_order_relaxed);
GUNIT_WARN("Finish firing");
CSRreg.FINISH = true;
gifUnit.gsFINISH.gsFINISHFired = false;
gifUnit.gsFINISH.gsFINISHPending = true;

if (!gifRegs.stat.APATH)
if (!gifUnit.checkPaths(true, true, true, true))
Gif_FinishIRQ();
}
if (interrupts & InterruptFlagLabel)
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/SaveState.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum class FreezeAction
// [SAVEVERSION+]
// This informs the auto updater that the users savestates will be invalidated.

static const u32 g_SaveVersion = (0x9A3F << 16) | 0x0000;
static const u32 g_SaveVersion = (0x9A40 << 16) | 0x0000;


// the freezing data between submodules and core
Expand Down

0 comments on commit de1a74d

Please sign in to comment.