src/mess/machine/cbmserial.c
| r6676 | r6677 | |
| 1 | | /********************************************************************** |
| 2 | | |
| 3 | | Commodore Serial Bus emulation |
| 4 | | |
| 5 | | Copyright MESS Team. |
| 6 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | | |
| 8 | | **********************************************************************/ |
| 9 | | |
| 10 | | /* |
| 11 | | |
| 12 | | C64 SERIAL BUS |
| 13 | | |
| 14 | | |
| 15 | | Serial Bus Pinouts |
| 16 | | |
| 17 | | |
| 18 | | Pin Name Description |
| 19 | | 1 SRQ Serial Service Request In |
| 20 | | 2 GND Ground |
| 21 | | 3 ATN Serial Attention In/Out |
| 22 | | 4 CLK Serial Clock In/Out |
| 23 | | 5 DATA Serial Data In/Out |
| 24 | | 6 RESET Serial Reset |
| 25 | | |
| 26 | | All signals are active low. |
| 27 | | |
| 28 | | |
| 29 | | SRQ: Serial Service Request In |
| 30 | | |
| 31 | | This signal is not used on the C64. On C128 it is replaced with Fast Serial |
| 32 | | Clock for the 1571 disk drive. |
| 33 | | |
| 34 | | |
| 35 | | ATN: Serial Attention In/Out |
| 36 | | |
| 37 | | Sending any byte with the ATN line low (sending under attention) causes it |
| 38 | | to be interpreted as a Bus Command for peripherals on the serial bus. |
| 39 | | |
| 40 | | When the C64 brings this signal LOW, all other devices start listening for |
| 41 | | it to transmit an address. The device addressed must respond in a preset |
| 42 | | period of time; otherwise, the C64 will assume that the device addressed is |
| 43 | | not on the bus, and will return an error in the STATUS word. |
| 44 | | |
| 45 | | Usually, the address byte will be followed by one to two commands for the |
| 46 | | device addressed, meaning the secondary address and channel on the peripheral. |
| 47 | | Such a command can be one of the following: |
| 48 | | |
| 49 | | 20 |
| 50 | | 40 |
| 51 | | 60 |
| 52 | | E0 |
| 53 | | F0 |
| 54 | | |
| 55 | | |
| 56 | | CLK: Serial Clock In/Out |
| 57 | | |
| 58 | | This signal is for timing the data sent on the serial bus. This signal is |
| 59 | | always generated by the active TALKER. RISING EDGE OF THE CLOCK means data |
| 60 | | bit is valid. |
| 61 | | |
| 62 | | |
| 63 | | DATA: Serial Data In/Out |
| 64 | | |
| 65 | | Data on the serial bus is transmitted bit by bit at a time on this line. |
| 66 | | |
| 67 | | |
| 68 | | RESET: Serial Reset |
| 69 | | |
| 70 | | You may disconnect this line to save your disk drive. The easiest way is to |
| 71 | | do that on the cable, thus avoiding any modifications on your peripherals. |
| 72 | | |
| 73 | | |
| 74 | | |
| 75 | | Serial Bus Timing |
| 76 | | |
| 77 | | ___ |
| 78 | | CLK |____|~~~~| Ts Bit Set-up time |
| 79 | | : Ts : Tv : Tv Bit Valid time |
| 80 | | |
| 81 | | |
| 82 | | |
| 83 | | |<--------- Byte sent under attention (to devices) ------------>| |
| 84 | | |
| 85 | | ___ ____ _____ _____ |
| 86 | | ATN |________________________________________________________| |
| 87 | | : : |
| 88 | | ___ ______ ________ ___ ___ ___ ___ ___ ___ ___ ___ : |
| 89 | | CLK : |_____| |_| |_| |_| |_| |_| |_| |_| |_| |______________ _____ |
| 90 | | : : : : : |
| 91 | | : Tat : :Th: Tne : : Tf : Tr : |
| 92 | | ____ ________ : : :___________________________________:____: |
| 93 | | DATA ___|\\\\\\\\\\__:__| |__||__||__||__||__||__||__||__| |_________ _____ |
| 94 | | : 0 1 2 3 4 5 6 7 : |
| 95 | | : LSB MSB : |
| 96 | | : : : |
| 97 | | : : Data Valid Listener: Data Accepted |
| 98 | | : Listener READY-FOR-DATA |
| 99 | | |
| 100 | | |
| 101 | | |
| 102 | | |
| 103 | | END-OR-IDENTIFY HANDSHAKE (LAST BYTE IN MESSAGE) |
| 104 | | ___ _______________________________________________________________________ |
| 105 | | ATN |
| 106 | | ___ ___ ___ ________________ ___ ___ ___ ___ ___ ___ ___ ___ __ |
| 107 | | CLK _| |_| |______| |_| |_| |_| |_| |_| |_| |_| |_| |_______|_ |
| 108 | | : : : : : |
| 109 | | :Tf:Tbb:Th:Tye:Tei:Try: :Tf :Tfr: |
| 110 | | ____ __________: : :___: :_______________________________________: :_ |
| 111 | | DATA |__||__| |______| |___| : |___|_ |
| 112 | | 6 7 : : : : : : |
| 113 | | MSB : : : : : Talker Sending : |
| 114 | | : : : : Listener READY-FOR-DATA System |
| 115 | | : : : EOI-Timeout Handshake Line Release |
| 116 | | : : Listener READY-FOR-DATA |
| 117 | | : Talker Ready-To-Send |
| 118 | | |
| 119 | | |
| 120 | | |
| 121 | | |
| 122 | | TALK-ATTENTION TURN AROUND (TALKER AND LISTENER REVERSED) |
| 123 | | ___ _________________________________________________________ |
| 124 | | ATN _____________| |
| 125 | | : |
| 126 | | ___ ___ ___ : _____ ________ ___ ___ ___ ___ ___ ___ ___ ___ |
| 127 | | CLK _| |_| |_________| |___| |_| |_| |_| |_| |_| |_| |_| |_| |_____ |
| 128 | | : : : : : : : |
| 129 | | :Tf:Tr:Ttk:Tdc:Tda:Th:Try: :Tf : |
| 130 | | ____ __________: : : : :_______________________________________: |
| 131 | | DATA |__||__| |_________________| :|__||__||__||__||__||__||__||__| |_ |
| 132 | | 6 7 : : : : : : 0 1 2 3 4 5 6 7 |
| 133 | | MSB : : : : : :LSB MSB |
| 134 | | : : : : : : |
| 135 | | : : : : : : Data Valid |
| 136 | | : : : : : Listener READY-FOR-DATA |
| 137 | | : : : : Talker Ready-To-Send |
| 138 | | : : : Device acknowledges it's now TALKER. |
| 139 | | : : Becomes LISTENER, Clock = High, Data = Low |
| 140 | | : Talker Ready-To-Send |
| 141 | | |
| 142 | | |
| 143 | | |
| 144 | | |
| 145 | | ___ _____________________________________________________________________ |
| 146 | | ATN |
| 147 | | ___ _________ ___ ___ ___ ___ ___ ___ ___ ___ ________ ___ ___ |
| 148 | | CLK ____| |_| |_| |_| |_| |_| |_| |_| |_| |_______| |_| |_| |_ |
| 149 | | : : : : : |
| 150 | | :Th :Tne: :Tf :Tbb:Th:Tne: |
| 151 | | ____ : :___:___________________________________: :_____________ |
| 152 | | DATA ________| :|__||__||__||__||__||__||__||__| |______| |
| 153 | | : : : 0 1 2 3 4 5 6 7 : |
| 154 | | : : :LSB MSB : |
| 155 | | : : : : |
| 156 | | : : : TALKER SENDING Listener: Data Accepted |
| 157 | | : : LISTENER READY-FOR-DATA |
| 158 | | : TALKER READY-TO-SEND |
| 159 | | |
| 160 | | |
| 161 | | |
| 162 | | Serial Bus Timing |
| 163 | | |
| 164 | | |
| 165 | | Description Symbol Min Typ Max |
| 166 | | |
| 167 | | ATN Response (required) 1) Tat - - 1000us |
| 168 | | Listener Hold-Off Th 0 - oo |
| 169 | | Non-EOI Response to RFD 2) Tne - 40us 200us |
| 170 | | Bit Set-Up Talker 4) Ts 20us 70us - |
| 171 | | Data Valid Tv 20us 20us - |
| 172 | | Frame Handshake 3) Tf 0 20 1000us |
| 173 | | Frame to Release of ATN Tr 20us - - |
| 174 | | Between Bytes Time Tbb 100us - - |
| 175 | | EOI Response Time Tye 200us 250us - |
| 176 | | EOI Response Hold Time 5) Tei 60us - - |
| 177 | | Talker Response Limit Try 0 30us 60us |
| 178 | | Byte-Acknowledge 4) Tpr 20us 30us - |
| 179 | | Talk-Attention Release Ttk 20us 30us 100us |
| 180 | | Talk-Attention Acknowledge Tdc 0 - - |
| 181 | | Talk-Attention Ack. Hold Tda 80us - - |
| 182 | | EOI Acknowledge Tfr 60us - - |
| 183 | | |
| 184 | | |
| 185 | | Notes: |
| 186 | | 1) If maximum time exceeded, device not present error. |
| 187 | | 2) If maximum time exceeded, EOI response required. |
| 188 | | 3) If maximum time exceeded, frame error. |
| 189 | | 4) Tv and Tpr minimum must be 60us for external device to be a talker. |
| 190 | | 5) Tei minimum must be 80us for external device to be a listener. |
| 191 | | */ |
| 192 | | |
| 193 | | #include "driver.h" |
| 194 | | #include "cbmserial.h" |
| 195 | | |
| 196 | | /*************************************************************************** |
| 197 | | PARAMETERS |
| 198 | | ***************************************************************************/ |
| 199 | | |
| 200 | | #define LOG 0 |
| 201 | | |
| 202 | | enum |
| 203 | | { |
| 204 | | SRQ = 0, |
| 205 | | ATN, |
| 206 | | CLK, |
| 207 | | DATA, |
| 208 | | RESET, |
| 209 | | SIGNAL_COUNT |
| 210 | | }; |
| 211 | | |
| 212 | | static const char *const SIGNAL_NAME[] = { "SRQ", "ATN", "CLK", "DATA", "RESET" }; |
| 213 | | |
| 214 | | /*************************************************************************** |
| 215 | | TYPE DEFINITIONS |
| 216 | | ***************************************************************************/ |
| 217 | | |
| 218 | | typedef struct _cbmserial_daisy_state cbmserial_daisy_state; |
| 219 | | struct _cbmserial_daisy_state |
| 220 | | { |
| 221 | | cbmserial_daisy_state *next; /* next device */ |
| 222 | | const device_config *device; /* associated device */ |
| 223 | | |
| 224 | | int line[SIGNAL_COUNT]; /* serial signal states */ |
| 225 | | |
| 226 | | cbmserial_line out_line_func[SIGNAL_COUNT]; |
| 227 | | }; |
| 228 | | |
| 229 | | typedef struct _cbmserial_t cbmserial_t; |
| 230 | | struct _cbmserial_t |
| 231 | | { |
| 232 | | cbmserial_daisy_state *daisy_state; |
| 233 | | }; |
| 234 | | |
| 235 | | /*************************************************************************** |
| 236 | | INLINE FUNCTIONS |
| 237 | | ***************************************************************************/ |
| 238 | | |
| 239 | | INLINE cbmserial_t *get_safe_token(const device_config *device) |
| 240 | | { |
| 241 | | assert(device != NULL); |
| 242 | | assert(device->token != NULL); |
| 243 | | assert(device->type == CBMSERIAL); |
| 244 | | return (cbmserial_t *)device->token; |
| 245 | | } |
| 246 | | |
| 247 | | INLINE const cbmserial_daisy_chain *get_interface(const device_config *device) |
| 248 | | { |
| 249 | | assert(device != NULL); |
| 250 | | assert((device->type == CBMSERIAL)); |
| 251 | | return (const cbmserial_daisy_chain *) device->static_config; |
| 252 | | } |
| 253 | | |
| 254 | | INLINE int get_signal(const device_config *device, int line) |
| 255 | | { |
| 256 | | cbmserial_t *cbmserial = get_safe_token(device); |
| 257 | | cbmserial_daisy_state *daisy = cbmserial->daisy_state; |
| 258 | | int state = 1; |
| 259 | | |
| 260 | | for ( ; daisy != NULL; daisy = daisy->next) |
| 261 | | { |
| 262 | | if (!daisy->line[line]) |
| 263 | | { |
| 264 | | state = 0; |
| 265 | | break; |
| 266 | | } |
| 267 | | } |
| 268 | | |
| 269 | | return state; |
| 270 | | } |
| 271 | | |
| 272 | | INLINE void set_signal(const device_config *serial_bus_device, const device_config *calling_device, int line, int state) |
| 273 | | { |
| 274 | | cbmserial_t *cbmserial = get_safe_token(serial_bus_device); |
| 275 | | cbmserial_daisy_state *daisy = cbmserial->daisy_state; |
| 276 | | int data = 1; |
| 277 | | |
| 278 | | for ( ; daisy != NULL; daisy = daisy->next) |
| 279 | | { |
| 280 | | if (!strcmp(daisy->device->tag, calling_device->tag)) |
| 281 | | { |
| 282 | | if (daisy->line[line] != state) |
| 283 | | { |
| 284 | | if (LOG) logerror("CBM Serial Bus: '%s' %s %u\n", calling_device->tag, SIGNAL_NAME[line], state); |
| 285 | | daisy->line[line] = state; |
| 286 | | } |
| 287 | | break; |
| 288 | | } |
| 289 | | } |
| 290 | | |
| 291 | | data = get_signal(serial_bus_device, line); |
| 292 | | daisy = cbmserial->daisy_state; |
| 293 | | |
| 294 | | for ( ; daisy != NULL; daisy = daisy->next) |
| 295 | | { |
| 296 | | if (daisy->out_line_func[line]) (daisy->out_line_func[line])(daisy->device, data); |
| 297 | | } |
| 298 | | |
| 299 | | if (LOG) logerror("CBM Serial Bus: SRQ %u ATN %u CLK %u DATA %u RESET %u\n", get_signal(serial_bus_device, SRQ),get_signal(serial_bus_device, ATN),get_signal(serial_bus_device, CLK),get_signal(serial_bus_device, DATA),get_signal(serial_bus_device, RESET)); |
| 300 | | } |
| 301 | | |
| 302 | | /*************************************************************************** |
| 303 | | IMPLEMENTATION |
| 304 | | ***************************************************************************/ |
| 305 | | |
| 306 | | void cbmserial_srq_w(const device_config *serial_bus_device, const device_config *calling_device, int state) |
| 307 | | { |
| 308 | | set_signal(serial_bus_device, calling_device, SRQ, state); |
| 309 | | } |
| 310 | | |
| 311 | | READ_LINE_DEVICE_HANDLER( cbmserial_srq_r ) |
| 312 | | { |
| 313 | | return get_signal(device, SRQ); |
| 314 | | } |
| 315 | | |
| 316 | | void cbmserial_atn_w(const device_config *serial_bus_device, const device_config *calling_device, int state) |
| 317 | | { |
| 318 | | set_signal(serial_bus_device, calling_device, ATN, state); |
| 319 | | } |
| 320 | | |
| 321 | | READ_LINE_DEVICE_HANDLER( cbmserial_atn_r ) |
| 322 | | { |
| 323 | | return get_signal(device, ATN); |
| 324 | | } |
| 325 | | |
| 326 | | void cbmserial_clk_w(const device_config *serial_bus_device, const device_config *calling_device, int state) |
| 327 | | { |
| 328 | | set_signal(serial_bus_device, calling_device, CLK, state); |
| 329 | | } |
| 330 | | |
| 331 | | READ_LINE_DEVICE_HANDLER( cbmserial_clk_r ) |
| 332 | | { |
| 333 | | return get_signal(device, CLK); |
| 334 | | } |
| 335 | | |
| 336 | | void cbmserial_data_w(const device_config *serial_bus_device, const device_config *calling_device, int state) |
| 337 | | { |
| 338 | | set_signal(serial_bus_device, calling_device, DATA, state); |
| 339 | | } |
| 340 | | |
| 341 | | READ_LINE_DEVICE_HANDLER( cbmserial_data_r ) |
| 342 | | { |
| 343 | | return get_signal(device, DATA); |
| 344 | | } |
| 345 | | |
| 346 | | void cbmserial_reset_w(const device_config *serial_bus_device, const device_config *calling_device, int state) |
| 347 | | { |
| 348 | | set_signal(serial_bus_device, calling_device, RESET, state); |
| 349 | | } |
| 350 | | |
| 351 | | READ_LINE_DEVICE_HANDLER( cbmserial_reset_r ) |
| 352 | | { |
| 353 | | return get_signal(device, RESET); |
| 354 | | } |
| 355 | | |
| 356 | | /*------------------------------------------------- |
| 357 | | DEVICE_START( cbmserial ) |
| 358 | | -------------------------------------------------*/ |
| 359 | | |
| 360 | | static DEVICE_START( cbmserial ) |
| 361 | | { |
| 362 | | cbmserial_t *cbmserial = get_safe_token(device); |
| 363 | | const cbmserial_daisy_chain *daisy = get_interface(device); |
| 364 | | int i; |
| 365 | | |
| 366 | | astring *tempstring = astring_alloc(); |
| 367 | | cbmserial_daisy_state *head = NULL; |
| 368 | | cbmserial_daisy_state **tailptr = &head; |
| 369 | | |
| 370 | | /* create a linked list of devices */ |
| 371 | | for ( ; daisy->tag != NULL; daisy++) |
| 372 | | { |
| 373 | | *tailptr = auto_alloc(device->machine, cbmserial_daisy_state); |
| 374 | | |
| 375 | | (*tailptr)->next = NULL; |
| 376 | | (*tailptr)->device = devtag_get_device(device->machine, daisy->tag); |
| 377 | | |
| 378 | | if ((*tailptr)->device == NULL) |
| 379 | | { |
| 380 | | astring_free(tempstring); |
| 381 | | fatalerror("Unable to locate device '%s'", daisy->tag); |
| 382 | | } |
| 383 | | |
| 384 | | for (i = SRQ; i < SIGNAL_COUNT; i++) |
| 385 | | { |
| 386 | | (*tailptr)->line[i] = 1; |
| 387 | | } |
| 388 | | |
| 389 | | (*tailptr)->out_line_func[SRQ] = (cbmserial_line)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CBM_SERIAL_SRQ); |
| 390 | | (*tailptr)->out_line_func[ATN] = (cbmserial_line)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CBM_SERIAL_ATN); |
| 391 | | (*tailptr)->out_line_func[CLK] = (cbmserial_line)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CBM_SERIAL_CLK); |
| 392 | | (*tailptr)->out_line_func[DATA] = (cbmserial_line)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CBM_SERIAL_DATA); |
| 393 | | (*tailptr)->out_line_func[RESET] = (cbmserial_line)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CBM_SERIAL_RESET); |
| 394 | | |
| 395 | | tailptr = &(*tailptr)->next; |
| 396 | | } |
| 397 | | |
| 398 | | cbmserial->daisy_state = head; |
| 399 | | |
| 400 | | astring_free(tempstring); |
| 401 | | |
| 402 | | /* register for state saving */ |
| 403 | | // state_save_register_device_item(device, 0, cbmserial->); |
| 404 | | } |
| 405 | | |
| 406 | | /*------------------------------------------------- |
| 407 | | DEVICE_GET_INFO( cbmserial ) |
| 408 | | -------------------------------------------------*/ |
| 409 | | |
| 410 | | DEVICE_GET_INFO( cbmserial ) |
| 411 | | { |
| 412 | | switch (state) |
| 413 | | { |
| 414 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 415 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cbmserial_t); break; |
| 416 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 417 | | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 418 | | |
| 419 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 420 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cbmserial); break; |
| 421 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 422 | | case DEVINFO_FCT_RESET: /* Nothing */ break; |
| 423 | | |
| 424 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 425 | | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore Serial Bus"); break; |
| 426 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "IEEE-488"); break; |
| 427 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 428 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 429 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 430 | | } |
| 431 | | } |
src/mess/machine/cbmserial.h
| r6676 | r6677 | |
| 1 | | /********************************************************************** |
| 2 | | |
| 3 | | Commodore Serial Bus emulation |
| 4 | | |
| 5 | | Copyright MESS Team. |
| 6 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | | |
| 8 | | **********************************************************************/ |
| 9 | | |
| 10 | | #ifndef __CBMSERIAL__ |
| 11 | | #define __CBMSERIAL__ |
| 12 | | |
| 13 | | #include "driver.h" |
| 14 | | |
| 15 | | /*************************************************************************** |
| 16 | | MACROS / CONSTANTS |
| 17 | | ***************************************************************************/ |
| 18 | | |
| 19 | | #define CBMSERIAL DEVICE_GET_INFO_NAME( cbmserial ) |
| 20 | | |
| 21 | | #define MDRV_CBMSERIAL_ADD(_tag, _daisy_chain) \ |
| 22 | | MDRV_DEVICE_ADD(_tag, CBMSERIAL, 0) \ |
| 23 | | MDRV_DEVICE_CONFIG(_daisy_chain) |
| 24 | | |
| 25 | | #define CBMSERIAL_DAISY(_name) \ |
| 26 | | const cbmserial_daisy_chain (_name)[] = |
| 27 | | |
| 28 | | enum |
| 29 | | { |
| 30 | | DEVINFO_FCT_CBM_SERIAL_SRQ = DEVINFO_FCT_DEVICE_SPECIFIC, |
| 31 | | DEVINFO_FCT_CBM_SERIAL_ATN, |
| 32 | | DEVINFO_FCT_CBM_SERIAL_CLK, |
| 33 | | DEVINFO_FCT_CBM_SERIAL_DATA, |
| 34 | | DEVINFO_FCT_CBM_SERIAL_RESET |
| 35 | | }; |
| 36 | | |
| 37 | | #define CBMSERIAL_SRQ_NAME(name) cbmserial_srq_##name |
| 38 | | #define CBMSERIAL_SRQ(name) void CBMSERIAL_SRQ_NAME(name)(const device_config *device, int state) |
| 39 | | |
| 40 | | #define CBMSERIAL_ATN_NAME(name) cbmserial_atn_##name |
| 41 | | #define CBMSERIAL_ATN(name) void CBMSERIAL_ATN_NAME(name)(const device_config *device, int state) |
| 42 | | |
| 43 | | #define CBMSERIAL_CLK_NAME(name) cbmserial_clk_##name |
| 44 | | #define CBMSERIAL_CLK(name) void CBMSERIAL_CLK_NAME(name)(const device_config *device, int state) |
| 45 | | |
| 46 | | #define CBMSERIAL_DATA_NAME(name) cbmserial_data_##name |
| 47 | | #define CBMSERIAL_DATA(name) void CBMSERIAL_DATA_NAME(name)(const device_config *device, int state) |
| 48 | | |
| 49 | | #define CBMSERIAL_RESET_NAME(name) cbmserial_reset_##name |
| 50 | | #define CBMSERIAL_RESET(name) void CBMSERIAL_RESET_NAME(name)(const device_config *device, int state) |
| 51 | | |
| 52 | | /*************************************************************************** |
| 53 | | TYPE DEFINITIONS |
| 54 | | ***************************************************************************/ |
| 55 | | |
| 56 | | typedef struct _cbmserial_daisy_chain cbmserial_daisy_chain; |
| 57 | | struct _cbmserial_daisy_chain |
| 58 | | { |
| 59 | | const char *tag; /* device tag */ |
| 60 | | }; |
| 61 | | |
| 62 | | typedef void (*cbmserial_line)(const device_config *device, int state); |
| 63 | | |
| 64 | | /*************************************************************************** |
| 65 | | PROTOTYPES |
| 66 | | ***************************************************************************/ |
| 67 | | |
| 68 | | /* device interface */ |
| 69 | | DEVICE_GET_INFO( cbmserial ); |
| 70 | | |
| 71 | | /* serial service request */ |
| 72 | | void cbmserial_srq_w(const device_config *serial_bus_device, const device_config *calling_device, int state); |
| 73 | | READ_LINE_DEVICE_HANDLER( cbmserial_srq_r ); |
| 74 | | |
| 75 | | /* attention */ |
| 76 | | void cbmserial_atn_w(const device_config *serial_bus_device, const device_config *calling_device, int state); |
| 77 | | READ_LINE_DEVICE_HANDLER( cbmserial_atn_r ); |
| 78 | | |
| 79 | | /* clock */ |
| 80 | | void cbmserial_clk_w(const device_config *serial_bus_device, const device_config *calling_device, int state); |
| 81 | | READ_LINE_DEVICE_HANDLER( cbmserial_clk_r ); |
| 82 | | |
| 83 | | /* data */ |
| 84 | | void cbmserial_data_w(const device_config *serial_bus_device, const device_config *calling_device, int state); |
| 85 | | READ_LINE_DEVICE_HANDLER( cbmserial_data_r ); |
| 86 | | |
| 87 | | /* reset */ |
| 88 | | void cbmserial_reset_w(const device_config *serial_bus_device, const device_config *calling_device, int state); |
| 89 | | READ_LINE_DEVICE_HANDLER( cbmserial_reset_r ); |
| 90 | | |
| 91 | | #endif |
src/mess/machine/cbmiec.c
| r0 | r6677 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Commodore IEC Serial Bus emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | /* |
| 11 | |
| 12 | C64 SERIAL BUS |
| 13 | |
| 14 | |
| 15 | Serial Bus Pinouts |
| 16 | |
| 17 | |
| 18 | Pin Name Description |
| 19 | 1 SRQ Serial Service Request In |
| 20 | 2 GND Ground |
| 21 | 3 ATN Serial Attention In/Out |
| 22 | 4 CLK Serial Clock In/Out |
| 23 | 5 DATA Serial Data In/Out |
| 24 | 6 RESET Serial Reset |
| 25 | |
| 26 | All signals are active low. |
| 27 | |
| 28 | |
| 29 | SRQ: Serial Service Request In |
| 30 | |
| 31 | This signal is not used on the C64. On C128 it is replaced with Fast Serial |
| 32 | Clock for the 1571 disk drive. |
| 33 | |
| 34 | |
| 35 | ATN: Serial Attention In/Out |
| 36 | |
| 37 | Sending any byte with the ATN line low (sending under attention) causes it |
| 38 | to be interpreted as a Bus Command for peripherals on the serial bus. |
| 39 | |
| 40 | When the C64 brings this signal LOW, all other devices start listening for |
| 41 | it to transmit an address. The device addressed must respond in a preset |
| 42 | period of time; otherwise, the C64 will assume that the device addressed is |
| 43 | not on the bus, and will return an error in the STATUS word. |
| 44 | |
| 45 | Usually, the address byte will be followed by one to two commands for the |
| 46 | device addressed, meaning the secondary address and channel on the peripheral. |
| 47 | Such a command can be one of the following: |
| 48 | |
| 49 | 20 |
| 50 | 40 |
| 51 | 60 |
| 52 | E0 |
| 53 | F0 |
| 54 | |
| 55 | |
| 56 | CLK: Serial Clock In/Out |
| 57 | |
| 58 | This signal is for timing the data sent on the serial bus. This signal is |
| 59 | always generated by the active TALKER. RISING EDGE OF THE CLOCK means data |
| 60 | bit is valid. |
| 61 | |
| 62 | |
| 63 | DATA: Serial Data In/Out |
| 64 | |
| 65 | Data on the serial bus is transmitted bit by bit at a time on this line. |
| 66 | |
| 67 | |
| 68 | RESET: Serial Reset |
| 69 | |
| 70 | You may disconnect this line to save your disk drive. The easiest way is to |
| 71 | do that on the cable, thus avoiding any modifications on your peripherals. |
| 72 | |
| 73 | |
| 74 | |
| 75 | Serial Bus Timing |
| 76 | |
| 77 | ___ |
| 78 | CLK |____|~~~~| Ts Bit Set-up time |
| 79 | : Ts : Tv : Tv Bit Valid time |
| 80 | |
| 81 | |
| 82 | |
| 83 | |<--------- Byte sent under attention (to devices) ------------>| |
| 84 | |
| 85 | ___ ____ _____ _____ |
| 86 | ATN |________________________________________________________| |
| 87 | : : |
| 88 | ___ ______ ________ ___ ___ ___ ___ ___ ___ ___ ___ : |
| 89 | CLK : |_____| |_| |_| |_| |_| |_| |_| |_| |_| |______________ _____ |
| 90 | : : : : : |
| 91 | : Tat : :Th: Tne : : Tf : Tr : |
| 92 | ____ ________ : : :___________________________________:____: |
| 93 | DATA ___|\\\\\\\\\\__:__| |__||__||__||__||__||__||__||__| |_________ _____ |
| 94 | : 0 1 2 3 4 5 6 7 : |
| 95 | : LSB MSB : |
| 96 | : : : |
| 97 | : : Data Valid Listener: Data Accepted |
| 98 | : Listener READY-FOR-DATA |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | END-OR-IDENTIFY HANDSHAKE (LAST BYTE IN MESSAGE) |
| 104 | ___ _______________________________________________________________________ |
| 105 | ATN |
| 106 | ___ ___ ___ ________________ ___ ___ ___ ___ ___ ___ ___ ___ __ |
| 107 | CLK _| |_| |______| |_| |_| |_| |_| |_| |_| |_| |_| |_______|_ |
| 108 | : : : : : |
| 109 | :Tf:Tbb:Th:Tye:Tei:Try: :Tf :Tfr: |
| 110 | ____ __________: : :___: :_______________________________________: :_ |
| 111 | DATA |__||__| |______| |___| : |___|_ |
| 112 | 6 7 : : : : : : |
| 113 | MSB : : : : : Talker Sending : |
| 114 | : : : : Listener READY-FOR-DATA System |
| 115 | : : : EOI-Timeout Handshake Line Release |
| 116 | : : Listener READY-FOR-DATA |
| 117 | : Talker Ready-To-Send |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | TALK-ATTENTION TURN AROUND (TALKER AND LISTENER REVERSED) |
| 123 | ___ _________________________________________________________ |
| 124 | ATN _____________| |
| 125 | : |
| 126 | ___ ___ ___ : _____ ________ ___ ___ ___ ___ ___ ___ ___ ___ |
| 127 | CLK _| |_| |_________| |___| |_| |_| |_| |_| |_| |_| |_| |_| |_____ |
| 128 | : : : : : : : |
| 129 | :Tf:Tr:Ttk:Tdc:Tda:Th:Try: :Tf : |
| 130 | ____ __________: : : : :_______________________________________: |
| 131 | DATA |__||__| |_________________| :|__||__||__||__||__||__||__||__| |_ |
| 132 | 6 7 : : : : : : 0 1 2 3 4 5 6 7 |
| 133 | MSB : : : : : :LSB MSB |
| 134 | : : : : : : |
| 135 | : : : : : : Data Valid |
| 136 | : : : : : Listener READY-FOR-DATA |
| 137 | : : : : Talker Ready-To-Send |
| 138 | : : : Device acknowledges it's now TALKER. |
| 139 | : : Becomes LISTENER, Clock = High, Data = Low |
| 140 | : Talker Ready-To-Send |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | ___ _____________________________________________________________________ |
| 146 | ATN |
| 147 | ___ _________ ___ ___ ___ ___ ___ ___ ___ ___ ________ ___ ___ |
| 148 | CLK ____| |_| |_| |_| |_| |_| |_| |_| |_| |_______| |_| |_| |_ |
| 149 | : : : : : |
| 150 | :Th :Tne: :Tf :Tbb:Th:Tne: |
| 151 | ____ : :___:___________________________________: :_____________ |
| 152 | DATA ________| :|__||__||__||__||__||__||__||__| |______| |
| 153 | : : : 0 1 2 3 4 5 6 7 : |
| 154 | : : :LSB MSB : |
| 155 | : : : : |
| 156 | : : : TALKER SENDING Listener: Data Accepted |
| 157 | : : LISTENER READY-FOR-DATA |
| 158 | : TALKER READY-TO-SEND |
| 159 | |
| 160 | |
| 161 | |
| 162 | Serial Bus Timing |
| 163 | |
| 164 | |
| 165 | Description Symbol Min Typ Max |
| 166 | |
| 167 | ATN Response (required) 1) Tat - - 1000us |
| 168 | Listener Hold-Off Th 0 - oo |
| 169 | Non-EOI Response to RFD 2) Tne - 40us 200us |
| 170 | Bit Set-Up Talker 4) Ts 20us 70us - |
| 171 | Data Valid Tv 20us 20us - |
| 172 | Frame Handshake 3) Tf 0 20 1000us |
| 173 | Frame to Release of ATN Tr 20us - - |
| 174 | Between Bytes Time Tbb 100us - - |
| 175 | EOI Response Time Tye 200us 250us - |
| 176 | EOI Response Hold Time 5) Tei 60us - - |
| 177 | Talker Response Limit Try 0 30us 60us |
| 178 | Byte-Acknowledge 4) Tpr 20us 30us - |
| 179 | Talk-Attention Release Ttk 20us 30us 100us |
| 180 | Talk-Attention Acknowledge Tdc 0 - - |
| 181 | Talk-Attention Ack. Hold Tda 80us - - |
| 182 | EOI Acknowledge Tfr 60us - - |
| 183 | |
| 184 | |
| 185 | Notes: |
| 186 | 1) If maximum time exceeded, device not present error. |
| 187 | 2) If maximum time exceeded, EOI response required. |
| 188 | 3) If maximum time exceeded, frame error. |
| 189 | 4) Tv and Tpr minimum must be 60us for external device to be a talker. |
| 190 | 5) Tei minimum must be 80us for external device to be a listener. |
| 191 | */ |
| 192 | |
| 193 | #include "driver.h" |
| 194 | #include "cbmiec.h" |
| 195 | |
| 196 | /*************************************************************************** |
| 197 | PARAMETERS |
| 198 | ***************************************************************************/ |
| 199 | |
| 200 | #define LOG 0 |
| 201 | |
| 202 | enum |
| 203 | { |
| 204 | SRQ = 0, |
| 205 | ATN, |
| 206 | CLK, |
| 207 | DATA, |
| 208 | RESET, |
| 209 | SIGNAL_COUNT |
| 210 | }; |
| 211 | |
| 212 | static const char *const SIGNAL_NAME[] = { "SRQ", "ATN", "CLK", "DATA", "RESET" }; |
| 213 | |
| 214 | /*************************************************************************** |
| 215 | TYPE DEFINITIONS |
| 216 | ***************************************************************************/ |
| 217 | |
| 218 | typedef struct _cbm_iec_daisy_state cbm_iec_daisy_state; |
| 219 | struct _cbm_iec_daisy_state |
| 220 | { |
| 221 | cbm_iec_daisy_state *next; /* next device */ |
| 222 | const device_config *device; /* associated device */ |
| 223 | |
| 224 | int line[SIGNAL_COUNT]; /* serial signal states */ |
| 225 | |
| 226 | cbm_iec_line out_line_func[SIGNAL_COUNT]; |
| 227 | }; |
| 228 | |
| 229 | typedef struct _cbm_iec_t cbm_iec_t; |
| 230 | struct _cbm_iec_t |
| 231 | { |
| 232 | cbm_iec_daisy_state *daisy_state; |
| 233 | }; |
| 234 | |
| 235 | /*************************************************************************** |
| 236 | INLINE FUNCTIONS |
| 237 | ***************************************************************************/ |
| 238 | |
| 239 | INLINE cbm_iec_t *get_safe_token(const device_config *device) |
| 240 | { |
| 241 | assert(device != NULL); |
| 242 | assert(device->token != NULL); |
| 243 | assert(device->type == CBM_IEC); |
| 244 | return (cbm_iec_t *)device->token; |
| 245 | } |
| 246 | |
| 247 | INLINE const cbm_iec_daisy_chain *get_interface(const device_config *device) |
| 248 | { |
| 249 | assert(device != NULL); |
| 250 | assert(device->type == CBM_IEC); |
| 251 | return (const cbm_iec_daisy_chain *) device->static_config; |
| 252 | } |
| 253 | |
| 254 | INLINE int get_signal(const device_config *device, int line) |
| 255 | { |
| 256 | cbm_iec_t *cbm_iec = get_safe_token(device); |
| 257 | cbm_iec_daisy_state *daisy = cbm_iec->daisy_state; |
| 258 | int state = 1; |
| 259 | |
| 260 | for ( ; daisy != NULL; daisy = daisy->next) |
| 261 | { |
| 262 | if (!daisy->line[line]) |
| 263 | { |
| 264 | state = 0; |
| 265 | break; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | return state; |
| 270 | } |
| 271 | |
| 272 | INLINE void set_signal(const device_config *iec, const device_config *device, int line, int state) |
| 273 | { |
| 274 | cbm_iec_t *cbm_iec = get_safe_token(iec); |
| 275 | cbm_iec_daisy_state *daisy = cbm_iec->daisy_state; |
| 276 | int data = 1; |
| 277 | |
| 278 | for ( ; daisy != NULL; daisy = daisy->next) |
| 279 | { |
| 280 | if (!strcmp(daisy->device->tag, device->tag)) |
| 281 | { |
| 282 | if (daisy->line[line] != state) |
| 283 | { |
| 284 | if (LOG) logerror("CBM IEC: '%s' %s %u\n", device->tag, SIGNAL_NAME[line], state); |
| 285 | daisy->line[line] = state; |
| 286 | } |
| 287 | break; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | data = get_signal(iec, line); |
| 292 | daisy = cbm_iec->daisy_state; |
| 293 | |
| 294 | for ( ; daisy != NULL; daisy = daisy->next) |
| 295 | { |
| 296 | if (daisy->out_line_func[line]) (daisy->out_line_func[line])(daisy->device, data); |
| 297 | } |
| 298 | |
| 299 | if (LOG) logerror("CBM IEC: SRQ %u ATN %u CLK %u DATA %u RESET %u\n", get_signal(iec, SRQ),get_signal(iec, ATN),get_signal(iec, CLK),get_signal(iec, DATA),get_signal(iec, RESET)); |
| 300 | } |
| 301 | |
| 302 | /*************************************************************************** |
| 303 | IMPLEMENTATION |
| 304 | ***************************************************************************/ |
| 305 | |
| 306 | void cbm_iec_srq_w(const device_config *iec, const device_config *device, int state) |
| 307 | { |
| 308 | set_signal(iec, device, SRQ, state); |
| 309 | } |
| 310 | |
| 311 | READ_LINE_DEVICE_HANDLER( cbm_iec_srq_r ) |
| 312 | { |
| 313 | return get_signal(device, SRQ); |
| 314 | } |
| 315 | |
| 316 | void cbm_iec_atn_w(const device_config *iec, const device_config *device, int state) |
| 317 | { |
| 318 | set_signal(iec, device, ATN, state); |
| 319 | } |
| 320 | |
| 321 | READ_LINE_DEVICE_HANDLER( cbm_iec_atn_r ) |
| 322 | { |
| 323 | return get_signal(device, ATN); |
| 324 | } |
| 325 | |
| 326 | void cbm_iec_clk_w(const device_config *iec, const device_config *device, int state) |
| 327 | { |
| 328 | set_signal(iec, device, CLK, state); |
| 329 | } |
| 330 | |
| 331 | READ_LINE_DEVICE_HANDLER( cbm_iec_clk_r ) |
| 332 | { |
| 333 | return get_signal(device, CLK); |
| 334 | } |
| 335 | |
| 336 | void cbm_iec_data_w(const device_config *iec, const device_config *device, int state) |
| 337 | { |
| 338 | set_signal(iec, device, DATA, state); |
| 339 | } |
| 340 | |
| 341 | READ_LINE_DEVICE_HANDLER( cbm_iec_data_r ) |
| 342 | { |
| 343 | return get_signal(device, DATA); |
| 344 | } |
| 345 | |
| 346 | void cbm_iec_reset_w(const device_config *iec, const device_config *device, int state) |
| 347 | { |
| 348 | set_signal(iec, device, RESET, state); |
| 349 | } |
| 350 | |
| 351 | READ_LINE_DEVICE_HANDLER( cbm_iec_reset_r ) |
| 352 | { |
| 353 | return get_signal(device, RESET); |
| 354 | } |
| 355 | |
| 356 | /*------------------------------------------------- |
| 357 | DEVICE_START( cbm_iec ) |
| 358 | -------------------------------------------------*/ |
| 359 | |
| 360 | static DEVICE_START( cbm_iec ) |
| 361 | { |
| 362 | cbm_iec_t *cbm_iec = get_safe_token(device); |
| 363 | const cbm_iec_daisy_chain *daisy = get_interface(device); |
| 364 | int i; |
| 365 | |
| 366 | astring *tempstring = astring_alloc(); |
| 367 | cbm_iec_daisy_state *head = NULL; |
| 368 | cbm_iec_daisy_state **tailptr = &head; |
| 369 | |
| 370 | /* create a linked list of devices */ |
| 371 | for ( ; daisy->tag != NULL; daisy++) |
| 372 | { |
| 373 | *tailptr = auto_alloc(device->machine, cbm_iec_daisy_state); |
| 374 | |
| 375 | (*tailptr)->next = NULL; |
| 376 | (*tailptr)->device = devtag_get_device(device->machine, daisy->tag); |
| 377 | |
| 378 | if ((*tailptr)->device == NULL) |
| 379 | { |
| 380 | astring_free(tempstring); |
| 381 | fatalerror("Unable to locate device '%s'", daisy->tag); |
| 382 | } |
| 383 | |
| 384 | for (i = SRQ; i < SIGNAL_COUNT; i++) |
| 385 | { |
| 386 | (*tailptr)->line[i] = 1; |
| 387 | } |
| 388 | |
| 389 | (*tailptr)->out_line_func[SRQ] = (cbm_iec_line)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CBM_IEC_SRQ); |
| 390 | (*tailptr)->out_line_func[ATN] = (cbm_iec_line)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CBM_IEC_ATN); |
| 391 | (*tailptr)->out_line_func[CLK] = (cbm_iec_line)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CBM_IEC_CLK); |
| 392 | (*tailptr)->out_line_func[DATA] = (cbm_iec_line)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CBM_IEC_DATA); |
| 393 | (*tailptr)->out_line_func[RESET] = (cbm_iec_line)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CBM_IEC_RESET); |
| 394 | |
| 395 | tailptr = &(*tailptr)->next; |
| 396 | } |
| 397 | |
| 398 | cbm_iec->daisy_state = head; |
| 399 | |
| 400 | astring_free(tempstring); |
| 401 | |
| 402 | /* register for state saving */ |
| 403 | // state_save_register_device_item(device, 0, cbm_iec->); |
| 404 | } |
| 405 | |
| 406 | /*------------------------------------------------- |
| 407 | DEVICE_GET_INFO( cbm_iec ) |
| 408 | -------------------------------------------------*/ |
| 409 | |
| 410 | DEVICE_GET_INFO( cbm_iec ) |
| 411 | { |
| 412 | switch (state) |
| 413 | { |
| 414 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 415 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cbm_iec_t); break; |
| 416 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 417 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 418 | |
| 419 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 420 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cbm_iec); break; |
| 421 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 422 | case DEVINFO_FCT_RESET: /* Nothing */ break; |
| 423 | |
| 424 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 425 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore Serial Bus"); break; |
| 426 | case DEVINFO_STR_FAMILY: strcpy(info->s, "IEEE-488"); break; |
| 427 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 428 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 429 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 430 | } |
| 431 | } |
src/mess/machine/cbmiec.h
| r0 | r6677 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Commodore IEC Serial Bus emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #ifndef __CBM_IEC__ |
| 11 | #define __CBM_IEC__ |
| 12 | |
| 13 | #include "driver.h" |
| 14 | |
| 15 | /*************************************************************************** |
| 16 | MACROS / CONSTANTS |
| 17 | ***************************************************************************/ |
| 18 | |
| 19 | #define CBM_IEC DEVICE_GET_INFO_NAME( cbm_iec ) |
| 20 | |
| 21 | #define MDRV_CBM_IEC_ADD(_tag, _daisy_chain) \ |
| 22 | MDRV_DEVICE_ADD(_tag, CBM_IEC, 0) \ |
| 23 | MDRV_DEVICE_CONFIG(_daisy_chain) |
| 24 | |
| 25 | #define CBM_IEC_DAISY(_name) \ |
| 26 | const cbm_iec_daisy_chain (_name)[] = |
| 27 | |
| 28 | enum |
| 29 | { |
| 30 | DEVINFO_FCT_CBM_IEC_SRQ = DEVINFO_FCT_DEVICE_SPECIFIC, |
| 31 | DEVINFO_FCT_CBM_IEC_ATN, |
| 32 | DEVINFO_FCT_CBM_IEC_CLK, |
| 33 | DEVINFO_FCT_CBM_IEC_DATA, |
| 34 | DEVINFO_FCT_CBM_IEC_RESET |
| 35 | }; |
| 36 | |
| 37 | #define CBM_IEC_SRQ_NAME(name) cbm_iec_srq_##name |
| 38 | #define CBM_IEC_SRQ(name) void CBM_IEC_SRQ_NAME(name)(const device_config *device, int state) |
| 39 | |
| 40 | #define CBM_IEC_ATN_NAME(name) cbm_iec_atn_##name |
| 41 | #define CBM_IEC_ATN(name) void CBM_IEC_ATN_NAME(name)(const device_config *device, int state) |
| 42 | |
| 43 | #define CBM_IEC_CLK_NAME(name) cbm_iec_clk_##name |
| 44 | #define CBM_IEC_CLK(name) void CBM_IEC_CLK_NAME(name)(const device_config *device, int state) |
| 45 | |
| 46 | #define CBM_IEC_DATA_NAME(name) cbm_iec_data_##name |
| 47 | #define CBM_IEC_DATA(name) void CBM_IEC_DATA_NAME(name)(const device_config *device, int state) |
| 48 | |
| 49 | #define CBM_IEC_RESET_NAME(name) cbm_iec_reset_##name |
| 50 | #define CBM_IEC_RESET(name) void CBM_IEC_RESET_NAME(name)(const device_config *device, int state) |
| 51 | |
| 52 | /*************************************************************************** |
| 53 | TYPE DEFINITIONS |
| 54 | ***************************************************************************/ |
| 55 | |
| 56 | typedef struct _cbm_iec_daisy_chain cbm_iec_daisy_chain; |
| 57 | struct _cbm_iec_daisy_chain |
| 58 | { |
| 59 | const char *tag; /* device tag */ |
| 60 | }; |
| 61 | |
| 62 | typedef void (*cbm_iec_line)(const device_config *device, int state); |
| 63 | |
| 64 | /*************************************************************************** |
| 65 | PROTOTYPES |
| 66 | ***************************************************************************/ |
| 67 | |
| 68 | /* device interface */ |
| 69 | DEVICE_GET_INFO( cbm_iec ); |
| 70 | |
| 71 | /* service request */ |
| 72 | void cbm_iec_srq_w(const device_config *iec, const device_config *device, int state); |
| 73 | READ_LINE_DEVICE_HANDLER( cbm_iec_srq_r ); |
| 74 | |
| 75 | /* attention */ |
| 76 | void cbm_iec_atn_w(const device_config *iec, const device_config *device, int state); |
| 77 | READ_LINE_DEVICE_HANDLER( cbm_iec_atn_r ); |
| 78 | |
| 79 | /* clock */ |
| 80 | void cbm_iec_clk_w(const device_config *iec, const device_config *device, int state); |
| 81 | READ_LINE_DEVICE_HANDLER( cbm_iec_clk_r ); |
| 82 | |
| 83 | /* data */ |
| 84 | void cbm_iec_data_w(const device_config *iec, const device_config *device, int state); |
| 85 | READ_LINE_DEVICE_HANDLER( cbm_iec_data_r ); |
| 86 | |
| 87 | /* reset */ |
| 88 | void cbm_iec_reset_w(const device_config *iec, const device_config *device, int state); |
| 89 | READ_LINE_DEVICE_HANDLER( cbm_iec_reset_r ); |
| 90 | |
| 91 | #endif |
src/mess/machine/c1581.c
| r6676 | r6677 | |
| 27 | 27 | #include "devices/flopdrv.h" |
| 28 | 28 | #include "formats/basicdsk.h" |
| 29 | 29 | #include "machine/6526cia.h" |
| 30 | | #include "machine/cbmserial.h" |
| 30 | #include "machine/cbmiec.h" |
| 31 | 31 | #include "machine/wd17xx.h" |
| 32 | 32 | |
| 33 | 33 | /*************************************************************************** |
| r6676 | r6677 | |
| 87 | 87 | c1581_atn_w - serial bus attention |
| 88 | 88 | -------------------------------------------------*/ |
| 89 | 89 | |
| 90 | | static CBMSERIAL_ATN( c1581 ) |
| 90 | static CBM_IEC_ATN( c1581 ) |
| 91 | 91 | { |
| 92 | 92 | c1581_t *c1581 = get_safe_token(device); |
| 93 | 93 | int data_out = !c1581->data_out && !(c1581->atn_ack && !state); |
| 94 | 94 | |
| 95 | 95 | mos6526_flag_w(c1581->cia, state); |
| 96 | 96 | |
| 97 | | cbmserial_data_w(c1581->serial_bus, device, data_out); |
| 97 | cbm_iec_data_w(c1581->serial_bus, device, data_out); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /*------------------------------------------------- |
| 101 | 101 | c1581_reset_w - serial bus reset |
| 102 | 102 | -------------------------------------------------*/ |
| 103 | 103 | |
| 104 | | static CBMSERIAL_RESET( c1581 ) |
| 104 | static CBM_IEC_RESET( c1581 ) |
| 105 | 105 | { |
| 106 | 106 | if (!state) |
| 107 | 107 | { |
| r6676 | r6677 | |
| 207 | 207 | UINT8 data = 0; |
| 208 | 208 | |
| 209 | 209 | /* data in */ |
| 210 | | data = !cbmserial_data_r(c1581->serial_bus); |
| 210 | data = !cbm_iec_data_r(c1581->serial_bus); |
| 211 | 211 | |
| 212 | 212 | /* clock in */ |
| 213 | | data |= !cbmserial_clk_r(c1581->serial_bus) << 2; |
| 213 | data |= !cbm_iec_clk_r(c1581->serial_bus) << 2; |
| 214 | 214 | |
| 215 | 215 | /* write protect */ |
| 216 | 216 | data |= !floppy_wpt_r(c1581->image) << 6; |
| 217 | 217 | |
| 218 | 218 | /* attention in */ |
| 219 | | data |= !cbmserial_atn_r(c1581->serial_bus) << 7; |
| 219 | data |= !cbm_iec_atn_r(c1581->serial_bus) << 7; |
| 220 | 220 | |
| 221 | 221 | return data; |
| 222 | 222 | } |
| r6676 | r6677 | |
| 245 | 245 | int atn_ack = BIT(data, 4); |
| 246 | 246 | |
| 247 | 247 | /* data out */ |
| 248 | | int serial_data = !data_out && !(atn_ack && !cbmserial_atn_r(c1581->serial_bus)); |
| 249 | | cbmserial_data_w(c1581->serial_bus, device->owner, serial_data); |
| 248 | int serial_data = !data_out && !(atn_ack && !cbm_iec_atn_r(c1581->serial_bus)); |
| 249 | cbm_iec_data_w(c1581->serial_bus, device->owner, serial_data); |
| 250 | 250 | c1581->data_out = data_out; |
| 251 | 251 | |
| 252 | 252 | /* clock out */ |
| 253 | | cbmserial_clk_w(c1581->serial_bus, device->owner, !clk_out); |
| 253 | cbm_iec_clk_w(c1581->serial_bus, device->owner, !clk_out); |
| 254 | 254 | |
| 255 | 255 | /* attention acknowledge */ |
| 256 | 256 | c1581->atn_ack = BIT(data, 4); |
| r6676 | r6677 | |
| 403 | 403 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(c1581); break; |
| 404 | 404 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 405 | 405 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(c1581); break; |
| 406 | | case DEVINFO_FCT_CBM_SERIAL_ATN: info->f = (genf *)CBMSERIAL_ATN_NAME(c1581); break; |
| 407 | | case DEVINFO_FCT_CBM_SERIAL_RESET: info->f = (genf *)CBMSERIAL_RESET_NAME(c1581); break; |
| 406 | case DEVINFO_FCT_CBM_IEC_ATN: info->f = (genf *)CBM_IEC_ATN_NAME(c1581); break; |
| 407 | case DEVINFO_FCT_CBM_IEC_RESET: info->f = (genf *)CBM_IEC_RESET_NAME(c1581); break; |
| 408 | 408 | |
| 409 | 409 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 410 | 410 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1581"); break; |
src/mess/machine/c1541.c
| r6676 | r6677 | |
| 141 | 141 | #include "devices/flopdrv.h" |
| 142 | 142 | #include "formats/g64_dsk.h" |
| 143 | 143 | #include "machine/6522via.h" |
| 144 | | #include "machine/cbmserial.h" |
| 144 | #include "machine/cbmiec.h" |
| 145 | 145 | |
| 146 | 146 | /*************************************************************************** |
| 147 | 147 | PARAMETERS |
| r6676 | r6677 | |
| 293 | 293 | c1541_atn_w - serial bus attention |
| 294 | 294 | -------------------------------------------------*/ |
| 295 | 295 | |
| 296 | | static CBMSERIAL_ATN( c1541 ) |
| 296 | static CBM_IEC_ATN( c1541 ) |
| 297 | 297 | { |
| 298 | 298 | c1541_t *c1541 = get_safe_token(device); |
| 299 | 299 | int data_out = !c1541->data_out && !(c1541->atna ^ !state); |
| 300 | 300 | |
| 301 | 301 | via_ca1_w(c1541->via0, 0, !state); |
| 302 | 302 | |
| 303 | | cbmserial_data_w(c1541->serial_bus, device, data_out); |
| 303 | cbm_iec_data_w(c1541->serial_bus, device, data_out); |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /*------------------------------------------------- |
| 307 | 307 | c1541_reset_w - serial bus reset |
| 308 | 308 | -------------------------------------------------*/ |
| 309 | 309 | |
| 310 | | static CBMSERIAL_RESET( c1541 ) |
| 310 | static CBM_IEC_RESET( c1541 ) |
| 311 | 311 | { |
| 312 | 312 | if (!state) |
| 313 | 313 | { |
| r6676 | r6677 | |
| 410 | 410 | UINT8 data = 0; |
| 411 | 411 | |
| 412 | 412 | /* data in */ |
| 413 | | data = !cbmserial_data_r(c1541->serial_bus); |
| 413 | data = !cbm_iec_data_r(c1541->serial_bus); |
| 414 | 414 | |
| 415 | 415 | /* clock in */ |
| 416 | | data |= !cbmserial_clk_r(c1541->serial_bus) << 2; |
| 416 | data |= !cbm_iec_clk_r(c1541->serial_bus) << 2; |
| 417 | 417 | |
| 418 | 418 | /* serial bus address */ |
| 419 | 419 | data |= c1541->address << 5; |
| 420 | 420 | |
| 421 | 421 | /* attention in */ |
| 422 | | data |= !cbmserial_atn_r(c1541->serial_bus) << 7; |
| 422 | data |= !cbm_iec_atn_r(c1541->serial_bus) << 7; |
| 423 | 423 | |
| 424 | 424 | return data; |
| 425 | 425 | } |
| r6676 | r6677 | |
| 448 | 448 | int atna = BIT(data, 4); |
| 449 | 449 | |
| 450 | 450 | /* data out */ |
| 451 | | int serial_data = !data_out && !(atna ^ !cbmserial_atn_r(c1541->serial_bus)); |
| 452 | | cbmserial_data_w(c1541->serial_bus, device->owner, serial_data); |
| 451 | int serial_data = !data_out && !(atna ^ !cbm_iec_atn_r(c1541->serial_bus)); |
| 452 | cbm_iec_data_w(c1541->serial_bus, device->owner, serial_data); |
| 453 | 453 | c1541->data_out = data_out; |
| 454 | 454 | |
| 455 | 455 | /* clock out */ |
| 456 | | cbmserial_clk_w(c1541->serial_bus, device->owner, !clk_out); |
| 456 | cbm_iec_clk_w(c1541->serial_bus, device->owner, !clk_out); |
| 457 | 457 | |
| 458 | 458 | /* attention acknowledge */ |
| 459 | 459 | c1541->atna = atna; |
| r6676 | r6677 | |
| 1074 | 1074 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(c1541); break; |
| 1075 | 1075 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 1076 | 1076 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(c1541); break; |
| 1077 | | case DEVINFO_FCT_CBM_SERIAL_ATN: info->f = (genf *)CBMSERIAL_ATN_NAME(c1541); break; |
| 1078 | | case DEVINFO_FCT_CBM_SERIAL_RESET: info->f = (genf *)CBMSERIAL_RESET_NAME(c1541); break; |
| 1077 | case DEVINFO_FCT_CBM_IEC_ATN: info->f = (genf *)CBM_IEC_ATN_NAME(c1541); break; |
| 1078 | case DEVINFO_FCT_CBM_IEC_RESET: info->f = (genf *)CBM_IEC_RESET_NAME(c1541); break; |
| 1079 | 1079 | |
| 1080 | 1080 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1081 | 1081 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore VIC-1540"); break; |
| r6676 | r6677 | |
| 1107 | 1107 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(c1541); break; |
| 1108 | 1108 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 1109 | 1109 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(c1541); break; |
| 1110 | | case DEVINFO_FCT_CBM_SERIAL_ATN: info->f = (genf *)CBMSERIAL_ATN_NAME(c1541); break; |
| 1111 | | case DEVINFO_FCT_CBM_SERIAL_RESET: info->f = (genf *)CBMSERIAL_RESET_NAME(c1541); break; |
| 1110 | case DEVINFO_FCT_CBM_IEC_ATN: info->f = (genf *)CBM_IEC_ATN_NAME(c1541); break; |
| 1111 | case DEVINFO_FCT_CBM_IEC_RESET: info->f = (genf *)CBM_IEC_RESET_NAME(c1541); break; |
| 1112 | 1112 | |
| 1113 | 1113 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1114 | 1114 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1541"); break; |
| r6676 | r6677 | |
| 1140 | 1140 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(c1541); break; |
| 1141 | 1141 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 1142 | 1142 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(c1541); break; |
| 1143 | | case DEVINFO_FCT_CBM_SERIAL_ATN: info->f = (genf *)CBMSERIAL_ATN_NAME(c1541); break; |
| 1144 | | case DEVINFO_FCT_CBM_SERIAL_RESET: info->f = (genf *)CBMSERIAL_RESET_NAME(c1541); break; |
| 1143 | case DEVINFO_FCT_CBM_IEC_ATN: info->f = (genf *)CBM_IEC_ATN_NAME(c1541); break; |
| 1144 | case DEVINFO_FCT_CBM_IEC_RESET: info->f = (genf *)CBM_IEC_RESET_NAME(c1541); break; |
| 1145 | 1145 | |
| 1146 | 1146 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1147 | 1147 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1541C"); break; |
| r6676 | r6677 | |
| 1173 | 1173 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(c1541); break; |
| 1174 | 1174 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 1175 | 1175 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(c1541); break; |
| 1176 | | case DEVINFO_FCT_CBM_SERIAL_ATN: info->f = (genf *)CBMSERIAL_ATN_NAME(c1541); break; |
| 1177 | | case DEVINFO_FCT_CBM_SERIAL_RESET: info->f = (genf *)CBMSERIAL_RESET_NAME(c1541); break; |
| 1176 | case DEVINFO_FCT_CBM_IEC_ATN: info->f = (genf *)CBM_IEC_ATN_NAME(c1541); break; |
| 1177 | case DEVINFO_FCT_CBM_IEC_RESET: info->f = (genf *)CBM_IEC_RESET_NAME(c1541); break; |
| 1178 | 1178 | |
| 1179 | 1179 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1180 | 1180 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1541-II"); break; |
src/mess/machine/vc20.c
| r6676 | r6677 | |
| 20 | 20 | #include "machine/6522via.h" |
| 21 | 21 | #include "video/vic6560.h" |
| 22 | 22 | #include "includes/vc1541.h" |
| 23 | | #include "includes/cbmserb.h" |
| 23 | #include "machine/cbmiec.h" |
| 24 | 24 | #include "includes/cbmieeeb.h" |
| 25 | 25 | #include "includes/cbmdrive.h" |
| 26 | 26 | |
| r6676 | r6677 | |
| 107 | 107 | |
| 108 | 108 | static READ8_DEVICE_HANDLER( vc20_via0_read_porta ) |
| 109 | 109 | { |
| 110 | | UINT8 value = 0xff; |
| 111 | | const device_config *serbus = devtag_get_device(device->machine, "serial_bus"); |
| 110 | const device_config *serbus = devtag_get_device(device->machine, "iec"); |
| 111 | UINT8 data = 0xfc; |
| 112 | 112 | |
| 113 | | value &= ~(input_port_read(device->machine, "JOY") & 0x3c); |
| 113 | data &= ~(input_port_read(device->machine, "JOY") & 0x3c); |
| 114 | 114 | |
| 115 | 115 | /* to short to be recognized normally */ |
| 116 | 116 | /* should be reduced to about 1 or 2 microseconds */ |
| 117 | 117 | /* if ((input_port_read(space->machine, "CTRLSEL") & 0x20 ) && (input_port_read(space->machine, "JOY") & 0x40) ) // i.e. LIGHTPEN_BUTTON |
| 118 | | value &= ~0x20; */ |
| 119 | | if (!serial_clock || !cbm_serial_clock_read(serbus, 0)) |
| 120 | | value &= ~0x01; |
| 121 | | if (!serial_data || !cbm_serial_data_read(serbus, 0)) |
| 122 | | value &= ~0x02; |
| 118 | data &= ~0x20; */ |
| 123 | 119 | |
| 120 | data |= cbm_iec_clk_r(serbus); |
| 121 | data |= cbm_iec_data_r(serbus) << 1; |
| 122 | |
| 124 | 123 | if ((cassette_get_state(devtag_get_device(device->machine, "cassette")) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| 125 | | value &= ~0x40; |
| 124 | data &= ~0x40; |
| 126 | 125 | else |
| 127 | | value |= 0x40; |
| 126 | data |= 0x40; |
| 128 | 127 | |
| 129 | | return value; |
| 128 | return data; |
| 130 | 129 | } |
| 131 | 130 | |
| 132 | 131 | static WRITE8_DEVICE_HANDLER( vc20_via0_write_porta ) |
| 133 | 132 | { |
| 134 | | const device_config *serbus = devtag_get_device(device->machine, "serial_bus"); |
| 133 | const device_config *serbus = devtag_get_device(device->machine, "iec"); |
| 135 | 134 | |
| 136 | | cbm_serial_atn_write(serbus, 0, serial_atn = !(data & 0x80)); |
| 135 | cbm_iec_atn_w(serbus, device, !(data & 0x80)); |
| 137 | 136 | DBG_LOG(device->machine, 1, "serial out", ("atn %s\n", serial_atn ? "high" : "low")); |
| 138 | 137 | } |
| 139 | 138 | |
| r6676 | r6677 | |
| 192 | 191 | |
| 193 | 192 | static WRITE8_DEVICE_HANDLER( vc20_via1_write_ca2 ) |
| 194 | 193 | { |
| 195 | | const device_config *serbus = devtag_get_device(device->machine, "serial_bus"); |
| 194 | const device_config *serbus = devtag_get_device(device->machine, "iec"); |
| 196 | 195 | |
| 197 | | cbm_serial_clock_write(serbus, 0, serial_clock = !data); |
| 196 | cbm_iec_clk_w(serbus, device, !data); |
| 198 | 197 | } |
| 199 | 198 | |
| 200 | 199 | static READ8_DEVICE_HANDLER( vc20_via1_read_portb ) |
| r6676 | r6677 | |
| 333 | 332 | |
| 334 | 333 | static READ8_DEVICE_HANDLER( vc20_via1_read_cb1 ) |
| 335 | 334 | { |
| 336 | | const device_config *serbus = devtag_get_device(device->machine, "serial_bus"); |
| 335 | const device_config *serbus = devtag_get_device(device->machine, "iec"); |
| 337 | 336 | |
| 338 | 337 | DBG_LOG(device->machine, 1, "serial in", ("request read\n")); |
| 339 | | return cbm_serial_request_read(serbus, 0); |
| 338 | return cbm_iec_srq_r(serbus); |
| 340 | 339 | } |
| 341 | 340 | |
| 342 | 341 | static WRITE8_DEVICE_HANDLER( vc20_via1_write_cb2 ) |
| 343 | 342 | { |
| 344 | | const device_config *serbus = devtag_get_device(device->machine, "serial_bus"); |
| 345 | | cbm_serial_data_write(serbus, 0, serial_data = !data); |
| 343 | const device_config *serbus = devtag_get_device(device->machine, "iec"); |
| 344 | cbm_iec_data_w(serbus, device, !data); |
| 346 | 345 | } |
| 347 | 346 | |
| 348 | 347 | /* ieee 6522 number 1 (via4) |
src/mess/machine/c1571.c
| r6676 | r6677 | |
| 14 | 14 | #include "formats/g64_dsk.h"
|
| 15 | 15 | #include "machine/6522via.h"
|
| 16 | 16 | #include "machine/6526cia.h"
|
| 17 | | #include "machine/cbmserial.h"
|
| 17 | #include "machine/cbmiec.h"
|
| 18 | 18 | #include "machine/wd17xx.h"
|
| 19 | 19 | |
| 20 | 20 | /***************************************************************************
|
| r6676 | r6677 | |
| 87 | 87 | c1571_atn_w - serial bus attention
|
| 88 | 88 | -------------------------------------------------*/
|
| 89 | 89 | |
| 90 | | static CBMSERIAL_ATN( c1571 )
|
| 90 | static CBM_IEC_ATN( c1571 )
|
| 91 | 91 | {
|
| 92 | 92 | c1571_t *c1571 = get_safe_token(device);
|
| 93 | 93 | int data_out = !c1571->data_out && !(c1571->atn_ack ^ !state);
|
| 94 | 94 | |
| 95 | 95 | via_ca1_w(c1571->via0, 0, !state);
|
| 96 | 96 | |
| 97 | | cbmserial_data_w(c1571->serial_bus, device, data_out);
|
| 97 | cbm_iec_data_w(c1571->serial_bus, device, data_out);
|
| 98 | 98 | }
|
| 99 | 99 | |
| 100 | 100 | /*-------------------------------------------------
|
| 101 | 101 | c1571_reset_w - serial bus reset
|
| 102 | 102 | -------------------------------------------------*/
|
| 103 | 103 | |
| 104 | | static CBMSERIAL_RESET( c1571 )
|
| 104 | static CBM_IEC_RESET( c1571 )
|
| 105 | 105 | {
|
| 106 | 106 | if (!state)
|
| 107 | 107 | {
|
| r6676 | r6677 | |
| 229 | 229 | UINT8 data = 0;
|
| 230 | 230 | |
| 231 | 231 | /* data in */
|
| 232 | | data = !cbmserial_data_r(c1571->serial_bus);
|
| 232 | data = !cbm_iec_data_r(c1571->serial_bus);
|
| 233 | 233 | |
| 234 | 234 | /* clock in */
|
| 235 | | data |= !cbmserial_clk_r(c1571->serial_bus) << 2;
|
| 235 | data |= !cbm_iec_clk_r(c1571->serial_bus) << 2;
|
| 236 | 236 | |
| 237 | 237 | /* serial bus address */
|
| 238 | 238 | data |= c1571->address << 5;
|
| 239 | 239 | |
| 240 | 240 | /* attention in */
|
| 241 | | data |= !cbmserial_atn_r(c1571->serial_bus) << 7;
|
| 241 | data |= !cbm_iec_atn_r(c1571->serial_bus) << 7;
|
| 242 | 242 | |
| 243 | 243 | return data;
|
| 244 | 244 | }
|
| r6676 | r6677 | |
| 267 | 267 | int atn_ack = BIT(data, 4);
|
| 268 | 268 | |
| 269 | 269 | /* data out */
|
| 270 | | int serial_data = !data_out && !(atn_ack ^ !cbmserial_atn_r(c1571->serial_bus));
|
| 271 | | cbmserial_data_w(c1571->serial_bus, device->owner, serial_data);
|
| 270 | int serial_data = !data_out && !(atn_ack ^ !cbm_iec_atn_r(c1571->serial_bus));
|
| 271 | cbm_iec_data_w(c1571->serial_bus, device->owner, serial_data);
|
| 272 | 272 | c1571->data_out = data_out;
|
| 273 | 273 | |
| 274 | 274 | /* clock out */
|
| 275 | | cbmserial_clk_w(c1571->serial_bus, device->owner, !clk_out);
|
| 275 | cbm_iec_clk_w(c1571->serial_bus, device->owner, !clk_out);
|
| 276 | 276 | |
| 277 | 277 | /* attention acknowledge */
|
| 278 | 278 | c1571->atn_ack = atn_ack;
|
| r6676 | r6677 | |
| 643 | 643 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(c1571); break;
|
| 644 | 644 | case DEVINFO_FCT_STOP: /* Nothing */ break;
|
| 645 | 645 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(c1571); break;
|
| 646 | | case DEVINFO_FCT_CBM_SERIAL_ATN: info->f = (genf *)CBMSERIAL_ATN_NAME(c1571); break;
|
| 647 | | case DEVINFO_FCT_CBM_SERIAL_RESET: info->f = (genf *)CBMSERIAL_RESET_NAME(c1571); break;
|
| 646 | case DEVINFO_FCT_CBM_IEC_ATN: info->f = (genf *)CBM_IEC_ATN_NAME(c1571); break;
|
| 647 | case DEVINFO_FCT_CBM_IEC_RESET: info->f = (genf *)CBM_IEC_RESET_NAME(c1571); break;
|
| 648 | 648 | |
| 649 | 649 | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 650 | 650 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1570"); break;
|
| r6676 | r6677 | |
| 676 | 676 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(c1571); break;
|
| 677 | 677 | case DEVINFO_FCT_STOP: /* Nothing */ break;
|
| 678 | 678 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(c1571); break;
|
| 679 | | case DEVINFO_FCT_CBM_SERIAL_ATN: info->f = (genf *)CBMSERIAL_ATN_NAME(c1571); break;
|
| 680 | | case DEVINFO_FCT_CBM_SERIAL_RESET: info->f = (genf *)CBMSERIAL_RESET_NAME(c1571); break;
|
| 679 | case DEVINFO_FCT_CBM_IEC_ATN: info->f = (genf *)CBM_IEC_ATN_NAME(c1571); break;
|
| 680 | case DEVINFO_FCT_CBM_IEC_RESET: info->f = (genf *)CBM_IEC_RESET_NAME(c1571); break;
|
| 681 | 681 | |
| 682 | 682 | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 683 | 683 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1571"); break;
|
| r6676 | r6677 | |
| 709 | 709 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(c1571); break;
|
| 710 | 710 | case DEVINFO_FCT_STOP: /* Nothing */ break;
|
| 711 | 711 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(c1571); break;
|
| 712 | | case DEVINFO_FCT_CBM_SERIAL_ATN: info->f = (genf *)CBMSERIAL_ATN_NAME(c1571); break;
|
| 713 | | case DEVINFO_FCT_CBM_SERIAL_RESET: info->f = (genf *)CBMSERIAL_RESET_NAME(c1571); break;
|
| 712 | case DEVINFO_FCT_CBM_IEC_ATN: info->f = (genf *)CBM_IEC_ATN_NAME(c1571); break;
|
| 713 | case DEVINFO_FCT_CBM_IEC_RESET: info->f = (genf *)CBM_IEC_RESET_NAME(c1571); break;
|
| 714 | 714 | |
| 715 | 715 | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 716 | 716 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1571CR"); break;
|
src/mess/drivers/vc20.c
| r6676 | r6677 | |
| 92 | 92 | |
| 93 | 93 | /* devices config */ |
| 94 | 94 | #include "includes/cbm.h" |
| 95 | | #include "includes/cbmserb.h" // needed for MDRV_DEVICE_REMOVE |
| 96 | | #include "includes/cbmdrive.h" |
| 95 | #include "machine/cbmiec.h" |
| 96 | #include "machine/c1541.h" |
| 97 | 97 | #include "includes/vc1541.h" |
| 98 | 98 | #include "includes/cbmieeeb.h" |
| 99 | 99 | #include "devices/messram.h" |
| r6676 | r6677 | |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | static CBM_IEC_DAISY( cbm_iec_daisy ) |
| 250 | { |
| 251 | { "via6522_0" }, |
| 252 | { "via6522_1" }, |
| 253 | { "c1540" }, |
| 254 | { NULL} |
| 255 | }; |
| 249 | 256 | |
| 250 | 257 | |
| 251 | 258 | /************************************* |
| r6676 | r6677 | |
| 290 | 297 | MDRV_CASSETTE_ADD( "cassette", cbm_cassette_config ) |
| 291 | 298 | |
| 292 | 299 | /* floppy from serial bus */ |
| 293 | | MDRV_IMPORT_FROM(simulated_drive) |
| 300 | MDRV_CBM_IEC_ADD("iec", cbm_iec_daisy) |
| 301 | MDRV_C1540_ADD("c1540", "iec", 8) |
| 294 | 302 | |
| 295 | 303 | /* IEEE bus */ |
| 296 | 304 | MDRV_CBM_IEEEBUS_ADD("ieee_bus") |
| r6676 | r6677 | |
| 313 | 321 | static MACHINE_DRIVER_START( vic20v ) |
| 314 | 322 | MDRV_IMPORT_FROM( vic20 ) |
| 315 | 323 | |
| 316 | | MDRV_DEVICE_REMOVE("serial_bus") // in the current code, serial bus device is tied to the floppy drive |
| 317 | | MDRV_IMPORT_FROM( cpu_vc1540 ) |
| 324 | MDRV_DEVICE_REMOVE("iec") |
| 325 | MDRV_DEVICE_REMOVE("c1540") |
| 318 | 326 | #ifdef CPU_SYNC |
| 319 | 327 | MDRV_QUANTUM_TIME(HZ(60)) |
| 320 | 328 | #else |
| r6676 | r6677 | |
| 353 | 361 | static MACHINE_DRIVER_START( vc20v ) |
| 354 | 362 | MDRV_IMPORT_FROM( vc20 ) |
| 355 | 363 | |
| 356 | | MDRV_DEVICE_REMOVE("serial_bus") // in the current code, serial bus device is tied to the floppy drive |
| 357 | | MDRV_IMPORT_FROM( cpu_vc1540 ) |
| 364 | MDRV_DEVICE_REMOVE("iec") |
| 365 | MDRV_DEVICE_REMOVE("c1540") |
| 358 | 366 | #ifdef CPU_SYNC |
| 359 | 367 | MDRV_QUANTUM_TIME(HZ(60)) |
| 360 | 368 | #else |
| r6676 | r6677 | |
| 434 | 442 | ROM_FILL( 0x9000, 0x3000, 0xff ) |
| 435 | 443 | ROM_LOAD( "901486.01", 0xc000, 0x2000, CRC(db4c43c1) SHA1(587d1e90950675ab6b12d91248a3f0d640d02e8d) ) |
| 436 | 444 | ROM_LOAD( "901486.06", 0xe000, 0x2000, CRC(e5e7c174) SHA1(06de7ec017a5e78bd6746d89c2ecebb646efeb19) ) |
| 437 | | |
| 438 | | VC1540_ROM("cpu_vc1540") |
| 439 | 445 | ROM_END |
| 440 | 446 | |
| 441 | 447 | ROM_START( vic20plv ) |
| r6676 | r6677 | |
| 445 | 451 | ROM_FILL( 0x9000, 0x3000, 0xff ) |
| 446 | 452 | ROM_LOAD( "901486.01", 0xc000, 0x2000, CRC(db4c43c1) SHA1(587d1e90950675ab6b12d91248a3f0d640d02e8d) ) |
| 447 | 453 | ROM_LOAD( "901486.07", 0xe000, 0x2000, CRC(4be07cb4) SHA1(ce0137ed69f003a299f43538fa9eee27898e621e) ) |
| 448 | | |
| 449 | | VC1540_ROM("cpu_vc1540") |
| 450 | 454 | ROM_END |
| 451 | 455 | |
| 452 | 456 | #define rom_vc20v rom_vic20plv |
| 453 | 457 | |
| 454 | 458 | |
| 455 | | /************************************* |
| 456 | | * |
| 457 | | * System configuration(s) |
| 458 | | * |
| 459 | | *************************************/ |
| 460 | | |
| 461 | | |
| 462 | | static SYSTEM_CONFIG_START(vic20) |
| 463 | | CONFIG_DEVICE(cbmfloppy_device_getinfo) |
| 464 | | |
| 465 | | SYSTEM_CONFIG_END |
| 466 | | |
| 467 | | static SYSTEM_CONFIG_START(vic20v) |
| 468 | | CONFIG_DEVICE(vc1541_device_getinfo) |
| 469 | | SYSTEM_CONFIG_END |
| 470 | | |
| 471 | | |
| 472 | 459 | /*************************************************************************** |
| 473 | 460 | |
| 474 | 461 | Game driver(s) |
| r6676 | r6677 | |
| 477 | 464 | |
| 478 | 465 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 479 | 466 | |
| 480 | | COMP( 1981, vic1001, vic20, 0, vic20, vic1001, vic20, vic20, "Commodore Business Machines Co.", "VIC-1001 (NTSC, Japan)", GAME_IMPERFECT_SOUND) |
| 467 | COMP( 1981, vic1001, vic20, 0, vic20, vic1001, vic20, 0, "Commodore Business Machines Co.", "VIC-1001 (NTSC, Japan)", GAME_IMPERFECT_SOUND) |
| 481 | 468 | |
| 482 | | COMP( 1981, vic20, 0, 0, vic20, vic20, vic20, vic20, "Commodore Business Machines Co.", "VIC 20 (NTSC)", GAME_IMPERFECT_SOUND) |
| 483 | | COMP( 1981, vic20cr, vic20, 0, vic20, vic20, vic20, vic20, "Commodore Business Machines Co.", "VIC 20CR (NTSC)", GAME_IMPERFECT_SOUND) |
| 484 | | COMP( 1981, vic20i, vic20, 0, vic20i, vic20, vic20i, vic20, "Commodore Business Machines Co.", "VIC 20 (NTSC, IEEE488 Interface - SYS45065)", GAME_IMPERFECT_SOUND) |
| 485 | | COMP( 1981, vic20v, vic20, 0, vic20v, vic20, vic20v, vic20v, "Commodore Business Machines Co.", "VIC 20 (NTSC, VC1540)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| 469 | COMP( 1981, vic20, 0, 0, vic20, vic20, vic20, 0, "Commodore Business Machines Co.", "VIC 20 (NTSC)", GAME_IMPERFECT_SOUND) |
| 470 | COMP( 1981, vic20cr, vic20, 0, vic20, vic20, vic20, 0, "Commodore Business Machines Co.", "VIC 20CR (NTSC)", GAME_IMPERFECT_SOUND) |
| 471 | COMP( 1981, vic20i, vic20, 0, vic20i, vic20, vic20i, 0, "Commodore Business Machines Co.", "VIC 20 (NTSC, IEEE488 Interface - SYS45065)", GAME_IMPERFECT_SOUND) |
| 472 | COMP( 1981, vic20v, vic20, 0, vic20v, vic20, vic20v, 0, "Commodore Business Machines Co.", "VIC 20 (NTSC, VC1540)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| 486 | 473 | |
| 487 | | COMP( 1981, vic20pal, vic20, 0, vc20, vc20, vc20, vic20, "Commodore Business Machines Co.", "VC 20 (PAL)", GAME_IMPERFECT_SOUND) |
| 488 | | COMP( 1981, vic20crp, vic20, 0, vc20, vc20, vc20, vic20, "Commodore Business Machines Co.", "VC 20CR (PAL)", GAME_IMPERFECT_SOUND) |
| 489 | | COMP( 1981, vic20plv, vic20, 0, vc20v, vic20, vc20v, vic20v, "Commodore Business Machines Co.", "VC 20 (PAL, VC1540)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| 490 | | COMP( 1981, vc20, vic20, 0, vc20, vc20, vc20, vic20, "Commodore Business Machines Co.", "VIC 20 (PAL, Germany)", GAME_IMPERFECT_SOUND) |
| 491 | | COMP( 1981, vc20v, vic20, 0, vc20v, vic20, vc20v, vic20v, "Commodore Business Machines Co.", "VIC 20 (PAL, Germany, VC1540)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| 474 | COMP( 1981, vic20pal, vic20, 0, vc20, vc20, vc20, 0, "Commodore Business Machines Co.", "VC 20 (PAL)", GAME_IMPERFECT_SOUND) |
| 475 | COMP( 1981, vic20crp, vic20, 0, vc20, vc20, vc20, 0, "Commodore Business Machines Co.", "VC 20CR (PAL)", GAME_IMPERFECT_SOUND) |
| 476 | COMP( 1981, vic20plv, vic20, 0, vc20v, vic20, vc20v, 0, "Commodore Business Machines Co.", "VC 20 (PAL, VC1540)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| 477 | COMP( 1981, vc20, vic20, 0, vc20, vc20, vc20, 0, "Commodore Business Machines Co.", "VIC 20 (PAL, Germany)", GAME_IMPERFECT_SOUND) |
| 478 | COMP( 1981, vc20v, vic20, 0, vc20v, vic20, vc20v, 0, "Commodore Business Machines Co.", "VIC 20 (PAL, Germany, VC1540)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| 492 | 479 | |
| 493 | | COMP( 1981, vic20swe, vic20, 0, vc20, vic20swe, vc20, vic20, "Commodore Business Machines Co.", "VIC 20 (PAL, Swedish Expansion Kit)", GAME_IMPERFECT_SOUND) |
| 480 | COMP( 1981, vic20swe, vic20, 0, vc20, vic20swe, vc20, 0, "Commodore Business Machines Co.", "VIC 20 (PAL, Swedish Expansion Kit)", GAME_IMPERFECT_SOUND) |