annotate io.h @ 2299:a1c9edf44c7e

Fix a place I missed a problem from the SDL2 upgrade
author Michael Pavone <pavone@retrodev.com>
date Thu, 09 Mar 2023 22:59:29 -0800
parents 93918a6a8ab7
children 1978bd770023
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
467
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 421
diff changeset
1 /*
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 421
diff changeset
2 Copyright 2013 Michael Pavone
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
3 This file is part of BlastEm.
467
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 421
diff changeset
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.
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 421
diff changeset
5 */
421
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 #ifndef IO_H_
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 #define IO_H_
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 #include <stdint.h>
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
9 #include "tern.h"
913
a5a51465f8b0 Allow IO device config to be overriden by ROM DB
Michael Pavone <pavone@retrodev.com>
parents: 912
diff changeset
10 #include "romdb.h"
1427
4e5797b3935a WIP - New savestate format
Michael Pavone <pavone@retrodev.com>
parents: 1348
diff changeset
11 #include "serialize.h"
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
12
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
13 enum {
1650
d6c403135e64 Re-order IO device type enum so "None" is selected when no device is specified for a port
Michael Pavone <pavone@retrodev.com>
parents: 1610
diff changeset
14 IO_NONE,
1146
3e24de8d8073 Add support for SMS controllers
Michael Pavone <pavone@retrodev.com>
parents: 1116
diff changeset
15 IO_GAMEPAD2,
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
16 IO_GAMEPAD3,
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
17 IO_GAMEPAD6,
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
18 IO_MOUSE,
1026
7267bc1ab547 Fix bug in 68K movep.l when the destination is a register mapped to a host register
Michael Pavone <pavone@retrodev.com>
parents: 971
diff changeset
19 IO_SATURN_KEYBOARD,
1232
c0120977eeea Initial implementation of the XBAND "Eric Smith" keyboard
Michael Pavone <pavone@retrodev.com>
parents: 1215
diff changeset
20 IO_XBAND_KEYBOARD,
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
21 IO_MENACER,
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
22 IO_JUSTIFIER,
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
23 IO_SEGA_MULTI,
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
24 IO_EA_MULTI_A,
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
25 IO_EA_MULTI_B,
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
26 IO_SEGA_PARALLEL,
2025
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
27 IO_GENERIC,
2027
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
28 IO_GENERIC_SERIAL,
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
29 IO_HEARTBEAT_TRAINER
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
30 };
421
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
31
2235
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
32 typedef struct io_port io_port;
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
33 struct io_port {
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
34 union {
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
35 struct {
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
36 uint32_t timeout_cycle;
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
37 uint16_t th_counter;
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
38 uint16_t gamepad_num;
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
39 } pad;
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
40 struct {
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
41 int data_fd;
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
42 int listen_fd;
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
43 } stream;
897
b9564fb88a5a WIP support for mega mouse
Michael Pavone <pavone@retrodev.com>
parents: 884
diff changeset
44 struct {
912
599e2861f484 Rough emulation of mouse response delays when TR is toggled. Latch current mouse value rather than delta. Some other IO cleanup/fixes
Michael Pavone <pavone@retrodev.com>
parents: 907
diff changeset
45 uint32_t ready_cycle;
897
b9564fb88a5a WIP support for mega mouse
Michael Pavone <pavone@retrodev.com>
parents: 884
diff changeset
46 uint16_t last_read_x;
b9564fb88a5a WIP support for mega mouse
Michael Pavone <pavone@retrodev.com>
parents: 884
diff changeset
47 uint16_t last_read_y;
b9564fb88a5a WIP support for mega mouse
Michael Pavone <pavone@retrodev.com>
parents: 884
diff changeset
48 uint16_t cur_x;
b9564fb88a5a WIP support for mega mouse
Michael Pavone <pavone@retrodev.com>
parents: 884
diff changeset
49 uint16_t cur_y;
912
599e2861f484 Rough emulation of mouse response delays when TR is toggled. Latch current mouse value rather than delta. Some other IO cleanup/fixes
Michael Pavone <pavone@retrodev.com>
parents: 907
diff changeset
50 uint16_t latched_x;
599e2861f484 Rough emulation of mouse response delays when TR is toggled. Latch current mouse value rather than delta. Some other IO cleanup/fixes
Michael Pavone <pavone@retrodev.com>
parents: 907
diff changeset
51 uint16_t latched_y;
897
b9564fb88a5a WIP support for mega mouse
Michael Pavone <pavone@retrodev.com>
parents: 884
diff changeset
52 uint8_t tr_counter;
907
b5d35222047e Mega mouse support is mostly done
Michael Pavone <pavone@retrodev.com>
parents: 897
diff changeset
53 uint8_t mouse_num;
897
b9564fb88a5a WIP support for mega mouse
Michael Pavone <pavone@retrodev.com>
parents: 884
diff changeset
54 } mouse;
1026
7267bc1ab547 Fix bug in 68K movep.l when the destination is a register mapped to a host register
Michael Pavone <pavone@retrodev.com>
parents: 971
diff changeset
55 struct {
7267bc1ab547 Fix bug in 68K movep.l when the destination is a register mapped to a host register
Michael Pavone <pavone@retrodev.com>
parents: 971
diff changeset
56 uint16_t events[8];
7267bc1ab547 Fix bug in 68K movep.l when the destination is a register mapped to a host register
Michael Pavone <pavone@retrodev.com>
parents: 971
diff changeset
57 uint8_t read_pos;
7267bc1ab547 Fix bug in 68K movep.l when the destination is a register mapped to a host register
Michael Pavone <pavone@retrodev.com>
parents: 971
diff changeset
58 uint8_t write_pos;
1028
56b1748a8473 Initial stab at Saturn keyboard support
Michael Pavone <pavone@retrodev.com>
parents: 1026
diff changeset
59 uint8_t tr_counter;
1232
c0120977eeea Initial implementation of the XBAND "Eric Smith" keyboard
Michael Pavone <pavone@retrodev.com>
parents: 1215
diff changeset
60 uint8_t mode;
c0120977eeea Initial implementation of the XBAND "Eric Smith" keyboard
Michael Pavone <pavone@retrodev.com>
parents: 1215
diff changeset
61 uint8_t cmd;
1026
7267bc1ab547 Fix bug in 68K movep.l when the destination is a register mapped to a host register
Michael Pavone <pavone@retrodev.com>
parents: 971
diff changeset
62 } keyboard;
2027
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
63 struct {
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
64 uint8_t *nv_memory;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
65 uint8_t *cur_buffer;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
66 uint64_t rtc_base_timestamp;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
67 uint8_t rtc_base[5];
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
68 uint8_t bpm;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
69 uint8_t cadence;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
70 uint8_t buttons;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
71 uint8_t nv_page_size;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
72 uint8_t nv_pages;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
73 uint8_t param;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
74 uint8_t state;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
75 uint8_t status;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
76 uint8_t device_num;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
77 uint8_t cmd;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
78 uint8_t remaining_bytes;
0f54a898db03 Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents: 2025
diff changeset
79 } heartbeat_trainer;
2235
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
80 struct {
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
81 io_port *ports;
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
82 uint32_t ready_cycle;
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
83 uint8_t tr_counter;
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
84 uint8_t tap_num;
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
85 uint8_t device_ids[4];
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
86 uint8_t data[4];
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
87 uint8_t cur_port;
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
88 uint8_t port_start;
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
89 uint8_t reset_state;
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
90 } multitap;
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
91 } device;
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
92 uint8_t output;
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
93 uint8_t control;
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
94 uint8_t input[3];
1348
040c5600e2d9 Implemented slow rise time of IO pins set as inputs, but not driven by device. Fixes input in Decap Attack and possibly other games with buggy controller code
Michael Pavone <pavone@retrodev.com>
parents: 1254
diff changeset
95 uint32_t slow_rise_start[8];
2025
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
96 uint32_t serial_cycle;
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
97 uint32_t serial_divider;
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
98 uint32_t last_poll_cycle;
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
99 uint32_t transmit_end;
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
100 uint32_t receive_end;
1215
cf69a179aeaf Basic implementation of serial IO registers, but without actual serial IO support. Needed to run a certain software check cartridge that is floating around.
Michael Pavone <pavone@retrodev.com>
parents: 1207
diff changeset
101 uint8_t serial_out;
2025
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
102 uint8_t serial_transmitting;
1215
cf69a179aeaf Basic implementation of serial IO registers, but without actual serial IO support. Needed to run a certain software check cartridge that is floating around.
Michael Pavone <pavone@retrodev.com>
parents: 1207
diff changeset
103 uint8_t serial_in;
2025
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
104 uint8_t serial_receiving;
1215
cf69a179aeaf Basic implementation of serial IO registers, but without actual serial IO support. Needed to run a certain software check cartridge that is floating around.
Michael Pavone <pavone@retrodev.com>
parents: 1207
diff changeset
105 uint8_t serial_ctrl;
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
106 uint8_t device_type;
2235
93918a6a8ab7 Initial support for Sega multi-tap
Michael Pavone <pavone@retrodev.com>
parents: 2027
diff changeset
107 };
421
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
108
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents: 1028
diff changeset
109 typedef struct {
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents: 1028
diff changeset
110 io_port ports[3];
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents: 1028
diff changeset
111 } sega_io;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents: 1028
diff changeset
112
1583
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
113 //pseudo gamepad for buttons on main console unit
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
114 #define GAMEPAD_MAIN_UNIT 255
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
115
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
116 enum {
1583
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
117 BUTTON_INVALID,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
118 DPAD_UP,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
119 DPAD_DOWN,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
120 DPAD_LEFT,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
121 DPAD_RIGHT,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
122 BUTTON_A,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
123 BUTTON_B,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
124 BUTTON_C,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
125 BUTTON_START,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
126 BUTTON_X,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
127 BUTTON_Y,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
128 BUTTON_Z,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
129 BUTTON_MODE,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
130 NUM_GAMEPAD_BUTTONS
645
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
131 };
d77c79cec800 Initial support for configurable IO, custom IO and sega transfer board emulation
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
132
1583
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
133 enum {
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
134 MAIN_UNIT_PAUSE
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
135 };
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
136
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
137 enum {
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
138 MOUSE_LEFT = 1,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
139 MOUSE_RIGHT = 2,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
140 MOUSE_MIDDLE = 4,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
141 MOUSE_START = 8,
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
142 PSEUDO_BUTTON_MOTION=0xFF
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
143 };
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
144
1116
fe8c79f82c22 More cleanup in preparation for SMS/Mark III support
Michael Pavone <pavone@retrodev.com>
parents: 1111
diff changeset
145 void setup_io_devices(tern_node * config, rom_info *rom, sega_io *io);
421
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
146 void io_adjust_cycles(io_port * pad, uint32_t current_cycle, uint32_t deduction);
2025
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
147 void io_run(io_port *port, uint32_t current_cycle);
1348
040c5600e2d9 Implemented slow rise time of IO pins set as inputs, but not driven by device. Fixes input in Decap Attack and possibly other games with buggy controller code
Michael Pavone <pavone@retrodev.com>
parents: 1254
diff changeset
148 void io_control_write(io_port *port, uint8_t value, uint32_t current_cycle);
421
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
149 void io_data_write(io_port * pad, uint8_t value, uint32_t current_cycle);
2025
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
150 void io_tx_write(io_port *port, uint8_t value, uint32_t current_cycle);
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
151 void io_sctrl_write(io_port *port, uint8_t value, uint32_t current_cycle);
421
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
152 uint8_t io_data_read(io_port * pad, uint32_t current_cycle);
2025
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
153 uint8_t io_rx_read(io_port * port, uint32_t current_cycle);
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
154 uint8_t io_sctrl_read(io_port *port, uint32_t current_cycle);
e7a516f08cec Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents: 1650
diff changeset
155 uint32_t io_next_interrupt(io_port *port, uint32_t current_cycle);
1427
4e5797b3935a WIP - New savestate format
Michael Pavone <pavone@retrodev.com>
parents: 1348
diff changeset
156 void io_serialize(io_port *port, serialize_buffer *buf);
4e5797b3935a WIP - New savestate format
Michael Pavone <pavone@retrodev.com>
parents: 1348
diff changeset
157 void io_deserialize(deserialize_buffer *buf, void *vport);
1583
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
158
1610
c206a422d466 Added J-Cart support
Michael Pavone <pavone@retrodev.com>
parents: 1583
diff changeset
159 void io_port_gamepad_down(io_port *port, uint8_t button);
c206a422d466 Added J-Cart support
Michael Pavone <pavone@retrodev.com>
parents: 1583
diff changeset
160 void io_port_gamepad_up(io_port *port, uint8_t button);
1583
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
161 void io_gamepad_down(sega_io *io, uint8_t gamepad_num, uint8_t button);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
162 void io_gamepad_up(sega_io *io, uint8_t gamepad_num, uint8_t button);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
163 void io_mouse_down(sega_io *io, uint8_t mouse_num, uint8_t button);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
164 void io_mouse_up(sega_io *io, uint8_t mouse_num, uint8_t button);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
165 void io_mouse_motion_absolute(sega_io *io, uint8_t mouse_num, uint16_t x, uint16_t y);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
166 void io_mouse_motion_relative(sega_io *io, uint8_t mouse_num, int32_t x, int32_t y);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
167 void io_keyboard_down(sega_io *io, uint8_t scancode);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
168 void io_keyboard_up(sega_io *io, uint8_t scancode);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1576
diff changeset
169 uint8_t io_has_keyboard(sega_io *io);
421
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
170
1501
31a2997b745e Added RAM init and IO port config to system settings menu
Michael Pavone <pavone@retrodev.com>
parents: 1427
diff changeset
171 extern const char * device_type_names[];
31a2997b745e Added RAM init and IO port config to system settings menu
Michael Pavone <pavone@retrodev.com>
parents: 1427
diff changeset
172
421
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
173 #endif //IO_H_
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
174