From 2421a712dcbd0f239bef43749534f77c355b5d9d Mon Sep 17 00:00:00 2001 From: dborth Date: Mon, 12 Apr 2010 21:15:11 +0000 Subject: [PATCH] PAL <> NTSC timing corrections --- source/fceugx.cpp | 2 +- source/fceuload.cpp | 2 +- source/gcvideo.cpp | 10 ++++------ source/menu.cpp | 13 +++++++++++-- source/preferences.cpp | 6 +++--- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/source/fceugx.cpp b/source/fceugx.cpp index 0701017..cfba211 100644 --- a/source/fceugx.cpp +++ b/source/fceugx.cpp @@ -368,7 +368,7 @@ int main(int argc, char *argv[]) else MainMenu(MENU_GAME); - if(currentTiming != GCSettings.timing) + if(currentTiming != GCSettings.timing && GCSettings.timing != 2) FCEUI_SetVidSystem(GCSettings.timing); // causes a small 'pop' in the audio currentTiming = GCSettings.timing; diff --git a/source/fceuload.cpp b/source/fceuload.cpp index edad515..bac666f 100644 --- a/source/fceuload.cpp +++ b/source/fceuload.cpp @@ -50,7 +50,7 @@ int GCMemROM(int size) GameInfo->soundrate = SAMPLERATE; GameInfo->name=0; GameInfo->type=GIT_CART; - GameInfo->vidsys=GIV_USER; + GameInfo->vidsys=(EGIV)GCSettings.timing; GameInfo->input[0]=GameInfo->input[1]=SI_UNSET; GameInfo->inputfc=SIFC_UNSET; GameInfo->cspecial=SIS_NONE; diff --git a/source/gcvideo.cpp b/source/gcvideo.cpp index 40f73ec..765310d 100644 --- a/source/gcvideo.cpp +++ b/source/gcvideo.cpp @@ -203,7 +203,7 @@ static u32 normaldiff; void setFrameTimer() { - if (GCSettings.timing == 1) // PAL + if (FCEUI_GetCurrentVidSystem(NULL, NULL) == 1) // PAL normaldiff = 20000; // 50hz else normaldiff = 16667; // 60hz @@ -212,16 +212,14 @@ void setFrameTimer() void SyncSpeed() { - if(GCSettings.timing != vmode_60hz) - return; // same timing as game - no adjustment necessary - now = gettime(); + u32 diff = diff_usec(prev, now); if(turbomode) { // do nothing } - else if (diff_usec(prev, now) > normaldiff) + else if (diff > normaldiff) { frameskip++; } @@ -609,7 +607,7 @@ ResetVideo_Emu () // change current VI mode if using original render mode if (GCSettings.render == 0) - rmode = tvmodes[GCSettings.timing]; + rmode = tvmodes[FCEUI_GetCurrentVidSystem(NULL, NULL)]; else rmode = FindVideoMode(); diff --git a/source/menu.cpp b/source/menu.cpp index 5bd0cba..708983d 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -3051,7 +3051,9 @@ static int MenuSettingsVideo() break; case 5: // timing - GCSettings.timing ^= 1; + GCSettings.timing++; + if(GCSettings.timing > 2) + GCSettings.timing = 0; break; case 6: @@ -3110,7 +3112,13 @@ static int MenuSettingsVideo() sprintf (options.value[4], "%s", GCSettings.currpal ? palettes[GCSettings.currpal-1].desc : "Default"); - sprintf (options.value[5], "%s", GCSettings.timing == 1 ? "PAL" : "NTSC"); + switch(GCSettings.timing) + { + case 0: sprintf (options.value[5], "NTSC"); break; + case 1: sprintf (options.value[5], "PAL"); break; + case 2: sprintf (options.value[5], "Automatic"); break; + } + sprintf (options.value[6], "%.2f%%, %.2f%%", GCSettings.zoomHor*100, GCSettings.zoomVert*100); sprintf (options.value[7], "%d, %d", GCSettings.xshift, GCSettings.yshift); sprintf (options.value[8], "%s", GCSettings.crosshair == 1 ? "On" : "Off"); @@ -3133,6 +3141,7 @@ static int MenuSettingsVideo() } if(backBtn.GetState() == STATE_CLICKED) + { menu = MENU_GAMESETTINGS; } diff --git a/source/preferences.cpp b/source/preferences.cpp index fa8aa59..5ff0a37 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -380,8 +380,8 @@ void FixInvalidSettings() GCSettings.Controller = CTRL_PAD2; if(!(GCSettings.render >= 0 && GCSettings.render < 3)) GCSettings.render = 2; - if(GCSettings.timing != 0 && GCSettings.timing != 1) - GCSettings.timing = 0; + if(GCSettings.timing < 0 || GCSettings.timing > 2) + GCSettings.timing = 2; if(!(GCSettings.videomode >= 0 && GCSettings.videomode < 5)) GCSettings.videomode = 0; } @@ -398,7 +398,7 @@ DefaultSettings () ResetControls(); // controller button mappings GCSettings.currpal = 1; // color palette - GCSettings.timing = 0; // 0 - NTSC, 1 - PAL + GCSettings.timing = 2; // 0 - NTSC, 1 - PAL, 2 - Automatic GCSettings.videomode = 0; // automatic video mode detection GCSettings.Controller = CTRL_PAD2; // NES pad, Four Score, Zapper GCSettings.crosshair = 1; // show zapper crosshair