summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-08-14 00:07:21 -0700
committerMichael Pavone <pavone@retrodev.com>2018-08-14 00:07:21 -0700
commit7f914285b17c1b010c5a3f007f13e587126f6f4d (patch)
treec7caf557adee57425f19c5f70356fe79eed45924 /io.c
parent04063013139898718b3775dc10123a400b2c9173 (diff)
Added J-Cart support
Diffstat (limited to 'io.c')
-rw-r--r--io.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/io.c b/io.c
index f6b7cff..f306f06 100644
--- a/io.c
+++ b/io.c
@@ -114,15 +114,29 @@ static io_port *find_keyboard(sega_io *io)
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 @@ void io_gamepad_up(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_up(port, button);
}
}