comparison io.h @ 645:d77c79cec800

Initial support for configurable IO, custom IO and sega transfer board emulation
author Michael Pavone <pavone@retrodev.com>
date Wed, 03 Dec 2014 09:32:32 -0800
parents 140af5509ce7
children 252dfd29831d
comparison
equal deleted inserted replaced
644:2d7e84ae818c 645:d77c79cec800
1 /* 1 /*
2 Copyright 2013 Michael Pavone 2 Copyright 2013 Michael Pavone
3 This file is part of BlastEm. 3 This file is part of BlastEm.
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. 4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
5 */ 5 */
6 #ifndef IO_H_ 6 #ifndef IO_H_
7 #define IO_H_ 7 #define IO_H_
8 #include <stdint.h> 8 #include <stdint.h>
9 #include "tern.h"
10
11 enum {
12 IO_GAMEPAD3,
13 IO_GAMEPAD6,
14 IO_MOUSE,
15 IO_MENACER,
16 IO_JUSTIFIER,
17 IO_SEGA_MULTI,
18 IO_EA_MULTI_A,
19 IO_EA_MULTI_B,
20 IO_SEGA_PARALLEL,
21 IO_GENERIC,
22 IO_NONE
23 };
9 24
10 typedef struct { 25 typedef struct {
11 uint32_t th_counter; 26 union {
12 uint32_t timeout_cycle; 27 struct {
13 uint8_t output; 28 uint32_t timeout_cycle;
14 uint8_t control; 29 uint16_t th_counter;
15 uint8_t input[3]; 30 uint16_t gamepad_num;
31 } pad;
32 struct {
33 int data_fd;
34 int listen_fd;
35 } stream;
36 } device;
37 uint8_t output;
38 uint8_t control;
39 uint8_t input[3];
40 uint8_t device_type;
16 } io_port; 41 } io_port;
17 42
18 #define GAMEPAD_TH0 0 43 #define GAMEPAD_TH0 0
19 #define GAMEPAD_TH1 1 44 #define GAMEPAD_TH1 1
20 #define GAMEPAD_EXTRA 2 45 #define GAMEPAD_EXTRA 2
21 #define GAMEPAD_NONE 0xF 46 #define GAMEPAD_NONE 0xF
22 47
23 void set_keybindings(); 48 #define IO_TH0 0
49 #define IO_TH1 1
50 #define IO_STATE 2
51
52 enum {
53 IO_WRITE_PENDING,
54 IO_WRITTEN,
55 IO_READ_PENDING,
56 IO_READ
57 };
58
59 void set_keybindings(io_port *ports);
60 void setup_io_devices(tern_node * config, io_port * ports);
24 void io_adjust_cycles(io_port * pad, uint32_t current_cycle, uint32_t deduction); 61 void io_adjust_cycles(io_port * pad, uint32_t current_cycle, uint32_t deduction);
25 void io_data_write(io_port * pad, uint8_t value, uint32_t current_cycle); 62 void io_data_write(io_port * pad, uint8_t value, uint32_t current_cycle);
26 uint8_t io_data_read(io_port * pad, uint32_t current_cycle); 63 uint8_t io_data_read(io_port * pad, uint32_t current_cycle);
27 void handle_keydown(int keycode); 64 void handle_keydown(int keycode);
28 void handle_keyup(int keycode); 65 void handle_keyup(int keycode);