From 5a9c697cd66203fa6160f2dfed02a5dad2351eec Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Tue, 3 Jan 2017 20:43:35 -0800 Subject: 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 --- io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'io.c') 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; -- cgit v1.2.3