Previous 15994 Revisions Next

r6572 Monday 7th December, 2009 at 22:00:29 UTC by Curt Coder
[CONKORT] Implemented Z80 wait logic, and I/O mirroring.
[src/mess/machine]conkort.c

src/mess/machine/conkort.c
r6571r6572
7171
7272    Slow Controller
7373    ---------------
74   - FD1791 HLD/HLT callbacks
75   - copy protection device
7476    - DS/DD SS/DS jumpers
7577    - S1-S5 jumpers
76    - protection device @ 8B
77    - FDC DRQ
78    - Z80 wait logic
7978
8079    Fast Controller
8180    ---------------
r6571r6572
116115   UINT8 status;         /* ABC BUS status */
117116   UINT8 data;            /* ABC BUS data */
118117   int pio_ardy;         /* PIO port A ready */
119   int fdc_irq;         /* FDC interrupt */
118   int fdc_irq;         /* floppy interrupt */
119   int fdc_drq;         /* floppy data request */
120   int fdc_dden;         /* floppy density */
121   int wait_enable;      /* wait enable */
120122
121123   /* devices */
122124   const device_config *cpu;
r6571r6572
256258
257259        bit     description
258260
259        0       _SEL 0
260        1       _SEL 1
261        2       _SEL 2
262        3       _MOT
263        4       _SIDE
264        5       8B pin 2 (if S4 shorted)
265        6       8A pin 13
261        0       SEL 0
262        1       SEL 1
263        2       SEL 2
264        3       MOT ON
265        4       SIDE
266        5       _PRECOMP ON
267        6       _WAIT ENABLE
266268        7       FDC _MR
267269
268270    */
r6571r6572
270272   slow_t *conkort = get_safe_token_machine_slow(space->machine);
271273
272274   /* drive selection */
273   if (!BIT(data, 0)) wd17xx_set_drive(conkort->wd1791, 0);
274   if (!BIT(data, 1)) wd17xx_set_drive(conkort->wd1791, 1);
275//  if (!BIT(data, 2)) wd17xx_set_drive(conkort->wd1791, 2);
275   if (BIT(data, 0)) wd17xx_set_drive(conkort->wd1791, 0);
276   if (BIT(data, 1)) wd17xx_set_drive(conkort->wd1791, 1);
277//  if (BIT(data, 2)) wd17xx_set_drive(conkort->wd1791, 2);
276278
277279   /* motor enable */
278   floppy_drive_set_motor_state(get_floppy_image(space->machine, 0), !BIT(data, 3));
279   floppy_drive_set_motor_state(get_floppy_image(space->machine, 1), !BIT(data, 3));
280   floppy_drive_set_motor_state(get_floppy_image(space->machine, 0), BIT(data, 3));
281   floppy_drive_set_motor_state(get_floppy_image(space->machine, 1), BIT(data, 3));
280282   floppy_drive_set_ready_state(get_floppy_image(space->machine, 0), 1, 1);
281283   floppy_drive_set_ready_state(get_floppy_image(space->machine, 1), 1, 1);
282284
283285   /* disk side selection */
284   wd17xx_set_side(conkort->wd1791,!BIT(data, 4));
286   wd17xx_set_side(conkort->wd1791, BIT(data, 4));
285287
288   /* wait enable */
289   conkort->wait_enable = BIT(data, 6);
290
286291   if (!BIT(data, 7))
287292   {
288293      /* FDC master reset */
r6571r6572
315320   cpu_set_input_line(conkort->cpu, INPUT_LINE_IRQ0, BIT(data, 7) ? ASSERT_LINE : CLEAR_LINE);
316321}
317322
323static READ8_DEVICE_HANDLER( slow_fdc_r )
324{
325   slow_t *conkort = get_safe_token_machine_slow(device->machine);
326   UINT8 data = 0;
327
328   switch (offset & 0x03)
329   {
330   case 0: data = wd17xx_status_r(device, 0);
331   case 1:   data = wd17xx_track_r(device, 0);
332   case 2:   data = wd17xx_sector_r(device, 0);
333   case 3:   data = wd17xx_data_r(device, 0);
334   }
335
336   if (!conkort->wait_enable && !conkort->fdc_irq && !conkort->fdc_drq)
337   {
338      logerror("WAIT\n");
339      /* TODO: this is really connected to the Z80 _RDY line */
340      cpu_set_input_line(conkort->cpu, INPUT_LINE_HALT, ASSERT_LINE);
341   }
342
343   return data;
344}
345
346static WRITE8_DEVICE_HANDLER( slow_fdc_w )
347{
348   slow_t *conkort = get_safe_token_machine_slow(device->machine);
349
350   switch (offset & 0x03)
351   {
352   case 0: wd17xx_command_w(device, 0, data); break;
353   case 1:   wd17xx_track_w(device, 0, data);   break;
354   case 2: wd17xx_sector_w(device, 0, data);  break;
355   case 3: wd17xx_data_w(device, 0, data);    break;
356   }
357
358   if (!conkort->wait_enable && !conkort->fdc_irq && !conkort->fdc_drq)
359   {
360      logerror("WAIT\n");
361      /* TODO: this is really connected to the Z80 _RDY line */
362      cpu_set_input_line(conkort->cpu, INPUT_LINE_HALT, ASSERT_LINE);
363   }
364}
365
318366/* Fast Controller */
319367
320368static READ8_HANDLER( fast_bus_data_r )
r6571r6572
433481
434482static ADDRESS_MAP_START( slow_io_map, ADDRESS_SPACE_IO, 8 )
435483   ADDRESS_MAP_GLOBAL_MASK(0xff)
436   AM_RANGE(0x7c, 0x7f) AM_DEVREADWRITE(Z80PIO_TAG, z80pio_alt_r, z80pio_alt_w)
437   AM_RANGE(0xbc, 0xbf) AM_DEVREADWRITE(WD1791_TAG, wd17xx_r, wd17xx_w)
438   AM_RANGE(0xdf, 0xdf) AM_WRITE(slow_status_w)
439   AM_RANGE(0xef, 0xef) AM_WRITE(slow_ctrl_w)
484   AM_RANGE(0x70, 0x73) AM_MIRROR(0x0c) AM_DEVREADWRITE(Z80PIO_TAG, z80pio_alt_r, z80pio_alt_w)
485   AM_RANGE(0xb0, 0xb3) AM_MIRROR(0x0c) AM_DEVREADWRITE(WD1791_TAG, wd17xx_r, wd17xx_w)
486   AM_RANGE(0xd0, 0xd0) AM_MIRROR(0x0f) AM_WRITE(slow_status_w)
487   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x0f) AM_WRITE(slow_ctrl_w)
440488ADDRESS_MAP_END
441489
442490// Fast Controller
r6571r6572
454502//  AM_RANGE(0x30, 0x30) AM_MIRROR(0x0f) AM_WRITE()
455503//  AM_RANGE(0x40, 0x40) AM_MIRROR(0x0f) AM_WRITE()
456504   AM_RANGE(0x50, 0x50) AM_MIRROR(0x0f) AM_READ(fast_ctrl_r)
457   AM_RANGE(0x60, 0x63) AM_MIRROR(0x0c) AM_DEVREAD(SAB1793_TAG, wd17xx_r)
458   AM_RANGE(0x70, 0x73) AM_MIRROR(0x0c) AM_DEVWRITE(SAB1793_TAG, wd17xx_w)
505   AM_RANGE(0x60, 0x63) AM_MIRROR(0x0c) AM_DEVREAD(SAB1793_TAG, slow_fdc_r)
506   AM_RANGE(0x70, 0x73) AM_MIRROR(0x0c) AM_DEVWRITE(SAB1793_TAG, slow_fdc_w)
459507   AM_RANGE(0x80, 0x80) AM_MIRROR(0x0f) AM_DEVREADWRITE(Z80DMA_TAG, z80dma_r, z80dma_w)
460508ADDRESS_MAP_END
461509
r6571r6572
545593
546594   slow_t *conkort = get_safe_token_machine_slow(device->machine);
547595
548   return conkort->fdc_irq << 7;
596   return conkort->fdc_irq << 7 | 0x10 | !conkort->fdc_dden << 2;
549597}
550598
551599static WRITE8_DEVICE_HANDLER( conkort_pio_port_b_w )
r6571r6572
557605        0       !(_DS0 & _DS1)
558606        1       !(_DD0 & _DD1)
559607        2       8B pin 10
560        3       FDC DDEN
608        3       FDC _DDEN
561609        4       _R/BS
562610        5       FDC HLT
563611        6       FDC _HDLD
r6571r6572
565613
566614    */
567615
616   slow_t *conkort = get_safe_token_machine_slow(device->machine);
617
618   /* disk density */
619   wd17xx_set_density(conkort->wd1791, BIT(data, 3) ? DEN_FM_HI : DEN_FM_LO);
620   conkort->fdc_dden = BIT(data, 3);
568621}
569622
570623static WRITE_LINE_DEVICE_HANDLER( conkort_pio_ardy_w )
r6571r6572
662715   slow_t *conkort = get_safe_token_machine_slow(device->machine);
663716
664717   conkort->fdc_irq = state;
718
719   if (state)
720   {
721      /* TODO: this is really connected to the Z80 _RDY line */
722      cpu_set_input_line(conkort->cpu, INPUT_LINE_HALT, CLEAR_LINE);
723   }
665724}
666725
726static WRITE_LINE_DEVICE_HANDLER( slow_wd1791_drq_w )
727{
728   slow_t *conkort = get_safe_token_machine_slow(device->machine);
729
730   conkort->fdc_drq = state;
731
732   if (state)
733   {
734      /* TODO: this is really connected to the Z80 _RDY line */
735      cpu_set_input_line(conkort->cpu, INPUT_LINE_HALT, CLEAR_LINE);
736   }
737}
738
667739static const wd17xx_interface slow_wd17xx_interface =
668740{
669741   DEVCB_LINE(slow_wd1791_intrq_w),
670   DEVCB_NULL,
742   DEVCB_LINE(slow_wd1791_drq_w),
671743   { FLOPPY_0, FLOPPY_1, NULL, NULL }
672744};
673745
r6571r6572
769841   state_save_register_device_item(device, 0, conkort->data);
770842   state_save_register_device_item(device, 0, conkort->pio_ardy);
771843   state_save_register_device_item(device, 0, conkort->fdc_irq);
844   state_save_register_device_item(device, 0, conkort->fdc_drq);
845   state_save_register_device_item(device, 0, conkort->fdc_dden);
846   state_save_register_device_item(device, 0, conkort->wait_enable);
772847}
773848
774849/*-------------------------------------------------

Previous 15994 Revisions Next


© 1998-2018 The MESS Team