From 70ef2fc20b453e3a88d69a131f8f9aacbb0b2544 Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Tue, 25 May 2010 07:34:02 +0000 Subject: [PATCH] improved automatic frame-skipping (fixes Virtua Racing on Gamecube) --- source/gx/gx_video.c | 1 + source/gx/main.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/source/gx/gx_video.c b/source/gx/gx_video.c index f936a9d..3e5b284 100644 --- a/source/gx/gx_video.c +++ b/source/gx/gx_video.c @@ -1288,6 +1288,7 @@ void gx_video_Stop(void) VIDEO_Configure(vmode); /* starts menu rendering */ + gxClearScreen((GXColor)BLACK); gxDrawScreenshot(0xff); gxSetScreen(); } diff --git a/source/gx/main.c b/source/gx/main.c index d28f487..4760382 100644 --- a/source/gx/main.c +++ b/source/gx/main.c @@ -334,6 +334,7 @@ int main (int argc, char *argv[]) #endif /* main emulation loop */ + int skip = 0; while (1) { /* Main Menu request */ @@ -350,23 +351,20 @@ int main (int argc, char *argv[]) /* start video & audio */ gx_audio_Start(); gx_video_Start(); - frameticker = 1; + skip = 0; } - if (frameticker > 1) + frameticker = 0; + if (skip) { /* skip frame */ system_frame(1); - --frameticker; + skip = 0; } else { - while (frameticker < 1) - usleep(10); - /* render frame */ system_frame(0); - --frameticker; /* update video */ gx_video_Update(); @@ -374,6 +372,14 @@ int main (int argc, char *argv[]) /* update audio */ gx_audio_Update(); + + /* wait for next frame */ + while (frameticker < 1) + usleep(1); + + /* automatic frame skipping */ + if (frameticker > 1) + skip = 1; } return 0;