Previous 15994 Revisions Next

r11268 Thursday 21st April, 2011 at 19:35:28 UTC by Curt Coder
Implemented Commodore 2031 disk drive. (no whatsnew)
[src/mess]mess.mak
[src/mess/drivers]vic20.c
[src/mess/machine]c1541.c c1541.h c2031.c* c2031.h*

src/mess/machine/c2031.c
r0r11268
1/**********************************************************************
2
3    Commodore 2031 Single Disk Drive emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10
11#include "c2031.h"
12
13
14
15//**************************************************************************
16//  MACROS / CONSTANTS
17//**************************************************************************
18
19#define M6502_TAG      "ucd5"
20#define M6522_0_TAG      "uab1"
21#define M6522_1_TAG      "ucd4"
22#define C64H156_TAG      "64h156"
23
24
25enum
26{
27   LED_POWER = 0,
28   LED_ACT
29};
30
31
32
33//**************************************************************************
34//  DEVICE DEFINITIONS
35//**************************************************************************
36
37const device_type C2031 = c2031_device_config::static_alloc_device_config;
38
39
40
41//**************************************************************************
42//  DEVICE CONFIGURATION
43//**************************************************************************
44
45//-------------------------------------------------
46//  c2031_device_config - constructor
47//-------------------------------------------------
48
49c2031_device_config::c2031_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
50   : device_config(mconfig, static_alloc_device_config, "C2031", tag, owner, clock),
51     device_config_ieee488_interface(mconfig, *this)
52{
53}
54
55
56//-------------------------------------------------
57//  static_alloc_device_config - allocate a new
58//  configuration object
59//-------------------------------------------------
60
61device_config *c2031_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
62{
63   return global_alloc(c2031_device_config(mconfig, tag, owner, clock));
64}
65
66
67//-------------------------------------------------
68//  alloc_device - allocate a new device object
69//-------------------------------------------------
70
71device_t *c2031_device_config::alloc_device(running_machine &machine) const
72{
73   return auto_alloc(machine, c2031_device(machine, *this));
74}
75
76
77//-------------------------------------------------
78//  device_config_complete - perform any
79//  operations now that the configuration is
80//  complete
81//-------------------------------------------------
82
83void c2031_device_config::device_config_complete()
84{
85   m_shortname = "c2031";
86}
87
88
89//-------------------------------------------------
90//  static_set_config - configuration helper
91//-------------------------------------------------
92
93void c2031_device_config::static_set_config(device_config *device, int address)
94{
95   c2031_device_config *c2031 = downcast<c2031_device_config *>(device);
96
97   assert((address > 7) && (address < 12));
98
99   c2031->m_address = address - 8;
100}
101
102
103//-------------------------------------------------
104//  ROM( c2031 )
105//-------------------------------------------------
106
107ROM_START( c2031 )
108   ROM_REGION( 0x4000, M6502_TAG, 0 )
109   ROM_LOAD( "901484-03.u5f", 0x0000, 0x2000, CRC(ee4b893b) SHA1(54d608f7f07860f24186749f21c96724dd48bc50) )
110   ROM_LOAD( "901484-05.u5h", 0x2000, 0x2000, CRC(6a629054) SHA1(ec6b75ecfdd4744e5d57979ef6af990444c11ae1) )
111ROM_END
112
113
114//-------------------------------------------------
115//  rom_region - device-specific ROM region
116//-------------------------------------------------
117
118const rom_entry *c2031_device_config::device_rom_region() const
119{
120   return ROM_NAME( c2031 );
121}
122
123
124//-------------------------------------------------
125//  ADDRESS_MAP( c2031_mem )
126//-------------------------------------------------
127
128static ADDRESS_MAP_START( c2031_mem, AS_PROGRAM, 8, c2031_device )
129   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x6000) AM_RAM
130   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_0_TAG, via6522_device, read, write)
131   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_1_TAG, via6522_device, read, write)
132   AM_RANGE(0x8000, 0xbfff) AM_MIRROR(0x4000) // AM_ROM
133ADDRESS_MAP_END
134
135
136//-------------------------------------------------
137//  via6522_interface via0_intf
138//-------------------------------------------------
139
140WRITE_LINE_MEMBER( c2031_device::via0_irq_w )
141{
142   m_via0_irq = state;
143
144   m_maincpu->set_input_line(INPUT_LINE_IRQ0, (m_via0_irq | m_via1_irq) ? ASSERT_LINE : CLEAR_LINE);
145}
146
147
148READ8_MEMBER( c2031_device::via0_pa_r )
149{
150   /*
151
152        bit     description
153
154        PA0     DI0
155        PA1     DI1
156        PA2     DI2
157        PA3     DI3
158        PA4     DI4
159        PA5     DI5
160        PA6     DI6
161        PA7     DI7
162
163    */
164
165   return m_bus->dio_r();
166}
167
168
169WRITE8_MEMBER( c2031_device::via0_pa_w )
170{
171   /*
172
173        bit     description
174
175        PA0     DI0
176        PA1     DI1
177        PA2     DI2
178        PA3     DI3
179        PA4     DI4
180        PA5     DI5
181        PA6     DI6
182        PA7     DI7
183
184    */
185
186   m_bus->dio_w(this, data);
187}
188
189
190READ8_MEMBER( c2031_device::via0_pb_r )
191{
192   /*
193
194        bit     description
195
196        PB0     ATNA
197        PB1     NRFD
198        PB2     NDAC
199        PB3     EOI
200        PB4     T/_R
201        PB5     HD SEL
202        PB6     DAV
203        PB7     _ATN
204
205    */
206
207   UINT8 data = 0;
208
209   // not ready for data
210   data |= m_bus->nrfd_r() << 1;
211
212   // not data accepted
213   data |= m_bus->ndac_r() << 2;
214
215   // end or identify
216   data |= m_bus->eoi_r() << 3;
217
218   // data valid
219   data |= m_bus->dav_r() << 6;
220
221   // attention
222   data |= !m_bus->atn_r() << 7;
223
224   return data;
225}
226
227
228WRITE8_MEMBER( c2031_device::via0_pb_w )
229{
230   /*
231
232        bit     description
233
234        PB0     ATNA
235        PB1     NRFD
236        PB2     NDAC
237        PB3     EOI
238        PB4     T/_R
239        PB5     HD SEL
240        PB6     DAV
241        PB7     _ATN
242
243    */
244
245   int atna = BIT(data, 0);
246   int nrfd = BIT(data, 1);
247   int ndac = BIT(data, 2);
248
249   // not ready for data
250   m_nrfd_out = nrfd;
251
252   // not data accepted
253   m_ndac_out = ndac;
254
255   // end or identify
256   m_bus->eoi_w(this, BIT(data, 3));
257
258   // data valid
259   m_bus->dav_w(this, BIT(data, 6));
260
261   // attention acknowledge
262   m_atna = atna;
263
264   if (!m_bus->atn_r() ^ atna)
265   {
266      nrfd = ndac = 0;
267   }
268
269   m_bus->nrfd_w(this, nrfd);
270   m_bus->ndac_w(this, ndac);
271}
272
273
274READ_LINE_MEMBER( c2031_device::via0_ca1_r )
275{
276   return !m_bus->atn_r();
277}
278
279
280READ_LINE_MEMBER( c2031_device::via0_ca2_r )
281{
282   int state = 0;
283
284   /*
285   switch (m_config.m_address)
286   {
287   case 0: state = (m_atna | m_nrfd_out);   break;
288   case 1: state = m_atna;               break;
289   case 2: state = m_nrfd_out;            break;
290   case 3: state = 0;                  break;
291   }
292   */
293
294   return state;
295}
296
297
298static const via6522_interface via0_intf =
299{
300   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_pa_r),
301   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_pb_r),
302   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_ca1_r),
303   DEVCB_NULL,
304   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_ca2_r),
305   DEVCB_NULL,
306
307   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_pa_w),
308   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_pb_w),
309   DEVCB_NULL,
310   DEVCB_NULL,
311   DEVCB_NULL,
312   DEVCB_NULL, // PLL SYN
313
314   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_irq_w)
315};
316
317
318//-------------------------------------------------
319//  via6522_interface via1_intf
320//-------------------------------------------------
321
322WRITE_LINE_MEMBER( c2031_device::via1_irq_w )
323{
324   m_via1_irq = state;
325
326   m_maincpu->set_input_line(INPUT_LINE_IRQ0, (m_via0_irq | m_via1_irq) ? ASSERT_LINE : CLEAR_LINE);
327}
328
329
330READ8_MEMBER( c2031_device::via1_pb_r )
331{
332   /*
333
334        bit     signal      description
335
336        PB0     
337        PB1     
338        PB2     
339        PB3     
340        PB4     WPS         write protect sense
341        PB5     
342        PB6     
343        PB7     SYNC        SYNC detect line
344
345    */
346
347   UINT8 data = 0;
348
349   // write protect sense
350   data |= !floppy_wpt_r(m_image) << 4;
351
352   // SYNC detect line
353   data |= m_ga->sync_r() << 7;
354
355   return data;
356}
357
358
359WRITE8_MEMBER( c2031_device::via1_pb_w )
360{
361   /*
362
363        bit     signal      description
364
365        PB0     STP0        stepping motor bit 0
366        PB1     STP1        stepping motor bit 1
367        PB2     MTR         motor ON/OFF
368        PB3     ACT         drive 0 LED
369        PB4     
370        PB5     DS0         density select 0
371        PB6     DS1         density select 1
372        PB7     SYNC        SYNC detect line
373
374    */
375
376   // spindle motor
377   m_ga->mtr_w(BIT(data, 2));
378
379   // stepper motor
380   m_ga->stp_w(data & 0x03);
381
382   // activity LED
383   output_set_led_value(LED_ACT, BIT(data, 3));
384
385   // density select
386   m_ga->ds_w((data >> 5) & 0x03);
387}
388
389
390static const via6522_interface via1_intf =
391{
392   DEVCB_DEVICE_MEMBER(C64H156_TAG, c64h156_device, yb_r),
393   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via1_pb_r),
394   DEVCB_DEVICE_LINE_MEMBER(C64H156_TAG, c64h156_device, byte_r),
395   DEVCB_NULL,
396   DEVCB_NULL,
397   DEVCB_NULL,
398
399   DEVCB_DEVICE_MEMBER(C64H156_TAG, c64h156_device, yb_w),
400   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via1_pb_w),
401   DEVCB_NULL,
402   DEVCB_NULL,
403   DEVCB_DEVICE_LINE_MEMBER(C64H156_TAG, c64h156_device, soe_w),
404   DEVCB_DEVICE_LINE_MEMBER(C64H156_TAG, c64h156_device, oe_w),
405
406   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via1_irq_w)
407};
408
409
410//-------------------------------------------------
411//  C64H156_INTERFACE( ga_intf )
412//-------------------------------------------------
413
414WRITE_LINE_MEMBER( c2031_device::byte_w )
415{
416   m_maincpu->set_input_line(M6502_SET_OVERFLOW, state);
417   m_via1->write_ca1(state);
418}
419
420
421static C64H156_INTERFACE( ga_intf )
422{
423   DEVCB_NULL,
424   DEVCB_NULL,
425   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2031_device, byte_w)
426};
427
428
429
430//-------------------------------------------------
431//  FLOPPY_OPTIONS( c2031 )
432//-------------------------------------------------
433
434static FLOPPY_OPTIONS_START( c2031 )
435   FLOPPY_OPTION( c2031, "g64", "Commodore 1541 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL )
436   FLOPPY_OPTION( c2031, "d64", "Commodore 1541 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL )
437FLOPPY_OPTIONS_END
438
439
440//-------------------------------------------------
441//  floppy_config c2031_floppy_config
442//-------------------------------------------------
443
444static const floppy_config c2031_floppy_config =
445{
446   DEVCB_NULL,
447   DEVCB_NULL,
448   DEVCB_NULL,
449   DEVCB_NULL,
450   DEVCB_NULL,
451   FLOPPY_STANDARD_5_25_DSDD,
452   FLOPPY_OPTIONS_NAME(c2031),
453   "floppy_5_25"
454};
455
456
457//-------------------------------------------------
458//  MACHINE_DRIVER( c2031 )
459//-------------------------------------------------
460
461static MACHINE_CONFIG_FRAGMENT( c2031 )
462   MCFG_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
463   MCFG_CPU_PROGRAM_MAP(c2031_mem)
464
465   MCFG_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/16, via0_intf)
466   MCFG_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/16, via1_intf)
467
468   MCFG_FLOPPY_DRIVE_ADD(FLOPPY_0, c2031_floppy_config)
469   MCFG_64H156_ADD(C64H156_TAG, XTAL_16MHz, ga_intf)
470MACHINE_CONFIG_END
471
472
473//-------------------------------------------------
474//  machine_config_additions - device-specific
475//  machine configurations
476//-------------------------------------------------
477
478machine_config_constructor c2031_device_config::device_mconfig_additions() const
479{
480   return MACHINE_CONFIG_NAME( c2031 );
481}
482
483
484
485//**************************************************************************
486//  LIVE DEVICE
487//**************************************************************************
488
489//-------------------------------------------------
490//  c2031_device - constructor
491//-------------------------------------------------
492
493c2031_device::c2031_device(running_machine &_machine, const c2031_device_config &_config)
494    : device_t(_machine, _config),
495     device_ieee488_interface(_machine, _config, *this),
496     m_maincpu(*this, M6502_TAG),
497     m_via0(*this, M6522_0_TAG),
498     m_via1(*this, M6522_1_TAG),
499     m_ga(*this, C64H156_TAG),
500     m_image(*this, FLOPPY_0),
501     m_bus(*this->owner(), IEEE488_TAG),
502     m_nrfd_out(1),
503     m_ndac_out(1),
504     m_atna(1),
505     m_via0_irq(0),
506     m_via1_irq(0),
507      m_config(_config)
508{
509}
510
511
512//-------------------------------------------------
513//  device_start - device-specific startup
514//-------------------------------------------------
515
516void c2031_device::device_start()
517{
518   // map ROM
519   address_space *program = m_maincpu->memory().space(AS_PROGRAM);
520   program->install_rom(0x8000, 0xbfff, 0, 0x4000, subregion(M6502_TAG)->base());
521
522   // install image callbacks
523   floppy_install_unload_proc(m_image, c2031_device::on_disk_change);
524   floppy_install_load_proc(m_image, c2031_device::on_disk_change);
525
526   // register for state saving
527   save_item(NAME(m_nrfd_out));
528   save_item(NAME(m_ndac_out));
529   save_item(NAME(m_atna));
530   save_item(NAME(m_via0_irq));
531   save_item(NAME(m_via1_irq));
532}
533
534
535//-------------------------------------------------
536//  device_reset - device-specific reset
537//-------------------------------------------------
538
539void c2031_device::device_reset()
540{
541}
542
543
544//-------------------------------------------------
545//  ieee488_atn_w -
546//-------------------------------------------------
547
548void c2031_device::ieee488_atn(int state)
549{
550   int nrfd = m_nrfd_out;
551   int ndac = m_ndac_out;
552
553   m_via0->write_ca1(!state);
554
555   if (!state ^ m_atna)
556   {
557      nrfd = ndac = 0;
558   }
559
560   m_bus->nrfd_w(this, nrfd);
561   m_bus->ndac_w(this, ndac);
562}
563
564
565//-------------------------------------------------
566//  ieee488_ifc_w -
567//-------------------------------------------------
568
569void c2031_device::ieee488_ifc(int state)
570{
571   if (!state)
572   {
573      device_reset();
574   }
575}
576
577
578//-------------------------------------------------
579//  on_disk_change -
580//-------------------------------------------------
581
582void c2031_device::on_disk_change(device_image_interface &image)
583{
584    c2031_device *c2031 = static_cast<c2031_device *>(image.device().owner());
585
586   c2031->m_ga->on_disk_changed();
587}
src/mess/machine/c2031.h
r0r11268
1/**********************************************************************
2
3    Commodore 2031 Single Disk Drive emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __C2031__
13#define __C2031__
14
15#define ADDRESS_MAP_MODERN
16
17#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/ieee488.h"
25
26
27
28//**************************************************************************
29//  MACROS / CONSTANTS
30//**************************************************************************
31
32#define C2031_TAG         "c2031"
33
34
35
36//**************************************************************************
37//  INTERFACE CONFIGURATION MACROS
38//**************************************************************************
39
40#define MCFG_C2031_ADD(_tag, _address) \
41    MCFG_DEVICE_ADD(_tag, C2031, 0) \
42   c2031_device_config::static_set_config(device, _address);
43
44
45
46//**************************************************************************
47//  TYPE DEFINITIONS
48//**************************************************************************
49
50// ======================> c2031_device_config
51
52class c2031_device_config :   public device_config,
53                       public device_config_ieee488_interface
54{
55    friend class c2031_device;
56
57    // construction/destruction
58    c2031_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
59
60public:
61   // allocators
62    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
63    virtual device_t *alloc_device(running_machine &machine) const;
64
65   // inline configuration helpers
66   static void static_set_config(device_config *device, int address);
67
68   // optional information overrides
69   virtual const rom_entry *device_rom_region() const;
70   virtual machine_config_constructor device_mconfig_additions() const;
71
72protected:
73   // device_config overrides
74    virtual void device_config_complete();
75   
76   int m_address;
77};
78
79
80// ======================> c2031_device
81
82class c2031_device :  public device_t,
83                 public device_ieee488_interface
84{
85    friend class c2031_device_config;
86
87    // construction/destruction
88    c2031_device(running_machine &_machine, const c2031_device_config &_config);
89
90public:
91   // not really public
92   static void on_disk_change(device_image_interface &image);
93
94   DECLARE_WRITE_LINE_MEMBER( via0_irq_w );
95   DECLARE_READ8_MEMBER( via0_pa_r );
96   DECLARE_WRITE8_MEMBER( via0_pa_w );
97   DECLARE_READ8_MEMBER( via0_pb_r );
98   DECLARE_WRITE8_MEMBER( via0_pb_w );
99   DECLARE_READ_LINE_MEMBER( via0_ca1_r );
100   DECLARE_READ_LINE_MEMBER( via0_ca2_r );
101   DECLARE_WRITE_LINE_MEMBER( via1_irq_w );
102   DECLARE_READ8_MEMBER( via1_pb_r );
103   DECLARE_WRITE8_MEMBER( via1_pb_w );
104   DECLARE_WRITE_LINE_MEMBER( byte_w );
105
106protected:
107    // device-level overrides
108    virtual void device_start();
109   virtual void device_reset();
110
111   // device_ieee488_interface overrides
112   void ieee488_atn(int state);
113   void ieee488_ifc(int state);
114
115   required_device<cpu_device> m_maincpu;
116   required_device<via6522_device> m_via0;
117   required_device<via6522_device> m_via1;
118   required_device<c64h156_device> m_ga;
119   required_device<device_t> m_image;
120   required_device<ieee488_device> m_bus;
121
122   // IEEE-488 bus
123   int m_nrfd_out;            // not ready for data
124   int m_ndac_out;            // not data accepted
125   int m_atna;               // attention acknowledge
126
127   // interrupts
128   int m_via0_irq;                     // VIA #0 interrupt request
129   int m_via1_irq;                     // VIA #1 interrupt request
130
131    const c2031_device_config &m_config;
132};
133
134
135// device type definition
136extern const device_type C2031;
137
138
139
140#endif
src/mess/machine/c1541.c
r11267r11268
11/**********************************************************************
22
3    Commodore 1540/1541/1541C/1541-II/2031 Single Disk Drive emulation
3    Commodore 1540/1541/1541C/1541-II Single Disk Drive emulation
44
55    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
r11267r11268
166166const device_type C1541II = c1541_device_config::static_alloc_device_config;
167167const device_type SX1541 = c1541_device_config::static_alloc_device_config;
168168const device_type OC118 = c1541_device_config::static_alloc_device_config;
169const device_type C2031 = c1541_device_config::static_alloc_device_config;
170169
171170
172171
r11267r11268
240239   case TYPE_OC118:
241240      m_shortname = "oc118";
242241      break;
243
244   case TYPE_C2031:
245      m_shortname = "c2031";
246      break;
247242   }
248243}
249244
r11267r11268
328323
329324
330325//-------------------------------------------------
331//  ROM( c2031 )
332//-------------------------------------------------
333
334ROM_START( c2031 )
335   ROM_REGION( 0x4000, M6502_TAG, 0 )
336   ROM_LOAD( "901484-03.u5f", 0x0000, 0x2000, CRC(ee4b893b) SHA1(54d608f7f07860f24186749f21c96724dd48bc50) )
337   ROM_LOAD( "901484-05.u5h", 0x2000, 0x2000, CRC(6a629054) SHA1(ec6b75ecfdd4744e5d57979ef6af990444c11ae1) )
338ROM_END
339
340
341//-------------------------------------------------
342326//  ROM( oc118 )
343327//-------------------------------------------------
344328
r11267r11268
375359
376360   case TYPE_OC118:
377361      return ROM_NAME( oc118 );
378
379   case TYPE_C2031:
380      return ROM_NAME( c2031 );
381362   }
382363}
383364
r11267r11268
548529
549530
550531//-------------------------------------------------
551//  via6522_interface c2031_via0_intf
552//-------------------------------------------------
553
554READ8_MEMBER( c2031_device::via0_pa_r )
555{
556   /*
557
558        bit     description
559
560        PA0     DI0
561        PA1     DI1
562        PA2     DI2
563        PA3     DI3
564        PA4     DI4
565        PA5     DI5
566        PA6     DI6
567        PA7     DI7
568
569    */
570
571   return m_bus->dio_r();
572}
573
574
575WRITE8_MEMBER( c2031_device::via0_pa_w )
576{
577   /*
578
579        bit     description
580
581        PA0     DI0
582        PA1     DI1
583        PA2     DI2
584        PA3     DI3
585        PA4     DI4
586        PA5     DI5
587        PA6     DI6
588        PA7     DI7
589
590    */
591
592   m_bus->dio_w(this, data);
593}
594
595
596READ8_MEMBER( c2031_device::via0_pb_r )
597{
598   /*
599
600        bit     description
601
602        PB0     ATNA
603        PB1     NRFD
604        PB2     NDAC
605        PB3     EOI
606        PB4     T/_R
607        PB5     HD SEL
608        PB6     DAV
609        PB7     _ATN
610
611    */
612
613   UINT8 data = 0;
614
615   // not ready for data
616   data |= m_bus->nrfd_r() << 1;
617
618   // not data accepted
619   data |= m_bus->ndac_r() << 2;
620
621   // end or identify
622   data |= m_bus->eoi_r() << 3;
623
624   // data valid
625   data |= m_bus->dav_r() << 6;
626
627   // attention
628   data |= !m_bus->atn_r() << 7;
629
630   return data;
631}
632
633
634WRITE8_MEMBER( c2031_device::via0_pb_w )
635{
636   /*
637
638        bit     description
639
640        PB0     ATNA
641        PB1     NRFD
642        PB2     NDAC
643        PB3     EOI
644        PB4     T/_R
645        PB5     HD SEL
646        PB6     DAV
647        PB7     _ATN
648
649    */
650
651   int atna = BIT(data, 0);
652   int nrfd = BIT(data, 1);
653   int ndac = BIT(data, 2);
654
655   // not ready for data
656   m_nrfd_out = nrfd;
657
658   // not data accepted
659   m_ndac_out = ndac;
660
661   // end or identify
662   m_bus->eoi_w(this, BIT(data, 3));
663
664   // data valid
665   m_bus->dav_w(this, BIT(data, 6));
666
667   // attention acknowledge
668   m_atna = atna;
669
670   if (!m_bus->atn_r() ^ atna)
671   {
672      nrfd = ndac = 0;
673   }
674
675   m_bus->nrfd_w(this, nrfd);
676   m_bus->ndac_w(this, ndac);
677}
678
679
680READ_LINE_MEMBER( c2031_device::via0_ca1_r )
681{
682   return !m_bus->atn_r();
683}
684
685
686READ_LINE_MEMBER( c2031_device::via0_ca2_r )
687{
688   int state = 0;
689
690   /*
691   switch (m_config.m_address)
692   {
693   case 0: state = (m_atna | m_nrfd_out);   break;
694   case 1: state = m_atna;               break;
695   case 2: state = m_nrfd_out;            break;
696   case 3: state = 0;                  break;
697   }
698   */
699
700   return state;
701}
702
703
704static const via6522_interface c2031_via0_intf =
705{
706   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_pa_r),
707   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_pb_r),
708   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_ca1_r),
709   DEVCB_NULL,
710   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_ca2_r),
711   DEVCB_NULL,
712
713   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_pa_w),
714   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c2031_device, via0_pb_w),
715   DEVCB_NULL,
716   DEVCB_NULL,
717   DEVCB_NULL,
718   DEVCB_NULL, // PLL SYN
719
720   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1541_device, via0_irq_w)
721};
722
723
724//-------------------------------------------------
725532//  via6522_interface via1_intf
726533//-------------------------------------------------
727534
r11267r11268
899706
900707
901708//-------------------------------------------------
902//  MACHINE_DRIVER( c2031 )
903//-------------------------------------------------
904
905static MACHINE_CONFIG_FRAGMENT( c2031 )
906   MCFG_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
907   MCFG_CPU_PROGRAM_MAP(c1541_mem)
908
909   MCFG_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/16, c2031_via0_intf)
910   MCFG_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/16, c1541_via1_intf)
911
912   MCFG_FLOPPY_DRIVE_ADD(FLOPPY_0, c1541_floppy_config)
913   MCFG_64H156_ADD(C64H156_TAG, XTAL_16MHz, ga_intf)
914MACHINE_CONFIG_END
915
916
917//-------------------------------------------------
918709//  machine_config_additions - device-specific
919710//  machine configurations
920711//-------------------------------------------------
r11267r11268
926717   case TYPE_1541C:
927718      return MACHINE_CONFIG_NAME( c1541c );
928719
929   case TYPE_C2031:
930      return MACHINE_CONFIG_NAME( c2031 );
931
932720   default:
933721      return MACHINE_CONFIG_NAME( c1541 );
934722   }
r11267r11268
1035823
1036824
1037825//-------------------------------------------------
1038//  ieee488_atn_w -
1039//-------------------------------------------------
1040
1041void c2031_device::ieee488_atn(int state)
1042{
1043   int nrfd = m_nrfd_out;
1044   int ndac = m_ndac_out;
1045
1046   m_via0->write_ca1(!state);
1047
1048   if (!state ^ m_atna)
1049   {
1050      nrfd = ndac = 0;
1051   }
1052
1053   m_bus->nrfd_w(this, nrfd);
1054   m_bus->ndac_w(this, ndac);
1055}
1056
1057
1058//-------------------------------------------------
1059//  ieee488_ifc_w -
1060//-------------------------------------------------
1061
1062void c2031_device::ieee488_ifc(int state)
1063{
1064   if (!state)
1065   {
1066      device_reset();
1067   }
1068}
1069
1070
1071//-------------------------------------------------
1072826//  on_disk_change -
1073827//-------------------------------------------------
1074828
src/mess/machine/c1541.h
r11267r11268
11/**********************************************************************
22
3    Commodore 1540/1541/1541C/1541-II/2031 Single Disk Drive emulation
3    Commodore 1540/1541/1541C/1541-II Single Disk Drive emulation
44
55    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
r11267r11268
2222#include "machine/64h156.h"
2323#include "machine/6522via.h"
2424#include "machine/cbmiec.h"
25#include "machine/ieee488.h"
2625
2726
2827
r11267r11268
3130//**************************************************************************
3231
3332#define C1541_TAG         "c1541"
34#define C2031_TAG         "c2031"
3533
3634
3735
r11267r11268
6361    MCFG_DEVICE_ADD(_tag, OC118, 0) \
6462   c1541_device_config::static_set_config(device, _address, c1541_device_config::TYPE_OC118);
6563
66#define MCFG_C2031_ADD(_tag, _address) \
67    MCFG_DEVICE_ADD(_tag, C2031, 0) \
68   c1541_device_config::static_set_config(device, _address, c1541_device_config::TYPE_C2031);
6964
7065
71
7266//**************************************************************************
7367//  TYPE DEFINITIONS
7468//**************************************************************************
r11267r11268
8478    friend class c1541ii_device;
8579    friend class sx1541_device;
8680    friend class oc118_device;
87    friend class c2031_device;
8881
8982    // construction/destruction
9083    c1541_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
r11267r11268
9790      TYPE_1541C,
9891      TYPE_1541II,
9992      TYPE_SX1541,
100      TYPE_OC118,
101      TYPE_C2031
93      TYPE_OC118
10294   };
10395   
10496   // allocators
r11267r11268
235227};
236228
237229
238// ======================> c2031_device
239
240class c2031_device :  public c1541_device,
241                 public device_ieee488_interface
242{
243    friend class c1541_device_config;
244
245    // construction/destruction
246    c2031_device(running_machine &_machine, const c1541_device_config &_config);
247
248public:
249   // not really public
250   DECLARE_READ8_MEMBER( via0_pa_r );
251   DECLARE_WRITE8_MEMBER( via0_pa_w );
252   DECLARE_READ8_MEMBER( via0_pb_r );
253   DECLARE_WRITE8_MEMBER( via0_pb_w );
254   DECLARE_READ_LINE_MEMBER( via0_ca1_r );
255   DECLARE_READ_LINE_MEMBER( via0_ca2_r );
256
257protected:
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
264   int m_nrfd_out;            // not ready for data
265   int m_ndac_out;            // not data accepted
266   int m_atna;               // attention acknowledge
267};
268
269
270230// device type definition
271231extern const device_type C1540;
272232extern const device_type C1541;
r11267r11268
274234extern const device_type C1541II;
275235extern const device_type SX1541;
276236extern const device_type OC118;
277extern const device_type C2031;
278237
279238
280239
src/mess/mess.mak
r11267r11268
765765   $(MESS_MACHINE)/c1551.o      \
766766   $(MESS_MACHINE)/c1571.o      \
767767   $(MESS_MACHINE)/c1581.o      \
768   $(MESS_MACHINE)/c2031.o      \
768769   $(MESS_MACHINE)/c2040.o      \
769770   $(MESS_DRIVERS)/clcd.o      \
770771   $(MESS_MACHINE)/6525tpi.o   \
src/mess/drivers/vic20.c
r11267r11268
7979#include "machine/ram.h"
8080#include "machine/6522via.h"
8181#include "machine/c1541.h"
82#include "machine/c2040.h"
82#include "machine/c2031.h"
8383#include "machine/cbmiec.h"
8484#include "machine/ieee488.h"
8585#include "machine/vic1112.h"
r11267r11268
452452#ifdef INCLUDE_VIC1112
453453static IEEE488_DAISY( ieee488_daisy )
454454{
455   { C4040_TAG },
455   { C2031_TAG },
456456   { NULL}
457457};
458458
r11267r11268
693693   MCFG_C1541_ADD(C1541_TAG, 8)
694694#ifdef INCLUDE_VIC1112
695695    MCFG_VIC1112_ADD(ieee488_daisy)
696    MCFG_C4040_ADD(C4040_TAG, 9)
696    MCFG_C2031_ADD(C2031_TAG, 9)
697697#endif
698698   MCFG_CARTSLOT_ADD("cart")
699699   MCFG_CARTSLOT_EXTENSION_LIST("20,40,60,70,a0,b0")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team