Previous 15994 Revisions Next

r7298 Tuesday 9th February, 2010 at 13:46:46 UTC by Curt Coder
[C1551] WIP
[src/mess/machine]c1551.c c1551.h

src/mess/machine/c1551.c
r7297r7298
3232#define LOG 0
3333
3434#define M6510T_TAG      "u2"
35#define M6525_TAG      "u3"
36#define M6523_TAG      "ci_u2"
35#define M6523_0_TAG      "u3"
36#define M6523_1_TAG      "ci_u2"
3737
3838#define FLOPPY_TAG      "c1551_floppy"
3939
r7297r7298
4444typedef struct _c1551_t c1551_t;
4545struct _c1551_t
4646{
47   /* TCBM bus */
48   int address;                     /* device address - 8 */
49   int status;                        /* status */
50   int dav;                        /* data valid */
51   int ack;                        /* acknowledge */
52
4753   /* motors */
4854   int stp;                        /* stepper motor phase */
4955   int mtr;                        /* spindle motor on */
r7297r7298
8591   return (c1551_t *)device->token;
8692}
8793
94INLINE c1551_config *get_safe_config(running_device *device)
95{
96   assert(device != NULL);
97   assert(device->type == C1551);
98   return (c1551_config *)device->baseconfig().inline_config;
99}
100
88101/***************************************************************************
89102    IMPLEMENTATION
90103***************************************************************************/
r7297r7298
261274   int mtr = BIT(data, 2);
262275   spindle_motor(c1551, mtr);
263276
264   /* activity LED */
277   /* TODO activity LED */
265278
266279   /* density select */
267280   int ds = (data >> 5) & 0x03;
r7297r7298
280293static ADDRESS_MAP_START( c1551_map, ADDRESS_SPACE_PROGRAM, 8 )
281294   AM_RANGE(0x0000, 0x0001) AM_DEVREADWRITE(M6510T_TAG, c1551_port_r, c1551_port_w)
282295   AM_RANGE(0x0002, 0x07ff) AM_RAM
283   AM_RANGE(0x4000, 0x4007) AM_DEVREADWRITE(M6525_TAG, tpi6525_r, tpi6525_w)
296   AM_RANGE(0x4000, 0x4007) AM_MIRROR(0x3ff8) AM_DEVREADWRITE(M6523_0_TAG, tpi6525_r, tpi6525_w)
284297   AM_RANGE(0xc000, 0xffff) AM_ROM AM_REGION("c1551", 0)
285298ADDRESS_MAP_END
286299
287300/*-------------------------------------------------
288    tpi6525_interface c1551_tpi_intf
301    tpi6525_interface tpi0_intf
289302-------------------------------------------------*/
290303
291static READ8_DEVICE_HANDLER( c1551_tpi_pa_r )
304static READ8_DEVICE_HANDLER( tpi0_pa_r )
292305{
293306   /*
294307
r7297r7298
305318
306319    */
307320
308   return 0;
321   c1551_t *c1551 = get_safe_token(device->owner);
322
323   return tpi6525_porta_r(c1551->tpi1, 0);
309324}
310325
311static WRITE8_DEVICE_HANDLER( c1551_tpi_pa_w )
326static WRITE8_DEVICE_HANDLER( tpi0_pa_w )
312327{
313328   /*
314329
r7297r7298
324339        PA7     TCBM PA7
325340
326341    */
342
343   c1551_t *c1551 = get_safe_token(device->owner);
344
345   tpi6525_porta_w(c1551->tpi1, 0, data);
327346}
328347
329static READ8_DEVICE_HANDLER( c1551_tpi_pb_r )
348static READ8_DEVICE_HANDLER( tpi0_pb_r )
330349{
331350   /*
332351
r7297r7298
348367   return c1551->data & 0xff;
349368}
350369
351static WRITE8_DEVICE_HANDLER( c1551_tpi_pb_w )
370static WRITE8_DEVICE_HANDLER( tpi0_pb_w )
352371{
353372   /*
354373
r7297r7298
370389   c1551->yb = data;
371390}
372391
373static READ8_DEVICE_HANDLER( c1551_tpi_pc_r )
392static READ8_DEVICE_HANDLER( tpi0_pc_r )
374393{
375394   /*
376395
r7297r7298
390409   c1551_t *c1551 = get_safe_token(device->owner);
391410   UINT8 data = 0;
392411
412   /* JP1 */
413   data |= c1551->address << 5;
414
393415   /* SYNC detect line */
394416   data |= !(c1551->mode && ((c1551->data & G64_SYNC_MARK) == G64_SYNC_MARK)) << 6;
395417
396418   return data;
397419}
398420
399static WRITE8_DEVICE_HANDLER( c1551_tpi_pc_w )
421static WRITE8_DEVICE_HANDLER( tpi0_pc_w )
400422{
401423   /*
402424
r7297r7298
415437
416438   c1551_t *c1551 = get_safe_token(device->owner);
417439
418   /* SOE */
419   c1551->soe = BIT(data, 4);
440   /* TCBM status */
441   c1551->status = data & 0x03;
442
443   /* TODO TCBM device number */
444
445   /* TODO TCBM acknowledge */
446
447   /* read/write mode */
448   c1551->mode = BIT(data, 4);
449
450   /* TODO TCBM data valid */
420451}
421452
422static const tpi6525_interface c1551_tpi_intf =
453static const tpi6525_interface tpi0_intf =
423454{
424   c1551_tpi_pa_r,
425   c1551_tpi_pb_r,
426   c1551_tpi_pc_r,
427   c1551_tpi_pa_w,
428   c1551_tpi_pb_w,
429   c1551_tpi_pc_w,
455   tpi0_pa_r,
456   tpi0_pb_r,
457   tpi0_pc_r,
458   tpi0_pa_w,
459   tpi0_pb_w,
460   tpi0_pc_w,
430461   NULL,
431462   NULL,
432463   NULL
433464};
434465
435466/*-------------------------------------------------
467    tpi6525_interface tpi1_intf
468-------------------------------------------------*/
469
470static READ8_DEVICE_HANDLER( tpi1_pa_r )
471{
472   /*
473
474        bit     description
475
476        PA0     TCBM PA0
477        PA1     TCBM PA1
478        PA2     TCBM PA2
479        PA3     TCBM PA3
480        PA4     TCBM PA4
481        PA5     TCBM PA5
482        PA6     TCBM PA6
483        PA7     TCBM PA7
484
485    */
486
487   c1551_t *c1551 = get_safe_token(device->owner);
488
489   return tpi6525_porta_r(c1551->tpi0, 0);
490}
491
492static WRITE8_DEVICE_HANDLER( tpi1_pa_w )
493{
494   /*
495
496        bit     description
497
498        PA0     TCBM PA0
499        PA1     TCBM PA1
500        PA2     TCBM PA2
501        PA3     TCBM PA3
502        PA4     TCBM PA4
503        PA5     TCBM PA5
504        PA6     TCBM PA6
505        PA7     TCBM PA7
506
507    */
508
509   c1551_t *c1551 = get_safe_token(device->owner);
510
511   tpi6525_porta_w(c1551->tpi0, 0, data);
512}
513
514static READ8_DEVICE_HANDLER( tpi1_pb_r )
515{
516   /*
517
518        bit     description
519
520        PB0     STATUS0
521        PB1     STATUS1
522        PB2     
523        PB3     
524        PB4     
525        PB5     
526        PB6     
527        PB7     
528
529    */
530
531   return 0;
532}
533
534static WRITE8_DEVICE_HANDLER( tpi1_pb_w )
535{
536   /*
537
538        bit     description
539
540        PB0     STATUS0
541        PB1     STATUS1
542        PB2     
543        PB3     
544        PB4     
545        PB5     
546        PB6     
547        PB7     
548
549    */
550}
551
552static READ8_DEVICE_HANDLER( tpi1_pc_r )
553{
554   /*
555
556        bit     description
557
558        PC0     
559        PC1     
560        PC2     
561        PC3     
562        PC4     
563        PC5     
564        PC6     TCBM ACK
565        PC7     TCBM DAV
566
567    */
568
569   return 0;
570}
571
572static WRITE8_DEVICE_HANDLER( tpi1_pc_w )
573{
574   /*
575
576        bit     description
577
578        PC0     
579        PC1     
580        PC2     
581        PC3     
582        PC4     
583        PC5     
584        PC6     TCBM ACK
585        PC7     TCBM DAV
586
587    */
588}
589
590static const tpi6525_interface tpi1_intf =
591{
592   tpi1_pa_r,
593   tpi1_pb_r,
594   tpi1_pc_r,
595   tpi1_pa_w,
596   tpi1_pb_w,
597   tpi1_pc_w,
598   NULL,
599   NULL,
600   NULL
601};
602
603/*-------------------------------------------------
436604    FLOPPY_OPTIONS( c1551 )
437605-------------------------------------------------*/
438606
439607static FLOPPY_OPTIONS_START( c1551 )
440   FLOPPY_OPTION( c1551, "g64", "Commodore 1541 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL )
441   FLOPPY_OPTION( c1551, "d64", "Commodore 1541 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL )
608   FLOPPY_OPTION( c1551, "g64", "Commodore 1551 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL )
609   FLOPPY_OPTION( c1551, "d64", "Commodore 1551 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL )
442610FLOPPY_OPTIONS_END
443611
444612/*-------------------------------------------------
r7297r7298
465633   MDRV_CPU_ADD(M6510T_TAG, M6510T, 2000000)
466634   MDRV_CPU_PROGRAM_MAP(c1551_map)
467635
468   MDRV_TPI6525_ADD(M6525_TAG, c1551_tpi_intf)
469//  MDRV_MOS6523_ADD(M6523_TAG, 2000000, c1551_mos6523_intf)
636   MDRV_TPI6525_ADD(M6523_0_TAG, tpi0_intf) // 6523
637   MDRV_TPI6525_ADD(M6523_1_TAG, tpi1_intf) // 6523
470638
471639   MDRV_FLOPPY_DRIVE_ADD(FLOPPY_TAG, c1551_floppy_config)
472640MACHINE_DRIVER_END
r7297r7298
487655static DEVICE_START( c1551 )
488656{
489657   c1551_t *c1551 = get_safe_token(device);
658   const c1551_config *config = get_safe_config(device);
490659
660   /* set address */
661   assert((config->address > 7) && (config->address < 10));
662   c1551->address = config->address - 8;
663
491664   /* find our CPU */
492665   c1551->cpu = device->subdevice(M6510T_TAG);
493666
494667   /* find devices */
495   c1551->tpi0 = device->subdevice(M6525_TAG);
496   c1551->tpi1 = device->subdevice(M6523_TAG);
668   c1551->tpi0 = device->subdevice(M6523_0_TAG);
669   c1551->tpi1 = device->subdevice(M6523_1_TAG);
497670   c1551->image = device->subdevice(FLOPPY_0);
498671
499672   /* allocate track buffer */
r7297r7298
523696
524697static DEVICE_RESET( c1551 )
525698{
699   c1551_t *c1551 = get_safe_token(device);
700
701   c1551->cpu->reset();
702   c1551->tpi0->reset();
703
704   c1551->soe = 1;
526705}
527706
528707/*-------------------------------------------------
src/mess/machine/c1551.h
r7297r7298
1818
1919#define C1551 DEVICE_GET_INFO_NAME( c1551 )
2020
21#define MDRV_C1551_ADD(_tag) \
22   MDRV_DEVICE_ADD(_tag, C1551, 0)
21#define MDRV_C1551_ADD(_tag, _cpu_tag, _address) \
22   MDRV_DEVICE_ADD(_tag, C1551, 0) \
23   MDRV_DEVICE_CONFIG_DATAPTR(c1551_config, cpu_tag, _cpu_tag) \
24   MDRV_DEVICE_CONFIG_DATA32(c1551_config, address, _address)
2325
2426/***************************************************************************
27    TYPE DEFINITIONS
28***************************************************************************/
29
30typedef struct _c1551_config c1551_config;
31struct _c1551_config
32{
33   const char *cpu_tag;      /* CPU to hook into */
34   int address;            /* bus address */
35};
36
37/***************************************************************************
2538    PROTOTYPES
2639***************************************************************************/
2740

Previous 15994 Revisions Next


© 1998-2018 The MESS Team