Move S9xSyncSpeed call.

DMA can last multiple frames, and so can S9xMainLoop.
If we throttle outside of S9xMainLoop or only as we're exiting the
loop as is currently done, we zoom through multiple frames and
overrun the audio. Moving S9xSyncSpeed just after EndScreenRefresh
causes it to be called every frame.

This seemingly wasn't a problem because throttling with vsync *did*
happen every frame regardless. Oops.
This commit is contained in:
BearOso 2023-03-20 16:02:36 -05:00
parent c325cbc2f6
commit 50f9f9eba1
2 changed files with 7 additions and 9 deletions

View File

@ -132,13 +132,6 @@ void S9xMainLoop (void)
if (CPU.Flags & SCAN_KEYS_FLAG) if (CPU.Flags & SCAN_KEYS_FLAG)
{ {
#ifdef DEBUGGER
if (!(CPU.Flags & FRAME_ADVANCE_FLAG))
#endif
{
S9xSyncSpeed();
}
break; break;
} }
@ -326,6 +319,12 @@ void S9xDoHEventProcessing (void)
if (CPU.V_Counter == PPU.ScreenHeight + FIRST_VISIBLE_LINE) // VBlank starts from V=225(240). if (CPU.V_Counter == PPU.ScreenHeight + FIRST_VISIBLE_LINE) // VBlank starts from V=225(240).
{ {
S9xEndScreenRefresh(); S9xEndScreenRefresh();
#ifdef DEBUGGER
if (!(CPU.Flags & FRAME_ADVANCE_FLAG))
#endif
{
S9xSyncSpeed();
}
CPU.Flags |= SCAN_KEYS_FLAG; CPU.Flags |= SCAN_KEYS_FLAG;

View File

@ -304,8 +304,6 @@ static bool S9xIdleFunc()
S9xProcessEvents(true); S9xProcessEvents(true);
S9xThrottle(Settings.SkipFrames);
if (!S9xDisplayDriverIsReady()) if (!S9xDisplayDriverIsReady())
{ {
usleep(100); usleep(100);
@ -494,6 +492,7 @@ static void S9xThrottle(int method)
void S9xSyncSpeed() void S9xSyncSpeed()
{ {
S9xThrottle(Settings.SkipFrames);
} }
static void S9xCheckPointerTimer() static void S9xCheckPointerTimer()