Skip to content

Commit

Permalink
Counters: Pass correct start cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
refractionpcsx2 committed Nov 8, 2023
1 parent e3d4b0e commit 8e9fd91
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions pcsx2/Counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,13 @@ __fi void rcntUpdate_hScanline()
//iopEventAction = 1;
if (hsyncCounter.Mode == MODE_HBLANK)
{ //HBLANK Start
rcntStartGate(false, hsyncCounter.sCycle);
psxCheckStartGate16(0);

// Setup the hRender's start and end cycle information:
hsyncCounter.sCycle += vSyncInfo.hBlank; // start (absolute cycle value)
hsyncCounter.CycleT = vSyncInfo.hRender; // endpoint (delta from start value)
hsyncCounter.Mode = MODE_HRENDER;

rcntStartGate(false, hsyncCounter.sCycle);
psxCheckStartGate16(0);
}
else
{ //HBLANK END / HRENDER Begin
Expand All @@ -616,16 +616,17 @@ __fi void rcntUpdate_hScanline()
if (!GSIMR.HSMSK)
gsIrq();
}
if (gates)
rcntEndGate(false, hsyncCounter.sCycle);
if (psxhblankgate)
psxCheckEndGate16(0);

// set up the hblank's start and end cycle information:
hsyncCounter.sCycle += vSyncInfo.hRender; // start (absolute cycle value)
hsyncCounter.CycleT = vSyncInfo.hBlank; // endpoint (delta from start value)
hsyncCounter.Mode = MODE_HBLANK;

if (gates)
rcntEndGate(false, hsyncCounter.sCycle);
if (psxhblankgate)
psxCheckEndGate16(0);

#ifdef VSYNC_DEBUG
hsc++;
#endif
Expand All @@ -639,11 +640,11 @@ __fi void rcntUpdate_vSync()

if (vsyncCounter.Mode == MODE_VSYNC)
{
VSyncEnd(vsyncCounter.sCycle);

vsyncCounter.sCycle += vSyncInfo.Blank;
vsyncCounter.CycleT = vSyncInfo.Render;
vsyncCounter.Mode = MODE_VRENDER;

VSyncEnd(vsyncCounter.sCycle);
}
else if (vsyncCounter.Mode == MODE_GSBLANK) // GS CSR Swap and interrupt
{
Expand All @@ -655,15 +656,15 @@ __fi void rcntUpdate_vSync()
}
else // VSYNC end / VRENDER begin
{
VSyncStart(vsyncCounter.sCycle);

vsyncCounter.sCycle += vSyncInfo.Render;
vsyncCounter.CycleT = vSyncInfo.GSBlank;
vsyncCounter.Mode = MODE_GSBLANK;

// Accumulate hsync rounding errors:
hsyncCounter.sCycle += vSyncInfo.hSyncError;

VSyncStart(vsyncCounter.sCycle);

#ifdef VSYNC_DEBUG
vblankinc++;
if (vblankinc > 1)
Expand Down

0 comments on commit 8e9fd91

Please sign in to comment.