Previous 15994 Revisions Next

r7307 Wednesday 10th February, 2010 at 13:30:57 UTC by Curt Coder
[C1551] WIP
[src/mess/drivers]c16.c
[src/mess/machine]c1551.c

src/mess/machine/c1551.c
r7306r7307
1111
1212   TODO:
1313
14   - 74 drive not ready
1415   - move M6510T port handling to cpu core
15   - TCBM bus
16   - connect to C16/Plus4
1716
1817*/
1918
r7306r7307
3534#define M6523_0_TAG      "u3"
3635#define M6523_1_TAG      "ci_u2"
3736
38#define FLOPPY_TAG      "c1551_floppy"
39
4037/***************************************************************************
4138    TYPE DEFINITIONS
4239***************************************************************************/
r7306r7307
4643{
4744   /* TCBM bus */
4845   int address;                     /* device address - 8 */
46   UINT8 tcbm_data;                  /* data */
4947   int status;                        /* status */
5048   int dav;                        /* data valid */
5149   int ack;                        /* acknowledge */
r7306r7307
6967   int byte;                        /* byte ready */
7068   int mode;                        /* mode (0 = write, 1 = read) */
7169
70   /* interrupts */
71   int irq;                        /* NE555 interrupt */
72
7273   /* devices */
7374   running_device *cpu;
7475   running_device *tpi0;
r7306r7307
103104***************************************************************************/
104105
105106/*-------------------------------------------------
107    TIMER_DEVICE_CALLBACK( irq_tick )
108-------------------------------------------------*/
109
110static TIMER_DEVICE_CALLBACK( irq_tick )
111{
112   c1551_t *c1551 = get_safe_token(timer->owner);
113
114   c1551->irq = !c1551->irq;
115
116   cpu_set_input_line(c1551->cpu, M6502_IRQ_LINE, c1551->irq);
117}
118
119/*-------------------------------------------------
106120    TIMER_CALLBACK( bit_tick )
107121-------------------------------------------------*/
108122
r7306r7307
291305-------------------------------------------------*/
292306
293307static ADDRESS_MAP_START( c1551_map, ADDRESS_SPACE_PROGRAM, 8 )
294   AM_RANGE(0x0000, 0x0001) AM_DEVREADWRITE(M6510T_TAG, c1551_port_r, c1551_port_w)
295   AM_RANGE(0x0002, 0x07ff) AM_RAM
308   AM_RANGE(0x0001, 0x0001) AM_DEVREADWRITE(M6510T_TAG, c1551_port_r, c1551_port_w)
309   AM_RANGE(0x0002, 0x07ff) AM_MIRROR(0x0800) AM_RAM
296310   AM_RANGE(0x4000, 0x4007) AM_MIRROR(0x3ff8) AM_DEVREADWRITE(M6523_0_TAG, tpi6525_r, tpi6525_w)
297311   AM_RANGE(0xc000, 0xffff) AM_ROM AM_REGION("c1551", 0)
298312ADDRESS_MAP_END
r7306r7307
320334
321335   c1551_t *c1551 = get_safe_token(device->owner);
322336
323   return tpi6525_porta_r(c1551->tpi1, 0);
337   return c1551->tcbm_data;
324338}
325339
326340static WRITE8_DEVICE_HANDLER( tpi0_pa_w )
r7306r7307
342356
343357   c1551_t *c1551 = get_safe_token(device->owner);
344358
345   tpi6525_porta_w(c1551->tpi1, 0, data);
359   c1551->tcbm_data = data;
346360}
347361
348362static READ8_DEVICE_HANDLER( tpi0_pb_r )
r7306r7307
415429   /* SYNC detect line */
416430   data |= !(c1551->mode && ((c1551->data & G64_SYNC_MARK) == G64_SYNC_MARK)) << 6;
417431
432   /* TCBM data valid */
433   data |= c1551->dav << 7;
434
418435   return data;
419436}
420437
r7306r7307
442459
443460   /* TODO TCBM device number */
444461
445   /* TODO TCBM acknowledge */
462   /* TCBM acknowledge */
463   c1551->ack = BIT(data, 3);
446464
447465   /* read/write mode */
448466   c1551->mode = BIT(data, 4);
449
450   /* TODO TCBM data valid */
451467}
452468
453469static const tpi6525_interface tpi0_intf =
r7306r7307
486502
487503   c1551_t *c1551 = get_safe_token(device->owner);
488504
489   return tpi6525_porta_r(c1551->tpi0, 0);
505   return c1551->tcbm_data;
490506}
491507
492508static WRITE8_DEVICE_HANDLER( tpi1_pa_w )
r7306r7307
508524
509525   c1551_t *c1551 = get_safe_token(device->owner);
510526
511   tpi6525_porta_w(c1551->tpi0, 0, data);
527   c1551->tcbm_data = data;
512528}
513529
514530static READ8_DEVICE_HANDLER( tpi1_pb_r )
r7306r7307
528544
529545    */
530546
531   return 0;
532}
547   c1551_t *c1551 = get_safe_token(device->owner);
533548
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    */
549   return c1551->status;
550550}
551551
552552static READ8_DEVICE_HANDLER( tpi1_pc_r )
r7306r7307
561561        PC3     
562562        PC4     
563563        PC5     
564        PC6     TCBM ACK
565        PC7     TCBM DAV
564        PC6     TCBM DAV
565        PC7     TCBM ACK
566566
567567    */
568568
569   return 0;
569   c1551_t *c1551 = get_safe_token(device->owner);
570   
571   UINT8 data = 0;
572
573   /* TCBM acknowledge */
574   data |= c1551->ack << 7;
575
576   return data;
570577}
571578
572579static WRITE8_DEVICE_HANDLER( tpi1_pc_w )
r7306r7307
581588        PC3     
582589        PC4     
583590        PC5     
584        PC6     TCBM ACK
585        PC7     TCBM DAV
591        PC6     TCBM DAV
592        PC7     TCBM ACK
586593
587594    */
595
596   c1551_t *c1551 = get_safe_token(device->owner);
597
598   /* TCBM data valid */
599   c1551->dav = BIT(data, 6);
588600}
589601
590602static const tpi6525_interface tpi1_intf =
r7306r7307
593605   tpi1_pb_r,
594606   tpi1_pc_r,
595607   tpi1_pa_w,
596   tpi1_pb_w,
608   NULL,
597609   tpi1_pc_w,
598610   NULL,
599611   NULL,
r7306r7307
630642-------------------------------------------------*/
631643
632644static MACHINE_DRIVER_START( c1551 )
633   MDRV_CPU_ADD(M6510T_TAG, M6510T, 2000000)
645   MDRV_CPU_ADD(M6510T_TAG, M6510T, XTAL_16MHz/8)
634646   MDRV_CPU_PROGRAM_MAP(c1551_map)
635647
636648   MDRV_TPI6525_ADD(M6523_0_TAG, tpi0_intf) // 6523
637649   MDRV_TPI6525_ADD(M6523_1_TAG, tpi1_intf) // 6523
638650
639   MDRV_FLOPPY_DRIVE_ADD(FLOPPY_TAG, c1551_floppy_config)
651   MDRV_TIMER_ADD_PERIODIC("irq", irq_tick, HZ(120))
652
653   MDRV_FLOPPY_DRIVE_ADD(FLOPPY_0, c1551_floppy_config)
640654MACHINE_DRIVER_END
641655
642656/*-------------------------------------------------
r7306r7307
675689   /* allocate data timer */
676690   c1551->bit_timer = timer_alloc(device->machine, bit_tick, (void *)device);
677691
692   /* map TPI1 to main CPU memory space */
693   const address_space *program = cpu_get_address_space(device->machine->firstcpu, ADDRESS_SPACE_PROGRAM);
694   memory_install_readwrite8_device_handler(program, c1551->tpi1, 0xfef0, 0xfef7, 0, 0, tpi6525_r, tpi6525_w);
695
678696   /* register for state saving */
679697//  state_save_register_device_item_pointer(device, 0, c1551->track_buffer, G64_BUFFER_SIZE);
680698   state_save_register_device_item(device, 0, c1551->track_len);
r7306r7307
714732   {
715733      /* --- the following bits of info are returned as 64-bit signed integers --- */
716734      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(c1551_t);                           break;
717      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                    break;
735      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(c1551_config);                        break;
718736      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                     break;
719737
720738      /* --- the following bits of info are returned as pointers --- */
r7306r7307
728746
729747      /* --- the following bits of info are returned as NULL-terminated strings --- */
730748      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 1551");                     break;
731      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Commodore VIC-1540");                  break;
749      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Commodore Plus/4");                  break;
732750      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
733751      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
734752      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
src/mess/drivers/c16.c
r7306r7307
420420static MACHINE_DRIVER_START( c16c )
421421   MDRV_IMPORT_FROM( c16 )
422422
423   //MDRV_C1551_ADD("c1551", "maincpu", 8)
423   MDRV_C1551_ADD("c1551", "maincpu", 8)
424424
425425#ifdef CPU_SYNC
426426   MDRV_QUANTUM_TIME(HZ(60))
r7306r7307
464464static MACHINE_DRIVER_START( plus4c )
465465   MDRV_IMPORT_FROM( plus4 )
466466
467   //MDRV_C1551_ADD("c1551", "maincpu", 8)
467   MDRV_C1551_ADD("c1551", "maincpu", 8)
468468
469469   MDRV_SCREEN_MODIFY("screen")
470470   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team