diff --git a/gtk/src/gtk_config.cpp b/gtk/src/gtk_config.cpp index eb70c684..f933270f 100644 --- a/gtk/src/gtk_config.cpp +++ b/gtk/src/gtk_config.cpp @@ -158,6 +158,7 @@ int Snes9xConfig::load_defaults () netplay_last_port = 6096; modal_dialogs = 1; use_headerbar = 0; + current_save_slot = 0; S9xCheatsEnable (); rewind_granularity = 5; @@ -361,6 +362,7 @@ int Snes9xConfig::save_config_file () outbool (cf, z"UseModalDialogs", modal_dialogs); cf.SetInt (z"RewindBufferSize", rewind_buffer_size, "Amount of memory (in MB) to use for rewinding"); cf.SetInt (z"RewindGranularity", rewind_granularity, "Only save rewind snapshots every N frames"); + cf.SetInt (z"CurrentSaveSlot", current_save_slot); #undef z #define z "Emulation::" @@ -562,6 +564,7 @@ int Snes9xConfig::load_config_file () inbool (z"UseModalDialogs", modal_dialogs); inint (z"RewindBufferSize", rewind_buffer_size); inint (z"RewindGranularity", rewind_granularity); + inint (z"CurrentSaveSlot", current_save_slot); #undef z #define z "Emulation::" diff --git a/gtk/src/gtk_config.h b/gtk/src/gtk_config.h index fcba80ef..8f5c3a45 100644 --- a/gtk/src/gtk_config.h +++ b/gtk/src/gtk_config.h @@ -135,6 +135,8 @@ class Snes9xConfig unsigned int rewind_granularity; unsigned int rewind_buffer_size; + int current_save_slot; + XRRScreenResources *xrr_screen_resources; XRRCrtcInfo *xrr_crtc_info; diff --git a/gtk/src/gtk_control.cpp b/gtk/src/gtk_control.cpp index 01a97976..2d4e3f47 100644 --- a/gtk/src/gtk_control.cpp +++ b/gtk/src/gtk_control.cpp @@ -57,6 +57,12 @@ const BindingLink b_links[] = { "b_bg_layering_hack", "BGLayeringHack" }, { "b_screenshot", "Screenshot" }, { "b_fullscreen", "GTK_fullscreen" }, + { "b_state_save_current", "GTK_state_save_current" }, + { "b_state_load_current", "GTK_state_load_current" }, + { "b_state_increment_save","GTK_state_increment_save" }, + { "b_state_decrement_load","GTK_state_decrement_load" }, + { "b_state_increment", "GTK_state_increment" }, + { "b_state_decrement", "GTK_state_decrement" }, { "b_save_0", "QuickSave000" }, { "b_save_1", "QuickSave001" }, { "b_save_2", "QuickSave002" }, @@ -104,9 +110,9 @@ const int b_breaks[] = 24, /* End of turbo/sticky buttons */ 35, /* End of base emulator buttons */ 43, /* End of Graphic options */ - 63, /* End of save/load states */ - 72, /* End of sound buttons */ - 79, /* End of miscellaneous buttons */ + 69, /* End of save/load states */ + 78, /* End of sound buttons */ + 85, /* End of miscellaneous buttons */ -1 }; @@ -171,6 +177,19 @@ static void swap_controllers_1_2 () gui_config->rebind_keys (); } +static void change_slot (int difference) +{ + static char buf[256]; + + gui_config->current_save_slot += difference; + gui_config->current_save_slot %= 1000; + if (gui_config->current_save_slot < 0) + gui_config->current_save_slot += 1000; + snprintf (buf, 256, "Slot %d", gui_config->current_save_slot); + S9xSetInfoString (buf); + GFX.InfoStringTimeout = 60; +} + void S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2) { static bool quit_binding_down = FALSE; @@ -238,6 +257,38 @@ void S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2) { S9xQuickLoadSlot (cmd.port[0] - PORT_QUICKLOAD0); } + + else if (cmd.port[0] == PORT_SAVESLOT) + { + S9xQuickSaveSlot (gui_config->current_save_slot); + } + + else if (cmd.port[0] == PORT_LOADSLOT) + { + S9xQuickLoadSlot (gui_config->current_save_slot); + } + + else if (cmd.port[0] == PORT_INCREMENTSAVESLOT) + { + change_slot (1); + S9xQuickSaveSlot (gui_config->current_save_slot); + } + + else if (cmd.port[0] == PORT_DECREMENTLOADSLOT) + { + change_slot (-1); + S9xQuickLoadSlot (gui_config->current_save_slot); + } + + else if (cmd.port[0] == PORT_INCREMENTSLOT) + { + change_slot (1); + } + + else if (cmd.port[0] == PORT_DECREMENTSLOT) + { + change_slot (-1); + } } } @@ -356,6 +407,37 @@ s9xcommand_t S9xGetPortCommandT (const char *name) cmd.port[0] = PORT_QUICKLOAD9; } + else if (strstr (name, "GTK_state_save_current")) + { + cmd.port[0] = PORT_SAVESLOT; + } + + else if (strstr (name, "GTK_state_load_current")) + { + cmd.port[0] = PORT_LOADSLOT; + } + + else if (strstr (name, "GTK_state_increment_save")) + { + cmd.port[0] = PORT_INCREMENTSAVESLOT; + } + + else if (strstr (name, "GTK_state_decrement_load")) + { + cmd.port[0] = PORT_DECREMENTLOADSLOT; + } + + else if (strstr (name, "GTK_state_increment")) + { + cmd.port[0] = PORT_INCREMENTSLOT; + } + + else if (strstr (name, "GTK_state_decrement")) + { + cmd.port[0] = PORT_DECREMENTSLOT; + } + + else { cmd = S9xGetCommandT (name); diff --git a/gtk/src/gtk_control.h b/gtk/src/gtk_control.h index aacb47b2..1130645c 100644 --- a/gtk/src/gtk_control.h +++ b/gtk/src/gtk_control.h @@ -42,7 +42,13 @@ enum PORT_QUICKLOAD6 = 15, PORT_QUICKLOAD7 = 16, PORT_QUICKLOAD8 = 17, - PORT_QUICKLOAD9 = 18 + PORT_QUICKLOAD9 = 18, + PORT_SAVESLOT = 19, + PORT_LOADSLOT = 20, + PORT_INCREMENTSAVESLOT = 21, + PORT_DECREMENTLOADSLOT = 22, + PORT_INCREMENTSLOT = 23, + PORT_DECREMENTSLOT = 24, }; typedef struct BindingLink @@ -55,7 +61,7 @@ typedef struct BindingLink extern const BindingLink b_links[]; extern const int b_breaks[]; const int NUM_JOYPAD_LINKS = 24; -const int NUM_EMU_LINKS = 55; +const int NUM_EMU_LINKS = 61; typedef struct JoypadBinding { diff --git a/gtk/src/gtk_file.cpp b/gtk/src/gtk_file.cpp index 10422871..393e9efe 100644 --- a/gtk/src/gtk_file.cpp +++ b/gtk/src/gtk_file.cpp @@ -489,6 +489,9 @@ S9xQuickSaveSlot (int slot) char dir[_MAX_DIR]; char ext[_MAX_EXT]; + if (!gui_config->rom_loaded) + return; + _splitpath (Memory.ROMFilename, drive, dir, def, ext); snprintf (filename, PATH_MAX, "%s%s%s.%03d", @@ -503,8 +506,7 @@ S9xQuickSaveSlot (int slot) } } -void -S9xQuickLoadSlot (int slot) +void S9xQuickLoadSlot (int slot) { char def[PATH_MAX]; char filename[PATH_MAX]; @@ -512,6 +514,9 @@ S9xQuickLoadSlot (int slot) char dir[_MAX_DIR]; char ext[_MAX_EXT]; + if (!gui_config->rom_loaded) + return; + _splitpath (Memory.ROMFilename, drive, dir, def, ext); snprintf (filename, PATH_MAX, "%s%s%s.%03d", diff --git a/gtk/src/snes9x.ui b/gtk/src/snes9x.ui index 74c4186c..5b9423c5 100644 --- a/gtk/src/snes9x.ui +++ b/gtk/src/snes9x.ui @@ -7425,12 +7425,236 @@ False queue none + + + True + 5 + + + + + True + False + 10 + 8 + 2 + 10 + 5 + + + + + True + False + 0 + Save current slot + + + 0 + 1 + 0 + 1 + GTK_FILL + + + + + True + True + False + False + False + True + True + + + 1 + 2 + 0 + 1 + GTK_FILL + + + + + + True + False + 0 + Load current slot + + + 0 + 1 + 1 + 2 + GTK_FILL + + + + + True + True + False + False + False + True + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + True + False + 0 + Increment and save + + + 0 + 1 + 2 + 3 + GTK_FILL + + + + + True + True + False + False + False + True + True + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + + True + False + 0 + Decrement and load + + + 0 + 1 + 3 + 4 + GTK_FILL + + + + + True + True + False + False + False + True + True + + + 1 + 2 + 3 + 4 + GTK_FILL + + + + + + + True + False + 0 + Increment slot + + + 0 + 1 + 4 + 5 + GTK_FILL + + + + + True + True + False + False + False + True + True + + + 1 + 2 + 4 + 5 + GTK_FILL + + + + + + True + False + 0 + Decrement slot + + + 0 + 1 + 5 + 6 + GTK_FILL + + + + + True + True + False + False + False + True + True + + + 1 + 2 + 5 + 6 + GTK_FILL + + + + + True False 10 - 11 + 14 4 10 5 @@ -8146,6 +8370,8 @@ + +