summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2017-01-03 20:43:35 -0800
committerMichael Pavone <pavone@retrodev.com>2017-01-03 20:43:35 -0800
commit5a9c697cd66203fa6160f2dfed02a5dad2351eec (patch)
tree6125e121b4241683645e006eff88c6249c69c493 /io.c
parentc562554ca59360448c10c6e3e9444d35dd464e47 (diff)
Increment TH counter on low to high transitions rather than high to low transitions for six button controllers. Fixes Charles MacDonald's SMS six button controller demo
Diffstat (limited to 'io.c')
-rw-r--r--io.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/io.c b/io.c
index ec298cc..312a10a 100644
--- a/io.c
+++ b/io.c
@@ -1298,7 +1298,7 @@ void io_data_write(io_port * port, uint8_t value, uint32_t current_cycle)
if (current_cycle >= port->device.pad.timeout_cycle) {
port->device.pad.th_counter = 0;
}
- if (!(output & TH)) {
+ if ((output & TH)) {
port->device.pad.th_counter++;
}
port->device.pad.timeout_cycle = current_cycle + TH_TIMEOUT;
@@ -1389,9 +1389,9 @@ uint8_t io_data_read(io_port * port, uint32_t current_cycle)
input = port->input[GAMEPAD_TH1];
}
} else {
- if (port->device.pad.th_counter == 3) {
+ if (port->device.pad.th_counter == 2) {
input = port->input[GAMEPAD_TH0] | 0xF;
- } else if(port->device.pad.th_counter == 4) {
+ } else if(port->device.pad.th_counter == 3) {
input = port->input[GAMEPAD_TH0] & 0x30;
} else {
input = port->input[GAMEPAD_TH0] | 0xC;