Previous 15994 Revisions Next

r7035 Thursday 14th January, 2010 at 08:13:41 UTC by Curt Coder
[VIC20] Connected VIC-1112 and C2031 to IEEE-488 bus.
[src/mess/machine]c1541.c c1541.h vic1112.c vic1112.h

src/mess/machine/vic1112.c
r7034r7035
99
1010#include "driver.h"
1111#include "vic1112.h"
12#include "cpu/m6502/m6502.h"
1213#include "machine/6522via.h"
14#include "machine/ieee488.h"
1315
1416/***************************************************************************
1517    PARAMETERS
r7034r7035
2729{
2830   const device_config *via0;
2931   const device_config *via1;
30   const device_config *ieee_bus;
32   const device_config *bus;
3133};
3234
3335/***************************************************************************
r7034r7035
5456***************************************************************************/
5557
5658/*-------------------------------------------------
59    vic1112_ieee488_srq_w - IEEE-488 service
60   request
61-------------------------------------------------*/
62
63WRITE_LINE_DEVICE_HANDLER( vic1112_ieee488_srq_w )
64{
65   vic1112_t *vic1112 = get_safe_token(device);
66
67   via_cb1_w(vic1112->bus, state);
68}
69
70/*-------------------------------------------------
5771    via6522_interface vic1112_via0_intf
5872-------------------------------------------------*/
5973
74static WRITE_LINE_DEVICE_HANDLER( via_irq_w )
75{
76   cpu_set_input_line(device->machine->firstcpu, M6502_IRQ_LINE, state);
77}
78
6079static READ8_DEVICE_HANDLER( via0_pb_r )
6180{
6281   /*
r7034r7035
7493
7594    */
7695
77   return 0;
96   vic1112_t *vic1112 = get_safe_token(device->owner);
97   UINT8 data = 0;
98
99   /* data valid in */
100   data |= ieee488_dav_r(vic1112->bus) << 4;
101
102   /* not ready for data in */
103   data |= ieee488_nrfd_r(vic1112->bus) << 5;
104
105   /* not data accepted in */
106   data |= ieee488_ndac_r(vic1112->bus) << 6;
107
108   /* attention in */
109   data |= ieee488_atn_r(vic1112->bus) << 7;
110
111   return data;
78112}
79113
80114static WRITE8_DEVICE_HANDLER( via0_pb_w )
r7034r7035
93127        PB7     _ATN IN
94128
95129    */
130
131   vic1112_t *vic1112 = get_safe_token(device->owner);
132
133   /* data valid out */
134   ieee488_dav_w(vic1112->bus, device->owner, BIT(data, 0));
135
136   /* not ready for data out */
137   ieee488_nrfd_w(vic1112->bus, device->owner, BIT(data, 1));
138
139   /* not data accepted out */
140   ieee488_ndac_w(vic1112->bus, device->owner, BIT(data, 2));
141
142   /* end or identify */
143   ieee488_eoi_w(vic1112->bus, device->owner, BIT(data, 3));
96144}
97145
98146static const via6522_interface vic1112_via0_intf =
r7034r7035
111159   DEVCB_NULL,
112160   DEVCB_NULL,
113161
114   DEVCB_NULL
162   DEVCB_LINE(via_irq_w)
115163};
116164
117165/*-------------------------------------------------
r7034r7035
135183
136184    */
137185
138   return 0;
186   vic1112_t *vic1112 = get_safe_token(device->owner);
187
188   return ieee488_dio_r(vic1112->bus, 0);
139189}
140190
141191static WRITE8_DEVICE_HANDLER( via1_pb_w )
r7034r7035
154204        PB7     DO8
155205
156206    */
207
208   vic1112_t *vic1112 = get_safe_token(device->owner);
209
210   ieee488_dio_w(vic1112->bus, 0, data);
157211}
158212
213static WRITE_LINE_DEVICE_HANDLER( via1_ca2_w )
214{
215   vic1112_t *vic1112 = get_safe_token(device->owner);
216
217   /* attention out */
218   ieee488_atn_w(vic1112->bus, device->owner, state);
219}
220
221static WRITE_LINE_DEVICE_HANDLER( via1_cb2_w )
222{
223   vic1112_t *vic1112 = get_safe_token(device->owner);
224
225   /* end or identify out */
226   ieee488_eoi_w(vic1112->bus, device->owner, state);
227}
228
159229static const via6522_interface vic1112_via1_intf =
160230{
161231   DEVCB_HANDLER(via1_pa_r),
162232   DEVCB_NULL,
163233   DEVCB_NULL,
234   DEVCB_NULL, /* _SRQ IN */
164235   DEVCB_NULL,
165236   DEVCB_NULL,
166   DEVCB_NULL,
167237
168238   DEVCB_NULL,
169239   DEVCB_HANDLER(via1_pb_w),
170240   DEVCB_NULL,
171   DEVCB_NULL, // _SRQ IN
172   DEVCB_NULL, // _ATN OUT
173   DEVCB_NULL, // _EOI
241   DEVCB_NULL,
242   DEVCB_LINE(via1_ca2_w),
243   DEVCB_LINE(via1_cb2_w),
174244
175   DEVCB_NULL
245   DEVCB_LINE(via_irq_w)
176246};
177247
178248/*-------------------------------------------------
r7034r7035
189259-------------------------------------------------*/
190260
191261ROM_START( vic1112 )
192   ROM_REGION( 0x800, "vic1112", ROMREGION_LOADBYNAME )
193   ROM_LOAD( "325329-03.u2", 0x000, 0x800, CRC(dd6147ba) SHA1(3945b9aa417f5905fa52f6f667a3e22add7ab15f) )
262   ROM_REGION( 0x800, VIC1112_TAG, ROMREGION_LOADBYNAME )
263   ROM_LOAD( "325329-03.u2", 0x000, 0x800, CRC(d37b6335) SHA1(828c965829d21c60e8c2d083caee045c639a270f) )
194264ROM_END
195265
196266/*-------------------------------------------------
r7034r7035
201271{
202272   vic1112_t *vic1112 = get_safe_token(device);
203273   const vic1112_config *config = get_safe_config(device);
274   const address_space *program = cpu_get_address_space(device->machine->firstcpu, ADDRESS_SPACE_PROGRAM);
204275
205   /* set IEEE address */
206
207276   /* find devices */
208277   vic1112->via0 = device_find_child_by_tag(device, M6522_0_TAG);
209278   vic1112->via1 = device_find_child_by_tag(device, M6522_1_TAG);
210   vic1112->ieee_bus = devtag_get_device(device->machine, config->ieee_bus_tag);
279   vic1112->bus = devtag_get_device(device->machine, config->bus_tag);
211280
212281   /* set VIA clocks */
213282   device_set_clock(vic1112->via0, cpu_get_clock(device->machine->firstcpu));
214283   device_set_clock(vic1112->via1, cpu_get_clock(device->machine->firstcpu));
215284
216   /* register for state saving */
217//   state_save_register_device_item(device, 0, vic1112->);
285   /* map VIAs to memory */
286   memory_install_readwrite8_device_handler(program, vic1112->via0, 0x9200, 0x920f, 0, 0, via_r, via_w);
287   memory_install_readwrite8_device_handler(program, vic1112->via1, 0x9210, 0x921f, 0, 0, via_r, via_w);
288
289   /* map ROM to memory */
290   memory_install_rom(program, 0xb000, 0xb7ff, 0, 0, memory_region(device->machine, VIC1112_TAG));
218291}
219292
220293/*-------------------------------------------------
r7034r7035
230303   device_reset(vic1112->via1);
231304
232305   /* _IFC */
306   ieee488_ifc_w(vic1112->bus, device, 0);
307   ieee488_ifc_w(vic1112->bus, device, 1);
233308}
234309
235310/*-------------------------------------------------
src/mess/machine/vic1112.h
r7034r7035
2020
2121#define VIC1112   DEVICE_GET_INFO_NAME( vic1112 )
2222
23#define MDRV_VIC1112_ADD(_ieee_bus_tag) \
23#define MDRV_VIC1112_ADD(_bus_tag) \
2424   MDRV_DEVICE_ADD(VIC1112_TAG, VIC1112, 0) \
25   MDRV_DEVICE_CONFIG_DATAPTR(vic1112_config, ieee_bus_tag, _ieee_bus_tag) \
25   MDRV_DEVICE_CONFIG_DATAPTR(vic1112_config, bus_tag, _bus_tag) \
2626
27#define VIC1112_IEEE488 \
28   VIC1112_TAG, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE(VIC1112_TAG, vic1112_ieee488_srq_w), DEVCB_NULL, DEVCB_NULL
29
2730/***************************************************************************
2831    TYPE DEFINITIONS
2932***************************************************************************/
r7034r7035
3134typedef struct _vic1112_config vic1112_config;
3235struct _vic1112_config
3336{
34   const char *ieee_bus_tag;   /* IEEE bus device */
37   const char *bus_tag;   /* bus device */
3538};
3639
3740/***************************************************************************
r7034r7035
4144/* device interface */
4245DEVICE_GET_INFO( vic1112 );
4346
47/* IEEE-488 interface */
48WRITE_LINE_DEVICE_HANDLER( vic1112_ieee488_srq_w );
49
4450#endif
src/mess/machine/c1541.c
r7034r7035
142142#include "formats/g64_dsk.h"
143143#include "machine/6522via.h"
144144#include "machine/cbmiec.h"
145#include "machine/ieee488.h"
145146
146147/***************************************************************************
147148    PARAMETERS
r7034r7035
201202   const device_config *cpu;
202203   const device_config *via0;
203204   const device_config *via1;
204   const device_config *serial_bus;
205   const device_config *bus;
205206   const device_config *image;
206207
207208   /* timers */
r7034r7035
300301
301302   via_ca1_w(c1541->via0, !state);
302303
303   cbm_iec_data_w(c1541->serial_bus, device, data_out);
304   cbm_iec_data_w(c1541->bus, device, data_out);
304305}
305306
306307/*-------------------------------------------------
r7034r7035
316317}
317318
318319/*-------------------------------------------------
320    c2031_ieee488_atn_w - IEEE-488 bus attention
321-------------------------------------------------*/
322
323WRITE_LINE_DEVICE_HANDLER( c2031_ieee488_atn_w )
324{
325   c1541_t *c1541 = get_safe_token(device);
326
327   via_ca1_w(c1541->via0, state);
328}
329
330/*-------------------------------------------------
331    c2031_ieee488_ifc_w - IEEE-488 bus reset
332-------------------------------------------------*/
333
334WRITE_LINE_DEVICE_HANDLER( c2031_ieee488_ifc_w )
335{
336   if (!state)
337   {
338      device_reset(device);
339   }
340}
341
342/*-------------------------------------------------
319343    ADDRESS_MAP( c1540_map )
320344-------------------------------------------------*/
321345
r7034r7035
410434   UINT8 data = 0;
411435
412436   /* data in */
413   data = !cbm_iec_data_r(c1541->serial_bus);
437   data = !cbm_iec_data_r(c1541->bus);
414438
415439   /* clock in */
416   data |= !cbm_iec_clk_r(c1541->serial_bus) << 2;
440   data |= !cbm_iec_clk_r(c1541->bus) << 2;
417441
418442   /* serial bus address */
419443   data |= c1541->address << 5;
420444
421445   /* attention in */
422   data |= !cbm_iec_atn_r(c1541->serial_bus) << 7;
446   data |= !cbm_iec_atn_r(c1541->bus) << 7;
423447
424448   return data;
425449}
r7034r7035
448472   int atna = BIT(data, 4);
449473
450474   /* data out */
451   int serial_data = !data_out && !(atna ^ !cbm_iec_atn_r(c1541->serial_bus));
452   cbm_iec_data_w(c1541->serial_bus, device->owner, serial_data);
475   int serial_data = !data_out && !(atna ^ !cbm_iec_atn_r(c1541->bus));
476   cbm_iec_data_w(c1541->bus, device->owner, serial_data);
453477   c1541->data_out = data_out;
454478
455479   /* clock out */
456   cbm_iec_clk_w(c1541->serial_bus, device->owner, !clk_out);
480   cbm_iec_clk_w(c1541->bus, device->owner, !clk_out);
457481
458482   /* attention acknowledge */
459483   c1541->atna = atna;
r7034r7035
544568
545569    */
546570
547   return 0;
571   c1541_t *c1541 = get_safe_token(device->owner);
572
573   return ieee488_dio_r(c1541->bus, 0);
548574}
549575
550576static WRITE8_DEVICE_HANDLER( c2031_via0_pa_w )
r7034r7035
563589        PA7     DI7
564590
565591    */
592
593   c1541_t *c1541 = get_safe_token(device->owner);
594
595   ieee488_dio_w(c1541->bus, 0, data);
566596}
567597
568598static READ8_DEVICE_HANDLER( c2031_via0_pb_r )
r7034r7035
582612
583613    */
584614
585   return 0;
615   c1541_t *c1541 = get_safe_token(device->owner);
616   UINT8 data = 0;
617
618   /* not ready for data */
619   data |= ieee488_nrfd_r(c1541->bus) << 1;
620
621   /* not data accepted */
622   data |= ieee488_ndac_r(c1541->bus) << 2;
623
624   /* end or identify */
625   data |= ieee488_eoi_r(c1541->bus) << 3;
626
627   /* data valid */
628   data |= ieee488_dav_r(c1541->bus) << 6;
629
630   /* attention */
631   data |= ieee488_atn_r(c1541->bus) << 7;
632
633   return data;
586634}
587635
588636static WRITE8_DEVICE_HANDLER( c2031_via0_pb_w )
r7034r7035
601649        PB7     _ATN
602650
603651    */
652
653   c1541_t *c1541 = get_safe_token(device->owner);
654
655   /* attention acknowledge */
656
657   /* not ready for data */
658   ieee488_nrfd_w(c1541->bus, device->owner, BIT(data, 1));
659
660   /* not data accepted */
661   ieee488_ndac_w(c1541->bus, device->owner, BIT(data, 2));
662
663   /* end or identify */
664   ieee488_eoi_w(c1541->bus, device->owner, BIT(data, 3));
604665}
605666
667static READ_LINE_DEVICE_HANDLER( c2031_via0_ca1_r )
668{
669   c1541_t *c1541 = get_safe_token(device->owner);
670
671   return ieee488_atn_r(c1541->bus);
672}
673
674static READ_LINE_DEVICE_HANDLER( c2031_via0_ca2_r )
675{
676   /* device # selection */
677   return 0;
678}
679
606680static const via6522_interface c2031_via0_intf =
607681{
608682   DEVCB_HANDLER(c2031_via0_pa_r),
609683   DEVCB_HANDLER(c2031_via0_pb_r),
684   DEVCB_LINE(c2031_via0_ca1_r),
610685   DEVCB_NULL,
686   DEVCB_LINE(c2031_via0_ca2_r),
611687   DEVCB_NULL,
612   DEVCB_NULL,
613   DEVCB_NULL,
614688
615689   DEVCB_HANDLER(c2031_via0_pa_w),
616690   DEVCB_HANDLER(c2031_via0_pb_w),
617691   DEVCB_NULL,
618692   DEVCB_NULL,
619693   DEVCB_NULL,
620   DEVCB_NULL,
694   DEVCB_NULL, /* PLL SYN */
621695
622696   DEVCB_LINE(via0_irq_w)
623697};
r7034r7035
10111085   /* find devices */
10121086   c1541->via0 = device_find_child_by_tag(device, M6522_0_TAG);
10131087   c1541->via1 = device_find_child_by_tag(device, M6522_1_TAG);
1014   c1541->serial_bus = devtag_get_device(device->machine, config->serial_bus_tag);
1088   c1541->bus = devtag_get_device(device->machine, config->bus_tag);
10151089   c1541->image = device_find_child_by_tag(device, FLOPPY_0);
10161090
10171091   /* allocate track buffer */
src/mess/machine/c1541.h
r7034r7035
2222#define C1541II DEVICE_GET_INFO_NAME( c1541ii )
2323#define C2031   DEVICE_GET_INFO_NAME( c2031 )
2424
25#define MDRV_C1540_ADD(_tag, _serial_bus_tag, _address) \
25#define MDRV_C1540_ADD(_tag, _bus_tag, _address) \
2626   MDRV_DEVICE_ADD(_tag, C1540, 0) \
27   MDRV_DEVICE_CONFIG_DATAPTR(c1541_config, serial_bus_tag, _serial_bus_tag) \
27   MDRV_DEVICE_CONFIG_DATAPTR(c1541_config, bus_tag, _bus_tag) \
2828   MDRV_DEVICE_CONFIG_DATA32(c1541_config, address, _address)
2929
30#define MDRV_C1541_ADD(_tag, _serial_bus_tag, _address) \
30#define MDRV_C1541_ADD(_tag, _bus_tag, _address) \
3131   MDRV_DEVICE_ADD(_tag, C1541, 0) \
32   MDRV_DEVICE_CONFIG_DATAPTR(c1541_config, serial_bus_tag, _serial_bus_tag) \
32   MDRV_DEVICE_CONFIG_DATAPTR(c1541_config, bus_tag, _bus_tag) \
3333   MDRV_DEVICE_CONFIG_DATA32(c1541_config, address, _address)
3434
35#define MDRV_C1541C_ADD(_tag, _serial_bus_tag, _address) \
35#define MDRV_C1541C_ADD(_tag, _bus_tag, _address) \
3636   MDRV_DEVICE_ADD(_tag, C1541C, 0) \
37   MDRV_DEVICE_CONFIG_DATAPTR(c1541_config, serial_bus_tag, _serial_bus_tag) \
37   MDRV_DEVICE_CONFIG_DATAPTR(c1541_config, bus_tag, _bus_tag) \
3838   MDRV_DEVICE_CONFIG_DATA32(c1541_config, address, _address)
3939
40#define MDRV_C1541II_ADD(_tag, _serial_bus_tag, _address) \
40#define MDRV_C1541II_ADD(_tag, _bus_tag, _address) \
4141   MDRV_DEVICE_ADD(_tag, C1541II, 0) \
42   MDRV_DEVICE_CONFIG_DATAPTR(c1541_config, serial_bus_tag, _serial_bus_tag) \
42   MDRV_DEVICE_CONFIG_DATAPTR(c1541_config, bus_tag, _bus_tag) \
4343   MDRV_DEVICE_CONFIG_DATA32(c1541_config, address, _address)
4444
45#define MDRV_C2031_ADD(_tag, _address) \
45#define MDRV_C2031_ADD(_tag, _bus_tag, _address) \
4646   MDRV_DEVICE_ADD(_tag, C2031, 0) \
47   MDRV_DEVICE_CONFIG_DATAPTR(c1541_config, bus_tag, _bus_tag) \
4748   MDRV_DEVICE_CONFIG_DATA32(c1541_config, address, _address)
4849
4950#define C1541_IEC(_tag) \
5051   _tag, DEVCB_NULL, DEVCB_DEVICE_LINE(_tag, c1541_iec_atn_w), DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE(_tag, c1541_iec_reset_w)
5152
53#define C2031_IEEE488(_tag) \
54   _tag, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE(_tag, c2031_ieee488_ifc_w), DEVCB_NULL, DEVCB_DEVICE_LINE(_tag, c2031_ieee488_atn_w), DEVCB_NULL
55
5256/***************************************************************************
5357    TYPE DEFINITIONS
5458***************************************************************************/
r7034r7035
5660typedef struct _c1541_config c1541_config;
5761struct _c1541_config
5862{
59   const char *serial_bus_tag;   /* serial bus device */
60   int address;            /* serial address */
63   const char *bus_tag;      /* bus device */
64   int address;            /* bus address */
6165};
6266
6367/***************************************************************************
r7034r7035
7579WRITE_LINE_DEVICE_HANDLER( c1541_iec_atn_w );
7680WRITE_LINE_DEVICE_HANDLER( c1541_iec_reset_w );
7781
82/* IEEE-488 interface */
83WRITE_LINE_DEVICE_HANDLER( c2031_ieee488_atn_w );
84WRITE_LINE_DEVICE_HANDLER( c2031_ieee488_ifc_w );
85
7886#endif

Previous 15994 Revisions Next


© 1998-2018 The MESS Team