From e8f54e3d566ddda92cf6946d00f0df55249b406e Mon Sep 17 00:00:00 2001 From: dborth Date: Wed, 22 Apr 2009 18:24:05 +0000 Subject: [PATCH] new option to force a video mode, PAL video mode changed --- source/ngc/menu.cpp | 34 ++++++++++++++--- source/ngc/vba.h | 1 + source/ngc/vbaconfig.cpp | 3 ++ source/ngc/video.cpp | 81 ++++++++++++++++++++++++++++++---------- 4 files changed, 93 insertions(+), 26 deletions(-) diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index 0716032..42d856c 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -907,7 +907,7 @@ static int MenuGameSelection() HaltGui(); btnLogo->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - btnLogo->SetPosition(-30, 24); + btnLogo->SetPosition(-50, 24); mainWindow->Append(&titleTxt); mainWindow->Append(&gameBrowser); mainWindow->Append(&buttonWindow); @@ -1095,7 +1095,7 @@ static int MenuGame() GuiImage closeBtnImgOver(&btnCloseOutlineOver); GuiButton closeBtn(btnCloseOutline.GetWidth(), btnCloseOutline.GetHeight()); closeBtn.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - closeBtn.SetPosition(-30, 35); + closeBtn.SetPosition(-50, 35); closeBtn.SetLabel(&closeBtnTxt); closeBtn.SetImage(&closeBtnImg); closeBtn.SetImageOver(&closeBtnImgOver); @@ -1164,7 +1164,7 @@ static int MenuGame() w.Append(&closeBtn); btnLogo->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); - btnLogo->SetPosition(-30, -40); + btnLogo->SetPosition(-50, -40); mainWindow->Append(&w); if(lastMenu == MENU_NONE) @@ -1380,7 +1380,7 @@ static int MenuGameSaves(int action) GuiImage closeBtnImgOver(&btnCloseOutlineOver); GuiButton closeBtn(btnCloseOutline.GetWidth(), btnCloseOutline.GetHeight()); closeBtn.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - closeBtn.SetPosition(-30, 35); + closeBtn.SetPosition(-50, 35); closeBtn.SetLabel(&closeBtnTxt); closeBtn.SetImage(&closeBtnImg); closeBtn.SetImageOver(&closeBtnImgOver); @@ -1714,7 +1714,7 @@ static int MenuGameSettings() GuiImage closeBtnImgOver(&btnCloseOutlineOver); GuiButton closeBtn(btnCloseOutline.GetWidth(), btnCloseOutline.GetHeight()); closeBtn.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - closeBtn.SetPosition(-30, 35); + closeBtn.SetPosition(-50, 35); closeBtn.SetLabel(&closeBtnTxt); closeBtn.SetImage(&closeBtnImg); closeBtn.SetImageOver(&closeBtnImgOver); @@ -2564,6 +2564,7 @@ static int MenuSettingsVideo() sprintf(options.name[i++], "Scaling"); sprintf(options.name[i++], "Screen Zoom"); sprintf(options.name[i++], "Screen Position"); + sprintf(options.name[i++], "Video Mode"); options.length = i; GuiText titleTxt("Game Settings - Video", 28, (GXColor){255, 255, 255, 255}); @@ -2597,6 +2598,7 @@ static int MenuSettingsVideo() GuiOptionBrowser optionBrowser(552, 248, &options); optionBrowser.SetPosition(0, 108); + optionBrowser.SetCol2Position(200); optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); HaltGui(); @@ -2631,6 +2633,20 @@ static int MenuSettingsVideo() sprintf (options.value[3], "%d, %d", GCSettings.xshift, GCSettings.yshift); + switch(GCSettings.videomode) + { + case 0: + sprintf (options.value[4], "Automatic (Recommended)"); break; + case 1: + sprintf (options.value[4], "NTSC (480i)"); break; + case 2: + sprintf (options.value[4], "Progressive (480p)"); break; + case 3: + sprintf (options.value[4], "PAL (50Hz)"); break; + case 4: + sprintf (options.value[4], "PAL (60Hz)"); break; + } + ret = optionBrowser.GetClickedOption(); switch (ret) @@ -2659,6 +2675,12 @@ static int MenuSettingsVideo() case 3: ScreenPositionWindow(); break; + + case 4: + GCSettings.videomode++; + if(GCSettings.videomode > 4) + GCSettings.videomode = 0; + break; } if(backBtn.GetState() == STATE_CLICKED) @@ -3314,7 +3336,7 @@ MainMenu (int menu) logoTxt.SetPosition(0, 4); btnLogo = new GuiButton(logoImg.GetWidth(), logoImg.GetHeight()); btnLogo->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - btnLogo->SetPosition(-30, 24); + btnLogo->SetPosition(-50, 24); btnLogo->SetImage(&logoImg); btnLogo->SetImageOver(&logoImgOver); btnLogo->SetLabel(&logoTxt); diff --git a/source/ngc/vba.h b/source/ngc/vba.h index 6b08e40..5954014 100644 --- a/source/ngc/vba.h +++ b/source/ngc/vba.h @@ -56,6 +56,7 @@ struct SGCSettings{ char smbshare[20]; float ZoomLevel; // zoom amount + int videomode; // 0 - automatic, 1 - NTSC (480i), 2 - Progressive (480p), 3 - PAL (50Hz), 4 - PAL (60Hz) int scaling; // 0 - default, 1 - partial stretch, 2 - stretch to fit, 3 - widescreen correction int render; // 0 - original, 1 - filtered, 2 - unfiltered int xshift; // video output shift diff --git a/source/ngc/vbaconfig.cpp b/source/ngc/vbaconfig.cpp index 329c153..8f9c277 100644 --- a/source/ngc/vbaconfig.cpp +++ b/source/ngc/vbaconfig.cpp @@ -36,6 +36,8 @@ void FixInvalidSettings() GCSettings.SFXVolume = 40; if(!(GCSettings.render >= 0 && GCSettings.render < 2)) GCSettings.render = 1; + if(!(GCSettings.videomode >= 0 && GCSettings.videomode < 5)) + GCSettings.videomode = 0; } /**************************************************************************** @@ -72,6 +74,7 @@ DefaultSettings () GCSettings.VerifySaves = 0; GCSettings.ZoomLevel = 1.0; // zoom level + GCSettings.videomode = 0; // automatic video mode detection GCSettings.render = 1; // Filtered GCSettings.scaling = 1; // partial stretch GCSettings.WiiControls = false; // Match Wii Game diff --git a/source/ngc/video.cpp b/source/ngc/video.cpp index e667f24..db38119 100644 --- a/source/ngc/video.cpp +++ b/source/ngc/video.cpp @@ -31,6 +31,7 @@ u32 FrameTimer = 0; /*** External 2D Video ***/ /*** 2D Video Globals ***/ static GXRModeObj *vmode = NULL; // Graphics Mode Object +static int currentVideoMode = -1; // -1 - not set, 0 - automatic, 1 - NTSC (480i), 2 - Progressive (480p), 3 - PAL (50Hz), 4 - PAL (60Hz) unsigned int *xfb[2]; // Framebuffers int whichfb = 0; // Frame buffer toggle @@ -341,19 +342,51 @@ UpdatePadsCB () } } + /**************************************************************************** - * InitializeVideo + * SetupVideoMode * - * This function MUST be called at startup. - * - also sets up menu video mode + * Finds the optimal video mode, or uses the user-specified one + * Also configures original video modes ***************************************************************************/ - -void -InitializeVideo () +static void SetupVideoMode() { - // get default video mode - vmode = VIDEO_GetPreferredMode(NULL); + if(currentVideoMode == GCSettings.videomode) + return; // no need to do anything + // choose the desired video mode + switch(GCSettings.videomode) + { + case 1: // NTSC (480i) + vmode = &TVNtsc480IntDf; + break; + case 2: // Progressive (480p) + vmode = &TVNtsc480Prog; + break; + case 3: // PAL (50Hz) + vmode = &TVPal574IntDfScale; + break; + case 4: // PAL (60Hz) + vmode = &TVEurgb60Hz480IntDf; + break; + default: + vmode = VIDEO_GetPreferredMode(NULL); + + #ifdef HW_DOL + /* we have component cables, but the preferred mode is interlaced + * why don't we switch into progressive? + * on the Wii, the user can do this themselves on their Wii Settings */ + if(VIDEO_HaveComponentCable()) + vmode = &TVNtsc480Prog; + #endif + + // use hardware vertical scaling to fill screen + if(vmode->viTVMode >> 2 == VI_PAL) + vmode = &TVPal574IntDfScale; + break; + } + + // configure original modes (not implemented) switch (vmode->viTVMode >> 2) { case VI_PAL: @@ -369,17 +402,11 @@ InitializeVideo () break; } - #ifdef HW_DOL - /* we have component cables, but the preferred mode is interlaced - * why don't we switch into progressive? - * on the Wii, the user can do this themselves on their Wii Settings */ - if(VIDEO_HaveComponentCable()) - vmode = &TVNtsc480Prog; - #endif - // check for progressive scan if (vmode->viTVMode == VI_TVMODE_NTSC_PROG) progressive = true; + else + progressive = false; #ifdef HW_RVL // widescreen fix @@ -390,10 +417,24 @@ InitializeVideo () } #endif + currentVideoMode = GCSettings.videomode; +} + +/**************************************************************************** + * InitializeVideo + * + * This function MUST be called at startup. + * - also sets up menu video mode + ***************************************************************************/ + +void +InitializeVideo () +{ + SetupVideoMode(); VIDEO_Configure (vmode); screenheight = 480; - screenwidth = vmode->fbWidth; + screenwidth = 640; // Allocate the video buffers xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); @@ -511,11 +552,10 @@ static void UpdateScaling() void ResetVideo_Emu () { - GXRModeObj *rmode; + SetupVideoMode(); + GXRModeObj *rmode = vmode; // same mode as menu Mtx44 p; - rmode = vmode; // same mode as menu - // reconfigure VI VIDEO_Configure (rmode); VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK); @@ -725,6 +765,7 @@ ResetVideo_Menu () f32 yscale; u32 xfbHeight; + SetupVideoMode(); VIDEO_Configure (vmode); VIDEO_Flush(); VIDEO_WaitVSync();