diff io.c @ 1610:c206a422d466

Added J-Cart support
author Michael Pavone <pavone@retrodev.com>
date Tue, 14 Aug 2018 00:07:21 -0700
parents 360d5bab199f
children d6c403135e64
line wrap: on
line diff
--- a/io.c	Fri Aug 10 19:10:20 2018 -0700
+++ b/io.c	Tue Aug 14 00:07:21 2018 -0700
@@ -114,15 +114,29 @@
 	return NULL;
 }
 
+void io_port_gamepad_down(io_port *port, uint8_t button)
+{
+	gp_button_def *def = button_defs + button;
+	port->input[def->states[0]] |= def->value;
+	if (def->states[1] != GAMEPAD_NONE) {
+		port->input[def->states[1]] |= def->value;
+	}
+}
+
+void io_port_gamepad_up(io_port *port, uint8_t button)
+{
+	gp_button_def *def = button_defs + button;
+	port->input[def->states[0]] &= ~def->value;
+	if (def->states[1] != GAMEPAD_NONE) {
+		port->input[def->states[1]] &= ~def->value;
+	}
+}
+
 void io_gamepad_down(sega_io *io, uint8_t gamepad_num, uint8_t button)
 {
 	io_port *port = find_gamepad(io, gamepad_num);
 	if (port) {
-		gp_button_def *def = button_defs + button;
-		port->input[def->states[0]] |= def->value;
-		if (def->states[1] != GAMEPAD_NONE) {
-			port->input[def->states[1]] |= def->value;
-		}
+		io_port_gamepad_down(port, button);
 	}
 }
 
@@ -130,11 +144,7 @@
 {
 	io_port *port = find_gamepad(io, gamepad_num);
 	if (port) {
-		gp_button_def *def = button_defs + button;
-		port->input[def->states[0]] &= ~def->value;
-		if (def->states[1] != GAMEPAD_NONE) {
-			port->input[def->states[1]] &= ~def->value;
-		}
+		io_port_gamepad_up(port, button);
 	}
 }