Previous 15994 Revisions Next

r11257 Wednesday 20th April, 2011 at 19:48:37 UTC by Curt Coder
Refactored the Commodore IEC bus into a C++ device. (no whatsnew)
[src/mess]mess.mak
[src/mess/drivers]c128.c c16.c c64.c primo.c vic20.c
[src/mess/includes]c16.h c64.h primo.h vic20.h
[src/mess/machine]c128.c c1541.c c1541.h c1571.c c1571.h c1581.c c1581.h c16.c c64.c c65.c cbmiec.c cbmiec.h iecstub.c* primo.c

src/mess/machine/cbmiec.c
r11256r11257
190190    5)  Tei minimum must be 80us for external device to be a listener.
191191*/
192192
193#include "emu.h"
194193#include "cbmiec.h"
194#include "machine/devhelpr.h"
195195
196/***************************************************************************
197    PARAMETERS
198***************************************************************************/
199196
200#define LOG 0
201197
202enum
203{
204   SRQ = 0,
205   ATN,
206   CLK,
207   DATA,
208   RESET,
209   SIGNAL_COUNT
210};
198//**************************************************************************
199//  MACROS / CONSTANTS
200//**************************************************************************
211201
202#define LOG 1
203
204
212205static const char *const SIGNAL_NAME[] = { "SRQ", "ATN", "CLK", "DATA", "RESET" };
213206
214/***************************************************************************
215    TYPE DEFINITIONS
216***************************************************************************/
217207
218typedef struct _cbm_iec_daisy_state cbm_iec_daisy_state;
219struct _cbm_iec_daisy_state
208
209//**************************************************************************
210//  DEVICE DEFINITIONS
211//**************************************************************************
212
213const device_type CBM_IEC = cbm_iec_device_config::static_alloc_device_config;
214
215
216
217//**************************************************************************
218//  DEVICE CONFIGURATION INTERFACE
219//**************************************************************************
220
221//-------------------------------------------------
222//  device_config_cbm_iec_interface - constructor
223//-------------------------------------------------
224
225device_config_cbm_iec_interface::device_config_cbm_iec_interface(const machine_config &mconfig, device_config &devconfig)
226   : device_config_interface(mconfig, devconfig)
220227{
221   cbm_iec_daisy_state         *next;         /* next device */
222   device_t *device;      /* associated device */
228}
223229
224   int line[SIGNAL_COUNT];                  /* serial signal states */
225230
226   devcb_resolved_write_line   out_line_func[SIGNAL_COUNT];
227};
231//-------------------------------------------------
232//  ~device_config_cbm_iec_interface - destructor
233//-------------------------------------------------
228234
229typedef struct _cbm_iec_t cbm_iec_t;
230struct _cbm_iec_t
235device_config_cbm_iec_interface::~device_config_cbm_iec_interface()
231236{
232   cbm_iec_daisy_state *daisy_state;
233};
237}
234238
235/***************************************************************************
236    INLINE FUNCTIONS
237***************************************************************************/
238239
239INLINE cbm_iec_t *get_safe_token(device_t *device)
240
241//**************************************************************************
242//  DEVICE INTERFACE
243//**************************************************************************
244
245//-------------------------------------------------
246//  device_cbm_iec_interface - constructor
247//-------------------------------------------------
248
249device_cbm_iec_interface::device_cbm_iec_interface(running_machine &machine, const device_config &config, device_t &device)
250   : device_interface(machine, config, device),
251     m_cbm_iec_config(dynamic_cast<const device_config_cbm_iec_interface &>(config))
240252{
241   assert(device != NULL);
242   assert(device->type() == CBM_IEC);
243   return (cbm_iec_t *)downcast<legacy_device_base *>(device)->token();
244253}
245254
246INLINE const cbm_iec_daisy_chain *get_interface(device_t *device)
255
256//-------------------------------------------------
257//  ~device_cbm_iec_interface - destructor
258//-------------------------------------------------
259
260device_cbm_iec_interface::~device_cbm_iec_interface()
247261{
248   assert(device != NULL);
249   assert(device->type() == CBM_IEC);
250   return (const cbm_iec_daisy_chain *) device->baseconfig().static_config();
251262}
252263
253INLINE int get_signal(device_t *device, int line)
264
265
266//**************************************************************************
267//  DEVICE CONFIGURATION
268//**************************************************************************
269
270GENERIC_DEVICE_CONFIG_SETUP(cbm_iec, "CBM IEC")
271
272
273//-------------------------------------------------
274//  device_config_complete - perform any
275//  operations now that the configuration is
276//  complete
277//-------------------------------------------------
278
279void cbm_iec_device_config::device_config_complete()
254280{
255   cbm_iec_t *cbm_iec = get_safe_token(device);
256   cbm_iec_daisy_state *daisy = cbm_iec->daisy_state;
257   int state = 1;
281   // inherit a copy of the static data
282   const cbm_iec_config *intf = reinterpret_cast<const cbm_iec_config *>(static_config());
283   if (intf != NULL)
284      *static_cast<cbm_iec_config *>(this) = *intf;
258285
259   for ( ; daisy != NULL; daisy = daisy->next)
286   // or initialize to defaults if none provided
287   else
260288   {
261      if (!daisy->line[line])
289      fatalerror("Daisy chain not provided!");
290   }
291
292   m_daisy = intf;
293}
294
295
296
297//**************************************************************************
298//  INLINE HELPERS
299//**************************************************************************
300
301//-------------------------------------------------
302//  set_signal -
303//-------------------------------------------------
304
305inline void cbm_iec_device::set_signal(device_t *device, int signal, int state)
306{
307   bool changed = false;
308
309   for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next)
310   {
311      if (!strcmp(daisy->m_device->tag(), device->tag()))
262312      {
263         state = 0;
264         break;
313         if (daisy->m_line[signal] != state)
314         {
315            if (LOG) logerror("CBM IEC: '%s' %s %u\n", device->tag(), SIGNAL_NAME[signal], state);
316            daisy->m_line[signal] = state;
317            changed = true;
318         }
265319      }
266320   }
267321
268   return state;
322   if (changed)
323   {
324      for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next)
325      {
326         switch (signal)
327         {
328         case SRQ:
329            daisy->m_interface->cbm_iec_srq(state);
330            break;
331
332         case ATN:
333            daisy->m_interface->cbm_iec_atn(state);
334            break;
335
336         case CLK:
337            daisy->m_interface->cbm_iec_clk(state);
338            break;
339
340         case DATA:
341            daisy->m_interface->cbm_iec_data(state);
342            break;
343
344         case RESET:
345            daisy->m_interface->cbm_iec_reset(state);
346            break;
347         }
348      }
349
350      if (LOG) logerror("CBM IEC: SRQ %u ATN %u CLK %u DATA %u RESET %u\n", get_signal(SRQ),get_signal(ATN),get_signal(CLK),get_signal(DATA),get_signal(RESET));
351   }
269352}
270353
271INLINE void set_signal(device_t *iec, device_t *device, int line, int state)
354
355//-------------------------------------------------
356//  get_signal -
357//-------------------------------------------------
358
359inline int cbm_iec_device::get_signal(int signal)
272360{
273   cbm_iec_t *cbm_iec = get_safe_token(iec);
274   cbm_iec_daisy_state *daisy = cbm_iec->daisy_state;
275   int data = 1;
361   int state = 1;
276362
277   for ( ; daisy != NULL; daisy = daisy->next)
363   for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next)
278364   {
279      if (!strcmp(daisy->device->tag(), device->tag()))
365      if (!daisy->m_line[signal])
280366      {
281         if (daisy->line[line] != state)
282         {
283            if (LOG) logerror("CBM IEC: '%s' %s %u\n", device->tag(), SIGNAL_NAME[line], state);
284            daisy->line[line] = state;
285         }
367         state = 0;
286368         break;
287369      }
288370   }
289371
290   data = get_signal(iec, line);
291   daisy = cbm_iec->daisy_state;
372   return state;
373}
292374
293   for ( ; daisy != NULL; daisy = daisy->next)
375
376
377//**************************************************************************
378//  LIVE DEVICE
379//**************************************************************************
380
381//-------------------------------------------------
382//  cbm_iec_device - constructor
383//-------------------------------------------------
384
385cbm_iec_device::cbm_iec_device(running_machine &_machine, const cbm_iec_device_config &_config)
386    : device_t(_machine, _config),
387     m_stub(*this->owner(), CBM_IEC_STUB_TAG),
388      m_config(_config)
389{
390}
391
392
393//-------------------------------------------------
394//  device_start - device-specific startup
395//-------------------------------------------------
396
397void cbm_iec_device::device_start()
398{
399   const cbm_iec_config *daisy = m_config.m_daisy;
400
401   // create a linked list of devices
402   daisy_entry **tailptr = &m_daisy_list;
403   for ( ; daisy->m_tag != NULL; daisy++)
294404   {
295      devcb_call_write_line(&daisy->out_line_func[line], data);
405      // find the device
406      device_t *target = machine().device(daisy->m_tag);
407      if (target == NULL)
408         fatalerror("Unable to locate device '%s'", daisy->m_tag);
409
410      // make sure it has an interface
411      device_cbm_iec_interface *intf;
412      if (!target->interface(intf))
413         fatalerror("Device '%s' does not implement the CBM IEC interface!", daisy->m_tag);
414
415      // append to the end
416      *tailptr = auto_alloc(machine(), daisy_entry(target));
417      tailptr = &(*tailptr)->m_next;
296418   }
297419
298   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));
420   // append driver stub to the end
421   device_t *target = machine().device(CBM_IEC_STUB_TAG);
422   *tailptr = auto_alloc(machine(), daisy_entry(target));
423   tailptr = &(*tailptr)->m_next;
299424}
300425
301/***************************************************************************
302    IMPLEMENTATION
303***************************************************************************/
304426
305void cbm_iec_srq_w(device_t *iec, device_t *device, int state)
427//-------------------------------------------------
428//  daisy_entry - constructor
429//-------------------------------------------------
430
431cbm_iec_device::daisy_entry::daisy_entry(device_t *device)
432   : m_next(NULL),
433     m_device(device),
434     m_interface(NULL)
306435{
307   set_signal(iec, device, SRQ, state);
436   for (int i = 0; i < SIGNAL_COUNT; i++)
437   {
438      m_line[i] = 1;
439   }
440
441   device->interface(m_interface);
308442}
309443
310READ_LINE_DEVICE_HANDLER( cbm_iec_srq_r )
444
445//-------------------------------------------------
446//  srq_r -
447//-------------------------------------------------
448
449READ_LINE_MEMBER( cbm_iec_device::srq_r )
311450{
312   return get_signal(device, SRQ);
451   return get_signal(SRQ);
313452}
314453
315void cbm_iec_atn_w(device_t *iec, device_t *device, int state)
454
455//-------------------------------------------------
456//  atn_r -
457//-------------------------------------------------
458
459READ_LINE_MEMBER( cbm_iec_device::atn_r )
316460{
317   set_signal(iec, device, ATN, state);
461   return get_signal(ATN);
318462}
319463
320READ_LINE_DEVICE_HANDLER( cbm_iec_atn_r )
464
465//-------------------------------------------------
466//  clk_r -
467//-------------------------------------------------
468
469READ_LINE_MEMBER( cbm_iec_device::clk_r )
321470{
322   return get_signal(device, ATN);
471   return get_signal(CLK);
323472}
324473
325void cbm_iec_clk_w(device_t *iec, device_t *device, int state)
474
475//-------------------------------------------------
476//  data_r -
477//-------------------------------------------------
478
479READ_LINE_MEMBER( cbm_iec_device::data_r )
326480{
327   set_signal(iec, device, CLK, state);
481   return get_signal(DATA);
328482}
329483
330READ_LINE_DEVICE_HANDLER( cbm_iec_clk_r )
484
485//-------------------------------------------------
486//  reset_r -
487//-------------------------------------------------
488
489READ_LINE_MEMBER( cbm_iec_device::reset_r )
331490{
332   return get_signal(device, CLK);
491   return get_signal(RESET);
333492}
334493
335void cbm_iec_data_w(device_t *iec, device_t *device, int state)
494
495//-------------------------------------------------
496//  srq_w -
497//-------------------------------------------------
498
499WRITE_LINE_MEMBER( cbm_iec_device::srq_w )
336500{
337   set_signal(iec, device, DATA, state);
501   set_signal(m_stub, SRQ, state);
338502}
339503
340READ_LINE_DEVICE_HANDLER( cbm_iec_data_r )
504
505//-------------------------------------------------
506//  atn_w -
507//-------------------------------------------------
508
509WRITE_LINE_MEMBER( cbm_iec_device::atn_w )
341510{
342   return get_signal(device, DATA);
511   set_signal(m_stub, ATN, state);
343512}
344513
345void cbm_iec_reset_w(device_t *iec, device_t *device, int state)
514
515//-------------------------------------------------
516//  clk_w -
517//-------------------------------------------------
518
519WRITE_LINE_MEMBER( cbm_iec_device::clk_w )
346520{
347   set_signal(iec, device, RESET, state);
521   set_signal(m_stub, CLK, state);
348522}
349523
350READ_LINE_DEVICE_HANDLER( cbm_iec_reset_r )
524
525//-------------------------------------------------
526//  data_w -
527//-------------------------------------------------
528
529WRITE_LINE_MEMBER( cbm_iec_device::data_w )
351530{
352   return get_signal(device, RESET);
531   set_signal(m_stub, DATA, state);
353532}
354533
355/*-------------------------------------------------
356    DEVICE_START( cbm_iec )
357-------------------------------------------------*/
358534
359static DEVICE_START( cbm_iec )
535//-------------------------------------------------
536//  reset_w -
537//-------------------------------------------------
538
539WRITE_LINE_MEMBER( cbm_iec_device::reset_w )
360540{
361   cbm_iec_t *cbm_iec = get_safe_token(device);
362   const cbm_iec_daisy_chain *daisy = get_interface(device);
363   int i;
541   set_signal(m_stub, RESET, state);
542}
364543
365   cbm_iec_daisy_state *head = NULL;
366   cbm_iec_daisy_state **tailptr = &head;
367544
368   /* create a linked list of devices */
369   for ( ; daisy->tag != NULL; daisy++)
370   {
371      *tailptr = auto_alloc(device->machine(), cbm_iec_daisy_state);
545//-------------------------------------------------
546//  srq_w -
547//-------------------------------------------------
372548
373      (*tailptr)->next = NULL;
374      (*tailptr)->device = device->machine().device(daisy->tag);
549void cbm_iec_device::srq_w(device_t *device, int state)
550{
551   set_signal(device, SRQ, state);
552}
375553
376      if ((*tailptr)->device == NULL)
377      {
378         fatalerror("Unable to locate device '%s'", daisy->tag);
379      }
380554
381      for (i = SRQ; i < SIGNAL_COUNT; i++)
382      {
383         (*tailptr)->line[i] = 1;
384      }
555//-------------------------------------------------
556//  atn_w -
557//-------------------------------------------------
385558
386      devcb_resolve_write_line(&(*tailptr)->out_line_func[SRQ], &daisy->out_srq_func, device);
387      devcb_resolve_write_line(&(*tailptr)->out_line_func[ATN], &daisy->out_atn_func, device);
388      devcb_resolve_write_line(&(*tailptr)->out_line_func[CLK], &daisy->out_clk_func, device);
389      devcb_resolve_write_line(&(*tailptr)->out_line_func[DATA], &daisy->out_data_func, device);
390      devcb_resolve_write_line(&(*tailptr)->out_line_func[RESET], &daisy->out_reset_func, device);
559void cbm_iec_device::atn_w(device_t *device, int state)
560{
561   set_signal(device, ATN, state);
562}
391563
392      tailptr = &(*tailptr)->next;
393   }
394564
395   cbm_iec->daisy_state = head;
565//-------------------------------------------------
566//  clk_w -
567//-------------------------------------------------
396568
397   /* register for state saving */
398//  device->save_item(NAME(cbm_iec->));
569void cbm_iec_device::clk_w(device_t *device, int state)
570{
571   set_signal(device, CLK, state);
399572}
400573
401/*-------------------------------------------------
402    DEVICE_GET_INFO( cbm_iec )
403-------------------------------------------------*/
404574
405DEVICE_GET_INFO( cbm_iec )
575//-------------------------------------------------
576//  data_w -
577//-------------------------------------------------
578
579void cbm_iec_device::data_w(device_t *device, int state)
406580{
407   switch (state)
408   {
409      /* --- the following bits of info are returned as 64-bit signed integers --- */
410      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(cbm_iec_t);                        break;
411      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                    break;
581   set_signal(device, DATA, state);
582}
412583
413      /* --- the following bits of info are returned as pointers to data or functions --- */
414      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(cbm_iec);               break;
415      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
416      case DEVINFO_FCT_RESET:                     /* Nothing */                                    break;
417584
418      /* --- the following bits of info are returned as NULL-terminated strings --- */
419      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore Serial Bus");               break;
420      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "IEEE-488");                        break;
421      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
422      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
423      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
424   }
585//-------------------------------------------------
586//  reset_w -
587//-------------------------------------------------
588
589void cbm_iec_device::reset_w(device_t *device, int state)
590{
591   set_signal(device, RESET, state);
425592}
426
427DEFINE_LEGACY_DEVICE(CBM_IEC, cbm_iec);
src/mess/machine/cbmiec.h
r11256r11257
77
88**********************************************************************/
99
10#pragma once
11
1012#ifndef __CBM_IEC__
1113#define __CBM_IEC__
1214
1315#include "emu.h"
1416
15/***************************************************************************
16    MACROS / CONSTANTS
17***************************************************************************/
1817
19DECLARE_LEGACY_DEVICE(CBM_IEC, cbm_iec);
2018
21#define MCFG_CBM_IEC_ADD(_tag, _daisy_chain) \
22   MCFG_DEVICE_ADD(_tag, CBM_IEC, 0) \
23   MCFG_DEVICE_CONFIG(_daisy_chain)
19//**************************************************************************
20//  MACROS / CONSTANTS
21//**************************************************************************
2422
23#define CBM_IEC_TAG         "iec_bus"
24#define CBM_IEC_STUB_TAG   "iec_stub"
25
26
27
28//**************************************************************************
29//  INTERFACE CONFIGURATION MACROS
30//**************************************************************************
31
32#define MCFG_CBM_IEC_ADD(_daisy) \
33    MCFG_DEVICE_ADD(CBM_IEC_STUB_TAG, CBM_IEC_STUB, 0) \
34   MCFG_DEVICE_CONFIG(default_cbm_iec_stub_interface) \
35   MCFG_DEVICE_ADD(CBM_IEC_TAG, CBM_IEC, 0) \
36   MCFG_DEVICE_CONFIG(_daisy)
37
38
39#define MCFG_CBM_IEC_CONFIG_ADD(_daisy, _config) \
40    MCFG_DEVICE_ADD(CBM_IEC_STUB_TAG, CBM_IEC_STUB, 0) \
41   MCFG_DEVICE_CONFIG(_config) \
42   MCFG_DEVICE_ADD(CBM_IEC_TAG, CBM_IEC, 0) \
43   MCFG_DEVICE_CONFIG(_daisy)
44
45
46#define MCFG_CBM_IEC_REMOVE() \
47   MCFG_DEVICE_REMOVE(CBM_IEC_STUB_TAG) \
48   MCFG_DEVICE_REMOVE(CBM_IEC_TAG)
49
50
2551#define CBM_IEC_DAISY(_name) \
26   const cbm_iec_daisy_chain (_name)[] =
52   const cbm_iec_config (_name)[] =
2753
28/***************************************************************************
29    TYPE DEFINITIONS
30***************************************************************************/
3154
32typedef struct _cbm_iec_daisy_chain cbm_iec_daisy_chain;
33struct _cbm_iec_daisy_chain
55#define CBM_IEC_INTERFACE(_name) \
56   const cbm_iec_stub_interface (_name) =
57
58
59
60//**************************************************************************
61//  TYPE DEFINITIONS
62//**************************************************************************
63
64// ======================> cbm_iec_config
65
66struct cbm_iec_config
3467{
35   const char *tag;   /* device tag */
68   const char *m_tag;
69};
3670
37   devcb_write_line   out_srq_func;
38   devcb_write_line   out_atn_func;
39   devcb_write_line   out_clk_func;
40   devcb_write_line   out_data_func;
41   devcb_write_line   out_reset_func;
71
72// ======================> device_config_cbm_iec_interface
73
74// device_config_cbm_iec_interface represents configuration information for a cbm_iec device
75class device_config_cbm_iec_interface : public device_config_interface
76{
77public:
78   // construction/destruction
79   device_config_cbm_iec_interface(const machine_config &mconfig, device_config &devconfig);
80   virtual ~device_config_cbm_iec_interface();
4281};
4382
44/***************************************************************************
45    PROTOTYPES
46***************************************************************************/
47/* service request */
48void cbm_iec_srq_w(device_t *iec, device_t *device, int state);
49READ_LINE_DEVICE_HANDLER( cbm_iec_srq_r );
5083
51/* attention */
52void cbm_iec_atn_w(device_t *iec, device_t *device, int state);
53READ_LINE_DEVICE_HANDLER( cbm_iec_atn_r );
84// ======================> device_cbm_iec_interface
5485
55/* clock */
56void cbm_iec_clk_w(device_t *iec, device_t *device, int state);
57READ_LINE_DEVICE_HANDLER( cbm_iec_clk_r );
86class device_cbm_iec_interface : public device_interface
87{
88public:
89   // construction/destruction
90   device_cbm_iec_interface(running_machine &machine, const device_config &config, device_t &device);
91   virtual ~device_cbm_iec_interface();
5892
59/* data */
60void cbm_iec_data_w(device_t *iec, device_t *device, int state);
61READ_LINE_DEVICE_HANDLER( cbm_iec_data_r );
93   // optional operation overrides
94   virtual void cbm_iec_atn(int state) { };
95   virtual void cbm_iec_clk(int state) { };
96   virtual void cbm_iec_data(int state) { };
97   virtual void cbm_iec_srq(int state) { };
98   virtual void cbm_iec_reset(int state) { };
6299
63/* reset */
64void cbm_iec_reset_w(device_t *iec, device_t *device, int state);
65READ_LINE_DEVICE_HANDLER( cbm_iec_reset_r );
100protected:
101   const device_config_cbm_iec_interface &m_cbm_iec_config;
102};
66103
104
105// ======================> cbm_iec_device_config
106
107class cbm_iec_device_config :   public device_config,
108                         public cbm_iec_config
109{
110    friend class cbm_iec_device;
111
112    // construction/destruction
113    cbm_iec_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
114
115public:
116    // allocators
117    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
118    virtual device_t *alloc_device(running_machine &machine) const;
119
120protected:
121    // device_config overrides
122    virtual void device_config_complete();
123
124private:
125   const cbm_iec_config *m_daisy;
126};
127
128
129// ======================> cbm_iec_device
130
131class cbm_iec_stub_device;
132
133class cbm_iec_device :  public device_t
134{
135    friend class cbm_iec_device_config;
136
137    // construction/destruction
138    cbm_iec_device(running_machine &_machine, const cbm_iec_device_config &_config);
139
140public:
141   // reads for both host and peripherals
142   DECLARE_READ_LINE_MEMBER( srq_r );
143   DECLARE_READ_LINE_MEMBER( atn_r );
144   DECLARE_READ_LINE_MEMBER( clk_r );
145   DECLARE_READ_LINE_MEMBER( data_r );
146   DECLARE_READ_LINE_MEMBER( reset_r );
147
148   // writes for host (driver_device)
149   DECLARE_WRITE_LINE_MEMBER( srq_w );
150   DECLARE_WRITE_LINE_MEMBER( atn_w );
151   DECLARE_WRITE_LINE_MEMBER( clk_w );
152   DECLARE_WRITE_LINE_MEMBER( data_w );
153   DECLARE_WRITE_LINE_MEMBER( reset_w );
154
155   // writes for peripherals (device_t)
156   void srq_w(device_t *device, int state);
157   void atn_w(device_t *device, int state);
158   void clk_w(device_t *device, int state);
159   void data_w(device_t *device, int state);
160   void reset_w(device_t *device, int state);
161
162protected:
163   enum
164   {
165      SRQ = 0,
166      ATN,
167      CLK,
168      DATA,
169      RESET,
170      SIGNAL_COUNT
171   };
172
173   // device-level overrides
174    virtual void device_start();
175
176   class daisy_entry
177   {
178   public:
179      daisy_entry(device_t *device);
180
181      daisy_entry *            m_next;         // next device
182      device_t *               m_device;      // associated device
183      device_cbm_iec_interface *   m_interface;   // associated device's daisy interface
184
185      int m_line[SIGNAL_COUNT];
186   };
187
188   daisy_entry *         m_daisy_list;   // head of the daisy chain
189
190private:
191   inline void set_signal(device_t *device, int signal, int state);
192   inline int get_signal(int signal);
193
194   required_device<cbm_iec_stub_device> m_stub;
195
196    const cbm_iec_device_config &m_config;
197};
198
199
200// ======================> cbm_iec_stub_interface
201
202struct cbm_iec_stub_interface
203{
204   devcb_write_line   m_out_srq_func;
205   devcb_write_line   m_out_atn_func;
206   devcb_write_line   m_out_clk_func;
207   devcb_write_line   m_out_data_func;
208   devcb_write_line   m_out_reset_func;
209};
210
211const cbm_iec_stub_interface default_cbm_iec_stub_interface = { DEVCB_NULL, };
212
213
214// ======================> cbm_iec_stub_device_config
215
216class cbm_iec_stub_device_config :   public device_config,
217                            public cbm_iec_stub_interface,
218                            public device_config_cbm_iec_interface
219{
220    friend class cbm_iec_stub_device;
221
222    // construction/destruction
223    cbm_iec_stub_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
224
225public:
226    // allocators
227    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
228    virtual device_t *alloc_device(running_machine &machine) const;
229
230protected:
231    // device_config overrides
232    virtual void device_config_complete();
233};
234
235
236// ======================> cbm_iec_stub_device
237
238class cbm_iec_stub_device :  public device_t,
239                      public device_cbm_iec_interface
240{
241    friend class cbm_iec_stub_device_config;
242
243    // construction/destruction
244    cbm_iec_stub_device(running_machine &_machine, const cbm_iec_stub_device_config &_config);
245
246protected:
247    // device-level overrides
248    virtual void device_start();
249
250   // device_cbm_iec_interface overrides
251   void cbm_iec_atn(int state);
252   void cbm_iec_clk(int state);
253   void cbm_iec_data(int state);
254   void cbm_iec_srq(int state);
255   void cbm_iec_reset(int state);
256
257private:
258   devcb_resolved_write_line   m_out_atn_func;
259   devcb_resolved_write_line   m_out_clk_func;
260   devcb_resolved_write_line   m_out_data_func;
261   devcb_resolved_write_line   m_out_srq_func;
262   devcb_resolved_write_line   m_out_reset_func;
263
264    const cbm_iec_stub_device_config &m_config;
265};
266
267
268// device type definition
269extern const device_type CBM_IEC;
270extern const device_type CBM_IEC_STUB;
271
272
67273#endif
src/mess/machine/c65.c
r11256r11257
181181 */
182182static READ8_DEVICE_HANDLER( c65_cia1_port_a_r )
183183{
184   c65_state *state = device->machine().driver_data<c65_state>();
184185   UINT8 value = 0xff;
185   device_t *serbus = device->machine().device("serial_bus");
186186
187   if (!cbm_iec_clk_r(serbus))
187   if (!state->m_iec->clk_r())
188188      value &= ~0x40;
189189
190   if (!cbm_iec_data_r(serbus))
190   if (!state->m_iec->data_r())
191191      value &= ~0x80;
192192
193193   return value;
r11256r11257
197197{
198198   c65_state *state = device->machine().driver_data<c65_state>();
199199   static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000};
200   device_t *serbus = device->machine().device("serial_bus");
201200
202   cbm_iec_atn_w(serbus, device, !BIT(data, 3));
203   cbm_iec_clk_w(serbus, device, !BIT(data, 4));
204   cbm_iec_data_w(serbus, device, !BIT(data, 5));
201   state->m_iec->atn_w(!BIT(data, 3));
202   state->m_iec->clk_w(!BIT(data, 4));
203   state->m_iec->data_w(!BIT(data, 5));
205204
206205   state->m_vicaddr = state->m_memory + helper[data & 0x03];
207206}
src/mess/machine/c1581.c
r11256r11257
4848//  DEVICE CONFIGURATION
4949//**************************************************************************
5050
51GENERIC_DEVICE_CONFIG_SETUP(c1581, "C1581");
5251
52//-------------------------------------------------
53//  c1581_device_config - constructor
54//-------------------------------------------------
5355
56c1581_device_config::c1581_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
57   : device_config(mconfig, static_alloc_device_config, "C1581", tag, owner, clock),
58     device_config_cbm_iec_interface(mconfig, *this)
59{
60}
61
62
5463//-------------------------------------------------
64//  static_alloc_device_config - allocate a new
65//  configuration object
66//-------------------------------------------------
67
68device_config *c1581_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
69{
70   return global_alloc(c1581_device_config(mconfig, tag, owner, clock));
71}
72
73
74//-------------------------------------------------
75//  alloc_device - allocate a new device object
76//-------------------------------------------------
77
78device_t *c1581_device_config::alloc_device(running_machine &machine) const
79{
80   return auto_alloc(machine, c1581_device(machine, *this));
81}
82
83
84//-------------------------------------------------
5585//  device_config_complete - perform any
5686//  operations now that the configuration is
5787//  complete
r11256r11257
6797//  static_set_config - configuration helper
6898//-------------------------------------------------
6999
70void c1581_device_config::static_set_config(device_config *device, const char *bus_tag, int address)
100void c1581_device_config::static_set_config(device_config *device, int address)
71101{
72102   c1581_device_config *c1581 = downcast<c1581_device_config *>(device);
73103
74   assert(bus_tag != NULL);
75104   assert((address > 7) && (address < 12));
76105
77   c1581->m_bus_tag = bus_tag;
78106   c1581->m_address = address - 8;
79107}
80108
r11256r11257
224252   UINT8 data = 0;
225253
226254   // data in
227   data = !cbm_iec_data_r(m_bus);
255   data = !m_bus->data_r();
228256
229257   // clock in
230   data |= !cbm_iec_clk_r(m_bus) << 2;
258   data |= !m_bus->clk_r() << 2;
231259
232260   // write protect
233261   data |= !floppy_wpt_r(m_image) << 6;
234262
235263   // attention in
236   data |= !cbm_iec_atn_r(m_bus) << 7;
264   data |= !m_bus->atn_r() << 7;
237265
238266   return data;
239267}
r11256r11257
260288   m_data_out = BIT(data, 1);
261289
262290   // clock out
263   cbm_iec_clk_w(m_bus, this, !BIT(data, 3));
291   m_bus->clk_w(this, !BIT(data, 3));
264292
265293   // attention acknowledge
266294   m_atn_ack = BIT(data, 4);
r11256r11257
363391
364392inline void c1581_device::set_iec_data()
365393{
366   int atn = cbm_iec_atn_r(m_bus);
394   int atn = m_bus->atn_r();
367395   int data = !m_data_out & !(m_atn_ack & !atn);
368396
369397   // fast serial data
370398   if (m_fast_ser_dir) data &= m_sp_out;
371399
372   cbm_iec_data_w(m_bus, this, data);
400   m_bus->data_w(this, data);
373401}
374402
375403
r11256r11257
384412   // fast serial clock
385413   if (m_fast_ser_dir) srq &= m_cnt_out;
386414
387   cbm_iec_srq_w(m_bus, this, srq);
415   m_bus->srq_w(this, srq);
388416}
389417
390418
r11256r11257
399427
400428c1581_device::c1581_device(running_machine &_machine, const c1581_device_config &_config)
401429    : device_t(_machine, _config),
430     device_cbm_iec_interface(_machine, _config, *this),
402431     m_maincpu(*this, M6502_TAG),
403432     m_cia(*this, M8520_TAG),
404433     m_fdc(*this, WD1770_TAG),
405434     m_image(*this, FLOPPY_0),
406     m_bus(machine().device(_config.m_bus_tag)),
435     m_bus(machine().device<cbm_iec_device>(CBM_IEC_TAG)),
407436      m_config(_config)
408437{
409438}
r11256r11257
436465
437466
438467//-------------------------------------------------
439//  iec_atn_w -
468//  cbm_iec_srq -
440469//-------------------------------------------------
441470
442WRITE_LINE_MEMBER( c1581_device::iec_atn_w )
471void c1581_device::cbm_iec_srq(int state)
443472{
444   m_cia->flag_w(state);
445
446   set_iec_data();
473   if (!m_fast_ser_dir)
474   {
475      m_cia->cnt_w(state);
476   }
447477}
448478
449479
450480//-------------------------------------------------
451//  iec_srq_w -
481//  cbm_iec_atn -
452482//-------------------------------------------------
453483
454WRITE_LINE_MEMBER( c1581_device::iec_srq_w )
484void c1581_device::cbm_iec_atn(int state)
455485{
456   if (!m_fast_ser_dir)
457   {
458      m_cia->cnt_w(state);
459   }
486   m_cia->flag_w(state);
487
488   set_iec_data();
460489}
461490
462491
463492//-------------------------------------------------
464//  iec_data_w -
493//  cbm_iec_data -
465494//-------------------------------------------------
466495
467WRITE_LINE_MEMBER( c1581_device::iec_data_w )
496void c1581_device::cbm_iec_data(int state)
468497{
469498   if (!m_fast_ser_dir)
470499   {
r11256r11257
474503
475504
476505//-------------------------------------------------
477//  iec_reset_w -
506//  cbm_iec_reset -
478507//-------------------------------------------------
479WRITE_LINE_MEMBER( c1581_device::iec_reset_w )
508
509void c1581_device::cbm_iec_reset(int state)
480510{
481511   if (!state)
482512   {
src/mess/machine/c1581.h
r11256r11257
2121#include "machine/6526cia.h"
2222#include "machine/cbmiec.h"
2323#include "machine/wd17xx.h"
24#include "machine/devhelpr.h"
2524
2625
2726
r11256r11257
2928//  INTERFACE CONFIGURATION MACROS
3029//**************************************************************************
3130
32#define MCFG_C1581_ADD(_tag, _bus_tag, _address) \
31#define MCFG_C1581_ADD(_tag, _address) \
3332    MCFG_DEVICE_ADD(_tag, C1581, 0) \
34   c1581_device_config::static_set_config(device, _bus_tag, _address);
33   c1581_device_config::static_set_config(device, _address);
3534
3635
37#define C1581_IEC(_tag) \
38   _tag, \
39   DEVCB_DEVICE_LINE_MEMBER(_tag, c1581_device, iec_srq_w), \
40   DEVCB_DEVICE_LINE_MEMBER(_tag, c1581_device, iec_atn_w), \
41   DEVCB_NULL, \
42   DEVCB_DEVICE_LINE_MEMBER(_tag, c1581_device, iec_data_w), \
43   DEVCB_DEVICE_LINE_MEMBER(_tag, c1581_device, iec_reset_w)
4436
45
46
4737//**************************************************************************
4838//  TYPE DEFINITIONS
4939//**************************************************************************
5040
5141// ======================> c1581_device_config
5242
53class c1581_device_config :   public device_config
43class c1581_device_config :   public device_config,
44                       public device_config_cbm_iec_interface
5445{
5546    friend class c1581_device;
5647
r11256r11257
6354    virtual device_t *alloc_device(running_machine &machine) const;
6455
6556   // inline configuration helpers
66   static void static_set_config(device_config *device, const char *bus_tag, int address);
57   static void static_set_config(device_config *device, int address);
6758
6859   // optional information overrides
6960   virtual const rom_entry *device_rom_region() const;
r11256r11257
7465    virtual void device_config_complete();
7566
7667private:
77   const char *m_bus_tag;
7868   int m_address;
7969};
8070
8171
8272// ======================> c1581_device
8373
84class c1581_device :  public device_t
74class c1581_device :  public device_t,
75                 public device_cbm_iec_interface
8576{
8677    friend class c1581_device_config;
8778
r11256r11257
8980    c1581_device(running_machine &_machine, const c1581_device_config &_config);
9081
9182public:
92   DECLARE_WRITE_LINE_MEMBER( iec_atn_w );
93   DECLARE_WRITE_LINE_MEMBER( iec_srq_w );
94   DECLARE_WRITE_LINE_MEMBER( iec_data_w );
95   DECLARE_WRITE_LINE_MEMBER( iec_reset_w );
96
9783   // not really public
9884   DECLARE_WRITE_LINE_MEMBER( cnt_w );
9985   DECLARE_WRITE_LINE_MEMBER( sp_w );
r11256r11257
10793    virtual void device_start();
10894   virtual void device_reset();
10995
96   // device_cbm_iec_interface overrides
97   void cbm_iec_srq(int state);
98   void cbm_iec_atn(int state);
99   void cbm_iec_data(int state);
100   void cbm_iec_reset(int state);
101
110102private:
111103   inline void set_iec_data();
112104   inline void set_iec_srq();
r11256r11257
115107   required_device<mos6526_device> m_cia;
116108   required_device<device_t> m_fdc;
117109   required_device<device_t> m_image;
118   device_t *m_bus;
110   cbm_iec_device *m_bus;
119111
120112   int m_data_out;            // serial data out
121113   int m_atn_ack;            // attention acknowledge
src/mess/machine/c128.c
r11256r11257
200200static void c128_iec_data_out_w(running_machine &machine)
201201{
202202   c128_state *state = machine.driver_data<c128_state>();
203   device_t *cia_1 = machine.device("cia_1");
204   device_t *iec = machine.device("iec");
205203   int data = !state->m_data_out;
206204
207205   /* fast serial data */
208206   if (MMU_FSDIR(state)) data &= state->m_sp1;
209207
210   cbm_iec_data_w(iec, cia_1, data);
208   state->m_iec->data_w(data);
211209}
212210
213211static void c128_iec_srq_out_w(running_machine &machine)
214212{
215213   c128_state *state = machine.driver_data<c128_state>();
216   device_t *cia_1 = machine.device("cia_1");
217   device_t *iec = machine.device("iec");
218214   int srq = 1;
219215
220216   /* fast serial clock */
221217   if (MMU_FSDIR(state)) srq &= state->m_cnt1;
222218
223   cbm_iec_srq_w(iec, cia_1, srq);
219   state->m_iec->srq_w(srq);
224220}
225221
226222static WRITE_LINE_DEVICE_HANDLER( cia0_cnt_w )
r11256r11257
311307 */
312308static READ8_DEVICE_HANDLER( c128_cia1_port_a_r )
313309{
310   c128_state *state = device->machine().driver_data<c128_state>();
314311   UINT8 value = 0xff;
315   device_t *serbus = device->machine().device("iec");
316
317   if (!cbm_iec_clk_r(serbus))
312   
313   if (!state->m_iec->clk_r())
318314      value &= ~0x40;
319315
320   if (!cbm_iec_data_r(serbus))
316   if (!state->m_iec->data_r())
321317      value &= ~0x80;
322318
323319   return value;
r11256r11257
327323{
328324   c128_state *state = device->machine().driver_data<c128_state>();
329325   static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000};
330   device_t *serbus = device->machine().device("iec");
331326
332327   state->m_data_out = BIT(data, 5);
333328   c128_iec_data_out_w(device->machine());
334329
335   cbm_iec_clk_w(serbus, device, !BIT(data, 4));
330   state->m_iec->clk_w(!BIT(data, 4));
336331
337   cbm_iec_atn_w(serbus, device, !BIT(data, 3));
332   state->m_iec->atn_w(!BIT(data, 3));
338333
339334   state->m_vicaddr = state->m_memory + helper[data & 0x03];
340335   state->m_c128_vicaddr = state->m_memory + helper[data & 0x03] + state->m_va1617;
src/mess/machine/c16.c
r11256r11257
7373   c16_state *state = device->machine().driver_data<c16_state>();
7474
7575   /* bit zero then output 0 */
76   cbm_iec_atn_w(state->m_serbus, device, !BIT(data, 2));
77   cbm_iec_clk_w(state->m_serbus, device, !BIT(data, 1));
78   cbm_iec_data_w(state->m_serbus, device, !BIT(data, 0));
76   state->m_iec->atn_w(!BIT(data, 2));
77   state->m_iec->clk_w(!BIT(data, 1));
78   state->m_iec->data_w(!BIT(data, 0));
7979
8080   cassette_output(state->m_cassette, !BIT(data, 1) ? -(0x5a9e >> 1) : +(0x5a9e >> 1));
8181
r11256r11257
8888   UINT8 data = 0xff;
8989   UINT8 c16_port7501 = m6510_get_port(state->m_maincpu);
9090
91   if (BIT(c16_port7501, 0) || !cbm_iec_data_r(state->m_serbus))
91   if (BIT(c16_port7501, 0) || !state->m_iec->data_r())
9292      data &= ~0x80;
9393
94   if (BIT(c16_port7501, 1) || !cbm_iec_clk_r(state->m_serbus))
94   if (BIT(c16_port7501, 1) || !state->m_iec->clk_r())
9595      data &= ~0x40;
9696
9797//  data &= ~0x20; // port bit not in pinout
src/mess/machine/c1541.c
r11256r11257
135135*/
136136
137137#include "c1541.h"
138#include "machine/devhelpr.h"
139138
140139
141140
r11256r11257
175174//  DEVICE CONFIGURATION
176175//**************************************************************************
177176
178GENERIC_DEVICE_CONFIG_SETUP(c1541, "C1541");
177//-------------------------------------------------
178//  c1541_device_config - constructor
179//-------------------------------------------------
179180
181c1541_device_config::c1541_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
182   : device_config(mconfig, static_alloc_device_config, "C1541", tag, owner, clock),
183     device_config_cbm_iec_interface(mconfig, *this)
184{
185}
180186
187
181188//-------------------------------------------------
189//  static_alloc_device_config - allocate a new
190//  configuration object
191//-------------------------------------------------
192
193device_config *c1541_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
194{
195   return global_alloc(c1541_device_config(mconfig, tag, owner, clock));
196}
197
198
199//-------------------------------------------------
200//  alloc_device - allocate a new device object
201//-------------------------------------------------
202
203device_t *c1541_device_config::alloc_device(running_machine &machine) const
204{
205   return auto_alloc(machine, c1541_device(machine, *this));
206}
207
208
209//-------------------------------------------------
182210//  device_config_complete - perform any
183211//  operations now that the configuration is
184212//  complete
r11256r11257
194222//  static_set_config - configuration helper
195223//-------------------------------------------------
196224
197void c1541_device_config::static_set_config(device_config *device, const char *bus_tag, int address)
225void c1541_device_config::static_set_config(device_config *device, int address)
198226{
199227   c1541_device_config *c1541 = downcast<c1541_device_config *>(device);
200228
201   assert(bus_tag != NULL);
202229   assert((address > 7) && (address < 12));
203230
204   c1541->m_bus_tag = bus_tag;
205231   c1541->m_address = address - 8;
206232}
207233
r11256r11257
311337   UINT8 data = 0;
312338
313339   // data in
314   data = !cbm_iec_data_r(m_bus);
340   data = !m_bus->data_r();
315341
316342   // clock in
317   data |= !cbm_iec_clk_r(m_bus) << 2;
343   data |= !m_bus->clk_r() << 2;
318344
319345   // serial bus address
320346   data |= m_config.m_address << 5;
321347
322348   // attention in
323   data |= !cbm_iec_atn_r(m_bus) << 7;
349   data |= !m_bus->atn_r() << 7;
324350
325351   return data;
326352}
r11256r11257
350376   m_ga->atna_w(BIT(data, 4));
351377
352378   // clock out
353   cbm_iec_clk_w(m_bus, this, !BIT(data, 3));
379   m_bus->clk_w(this, !BIT(data, 3));
354380}
355381
356382
357383READ_LINE_MEMBER( c1541_device::atn_in_r )
358384{
359   return !cbm_iec_atn_r(m_bus);
385   return !m_bus->atn_r();
360386}
361387
362388
r11256r11257
784810{
785811   int data = !m_data_out & !m_ga->atn_r();
786812
787   cbm_iec_data_w(m_bus, this, data);
813   m_bus->data_w(this, data);
788814}
789815
790816
r11256r11257
799825
800826c1541_device::c1541_device(running_machine &_machine, const c1541_device_config &_config)
801827    : device_t(_machine, _config),
828     device_cbm_iec_interface(_machine, _config, *this),
802829     m_maincpu(*this, M6502_TAG),
803830     m_via0(*this, M6522_0_TAG),
804831     m_via1(*this, M6522_1_TAG),
805832     m_ga(*this, C64H156_TAG),
806833     m_image(*this, FLOPPY_0),
807     m_bus(machine().device(_config.m_bus_tag)),
834     m_bus(machine().device<cbm_iec_device>(CBM_IEC_TAG)),
808835     m_data_out(1),
809836     m_via0_irq(0),
810837     m_via1_irq(0),
r11256r11257
843870//  iec_atn_w -
844871//-------------------------------------------------
845872
846WRITE_LINE_MEMBER( c1541_device::iec_atn_w )
873void c1541_device::cbm_iec_atn(int state)
847874{
848875   m_via0->write_ca1(!state);
849876   m_ga->atni_w(!state);
r11256r11257
856883//  iec_reset_w -
857884//-------------------------------------------------
858885
859WRITE_LINE_MEMBER( c1541_device::iec_reset_w )
886void c1541_device::cbm_iec_reset(int state)
860887{
861888   if (!state)
862889   {
src/mess/machine/c1541.h
r11256r11257
3030//  INTERFACE CONFIGURATION MACROS
3131//**************************************************************************
3232
33#define MCFG_C1541_ADD(_tag, _bus_tag, _address) \
33#define MCFG_C1541_ADD(_tag, _address) \
3434    MCFG_DEVICE_ADD(_tag, C1541, 0) \
35   c1541_device_config::static_set_config(device, _bus_tag, _address);
35   c1541_device_config::static_set_config(device, _address);
3636
3737
38#define C1541_IEC(_tag) \
39   _tag, \
40   DEVCB_NULL, \
41   DEVCB_DEVICE_LINE_MEMBER(_tag, c1541_device, iec_atn_w), \
42   DEVCB_NULL, \
43   DEVCB_NULL, \
44   DEVCB_DEVICE_LINE_MEMBER(_tag, c1541_device, iec_reset_w)
4538
46
47
4839//**************************************************************************
4940//  TYPE DEFINITIONS
5041//**************************************************************************
5142
5243// ======================> c1541_device_config
5344
54class c1541_device_config :   public device_config
45class c1541_device_config :   public device_config,
46                       public device_config_cbm_iec_interface
5547{
5648    friend class c1541_device;
5749
r11256r11257
6456    virtual device_t *alloc_device(running_machine &machine) const;
6557
6658   // inline configuration helpers
67   static void static_set_config(device_config *device, const char *bus_tag, int address);
59   static void static_set_config(device_config *device, int address);
6860
6961   // optional information overrides
7062   virtual const rom_entry *device_rom_region() const;
r11256r11257
7466    // device_config overrides
7567    virtual void device_config_complete();
7668   
77   const char *m_bus_tag;
7869   int m_address;
7970};
8071
8172
8273// ======================> c1541_device
8374
84class c1541_device :  public device_t
75class c1541_device :  public device_t,
76                 public device_cbm_iec_interface
8577{
8678    friend class c1541_device_config;
8779
r11256r11257
8981    c1541_device(running_machine &_machine, const c1541_device_config &_config);
9082
9183public:
92   DECLARE_WRITE_LINE_MEMBER( iec_atn_w );
93   DECLARE_WRITE_LINE_MEMBER( iec_reset_w );
94
9584   // not really public
9685   static void on_disk_change(device_image_interface &image);
9786
r11256r11257
112101    virtual void device_start();
113102   virtual void device_reset();
114103
104   // device_cbm_iec_interface overrides
105   void cbm_iec_atn(int state);
106   void cbm_iec_reset(int state);
107
115108   inline void set_iec_data();
116109
117110   required_device<cpu_device> m_maincpu;
r11256r11257
119112   required_device<via6522_device> m_via1;
120113   required_device<c64h156_device> m_ga;
121114   required_device<device_t> m_image;
122   device_t *m_bus;
115   cbm_iec_device *m_bus;
123116
124117   // IEC bus
125118   int m_data_out;                     // serial data out
src/mess/machine/primo.c
r11256r11257
104104
105105READ8_HANDLER( primo_be_2_r )
106106{
107   primo_state *state = space->machine().driver_data<primo_state>();
107108   UINT8 data = 0xff;
108   device_t *serbus = space->machine().device("serial_bus");
109109
110110   // bit 7, 6 - not used
111111
112112   // bit 5 - SCLK
113   if (!cbm_iec_clk_r(serbus))
113   if (!state->m_iec->clk_r())
114114      data &= ~0x20;
115115
116116   // bit 4 - SDATA
117   if (!cbm_iec_data_r(serbus))
117   if (!state->m_iec->data_r())
118118      data &= ~0x10;
119119
120120   // bit 3 - SRQ
121   if (!cbm_iec_srq_r(serbus))
121   if (!state->m_iec->srq_r())
122122      data &= ~0x08;
123123
124124   // bit 2 - joystic 2 (not implemeted yet)
125125
126126   // bit 1 - ATN
127   if (!cbm_iec_atn_r(serbus))
127   if (!state->m_iec->atn_r())
128128      data &= ~0x02;
129129
130130   // bit 0 - joystic 1 (not implemeted yet)
r11256r11257
173173
174174WRITE8_HANDLER( primo_ki_2_w )
175175{
176   device_t *serbus = space->machine().device("serial_bus");
176   primo_state *state = space->machine().driver_data<primo_state>();
177177
178178   // bit 7, 6 - not used
179179
180180   // bit 5 - SCLK
181   cbm_iec_clk_w(serbus, NULL, !BIT(data, 5));
181   state->m_iec->clk_w(!BIT(data, 5));
182182
183183   // bit 4 - SDATA
184   cbm_iec_data_w(serbus, NULL, !BIT(data, 4));
184   state->m_iec->data_w(!BIT(data, 4));
185185
186186   // bit 3 - not used
187187
188188   // bit 2 - SRQ
189   cbm_iec_srq_w(serbus, NULL, !BIT(data, 2));
189   state->m_iec->srq_w(!BIT(data, 2));
190190
191191   // bit 1 - ATN
192   cbm_iec_atn_w(serbus, NULL, !BIT(data, 1));
192   state->m_iec->atn_w(!BIT(data, 1));
193193
194194   // bit 0 - not used
195195
src/mess/machine/iecstub.c
r0r11257
1#include "cbmiec.h"
2
3
4
5//**************************************************************************
6//  DEVICE DEFINITIONS
7//**************************************************************************
8
9const device_type CBM_IEC_STUB = cbm_iec_stub_device_config::static_alloc_device_config;
10
11
12
13//**************************************************************************
14//  DEVICE CONFIGURATION
15//**************************************************************************
16
17//-------------------------------------------------
18//  cbm_iec_stub_device_config - constructor
19//-------------------------------------------------
20
21cbm_iec_stub_device_config::cbm_iec_stub_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
22   : device_config(mconfig, static_alloc_device_config, "CBM IEC driver stub", tag, owner, clock),
23     device_config_cbm_iec_interface(mconfig, *this)
24{
25}
26
27
28//-------------------------------------------------
29//  static_alloc_device_config - allocate a new
30//  configuration object
31//-------------------------------------------------
32
33device_config *cbm_iec_stub_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
34{
35   return global_alloc(cbm_iec_stub_device_config(mconfig, tag, owner, clock));
36}
37
38
39//-------------------------------------------------
40//  alloc_device - allocate a new device object
41//-------------------------------------------------
42
43device_t *cbm_iec_stub_device_config::alloc_device(running_machine &machine) const
44{
45   return auto_alloc(machine, cbm_iec_stub_device(machine, *this));
46}
47
48
49//-------------------------------------------------
50//  device_config_complete - perform any
51//  operations now that the configuration is
52//  complete
53//-------------------------------------------------
54
55void cbm_iec_stub_device_config::device_config_complete()
56{
57   // inherit a copy of the static data
58   const cbm_iec_stub_interface *intf = reinterpret_cast<const cbm_iec_stub_interface *>(static_config());
59   if (intf != NULL)
60      *static_cast<cbm_iec_stub_interface *>(this) = *intf;
61
62   // or initialize to defaults if none provided
63   else
64   {
65      memset(&m_out_srq_func, 0, sizeof(m_out_srq_func));
66      memset(&m_out_atn_func, 0, sizeof(m_out_atn_func));
67      memset(&m_out_clk_func, 0, sizeof(m_out_clk_func));
68      memset(&m_out_data_func, 0, sizeof(m_out_data_func));
69      memset(&m_out_reset_func, 0, sizeof(m_out_reset_func));
70   }
71}
72
73
74//**************************************************************************
75//  LIVE DEVICE
76//**************************************************************************
77
78//-------------------------------------------------
79//  cbm_iec_stub_device - constructor
80//-------------------------------------------------
81
82cbm_iec_stub_device::cbm_iec_stub_device(running_machine &_machine, const cbm_iec_stub_device_config &_config)
83    : device_t(_machine, _config),
84     device_cbm_iec_interface(_machine, _config, *this),
85      m_config(_config)
86{
87}
88
89
90//-------------------------------------------------
91//  device_start - device-specific startup
92//-------------------------------------------------
93
94void cbm_iec_stub_device::device_start()
95{
96   // resolve callbacks
97    devcb_resolve_write_line(&m_out_srq_func, &m_config.m_out_srq_func, this);
98    devcb_resolve_write_line(&m_out_atn_func, &m_config.m_out_atn_func, this);
99    devcb_resolve_write_line(&m_out_clk_func, &m_config.m_out_clk_func, this);
100    devcb_resolve_write_line(&m_out_data_func, &m_config.m_out_data_func, this);
101    devcb_resolve_write_line(&m_out_reset_func, &m_config.m_out_reset_func, this);
102}
103
104
105//-------------------------------------------------
106//  cbm_iec_srq -
107//-------------------------------------------------
108
109void cbm_iec_stub_device::cbm_iec_srq(int state)
110{
111   devcb_call_write_line(&m_out_srq_func, state);
112}
113
114
115//-------------------------------------------------
116//  cbm_iec_atn -
117//-------------------------------------------------
118
119void cbm_iec_stub_device::cbm_iec_atn(int state)
120{
121   devcb_call_write_line(&m_out_atn_func, state);
122}
123
124
125//-------------------------------------------------
126//  cbm_iec_clk -
127//-------------------------------------------------
128
129void cbm_iec_stub_device::cbm_iec_clk(int state)
130{
131   devcb_call_write_line(&m_out_clk_func, state);
132}
133
134
135//-------------------------------------------------
136//  cbm_iec_data -
137//-------------------------------------------------
138
139void cbm_iec_stub_device::cbm_iec_data(int state)
140{
141   devcb_call_write_line(&m_out_data_func, state);
142}
143
144
145//-------------------------------------------------
146//  cbm_iec_reset -
147//-------------------------------------------------
148
149void cbm_iec_stub_device::cbm_iec_reset(int state)
150{
151   devcb_call_write_line(&m_out_reset_func, state);
152}
src/mess/machine/c1571.c
r11256r11257
2020*/
2121
2222#include "c1571.h"
23#include "machine/devhelpr.h"
2423
2524
2625
r11256r11257
5655//  DEVICE CONFIGURATION
5756//**************************************************************************
5857
59GENERIC_DEVICE_CONFIG_SETUP(c1571, "C1571");
58//-------------------------------------------------
59//  c1571_device_config - constructor
60//-------------------------------------------------
6061
62c1571_device_config::c1571_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
63   : device_config(mconfig, static_alloc_device_config, "C1571", tag, owner, clock),
64     device_config_cbm_iec_interface(mconfig, *this)
65{
66}
6167
68
6269//-------------------------------------------------
70//  static_alloc_device_config - allocate a new
71//  configuration object
72//-------------------------------------------------
73
74device_config *c1571_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
75{
76   return global_alloc(c1571_device_config(mconfig, tag, owner, clock));
77}
78
79
80//-------------------------------------------------
81//  alloc_device - allocate a new device object
82//-------------------------------------------------
83
84device_t *c1571_device_config::alloc_device(running_machine &machine) const
85{
86   return auto_alloc(machine, c1571_device(machine, *this));
87}
88
89
90//-------------------------------------------------
6391//  device_config_complete - perform any
6492//  operations now that the configuration is
6593//  complete
r11256r11257
75103//  static_set_config - configuration helper
76104//-------------------------------------------------
77105
78void c1571_device_config::static_set_config(device_config *device, const char *bus_tag, int address)
106void c1571_device_config::static_set_config(device_config *device, int address)
79107{
80108   c1571_device_config *c1571 = downcast<c1571_device_config *>(device);
81109
82   assert(bus_tag != NULL);
83110   assert((address > 7) && (address < 12));
84111
85   c1571->m_bus_tag = bus_tag;
86112   c1571->m_address = address - 8;
87113}
88114
r11256r11257
216242   
217243      if (!m_ser_dir)
218244      {
219         //m_cia->cnt_w(cbm_iec_srq_r(m_bus));
220         //m_cia->sp_w(cbm_iec_data_r(m_bus));
245         //m_cia->cnt_w(m_bus->srq_r());
246         //m_cia->sp_w(m_bus->data_r());
221247      }
222248   }
223249
r11256r11257
225251   m_ga->set_side(BIT(data, 2));
226252
227253   // attention out
228   cbm_iec_atn_w(m_bus, this, !BIT(data, 6));
254   m_bus->atn_w(this, !BIT(data, 6));
229255}
230256
231257
r11256r11257
249275   UINT8 data = 0;
250276
251277   // data in
252   data = !cbm_iec_data_r(m_bus);
278   data = !m_bus->data_r();
253279
254280   // clock in
255   data |= !cbm_iec_clk_r(m_bus) << 2;
281   data |= !m_bus->clk_r() << 2;
256282
257283   // serial bus address
258284   data |= m_config.m_address << 5;
259285
260286   // attention in
261   data |= !cbm_iec_atn_r(m_bus) << 7;
287   data |= !m_bus->atn_r() << 7;
262288
263289   return data;
264290}
r11256r11257
288314   m_ga->atna_w(BIT(data, 4));
289315
290316   // clock out
291   cbm_iec_clk_w(m_bus, this, !BIT(data, 3));
317   m_bus->clk_w(this, !BIT(data, 3));
292318}
293319
294320
295321READ_LINE_MEMBER( c1571_device::atn_in_r )
296322{
297   return !cbm_iec_atn_r(m_bus);
323   return !m_bus->atn_r();
298324}
299325
300326
r11256r11257
574600   // fast serial data
575601   if (m_ser_dir) data &= m_sp_out;
576602
577   cbm_iec_data_w(m_bus, this, data);
603   m_bus->data_w(this, data);
578604}
579605
580606
r11256r11257
589615   // fast serial clock
590616   if (m_ser_dir) srq &= m_cnt_out;
591617
592   cbm_iec_srq_w(m_bus, this, srq);
618   m_bus->srq_w(this, srq);
593619}
594620
595621
r11256r11257
604630
605631c1571_device::c1571_device(running_machine &_machine, const c1571_device_config &_config)
606632    : device_t(_machine, _config),
633     device_cbm_iec_interface(_machine, _config, *this),
607634     m_maincpu(*this, M6502_TAG),
608635     m_via0(*this, M6522_0_TAG),
609636     m_via1(*this, M6522_1_TAG),
r11256r11257
611638     m_fdc(*this, WD1770_TAG),
612639     m_ga(*this, C64H156_TAG),
613640     m_image(*this, FLOPPY_0),
614     m_bus(machine().device(_config.m_bus_tag)),
641     m_bus(machine().device<cbm_iec_device>(CBM_IEC_TAG)),
615642     m_1_2mhz(0),
616643     m_data_out(1),
617644     m_ser_dir(0),
r11256r11257
662689
663690
664691//-------------------------------------------------
665//  iec_atn_w -
692//  cbm_iec_srq -
666693//-------------------------------------------------
667694
668WRITE_LINE_MEMBER( c1571_device::iec_atn_w )
695void c1571_device::cbm_iec_srq(int state)
669696{
670   m_via0->write_ca1(!state);
671   m_ga->atni_w(!state);
672
673   set_iec_data();
697   if (!m_ser_dir)
698   {
699      //m_cia->cnt_w(state);
700   }
674701}
675702
676703
677704//-------------------------------------------------
678//  iec_srq_w -
705//  cbm_iec_atn -
679706//-------------------------------------------------
680707
681WRITE_LINE_MEMBER( c1571_device::iec_srq_w )
708void c1571_device::cbm_iec_atn(int state)
682709{
683   if (!m_ser_dir)
684   {
685      //m_cia->cnt_w(state);
686   }
710   m_via0->write_ca1(!state);
711   m_ga->atni_w(!state);
712
713   set_iec_data();
687714}
688715
689716
690717//-------------------------------------------------
691//  iec_data_w -
718//  cbm_iec_data -
692719//-------------------------------------------------
693720
694WRITE_LINE_MEMBER( c1571_device::iec_data_w )
721void c1571_device::cbm_iec_data(int state)
695722{
696723   if (!m_ser_dir)
697724   {
r11256r11257
701728
702729
703730//-------------------------------------------------
704//  iec_reset_w -
731//  cbm_iec_reset -
705732//-------------------------------------------------
706733
707WRITE_LINE_MEMBER( c1571_device::iec_reset_w )
734void c1571_device::cbm_iec_reset(int state)
708735{
709736   if (!state)
710737   {
src/mess/machine/c1571.h
r11256r11257
3131//  INTERFACE CONFIGURATION MACROS
3232//**************************************************************************
3333
34#define MCFG_C1571_ADD(_tag, _bus_tag, _address) \
34#define MCFG_C1571_ADD(_tag, _address) \
3535    MCFG_DEVICE_ADD(_tag, C1571, 0) \
36   c1571_device_config::static_set_config(device, _bus_tag, _address);
36   c1571_device_config::static_set_config(device, _address);
3737
3838
39#define C1571_IEC(_tag) \
40   _tag, \
41   DEVCB_DEVICE_LINE_MEMBER(_tag, c1571_device, iec_srq_w), \
42   DEVCB_DEVICE_LINE_MEMBER(_tag, c1571_device, iec_atn_w), \
43   DEVCB_NULL, \
44   DEVCB_DEVICE_LINE_MEMBER(_tag, c1571_device, iec_data_w), \
45   DEVCB_DEVICE_LINE_MEMBER(_tag, c1571_device, iec_reset_w)
4639
47
48
4940//**************************************************************************
5041//  TYPE DEFINITIONS
5142//**************************************************************************
5243
5344// ======================> c1571_device_config
5445
55class c1571_device_config :   public device_config
46class c1571_device_config :   public device_config,
47                       public device_config_cbm_iec_interface
5648{
5749    friend class c1571_device;
5850
r11256r11257
6557    virtual device_t *alloc_device(running_machine &machine) const;
6658
6759   // inline configuration helpers
68   static void static_set_config(device_config *device, const char *bus_tag, int address);
60   static void static_set_config(device_config *device, int address);
6961
7062   // optional information overrides
7163   virtual const rom_entry *device_rom_region() const;
r11256r11257
7668    virtual void device_config_complete();
7769   
7870private:
79   const char *m_bus_tag;
8071   int m_address;
8172};
8273
8374
8475// ======================> c1571_device
8576
86class c1571_device :  public device_t
77class c1571_device :  public device_t,
78                 public device_cbm_iec_interface
8779{
8880    friend class c1571_device_config;
8981
r11256r11257
9183    c1571_device(running_machine &_machine, const c1571_device_config &_config);
9284
9385public:
94   DECLARE_WRITE_LINE_MEMBER( iec_atn_w );
95   DECLARE_WRITE_LINE_MEMBER( iec_srq_w );
96   DECLARE_WRITE_LINE_MEMBER( iec_data_w );
97   DECLARE_WRITE_LINE_MEMBER( iec_reset_w );
98
9986   // not really public
10087   static void on_disk_change(device_image_interface &image);
10188
r11256r11257
121108    virtual void device_start();
122109   virtual void device_reset();
123110
111   // device_cbm_iec_interface overrides
112   void cbm_iec_srq(int state);
113   void cbm_iec_atn(int state);
114   void cbm_iec_data(int state);
115   void cbm_iec_reset(int state);
116
124117private:
125118   inline void set_iec_data();
126119   inline void set_iec_srq();
r11256r11257
132125   required_device<device_t> m_fdc;
133126   required_device<c64h156_device> m_ga;
134127   required_device<device_t> m_image;
135   device_t *m_bus;
128   cbm_iec_device *m_bus;
136129
137130   // signals
138131   int m_1_2mhz;                     // clock speed
src/mess/machine/c64.c
r11256r11257
180180 */
181181static READ8_DEVICE_HANDLER( c64_cia1_port_a_r )
182182{
183   c64_state *state = device->machine().driver_data<c64_state>();
184
183185   UINT8 value = 0xff;
184   device_t *serbus = device->machine().device("iec");
185186
186   if (!cbm_iec_clk_r(serbus))
187   if (!state->m_iec->clk_r())
187188      value &= ~0x40;
188189
189   if (!cbm_iec_data_r(serbus))
190   if (!state->m_iec->data_r())
190191      value &= ~0x80;
191192
192193   return value;
r11256r11257
196197{
197198   c64_state *state = device->machine().driver_data<c64_state>();
198199   static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000};
199   device_t *serbus = device->machine().device("iec");
200200
201   cbm_iec_clk_w(serbus, device, !(data & 0x10));
202   cbm_iec_data_w(serbus, device, !(data & 0x20));
203   cbm_iec_atn_w(serbus, device, !(data & 0x08));
201   state->m_iec->clk_w(!(data & 0x10));
202   state->m_iec->data_w(!(data & 0x20));
203   state->m_iec->atn_w(!(data & 0x08));
204204   state->m_vicaddr = state->m_memory + helper[data & 0x03];
205205}
206206
src/mess/includes/vic20.h
r11256r11257
22#define __VIC20__
33
44#include "machine/6522via.h"
5#include "machine/cbmiec.h"
56
67#define SCREEN_TAG      "screen"
78#define M6502_TAG      "ue10"
r11256r11257
2021{
2122public:
2223   vic20_state(running_machine &machine, const driver_device_config_base &config)
23      : driver_device(machine, config) { }
24      : driver_device(machine, config),
25        m_maincpu(*this, M6502_TAG),
26        m_via0(*this, M6522_0_TAG),
27        m_via1(*this, M6522_1_TAG),
28        m_iec(*this, CBM_IEC_TAG),
29        m_cassette(*this, CASSETTE_TAG),
30        m_mos6560(*this, M6560_TAG)
31   { }
2432
33   required_device<cpu_device> m_maincpu;
34   required_device<via6522_device> m_via0;
35   required_device<via6522_device> m_via1;
36   required_device<cbm_iec_device> m_iec;
37   required_device<device_t> m_cassette;
38   required_device<device_t> m_mos6560;
39
2540   /* keyboard state */
2641   int m_key_col;
2742
28   /* devices */
29   via6522_device *m_via0;
30   via6522_device *m_via1;
31   device_t *m_iec;
32   device_t *m_cassette;
33   device_t *m_mos6560;
34
3543   /* timers */
3644   timer_device *m_cassette_timer;
3745};
src/mess/includes/c16.h
r11256r11257
77#ifndef __C16_H__
88#define __C16_H__
99
10#include "machine/cbmiec.h"
11
1012class c16_state : public driver_device
1113{
1214public:
1315   c16_state(running_machine &machine, const driver_device_config_base &config)
14      : driver_device(machine, config) { }
15
16      : driver_device(machine, config),
17        m_iec(*this, CBM_IEC_TAG)
18    { }
19   
20   required_device<cbm_iec_device> m_iec;
21   
1622   /* memory pointers */
1723   UINT8 *      m_mem10000;
1824   UINT8 *      m_mem14000;
r11256r11257
3440   /* devices */
3541   legacy_cpu_device *m_maincpu;
3642   device_t *m_ted7360;
37   device_t *m_serbus;
3843   device_t *m_cassette;
3944   device_t *m_messram;
4045   device_t *m_sid;
src/mess/includes/primo.h
r11256r11257
88#define PRIMO_H_
99
1010#include "imagedev/snapquik.h"
11#include "machine/cbmiec.h"
1112
12
1313class primo_state : public driver_device
1414{
1515public:
1616   primo_state(running_machine &machine, const driver_device_config_base &config)
17      : driver_device(machine, config) { }
17      : driver_device(machine, config),
18        m_iec(*this, CBM_IEC_TAG)
19    { }
1820
21   required_device<cbm_iec_device> m_iec;
22
1923   UINT16 m_video_memory_base;
2024   UINT8 m_port_FD;
2125   int m_nmi;
src/mess/includes/c64.h
r11256r11257
1414#define C64_H_
1515
1616#include "machine/6526cia.h"
17#include "machine/cbmiec.h"
1718#include "imagedev/cartslot.h"
1819
1920#define C64_MAX_ROMBANK 64 // .crt files contain multiple 'CHIPs', i.e. rom banks (of variable size) with headers. Known carts have at most 64 'CHIPs'.
r11256r11257
3536{
3637public:
3738   c64_state(running_machine &machine, const driver_device_config_base &config)
38      : driver_device(machine, config) { }
39      : driver_device(machine, config),
40        m_iec(*this, CBM_IEC_TAG)
41    { }
3942
43   required_device<cbm_iec_device> m_iec;
44
4045   int m_old_level;
4146   int m_old_data;
4247   int m_old_exrom;
src/mess/mess.mak
r11256r11257
758758   $(MESS_DRIVERS)/c65.o      \
759759   $(MESS_DRIVERS)/c128.o      \
760760   $(MESS_MACHINE)/cbmiec.o   \
761   $(MESS_MACHINE)/iecstub.o   \
761762   $(MESS_MACHINE)/c1541.o      \
762763   $(MESS_MACHINE)/c1551.o      \
763764   $(MESS_MACHINE)/c1571.o      \
src/mess/drivers/vic20.c
r11256r11257
188188   UINT8 data = 0xfc;
189189
190190   /* serial clock in */
191   data |= cbm_iec_clk_r(state->m_iec);
191   data |= state->m_iec->clk_r();
192192
193193   /* serial data in */
194   data |= cbm_iec_data_r(state->m_iec) << 1;
194   data |= state->m_iec->data_r() << 1;
195195
196196   /* joystick */
197197   data &= ~(input_port_read(device->machine(), "JOY") & 0x3c);
r11256r11257
225225   vic20_state *state = device->machine().driver_data<vic20_state>();
226226
227227   /* serial attention out */
228   cbm_iec_atn_w(state->m_iec, device, !BIT(data, 7));
228   state->m_iec->atn_w(!BIT(data, 7));
229229}
230230
231231static READ8_DEVICE_HANDLER( via0_pb_r )
r11256r11257
389389   vic20_state *driver_state = device->machine().driver_data<vic20_state>();
390390
391391   /* serial clock out */
392   cbm_iec_clk_w(driver_state->m_iec, device, !state);
392   driver_state->m_iec->clk_w(!state);
393393}
394394
395395static WRITE_LINE_DEVICE_HANDLER( via1_cb2_w )
r11256r11257
397397   vic20_state *driver_state = device->machine().driver_data<vic20_state>();
398398
399399   /* serial data out */
400   cbm_iec_data_w(driver_state->m_iec, device, !state);
400   driver_state->m_iec->data_w(!state);
401401}
402402
403403static const via6522_interface vic20_via1_intf =
r11256r11257
433433
434434static CBM_IEC_DAISY( cbm_iec_daisy )
435435{
436   { M6522_0_TAG },
437   { M6522_1_TAG, DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_cb1), },
438   { C1541_IEC(C1540_TAG) },
439   { NULL}
436   { C1540_TAG },
437   { NULL }
440438};
441439
440static CBM_IEC_INTERFACE( cbm_iec_intf )
441{
442   DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_cb1),
443   DEVCB_NULL,
444   DEVCB_NULL,
445   DEVCB_NULL,
446   DEVCB_NULL
447};
448
442449/* IEEE-488 Bus */
443450
444451#ifdef INCLUDE_C2031
r11256r11257
526533   address_space *program = machine.device(M6502_TAG)->memory().space(AS_PROGRAM);
527534
528535   /* find devices */
529   state->m_via0 = machine.device<via6522_device>(M6522_0_TAG);
530   state->m_via1 = machine.device<via6522_device>(M6522_1_TAG);
531   state->m_iec = machine.device(IEC_TAG);
532   state->m_cassette = machine.device(CASSETTE_TAG);
533536   state->m_cassette_timer = machine.device<timer_device>(TIMER_C1530_TAG);
534   state->m_mos6560 = machine.device(M6560_TAG);
535537
536   /* set VIA clocks */
537   state->m_via0->set_unscaled_clock(machine.device(M6502_TAG)->unscaled_clock());
538   state->m_via1->set_unscaled_clock(machine.device(M6502_TAG)->unscaled_clock());
539
540538   /* memory expansions */
541539   switch (ram_get_size(machine.device(RAM_TAG)))
542540   {
r11256r11257
696694
697695   MCFG_QUICKLOAD_ADD("quickload", cbm_vc20, "p00,prg", CBM_QUICKLOAD_DELAY_SECONDS)
698696   MCFG_CASSETTE_ADD(CASSETTE_TAG, cbm_cassette_config )
699   MCFG_CBM_IEC_ADD(IEC_TAG, cbm_iec_daisy)
700   //MCFG_C1540_ADD(C1540_TAG, IEC_TAG, 8)
701   MCFG_C1541_ADD(C1540_TAG, IEC_TAG, 8)
697   MCFG_CBM_IEC_CONFIG_ADD(cbm_iec_daisy, cbm_iec_intf)
698   //MCFG_C1540_ADD(C1540_TAG, 8)
699   MCFG_C1541_ADD(C1540_TAG, 8)
702700#ifdef INCLUDE_C2031
703701    MCFG_IEEE488_ADD(IEEE488_TAG, ieee488_daisy)
704702    MCFG_VIC1112_ADD(vic1112_intf)
src/mess/drivers/c128.c
r11256r11257
660660
661661static CBM_IEC_DAISY( c128_iec_bus )
662662{
663   { "cia_0", DEVCB_DEVICE_LINE("cia_0", c128_iec_srq_w), DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE("cia_0", c128_iec_data_w) },
664   { "cia_1" },
665   { C1571_IEC("c1571") },
666   { NULL}
663   { "c1571" },
664   { NULL }
667665};
668666
669667static CBM_IEC_DAISY( c128d81_iec_bus )
670668{
671   { "cia_0", DEVCB_DEVICE_LINE("cia_0", c128_iec_srq_w), DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE("cia_0", c128_iec_data_w) },
672   { "cia_1" },
673   { C1581_IEC("c1581") },
674   { NULL}
669   { "c1581" },
670   { NULL }
675671};
676672
673static CBM_IEC_INTERFACE( c128_iec_intf )
674{
675   DEVCB_DEVICE_LINE("cia_0", c128_iec_srq_w),
676   DEVCB_NULL,
677   DEVCB_NULL,
678   DEVCB_DEVICE_LINE("cia_0", c128_iec_data_w),
679   DEVCB_NULL
680};
681
677682/*************************************
678683 *
679684 *  VIC II / VDC interfaces
r11256r11257
790795   MCFG_MOS6526R1_ADD("cia_1", VIC6567_CLOCK, c128_ntsc_cia1)
791796
792797   /* floppy from serial bus */
793   MCFG_CBM_IEC_ADD("iec", c128_iec_bus)
794   MCFG_C1571_ADD("c1571", "iec", 8)
798   MCFG_CBM_IEC_CONFIG_ADD(c128_iec_bus, c128_iec_intf)
799   MCFG_C1571_ADD("c1571", 8)
795800
796801   MCFG_FRAGMENT_ADD(c64_cartslot)
797802MACHINE_CONFIG_END
r11256r11257
808813
809814static MACHINE_CONFIG_DERIVED( c128d81, c128 )
810815
811   MCFG_DEVICE_REMOVE("iec")
816   MCFG_CBM_IEC_REMOVE()
812817   MCFG_DEVICE_REMOVE("c1571")
813818
814   MCFG_CBM_IEC_ADD("iec", c128d81_iec_bus)
815//  MCFG_C1563_ADD("c1563", "iec", 8)
816   MCFG_C1581_ADD("c1581", "iec", 8)
819   MCFG_CBM_IEC_CONFIG_ADD(c128d81_iec_bus, c128_iec_intf)
820//  MCFG_C1563_ADD("c1563", 8)
821   MCFG_C1581_ADD("c1581", 8)
817822MACHINE_CONFIG_END
818823
819824
src/mess/drivers/c16.c
r11256r11257
419419
420420static CBM_IEC_DAISY( c16_iec_no_drives )
421421{
422   { "maincpu" },
423   { NULL}
422   { NULL }
424423};
425424
426425static CBM_IEC_DAISY( c16_iec_1541 )
427426{
428   { "maincpu" },
429   { C1541_IEC("c1541") },
430   { NULL}
427   { "c1541" },
428   { NULL }
431429};
432430
433431static SCREEN_UPDATE( c16 )
r11256r11257
450448
451449   state->m_maincpu = machine.device<legacy_cpu_device>("maincpu");
452450   state->m_ted7360 = machine.device("ted7360");
453   state->m_serbus = machine.device("iec");
454451   state->m_cassette = machine.device("cassette");
455452   state->m_messram = machine.device(RAM_TAG);
456453   state->m_sid = machine.device("sid");
r11256r11257
501498   MCFG_FRAGMENT_ADD(c16_cartslot)
502499
503500   /* IEC serial bus */
504   MCFG_CBM_IEC_ADD("iec", c16_iec_no_drives)
501   MCFG_CBM_IEC_ADD(c16_iec_no_drives)
505502
506503   /* internal ram */
507504   MCFG_RAM_ADD(RAM_TAG)
r11256r11257
525522static MACHINE_CONFIG_DERIVED( c16v, c16 )
526523
527524   /* floppy from serial bus */
528   MCFG_DEVICE_REMOVE("iec")
529   MCFG_CBM_IEC_ADD("iec", c16_iec_1541)
530   MCFG_C1541_ADD("c1541", "iec", 8)
525   MCFG_CBM_IEC_REMOVE()
526   MCFG_CBM_IEC_ADD(c16_iec_1541)
527   MCFG_C1541_ADD("c1541", 8)
531528#ifdef CPU_SYNC
532529   MCFG_QUANTUM_TIME(attotime::from_hz(60))
533530#else
r11256r11257
573570static MACHINE_CONFIG_DERIVED( plus4v, plus4 )
574571
575572   /* floppy from serial bus */
576   MCFG_DEVICE_REMOVE("iec")
577   MCFG_CBM_IEC_ADD("iec", c16_iec_1541)
578   MCFG_C1541_ADD("c1541", "iec", 8)
573   MCFG_CBM_IEC_REMOVE()
574   MCFG_CBM_IEC_ADD(c16_iec_1541)
575   MCFG_C1541_ADD("c1541", 8)
579576
580577   MCFG_SCREEN_MODIFY("screen")
581578   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
src/mess/drivers/primo.c
r11256r11257
288288   /* floppy from serial bus */
289289   /* for some reason machine/primo.c sets up the serial bus
290290    but no floppy drive has been apparently added... incomplete driver? */
291   MCFG_CBM_IEC_ADD("serial_bus", cbm_iec_daisy)
291   MCFG_CBM_IEC_ADD(cbm_iec_daisy)
292292
293293   /* cartridge */
294294   MCFG_CARTSLOT_ADD("cart1")
src/mess/drivers/c64.c
r11256r11257
554554
555555static CBM_IEC_DAISY( cbm_iec_daisy )
556556{
557   { "cia_1" },
558   { C1541_IEC("c1541") },
559   { NULL}
557   { "c1541" },
558   { NULL }
560559};
561560
562561
r11256r11257
717716   MCFG_MOS6526R1_ADD("cia_1", VIC6567_CLOCK, c64_ntsc_cia1)
718717
719718   /* floppy from serial bus */
720   MCFG_CBM_IEC_ADD("iec", cbm_iec_daisy)
721   MCFG_C1541_ADD("c1541", "iec", 8)
719   MCFG_CBM_IEC_ADD(cbm_iec_daisy)
720   MCFG_C1541_ADD("c1541", 8)
722721
723722   MCFG_FRAGMENT_ADD(c64_cartslot)
724723MACHINE_CONFIG_END
r11256r11257
767766   MCFG_MOS6526R1_ADD("cia_1", VIC6569_CLOCK, c64_pal_cia1)
768767
769768   /* floppy from serial bus */
770   MCFG_CBM_IEC_ADD("iec", cbm_iec_daisy)
771   MCFG_C1541_ADD("c1541", "iec", 8)
769   MCFG_CBM_IEC_ADD(cbm_iec_daisy)
770   MCFG_C1541_ADD("c1541", 8)
772771
773772   MCFG_FRAGMENT_ADD(c64_cartslot)
774773MACHINE_CONFIG_END
r11256r11257
785784   MCFG_DEVICE_REMOVE("vic2")
786785   MCFG_VIC2_ADD("vic2", ultimax_vic2_intf)
787786
788   MCFG_DEVICE_REMOVE("iec")
787   MCFG_CBM_IEC_REMOVE()
789788   MCFG_DEVICE_REMOVE("c1541")
790789   MCFG_DEVICE_REMOVE("cart1")
791790   MCFG_DEVICE_REMOVE("cart2")
r11256r11257
802801   MCFG_DEVICE_REMOVE( "dac" )
803802   MCFG_DEVICE_REMOVE( "cassette" )
804803   MCFG_DEVICE_REMOVE( "quickload" )
805   //MCFG_DEVICE_REMOVE("iec")
804   //MCFG_CBM_IEC_REMOVE()
806805   //MCFG_DEVICE_REMOVE("c1541")
807806MACHINE_CONFIG_END
808807
r11256r11257
810809static MACHINE_CONFIG_DERIVED( sx64, c64pal )
811810
812811//   MCFG_DEVICE_REMOVE( "c1541" )
813//   MCFG_SX1541_ADD("c1541", "iec", 8)
812//   MCFG_SX1541_ADD("c1541", 8)
814813
815814   MCFG_DEVICE_REMOVE( "dac" )
816815   MCFG_DEVICE_REMOVE( "cassette" )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team