changeset 1005:580a806aef6a

Allow overriding speed 0. May be useful for people that want to use vsync
author Michael Pavone <pavone@retrodev.com>
date Sun, 01 May 2016 15:57:43 -0700
parents fc000f245cc8
children 9ab35686a025
files default.cfg io.c
diffstat 2 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/default.cfg	Sun May 01 14:59:40 2016 -0700
+++ b/default.cfg	Sun May 01 15:57:43 2016 -0700
@@ -122,6 +122,7 @@
 	m68k_divider 7
 	max_cycles 3420
 	speeds {
+		0 100
 		1 150
 		2 200
 		3 300
--- a/io.c	Sun May 01 14:59:40 2016 -0700
+++ b/io.c	Sun May 01 15:57:43 2016 -0700
@@ -602,13 +602,10 @@
 	if (cur->el) {
 		process_speeds(cur->straight.next, curstr);
 	} else {
-		int speed_index = atoi(curstr);
-		if (speed_index < 1) {
-			if (!strcmp(curstr, "0")) {
-				warning("Speed index 0 cannot be set to a custom value\n");
-			} else {
-				warning("%s is not a valid speed index", curstr);
-			}
+		char *end;
+		long speed_index = strtol(curstr, &end, 10);
+		if (speed_index < 0 || end == curstr || *end) {
+			warning("%s is not a valid speed index", curstr);
 		} else {
 			if (speed_index >= num_speeds) {
 				speeds = realloc(speeds, sizeof(uint32_t) * (speed_index+1));
@@ -617,6 +614,10 @@
 				}
 			}
 			speeds[speed_index] = atoi(cur->straight.value.ptrval);
+			if (speeds[speed_index] < 1) {
+				warning("%s is not a valid speed percentage, setting speed %d to 100", cur->straight.value.ptrval, speed_index);
+				speeds[speed_index] = 100;
+			}
 		}
 	}
 	process_speeds(cur->left, prefix);
@@ -1059,6 +1060,10 @@
 		}
 		map_bindings(ports, mice[mouse].buttons, MAX_MOUSE_BUTTONS);
 	}
+	//not really related to the intention of this function, but the best place to do this currently
+	if (speeds[0] != 100) {
+		set_speed_percent(genesis, speeds[0]);
+	}
 }
 
 #define TH 0x40