From 78746f0d3acf8654bc9b7bbeb03f8bf48754b3fe Mon Sep 17 00:00:00 2001 From: refraction Date: Wed, 17 Jun 2009 20:58:03 +0000 Subject: [PATCH] Modified how the GS interrupts work, solves the issue of the picture flashing on and off in some games (Street Fighter EX3). Needs some testing possibly, but should be better. Developer note: The reason for this is the event can only generate an interrupt if it is enabled (via CSRw). the CSRw has to also reflect the IMR status else it could give false readings. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1380 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Counters.cpp | 16 ++++++++++++---- pcsx2/GS.cpp | 3 ++- pcsx2/MTGS.cpp | 17 ++++++++++------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index d8af6b3f80..62398ea880 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -336,8 +336,12 @@ static __forceinline void VSyncStart(u32 sCycle) EECNT_LOG( "///////// EE COUNTER VSYNC START \\\\\\\\\\\\\\\\\\\\ (frame: %d)", iFrame ); vSyncDebugStuff( iFrame ); // EE Profiling and Debug code - if ((CSRw & 0x8)) GSCSRr|= 0x8; - if (!(GSIMR&0x800)) gsIrq(); + if ((CSRw & 0x8)) + { + CSRw &= ~0x8; + GSCSRr|= 0x8; + if (!(GSIMR&0x800)) gsIrq(); + } hwIntcIrq(INTC_VBLANK_S); psxVBlankStart(); @@ -404,8 +408,12 @@ __forceinline void rcntUpdate_hScanline() hsyncCounter.Mode = MODE_HRENDER; } else { //HBLANK END / HRENDER Begin - if (CSRw & 0x4) GSCSRr |= 4; // signal - if (!(GSIMR&0x400)) gsIrq(); + if (CSRw & 0x4) + { + CSRw &= ~0x4; + GSCSRr |= 4; // signal + if (!(GSIMR&0x400)) gsIrq(); + } if (gates) rcntEndGate(false, hsyncCounter.sCycle); if (psxhblankgate) psxCheckEndGate16(0); diff --git a/pcsx2/GS.cpp b/pcsx2/GS.cpp index 8b8fe7e958..287a063dfc 100644 --- a/pcsx2/GS.cpp +++ b/pcsx2/GS.cpp @@ -243,6 +243,7 @@ void gsReset() memzero_obj(g_RealGSMem); + CSRw = 0; GSCSRr = 0x551B400F; // Set the FINISH bit to 1 for now GSIMR = 0x7f00; psHu32(GIF_STAT) = 0; @@ -323,7 +324,7 @@ void gsCSRwrite(u32 value) static void IMRwrite(u32 value) { GSIMR = (value & 0x1f00)|0x6000; - + CSRw |= (GSIMR >> 8) & 0x1f; // don't update mtgs mem } diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index 55195caf5e..17416eb8e3 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -142,10 +142,12 @@ static void RegHandlerSIGNAL(const u32* data) GSSIGLBLID->SIGID = (GSSIGLBLID->SIGID&~data[1])|(data[0]&data[1]); if ((CSRw & 0x1)) + { + CSRw &= ~0x1; GSCSRr |= 1; // signal - - if (!(GSIMR&0x100) ) - gsIrq(); + if (!(GSIMR&0x100) ) + gsIrq(); + } } static void RegHandlerFINISH(const u32* data) @@ -153,11 +155,12 @@ static void RegHandlerFINISH(const u32* data) MTGS_LOG("MTGS FINISH data %x_%x CSRw %x\n",data[0], data[1], CSRw); if ((CSRw & 0x2)) + { GSCSRr |= 2; // finish - - if (!(GSIMR&0x200) ) - gsIrq(); - + CSRw &= ~0x2; + if (!(GSIMR&0x200) ) + gsIrq(); + } } static void RegHandlerLABEL(const u32* data)