changeset 2162:1270fe86eb89

Add Quick Load binding
author Michael Pavone <pavone@retrodev.com>
date Thu, 09 Jun 2022 09:35:38 -0700
parents 6a954675d634
children 0bf077df45c3 4fbe1e7c4a73
files bindings.c config.c default.cfg nuklear_ui/blastem_nuklear.c
diffstat 4 files changed, 29 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/bindings.c	Tue May 24 18:49:38 2022 -0700
+++ b/bindings.c	Thu Jun 09 09:35:38 2022 -0700
@@ -26,6 +26,7 @@
 	UI_DEBUG_MODE_INC,
 	UI_ENTER_DEBUGGER,
 	UI_SAVE_STATE,
+	UI_LOAD_STATE,
 	UI_SET_SPEED,
 	UI_NEXT_SPEED,
 	UI_PREV_SPEED,
@@ -325,6 +326,11 @@
 				current_system->save_state = QUICK_SAVE_SLOT+1;
 			}
 			break;
+		case UI_LOAD_STATE:
+			if (allow_content_binds) {
+				current_system->load_state(current_system, QUICK_SAVE_SLOT);
+			}
+			break;
 		case UI_NEXT_SPEED:
 			if (allow_content_binds) {
 				current_speed++;
@@ -630,6 +636,8 @@
 			*subtype_a = UI_ENTER_DEBUGGER;
 		} else if(!strcmp(target + 3, "save_state")) {
 			*subtype_a = UI_SAVE_STATE;
+		} else if(!strcmp(target + 3, "load_state")) {
+			*subtype_a = UI_LOAD_STATE;
 		} else if(startswith(target + 3, "set_speed.")) {
 			*subtype_a = UI_SET_SPEED;
 			*subtype_b = atoi(target + 3 + strlen("set_speed."));
--- a/config.c	Tue May 24 18:49:38 2022 -0700
+++ b/config.c	Thu Jun 09 09:35:38 2022 -0700
@@ -285,7 +285,7 @@
 	*pads = tern_insert_node(*pads, key, dupe_tree(val.ptrval));
 }
 
-#define CONFIG_VERSION 1
+#define CONFIG_VERSION 2
 static tern_node *migrate_config(tern_node *config, int from_version)
 {
 	tern_node *def_config = parse_bundled_config("default.cfg");
@@ -326,6 +326,13 @@
 		config = tern_insert_path(config, "bindings\0pads\0", (tern_val){.ptrval = pads}, TVAL_NODE);
 		break;
 	}
+	case 1: {
+		char *l_bind = tern_find_path(config, "bindings\0keys\0l\0", TVAL_PTR).ptrval;
+		if (!l_bind) {
+			config = tern_insert_path(config, "bindings\0keys\0l\0", (tern_val){.ptrval = strdup("ui.load_state")}, TVAL_PTR);
+		}
+		break;
+	}
 	}
 	char buffer[16];
 	sprintf(buffer, "%d", CONFIG_VERSION);
--- a/default.cfg	Tue May 24 18:49:38 2022 -0700
+++ b/default.cfg	Thu Jun 09 09:35:38 2022 -0700
@@ -24,6 +24,7 @@
 		m ui.vgm_log
 		esc ui.exit
 		` ui.save_state
+		l ui.load_state
 		0 ui.set_speed.0
 		1 ui.set_speed.1
 		2 ui.set_speed.2
--- a/nuklear_ui/blastem_nuklear.c	Tue May 24 18:49:38 2022 -0700
+++ b/nuklear_ui/blastem_nuklear.c	Thu Jun 09 09:35:38 2022 -0700
@@ -465,37 +465,37 @@
 
 void view_key_bindings(struct nk_context *context)
 {
-	const char *controller1_binds[] = {
+	static const char *controller1_binds[] = {
 		"gamepads.1.up", "gamepads.1.down", "gamepads.1.left", "gamepads.1.right",
 		"gamepads.1.a", "gamepads.1.b", "gamepads.1.c",
 		"gamepads.1.x", "gamepads.1.y", "gamepads.1.z",
 		"gamepads.1.start", "gamepads.1.mode"
 	};
-	const char *controller2_binds[] = {
+	static const char *controller2_binds[] = {
 		"gamepads.2.up", "gamepads.2.down", "gamepads.2.left", "gamepads.2.right",
 		"gamepads.2.a", "gamepads.2.b", "gamepads.2.c",
 		"gamepads.2.x", "gamepads.2.y", "gamepads.2.z",
 		"gamepads.2.start", "gamepads.2.mode"
 	};
-	const char *general_binds[] = {
-		"ui.exit", "ui.save_state", "ui.toggle_fullscreen", "ui.soft_reset", "ui.reload",
-		"ui.screenshot", "ui.vgm_log", "ui.sms_pause", "ui.toggle_keyboard_cpatured", "ui.release_mouse"
+	static const char *general_binds[] = {
+		"ui.exit", "ui.save_state", "ui.load_state", "ui.toggle_fullscreen", "ui.soft_reset", "ui.reload",
+		"ui.screenshot", "ui.vgm_log", "ui.sms_pause", "ui.toggle_keyboard_captured", "ui.release_mouse"
 	};
-	const char *general_names[] = {
-		"Show Menu", "Quick Save", "Toggle Fullscreen", "Soft Reset", "Reload Media",
+	static const char *general_names[] = {
+		"Show Menu", "Quick Save", "Quick Load", "Toggle Fullscreen", "Soft Reset", "Reload Media",
 		"Internal Screenshot", "Toggle VGM Log", "SMS Pause", "Capture Keyboard", "Release Mouse"
 	};
-	const char *speed_binds[] = {
+	static const char *speed_binds[] = {
 		"ui.next_speed", "ui.prev_speed",
 		"ui.set_speed.0", "ui.set_speed.1", "ui.set_speed.2" ,"ui.set_speed.3", "ui.set_speed.4",
 		"ui.set_speed.5", "ui.set_speed.6", "ui.set_speed.7" ,"ui.set_speed.8", "ui.set_speed.9",
 	};
-	const char *speed_names[] = {
+	static const char *speed_names[] = {
 		"Next", "Previous",
 		"Default Speed", "Set Speed 1", "Set Speed 2", "Set Speed 3", "Set Speed 4",
 		"Set Speed 5", "Set Speed 6", "Set Speed 7", "Set Speed 8", "Set Speed 9"
 	};
-	const char *debug_binds[] = {
+	static const char *debug_binds[] = {
 		"ui.enter_debugger", "ui.plane_debug", "ui.vram_debug", "ui.cram_debug",
 		"ui.compositing_debug", "ui.vdp_debug_mode"
 	};
@@ -633,6 +633,7 @@
 		conf_names = tern_insert_ptr(conf_names, "ui.vgm_log", "Toggle VGM Log");
 		conf_names = tern_insert_ptr(conf_names, "ui.exit", "Show Menu");
 		conf_names = tern_insert_ptr(conf_names, "ui.save_state", "Quick Save");
+		conf_names = tern_insert_ptr(conf_names, "ui.load_state", "Quick Load");
 		conf_names = tern_insert_ptr(conf_names, "ui.set_speed.0", "Set Speed 0");
 		conf_names = tern_insert_ptr(conf_names, "ui.set_speed.1", "Set Speed 1");
 		conf_names = tern_insert_ptr(conf_names, "ui.set_speed.2", "Set Speed 2");
@@ -696,6 +697,7 @@
 	};
 	static const char *emu_control[] = {
 		"ui.save_state",
+		"ui.load_state",
 		"ui.exit",
 		"ui.toggle_fullscreen",
 		"ui.screenshot",