comparison io.c @ 1026:7267bc1ab547

Fix bug in 68K movep.l when the destination is a register mapped to a host register
author Michael Pavone <pavone@retrodev.com>
date Tue, 10 May 2016 08:59:17 -0700
parents 580a806aef6a
children 56b1748a8473
comparison
equal deleted inserted replaced
1025:01a91df5b87c 1026:7267bc1ab547
24 24
25 const char * device_type_names[] = { 25 const char * device_type_names[] = {
26 "3-button gamepad", 26 "3-button gamepad",
27 "6-button gamepad", 27 "6-button gamepad",
28 "Mega Mouse", 28 "Mega Mouse",
29 "Saturn Keyboard",
29 "Menacer", 30 "Menacer",
30 "Justifier", 31 "Justifier",
31 "Sega multi-tap", 32 "Sega multi-tap",
32 "EA 4-way Play cable A", 33 "EA 4-way Play cable A",
33 "EA 4-way Play cable B", 34 "EA 4-way Play cable B",
105 #define DEFAULT_JOYBUTTON_ALLOC 12 106 #define DEFAULT_JOYBUTTON_ALLOC 12
106 107
107 static keybinding * bindings[0x10000]; 108 static keybinding * bindings[0x10000];
108 static joystick joysticks[MAX_JOYSTICKS]; 109 static joystick joysticks[MAX_JOYSTICKS];
109 static mousebinding mice[MAX_MICE]; 110 static mousebinding mice[MAX_MICE];
111 static io_port *keyboard_port;
110 const uint8_t dpadbits[] = {RENDER_DPAD_UP, RENDER_DPAD_DOWN, RENDER_DPAD_LEFT, RENDER_DPAD_RIGHT}; 112 const uint8_t dpadbits[] = {RENDER_DPAD_UP, RENDER_DPAD_DOWN, RENDER_DPAD_LEFT, RENDER_DPAD_RIGHT};
111 113
112 void bind_key(int keycode, uint8_t bind_type, uint8_t subtype_a, uint8_t subtype_b, uint8_t value) 114 void bind_key(int keycode, uint8_t bind_type, uint8_t subtype_a, uint8_t subtype_b, uint8_t value)
113 { 115 {
114 int bucket = keycode >> 15 & 0xFFFF; 116 int bucket = keycode >> 15 & 0xFFFF;
252 binding->port->input[0] |= binding->value; 254 binding->port->input[0] |= binding->value;
253 } 255 }
254 } 256 }
255 } 257 }
256 258
257 void handle_keydown(int keycode) 259 void store_key_event(uint16_t code)
260 {
261 if (keyboard_port) {
262 keyboard_port->device.keyboard.write_pos = (keyboard_port->device.keyboard.write_pos + 1) & 7;
263 if (keyboard_port->device.keyboard.write_pos == keyboard_port->device.keyboard.read_pos) {
264 //we've wrapped around to the read position, drop this event
265 keyboard_port->device.keyboard.write_pos = (keyboard_port->device.keyboard.write_pos - 1) & 7;
266 return;
267 }
268 keyboard_port->device.keyboard.events[keyboard_port->device.keyboard.write_pos] = code;
269 }
270 }
271
272 void handle_keydown(int keycode, char scancode)
258 { 273 {
259 int bucket = keycode >> 15 & 0xFFFF; 274 int bucket = keycode >> 15 & 0xFFFF;
260 if (!bindings[bucket]) { 275 if (!bindings[bucket]) {
261 return; 276 return;
262 } 277 }
263 int idx = keycode & 0x7FFF; 278 int idx = keycode & 0x7FFF;
264 keybinding * binding = bindings[bucket] + idx; 279 keybinding * binding = bindings[bucket] + idx;
265 handle_binding_down(binding); 280 handle_binding_down(binding);
281 store_key_event(scancode);
266 } 282 }
267 283
268 void handle_joydown(int joystick, int button) 284 void handle_joydown(int joystick, int button)
269 { 285 {
270 if (joystick >= MAX_JOYSTICKS || button >= joysticks[joystick].num_buttons) { 286 if (joystick >= MAX_JOYSTICKS || button >= joysticks[joystick].num_buttons) {
386 } 402 }
387 break; 403 break;
388 } 404 }
389 } 405 }
390 406
391 void handle_keyup(int keycode) 407 void handle_keyup(int keycode, char scancode)
392 { 408 {
393 int bucket = keycode >> 15 & 0xFFFF; 409 int bucket = keycode >> 15 & 0xFFFF;
394 if (!bindings[bucket]) { 410 if (!bindings[bucket]) {
395 return; 411 return;
396 } 412 }
397 int idx = keycode & 0x7FFF; 413 int idx = keycode & 0x7FFF;
398 keybinding * binding = bindings[bucket] + idx; 414 keybinding * binding = bindings[bucket] + idx;
399 handle_binding_up(binding); 415 handle_binding_up(binding);
416 store_key_event(0x100 | scancode);
400 } 417 }
401 418
402 void handle_joyup(int joystick, int button) 419 void handle_joyup(int joystick, int button)
403 { 420 {
404 if (joystick >= MAX_JOYSTICKS || button >= joysticks[joystick].num_buttons) { 421 if (joystick >= MAX_JOYSTICKS || button >= joysticks[joystick].num_buttons) {
1058 } 1075 }
1059 } 1076 }
1060 } 1077 }
1061 map_bindings(ports, mice[mouse].buttons, MAX_MOUSE_BUTTONS); 1078 map_bindings(ports, mice[mouse].buttons, MAX_MOUSE_BUTTONS);
1062 } 1079 }
1080 keyboard_port = NULL;
1081 for (int i = 0; i < 3; i++)
1082 {
1083 if (ports[i].device_type == IO_SATURN_KEYBOARD) {
1084 keyboard_port = ports + i;
1085 break;
1086 }
1087 }
1063 //not really related to the intention of this function, but the best place to do this currently 1088 //not really related to the intention of this function, but the best place to do this currently
1064 if (speeds[0] != 100) { 1089 if (speeds[0] != 100) {
1065 set_speed_percent(genesis, speeds[0]); 1090 set_speed_percent(genesis, speeds[0]);
1066 } 1091 }
1067 } 1092 }