From 3c0bafb263d2db06e0dc5e630f944d977d8d1beb Mon Sep 17 00:00:00 2001 From: Juan Ruvalcaba Date: Sat, 12 Mar 2016 13:58:51 -0700 Subject: [PATCH] -Add Super FX Overclock option --- source/menu.cpp | 24 ++++++++++++++++++++++++ source/preferences.cpp | 11 +++++++++++ source/snes9x/fxemu.cpp | 3 ++- source/snes9x/snes9x.h | 1 + source/snes9xgx.cpp | 21 +++++++++++++-------- source/snes9xgx.h | 10 ++++++---- 6 files changed, 57 insertions(+), 13 deletions(-) diff --git a/source/menu.cpp b/source/menu.cpp index 0c28375..529e7ea 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -39,6 +39,7 @@ #include "utils/gettext.h" #include "snes9x/snes9x.h" +#include "snes9x/fxemu.h" #include "snes9x/memmap.h" #include "snes9x/cheats.h" @@ -3101,6 +3102,7 @@ static int MenuSettingsVideo() int ret; int i = 0; bool firstRun = true; + bool reset_sfx = false; OptionList options; sprintf(options.name[i++], "Rendering"); @@ -3111,6 +3113,7 @@ static int MenuSettingsVideo() sprintf(options.name[i++], "Crosshair"); sprintf(options.name[i++], "Video Mode"); sprintf(options.name[i++], "Show Framerate"); + sprintf(options.name[i++], "SuperFX Overclock"); options.length = i; #ifdef HW_DOL @@ -3202,6 +3205,18 @@ static int MenuSettingsVideo() Settings.AutoDisplayMessages ^= 1; Settings.DisplayFrameRate ^= 1; break; + case 8: + GCSettings.sfxOverclock++; + if (GCSettings.sfxOverclock > 2) + GCSettings.sfxOverclock = 0; + switch(GCSettings.sfxOverclock) + { + case 0: Settings.SuperFXSpeedPerLine = 0.417 * 10.5e6; reset_sfx = true; break; + case 1: Settings.SuperFXSpeedPerLine = 0.417 * 40.5e6; reset_sfx = true; break; + case 2: Settings.SuperFXSpeedPerLine = 0.417 * 60.5e6; reset_sfx = true; break; + } + if (reset_sfx) S9xResetSuperFX(); S9xReset(); + break; } if(ret >= 0 || firstRun) @@ -3244,6 +3259,15 @@ static int MenuSettingsVideo() sprintf (options.value[6], "PAL (60Hz)"); break; } sprintf (options.value[7], "%s", Settings.DisplayFrameRate ? "On" : "Off"); + switch(GCSettings.sfxOverclock) + { + case 0: + sprintf (options.value[8], "Default"); break; + case 1: + sprintf (options.value[8], "40 Mhz"); break; + case 2: + sprintf (options.value[8], "60 Mhz"); break; + } optionBrowser.TriggerUpdate(); } diff --git a/source/preferences.cpp b/source/preferences.cpp index 93527c5..4968ef0 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -146,6 +146,7 @@ preparePrefsData () createXMLSetting("FilterMethod", "Filter Method", toStr(GCSettings.FilterMethod)); createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift)); createXMLSetting("yshift", "Vertical Video Shift", toStr(GCSettings.yshift)); + createXMLSetting("sfxOverclock", "SuperFX Overclock", toStr(GCSettings.sfxOverclock)); createXMLSection("Menu", "Menu Settings"); @@ -323,6 +324,10 @@ decodePrefsData () loadXMLSetting(&GCSettings.xshift, "xshift"); loadXMLSetting(&GCSettings.yshift, "yshift"); + //Emulation Settings + + loadXMLSetting(&GCSettings.sfxOverclock, "sfxOverclock"); + // Menu Settings loadXMLSetting(&GCSettings.WiimoteOrientation, "WiimoteOrientation"); @@ -346,6 +351,7 @@ decodePrefsData () loadXMLController(btnmap[CTRL_MOUSE][CTRLR_WIIMOTE], "btnmap_mouse_wiimote"); loadXMLController(btnmap[CTRL_JUST][CTRLR_GCPAD], "btnmap_just_gcpad"); loadXMLController(btnmap[CTRL_JUST][CTRLR_WIIMOTE], "btnmap_just_wiimote"); + } mxmlDelete(xml); } @@ -474,6 +480,11 @@ DefaultSettings () // Frame timings in 50hz and 60hz cpu mode Settings.FrameTimePAL = 20000; Settings.FrameTimeNTSC = 16667; + + GCSettings.sfxOverclock = 0; + /* Initialize SuperFX CPU to normal speed by default */ + Settings.SuperFXSpeedPerLine = 0.417 * 10.5e6; + } /**************************************************************************** diff --git a/source/snes9x/fxemu.cpp b/source/snes9x/fxemu.cpp index b3237ae..b0f1561 100644 --- a/source/snes9x/fxemu.cpp +++ b/source/snes9x/fxemu.cpp @@ -199,7 +199,8 @@ void S9xInitSuperFX (void) void S9xResetSuperFX (void) { // FIXME: Snes9x can't execute CPU and SuperFX at a time. Don't ask me what is 0.417 :P - SuperFX.speedPerLine = (uint32) (0.417 * 10.5e6 * ((1.0 / (float) Memory.ROMFramesPerSecond) / ((float) (Timings.V_Max)))); + //SuperFX.speedPerLine = (uint32) (0.417 * 10.5e6 * ((1.0 / (float) Memory.ROMFramesPerSecond) / ((float) (Timings.V_Max)))); + SuperFX.speedPerLine = (uint32) (Settings.SuperFXSpeedPerLine * ((1.0f / Memory.ROMFramesPerSecond) / ((float) (Timings.V_Max)))); SuperFX.oneLineDone = FALSE; SuperFX.vFlags = 0; FxReset(&SuperFX); diff --git a/source/snes9x/snes9x.h b/source/snes9x/snes9x.h index a58be71..f2e5ca9 100644 --- a/source/snes9x/snes9x.h +++ b/source/snes9x/snes9x.h @@ -446,6 +446,7 @@ struct SSettings bool8 UpAndDown; bool8 OpenGLEnable; + float SuperFXSpeedPerLine; }; struct SSNESGameFixes diff --git a/source/snes9xgx.cpp b/source/snes9xgx.cpp index 155c5f2..9556d0d 100644 --- a/source/snes9xgx.cpp +++ b/source/snes9xgx.cpp @@ -44,6 +44,7 @@ #include "utils/FreeTypeGX.h" #include "snes9x/snes9x.h" +#include "snes9x/fxemu.h" #include "snes9x/memmap.h" #include "snes9x/apu/apu.h" #include "snes9x/controls.h" @@ -504,6 +505,14 @@ int main(int argc, char *argv[]) BrowserLoadFile(); } + switch (GCSettings.sfxOverclock) + { + case 0: Settings.SuperFXSpeedPerLine = 0.417 * 10.5e6; break; + case 1: Settings.SuperFXSpeedPerLine = 0.417 * 40.5e6; break; + case 2: Settings.SuperFXSpeedPerLine = 0.417 * 60.5e6; break; + S9xResetSuperFX(); + } + while (1) // main loop { // go back to checking if devices were inserted/removed @@ -512,10 +521,6 @@ int main(int argc, char *argv[]) SwitchAudioMode(1); -// if(SNESROMSize == 0) -// MainMenu(MENU_GAMESELECTION); -// else -// MainMenu(MENU_GAME); if(!autoboot) { if(SNESROMSize == 0) @@ -549,11 +554,11 @@ int main(int argc, char *argv[]) HaltDeviceThread(); AudioStart (); - - FrameTimer = 0; - setFrameTimerMethod (); // set frametimer method every time a ROM is loaded - CheckVideo = 2; // force video update + FrameTimer = 0; + setFrameTimerMethod (); // set frametimer method every time a ROM is loaded + + CheckVideo = 2; // force video update prevRenderedFrameCount = IPPU.RenderedFramesCount; currentMode = GCSettings.render; diff --git a/source/snes9xgx.h b/source/snes9xgx.h index 1b2def5..c88e009 100644 --- a/source/snes9xgx.h +++ b/source/snes9xgx.h @@ -19,9 +19,9 @@ #include "filter.h" #include "filelist.h" -#define APPNAME "Snes9x GX" -#define APPVERSION "4.3.6" -#define APPFOLDER "snes9xgx" +#define APPNAME "Snes9x GX" +#define APPVERSION "4.3.6" +#define APPFOLDER "snes9xgx" #define PREF_FILE_NAME "settings.xml" #define NOTSILENT 0 @@ -114,7 +114,9 @@ struct SGCSettings{ int MusicVolume; int SFXVolume; int Rumble; - int language; + int language; + + int sfxOverclock; }; void ExitApp();