summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2016-05-01 15:57:43 -0700
committerMichael Pavone <pavone@retrodev.com>2016-05-01 15:57:43 -0700
commit93c128f5e2f6c42934d5fbd7a15417a4b33bd2ca (patch)
tree5585fecc83195abb795e9735e4cb14aba6cf1763 /io.c
parentd2cf54c6a06190f374ede3fc3a378ed8b72051dd (diff)
Allow overriding speed 0. May be useful for people that want to use vsync
Diffstat (limited to 'io.c')
-rw-r--r--io.c19
1 files changed, 12 insertions, 7 deletions
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