Counters: Fix vsync hsync cycles calculation for rounding error

In games like ICO where the render and blanks both need to be rounded,
one was prioritized over the other one leading to a truncated value in
the total vsync cycles. This patch fixes it, it's more or less for a
trivial cycle accuracy rather than a signfifcant change which might
influence games. (Not sure, maybe it would?)

Potentially it might be nice to revamp the whole vertical blank
calculation system to make it more readable (discussed about this with
ref), but it's not of much priority right now.
This commit is contained in:
Akash 2018-06-27 19:55:33 +05:30
parent 387db6d4ba
commit bb1c225e66
1 changed files with 4 additions and 4 deletions

View File

@ -220,6 +220,8 @@ static void vSyncInfoCalc(vSyncTimingInfo* info, Fixed100 framesPerSecond, u32 s
hRender /= 2;
}
//TODO: Carry fixed-point math all the way through the entire vsync and hsync counting processes, and continually apply rounding
//as needed for each scheduled v/hsync related event. Much better to handle than this messed state.
info->Framerate = framesPerSecond;
info->Render = (u32)(Render / 10000);
info->Blank = (u32)(Blank / 10000);
@ -228,13 +230,11 @@ static void vSyncInfoCalc(vSyncTimingInfo* info, Fixed100 framesPerSecond, u32 s
info->hBlank = (u32)(hBlank / 10000);
info->hScanlinesPerFrame = scansPerFrame;
// Apply rounding:
// To investigate: Why is render rounding prioritized over blank? why skip the latter?
if ((Render % 10000) >= 5000) info->Render++;
else if ((Blank % 10000) >= 5000) info->Blank++;
if ((Blank % 10000) >= 5000) info->Blank++;
if ((hRender % 10000) >= 5000) info->hRender++;
else if ((hBlank % 10000) >= 5000) info->hBlank++;
if ((hBlank % 10000) >= 5000) info->hBlank++;
// Calculate accumulative hSync rounding error per half-frame:
if (IsAnalogVideoMode()) // gets off the chart in that mode