r7267 Friday 5th February, 2010 at 09:20:14 UTC by Curt Coder
Added Commodore 9060/9090 hard disk drive skeleton.
[src/mess]mess.mak
[src/mess/machine]c9060.c* c9060.h*

src/mess/machine/c9060.c
r0r7267
1/**********************************************************************
2 
3    Commodore 9060/9090 Hard Disk Drive emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************/
9 
10/*
11 
12   TODO:
13 
14   - everything
15 
16*/
17 
18#include "emu.h"
19#include "c9060.h"
20#include "cpu/m6502/m6502.h"
21#include "machine/6522via.h"
22#include "machine/6532riot.h"
23#include "machine/ieee488.h"
24 
25/***************************************************************************
26    PARAMETERS
27***************************************************************************/
28 
29#define LOG 0
30 
31#define M6502_TAG      "7e"
32#define M6532_0_TAG      "7f"
33#define M6532_1_TAG      "7g"
34 
35#define M6504_TAG      "4a"
36#define M6522_TAG      "4b"
37 
38#define C9060_REGION   "c9060"
39 
40/***************************************************************************
41    TYPE DEFINITIONS
42***************************************************************************/
43 
44typedef struct _c9060_t c9060_t;
45struct _c9060_t
46{
47   /* IEEE-488 bus */
48   int address;                  /* device address - 8 */
49   int rfdo;                     /* not ready for data output */
50   int daco;                     /* not data accepted output */
51   int atna;                     /* attention acknowledge */
52 
53   /* devices */
54   running_device *cpu_dos;
55   running_device *cpu_hdc;
56   running_device *riot0;
57   running_device *riot1;
58   running_device *via;
59   running_device *bus;
60};
61 
62/***************************************************************************
63    INLINE FUNCTIONS
64***************************************************************************/
65 
66INLINE c9060_t *get_safe_token(running_device *device)
67{
68   assert(device != NULL);
69   assert(device->token != NULL);
70   assert((device->type == C9060) || (device->type == C9090));
71   return (c9060_t *)device->token;
72}
73 
74INLINE c9060_config *get_safe_config(running_device *device)
75{
76   assert(device != NULL);
77   assert((device->type == C9060) || (device->type == C9090));
78   return (c9060_config *)device->baseconfig().inline_config;
79}
80 
81INLINE void update_ieee_signals(running_device *device)
82{
83   c9060_t *c9060 = get_safe_token(device);
84 
85   int atn = ieee488_atn_r(c9060->bus);
86   int atna = c9060->atna;
87   int rfdo = c9060->rfdo;
88   int daco = c9060->daco;
89 
90   int nrfd = !(!(!(atn&atna)&rfdo)|!(atn|atna));
91   int ndac = !(daco|!(atn|atna));
92 
93   ieee488_nrfd_w(c9060->bus, device, nrfd);
94   ieee488_ndac_w(c9060->bus, device, ndac);
95}
96 
97/***************************************************************************
98    IMPLEMENTATION
99***************************************************************************/
100 
101/*-------------------------------------------------
102    c9060_ieee488_atn_w - IEEE-488 bus attention
103-------------------------------------------------*/
104 
105WRITE_LINE_DEVICE_HANDLER( c9060_ieee488_atn_w )
106{
107   c9060_t *c9060 = get_safe_token(device);
108 
109   update_ieee_signals(device);
110 
111   /* set RIOT PA7 */
112   riot6532_porta_in_set(c9060->riot1, !state << 7, 0x80);
113}
114 
115/*-------------------------------------------------
116    c9060_ieee488_ifc_w - IEEE-488 bus reset
117-------------------------------------------------*/
118 
119WRITE_LINE_DEVICE_HANDLER( c9060_ieee488_ifc_w )
120{
121   if (!state)
122   {
123      device->reset();
124   }
125}
126 
127/*-------------------------------------------------
128    ADDRESS_MAP( c9060_dos_map )
129-------------------------------------------------*/
130 
131static ADDRESS_MAP_START( c9060_dos_map, ADDRESS_SPACE_PROGRAM, 8 )
132   AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0100) AM_RAM // 6532 #1
133   AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0100) AM_RAM // 6532 #2
134   AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w)
135   AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w)
136   AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share1")
137   AM_RANGE(0x2000, 0x23ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share2")
138   AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share3")
139   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share4")
140   AM_RANGE(0xc000, 0xffff) AM_ROM AM_REGION(C9060_REGION, 0x0000)
141ADDRESS_MAP_END
142 
143/*-------------------------------------------------
144    ADDRESS_MAP( c9060_fdc_map )
145-------------------------------------------------*/
146 
147static ADDRESS_MAP_START( c9060_fdc_map, ADDRESS_SPACE_PROGRAM, 8 )
148   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
149   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
150   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w)
151   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
152   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
153   AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3")
154   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_SHARE("share4")
155   AM_RANGE(0x1800, 0x1fff) AM_ROM AM_REGION(C9060_REGION, 0x2000) // 6530
156ADDRESS_MAP_END
157 
158/*-------------------------------------------------
159    riot6532_interface riot0_intf 7f
160-------------------------------------------------*/
161 
162static READ8_DEVICE_HANDLER( dio_r )
163{
164   /*
165 
166        bit     description
167 
168        PA0     DI0
169        PA1     DI1
170        PA2     DI2
171        PA3     DI3
172        PA4     DI4
173        PA5     DI5
174        PA6     DI6
175        PA7     DI7
176 
177    */
178 
179   c9060_t *c9060 = get_safe_token(device->owner);
180 
181   return ieee488_dio_r(c9060->bus, 0);
182}
183 
184static WRITE8_DEVICE_HANDLER( dio_w )
185{
186   /*
187 
188        bit     description
189 
190        PB0     DO0
191        PB1     DO1
192        PB2     DO2
193        PB3     DO3
194        PB4     DO4
195        PB5     DO5
196        PB6     DO6
197        PB7     DO7
198 
199    */
200 
201   c9060_t *c9060 = get_safe_token(device->owner);
202 
203   ieee488_dio_w(c9060->bus, device->owner, data);
204}
205 
206static const riot6532_interface riot0_intf =
207{
208   DEVCB_HANDLER(dio_r),
209   DEVCB_NULL,
210   DEVCB_NULL,
211   DEVCB_HANDLER(dio_w),
212   DEVCB_NULL
213};
214 
215/*-------------------------------------------------
216    riot6532_interface riot1_intf ue1
217-------------------------------------------------*/
218 
219static READ8_DEVICE_HANDLER( riot1_pa_r )
220{
221   /*
222 
223        bit     description
224 
225        PA0     ATNA
226        PA1      DACO
227        PA2      RFDO
228        PA3      EOIO
229        PA4      DAVO
230        PA5      EOII
231        PA6      DAVI
232        PA7      _ATN
233 
234    */
235 
236   c9060_t *c9060 = get_safe_token(device->owner);
237 
238   UINT8 data = 0;
239 
240   /* end or identify in */
241   data |= ieee488_eoi_r(c9060->bus) << 5;
242 
243   /* data valid in */
244   data |= ieee488_dav_r(c9060->bus) << 6;
245 
246   /* attention */
247   data |= !ieee488_atn_r(c9060->bus) << 7;
248 
249   return data;
250}
251 
252static WRITE8_DEVICE_HANDLER( riot1_pa_w )
253{
254   /*
255 
256        bit     description
257 
258        PA0     ATNA
259        PA1      DACO
260        PA2      RFDO
261        PA3      EOIO
262        PA4      DAVO
263        PA5      EOII
264        PA6      DAVI
265        PA7      _ATN
266 
267    */
268 
269   c9060_t *c9060 = get_safe_token(device->owner);
270 
271   /* attention acknowledge */
272   c9060->atna = BIT(data, 0);
273 
274   /* data accepted out */
275   c9060->daco = BIT(data, 1);
276 
277   /* not ready for data out */
278   c9060->rfdo = BIT(data, 2);
279 
280   /* end or identify out */
281   ieee488_eoi_w(c9060->bus, device->owner, BIT(data, 3));
282 
283   /* data valid out */
284   ieee488_dav_w(c9060->bus, device->owner, BIT(data, 4));
285 
286   update_ieee_signals(device->owner);
287}
288 
289static READ8_DEVICE_HANDLER( riot1_pb_r )
290{
291   /*
292 
293        bit     description
294 
295        PB0       
296        PB1       
297        PB2       
298        PB3       
299        PB4      DRIVE RDY
300        PB5      PWR ON AND NO ERRORS
301        PB6      DACI
302        PB7      RFDI
303 
304    */
305 
306   c9060_t *c9060 = get_safe_token(device->owner);
307 
308   UINT8 data = 0;
309 
310   /* data accepted in */
311   data |= ieee488_ndac_r(c9060->bus) << 6;
312 
313   /* ready for data in */
314   data |= ieee488_nrfd_r(c9060->bus) << 7;
315 
316   return data;
317}
318 
319static WRITE8_DEVICE_HANDLER( riot1_pb_w )
320{
321   /*
322 
323        bit     description
324 
325        PB0       
326        PB1       
327        PB2       
328        PB3       
329        PB4      DRIVE RDY
330        PB5      PWR ON AND NO ERRORS
331        PB6      DACI
332        PB7      RFDI
333 
334    */
335}
336 
337static WRITE_LINE_DEVICE_HANDLER( riot1_irq_w )
338{
339   c9060_t *c9060 = get_safe_token(device->owner);
340 
341   cpu_set_input_line(c9060->cpu_dos, M6502_IRQ_LINE, state);
342}
343 
344static const riot6532_interface riot1_intf =
345{
346   DEVCB_HANDLER(riot1_pa_r),
347   DEVCB_HANDLER(riot1_pb_r),
348   DEVCB_HANDLER(riot1_pa_w),
349   DEVCB_HANDLER(riot1_pb_w),
350   DEVCB_LINE(riot1_irq_w)
351};
352 
353/*-------------------------------------------------
354    via6522_interface via_intf 4b
355-------------------------------------------------*/
356 
357static READ8_DEVICE_HANDLER( via_pa_r )
358{
359   /*
360 
361        bit     description
362 
363        PA0     DB0
364        PA1      DB1
365        PA2      DB2
366        PA3      DB3
367        PA4      DB4
368        PA5      DB5
369        PA6      DB6
370        PA7      DB7
371 
372    */
373 
374   return 0;
375}
376 
377static WRITE8_DEVICE_HANDLER( via_pa_w )
378{
379   /*
380 
381        bit     description
382 
383        PA0     DB0
384        PA1      DB1
385        PA2      DB2
386        PA3      DB3
387        PA4      DB4
388        PA5      DB5
389        PA6      DB6
390        PA7      DB7
391 
392    */
393}
394 
395static READ8_DEVICE_HANDLER( via_pb_r )
396{
397   /*
398 
399        bit     description
400 
401        PB0      SEL
402        PB1      RST
403        PB2      C/D
404        PB3      BUSY
405        PB4      J14
406        PB5      J14
407        PB6      I/O
408        PB7      MSG
409 
410    */
411 
412   return 0;
413}
414 
415static WRITE8_DEVICE_HANDLER( via_pb_w )
416{
417   /*
418 
419        bit     description
420 
421        PB0      SEL
422        PB1      RST
423        PB2      C/D
424        PB3      BUSY
425        PB4      J14
426        PB5      J14
427        PB6      I/O
428        PB7      MSG
429 
430    */
431}
432 
433static const via6522_interface via_intf =
434{
435   DEVCB_HANDLER(via_pa_r),
436   DEVCB_HANDLER(via_pb_r),
437   DEVCB_NULL, // ACK
438   DEVCB_NULL,
439   DEVCB_NULL, // MSG
440   DEVCB_NULL, // ?
441 
442   DEVCB_HANDLER(via_pa_w),
443   DEVCB_HANDLER(via_pb_w),
444   DEVCB_NULL,
445   DEVCB_NULL,
446   DEVCB_NULL,
447   DEVCB_NULL,
448 
449   DEVCB_NULL
450};
451 
452/*-------------------------------------------------
453    MACHINE_DRIVER( c9060 )
454-------------------------------------------------*/
455 
456static MACHINE_DRIVER_START( c9060 )
457   /* DOS */
458   MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
459   MDRV_CPU_PROGRAM_MAP(c9060_dos_map)
460   
461   MDRV_RIOT6532_ADD(M6532_0_TAG, XTAL_16MHz/16, riot0_intf)
462   MDRV_RIOT6532_ADD(M6532_1_TAG, XTAL_16MHz/16, riot1_intf)
463 
464   /* controller */
465   MDRV_CPU_ADD(M6504_TAG, M6502, XTAL_16MHz/16)
466   MDRV_CPU_PROGRAM_MAP(c9060_fdc_map)
467   
468   MDRV_VIA6522_ADD(M6522_TAG, XTAL_16MHz/16, via_intf)
469 
470   // Tandon TM602S
471MACHINE_DRIVER_END
472 
473/*-------------------------------------------------
474    MACHINE_DRIVER( c9090 )
475-------------------------------------------------*/
476 
477static MACHINE_DRIVER_START( c9090 )
478   MDRV_IMPORT_FROM(c9060)
479 
480   // Tandon TM603S
481MACHINE_DRIVER_END
482 
483/*-------------------------------------------------
484    ROM( c9060 )
485-------------------------------------------------*/
486 
487ROM_START( c9060 ) // schematic 300010
488   ROM_REGION( 0x4800, C9060_REGION, ROMREGION_LOADBYNAME )
489   ROM_LOAD( "300516-revb.7c", 0x0000, 0x2000, CRC(2d758a14) SHA1(c959cc9dde84fc3d64e95e58a0a096a26d8107fd) )
490   ROM_LOAD( "300516-revc.7c", 0x0000, 0x2000, CRC(d6a3e88f) SHA1(bb1ddb5da94a86266012eca54818aa21dc4cef6a) )
491   ROM_LOAD( "300517-reva.7d", 0x2000, 0x2000, CRC(566df630) SHA1(b1602dfff408b165ee52a6a4ca3e2ec27e689ba9) )
492   ROM_LOAD( "300517-revb.7d", 0x2000, 0x2000, CRC(f0382bc3) SHA1(0b0a8dc520f5b41ffa832e4a636b3d226ccbb7f1) )
493   ROM_LOAD( "300517-revc.7d", 0x2000, 0x2000, CRC(2a9ad4ad) SHA1(4c17d014de48c906871b9b6c7d037d8736b1fd52) )
494 
495   ROM_LOAD( "300515-reva.4c", 0x4000, 0x0800, CRC(99e096f7) SHA1(a3d1deb27bf5918b62b89c27fa3e488eb8f717a4) )
496   ROM_LOAD( "300515-revb.4c", 0x4000, 0x0800, CRC(49adf4fb) SHA1(59dafbd4855083074ba8dc96a04d4daa5b76e0d6) )
497ROM_END
498 
499/*-------------------------------------------------
500    DEVICE_START( c9060 )
501-------------------------------------------------*/
502 
503static DEVICE_START( c9060 )
504{
505   c9060_t *c9060 = get_safe_token(device);
506   const c9060_config *config = get_safe_config(device);
507 
508   /* find our CPU */
509   c9060->cpu_dos = device->subdevice(M6502_TAG);
510   c9060->cpu_hdc = device->subdevice(M6504_TAG);
511 
512   /* find devices */
513   c9060->riot0 = device->subdevice(M6532_0_TAG);
514   c9060->riot1 = device->subdevice(M6532_1_TAG);
515   c9060->via = device->subdevice(M6522_TAG);
516   c9060->bus = devtag_get_device(device->machine, config->bus_tag);
517 
518   /* register for state saving */
519//   state_save_register_device_item(device, 0, c9060->);
520}
521 
522/*-------------------------------------------------
523    DEVICE_RESET( c9060 )
524-------------------------------------------------*/
525 
526static DEVICE_RESET( c9060 )
527{
528   c9060_t *c9060 = get_safe_token(device);
529 
530   /* reset devices */
531   c9060->cpu_dos->reset();
532   c9060->cpu_hdc->reset();
533   c9060->riot0->reset();
534   c9060->riot1->reset();
535   c9060->via->reset();
536 
537   /* toggle M6502 SO */
538   cpu_set_input_line(c9060->cpu_dos, M6502_SET_OVERFLOW, ASSERT_LINE);
539   cpu_set_input_line(c9060->cpu_dos, M6502_SET_OVERFLOW, CLEAR_LINE);
540}
541 
542/*-------------------------------------------------
543    DEVICE_GET_INFO( c9060 )
544-------------------------------------------------*/
545 
546DEVICE_GET_INFO( c9060 )
547{
548   switch (state)
549   {
550      /* --- the following bits of info are returned as 64-bit signed integers --- */
551      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(c9060_t);                           break;
552      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(c9060_config);                        break;
553      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                     break;
554 
555      /* --- the following bits of info are returned as pointers --- */
556      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c9060);                     break;
557      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_DRIVER_NAME(c9060);         break;
558 
559      /* --- the following bits of info are returned as pointers to data or functions --- */
560      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(c9060);                  break;
561      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
562      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(c9060);                  break;
563 
564      /* --- the following bits of info are returned as NULL-terminated strings --- */
565      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 9060");                     break;
566      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Commodore PET");                     break;
567      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
568      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
569      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
570   }
571}
572 
573/*-------------------------------------------------
574    DEVICE_GET_INFO( c9090 )
575-------------------------------------------------*/
576 
577DEVICE_GET_INFO( c9090 )
578{
579   switch (state)
580   {
581      /* --- the following bits of info are returned as pointers --- */
582      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_DRIVER_NAME(c9090);         break;
583 
584      /* --- the following bits of info are returned as NULL-terminated strings --- */
585      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 9090");                     break;
586 
587      default:                              DEVICE_GET_INFO_CALL(c9060);                        break;
588   }
589}
src/mess/machine/c9060.h
r0r7267
1/**********************************************************************
2 
3    Commodore 9060/9090 Hard Disk Drive emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************/
9 
10#ifndef __C9060__
11#define __C9060__
12 
13#include "emu.h"
14 
15/***************************************************************************
16    MACROS / CONSTANTS
17***************************************************************************/
18 
19#define C9060   DEVICE_GET_INFO_NAME( c9060 )
20#define C9090   DEVICE_GET_INFO_NAME( c9090 )
21 
22#define MDRV_C9060_ADD(_tag, _bus_tag, _address) \
23   MDRV_DEVICE_ADD(_tag, C9060, 0) \
24   MDRV_DEVICE_CONFIG_DATAPTR(c9060_config, bus_tag, _bus_tag) \
25   MDRV_DEVICE_CONFIG_DATA32(c9060_config, address, _address)
26 
27#define MDRV_C9090_ADD(_tag, _bus_tag, _address) \
28   MDRV_DEVICE_ADD(_tag, C9090, 0) \
29   MDRV_DEVICE_CONFIG_DATAPTR(c9060_config, bus_tag, _bus_tag) \
30   MDRV_DEVICE_CONFIG_DATA32(c9060_config, address, _address)
31 
32#define C9060_IEEE488(_tag) \
33   _tag, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE(_tag, c9060_ieee488_ifc_w), DEVCB_NULL, DEVCB_DEVICE_LINE(_tag, c9060_ieee488_atn_w), DEVCB_NULL
34 
35/***************************************************************************
36    TYPE DEFINITIONS
37***************************************************************************/
38 
39typedef struct _c9060_config c9060_config;
40struct _c9060_config
41{
42   const char *bus_tag;      /* bus device */
43   int address;            /* bus address */
44};
45 
46/***************************************************************************
47    PROTOTYPES
48***************************************************************************/
49 
50/* device interface */
51DEVICE_GET_INFO( c9060 );
52DEVICE_GET_INFO( c9090 );
53 
54/* IEEE-488 interface */
55WRITE_LINE_DEVICE_HANDLER( c9060_ieee488_atn_w );
56WRITE_LINE_DEVICE_HANDLER( c9060_ieee488_ifc_w );
57 
58#endif
src/mess/mess.mak
r7266r7267
716716   $(MESS_MACHINE)/c1581.o      \
717717   $(MESS_MACHINE)/c2040.o      \
718718   $(MESS_MACHINE)/c8280.o      \
719   $(MESS_MACHINE)/c9060.o      \
719720   $(MESS_FORMATS)/d64_dsk.o   \
720721   $(MESS_FORMATS)/g64_dsk.o   \
721722   $(MESS_DRIVERS)/clcd.o      \

Previous 509077 RevisionsNext 50


© 1998-2010 The MESS Team