From 7223e2283efc0077a7741e4fb30ef9122d4e931a Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Sat, 8 Oct 2016 21:33:34 -0500 Subject: [PATCH] Save rewind variables to config file. Rename rewind variables to fit port style. Set default rewind buffer to 0. --- gtk/src/gtk_config.cpp | 17 ++++++++++++++--- gtk/src/gtk_config.h | 4 ++-- gtk/src/gtk_s9x.cpp | 8 ++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/gtk/src/gtk_config.cpp b/gtk/src/gtk_config.cpp index d73edc07..7bb1e6be 100644 --- a/gtk/src/gtk_config.cpp +++ b/gtk/src/gtk_config.cpp @@ -175,9 +175,9 @@ Snes9xConfig::load_defaults (void) netplay_last_host [0] = '\0'; netplay_last_port = 6096; modal_dialogs = 1; - - rewindGranularity = 5; - rewindBufferSize = 150; + + rewind_granularity = 5; + rewind_buffer_size = 0; #ifdef USE_OPENGL sync_to_vblank = 1; @@ -328,6 +328,9 @@ Snes9xConfig::save_config_file (void) xml_out_int (xml, "hw_accel", hw_accel); xml_out_int (xml, "bilinear_filter", bilinear_filter); + xml_out_int (xml, "rewind_buffer_size", rewind_buffer_size); + xml_out_int (xml, "rewind_granularity", rewind_granularity); + #ifdef USE_OPENGL xml_out_int (xml, "sync_to_vblank", sync_to_vblank); xml_out_int (xml, "sync_every_frame", sync_every_frame); @@ -841,6 +844,14 @@ Snes9xConfig::set_option (const char *name, const char *value) { Settings.SoundSync = atoi (value) ? 1 : 0; } + else if (!strcasecmp (name, "rewind_buffer_size")) + { + rewind_buffer_size = CLAMP (atoi (value), 0, 2000); + } + else if (!strcasecmp (name, "rewind_granularity")) + { + rewind_granularity = CLAMP (atoi (value), 0, 600); + } else { fprintf (stderr, _("bad option name: %s\n"), name); diff --git a/gtk/src/gtk_config.h b/gtk/src/gtk_config.h index 04b06553..30e26feb 100644 --- a/gtk/src/gtk_config.h +++ b/gtk/src/gtk_config.h @@ -134,8 +134,8 @@ class Snes9xConfig int pointer_is_visible; struct timeval pointer_timestamp; - unsigned int rewindGranularity; - unsigned int rewindBufferSize; + unsigned int rewind_granularity; + unsigned int rewind_buffer_size; #ifdef USE_XRANDR XRRScreenConfiguration *xrr_config; diff --git a/gtk/src/gtk_s9x.cpp b/gtk/src/gtk_s9x.cpp index 80288e4b..955acf97 100644 --- a/gtk/src/gtk_s9x.cpp +++ b/gtk/src/gtk_s9x.cpp @@ -222,10 +222,10 @@ S9xOpenROM (const char *rom_filename) CPU.Flags = flags; - if (gui_config->rewindBufferSize) + if (gui_config->rewind_buffer_size) { - printf("Setting buffer size to %u\n", gui_config->rewindBufferSize * 1024 * 1024); - stateMan.init(gui_config->rewindBufferSize * 1024 * 1024); + printf ("Using rewind buffer of %uMB\n", gui_config->rewind_buffer_size); + stateMan.init (gui_config->rewind_buffer_size * 1024 * 1024); } S9xROMLoaded (); @@ -367,7 +367,7 @@ S9xIdleFunc (gpointer data) if(top_level->user_rewind) top_level->user_rewind = stateMan.pop(); - else if(IPPU.TotalEmulatedFrames % gui_config->rewindGranularity == 0) + else if(IPPU.TotalEmulatedFrames % gui_config->rewind_granularity == 0) stateMan.push(); static int muted_from_turbo = FALSE;