Previous 15994 Revisions Next

r5985 Tuesday 6th October, 2009 at 11:26:27 UTC by Dirk Best
[WD17XX] Refactored interface to use devcb callbacks for the INTRQ and DRQ lines
[src/mess/devices]coco_fdc.c thomflop.c
[src/mess/drivers]a310.c atarist.c bw2.c enterp.c fm7.c fmtowns.c pentagon.c pk8020.c scorpion.c thomson.c tiki100.c v1050.c x1.c xerox820.c xor100.c z80ne.c
[src/mess/includes]pk8020.h thomson.h z80ne.h
[src/mess/machine]99_dsk.c bbc.c beta.c beta.h cgenie.c coco.c comx35.c concept.c conkort.c dgn_beta.c kaypro.c mbee.c msx.c nascom1.c oric.c partner.c pk8020.c svi318.c trs80.c wd17xx.c wd17xx.h z80ne.c

src/mess/includes/z80ne.h
r5984r5985
1111#ifndef Z80NE_H_
1212#define Z80NE_H_
1313
14#include "machine/wd17xx.h"
1514
1615/***************************************************************************
1716    CONSTANTS
src/mess/includes/thomson.h
r5984r5985
2121#include "devices/cartslot.h"
2222#include "includes/serial.h"
2323#include "devices/cassette.h"
24#include "machine/wd17xx.h"
2524#include "machine/mc6843.h"
2625#include "machine/mc6846.h"
2726#include "machine/mc6854.h"
src/mess/includes/pk8020.h
r5984r5985
1111#include "machine/pit8253.h"
1212#include "machine/pic8259.h"
1313#include "machine/msm8251.h"
14#include "machine/wd17xx.h"
1514#include "devices/cassette.h"
1615#include "sound/speaker.h"
1716#include "sound/wave.h"
src/mess/machine/dgn_beta.c
r5984r5985
6767#include "machine/6551.h"
6868#include "image.h"
6969#include "machine/wd17xx.h"
70#include "devices/flopdrv.h"
7071
7172#include "debug/debugcpu.h"
7273#include "debug/debugcon.h"
r5984r5985
923924/* Dragon Beta onboard FDC */
924925/********************************************************************************************/
925926
926static WD17XX_CALLBACK( dgnbeta_fdc_callback )
927/* The INTRQ line goes through pia2 ca1, in exactly the same way as DRQ from DragonDos does */
928static WRITE_LINE_DEVICE_HANDLER( dgnbeta_fdc_intrq_w )
927929{
928   /* The INTRQ line goes through pia2 ca1, in exactly the same way as DRQ from DragonDos does */
929   /* DRQ is routed through various logic to the FIRQ inturrupt line on *BOTH* CPUs */
930   const device_config *pia_2 = devtag_get_device( device->machine, "pia_2" );
930   LOG_DISK(("dgnbeta_fdc_intrq_w(%d)\n", state));
931   pia6821_ca1_w(device, 0, state);
932}
931933
932   switch(state)
933   {
934      case WD17XX_IRQ_CLR:
935         pia6821_ca1_w(pia_2, 0, CLEAR_LINE);
936         break;
937      case WD17XX_IRQ_SET:
938         pia6821_ca1_w(pia_2, 0, ASSERT_LINE);
939         break;
940      case WD17XX_DRQ_CLR:
941         /*wd2797_drq=CLEAR_LINE;*/
942         cpu1_recalc_firq(device->machine, CLEAR_LINE);
943         break;
944      case WD17XX_DRQ_SET:
945         /*wd2797_drq=ASSERT_LINE;*/
946         cpu1_recalc_firq(device->machine, ASSERT_LINE);
947         break;
948   }
949
950   LOG_DISK(("dgnbeta_fdc_callback(%d)\n",state));
934/* DRQ is routed through various logic to the FIRQ inturrupt line on *BOTH* CPUs */
935static WRITE_LINE_DEVICE_HANDLER( dgnbeta_fdc_drq_w )
936{
937   LOG_DISK(("dgnbeta_fdc_drq_w(%d)\n", state));
938   cpu1_recalc_firq(device->machine, state);
951939}
952940
953const wd17xx_interface dgnbeta_wd17xx_interface = { dgnbeta_fdc_callback, NULL, {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}};
941const wd17xx_interface dgnbeta_wd17xx_interface =
942{
943   DEVCB_DEVICE_LINE("pia_2", dgnbeta_fdc_intrq_w),
944   DEVCB_LINE(dgnbeta_fdc_drq_w),
945   NULL,
946   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
947};
954948
955 READ8_HANDLER(dgnbeta_wd2797_r)
949READ8_HANDLER(dgnbeta_wd2797_r)
956950{
957951   int result = 0;
958952   const device_config *fdc = devtag_get_device(space->machine, "wd179x");
src/mess/machine/conkort.c
r5984r5985
9393#include "cpu/z80/z80daisy.h"
9494#include "machine/wd17xx.h"
9595#include "machine/abcbus.h"
96#include "devices/flopdrv.h"
9697
98
9799/***************************************************************************
98100    PARAMETERS
99101***************************************************************************/
r5984r5985
695697
696698/* FD1791 */
697699
698static WD17XX_CALLBACK( slow_wd1791_callback )
700static WRITE_LINE_DEVICE_HANDLER( slow_wd1791_intrq_w )
699701{
700702   slow_t *conkort = get_safe_token_machine_slow(device->machine);
701
702   switch(state)
703   {
704      case WD17XX_IRQ_CLR:
705         conkort->fdc_irq = 0;
706         break;
707      case WD17XX_IRQ_SET:
708         conkort->fdc_irq = 1;
709         break;
710      case WD17XX_DRQ_CLR:
711         break;
712      case WD17XX_DRQ_SET:
713         break;
714   }
703   conkort->fdc_irq = state;
715704}
716705
717706static const wd17xx_interface slow_wd17xx_interface =
718707{
719   slow_wd1791_callback,
708   DEVCB_LINE(slow_wd1791_intrq_w),
709   DEVCB_NULL,
720710   NULL,
721   {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}
711   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
722712};
723713
724714/* FD1793 */
725715
726static WD17XX_CALLBACK( fast_wd1793_callback )
716static WRITE_LINE_DEVICE_HANDLER( fast_wd1793_drq_w )
727717{
728718   fast_t *conkort = get_safe_token_machine_fast(device->machine);
729
730   switch(state)
731   {
732      case WD17XX_IRQ_CLR:
733         break;
734      case WD17XX_IRQ_SET:
735         break;
736      case WD17XX_DRQ_CLR:
737         z80dma_rdy_w(conkort->z80dma, 0, 0);
738         break;
739      case WD17XX_DRQ_SET:
740         z80dma_rdy_w(conkort->z80dma, 0, 1);
741         break;
742   }
719   z80dma_rdy_w(conkort->z80dma, 0, state);
743720}
744721
745722static const wd17xx_interface fast_wd17xx_interface =
746723{
747   fast_wd1793_callback,
724   DEVCB_NULL,
725   DEVCB_LINE(fast_wd1793_drq_w),
748726   NULL,
749   {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}
727   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
750728};
751729
752730/* Machine Driver */
src/mess/machine/mbee.c
r5984r5985
99****************************************************************************/
1010
1111#include "driver.h"
12#include "devices/flopdrv.h"
1213#include "includes/mbee.h"
1314
1415static UINT8 mbee_vsync;
r5984r5985
124125
125126*************************************************************************************/
126127
127static WD17XX_CALLBACK( mbee_fdc_callback )
128static WRITE_LINE_DEVICE_HANDLER( mbee_fdc_intrq_w )
128129{
129   if (WD17XX_IRQ_SET || WD17XX_DRQ_SET)
130   if (state)
130131      fdc_status |= 0x80;
131132   else
132133      fdc_status &= 0x7f;
133134}
134135
135const wd17xx_interface mbee_wd17xx_interface = { mbee_fdc_callback, NULL, {FLOPPY_0, FLOPPY_1, NULL, NULL }};
136static WRITE_LINE_DEVICE_HANDLER( mbee_fdc_drq_w )
137{
138   if (state)
139      fdc_status |= 0x80;
140   else
141      fdc_status &= 0x7f;
142}
136143
144const wd17xx_interface mbee_wd17xx_interface =
145{
146   DEVCB_LINE(mbee_fdc_intrq_w),
147   DEVCB_LINE(mbee_fdc_drq_w),
148   NULL,
149   {FLOPPY_0, FLOPPY_1, NULL, NULL }
150};
151
137152READ8_HANDLER ( mbee_fdc_status_r )
138153{
139154/*  d7 indicate if IRQ or DRQ is occuring (1=happening)
src/mess/machine/coco.c
r5984r5985
9999#include "sound/ay8910.h"
100100#include "devices/cococart.h"
101101#include "devices/cartslot.h"
102#include "devices/flopdrv.h"
102103
103104
104105/***************************************************************************
r5984r5985
17481749/* Dragon Alpha onboard FDC */
17491750/********************************************************************************************/
17501751
1751static WD17XX_CALLBACK( dgnalpha_fdc_callback )
1752/* The NMI line on the alphaAlpha is gated through IC16 (early PLD), and is gated by pia2 CA2  */
1753static WRITE_LINE_DEVICE_HANDLER( dgnalpha_fdc_intrq_w )
17521754{
1753   /* The NMI line on the alphaAlpha is gated through IC16 (early PLD), and is gated by pia2 CA2  */
1754   /* The DRQ line goes through pia2 cb1, in exactly the same way as DRQ from DragonDos does */
1755   /* for pia1 cb1 */
17561755   coco_state *cstate = device->machine->driver_data;
17571756
1758   switch(state)
1757   if (state)
17591758   {
1760      case WD17XX_IRQ_CLR:
1761         cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
1762         break;
1763      case WD17XX_IRQ_SET:
1764         if(dgnalpha_just_reset)
1765         {
1766            dgnalpha_just_reset = 0;
1767         }
1768         else
1769         {
1770            if (pia6821_get_output_ca2_z(cstate->pia_2))
1771               cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
1772         }
1773         break;
1774      case WD17XX_DRQ_CLR:
1775         pia6821_cb1_w(cstate->pia_2, 0, CARTLINE_CLEAR);
1776         break;
1777      case WD17XX_DRQ_SET:
1778         pia6821_cb1_w(cstate->pia_2, 0, CARTLINE_ASSERTED);
1779         break;
1759      if(dgnalpha_just_reset)
1760      {
1761         dgnalpha_just_reset = 0;
1762      }
1763      else
1764      {
1765         if (pia6821_get_output_ca2_z(cstate->pia_2))
1766            cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
1767      }
17801768   }
1769   else
1770   {
1771      cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
1772   }
17811773}
17821774
1775/* The DRQ line goes through pia2 cb1, in exactly the same way as DRQ from DragonDos does */
1776/* for pia1 cb1 */
1777static WRITE_LINE_DEVICE_HANDLER( dgnalpha_fdc_drq_w )
1778{
1779   coco_state *cstate = device->machine->driver_data;
1780   pia6821_cb1_w(cstate->pia_2, 0, state ? CARTLINE_ASSERTED : CARTLINE_CLEAR);
1781}
1782
17831783/* The Dragon Alpha hardware reverses the order of the WD2797 registers */
17841784READ8_HANDLER(wd2797_r)
17851785{
r5984r5985
29192919   dgnalpha_just_reset=1;
29202920}
29212921
2922const wd17xx_interface dgnalpha_wd17xx_interface = {
2923   dgnalpha_fdc_callback,
2922const wd17xx_interface dgnalpha_wd17xx_interface =
2923{
2924   DEVCB_LINE(dgnalpha_fdc_intrq_w),
2925   DEVCB_LINE(dgnalpha_fdc_drq_w),
29242926   NULL,
2925   {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}
2927   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
29262928};
2929
29272930/******* Machine Setups CoCos **********/
29282931
29292932MACHINE_START( coco )
src/mess/machine/99_dsk.c
r5984r5985
367367/*
368368    callback called whenever DRQ/IRQ state change
369369*/
370static WD17XX_CALLBACK( fdc_callback )
370static WRITE_LINE_DEVICE_HANDLER( ti99_fdc_intrq_w )
371371{
372   switch (state)
372   if (state)
373373   {
374   case WD17XX_IRQ_CLR:
375      DRQ_IRQ_status &= ~fdc_IRQ;
376      ti99_peb_set_ilb_bit(device->machine, intb_fdc_bit, 0);
377      break;
378   case WD17XX_IRQ_SET:
379374      DRQ_IRQ_status |= fdc_IRQ;
380375      ti99_peb_set_ilb_bit(device->machine, intb_fdc_bit, 1);
381      break;
382   case WD17XX_DRQ_CLR:
383      DRQ_IRQ_status &= ~fdc_DRQ;
384      break;
385   case WD17XX_DRQ_SET:
386      DRQ_IRQ_status |= fdc_DRQ;
387      break;
388376   }
377   else
378   {
379      DRQ_IRQ_status &= ~fdc_IRQ;
380      ti99_peb_set_ilb_bit(device->machine, intb_fdc_bit, 0);
381   }
389382
390383   fdc_handle_hold(device->machine);
391384}
392385
393const wd17xx_interface ti99_wd17xx_interface = { fdc_callback, NULL, {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3} };
386static WRITE_LINE_DEVICE_HANDLER( ti99_fdc_drq_w )
387{
388   if (state)
389      DRQ_IRQ_status |= fdc_DRQ;
390   else
391      DRQ_IRQ_status &= ~fdc_DRQ;
394392
393   fdc_handle_hold(device->machine);
394}
395395
396const wd17xx_interface ti99_wd17xx_interface =
397{
398   DEVCB_LINE(ti99_fdc_intrq_w),
399   DEVCB_LINE(ti99_fdc_drq_w),
400   NULL,
401   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
402};
403
404
396405/*
397406    Initializes all available controllers. This routine is only used in the
398407    init state of the emulator. During the normal operation, only the
src/mess/machine/oric.c
r5984r5985
2727#include "machine/ctronics.h"
2828#include "devices/cassette.h"
2929#include "sound/ay8910.h"
30#include "devices/flopdrv.h"
3031
3132
3233UINT8 *oric_ram;
r5984r5985
661662   }
662663}
663664
664static WD17XX_CALLBACK( oric_jasmin_wd179x_callback )
665/* DRQ is connected to interrupt */
666static WRITE_LINE_DEVICE_HANDLER( oric_jasmin_wd179x_drq_w )
665667{
666   switch (state)
667   {
668      /* DRQ is connected to interrupt */
669      case WD17XX_DRQ_CLR:
670      {
671         oric_irqs &=~(1<<1);
668   if (state)
669      oric_irqs |= (1<<1);
670   else
671      oric_irqs &=~(1<<1);
672672
673         oric_refresh_ints(device->machine);
674      }
675      break;
676
677      case WD17XX_DRQ_SET:
678      {
679         oric_irqs |= (1<<1);
680
681         oric_refresh_ints(device->machine);
682      }
683      break;
684
685      default:
686         break;
687   }
673   oric_refresh_ints(device->machine);
688674}
689675
690676static READ8_HANDLER (oric_jasmin_r)
r5984r5985
815801   oric_refresh_ints(machine);
816802}
817803
818static WD17XX_CALLBACK( oric_microdisc_wd179x_callback )
804static WRITE_LINE_DEVICE_HANDLER( oric_microdisc_wd179x_intrq_w )
819805{
820   switch (state)
821   {
822      case WD17XX_IRQ_CLR:
823      {
824         port_314_r |=(1<<7);
806   oric_wd179x_int_state = state;
825807
826         oric_wd179x_int_state = 0;
808   if (state)
809      port_314_r &= ~(1<<7);
810   else
811      port_314_r |=(1<<7);
827812
828         oric_microdisc_refresh_wd179x_ints(device->machine);
829      }
830      break;
813   oric_microdisc_refresh_wd179x_ints(device->machine);
814}
831815
832      case WD17XX_IRQ_SET:
833      {
834         port_314_r &= ~(1<<7);
835
836         oric_wd179x_int_state = 1;
837
838         oric_microdisc_refresh_wd179x_ints(device->machine);
839      }
840      break;
841
842      case WD17XX_DRQ_CLR:
843      {
844         port_318_r |= (1<<7);
845      }
846      break;
847
848      case WD17XX_DRQ_SET:
849      {
850         port_318_r &=~(1<<7);
851      }
852      break;
853   }
816static WRITE_LINE_DEVICE_HANDLER( oric_microdisc_wd179x_drq_w )
817{
818   if (state)
819      port_318_r &=~(1<<7);
820   else
821      port_318_r |= (1<<7);
854822}
855823
856
857824static void   oric_microdisc_set_mem_0x0c000(running_machine *machine)
858825{
859826   if (oric_is_telestrat)
r5984r5985
10451012
10461013/*********************************************************/
10471014
1015static WRITE_LINE_DEVICE_HANDLER( oric_wd179x_intrq_w )
1016{
1017   if ((input_port_read(device->machine, "FLOPPY") & 0x07) == ORIC_FLOPPY_INTERFACE_MICRODISC)
1018      oric_microdisc_wd179x_intrq_w(device, state);
1019}
10481020
1049static WD17XX_CALLBACK(oric_wd179x_callback)
1021static WRITE_LINE_DEVICE_HANDLER( oric_wd179x_drq_w )
10501022{
10511023   switch (input_port_read(device->machine, "FLOPPY") &  0x07)
10521024   {
r5984r5985
10551027      case ORIC_FLOPPY_INTERFACE_APPLE2:
10561028         return;
10571029      case ORIC_FLOPPY_INTERFACE_MICRODISC:
1058         oric_microdisc_wd179x_callback(device, state, param);
1030         oric_microdisc_wd179x_drq_w(device, state);
10591031         return;
10601032      case ORIC_FLOPPY_INTERFACE_JASMIN:
1061         oric_jasmin_wd179x_callback(device, state, param);
1033         oric_jasmin_wd179x_drq_w(device, state);
10621034         return;
10631035   }
10641036}
10651037
1066const wd17xx_interface oric_wd17xx_interface = { oric_wd179x_callback, NULL, {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3} };
1038const wd17xx_interface oric_wd17xx_interface =
1039{
1040   DEVCB_LINE(oric_wd179x_intrq_w),
1041   DEVCB_LINE(oric_wd179x_drq_w),
1042   NULL,
1043   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
1044};
10671045
10681046static void oric_common_init_machine(running_machine *machine)
10691047{
src/mess/machine/nascom1.c
r5984r5985
1616/* Devices */
1717#include "devices/snapquik.h"
1818#include "devices/cassette.h"
19#include "devices/flopdrv.h"
1920
21
2022#define NASCOM1_KEY_RESET   0x02
2123#define NASCOM1_KEY_INCR   0x01
2224
r5984r5985
5456 *
5557 *************************************/
5658
57static WD17XX_CALLBACK( nascom2_fdc_callback )
59static WRITE_LINE_DEVICE_HANDLER( nascom2_fdc_intrq_w )
5860{
59   switch (state)
60   {
61   case WD17XX_IRQ_SET: nascom2_fdc.irq = 1; break;
62   case WD17XX_IRQ_CLR: nascom2_fdc.irq = 0; break;
63   case WD17XX_DRQ_SET: nascom2_fdc.drq = 1; break;
64   case WD17XX_DRQ_CLR: nascom2_fdc.drq = 0; break;
65   }
61   nascom2_fdc.irq = state;
6662}
6763
64static WRITE_LINE_DEVICE_HANDLER( nascom2_fdc_drq_w )
65{
66   nascom2_fdc.drq = state;
67}
6868
69const wd17xx_interface nascom2_wd17xx_interface = { nascom2_fdc_callback, NULL, {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3} };
69const wd17xx_interface nascom2_wd17xx_interface =
70{
71   DEVCB_LINE(nascom2_fdc_intrq_w),
72   DEVCB_LINE(nascom2_fdc_drq_w),
73   NULL,
74   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
75};
7076
7177
7278READ8_HANDLER( nascom2_fdc_select_r )
src/mess/machine/wd17xx.c
r5984r5985
197197typedef struct _wd17xx_t wd17xx_t;
198198struct _wd17xx_t
199199{
200   /* callbacks */
201   devcb_resolved_write_line out_intrq_func;
202   devcb_resolved_write_line out_drq_func;
203
200204   DENSITY   density;            /* FM/MFM, single / double density */
201205   wd17xx_type_t type;
202206   UINT8   track_reg;            /* value of track register */
r5984r5985
816820
817821
818822
819static void wd17xx_callback(const device_config *device, wd17xx_state_t state)
820{
821   wd17xx_t *w = get_safe_token(device);
822   void *param = NULL;
823   if (w->intf->callback_param)
824      param = (*w->intf->callback_param)(device);
825   if (w->intf->callback)
826      (*w->intf->callback)(device, state, param);
827}
828
829
830
831823static void   wd17xx_set_irq(const device_config *device)
832824{
833825   wd17xx_t *w = get_safe_token(device);
826
834827   w->status &= ~STA_2_BUSY;
835   /* generate an IRQ */
836   wd17xx_callback(device, WD17XX_IRQ_SET);
828   devcb_call_write_line(&w->out_intrq_func, ASSERT_LINE);
837829}
838830
839831
r5984r5985
10151007   wd17xx_t *w = get_safe_token(device);
10161008
10171009//  w->status_drq = 0;
1018   wd17xx_callback(device, WD17XX_DRQ_CLR);
10191010   w->status &= ~STA_2_DRQ;
1011   devcb_call_write_line(&w->out_drq_func, CLEAR_LINE);
10201012}
10211013
10221014
r5984r5985
10341026
10351027   /* set drq */
10361028//  w->status_drq = STA_2_DRQ;
1037   wd17xx_callback(device, WD17XX_DRQ_SET);
10381029   w->status |= STA_2_DRQ;
1030   devcb_call_write_line(&w->out_drq_func, ASSERT_LINE);
10391031}
10401032
10411033
r5984r5985
11661158   wd17xx_t *w = get_safe_token(device);
11671159   int result = w->status;
11681160
1169   wd17xx_callback(device, WD17XX_IRQ_CLR);
1161   devcb_call_write_line(&w->out_intrq_func, CLEAR_LINE);
11701162
11711163   /* type 1 command or force int command? */
11721164   if ((w->command_type==TYPE_I) || (w->command_type==TYPE_IV))
r5984r5985
13321324   floppy_drive_set_motor_state(wd17xx_current_image(device), 1);
13331325   floppy_drive_set_ready_state(wd17xx_current_image(device), 1,0);
13341326   /* also cleared by writing command */
1335   wd17xx_callback(device, WD17XX_IRQ_CLR);
1327   devcb_call_write_line(&w->out_intrq_func, CLEAR_LINE);
13361328
13371329   /* clear write protected. On read sector, read track and read dam, write protected bit is clear */
13381330   w->status &= ~((1<<6) | (1<<5) | (1<<4));
r5984r5985
17431735   }
17441736}
17451737
1746const wd17xx_interface default_wd17xx_interface = { NULL, NULL, { FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3} };
1747const wd17xx_interface default_wd17xx_interface_2_drives = { NULL, NULL, { FLOPPY_0, FLOPPY_1, NULL, NULL} };
1738const wd17xx_interface default_wd17xx_interface = { DEVCB_NULL, DEVCB_NULL, NULL, { FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3} };
1739const wd17xx_interface default_wd17xx_interface_2_drives = { DEVCB_NULL, DEVCB_NULL, NULL, { FLOPPY_0, FLOPPY_1, NULL, NULL} };
17481740
17491741/* device interface */
17501742static void common_start(const device_config *device, wd17xx_type_t device_type)
r5984r5985
17651757   w->timer_rs = timer_alloc(device->machine, wd17xx_read_sector_callback, (void*)device);
17661758   w->timer_ws = timer_alloc(device->machine, wd17xx_write_sector_callback, (void*)device);
17671759   w->pause_time = 40;
1760
1761   /* resolve callbacks */
1762   devcb_resolve_write_line(&w->out_intrq_func, &w->intf->out_intrq_func, device);
1763   devcb_resolve_write_line(&w->out_drq_func, &w->intf->out_drq_func, device);
17681764}
17691765
17701766static DEVICE_RESET( wd17xx )
src/mess/machine/wd17xx.h
r5984r5985
77
88*********************************************************************/
99
10#ifndef WD179X_H
11#define WD179X_H
10#ifndef __WD17XX_H__
11#define __WD17XX_H__
1212
13#include "devices/flopdrv.h"
13#include "devcb.h"
1414
15
1516/***************************************************************************
1617    MACROS
1718***************************************************************************/
r5984r5985
2627#define WD177X      DEVICE_GET_INFO_NAME(wd177x)
2728#define MB8877      DEVICE_GET_INFO_NAME(mb8877)
2829
30
2931/***************************************************************************
3032    TYPE DEFINITIONS
3133***************************************************************************/
3234
3335typedef enum
3436{
35   WD17XX_IRQ_CLR,
36   WD17XX_IRQ_SET,
37   WD17XX_DRQ_CLR,
38   WD17XX_DRQ_SET
39} wd17xx_state_t;
40
41typedef enum
42{
4337   DEN_FM_LO = 0,
4438   DEN_FM_HI,
4539   DEN_MFM_LO,
4640   DEN_MFM_HI
4741} DENSITY;
4842
49typedef void (*wd17xx_callback_func)(const device_config *device, wd17xx_state_t state, void *param);
50#define WD17XX_CALLBACK(name)   void name(const device_config *device, wd17xx_state_t state, void *param )
51
5243typedef void* (*wd17xx_param_callback_func)(const device_config *device);
5344#define WD17XX_PARAM_CALLBACK(name)   void* name(const device_config *device)
5445
r5984r5985
5647typedef struct _wd17xx_interface wd17xx_interface;
5748struct _wd17xx_interface
5849{
59   wd17xx_callback_func callback;
50   devcb_write_line out_intrq_func;
51   devcb_write_line out_drq_func;
6052   wd17xx_param_callback_func callback_param;
6153   const char *floppy_drive_tags[4];
6254};
r5984r5985
10193
10294extern const wd17xx_interface default_wd17xx_interface;
10395extern const wd17xx_interface default_wd17xx_interface_2_drives;
96
97
10498/***************************************************************************
10599    DEVICE CONFIGURATION MACROS
106100***************************************************************************/
r5984r5985
142136   MDRV_DEVICE_CONFIG(_intrf)
143137
144138
145#endif /* WD179X_H */
146
147
148
139#endif /* __WD17XX_H__ */
src/mess/machine/comx35.c
r5984r5985
123123#include "video/mc6845.h"
124124#include "includes/comx35.h"
125125#include "machine/rescap.h"
126#include "devices/flopdrv.h"
126127
128
127129enum
128130{
129131   PRINTER_PARALLEL = 0,
r5984r5985
183185}
184186
185187/* Floppy Disc Controller */
186static WD17XX_CALLBACK( comx35_fdc_callback )
188static WRITE_LINE_DEVICE_HANDLER( comx35_fdc_intrq_w )
187189{
188190   comx35_state *driver_state = device->machine->driver_data;
191   driver_state->fdc_irq = state;
192}
189193
190   switch (state)
191   {
192   case WD17XX_IRQ_SET:
193      driver_state->fdc_irq = 1;
194      break;
194static WRITE_LINE_DEVICE_HANDLER( comx35_fdc_drq_w )
195{
196   comx35_state *driver_state = device->machine->driver_data;
195197
196   case WD17XX_IRQ_CLR:
197      driver_state->fdc_irq = 0;
198      break;
199
200   case WD17XX_DRQ_SET:
201      if (driver_state->fdc_drq_enable)
202      {
203         driver_state->cdp1802_ef4 = 1;
204      }
205      break;
206
207   case WD17XX_DRQ_CLR:
208      if (driver_state->fdc_drq_enable)
209      {
210         driver_state->cdp1802_ef4 = 0;
211      }
212      break;
213   }
198   if (driver_state->fdc_drq_enable)
199      driver_state->cdp1802_ef4 = state;
214200}
215201
216const wd17xx_interface comx35_wd17xx_interface = { comx35_fdc_callback, NULL, {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3} };
202const wd17xx_interface comx35_wd17xx_interface =
203{
204   DEVCB_LINE(comx35_fdc_intrq_w),
205   DEVCB_LINE(comx35_fdc_drq_w),
206   NULL,
207   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
208};
217209
218210static UINT8 fdc_r(const address_space *space)
219211{
src/mess/machine/trs80.c
r5984r5985
2020
2121/* Devices */
2222#include "devices/cassette.h"
23#include "devices/flopdrv.h"
2324
25
2426#ifdef MAME_DEBUG
2527#define VERBOSE 1
2628#else
r5984r5985
773775   trs80_fdc_interrupt_internal(device->machine);
774776}
775777
776static WD17XX_CALLBACK( trs80_fdc_callback )
778static WRITE_LINE_DEVICE_HANDLER( trs80_fdc_intrq_w )
777779{
778   switch (state)
780   if (state)
779781   {
780      case WD17XX_IRQ_CLR:
781         if (trs80_model4)
782            trs80_nmi_data = 0;
783         else
784            trs80_int &= ~IRQ_M1_FDC;
785         break;
786      case WD17XX_IRQ_SET:
787         trs80_fdc_interrupt_internal(device->machine);
788         break;
789      case WD17XX_DRQ_CLR:
790      case WD17XX_DRQ_SET:
791         /* do nothing */
792         break;
782      trs80_fdc_interrupt_internal(device->machine);
793783   }
784   else
785   {
786      if (trs80_model4)
787         trs80_nmi_data = 0;
788      else
789         trs80_int &= ~IRQ_M1_FDC;
790   }
794791}
795792
796const wd17xx_interface trs80_wd17xx_interface = { trs80_fdc_callback, NULL, {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3} };
793const wd17xx_interface trs80_wd17xx_interface =
794{
795   DEVCB_LINE(trs80_fdc_intrq_w),
796   DEVCB_NULL,
797   NULL,
798   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
799};
797800
798801
799802/*************************************
src/mess/machine/svi318.c
r5984r5985
305305typedef struct
306306{
307307   UINT8 driveselect;
308   UINT8 irq_drq;
308   int drq;
309   int irq;
309310   UINT8 heads[2];
310311} SVI318_FDC_STRUCT;
311312
312313static SVI318_FDC_STRUCT svi318_fdc;
313314
314static WD17XX_CALLBACK( svi_fdc_callback )
315static WRITE_LINE_DEVICE_HANDLER( svi_fdc_intrq_w )
315316{
316   switch( state )
317   {
318   case WD17XX_IRQ_CLR:
319      svi318_fdc.irq_drq &= ~0x80;
320      break;
321   case WD17XX_IRQ_SET:
322      svi318_fdc.irq_drq |= 0x80;
323      break;
324   case WD17XX_DRQ_CLR:
325      svi318_fdc.irq_drq &= ~0x40;
326      break;
327   case WD17XX_DRQ_SET:
328      svi318_fdc.irq_drq |= 0x40;
329      break;
330   }
317   svi318_fdc.irq = state;
331318}
332319
333const wd17xx_interface svi_wd17xx_interface = { svi_fdc_callback, NULL, {FLOPPY_0,FLOPPY_1,NULL,NULL} };
320static WRITE_LINE_DEVICE_HANDLER( svi_fdc_drq_w )
321{
322   svi318_fdc.drq = state;
323}
334324
325const wd17xx_interface svi_wd17xx_interface =
326{
327   DEVCB_LINE(svi_fdc_intrq_w),
328   DEVCB_LINE(svi_fdc_drq_w),
329   NULL,
330   {FLOPPY_0, FLOPPY_1, NULL, NULL}
331};
332
335333static WRITE8_HANDLER( svi318_fdc_drive_motor_w )
336334{
337335   const device_config *fdc = devtag_get_device(space->machine, "wd179x");
r5984r5985
360358
361359static READ8_HANDLER( svi318_fdc_irqdrq_r )
362360{
363   return svi318_fdc.irq_drq;
361   UINT8 result = 0;
362
363   result |= svi318_fdc.drq << 6;
364   result |= svi318_fdc.irq << 7;
365
366   return result;
364367}
365368
366369MC6845_UPDATE_ROW( svi806_crtc6845_update_row )
src/mess/machine/z80ne.c
r5984r5985
1616#include "machine/ay31015.h"
1717#include "machine/kr2376.h"
1818#include "video/m6847.h"
19#include "machine/wd17xx.h"
1920
2021/* Devices */
2122#include "devices/cassette.h"
src/mess/machine/concept.c
r5984r5985
1212#include "machine/wd17xx.h"
1313#include "cpu/m68000/m68000.h"
1414#include "includes/corvushd.h"
15#include "devices/flopdrv.h"
1516
17
1618#define VERBOSE 1
1719
1820#define LOG(x)  do { if (VERBOSE > 0) logerror x; } while (0)
r5984r5985
578580   install_expansion_slot(slot, concept_fdc_reg_r, concept_fdc_reg_w, concept_fdc_rom_r, NULL);
579581}
580582
581static WD17XX_CALLBACK( fdc_callback )
583static WRITE_LINE_DEVICE_HANDLER( concept_fdc_intrq_w )
582584{
583   switch (state)
584   {
585      case WD17XX_IRQ_CLR:
586         fdc_local_status &= ~LS_INT_mask;
587         break;
588      case WD17XX_IRQ_SET:
589         fdc_local_status |= LS_INT_mask;
590         break;
591      case WD17XX_DRQ_CLR:
592         fdc_local_status &= ~LS_DRQ_mask;
593         break;
594      case WD17XX_DRQ_SET:
595         fdc_local_status |= LS_DRQ_mask;
596         break;
597   }
585   if (state)
586      fdc_local_status |= LS_INT_mask;
587   else
588      fdc_local_status &= ~LS_INT_mask;
598589}
599590
600const wd17xx_interface concept_wd17xx_interface = { fdc_callback, NULL, {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}};
591static WRITE_LINE_DEVICE_HANDLER( concept_fdc_drq_w )
592{
593   if (state)
594      fdc_local_status |= LS_DRQ_mask;
595   else
596      fdc_local_status &= ~LS_DRQ_mask;
597}
601598
599const wd17xx_interface concept_wd17xx_interface =
600{
601   DEVCB_LINE(concept_fdc_intrq_w),
602   DEVCB_LINE(concept_fdc_drq_w),
603   NULL,
604   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
605};
606
602607static  READ8_HANDLER(concept_fdc_reg_r)
603608{
604609   const device_config *fdc = devtag_get_device(space->machine, "wd179x");
src/mess/machine/msx.c
r5984r5985
710710
711711*/
712712
713static WD17XX_CALLBACK( msx_wd179x_int )
713static WRITE_LINE_DEVICE_HANDLER( msx_wd179x_intrq_w )
714714{
715   switch (state)
716   {
717      case WD17XX_IRQ_CLR: msx1.dsk_stat |= 0x40; break;
718      case WD17XX_IRQ_SET: msx1.dsk_stat &= ~0x40; break;
719      case WD17XX_DRQ_CLR: msx1.dsk_stat |= 0x80; break;
720      case WD17XX_DRQ_SET: msx1.dsk_stat &= ~0x80; break;
721   }
715   if (state)
716      msx1.dsk_stat &= ~0x40;
717   else
718      msx1.dsk_stat |= 0x40;
722719}
723720
724const wd17xx_interface msx_wd17xx_interface = { msx_wd179x_int, NULL, {FLOPPY_0,FLOPPY_1,NULL,NULL} };
721static WRITE_LINE_DEVICE_HANDLER( msx_wd179x_drq_w )
722{
723   if (state)
724      msx1.dsk_stat &= ~0x80;
725   else
726      msx1.dsk_stat |= 0x80;
727}
725728
729const wd17xx_interface msx_wd17xx_interface =
730{
731   DEVCB_LINE(msx_wd179x_intrq_w),
732   DEVCB_LINE(msx_wd179x_drq_w),
733   NULL,
734   {FLOPPY_0, FLOPPY_1, NULL, NULL}
735};
736
726737FLOPPY_OPTIONS_START(msx)
727738   FLOPPY_OPTION(msx, "dsk", "MSX SS", basicdsk_identify_default, basicdsk_construct_default,
728739      HEADS([1])
src/mess/machine/cgenie.c
r5984r5985
1515#include "devices/cassette.h"
1616#include "sound/ay8910.h"
1717#include "sound/dac.h"
18#include "devices/flopdrv.h"
1819
1920
2021#define AYWriteReg(chip,port,value) \
r5984r5985
425426   }
426427}
427428
428static WD17XX_CALLBACK( cgenie_fdc_callback )
429static WRITE_LINE_DEVICE_HANDLER( cgenie_fdc_intrq_w )
429430{
430431   /* if disc hardware is not enabled, do not cause an int */
431432   if (!( input_port_read(device->machine, "DSW0") & 0x80 ))
432433      return;
433434
434   switch( state )
435   if (state)
435436   {
436      case WD17XX_IRQ_CLR:
437         irq_status &= ~IRQ_FDC;
438         break;
439      case WD17XX_IRQ_SET:
440         if( (irq_status & IRQ_FDC) == 0 )
441         {
442            irq_status |= IRQ_FDC;
443            cputag_set_input_line(device->machine, "maincpu", 0, HOLD_LINE);
444         }
445         break;
446      case WD17XX_DRQ_CLR:
447      case WD17XX_DRQ_SET:
448         /* do nothing */
449         break;
437      if( (irq_status & IRQ_FDC) == 0 )
438      {
439         irq_status |= IRQ_FDC;
440         cputag_set_input_line(device->machine, "maincpu", 0, HOLD_LINE);
441      }
450442   }
443   else
444   {
445      irq_status &= ~IRQ_FDC;
446   }
451447}
452448
453const wd17xx_interface cgenie_wd17xx_interface = { cgenie_fdc_callback, NULL, {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3} };
449const wd17xx_interface cgenie_wd17xx_interface =
450{
451   DEVCB_LINE(cgenie_fdc_intrq_w),
452   DEVCB_NULL,
453   NULL,
454   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
455};
454456
455457WRITE8_HANDLER( cgenie_motor_w )
456458{
src/mess/machine/kaypro.c
r5984r5985
55#include "machine/kay_kbd.h"
66#include "devices/snapquik.h"
77#include "includes/kaypro.h"
8#include "devices/flopdrv.h"
89
910
1011static const device_config *kayproii_z80pio_g;
r5984r5985
329330static TIMER_CALLBACK( kaypro_timer_callback )
330331{
331332   if (cpu_get_reg(cputag_get_cpu(machine, "maincpu"), Z80_HALT))
332      cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, 1);
333      cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
333334}
334335
336static WRITE_LINE_DEVICE_HANDLER( kaypro_fdc_intrq_w )
337{
338   if (state)
339      timer_set(device->machine, ATTOTIME_IN_USEC(25), NULL, 0, kaypro_timer_callback);
340   else
341      cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
342}
335343
336static WD17XX_CALLBACK( kaypro_fdc_callback )
344static WRITE_LINE_DEVICE_HANDLER( kaypro_fdc_drq_w )
337345{
338   if ((state == WD17XX_DRQ_SET) || (state == WD17XX_IRQ_SET))
339   {
346   if (state)
340347      timer_set(device->machine, ATTOTIME_IN_USEC(25), NULL, 0, kaypro_timer_callback);
341   }
342348   else
343   {
344      cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, 0);
345   }
349      cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
350
346351}
347352
348const wd17xx_interface kaypro_wd1793_interface = { kaypro_fdc_callback, NULL, {FLOPPY_0,FLOPPY_1,NULL,NULL} };
353const wd17xx_interface kaypro_wd1793_interface =
354{
355   DEVCB_LINE(kaypro_fdc_intrq_w),
356   DEVCB_LINE(kaypro_fdc_drq_w),
357   NULL,
358   {FLOPPY_0, FLOPPY_1, NULL, NULL}
359};
349360
361
350362/***********************************************************
351363
352364    Machine
src/mess/machine/beta.c
r5984r5985
6767   beta->betadisk_status = 0;
6868}
6969
70static WD17XX_CALLBACK( betadisk_wd179x_callback )
70static WRITE_LINE_DEVICE_HANDLER( betadisk_wd179x_intrq_w )
7171{
72   const device_config *wd_device = devtag_get_device(device->machine, BETA_DISK_TAG);
73   beta_disk_state *beta = get_safe_token(wd_device);
74   if (wd_device->started) {
75      switch (state)
76      {
77         case WD17XX_DRQ_SET:
78         {
79            beta->betadisk_status |= (1<<6);
80         }
81         break;
72   beta_disk_state *beta = get_safe_token(device->owner);
8273
83         case WD17XX_DRQ_CLR:
84         {
85            beta->betadisk_status &=~(1<<6);
86         }
87         break;
74   if (state)
75      beta->betadisk_status |= (1<<7);
76   else
77      beta->betadisk_status &=~(1<<7);
78}
8879
89         case WD17XX_IRQ_SET:
90         {
91            beta->betadisk_status |= (1<<7);
92         }
93         break;
80static WRITE_LINE_DEVICE_HANDLER( betadisk_wd179x_drq_w )
81{
82   beta_disk_state *beta = get_safe_token(device->owner);
9483
95         case WD17XX_IRQ_CLR:
96         {
97            beta->betadisk_status &=~(1<<7);
98         }
99         break;
100      }
101   }
84   if (state)
85      beta->betadisk_status |= (1<<6);
86   else
87      beta->betadisk_status &=~(1<<6);
10288}
10389
104static const wd17xx_interface beta_wd17xx_interface = { betadisk_wd179x_callback, NULL, {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3} };
90static const wd17xx_interface beta_wd17xx_interface =
91{
92   DEVCB_LINE(betadisk_wd179x_intrq_w),
93   DEVCB_LINE(betadisk_wd179x_drq_w),
94   NULL,
95   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
96};
10597
10698READ8_DEVICE_HANDLER(betadisk_status_r)
10799{
src/mess/machine/beta.h
r5984r5985
77    04/05/2008 Created by Miodrag Milanovic
88
99*********************************************************************/
10#ifndef BETA_H
11#define BETA_H
10#ifndef __BETA_H__
11#define __BETA_H__
1212
13#include "machine/wd17xx.h"
1413
1514int betadisk_is_active(const device_config *device);
1615void betadisk_enable(const device_config *device);
r5984r5985
4443/* device interface */
4544DEVICE_GET_INFO( beta_disk );
4645
47#endif /* BETA_H */
46#endif /* __BETA_H__ */
src/mess/machine/partner.c
r5984r5985
1616#include "video/i8275.h"
1717#include "includes/radio86.h"
1818#include "includes/partner.h"
19#include "devices/flopdrv.h"
1920
2021static UINT8 partner_mem_page;
2122static UINT8 partner_win_mem_page;
r5984r5985
2728   radio86_tape_value = 0x80;
2829}
2930
30static WD17XX_CALLBACK( partner_wd17xx_callback )
31static WRITE_LINE_DEVICE_HANDLER( partner_wd17xx_drq_w )
3132{
32   const device_config *dma8257 = devtag_get_device(device->machine, "dma8257");
33   switch(state)
34   {
35      case WD17XX_IRQ_CLR:
36         break;
37      case WD17XX_IRQ_SET:
38         break;
39      case WD17XX_DRQ_CLR:
40         break;
41      case WD17XX_DRQ_SET:
42         dma8257_drq_w(dma8257, 0, 1);
43         break;
44   }
33   if (state)
34      dma8257_drq_w(device, 0, 1);
4535}
4636
47const wd17xx_interface partner_wd17xx_interface = { partner_wd17xx_callback, NULL, {FLOPPY_0,FLOPPY_1,NULL,NULL} };
37const wd17xx_interface partner_wd17xx_interface =
38{
39   DEVCB_NULL,
40   DEVCB_DEVICE_LINE("dma8257", partner_wd17xx_drq_w),
41   NULL,
42   {FLOPPY_0, FLOPPY_1, NULL, NULL}
43};
4844
4945MACHINE_START(partner)
5046{
src/mess/machine/pk8020.c
r5984r5985
88
99
1010#include "driver.h"
11#include "includes/pk8020.h"
1112#include "cpu/i8085/i8085.h"
12#include "includes/pk8020.h"
13#include "machine/wd17xx.h"
1314
1415static UINT8 attr = 0;
1516static UINT8 text_attr = 0;
src/mess/machine/bbc.c
r5984r5985
1515#include "sound/tms5220.h"
1616#include "machine/6522via.h"
1717#include "machine/wd17xx.h"
18#include "devices/flopdrv.h"
1819#include "includes/bbc.h"
1920#include "machine/upd7002.h"
2021#include "machine/i8271.h"
r5984r5985
15501551***************************************/
15511552
15521553static int  drive_control;
1553/* bit 0: 1 = drq set, bit 1: 1 = irq set */
1554static int   bbc_wd177x_drq_irq_state;
1554static int bbc_wd177x_irq_state;
1555static int bbc_wd177x_drq_state;
15551556
1557
15561558static int previous_wd177x_int_state;
15571559
15581560/*
r5984r5985
15801582
15811583static int bbc_1770_IntEnabled;
15821584
1583static WD17XX_CALLBACK( bbc_wd177x_callback)
1585/* wd177x_IRQ_SET and latch bit 4 (nmi_enable) are NAND'ED together
1586   wd177x_DRQ_SET and latch bit 4 (nmi_enable) are NAND'ED together
1587   the output of the above two NAND gates are then OR'ED together and sent to the 6502 NMI line.
1588    DRQ and IRQ are active low outputs from wd177x. We use wd177x_DRQ_SET for DRQ = 0,
1589    and wd177x_DRQ_CLR for DRQ = 1. Similarly wd177x_IRQ_SET for IRQ = 0 and wd177x_IRQ_CLR
1590    for IRQ = 1.
1591
1592  The above means that if IRQ or DRQ are set, a interrupt should be generated.
1593  The nmi_enable decides if interrupts are actually triggered.
1594  The nmi is edge triggered, and triggers on a +ve edge.
1595*/
1596
1597static void bbc_update_fdq_int(running_machine *machine, int state)
15841598{
15851599   int bbc_state;
1586   /* wd177x_IRQ_SET and latch bit 4 (nmi_enable) are NAND'ED together
1587       wd177x_DRQ_SET and latch bit 4 (nmi_enable) are NAND'ED together
1588       the output of the above two NAND gates are then OR'ED together and sent to the 6502 NMI line.
1589        DRQ and IRQ are active low outputs from wd177x. We use wd177x_DRQ_SET for DRQ = 0,
1590        and wd177x_DRQ_CLR for DRQ = 1. Similarly wd177x_IRQ_SET for IRQ = 0 and wd177x_IRQ_CLR
1591        for IRQ = 1.
15921600
1593      The above means that if IRQ or DRQ are set, a interrupt should be generated.
1594      The nmi_enable decides if interrupts are actually triggered.
1595      The nmi is edge triggered, and triggers on a +ve edge.
1596    */
1597
1598   logerror("callback $%02X\n", state);
1599
1600
1601   /* update bbc_wd177x_drq_irq_state depending on event */
1602   switch (state)
1603   {
1604        case WD17XX_DRQ_SET:
1605      {
1606         bbc_wd177x_drq_irq_state |= 1;
1607      }
1608      break;
1609
1610      case WD17XX_DRQ_CLR:
1611      {
1612         bbc_wd177x_drq_irq_state &= ~1;
1613      }
1614      break;
1615
1616      case  WD17XX_IRQ_SET:
1617      {
1618         bbc_wd177x_drq_irq_state |= (1<<1);
1619      }
1620      break;
1621
1622      case WD17XX_IRQ_CLR:
1623      {
1624         bbc_wd177x_drq_irq_state &= ~(1<<1);
1625      }
1626      break;
1627   }
1628
16291601   /* if drq or irq is set, and interrupt is enabled */
1630   if (((bbc_wd177x_drq_irq_state & 3)!=0) && (bbc_1770_IntEnabled))
1602   if ((bbc_wd177x_irq_state || bbc_wd177x_drq_state) && (bbc_1770_IntEnabled))
16311603   {
16321604      /* int trigger */
16331605      bbc_state = 1;
r5984r5985
16461618      {
16471619         /* I'll pulse it because if I used hold-line I'm not sure
16481620            it would clear - to be checked */
1649         cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI,PULSE_LINE);
1621         cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI,PULSE_LINE);
16501622      }
16511623   }
16521624
16531625   previous_wd177x_int_state = bbc_state;
1626}
16541627
1628static WRITE_LINE_DEVICE_HANDLER( bbc_wd177x_intrq_w )
1629{
1630   bbc_wd177x_irq_state = state;
1631   bbc_update_fdq_int(device->machine, state);
16551632}
16561633
1657const wd17xx_interface bbc_wd17xx_interface = {
1658   bbc_wd177x_callback,
1634static WRITE_LINE_DEVICE_HANDLER( bbc_wd177x_drq_w )
1635{
1636   bbc_wd177x_drq_state = state;
1637   bbc_update_fdq_int(device->machine, state);
1638}
1639
1640const wd17xx_interface bbc_wd17xx_interface =
1641{
1642   DEVCB_LINE(bbc_wd177x_intrq_w),
1643   DEVCB_LINE(bbc_wd177x_drq_w),
16591644   NULL,
1660   {FLOPPY_0,FLOPPY_1,NULL,NULL}
1645   {FLOPPY_0, FLOPPY_1, NULL, NULL}
16611646};
16621647
16631648static WRITE8_HANDLER(bbc_wd177x_status_w)
src/mess/devices/coco_fdc.c
r5984r5985
6868
6969#include "driver.h"
7070#include "cococart.h"
71#include "flopdrv.h"
7172#include "includes/coco.h"
7273#include "machine/wd17xx.h"
7374#include "machine/ds1315.h"
r5984r5985
135136    PROTOTYPES
136137***************************************************************************/
137138
138static WD17XX_CALLBACK( fdc_callback );
139static WRITE_LINE_DEVICE_HANDLER( fdc_intrq_w );
140static WRITE_LINE_DEVICE_HANDLER( fdc_drq_w );
139141
140142
141143/***************************************************************************
r5984r5985
144146
145147static const wd17xx_interface coco_wd17xx_interface =
146148{
147   fdc_callback,
149   DEVCB_LINE(fdc_intrq_w),
150   DEVCB_LINE(fdc_drq_w),
148151   NULL,
149152   {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}
150153};
r5984r5985
193196
194197
195198/*-------------------------------------------------
196    fdc_callback - callback from the FDC
199    fdc_intrq_w - callback from the FDC
197200-------------------------------------------------*/
198201
199static WD17XX_CALLBACK( fdc_callback )
202static WRITE_LINE_DEVICE_HANDLER( fdc_intrq_w )
200203{
201   const device_config *fdc_device = device->owner;
202   fdc_t *fdc = get_token(fdc_device);
204   fdc_t *fdc = get_token(device->owner);
205   fdc->intrq = state;
206   (*fdc->hwtype->update_lines)(device->owner);
207}
203208
204   switch(state)
205   {
206      case WD17XX_IRQ_CLR:
207         fdc->intrq = 0;
208         break;
209209
210      case WD17XX_IRQ_SET:
211         fdc->intrq = 1;
212         break;
210/*-------------------------------------------------
211    fdc_drq_w - callback from the FDC
212-------------------------------------------------*/
213213
214      case WD17XX_DRQ_CLR:
215         fdc->drq = 0;
216         break;
217
218      case WD17XX_DRQ_SET:
219         fdc->drq = 1;
220         break;
221   }
222
223   (*fdc->hwtype->update_lines)(fdc_device);
214static WRITE_LINE_DEVICE_HANDLER( fdc_drq_w )
215{
216   fdc_t *fdc = get_token(device->owner);
217   fdc->drq = state;
218   (*fdc->hwtype->update_lines)(device->owner);
224219}
225220
226221
src/mess/devices/thomflop.c
r5984r5985
77**********************************************************************/
88
99#include "includes/thomson.h"
10#include "machine/wd17xx.h"
1011
1112
1213#define VERBOSE 0 /* 0, 1 or 2 */
src/mess/drivers/x1.c
r5984r5985
873873//static UINT8 fdc_side;
874874//static UINT8 fdc_drive;
875875
876static WD17XX_CALLBACK( x1_fdc_irq )
877{
878   #if 0
879   switch(state)
880   {
881      case WD17XX_IRQ_CLR:
882         fdc_irq_flag = 0;
883         break;
884      case WD17XX_IRQ_SET:
885         fdc_irq_flag = 1;
886         break;
887      case WD17XX_DRQ_CLR:
888         fdc_drq_flag = 0;
889         break;
890      case WD17XX_DRQ_SET:
891         fdc_drq_flag = 1;
892         break;
893   }
894   #endif
895}
896
897876static READ8_HANDLER( x1_fdc_r )
898877{
899878   const device_config* dev = devtag_get_device(space->machine,"fdc");
r5984r5985
954933
955934static const wd17xx_interface x1_mb8877a_interface =
956935{
957   x1_fdc_irq,
936   DEVCB_NULL,
937   DEVCB_NULL,
958938   NULL,
959   {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}
939   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
960940};
961941
962942/*************************************
src/mess/drivers/xor100.c
r5984r5985
244244
245245/* WD1795-02 Interface */
246246
247static WD17XX_CALLBACK( wd1795_callback )
248{
249   switch (state)
250   {
251   case WD17XX_IRQ_CLR:
252      break;
253
254   case WD17XX_IRQ_SET:
255      break;
256
257   case WD17XX_DRQ_CLR:
258      break;
259
260   case WD17XX_DRQ_SET:
261      break;
262   }
263}
264
265247static const wd17xx_interface wd1795_intf =
266248{
267   wd1795_callback,
249   DEVCB_NULL,
250   DEVCB_NULL,
268251   NULL,
269   {FLOPPY_0,FLOPPY_1,NULL,NULL}
252   {FLOPPY_0, FLOPPY_1, NULL, NULL}
270253};
271254
272255/* Machine Initialization */
src/mess/drivers/thomson.c
r5984r5985
7474
7575#include "includes/thomson.h"
7676#include "machine/6821pia.h"
77#include "machine/wd17xx.h"
7778#include "machine/ctronics.h"
7879#include "devices/flopdrv.h"
7980#include "formats/basicdsk.h"
8081
82
8183/**************************** common *******************************/
8284
8385/* layout */
src/mess/drivers/scorpion.c
r5984r5985
153153#include "sound/ay8910.h"
154154#include "sound/speaker.h"
155155#include "formats/tzx_cas.h"
156
157#include "machine/wd17xx.h"
158156#include "machine/beta.h"
159157
158
160159/****************************************************************************************************/
161160/* Zs Scorpion 256 */
162161
src/mess/drivers/atarist.c
r5984r5985
8080   }
8181}
8282
83static WD17XX_CALLBACK( atarist_fdc_callback )
83static WRITE_LINE_DEVICE_HANDLER( atarist_fdc_intrq_w )
8484{
8585   atarist_state *driver_state = device->machine->driver_data;
86   driver_state->fdc_irq = state;
87}
8688
87   switch (state)
89static WRITE_LINE_DEVICE_HANDLER( atarist_fdc_drq_w )
90{
91   atarist_state *driver_state = device->machine->driver_data;
92
93   if (state)
8894   {
89   case WD17XX_IRQ_SET:
90      driver_state->fdc_irq = 1;
91      break;
92
93   case WD17XX_IRQ_CLR:
94      driver_state->fdc_irq = 0;
95      break;
96
97   case WD17XX_DRQ_SET:
9895      driver_state->fdc_status |= ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST;
9996      atarist_fdc_dma_transfer(device->machine);
100      break;
101
102   case WD17XX_DRQ_CLR:
97   }
98   else
99   {
103100      driver_state->fdc_status &= ~ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST;
104      break;
105101   }
106102}
107103
108static const wd17xx_interface atarist_wd17xx_interface = { atarist_fdc_callback, NULL, {FLOPPY_0,FLOPPY_1, NULL,NULL} };
104static const wd17xx_interface atarist_wd17xx_interface =
105{
106   DEVCB_LINE(atarist_fdc_intrq_w),
107   DEVCB_LINE(atarist_fdc_drq_w),
108   NULL,
109   {FLOPPY_0, FLOPPY_1, NULL, NULL}
110};
109111
110112static READ16_HANDLER( atarist_fdc_data_r )
111113{
src/mess/drivers/v1050.c
r5984r5985
10481048
10491049/* MB8877 Interface */
10501050
1051static WD17XX_CALLBACK( v1050_mb8877_callback )
1051static WRITE_LINE_DEVICE_HANDLER( v1050_mb8877_intrq_w )
10521052{
10531053   v1050_state *driver_state = device->machine->driver_data;
10541054
10551055   if (driver_state->f_int_enb)
1056      v1050_set_int(device->machine, INT_FLOPPY, state);
10561057   {
1057      switch (state)
1058      {
1059      case WD17XX_IRQ_CLR:
1060         v1050_set_int(device->machine, INT_FLOPPY, 0);
1061         break;
1058      v1050_set_int(device->machine, INT_FLOPPY, 0);
1059      cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, CLEAR_LINE);
1060   }
1061}
10621062
1063      case WD17XX_IRQ_SET:
1064         v1050_set_int(device->machine, INT_FLOPPY, 1);
1065         break;
1063static WRITE_LINE_DEVICE_HANDLER( v1050_mb8877_drq_w )
1064{
1065   v1050_state *driver_state = device->machine->driver_data;
10661066
1067      case WD17XX_DRQ_CLR:
1068         cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, CLEAR_LINE);
1069         break;
1070
1071      case WD17XX_DRQ_SET:
1072         cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, ASSERT_LINE);
1073         break;
1074      }
1075   }
1067   if (driver_state->f_int_enb)
1068      cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, state);
10761069   else
10771070   {
10781071      v1050_set_int(device->machine, INT_FLOPPY, 0);
r5984r5985
10821075
10831076static const wd17xx_interface v1050_wd17xx_intf =
10841077{
1085   v1050_mb8877_callback,
1078   DEVCB_LINE(v1050_mb8877_intrq_w),
1079   DEVCB_LINE(v1050_mb8877_drq_w),
10861080   NULL,
10871081   {FLOPPY_0,FLOPPY_1,NULL,NULL}
10881082};
src/mess/drivers/fmtowns.c
r5984r5985
118118   int x,y;
119119   char code[7] = "USTIJUF";
120120   memset(towns_serial_rom,0,256/8);
121   
121
122122   for(x=72;x<=194;x++)  // set these bits to 1
123123      towns_serial_rom[x/8] |= (1 << (x%8));
124   
124
125125   y=0;
126126   for(x=195;x<=251;x++)
127127   {
128128      if(code[y/8] & (1 << (y % 8)))
129129         towns_serial_rom[x/8] |= (1 << (x%8));
130130   }
131   
131
132132   // add Machine ID
133133   towns_serial_rom[7] = 0x01;
134134   towns_serial_rom[8] = 0x01;
135   
135
136136   // serial number?
137137   towns_serial_rom[2] = 0x10;
138138   towns_serial_rom[3] = 0x6e;
r5984r5985
144144static READ8_HANDLER(towns_system_r)
145145{
146146   UINT8 ret = 0;
147   
147
148148   switch(offset)
149149   {
150150      case 0x00:
r5984r5985
170170         /* Bit 0 = data, bit 6 = CLK, bit 7 = RESET, bit 5 is always 1? */
171171         ret = (towns_serial_rom[towns_srom_position/8] & (1 << (towns_srom_position%8))) ? 1 : 0;
172172         ret |= towns_srom_clk;
173         ret |= towns_srom_reset;
173         ret |= towns_srom_reset;
174174         //logerror("SYS: (0x32) Serial ROM read [0x%02x, pos=%i]\n",ret,towns_srom_position);
175175         return ret;
176176      default:
r5984r5985
203203         if((data & 0x80) && towns_srom_reset == 0) // reset
204204         {  // reset to beginning
205205            towns_srom_position = 0;
206         }         
206         }
207207         towns_srom_clk = data & 0x40;
208208         towns_srom_reset = data & 0x80;
209209         break;
r5984r5985
259259/*
260260 *  Floppy Disc Controller (MB8877A)
261261 */
262 
263static WD17XX_CALLBACK(towns_fdc_irq)
262
263static WRITE_LINE_DEVICE_HANDLER( towns_mb8877a_drq_w )
264264{
265   const device_config* dev = devtag_get_device(device->machine,"dma_1");
266   
267   switch(state)
268   {
269      case WD17XX_IRQ_CLR:
270         break;
271      case WD17XX_IRQ_SET:
272         break;
273      case WD17XX_DRQ_CLR:
274         upd71071_dmarq(dev,0,0);
275         break;
276      case WD17XX_DRQ_SET:
277         upd71071_dmarq(dev,1,0);
278         break;
279   }
265   upd71071_dmarq(device, state, 0);
280266}
281
267
282268static READ8_HANDLER(towns_floppy_r)
283269{
284270   const device_config* fdc = devtag_get_device(space->machine,"fdc");
r5984r5985
344330         // bit 2 - HDISEL
345331         // bit 1 - DDEN
346332         // bit 0 - IRQMSK
347         logerror("FDC: write %02x to offset 0x08\n",data);
333         logerror("FDC: write %02x to offset 0x08\n",data);
348334         break;
349335      case 0x0c:  // drive select
350336         switch(data & 0x0f)
r5984r5985
381367void towns_fdc_dma_w(running_machine* machine, UINT16 data)
382368{
383369   const device_config* fdc = devtag_get_device(machine,"fdc");
384   wd17xx_data_w(fdc,0,data);   
370   wd17xx_data_w(fdc,0,data);
385371}
386372
387373static READ8_HANDLER(towns_video_440_r)
r5984r5985
407393}
408394
409395/* Video/CRTC
410 *
396 *
411397 * 0xfd90 - palette colour select
412398 * 0xfd92/4/6 - BRG value
413399 * 0xfd98-9f  - degipal(?)
r5984r5985
567553
568554   if(towns_mainmem_enable != 0)
569555      return mess_ram[offset + 0xd8000];
570     
556
571557   return cmos[offset];
572558}
573559
r5984r5985
613599   UINT8* ROM = memory_region(space->machine,"user");
614600   if(towns_mainmem_enable != 0)
615601      return mess_ram[offset+0xcff80];
616   
602
617603   switch(offset)
618604   {
619605      case 0x01:  // read/write plane select (bit 0-3 write, bit 6-7 read)
r5984r5985
630616      default:
631617         logerror("VGA: read from invalid or unimplemented memory-mapped port %05x\n",0xcff80+offset*4);
632618   }
633   
619
634620   return 0;
635621}
636622
r5984r5985
692678static void towns_update_video_banks(const address_space* space)
693679{
694680   UINT8* ROM;
695   
681
696682   if(towns_mainmem_enable != 0)  // first MB is RAM
697683   {
698684      memory_set_bankptr(space->machine,1,mess_ram+0xc0000);
r5984r5985
761747{
762748   if(towns_mainmem_enable != 0)
763749      return 0x00000080;
764   
750
765751   return 0;
766752}
767753
r5984r5985
813799  // may not be (and probably is not) correct
814800  AM_RANGE(0x00000000, 0x000bffff) AM_RAM
815801  AM_RANGE(0x000c0000, 0x000c7fff) AM_READ(SMH_BANK(1))
816  AM_RANGE(0x000c0000, 0x000c7fff) AM_WRITE8(towns_gfx_w,0xffffffff)
802  AM_RANGE(0x000c0000, 0x000c7fff) AM_WRITE8(towns_gfx_w,0xffffffff)
817803  AM_RANGE(0x000c8000, 0x000c8fff) AM_READWRITE(SMH_BANK(2),SMH_BANK(2))
818804  AM_RANGE(0x000c9000, 0x000c9fff) AM_READWRITE(SMH_BANK(3),SMH_BANK(3))
819805  AM_RANGE(0x000ca000, 0x000ca7ff) AM_READWRITE(SMH_BANK(4),SMH_BANK(5))
820806  AM_RANGE(0x000ca800, 0x000cafff) AM_READWRITE(SMH_BANK(10),SMH_BANK(10))
821  AM_RANGE(0x000cb000, 0x000cbfff) AM_READWRITE(SMH_BANK(6),SMH_BANK(7))
807  AM_RANGE(0x000cb000, 0x000cbfff) AM_READWRITE(SMH_BANK(6),SMH_BANK(7))
822808  AM_RANGE(0x000cc000, 0x000cff7f) AM_READWRITE(SMH_BANK(8),SMH_BANK(8))
823  AM_RANGE(0x000cff80, 0x000cffff) AM_READWRITE8(towns_video_cff80_r,towns_video_cff80_w,0xffffffff)
809  AM_RANGE(0x000cff80, 0x000cffff) AM_READWRITE8(towns_video_cff80_r,towns_video_cff80_w,0xffffffff)
824810  AM_RANGE(0x000d0000, 0x000d7fff) AM_RAM
825811  AM_RANGE(0x000d8000, 0x000d9fff) AM_READWRITE8(towns_cmos_low_r,towns_cmos_low_w,0xffffffff) // CMOS? RAM
826812  AM_RANGE(0x000da000, 0x000effff) AM_RAM //READWRITE(SMH_BANK(11),SMH_BANK(11))
r5984r5985
878864  // Keyboard (8042 MCU)
879865  AM_RANGE(0x0600,0x0607) AM_READWRITE8(towns_keyboard_r, towns_keyboard_w,0x00ff00ff)
880866  // No idea what this is currently...
881  AM_RANGE(0x0c30,0x0c33) AM_READ8(towns_unknown_r,0x00ff0000)
867  AM_RANGE(0x0c30,0x0c33) AM_READ8(towns_unknown_r,0x00ff0000)
882868  // CMOS
883869  AM_RANGE(0x3000,0x3fff) AM_READWRITE8(towns_cmos8_r, towns_cmos8_w,0x00ff00ff)
884870  // CRTC / Video (again)
r5984r5985
933919         dat2 = towns_gfxvram[(x/8) + (y*0x50) + 0x8000];
934920         dat3 = towns_gfxvram[(x/8) + (y*0x50) + 0x10000];
935921         dat4 = towns_gfxvram[(x/8) + (y*0x50) + 0x18000];
936         colour = (dat1 & (1 << bit) ? 1 : 0)
922         colour = (dat1 & (1 << bit) ? 1 : 0)
937923            | (dat2 & (1 << bit) ? 2 : 0)
938924            | (dat3 & (1 << bit) ? 4 : 0)
939925            | (dat4 & (1 << bit) ? 8 : 0);
940         *BITMAP_ADDR32(bitmap,y,x) =
926         *BITMAP_ADDR32(bitmap,y,x) =
941927            (towns_palette_r[colour] << 16)
942928            | (towns_palette_g[colour] << 8)
943            | (towns_palette_b[colour]);
929            | (towns_palette_b[colour]);
944930      }
945931   }
946932
r5984r5985
978964
979965static const wd17xx_interface towns_mb8877a_interface =
980966{
981   towns_fdc_irq,
967   DEVCB_NULL,
968   DEVCB_DEVICE_LINE("dma_1", towns_mb8877a_drq_w),
982969   NULL,
983970   {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}
984971};
src/mess/drivers/tiki100.c
r5984r5985
553553
554554static const wd17xx_interface tiki100_wd17xx_interface =
555555{
556   DEVCB_NULL,
557   DEVCB_NULL,
556558   NULL,
557   NULL,
558   {FLOPPY_0,FLOPPY_1,NULL,NULL}
559   {FLOPPY_0, FLOPPY_1, NULL, NULL}
559560};
560561
561562/* AY-3-8912 Interface */
src/mess/drivers/fm7.c
r5984r5985
439439 *  Main CPU: I/O ports 0xfd18 - 0xfd1f
440440 *  Floppy Disk Controller (MB8877A)
441441 */
442static WD17XX_CALLBACK( fm7_fdc_irq )
442static WRITE_LINE_DEVICE_HANDLER( fm7_fdc_intrq_w )
443443{
444   switch(state)
445   {
446      case WD17XX_IRQ_CLR:
447         fdc_irq_flag = 0;
448         break;
449      case WD17XX_IRQ_SET:
450         fdc_irq_flag = 1;
451         break;
452      case WD17XX_DRQ_CLR:
453         fdc_drq_flag = 0;
454         break;
455      case WD17XX_DRQ_SET:
456         fdc_drq_flag = 1;
457         break;
458   }
444   fdc_irq_flag = state;
459445}
460446
447static WRITE_LINE_DEVICE_HANDLER( fm7_fdc_drq_w )
448{
449   fdc_drq_flag = state;
450}
451
461452static READ8_HANDLER( fm7_fdc_r )
462453{
463454   const device_config* dev = devtag_get_device(space->machine,"fdc");
r5984r5985
18081799
18091800static const wd17xx_interface fm7_mb8877a_interface =
18101801{
1811   fm7_fdc_irq,
1802   DEVCB_LINE(fm7_fdc_intrq_w),
1803   DEVCB_LINE(fm7_fdc_drq_w),
18121804   NULL,
1813   {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}
1805   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
18141806};
18151807
18161808static const ay8910_interface fm7_psg_intf =
src/mess/drivers/z80ne.c
r5984r5985
100100#include "machine/ay31015.h"
101101#include "machine/kr2376.h"
102102#include "video/m6847.h"
103#include "machine/wd17xx.h"
103104
104105/* Layout */
105106#include "z80ne.lh"
src/mess/drivers/pentagon.c
r5984r5985
77#include "sound/ay8910.h"
88#include "sound/speaker.h"
99#include "formats/tzx_cas.h"
10#include "machine/wd17xx.h"
1110#include "machine/beta.h"
1211
1312
src/mess/drivers/bw2.c
r5984r5985
260260
261261
262262/* Floppy */
263static WD17XX_CALLBACK( bw2_wd17xx_callback )
263static WRITE_LINE_DEVICE_HANDLER( bw2_wd17xx_drq_w )
264264{
265   switch(state)
265   if (state)
266266   {
267      case WD17XX_IRQ_CLR:
268         cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_IRQ0, CLEAR_LINE);
269         break;
270
271      case WD17XX_IRQ_SET:
272         cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_IRQ0, HOLD_LINE);
273         break;
274
275      case WD17XX_DRQ_CLR:
276         cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, CLEAR_LINE);
277         break;
278
279      case WD17XX_DRQ_SET:
280         if (cpu_get_reg(cputag_get_cpu(device->machine, Z80_TAG), Z80_HALT))
281         {
282            cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, HOLD_LINE);
283         }
284         break;
267      if (cpu_get_reg(cputag_get_cpu(device->machine, Z80_TAG), Z80_HALT))
268         cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, HOLD_LINE);
285269   }
270   else
271   {
272      cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, CLEAR_LINE);
273   }
286274}
287275
288276static READ8_HANDLER( bw2_wd2797_r )
r5984r5985
803791   FLOPPY_OPTIONS_NAME(bw2),
804792   DO_NOT_KEEP_GEOMETRY
805793};
806static const wd17xx_interface bw2_wd17xx_interface = { bw2_wd17xx_callback, NULL, {FLOPPY_0, FLOPPY_1, NULL, NULL}};
807794
795static const wd17xx_interface bw2_wd17xx_interface =
796{
797   DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0),
798   DEVCB_LINE(bw2_wd17xx_drq_w),
799   NULL,
800   {FLOPPY_0, FLOPPY_1, NULL, NULL}
801};
802
808803static MACHINE_DRIVER_START( bw2 )
809804   MDRV_DRIVER_DATA(bw2_state)
810805
src/mess/drivers/enterp.c
r5984r5985
184184    FLOPPY/EXDOS
185185***************************************************************************/
186186
187static WD17XX_CALLBACK( enterp_wd1770_callback )
187static WRITE_LINE_DEVICE_HANDLER( enterp_wd1770_intrq_w )
188188{
189189   ep_state *ep = device->machine->driver_data;
190190
191   switch (state)
192   {
193   case WD17XX_IRQ_CLR: ep->exdos_card_value &= ~0x02; break;
194   case WD17XX_IRQ_SET: ep->exdos_card_value |= 0x02; break;
195   case WD17XX_DRQ_CLR: ep->exdos_card_value &= ~0x80; break;
196   case WD17XX_DRQ_SET: ep->exdos_card_value |= 0x80; break;
197   }
191   if (state)
192      ep->exdos_card_value |= 0x02;
193   else
194      ep->exdos_card_value &= ~0x02;
198195}
199196
197static WRITE_LINE_DEVICE_HANDLER( enterp_wd1770_drq_w )
198{
199   ep_state *ep = device->machine->driver_data;
200200
201   if (state)
202      ep->exdos_card_value |= 0x80;
203   else
204      ep->exdos_card_value &= ~0x80;
205}
206
207
201208/* bit 0 - ??
202209   bit 1 - IRQ from WD1770
203210   bit 2 - ??
r5984r5985
412419    MACHINE DRIVERS
413420***************************************************************************/
414421
415static const wd17xx_interface enterp_wd1770_interface = { enterp_wd1770_callback, NULL, {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3} };
422static const wd17xx_interface enterp_wd1770_interface =
423{
424   DEVCB_LINE(enterp_wd1770_intrq_w),
425   DEVCB_LINE(enterp_wd1770_drq_w),
426   NULL,
427   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
428};
416429
417430static FLOPPY_OPTIONS_START(enterprise)
418431   FLOPPY_OPTION(enterprise, "dsk,img", "Enterprise disk image", basicdsk_identify_default, basicdsk_construct_default,
src/mess/drivers/a310.c
r5984r5985
3131
3232#include "driver.h"
3333#include "machine/wd17xx.h"
34#include "devices/flopdrv.h"
3435#include "cpu/arm/arm.h"
3536#include "sound/dac.h"
3637#include "includes/archimds.h"
r5984r5985
4445   return 0;
4546}
4647
47static WD17XX_CALLBACK ( a310_wd177x_callback )
48static WRITE_LINE_DEVICE_HANDLER( a310_wd177x_intrq_w )
4849{
49   switch (state)
50   {
51      case WD17XX_IRQ_CLR:
52         archimedes_clear_fiq(device->machine, ARCHIMEDES_FIQ_FLOPPY);
53         break;
50   if (state)
51      archimedes_request_fiq(device->machine, ARCHIMEDES_FIQ_FLOPPY);
52   else
53      archimedes_clear_fiq(device->machine, ARCHIMEDES_FIQ_FLOPPY);
54}
5455
55      case WD17XX_IRQ_SET:
56         archimedes_request_fiq(device->machine, ARCHIMEDES_FIQ_FLOPPY);
57         break;
58
59      case WD17XX_DRQ_CLR:
60         archimedes_clear_fiq(device->machine, ARCHIMEDES_FIQ_FLOPPY_DRQ);
61         break;
62
63      case WD17XX_DRQ_SET:
64         archimedes_request_fiq(device->machine, ARCHIMEDES_FIQ_FLOPPY_DRQ);
65         break;
66   }
56static WRITE_LINE_DEVICE_HANDLER( a310_wd177x_drq_w )
57{
58   if (state)
59      archimedes_request_fiq(device->machine, ARCHIMEDES_FIQ_FLOPPY_DRQ);
60   else
61      archimedes_clear_fiq(device->machine, ARCHIMEDES_FIQ_FLOPPY_DRQ);
6762}
6863
6964static DRIVER_INIT(a310)
r5984r5985
205200   PORT_BIT (0xf8, 0x80, IPT_UNUSED)
206201INPUT_PORTS_END
207202
208static const wd17xx_interface a310_wd17xx_interface = {
209   a310_wd177x_callback,
203static const wd17xx_interface a310_wd17xx_interface =
204{
205   DEVCB_LINE(a310_wd177x_intrq_w),
206   DEVCB_LINE(a310_wd177x_drq_w),
210207   NULL,
211   {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}
208   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
212209};
213210
214211static MACHINE_DRIVER_START( a310 )
src/mess/drivers/xerox820.c
r5984r5985
492492
493493/* WD1771 Interface */
494494
495static WD17XX_CALLBACK( wd1771_callback )
495static WRITE_LINE_DEVICE_HANDLER( xerox820_wd1771_intrq_w )
496496{
497497   xerox820_state *driver_state = device->machine->driver_data;
498   int halt = cpu_get_reg(cputag_get_cpu(device->machine, Z80_TAG), Z80_HALT);
498499
500   driver_state->fdc_irq = state;
501
502   if (halt && state)
503      cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, ASSERT_LINE);
504   else
505      cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, CLEAR_LINE);
506}
507
508static WRITE_LINE_DEVICE_HANDLER( xerox820_wd1771_drq_w )
509{
510   xerox820_state *driver_state = device->machine->driver_data;
499511   int halt = cpu_get_reg(cputag_get_cpu(device->machine, Z80_TAG), Z80_HALT);
500512
501   switch (state)
502   {
503   case WD17XX_IRQ_CLR: driver_state->fdc_irq = 0; break;
504   case WD17XX_IRQ_SET: driver_state->fdc_irq = 1; break;
505   case WD17XX_DRQ_CLR: driver_state->fdc_drq = 0; break;
506   case WD17XX_DRQ_SET: driver_state->fdc_drq = 1; break;
507   }
513   driver_state->fdc_drq = state;
508514
509   if (halt && (driver_state->fdc_irq | driver_state->fdc_drq))
510   {
515   if (halt && state)
511516      cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, ASSERT_LINE);
512   }
513517   else
514   {
515518      cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, CLEAR_LINE);
516   }
517519}
518520
519521static const wd17xx_interface wd1771_intf =
520522{
521   wd1771_callback,
523   DEVCB_LINE(xerox820_wd1771_intrq_w),
524   DEVCB_LINE(xerox820_wd1771_drq_w),
522525   NULL,
523   {FLOPPY_0,FLOPPY_1,NULL,NULL}
526   {FLOPPY_0, FLOPPY_1, NULL, NULL}
524527};
525528
526529/* COM8116 Interface */
src/mess/drivers/pk8020.c
r5984r5985
1010#include "driver.h"
1111#include "cpu/i8085/i8085.h"
1212#include "machine/i8255a.h"
13#include "machine/wd17xx.h"
1314#include "devices/flopdrv.h"
1415#include "formats/basicdsk.h"
1516#include "includes/pk8020.h"

Previous 15994 Revisions Next


© 1998-2018 The MESS Team