summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2016-05-10 08:59:17 -0700
committerMichael Pavone <pavone@retrodev.com>2016-05-10 08:59:17 -0700
commitbfc49a8c524c098f5df0244e7329dfe5d6702acb (patch)
treea01d5ca874220036d8e653888945bf68d41b6107 /io.c
parentbbd9deb6bbdeb54c6ce90668a11ea37af6bf27f1 (diff)
Fix bug in 68K movep.l when the destination is a register mapped to a host register
Diffstat (limited to 'io.c')
-rw-r--r--io.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/io.c b/io.c
index 2002854..0e562a1 100644
--- a/io.c
+++ b/io.c
@@ -26,6 +26,7 @@ const char * device_type_names[] = {
"3-button gamepad",
"6-button gamepad",
"Mega Mouse",
+ "Saturn Keyboard",
"Menacer",
"Justifier",
"Sega multi-tap",
@@ -107,6 +108,7 @@ typedef struct {
static keybinding * bindings[0x10000];
static joystick joysticks[MAX_JOYSTICKS];
static mousebinding mice[MAX_MICE];
+static io_port *keyboard_port;
const uint8_t dpadbits[] = {RENDER_DPAD_UP, RENDER_DPAD_DOWN, RENDER_DPAD_LEFT, RENDER_DPAD_RIGHT};
void bind_key(int keycode, uint8_t bind_type, uint8_t subtype_a, uint8_t subtype_b, uint8_t value)
@@ -254,7 +256,20 @@ void handle_binding_down(keybinding * binding)
}
}
-void handle_keydown(int keycode)
+void store_key_event(uint16_t code)
+{
+ if (keyboard_port) {
+ keyboard_port->device.keyboard.write_pos = (keyboard_port->device.keyboard.write_pos + 1) & 7;
+ if (keyboard_port->device.keyboard.write_pos == keyboard_port->device.keyboard.read_pos) {
+ //we've wrapped around to the read position, drop this event
+ keyboard_port->device.keyboard.write_pos = (keyboard_port->device.keyboard.write_pos - 1) & 7;
+ return;
+ }
+ keyboard_port->device.keyboard.events[keyboard_port->device.keyboard.write_pos] = code;
+ }
+}
+
+void handle_keydown(int keycode, char scancode)
{
int bucket = keycode >> 15 & 0xFFFF;
if (!bindings[bucket]) {
@@ -263,6 +278,7 @@ void handle_keydown(int keycode)
int idx = keycode & 0x7FFF;
keybinding * binding = bindings[bucket] + idx;
handle_binding_down(binding);
+ store_key_event(scancode);
}
void handle_joydown(int joystick, int button)
@@ -388,7 +404,7 @@ void handle_binding_up(keybinding * binding)
}
}
-void handle_keyup(int keycode)
+void handle_keyup(int keycode, char scancode)
{
int bucket = keycode >> 15 & 0xFFFF;
if (!bindings[bucket]) {
@@ -397,6 +413,7 @@ void handle_keyup(int keycode)
int idx = keycode & 0x7FFF;
keybinding * binding = bindings[bucket] + idx;
handle_binding_up(binding);
+ store_key_event(0x100 | scancode);
}
void handle_joyup(int joystick, int button)
@@ -1060,6 +1077,14 @@ void map_all_bindings(io_port *ports)
}
map_bindings(ports, mice[mouse].buttons, MAX_MOUSE_BUTTONS);
}
+ keyboard_port = NULL;
+ for (int i = 0; i < 3; i++)
+ {
+ if (ports[i].device_type == IO_SATURN_KEYBOARD) {
+ keyboard_port = ports + i;
+ break;
+ }
+ }
//not really related to the intention of this function, but the best place to do this currently
if (speeds[0] != 100) {
set_speed_percent(genesis, speeds[0]);