Previous 15994 Revisions Next

r11263 Thursday 21st April, 2011 at 14:22:03 UTC by Curt Coder
Refactored the IEEE-488 bus into a C++ device. (no whatsnew)
[src/mess]mess.mak
[src/mess/drivers]cbmb.c pet.c tek405x.c vic20.c victor9k.c vixen.c
[src/mess/includes]cbmb.h pet.h tek405x.h victor9k.h vixen.h
[src/mess/machine]c1541.c c1541.h c1571.c c1581.c c2040.c c2040.h cbmb.c ieee488.c ieee488.h ieeestub.c* pet.c vic1112.c vic1112.h

src/mess/machine/c1581.c
r11262r11263
8282
8383void c1581_device_config::device_config_complete()
8484{
85   m_shortname = "c1581";
85   switch (m_variant)
86   {
87   default:
88   case TYPE_1581:
89      m_shortname = "c1581";
90      break;
91
92   case TYPE_1563:
93      m_shortname = "c1563";
94      break;
95   }
8696}
8797
8898
r11262r11263
359369   DEVCB_NULL,
360370   FLOPPY_STANDARD_3_5_DSDD,
361371   FLOPPY_OPTIONS_NAME(c1581),
362   NULL
372   "floppy_3_5"
363373};
364374
365375
src/mess/machine/cbmb.c
r11262r11263
5959 */
6060READ8_DEVICE_HANDLER( cbmb_tpi0_port_a_r )
6161{
62   device_t *ieeebus = device->machine().device("ieee_bus");
62   cbmb_state *state = device->machine().driver_data<cbmb_state>();
6363   UINT8 data = 0;
6464
65   if (ieee488_nrfd_r(ieeebus))
65   if (state->m_ieee->nrfd_r())
6666      data |= 0x80;
6767
68   if (ieee488_ndac_r(ieeebus))
68   if (state->m_ieee->ndac_r())
6969      data |= 0x40;
7070
71   if (ieee488_eoi_r(ieeebus))
71   if (state->m_ieee->eoi_r())
7272      data |= 0x20;
7373
74   if (ieee488_dav_r(ieeebus))
74   if (state->m_ieee->dav_r())
7575      data |= 0x10;
7676
77   if (ieee488_atn_r(ieeebus))
77   if (state->m_ieee->atn_r())
7878      data |= 0x08;
7979
80   if (ieee488_ren_r(ieeebus))
80   if (state->m_ieee->ren_r())
8181        data |= 0x04;
8282
8383   return data;
r11262r11263
8585
8686WRITE8_DEVICE_HANDLER( cbmb_tpi0_port_a_w )
8787{
88   device_t *ieeebus = device->machine().device("ieee_bus");
88   cbmb_state *state = device->machine().driver_data<cbmb_state>();
8989
90   ieee488_nrfd_w(ieeebus, device, BIT(data, 7));
91   ieee488_ndac_w(ieeebus, device, BIT(data, 6));
92   ieee488_eoi_w(ieeebus, device, BIT(data, 5));
93   ieee488_dav_w(ieeebus, device, BIT(data, 4));
94   ieee488_atn_w(ieeebus, device, BIT(data, 3));
95   ieee488_ren_w(ieeebus, device, BIT(data, 2));
90   state->m_ieee->nrfd_w(BIT(data, 7));
91   state->m_ieee->ndac_w(BIT(data, 6));
92   state->m_ieee->eoi_w(BIT(data, 5));
93   state->m_ieee->dav_w(BIT(data, 4));
94   state->m_ieee->atn_w(BIT(data, 3));
95   state->m_ieee->ren_w(BIT(data, 2));
9696}
9797
9898READ8_DEVICE_HANDLER( cbmb_tpi0_port_b_r )
9999{
100   device_t *ieeebus = device->machine().device("ieee_bus");
100   cbmb_state *state = device->machine().driver_data<cbmb_state>();
101101   UINT8 data = 0;
102102
103   if (ieee488_srq_r(ieeebus))
103   if (state->m_ieee->srq_r())
104104      data |= 0x02;
105105
106   if (ieee488_ifc_r(ieeebus))
106   if (state->m_ieee->ifc_r())
107107      data |= 0x01;
108108
109109   return data;
r11262r11263
111111
112112WRITE8_DEVICE_HANDLER( cbmb_tpi0_port_b_w )
113113{
114   device_t *ieeebus = device->machine().device("ieee_bus");
114   cbmb_state *state = device->machine().driver_data<cbmb_state>();
115115
116   ieee488_srq_w(ieeebus, device, BIT(data, 1));
117   ieee488_ifc_w(ieeebus, device, BIT(data, 0));
116   state->m_ieee->srq_w(BIT(data, 1));
117   state->m_ieee->ifc_w(BIT(data, 0));
118118}
119119
120120/* tpi at 0xfdf00
r11262r11263
256256  pb7 .. 4 gameport 2
257257  pb3 .. 0 gameport 1
258258 */
259static READ8_DEVICE_HANDLER( cbmb_cia_port_a_r )
260{
261   device_t *ieeebus = device->machine().device("ieee_bus");
262   return ieee488_dio_r(ieeebus, 0);
263}
264259
265static WRITE8_DEVICE_HANDLER( cbmb_cia_port_a_w )
266{
267   device_t *ieeebus = device->machine().device("ieee_bus");
268   ieee488_dio_w(ieeebus, device, data);
269}
270
271260const mos6526_interface cbmb_cia =
272261{
273262   60,
r11262r11263
275264   DEVCB_NULL,   /* pc_func */
276265   DEVCB_NULL,
277266   DEVCB_NULL,
278   DEVCB_HANDLER(cbmb_cia_port_a_r),
279   DEVCB_HANDLER(cbmb_cia_port_a_w),
267   DEVCB_DEVICE_MEMBER(IEEE488_TAG, ieee488_device, dio_r),
268   DEVCB_DEVICE_MEMBER(IEEE488_TAG, ieee488_device, dio_w),
280269   DEVCB_NULL,
281270   DEVCB_NULL
282271};
src/mess/machine/vic1112.c
r11262r11263
1/*
2
3   TODO:
4
5   - add IEEE488 bus here, not in the driver
6   - SRQ IN -> VIA1 CB1
7
8*/
9
110#include "vic1112.h"
211
312
r11262r11263
103112   UINT8 data = 0;
104113
105114   /* end or identify */
106   data |= ieee488_eoi_r(m_bus) << 3;
115   data |= m_bus->eoi_r() << 3;
107116
108117   /* data valid in */
109   data |= ieee488_dav_r(m_bus) << 4;
118   data |= m_bus->dav_r() << 4;
110119
111120   /* not ready for data in */
112   data |= ieee488_nrfd_r(m_bus) << 5;
121   data |= m_bus->nrfd_r() << 5;
113122
114123   /* not data accepted in */
115   data |= ieee488_ndac_r(m_bus) << 6;
124   data |= m_bus->ndac_r() << 6;
116125
117126   /* attention in */
118   data |= ieee488_atn_r(m_bus) << 7;
127   data |= m_bus->atn_r() << 7;
119128
120129   return data;
121130}
r11262r11263
139148    */
140149
141150   /* data valid out */
142   ieee488_dav_w(m_bus, this, BIT(data, 0));
151   m_bus->dav_w(BIT(data, 0));
143152
144153   /* not ready for data out */
145   ieee488_nrfd_w(m_bus, this, BIT(data, 1));
154   m_bus->nrfd_w(BIT(data, 1));
146155
147156   /* not data accepted out */
148   ieee488_ndac_w(m_bus, this, BIT(data, 2));
157   m_bus->ndac_w(BIT(data, 2));
149158}
150159
151160
r11262r11263
197206
198207    */
199208
200   return ieee488_dio_r(m_bus, 0);
209   return m_bus->dio_r();
201210}
202211
203212
r11262r11263
218227
219228    */
220229
221   ieee488_dio_w(m_bus, this, data);
230   m_bus->dio_w(data);
222231}
223232
224233
225234WRITE_LINE_MEMBER( vic1112_device::atn_w )
226235{
227236   /* attention out */
228   ieee488_atn_w(m_bus, this, state);
237   m_bus->atn_w(state);
229238}
230239
231240
232241READ_LINE_MEMBER( vic1112_device::srq_r )
233242{
234243   /* service request in */
235   return ieee488_srq_r(m_bus);
244   return m_bus->srq_r();
236245}
237246
238247
239248WRITE_LINE_MEMBER( vic1112_device::eoi_w )
240249{
241250   /* end or identify out */
242   ieee488_eoi_w(m_bus, this, state);
251   m_bus->eoi_w(state);
243252}
244253
245254
r11262r11263
297306    : device_t(_machine, _config),
298307     m_via0(*this, M6522_0_TAG),
299308     m_via1(*this, M6522_1_TAG),
300     m_bus(machine().device(_config.m_bus_tag)),
309     m_bus(*this->owner(), IEEE488_TAG),
301310      m_config(_config)
302311{
303312}
r11262r11263
330339
331340void vic1112_device::device_reset()
332341{
333   ieee488_ifc_w(m_bus, this, 0);
334   ieee488_ifc_w(m_bus, this, 1);
342   m_bus->ifc_w(0);
343   m_bus->ifc_w(1);
335344}
336345
337346
src/mess/machine/c2040.c
r11262r11263
1212    TODO:
1313
1414    - 2040 DOS 1 FDC rom (jumps to 104d while getting block header)
15
15   
1616        FE70: jsr  $104D
1717        104D: m6502_brk#$00
1818
1919    - Micropolis 8x50 stepper motor is same as 4040, except it takes 4 pulses to step a track instead of 1
20    - error/activity LEDs
20    - 8250 cannot read d80 images
2121
2222*/
2323
24#include "emu.h"
2524#include "c2040.h"
26#include "cpu/m6502/m6502.h"
27#include "imagedev/flopdrv.h"
28#include "formats/d64_dsk.h"
29#include "formats/g64_dsk.h"
30#include "machine/6522via.h"
31#include "machine/6532riot.h"
32#include "machine/mos6530.h"
33#include "machine/ieee488.h"
3425
35/***************************************************************************
36    PARAMETERS
37***************************************************************************/
3826
27
28//**************************************************************************
29//  MACROS / CONSTANTS
30//**************************************************************************
31
3932#define M6502_TAG      "un1"
4033#define M6532_0_TAG      "uc1"
4134#define M6532_1_TAG      "ue1"
r11262r11263
4437#define M6522_TAG      "um3"
4538#define M6530_TAG      "uk3"
4639
47#define C2040_REGION   "c2040"
48#define C4040_REGION   "c4040"
49#define C8050_REGION   "c8050"
50#define SFD1001_REGION   "sfd1001"
5140
41enum
42{
43   LED_POWER = 0,
44   LED_ACT0,
45   LED_ACT1,
46   LED_ERR
47};
48
49
5250#define SYNC \
53   (!(((c2040->sr & G64_SYNC_MARK) == G64_SYNC_MARK) & c2040->rw))
51   (!(((m_sr & G64_SYNC_MARK) == G64_SYNC_MARK) & m_rw))
5452
5553#define ERROR \
56   (!(c2040->ready | BIT(c2040->e, 3)))
54   (!(m_ready | BIT(m_e, 3)))
5755
58/***************************************************************************
59    TYPE DEFINITIONS
60***************************************************************************/
6156
62typedef struct _c2040_unit_t c2040_unit_t;
63struct _c2040_unit_t
64{
65   /* motors */
66   int stp;                        /* stepper motor phase */
67   int mtr;                        /* spindle motor on */
6857
69   /* track */
70   UINT8 track_buffer[G64_BUFFER_SIZE];   /* track data buffer */
71   int track_len;                     /* track length */
72   int buffer_pos;                     /* byte position within track buffer */
73   int bit_pos;                     /* bit position within track buffer byte */
58//**************************************************************************
59//  DEVICE DEFINITIONS
60//**************************************************************************
7461
75   /* devices */
76   device_t *image;
77};
62const device_type C2040 = c2040_device_config::static_alloc_device_config;
63const device_type C3040 = c2040_device_config::static_alloc_device_config;
64const device_type C4040 = c2040_device_config::static_alloc_device_config;
65const device_type C8050 = c2040_device_config::static_alloc_device_config;
66const device_type C8250 = c2040_device_config::static_alloc_device_config;
67const device_type SFD1001 = c2040_device_config::static_alloc_device_config;
7868
79typedef struct _c2040_t c2040_t;
80struct _c2040_t
81{
82   /* hardware */
83   c2040_unit_t unit[2];            /* drive unit */
84   int drive;                     /* selected drive */
85   int side;                     /* selected side */
8669
87   /* IEEE-488 bus */
88   int address;                  /* device address - 8 */
89   int rfdo;                     /* not ready for data output */
90   int daco;                     /* not data accepted output */
91   int atna;                     /* attention acknowledge */
9270
93   /* track */
94   int ds;                        /* density select */
95   int bit_count;                  /* GCR bit counter */
96   UINT16 sr;                     /* GCR data shift register */
97   UINT8 pi;                     /* parallel data input */
98   UINT8* gcr;                     /* GCR encoder/decoder ROM */
99   UINT16 i;                     /* GCR encoder/decoded ROM address */
100   UINT8 e;                     /* GCR encoder/decoded ROM data */
71//**************************************************************************
72//  DEVICE CONFIGURATION
73//**************************************************************************
10174
102   /* signals */
103   int ready;                     /* byte ready */
104   int mode;                     /* mode select */
105   int rw;                        /* read/write select */
106   int miot_irq;                  /* MIOT interrupt */
75//-------------------------------------------------
76//  c2040_device_config - constructor
77//-------------------------------------------------
10778
108   /* devices */
109   device_t *cpu_dos;
110   device_t *cpu_fdc;
111   device_t *riot0;
112   device_t *riot1;
113   device_t *miot;
114   via6522_device *via;
115   device_t *bus;
79c2040_device_config::c2040_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
80   : device_config(mconfig, static_alloc_device_config, "C2040", tag, owner, clock),
81     device_config_ieee488_interface(mconfig, *this)
82{
83}
11684
117   /* timers */
118   emu_timer *bit_timer;
119};
12085
121/***************************************************************************
122    INLINE FUNCTIONS
123***************************************************************************/
86//-------------------------------------------------
87//  static_alloc_device_config - allocate a new
88//  configuration object
89//-------------------------------------------------
12490
125INLINE c2040_t *get_safe_token(device_t *device)
91device_config *c2040_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
12692{
127   assert(device != NULL);
128   assert((device->type() == C2040) || (device->type() == C3040) || (device->type() == C4040) ||
129      (device->type() == C8050) || (device->type() == C8250) || (device->type() == SFD1001));
130   return (c2040_t *)downcast<legacy_device_base *>(device)->token();
93   return global_alloc(c2040_device_config(mconfig, tag, owner, clock));
13194}
13295
133INLINE c2040_config *get_safe_config(device_t *device)
96
97//-------------------------------------------------
98//  alloc_device - allocate a new device object
99//-------------------------------------------------
100
101device_t *c2040_device_config::alloc_device(running_machine &machine) const
134102{
135   assert(device != NULL);
136   assert((device->type() == C2040) || (device->type() == C3040) || (device->type() == C4040) ||
137      (device->type() == C8050) || (device->type() == C8250) || (device->type() == SFD1001));
138   return (c2040_config *)downcast<const legacy_device_config_base &>(device->baseconfig()).inline_config();
103   return auto_alloc(machine, c2040_device(machine, *this));
139104}
140105
141INLINE void update_ieee_signals(device_t *device)
142{
143   c2040_t *c2040 = get_safe_token(device);
144106
145   int atn = ieee488_atn_r(c2040->bus);
146   int atna = c2040->atna;
147   int rfdo = c2040->rfdo;
148   int daco = c2040->daco;
107//-------------------------------------------------
108//  device_config_complete - perform any
109//  operations now that the configuration is
110//  complete
111//-------------------------------------------------
149112
150   int nrfd = !(!(!(atn&atna)&rfdo)|!(atn|atna));
151   int ndac = !(daco|!(atn|atna));
152
153   ieee488_nrfd_w(c2040->bus, device, nrfd);
154   ieee488_ndac_w(c2040->bus, device, ndac);
155}
156
157INLINE void update_gcr_data(c2040_t *c2040)
113void c2040_device_config::device_config_complete()
158114{
159   if (c2040->rw)
115   switch (m_variant)
160116   {
161      /*
117   default:
118   case TYPE_2040:
119   case TYPE_3040:
120      m_shortname = "c2040";
121      break;
162122
163            bit     description
123   case TYPE_4040:
124      m_shortname = "c4040";
125      break;
164126
165            I0      SR0
166            I1      SR1
167            I2      SR2
168            I3      SR3
169            I4      SR4
170            I5      SR5
171            I6      SR6
172            I7      SR7
173            I8      SR8
174            I9      SR9
175            I10     R/_W SEL
127   case TYPE_8050:
128      m_shortname = "c8050";
129      break;
176130
177        */
131   case TYPE_8250:
132      m_shortname = "c8250";
133      break;
178134
179      c2040->i = (c2040->rw << 10) | (c2040->sr & 0x3ff);
135   case TYPE_SFD1001:
136      m_shortname = "sfd1001";
137      break;
180138   }
181   else
182   {
183      /*
184
185            bit     description
186
187            I0      PI0
188            I1      PI1
189            I2      PI2
190            I3      PI3
191            I4      MODE SEL
192            I5      PI4
193            I6      PI5
194            I7      PI6
195            I8      PI7
196            I9      0
197            I10     R/_W SEL
198
199        */
200
201      c2040->i = (c2040->rw << 10) | ((c2040->pi & 0xf0) << 1) | (c2040->mode << 4) | (c2040->pi & 0x0f);
202   }
203
204   c2040->e = c2040->gcr[c2040->i];
205139}
206140
207/***************************************************************************
208    IMPLEMENTATION
209***************************************************************************/
210141
211/*-------------------------------------------------
212    TIMER_CALLBACK( bit_tick )
213-------------------------------------------------*/
142//-------------------------------------------------
143//  static_set_config - configuration helper
144//-------------------------------------------------
214145
215static TIMER_CALLBACK( bit_tick )
146void c2040_device_config::static_set_config(device_config *device, int address, int variant)
216147{
217   device_t *device = (device_t *)ptr;
218   c2040_t *c2040 = get_safe_token(device);
219   int ready = 1;
148   c2040_device_config *c2040 = downcast<c2040_device_config *>(device);
220149
221   /* shift in data from the read head */
222   c2040->sr <<= 1;
223   c2040->sr |= BIT(c2040->unit[c2040->drive].track_buffer[c2040->unit[c2040->drive].buffer_pos], c2040->unit[c2040->drive].bit_pos);
150   assert((address > 7) && (address < 12));
224151
225   /* update GCR data */
226   update_gcr_data(c2040);
152   c2040->m_address = address - 8;
153   c2040->m_variant = variant;
154}
227155
228   /* update bit counters */
229   c2040->unit[c2040->drive].bit_pos--;
230   c2040->bit_count++;
231156
232   if (c2040->unit[c2040->drive].bit_pos < 0)
233   {
234      c2040->unit[c2040->drive].bit_pos = 7;
235      c2040->unit[c2040->drive].buffer_pos++;
157//-------------------------------------------------
158//  ROM( c2040 )
159//-------------------------------------------------
236160
237      if (c2040->unit[c2040->drive].buffer_pos >= c2040->unit[c2040->drive].track_len)
238      {
239         /* loop to the start of the track */
240         c2040->unit[c2040->drive].buffer_pos = 0;
241      }
242   }
161ROM_START( c2040 ) // schematic 320806
162   ROM_REGION( 0x3000, M6502_TAG, 0 )
163   // DOS 1.0
164   ROM_LOAD( "901468-06.ul1", 0x1000, 0x1000, CRC(25b5eed5) SHA1(4d9658f2e6ff3276e5c6e224611a66ce44b16fc7) )
165   ROM_LOAD( "901468-07.uh1", 0x2000, 0x1000, CRC(9b09ae83) SHA1(6a51c7954938439ca8342fc295bda050c06e1791) )
243166
244   if (!SYNC)
245   {
246      /* SYNC detected */
247      c2040->bit_count = 0;
248   }
167   ROM_REGION( 0x400, M6504_TAG, 0 )
168   // RIOT DOS 1
169   ROM_LOAD( "901466-02.uk3", 0x000, 0x400, BAD_DUMP /* parsed in from disassembly */ CRC(e1c86c43) SHA1(d8209c66fde3f2937688ba934ba968678a9d2ebb) )
249170
250   if (c2040->bit_count == 10)
251   {
252      /* byte ready */
253      c2040->bit_count = 0;
254      ready = 0;
255   }
171   ROM_REGION( 0x800, "gcr", 0)
172   ROM_LOAD( "901467.uk6",    0x2400, 0x0800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
173ROM_END
256174
257   if (c2040->ready != ready)
258   {
259      /* set byte ready flag */
260      c2040->ready = ready;
261175
262      c2040->via->write_ca1(ready);
263      c2040->via->write_cb1(ERROR);
176//-------------------------------------------------
177//  ROM( c4040 )
178//-------------------------------------------------
264179
265      if ((device->type() == C8050) || (device->type() == C8250) || (device->type() == SFD1001))
266      {
267         device_set_input_line(c2040->cpu_fdc, M6502_SET_OVERFLOW, ready ? CLEAR_LINE : ASSERT_LINE);
268      }
269   }
270}
180ROM_START( c4040 ) // schematic ?
181   ROM_REGION( 0x3000, M6502_TAG, 0 )
182   // DOS 2.1
183   ROM_LOAD_OPTIONAL( "901468-11.uj1", 0x0000, 0x1000, CRC(b7157458) SHA1(8415f3159dea73161e0cef7960afa6c76953b6f8) )
184   ROM_LOAD_OPTIONAL( "901468-12.ul1", 0x1000, 0x1000, CRC(02c44ff9) SHA1(e8a94f239082d45f64f01b2d8e488d18fe659cbb) )
185   ROM_LOAD_OPTIONAL( "901468-13.uh1", 0x2000, 0x1000, CRC(cbd785b3) SHA1(6ada7904ac9d13c3f1c0a8715f9c4be1aa6eb0bb) )
186   // DOS 2 rev
187   ROM_LOAD( "901468-14.uj1", 0x0000, 0x1000, CRC(bc4d4872) SHA1(ffb992b82ec913ddff7be964d7527aca3e21580c) )
188   ROM_LOAD( "901468-15.ul1", 0x1000, 0x1000, CRC(b6970533) SHA1(f702d6917fe8a798740ba4d467b500944ae7b70a) )
189   ROM_LOAD( "901468-16.uh1", 0x2000, 0x1000, CRC(1f5eefb7) SHA1(04b918cf4adeee8015b43383d3cea7288a7d0aa8) )
271190
272/*-------------------------------------------------
273    read_current_track - read track from disk
274-------------------------------------------------*/
191   ROM_REGION( 0x400, M6504_TAG, 0 )
192   // RIOT DOS 2
193   ROM_LOAD( "901466-04.uk3", 0x000, 0x400, CRC(0ab338dc) SHA1(6645fa40b81be1ff7d1384e9b52df06a26ab0bfb) )
275194
276static void read_current_track(c2040_t *c2040, int unit)
277{
278   c2040->unit[unit].track_len = G64_BUFFER_SIZE;
279   c2040->unit[unit].buffer_pos = 0;
280   c2040->unit[unit].bit_pos = 7;
281   c2040->bit_count = 0;
195   ROM_REGION( 0x800, "gcr", 0)
196   ROM_LOAD( "901467.uk6",    0x000, 0x800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
197ROM_END
282198
283   /* read track data */
284   floppy_drive_read_track_data_info_buffer(c2040->unit[unit].image, c2040->side, c2040->unit[unit].track_buffer, &c2040->unit[unit].track_len);
285199
286   /* extract track length */
287   c2040->unit[unit].track_len = floppy_drive_get_current_track_size(c2040->unit[unit].image, c2040->side);
288}
200//-------------------------------------------------
201//  ROM( c8050 )
202//-------------------------------------------------
289203
290/*-------------------------------------------------
291    on_disk_0_change - disk 0 change handler
292-------------------------------------------------*/
204/*
293205
294static void on_disk_0_change(device_image_interface &image)
295{
296   c2040_t *c2040 = get_safe_token(image.device().owner());
206    DOS/CONTROLLER ROMS FOR DIGITAL PCB #8050002
297207
298   read_current_track(c2040, 0);
299}
208    DESCRIPTION     PCB PART NO.        UL1         UH1         UK3
300209
301/*-------------------------------------------------
302    on_disk_1_change - disk 1 change handler
303-------------------------------------------------*/
210    2.5 Micropolis  8050002-01      901482-07   901482-06   901483-03
211    2.5 Tandon      8050002-02      901482-07   901482-06   901483-04
212    2.7 Tandon      8050002-03      901887-01   901888-01   901884-01
213    2.7 Micropolis  8050002-04      901887-01   901888-01   901885-04
214    2.7 MPI 8050    8050002-05      901887-01   901888-01   901869-01
215    2.7 MPI 8250    8050002-06      901887-01   901888-01   901869-01
304216
305static void on_disk_1_change(device_image_interface &image)
306{
307   c2040_t *c2040 = get_safe_token(image.device().owner());
217*/
308218
309   read_current_track(c2040, 1);
310}
219ROM_START( c8050 ) // schematic 8050001
220   ROM_REGION( 0x4000, M6502_TAG, 0 )
221   // 2364 ROM DOS 2.5
222   ROM_LOAD_OPTIONAL( "901482-03.ul1", 0x0000, 0x2000, CRC(09a609b9) SHA1(166d8bfaaa9c4767f9b17ad63fc7ae77c199a64e) )
223   ROM_LOAD_OPTIONAL( "901482-04.uh1", 0x2000, 0x2000, CRC(1bcf9df9) SHA1(217f4a8b348658bb365f4a1de21ecbaa6402b1c0) )
224   // 2364-091 ROM DOS 2.5 rev
225   ROM_LOAD_OPTIONAL( "901482-06.ul1", 0x0000, 0x2000, CRC(3cbd2756) SHA1(7f5fbed0cddb95138dd99b8fe84fddab900e3650) )
226   ROM_LOAD_OPTIONAL( "901482-07.uh1", 0x2000, 0x2000, CRC(c7532d90) SHA1(0b6d1e55afea612516df5f07f4a6dccd3bd73963) )
227   // 2364 ROM DOS 2.7
228   ROM_LOAD( "901887-01.ul1", 0x0000, 0x2000, CRC(0073b8b2) SHA1(b10603195f240118fe5fb6c6dfe5c5097463d890) )
229   ROM_LOAD( "901888-01.uh1", 0x2000, 0x2000, CRC(de9b6132) SHA1(2e6c2d7ca934e5c550ad14bd5e9e7749686b7af4) )
311230
312/*-------------------------------------------------
313    spindle_motor - spindle motor control
314-------------------------------------------------*/
231   ROM_REGION( 0x400, M6504_TAG, 0 )
232   ROM_LOAD_OPTIONAL( "901483-03.uk3", 0x000, 0x400, CRC(9e83fa70) SHA1(e367ea8a5ddbd47f13570088427293138a10784b) )
233   ROM_LOAD_OPTIONAL( "901483-04.uk3", 0x000, 0x400, NO_DUMP )
234   ROM_LOAD_OPTIONAL( "901884-01.uk3", 0x000, 0x400, NO_DUMP )
235   ROM_LOAD_OPTIONAL( "901885-04.uk3", 0x000, 0x400, CRC(bab998c9) SHA1(0dc9a3b60f1b866c63eebd882403532fc59fe57f) )
236   ROM_LOAD( "901869-01.uk3", 0x000, 0x400, CRC(2915327a) SHA1(3a9a80f72ce76e5f5c72513f8ef7553212912ae3) )
315237
316static void spindle_motor(c2040_t *c2040, int unit, int mtr)
317{
318   if (c2040->unit[unit].mtr != mtr)
319   {
320      if (!mtr)
321      {
322         /* read track data */
323         read_current_track(c2040, unit);
324      }
238   ROM_REGION( 0x800, "gcr", 0)
239   ROM_LOAD( "901467.uk6",    0x000, 0x800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
240ROM_END
325241
326      floppy_mon_w(c2040->unit[unit].image, mtr);
327242
328      c2040->unit[unit].mtr = mtr;
329   }
330}
243//-------------------------------------------------
244//  ROM( sfd1001 )
245//-------------------------------------------------
331246
332/*-------------------------------------------------
333    micropolis_step_motor - Micropolis stepper
334    motor control
335-------------------------------------------------*/
247ROM_START( sfd1001 ) // schematic 251406
248   ROM_REGION( 0x4000, M6502_TAG, 0 )
249   ROM_LOAD( "901887-01.1j",  0x0000, 0x2000, CRC(0073b8b2) SHA1(b10603195f240118fe5fb6c6dfe5c5097463d890) )
250   ROM_LOAD( "901888-01.3j",  0x2000, 0x2000, CRC(de9b6132) SHA1(2e6c2d7ca934e5c550ad14bd5e9e7749686b7af4) )
336251
337static void micropolis_step_motor(c2040_t *c2040, int unit, int mtr, int stp)
338{
339   if (!mtr && (c2040->unit[unit].stp != stp))
340   {
341      int tracks = 0;
252   ROM_REGION( 0x800, M6504_TAG, 0 )
253   ROM_LOAD( "251257-02a.u2", 0x000, 0x800, CRC(b51150de) SHA1(3b954eb34f7ea088eed1d33ebc6d6e83a3e9be15) )
342254
343      switch (c2040->unit[unit].stp)
344      {
345      case 0:   if (stp == 1) tracks++; else if (stp == 3) tracks--; break;
346      case 1:   if (stp == 2) tracks++; else if (stp == 0) tracks--; break;
347      case 2: if (stp == 3) tracks++; else if (stp == 1) tracks--; break;
348      case 3: if (stp == 0) tracks++; else if (stp == 2) tracks--; break;
349      }
255   ROM_REGION( 0x800, "gcr", 0)
256   ROM_LOAD( "901467.5c",     0x000, 0x800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
257ROM_END
350258
351      if (tracks != 0)
352      {
353         /* step read/write head */
354         floppy_drive_seek(c2040->unit[unit].image, tracks);
355259
356         /* read new track data */
357         read_current_track(c2040, unit);
358      }
260//-------------------------------------------------
261//  rom_region - device-specific ROM region
262//-------------------------------------------------
359263
360      c2040->unit[unit].stp = stp;
361   }
362}
363
364/*-------------------------------------------------
365    mpi_step_motor - MPI stepper motor control
366-------------------------------------------------*/
367
368static void mpi_step_motor(c2040_t *c2040, int unit, int mtr, int stp)
264const rom_entry *c2040_device_config::device_rom_region() const
369265{
370   if (!mtr && (c2040->unit[unit].stp != stp))
266   switch (m_variant)
371267   {
372      int tracks = 0;
268   default:
269   case TYPE_2040:
270   case TYPE_3040:
271      return ROM_NAME( c2040 );
373272
374      switch (c2040->unit[unit].stp)
375      {
376      case 0:   if (stp == 1) tracks++; else if (stp == 2) tracks--; break;
377      case 1:   if (stp == 3) tracks++; else if (stp == 0) tracks--; break;
378      case 2: if (stp == 0) tracks++; else if (stp == 3) tracks--; break;
379      case 3: if (stp == 2) tracks++; else if (stp == 1) tracks--; break;
380      }
273   case TYPE_4040:
274      return ROM_NAME( c4040 );
381275
382      if (tracks != 0)
383      {
384         /* step read/write head */
385         floppy_drive_seek(c2040->unit[unit].image, tracks);
276   case TYPE_8050:
277   case TYPE_8250:
278      return ROM_NAME( c8050 );
386279
387         /* read new track data */
388         read_current_track(c2040, unit);
389      }
390
391      c2040->unit[unit].stp = stp;
280   case TYPE_SFD1001:
281      return ROM_NAME( sfd1001 );
392282   }
393283}
394284
395/*-------------------------------------------------
396    c2040_ieee488_atn_w - IEEE-488 bus attention
397-------------------------------------------------*/
398285
399WRITE_LINE_DEVICE_HANDLER( c2040_ieee488_atn_w )
400{
401   c2040_t *c2040 = get_safe_token(device);
286//-------------------------------------------------
287//  ADDRESS_MAP( c2040_main_mem )
288//-------------------------------------------------
402289
403   update_ieee_signals(device);
404
405   /* set RIOT PA7 */
406   riot6532_porta_in_set(c2040->riot1, !state << 7, 0x80);
407}
408
409/*-------------------------------------------------
410    c2040_ieee488_ifc_w - IEEE-488 bus reset
411-------------------------------------------------*/
412
413WRITE_LINE_DEVICE_HANDLER( c2040_ieee488_ifc_w )
414{
415   if (!state)
416   {
417      device->reset();
418   }
419}
420
421/*-------------------------------------------------
422    ADDRESS_MAP( c2040_dos_map )
423-------------------------------------------------*/
424
425static ADDRESS_MAP_START( c2040_dos_map, AS_PROGRAM, 8 )
290static ADDRESS_MAP_START( c2040_main_mem, AS_PROGRAM, 8, c2040_device )
426291   ADDRESS_MAP_GLOBAL_MASK(0x7fff)
427292   AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0100) AM_RAM // 6532 #1
428293   AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0100) AM_RAM // 6532 #2
429   AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w)
430   AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w)
294   AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE_LEGACY(M6532_0_TAG, riot6532_r, riot6532_w)
295   AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE_LEGACY(M6532_1_TAG, riot6532_r, riot6532_w)
431296   AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share1")
432297   AM_RANGE(0x2000, 0x23ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share2")
433298   AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share3")
434299   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share4")
435   AM_RANGE(0x6000, 0x7fff) AM_MIRROR(0x0000) AM_ROM AM_REGION("drive:c2040", 0x0000)
300   AM_RANGE(0x5000, 0x7fff) // AM_ROM
436301ADDRESS_MAP_END
437302
438/*-------------------------------------------------
439    ADDRESS_MAP( c2040_fdc_map )
440-------------------------------------------------*/
441303
442static ADDRESS_MAP_START( c2040_fdc_map, AS_PROGRAM, 8 )
443   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
444   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
445   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE_MODERN(M6522_TAG, via6522_device, read, write)
446   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w)
447   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
448   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
449   AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3")
450   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_SHARE("share4")
451   AM_RANGE(0x1c00, 0x1fff) AM_ROM AM_REGION("drive:c2040", 0x2000) // 6530
452ADDRESS_MAP_END
304//-------------------------------------------------
305//  ADDRESS_MAP( c2040_fdc_mem )
306//-------------------------------------------------
453307
454/*-------------------------------------------------
455    ADDRESS_MAP( c4040_dos_map )
456-------------------------------------------------*/
457
458static ADDRESS_MAP_START( c4040_dos_map, AS_PROGRAM, 8 )
459   ADDRESS_MAP_GLOBAL_MASK(0x7fff)
460   AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0100) AM_RAM // 6532 #1
461   AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0100) AM_RAM // 6532 #2
462   AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w)
463   AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w)
464   AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share1")
465   AM_RANGE(0x2000, 0x23ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share2")
466   AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share3")
467   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share4")
468   AM_RANGE(0x5000, 0x7fff) AM_ROM AM_REGION("drive:c4040", 0x0000)
469ADDRESS_MAP_END
470
471/*-------------------------------------------------
472    ADDRESS_MAP( c4040_fdc_map )
473-------------------------------------------------*/
474
475static ADDRESS_MAP_START( c4040_fdc_map, AS_PROGRAM, 8 )
308static ADDRESS_MAP_START( c2040_fdc_mem, AS_PROGRAM, 8, c2040_device )
476309   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
477310   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
478   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE_MODERN(M6522_TAG, via6522_device, read, write)
479   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w)
311   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via6522_device, read, write)
312   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE_LEGACY(M6530_TAG, mos6530_r, mos6530_w)
480313   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
481314   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
482315   AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3")
483316   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_SHARE("share4")
484   AM_RANGE(0x1c00, 0x1fff) AM_ROM AM_REGION("drive:c4040", 0x3000) // 6530
317   AM_RANGE(0x1c00, 0x1fff) // AM_ROM 6530
485318ADDRESS_MAP_END
486319
487/*-------------------------------------------------
488    ADDRESS_MAP( c8050_dos_map )
489-------------------------------------------------*/
490320
491static ADDRESS_MAP_START( c8050_dos_map, AS_PROGRAM, 8 )
321//-------------------------------------------------
322//  ADDRESS_MAP( c8050_main_mem )
323//-------------------------------------------------
324
325static ADDRESS_MAP_START( c8050_main_mem, AS_PROGRAM, 8, c2040_device )
492326   AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0100) AM_RAM // 6532 #1
493327   AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0100) AM_RAM // 6532 #2
494   AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w)
495   AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w)
328   AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE_LEGACY(M6532_0_TAG, riot6532_r, riot6532_w)
329   AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE_LEGACY(M6532_1_TAG, riot6532_r, riot6532_w)
496330   AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share1")
497331   AM_RANGE(0x2000, 0x23ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share2")
498332   AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share3")
499333   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share4")
500   AM_RANGE(0xc000, 0xffff) AM_ROM AM_REGION("drive:c8050", 0x0000)
334   AM_RANGE(0xc000, 0xffff) // AM_ROM
501335ADDRESS_MAP_END
502336
503/*-------------------------------------------------
504    ADDRESS_MAP( c8050_fdc_map )
505-------------------------------------------------*/
506337
507static ADDRESS_MAP_START( c8050_fdc_map, AS_PROGRAM, 8 )
338//-------------------------------------------------
339//  ADDRESS_MAP( c8050_fdc_mem )
340//-------------------------------------------------
341
342static ADDRESS_MAP_START( c8050_fdc_mem, AS_PROGRAM, 8, c2040_device )
508343   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
509344   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
510   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE_MODERN(M6522_TAG, via6522_device, read, write)
511   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w)
345   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via6522_device, read, write)
346   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE_LEGACY(M6530_TAG, mos6530_r, mos6530_w)
512347   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
513348   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
514349   AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3")
515350   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_SHARE("share4")
516   AM_RANGE(0x1c00, 0x1fff) AM_ROM AM_REGION("drive:c8050", 0x4000) // 6530
351   AM_RANGE(0x1c00, 0x1fff) // AM_ROM 6530
517352ADDRESS_MAP_END
518353
519/*-------------------------------------------------
520    ADDRESS_MAP( sfd1001_dos_map )
521-------------------------------------------------*/
522354
523static ADDRESS_MAP_START( sfd1001_dos_map, AS_PROGRAM, 8 )
524   AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0100) AM_RAM // 6532 #1
525   AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0100) AM_RAM // 6532 #2
526   AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w)
527   AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w)
528   AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share1")
529   AM_RANGE(0x2000, 0x23ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share2")
530   AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share3")
531   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share4")
532   AM_RANGE(0xc000, 0xffff) AM_ROM AM_REGION("drive:sfd1001", 0x0000)
533ADDRESS_MAP_END
355//-------------------------------------------------
356//  ADDRESS_MAP( sfd1001_fdc_mem )
357//-------------------------------------------------
534358
535/*-------------------------------------------------
536    ADDRESS_MAP( sfd1001_fdc_map )
537-------------------------------------------------*/
538
539static ADDRESS_MAP_START( sfd1001_fdc_map, AS_PROGRAM, 8 )
359static ADDRESS_MAP_START( sfd1001_fdc_mem, AS_PROGRAM, 8, c2040_device )
540360   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
541361   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
542   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE_MODERN(M6522_TAG, via6522_device, read, write)
543   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w)
362   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via6522_device, read, write)
363   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE_LEGACY(M6530_TAG, mos6530_r, mos6530_w)
544364   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
545365   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
546366   AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3")
547367   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_SHARE("share4")
548   AM_RANGE(0x1800, 0x1fff) AM_ROM AM_REGION("drive:sfd1001", 0x4000)
368   AM_RANGE(0x1800, 0x1fff) // AM_ROM
549369ADDRESS_MAP_END
550370
551/*-------------------------------------------------
552    riot6532_interface riot0_intf uc1
553-------------------------------------------------*/
554371
555static READ8_DEVICE_HANDLER( dio_r )
372//-------------------------------------------------
373//  riot6532_interface riot0_intf uc1
374//-------------------------------------------------
375
376READ8_MEMBER( c2040_device::dio_r )
556377{
557378   /*
558379
r11262r11263
569390
570391    */
571392
572   c2040_t *c2040 = get_safe_token(device->owner());
573
574   return ieee488_dio_r(c2040->bus, 0);
393   return m_bus->dio_r();
575394}
576395
577static WRITE8_DEVICE_HANDLER( dio_w )
396
397WRITE8_MEMBER( c2040_device::dio_w )
578398{
579399   /*
580400
r11262r11263
591411
592412    */
593413
594   c2040_t *c2040 = get_safe_token(device->owner());
595
596   ieee488_dio_w(c2040->bus, device->owner(), data);
414   m_bus->dio_w(this, data);
597415}
598416
417
599418static const riot6532_interface riot0_intf =
600419{
601   DEVCB_HANDLER(dio_r),
420   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, dio_r),
602421   DEVCB_NULL,
603422   DEVCB_NULL,
604   DEVCB_HANDLER(dio_w),
423   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, dio_w),
605424   DEVCB_NULL
606425};
607426
608/*-------------------------------------------------
609    riot6532_interface riot1_intf ue1
610-------------------------------------------------*/
611427
612static READ8_DEVICE_HANDLER( riot1_pa_r )
428//-------------------------------------------------
429//  riot6532_interface riot1_intf ue1
430//-------------------------------------------------
431
432READ8_MEMBER( c2040_device::riot1_pa_r )
613433{
614434   /*
615435
r11262r11263
626446
627447    */
628448
629   c2040_t *c2040 = get_safe_token(device->owner());
630
631449   UINT8 data = 0;
632450
633   /* end or identify in */
634   data |= ieee488_eoi_r(c2040->bus) << 5;
451   // end or identify in
452   data |= m_bus->eoi_r() << 5;
635453
636   /* data valid in */
637   data |= ieee488_dav_r(c2040->bus) << 6;
454   // data valid in
455   data |= m_bus->dav_r() << 6;
638456
639   /* attention */
640   data |= !ieee488_atn_r(c2040->bus) << 7;
457   // attention
458   data |= !m_bus->atn_r() << 7;
641459
642460   return data;
643461}
644462
645static WRITE8_DEVICE_HANDLER( riot1_pa_w )
463
464WRITE8_MEMBER( c2040_device::riot1_pa_w )
646465{
647466   /*
648467
r11262r11263
659478
660479    */
661480
662   c2040_t *c2040 = get_safe_token(device->owner());
481   // attention acknowledge
482   m_atna = BIT(data, 0);
663483
664   /* attention acknowledge */
665   c2040->atna = BIT(data, 0);
484   // data accepted out
485   m_daco = BIT(data, 1);
666486
667   /* data accepted out */
668   c2040->daco = BIT(data, 1);
487   // not ready for data out
488   m_rfdo = BIT(data, 2);
669489
670   /* not ready for data out */
671   c2040->rfdo = BIT(data, 2);
490   // end or identify out
491   m_bus->eoi_w(this, BIT(data, 3));
672492
673   /* end or identify out */
674   ieee488_eoi_w(c2040->bus, device->owner(), BIT(data, 3));
493   // data valid out
494   m_bus->dav_w(this, BIT(data, 4));
675495
676   /* data valid out */
677   ieee488_dav_w(c2040->bus, device->owner(), BIT(data, 4));
678
679   update_ieee_signals(device->owner());
496   update_ieee_signals();
680497}
681498
682static READ8_DEVICE_HANDLER( riot1_pb_r )
499
500READ8_MEMBER( c2040_device::riot1_pb_r )
683501{
684502   /*
685503
r11262r11263
696514
697515    */
698516
699   c2040_t *c2040 = get_safe_token(device->owner());
700
701517   UINT8 data = 0;
702518
703   /* device number selection */
704   data |= c2040->address;
519   // device number selection
520   data |= m_config.m_address;
705521
706   /* data accepted in */
707   data |= ieee488_ndac_r(c2040->bus) << 6;
522   // data accepted in
523   data |= m_bus->ndac_r() << 6;
708524
709   /* ready for data in */
710   data |= ieee488_nrfd_r(c2040->bus) << 7;
525   // ready for data in
526   data |= m_bus->nrfd_r() << 7;
711527
712528   return data;
713529}
714530
715static WRITE8_DEVICE_HANDLER( riot1_pb_w )
531
532WRITE8_MEMBER( c2040_device::riot1_pb_w )
716533{
717534   /*
718535
r11262r11263
729546
730547    */
731548
732   /* TODO activity led 1 */
549   // activity led 1
550   output_set_led_value(LED_ACT1, BIT(data, 3));
733551
734   /* TODO activity led 0 */
552   // activity led 0
553   output_set_led_value(LED_ACT0, BIT(data, 4));
735554
736   /* TODO error led */
555   // error led
556   output_set_led_value(LED_ERR, BIT(data, 5));
737557}
738558
739static WRITE_LINE_DEVICE_HANDLER( riot1_irq_w )
740{
741   c2040_t *c2040 = get_safe_token(device->owner());
742559
743   device_set_input_line(c2040->cpu_dos, M6502_IRQ_LINE, state);
744}
745
746560static const riot6532_interface riot1_intf =
747561{
748   DEVCB_HANDLER(riot1_pa_r),
749   DEVCB_HANDLER(riot1_pb_r),
750   DEVCB_HANDLER(riot1_pa_w),
751   DEVCB_HANDLER(riot1_pb_w),
752   DEVCB_LINE(riot1_irq_w)
562   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, riot1_pa_r),
563   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, riot1_pb_r),
564   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, riot1_pa_w),
565   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, riot1_pb_w),
566   DEVCB_CPU_INPUT_LINE(M6502_TAG, INPUT_LINE_IRQ0)
753567};
754568
755/*-------------------------------------------------
756    via6522_interface via_intf um3
757-------------------------------------------------*/
758569
759static READ8_DEVICE_HANDLER( via_pa_r )
570//-------------------------------------------------
571//  via6522_interface via_intf um3
572//-------------------------------------------------
573
574READ8_MEMBER( c2040_device::via_pa_r )
760575{
761576   /*
762577
r11262r11263
773588
774589    */
775590
776   c2040_t *c2040 = get_safe_token(device->owner());
777
778   UINT16 i = c2040->i;
779   UINT8 e = c2040->e;
591   UINT16 i = m_i;
592   UINT8 e = m_e;
780593   UINT8 data = (BIT(e, 6) << 7) | (BIT(i, 7) << 6) | (e & 0x33) | (BIT(e, 2) << 3) | (i & 0x04);
781594
782595   return data;
783596}
784597
785static WRITE8_DEVICE_HANDLER( via_pb_w )
598
599WRITE8_MEMBER( c2040_device::via_pb_w )
786600{
787601   /*
788602
r11262r11263
799613
800614    */
801615
802   c2040_t *c2040 = get_safe_token(device->owner());
803
804   /* spindle motor 1 */
616   // spindle motor 1
805617   int mtr1 = BIT(data, 4);
806   spindle_motor(c2040, 1, mtr1);
618   spindle_motor(1, mtr1);
807619
808   /* spindle motor 0 */
620   // spindle motor 0
809621   int mtr0 = BIT(data, 5);
810   spindle_motor(c2040, 0, mtr0);
622   spindle_motor(0, mtr0);
811623
812   /* stepper motor 1 */
624   // stepper motor 1
813625   int s1 = data & 0x03;
814   micropolis_step_motor(c2040, 1, mtr1, s1);
626   micropolis_step_motor(1, s1);
815627
816   /* stepper motor 0 */
628   // stepper motor 0
817629   int s0 = (data >> 2) & 0x03;
818   micropolis_step_motor(c2040, 0, mtr0, s0);
630   micropolis_step_motor(0, s0);
819631
820   c2040->bit_timer->enable(!mtr1 | !mtr0);
632   m_bit_timer->enable(!mtr1 | !mtr0);
821633}
822634
823static READ_LINE_DEVICE_HANDLER( ready_r )
824{
825   c2040_t *c2040 = get_safe_token(device->owner());
826635
827   return c2040->ready;
636READ_LINE_MEMBER( c2040_device::ready_r )
637{
638   return m_ready;
828639}
829640
830static READ_LINE_DEVICE_HANDLER( err_r )
831{
832   c2040_t *c2040 = get_safe_token(device->owner());
833641
642READ_LINE_MEMBER( c2040_device::err_r )
643{
834644   return ERROR;
835645}
836646
837static WRITE_LINE_DEVICE_HANDLER( mode_sel_w )
647
648WRITE_LINE_MEMBER( c2040_device::mode_sel_w )
838649{
839   c2040_t *c2040 = get_safe_token(device->owner());
650   // mode select
651   m_mode = state;
840652
841   /* mode select */
842   c2040->mode = state;
843
844   update_gcr_data(c2040);
845   c2040->via->write_cb1(ERROR);
653   update_gcr_data();
654   m_via->write_cb1(ERROR);
846655}
847656
848static WRITE_LINE_DEVICE_HANDLER( rw_sel_w )
657WRITE_LINE_MEMBER( c2040_device::rw_sel_w )
849658{
850   c2040_t *c2040 = get_safe_token(device->owner());
659   // read/write select
660   m_rw = state;
851661
852   /* read/write select */
853   c2040->rw = state;
854
855   update_gcr_data(c2040);
856   c2040->via->write_cb1(ERROR);
662   update_gcr_data();
663   m_via->write_cb1(ERROR);
857664}
858665
666
859667static const via6522_interface via_intf =
860668{
861   DEVCB_HANDLER(via_pa_r),
669   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, via_pa_r),
862670   DEVCB_NULL,
863   DEVCB_LINE(ready_r),
864   DEVCB_LINE(err_r),
671   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2040_device, ready_r),
672   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2040_device, err_r),
865673   DEVCB_NULL,
866674   DEVCB_NULL,
867675
868676   DEVCB_NULL,
869   DEVCB_HANDLER(via_pb_w),
677   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, via_pb_w),
870678   DEVCB_NULL,
871679   DEVCB_NULL,
872   DEVCB_LINE(mode_sel_w),
873   DEVCB_LINE(rw_sel_w),
680   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2040_device, mode_sel_w),
681   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2040_device, rw_sel_w),
874682
875683   DEVCB_NULL
876684};
877685
878/*-------------------------------------------------
879    via6522_interface c8050_via_intf um3
880-------------------------------------------------*/
881686
882static READ8_DEVICE_HANDLER( c8050_via_pb_r )
687//-------------------------------------------------
688//  via6522_interface c8050_via_intf um3
689//-------------------------------------------------
690
691READ8_MEMBER( c2040_device::c8050_via_pb_r )
883692{
884693   /*
885694
r11262r11263
896705
897706    */
898707
899   c2040_t *c2040 = get_safe_token(device->owner());
900
901708   UINT8 data = 0;
902709
903   /* SYNC detected */
710   // SYNC detected
904711   data |= SYNC << 7;
905712
906713   return data;
907714}
908715
909static WRITE8_DEVICE_HANDLER( c8050_via_pb_w )
716
717WRITE8_MEMBER( c2040_device::c8050_via_pb_w )
910718{
911719   /*
912720
r11262r11263
923731
924732    */
925733
926   c2040_t *c2040 = get_safe_token(device->owner());
927
928   /* spindle motor 1 */
734   // spindle motor 1
929735   int mtr1 = BIT(data, 4);
930   spindle_motor(c2040, 1, mtr1);
736   spindle_motor(1, mtr1);
931737
932   /* spindle motor 0 */
738   // spindle motor 0
933739   int mtr0 = BIT(data, 5);
934   spindle_motor(c2040, 0, mtr0);
740   spindle_motor(0, mtr0);
935741
936   /* stepper motor 1 */
742   // stepper motor 1
937743   int s1 = data & 0x03;
938   mpi_step_motor(c2040, 1, mtr1, s1);
744   mpi_step_motor(1, s1);
939745
940   /* stepper motor 0 */
746   // stepper motor 0
941747   int s0 = (data >> 2) & 0x03;
942   mpi_step_motor(c2040, 0, mtr0, s0);
748   mpi_step_motor(0, s0);
943749
944   c2040->bit_timer->enable(!mtr1 | !mtr0);
750   m_bit_timer->enable(!mtr1 | !mtr0);
945751}
946752
753
947754static const via6522_interface c8050_via_intf =
948755{
949   DEVCB_HANDLER(via_pa_r),
950   DEVCB_HANDLER(c8050_via_pb_r),
951   DEVCB_LINE(ready_r),
952   DEVCB_LINE(err_r),
756   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, via_pa_r),
757   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, c8050_via_pb_r),
758   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2040_device, ready_r),
759   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2040_device, err_r),
953760   DEVCB_NULL,
954761   DEVCB_NULL,
955762
956763   DEVCB_NULL,
957   DEVCB_HANDLER(c8050_via_pb_w),
764   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, c8050_via_pb_w),
958765   DEVCB_NULL,
959766   DEVCB_NULL,
960   DEVCB_LINE(mode_sel_w),
961   DEVCB_LINE(rw_sel_w),
767   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2040_device, mode_sel_w),
768   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2040_device, rw_sel_w),
962769
963770   DEVCB_NULL
964771};
965772
966/*-------------------------------------------------
967    mos6530_interface miot_intf uk3
968-------------------------------------------------*/
969773
970static READ8_DEVICE_HANDLER( pi_r )
774//-------------------------------------------------
775//  mos6530_interface miot_intf uk3
776//-------------------------------------------------
777
778READ8_MEMBER( c2040_device::pi_r )
971779{
972780   /*
973781
r11262r11263
984792
985793    */
986794
987   c2040_t *c2040 = get_safe_token(device->owner());
988
989   return c2040->pi;
795   return m_pi;
990796}
991797
992static WRITE8_DEVICE_HANDLER( pi_w )
798WRITE8_MEMBER( c2040_device::pi_w )
993799{
994800   /*
995801
r11262r11263
1006812
1007813    */
1008814
1009   c2040_t *c2040 = get_safe_token(device->owner());
1010
1011   c2040->pi = data;
815   m_pi = data;
1012816}
1013817
1014static READ8_DEVICE_HANDLER( miot_pb_r )
818READ8_MEMBER( c2040_device::miot_pb_r )
1015819{
1016820   /*
1017821
r11262r11263
1028832
1029833    */
1030834
1031   c2040_t *c2040 = get_safe_token(device->owner());
1032
1033835   UINT8 data = 0;
1034836
1035   /* write protect sense */
1036   data |= floppy_wpt_r(c2040->unit[c2040->drive].image) << 3;
837   // write protect sense
838   data |= floppy_wpt_r(m_unit[m_drive].m_image) << 3;
1037839
1038   /* SYNC detected */
840   // SYNC detected
1039841   data |= SYNC << 6;
1040842
1041843   return data;
1042844}
1043845
1044static WRITE8_DEVICE_HANDLER( miot_pb_w )
846WRITE8_MEMBER( c2040_device::miot_pb_w )
1045847{
1046848   /*
1047849
r11262r11263
1058860
1059861    */
1060862
1061   c2040_t *c2040 = get_safe_token(device->owner());
863   // drive select
864   m_drive = BIT(data, 0);
1062865
1063   /* drive select */
1064   c2040->drive = BIT(data, 0);
1065
1066   /* density select */
866   // density select
1067867   int ds = (data >> 1) & 0x03;
1068868
1069   if (c2040->ds != ds)
869   if (m_ds != ds)
1070870   {
1071      c2040->bit_timer->adjust(attotime::zero, 0, attotime::from_hz(C2040_BITRATE[ds]/4));
1072      c2040->ds = ds;
871      m_bit_timer->adjust(attotime::zero, 0, attotime::from_hz(C2040_BITRATE[ds]/4));
872      m_ds = ds;
1073873   }
1074874
1075   /* interrupt */
1076   if (c2040->miot_irq != BIT(data, 7))
875   // interrupt
876   if (m_miot_irq != BIT(data, 7))
1077877   {
1078      device_set_input_line(c2040->cpu_fdc, M6502_IRQ_LINE, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE);
1079      c2040->miot_irq = BIT(data, 7);
878      m_fdccpu->set_input_line(M6502_IRQ_LINE, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE);
879      m_miot_irq = BIT(data, 7);
1080880   }
1081881}
1082882
1083883static MOS6530_INTERFACE( miot_intf )
1084884{
1085   DEVCB_HANDLER(pi_r),
1086   DEVCB_HANDLER(pi_w),
1087   DEVCB_HANDLER(miot_pb_r),
1088   DEVCB_HANDLER(miot_pb_w)
885   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, pi_r),
886   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, pi_w),
887   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, miot_pb_r),
888   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, miot_pb_w)
1089889};
1090890
1091/*-------------------------------------------------
1092    mos6530_interface c8050_miot_intf uk3
1093-------------------------------------------------*/
1094891
1095static READ8_DEVICE_HANDLER( c8050_miot_pb_r )
892//-------------------------------------------------
893//  mos6530_interface c8050_miot_intf uk3
894//-------------------------------------------------
895
896READ8_MEMBER( c2040_device::c8050_miot_pb_r )
1096897{
1097898   /*
1098899
r11262r11263
1109910
1110911    */
1111912
1112   c2040_t *c2040 = get_safe_token(device->owner());
1113
1114913   UINT8 data = 0;
1115914
1116   /* write protect sense */
1117   data |= floppy_wpt_r(c2040->unit[c2040->drive].image) << 3;
915   // write protect sense
916   data |= floppy_wpt_r(m_unit[m_drive].m_image) << 3;
1118917
1119   /* drive type */
918   // drive type
1120919   data |= 0x10;
1121920
1122   /* single/dual sided */
1123   if (device->owner()->type() == C8050)
921   // single/dual sided
922   if (m_config.m_variant == c2040_device_config::TYPE_8050)
1124923   {
1125924      data |= 0x40;
1126925   }
r11262r11263
1128927   return data;
1129928}
1130929
1131static WRITE8_DEVICE_HANDLER( c8050_miot_pb_w )
930WRITE8_MEMBER( c2040_device::c8050_miot_pb_w )
1132931{
1133932   /*
1134933
r11262r11263
1145944
1146945    */
1147946
1148   c2040_t *c2040 = get_safe_token(device->owner());
1149
1150   /* drive select */
1151   if ((device->owner()->type() == C8050) || (device->owner()->type() == C8250))
947   // drive select
948   if ((m_config.m_variant == c2040_device_config::TYPE_8050) ||
949      (m_config.m_variant == c2040_device_config::TYPE_8250))
1152950   {
1153      c2040->drive = BIT(data, 0);
951      m_drive = BIT(data, 0);
1154952   }
1155953
1156   /* density select */
954   // density select
1157955   int ds = (data >> 1) & 0x03;
1158956
1159   if (c2040->ds != ds)
957   if (m_ds != ds)
1160958   {
1161      c2040->bit_timer->adjust(attotime::zero, 0, attotime::from_hz(C8050_BITRATE[ds]));
1162      c2040->ds = ds;
959      m_bit_timer->adjust(attotime::zero, 0, attotime::from_hz(C8050_BITRATE[ds]));
960      m_ds = ds;
1163961   }
1164962
1165   /* side select */
1166   if ((device->owner()->type() == C8250) || (device->owner()->type() == SFD1001))
963   // side select
964   if ((m_config.m_variant == c2040_device_config::TYPE_8250) ||
965      (m_config.m_variant == c2040_device_config::TYPE_SFD1001))
1167966   {
1168      c2040->side = !BIT(data, 4);
967      m_side = !BIT(data, 4);
1169968   }
1170969
1171   /* interrupt */
1172   if (c2040->miot_irq != BIT(data, 7))
970   // interrupt
971   if (m_miot_irq != BIT(data, 7))
1173972   {
1174      device_set_input_line(c2040->cpu_fdc, M6502_IRQ_LINE, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE);
1175      c2040->miot_irq = BIT(data, 7);
973      m_fdccpu->set_input_line(M6502_IRQ_LINE, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE);
974      m_miot_irq = BIT(data, 7);
1176975   }
1177976}
1178977
1179978static MOS6530_INTERFACE( c8050_miot_intf )
1180979{
1181   DEVCB_HANDLER(pi_r),
1182   DEVCB_HANDLER(pi_w),
1183   DEVCB_HANDLER(c8050_miot_pb_r),
1184   DEVCB_HANDLER(c8050_miot_pb_w)
980   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, pi_r),
981   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, pi_w),
982   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, c8050_miot_pb_r),
983   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2040_device, c8050_miot_pb_w)
1185984};
1186985
1187/*-------------------------------------------------
1188    FLOPPY_OPTIONS( c2040 )
1189-------------------------------------------------*/
1190986
987//-------------------------------------------------
988//  FLOPPY_OPTIONS( c2040 )
989//-------------------------------------------------
990
1191991static FLOPPY_OPTIONS_START( c2040 )
1192992   FLOPPY_OPTION( c2040, "d67", "Commodore 2040/3040 Disk Image", d67_dsk_identify, d64_dsk_construct, NULL )
1193993   FLOPPY_OPTION( c2040, "g64", "Commodore 2040/3040 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL )
1194994FLOPPY_OPTIONS_END
1195995
1196/*-------------------------------------------------
1197    FLOPPY_OPTIONS( c4040 )
1198-------------------------------------------------*/
1199996
997//-------------------------------------------------
998//  FLOPPY_OPTIONS( c4040 )
999//-------------------------------------------------
1000
12001001static FLOPPY_OPTIONS_START( c4040 )
12011002   FLOPPY_OPTION( c4040, "d64", "Commodore 4040 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL )
12021003   FLOPPY_OPTION( c4040, "g64", "Commodore 4040 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL )
12031004FLOPPY_OPTIONS_END
12041005
1205/*-------------------------------------------------
1206    FLOPPY_OPTIONS( c8050 )
1207-------------------------------------------------*/
12081006
1007//-------------------------------------------------
1008//  FLOPPY_OPTIONS( c8050 )
1009//-------------------------------------------------
1010
12091011static FLOPPY_OPTIONS_START( c8050 )
12101012   FLOPPY_OPTION( c8050, "d80", "Commodore 8050 Disk Image", d80_dsk_identify, d64_dsk_construct, NULL )
12111013FLOPPY_OPTIONS_END
12121014
1213/*-------------------------------------------------
1214    FLOPPY_OPTIONS( c8050 )
1215-------------------------------------------------*/
12161015
1016//-------------------------------------------------
1017//  FLOPPY_OPTIONS( c8250 )
1018//-------------------------------------------------
1019
12171020static FLOPPY_OPTIONS_START( c8250 )
12181021   FLOPPY_OPTION( c8250, "d80", "Commodore 8050 Disk Image", d80_dsk_identify, d64_dsk_construct, NULL )
12191022   FLOPPY_OPTION( c8250, "d82", "Commodore 8250/SFD1001 Disk Image", d82_dsk_identify, d64_dsk_construct, NULL )
12201023FLOPPY_OPTIONS_END
12211024
1222/*-------------------------------------------------
1223    floppy_config c2040_floppy_config
1224-------------------------------------------------*/
12251025
1026//-------------------------------------------------
1027//  floppy_config c2040_floppy_config
1028//-------------------------------------------------
1029
12261030static const floppy_config c2040_floppy_config =
12271031{
12281032   DEVCB_NULL,
r11262r11263
12321036   DEVCB_NULL,
12331037   FLOPPY_STANDARD_5_25_SSDD,
12341038   FLOPPY_OPTIONS_NAME(c2040),
1235   NULL
1039   "floppy_5_25"
12361040};
12371041
1238/*-------------------------------------------------
1239    floppy_config c4040_floppy_config
1240-------------------------------------------------*/
12411042
1043//-------------------------------------------------
1044//  floppy_config c4040_floppy_config
1045//-------------------------------------------------
1046
12421047static const floppy_config c4040_floppy_config =
12431048{
12441049   DEVCB_NULL,
r11262r11263
12481053   DEVCB_NULL,
12491054   FLOPPY_STANDARD_5_25_SSDD,
12501055   FLOPPY_OPTIONS_NAME(c4040),
1251   NULL
1056   "floppy_5_25"
12521057};
12531058
1254/*-------------------------------------------------
1255    floppy_config c8050_floppy_config
1256-------------------------------------------------*/
12571059
1060//-------------------------------------------------
1061//  floppy_config c8050_floppy_config
1062//-------------------------------------------------
1063
12581064static const floppy_config c8050_floppy_config =
12591065{
12601066   DEVCB_NULL,
r11262r11263
12641070   DEVCB_NULL,
12651071   FLOPPY_STANDARD_5_25_SSDD,
12661072   FLOPPY_OPTIONS_NAME(c8050),
1267   NULL
1073   "floppy_5_25"
12681074};
12691075
1270/*-------------------------------------------------
1271    floppy_config c8250_floppy_config
1272-------------------------------------------------*/
12731076
1077//-------------------------------------------------
1078//  floppy_config c8250_floppy_config
1079//-------------------------------------------------
1080
12741081static const floppy_config c8250_floppy_config =
12751082{
12761083   DEVCB_NULL,
r11262r11263
12781085   DEVCB_NULL,
12791086   DEVCB_NULL,
12801087   DEVCB_NULL,
1281   FLOPPY_STANDARD_5_25_DSHD,
1088   FLOPPY_STANDARD_5_25_DSQD,
12821089   FLOPPY_OPTIONS_NAME(c8250),
1283   NULL
1090   "floppy_5_25"
12841091};
12851092
1286/*-------------------------------------------------
1287    MACHINE_DRIVER( c2040 )
1288-------------------------------------------------*/
12891093
1094//-------------------------------------------------
1095//  MACHINE_CONFIG_FRAGMENT( c2040 )
1096//-------------------------------------------------
1097
12901098static MACHINE_CONFIG_FRAGMENT( c2040 )
1291   /* DOS */
1099   // DOS
12921100   MCFG_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
1293   MCFG_CPU_PROGRAM_MAP(c2040_dos_map)
1101   MCFG_CPU_PROGRAM_MAP(c2040_main_mem)
12941102
12951103   MCFG_RIOT6532_ADD(M6532_0_TAG, XTAL_16MHz/16, riot0_intf)
12961104   MCFG_RIOT6532_ADD(M6532_1_TAG, XTAL_16MHz/16, riot1_intf)
12971105
1298   /* controller */
1106   // controller
12991107   MCFG_CPU_ADD(M6504_TAG, M6504, XTAL_16MHz/16)
1300   MCFG_CPU_PROGRAM_MAP(c2040_fdc_map)
1108   MCFG_CPU_PROGRAM_MAP(c2040_fdc_mem)
13011109
13021110   MCFG_VIA6522_ADD(M6522_TAG, XTAL_16MHz/16, via_intf)
13031111   MCFG_MOS6530_ADD(M6530_TAG, XTAL_16MHz/16, miot_intf)
r11262r11263
13051113   MCFG_FLOPPY_2_DRIVES_ADD(c2040_floppy_config)
13061114MACHINE_CONFIG_END
13071115
1308/*-------------------------------------------------
1309    MACHINE_DRIVER( c4040 )
1310-------------------------------------------------*/
13111116
1117//-------------------------------------------------
1118//  MACHINE_CONFIG_FRAGMENT( c4040 )
1119//-------------------------------------------------
1120
13121121static MACHINE_CONFIG_FRAGMENT( c4040 )
1313   /* DOS */
1122   // DOS
13141123   MCFG_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
1315   MCFG_CPU_PROGRAM_MAP(c4040_dos_map)
1124   MCFG_CPU_PROGRAM_MAP(c2040_main_mem)
13161125
13171126   MCFG_RIOT6532_ADD(M6532_0_TAG, XTAL_16MHz/16, riot0_intf)
13181127   MCFG_RIOT6532_ADD(M6532_1_TAG, XTAL_16MHz/16, riot1_intf)
13191128
1320   /* controller */
1129   // controller
13211130   MCFG_CPU_ADD(M6504_TAG, M6504, XTAL_16MHz/16)
1322   MCFG_CPU_PROGRAM_MAP(c4040_fdc_map)
1131   MCFG_CPU_PROGRAM_MAP(c2040_fdc_mem)
13231132
13241133   MCFG_VIA6522_ADD(M6522_TAG, XTAL_16MHz/16, via_intf)
13251134   MCFG_MOS6530_ADD(M6530_TAG, XTAL_16MHz/16, miot_intf)
r11262r11263
13271136   MCFG_FLOPPY_2_DRIVES_ADD(c4040_floppy_config)
13281137MACHINE_CONFIG_END
13291138
1330/*-------------------------------------------------
1331    MACHINE_DRIVER( c8050 )
1332-------------------------------------------------*/
13331139
1140//-------------------------------------------------
1141//  MACHINE_CONFIG_FRAGMENT( c8050 )
1142//-------------------------------------------------
1143
13341144static MACHINE_CONFIG_FRAGMENT( c8050 )
1335   /* DOS */
1145   // DOS
13361146   MCFG_CPU_ADD(M6502_TAG, M6502, XTAL_12MHz/12)
1337   MCFG_CPU_PROGRAM_MAP(c8050_dos_map)
1147   MCFG_CPU_PROGRAM_MAP(c8050_main_mem)
13381148
13391149   MCFG_RIOT6532_ADD(M6532_0_TAG, XTAL_12MHz/12, riot0_intf)
13401150   MCFG_RIOT6532_ADD(M6532_1_TAG, XTAL_12MHz/12, riot1_intf)
13411151
1342   /* controller */
1152   // controller
13431153   MCFG_CPU_ADD(M6504_TAG, M6504, XTAL_12MHz/12)
1344   MCFG_CPU_PROGRAM_MAP(c8050_fdc_map)
1154   MCFG_CPU_PROGRAM_MAP(c8050_fdc_mem)
13451155
13461156   MCFG_VIA6522_ADD(M6522_TAG, XTAL_12MHz/12, c8050_via_intf)
13471157   MCFG_MOS6530_ADD(M6530_TAG, XTAL_12MHz/12, c8050_miot_intf)
r11262r11263
13491159   MCFG_FLOPPY_2_DRIVES_ADD(c8050_floppy_config)
13501160MACHINE_CONFIG_END
13511161
1352/*-------------------------------------------------
1353    MACHINE_DRIVER( c8250 )
1354-------------------------------------------------*/
13551162
1163//-------------------------------------------------
1164//  MACHINE_CONFIG_FRAGMENT( c8250 )
1165//-------------------------------------------------
1166
13561167static MACHINE_CONFIG_FRAGMENT( c8250 )
1357   /* DOS */
1168   // DOS
13581169   MCFG_CPU_ADD(M6502_TAG, M6502, XTAL_12MHz/12)
1359   MCFG_CPU_PROGRAM_MAP(c8050_dos_map)
1170   MCFG_CPU_PROGRAM_MAP(c8050_main_mem)
13601171
13611172   MCFG_RIOT6532_ADD(M6532_0_TAG, XTAL_12MHz/12, riot0_intf)
13621173   MCFG_RIOT6532_ADD(M6532_1_TAG, XTAL_12MHz/12, riot1_intf)
13631174
1364   /* controller */
1175   // controller
13651176   MCFG_CPU_ADD(M6504_TAG, M6504, XTAL_12MHz/12)
1366   MCFG_CPU_PROGRAM_MAP(c8050_fdc_map)
1177   MCFG_CPU_PROGRAM_MAP(c8050_fdc_mem)
13671178
13681179   MCFG_VIA6522_ADD(M6522_TAG, XTAL_12MHz/12, c8050_via_intf)
13691180   MCFG_MOS6530_ADD(M6530_TAG, XTAL_12MHz/12, c8050_miot_intf)
r11262r11263
13711182   MCFG_FLOPPY_2_DRIVES_ADD(c8250_floppy_config)
13721183MACHINE_CONFIG_END
13731184
1374/*-------------------------------------------------
1375    MACHINE_DRIVER( sfd1001 )
1376-------------------------------------------------*/
13771185
1186//-------------------------------------------------
1187//  MACHINE_CONFIG_FRAGMENT( sfd1001 )
1188//-------------------------------------------------
1189
13781190static MACHINE_CONFIG_FRAGMENT( sfd1001 )
1379   /* DOS */
1191   // DOS
13801192   MCFG_CPU_ADD(M6502_TAG, M6502, XTAL_12MHz/12)
1381   MCFG_CPU_PROGRAM_MAP(sfd1001_dos_map)
1193   MCFG_CPU_PROGRAM_MAP(c8050_main_mem)
13821194
13831195   MCFG_RIOT6532_ADD(M6532_0_TAG, XTAL_12MHz/12, riot0_intf)
13841196   MCFG_RIOT6532_ADD(M6532_1_TAG, XTAL_12MHz/12, riot1_intf)
13851197
1386   /* controller */
1198   // controller
13871199   MCFG_CPU_ADD(M6504_TAG, M6504, XTAL_12MHz/12)
1388   MCFG_CPU_PROGRAM_MAP(sfd1001_fdc_map)
1200   MCFG_CPU_PROGRAM_MAP(sfd1001_fdc_mem)
13891201
13901202   MCFG_VIA6522_ADD(M6522_TAG, XTAL_12MHz/12, c8050_via_intf)
13911203   MCFG_MOS6530_ADD(M6530_TAG, XTAL_12MHz/12, c8050_miot_intf)
r11262r11263
13931205   MCFG_FLOPPY_DRIVE_ADD(FLOPPY_0, c8250_floppy_config)
13941206MACHINE_CONFIG_END
13951207
1396/*-------------------------------------------------
1397    ROM( c2040 )
1398-------------------------------------------------*/
13991208
1400ROM_START( c2040 ) // schematic 320806
1401   ROM_REGION( 0x2c00, C2040_REGION, ROMREGION_LOADBYNAME )
1402   /* DOS 1.0 */
1403   ROM_LOAD( "901468-06.ul1", 0x0000, 0x1000, CRC(25b5eed5) SHA1(4d9658f2e6ff3276e5c6e224611a66ce44b16fc7) )
1404   ROM_LOAD( "901468-07.uh1", 0x1000, 0x1000, CRC(9b09ae83) SHA1(6a51c7954938439ca8342fc295bda050c06e1791) )
1209//-------------------------------------------------
1210//  machine_config_additions - device-specific
1211//  machine configurations
1212//-------------------------------------------------
14051213
1406   /* RIOT DOS 1 */
1407   ROM_LOAD( "901466-02.uk3", 0x2000, 0x0400, BAD_DUMP /* parsed in from disassembly */ CRC(e1c86c43) SHA1(d8209c66fde3f2937688ba934ba968678a9d2ebb) )
1214machine_config_constructor c2040_device_config::device_mconfig_additions() const
1215{
1216   switch (m_variant)
1217   {
1218   default:
1219   case TYPE_2040:
1220   case TYPE_3040:
1221      return MACHINE_CONFIG_NAME( c2040 );
14081222
1409   /* ROM GCR */
1410   ROM_LOAD( "901467.uk6",    0x2400, 0x0800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
1411ROM_END
1223   case TYPE_4040:
1224      return MACHINE_CONFIG_NAME( c4040 );
14121225
1413/*-------------------------------------------------
1414    ROM( c4040 )
1415-------------------------------------------------*/
1226   case TYPE_8050:
1227      return MACHINE_CONFIG_NAME( c8050 );
14161228
1417ROM_START( c4040 ) // schematic ?
1418   ROM_REGION( 0x3c00, C4040_REGION, ROMREGION_LOADBYNAME )
1419   /* DOS 2.1 */
1420   ROM_LOAD_OPTIONAL( "901468-11.uj1", 0x0000, 0x1000, CRC(b7157458) SHA1(8415f3159dea73161e0cef7960afa6c76953b6f8) )
1421   ROM_LOAD_OPTIONAL( "901468-12.ul1", 0x1000, 0x1000, CRC(02c44ff9) SHA1(e8a94f239082d45f64f01b2d8e488d18fe659cbb) )
1422   ROM_LOAD_OPTIONAL( "901468-13.uh1", 0x2000, 0x1000, CRC(cbd785b3) SHA1(6ada7904ac9d13c3f1c0a8715f9c4be1aa6eb0bb) )
1423   /* DOS 2 rev */
1424   ROM_LOAD( "901468-14.uj1", 0x0000, 0x1000, CRC(bc4d4872) SHA1(ffb992b82ec913ddff7be964d7527aca3e21580c) )
1425   ROM_LOAD( "901468-15.ul1", 0x1000, 0x1000, CRC(b6970533) SHA1(f702d6917fe8a798740ba4d467b500944ae7b70a) )
1426   ROM_LOAD( "901468-16.uh1", 0x2000, 0x1000, CRC(1f5eefb7) SHA1(04b918cf4adeee8015b43383d3cea7288a7d0aa8) )
1229   case TYPE_8250:
1230      return MACHINE_CONFIG_NAME( c8250 );
14271231
1428   /* RIOT DOS 2 */
1429   ROM_LOAD( "901466-04.uk3", 0x3000, 0x0400, CRC(0ab338dc) SHA1(6645fa40b81be1ff7d1384e9b52df06a26ab0bfb) )
1232   case TYPE_SFD1001:
1233      return MACHINE_CONFIG_NAME( sfd1001 );
1234   }
1235}
14301236
1431   /* ROM GCR */
1432   ROM_LOAD( "901467.uk6",    0x3400, 0x0800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
1433ROM_END
14341237
1435/*-------------------------------------------------
1436    ROM( c8050 )
1437-------------------------------------------------*/
14381238
1439/*
1239//**************************************************************************
1240//  INLINE HELPERS
1241//**************************************************************************
14401242
1441    DOS/CONTROLLER ROMS FOR DIGITAL PCB #8050002
1243//-------------------------------------------------
1244//  update_ieee_signals -
1245//-------------------------------------------------
14421246
1443    DESCRIPTION     PCB PART NO.        UL1         UH1         UK3
1247inline void c2040_device::update_ieee_signals()
1248{
1249   int atn = m_bus->atn_r();
1250   int nrfd = !(!(!(atn & m_atna) & m_rfdo) | !(atn | m_atna));
1251   int ndac = !(m_daco | !(atn | m_atna));
14441252
1445    2.5 Micropolis  8050002-01      901482-07   901482-06   901483-03
1446    2.5 Tandon      8050002-02      901482-07   901482-06   901483-04
1447    2.7 Tandon      8050002-03      901887-01   901888-01   901884-01
1448    2.7 Micropolis  8050002-04      901887-01   901888-01   901885-04
1449    2.7 MPI 8050    8050002-05      901887-01   901888-01   901869-01
1450    2.7 MPI 8250    8050002-06      901887-01   901888-01   901869-01
1253   m_bus->nrfd_w(this, nrfd);
1254   m_bus->ndac_w(this, ndac);
1255}
14511256
1452*/
14531257
1454ROM_START( c8050 ) // schematic 8050001
1455   ROM_REGION( 0x4c00, C8050_REGION, ROMREGION_LOADBYNAME )
1456   /* 2364 ROM DOS 2.5 */
1457   ROM_LOAD_OPTIONAL( "901482-03.ul1", 0x0000, 0x2000, CRC(09a609b9) SHA1(166d8bfaaa9c4767f9b17ad63fc7ae77c199a64e) )
1458   ROM_LOAD_OPTIONAL( "901482-04.uh1", 0x2000, 0x2000, CRC(1bcf9df9) SHA1(217f4a8b348658bb365f4a1de21ecbaa6402b1c0) )
1459   /* 2364-091 ROM DOS 2.5 rev */
1460   ROM_LOAD_OPTIONAL( "901482-06.ul1", 0x0000, 0x2000, CRC(3cbd2756) SHA1(7f5fbed0cddb95138dd99b8fe84fddab900e3650) )
1461   ROM_LOAD_OPTIONAL( "901482-07.uh1", 0x2000, 0x2000, CRC(c7532d90) SHA1(0b6d1e55afea612516df5f07f4a6dccd3bd73963) )
1462   /* 2364 ROM DOS 2.7 */
1463   ROM_LOAD( "901887-01.ul1", 0x0000, 0x2000, CRC(0073b8b2) SHA1(b10603195f240118fe5fb6c6dfe5c5097463d890) )
1464   ROM_LOAD( "901888-01.uh1", 0x2000, 0x2000, CRC(de9b6132) SHA1(2e6c2d7ca934e5c550ad14bd5e9e7749686b7af4) )
1258//-------------------------------------------------
1259//  update_gcr_data -
1260//-------------------------------------------------
14651261
1466   /* controller */
1467   ROM_LOAD_OPTIONAL( "901483-03.uk3", 0x4000, 0x0400, CRC(9e83fa70) SHA1(e367ea8a5ddbd47f13570088427293138a10784b) )
1468   ROM_LOAD_OPTIONAL( "901483-04.uk3", 0x4000, 0x0400, NO_DUMP )
1469   ROM_LOAD_OPTIONAL( "901884-01.uk3", 0x4000, 0x0400, NO_DUMP )
1470   ROM_LOAD_OPTIONAL( "901885-04.uk3", 0x4000, 0x0400, CRC(bab998c9) SHA1(0dc9a3b60f1b866c63eebd882403532fc59fe57f) )
1471   ROM_LOAD( "901869-01.uk3", 0x4000, 0x0400, CRC(2915327a) SHA1(3a9a80f72ce76e5f5c72513f8ef7553212912ae3) )
1262inline void c2040_device::update_gcr_data()
1263{
1264   if (m_rw)
1265   {
1266      /*
14721267
1473   /* GCR decoder */
1474   ROM_LOAD( "901467.uk6",    0x4400, 0x0800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
1475ROM_END
1268            bit     description
14761269
1477/*-------------------------------------------------
1478    ROM( sfd1001 )
1479-------------------------------------------------*/
1270            I0      SR0
1271            I1      SR1
1272            I2      SR2
1273            I3      SR3
1274            I4      SR4
1275            I5      SR5
1276            I6      SR6
1277            I7      SR7
1278            I8      SR8
1279            I9      SR9
1280            I10     R/_W SEL
14801281
1481ROM_START( sfd1001 ) // schematic 251406
1482   ROM_REGION( 0x5000, SFD1001_REGION, ROMREGION_LOADBYNAME )
1483   ROM_LOAD( "901887-01.1j",  0x0000, 0x2000, CRC(0073b8b2) SHA1(b10603195f240118fe5fb6c6dfe5c5097463d890) )
1484   ROM_LOAD( "901888-01.3j",  0x2000, 0x2000, CRC(de9b6132) SHA1(2e6c2d7ca934e5c550ad14bd5e9e7749686b7af4) )
1282        */
14851283
1486   /* controller */
1487   ROM_LOAD( "251257-02a.u2", 0x4000, 0x0800, CRC(b51150de) SHA1(3b954eb34f7ea088eed1d33ebc6d6e83a3e9be15) )
1284      m_i = (m_rw << 10) | (m_sr & 0x3ff);
1285   }
1286   else
1287   {
1288      /*
14881289
1489   /* GCR decoder */
1490   ROM_LOAD( "901467.5c",     0x4800, 0x0800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
1491ROM_END
1290            bit     description
14921291
1493/*-------------------------------------------------
1494    DEVICE_START( c2040 )
1495-------------------------------------------------*/
1292            I0      PI0
1293            I1      PI1
1294            I2      PI2
1295            I3      PI3
1296            I4      MODE SEL
1297            I5      PI4
1298            I6      PI5
1299            I7      PI6
1300            I8      PI7
1301            I9      0
1302            I10     R/_W SEL
14961303
1497static DEVICE_START( c2040 )
1498{
1499   c2040_t *c2040 = get_safe_token(device);
1500   const c2040_config *config = get_safe_config(device);
1304        */
15011305
1502   /* set serial address */
1503   assert((config->address > 7) && (config->address < 16));
1504   c2040->address = config->address - 8;
1306      m_i = (m_rw << 10) | ((m_pi & 0xf0) << 1) | (m_mode << 4) | (m_pi & 0x0f);
1307   }
15051308
1506   /* find our CPU */
1507   c2040->cpu_dos = device->subdevice(M6502_TAG);
1508   c2040->cpu_fdc = device->subdevice(M6504_TAG);
1309   m_e = m_gcr[m_i];
1310}
15091311
1510   /* find devices */
1511   c2040->riot0 = device->subdevice(M6532_0_TAG);
1512   c2040->riot1 = device->subdevice(M6532_1_TAG);
1513   c2040->miot = device->subdevice(M6530_TAG);
1514   c2040->via = device->subdevice<via6522_device>(M6522_TAG);
1515   c2040->bus = device->machine().device(config->bus_tag);
1516   c2040->unit[0].image = device->subdevice(FLOPPY_0);
1517   c2040->unit[1].image = device->subdevice(FLOPPY_1);
15181312
1519   /* install image callbacks */
1520   floppy_install_unload_proc(c2040->unit[0].image, on_disk_0_change);
1521   floppy_install_load_proc(c2040->unit[0].image, on_disk_0_change);
1522   floppy_install_unload_proc(c2040->unit[1].image, on_disk_1_change);
1523   floppy_install_load_proc(c2040->unit[1].image, on_disk_1_change);
1313//-------------------------------------------------
1314//  update_ieee_signals -
1315//-------------------------------------------------
15241316
1525   /* find GCR ROM */
1526   const memory_region *region = device->subregion(C4040_REGION);
1317inline void c2040_device::read_current_track(int unit)
1318{
1319   m_unit[unit].m_track_len = G64_BUFFER_SIZE;
1320   m_unit[unit].m_buffer_pos = 0;
1321   m_unit[unit].m_bit_pos = 7;
1322   m_bit_count = 0;
15271323
1528   if ((device->type() == C2040) || (device->type() == C3040))
1324   // read track data
1325   floppy_drive_read_track_data_info_buffer(m_unit[unit].m_image, m_side, m_unit[unit].m_track_buffer, &m_unit[unit].m_track_len);
1326
1327   // extract track length
1328   m_unit[unit].m_track_len = floppy_drive_get_current_track_size(m_unit[unit].m_image, m_side);
1329}
1330
1331
1332//-------------------------------------------------
1333//  spindle_motor -
1334//-------------------------------------------------
1335
1336inline void c2040_device::spindle_motor(int unit, int mtr)
1337{
1338   if (m_unit[unit].m_mtr != mtr)
15291339   {
1530      region = device->subregion(C2040_REGION);
1340      if (!mtr)
1341      {
1342         // read track data
1343         read_current_track(unit);
1344      }
1345
1346      floppy_mon_w(m_unit[unit].m_image, mtr);
1347
1348      m_unit[unit].m_mtr = mtr;
15311349   }
1532   else if (device->type() == C4040)
1350}
1351
1352
1353//-------------------------------------------------
1354//  micropolis_step_motor -
1355//-------------------------------------------------
1356
1357inline void c2040_device::micropolis_step_motor(int unit, int stp)
1358{
1359   if (!m_unit[unit].m_mtr && (m_unit[unit].m_stp != stp))
15331360   {
1534      region = device->subregion(C4040_REGION);
1535   }
1536   else if ((device->type() == C8050) || (device->type() == C8250))
1537   {
1538      region = device->subregion(C8050_REGION);
1539   }
1540   else if (device->type() == SFD1001)
1541   {
1542      region = device->subregion(SFD1001_REGION);
1543   }
1361      int tracks = 0;
15441362
1545   c2040->gcr = region->base() + region->bytes() - 0x800;
1363      switch (m_unit[unit].m_stp)
1364      {
1365      case 0:   if (stp == 1) tracks++; else if (stp == 3) tracks--; break;
1366      case 1:   if (stp == 2) tracks++; else if (stp == 0) tracks--; break;
1367      case 2: if (stp == 3) tracks++; else if (stp == 1) tracks--; break;
1368      case 3: if (stp == 0) tracks++; else if (stp == 2) tracks--; break;
1369      }
15461370
1547   /* allocate data timer */
1548   c2040->bit_timer = device->machine().scheduler().timer_alloc(FUNC(bit_tick), (void *)device);
1371      if (tracks != 0)
1372      {
1373         // step read/write head
1374         floppy_drive_seek(m_unit[unit].m_image, tracks);
15491375
1550   /* register for state saving */
1551   device->save_item(NAME(c2040->drive));
1552   device->save_item(NAME(c2040->side));
1553   device->save_item(NAME(c2040->address));
1554   device->save_item(NAME(c2040->rfdo));
1555   device->save_item(NAME(c2040->daco));
1556   device->save_item(NAME(c2040->atna));
1557   device->save_item(NAME(c2040->ds));
1558   device->save_item(NAME(c2040->bit_count));
1559   device->save_item(NAME(c2040->sr));
1560   device->save_item(NAME(c2040->pi));
1561   device->save_item(NAME(c2040->i));
1562   device->save_item(NAME(c2040->e));
1563   device->save_item(NAME(c2040->ready));
1564   device->save_item(NAME(c2040->mode));
1565   device->save_item(NAME(c2040->rw));
1566   device->save_item(NAME(c2040->miot_irq));
1567   device->save_item(NAME(c2040->unit[0].stp));
1568   device->save_item(NAME(c2040->unit[0].mtr));
1569   device->save_item(NAME(c2040->unit[0].track_len));
1570   device->save_item(NAME(c2040->unit[0].buffer_pos));
1571   device->save_item(NAME(c2040->unit[0].bit_pos));
1572   device->save_item(NAME(c2040->unit[1].stp));
1573   device->save_item(NAME(c2040->unit[1].mtr));
1574   device->save_item(NAME(c2040->unit[1].track_len));
1575   device->save_item(NAME(c2040->unit[1].buffer_pos));
1576   device->save_item(NAME(c2040->unit[1].bit_pos));
1376         // read new track data
1377         read_current_track(unit);
1378      }
1379
1380      m_unit[unit].m_stp = stp;
1381   }
15771382}
15781383
1579/*-------------------------------------------------
1580    DEVICE_RESET( c2040 )
1581-------------------------------------------------*/
15821384
1583static DEVICE_RESET( c2040 )
1385//-------------------------------------------------
1386//  mpi_step_motor -
1387//-------------------------------------------------
1388
1389inline void c2040_device::mpi_step_motor(int unit, int stp)
15841390{
1585   c2040_t *c2040 = get_safe_token(device);
1391   if (!m_unit[unit].m_mtr && (m_unit[unit].m_stp != stp))
1392   {
1393      int tracks = 0;
15861394
1587   /* reset devices */
1588   c2040->cpu_dos->reset();
1589   c2040->cpu_fdc->reset();
1590   c2040->riot0->reset();
1591   c2040->riot1->reset();
1592   c2040->miot->reset();
1593   c2040->via->reset();
1395      switch (m_unit[unit].m_stp)
1396      {
1397      case 0:   if (stp == 1) tracks++; else if (stp == 2) tracks--; break;
1398      case 1:   if (stp == 3) tracks++; else if (stp == 0) tracks--; break;
1399      case 2: if (stp == 0) tracks++; else if (stp == 3) tracks--; break;
1400      case 3: if (stp == 2) tracks++; else if (stp == 1) tracks--; break;
1401      }
15941402
1595   /* toggle M6502 SO */
1596   device_set_input_line(c2040->cpu_dos, M6502_SET_OVERFLOW, ASSERT_LINE);
1597   device_set_input_line(c2040->cpu_dos, M6502_SET_OVERFLOW, CLEAR_LINE);
1403      if (tracks != 0)
1404      {
1405         // step read/write head
1406         floppy_drive_seek(m_unit[unit].m_image, tracks);
15981407
1599   /* turn off spindle motors */
1600   c2040->unit[0].mtr = c2040->unit[1].mtr = 1;
1408         // read new track data
1409         read_current_track(unit);
1410      }
1411
1412      m_unit[unit].m_stp = stp;
1413   }
16011414}
16021415
1603/*-------------------------------------------------
1604    DEVICE_GET_INFO( c2040 )
1605-------------------------------------------------*/
16061416
1607DEVICE_GET_INFO( c2040 )
1417//-------------------------------------------------
1418//  initialize -
1419//-------------------------------------------------
1420
1421inline void c2040_device::initialize(int drives)
16081422{
1609   switch (state)
1423   // find GCR ROM
1424   m_gcr = subregion("gcr")->base();
1425
1426   // install image callbacks
1427   m_unit[0].m_image = m_image0;
1428   
1429   floppy_install_unload_proc(m_image0, c2040_device::on_disk0_change);
1430   floppy_install_load_proc(m_image0, c2040_device::on_disk0_change);
1431
1432   if (drives == 2)
16101433   {
1611      /* --- the following bits of info are returned as 64-bit signed integers --- */
1612      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(c2040_t);                           break;
1613      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(c2040_config);                        break;
1434      m_unit[1].m_image = m_image1;
16141435
1615      /* --- the following bits of info are returned as pointers --- */
1616      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c2040);                     break;
1617      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME(c2040);         break;
1436      floppy_install_unload_proc(m_image1, c2040_device::on_disk1_change);
1437      floppy_install_load_proc(m_image1, c2040_device::on_disk1_change);
1438   }
16181439
1619      /* --- the following bits of info are returned as pointers to data or functions --- */
1620      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(c2040);                  break;
1621      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
1622      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(c2040);                  break;
1440   // register for state saving
1441   save_item(NAME(m_drive));
1442   save_item(NAME(m_side));
1443   save_item(NAME(m_rfdo));
1444   save_item(NAME(m_daco));
1445   save_item(NAME(m_atna));
1446   save_item(NAME(m_ds));
1447   save_item(NAME(m_bit_count));
1448   save_item(NAME(m_sr));
1449   save_item(NAME(m_pi));
1450   save_item(NAME(m_i));
1451   save_item(NAME(m_e));
1452   save_item(NAME(m_ready));
1453   save_item(NAME(m_mode));
1454   save_item(NAME(m_rw));
1455   save_item(NAME(m_miot_irq));
1456   save_item(NAME(m_unit[0].m_stp));
1457   save_item(NAME(m_unit[0].m_mtr));
1458   save_item(NAME(m_unit[0].m_track_len));
1459   save_item(NAME(m_unit[0].m_buffer_pos));
1460   save_item(NAME(m_unit[0].m_bit_pos));
16231461
1624      /* --- the following bits of info are returned as NULL-terminated strings --- */
1625      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 2040");                     break;
1626      case DEVINFO_STR_SHORTNAME:                  strcpy(info->s, "c2040");                           break;
1627      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Commodore PET");                     break;
1628      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
1629      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
1630      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
1462   if (drives == 2)
1463   {
1464      save_item(NAME(m_unit[1].m_stp));
1465      save_item(NAME(m_unit[1].m_mtr));
1466      save_item(NAME(m_unit[1].m_track_len));
1467      save_item(NAME(m_unit[1].m_buffer_pos));
1468      save_item(NAME(m_unit[1].m_bit_pos));
16311469   }
16321470}
16331471
1634/*-------------------------------------------------
1635    DEVICE_GET_INFO( c3040 )
1636-------------------------------------------------*/
16371472
1638DEVICE_GET_INFO( c3040 )
1639{
1640   switch (state)
1641   {
1642      /* --- the following bits of info are returned as pointers --- */
1643      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c2040);                     break;
1644      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME(c2040);         break;
16451473
1646      /* --- the following bits of info are returned as NULL-terminated strings --- */
1647      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 3040");                     break;
1648      case DEVINFO_STR_SHORTNAME:                  strcpy(info->s, "c3040");                           break;
1474//**************************************************************************
1475//  LIVE DEVICE
1476//**************************************************************************
16491477
1650      default:                              DEVICE_GET_INFO_CALL(c2040);                        break;
1478//-------------------------------------------------
1479//  c2040_device - constructor
1480//-------------------------------------------------
1481
1482c2040_device::c2040_device(running_machine &_machine, const c2040_device_config &_config)
1483    : device_t(_machine, _config),
1484     device_ieee488_interface(_machine, _config, *this),
1485     m_maincpu(*this, M6502_TAG),
1486     m_fdccpu(*this, M6504_TAG),
1487     m_riot0(*this, M6532_0_TAG),
1488     m_riot1(*this, M6532_1_TAG),
1489     m_miot(*this, M6530_TAG),
1490     m_via(*this, M6522_TAG),
1491     m_image0(*this, FLOPPY_0),
1492     m_image1(*this, FLOPPY_1),
1493     m_bus(*this->owner(), IEEE488_TAG),
1494     m_drive(0),
1495     m_side(0),
1496     m_rfdo(1),
1497     m_daco(1),
1498     m_atna(1),
1499     m_ds(-1),
1500     m_bit_count(0),
1501     m_ready(0),
1502     m_mode(0),
1503     m_rw(0),
1504     m_miot_irq(CLEAR_LINE),
1505     m_bit_timer(timer_alloc()),
1506      m_config(_config)
1507{
1508   for (int i = 0; i < 2; i++)
1509   {
1510      m_unit[i].m_stp = 0;
1511      m_unit[i].m_mtr = 1;
1512      m_unit[i].m_track_len = 0;
1513      m_unit[i].m_buffer_pos = 0;
1514      m_unit[i].m_bit_pos = 0;
16511515   }
16521516}
16531517
1654/*-------------------------------------------------
1655    DEVICE_GET_INFO( c4040 )
1656-------------------------------------------------*/
16571518
1658DEVICE_GET_INFO( c4040 )
1519//-------------------------------------------------
1520//  device_start - device-specific startup
1521//-------------------------------------------------
1522
1523void c2040_device::device_start()
16591524{
1660   switch (state)
1525   address_space *main = m_maincpu->memory().space(AS_PROGRAM);
1526   address_space *fdc = m_fdccpu->memory().space(AS_PROGRAM);
1527
1528   switch (m_config.m_variant)
16611529   {
1662      /* --- the following bits of info are returned as pointers --- */
1663      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c4040);                     break;
1664      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME(c4040);         break;
1530   default:
1531      main->install_rom(0x5000, 0x7fff, subregion(M6502_TAG)->base());
1532      fdc->install_rom(0x1c00, 0x1fff, subregion(M6504_TAG)->base());
16651533
1666      /* --- the following bits of info are returned as NULL-terminated strings --- */
1667      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 4040");                     break;
1668      case DEVINFO_STR_SHORTNAME:                  strcpy(info->s, "c4040");                           break;
1534      initialize(2);
1535      break;
16691536
1670      default:                              DEVICE_GET_INFO_CALL(c3040);                        break;
1537   case c2040_device_config::TYPE_8050:
1538   case c2040_device_config::TYPE_8250:
1539      main->install_rom(0xc000, 0xffff, subregion(M6502_TAG)->base());
1540      fdc->install_rom(0x1c00, 0x1fff, subregion(M6504_TAG)->base());
1541
1542      initialize(2);
1543      break;
1544
1545   case c2040_device_config::TYPE_SFD1001:
1546      main->install_rom(0xc000, 0xffff, subregion(M6502_TAG)->base());
1547      fdc->install_rom(0x1800, 0x1fff, subregion(M6504_TAG)->base());
1548
1549      initialize(1);
1550      break;
16711551   }
16721552}
16731553
1674/*-------------------------------------------------
1675    DEVICE_GET_INFO( c8050 )
1676-------------------------------------------------*/
16771554
1678DEVICE_GET_INFO( c8050 )
1555//-------------------------------------------------
1556//  device_reset - device-specific reset
1557//-------------------------------------------------
1558
1559void c2040_device::device_reset()
16791560{
1680   switch (state)
1561   // toggle M6502 SO
1562   m_fdccpu->set_input_line(M6502_SET_OVERFLOW, ASSERT_LINE);
1563   m_fdccpu->set_input_line(M6502_SET_OVERFLOW, CLEAR_LINE);
1564
1565   // turn off spindle motors
1566   m_unit[0].m_mtr = m_unit[1].m_mtr = 1;
1567}
1568
1569
1570//-------------------------------------------------
1571//  device_timer - handler timer events
1572//-------------------------------------------------
1573
1574void c2040_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
1575{
1576   int ready = 1;
1577
1578   // shift in data from the read head
1579   m_sr <<= 1;
1580   m_sr |= BIT(m_unit[m_drive].m_track_buffer[m_unit[m_drive].m_buffer_pos], m_unit[m_drive].m_bit_pos);
1581
1582   // update GCR data
1583   update_gcr_data();
1584
1585   // update bit counters
1586   m_unit[m_drive].m_bit_pos--;
1587   m_bit_count++;
1588
1589   if (m_unit[m_drive].m_bit_pos < 0)
16811590   {
1682      /* --- the following bits of info are returned as pointers --- */
1683      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c8050);                     break;
1684      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME(c8050);         break;
1591      m_unit[m_drive].m_bit_pos = 7;
1592      m_unit[m_drive].m_buffer_pos++;
16851593
1686      /* --- the following bits of info are returned as NULL-terminated strings --- */
1687      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 8050");                     break;
1688      case DEVINFO_STR_SHORTNAME:                  strcpy(info->s, "c8050");                           break;
1594      if (m_unit[m_drive].m_buffer_pos >= m_unit[m_drive].m_track_len)
1595      {
1596         // loop to the start of the track
1597         m_unit[m_drive].m_buffer_pos = 0;
1598      }
1599   }
16891600
1690      default:                              DEVICE_GET_INFO_CALL(c2040);                        break;
1601   if (!SYNC)
1602   {
1603      // SYNC detected
1604      m_bit_count = 0;
16911605   }
1692}
16931606
1694/*-------------------------------------------------
1695    DEVICE_GET_INFO( c8250 )
1696-------------------------------------------------*/
1607   if (m_bit_count == 10)
1608   {
1609      // byte ready
1610      m_bit_count = 0;
1611      ready = 0;
1612   }
16971613
1698DEVICE_GET_INFO( c8250 )
1699{
1700   switch (state)
1614   if (m_ready != ready)
17011615   {
1702      /* --- the following bits of info are returned as pointers --- */
1703      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c8050);                     break;
1704      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME(c8250);         break;
1616      // set byte ready flag
1617      m_ready = ready;
17051618
1706      /* --- the following bits of info are returned as NULL-terminated strings --- */
1707      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 8250");                     break;
1708      case DEVINFO_STR_SHORTNAME:                  strcpy(info->s, "c8250");                           break;
1619      m_via->write_ca1(ready);
1620      m_via->write_cb1(ERROR);
17091621
1710      default:                              DEVICE_GET_INFO_CALL(c2040);                        break;
1622      if ((m_config.m_variant == c2040_device_config::TYPE_8050) ||
1623         (m_config.m_variant == c2040_device_config::TYPE_8250) ||
1624         (m_config.m_variant == c2040_device_config::TYPE_SFD1001))
1625      {
1626         m_fdccpu->set_input_line(M6502_SET_OVERFLOW, ready ? CLEAR_LINE : ASSERT_LINE);
1627      }
17111628   }
17121629}
17131630
1714/*-------------------------------------------------
1715    DEVICE_GET_INFO( sfd1001 )
1716-------------------------------------------------*/
17171631
1718DEVICE_GET_INFO( sfd1001 )
1632//-------------------------------------------------
1633//  ieee488_atn -
1634//-------------------------------------------------
1635
1636void c2040_device::ieee488_atn(int state)
17191637{
1720   switch (state)
1721   {
1722      /* --- the following bits of info are returned as pointers --- */
1723      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(sfd1001);                  break;
1724      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME(sfd1001);      break;
1638   update_ieee_signals();
17251639
1726      /* --- the following bits of info are returned as NULL-terminated strings --- */
1727      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore SFD-1001");                  break;
1728      case DEVINFO_STR_SHORTNAME:                  strcpy(info->s, "sfd1001");                           break;
1640   // set RIOT PA7
1641   riot6532_porta_in_set(m_riot1, !state << 7, 0x80);
1642}
17291643
1730      default:                              DEVICE_GET_INFO_CALL(c2040);                        break;
1644
1645//-------------------------------------------------
1646//  ieee488_ifc -
1647//-------------------------------------------------
1648
1649void c2040_device::ieee488_ifc(int state)
1650{
1651   if (!state)
1652   {
1653      device_reset();
17311654   }
17321655}
17331656
1734DEFINE_LEGACY_DEVICE(C2040, c2040);
1735DEFINE_LEGACY_DEVICE(C3040, c3040);
1736DEFINE_LEGACY_DEVICE(C4040, c4040);
1737DEFINE_LEGACY_DEVICE(C8050, c8050);
1738DEFINE_LEGACY_DEVICE(C8250, c8250);
1739DEFINE_LEGACY_DEVICE(SFD1001, sfd1001);
1657
1658//-------------------------------------------------
1659//  on_disk0_change -
1660//-------------------------------------------------
1661
1662void c2040_device::on_disk0_change(device_image_interface &image)
1663{
1664    c2040_device *c2040 = static_cast<c2040_device *>(image.device().owner());
1665
1666   c2040->read_current_track(0);
1667}
1668
1669
1670//-------------------------------------------------
1671//  on_disk_change -
1672//-------------------------------------------------
1673
1674void c2040_device::on_disk1_change(device_image_interface &image)
1675{
1676    c2040_device *c2040 = static_cast<c2040_device *>(image.device().owner());
1677
1678   c2040->read_current_track(1);
1679}
src/mess/machine/pet.c
r11262r11263
6363
6464    */
6565
66   device_t *ieeebus = device->machine().device("ieee_bus");
6766   UINT8 data = 0;
6867
6968   /* key */
r11262r11263
7675   data |= ((cassette_get_state(device->machine().device("cassette2")) & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED) << 5;
7776
7877   /* end or identify in */
79   data |= ieee488_eoi_r(ieeebus) << 6;
78   data |= state->m_ieee->eoi_r() << 6;
8079
8180   /* diagnostic jumper */
8281   data |= 0x80;
r11262r11263
177176   return (cassette_input(device->machine().device("cassette1")) > +0.0) ? 1 : 0;
178177}
179178
180static WRITE8_DEVICE_HANDLER( eoi_w )
181{
182   device_t *ieeebus = device->machine().device("ieee_bus");
183
184   ieee488_eoi_w(ieeebus, device, data);
185}
186
187179static WRITE8_DEVICE_HANDLER( cass1_motor_w )
188180{
189181   pet_state *state = device->machine().driver_data<pet_state>();
r11262r11263
219211   DEVCB_NULL,                  /* in_cb2_func */
220212   DEVCB_HANDLER(pia0_pa_w),      /* out_a_func */
221213   DEVCB_NULL,                  /* out_b_func */
222   DEVCB_HANDLER(eoi_w),         /* out_ca2_func */
214   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, eoi_w),         /* out_ca2_func */
223215   DEVCB_HANDLER(cass1_motor_w),   /* out_cb2_func */
224216   DEVCB_LINE(pia0_irq_w),         /* irq_a_func */
225217   DEVCB_LINE(pia0_irq_w)         /* irq_b_func */
r11262r11263
235227   DEVCB_NULL,                  /* in_cb2_func */
236228   DEVCB_HANDLER(pia0_pa_w),      /* out_a_func */
237229   DEVCB_NULL,                  /* out_b_func */
238   DEVCB_HANDLER(eoi_w),         /* out_ca2_func */
230   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, eoi_w),         /* out_ca2_func */
239231   DEVCB_HANDLER(cass1_motor_w),   /* out_cb2_func */
240232   DEVCB_LINE(pia0_irq_w),         /* irq_a_func */
241233   DEVCB_LINE(pia0_irq_w)         /* irq_b_func */
r11262r11263
250242  cb2 dav out
251243 */
252244
253static WRITE8_DEVICE_HANDLER( do_w )
254{
255   /*
256
257        bit     description
258
259        PB0     DO-1
260        PB1     DO-2
261        PB2     DO-3
262        PB3     DO-4
263        PB4     DO-5
264        PB5     DO-6
265        PB6     DO-7
266        PB7     DO-8
267
268    */
269
270   device_t *ieeebus = device->machine().device("ieee_bus");
271
272   ieee488_dio_w(ieeebus, device, data);
273}
274
275static WRITE8_DEVICE_HANDLER( ndac_w )
276{
277   device_t *ieeebus = device->machine().device("ieee_bus");
278
279   ieee488_ndac_w(ieeebus, device, data);
280}
281
282static WRITE8_DEVICE_HANDLER( dav_w )
283{
284   device_t *ieeebus = device->machine().device("ieee_bus");
285
286   ieee488_dav_w(ieeebus, device, data);
287}
288
289245static WRITE_LINE_DEVICE_HANDLER( pia1_irq_w )
290246{
291247   pet_state *driver_state = device->machine().driver_data<pet_state>();
r11262r11263
298254
299255const pia6821_interface pet_pia1 =
300256{
301   DEVCB_DEVICE_HANDLER("ieee_bus", ieee488_dio_r),/* in_a_func */
257   DEVCB_DEVICE_MEMBER(IEEE488_TAG, ieee488_device, dio_r),/* in_a_func */
302258   DEVCB_NULL,                        /* in_b_func */
303   DEVCB_DEVICE_LINE("ieee_bus", ieee488_atn_r),   /* in_ca1_func */
304   DEVCB_DEVICE_LINE("ieee_bus", ieee488_srq_r),   /* in_cb1_func */
259   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, atn_r),   /* in_ca1_func */
260   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, srq_r),   /* in_cb1_func */
305261   DEVCB_NULL,                        /* in_ca2_func */
306262   DEVCB_NULL,                        /* in_cb2_func */
307263   DEVCB_NULL,                        /* out_a_func */
308   DEVCB_HANDLER(do_w),               /* out_b_func */
309   DEVCB_HANDLER(ndac_w),               /* out_ca2_func */
310   DEVCB_HANDLER(dav_w),               /* out_cb2_func */
264   DEVCB_DEVICE_MEMBER(IEEE488_TAG, ieee488_device, dio_w),               /* out_b_func */
265   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, ndac_w),               /* out_ca2_func */
266   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, dav_w),               /* out_cb2_func */
311267   DEVCB_LINE(pia1_irq_w),               /* irq_a_func */
312268   DEVCB_LINE(pia1_irq_w)               /* irq_b_func */
313269};
r11262r11263
346302
347303    */
348304
349   device_t *ieeebus = device->machine().device("ieee_bus");
305   pet_state *state = device->machine().driver_data<pet_state>();
350306   UINT8 data = 0;
351307
352308   /* not data accepted in */
353   data |= ieee488_ndac_r(ieeebus);
309   data |= state->m_ieee->ndac_r();
354310
355311   /* sync in */
356312
357313   /* not ready for data in */
358   data |= ieee488_nrfd_r(ieeebus) << 6;
314   data |= state->m_ieee->nrfd_r() << 6;
359315
360316   /* data valid in */
361   data |= ieee488_dav_r(ieeebus) << 7;
317   data |= state->m_ieee->dav_r() << 7;
362318
363319   return data;
364320}
r11262r11263
371327
372328static WRITE8_DEVICE_HANDLER( via_pb_w )
373329{
374   pet_state *state = device->machine().driver_data<pet_state>();
375330   /*
376331
377332        bit     description
r11262r11263
387342
388343    */
389344
390   device_t *ieeebus = device->machine().device("ieee_bus");
345   pet_state *state = device->machine().driver_data<pet_state>();
391346
392347   /* not ready for data out */
393   ieee488_nrfd_w(ieeebus, device, BIT(data, 1));
348   state->m_ieee->nrfd_w(BIT(data, 1));
394349
395350   /* attention out */
396   ieee488_atn_w(ieeebus, device, BIT(data, 2));
351   state->m_ieee->atn_w(BIT(data, 2));
397352
398353   /* cassette write */
399354   cassette_output(device->machine().device("cassette1"), BIT(data, 3) ? -(0x5a9e >> 1) : +(0x5a9e >> 1));
r11262r11263
771726MACHINE_RESET( pet )
772727{
773728   pet_state *state = machine.driver_data<pet_state>();
774   device_t *ieeebus = machine.device("ieee_bus");
775   device_t *scapegoat = machine.device("pia_0");
776729
777730   if (state->m_superpet)
778731   {
r11262r11263
808761//removed   cbm_drive_1_config (input_port_read(machine, "CFG") & 1 ? IEEE : 0, 9);
809762   machine.device("maincpu")->reset();
810763
811   ieee488_ren_w(ieeebus, scapegoat, 0);
812   ieee488_ifc_w(ieeebus, scapegoat, 0);
813   ieee488_ifc_w(ieeebus, scapegoat, 1);
764   state->m_ieee->ren_w(0);
765   state->m_ieee->ifc_w(0);
766   state->m_ieee->ifc_w(1);
814767}
815768
816769
src/mess/machine/vic1112.h
r11262r11263
121121private:
122122   required_device<via6522_device> m_via0;
123123   required_device<via6522_device> m_via1;
124   device_t *m_bus;
124   required_device<ieee488_device> m_bus;
125125
126126   int m_via0_irq;
127127   int m_via1_irq;
src/mess/machine/c2040.h
r11262r11263
77
88**********************************************************************/
99
10#pragma once
11
1012#ifndef __C2040__
1113#define __C2040__
1214
15#define ADDRESS_MAP_MODERN
16
1317#include "emu.h"
18#include "cpu/m6502/m6502.h"
19#include "imagedev/flopdrv.h"
20#include "formats/d64_dsk.h"
21#include "formats/g64_dsk.h"
22#include "machine/6522via.h"
23#include "machine/6532riot.h"
24#include "machine/mos6530.h"
25#include "machine/ieee488.h"
1426
15/***************************************************************************
16    MACROS / CONSTANTS
17***************************************************************************/
1827
19DECLARE_LEGACY_DEVICE(C2040, c2040);
20DECLARE_LEGACY_DEVICE(C3040, c3040);
21DECLARE_LEGACY_DEVICE(C4040, c4040);
22DECLARE_LEGACY_DEVICE(C8050, c8050);
23DECLARE_LEGACY_DEVICE(C8250, c8250);
24DECLARE_LEGACY_DEVICE(SFD1001, sfd1001);
2528
26#define MCFG_C2040_ADD(_tag, _bus_tag, _address) \
27   MCFG_DEVICE_ADD(_tag, C2040, 0) \
28   MCFG_DEVICE_CONFIG_DATAPTR(c2040_config, bus_tag, _bus_tag) \
29   MCFG_DEVICE_CONFIG_DATA32(c2040_config, address, _address)
29//**************************************************************************
30//  MACROS / CONSTANTS
31//**************************************************************************
3032
31#define MCFG_C3040_ADD(_tag, _bus_tag, _address) \
32   MCFG_DEVICE_ADD(_tag, C3040, 0) \
33   MCFG_DEVICE_CONFIG_DATAPTR(c2040_config, bus_tag, _bus_tag) \
34   MCFG_DEVICE_CONFIG_DATA32(c2040_config, address, _address)
33#define C2040_TAG         "c2040"
34#define C3040_TAG         "c3040"
35#define C4040_TAG         "c4040"
36#define C8050_TAG         "c8050"
37#define C8250_TAG         "c8250"
38#define SFD1001_TAG         "sfd1001"
3539
36#define MCFG_C4040_ADD(_tag, _bus_tag, _address) \
37   MCFG_DEVICE_ADD(_tag, C4040, 0) \
38   MCFG_DEVICE_CONFIG_DATAPTR(c2040_config, bus_tag, _bus_tag) \
39   MCFG_DEVICE_CONFIG_DATA32(c2040_config, address, _address)
4040
41#define MCFG_C8050_ADD(_tag, _bus_tag, _address) \
42   MCFG_DEVICE_ADD(_tag, C8050, 0) \
43   MCFG_DEVICE_CONFIG_DATAPTR(c2040_config, bus_tag, _bus_tag) \
44   MCFG_DEVICE_CONFIG_DATA32(c2040_config, address, _address)
4541
46#define MCFG_C8250_ADD(_tag, _bus_tag, _address) \
47   MCFG_DEVICE_ADD(_tag, C8250, 0) \
48   MCFG_DEVICE_CONFIG_DATAPTR(c2040_config, bus_tag, _bus_tag) \
49   MCFG_DEVICE_CONFIG_DATA32(c2040_config, address, _address)
42//**************************************************************************
43//  INTERFACE CONFIGURATION MACROS
44//**************************************************************************
5045
51#define MCFG_SFD1001_ADD(_tag, _bus_tag, _address) \
52   MCFG_DEVICE_ADD(_tag, SFD1001, 0) \
53   MCFG_DEVICE_CONFIG_DATAPTR(c2040_config, bus_tag, _bus_tag) \
54   MCFG_DEVICE_CONFIG_DATA32(c2040_config, address, _address)
46#define MCFG_C2040_ADD(_tag, _address) \
47    MCFG_DEVICE_ADD(_tag, C2040, 0) \
48   c2040_device_config::static_set_config(device, _address, c2040_device_config::TYPE_2040);
5549
56#define C2040_IEEE488(_tag) \
57   _tag, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE(_tag, c2040_ieee488_ifc_w), DEVCB_NULL, DEVCB_DEVICE_LINE(_tag, c2040_ieee488_atn_w), DEVCB_NULL
50#define MCFG_C3040_ADD(_tag, _address) \
51    MCFG_DEVICE_ADD(_tag, C3040, 0) \
52   c2040_device_config::static_set_config(device, _address, c2040_device_config::TYPE_3040);
5853
59/***************************************************************************
60    TYPE DEFINITIONS
61***************************************************************************/
54#define MCFG_C4040_ADD(_tag, _address) \
55    MCFG_DEVICE_ADD(_tag, C4040, 0) \
56   c2040_device_config::static_set_config(device, _address, c2040_device_config::TYPE_4040);
6257
63typedef struct _c2040_config c2040_config;
64struct _c2040_config
58#define MCFG_C8050_ADD(_tag, _address) \
59    MCFG_DEVICE_ADD(_tag, C8050, 0) \
60   c2040_device_config::static_set_config(device, _address, c2040_device_config::TYPE_8050);
61
62#define MCFG_C8250_ADD(_tag, _address) \
63    MCFG_DEVICE_ADD(_tag, C8250, 0) \
64   c2040_device_config::static_set_config(device, _address, c2040_device_config::TYPE_8250);
65
66#define MCFG_SFD1001_ADD(_tag, _address) \
67    MCFG_DEVICE_ADD(_tag, SFD1001, 0) \
68   c2040_device_config::static_set_config(device, _address, c2040_device_config::TYPE_SFD1001);
69
70
71
72//**************************************************************************
73//  TYPE DEFINITIONS
74//**************************************************************************
75
76// ======================> c2040_device_config
77
78class c2040_device_config :   public device_config,
79                       public device_config_ieee488_interface
6580{
66   const char *bus_tag;      /* bus device */
67   int address;            /* bus address */
81    friend class c2040_device;
82    friend class c3040_device;
83    friend class c4040_device;
84    friend class c8050_device;
85    friend class c8250_device;
86    friend class sfd1001_device;
87
88    // construction/destruction
89    c2040_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
90
91public:
92   enum
93   {
94      TYPE_2040 = 0,
95      TYPE_3040,
96      TYPE_4040,
97      TYPE_8050,
98      TYPE_8250,
99      TYPE_SFD1001,
100   };
101   
102   // allocators
103    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
104    virtual device_t *alloc_device(running_machine &machine) const;
105
106   // inline configuration helpers
107   static void static_set_config(device_config *device, int address, int variant);
108
109   // optional information overrides
110   virtual const rom_entry *device_rom_region() const;
111   virtual machine_config_constructor device_mconfig_additions() const;
112
113protected:
114   // device_config overrides
115    virtual void device_config_complete();
116   
117   int m_address;
118   int m_variant;
68119};
69120
70/***************************************************************************
71    PROTOTYPES
72***************************************************************************/
73/* IEEE-488 interface */
74WRITE_LINE_DEVICE_HANDLER( c2040_ieee488_atn_w );
75WRITE_LINE_DEVICE_HANDLER( c2040_ieee488_ifc_w );
76121
122// ======================> c2040_device
123
124class c2040_device :  public device_t,
125                 public device_ieee488_interface
126{
127    friend class c2040_device_config;
128
129    // construction/destruction
130    c2040_device(running_machine &_machine, const c2040_device_config &_config);
131
132public:
133   // not really public
134   static void on_disk0_change(device_image_interface &image);
135   static void on_disk1_change(device_image_interface &image);
136
137   DECLARE_READ8_MEMBER( dio_r );
138   DECLARE_WRITE8_MEMBER( dio_w );
139   DECLARE_READ8_MEMBER( riot1_pa_r );
140   DECLARE_WRITE8_MEMBER( riot1_pa_w );
141   DECLARE_READ8_MEMBER( riot1_pb_r );
142   DECLARE_WRITE8_MEMBER( riot1_pb_w );
143   DECLARE_READ8_MEMBER( via_pa_r );
144   DECLARE_WRITE8_MEMBER( via_pb_w );
145   DECLARE_READ_LINE_MEMBER( ready_r );
146   DECLARE_READ_LINE_MEMBER( err_r );
147   DECLARE_WRITE_LINE_MEMBER( mode_sel_w );
148   DECLARE_WRITE_LINE_MEMBER( rw_sel_w );
149   DECLARE_READ8_MEMBER( pi_r );
150   DECLARE_WRITE8_MEMBER( pi_w );
151   DECLARE_READ8_MEMBER( miot_pb_r );
152   DECLARE_WRITE8_MEMBER( miot_pb_w );
153   DECLARE_READ8_MEMBER( c8050_via_pb_r );
154   DECLARE_WRITE8_MEMBER( c8050_via_pb_w );
155   DECLARE_READ8_MEMBER( c8050_miot_pb_r );
156   DECLARE_WRITE8_MEMBER( c8050_miot_pb_w );
157protected:
158    // device-level overrides
159    virtual void device_start();
160   virtual void device_reset();
161   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
162
163   // device_ieee488_interface overrides
164   void ieee488_atn(int state);
165   void ieee488_ifc(int state);
166
167   inline void update_ieee_signals();
168   inline void update_gcr_data();
169   inline void read_current_track(int unit);
170   inline void spindle_motor(int unit, int mtr);
171   inline void micropolis_step_motor(int unit, int stp);
172   inline void mpi_step_motor(int unit, int stp);
173   inline void initialize(int drives);
174
175   required_device<cpu_device> m_maincpu;
176   required_device<cpu_device> m_fdccpu;
177   required_device<device_t> m_riot0;
178   required_device<device_t> m_riot1;
179   required_device<device_t> m_miot;
180   required_device<via6522_device> m_via;
181   required_device<device_t> m_image0;
182   optional_device<device_t> m_image1;
183   required_device<ieee488_device> m_bus;
184
185   struct {
186      /* motors */
187      int m_stp;                        /* stepper motor phase */
188      int m_mtr;                        /* spindle motor on */
189
190      /* track */
191      UINT8 m_track_buffer[G64_BUFFER_SIZE];   /* track data buffer */
192      int m_track_len;                  /* track length */
193      int m_buffer_pos;                  /* byte position within track buffer */
194      int m_bit_pos;                     /* bit position within track buffer byte */
195
196      /* devices */
197      device_t *m_image;
198   } m_unit[2];
199
200   int m_drive;                  /* selected drive */
201   int m_side;                     /* selected side */
202
203   /* IEEE-488 bus */
204   int m_rfdo;                     /* not ready for data output */
205   int m_daco;                     /* not data accepted output */
206   int m_atna;                     /* attention acknowledge */
207
208   /* track */
209   int m_ds;                     /* density select */
210   int m_bit_count;               /* GCR bit counter */
211   UINT16 m_sr;                  /* GCR data shift register */
212   UINT8 m_pi;                     /* parallel data input */
213   UINT8* m_gcr;                  /* GCR encoder/decoder ROM */
214   UINT16 m_i;                     /* GCR encoder/decoded ROM address */
215   UINT8 m_e;                     /* GCR encoder/decoded ROM data */
216
217   /* signals */
218   int m_ready;                  /* byte ready */
219   int m_mode;                     /* mode select */
220   int m_rw;                     /* read/write select */
221   int m_miot_irq;                  /* MIOT interrupt */
222
223   /* timers */
224   emu_timer *m_bit_timer;
225
226    const c2040_device_config &m_config;
227};
228
229
230// ======================> c3040_device
231
232class c3040_device :  public c2040_device
233{
234    friend class c2040_device_config;
235
236    // construction/destruction
237    c3040_device(running_machine &_machine, const c2040_device_config &_config);
238};
239
240
241// ======================> c4040_device
242
243class c4040_device :  public c2040_device
244{
245    friend class c2040_device_config;
246
247    // construction/destruction
248    c4040_device(running_machine &_machine, const c2040_device_config &_config);
249};
250
251
252// ======================> c8050_device
253
254class c8050_device :  public c2040_device
255{
256    friend class c2040_device_config;
257
258   // construction/destruction
259    c8050_device(running_machine &_machine, const c2040_device_config &_config);
260};
261
262
263// ======================> c8250_device
264
265class c8250_device :  public c8050_device
266{
267    friend class c2040_device_config;
268
269    // construction/destruction
270    c8250_device(running_machine &_machine, const c2040_device_config &_config);
271};
272
273
274// ======================> sfd1001_device
275
276class sfd1001_device :  public c8050_device
277{
278    friend class c2040_device_config;
279
280    // construction/destruction
281    sfd1001_device(running_machine &_machine, const c2040_device_config &_config);
282};
283
284
285// device type definition
286extern const device_type C2040;
287extern const device_type C3040;
288extern const device_type C4040;
289extern const device_type C8050;
290extern const device_type C8250;
291extern const device_type SFD1001;
292
293
294
77295#endif
src/mess/machine/c1541.c
r11262r11263
214214
215215void c1541_device_config::device_config_complete()
216216{
217   m_shortname = "c1541";
217   switch (m_variant)
218   {
219   case TYPE_1540:
220      m_shortname = "c1540";
221      break;
222
223   default:
224   case TYPE_1541:
225      m_shortname = "c1541";
226      break;
227
228   case TYPE_1541C:
229      m_shortname = "c1541c";
230      break;
231
232   case TYPE_1541II:
233      m_shortname = "c1541ii";
234      break;
235
236   case TYPE_SX1541:
237      m_shortname = "sx1541";
238      break;
239
240   case TYPE_OC118:
241      m_shortname = "oc118";
242      break;
243
244   case TYPE_C2031:
245      m_shortname = "c2031";
246      break;
247   }
218248}
219249
220250
r11262r11263
538568
539569    */
540570
541   return ieee488_dio_r(m_bus, 0);
571   return m_bus->dio_r();
542572}
543573
544574
r11262r11263
559589
560590    */
561591
562   ieee488_dio_w(m_bus, this, data);
592   m_bus->dio_w(this, data);
563593}
564594
565595
r11262r11263
583613   UINT8 data = 0;
584614
585615   // not ready for data
586   data |= ieee488_nrfd_r(m_bus) << 1;
616   data |= m_bus->nrfd_r() << 1;
587617
588618   // not data accepted
589   data |= ieee488_ndac_r(m_bus) << 2;
619   data |= m_bus->ndac_r() << 2;
590620
591621   // end or identify
592   data |= ieee488_eoi_r(m_bus) << 3;
622   data |= m_bus->eoi_r() << 3;
593623
594624   // data valid
595   data |= ieee488_dav_r(m_bus) << 6;
625   data |= m_bus->dav_r() << 6;
596626
597627   // attention
598   data |= !ieee488_atn_r(m_bus) << 7;
628   data |= !m_bus->atn_r() << 7;
599629
600630   return data;
601631}
r11262r11263
629659   m_ndac_out = ndac;
630660
631661   // end or identify
632   ieee488_eoi_w(m_bus, this, BIT(data, 3));
662   m_bus->eoi_w(this, BIT(data, 3));
633663
634664   // data valid
635   ieee488_dav_w(m_bus, this, BIT(data, 6));
665   m_bus->dav_w(this, BIT(data, 6));
636666
637667   // attention acknowledge
638668   m_atna = atna;
639669
640   if (!ieee488_atn_r(m_bus) ^ atna)
670   if (!m_bus->atn_r() ^ atna)
641671   {
642672      nrfd = ndac = 0;
643673   }
644674
645   ieee488_nrfd_w(m_bus, this, nrfd);
646   ieee488_ndac_w(m_bus, this, ndac);
675   m_bus->nrfd_w(this, nrfd);
676   m_bus->ndac_w(this, ndac);
647677}
648678
649679
650680READ_LINE_MEMBER( c2031_device::via0_ca1_r )
651681{
652   return !ieee488_atn_r(m_bus);
682   return !m_bus->atn_r();
653683}
654684
655685
r11262r11263
832862   DEVCB_NULL,
833863   FLOPPY_STANDARD_5_25_DSDD,
834864   FLOPPY_OPTIONS_NAME(c1541),
835   NULL
865   "floppy_5_25"
836866};
837867
838868
r11262r11263
911941//**************************************************************************
912942
913943//-------------------------------------------------
914//  c1541_device - constructor
944//  set_iec_data -
915945//-------------------------------------------------
916946
917947inline void c1541_device::set_iec_data()
r11262r11263
10081038//  ieee488_atn_w -
10091039//-------------------------------------------------
10101040
1011WRITE_LINE_MEMBER( c2031_device::ieee488_atn_w )
1041void c2031_device::ieee488_atn(int state)
10121042{
10131043   int nrfd = m_nrfd_out;
10141044   int ndac = m_ndac_out;
r11262r11263
10201050      nrfd = ndac = 0;
10211051   }
10221052
1023   ieee488_nrfd_w(m_bus, this, nrfd);
1024   ieee488_ndac_w(m_bus, this, ndac);
1053   m_bus->nrfd_w(this, nrfd);
1054   m_bus->ndac_w(this, ndac);
10251055}
10261056
10271057
r11262r11263
10291059//  ieee488_ifc_w -
10301060//-------------------------------------------------
10311061
1032WRITE_LINE_MEMBER( c2031_device::ieee488_ifc_w )
1062void c2031_device::ieee488_ifc(int state)
10331063{
10341064   if (!state)
10351065   {
src/mess/machine/c1541.h
r11262r11263
237237
238238// ======================> c2031_device
239239
240class c2031_device :  public c1541_device
240class c2031_device :  public c1541_device,
241                 public device_ieee488_interface
241242{
242243    friend class c1541_device_config;
243244
r11262r11263
245246    c2031_device(running_machine &_machine, const c1541_device_config &_config);
246247
247248public:
248   DECLARE_WRITE_LINE_MEMBER( ieee488_atn_w );
249   DECLARE_WRITE_LINE_MEMBER( ieee488_ifc_w );
250
251249   // not really public
252250   DECLARE_READ8_MEMBER( via0_pa_r );
253251   DECLARE_WRITE8_MEMBER( via0_pa_w );
r11262r11263
257255   DECLARE_READ_LINE_MEMBER( via0_ca2_r );
258256
259257protected:
258   // device_ieee488_interface overrides
259   void ieee488_atn(int state);
260   void ieee488_ifc(int state);
261
262   required_device<ieee488_device> m_bus;
263
260264   int m_nrfd_out;            // not ready for data
261265   int m_ndac_out;            // not data accepted
262266   int m_atna;               // attention acknowledge
src/mess/machine/ieeestub.c
r0r11263
1#include "ieee488.h"
2
3
4
5//**************************************************************************
6//  DEVICE DEFINITIONS
7//**************************************************************************
8
9const device_type IEEE488_STUB = ieee488_stub_device_config::static_alloc_device_config;
10
11
12
13//**************************************************************************
14//  DEVICE CONFIGURATION
15//**************************************************************************
16
17//-------------------------------------------------
18//  ieee488_stub_device_config - constructor
19//-------------------------------------------------
20
21ieee488_stub_device_config::ieee488_stub_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
22   : device_config(mconfig, static_alloc_device_config, "IEEE488 driver stub", tag, owner, clock),
23     device_config_ieee488_interface(mconfig, *this)
24{
25}
26
27
28//-------------------------------------------------
29//  static_alloc_device_config - allocate a new
30//  configuration object
31//-------------------------------------------------
32
33device_config *ieee488_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(ieee488_stub_device_config(mconfig, tag, owner, clock));
36}
37
38
39//-------------------------------------------------
40//  alloc_device - allocate a new device object
41//-------------------------------------------------
42
43device_t *ieee488_stub_device_config::alloc_device(running_machine &machine) const
44{
45   return auto_alloc(machine, ieee488_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 ieee488_stub_device_config::device_config_complete()
56{
57   // inherit a copy of the static data
58   const ieee488_stub_interface *intf = reinterpret_cast<const ieee488_stub_interface *>(static_config());
59   if (intf != NULL)
60      *static_cast<ieee488_stub_interface *>(this) = *intf;
61
62   // or initialize to defaults if none provided
63   else
64   {
65      memset(&m_out_eoi_func, 0, sizeof(m_out_eoi_func));
66      memset(&m_out_dav_func, 0, sizeof(m_out_dav_func));
67      memset(&m_out_nrfd_func, 0, sizeof(m_out_nrfd_func));
68      memset(&m_out_ndac_func, 0, sizeof(m_out_ndac_func));
69      memset(&m_out_ifc_func, 0, sizeof(m_out_ifc_func));
70      memset(&m_out_srq_func, 0, sizeof(m_out_srq_func));
71      memset(&m_out_atn_func, 0, sizeof(m_out_atn_func));
72      memset(&m_out_ren_func, 0, sizeof(m_out_ren_func));
73   }
74}
75
76
77//**************************************************************************
78//  LIVE DEVICE
79//**************************************************************************
80
81//-------------------------------------------------
82//  ieee488_stub_device - constructor
83//-------------------------------------------------
84
85ieee488_stub_device::ieee488_stub_device(running_machine &_machine, const ieee488_stub_device_config &_config)
86    : device_t(_machine, _config),
87     device_ieee488_interface(_machine, _config, *this),
88      m_config(_config)
89{
90}
91
92
93//-------------------------------------------------
94//  device_start - device-specific startup
95//-------------------------------------------------
96
97void ieee488_stub_device::device_start()
98{
99   // resolve callbacks
100    devcb_resolve_write_line(&m_out_eoi_func, &m_config.m_out_eoi_func, this);
101    devcb_resolve_write_line(&m_out_dav_func, &m_config.m_out_dav_func, this);
102    devcb_resolve_write_line(&m_out_nrfd_func, &m_config.m_out_nrfd_func, this);
103    devcb_resolve_write_line(&m_out_ndac_func, &m_config.m_out_ndac_func, this);
104    devcb_resolve_write_line(&m_out_ifc_func, &m_config.m_out_ifc_func, this);
105    devcb_resolve_write_line(&m_out_srq_func, &m_config.m_out_srq_func, this);
106    devcb_resolve_write_line(&m_out_atn_func, &m_config.m_out_atn_func, this);
107    devcb_resolve_write_line(&m_out_ren_func, &m_config.m_out_ren_func, this);
108}
109
110
111//-------------------------------------------------
112//  ieee488_eoi -
113//-------------------------------------------------
114
115void ieee488_stub_device::ieee488_eoi(int state)
116{
117   devcb_call_write_line(&m_out_eoi_func, state);
118}
119
120
121//-------------------------------------------------
122//  ieee488_dav -
123//-------------------------------------------------
124
125void ieee488_stub_device::ieee488_dav(int state)
126{
127   devcb_call_write_line(&m_out_dav_func, state);
128}
129
130
131//-------------------------------------------------
132//  ieee488_nrfd -
133//-------------------------------------------------
134
135void ieee488_stub_device::ieee488_nrfd(int state)
136{
137   devcb_call_write_line(&m_out_nrfd_func, state);
138}
139
140
141//-------------------------------------------------
142//  ieee488_ndac -
143//-------------------------------------------------
144
145void ieee488_stub_device::ieee488_ndac(int state)
146{
147   devcb_call_write_line(&m_out_ndac_func, state);
148}
149
150
151//-------------------------------------------------
152//  ieee488_ifc -
153//-------------------------------------------------
154
155void ieee488_stub_device::ieee488_ifc(int state)
156{
157   devcb_call_write_line(&m_out_ifc_func, state);
158}
159
160
161//-------------------------------------------------
162//  ieee488_srq -
163//-------------------------------------------------
164
165void ieee488_stub_device::ieee488_srq(int state)
166{
167   devcb_call_write_line(&m_out_srq_func, state);
168}
169
170
171//-------------------------------------------------
172//  ieee488_atn -
173//-------------------------------------------------
174
175void ieee488_stub_device::ieee488_atn(int state)
176{
177   devcb_call_write_line(&m_out_atn_func, state);
178}
179
180
181//-------------------------------------------------
182//  ieee488_ren -
183//-------------------------------------------------
184
185void ieee488_stub_device::ieee488_ren(int state)
186{
187   devcb_call_write_line(&m_out_ren_func, state);
188}
src/mess/machine/c1571.c
r11262r11263
9595
9696void c1571_device_config::device_config_complete()
9797{
98   m_shortname = "c1571";
98   switch (m_variant)
99   {
100   case TYPE_1570:
101      m_shortname = "c1570";
102      break;
103
104   default:
105   case TYPE_1571:
106      m_shortname = "c1571";
107      break;
108
109   case TYPE_1571CR:
110      m_shortname = "c1571cr";
111      break;
112   }
99113}
100114
101115
r11262r11263
577591   DEVCB_NULL,
578592   FLOPPY_STANDARD_5_25_DSDD,
579593   FLOPPY_OPTIONS_NAME(c1571),
580   NULL
594   "floppy_5_25"
581595};
582596
583597
src/mess/machine/ieee488.c
r11262r11263
88
99**********************************************************************/
1010
11#include "emu.h"
1211#include "ieee488.h"
12#include "machine/devhelpr.h"
1313
14/***************************************************************************
15    PARAMETERS
16***************************************************************************/
1714
18#define LOG 0
1915
20enum
21{
22   EOI = 0,
23   DAV,
24   NRFD,
25   NDAC,
26   IFC,
27   SRQ,
28   ATN,
29   REN,
30   SIGNAL_COUNT
31};
16//**************************************************************************
17//  MACROS / CONSTANTS
18//**************************************************************************
3219
20#define LOG 1
21
22
3323static const char *const SIGNAL_NAME[] = { "EOI", "DAV", "NRFD", "NDAC", "IFC", "SRQ", "ATN", "REN" };
3424
35/***************************************************************************
36    TYPE DEFINITIONS
37***************************************************************************/
3825
39typedef struct _ieee488_daisy_state ieee488_daisy_state;
40struct _ieee488_daisy_state
26
27//**************************************************************************
28//  DEVICE DEFINITIONS
29//**************************************************************************
30
31const device_type IEEE488 = ieee488_device_config::static_alloc_device_config;
32
33
34
35//**************************************************************************
36//  DEVICE CONFIGURATION INTERFACE
37//**************************************************************************
38
39//-------------------------------------------------
40//  device_config_ieee488_interface - constructor
41//-------------------------------------------------
42
43device_config_ieee488_interface::device_config_ieee488_interface(const machine_config &mconfig, device_config &devconfig)
44   : device_config_interface(mconfig, devconfig)
4145{
42   ieee488_daisy_state         *next;         /* next device */
43   device_t *device;      /* associated device */
46}
4447
45   int line[SIGNAL_COUNT];                  /* control lines' state */
46   UINT8 dio;                           /* data lines' state */
4748
48   devcb_resolved_write_line   out_line_func[SIGNAL_COUNT];
49};
49//-------------------------------------------------
50//  ~device_config_ieee488_interface - destructor
51//-------------------------------------------------
5052
51typedef struct _ieee488_t ieee488_t;
52struct _ieee488_t
53device_config_ieee488_interface::~device_config_ieee488_interface()
5354{
54   ieee488_daisy_state *daisy_state;
55};
55}
5656
57/***************************************************************************
58    INLINE FUNCTIONS
59***************************************************************************/
6057
61INLINE ieee488_t *get_safe_token(device_t *device)
58
59//**************************************************************************
60//  DEVICE INTERFACE
61//**************************************************************************
62
63//-------------------------------------------------
64//  device_ieee488_interface - constructor
65//-------------------------------------------------
66
67device_ieee488_interface::device_ieee488_interface(running_machine &machine, const device_config &config, device_t &device)
68   : device_interface(machine, config, device),
69     m_ieee488_config(dynamic_cast<const device_config_ieee488_interface &>(config))
6270{
63   assert(device != NULL);
64   assert(device->type() == IEEE488);
65   return (ieee488_t *)downcast<legacy_device_base *>(device)->token();
6671}
6772
68INLINE const ieee488_daisy_chain *get_interface(device_t *device)
73
74//-------------------------------------------------
75//  ~device_ieee488_interface - destructor
76//-------------------------------------------------
77
78device_ieee488_interface::~device_ieee488_interface()
6979{
70   assert(device != NULL);
71   assert(device->type() == IEEE488);
72   return (const ieee488_daisy_chain *) device->baseconfig().static_config();
7380}
7481
75INLINE int get_signal(device_t *bus, int line)
82
83
84//**************************************************************************
85//  DEVICE CONFIGURATION
86//**************************************************************************
87
88GENERIC_DEVICE_CONFIG_SETUP(ieee488, "IEEE488")
89
90
91//-------------------------------------------------
92//  device_config_complete - perform any
93//  operations now that the configuration is
94//  complete
95//-------------------------------------------------
96
97void ieee488_device_config::device_config_complete()
7698{
77   ieee488_t *ieee488 = get_safe_token(bus);
78   ieee488_daisy_state *daisy = ieee488->daisy_state;
79   int state = 1;
99   // inherit a copy of the static data
100   const ieee488_config *intf = reinterpret_cast<const ieee488_config *>(static_config());
101   if (intf != NULL)
102      *static_cast<ieee488_config *>(this) = *intf;
80103
81   for ( ; daisy != NULL; daisy = daisy->next)
104   // or initialize to defaults if none provided
105   else
82106   {
83      state &= daisy->line[line];
107      fatalerror("Daisy chain not provided!");
84108   }
85109
86   return state;
110   m_daisy = intf;
87111}
88112
89INLINE int get_data(device_t *bus)
113
114
115//**************************************************************************
116//  INLINE HELPERS
117//**************************************************************************
118
119//-------------------------------------------------
120//  set_signal -
121//-------------------------------------------------
122
123inline void ieee488_device::set_signal(device_t *device, int signal, int state)
90124{
91   ieee488_t *ieee488 = get_safe_token(bus);
92   ieee488_daisy_state *daisy = ieee488->daisy_state;
93   UINT8 data = 0xff;
125   bool changed = false;
94126
95   for ( ; daisy != NULL; daisy = daisy->next)
127   for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next)
96128   {
97      data &= daisy->dio;
129      if (!strcmp(daisy->m_device->tag(), device->tag()))
130      {
131         if (daisy->m_line[signal] != state)
132         {
133            if (LOG) logerror("IEEE488: '%s' %s %u\n", device->tag(), SIGNAL_NAME[signal], state);
134            daisy->m_line[signal] = state;
135            changed = true;
136         }
137      }
98138   }
99139
100   return data;
140   if (changed)
141   {
142      for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next)
143      {
144         switch (signal)
145         {
146         case EOI:
147            daisy->m_interface->ieee488_eoi(state);
148            break;
149
150         case DAV:
151            daisy->m_interface->ieee488_dav(state);
152            break;
153
154         case NRFD:
155            daisy->m_interface->ieee488_nrfd(state);
156            break;
157
158         case NDAC:
159            daisy->m_interface->ieee488_ndac(state);
160            break;
161
162         case IFC:
163            daisy->m_interface->ieee488_ifc(state);
164            break;
165
166         case SRQ:
167            daisy->m_interface->ieee488_srq(state);
168            break;
169
170         case ATN:
171            daisy->m_interface->ieee488_atn(state);
172            break;
173
174         case REN:
175            daisy->m_interface->ieee488_ren(state);
176            break;
177         }
178      }
179
180      if (LOG) logerror("IEEE-488: EOI %u DAV %u NRFD %u NDAC %u IFC %u SRQ %u ATN %u REN %u DIO %02x\n",
181         get_signal(EOI), get_signal(DAV), get_signal(NRFD), get_signal(NDAC),
182         get_signal(IFC), get_signal(SRQ), get_signal(ATN), get_signal(REN), get_data());
183   }
101184}
102185
103INLINE void set_signal(device_t *bus, device_t *device, int line, int state)
186
187//-------------------------------------------------
188//  get_signal -
189//-------------------------------------------------
190
191inline int ieee488_device::get_signal(int signal)
104192{
105   ieee488_t *ieee488 = get_safe_token(bus);
106   ieee488_daisy_state *daisy = ieee488->daisy_state;
107   int new_state = 1;
193   int state = 1;
108194
109   for ( ; daisy != NULL; daisy = daisy->next)
195   for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next)
110196   {
111      if (!strcmp(daisy->device->tag(), device->tag()))
197      if (!daisy->m_line[signal])
112198      {
113         if (daisy->line[line] != state)
199         state = 0;
200         break;
201      }
202   }
203
204   return state;
205}
206
207
208//-------------------------------------------------
209//  set_data -
210//-------------------------------------------------
211
212inline void ieee488_device::set_data(device_t *device, UINT8 data)
213{
214   for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next)
215   {
216      if (!strcmp(daisy->m_device->tag(), device->tag()))
217      {
218         if (daisy->m_dio != data)
114219         {
115            if (LOG) logerror("IEEE-488: '%s' %s %u\n", device->tag(), SIGNAL_NAME[line], state);
116            daisy->line[line] = state;
220            if (LOG) logerror("IEEE488: '%s' DIO %02x\n", device->tag(), data);
221            daisy->m_dio = data;
117222         }
118         break;
119223      }
120224   }
225}
121226
122   new_state = get_signal(bus, line);
123   daisy = ieee488->daisy_state;
124227
125   for ( ; daisy != NULL; daisy = daisy->next)
228//-------------------------------------------------
229//  get_data -
230//-------------------------------------------------
231
232inline UINT8 ieee488_device::get_data()
233{
234   UINT8 data = 0xff;
235
236   for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next)
126237   {
127      devcb_call_write_line(&daisy->out_line_func[line], new_state);
238      data &= daisy->m_dio;
128239   }
129240
130   if (LOG) logerror("IEEE-488: EOI %u DAV %u NRFD %u NDAC %u IFC %u SRQ %u ATN %u REN %u DIO %02x\n",
131      get_signal(bus, EOI), get_signal(bus, DAV), get_signal(bus, NRFD), get_signal(bus, NDAC),
132      get_signal(bus, IFC), get_signal(bus, SRQ), get_signal(bus, ATN), get_signal(bus, REN), get_data(bus));
241   return data;
133242}
134243
135INLINE void set_data(device_t *bus, device_t *device, UINT8 data)
244
245
246//**************************************************************************
247//  LIVE DEVICE
248//**************************************************************************
249
250//-------------------------------------------------
251//  ieee488_device - constructor
252//-------------------------------------------------
253
254ieee488_device::ieee488_device(running_machine &_machine, const ieee488_device_config &_config)
255    : device_t(_machine, _config),
256     m_stub(*this->owner(), IEEE488_STUB_TAG),
257      m_config(_config)
136258{
137   ieee488_t *ieee488 = get_safe_token(bus);
138   ieee488_daisy_state *daisy = ieee488->daisy_state;
259}
139260
140   for ( ; daisy != NULL; daisy = daisy->next)
261
262//-------------------------------------------------
263//  device_start - device-specific startup
264//-------------------------------------------------
265
266void ieee488_device::device_start()
267{
268   const ieee488_config *daisy = m_config.m_daisy;
269
270   // create a linked list of devices
271   daisy_entry **tailptr = &m_daisy_list;
272   for ( ; daisy->m_tag != NULL; daisy++)
141273   {
142      if (!strcmp(daisy->device->tag(), device->tag()))
143      {
144         if (LOG) logerror("IEEE-488: '%s' DIO %02x\n", device->tag(), data);
145         daisy->dio = data;
146         break;
147      }
274      // find the device
275      device_t *target = machine().device(daisy->m_tag);
276      if (target == NULL)
277         fatalerror("Unable to locate device '%s'", daisy->m_tag);
278
279      // make sure it has an interface
280      device_ieee488_interface *intf;
281      if (!target->interface(intf))
282         fatalerror("Device '%s' does not implement the CBM IEC interface!", daisy->m_tag);
283
284      // append to the end
285      *tailptr = auto_alloc(machine(), daisy_entry(target));
286      tailptr = &(*tailptr)->m_next;
148287   }
149288
150   if (LOG) logerror("IEEE-488: EOI %u DAV %u NRFD %u NDAC %u IFC %u SRQ %u ATN %u REN %u DIO %02x\n",
151      get_signal(bus, EOI), get_signal(bus, DAV), get_signal(bus, NRFD), get_signal(bus, NDAC),
152      get_signal(bus, IFC), get_signal(bus, SRQ), get_signal(bus, ATN), get_signal(bus, REN), get_data(bus));
289   // append driver stub to the end
290   device_t *target = machine().device(IEEE488_STUB_TAG);
291   *tailptr = auto_alloc(machine(), daisy_entry(target));
292   tailptr = &(*tailptr)->m_next;
153293}
154294
155/***************************************************************************
156    IMPLEMENTATION
157***************************************************************************/
158295
159void ieee488_eoi_w(device_t *bus, device_t *device, int state)
296//-------------------------------------------------
297//  daisy_entry - constructor
298//-------------------------------------------------
299
300ieee488_device::daisy_entry::daisy_entry(device_t *device)
301   : m_next(NULL),
302     m_device(device),
303     m_interface(NULL),
304     m_dio(0xff)
160305{
161   set_signal(bus, device, EOI, state);
306   for (int i = 0; i < SIGNAL_COUNT; i++)
307   {
308      m_line[i] = 1;
309   }
310
311   device->interface(m_interface);
162312}
163313
164READ_LINE_DEVICE_HANDLER( ieee488_eoi_r )
314
315//-------------------------------------------------
316//  dio_r -
317//-------------------------------------------------
318
319UINT8 ieee488_device::dio_r()
165320{
166   return get_signal(device, EOI);
321   return get_data();
167322}
168323
169void ieee488_dav_w(device_t *bus, device_t *device, int state)
324
325//-------------------------------------------------
326//  dio_r -
327//-------------------------------------------------
328
329READ8_MEMBER( ieee488_device::dio_r )
170330{
171   set_signal(bus, device, DAV, state);
331   return get_data();
172332}
173333
174READ_LINE_DEVICE_HANDLER( ieee488_dav_r )
334
335//-------------------------------------------------
336//  eoi_r -
337//-------------------------------------------------
338
339READ_LINE_MEMBER( ieee488_device::eoi_r )
175340{
176   return get_signal(device, DAV);
341   return get_signal(EOI);
177342}
178343
179void ieee488_nrfd_w(device_t *bus, device_t *device, int state)
344
345//-------------------------------------------------
346//  dav_r -
347//-------------------------------------------------
348
349READ_LINE_MEMBER( ieee488_device::dav_r )
180350{
181   set_signal(bus, device, NRFD, state);
351   return get_signal(DAV);
182352}
183353
184READ_LINE_DEVICE_HANDLER( ieee488_nrfd_r )
354
355//-------------------------------------------------
356//  nrfd_r -
357//-------------------------------------------------
358
359READ_LINE_MEMBER( ieee488_device::nrfd_r )
185360{
186   return get_signal(device, NRFD);
361   return get_signal(NRFD);
187362}
188363
189void ieee488_ndac_w(device_t *bus, device_t *device, int state)
364
365//-------------------------------------------------
366//  ndac_r -
367//-------------------------------------------------
368
369READ_LINE_MEMBER( ieee488_device::ndac_r )
190370{
191   set_signal(bus, device, NDAC, state);
371   return get_signal(NDAC);
192372}
193373
194READ_LINE_DEVICE_HANDLER( ieee488_ndac_r )
374
375//-------------------------------------------------
376//  ifc_r -
377//-------------------------------------------------
378
379READ_LINE_MEMBER( ieee488_device::ifc_r )
195380{
196   return get_signal(device, NDAC);
381   return get_signal(IFC);
197382}
198383
199void ieee488_ifc_w(device_t *bus, device_t *device, int state)
384
385//-------------------------------------------------
386//  srq_r -
387//-------------------------------------------------
388
389READ_LINE_MEMBER( ieee488_device::srq_r )
200390{
201   set_signal(bus, device, IFC, state);
391   return get_signal(SRQ);
202392}
203393
204READ_LINE_DEVICE_HANDLER( ieee488_ifc_r )
394
395//-------------------------------------------------
396//  atn_r -
397//-------------------------------------------------
398
399READ_LINE_MEMBER( ieee488_device::atn_r )
205400{
206   return get_signal(device, IFC);
401   return get_signal(ATN);
207402}
208403
209void ieee488_srq_w(device_t *bus, device_t *device, int state)
404
405//-------------------------------------------------
406//  ren_r -
407//-------------------------------------------------
408
409READ_LINE_MEMBER( ieee488_device::ren_r )
210410{
211   set_signal(bus, device, SRQ, state);
411   return get_signal(REN);
212412}
213413
214READ_LINE_DEVICE_HANDLER( ieee488_srq_r )
414
415//-------------------------------------------------
416//  dio_w -
417//-------------------------------------------------
418
419void ieee488_device::dio_w(UINT8 data)
215420{
216   return get_signal(device, SRQ);
421   return set_data(m_stub, data);
217422}
218423
219void ieee488_atn_w(device_t *bus, device_t *device, int state)
424
425//-------------------------------------------------
426//  dio_w -
427//-------------------------------------------------
428
429WRITE8_MEMBER( ieee488_device::dio_w )
220430{
221   set_signal(bus, device, ATN, state);
431   return set_data(m_stub, data);
222432}
223433
224READ_LINE_DEVICE_HANDLER( ieee488_atn_r )
434
435//-------------------------------------------------
436//  eoi_w -
437//-------------------------------------------------
438
439WRITE_LINE_MEMBER( ieee488_device::eoi_w )
225440{
226   return get_signal(device, ATN);
441   set_signal(m_stub, EOI, state);
227442}
228443
229void ieee488_ren_w(device_t *bus, device_t *device, int state)
444
445//-------------------------------------------------
446//  dav_w -
447//-------------------------------------------------
448
449WRITE_LINE_MEMBER( ieee488_device::dav_w )
230450{
231   set_signal(bus, device, REN, state);
451   set_signal(m_stub, DAV, state);
232452}
233453
234READ_LINE_DEVICE_HANDLER( ieee488_ren_r )
454
455//-------------------------------------------------
456//  nrfd_w -
457//-------------------------------------------------
458
459WRITE_LINE_MEMBER( ieee488_device::nrfd_w )
235460{
236   return get_signal(device, REN);
461   set_signal(m_stub, NRFD, state);
237462}
238463
239READ8_DEVICE_HANDLER( ieee488_dio_r )
464
465//-------------------------------------------------
466//  ndac_w -
467//-------------------------------------------------
468
469WRITE_LINE_MEMBER( ieee488_device::ndac_w )
240470{
241   return get_data(device);
471   set_signal(m_stub, NDAC, state);
242472}
243473
244void ieee488_dio_w(device_t *bus, device_t *device, UINT8 data)
474
475//-------------------------------------------------
476//  ifc_w -
477//-------------------------------------------------
478
479WRITE_LINE_MEMBER( ieee488_device::ifc_w )
245480{
246   set_data(bus, device, data);
481   set_signal(m_stub, IFC, state);
247482}
248483
249/*-------------------------------------------------
250    DEVICE_START( ieee488 )
251-------------------------------------------------*/
252484
253static DEVICE_START( ieee488 )
485//-------------------------------------------------
486//  srq_w -
487//-------------------------------------------------
488
489WRITE_LINE_MEMBER( ieee488_device::srq_w )
254490{
255   ieee488_t *ieee488 = get_safe_token(device);
256   const ieee488_daisy_chain *daisy = get_interface(device);
257   int i;
491   set_signal(m_stub, SRQ, state);
492}
258493
259   ieee488_daisy_state *head = NULL;
260   ieee488_daisy_state **tailptr = &head;
261494
262   /* create a linked list of devices */
263   for ( ; daisy->tag != NULL; daisy++)
264   {
265      *tailptr = auto_alloc(device->machine(), ieee488_daisy_state);
495//-------------------------------------------------
496//  atn_w -
497//-------------------------------------------------
266498
267      /* find device */
268      (*tailptr)->next = NULL;
269      (*tailptr)->device = device->machine().device(daisy->tag);
499WRITE_LINE_MEMBER( ieee488_device::atn_w )
500{
501   set_signal(m_stub, ATN, state);
502}
270503
271      if ((*tailptr)->device == NULL)
272      {
273         fatalerror("Unable to locate device '%s'", daisy->tag);
274      }
275504
276      /* set control lines to 'false' state */
277      for (i = EOI; i < SIGNAL_COUNT; i++)
278      {
279         (*tailptr)->line[i] = 1;
280      }
505//-------------------------------------------------
506//  ren_w -
507//-------------------------------------------------
281508
282      /* set data lines to 'false' state */
283      (*tailptr)->dio = 0xff;
509WRITE_LINE_MEMBER( ieee488_device::ren_w )
510{
511   set_signal(m_stub, REN, state);
512}
284513
285      /* resolve callbacks */
286      devcb_resolve_write_line(&(*tailptr)->out_line_func[EOI], &daisy->out_eoi_func, device);
287      devcb_resolve_write_line(&(*tailptr)->out_line_func[DAV], &daisy->out_dav_func, device);
288      devcb_resolve_write_line(&(*tailptr)->out_line_func[NRFD], &daisy->out_nrfd_func, device);
289      devcb_resolve_write_line(&(*tailptr)->out_line_func[NDAC], &daisy->out_ndac_func, device);
290      devcb_resolve_write_line(&(*tailptr)->out_line_func[IFC], &daisy->out_ifc_func, device);
291      devcb_resolve_write_line(&(*tailptr)->out_line_func[SRQ], &daisy->out_srq_func, device);
292      devcb_resolve_write_line(&(*tailptr)->out_line_func[ATN], &daisy->out_atn_func, device);
293      devcb_resolve_write_line(&(*tailptr)->out_line_func[REN], &daisy->out_ren_func, device);
294514
295      tailptr = &(*tailptr)->next;
296   }
515//-------------------------------------------------
516//  dio_w -
517//-------------------------------------------------
297518
298   ieee488->daisy_state = head;
519void ieee488_device::dio_w(device_t *device, UINT8 data)
520{
521   return set_data(device, data);
522}
299523
300   /* register for state saving */
301//  device->save_item(NAME(ieee488->));
524
525//-------------------------------------------------
526//  eoi_w -
527//-------------------------------------------------
528
529void ieee488_device::eoi_w(device_t *device, int state)
530{
531   set_signal(device, EOI, state);
302532}
303533
304/*-------------------------------------------------
305    DEVICE_GET_INFO( ieee488 )
306-------------------------------------------------*/
307534
308DEVICE_GET_INFO( ieee488 )
535//-------------------------------------------------
536//  dav_w -
537//-------------------------------------------------
538
539void ieee488_device::dav_w(device_t *device, int state)
309540{
310   switch (state)
311   {
312      /* --- the following bits of info are returned as 64-bit signed integers --- */
313      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(ieee488_t);                        break;
314      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                    break;
541   set_signal(device, DAV, state);
542}
315543
316      /* --- the following bits of info are returned as pointers to data or functions --- */
317      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(ieee488);               break;
318      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
319      case DEVINFO_FCT_RESET:                     /* Nothing */                                    break;
320544
321      /* --- the following bits of info are returned as NULL-terminated strings --- */
322      case DEVINFO_STR_NAME:                     strcpy(info->s, "IEEE-488.1 Bus");                     break;
323      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "IEEE-488");                        break;
324      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
325      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
326      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
327   }
545//-------------------------------------------------
546//  nrfd_w -
547//-------------------------------------------------
548
549void ieee488_device::nrfd_w(device_t *device, int state)
550{
551   set_signal(device, NRFD, state);
328552}
329553
330DEFINE_LEGACY_DEVICE(IEEE488, ieee488);
554
555//-------------------------------------------------
556//  ndac_w -
557//-------------------------------------------------
558
559void ieee488_device::ndac_w(device_t *device, int state)
560{
561   set_signal(device, NDAC, state);
562}
563
564
565//-------------------------------------------------
566//  ifc_w -
567//-------------------------------------------------
568
569void ieee488_device::ifc_w(device_t *device, int state)
570{
571   set_signal(device, IFC, state);
572}
573
574
575//-------------------------------------------------
576//  srq_w -
577//-------------------------------------------------
578
579void ieee488_device::srq_w(device_t *device, int state)
580{
581   set_signal(device, SRQ, state);
582}
583
584
585//-------------------------------------------------
586//  atn_w -
587//-------------------------------------------------
588
589void ieee488_device::atn_w(device_t *device, int state)
590{
591   set_signal(device, ATN, state);
592}
593
594
595//-------------------------------------------------
596//  ren_w -
597//-------------------------------------------------
598
599void ieee488_device::ren_w(device_t *device, int state)
600{
601   set_signal(device, REN, state);
602}
src/mess/machine/ieee488.h
r11262r11263
88
99**********************************************************************/
1010
11#pragma once
12
1113#ifndef __IEEE488__
1214#define __IEEE488__
1315
1416#include "emu.h"
1517
16/***************************************************************************
17    MACROS / CONSTANTS
18***************************************************************************/
1918
20DECLARE_LEGACY_DEVICE(IEEE488, ieee488);
2119
22#define MCFG_IEEE488_ADD(_tag, _daisy_chain) \
23   MCFG_DEVICE_ADD(_tag, IEEE488, 0) \
24   MCFG_DEVICE_CONFIG(_daisy_chain)
20//**************************************************************************
21//  MACROS / CONSTANTS
22//**************************************************************************
2523
24#define IEEE488_TAG         "ieee_bus"
25#define IEEE488_STUB_TAG   "ieee_stub"
26
27
28
29//**************************************************************************
30//  INTERFACE CONFIGURATION MACROS
31//**************************************************************************
32
33#define MCFG_IEEE488_ADD(_daisy) \
34    MCFG_DEVICE_ADD(IEEE488_STUB_TAG, IEEE488_STUB, 0) \
35   MCFG_DEVICE_CONFIG(default_ieee488_stub_interface) \
36   MCFG_DEVICE_ADD(IEEE488_TAG, IEEE488, 0) \
37   MCFG_DEVICE_CONFIG(_daisy)
38
39
40#define MCFG_IEEE488_CONFIG_ADD(_daisy, _config) \
41    MCFG_DEVICE_ADD(IEEE488_STUB_TAG, IEEE488_STUB, 0) \
42   MCFG_DEVICE_CONFIG(_config) \
43   MCFG_DEVICE_ADD(IEEE488_TAG, IEEE488, 0) \
44   MCFG_DEVICE_CONFIG(_daisy)
45
46
47#define MCFG_IEEE488_REMOVE() \
48   MCFG_DEVICE_REMOVE(IEEE488_STUB_TAG) \
49   MCFG_DEVICE_REMOVE(IEEE488_TAG)
50
51
2652#define IEEE488_DAISY(_name) \
27   const ieee488_daisy_chain (_name)[] =
53   const ieee488_config (_name)[] =
2854
29/***************************************************************************
30    TYPE DEFINITIONS
31***************************************************************************/
3255
33typedef struct _ieee488_daisy_chain ieee488_daisy_chain;
34struct _ieee488_daisy_chain
56#define IEEE488_INTERFACE(_name) \
57   const ieee488_stub_interface (_name) =
58
59
60
61//**************************************************************************
62//  TYPE DEFINITIONS
63//**************************************************************************
64
65// ======================> ieee488_config
66
67struct ieee488_config
3568{
36   const char *tag;   /* device tag */
69   const char *m_tag;
70};
3771
38   devcb_write_line   out_eoi_func;
39   devcb_write_line   out_dav_func;
40   devcb_write_line   out_nrfd_func;
41   devcb_write_line   out_ndac_func;
42   devcb_write_line   out_ifc_func;
43   devcb_write_line   out_srq_func;
44   devcb_write_line   out_atn_func;
45   devcb_write_line   out_ren_func;
72
73// ======================> device_config_ieee488_interface
74
75// device_config_ieee488_interface represents configuration information for a ieee488 device
76class device_config_ieee488_interface : public device_config_interface
77{
78public:
79   // construction/destruction
80   device_config_ieee488_interface(const machine_config &mconfig, device_config &devconfig);
81   virtual ~device_config_ieee488_interface();
4682};
4783
48/***************************************************************************
49    PROTOTYPES
50***************************************************************************/
51/* end or identify */
52void ieee488_eoi_w(device_t *bus, device_t *device, int state);
53READ_LINE_DEVICE_HANDLER( ieee488_eoi_r );
5484
55/* data valid */
56void ieee488_dav_w(device_t *bus, device_t *device, int state);
57READ_LINE_DEVICE_HANDLER( ieee488_dav_r );
85// ======================> device_ieee488_interface
5886
59/* not ready for data */
60void ieee488_nrfd_w(device_t *bus, device_t *device, int state);
61READ_LINE_DEVICE_HANDLER( ieee488_nrfd_r );
87class device_ieee488_interface : public device_interface
88{
89public:
90   // construction/destruction
91   device_ieee488_interface(running_machine &machine, const device_config &config, device_t &device);
92   virtual ~device_ieee488_interface();
6293
63/* not data accepted */
64void ieee488_ndac_w(device_t *bus, device_t *device, int state);
65READ_LINE_DEVICE_HANDLER( ieee488_ndac_r );
94   // optional operation overrides
95   virtual void ieee488_eoi(int state) { };
96   virtual void ieee488_dav(int state) { };
97   virtual void ieee488_nrfd(int state) { };
98   virtual void ieee488_ndac(int state) { };
99   virtual void ieee488_ifc(int state) { };
100   virtual void ieee488_srq(int state) { };
101   virtual void ieee488_atn(int state) { };
102   virtual void ieee488_ren(int state) { };
66103
67/* interface clear */
68void ieee488_ifc_w(device_t *bus, device_t *device, int state);
69READ_LINE_DEVICE_HANDLER( ieee488_ifc_r );
104protected:
105   const device_config_ieee488_interface &m_ieee488_config;
106};
70107
71/* service request */
72void ieee488_srq_w(device_t *bus, device_t *device, int state);
73READ_LINE_DEVICE_HANDLER( ieee488_srq_r );
74108
75/* attention */
76void ieee488_atn_w(device_t *bus, device_t *device, int state);
77READ_LINE_DEVICE_HANDLER( ieee488_atn_r );
109// ======================> ieee488_device_config
78110
79/* remote enable */
80void ieee488_ren_w(device_t *bus, device_t *device, int state);
81READ_LINE_DEVICE_HANDLER( ieee488_ren_r );
111class ieee488_device_config :   public device_config,
112                         public ieee488_config
113{
114    friend class ieee488_device;
82115
83/* data */
84READ8_DEVICE_HANDLER( ieee488_dio_r );
85void ieee488_dio_w(device_t *bus, device_t *device, UINT8 data);
116    // construction/destruction
117    ieee488_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
86118
119public:
120    // allocators
121    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
122    virtual device_t *alloc_device(running_machine &machine) const;
123
124protected:
125    // device_config overrides
126    virtual void device_config_complete();
127
128private:
129   const ieee488_config *m_daisy;
130};
131
132
133// ======================> ieee488_device
134
135class ieee488_stub_device;
136
137class ieee488_device :  public device_t
138{
139    friend class ieee488_device_config;
140
141    // construction/destruction
142    ieee488_device(running_machine &_machine, const ieee488_device_config &_config);
143
144public:
145   // reads for both host and peripherals
146   UINT8 dio_r();
147   READ8_MEMBER( dio_r );
148   DECLARE_READ_LINE_MEMBER( eoi_r );
149   DECLARE_READ_LINE_MEMBER( dav_r );
150   DECLARE_READ_LINE_MEMBER( nrfd_r );
151   DECLARE_READ_LINE_MEMBER( ndac_r );
152   DECLARE_READ_LINE_MEMBER( ifc_r );
153   DECLARE_READ_LINE_MEMBER( srq_r );
154   DECLARE_READ_LINE_MEMBER( atn_r );
155   DECLARE_READ_LINE_MEMBER( ren_r );
156
157   // writes for host (driver_device)
158   void dio_w(UINT8 data);
159   WRITE8_MEMBER( dio_w );
160   DECLARE_WRITE_LINE_MEMBER( eoi_w );
161   DECLARE_WRITE_LINE_MEMBER( dav_w );
162   DECLARE_WRITE_LINE_MEMBER( nrfd_w );
163   DECLARE_WRITE_LINE_MEMBER( ndac_w );
164   DECLARE_WRITE_LINE_MEMBER( ifc_w );
165   DECLARE_WRITE_LINE_MEMBER( srq_w );
166   DECLARE_WRITE_LINE_MEMBER( atn_w );
167   DECLARE_WRITE_LINE_MEMBER( ren_w );
168
169   // writes for peripherals (device_t)
170   void dio_w(device_t *device, UINT8 data);
171   void eoi_w(device_t *device, int state);
172   void dav_w(device_t *device, int state);
173   void nrfd_w(device_t *device, int state);
174   void ndac_w(device_t *device, int state);
175   void ifc_w(device_t *device, int state);
176   void srq_w(device_t *device, int state);
177   void atn_w(device_t *device, int state);
178   void ren_w(device_t *device, int state);
179
180protected:
181   enum
182   {
183      EOI = 0,
184      DAV,
185      NRFD,
186      NDAC,
187      IFC,
188      SRQ,
189      ATN,
190      REN,
191      SIGNAL_COUNT
192   };
193
194   // device-level overrides
195    virtual void device_start();
196
197   class daisy_entry
198   {
199   public:
200      daisy_entry(device_t *device);
201
202      daisy_entry *            m_next;         // next device
203      device_t *               m_device;      // associated device
204      device_ieee488_interface *   m_interface;   // associated device's daisy interface
205
206      int m_line[SIGNAL_COUNT];
207      UINT8 m_dio;
208   };
209
210   daisy_entry *         m_daisy_list;   // head of the daisy chain
211
212private:
213   inline void set_signal(device_t *device, int signal, int state);
214   inline int get_signal(int signal);
215   inline void set_data(device_t *device, UINT8 data);
216   inline UINT8 get_data();
217
218   required_device<ieee488_stub_device> m_stub;
219
220    const ieee488_device_config &m_config;
221};
222
223
224// ======================> ieee488_stub_interface
225
226struct ieee488_stub_interface
227{
228   devcb_write_line   m_out_eoi_func;
229   devcb_write_line   m_out_dav_func;
230   devcb_write_line   m_out_nrfd_func;
231   devcb_write_line   m_out_ndac_func;
232   devcb_write_line   m_out_ifc_func;
233   devcb_write_line   m_out_srq_func;
234   devcb_write_line   m_out_atn_func;
235   devcb_write_line   m_out_ren_func;
236};
237
238const ieee488_stub_interface default_ieee488_stub_interface = { DEVCB_NULL, };
239
240
241// ======================> ieee488_stub_device_config
242
243class ieee488_stub_device_config :   public device_config,
244                            public ieee488_stub_interface,
245                            public device_config_ieee488_interface
246{
247    friend class ieee488_stub_device;
248
249    // construction/destruction
250    ieee488_stub_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
251
252public:
253    // allocators
254    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
255    virtual device_t *alloc_device(running_machine &machine) const;
256
257protected:
258    // device_config overrides
259    virtual void device_config_complete();
260};
261
262
263// ======================> ieee488_stub_device
264
265class ieee488_stub_device :  public device_t,
266                      public device_ieee488_interface
267{
268    friend class ieee488_stub_device_config;
269
270    // construction/destruction
271    ieee488_stub_device(running_machine &_machine, const ieee488_stub_device_config &_config);
272
273protected:
274    // device-level overrides
275    virtual void device_start();
276
277   // device_ieee488_interface overrides
278   void ieee488_eoi(int state);
279   void ieee488_dav(int state);
280   void ieee488_nrfd(int state);
281   void ieee488_ndac(int state);
282   void ieee488_ifc(int state);
283   void ieee488_srq(int state);
284   void ieee488_atn(int state);
285   void ieee488_ren(int state);
286
287private:
288   devcb_resolved_write_line   m_out_eoi_func;
289   devcb_resolved_write_line   m_out_dav_func;
290   devcb_resolved_write_line   m_out_nrfd_func;
291   devcb_resolved_write_line   m_out_ndac_func;
292   devcb_resolved_write_line   m_out_ifc_func;
293   devcb_resolved_write_line   m_out_srq_func;
294   devcb_resolved_write_line   m_out_atn_func;
295   devcb_resolved_write_line   m_out_ren_func;
296
297    const ieee488_stub_device_config &m_config;
298};
299
300
301// device type definition
302extern const device_type IEEE488;
303extern const device_type IEEE488_STUB;
304
305
87306#endif
src/mess/includes/vixen.h
r11262r11263
1111#define P8155H_IO_TAG   "c7"
1212#define P8251A_TAG      "c3"
1313#define DISCRETE_TAG   "discrete"
14#define IEEE488_TAG      "j9"
1514#define SCREEN_TAG      "screen"
1615
1716class vixen_state : public driver_device
r11262r11263
4140   required_device<device_t> m_io_i8155;
4241   required_device<device_t> m_usart;
4342   required_device<device_t> m_discrete;
44   required_device<device_t> m_ieee488;
43   required_device<ieee488_device> m_ieee488;
4544   required_device<device_t> m_ram;
4645   required_device<device_t> m_floppy0;
4746   required_device<device_t> m_floppy1;
r11262r11263
5756   DECLARE_WRITE8_MEMBER( ctl_w );
5857   DECLARE_READ8_MEMBER( status_r );
5958   DECLARE_WRITE8_MEMBER( cmd_w );
59   DECLARE_READ8_MEMBER( ieee488_r );
6060   DECLARE_READ8_MEMBER( port3_r );
6161   DECLARE_READ8_MEMBER( i8155_pa_r );
6262   DECLARE_WRITE8_MEMBER( i8155_pb_w );
6363   DECLARE_WRITE8_MEMBER( i8155_pc_w );
64   DECLARE_WRITE8_MEMBER( io_i8155_pa_w );
6564   DECLARE_WRITE8_MEMBER( io_i8155_pb_w );
6665   DECLARE_WRITE8_MEMBER( io_i8155_pc_w );
6766   DECLARE_WRITE_LINE_MEMBER( io_i8155_to_w );
src/mess/includes/cbmb.h
r11262r11263
1313
1414#include "video/mc6845.h"
1515#include "machine/6526cia.h"
16#include "machine/ieee488.h"
1617#include "imagedev/cartslot.h"
1718
1819class cbmb_state : public driver_device
1920{
2021public:
2122   cbmb_state(running_machine &machine, const driver_device_config_base &config)
22      : driver_device(machine, config) { }
23      : driver_device(machine, config),
24        m_ieee(*this, IEEE488_TAG)
25   { }
2326
27   required_device<ieee488_device> m_ieee;
28
2429   /* keyboard lines */
2530   int m_cbmb_keyline_a;
2631   int m_cbmb_keyline_b;
src/mess/includes/victor9k.h
r11262r11263
3838#define M6522_6_TAG      "m6522_6"
3939#define SPEAKER_TAG      "speaker"
4040#define CENTRONICS_TAG   "centronics"
41#define IEEE488_TAG      "ieee488"
4241
4342class victor9k_state : public driver_device
4443{
r11262r11263
6059
6160   required_device<cpu_device> m_maincpu;
6261   required_device<cpu_device> m_fdc_cpu;
63   required_device<device_t> m_ieee488;
62   required_device<ieee488_device> m_ieee488;
6463   required_device<device_t> m_pic;
6564   required_device<mc6852_device> m_ssda;
6665   required_device<device_t> m_via1;
r11262r11263
8382   DECLARE_WRITE_LINE_MEMBER( via5_irq_w );
8483   DECLARE_WRITE_LINE_MEMBER( via6_irq_w );
8584   DECLARE_WRITE8_MEMBER( via1_pa_w );
85   DECLARE_READ8_MEMBER( via1_pb_r );
8686   DECLARE_WRITE8_MEMBER( via1_pb_w );
8787   DECLARE_WRITE_LINE_MEMBER( codec_vol_w );
8888   DECLARE_READ8_MEMBER( via2_pa_r );
src/mess/includes/pet.h
r11262r11263
1010#include "video/mc6845.h"
1111#include "machine/6821pia.h"
1212#include "machine/6522via.h"
13#include "machine/ieee488.h"
1314#include "imagedev/cartslot.h"
1415
1516typedef struct
r11262r11263
2324{
2425public:
2526   pet_state(running_machine &machine, const driver_device_config_base &config)
26      : driver_device(machine, config) { }
27      : driver_device(machine, config),
28        m_ieee(*this, IEEE488_TAG)
29   { }
2730
31   required_device<ieee488_device> m_ieee;
32
2833   int m_pet_basic1; /* basic version 1 for quickloader */
2934   int m_superpet;
3035   int m_cbm8096;
src/mess/includes/tek405x.h
r11262r11263
1313#define MC6820_GPIB_TAG      "u265"
1414#define MC6820_COM_TAG      "u5"
1515#define MC6850_TAG         "u25"
16#define IEEE488_TAG         "ieee488"
1716#define RS232_TAG         "rs232"
1817#define SPEAKER_TAG         "speaker"
1918#define SCREEN_TAG         "screen"
r11262r11263
2928        m_gpib_pia(*this, MC6820_GPIB_TAG),
3029        m_com_pia(*this, MC6820_COM_TAG),
3130        m_acia(*this, MC6850_TAG),
32        m_ieee(*this, IEEE488_TAG),
31        m_gpib(*this, IEEE488_TAG),
3332        m_speaker(*this, SPEAKER_TAG),
3433        m_ram(*this, RAM_TAG)
3534    { }
r11262r11263
3837   required_device<device_t> m_gpib_pia;
3938   required_device<device_t> m_com_pia;
4039   required_device<acia6850_device> m_acia;
41   required_device<device_t> m_ieee;
40   required_device<ieee488_device> m_gpib;
4241   required_device<device_t> m_speaker;
4342   required_device<device_t> m_ram;
4443
src/mess/mess.mak
r11262r11263
513513   $(MESS_MACHINE)/i82439tx.o   \
514514   $(MESS_MACHINE)/i8271.o      \
515515   $(MESS_MACHINE)/ieee488.o   \
516   $(MESS_MACHINE)/ieeestub.o   \
516517   $(MESS_MACHINE)/isa.o      \
517518   $(MESS_MACHINE)/kb3600.o   \
518519   $(MESS_MACHINE)/kr2376.o   \
r11262r11263
764765   $(MESS_MACHINE)/c1571.o      \
765766   $(MESS_MACHINE)/c1581.o      \
766767   $(MESS_MACHINE)/c2040.o      \
767   $(MESS_MACHINE)/c8280.o      \
768   $(MESS_MACHINE)/c9060.o      \
769768   $(MESS_DRIVERS)/clcd.o      \
770769   $(MESS_MACHINE)/6525tpi.o   \
771770   $(MESS_MACHINE)/cbm.o      \
r11262r11263
782781   $(MESS_FORMATS)/d81_dsk.o   \
783782   $(MESS_FORMATS)/cbm_tap.o   \
784783   $(MESS_FORMATS)/cbm_snqk.o   \
784#   $(MESS_MACHINE)/c8280.o      \
785#   $(MESS_MACHINE)/c9060.o      \
785786
786787$(MESSOBJ)/cccp.a:            \
787788   $(MESS_DRIVERS)/argo.o      \
src/mess/drivers/cbmb.c
r11262r11263
413413
414414static IEEE488_DAISY( ieee488_daisy )
415415{
416   { "tpi6525_0" },
417   { "cia" },
418   { C2040_IEEE488("drive") },
416   { "drive" },
419417   { NULL}
420418};
421419
r11262r11263
459457   MCFG_TPI6525_ADD("tpi6525_1", cbmb_tpi_1_intf)
460458
461459   /* IEEE bus */
462   MCFG_IEEE488_ADD("ieee_bus", ieee488_daisy)
463   MCFG_C8250_ADD("drive", "ieee_bus", 8)
460   MCFG_IEEE488_ADD(ieee488_daisy)
461   MCFG_C8250_ADD("drive", 8)
464462
465463   MCFG_FRAGMENT_ADD(cbmb_cartslot)
466464MACHINE_CONFIG_END
r11262r11263
535533   MCFG_TPI6525_ADD("tpi6525_1", cbmb_tpi_1_intf)
536534
537535   /* IEEE bus */
538   MCFG_IEEE488_ADD("ieee_bus", ieee488_daisy)
539   MCFG_C8250_ADD("drive", "ieee_bus", 8)
536   MCFG_IEEE488_ADD(ieee488_daisy)
537   MCFG_C8250_ADD("drive", 8)
540538
541539   MCFG_FRAGMENT_ADD(cbmb_cartslot)
542540MACHINE_CONFIG_END
src/mess/drivers/vic20.c
r11262r11263
451451#ifdef INCLUDE_C2031
452452static IEEE488_DAISY( ieee488_daisy )
453453{
454   { VIC1112_IEEE488 },
455   { C2031_IEEE488(C2031_TAG) },
454   { C2031_TAG },
456455   { NULL}
457456};
458457
r11262r11263
698697#ifdef INCLUDE_C2031
699698    MCFG_IEEE488_ADD(IEEE488_TAG, ieee488_daisy)
700699    MCFG_VIC1112_ADD(vic1112_intf)
701    MCFG_C2031_ADD(C2031_TAG, IEEE488_TAG, 9)
700    MCFG_C2031_ADD(C2031_TAG, 9)
702701#endif
703702   MCFG_CARTSLOT_ADD("cart")
704703   MCFG_CARTSLOT_EXTENSION_LIST("20,40,60,70,a0,b0")
src/mess/drivers/pet.c
r11262r11263
648648
649649static IEEE488_DAISY( ieee488_daisy )
650650{
651   { "pia_0" },
652   { "pia_1", DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE("pia_1", pia6821_cb1_w), DEVCB_DEVICE_LINE("pia_1", pia6821_ca1_w), DEVCB_NULL },
653   { "via6522_0" },
654   { C2040_IEEE488("drive") },
651   { "drive" },
655652   { NULL}
656653};
657654
655static IEEE488_INTERFACE( ieee488_intf )
656{
657   DEVCB_NULL,
658   DEVCB_NULL,
659   DEVCB_NULL,
660   DEVCB_NULL,
661   DEVCB_NULL,
662   DEVCB_DEVICE_LINE("pia_1", pia6821_cb1_w),
663   DEVCB_DEVICE_LINE("pia_1", pia6821_ca1_w),
664   DEVCB_NULL
665};
666
667
658668/*************************************
659669 *
660670 *  Machine driver
r11262r11263
705715   MCFG_RAM_EXTRA_OPTIONS("8K,16K")
706716
707717   /* IEEE bus */
708   MCFG_IEEE488_ADD("ieee_bus", ieee488_daisy)
709   MCFG_C4040_ADD("drive", "ieee_bus", 8)
718   MCFG_IEEE488_CONFIG_ADD(ieee488_daisy, ieee488_intf)
719   MCFG_C4040_ADD("drive", 8)
710720MACHINE_CONFIG_END
711721
712722
r11262r11263
724734   MCFG_RAM_EXTRA_OPTIONS("4K")
725735
726736   /* IEEE bus */
727   MCFG_IEEE488_ADD("ieee_bus", ieee488_daisy)
728   MCFG_C4040_ADD("drive", "ieee_bus", 8)
737   MCFG_IEEE488_CONFIG_ADD(ieee488_daisy, ieee488_intf)
738   MCFG_C4040_ADD("drive", 8)
729739MACHINE_CONFIG_END
730740
731741
r11262r11263
778788   MCFG_RAM_DEFAULT_SIZE("32K")
779789
780790   /* IEEE bus */
781   MCFG_IEEE488_ADD("ieee_bus", ieee488_daisy)
782   MCFG_C8050_ADD("drive", "ieee_bus", 8)
791   MCFG_IEEE488_CONFIG_ADD(ieee488_daisy, ieee488_intf)
792   MCFG_C8050_ADD("drive", 8)
783793MACHINE_CONFIG_END
784794
785795
src/mess/drivers/victor9k.c
r11262r11263
6262/* Input Ports */
6363
6464static INPUT_PORTS_START( victor9k )
65   PORT_START("IEEE488")
66   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_dav_r)
67   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_eoi_r)
68   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_ren_r)
69   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_atn_r)
70   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_ifc_r)
71   PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_srq_r)
72   PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_nrfd_r)
73   PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_ndac_r)
7465INPUT_PORTS_END
7566
7667/* Video */
r11262r11263
272263
273264    */
274265
275   ieee488_dio_w(m_ieee488, m_via1, data);
266   m_ieee488->dio_w(data);
276267}
277268
269READ8_MEMBER( victor9k_state::via1_pb_r )
270{
271   /*
272
273        bit     description
274
275        PB0     DAV
276        PB1     EOI
277        PB2     REN
278        PB3     ATN
279        PB4     IFC
280        PB5     SRQ
281        PB6     NRFD
282        PB7     NDAC
283
284    */
285
286   UINT8 data = 0;
287
288   /* data valid */
289   data |= m_ieee488->dav_r();
290
291   /* end or identify */
292   data |= m_ieee488->eoi_r() << 1;
293
294   /* remote enable */
295   data |= m_ieee488->ren_r() << 2;
296
297   /* attention */
298   data |= m_ieee488->atn_r() << 3;
299
300   /* interface clear */
301   data |= m_ieee488->ifc_r() << 4;
302
303   /* service request */
304   data |= m_ieee488->srq_r() << 5;
305
306   /* not ready for data */
307   data |= m_ieee488->nrfd_r() << 6;
308
309   /* data not accepted */
310   data |= m_ieee488->ndac_r() << 7;
311
312   return data;
313}
314
278315WRITE8_MEMBER( victor9k_state::via1_pb_w )
279316{
280317   /*
r11262r11263
293330    */
294331
295332   /* data valid */
296   ieee488_dav_w(m_ieee488, m_via1, BIT(data, 0));
333   m_ieee488->dav_w(BIT(data, 0));
297334
298335   /* end or identify */
299   ieee488_eoi_w(m_ieee488, m_via1, BIT(data, 1));
336   m_ieee488->eoi_w(BIT(data, 1));
300337
301338   /* remote enable */
302   ieee488_ren_w(m_ieee488, m_via1, BIT(data, 2));
339   m_ieee488->ren_w(BIT(data, 2));
303340
304341   /* attention */
305   ieee488_atn_w(m_ieee488, m_via1, BIT(data, 3));
342   m_ieee488->atn_w(BIT(data, 3));
306343
307344   /* interface clear */
308   ieee488_ifc_w(m_ieee488, m_via1, BIT(data, 4));
345   m_ieee488->ifc_w(BIT(data, 4));
309346
310347   /* service request */
311   ieee488_srq_w(m_ieee488, m_via1, BIT(data, 5));
348   m_ieee488->srq_w(BIT(data, 5));
312349
313350   /* not ready for data */
314   ieee488_nrfd_w(m_ieee488, m_via1, BIT(data, 6));
351   m_ieee488->nrfd_w(BIT(data, 6));
315352
316353   /* data not accepted */
317   ieee488_ndac_w(m_ieee488, m_via1, BIT(data, 7));
354   m_ieee488->ndac_w(BIT(data, 7));
318355}
319356
320357WRITE_LINE_MEMBER( victor9k_state::codec_vol_w )
r11262r11263
330367
331368static const via6522_interface via1_intf =
332369{
333   DEVCB_DEVICE_HANDLER(IEEE488_TAG, ieee488_dio_r),
334   DEVCB_INPUT_PORT("IEEE488"),
335   DEVCB_DEVICE_LINE(IEEE488_TAG, ieee488_nrfd_r),
370   DEVCB_DEVICE_MEMBER(IEEE488_TAG, ieee488_device, dio_r),
371   DEVCB_DRIVER_MEMBER(victor9k_state, via1_pb_r),
372   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, nrfd_r),
336373   DEVCB_NULL,
337   DEVCB_DEVICE_LINE(IEEE488_TAG, ieee488_ndac_r),
374   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, ndac_r),
338375   DEVCB_NULL,
339376
340377   DEVCB_DRIVER_MEMBER(victor9k_state, via1_pa_w),
r11262r11263
845882
846883static IEEE488_DAISY( ieee488_daisy )
847884{
848   { M6522_1_TAG, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_ca1), DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_ca2) },
849885   { NULL }
850886};
851887
888static IEEE488_INTERFACE( ieee488_intf )
889{
890   DEVCB_NULL,
891   DEVCB_NULL,
892   DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_ca1),
893   DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_ca2),
894   DEVCB_NULL,
895   DEVCB_NULL,
896   DEVCB_NULL,
897   DEVCB_NULL
898};
899
852900/* Machine Initialization */
853901
854902static IRQ_CALLBACK( victor9k_irq_callback )
r11262r11263
904952   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
905953
906954   /* devices */
907   MCFG_IEEE488_ADD(IEEE488_TAG, ieee488_daisy)
955   MCFG_IEEE488_CONFIG_ADD(ieee488_daisy, ieee488_intf)
908956   MCFG_PIC8259_ADD(I8259A_TAG, pic_intf)
909957   MCFG_PIT8253_ADD(I8253_TAG, pit_intf)
910958   MCFG_UPD7201_ADD(UPD7201_TAG, XTAL_30MHz/30, mpsc_intf)
src/mess/drivers/tek405x.c
r11262r11263
706706   output_set_led_value(3, !BIT(data, 7));
707707
708708   // end or identify
709   ieee488_eoi_w(m_ieee, m_gpib_pia, !BIT(data, 4));
709   m_gpib->eoi_w(!BIT(data, 4));
710710
711711   // speaker
712712   speaker_level_w(m_speaker, !BIT(data, 7));
713713
714714   // remote enable
715   ieee488_ren_w(m_ieee, m_gpib_pia, !BIT(data, 7));
715   m_gpib->ren_w(!BIT(data, 7));
716716}
717717
718718READ_LINE_MEMBER( tek4051_state::key_r )
r11262r11263
885885
886886   if (m_talk)
887887   {
888      ieee488_dio_w(m_ieee, m_gpib_pia, data);
888      m_gpib->dio_w(data);
889889   }
890890}
891891
r11262r11263
909909   UINT8 data = 0;
910910
911911   // service request
912   data |= ieee488_srq_r(m_ieee) << 5;
912   data |= m_gpib->srq_r() << 5;
913913
914914   // data valid
915   data |= ieee488_dav_r(m_ieee) << 6;
915   data |= m_gpib->dav_r() << 6;
916916
917917   if (!m_talk)
918918   {
919919      // not ready for data
920      data |= ieee488_nrfd_r(m_ieee) << 4;
920      data |= m_gpib->nrfd_r() << 4;
921921
922922      // not data acknowledged
923      data |= ieee488_ndac_r(m_ieee) << 7;
923      data |= m_gpib->ndac_r() << 7;
924924   }
925925
926926   return data;
r11262r11263
944944    */
945945
946946   // end or identify
947   ieee488_eoi_w(m_ieee, m_gpib_pia, !BIT(data, 0));
947   m_gpib->eoi_w(!BIT(data, 0));
948948
949949   // interface clear
950   ieee488_ifc_w(m_ieee, m_gpib_pia, !BIT(data, 1));
950   m_gpib->ifc_w(!BIT(data, 1));
951951
952952   // attention
953   ieee488_atn_w(m_ieee, m_gpib_pia, BIT(data, 3));
953   m_gpib->atn_w(BIT(data, 3));
954954
955955   if (m_talk)
956956   {
957957      // not ready for data
958      ieee488_nrfd_w(m_ieee, m_gpib_pia, !BIT(data, 4));
958      m_gpib->nrfd_w(!BIT(data, 4));
959959
960960      // not data acknowledged
961      ieee488_ndac_w(m_ieee, m_gpib_pia, !BIT(data, 7));
961      m_gpib->ndac_w(!BIT(data, 7));
962962   }
963963}
964964
r11262r11263
968968
969969   if (!m_talk)
970970   {
971      ieee488_dio_w(m_ieee, m_gpib_pia, 0xff);
972      ieee488_nrfd_w(m_ieee, m_gpib_pia, 1);
973      ieee488_ndac_w(m_ieee, m_gpib_pia, 1);
971      m_gpib->dio_w(0xff);
972      m_gpib->nrfd_w(1);
973      m_gpib->ndac_w(1);
974974   }
975975}
976976
r11262r11263
988988
989989static const pia6821_interface gpib_pia_intf =
990990{
991   DEVCB_DEVICE_HANDLER(IEEE488_TAG, ieee488_dio_r),
991   DEVCB_DEVICE_MEMBER(IEEE488_TAG, ieee488_device, dio_r),
992992   DEVCB_DRIVER_MEMBER(tek4051_state, gpib_pia_pb_r),
993   DEVCB_DEVICE_LINE(IEEE488_TAG, ieee488_eoi_r),
994   DEVCB_DEVICE_LINE(IEEE488_TAG, ieee488_srq_r),
993   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, eoi_r),
994   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, srq_r),
995995   DEVCB_NULL,
996996   DEVCB_NULL,
997997   DEVCB_DRIVER_MEMBER(tek4051_state, dio_w),
r11262r11263
11491149
11501150static IEEE488_DAISY( ieee488_daisy )
11511151{
1152   { MC6820_GPIB_TAG },
11531152   { NULL}
11541153};
11551154
r11262r11263
12371236   MCFG_PIA6821_ADD(MC6820_GPIB_TAG, gpib_pia_intf)
12381237   MCFG_PIA6821_ADD(MC6820_COM_TAG, com_pia_intf)
12391238   MCFG_ACIA6850_ADD(MC6850_TAG, acia_intf)
1240   MCFG_IEEE488_ADD(IEEE488_TAG, ieee488_daisy)
1239   MCFG_IEEE488_ADD(ieee488_daisy)
12411240   //MCFG_RS232_ADD(RS232_TAG, rs232_intf)
12421241
12431242   // internal ram
src/mess/drivers/vixen.c
r11262r11263
172172
173173
174174//-------------------------------------------------
175//  ieee488_r - IEEE488 bus read
176//-------------------------------------------------
177
178READ8_MEMBER( vixen_state::ieee488_r )
179{
180   /*
181
182        bit     description
183
184        0       ATN
185        1      DAV
186        2      NDAC
187        3      NRFD
188        4      EOI
189        5      SRQ
190        6      IFC
191        7      REN
192
193    */
194
195   UINT8 data = 0;
196
197   /* attention */
198   data |= m_ieee488->atn_r();
199
200   /* data valid */
201   data |= m_ieee488->dav_r() << 1;
202
203   /* data not accepted */
204   data |= m_ieee488->ndac_r() << 2;
205
206   /* not ready for data */
207   data |= m_ieee488->nrfd_r() << 3;
208
209   /* end or identify */
210   data |= m_ieee488->eoi_r() << 4;
211
212   /* service request */
213   data |= m_ieee488->srq_r() << 5;
214
215   /* interface clear */
216   data |= m_ieee488->ifc_r() << 6;
217
218   /* remote enable */
219   data |= m_ieee488->ren_r() << 7;
220
221   return data;
222}
223
224
225//-------------------------------------------------
175226//  port3_r - serial status read
176227//-------------------------------------------------
177228
r11262r11263
231282   AM_RANGE(0x04, 0x04) AM_MIRROR(0x03) AM_READWRITE(status_r, cmd_w)
232283   AM_RANGE(0x08, 0x08) AM_MIRROR(0x01) AM_DEVREADWRITE(P8155H_TAG, i8155_device, read, write)
233284   AM_RANGE(0x0c, 0x0d) AM_DEVWRITE(P8155H_TAG, i8155_device, ale_w)
234   AM_RANGE(0x10, 0x10) AM_MIRROR(0x07) AM_DEVREAD_LEGACY(IEEE488_TAG, ieee488_dio_r)
235   AM_RANGE(0x18, 0x18) AM_MIRROR(0x07) AM_READ_PORT("IEEE488")
285   AM_RANGE(0x10, 0x10) AM_MIRROR(0x07) AM_DEVREAD(IEEE488_TAG, ieee488_device, dio_r)
286   AM_RANGE(0x18, 0x18) AM_MIRROR(0x07) AM_READ(ieee488_r)
236287   AM_RANGE(0x20, 0x21) AM_MIRROR(0x04) AM_DEVWRITE(P8155H_IO_TAG, i8155_device, ale_w)
237288   AM_RANGE(0x28, 0x28) AM_MIRROR(0x05) AM_DEVREADWRITE(P8155H_IO_TAG, i8155_device, read, write)
238289   AM_RANGE(0x30, 0x30) AM_MIRROR(0x06) AM_DEVREADWRITE_LEGACY(P8251A_TAG, msm8251_data_r, msm8251_data_w)
r11262r11263
331382   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
332383   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
333384   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
334
335   PORT_START("IEEE488")
336   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_atn_r)
337   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_dav_r)
338   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_ndac_r)
339   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_nrfd_r)
340   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_eoi_r)
341   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_srq_r)
342   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_ifc_r)
343   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(IEEE488_TAG, ieee488_ren_r)
344385INPUT_PORTS_END
345386
346387
r11262r11263
366407
367408
368409//-------------------------------------------------
369//  VIDEO_START( vixenc )
410//  VIDEO_START( vixen )
370411//-------------------------------------------------
371412
372413void vixen_state::video_start()
r11262r11263
536577//  I8155_INTERFACE( io_i8155_intf )
537578//-------------------------------------------------
538579
539WRITE8_MEMBER( vixen_state::io_i8155_pa_w )
540{
541   ieee488_dio_w(m_ieee488, m_io_i8155, data);
542}
543
544580WRITE8_MEMBER( vixen_state::io_i8155_pb_w )
545581{
546582   /*
r11262r11263
559595    */
560596
561597   /* data valid */
562   ieee488_atn_w(m_ieee488, m_io_i8155, BIT(data, 0));
598   m_ieee488->atn_w(BIT(data, 0));
563599
564600   /* end or identify */
565   ieee488_dav_w(m_ieee488, m_io_i8155, BIT(data, 1));
601   m_ieee488->dav_w(BIT(data, 1));
566602
567603   /* remote enable */
568   ieee488_ndac_w(m_ieee488, m_io_i8155, BIT(data, 2));
604   m_ieee488->ndac_w(BIT(data, 2));
569605
570606   /* attention */
571   ieee488_nrfd_w(m_ieee488, m_io_i8155, BIT(data, 3));
607   m_ieee488->nrfd_w(BIT(data, 3));
572608
573609   /* interface clear */
574   ieee488_eoi_w(m_ieee488, m_io_i8155, BIT(data, 4));
610   m_ieee488->eoi_w(BIT(data, 4));
575611
576612   /* service request */
577   ieee488_srq_w(m_ieee488, m_io_i8155, BIT(data, 5));
613   m_ieee488->srq_w(BIT(data, 5));
578614
579615   /* not ready for data */
580   ieee488_ifc_w(m_ieee488, m_io_i8155, BIT(data, 6));
616   m_ieee488->ifc_w(BIT(data, 6));
581617
582618   /* data not accepted */
583   ieee488_ren_w(m_ieee488, m_io_i8155, BIT(data, 7));
619   m_ieee488->ren_w(BIT(data, 7));
584620}
585621
586622WRITE8_MEMBER( vixen_state::io_i8155_pc_w )
r11262r11263
620656static I8155_INTERFACE( io_i8155_intf )
621657{
622658    DEVCB_NULL,
623   DEVCB_DRIVER_MEMBER(vixen_state, io_i8155_pa_w),
659   DEVCB_DEVICE_MEMBER(IEEE488_TAG, ieee488_device, dio_w),
624660    DEVCB_NULL,
625661   DEVCB_DRIVER_MEMBER(vixen_state, io_i8155_pb_w),
626662   DEVCB_NULL,
r11262r11263
677713
678714static IEEE488_DAISY( ieee488_daisy )
679715{
680   { P8155H_IO_TAG, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_DRIVER_LINE_MEMBER(vixen_state, srq_w), DEVCB_DRIVER_LINE_MEMBER(vixen_state, atn_w), DEVCB_NULL },
681716   { NULL }
682717};
683718
719static IEEE488_INTERFACE( ieee488_intf )
720{
721   DEVCB_NULL,
722   DEVCB_NULL,
723   DEVCB_NULL,
724   DEVCB_NULL,
725   DEVCB_NULL,
726   DEVCB_DRIVER_LINE_MEMBER(vixen_state, srq_w),
727   DEVCB_DRIVER_LINE_MEMBER(vixen_state, atn_w),
728   DEVCB_NULL
729};
684730
731
685732//-------------------------------------------------
686733//  wd17xx_interface fdc_intf
687734//-------------------------------------------------
r11262r11263
821868   MCFG_MSM8251_ADD(P8251A_TAG, usart_intf)
822869   MCFG_WD179X_ADD(FDC1797_TAG, fdc_intf)
823870   MCFG_FLOPPY_2_DRIVES_ADD(vixen_floppy_config)
824   MCFG_IEEE488_ADD(IEEE488_TAG, ieee488_daisy)
871   MCFG_IEEE488_CONFIG_ADD(ieee488_daisy, ieee488_intf)
825872
826873   /* software lists */
827874   MCFG_SOFTWARE_LIST_ADD("disk_list","vixen")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team