src/mess/machine/cbmieeeb.c
| r7041 | r7042 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | Commodore IEEE 488 (Parallel) Bus |
| 4 | | |
| 5 | | |
| 6 | | |
| 7 | | 2009-05 FP: Changed the implementation to be a MAME device. However, |
| 8 | | the main code has been kept the same as before (to reduce the risk of |
| 9 | | regressions, at this early stage). More work will be eventually done |
| 10 | | to improve emulation and to allow more devices (possibly of different |
| 11 | | kinds) to be connected to the bus like in the real thing. |
| 12 | | Notice that write handlers which are passed to the drivers, are always |
| 13 | | calling functions with the "device" parameter as 0. In turn, this calls |
| 14 | | c2031_state from machine/cbmdrive.c which calls again the functions with |
| 15 | | "device" parameter = 1! This forces the current code to export both the |
| 16 | | DEVICE_HANDLERs and the functions called by them. |
| 17 | | Eventually, proper emulation will remove the need of c2031_state (multiple |
| 18 | | devices would be identified by their tags) and it will allow to only export |
| 19 | | the DEVICE_HANDLERs, as it would be preferable. |
| 20 | | |
| 21 | | As I have written in cbmserb.c, you should not use this driver as an |
| 22 | | example of the right way to implement parallel devices in MAME/MESS! |
| 23 | | |
| 24 | | ***************************************************************************/ |
| 25 | | |
| 26 | | /* Documentation: */ |
| 27 | | /* |
| 28 | | |
| 29 | | IEEE-488 |
| 30 | | |
| 31 | | by Ruud Baltissen |
| 32 | | |
| 33 | | |
| 34 | | DISCLAIMER |
| 35 | | - All names with a copyright are acknowledged. |
| 36 | | - If the reader uses information from these documents to write software |
| 37 | | or build hardware, then it is on his own account. I cannot be held |
| 38 | | responsible for blowing up your computer, mother-in-law or whatever; it |
| 39 | | will always be your own fault. |
| 40 | | - I'm not a sexist, with 'he' and 'him' I also mean 'she' and 'her'. |
| 41 | | |
| 42 | | Copyrights |
| 43 | | - You may copy every bit on this page for NON-commercial use. I hope you |
| 44 | | enjoy it. If you use it, just give me at least some credit like "Stolen |
| 45 | | from Ruud" :-) |
| 46 | | |
| 47 | | |
| 48 | | The story of this document |
| 49 | | |
| 50 | | I own several CBM/PET-types equipped with an IEEE-488 interface. Due to the |
| 51 | | lack of any documentation on Internet about the technical background of this |
| 52 | | subject, I started to collect all kind information I could lay my hands on to |
| 53 | | make my own electronic manual. |
| 54 | | Everything in this manual is based on the original concept. Where Commodore |
| 55 | | used or did something else, I will mention this |
| 56 | | |
| 57 | | |
| 58 | | The history |
| 59 | | |
| 60 | | The IEEE-488 bus was developed by Hewlett-Packard to connect and control |
| 61 | | programmable instruments and they called it HP-IB. The interface quickly |
| 62 | | became very popular in the computer industry. The IEEE committee gave it its |
| 63 | | present number and renamed it to GPIB (General Purpose Interface Bus). |
| 64 | | Commodore started to use it to connect their floppydisks to their computers. |
| 65 | | One of my manuals said that it is used to connect printers as well but to be |
| 66 | | honest, I never heard of or saw a printer with an IEEE-interface. |
| 67 | | |
| 68 | | |
| 69 | | IEEE-488 Overview |
| 70 | | |
| 71 | | You can connect three type of devices to the IEEE-488 bus: |
| 72 | | - Listeners |
| 73 | | - Talkers |
| 74 | | - Controllers |
| 75 | | |
| 76 | | Some devices can perform more than one of these functions. The standard allows |
| 77 | | a maximum of 15 devices to be connected on the same bus. A minimum system |
| 78 | | consists of one Controller and one Talker or Listener device (i.e. a 8032 and |
| 79 | | a printer). |
| 80 | | A Listener is a device that can receive data from the bus when instructed by |
| 81 | | the Active Controller and a Talker transmits data on to the bus when |
| 82 | | instructed. It is possible to have several Controllers on the bus but only one |
| 83 | | may be active at any given time. The Active Controller may pass control to |
| 84 | | another controller which in turn can pass it back or on to another controller. |
| 85 | | The Controller can set up a talker and a group of listeners so that it is |
| 86 | | possible to send data between groups of devices as well. |
| 87 | | If you have more Controllers connected to each other, only one can be active |
| 88 | | at the startup-time. This Controller is called the System Controller. In our |
| 89 | | case it is obvious that this will be the CBM. This means that officially only |
| 90 | | one CBM is allowed on the bus according to IEEE-488. In fact you can connect |
| 91 | | more CBMs to the same bus without any problem as long as you take care that |
| 92 | | only one is performing a command at the time. In IEEE-488 terms: you, the |
| 93 | | user, acts as the System Controller, allowing one of the connected CBMs to be |
| 94 | | a temporary Active Controller for the time being. |
| 95 | | |
| 96 | | |
| 97 | | Interface Signals |
| 98 | | |
| 99 | | The IEEE-488 interface system consists of 16 signal lines and 8 ground lines. |
| 100 | | The 16 signal lines are divided into 3 groups: 8 data lines, 3 handshakelines, |
| 101 | | and 5 interface management lines. |
| 102 | | |
| 103 | | Data Lines |
| 104 | | The lines DIO1 through DIO8 are used to transfer addresses, control |
| 105 | | information and data. The formats for addresses and control bytes are |
| 106 | | defined by the IEEE-488 standard. DIO1 is the Least Significant Bit, |
| 107 | | corresponding to bit 0 on a CBM. |
| 108 | | |
| 109 | | Handshake Lines |
| 110 | | The three handshakelines (NRFD, NDAC, DAV) control the transfer of |
| 111 | | message bytes among the devices and form the method for acknowledging |
| 112 | | the transfer of data. This handshaking process guarantees that the |
| 113 | | bytes on the data lines are sent and received without any transmission |
| 114 | | errors and is one of the unique features of the IEEE-488 bus. |
| 115 | | The NRFD (Not Ready for Data) handshake line is asserted by a Listener |
| 116 | | to indicate it is not yet ready for the next data or control byte. Note |
| 117 | | that the CBM will not see NRFD released (i.e., ready for data) until |
| 118 | | all devices have released it. |
| 119 | | The NDAC (Not Data Accepted) handshake line is asserted by a Listener |
| 120 | | to indicate it has not yet accepted the data or control byte on the |
| 121 | | data lines. Note that the CBM will not see NDAC released (i.e., data |
| 122 | | accepted) until all devices have released it. |
| 123 | | The DAV (DAta Valid) handshake line is asserted by the Talker to |
| 124 | | indicate that a data or control byte has been placed on the data lines |
| 125 | | and has had the minimum specified stabilizing time. The byte can now be |
| 126 | | safely accepted by the devices. |
| 127 | | |
| 128 | | Handshaking |
| 129 | | The handshaking process is performed as follows. When the CBM or a |
| 130 | | Talker (i.e.: floppydisk) wishes to transmit data on the bus, it sets |
| 131 | | the DAV line high, data is not valid, and checks to see that the NRFD |
| 132 | | and NDAC lines are both low, and then it puts the data on the data |
| 133 | | lines. When all the devices that can receive the data are ready, each |
| 134 | | releases its NRFD (Not Ready For Data) line. When the last receiver |
| 135 | | releases NRFD, and it goes high, the CBM or Talker takes DAV low |
| 136 | | indicating that valid data is now on the bus. In response each receiver |
| 137 | | takes NRFD low again to indicate it is busy and releases NDAC (Not Data |
| 138 | | Accepted) when it has received the data. When the last receiver has |
| 139 | | accepted the data, NDAC will go high and the CBM or Talker can set DAV |
| 140 | | high again to transmit the next byte of data. Note that if after |
| 141 | | setting the DAV line high, the Controller or Talker senses that both |
| 142 | | NRFD and NDAC are high, an error will occur. Also if any device fails |
| 143 | | to perform its part of the handshake and releases either NDAC or NRFD, |
| 144 | | data cannot be transmitted over the bus. Eventually a timeout error |
| 145 | | will be generated. |
| 146 | | The speed of the data transfer is controlled by the response of the |
| 147 | | slowest device on the bus, for this reason it is difficult to estimate |
| 148 | | data transfer rates on the IEEE-488 bus as they are always device |
| 149 | | dependent. |
| 150 | | |
| 151 | | Interface Management Lines |
| 152 | | The five interface management lines (ATN, EOI, IFC, REN, SRQ) manage |
| 153 | | the flow of control and data bytes across the interface. |
| 154 | | The ATN (Attention) signal is asserted by the Controller to indicate |
| 155 | | that it is placing an address or control byte on the data bus. ATN is |
| 156 | | released to allow the assigned Talker to place status or data on the |
| 157 | | data bus. The Controller regains control by reasserting ATN; this is |
| 158 | | normally done synchronously with the handshake to avoid confusion |
| 159 | | between control and data bytes. |
| 160 | | The EOI (End or Identify) signal has two uses. A Talker may assert EOI |
| 161 | | simultaneously with the last byte of data to indicate end-of-data. The |
| 162 | | CBM may assert EOI along with ATN to initiate a parallel poll. Although |
| 163 | | many devices do not use parallel poll, all devices should use EOI to |
| 164 | | end transfers (many currently available ones do not). |
| 165 | | The IFC (Interface Clear) signal is asserted only by the System |
| 166 | | Controller in order to initialize all device interfaces to a known |
| 167 | | state. After releasing IFC, the System Controller is the Active |
| 168 | | Controller. In the CBMs IFC is operated by the RESET-line. |
| 169 | | The REN (Remote Enable) signal is asserted only by the System |
| 170 | | Controller. Its assertion does not place devices into remote control |
| 171 | | mode; REN only enables a device to go into remote mode when addressed |
| 172 | | to listen. When in remote mode, a device should ignore its local front |
| 173 | | panel controls. This line is connected to ground inside the Commodores. |
| 174 | | The SRQ (Service Request) line is like an interrupt: it may be asserted |
| 175 | | by any device to request the Controller to take some action. The |
| 176 | | Controller must determine which device is asserting SRQ by conducting |
| 177 | | a serial poll. The requesting device releases SRQ when it is polled. |
| 178 | | |
| 179 | | |
| 180 | | Resulting scheme |
| 181 | | |
| 182 | | Line NRFD NDAC DAV ATN EOI IFC REN SQR |
| 183 | | I O | I O | I O | I O | I O | I O | I O | I O | |
| 184 | | -----------|------|------|------|------|------|------|------|------| |
| 185 | | Listener | X | X | X | X | X | X | X | X | |
| 186 | | Talker | X | X | X | X | X | X | X | X | |
| 187 | | Controller | X X | X X | X X | X X | X X | X | G | X | |
| 188 | | |
| 189 | | X marks line used as "I = Input" or "O = Output" |
| 190 | | |
| 191 | | The block Controller/REN is marked G because a CBM doesn't use this line. In |
| 192 | | this case it is hardware-wired to GROUND. |
| 193 | | |
| 194 | | |
| 195 | | Service Request and Serial Polling |
| 196 | | |
| 197 | | If a device encounters a problem or a pre-programmed condition, it can |
| 198 | | activate the SQR-line by setting it (L). If the Controller detects this |
| 199 | | request, it can initiate a 'Serial Poll' by transmitting the command SPE ($18) |
| 200 | | on the bus. It then places an address von the bus, activates ATN (which makes |
| 201 | | the addressed device a talker) an de-activates it. |
| 202 | | If the device requested service, it will respond by setting DIO7 (L). It may |
| 203 | | indicate the nature of the request by setting other lines low as well. The |
| 204 | | Controller can now take appropriate actions. When all devices have been |
| 205 | | polled, the controller terminates the serial poll by issuing the command SPD |
| 206 | | ($19). |
| 207 | | |
| 208 | | |
| 209 | | Device Addresses |
| 210 | | The IEEE-488 standard allows up to 15 devices to be interconnected on one bus. |
| 211 | | Each device is assigned a unique primary address, ranging from 4-30, by |
| 212 | | setting the address switches on the device. A secondary address may also be |
| 213 | | specified, ranging from 0-31. See the device documentation for more |
| 214 | | information on how to set the device primary and optional secondary address. |
| 215 | | |
| 216 | | |
| 217 | | The hardware |
| 218 | | |
| 219 | | Looking at the circuitdiagrams of a PET, like the 3008, then you can see that |
| 220 | | the MC3446 is used as the driver for all the signals. According to "The PET |
| 221 | | revealed" by Nick Hampshire, these ICs have 'Open Collector'-outputs which |
| 222 | | means you can interconnect them without any fear of 'blowing up' a computer |
| 223 | | or device. |
| 224 | | Other models are equipped with the SN75160 and the SN75161 from Texas |
| 225 | | Instruments. These ICs are drivers especially developed for IEEE-488. |
| 226 | | The major difference between the two types is that you need one separate in- |
| 227 | | and outputline for every IEEE-line, together 32 lines. This means you need at |
| 228 | | least two 6522s or 6520s. For the SN-drivers you only need 19 lines or one |
| 229 | | 6525. |
| 230 | | The 720 is equipped with the SN-drivers. The Pet 3008, CBM 8032SK, 3040 and |
| 231 | | 4040 are equipped with four MC3446s. The CBM 8296 uses one 7417 and three |
| 232 | | MC3446s. |
| 233 | | |
| 234 | | |
| 235 | | The SN75160 |
| 236 | | |
| 237 | | You can roughly describe the 75160 as a bidirectional 8-bits bus interface. |
| 238 | | (like the 74245) |
| 239 | | |
| 240 | | |
| 241 | | The SN75161 |
| 242 | | |
| 243 | | The SN75161 is used to buffer the handshake- and interface managementlines. |
| 244 | | There is some internal logic to steer the output as follows: |
| 245 | | |
| 246 | | | ATN |
| 247 | | | NDAC | IFC |
| 248 | | | NRFD | REN |
| 249 | | ATN | TE | DC || EOI | DAVV | SQR |
| 250 | | ------------------------------------------------- |
| 251 | | L | L | L || O | O | O |
| 252 | | L | L | H || I | O | I |
| 253 | | L | H | L || O | I | O |
| 254 | | L | H | H || I | I | I |
| 255 | | H | L | L || O | O | O |
| 256 | | H | L | H || O | O | I |
| 257 | | H | H | L || I | I | O |
| 258 | | H | H | H || I | I | I |
| 259 | | |
| 260 | | In words: ATN, IFC, REN and SQR are outputs if DC = (L), else inputs. |
| 261 | | DAVV,NDAC and NRFD are outputs if TE = (L), else inputs. EOI behaves like DAVV |
| 262 | | when ATN = (H), else like SQR. |
| 263 | | |
| 264 | | |
| 265 | | Physical Characteristics |
| 266 | | |
| 267 | | You can link devices in either a linear, star or combination configuration |
| 268 | | using a shielded 24-conductor cable. The standard IEEE-488 cable has both a |
| 269 | | plug and receptacle connector on both ends. This connector is the Amphenol |
| 270 | | CHAMP or Cinch Series 57 MICRO RIBBON type. (it looks like a Centronics |
| 271 | | connector, but smaller) As far as I know all Commodore periphiral devices, |
| 272 | | like floppy-disks, and the CBM-8xxx series are equiped with this type of |
| 273 | | connector.The other CBMs and PETs are equiped with a male edge connector. |
| 274 | | (like the userport of a C64 or VIC-20) |
| 275 | | |
| 276 | | |
| 277 | | Pin Signal Abbreviation Source |
| 278 | | --- ---------------- ------------ ------------------ |
| 279 | | 1 Data Bit 1 DIO1 Talker |
| 280 | | 2 Data Bit 2 DIO2 Talker |
| 281 | | 3 Data Bit 3 DIO3 Talker |
| 282 | | 4 Data Bit 4 DIO4 Talker |
| 283 | | 5 End Or Indentity EOI Talker/Controller |
| 284 | | 6 Data Valid DAV Controller |
| 285 | | 7 Not Ready For Data NRFD Listener |
| 286 | | 8 No Data Accepted NDAC Listener |
| 287 | | 9 Interface Clear IFC Controller |
| 288 | | 10 Service Request SRQ Talker |
| 289 | | 11 Attention ATN Controller |
| 290 | | 12 Shield |
| 291 | | 13 Data Bit 5 DIO5 Talker |
| 292 | | 14 Data Bit 6 DIO6 Talker |
| 293 | | 15 Data Bit 7 DIO7 Talker |
| 294 | | 16 Data Bit 8 DIO8 Talker |
| 295 | | 17 Remote Enabled REN Controller |
| 296 | | 18 Ground DAV |
| 297 | | 19 Ground NRFD |
| 298 | | 20 Ground NDAC |
| 299 | | 21 Ground IFC |
| 300 | | 22 Ground SRQ |
| 301 | | 23 Ground ATN |
| 302 | | 24 Logical Ground |
| 303 | | |
| 304 | | |
| 305 | | |
| 306 | | |
| 307 | | Credits: |
| 308 | | |
| 309 | | - Gary Pfeiffer, Hewlett-Packard |
| 310 | | - Nick Hampshire |
| 311 | | - Marko Makela |
| 312 | | |
| 313 | | |
| 314 | | |
| 315 | | You can reach me at: |
| 316 | | |
| 317 | | rbaltiss@worldaccess.nl |
| 318 | | |
| 319 | | |
| 320 | | My Commodore Site: http://www.worldaccess.nl/~rbaltiss/cbm.htm |
| 321 | | */ |
| 322 | | |
| 323 | | |
| 324 | | #include "driver.h" |
| 325 | | |
| 326 | | #include "includes/cbmieeeb.h" |
| 327 | | |
| 328 | | /*************************************************************************** |
| 329 | | TYPE DEFINITIONS |
| 330 | | ***************************************************************************/ |
| 331 | | |
| 332 | | typedef struct _cbm_ieee_bus_t cbm_ieee_bus_t; |
| 333 | | struct _cbm_ieee_bus_t |
| 334 | | { |
| 335 | | struct { |
| 336 | | UINT8 data; |
| 337 | | /* int fic; */ |
| 338 | | int dav, nrfd, ndac, atn, eoi, ren; |
| 339 | | int srq; |
| 340 | | } bus[2]; |
| 341 | | }; |
| 342 | | |
| 343 | | /*************************************************************************** |
| 344 | | INLINE FUNCTIONS |
| 345 | | ***************************************************************************/ |
| 346 | | |
| 347 | | INLINE cbm_ieee_bus_t *get_safe_token(const device_config *device) |
| 348 | | { |
| 349 | | assert(device != NULL); |
| 350 | | assert(device->token != NULL); |
| 351 | | assert(device->type == CBM_IEEEBUS); |
| 352 | | return (cbm_ieee_bus_t *)device->token; |
| 353 | | } |
| 354 | | |
| 355 | | /*************************************************************************** |
| 356 | | IMPLEMENTATION |
| 357 | | ***************************************************************************/ |
| 358 | | |
| 359 | | #define VERBOSE_LEVEL 0 |
| 360 | | #define DBG_LOG( MACHINE, N, M, A ) \ |
| 361 | | do { \ |
| 362 | | if(VERBOSE_LEVEL >= N) \ |
| 363 | | { \ |
| 364 | | if( M ) \ |
| 365 | | logerror("%11.6f: %-24s", attotime_to_double(timer_get_time(MACHINE)), (char*) M ); \ |
| 366 | | logerror A; \ |
| 367 | | } \ |
| 368 | | } while (0) |
| 369 | | |
| 370 | | |
| 371 | | /* |
| 372 | | data 8 bit input/output |
| 373 | | |
| 374 | | all handshake lines low active |
| 375 | | |
| 376 | | handshake lines: |
| 377 | | dav data valid (asserted by talker) |
| 378 | | nrfd nor ready for data (asserted by listener) |
| 379 | | ndac not data accepted (asserted by listener) |
| 380 | | |
| 381 | | atn attention |
| 382 | | eoi end of information |
| 383 | | |
| 384 | | ifc |
| 385 | | ren |
| 386 | | srq serial request master input, other output |
| 387 | | */ |
| 388 | | |
| 389 | | /* TODO - These functions are used in the write handlers but also in c2031_state, hence |
| 390 | | cannot be static. However, it would be better if only the WRITE8_DEVICE_HANDLER would be |
| 391 | | made available to the rest of the source. */ |
| 392 | | |
| 393 | | void cbm_ieee_dav_w( const device_config *ieeedev, int device, int data ) |
| 394 | | { |
| 395 | | cbm_ieee_bus_t *ieeebus = get_safe_token(ieeedev); |
| 396 | | |
| 397 | | // DBG_LOG(ieeedev->machine, 1, "cbm ieee dav", ("%.4x dev:%d %d\n", activecpu_get_pc(), device, data)); |
| 398 | | ieeebus->bus[device].dav = data; |
| 399 | | //removed if (device == 0) |
| 400 | | //removed c2031_state(ieeedev->machine, cbm_drive); |
| 401 | | } |
| 402 | | |
| 403 | | WRITE8_DEVICE_HANDLER( cbm_ieee_dav_write ) |
| 404 | | { |
| 405 | | cbm_ieee_dav_w(device, 0, data ); |
| 406 | | } |
| 407 | | |
| 408 | | void cbm_ieee_nrfd_w( const device_config *ieeedev, int device, int data ) |
| 409 | | { |
| 410 | | cbm_ieee_bus_t *ieeebus = get_safe_token(ieeedev); |
| 411 | | |
| 412 | | // DBG_LOG(ieeedev->machine, 1, "cbm ieee nrfd", ("%.4x dev:%d %d\n", activecpu_get_pc(), device, data)); |
| 413 | | ieeebus->bus[device].nrfd = data; |
| 414 | | //removed if (device == 0) |
| 415 | | //removed c2031_state(ieeedev->machine, cbm_drive); |
| 416 | | } |
| 417 | | |
| 418 | | WRITE8_DEVICE_HANDLER( cbm_ieee_nrfd_write ) |
| 419 | | { |
| 420 | | cbm_ieee_nrfd_w(device, 0, data ); |
| 421 | | } |
| 422 | | |
| 423 | | void cbm_ieee_ndac_w( const device_config *ieeedev, int device, int data ) |
| 424 | | { |
| 425 | | cbm_ieee_bus_t *ieeebus = get_safe_token(ieeedev); |
| 426 | | |
| 427 | | // DBG_LOG(ieeedev->machine, 1, "cbm ieee ndac",("%.4x dev:%d %d\n", activecpu_get_pc(), device, data)); |
| 428 | | ieeebus->bus[device].ndac = data; |
| 429 | | //removed if (device == 0) |
| 430 | | //removed c2031_state(ieeedev->machine, cbm_drive); |
| 431 | | } |
| 432 | | |
| 433 | | WRITE8_DEVICE_HANDLER( cbm_ieee_ndac_write ) |
| 434 | | { |
| 435 | | cbm_ieee_ndac_w(device, 0, data ); |
| 436 | | } |
| 437 | | |
| 438 | | void cbm_ieee_atn_w( const device_config *ieeedev, int device, int data ) |
| 439 | | { |
| 440 | | cbm_ieee_bus_t *ieeebus = get_safe_token(ieeedev); |
| 441 | | |
| 442 | | // DBG_LOG(ieeedev->machine, 1, "cbm ieee atn",("%.4x dev:%d %d\n", activecpu_get_pc(), device, data)); |
| 443 | | ieeebus->bus[device].atn = data; |
| 444 | | //removed if (device == 0) |
| 445 | | //removed c2031_state(ieeedev->machine, cbm_drive); |
| 446 | | } |
| 447 | | |
| 448 | | WRITE8_DEVICE_HANDLER( cbm_ieee_atn_write ) |
| 449 | | { |
| 450 | | cbm_ieee_atn_w(device, 0, data ); |
| 451 | | } |
| 452 | | |
| 453 | | void cbm_ieee_eoi_w( const device_config *ieeedev, int device, int data ) |
| 454 | | { |
| 455 | | cbm_ieee_bus_t *ieeebus = get_safe_token(ieeedev); |
| 456 | | |
| 457 | | // DBG_LOG(ieeedev->machine, 1, "cbm ieee eoi", ("%.4x dev:%d %d\n", activecpu_get_pc(), device, data)); |
| 458 | | ieeebus->bus[device].eoi = data; |
| 459 | | //removed if (device == 0) |
| 460 | | //removed c2031_state(ieeedev->machine, cbm_drive); |
| 461 | | } |
| 462 | | |
| 463 | | WRITE8_DEVICE_HANDLER( cbm_ieee_eoi_write ) |
| 464 | | { |
| 465 | | cbm_ieee_eoi_w(device, 0, data ); |
| 466 | | } |
| 467 | | |
| 468 | | void cbm_ieee_data_w( const device_config *ieeedev, int device, int data ) |
| 469 | | { |
| 470 | | cbm_ieee_bus_t *ieeebus = get_safe_token(ieeedev); |
| 471 | | |
| 472 | | // DBG_LOG(ieeedev->machine, 1, "cbm ieee data", ("%.4x dev:%d %.2x\n", activecpu_get_pc(), device, data)); |
| 473 | | ieeebus->bus[device].data = data; |
| 474 | | //removed if (device == 0) |
| 475 | | //removed c2031_state(ieeedev->machine, cbm_drive); |
| 476 | | } |
| 477 | | |
| 478 | | WRITE8_DEVICE_HANDLER( cbm_ieee_data_write ) |
| 479 | | { |
| 480 | | cbm_ieee_data_w(device, 0, data ); |
| 481 | | } |
| 482 | | |
| 483 | | |
| 484 | | READ8_DEVICE_HANDLER( cbm_ieee_srq_r ) |
| 485 | | { |
| 486 | | cbm_ieee_bus_t *ieeebus = get_safe_token(device); |
| 487 | | int data = ieeebus->bus[1].srq; |
| 488 | | |
| 489 | | DBG_LOG(device->machine, 1, "cbm ieee srq", ("read %d\n", data)); |
| 490 | | return data; |
| 491 | | } |
| 492 | | |
| 493 | | READ8_DEVICE_HANDLER( cbm_ieee_dav_r ) |
| 494 | | { |
| 495 | | cbm_ieee_bus_t *ieeebus = get_safe_token(device); |
| 496 | | int data = ieeebus->bus[0].dav && ieeebus->bus[1].dav; |
| 497 | | |
| 498 | | DBG_LOG(device->machine, 1, "cbm ieee dav", ("read %d\n", data)); |
| 499 | | return data; |
| 500 | | } |
| 501 | | |
| 502 | | READ8_DEVICE_HANDLER( cbm_ieee_nrfd_r ) |
| 503 | | { |
| 504 | | cbm_ieee_bus_t *ieeebus = get_safe_token(device); |
| 505 | | int data = ieeebus->bus[0].nrfd && ieeebus->bus[1].nrfd; |
| 506 | | |
| 507 | | DBG_LOG(device->machine, 1, "cbm ieee nrfd", ("read %d\n", data)); |
| 508 | | return data; |
| 509 | | } |
| 510 | | |
| 511 | | READ8_DEVICE_HANDLER( cbm_ieee_ndac_r ) |
| 512 | | { |
| 513 | | cbm_ieee_bus_t *ieeebus = get_safe_token(device); |
| 514 | | int data = ieeebus->bus[0].ndac && ieeebus->bus[1].ndac; |
| 515 | | |
| 516 | | DBG_LOG(device->machine, 1,"cbm ieee ndac", ("read %d\n", data)); |
| 517 | | return data; |
| 518 | | } |
| 519 | | |
| 520 | | READ8_DEVICE_HANDLER( cbm_ieee_atn_r ) |
| 521 | | { |
| 522 | | cbm_ieee_bus_t *ieeebus = get_safe_token(device); |
| 523 | | int data = ieeebus->bus[0].atn && ieeebus->bus[1].atn; |
| 524 | | |
| 525 | | DBG_LOG(device->machine, 1,"cbm ieee atn", ("read %d\n", data)); |
| 526 | | return data; |
| 527 | | } |
| 528 | | |
| 529 | | READ8_DEVICE_HANDLER( cbm_ieee_eoi_r ) |
| 530 | | { |
| 531 | | cbm_ieee_bus_t *ieeebus = get_safe_token(device); |
| 532 | | int data = ieeebus->bus[0].eoi && ieeebus->bus[1].eoi; |
| 533 | | |
| 534 | | /* DBG_LOG(device->machine, 1, "cbm ieee eoi", ("read %d\n", data)); */ |
| 535 | | return data; |
| 536 | | } |
| 537 | | |
| 538 | | READ8_DEVICE_HANDLER( cbm_ieee_data_r ) |
| 539 | | { |
| 540 | | cbm_ieee_bus_t *ieeebus = get_safe_token(device); |
| 541 | | int data = ieeebus->bus[0].data & ieeebus->bus[1].data; |
| 542 | | |
| 543 | | DBG_LOG(device->machine, 1, "cbm ieee data", ("read %.2x\n", data)); |
| 544 | | return data; |
| 545 | | } |
| 546 | | |
| 547 | | |
| 548 | | READ8_DEVICE_HANDLER( cbm_ieee_state ) |
| 549 | | { |
| 550 | | cbm_ieee_bus_t *ieeebus = get_safe_token(device); |
| 551 | | |
| 552 | | switch (offset) |
| 553 | | { |
| 554 | | case 0: return ieeebus->bus[0].data; |
| 555 | | case 1: return ieeebus->bus[0].atn; |
| 556 | | case 2: return ieeebus->bus[0].dav; |
| 557 | | case 3: return ieeebus->bus[0].ndac; |
| 558 | | case 4: return ieeebus->bus[0].nrfd; |
| 559 | | case 5: return ieeebus->bus[0].eoi; |
| 560 | | case 6: return ieeebus->bus[0].ren; |
| 561 | | case 7: return ieeebus->bus[0].srq; |
| 562 | | |
| 563 | | case 0x10: return ieeebus->bus[1].data; |
| 564 | | case 0x11: return ieeebus->bus[1].atn; |
| 565 | | case 0x12: return ieeebus->bus[1].dav; |
| 566 | | case 0x13: return ieeebus->bus[1].ndac; |
| 567 | | case 0x14: return ieeebus->bus[1].nrfd; |
| 568 | | case 0x15: return ieeebus->bus[1].eoi; |
| 569 | | case 0x16: return ieeebus->bus[1].ren; |
| 570 | | case 0x17: return ieeebus->bus[1].srq; |
| 571 | | } |
| 572 | | |
| 573 | | return 0; |
| 574 | | } |
| 575 | | |
| 576 | | /*------------------------------------------------- |
| 577 | | DEVICE_START( cbm_ieee_bus ) |
| 578 | | -------------------------------------------------*/ |
| 579 | | |
| 580 | | static DEVICE_START( cbm_ieee_bus ) |
| 581 | | { |
| 582 | | cbm_ieee_bus_t *ieeebus = get_safe_token(device); |
| 583 | | |
| 584 | | memset(ieeebus, 0, sizeof(*ieeebus)); |
| 585 | | |
| 586 | | /* register for state saving */ |
| 587 | | // We need to save here ieeebus->bus[i]! |
| 588 | | } |
| 589 | | |
| 590 | | /*------------------------------------------------- |
| 591 | | DEVICE_RESET( cbm_ieee_bus ) |
| 592 | | -------------------------------------------------*/ |
| 593 | | |
| 594 | | static DEVICE_RESET( cbm_ieee_bus ) |
| 595 | | { |
| 596 | | cbm_ieee_bus_t *ieeebus = get_safe_token(device); |
| 597 | | int i; |
| 598 | | |
| 599 | | for (i = 0; i < 2; i++) |
| 600 | | { |
| 601 | | ieeebus->bus[i].dav = 1; |
| 602 | | ieeebus->bus[i].nrfd = 1; |
| 603 | | ieeebus->bus[i].ndac = 1; |
| 604 | | ieeebus->bus[i].atn = 1; |
| 605 | | ieeebus->bus[i].eoi = 1; |
| 606 | | ieeebus->bus[i].srq = 1; |
| 607 | | |
| 608 | | ieeebus->bus[i].data = 0xff; |
| 609 | | } |
| 610 | | } |
| 611 | | |
| 612 | | /*------------------------------------------------- |
| 613 | | DEVICE_GET_INFO( cbm_ieee_bus ) |
| 614 | | -------------------------------------------------*/ |
| 615 | | |
| 616 | | DEVICE_GET_INFO( cbm_ieee_bus ) |
| 617 | | { |
| 618 | | switch (state) |
| 619 | | { |
| 620 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 621 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cbm_ieee_bus_t); break; |
| 622 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 623 | | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 624 | | |
| 625 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 626 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cbm_ieee_bus); break; |
| 627 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 628 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(cbm_ieee_bus); break; |
| 629 | | |
| 630 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 631 | | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore IEEE Bus"); break; |
| 632 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Commodore IEEE Bus"); break; |
| 633 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 634 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 635 | | case DEVINFO_STR_CREDITS: /* Nothing */ break; |
| 636 | | } |
| 637 | | } |
src/mess/machine/pet.c
| r7041 | r7042 | |
| 11 | 11 | #include "includes/cbm.h" |
| 12 | 12 | #include "machine/6821pia.h" |
| 13 | 13 | #include "machine/6522via.h" |
| 14 | | #include "includes/cbmserb.h" |
| 15 | | #include "includes/cbmieeeb.h" |
| 14 | #include "machine/ieee488.h" |
| 16 | 15 | |
| 17 | 16 | #include "includes/pet.h" |
| 18 | 17 | |
| r7041 | r7042 | |
| 85 | 84 | if ((cassette_get_state(devtag_get_device(device->machine, "cassette2")) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| 86 | 85 | data &= ~0x20; |
| 87 | 86 | |
| 88 | | if (!cbm_ieee_eoi_r(ieeebus, 0)) |
| 87 | if (!ieee488_eoi_r(ieeebus)) |
| 89 | 88 | data &= ~0x40; |
| 90 | 89 | |
| 91 | 90 | return data; |
| r7041 | r7042 | |
| 156 | 155 | static WRITE8_DEVICE_HANDLER( pet_pia0_ca2_out ) |
| 157 | 156 | { |
| 158 | 157 | const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus"); |
| 159 | | cbm_ieee_eoi_write(ieeebus, 0, data); |
| 158 | ieee488_eoi_w(ieeebus, device, data); |
| 160 | 159 | } |
| 161 | 160 | |
| 162 | 161 | static WRITE8_DEVICE_HANDLER( pet_pia0_cb2_out ) |
| r7041 | r7042 | |
| 200 | 199 | static READ8_DEVICE_HANDLER( pet_pia1_port_a_read ) |
| 201 | 200 | { |
| 202 | 201 | const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus"); |
| 203 | | return cbm_ieee_data_r(ieeebus, 0); |
| 202 | return ieee488_dio_r(ieeebus, 0); |
| 204 | 203 | } |
| 205 | 204 | |
| 206 | 205 | static WRITE8_DEVICE_HANDLER( pet_pia1_port_b_write ) |
| 207 | 206 | { |
| 208 | 207 | const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus"); |
| 209 | | cbm_ieee_data_write(ieeebus, 0, data); |
| 208 | ieee488_dio_w(ieeebus, device, data); |
| 210 | 209 | } |
| 211 | 210 | |
| 212 | 211 | static READ8_DEVICE_HANDLER( pet_pia1_ca1_read ) |
| 213 | 212 | { |
| 214 | 213 | const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus"); |
| 215 | | return cbm_ieee_atn_r(ieeebus,0 ); |
| 214 | return ieee488_atn_r(ieeebus); |
| 216 | 215 | } |
| 217 | 216 | |
| 218 | 217 | static WRITE8_DEVICE_HANDLER( pet_pia1_ca2_write ) |
| 219 | 218 | { |
| 220 | 219 | const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus"); |
| 221 | | cbm_ieee_ndac_write(ieeebus, 0, data); |
| 220 | ieee488_ndac_w(ieeebus, device, data); |
| 222 | 221 | } |
| 223 | 222 | |
| 224 | 223 | static WRITE8_DEVICE_HANDLER( pet_pia1_cb2_write ) |
| 225 | 224 | { |
| 226 | 225 | const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus"); |
| 227 | | cbm_ieee_dav_write(ieeebus, 0, data); |
| 226 | ieee488_dav_w(ieeebus, device, data); |
| 228 | 227 | } |
| 229 | 228 | |
| 230 | 229 | static READ8_DEVICE_HANDLER( pet_pia1_cb1_read ) |
| 231 | 230 | { |
| 232 | 231 | const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus"); |
| 233 | | return cbm_ieee_srq_r(ieeebus, 0); |
| 232 | return ieee488_srq_r(ieeebus); |
| 234 | 233 | } |
| 235 | 234 | |
| 236 | 235 | const pia6821_interface pet_pia0 = |
| r7041 | r7042 | |
| 310 | 309 | const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus"); |
| 311 | 310 | UINT8 data = 0; |
| 312 | 311 | |
| 313 | | if (cbm_ieee_ndac_r(ieeebus, 0)) |
| 312 | if (ieee488_ndac_r(ieeebus)) |
| 314 | 313 | data |= 0x01; |
| 315 | 314 | |
| 316 | 315 | // data & 0x08 -> cassette write (it seems to BOTH cassettes from schematics) |
| r7041 | r7042 | |
| 326 | 325 | timer_reset(datasette2_timer, attotime_never); |
| 327 | 326 | } |
| 328 | 327 | |
| 329 | | if (cbm_ieee_nrfd_r(ieeebus, 0)) |
| 328 | if (ieee488_nrfd_r(ieeebus)) |
| 330 | 329 | data |= 0x40; |
| 331 | 330 | |
| 332 | | if (cbm_ieee_dav_r(ieeebus, 0)) |
| 331 | if (ieee488_dav_r(ieeebus)) |
| 333 | 332 | data |= 0x80; |
| 334 | 333 | |
| 335 | 334 | return data; |
| r7041 | r7042 | |
| 346 | 345 | static WRITE8_DEVICE_HANDLER( pet_via_port_b_w ) |
| 347 | 346 | { |
| 348 | 347 | const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus"); |
| 349 | | cbm_ieee_nrfd_write(ieeebus, 0, data & 2); |
| 350 | | cbm_ieee_atn_write(ieeebus, 0, data & 4); |
| 348 | ieee488_nrfd_w(ieeebus, device, BIT(data, 1)); |
| 349 | ieee488_atn_w(ieeebus, device, BIT(data, 2)); |
| 351 | 350 | } |
| 352 | 351 | |
| 353 | 352 | |
| r7041 | r7042 | |
| 689 | 688 | MACHINE_RESET( pet ) |
| 690 | 689 | { |
| 691 | 690 | pet_state *state = machine->driver_data; |
| 691 | const device_config *ieeebus = devtag_get_device(machine, "ieee_bus"); |
| 692 | const device_config *scapegoat = devtag_get_device(machine, "pia_0"); |
| 692 | 693 | |
| 693 | 694 | if (state->superpet) |
| 694 | 695 | { |
| r7041 | r7042 | |
| 723 | 724 | //removed cbm_drive_0_config (input_port_read(machine, "CFG") & 2 ? IEEE : 0, 8); |
| 724 | 725 | //removed cbm_drive_1_config (input_port_read(machine, "CFG") & 1 ? IEEE : 0, 9); |
| 725 | 726 | device_reset(cputag_get_cpu(machine, "maincpu")); |
| 727 | |
| 728 | ieee488_ren_w(ieeebus, scapegoat, 0); |
| 729 | ieee488_ifc_w(ieeebus, scapegoat, 0); |
| 730 | ieee488_ifc_w(ieeebus, scapegoat, 1); |
| 726 | 731 | } |
| 727 | 732 | |
| 728 | 733 | |