Previous 15994 Revisions Next

r7315 Wednesday 10th February, 2010 at 21:14:46 UTC by Curt Coder
[C1551] WIP
[src/mess/machine]c1551.c

src/mess/machine/c1551.c
r7314r7315
1111
1212   TODO:
1313
14   - 74 drive not ready
15   - move M6510T port handling to cpu core
14   - byte latched is wrong
15   - 23 data block checksum error
16   - activity LED
1617
1718*/
1819
r7314r7315
3435#define M6523_0_TAG      "u3"
3536#define M6523_1_TAG      "ci_u2"
3637
38#define SYNC \
39   !(c1551->mode && ((c1551->data & G64_SYNC_MARK) == G64_SYNC_MARK))
40
3741/***************************************************************************
3842    TYPE DEFINITIONS
3943***************************************************************************/
r7314r7315
5963   int bit_pos;                     /* current bit position within track buffer byte */
6064   int bit_count;                     /* current data byte bit counter */
6165   UINT16 data;                     /* data shift register */
62   UINT8 yb;                        /* GCR data byte to write */
66   UINT8 yb;                        /* GCR data byte */
6367
6468   /* signals */
6569   int ds;                           /* density select */
r7314r7315
6771   int byte;                        /* byte ready */
6872   int mode;                        /* mode (0 = write, 1 = read) */
6973
70   /* interrupts */
71   int irq;                        /* NE555 interrupt */
72
7374   /* devices */
7475   running_device *cpu;
7576   running_device *tpi0;
r7314r7315
111112{
112113   c1551_t *c1551 = get_safe_token(timer->owner);
113114
114   c1551->irq = !c1551->irq;
115
116   cpu_set_input_line(c1551->cpu, M6502_IRQ_LINE, c1551->irq);
115   cpu_set_input_line(c1551->cpu, M6502_IRQ_LINE, ASSERT_LINE);
116   cpu_set_input_line(c1551->cpu, M6502_IRQ_LINE, CLEAR_LINE);
117117}
118118
119119/*-------------------------------------------------
r7314r7315
144144      }
145145   }
146146
147   if ((c1551->data & G64_SYNC_MARK) == G64_SYNC_MARK)
147   if (!SYNC)
148148   {
149149      /* SYNC detected */
150150      c1551->bit_count = 0;
r7314r7315
156156      c1551->bit_count = 0;
157157      byte = 1;
158158
159      if (!(c1551->data & 0xff))
159      c1551->yb = c1551->data & 0xff;
160
161      if (!c1551->yb)
160162      {
161163         /* simulate weak bits with randomness */
162         c1551->data = (c1551->data & 0xff00) | (mame_rand(machine) & 0xff);
164         c1551->yb = mame_rand(machine) & 0xff;
163165      }
164166   }
165167
r7314r7315
201203   }
202204}
203205
204static void step_motor(c1551_t *c1551, int stp)
206static void step_motor(c1551_t *c1551, int mtr, int stp)
205207{
206   if (c1551->stp != stp)
208   if (mtr && (c1551->stp != stp))
207209   {
208210      int tracks = 0;
209211
r7314r7315
228230   }
229231}
230232
231static READ8_DEVICE_HANDLER( c1551_port_r )
233static UINT8 c1551_port_r( running_device *device, UINT8 direction )
232234{
233235   /*
234236
r7314r7315
252254   data |= !floppy_wpt_r(c1551->image) << 4;
253255   
254256   /* byte latched */
255   data |= !(c1551->soe && c1551->byte) << 7;
257   data |= (c1551->soe & c1551->byte) << 7;
256258
257259   return data;
258260}
r7314r7315
261263    c1551_port_w - M6510T port write
262264-------------------------------------------------*/
263265
264static WRITE8_DEVICE_HANDLER( c1551_port_w )
266static void c1551_port_w( running_device *device, UINT8 direction, UINT8 data )
265267{
266268   /*
267269
r7314r7315
280282
281283   c1551_t *c1551 = get_safe_token(device->owner);
282284
283   /* stepper motor */
284   int stp = data & 0x03;
285   step_motor(c1551, stp);
286
287285   /* spindle motor */
288286   int mtr = BIT(data, 2);
289287   spindle_motor(c1551, mtr);
290288
289   /* stepper motor */
290   int stp = data & 0x03;
291   step_motor(c1551, mtr, stp);
292
291293   /* TODO activity LED */
292294
293295   /* density select */
r7314r7315
300302   }
301303}
302304
305static const m6502_interface m6510t_intf =
306{
307   NULL,         /* read_indexed_func */
308   NULL,         /* write_indexed_func */
309   c1551_port_r,   /* port_read_func */
310   c1551_port_w   /* port_write_func */
311};
312
303313/*-------------------------------------------------
304314    ADDRESS_MAP( c1551_map )
305315-------------------------------------------------*/
306316
307317static ADDRESS_MAP_START( c1551_map, ADDRESS_SPACE_PROGRAM, 8 )
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
318   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x0800) AM_RAM
310319   AM_RANGE(0x4000, 0x4007) AM_MIRROR(0x3ff8) AM_DEVREADWRITE(M6523_0_TAG, tpi6525_r, tpi6525_w)
311320   AM_RANGE(0xc000, 0xffff) AM_ROM AM_REGION("c1551", 0)
312321ADDRESS_MAP_END
r7314r7315
378387
379388   c1551_t *c1551 = get_safe_token(device->owner);
380389
381   return c1551->data & 0xff;
390   return c1551->yb;
382391}
383392
384393static WRITE8_DEVICE_HANDLER( tpi0_pb_w )
r7314r7315
427436   data |= c1551->address << 5;
428437
429438   /* SYNC detect line */
430   data |= !(c1551->mode && ((c1551->data & G64_SYNC_MARK) == G64_SYNC_MARK)) << 6;
439   data |= SYNC << 6;
431440
432441   /* TCBM data valid */
433442   data |= c1551->dav << 7;
r7314r7315
644653static MACHINE_DRIVER_START( c1551 )
645654   MDRV_CPU_ADD(M6510T_TAG, M6510T, XTAL_16MHz/8)
646655   MDRV_CPU_PROGRAM_MAP(c1551_map)
656   MDRV_CPU_CONFIG(m6510t_intf)
647657
648658   MDRV_TPI6525_ADD(M6523_0_TAG, tpi0_intf) // 6523
649659   MDRV_TPI6525_ADD(M6523_1_TAG, tpi1_intf) // 6523
r7314r7315
683693   c1551->tpi1 = device->subdevice(M6523_1_TAG);
684694   c1551->image = device->subdevice(FLOPPY_0);
685695
686   /* allocate track buffer */
687//  c1551->track_buffer = auto_alloc_array(device->machine, UINT8, G64_BUFFER_SIZE);
688
689696   /* allocate data timer */
690697   c1551->bit_timer = timer_alloc(device->machine, bit_tick, (void *)device);
691698
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);
699   /* map TPI1 to host CPU memory space */
700   const address_space *program = cpu_get_address_space(devtag_get_device(device->machine, config->cpu_tag), ADDRESS_SPACE_PROGRAM);
701   UINT32 start_address = c1551->address ? 0xfec0 : 0xfef0;
695702
703   memory_install_readwrite8_device_handler(program, c1551->tpi1, start_address, start_address + 7, 0, 0, tpi6525_r, tpi6525_w);
704
696705   /* register for state saving */
697//  state_save_register_device_item_pointer(device, 0, c1551->track_buffer, G64_BUFFER_SIZE);
706   state_save_register_device_item(device, 0, c1551->tcbm_data);
707   state_save_register_device_item(device, 0, c1551->status);
708   state_save_register_device_item(device, 0, c1551->dav);
709   state_save_register_device_item(device, 0, c1551->ack);
710   state_save_register_device_item(device, 0, c1551->stp);
711   state_save_register_device_item(device, 0, c1551->mtr);
698712   state_save_register_device_item(device, 0, c1551->track_len);
699713   state_save_register_device_item(device, 0, c1551->buffer_pos);
700714   state_save_register_device_item(device, 0, c1551->bit_pos);
701715   state_save_register_device_item(device, 0, c1551->bit_count);
702716   state_save_register_device_item(device, 0, c1551->data);
703717   state_save_register_device_item(device, 0, c1551->yb);
704   state_save_register_device_item(device, 0, c1551->byte);
705718   state_save_register_device_item(device, 0, c1551->ds);
706   state_save_register_device_item(device, 0, c1551->stp);
707719   state_save_register_device_item(device, 0, c1551->soe);
720   state_save_register_device_item(device, 0, c1551->byte);
708721   state_save_register_device_item(device, 0, c1551->mode);
709722}
710723

Previous 15994 Revisions Next


© 1998-2018 The MESS Team