mirror of
https://github.com/libretro/pcsx2.git
synced 2024-12-13 04:26:10 +00:00
When debugging vSyncInfoCalc(), some serious problems with the math resulted in a nearly saturated u64 and hRender being 0 in all video modes. Team decided to revert to the earlier version, even though it probably breaks "Legendz Gekitou! Saga Battle".
No one knows how any games even started in the broken state and we prefer code being sane('ish) over one game miraculously working. The change is pretty big so it needs some good testing!
This commit is contained in:
parent
ab962bf5c6
commit
ff2845b2d2
@ -187,59 +187,55 @@ struct vSyncTimingInfo
|
||||
static vSyncTimingInfo vSyncInfo;
|
||||
|
||||
|
||||
static void vSyncInfoCalc( vSyncTimingInfo* info, Fixed100 framesPerSecond, u32 scansPerFrame )
|
||||
static void vSyncInfoCalc(vSyncTimingInfo* info, Fixed100 framesPerSecond, u32 scansPerFrame)
|
||||
{
|
||||
// I use fixed point math here to have strict control over rounding errors. --air
|
||||
|
||||
// NOTE: mgs3 likes a /4 vsync, but many games prefer /2. This seems to indicate a
|
||||
// problem in the counters vsync gates somewhere.
|
||||
|
||||
u64 Frame = ((u64)PS2CLK * 1000000ULL) / (framesPerSecond*100).ToIntRounded();
|
||||
u64 HalfFrame = Frame / 2;
|
||||
|
||||
// One test we have shows that VBlank lasts for ~22 HBlanks, another we have show that is the time it's off.
|
||||
// There exists a game (Legendz Gekitou! Saga Battle) Which runs REALLY slowly if VBlank is ~22 HBlanks, so the other test wins.
|
||||
|
||||
u64 Frame = ((u64)PS2CLK * 1000000ULL) / (framesPerSecond * 100).ToIntRounded();
|
||||
u64 HalfFrame = Frame / 2;
|
||||
u64 Blank = (Frame / scansPerFrame) * 22; // PAL VBlank Period is roughly 22 HSyncs
|
||||
|
||||
if (scansPerFrame == SCANLINES_TOTAL_NTSC)
|
||||
Blank = (Frame / scansPerFrame) * 26; // NTSC VBlank Period is roughly 26 HSyncs, so we update
|
||||
|
||||
//I would have suspected this to be Frame - Blank, but that seems to completely freak it out
|
||||
//and the test results are completely wrong. It seems 100% the same as the PS2 test on this,
|
||||
//So let's roll with it :P
|
||||
|
||||
u64 Render = HalfFrame - Blank; // so use the half-frame value for these...
|
||||
|
||||
// Important! The hRender/hBlank timers should be 50/50 for best results.
|
||||
// (this appears to be what the real EE's timing crystal does anyway)
|
||||
|
||||
u64 Scanline = (Frame / scansPerFrame);
|
||||
u64 hBlank = Scanline;
|
||||
u64 hRender = Scanline - hBlank;
|
||||
u64 Scanline = Frame / scansPerFrame;
|
||||
u64 hBlank = Scanline / 2;
|
||||
u64 hRender = Scanline - hBlank;
|
||||
|
||||
u64 Blank = Scanline * 22; // PAL VBlank Period is off for roughly 22 HSyncs
|
||||
u64 Render = (HalfFrame - Blank); // so use the half-frame value for these...
|
||||
|
||||
if ( gsRegionMode == Region_NTSC_PROGRESSIVE )
|
||||
if (gsRegionMode == Region_NTSC_PROGRESSIVE)
|
||||
{
|
||||
hBlank /= 2;
|
||||
hRender /= 2;
|
||||
}
|
||||
|
||||
info->Framerate = framesPerSecond;
|
||||
info->Render = (u32)(Render/10000);
|
||||
info->Blank = (u32)(Blank/10000);
|
||||
info->Framerate = framesPerSecond;
|
||||
info->Render = (u32)(Render / 10000);
|
||||
info->Blank = (u32)(Blank / 10000);
|
||||
|
||||
info->hRender = (u32)(hRender/10000);
|
||||
info->hBlank = (u32)(hBlank/10000);
|
||||
info->hRender = (u32)(hRender / 10000);
|
||||
info->hBlank = (u32)(hBlank / 10000);
|
||||
info->hScanlinesPerFrame = scansPerFrame;
|
||||
|
||||
// Apply rounding:
|
||||
if( ( Render - info->Render ) >= 5000 ) info->Render++;
|
||||
else if( ( Blank - info->Blank ) >= 5000 ) info->Blank++;
|
||||
if ((Render - info->Render) >= 5000) info->Render++;
|
||||
else if ((Blank - info->Blank) >= 5000) info->Blank++;
|
||||
|
||||
if( ( hRender - info->hRender ) >= 5000 ) info->hRender++;
|
||||
else if( ( hBlank - info->hBlank ) >= 5000 ) info->hBlank++;
|
||||
if ((hRender - info->hRender) >= 5000) info->hRender++;
|
||||
else if ((hBlank - info->hBlank) >= 5000) info->hBlank++;
|
||||
|
||||
// Calculate accumulative hSync rounding error per half-frame:
|
||||
if ( gsRegionMode != Region_NTSC_PROGRESSIVE ) // gets off the chart in that mode
|
||||
if (gsRegionMode != Region_NTSC_PROGRESSIVE) // gets off the chart in that mode
|
||||
{
|
||||
u32 hSyncCycles = ((info->hRender + info->hBlank) * scansPerFrame) / 2;
|
||||
u32 vSyncCycles = (info->Render + info->Blank);
|
||||
|
Loading…
Reference in New Issue
Block a user