Previous 15994 Revisions Next

r11249 Tuesday 19th April, 2011 at 21:33:23 UTC by Curt Coder
Refactored the Commodore 1571 disk drive into a C++ device. (no whatsnew)
[src/mess/drivers]c128.c
[src/mess/machine]64h156.c 64h156.h c1551.c c1551.h c1571.c c1571.h

src/mess/machine/64h156.c
r11248r11249
2727//  MACROS / CONSTANTS
2828//**************************************************************************
2929
30#define LOG 0
31
3032#define SYNC \
31   !(m_oe && ((m_data & G64_SYNC_MARK) == G64_SYNC_MARK))
33   !(m_oe & m_sync)
3234
3335#define BYTE \
3436   !(m_soe & m_byte)
3537
38#define ATN \
39   (m_atni ^ m_atna)
3640
3741
42
3843//**************************************************************************
3944//  DEVICE DEFINITIONS
4045//**************************************************************************
r11248r11249
8489
8590inline void c64h156_device::set_atn_line()
8691{
87   m_atn = !m_atni; // TODO m_atna
88
89   devcb_call_write_line(&m_out_atn_func, m_atn);
92   devcb_call_write_line(&m_out_atn_func, ATN);
9093}
9194
9295
r11248r11249
9497//  set_sync_line -
9598//-------------------------------------------------
9699
97inline void c64h156_device::set_sync_line(int state)
100inline void c64h156_device::set_sync_line()
98101{
99   m_sync = state;
100
101   devcb_call_write_line(&m_out_sync_func, m_sync);
102   devcb_call_write_line(&m_out_sync_func, SYNC);
102103}
103104
104105
r11248r11249
106107//  set_byte_line -
107108//-------------------------------------------------
108109
109inline void c64h156_device::set_byte_line(int state)
110inline void c64h156_device::set_byte_line()
110111{
111   m_byte = state;
112
113112   devcb_call_write_line(&m_out_byte_func, BYTE);
114113}
115114
r11248r11249
123122   int track_length = G64_BUFFER_SIZE;
124123
125124   // read track data
126   floppy_drive_read_track_data_info_buffer(m_image, 0, m_track_buffer, &track_length);
125   floppy_drive_read_track_data_info_buffer(m_image, m_side, m_track_buffer, &track_length);
127126
128127   // extract track length
129   m_track_len = floppy_drive_get_current_track_size(m_image, 0);
128   m_track_len = floppy_drive_get_current_track_size(m_image, m_side);
130129
131130   // set bit pointer to track start
132131   m_buffer_pos = 0;
r11248r11249
141140
142141inline void c64h156_device::receive_bit()
143142{
144   int byte = 0;
143   if (m_bit_count == 1)
144   {
145      m_byte = 0;
146      set_byte_line();
147   }
145148
146149   // shift in data from the read head
147150   m_data <<= 1;
r11248r11249
161164      }
162165   }
163166
164   set_sync_line(SYNC);
167   m_sync = ((m_data & G64_SYNC_MARK) == G64_SYNC_MARK);
168   set_sync_line();
165169
166   if (!m_sync)
170   if (m_sync)
167171   {
168172      // SYNC detected
169173      m_bit_count = 0;
174
175      if (LOG) logerror("SYNC\n");
170176   }
171177
172178   if (m_bit_count > 7)
173179   {
174180      // byte ready
181      m_yb = m_data & 0xff;
175182      m_bit_count = 0;
176      byte = 1;
183     
184      m_byte = 1;
185      set_byte_line();
177186
178      m_yb = m_data & 0xff;
187      if (LOG) logerror("BYTE %02x\n", m_yb);
179188
180189      if (!m_yb)
181190      {
182191         // simulate weak bits with randomness
183192         m_yb = machine().rand() & 0xff;
184193      }
185
186      set_byte_line(byte);
187194   }
188195}
189196
r11248r11249
202209     m_image(*this->owner(), FLOPPY_0),
203210     m_stp(-1),
204211     m_mtr(0),
212     m_side(0),
205213     m_accl(1),
206214     m_ds(-1),
207215     m_soe(0),
208216     m_byte(0),
209217     m_oe(0),
210218     m_sync(1),
211     m_atn(1),
212219     m_atni(1),
213220     m_atna(1),
214221      m_config(_config)
r11248r11249
233240   // register for state saving
234241   save_item(NAME(m_stp));
235242   save_item(NAME(m_mtr));
243   save_item(NAME(m_side));
236244   save_item(NAME(m_track_len));
237245   save_item(NAME(m_buffer_pos));
238246   save_item(NAME(m_bit_pos));
r11248r11249
245253   save_item(NAME(m_byte));
246254   save_item(NAME(m_oe));
247255   save_item(NAME(m_sync));
248   save_item(NAME(m_atn));
249256   save_item(NAME(m_atni));
250257   save_item(NAME(m_atna));
251258}
r11248r11249
267274
268275READ8_MEMBER( c64h156_device::yb_r )
269276{
270   set_byte_line(0); // TODO remove?
277   UINT8 data = 0;
271278
272   return m_yb;
279   if (LOG) logerror("YB read %02x\n", m_yb);
280
281   if (m_soe)
282   {
283      data = m_yb;
284   }
285
286   return data;
273287}
274288
275289
r11248r11249
279293
280294WRITE8_MEMBER( c64h156_device::yb_w )
281295{
282   m_yb = data;
296   //m_yb = data;
283297}
284298
285299
r11248r11249
308322
309323READ_LINE_MEMBER( c64h156_device::sync_r )
310324{
311   return m_sync;
325   return SYNC;
312326}
313327
314328
r11248r11249
351365WRITE_LINE_MEMBER( c64h156_device::oe_w )
352366{
353367   m_oe = state;
368
369   set_sync_line();
354370}
355371
356372
r11248r11249
361377WRITE_LINE_MEMBER( c64h156_device::soe_w )
362378{
363379   m_soe = state;
380
381   set_byte_line();
364382}
365383
366384
r11248r11249
370388
371389READ_LINE_MEMBER( c64h156_device::atn_r )
372390{
373   return m_atn;
391   return ATN;
374392}
375393
376394
r11248r11249
452470{
453471   read_current_track();
454472}
473
474
475//-------------------------------------------------
476//  on_disk_changed -
477//-------------------------------------------------
478
479void c64h156_device::set_side(int side)
480{
481   m_side = side;
482}
src/mess/machine/64h156.h
r11248r11249
142142
143143   void stp_w(int data);
144144   void ds_w(int data);
145   void set_side(int side);
145146
146147   void on_disk_changed();
147148
r11248r11249
151152   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
152153
153154   inline void set_atn_line();
154   inline void set_sync_line(int state);
155   inline void set_byte_line(int state);
155   inline void set_sync_line();
156   inline void set_byte_line();
156157   inline void read_current_track();
157158   inline void spindle_motor(int mtr);
158159   inline void step_motor(int mtr, int stp);
r11248r11249
170171   int m_mtr;                        // spindle motor on
171172
172173   // track
174   int m_side;                        // disk side
173175   UINT8 m_track_buffer[G64_BUFFER_SIZE];   // track data buffer
174176   size_t m_track_len;                  // track length
175177   offs_t m_buffer_pos;               // current byte position within track buffer
r11248r11249
184186   int m_soe;                        // s? output enable
185187   int m_byte;                        // byte ready
186188   int m_oe;                        // output enable (0 = write, 1 = read)
187   int m_sync;                        // sync character detected
189   int m_sync;                        // sync character found
188190
189191   // IEC
190   int m_atn;                        // attention
191192   int m_atni;                        // attention input
192193   int m_atna;                        // attention acknowledge
193194
src/mess/machine/c1551.c
r11248r11249
1313
1414    - byte latching does not match hardware behavior
1515      (CPU skips data bytes if implemented per schematics)
16    - activity LED
1716
1817*/
1918
r11248r11249
7675
7776   assert((address > 7) && (address < 10));
7877
79   c1551->m_address = address - 8;
78   c1551->m_jp1 = address - 8;
8079}
8180
8281
r11248r11249
239238   UINT8 data = 0;
240239
241240   // JP1
242   data |= m_config.m_address << 5;
241   data |= m_config.m_jp1 << 5;
243242
244243   // SYNC detect line
245244   data |= m_ga->sync_r() << 6;
r11248r11249
271270   // TCBM status
272271   m_status = data & 0x03;
273272
274   // TODO TCBM device number
273   // TCBM device number
274   set_tcbm_dev(BIT(data, 2));
275275
276276   // TCBM acknowledge
277277   m_ack = BIT(data, 3);
r11248r11249
462462
463463
464464//**************************************************************************
465//  INLINE HELPERS
466//**************************************************************************
467
468//-------------------------------------------------
469//  c1551_device - constructor
470//-------------------------------------------------
471
472inline void c1551_device::set_tcbm_dev(int dev)
473{
474   if (m_dev != dev)
475   {
476      address_space *program = machine().firstcpu->memory().space(AS_PROGRAM);
477      offs_t start_address = dev ? 0xfef0 : 0xfec0;
478
479      program->unmap_readwrite(0xfec0, 0xfec7);
480      program->unmap_readwrite(0xfef0, 0xfef7);
481      program->install_legacy_readwrite_handler(*m_tpi1, start_address, start_address + 5, FUNC(tpi6525_r), FUNC(tpi6525_w));
482
483      m_dev = dev;
484   }
485}
486
487
488
489//**************************************************************************
465490//  LIVE DEVICE
466491//**************************************************************************
467492
r11248r11249
476501     m_tpi1(*this, M6523_1_TAG),
477502     m_ga(*this, C64H156_TAG),
478503     m_image(*this, FLOPPY_0),
479     m_tcbm_data(0),
480     m_status(0),
481     m_dav(0),
482     m_ack(0),
504     m_tcbm_data(0xff),
505     m_status(1),
506     m_dav(1),
507     m_ack(1),
508     m_dev(-1),
483509      m_config(_config)
484510{
485511}
r11248r11249
493519{
494520   // allocate timers
495521   m_irq_timer = timer_alloc();
496   m_irq_timer->adjust(attotime::from_hz(120), 0, attotime::from_hz(120));
522   m_irq_timer->adjust(attotime::zero, CLEAR_LINE);
497523
498   // map TPI1 to host CPU memory space
499   address_space *program = machine().firstcpu->memory().space(AS_PROGRAM);
500   UINT32 start_address = m_config.m_address ? 0xfec0 : 0xfef0;
524   // map to host CPU memory space
525   set_tcbm_dev(1);
501526
502   program->install_legacy_readwrite_handler(*m_tpi1, start_address, start_address + 7, FUNC(tpi6525_r), FUNC(tpi6525_w));
503
504527   // install image callbacks
505528   floppy_install_unload_proc(m_image, c1551_device::on_disk_change);
506529   floppy_install_load_proc(m_image, c1551_device::on_disk_change);
r11248r11249
533556
534557void c1551_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
535558{
536   m_maincpu->set_input_line(M6502_IRQ_LINE, ASSERT_LINE);
537   m_maincpu->set_input_line(M6502_IRQ_LINE, CLEAR_LINE);
559   m_maincpu->set_input_line(M6502_IRQ_LINE, param);
560
561   if (param == ASSERT_LINE)
562   {
563      // Ts = 0.7*R2*C1 = 0.7*100R*0.1uF = 7us
564      m_irq_timer->adjust(attotime::from_usec(7), CLEAR_LINE);
565   }
566   else
567   {
568      // Tm = 0.7*(R1+R2)*C1 = 0.7*(120K+100R)*0.1uF = 0.008407s
569      m_irq_timer->adjust(attotime::from_usec(8407), ASSERT_LINE);
570   }
538571}
539572
540573
src/mess/machine/c1551.h
r11248r11249
6565
6666private:
6767   const char *m_cpu_tag;
68   int m_address;
68   int m_jp1;
6969};
7070
7171
r11248r11249
103103   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
104104
105105private:
106   inline void set_tcbm_dev(int dev);
107
106108   required_device<cpu_device> m_maincpu;
107109   required_device<device_t> m_tpi0;
108110   required_device<device_t> m_tpi1;
r11248r11249
114116   int m_status;                     // status
115117   int m_dav;                        // data valid
116118   int m_ack;                        // acknowledge
119   int m_dev;                        // device number
117120
118121   // timers
119122   emu_timer *m_irq_timer;
src/mess/machine/c1571.c
r11248r11249
1111
1212    TODO:
1313
14    - fast serial only works with PAL C128
14   - C1570
15   - C1571CR
16    - fast serial
1517    - 1541/1571 Alignment shows drive speed as 266 rpm, should be 310
1618    - CP/M disks
17    - power/activity LEDs
1819
1920*/
2021
21#include "emu.h"
2222#include "c1571.h"
23#include "cpu/m6502/m6502.h"
24#include "imagedev/flopdrv.h"
25#include "formats/d64_dsk.h"
26#include "formats/g64_dsk.h"
27#include "machine/6522via.h"
28#include "machine/6526cia.h"
29#include "machine/cbmiec.h"
30#include "machine/wd17xx.h"
23#include "machine/devhelpr.h"
3124
32/***************************************************************************
33    PARAMETERS
34***************************************************************************/
3525
26
27//**************************************************************************
28//  MACROS / CONSTANTS
29//**************************************************************************
30
3631#define M6502_TAG      "u1"
3732#define M6522_0_TAG      "u9"
3833#define M6522_1_TAG      "u4"
r11248r11249
4035#define WD1770_TAG      "u11"
4136#define C64H156_TAG      "u6"
4237
43/***************************************************************************
44    TYPE DEFINITIONS
45***************************************************************************/
4638
47typedef struct _c1571_t c1571_t;
48struct _c1571_t
39enum
4940{
50   /* IEC bus */
51   int address;                     /* device number */
52   int data_out;                     /* serial data out */
53   int atn_ack;                     /* attention acknowledge */
54   int ser_dir;                     /* fast serial direction */
55   int sp_out;                        /* fast serial data out */
56   int cnt_out;                     /* fast serial clock out */
57
58   /* motors */
59   int stp;                        /* stepper motor phase */
60   int mtr;                        /* spindle motor on */
61
62   /* track */
63   UINT8 track_buffer[G64_BUFFER_SIZE];   /* track data buffer */
64   int track_len;                     /* track length */
65   int buffer_pos;                     /* current byte position within track buffer */
66   int bit_pos;                     /* current bit position within track buffer byte */
67   int bit_count;                     /* current data byte bit counter */
68   UINT16 data;                     /* data shift register */
69   UINT8 yb;                        /* GCR data byte to write */
70
71   /* signals */
72   int ds;                           /* density select */
73   int soe;                        /* s? output enable */
74   int byte;                        /* byte ready */
75   int mode;                        /* mode (0 = write, 1 = read) */
76   int side;                        /* disk side select */
77   int clock;                        /* clock speed */
78
79   /* interrupts */
80   int via0_irq;                     /* VIA #0 interrupt request */
81   int via1_irq;                     /* VIA #1 interrupt request */
82   int cia_irq;                     /* CIA interrupt request */
83
84   /* devices */
85   device_t *cpu;
86   via6522_device *via0;
87   via6522_device *via1;
88   device_t *cia;
89   device_t *wd1770;
90   device_t *serial_bus;
91   device_t *image;
92
93   /* timers */
94   emu_timer *bit_timer;
41   LED_POWER = 0,
42   LED_ACT
9543};
9644
97/***************************************************************************
98    INLINE FUNCTIONS
99***************************************************************************/
10045
101INLINE c1571_t *get_safe_token(device_t *device)
102{
103   assert(device != NULL);
104   assert((device->type() == C1570) || (device->type() == C1571) || (device->type() == C1571CR));
105   return (c1571_t *)downcast<legacy_device_base *>(device)->token();
106}
10746
108INLINE c1571_config *get_safe_config(device_t *device)
109{
110   assert(device != NULL);
111   assert((device->type() == C1570) || (device->type() == C1571) || (device->type() == C1571CR));
112   return (c1571_config *)downcast<const legacy_device_config_base &>(device->baseconfig()).inline_config();
113}
47//**************************************************************************
48//  DEVICE DEFINITIONS
49//**************************************************************************
11450
115INLINE void iec_data_w(device_t *device)
116{
117   c1571_t *c1571 = get_safe_token(device);
51const device_type C1571 = c1571_device_config::static_alloc_device_config;
11852
119   int atn = cbm_iec_atn_r(c1571->serial_bus);
120   int data = !c1571->data_out & !(c1571->atn_ack ^ !atn);
12153
122   /* fast serial data */
123   if (c1571->ser_dir) data &= c1571->sp_out;
12454
125   cbm_iec_data_w(c1571->serial_bus, device, data);
126}
55//**************************************************************************
56//  DEVICE CONFIGURATION
57//**************************************************************************
12758
128INLINE void iec_srq_w(device_t *device)
129{
130   c1571_t *c1571 = get_safe_token(device);
59GENERIC_DEVICE_CONFIG_SETUP(c1571, "C1571");
13160
132   int srq = 1;
13361
134   /* fast serial clock */
135   if (c1571->ser_dir) srq &= c1571->cnt_out;
62//-------------------------------------------------
63//  device_config_complete - perform any
64//  operations now that the configuration is
65//  complete
66//-------------------------------------------------
13667
137   cbm_iec_srq_w(c1571->serial_bus, device, srq);
138}
139
140/***************************************************************************
141    IMPLEMENTATION
142***************************************************************************/
143
144/*-------------------------------------------------
145    TIMER_CALLBACK( bit_tick )
146-------------------------------------------------*/
147
148static TIMER_CALLBACK( bit_tick )
68void c1571_device_config::device_config_complete()
14969{
150   device_t *device = (device_t *)ptr;
151   c1571_t *c1571 = get_safe_token(device);
152   int byte = 0;
153
154   /* shift in data from the read head */
155   c1571->data <<= 1;
156   c1571->data |= BIT(c1571->track_buffer[c1571->buffer_pos], c1571->bit_pos);
157   c1571->bit_pos--;
158   c1571->bit_count++;
159
160   if (c1571->bit_pos < 0)
161   {
162      c1571->bit_pos = 7;
163      c1571->buffer_pos++;
164
165      if (c1571->buffer_pos >= c1571->track_len)
166      {
167         /* loop to the start of the track */
168         c1571->buffer_pos = 0;
169      }
170   }
171
172   if ((c1571->data & G64_SYNC_MARK) == G64_SYNC_MARK)
173   {
174      /* SYNC detected */
175      c1571->bit_count = 0;
176   }
177
178   if (c1571->bit_count > 7)
179   {
180      /* byte ready */
181      c1571->bit_count = 0;
182      byte = 1;
183
184      c1571->yb = c1571->data & 0xff;
185
186      if (!c1571->yb)
187      {
188         /* simulate weak bits with randomness */
189         c1571->yb = machine.rand() & 0xff;
190      }
191   }
192
193   if (c1571->byte != byte)
194   {
195      int byte_ready = !(byte && c1571->soe);
196
197      device_set_input_line(c1571->cpu, M6502_SET_OVERFLOW, byte_ready);
198      c1571->via1->write_ca1(byte_ready);
199
200      c1571->byte = byte;
201   }
70   m_shortname = "c1571";
20271}
20372
204/*-------------------------------------------------
205    read_current_track - read track from disk
206-------------------------------------------------*/
20773
208static void read_current_track(c1571_t *c1571)
209{
210   c1571->track_len = G64_BUFFER_SIZE;
211   c1571->buffer_pos = 0;
212   c1571->bit_pos = 7;
213   c1571->bit_count = 0;
74//-------------------------------------------------
75//  static_set_config - configuration helper
76//-------------------------------------------------
21477
215   /* read track data */
216   floppy_drive_read_track_data_info_buffer(c1571->image, c1571->side, c1571->track_buffer, &c1571->track_len);
217
218   /* extract track length */
219   c1571->track_len = floppy_drive_get_current_track_size(c1571->image, c1571->side);
220}
221
222/*-------------------------------------------------
223    on_disk_change - disk change handler
224-------------------------------------------------*/
225
226static void on_disk_change(device_image_interface &image)
78void c1571_device_config::static_set_config(device_config *device, const char *bus_tag, int address)
22779{
228   c1571_t *c1571 = get_safe_token(image.device().owner());
80   c1571_device_config *c1571 = downcast<c1571_device_config *>(device);
22981
230   read_current_track(c1571);
231}
82   assert(bus_tag != NULL);
83   assert((address > 7) && (address < 12));
23284
233/*-------------------------------------------------
234    set_side - set disk side
235-------------------------------------------------*/
236
237static void set_side(c1571_t *c1571, int side)
238{
239   if (c1571->side != side)
240   {
241      c1571->side = side;
242      wd17xx_set_side(c1571->wd1770, side);
243
244      if (c1571->mtr)
245      {
246         /* read track data */
247         read_current_track(c1571);
248      }
249   }
85   c1571->m_bus_tag = bus_tag;
86   c1571->m_address = address - 8;
25087}
25188
252/*-------------------------------------------------
253    spindle_motor - spindle motor control
254-------------------------------------------------*/
25589
256static void spindle_motor(c1571_t *c1571, int mtr)
257{
258   if (c1571->mtr != mtr)
259   {
260      if (mtr)
261      {
262         /* read track data */
263         read_current_track(c1571);
264      }
90//-------------------------------------------------
91//  ROM( c1571 )
92//-------------------------------------------------
26593
266      floppy_mon_w(c1571->image, !mtr);
267      c1571->bit_timer->enable(mtr);
94ROM_START( c1571 )
95   ROM_REGION( 0x8000, "c1570", 0 )
96   ROM_LOAD( "315090-01.u2", 0x0000, 0x8000, CRC(5a0c7937) SHA1(5fc06dc82ff6840f183bd43a4d9b8a16956b2f56) )
26897
269      c1571->mtr = mtr;
270   }
271}
98   ROM_REGION( 0x8000, "c1571", 0 )
99   ROM_LOAD_OPTIONAL( "jiffydos 1571.u2", 0x0000, 0x8000, CRC(fe6cac6d) SHA1(d4b79b60cf1eaa399d0932200eb7811e00455249) )
100   ROM_LOAD_OPTIONAL( "310654-03.u2", 0x0000, 0x8000, CRC(3889b8b8) SHA1(e649ef4419d65829d2afd65e07d31f3ce147d6eb) )
101   ROM_LOAD( "310654-05.u2", 0x0000, 0x8000, CRC(5755bae3) SHA1(f1be619c106641a685f6609e4d43d6fc9eac1e70) )
272102
273/*-------------------------------------------------
274    step_motor - stepper motor control
275-------------------------------------------------*/
103   ROM_REGION( 0x8000, "c1571cr", 0 )
104   ROM_LOAD_OPTIONAL( "jiffydos 1571d.u102", 0x0000, 0x8000, CRC(9cba146d) SHA1(823b178561302b403e6bfd8dd741d757efef3958) )
105   ROM_LOAD( "318047-01.u102", 0x0000, 0x8000, CRC(f24efcc4) SHA1(14ee7a0fb7e1c59c51fbf781f944387037daa3ee) )
106ROM_END
276107
277static void step_motor(c1571_t *c1571, int stp)
278{
279   if (c1571->mtr & (c1571->stp != stp))
280   {
281      int tracks = 0;
282108
283      switch (c1571->stp)
284      {
285      case 0:   if (stp == 1) tracks++; else if (stp == 3) tracks--; break;
286      case 1:   if (stp == 2) tracks++; else if (stp == 0) tracks--; break;
287      case 2: if (stp == 3) tracks++; else if (stp == 1) tracks--; break;
288      case 3: if (stp == 0) tracks++; else if (stp == 2) tracks--; break;
289      }
109//-------------------------------------------------
110//  rom_region - device-specific ROM region
111//-------------------------------------------------
290112
291      if (tracks != 0)
292      {
293         /* step read/write head */
294         floppy_drive_seek(c1571->image, tracks);
295
296         /* read new track data */
297         read_current_track(c1571);
298      }
299
300      c1571->stp = stp;
301   }
302}
303
304/*-------------------------------------------------
305    c1571_iec_atn_w - serial bus attention
306-------------------------------------------------*/
307
308WRITE_LINE_DEVICE_HANDLER( c1571_iec_atn_w )
113const rom_entry *c1571_device_config::device_rom_region() const
309114{
310   c1571_t *c1571 = get_safe_token(device);
311
312   c1571->via0->write_ca1(!state);
313   iec_data_w(device);
115   return ROM_NAME( c1571 );
314116}
315117
316/*-------------------------------------------------
317    c1571_iec_srq_w - serial bus fast clock
318-------------------------------------------------*/
319118
320WRITE_LINE_DEVICE_HANDLER( c1571_iec_srq_w )
321{
322   c1571_t *c1571 = get_safe_token(device);
119//-------------------------------------------------
120//  ADDRESS_MAP( c1571_mem )
121//-------------------------------------------------
323122
324   if (!c1571->ser_dir)
325   {
326      mos6526_cnt_w(c1571->cia, state);
327   }
328}
329
330/*-------------------------------------------------
331    c1571_iec_data_w - serial bus fast data
332-------------------------------------------------*/
333
334WRITE_LINE_DEVICE_HANDLER( c1571_iec_data_w )
335{
336   c1571_t *c1571 = get_safe_token(device);
337
338   if (!c1571->ser_dir)
339   {
340      mos6526_sp_w(c1571->cia, state);
341   }
342}
343
344/*-------------------------------------------------
345    c1571_iec_reset_w - serial bus reset
346-------------------------------------------------*/
347
348WRITE_LINE_DEVICE_HANDLER( c1571_iec_reset_w )
349{
350   if (!state)
351   {
352      device->reset();
353   }
354}
355
356/*-------------------------------------------------
357    ADDRESS_MAP( c1570_map )
358-------------------------------------------------*/
359
360static ADDRESS_MAP_START( c1570_map, AS_PROGRAM, 8 )
123static ADDRESS_MAP_START( c1571_mem, AS_PROGRAM, 8, c1571_device )
361124   AM_RANGE(0x0000, 0x07ff) AM_RAM
362   AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
363   AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
364   AM_RANGE(0x2000, 0x2003) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w)
365   AM_RANGE(0x4000, 0x400f) AM_DEVREADWRITE(M6526_TAG, mos6526_r, mos6526_w)
366   AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1570:c1570", 0)
367ADDRESS_MAP_END
368
369/*-------------------------------------------------
370    ADDRESS_MAP( c1571_map )
371-------------------------------------------------*/
372
373static ADDRESS_MAP_START( c1571_map, AS_PROGRAM, 8 )
374   AM_RANGE(0x0000, 0x07ff) AM_RAM
375   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x03f0) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
376   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x03f0) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
377   AM_RANGE(0x2000, 0x2003) AM_MIRROR(0x1ffc) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w)
378   AM_RANGE(0x4000, 0x400f) AM_MIRROR(0x3ff0) AM_DEVREADWRITE(M6526_TAG, mos6526_r, mos6526_w)
125   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x03f0) AM_DEVREADWRITE(M6522_0_TAG, via6522_device, read, write)
126   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x03f0) AM_DEVREADWRITE(M6522_1_TAG, via6522_device, read, write)
127   AM_RANGE(0x2000, 0x2003) AM_MIRROR(0x1ffc) AM_DEVREADWRITE_LEGACY(WD1770_TAG, wd17xx_r, wd17xx_w)
128   AM_RANGE(0x4000, 0x400f) AM_MIRROR(0x3ff0) AM_DEVREADWRITE_LEGACY(M6526_TAG, mos6526_r, mos6526_w)
379129   AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1571:c1571", 0)
380130ADDRESS_MAP_END
381131
382/*-------------------------------------------------
383    ADDRESS_MAP( c1571cr_map )
384-------------------------------------------------*/
385132
386static ADDRESS_MAP_START( c1571cr_map, AS_PROGRAM, 8 )
387   AM_RANGE(0x0000, 0x07ff) AM_RAM
388   AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
389   AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
390//  AM_RANGE(0x2000, 0x2005) 5710 FDC
391//  AM_RANGE(0x400c, 0x400e) 5710 CIA
392//  AM_RANGE(0x4010, 0x4017) 5710 CIA
393//  AM_RANGE(0x6000, 0x7fff) RAM mirrors
394   AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1571:c1571cr", 0)
395ADDRESS_MAP_END
133//-------------------------------------------------
134//  via6522_interface via0_intf
135//-------------------------------------------------
396136
397/*-------------------------------------------------
398    via6522_interface via0_intf
399-------------------------------------------------*/
400
401static WRITE_LINE_DEVICE_HANDLER( via0_irq_w )
137WRITE_LINE_MEMBER( c1571_device::via0_irq_w )
402138{
403   c1571_t *c1571 = get_safe_token(device->owner());
139   m_via0_irq = state;
404140
405   c1571->via0_irq = state;
406
407   device_set_input_line(c1571->cpu, INPUT_LINE_IRQ0, (c1571->via0_irq | c1571->via1_irq | c1571->cia_irq) ? ASSERT_LINE : CLEAR_LINE);
141   m_maincpu->set_input_line(INPUT_LINE_IRQ0, (m_via0_irq | m_via1_irq | m_cia_irq) ? ASSERT_LINE : CLEAR_LINE);
408142}
409143
410static READ8_DEVICE_HANDLER( via0_pa_r )
144
145READ8_MEMBER( c1571_device::via0_pa_r )
411146{
412147   /*
413148
414149        bit     description
415150
416151        PA0     TRK0 SNS
417        PA1     SER DIR
418        PA2     SIDE
152        PA1     
153        PA2     
419154        PA3
420155        PA4
421        PA5     _1/2 MHZ
422        PA6     ATN OUT
156        PA5     
157        PA6     
423158        PA7     BYTE RDY
424159
425160    */
426161
427   c1571_t *c1571 = get_safe_token(device->owner());
428162   UINT8 data = 0;
429163
430164   /* track 0 sense */
431   data |= floppy_tk00_r(c1571->image);
165   data |= floppy_tk00_r(m_image);
432166
433167   /* byte ready */
434   data |= !(c1571->byte && c1571->soe) << 7;
168   data |= m_ga->byte_r() << 7;
435169
436170   return data;
437171}
438172
439static WRITE8_DEVICE_HANDLER( via0_pa_w )
173
174WRITE8_MEMBER( c1571_device::via0_pa_w )
440175{
441176   /*
442177
443178        bit     description
444
445        PA0     TRK0 SNS
179     
180        PA0     
446181        PA1     SER DIR
447182        PA2     SIDE
448183        PA3
449184        PA4
450185        PA5     _1/2 MHZ
451186        PA6     ATN OUT
452        PA7     BYTE RDY
187        PA7     
453188
454189    */
455190
456   c1571_t *c1571 = get_safe_token(device->owner());
457
458191   /* 1/2 MHz */
459192   int clock_1_2 = BIT(data, 5);
460193
461   if (c1571->clock != clock_1_2)
194   if (m_1_2mhz != clock_1_2)
462195   {
463196      UINT32 clock = clock_1_2 ? XTAL_16MHz/8 : XTAL_16MHz/16;
464197
465      c1571->cpu->set_unscaled_clock(clock);
466      c1571->cia->set_unscaled_clock(clock);
467      c1571->via0->set_unscaled_clock(clock);
468      c1571->via1->set_unscaled_clock(clock);
198      m_maincpu->set_unscaled_clock(clock);
199      m_cia->set_unscaled_clock(clock);
200      m_via0->set_unscaled_clock(clock);
201      m_via1->set_unscaled_clock(clock);
202      m_ga->accl_w(clock_1_2);
469203
470      c1571->clock = clock_1_2;
204      m_1_2mhz = clock_1_2;
471205   }
472206
473207   /* fast serial direction */
474   c1571->ser_dir = BIT(data, 1);
475   iec_data_w(device->owner());
476   iec_srq_w(device->owner());
208   int ser_dir = BIT(data, 1);
477209
210   if (m_ser_dir != ser_dir)
211   {
212      m_ser_dir = ser_dir;
213     
214      set_iec_data();
215      set_iec_srq();
216   
217      if (!m_ser_dir)
218      {
219         //m_cia->cnt_w(cbm_iec_srq_r(m_bus));
220         //m_cia->sp_w(cbm_iec_data_r(m_bus));
221      }
222   }
223
478224   /* side select */
479   int side = BIT(data, 2);
480   set_side(c1571, side);
225   m_ga->set_side(BIT(data, 2));
481226
482227   /* attention out */
483   cbm_iec_atn_w(c1571->serial_bus, device->owner(), !BIT(data, 6));
228   cbm_iec_atn_w(m_bus, this, !BIT(data, 6));
484229}
485230
486static READ8_DEVICE_HANDLER( via0_pb_r )
231
232READ8_MEMBER( c1571_device::via0_pb_r )
487233{
488234   /*
489235
490236        bit     description
491237
492238        PB0     DATA IN
493        PB1     DATA OUT
239        PB1     
494240        PB2     CLK IN
495        PB3     CLK OUT
496        PB4     ATN ACK
241        PB3     
242        PB4     
497243        PB5     DEV# SEL
498244        PB6     DEV# SEL
499245        PB7     ATN IN
500246
501247    */
502248
503   c1571_t *c1571 = get_safe_token(device->owner());
504249   UINT8 data = 0;
505250
506251   /* data in */
507   data = !cbm_iec_data_r(c1571->serial_bus);
252   data = !cbm_iec_data_r(m_bus);
508253
509254   /* clock in */
510   data |= !cbm_iec_clk_r(c1571->serial_bus) << 2;
255   data |= !cbm_iec_clk_r(m_bus) << 2;
511256
512257   /* serial bus address */
513   data |= c1571->address << 5;
258   data |= m_config.m_address << 5;
514259
515260   /* attention in */
516   data |= !cbm_iec_atn_r(c1571->serial_bus) << 7;
261   data |= !cbm_iec_atn_r(m_bus) << 7;
517262
518263   return data;
519264}
520265
521static WRITE8_DEVICE_HANDLER( via0_pb_w )
266
267WRITE8_MEMBER( c1571_device::via0_pb_w )
522268{
523269   /*
524270
525271        bit     description
526272
527        PB0     DATA IN
273        PB0     
528274        PB1     DATA OUT
529        PB2     CLK IN
275        PB2     
530276        PB3     CLK OUT
531277        PB4     ATN ACK
532        PB5     DEV# SEL
533        PB6     DEV# SEL
534        PB7     ATN IN
278        PB5     
279        PB6     
280        PB7     
535281
536282    */
537283
538   c1571_t *c1571 = get_safe_token(device->owner());
284   /* data out */
285   m_data_out = BIT(data, 1);
539286
540287   /* attention acknowledge */
541   c1571->atn_ack = BIT(data, 4);
288   m_ga->atna_w(BIT(data, 4));
542289
543   /* data out */
544   c1571->data_out = BIT(data, 1);
545   iec_data_w(device->owner());
546
547290   /* clock out */
548   cbm_iec_clk_w(c1571->serial_bus, device->owner(), !BIT(data, 3));
291   cbm_iec_clk_w(m_bus, this, !BIT(data, 3));
549292}
550293
551static READ_LINE_DEVICE_HANDLER( atn_in_r )
552{
553   c1571_t *c1571 = get_safe_token(device->owner());
554294
555   return !cbm_iec_atn_r(c1571->serial_bus);
295READ_LINE_MEMBER( c1571_device::atn_in_r )
296{
297   return !cbm_iec_atn_r(m_bus);
556298}
557299
558static READ_LINE_DEVICE_HANDLER( wprt_r )
559{
560   c1571_t *c1571 = get_safe_token(device->owner());
561300
562   return !floppy_wpt_r(c1571->image);
301READ_LINE_MEMBER( c1571_device::wprt_r )
302{
303   return !floppy_wpt_r(m_image);
563304}
564305
306
565307static const via6522_interface via0_intf =
566308{
567   DEVCB_HANDLER(via0_pa_r),
568   DEVCB_HANDLER(via0_pb_r),
569   DEVCB_LINE(atn_in_r),
309   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c1571_device, via0_pa_r),
310   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c1571_device, via0_pb_r),
311   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1571_device, atn_in_r),
570312   DEVCB_NULL,
571   DEVCB_LINE(wprt_r),
313   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1571_device, wprt_r),
572314   DEVCB_NULL,
573315
574   DEVCB_HANDLER(via0_pa_w),
575   DEVCB_HANDLER(via0_pb_w),
316   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c1571_device, via0_pa_w),
317   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c1571_device, via0_pb_w),
576318   DEVCB_NULL,
577319   DEVCB_NULL,
578320   DEVCB_NULL,
579321   DEVCB_NULL,
580322
581   DEVCB_LINE(via0_irq_w)
323   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1571_device, via0_irq_w)
582324};
583325
584/*-------------------------------------------------
585    via6522_interface via1_intf
586-------------------------------------------------*/
587326
588static WRITE_LINE_DEVICE_HANDLER( via1_irq_w )
589{
590   c1571_t *c1571 = get_safe_token(device->owner());
327//-------------------------------------------------
328//  via6522_interface via1_intf
329//-------------------------------------------------
591330
592   c1571->via1_irq = state;
593
594   device_set_input_line(c1571->cpu, INPUT_LINE_IRQ0, (c1571->via0_irq | c1571->via1_irq | c1571->cia_irq) ? ASSERT_LINE : CLEAR_LINE);
595}
596
597static READ8_DEVICE_HANDLER( yb_r )
331WRITE_LINE_MEMBER( c1571_device::via1_irq_w )
598332{
599   /*
333   m_via1_irq = state;
600334
601        bit     description
602
603        PA0     YB0
604        PA1     YB1
605        PA2     YB2
606        PA3     YB3
607        PA4     YB4
608        PA5     YB5
609        PA6     YB6
610        PA7     YB7
611
612    */
613
614   c1571_t *c1571 = get_safe_token(device->owner());
615
616   return c1571->yb;
335   m_maincpu->set_input_line(INPUT_LINE_IRQ0, (m_via0_irq | m_via1_irq | m_cia_irq) ? ASSERT_LINE : CLEAR_LINE);
617336}
618337
619static WRITE8_DEVICE_HANDLER( yb_w )
620{
621   /*
622338
623        bit     description
624
625        PA0     YB0
626        PA1     YB1
627        PA2     YB2
628        PA3     YB3
629        PA4     YB4
630        PA5     YB5
631        PA6     YB6
632        PA7     YB7
633
634    */
635
636   c1571_t *c1571 = get_safe_token(device->owner());
637
638   c1571->yb = data;
639}
640
641static READ8_DEVICE_HANDLER( via1_pb_r )
339READ8_MEMBER( c1571_device::via1_pb_r )
642340{
643341   /*
644342
645343        bit     signal      description
646344
647        PB0     STP0        stepping motor bit 0
648        PB1     STP1        stepping motor bit 1
649        PB2     MTR         motor ON/OFF
650        PB3     ACT         drive 0 LED
345        PB0     
346        PB1     
347        PB2     
348        PB3     
651349        PB4     _WPRT       write protect sense
652        PB5     DS0         density select 0
653        PB6     DS1         density select 1
350        PB5     
351        PB6     
654352        PB7     _SYNC       SYNC detect line
655353
656354    */
657355
658   c1571_t *c1571 = get_safe_token(device->owner());
659356   UINT8 data = 0;
660357
661358   /* write protect sense */
662   data |= !floppy_wpt_r(c1571->image) << 4;
359   data |= !floppy_wpt_r(m_image) << 4;
663360
664361   /* SYNC detect line */
665   data |= !((c1571->data & G64_SYNC_MARK) == G64_SYNC_MARK) << 7;
362   data |= m_ga->sync_r() << 7;
666363
667364   return data;
668365}
669366
670static WRITE8_DEVICE_HANDLER( via1_pb_w )
367WRITE8_MEMBER( c1571_device::via1_pb_w )
671368{
672369   /*
673370
r11248r11249
677374        PB1     STP1        stepping motor bit 1
678375        PB2     MTR         motor ON/OFF
679376        PB3     ACT         drive 0 LED
680        PB4     _WPRT       write protect sense
377        PB4     
681378        PB5     DS0         density select 0
682379        PB6     DS1         density select 1
683        PB7     _SYNC       SYNC detect line
380        PB7     
684381
685382    */
686383
687   c1571_t *c1571 = get_safe_token(device->owner());
688
689384   /* spindle motor */
690   int mtr = BIT(data, 2);
691   spindle_motor(c1571, mtr);
385   m_ga->mtr_w(BIT(data, 2));
692386
693387   /* stepper motor */
694   int stp = data & 0x03;
695   step_motor(c1571, stp);
388   m_ga->stp_w(data & 0x03); // TODO actually STP1=0, STP0=!(PB0^PB1), Y0=PB1, Y2=!PB1
696389
697   /* TODO activity LED */
390   /* activity LED */
391   output_set_led_value(LED_ACT, BIT(data, 3));
698392
699393   /* density select */
700   int ds = (data >> 5) & 0x03;
701
702   if (c1571->ds != ds)
703   {
704      c1571->bit_timer->adjust(attotime::zero, 0, attotime::from_hz(C2040_BITRATE[ds]/4));
705      c1571->ds = ds;
706   }
394   m_ga->ds_w((data >> 5) & 0x03);
707395}
708396
709static READ_LINE_DEVICE_HANDLER( byte_ready_r )
710{
711   c1571_t *c1571 = get_safe_token(device->owner());
712397
713   return !(c1571->byte && c1571->soe);
714}
715
716static WRITE_LINE_DEVICE_HANDLER( soe_w )
717{
718   c1571_t *c1571 = get_safe_token(device->owner());
719   int byte_ready = !(state && c1571->byte);
720
721   c1571->soe = state;
722
723   device_set_input_line(c1571->cpu, M6502_SET_OVERFLOW, byte_ready);
724   c1571->via1->write_ca1(byte_ready);
725}
726
727static WRITE_LINE_DEVICE_HANDLER( mode_w )
728{
729   c1571_t *c1571 = get_safe_token(device->owner());
730
731   c1571->mode = state;
732}
733
734398static const via6522_interface via1_intf =
735399{
736   DEVCB_HANDLER(yb_r),
737   DEVCB_HANDLER(via1_pb_r),
738   DEVCB_LINE(byte_ready_r),
400   DEVCB_DEVICE_MEMBER(C64H156_TAG, c64h156_device, yb_r),
401   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c1571_device, via1_pb_r),
402   DEVCB_DEVICE_LINE_MEMBER(C64H156_TAG, c64h156_device, byte_r),
739403   DEVCB_NULL,
740404   DEVCB_NULL,
741405   DEVCB_NULL,
742406
743   DEVCB_HANDLER(yb_w),
744   DEVCB_HANDLER(via1_pb_w),
407   DEVCB_DEVICE_MEMBER(C64H156_TAG, c64h156_device, yb_w),
408   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c1571_device, via1_pb_w),
745409   DEVCB_NULL,
746410   DEVCB_NULL,
747   DEVCB_LINE(soe_w),
748   DEVCB_LINE(mode_w),
411   DEVCB_DEVICE_LINE_MEMBER(C64H156_TAG, c64h156_device, soe_w),
412   DEVCB_DEVICE_LINE_MEMBER(C64H156_TAG, c64h156_device, oe_w),
749413
750   DEVCB_LINE(via1_irq_w)
414   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1571_device, via1_irq_w)
751415};
752416
753/*-------------------------------------------------
754    mos6526_interface cia_intf
755-------------------------------------------------*/
756417
757static WRITE_LINE_DEVICE_HANDLER( cia_irq_w )
418//-------------------------------------------------
419//  mos6526_interface cia_intf
420//-------------------------------------------------
421
422WRITE_LINE_MEMBER( c1571_device::cia_irq_w )
758423{
759   c1571_t *c1571 = get_safe_token(device->owner());
424   m_cia_irq = state;
760425
761   c1571->cia_irq = state;
762
763   device_set_input_line(c1571->cpu, INPUT_LINE_IRQ0, (c1571->via0_irq | c1571->via1_irq | c1571->cia_irq) ? ASSERT_LINE : CLEAR_LINE);
426   m_maincpu->set_input_line(INPUT_LINE_IRQ0, (m_via0_irq | m_via1_irq | m_cia_irq) ? ASSERT_LINE : CLEAR_LINE);
764427}
765428
766static WRITE_LINE_DEVICE_HANDLER( cia_cnt_w )
767{
768   c1571_t *c1571 = get_safe_token(device->owner());
769429
430WRITE_LINE_MEMBER( c1571_device::cia_cnt_w )
431{
770432   /* fast serial clock out */
771   c1571->cnt_out = state;
772   iec_srq_w(device->owner());
433   m_cnt_out = state;
434   set_iec_srq();
773435}
774436
775static WRITE_LINE_DEVICE_HANDLER( cia_sp_w )
776{
777   c1571_t *c1571 = get_safe_token(device->owner());
778437
438WRITE_LINE_MEMBER( c1571_device::cia_sp_w )
439{
779440   /* fast serial data out */
780   c1571->sp_out = state;
781   iec_data_w(device->owner());
441   m_sp_out = state;
442   set_iec_data();
782443}
783444
445
784446static MOS6526_INTERFACE( cia_intf )
785447{
786448   0,
787   DEVCB_LINE(cia_irq_w),
449   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1571_device, cia_irq_w),
788450   DEVCB_NULL,
789   DEVCB_LINE(cia_cnt_w),
790   DEVCB_LINE(cia_sp_w),
451   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1571_device, cia_cnt_w),
452   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1571_device, cia_sp_w),
791453   DEVCB_NULL,
792454   DEVCB_NULL,
793455   DEVCB_NULL,
794456   DEVCB_NULL
795457};
796458
797/*-------------------------------------------------
798    wd17xx_interface wd1770_intf
799-------------------------------------------------*/
800459
801static const wd17xx_interface wd1770_intf =
460//-------------------------------------------------
461//  C64H156_INTERFACE( ga_intf )
462//-------------------------------------------------
463
464WRITE_LINE_MEMBER( c1571_device::atn_w )
802465{
466   set_iec_data();
467}
468
469
470WRITE_LINE_MEMBER( c1571_device::byte_w )
471{
472   m_maincpu->set_input_line(M6502_SET_OVERFLOW, state);
473   m_via1->write_ca1(state);
474}
475
476
477static C64H156_INTERFACE( ga_intf )
478{
479   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1571_device, atn_w),
480   DEVCB_NULL,
481   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1571_device, byte_w)
482};
483
484
485//-------------------------------------------------
486//  wd17xx_interface fdc_intf
487//-------------------------------------------------
488
489static const wd17xx_interface fdc_intf =
490{
803491   DEVCB_LINE_GND,
804492   DEVCB_NULL,
805493   DEVCB_NULL,
806494   { FLOPPY_0, NULL, NULL, NULL }
807495};
808496
809/*-------------------------------------------------
810    FLOPPY_OPTIONS( c1571 )
811-------------------------------------------------*/
812497
498//-------------------------------------------------
499//  FLOPPY_OPTIONS( c1571 )
500//-------------------------------------------------
501
813502static FLOPPY_OPTIONS_START( c1571 )
814503   FLOPPY_OPTION( c1571, "g64", "Commodore 1541 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL )
815504   FLOPPY_OPTION( c1571, "d64", "Commodore 1541 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL )
816505   FLOPPY_OPTION( c1571, "d71", "Commodore 1571 Disk Image", d71_dsk_identify, d64_dsk_construct, NULL )
817506FLOPPY_OPTIONS_END
818507
819/*-------------------------------------------------
820    floppy_config c1570_floppy_config
821-------------------------------------------------*/
822508
823static WRITE_LINE_DEVICE_HANDLER( wpt_w )
824{
825   c1571_t *c1571 = get_safe_token(device->owner());
509//-------------------------------------------------
510//  floppy_config c1571_floppy_config
511//-------------------------------------------------
826512
827   c1571->via0->write_ca2(!state);
513WRITE_LINE_MEMBER( c1571_device::wpt_w )
514{
515   m_via0->write_ca2(!state);
828516}
829517
830static const floppy_config c1570_floppy_config =
831{
832   DEVCB_NULL,
833   DEVCB_NULL,
834   DEVCB_NULL,
835   DEVCB_LINE(wpt_w),
836   DEVCB_NULL,
837   FLOPPY_STANDARD_5_25_SSDD,
838   FLOPPY_OPTIONS_NAME(c1571),
839   NULL
840};
841518
842/*-------------------------------------------------
843    floppy_config c1571_floppy_config
844-------------------------------------------------*/
845
846519static const floppy_config c1571_floppy_config =
847520{
848521   DEVCB_NULL,
849522   DEVCB_NULL,
850523   DEVCB_NULL,
851   DEVCB_LINE(wpt_w),
524   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1571_device, wpt_w),
852525   DEVCB_NULL,
853   FLOPPY_STANDARD_5_25_DSHD,
526   FLOPPY_STANDARD_5_25_DSDD,
854527   FLOPPY_OPTIONS_NAME(c1571),
855528   NULL
856529};
857530
858/*-------------------------------------------------
859    MACHINE_DRIVER( c1570 )
860-------------------------------------------------*/
861531
862static MACHINE_CONFIG_FRAGMENT( c1570 )
863   MCFG_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
864   MCFG_CPU_PROGRAM_MAP(c1570_map)
532//-------------------------------------------------
533//  MACHINE_DRIVER( c1571 )
534//-------------------------------------------------
865535
866   MCFG_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/16, via0_intf)
867   MCFG_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/16, via1_intf)
868   MCFG_MOS6526R1_ADD(M6526_TAG, XTAL_16MHz/16, cia_intf)
869   MCFG_WD1770_ADD(WD1770_TAG, /* XTAL_16MHz/2, */ wd1770_intf)
870
871   MCFG_FLOPPY_DRIVE_ADD(FLOPPY_0, c1570_floppy_config)
872MACHINE_CONFIG_END
873
874/*-------------------------------------------------
875    MACHINE_DRIVER( c1571 )
876-------------------------------------------------*/
877
878536static MACHINE_CONFIG_FRAGMENT( c1571 )
879537   MCFG_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
880   MCFG_CPU_PROGRAM_MAP(c1571_map)
538   MCFG_CPU_PROGRAM_MAP(c1571_mem)
881539
882540   MCFG_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/16, via0_intf)
883541   MCFG_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/16, via1_intf)
884542   MCFG_MOS6526R1_ADD(M6526_TAG, XTAL_16MHz/16, cia_intf)
885   MCFG_WD1770_ADD(WD1770_TAG, /* XTAL_16MHz/2, */ wd1770_intf)
543   MCFG_WD1770_ADD(WD1770_TAG, /* XTAL_16MHz/2, */ fdc_intf)
886544
887545   MCFG_FLOPPY_DRIVE_ADD(FLOPPY_0, c1571_floppy_config)
546   MCFG_64H156_ADD(C64H156_TAG, XTAL_16MHz, ga_intf)
888547MACHINE_CONFIG_END
889548
890/*-------------------------------------------------
891    MACHINE_DRIVER( c1571cr )
892-------------------------------------------------*/
893549
894static MACHINE_CONFIG_FRAGMENT( c1571cr )
895   MCFG_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
896   MCFG_CPU_PROGRAM_MAP(c1571cr_map)
550//-------------------------------------------------
551//  machine_config_additions - device-specific
552//  machine configurations
553//-------------------------------------------------
897554
898   MCFG_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/16, via0_intf)
899   MCFG_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/16, via1_intf)
900   MCFG_MOS6526R1_ADD(M6526_TAG, XTAL_16MHz/16, cia_intf)
901   MCFG_WD1770_ADD(WD1770_TAG, /* XTAL_16MHz/2, */ wd1770_intf)
555machine_config_constructor c1571_device_config::device_mconfig_additions() const
556{
557   return MACHINE_CONFIG_NAME( c1571 );
558}
902559
903   MCFG_FLOPPY_DRIVE_ADD(FLOPPY_0, c1571_floppy_config)
904MACHINE_CONFIG_END
905560
906/*-------------------------------------------------
907    ROM( c1570 )
908-------------------------------------------------*/
909561
910ROM_START( c1570 )
911   ROM_REGION( 0x8000, "c1570", ROMREGION_LOADBYNAME )
912   ROM_LOAD( "315090-01.u2", 0x0000, 0x8000, CRC(5a0c7937) SHA1(5fc06dc82ff6840f183bd43a4d9b8a16956b2f56) )
913ROM_END
562//**************************************************************************
563//  INLINE HELPERS
564//**************************************************************************
914565
915/*-------------------------------------------------
916    ROM( c1571 )
917-------------------------------------------------*/
566//-------------------------------------------------
567//  c1571_device - constructor
568//-------------------------------------------------
918569
919ROM_START( c1571 )
920   ROM_REGION( 0x10000, "c1571", ROMREGION_LOADBYNAME )
921   ROM_LOAD_OPTIONAL( "310654-03.u2", 0x0000, 0x8000, CRC(3889b8b8) SHA1(e649ef4419d65829d2afd65e07d31f3ce147d6eb) )
922   ROM_LOAD( "310654-05.u2", 0x0000, 0x8000, CRC(5755bae3) SHA1(f1be619c106641a685f6609e4d43d6fc9eac1e70) )
923   ROM_LOAD_OPTIONAL( "jiffydos 1571.u2", 0x8000, 0x8000, CRC(fe6cac6d) SHA1(d4b79b60cf1eaa399d0932200eb7811e00455249) )
924ROM_END
570inline void c1571_device::set_iec_data()
571{
572   int data = !m_data_out & !m_ga->atn_r();
925573
926/*-------------------------------------------------
927    ROM( c1571cr )
928-------------------------------------------------*/
574   /* fast serial data */
575   if (m_ser_dir) data &= m_sp_out;
929576
930ROM_START( c1571cr )
931   ROM_REGION( 0x10000, "c1571cr", ROMREGION_LOADBYNAME )
932   ROM_LOAD( "318047-01.u102", 0x0000, 0x8000, CRC(f24efcc4) SHA1(14ee7a0fb7e1c59c51fbf781f944387037daa3ee) )
933   ROM_LOAD_OPTIONAL( "jiffydos 1571d.u102", 0x8000, 0x8000, CRC(9cba146d) SHA1(823b178561302b403e6bfd8dd741d757efef3958) )
934ROM_END
577   cbm_iec_data_w(m_bus, this, data);
578}
935579
936/*-------------------------------------------------
937    DEVICE_START( c1571 )
938-------------------------------------------------*/
939580
940static DEVICE_START( c1571 )
581//-------------------------------------------------
582//  c1571_device - constructor
583//-------------------------------------------------
584
585inline void c1571_device::set_iec_srq()
941586{
942   c1571_t *c1571 = get_safe_token(device);
943   const c1571_config *config = get_safe_config(device);
587   int srq = 1;
944588
945   /* set serial address */
946   assert((config->address > 7) && (config->address < 12));
947   c1571->address = config->address - 8;
589   /* fast serial clock */
590   if (m_ser_dir) srq &= m_cnt_out;
948591
949   /* find our CPU */
950   c1571->cpu = device->subdevice(M6502_TAG);
592   cbm_iec_srq_w(m_bus, this, srq);
593}
951594
952   /* find devices */
953   c1571->via0 = device->subdevice<via6522_device>(M6522_0_TAG);
954   c1571->via1 = device->subdevice<via6522_device>(M6522_1_TAG);
955   c1571->cia = device->subdevice(M6526_TAG);
956   c1571->wd1770 = device->subdevice(WD1770_TAG);
957   c1571->serial_bus = device->machine().device(config->serial_bus_tag);
958   c1571->image = device->subdevice(FLOPPY_0);
959595
960   /* install image callbacks */
961   floppy_install_unload_proc(c1571->image, on_disk_change);
962   floppy_install_load_proc(c1571->image, on_disk_change);
963596
964   /* allocate data timer */
965   c1571->bit_timer = device->machine().scheduler().timer_alloc(FUNC(bit_tick), (void *)device);
597//**************************************************************************
598//  LIVE DEVICE
599//**************************************************************************
966600
967   /* register for state saving */
968   device->save_item(NAME(c1571->address));
969   device->save_item(NAME(c1571->data_out));
970   device->save_item(NAME(c1571->atn_ack));
971   device->save_item(NAME(c1571->ser_dir));
972   device->save_item(NAME(c1571->sp_out));
973   device->save_item(NAME(c1571->cnt_out));
974   device->save_item(NAME(c1571->stp));
975   device->save_item(NAME(c1571->mtr));
976   device->save_item(NAME(c1571->track_len));
977   device->save_item(NAME(c1571->buffer_pos));
978   device->save_item(NAME(c1571->bit_pos));
979   device->save_item(NAME(c1571->bit_count));
980   device->save_item(NAME(c1571->data));
981   device->save_item(NAME(c1571->yb));
982   device->save_item(NAME(c1571->ds));
983   device->save_item(NAME(c1571->soe));
984   device->save_item(NAME(c1571->byte));
985   device->save_item(NAME(c1571->mode));
986   device->save_item(NAME(c1571->side));
987   device->save_item(NAME(c1571->via0_irq));
988   device->save_item(NAME(c1571->via1_irq));
989   device->save_item(NAME(c1571->cia_irq));
601//-------------------------------------------------
602//  c1571_device - constructor
603//-------------------------------------------------
604
605c1571_device::c1571_device(running_machine &_machine, const c1571_device_config &_config)
606    : device_t(_machine, _config),
607     m_maincpu(*this, M6502_TAG),
608     m_via0(*this, M6522_0_TAG),
609     m_via1(*this, M6522_1_TAG),
610     m_cia(*this, M6526_TAG),
611     m_fdc(*this, WD1770_TAG),
612     m_ga(*this, C64H156_TAG),
613     m_image(*this, FLOPPY_0),
614     m_bus(machine().device(_config.m_bus_tag)),
615     m_1_2mhz(0),
616     m_data_out(1),
617     m_ser_dir(0),
618     m_sp_out(1),
619     m_cnt_out(1),
620     m_via0_irq(0),
621     m_via1_irq(0),
622     m_cia_irq(0),
623      m_config(_config)
624{
990625}
991626
992/*-------------------------------------------------
993    DEVICE_RESET( c1571 )
994-------------------------------------------------*/
995627
996static DEVICE_RESET( c1571 )
628//-------------------------------------------------
629//  device_start - device-specific startup
630//-------------------------------------------------
631
632void c1571_device::device_start()
997633{
998   c1571_t *c1571 = get_safe_token(device);
634   // install image callbacks
635   floppy_install_unload_proc(m_image, c1571_device::on_disk_change);
636   floppy_install_load_proc(m_image, c1571_device::on_disk_change);
999637
1000   c1571->cpu->reset();
1001   c1571->via0->reset();
1002   c1571->via1->reset();
1003   c1571->cia->reset();
1004   c1571->wd1770->reset();
1005
1006   c1571->sp_out = 1;
1007   c1571->cnt_out = 1;
638   /* register for state saving */
639   save_item(NAME(m_1_2mhz));
640   save_item(NAME(m_data_out));
641   save_item(NAME(m_ser_dir));
642   save_item(NAME(m_sp_out));
643   save_item(NAME(m_cnt_out));
644   save_item(NAME(m_via0_irq));
645   save_item(NAME(m_via1_irq));
646   save_item(NAME(m_cia_irq));
1008647}
1009648
1010/*-------------------------------------------------
1011    DEVICE_GET_INFO( c1570 )
1012-------------------------------------------------*/
1013649
1014DEVICE_GET_INFO( c1570 )
650//-------------------------------------------------
651//  device_reset - device-specific reset
652//-------------------------------------------------
653
654void c1571_device::device_reset()
1015655{
1016   switch (state)
1017   {
1018      /* --- the following bits of info are returned as 64-bit signed integers --- */
1019      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(c1571_t);                           break;
1020      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(c1571_config);                        break;
656   m_sp_out = 1;
657   set_iec_data();
1021658
1022      /* --- the following bits of info are returned as pointers --- */
1023      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c1570);                     break;
1024      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME(c1570);         break;
659   m_cnt_out = 1;
660   set_iec_srq();
661}
1025662
1026      /* --- the following bits of info are returned as pointers to data or functions --- */
1027      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(c1571);                  break;
1028      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
1029      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(c1571);                  break;
1030663
1031      /* --- the following bits of info are returned as NULL-terminated strings --- */
1032      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 1570");                     break;
1033      case DEVINFO_STR_SHORTNAME:                  strcpy(info->s, "c1570");                           break;
1034      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Commodore 1571");                     break;
1035      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
1036      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
1037      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
1038   }
664//-------------------------------------------------
665//  iec_atn_w -
666//-------------------------------------------------
667
668WRITE_LINE_MEMBER( c1571_device::iec_atn_w )
669{
670   m_via0->write_ca1(!state);
671   m_ga->atni_w(!state);
672
673   set_iec_data();
1039674}
1040675
1041/*-------------------------------------------------
1042    DEVICE_GET_INFO( c1571 )
1043-------------------------------------------------*/
1044676
1045DEVICE_GET_INFO( c1571 )
677//-------------------------------------------------
678//  iec_srq_w -
679//-------------------------------------------------
680
681WRITE_LINE_MEMBER( c1571_device::iec_srq_w )
1046682{
1047   switch (state)
683   if (!m_ser_dir)
1048684   {
1049      /* --- the following bits of info are returned as pointers --- */
1050      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c1571);                     break;
1051      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME(c1571);         break;
1052
1053      /* --- the following bits of info are returned as NULL-terminated strings --- */
1054      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 1571");                     break;
1055      case DEVINFO_STR_SHORTNAME:                  strcpy(info->s, "c1571");                           break;
1056
1057      default:                              DEVICE_GET_INFO_CALL(c1570);                        break;
685      //m_cia->cnt_w(state);
1058686   }
1059687}
1060688
1061/*-------------------------------------------------
1062    DEVICE_GET_INFO( c1571cr )
1063-------------------------------------------------*/
1064689
1065DEVICE_GET_INFO( c1571cr )
690//-------------------------------------------------
691//  iec_data_w -
692//-------------------------------------------------
693
694WRITE_LINE_MEMBER( c1571_device::iec_data_w )
1066695{
1067   switch (state)
696   if (!m_ser_dir)
1068697   {
1069      /* --- the following bits of info are returned as pointers --- */
1070      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c1571cr);                  break;
1071      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME(c1571cr);      break;
698      //m_cia->sp_w(state);
699   }
700}
1072701
1073      /* --- the following bits of info are returned as NULL-terminated strings --- */
1074      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 1571CR");                  break;
1075      case DEVINFO_STR_SHORTNAME:                  strcpy(info->s, "c1571cr");                           break;
1076702
1077      default:                              DEVICE_GET_INFO_CALL(c1570);                        break;
703//-------------------------------------------------
704//  iec_reset_w -
705//-------------------------------------------------
706
707WRITE_LINE_MEMBER( c1571_device::iec_reset_w )
708{
709   if (!state)
710   {
711      device_reset();
1078712   }
1079713}
1080714
1081DEFINE_LEGACY_DEVICE(C1570,  c1570);
1082DEFINE_LEGACY_DEVICE(C1571, c1571);
1083DEFINE_LEGACY_DEVICE(C1571CR, c1571cr);
715
716//-------------------------------------------------
717//  on_disk_change -
718//-------------------------------------------------
719
720void c1571_device::on_disk_change(device_image_interface &image)
721{
722    c1571_device *c1571 = static_cast<c1571_device *>(image.device().owner());
723
724   c1571->m_ga->on_disk_changed();
725}
src/mess/machine/c1571.h
r11248r11249
77
88**********************************************************************/
99
10#pragma once
11
1012#ifndef __C1571__
1113#define __C1571__
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/64h156.h"
23#include "machine/6522via.h"
24#include "machine/6526cia.h"
25#include "machine/cbmiec.h"
26#include "machine/wd17xx.h"
1427
15/***************************************************************************
16    MACROS / CONSTANTS
17***************************************************************************/
1828
19DECLARE_LEGACY_DEVICE(C1570,  c1570);
20DECLARE_LEGACY_DEVICE(C1571, c1571);
21DECLARE_LEGACY_DEVICE(C1571CR, c1571cr);
2229
23#define MCFG_C1570_ADD(_tag, _serial_bus_tag, _address) \
24   MCFG_DEVICE_ADD(_tag, C1570, 0) \
25   MCFG_DEVICE_CONFIG_DATAPTR(c1571_config, serial_bus_tag, _serial_bus_tag) \
26   MCFG_DEVICE_CONFIG_DATA32(c1571_config, address, _address)
30//**************************************************************************
31//  INTERFACE CONFIGURATION MACROS
32//**************************************************************************
2733
28#define MCFG_C1571_ADD(_tag, _serial_bus_tag, _address) \
29   MCFG_DEVICE_ADD(_tag, C1571, 0) \
30   MCFG_DEVICE_CONFIG_DATAPTR(c1571_config, serial_bus_tag, _serial_bus_tag) \
31   MCFG_DEVICE_CONFIG_DATA32(c1571_config, address, _address)
34#define MCFG_C1571_ADD(_tag, _bus_tag, _address) \
35    MCFG_DEVICE_ADD(_tag, C1571, 0) \
36   c1571_device_config::static_set_config(device, _bus_tag, _address);
3237
33#define MCFG_C1571CR_ADD(_tag, _serial_bus_tag, _address) \
34   MCFG_DEVICE_ADD(_tag, C1571CR, 0) \
35   MCFG_DEVICE_CONFIG_DATAPTR(c1571_config, serial_bus_tag, _serial_bus_tag) \
36   MCFG_DEVICE_CONFIG_DATA32(c1571_config, address, _address)
3738
3839#define C1571_IEC(_tag) \
39   _tag, DEVCB_DEVICE_LINE(_tag, c1571_iec_srq_w), DEVCB_DEVICE_LINE(_tag, c1571_iec_atn_w), DEVCB_NULL, DEVCB_DEVICE_LINE(_tag, c1571_iec_data_w), DEVCB_DEVICE_LINE(_tag, c1571_iec_reset_w)
40   _tag, \
41   DEVCB_DEVICE_LINE_MEMBER(_tag, c1571_device, iec_srq_w), \
42   DEVCB_DEVICE_LINE_MEMBER(_tag, c1571_device, iec_atn_w), \
43   DEVCB_NULL, \
44   DEVCB_DEVICE_LINE_MEMBER(_tag, c1571_device, iec_data_w), \
45   DEVCB_DEVICE_LINE_MEMBER(_tag, c1571_device, iec_reset_w)
4046
41/***************************************************************************
42    TYPE DEFINITIONS
43***************************************************************************/
4447
45typedef struct _c1571_config c1571_config;
46struct _c1571_config
48
49//**************************************************************************
50//  TYPE DEFINITIONS
51//**************************************************************************
52
53// ======================> c1571_device_config
54
55class c1571_device_config :   public device_config
4756{
48   const char *serial_bus_tag;   /* serial bus device */
49   int address;            /* serial address */
57    friend class c1571_device;
58
59    // construction/destruction
60    c1571_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
61
62public:
63    // allocators
64    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
65    virtual device_t *alloc_device(running_machine &machine) const;
66
67   // inline configuration helpers
68   static void static_set_config(device_config *device, const char *bus_tag, int address);
69
70   // optional information overrides
71   virtual const rom_entry *device_rom_region() const;
72   virtual machine_config_constructor device_mconfig_additions() const;
73
74protected:
75    // device_config overrides
76    virtual void device_config_complete();
77   
78private:
79   const char *m_bus_tag;
80   int m_address;
5081};
5182
52/***************************************************************************
53    PROTOTYPES
54***************************************************************************/
5583
56/* IEC interface */
57WRITE_LINE_DEVICE_HANDLER( c1571_iec_srq_w );
58WRITE_LINE_DEVICE_HANDLER( c1571_iec_atn_w );
59WRITE_LINE_DEVICE_HANDLER( c1571_iec_data_w );
60WRITE_LINE_DEVICE_HANDLER( c1571_iec_reset_w );
84// ======================> c1571_device
6185
86class c1571_device :  public device_t
87{
88    friend class c1571_device_config;
89
90    // construction/destruction
91    c1571_device(running_machine &_machine, const c1571_device_config &_config);
92
93public:
94   DECLARE_WRITE_LINE_MEMBER( iec_atn_w );
95   DECLARE_WRITE_LINE_MEMBER( iec_srq_w );
96   DECLARE_WRITE_LINE_MEMBER( iec_data_w );
97   DECLARE_WRITE_LINE_MEMBER( iec_reset_w );
98
99   // not really public
100   static void on_disk_change(device_image_interface &image);
101
102   DECLARE_WRITE_LINE_MEMBER( via0_irq_w );
103   DECLARE_READ8_MEMBER( via0_pa_r );
104   DECLARE_WRITE8_MEMBER( via0_pa_w );
105   DECLARE_READ8_MEMBER( via0_pb_r );
106   DECLARE_WRITE8_MEMBER( via0_pb_w );
107   DECLARE_READ_LINE_MEMBER( atn_in_r );
108   DECLARE_READ_LINE_MEMBER( wprt_r );
109   DECLARE_WRITE_LINE_MEMBER( via1_irq_w );
110   DECLARE_READ8_MEMBER( via1_pb_r );
111   DECLARE_WRITE8_MEMBER( via1_pb_w );
112   DECLARE_WRITE_LINE_MEMBER( cia_irq_w );
113   DECLARE_WRITE_LINE_MEMBER( cia_cnt_w );
114   DECLARE_WRITE_LINE_MEMBER( cia_sp_w );
115   DECLARE_WRITE_LINE_MEMBER( atn_w );
116   DECLARE_WRITE_LINE_MEMBER( byte_w );
117   DECLARE_WRITE_LINE_MEMBER( wpt_w );
118
119protected:
120    // device-level overrides
121    virtual void device_start();
122   virtual void device_reset();
123
124private:
125   inline void set_iec_data();
126   inline void set_iec_srq();
127
128   required_device<cpu_device> m_maincpu;
129   required_device<via6522_device> m_via0;
130   required_device<via6522_device> m_via1;
131   required_device<mos6526_device> m_cia;
132   required_device<device_t> m_fdc;
133   required_device<c64h156_device> m_ga;
134   required_device<device_t> m_image;
135   device_t *m_bus;
136
137   // signals
138   int m_1_2mhz;                     // clock speed
139
140   // IEC bus
141   int m_data_out;                     // serial data out
142   int m_ser_dir;                     // fast serial direction
143   int m_sp_out;                     // fast serial data out
144   int m_cnt_out;                     // fast serial clock out
145
146   // interrupts
147   int m_via0_irq;                     // VIA #0 interrupt request
148   int m_via1_irq;                     // VIA #1 interrupt request
149   int m_cia_irq;                     // CIA interrupt request
150
151    const c1571_device_config &m_config;
152};
153
154
155
156// device type definition
157extern const device_type C1571;
158
159
160
62161#endif
src/mess/drivers/c128.c
r11248r11249
802802
803803static MACHINE_CONFIG_DERIVED( c128dcr, c128 )
804804
805   MCFG_DEVICE_REMOVE("c1571")
806   MCFG_C1571CR_ADD("c1571", "iec", 8)
805//   MCFG_DEVICE_REMOVE("c1571")
806//   MCFG_C1571CR_ADD("c1571", "iec", 8)
807807MACHINE_CONFIG_END
808808
809809static MACHINE_CONFIG_DERIVED( c128d81, c128 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team