From 93c128f5e2f6c42934d5fbd7a15417a4b33bd2ca Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 1 May 2016 15:57:43 -0700 Subject: Allow overriding speed 0. May be useful for people that want to use vsync --- io.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index b7e39b9..2002854 100644 --- a/io.c +++ b/io.c @@ -602,13 +602,10 @@ void process_speeds(tern_node * cur, char * prefix) 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 @@ void process_speeds(tern_node * cur, char * prefix) } } 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 @@ void map_all_bindings(io_port *ports) } 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 -- cgit v1.2.3