Previous 15994 Revisions Next

r7042 Friday 15th January, 2010 at 11:50:10 UTC by Curt Coder
[CBMB, PET] Refactored to use the new IEEE-488 bus, and removed the old CBM IEEE implementation.
[src/mess]mess.mak
[src/mess/drivers]cbmb.c pet.c
[src/mess/includes]cbmb.h cbmieeeb.h
[src/mess/machine]cbmb.c cbmieeeb.c pet.c

src/mess/includes/cbmieeeb.h
r7041r7042
1/*****************************************************************************
2 *
3 * includes/cbmieeeb.h
4 *
5 ****************************************************************************/
6
7#ifndef CBMIEEEB_H_
8#define CBMIEEEB_H_
9
10
11/*----------- defined in machine/cbmieeeb.c -----------*/
12
13/***************************************************************************
14    MACROS / CONSTANTS
15***************************************************************************/
16
17#define CBM_IEEEBUS      DEVICE_GET_INFO_NAME(cbm_ieee_bus)
18
19#define MDRV_CBM_IEEEBUS_ADD(_tag) \
20   MDRV_DEVICE_ADD(_tag, CBM_IEEEBUS, 0)
21
22/***************************************************************************
23    PROTOTYPES
24***************************************************************************/
25
26DEVICE_GET_INFO( cbm_ieee_bus );
27
28void cbm_ieee_dav_w(const device_config *ieeedev, int device, int data);
29void cbm_ieee_nrfd_w(const device_config *ieeedev, int device, int data);
30void cbm_ieee_ndac_w(const device_config *ieeedev, int device, int data);
31void cbm_ieee_atn_w(const device_config *ieeedev, int device, int data);
32void cbm_ieee_eoi_w(const device_config *ieeedev, int device, int data);
33void cbm_ieee_data_w(const device_config *ieeedev, int device, int data);
34
35WRITE8_DEVICE_HANDLER( cbm_ieee_dav_write );
36WRITE8_DEVICE_HANDLER( cbm_ieee_nrfd_write );
37WRITE8_DEVICE_HANDLER( cbm_ieee_ndac_write );
38WRITE8_DEVICE_HANDLER( cbm_ieee_atn_write );
39WRITE8_DEVICE_HANDLER( cbm_ieee_eoi_write );
40WRITE8_DEVICE_HANDLER( cbm_ieee_data_write );
41
42READ8_DEVICE_HANDLER( cbm_ieee_srq_r );
43READ8_DEVICE_HANDLER( cbm_ieee_dav_r );
44READ8_DEVICE_HANDLER( cbm_ieee_nrfd_r );
45READ8_DEVICE_HANDLER( cbm_ieee_ndac_r );
46READ8_DEVICE_HANDLER( cbm_ieee_atn_r );
47READ8_DEVICE_HANDLER( cbm_ieee_eoi_r );
48READ8_DEVICE_HANDLER( cbm_ieee_data_r );
49
50/* for debugging  */
51READ8_DEVICE_HANDLER( cbm_ieee_state );
52
53
54#endif /* CBMIEEEB_H_ */
src/mess/includes/cbmb.h
r7041r7042
4343
4444READ8_DEVICE_HANDLER( cbmb_tpi0_port_a_r );
4545WRITE8_DEVICE_HANDLER( cbmb_tpi0_port_a_w );
46READ8_DEVICE_HANDLER( cbmb_tpi0_port_b_r );
47WRITE8_DEVICE_HANDLER( cbmb_tpi0_port_b_w );
4648
4749WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_a );
4850WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_b );
src/mess/machine/cbmieeeb.c
r7041r7042
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
34DISCLAIMER
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
42Copyrights
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
48The story of this document
49
50I own several CBM/PET-types equipped with an IEEE-488 interface. Due to the
51lack of any documentation on Internet about the technical background of this
52subject, I started to collect all kind information I could lay my hands on to
53make my own electronic manual.
54Everything in this manual is based on the original concept. Where Commodore
55used or did something else, I will mention this
56
57
58The history
59
60The IEEE-488 bus was developed by Hewlett-Packard to connect and control
61programmable instruments and they called it HP-IB. The interface quickly
62became very popular in the computer industry. The IEEE committee gave it its
63present number and renamed it to GPIB (General Purpose Interface Bus).
64Commodore started to use it to connect their floppydisks to their computers.
65One of my manuals said that it is used to connect printers as well but to be
66honest, I never heard of or saw a printer with an IEEE-interface.
67
68
69IEEE-488 Overview
70
71You can connect three type of devices to the IEEE-488 bus:
72-    Listeners
73-    Talkers
74-    Controllers
75
76Some devices can perform more than one of these functions. The standard allows
77a maximum of 15 devices to be connected on the same bus. A minimum system
78consists of one Controller and one Talker or Listener device (i.e. a 8032 and
79a printer).
80A Listener is a device that can receive data from the bus when instructed by
81the Active Controller and a Talker transmits data on to the bus when
82instructed. It is possible to have several Controllers on the bus but only one
83may be active at any given time. The Active Controller may pass control to
84another controller which in turn can pass it back or on to another controller.
85The Controller can set up a talker and a group of listeners so that it is
86possible to send data between groups of devices as well.
87If you have more Controllers connected to each other, only one can be active
88at the startup-time. This Controller is called the System Controller. In our
89case it is obvious that this will be the CBM. This means that officially only
90one CBM is allowed on the bus according to IEEE-488. In fact you can connect
91more CBMs to the same bus without any problem as long as you take care that
92only one is performing a command at the time. In IEEE-488 terms: you, the
93user, acts as the System Controller, allowing one of the connected CBMs to be
94a temporary Active Controller for the time being.
95
96
97Interface Signals
98
99The IEEE-488 interface system consists of 16 signal lines and 8 ground lines.
100The 16 signal lines are divided into 3 groups: 8 data lines, 3 handshakelines,
101and 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
180Resulting scheme
181
182Line         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-----------|------|------|------|------|------|------|------|------|
185Listener   |    X |    X | X    | X    | X    | X    | X    |    X |
186Talker     | X    | X    |    X | X    |    X | X    | X    |    X |
187Controller | X  X | X  X | X  X | X  X | X  X |    X |    G | X    |
188
189X marks line used as "I = Input" or "O = Output"
190
191The block Controller/REN is marked G because a CBM doesn't use this line. In
192this case it is hardware-wired to GROUND.
193
194
195Service Request and Serial Polling
196
197If a device encounters a problem or a pre-programmed condition, it can
198activate the SQR-line by setting it (L). If the Controller detects this
199request, it can initiate a 'Serial Poll' by transmitting the command SPE ($18)
200on the bus. It then places an address von the bus, activates ATN (which makes
201the addressed device a talker) an de-activates it.
202If the device requested service, it will respond by setting DIO7 (L). It may
203indicate the nature of the request by setting other lines low as well. The
204Controller can now take appropriate actions.  When all devices have been
205polled, the controller terminates the serial poll by issuing the command SPD
206($19).
207
208
209Device Addresses
210The IEEE-488 standard allows up to 15 devices to be interconnected on one bus.
211Each device is assigned a unique primary address, ranging from 4-30, by
212setting the address switches on the device. A secondary address may also be
213specified, ranging from 0-31. See the device documentation for more
214information on how to set the device primary and optional secondary address.
215
216
217The hardware
218
219Looking at the circuitdiagrams of a PET, like the 3008, then you can see that
220the MC3446 is used as the driver for all the signals. According to "The PET
221revealed" by Nick Hampshire, these ICs have 'Open Collector'-outputs which
222means you can interconnect them without any fear of 'blowing up' a computer
223or device.
224Other models are equipped with the SN75160 and the SN75161  from Texas
225Instruments. These ICs are drivers especially developed for IEEE-488.
226The major difference between the two types is that you need one separate in-
227and outputline for every IEEE-line, together 32 lines. This means you need at
228least two 6522s or 6520s. For the SN-drivers you only need 19 lines or one
2296525.
230The 720 is equipped with the SN-drivers. The Pet 3008, CBM 8032SK, 3040 and
2314040 are equipped with four MC3446s. The CBM 8296 uses one 7417 and three
232MC3446s.
233
234
235The SN75160
236
237You can roughly describe the 75160 as a bidirectional 8-bits bus interface.
238(like the 74245)
239
240
241The SN75161
242
243The SN75161 is used to buffer the handshake- and interface managementlines.
244There 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
260In words: ATN, IFC, REN and SQR are outputs if DC = (L), else inputs.
261DAVV,NDAC and NRFD are outputs if TE = (L), else inputs. EOI behaves like DAVV
262when ATN = (H), else like SQR.
263
264
265Physical Characteristics
266
267You can link devices in either a linear, star or combination configuration
268using a shielded 24-conductor cable. The standard IEEE-488 cable has both a
269plug and receptacle connector on both ends. This connector is the Amphenol
270CHAMP or Cinch Series 57 MICRO RIBBON type. (it looks like a Centronics
271connector, but smaller) As far as I know all Commodore periphiral devices,
272like floppy-disks, and the CBM-8xxx series are equiped with this type of
273connector.The other CBMs and PETs are equiped with a male edge connector.
274(like the userport of a C64 or VIC-20)
275
276
277Pin  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
28810   Service Request     SRQ           Talker
28911   Attention           ATN           Controller
29012   Shield
29113   Data Bit 5          DIO5          Talker
29214   Data Bit 6          DIO6          Talker
29315   Data Bit 7          DIO7          Talker
29416   Data Bit 8          DIO8          Talker
29517   Remote Enabled      REN           Controller
29618   Ground DAV
29719   Ground NRFD
29820   Ground NDAC
29921   Ground IFC
30022   Ground SRQ
30123   Ground ATN
30224   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
332typedef struct _cbm_ieee_bus_t cbm_ieee_bus_t;
333struct _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
347INLINE 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
390cannot be static. However, it would be better if only the WRITE8_DEVICE_HANDLER would be
391made available to the rest of the source. */
392
393void 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
403WRITE8_DEVICE_HANDLER( cbm_ieee_dav_write )
404{
405   cbm_ieee_dav_w(device, 0, data );
406}
407
408void 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
418WRITE8_DEVICE_HANDLER( cbm_ieee_nrfd_write )
419{
420   cbm_ieee_nrfd_w(device, 0, data );
421}
422
423void 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
433WRITE8_DEVICE_HANDLER( cbm_ieee_ndac_write )
434{
435   cbm_ieee_ndac_w(device, 0, data );
436}
437
438void 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
448WRITE8_DEVICE_HANDLER( cbm_ieee_atn_write )
449{
450   cbm_ieee_atn_w(device, 0, data );
451}
452
453void 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
463WRITE8_DEVICE_HANDLER( cbm_ieee_eoi_write )
464{
465   cbm_ieee_eoi_w(device, 0, data );
466}
467
468void 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
478WRITE8_DEVICE_HANDLER( cbm_ieee_data_write )
479{
480   cbm_ieee_data_w(device, 0, data );
481}
482
483
484READ8_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
493READ8_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
502READ8_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
511READ8_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
520READ8_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
529READ8_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
538READ8_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
548READ8_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
580static 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
594static 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
616DEVICE_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/cbmb.c
r7041r7042
1212
1313#include "includes/cbm.h"
1414#include "video/vic6567.h"
15#include "includes/cbmserb.h"
16#include "includes/cbmieeeb.h"
15#include "machine/ieee488.h"
1716
1817#include "includes/cbmb.h"
1918
r7041r7042
7069READ8_DEVICE_HANDLER( cbmb_tpi0_port_a_r )
7170{
7271   const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus");
73   int data = 0;
72   UINT8 data = 0;
7473
75   if (cbm_ieee_nrfd_r(ieeebus, 0))
74   if (ieee488_nrfd_r(ieeebus))
7675      data |= 0x80;
7776
78   if (cbm_ieee_ndac_r(ieeebus, 0))
77   if (ieee488_ndac_r(ieeebus))
7978      data |= 0x40;
8079
81   if (cbm_ieee_eoi_r(ieeebus, 0))
80   if (ieee488_eoi_r(ieeebus))
8281      data |= 0x20;
8382
84   if (cbm_ieee_dav_r(ieeebus, 0))
83   if (ieee488_dav_r(ieeebus))
8584      data |= 0x10;
8685
87   if (cbm_ieee_atn_r(ieeebus, 0))
86   if (ieee488_atn_r(ieeebus))
8887      data |= 0x08;
8988
90/*  if (cbm_ieee_ren_r(ieeebus, 0))
91        data |= 0x04; */
89   if (ieee488_ren_r(ieeebus))
90        data |= 0x04;
9291
9392   return data;
9493}
r7041r7042
9796{
9897   const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus");
9998
100   cbm_ieee_nrfd_write(ieeebus, 0, data & 0x80);
101   cbm_ieee_ndac_write(ieeebus, 0, data & 0x40);
102   cbm_ieee_eoi_write(ieeebus, 0, data & 0x20);
103   cbm_ieee_dav_write(ieeebus, 0, data & 0x10);
104   cbm_ieee_atn_write(ieeebus, 0, data & 0x08);
105/*  cbm_ieee_ren_write(ieeebus, 0, data & 0x04); */
106   logerror("cbm ieee %d %d\n", data & 0x02, data & 0x01);
99   ieee488_nrfd_w(ieeebus, device, BIT(data, 7));
100   ieee488_ndac_w(ieeebus, device, BIT(data, 6));
101   ieee488_eoi_w(ieeebus, device, BIT(data, 5));
102   ieee488_dav_w(ieeebus, device, BIT(data, 4));
103   ieee488_atn_w(ieeebus, device, BIT(data, 3));
104   ieee488_ren_w(ieeebus, device, BIT(data, 2));
107105}
108106
107READ8_DEVICE_HANDLER( cbmb_tpi0_port_b_r )
108{
109   const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus");
110   UINT8 data = 0;
111
112   if (ieee488_srq_r(ieeebus))
113      data |= 0x02;
114
115   if (ieee488_ifc_r(ieeebus))
116      data |= 0x01;
117
118   return data;
119}
120
121WRITE8_DEVICE_HANDLER( cbmb_tpi0_port_b_w )
122{
123   const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus");
124
125   ieee488_srq_w(ieeebus, device, BIT(data, 1));
126   ieee488_ifc_w(ieeebus, device, BIT(data, 0));
127}
128
109129/* tpi at 0xfdf00
110130  cbm 500
111131   port c7 video address lines?
r7041r7042
244264static READ8_DEVICE_HANDLER( cbmb_cia_port_a_r )
245265{
246266   const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus");
247   return cbm_ieee_data_r(ieeebus, 0);
267   return ieee488_dio_r(ieeebus, 0);
248268}
249269
250270static WRITE8_DEVICE_HANDLER( cbmb_cia_port_a_w )
251271{
252272   const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus");
253   cbm_ieee_data_write(ieeebus, 0, data);
273   ieee488_dio_w(ieeebus, device, data);
254274}
255275
256276const cia6526_interface cbmb_cia =
src/mess/machine/pet.c
r7041r7042
1111#include "includes/cbm.h"
1212#include "machine/6821pia.h"
1313#include "machine/6522via.h"
14#include "includes/cbmserb.h"
15#include "includes/cbmieeeb.h"
14#include "machine/ieee488.h"
1615
1716#include "includes/pet.h"
1817
r7041r7042
8584   if ((cassette_get_state(devtag_get_device(device->machine, "cassette2")) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED)
8685      data &= ~0x20;
8786
88   if (!cbm_ieee_eoi_r(ieeebus, 0))
87   if (!ieee488_eoi_r(ieeebus))
8988      data &= ~0x40;
9089
9190   return data;
r7041r7042
156155static WRITE8_DEVICE_HANDLER( pet_pia0_ca2_out )
157156{
158157   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);
160159}
161160
162161static WRITE8_DEVICE_HANDLER( pet_pia0_cb2_out )
r7041r7042
200199static READ8_DEVICE_HANDLER( pet_pia1_port_a_read )
201200{
202201   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);
204203}
205204
206205static WRITE8_DEVICE_HANDLER( pet_pia1_port_b_write )
207206{
208207   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);
210209}
211210
212211static READ8_DEVICE_HANDLER( pet_pia1_ca1_read )
213212{
214213   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);
216215}
217216
218217static WRITE8_DEVICE_HANDLER( pet_pia1_ca2_write )
219218{
220219   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);
222221}
223222
224223static WRITE8_DEVICE_HANDLER( pet_pia1_cb2_write )
225224{
226225   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);
228227}
229228
230229static READ8_DEVICE_HANDLER( pet_pia1_cb1_read )
231230{
232231   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);
234233}
235234
236235const pia6821_interface pet_pia0 =
r7041r7042
310309   const device_config *ieeebus = devtag_get_device(device->machine, "ieee_bus");
311310   UINT8 data = 0;
312311
313   if (cbm_ieee_ndac_r(ieeebus, 0))
312   if (ieee488_ndac_r(ieeebus))
314313      data |= 0x01;
315314
316315   //  data & 0x08 -> cassette write (it seems to BOTH cassettes from schematics)
r7041r7042
326325      timer_reset(datasette2_timer, attotime_never);
327326   }
328327
329   if (cbm_ieee_nrfd_r(ieeebus, 0))
328   if (ieee488_nrfd_r(ieeebus))
330329      data |= 0x40;
331330
332   if (cbm_ieee_dav_r(ieeebus, 0))
331   if (ieee488_dav_r(ieeebus))
333332      data |= 0x80;
334333
335334   return data;
r7041r7042
346345static WRITE8_DEVICE_HANDLER( pet_via_port_b_w )
347346{
348347   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));
351350}
352351
353352
r7041r7042
689688MACHINE_RESET( pet )
690689{
691690   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");
692693
693694   if (state->superpet)
694695   {
r7041r7042
723724//removed   cbm_drive_0_config (input_port_read(machine, "CFG") & 2 ? IEEE : 0, 8);
724725//removed   cbm_drive_1_config (input_port_read(machine, "CFG") & 1 ? IEEE : 0, 9);
725726   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);
726731}
727732
728733
src/mess/mess.mak
r7041r7042
708708   $(MESS_FORMATS)/cbm_tap.o    \
709709   $(MESS_MACHINE)/6525tpi.o   \
710710   $(MESS_MACHINE)/cbm.o      \
711   $(MESS_MACHINE)/cbmieeeb.o    \
712711   $(MESS_MACHINE)/cbmserb.o    \
713712   $(MESS_MACHINE)/cbmipt.o      \
714713   $(MESS_MACHINE)/c64.o       \
src/mess/drivers/cbmb.c
r7041r7042
7676
7777[To Do]
7878
79* Support is still missing for: Sound, IEEE488, Floppy, internal slots
79* Support is still missing for: Sound, internal slots
8080
8181* Emulate 8088 co-processor for BX-256HP and eventually add its European
8282    counterpart CBM 730
r7041r7042
104104
105105#include "includes/cbm.h"
106106#include "includes/cbmb.h"
107#include "includes/cbmieeeb.h"
107#include "machine/ieee488.h"
108#include "machine/c1541.h"
108109#include "machine/cbmipt.h"
109110#include "video/vic6567.h"
110111#include "video/mc6845.h"
r7041r7042
320321static const tpi6525_interface cbmb_tpi_0_intf =
321322{
322323   cbmb_tpi0_port_a_r,
324   cbmb_tpi0_port_b_r,
323325   NULL,
324   NULL,
325326   cbmb_tpi0_port_a_w,
327   cbmb_tpi0_port_b_w,
326328   NULL,
327   NULL,
328329   cbmb_change_font,
329330   NULL,
330331   cbmb_irq
r7041r7042
343344   NULL
344345};
345346
347static IEEE488_DAISY( ieee488_daisy )
348{
349   { "tpi6525_0" },
350   { "cia" },
351   { C2031_IEEE488("c2031") },
352   { NULL}
353};
346354
347355static MACHINE_DRIVER_START( cbm600 )
348356   MDRV_DRIVER_DATA(cbmb_state)
r7041r7042
384392   MDRV_TPI6525_ADD("tpi6525_1", cbmb_tpi_1_intf)
385393
386394   /* IEEE bus */
387   MDRV_CBM_IEEEBUS_ADD("ieee_bus")
395   MDRV_IEEE488_ADD("ieee_bus", ieee488_daisy)
396   MDRV_C2031_ADD("c2031", "ieee_bus", 8)
388397
389398   MDRV_IMPORT_FROM(cbmb_cartslot)
390399MACHINE_DRIVER_END
r7041r7042
456465   MDRV_TPI6525_ADD("tpi6525_1", cbmb_tpi_1_intf)
457466
458467   /* IEEE bus */
459   MDRV_CBM_IEEEBUS_ADD("ieee_bus")
468   MDRV_IEEE488_ADD("ieee_bus", ieee488_daisy)
469   MDRV_C2031_ADD("c2031", "ieee_bus", 8)
460470
461471   MDRV_IMPORT_FROM(cbmb_cartslot)
462472MACHINE_DRIVER_END
src/mess/drivers/pet.c
r7041r7042
358358
359359* Add sound support, for systems which had it
360360
361* Add IEEE488 Interface support
362
363361* Find out answers to the following details:
364362
365363+ Did BASIC 2 also come as upgrade ROMs for PET 2001 with Static Board? If
r7041r7042
390388#include "machine/cbmipt.h"
391389#include "video/mc6845.h"
392390#include "devices/messram.h"
391#include "machine/c1541.h"
393392
394393/* devices config */
395394#include "includes/cbm.h"
396#include "includes/cbmieeeb.h"
395#include "machine/ieee488.h"
397396
398397/*************************************
399398 *
r7041r7042
644643   return 0;
645644}
646645
646static IEEE488_DAISY( ieee488_daisy )
647{
648   { "pia_0" },
649   { "pia_1", DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_HANDLER("pia_1", pia6821_cb1_w), DEVCB_DEVICE_HANDLER("pia_1", pia6821_ca1_w), DEVCB_NULL },
650   { "via6522_0" },
651   { C2031_IEEE488("c2031") },
652   { NULL}
653};
647654
648655/*************************************
649656 *
r7041r7042
685692   MDRV_PIA6821_ADD( "pia_1", pet_pia1)
686693
687694   /* IEEE bus */
688   MDRV_CBM_IEEEBUS_ADD("ieee_bus")
695   MDRV_IEEE488_ADD("ieee_bus", ieee488_daisy)
696   MDRV_C2031_ADD("c2031", "ieee_bus", 8)
689697MACHINE_DRIVER_END
690698
691699

Previous 15994 Revisions Next


© 1998-2018 The MESS Team