trunk/src/emu/bus/coco/coco_dwsock.c
r0 | r32811 | |
| 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <unistd.h> |
| 4 | #include <fcntl.h> |
| 5 | #include <sys/types.h> |
| 6 | |
| 7 | #include "emu.h" |
| 8 | #include "osdcore.h" |
| 9 | #include "includes/coco.h" |
| 10 | |
| 11 | #include "coco_dwsock.h" |
| 12 | |
| 13 | //************************************************************************** |
| 14 | // DEVICE DEFINITIONS |
| 15 | //************************************************************************** |
| 16 | |
| 17 | const device_type COCO_DWSOCK = &device_creator<beckerport_device>; |
| 18 | |
| 19 | //------------------------------------------------- |
| 20 | // INPUT_PORTS( coco_drivewire ) |
| 21 | //------------------------------------------------- |
| 22 | |
| 23 | INPUT_PORTS_START( coco_drivewire ) |
| 24 | PORT_START(DRIVEWIRE_PORT_TAG) |
| 25 | PORT_CONFNAME( 0xffff, 65504, "Drivewire Server TCP Port") |
| 26 | PORT_CHANGED_MEMBER(DEVICE_SELF, beckerport_device, beckerport_device::drivewire_port_changed, NULL ) |
| 27 | PORT_CONFSETTING( 65500, "65500" ) |
| 28 | PORT_CONFSETTING( 65501, "65501" ) |
| 29 | PORT_CONFSETTING( 65502, "65502" ) |
| 30 | PORT_CONFSETTING( 65503, "65503" ) |
| 31 | PORT_CONFSETTING( 65504, "65504" ) |
| 32 | PORT_CONFSETTING( 65505, "65505" ) |
| 33 | PORT_CONFSETTING( 65506, "65506" ) |
| 34 | PORT_CONFSETTING( 65507, "65507" ) |
| 35 | PORT_CONFSETTING( 65508, "65508" ) |
| 36 | PORT_CONFSETTING( 65509, "65509" ) |
| 37 | INPUT_PORTS_END |
| 38 | |
| 39 | //------------------------------------------------- |
| 40 | // input_ports - device-specific input ports |
| 41 | //------------------------------------------------- |
| 42 | |
| 43 | ioport_constructor beckerport_device::device_input_ports() const |
| 44 | { |
| 45 | return INPUT_PORTS_NAME( coco_drivewire ); |
| 46 | } |
| 47 | |
| 48 | //------------------------------------------------- |
| 49 | // drivewire_port_changed |
| 50 | //------------------------------------------------- |
| 51 | INPUT_CHANGED_MEMBER(beckerport_device::drivewire_port_changed) |
| 52 | { |
| 53 | this->update_port(); |
| 54 | } |
| 55 | |
| 56 | //************************************************************************** |
| 57 | // LIVE DEVICE |
| 58 | //************************************************************************** |
| 59 | |
| 60 | //------------------------------------------------- |
| 61 | // beckerport_device - constructor / destructor |
| 62 | //------------------------------------------------- |
| 63 | |
| 64 | beckerport_device::beckerport_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 65 | : device_t(mconfig, COCO_DWSOCK, "Virtual Becker Port", tag, owner, clock, "coco_dwsock", __FILE__), |
| 66 | m_dwconfigport(*this, DRIVEWIRE_PORT_TAG) |
| 67 | { |
| 68 | m_pSocket = NULL; |
| 69 | m_head = 0; |
| 70 | m_rx_pending = 0; |
| 71 | } |
| 72 | |
| 73 | beckerport_device::~beckerport_device() |
| 74 | { |
| 75 | if (m_pSocket != NULL) |
| 76 | device_stop(); |
| 77 | } |
| 78 | |
| 79 | /*------------------------------------------------- |
| 80 | device_start |
| 81 | -------------------------------------------------*/ |
| 82 | |
| 83 | void beckerport_device::device_start(void) |
| 84 | { |
| 85 | char chAddress[64]; |
| 86 | |
| 87 | /* format address string for opening the port */ |
| 88 | snprintf(chAddress, sizeof(chAddress), "socket.%s:%d", m_hostname, m_dwtcpport); |
| 89 | |
| 90 | fprintf(stderr, "Connecting to Drivewire server on %s:%d... ", m_hostname, m_dwtcpport); |
| 91 | |
| 92 | UINT64 filesize; // unused |
| 93 | file_error filerr = osd_open(chAddress, 0, &m_pSocket, &filesize); |
| 94 | if (filerr != FILERR_NONE) |
| 95 | { |
| 96 | fprintf(stderr, "Error: osd_open returned error %i!\n", (int) filerr); |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | fprintf(stderr, "Connected!\n"); |
| 101 | } |
| 102 | |
| 103 | /*------------------------------------------------- |
| 104 | device_stop |
| 105 | -------------------------------------------------*/ |
| 106 | |
| 107 | void beckerport_device::device_stop(void) |
| 108 | { |
| 109 | if (m_pSocket != NULL) |
| 110 | { |
| 111 | printf("Closing connection to Drivewire server\n"); |
| 112 | osd_close(m_pSocket); |
| 113 | m_pSocket = NULL; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | /*------------------------------------------------- |
| 118 | device_config_complete |
| 119 | -------------------------------------------------*/ |
| 120 | |
| 121 | void beckerport_device::device_config_complete(void) |
| 122 | { |
| 123 | m_hostname = "127.0.0.1"; |
| 124 | m_dwtcpport = 65504; |
| 125 | } |
| 126 | |
| 127 | /*------------------------------------------------- |
| 128 | read |
| 129 | -------------------------------------------------*/ |
| 130 | |
| 131 | READ8_MEMBER(beckerport_device::read) |
| 132 | { |
| 133 | unsigned char data = 0x5a; |
| 134 | |
| 135 | switch (offset) |
| 136 | { |
| 137 | case DWS_STATUS: |
| 138 | if (!m_rx_pending) |
| 139 | { |
| 140 | /* Try to read from dws */ |
| 141 | file_error filerr = osd_read(m_pSocket, m_buf, 0, sizeof(m_buf), &m_rx_pending); |
| 142 | if (filerr != FILERR_NONE && filerr != FILERR_FAILURE) // FILERR_FAILURE means no data available, so don't throw error message |
| 143 | fprintf(stderr, "coco_dwsock.c: beckerport_device::read() socket read operation failed with file_error %i\n", filerr); |
| 144 | else |
| 145 | m_head = 0; |
| 146 | } |
| 147 | //printf("beckerport_device: status read. %i bytes remaining.\n", m_rx_pending); |
| 148 | data = (m_rx_pending > 0) ? 2 : 0; |
| 149 | break; |
| 150 | case DWS_DATA: |
| 151 | if (!m_rx_pending) { |
| 152 | fprintf(stderr, "coco_dwsock.c: beckerport_device::read() buffer underrun\n"); |
| 153 | break; |
| 154 | } |
| 155 | data = m_buf[m_head++]; |
| 156 | m_rx_pending--; |
| 157 | //printf("beckerport_device: data read 1 byte (0x%02x). %i bytes remaining.\n", data&0xff, m_rx_pending); |
| 158 | break; |
| 159 | default: |
| 160 | fprintf(stderr, "%s: read from bad offset %d\n", __FILE__, offset); |
| 161 | } |
| 162 | |
| 163 | return (int)data; |
| 164 | } |
| 165 | |
| 166 | /*------------------------------------------------- |
| 167 | write |
| 168 | -------------------------------------------------*/ |
| 169 | |
| 170 | WRITE8_MEMBER(beckerport_device::write) |
| 171 | { |
| 172 | char d = (char)data; |
| 173 | file_error filerr; |
| 174 | |
| 175 | switch (offset) |
| 176 | { |
| 177 | case DWS_STATUS: |
| 178 | //printf("beckerport_write: error: write (0x%02x) to status register\n", d); |
| 179 | break; |
| 180 | case DWS_DATA: |
| 181 | filerr = osd_write(m_pSocket, &d, 0, 1, NULL); |
| 182 | if (filerr != FILERR_NONE) |
| 183 | fprintf(stderr, "coco_dwsock.c: beckerport_device::write() socket write operation failed with file_error %i\n", filerr); |
| 184 | //printf("beckerport_write: data write one byte (0x%02x)\n", d & 0xff); |
| 185 | break; |
| 186 | default: |
| 187 | fprintf(stderr, "%s: write to bad offset %d\n", __FILE__, offset); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /*------------------------------------------------- |
| 192 | update_port |
| 193 | -------------------------------------------------*/ |
| 194 | |
| 195 | void beckerport_device::update_port(void) |
| 196 | { |
| 197 | device_stop(); |
| 198 | m_dwtcpport = m_dwconfigport->read_safe(65504); |
| 199 | device_start(); |
| 200 | } |
| 201 | |
trunk/src/emu/bus/coco/coco_dwsock.h
r0 | r32811 | |
| 1 | #ifndef _DWSOCK_H_ |
| 2 | #define _DWSOCK_H_ |
| 3 | |
| 4 | #include "emu.h" |
| 5 | #include "osdcore.h" |
| 6 | |
| 7 | //************************************************************************** |
| 8 | // MACROS / CONSTANTS |
| 9 | //************************************************************************** |
| 10 | |
| 11 | #define DRIVEWIRE_PORT_TAG "drivewire_port" |
| 12 | |
| 13 | //************************************************************************** |
| 14 | // INTERFACE CONFIGURATION MACROS |
| 15 | //************************************************************************** |
| 16 | |
| 17 | //************************************************************************** |
| 18 | // TYPE DEFINITIONS |
| 19 | //************************************************************************** |
| 20 | |
| 21 | // ======================> beckerport_device |
| 22 | |
| 23 | class beckerport_device : public device_t |
| 24 | { |
| 25 | public: |
| 26 | beckerport_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 27 | virtual ~beckerport_device(); |
| 28 | |
| 29 | // optional information overrides |
| 30 | virtual ioport_constructor device_input_ports() const; |
| 31 | |
| 32 | virtual void device_start(void); |
| 33 | virtual void device_stop(void); |
| 34 | virtual void device_config_complete(void); |
| 35 | |
| 36 | void update_port(void); |
| 37 | |
| 38 | // driver update handlers |
| 39 | DECLARE_INPUT_CHANGED_MEMBER(drivewire_port_changed); |
| 40 | |
| 41 | virtual DECLARE_READ8_MEMBER(read); |
| 42 | virtual DECLARE_WRITE8_MEMBER(write); |
| 43 | |
| 44 | // types |
| 45 | enum dwsock_ports { |
| 46 | DWS_STATUS, |
| 47 | DWS_DATA |
| 48 | }; |
| 49 | |
| 50 | private: |
| 51 | /* IP hostname */ |
| 52 | const char * m_hostname; |
| 53 | |
| 54 | /* IP port */ |
| 55 | required_ioport m_dwconfigport; |
| 56 | int m_dwtcpport; |
| 57 | |
| 58 | osd_file *m_pSocket; |
| 59 | |
| 60 | unsigned int m_rx_pending; |
| 61 | unsigned int m_head; |
| 62 | char m_buf[0x80]; |
| 63 | }; |
| 64 | |
| 65 | // device type definition |
| 66 | extern const device_type COCO_DWSOCK; |
| 67 | |
| 68 | // device iterator |
| 69 | typedef device_type_iterator<&device_creator<beckerport_device>, beckerport_device> beckerport_device_iterator; |
| 70 | |
| 71 | #endif /* _DWSOCK_H_ */ |
| 72 | |
trunk/src/mess/drivers/coco12.c
r32810 | r32811 | |
29 | 29 | #include "bus/coco/coco_pak.h" |
30 | 30 | #include "bus/coco/coco_fdc.h" |
31 | 31 | #include "bus/coco/coco_multi.h" |
| 32 | #include "bus/coco/coco_dwsock.h" |
32 | 33 | #include "formats/coco_cas.h" |
33 | 34 | |
34 | 35 | //************************************************************************** |
r32810 | r32811 | |
114 | 115 | |
115 | 116 | |
116 | 117 | //------------------------------------------------- |
| 118 | // INPUT_PORTS( coco_beckerport ) |
| 119 | //------------------------------------------------- |
| 120 | |
| 121 | INPUT_PORTS_START( coco_beckerport ) |
| 122 | PORT_START(BECKERPORT_TAG) |
| 123 | PORT_CONFNAME( 0x01, 0x01, "Becker Port" ) |
| 124 | PORT_CONFSETTING( 0x00, DEF_STR( Off )) |
| 125 | PORT_CONFSETTING( 0x01, DEF_STR( On )) |
| 126 | INPUT_PORTS_END |
| 127 | |
| 128 | //------------------------------------------------- |
117 | 129 | // INPUT_PORTS( coco_rtc ) |
118 | 130 | //------------------------------------------------- |
119 | 131 | |
r32810 | r32811 | |
223 | 235 | PORT_INCLUDE( coco_analog_control ) |
224 | 236 | PORT_INCLUDE( coco_cart_autostart ) |
225 | 237 | PORT_INCLUDE( coco_rtc ) |
| 238 | PORT_INCLUDE( coco_beckerport ) |
226 | 239 | INPUT_PORTS_END |
227 | 240 | |
228 | 241 | |
r32810 | r32811 | |
238 | 251 | SLOT_INTERFACE_START( coco_cart ) |
239 | 252 | SLOT_INTERFACE("fdc", COCO_FDC) |
240 | 253 | SLOT_INTERFACE("fdcv11", COCO_FDC_V11) |
| 254 | SLOT_INTERFACE("cc3hdb1", COCO3_HDB1) |
241 | 255 | SLOT_INTERFACE("cp400_fdc", CP400_FDC) |
242 | 256 | SLOT_INTERFACE("rs232", COCO_232) |
243 | 257 | SLOT_INTERFACE("orch90", COCO_ORCH90) |
r32810 | r32811 | |
300 | 314 | MCFG_SAM6883_ADD(SAM_TAG, XTAL_3_579545MHz, MAINCPU_TAG, AS_PROGRAM) |
301 | 315 | MCFG_SAM6883_RES_CALLBACK(READ8(coco12_state, sam_read)) |
302 | 316 | |
| 317 | // Becker Port device |
| 318 | MCFG_DEVICE_ADD(DWSOCK_TAG, COCO_DWSOCK, 0) |
| 319 | |
303 | 320 | MCFG_CASSETTE_ADD("cassette") |
304 | 321 | MCFG_CASSETTE_FORMATS(coco_cassette_formats) |
305 | 322 | MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_MUTED) |
trunk/src/mess/drivers/coco3.c
r32810 | r32811 | |
222 | 222 | PORT_INCLUDE( coco_rat_mouse ) |
223 | 223 | PORT_INCLUDE( coco_lightgun ) |
224 | 224 | PORT_INCLUDE( coco_rtc ) |
| 225 | PORT_INCLUDE( coco_beckerport ) |
225 | 226 | INPUT_PORTS_END |
226 | 227 | |
227 | 228 | static DEVICE_INPUT_DEFAULTS_START( printer ) |
r32810 | r32811 | |
261 | 262 | MCFG_PIA_IRQA_HANDLER(WRITELINE(coco_state, pia1_firq_a)) |
262 | 263 | MCFG_PIA_IRQB_HANDLER(WRITELINE(coco_state, pia1_firq_b)) |
263 | 264 | |
| 265 | // Becker Port device |
| 266 | MCFG_DEVICE_ADD(DWSOCK_TAG, COCO_DWSOCK, 0) |
| 267 | |
264 | 268 | MCFG_CASSETTE_ADD("cassette") |
265 | 269 | MCFG_CASSETTE_FORMATS(coco_cassette_formats) |
266 | 270 | MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_MUTED) |
r32810 | r32811 | |
337 | 341 | MCFG_CPU_PROGRAM_MAP(coco3_mem) |
338 | 342 | MACHINE_CONFIG_END |
339 | 343 | |
| 344 | static MACHINE_CONFIG_DERIVED( coco3dw1, coco3 ) |
| 345 | MCFG_COCO_CARTRIDGE_REMOVE(CARTRIDGE_TAG) |
| 346 | MCFG_COCO_CARTRIDGE_ADD(CARTRIDGE_TAG, coco_cart, "cc3hdb1") |
| 347 | MACHINE_CONFIG_END |
340 | 348 | |
341 | | |
342 | 349 | //************************************************************************** |
343 | 350 | // ROMS |
344 | 351 | //************************************************************************** |
r32810 | r32811 | |
354 | 361 | ROM_END |
355 | 362 | |
356 | 363 | #define rom_coco3h rom_coco3 |
| 364 | #define rom_coco3dw1 rom_coco3 |
357 | 365 | |
358 | | |
359 | | |
360 | 366 | //************************************************************************** |
361 | 367 | // SYSTEM DRIVERS |
362 | 368 | //************************************************************************** |
r32810 | r32811 | |
364 | 370 | COMP( 1986, coco3, coco, 0, coco3, coco3, driver_device, 0, "Tandy Radio Shack", "Color Computer 3 (NTSC)", 0) |
365 | 371 | COMP( 1986, coco3p, coco, 0, coco3p, coco3, driver_device, 0, "Tandy Radio Shack", "Color Computer 3 (PAL)", 0) |
366 | 372 | COMP( 19??, coco3h, coco, 0, coco3h, coco3, driver_device, 0, "Tandy Radio Shack", "Color Computer 3 (NTSC; HD6309)", GAME_UNOFFICIAL) |
| 373 | COMP( 19??, coco3dw1, coco, 0, coco3dw1, coco3, driver_device, 0, "Tandy Radio Shack", "Color Computer 3 (NTSC; HDB-DOS)", GAME_UNOFFICIAL) |
trunk/src/mess/machine/coco.c
r32810 | r32811 | |
89 | 89 | m_cassette(*this, "cassette"), |
90 | 90 | m_rs232(*this, RS232_TAG), |
91 | 91 | m_vhd_0(*this, VHD0_TAG), |
92 | | m_vhd_1(*this, VHD1_TAG) |
| 92 | m_vhd_1(*this, VHD1_TAG), |
| 93 | m_beckerport(*this, DWSOCK_TAG), |
| 94 | m_beckerportconfig(*this, BECKERPORT_TAG) |
93 | 95 | { |
94 | 96 | } |
95 | 97 | |
r32810 | r32811 | |
1016 | 1018 | poll_keyboard(); |
1017 | 1019 | } |
1018 | 1020 | |
1019 | | |
1020 | | |
1021 | 1021 | //------------------------------------------------- |
1022 | 1022 | // poll_hires_joystick |
1023 | 1023 | //------------------------------------------------- |
r32810 | r32811 | |
1159 | 1159 | |
1160 | 1160 | READ8_MEMBER( coco_state::ff40_read ) |
1161 | 1161 | { |
| 1162 | if (offset >= 1 && offset <= 2 && m_beckerportconfig->read_safe(0) == 1) |
| 1163 | { |
| 1164 | return m_beckerport->read(space, offset-1, mem_mask); |
| 1165 | } |
| 1166 | |
1162 | 1167 | return m_cococart->read(space, offset, mem_mask); |
1163 | 1168 | } |
1164 | 1169 | |
r32810 | r32811 | |
1170 | 1175 | |
1171 | 1176 | WRITE8_MEMBER( coco_state::ff40_write ) |
1172 | 1177 | { |
| 1178 | if (offset >= 1 && offset <= 2 && m_beckerportconfig->read_safe(0) == 1) |
| 1179 | { |
| 1180 | return m_beckerport->write(space, offset-1, data, mem_mask); |
| 1181 | } |
| 1182 | |
1173 | 1183 | m_cococart->write(space, offset, data, mem_mask); |
1174 | 1184 | } |
1175 | 1185 | |
r32810 | r32811 | |
1184 | 1194 | m_pia_1->cb1_w(state); |
1185 | 1195 | } |
1186 | 1196 | |
1187 | | |
1188 | | |
1189 | 1197 | /*************************************************************************** |
1190 | 1198 | DISASSEMBLY OVERRIDE (OS9 syscalls) |
1191 | 1199 | ***************************************************************************/ |
trunk/src/mess/includes/coco.h
r32810 | r32811 | |
18 | 18 | #include "machine/6821pia.h" |
19 | 19 | #include "bus/coco/cococart.h" |
20 | 20 | #include "machine/coco_vhd.h" |
| 21 | #include "bus/coco/coco_dwsock.h" |
21 | 22 | #include "machine/ram.h" |
22 | 23 | #include "sound/dac.h" |
23 | 24 | #include "sound/wave.h" |
r32810 | r32811 | |
31 | 32 | INPUT_PORTS_EXTERN( coco_analog_control ); |
32 | 33 | INPUT_PORTS_EXTERN( coco_cart_autostart ); |
33 | 34 | INPUT_PORTS_EXTERN( coco_rtc ); |
| 35 | INPUT_PORTS_EXTERN( coco_beckerport ); |
34 | 36 | |
35 | 37 | SLOT_INTERFACE_EXTERN( coco_cart ); |
36 | 38 | |
r32810 | r32811 | |
48 | 50 | #define DAC_TAG "dac" |
49 | 51 | #define CARTRIDGE_TAG "ext" |
50 | 52 | #define RS232_TAG "rs232" |
| 53 | #define DWSOCK_TAG "dwsock" |
51 | 54 | #define VHD0_TAG "vhd0" |
52 | 55 | #define VHD1_TAG "vhd1" |
53 | 56 | |
r32810 | r32811 | |
55 | 58 | #define CTRL_SEL_TAG "ctrl_sel" |
56 | 59 | #define HIRES_INTF_TAG "hires_intf" |
57 | 60 | #define CART_AUTOSTART_TAG "cart_autostart" |
| 61 | #define BECKERPORT_TAG "beckerport" |
58 | 62 | #define JOYSTICK_RX_TAG "joystick_rx" |
59 | 63 | #define JOYSTICK_RY_TAG "joystick_ry" |
60 | 64 | #define JOYSTICK_LX_TAG "joystick_lx" |
r32810 | r32811 | |
95 | 99 | optional_device<rs232_port_device> m_rs232; |
96 | 100 | optional_device<coco_vhd_image_device> m_vhd_0; |
97 | 101 | optional_device<coco_vhd_image_device> m_vhd_1; |
| 102 | required_device<beckerport_device> m_beckerport; |
| 103 | required_ioport m_beckerportconfig; |
98 | 104 | |
99 | 105 | // driver update handlers |
100 | 106 | DECLARE_INPUT_CHANGED_MEMBER(keyboard_changed); |