changeset 1144:be3df2d8530a

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
author Michael Pavone <pavone@retrodev.com>
date Tue, 03 Jan 2017 20:43:35 -0800
parents d4d770cfbc62
children 494234e7e88f
files io.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/io.c	Tue Jan 03 20:42:15 2017 -0800
+++ b/io.c	Tue Jan 03 20:43:35 2017 -0800
@@ -1298,7 +1298,7 @@
 			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 @@
 				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;