From 6d4bab0809a547c0520190fc5b680e21927b4947 Mon Sep 17 00:00:00 2001 From: dborth Date: Fri, 24 Oct 2008 05:11:01 +0000 Subject: [PATCH] add zoom saving, video corrections --- source/ngc/input.cpp | 2 +- source/ngc/menu.cpp | 39 +++++++++++++++++++------------------- source/ngc/preferences.cpp | 17 +++++++++++++++-- source/ngc/s9xconfig.cpp | 4 ++-- source/ngc/snes9xGX.h | 3 ++- source/ngc/video.cpp | 24 +++++++++++------------ 6 files changed, 51 insertions(+), 38 deletions(-) diff --git a/source/ngc/input.cpp b/source/ngc/input.cpp index 6948616..7fe084f 100644 --- a/source/ngc/input.cpp +++ b/source/ngc/input.cpp @@ -446,7 +446,7 @@ void NGCReportButtons () /*** Check for video zoom ***/ - if (GCSettings.NGCZoom) + if (GCSettings.Zoom) { if (gc_py < -36 || gc_py > 36) zoom ((float) gc_py / -36); diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index 1b1649a..78a3792 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -83,6 +83,20 @@ void Reboot() #endif } +void ExitToLoader() +{ + // Exit to Loader + #ifdef HW_RVL + #ifdef WII_DVD + DI_Close(); + #endif + exit(0); + #else // gamecube + if (psoid[0] == PSOSDLOADID) + PSOReload (); + #endif +} + /**************************************************************************** * Load Manager ***************************************************************************/ @@ -104,9 +118,6 @@ LoadManager () // setup cheats SetupCheats(); - - // reset zoom - zoom_reset (); } return loadROM; @@ -346,7 +357,6 @@ GameMenu () break; case 1: // Reset Game - zoom_reset (); S9xSoftReset (); quit = retval = 1; break; @@ -361,7 +371,6 @@ GameMenu () break; case 4: // Load SRAM - zoom_reset (); quit = retval = LoadSRAM(GCSettings.SaveMethod, NOTSILENT); break; @@ -370,7 +379,6 @@ GameMenu () break; case 6: // Load Freeze - zoom_reset (); quit = retval = NGCUnfreezeGame (GCSettings.SaveMethod, NOTSILENT); break; @@ -544,8 +552,8 @@ static char videomenu[][50] = { "Transparency", "Display Frame Rate", "Enable Zooming", - "Video Filtering", - "Widescreen", + "Video Rendering", + "Video Scaling", "Shift Video Up", "Shift Video Down", @@ -574,7 +582,7 @@ VideoOptions () Settings.DisplayFrameRate == true ? " ON" : "OFF"); sprintf (videomenu[2], "Enable Zooming %s", - GCSettings.NGCZoom == true ? " ON" : "OFF"); + GCSettings.Zoom == true ? " ON" : "OFF"); // don't allow original render mode if progressive video mode detected if (GCSettings.render==0 && progressive) @@ -605,7 +613,7 @@ VideoOptions () break; case 2: - GCSettings.NGCZoom ^= 1; + GCSettings.Zoom ^= 1; break; case 3: @@ -1111,16 +1119,7 @@ MainMenu (int selectedMenu) break; case 6: - // Exit to Loader - #ifdef HW_RVL - #ifdef WII_DVD - DI_Close(); - #endif - exit(0); - #else // gamecube - if (psoid[0] == PSOSDLOADID) - PSOReload (); - #endif + ExitToLoader(); break; case -1: // Button B diff --git a/source/ngc/preferences.cpp b/source/ngc/preferences.cpp index 09bddd6..d90fa16 100644 --- a/source/ngc/preferences.cpp +++ b/source/ngc/preferences.cpp @@ -47,6 +47,11 @@ const char * toStr(int i) sprintf(temp, "%d", i); return temp; } +const char * FtoStr(float i) +{ + sprintf(temp, "%.2f", i); + return temp; +} void createXMLSection(const char * name, const char * description) { @@ -154,7 +159,8 @@ preparePrefsData (int method) createXMLSetting("Transparency", "Transparency", toStr(Settings.Transparency)); createXMLSetting("DisplayFrameRate", "Display Frame Rate", toStr(Settings.DisplayFrameRate)); - createXMLSetting("NGCZoom", "C-Stick Zoom", toStr(GCSettings.NGCZoom)); + createXMLSetting("Zoom", "Zoom On/Off", toStr(GCSettings.Zoom)); + createXMLSetting("ZoomLevel", "Zoom Level", FtoStr(GCSettings.ZoomLevel)); createXMLSetting("render", "Video Filtering", toStr(GCSettings.render)); createXMLSetting("widescreen", "Aspect Ratio Correction", toStr(GCSettings.widescreen)); createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift)); @@ -198,6 +204,12 @@ void loadXMLSetting(int * var, const char * name) if(item) *var = atoi(mxmlElementGetAttr(item, "value")); } +void loadXMLSetting(float * var, const char * name) +{ + item = mxmlFindElement(xml, xml, "setting", "name", name, MXML_DESCEND); + if(item) + *var = atof(mxmlElementGetAttr(item, "value")); +} void loadXMLSetting(bool8 * var, const char * name) { item = mxmlFindElement(xml, xml, "setting", "name", name, MXML_DESCEND); @@ -278,7 +290,8 @@ decodePrefsData (int method) loadXMLSetting(&Settings.Transparency, "Transparency"); loadXMLSetting(&Settings.DisplayFrameRate, "DisplayFrameRate"); - loadXMLSetting(&GCSettings.NGCZoom, "NGCZoom"); + loadXMLSetting(&GCSettings.Zoom, "Zoom"); + loadXMLSetting(&GCSettings.ZoomLevel, "ZoomLevel"); loadXMLSetting(&GCSettings.render, "render"); loadXMLSetting(&GCSettings.widescreen, "widescreen"); loadXMLSetting(&GCSettings.xshift, "xshift"); diff --git a/source/ngc/s9xconfig.cpp b/source/ngc/s9xconfig.cpp index 8c9a93a..c4fae84 100644 --- a/source/ngc/s9xconfig.cpp +++ b/source/ngc/s9xconfig.cpp @@ -55,8 +55,8 @@ DefaultSettings () GCSettings.Mouse = 0; GCSettings.Justifier = 0; - GCSettings.NGCZoom = 0; // zooming default off - + GCSettings.Zoom = 0; // zooming default off + GCSettings.ZoomLevel = 1.0; // zoom level GCSettings.render = 2; // Unfiltered GCSettings.widescreen = 0; // no aspect ratio correction diff --git a/source/ngc/snes9xGX.h b/source/ngc/snes9xGX.h index 799386c..46c9e97 100644 --- a/source/ngc/snes9xGX.h +++ b/source/ngc/snes9xGX.h @@ -50,7 +50,8 @@ struct SGCSettings{ char smbgcid[20]; char smbsvid[20]; char smbshare[20]; - int NGCZoom; // 0 - off, 1 - on + int Zoom; // 0 - off, 1 - on + float ZoomLevel; // zoom amount int VerifySaves; int render; // 0 - original, 1 - filtered, 2 - unfiltered int Superscope; diff --git a/source/ngc/video.cpp b/source/ngc/video.cpp index 8b32834..b697a48 100644 --- a/source/ngc/video.cpp +++ b/source/ngc/video.cpp @@ -48,7 +48,6 @@ GXTexObj texobj; Mtx view; int vwidth, vheight, oldvwidth, oldvheight; -float zoom_level = 1; int zoom_xshift = 0; int zoom_yshift = 0; @@ -82,7 +81,7 @@ s16 square[] ATTRIBUTE_ALIGN (32) = -HASPECT, VASPECT, 0, // 0 HASPECT, VASPECT, 0, // 1 HASPECT, -VASPECT, 0, // 2 - -HASPECT, -VASPECT, 0, // 3 + -HASPECT, -VASPECT, 0 // 3 }; @@ -576,7 +575,7 @@ ResetVideo_Emu () TV_448i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE); // set VI position TV_239p.viXOrigin = TV_224p.viXOrigin = TV_478i.viXOrigin = TV_448i.viXOrigin = (VI_MAX_WIDTH_NTSC - 640)/2; - TV_239p.viYOrigin = TV_478i.viYOrigin = (VI_MAX_HEIGHT_NTSC/2 - 478/2)/2; + TV_239p.viYOrigin = TV_478i.viYOrigin = (VI_MAX_HEIGHT_PAL/2 - 478/2)/2; TV_224p.viYOrigin = TV_448i.viYOrigin = (VI_MAX_HEIGHT_NTSC/2 - 448/2)/2; break; @@ -760,8 +759,8 @@ update_video (int width, int height) if (GCSettings.widescreen) xscale = (3*xscale)/4; - xscale *= zoom_level; - yscale *= zoom_level; + xscale *= GCSettings.ZoomLevel; + yscale *= GCSettings.ZoomLevel; square[6] = square[3] = xscale + GCSettings.xshift; square[0] = square[9] = -xscale + GCSettings.xshift; @@ -812,13 +811,15 @@ update_video (int width, int height) void zoom (float speed) { - if (zoom_level > 1) - zoom_level += (speed / -100.0); + if (GCSettings.ZoomLevel > 1) + GCSettings.ZoomLevel += (speed / -100.0); else - zoom_level += (speed / -200.0); + GCSettings.ZoomLevel += (speed / -200.0); - if (zoom_level < 0.5) zoom_level = 0.5; - else if (zoom_level > 10.0) zoom_level = 10.0; + if (GCSettings.ZoomLevel < 0.5) + GCSettings.ZoomLevel = 0.5; + else if (GCSettings.ZoomLevel > 10.0) + GCSettings.ZoomLevel = 10.0; oldvheight = 0; // update video } @@ -826,8 +827,7 @@ zoom (float speed) void zoom_reset () { - zoom_level = 1.0; - + GCSettings.ZoomLevel = 1.0; oldvheight = 0; // update video }