Previous 15994 Revisions Next

r5484 Friday 21st August, 2009 at 10:14:39 UTC by Curt Coder
[NEC765] Refactored interrupt line to use devcb.
[src/mess/drivers]amstrad.c bw12.c mikromik.c nanos.c nc.c newbrain.c pcw.c prof80.c pyl601.c sg1000.c sord.c specpls3.c x68k.c
[src/mess/includes]amstrad.h
[src/mess/machine]compis.c kc.c nec765.c nec765.h pc8801.c pc_fdc.c

src/mess/includes/amstrad.h
r5483r5484
2828
2929READ8_HANDLER ( amstrad_psg_porta_read );
3030
31NEC765_INTERRUPT( aleste_interrupt );
31WRITE_LINE_DEVICE_HANDLER( aleste_interrupt );
3232
3333MACHINE_RESET( amstrad );
3434MACHINE_RESET( kccomp );
src/mess/machine/compis.c
r5483r5484
283283   nec765_reset(fdc, 0);
284284
285285   /* set FDC at reset */
286   nec765_set_reset_state(fdc, 1);
286   nec765_reset_w(fdc, 1);
287287}
288288
289289static void compis_fdc_tc(running_machine *machine, int state)
r5483r5484
292292   /* Terminal count if iSBX-218A has DMA enabled */
293293     if (input_port_read(machine, "DSW1"))
294294   {
295      nec765_set_tc_state(fdc, state);
295      nec765_tc_w(fdc, state);
296296   }
297297}
298298
299static NEC765_INTERRUPT( compis_fdc_int )
299static WRITE_LINE_DEVICE_HANDLER( compis_fdc_int )
300300{
301301   /* No interrupt requests if iSBX-218A has DMA enabled */
302302     if (!input_port_read(device->machine, "DSW1") && state)
r5483r5484
316316
317317const nec765_interface compis_fdc_interface =
318318{
319   compis_fdc_int,
319   DEVCB_LINE(compis_fdc_int),
320320   compis_fdc_dma_drq,
321321   NULL,
322322   NEC765_RDY_PIN_CONNECTED
src/mess/machine/nec765.c
r5483r5484
7878typedef struct _nec765_t nec765_t;
7979struct _nec765_t
8080{
81   devcb_resolved_write_line   out_int_func;
82
8183   unsigned long   sector_counter;
8284   /* version of fdc to emulate */
8385   NEC765_VERSION version;
r5483r5484
650652   fdc->nec765_flags = new_flags;
651653
652654   /* if interrupt changed, call the handler */
653   if ((changed_flags & NEC765_INT) && fdc->intf->interrupt)
654      fdc->intf->interrupt(device,(fdc->nec765_flags & NEC765_INT) ? 1 : 0);
655   if (changed_flags & NEC765_INT)
656      devcb_call_write_line(&fdc->out_int_func, (fdc->nec765_flags & NEC765_INT) ? 1 : 0);
655657
656658   /* if DRQ changed, call the handler */
657659   if ((changed_flags & NEC765_DMA_DRQ) && fdc->intf->dma_drq)
r5483r5484
726728
727729
728730/* terminal count input */
729void nec765_set_tc_state(const device_config *device, int state)
731WRITE_LINE_DEVICE_HANDLER( nec765_tc_w )
730732{
731733   int old_state;
732734   nec765_t *fdc = get_safe_token(device);
r5483r5484
22172219   }
22182220}
22192221
2220void nec765_set_reset_state(const device_config *device, int state)
2222WRITE_LINE_DEVICE_HANDLER( nec765_reset_w )
22212223{
22222224   nec765_t *fdc = get_safe_token(device);
22232225
r5483r5484
22532255}
22542256
22552257
2256void nec765_set_ready_state(const device_config *device, int state)
2258WRITE_LINE_DEVICE_HANDLER( nec765_ready_w )
22572259{
22582260   nec765_t *fdc = get_safe_token(device);
22592261
r5483r5484
22882290   fdc->nec765_flags &= NEC765_FDD_READY;
22892291   fdc->data_buffer = auto_alloc_array(device->machine, char, 32*1024);
22902292
2293   devcb_resolve_write_line(&fdc->out_int_func, &fdc->intf->out_int_func, device);
22912294
22922295   // register for state saving
22932296   //state_save_register_item(device->machine, "nec765", device->tag, 0, nec765->number);
src/mess/machine/nec765.h
r5483r5484
99#ifndef NEC765_H
1010#define NEC765_H
1111
12#include "devcb.h"
1213#include "devices/flopdrv.h"
1314
1415/***************************************************************************
r5483r5484
3435#define NEC765_DAM_DELETED_DATA 0x0f8
3536#define NEC765_DAM_DATA 0x0fb
3637
37typedef void (*nec765_interrupt_func)(const device_config *device, int state);
38#define NEC765_INTERRUPT(name)   void name(const device_config *device, int state )
39
4038typedef void (*nec765_dma_drq_func)(const device_config *device, int state,int read_write);
4139#define NEC765_DMA_REQUEST(name)   void name(const device_config *device, int state,int read_write )
4240
r5483r5484
4745typedef struct nec765_interface
4846{
4947   /* interrupt issued */
50   nec765_interrupt_func interrupt;
48   devcb_write_line out_int_func;
5149
5250   /* dma data request */
5351   nec765_dma_drq_func dma_drq;
r5483r5484
8583void nec765_reset(const device_config *device, int);
8684
8785/* reset pin of nec765 */
88void nec765_set_reset_state(const device_config *device, int);
86WRITE_LINE_DEVICE_HANDLER(nec765_reset_w);
8987
9088/* set nec765 terminal count input state */
91void nec765_set_tc_state(const device_config *device, int);
89WRITE_LINE_DEVICE_HANDLER(nec765_tc_w);
90
9291/* set nec765 ready input*/
93void nec765_set_ready_state(const device_config *device,int);
92WRITE_LINE_DEVICE_HANDLER(nec765_ready_w);
9493
9594void nec765_idle(const device_config *device);
9695
src/mess/machine/pc8801.c
r5483r5484
797797READ8_HANDLER(pc8801fd_nec765_tc)
798798{
799799  const device_config *fdc = devtag_get_device(space->machine, "nec765");
800  nec765_set_tc_state(fdc, 1);
801  nec765_set_tc_state(fdc, 0);
800  nec765_tc_w(fdc, 1);
801  nec765_tc_w(fdc, 0);
802802  return 0;
803803}
804804
805805/* callback for /INT output from FDC */
806static NEC765_INTERRUPT( pc8801_fdc_interrupt )
806static WRITE_LINE_DEVICE_HANDLER( pc8801_fdc_interrupt )
807807{
808808    cputag_set_input_line(device->machine, "sub", 0, state ? HOLD_LINE : CLEAR_LINE);
809809}
r5483r5484
815815
816816const nec765_interface pc8801_fdc_interface=
817817{
818   pc8801_fdc_interrupt,
818   DEVCB_LINE(pc8801_fdc_interrupt),
819819   pc8801_fdc_dma_drq,
820820   NULL,
821821   NEC765_RDY_PIN_CONNECTED
src/mess/machine/pc_fdc.c
r5483r5484
5656
5757static TIMER_CALLBACK( watchdog_timeout );
5858
59static NEC765_INTERRUPT(  pc_fdc_hw_interrupt );
59static WRITE_LINE_DEVICE_HANDLER(  pc_fdc_hw_interrupt );
6060static NEC765_DMA_REQUEST(pc_fdc_hw_dma_drq);
6161static NEC765_GET_IMAGE ( pc_fdc_get_image);
6262
6363const nec765_interface pc_fdc_nec765_connected_interface =
6464{
65   pc_fdc_hw_interrupt,
65   DEVCB_LINE(pc_fdc_hw_interrupt),
6666   pc_fdc_hw_dma_drq,
6767   pc_fdc_get_image,
6868   NEC765_RDY_PIN_CONNECTED
r5483r5484
7070
7171const nec765_interface pc_fdc_nec765_not_connected_interface =
7272{
73   pc_fdc_hw_interrupt,
73   DEVCB_LINE(pc_fdc_hw_interrupt),
7474   pc_fdc_hw_dma_drq,
7575   pc_fdc_get_image,
7676   NEC765_RDY_PIN_NOT_CONNECTED
r5483r5484
9393   nec765_reset(pc_get_device(machine),0);
9494
9595   /* set FDC at reset */
96   nec765_set_reset_state(pc_get_device(machine), 1);
96   nec765_reset_w(pc_get_device(machine), 1);
9797}
9898
9999
r5483r5484
152152   /* if dma is not enabled, tc's are not acknowledged */
153153   if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0)
154154   {
155      nec765_set_tc_state(pc_get_device(machine), state);
155      nec765_tc_w(pc_get_device(machine), state);
156156   }
157157}
158158
159159
160160
161static NEC765_INTERRUPT(  pc_fdc_hw_interrupt )
161static WRITE_LINE_DEVICE_HANDLER(  pc_fdc_hw_interrupt )
162162{
163163   fdc->int_state = state;
164164
r5483r5484
223223   if ((data & 0x080)!=0)
224224   {
225225      /* set ready state */
226      nec765_set_ready_state(pc_get_device(machine),1);
226      nec765_ready_w(pc_get_device(machine),1);
227227
228228      /* toggle reset state */
229      nec765_set_reset_state(pc_get_device(machine), 1);
230       nec765_set_reset_state(pc_get_device(machine), 0);
229      nec765_reset_w(pc_get_device(machine), 1);
230       nec765_reset_w(pc_get_device(machine), 0);
231231
232232      /* bit is self-clearing */
233233      data &= ~0x080;
r5483r5484
316316      what is not yet clear is if this is a result of the drives ready state
317317      changing...
318318      */
319         nec765_set_ready_state(pc_get_device(machine),1);
319         nec765_ready_w(pc_get_device(machine),1);
320320
321321      /* set FDC at reset */
322      nec765_set_reset_state(pc_get_device(machine), 1);
322      nec765_reset_w(pc_get_device(machine), 1);
323323   }
324324   else
325325   {
326326      pc_fdc_set_tc_state(machine, 0);
327327
328328      /* release reset on fdc */
329      nec765_set_reset_state(pc_get_device(machine), 0);
329      nec765_reset_w(pc_get_device(machine), 0);
330330   }
331331}
332332
r5483r5484
412412      what is not yet clear is if this is a result of the drives ready state
413413      changing...
414414      */
415         nec765_set_ready_state(pc_get_device(machine),1);
415         nec765_ready_w(pc_get_device(machine),1);
416416
417417      /* set FDC at reset */
418      nec765_set_reset_state(pc_get_device(machine), 1);
418      nec765_reset_w(pc_get_device(machine), 1);
419419   }
420420   else
421421   {
422422      pc_fdc_set_tc_state(machine, 0);
423423
424424      /* release reset on fdc */
425      nec765_set_reset_state(pc_get_device(machine), 0);
425      nec765_reset_w(pc_get_device(machine), 0);
426426   }
427427
428428   logerror("pcjr_fdc_dor_w: changing dor from %02x to %02x\n", fdc->digital_output_register, data);
src/mess/machine/kc.c
r5483r5484
205205{
206206   const device_config *fdc = devtag_get_device(space->machine, "nec765");
207207   logerror("kc85 disc hw tc w: %02x\n",data);
208   nec765_set_tc_state(fdc, data & 0x01);
208   nec765_tc_w(fdc, data & 0x01);
209209}
210210
211211
212212/* callback for /INT output from FDC */
213static NEC765_INTERRUPT( kc85_fdc_interrupt )
213static WRITE_LINE_DEVICE_HANDLER( kc85_fdc_interrupt )
214214{
215215   kc85_disc_hw_input_gate &=~(1<<6);
216216   if (state)
r5483r5484
227227
228228const nec765_interface kc_fdc_interface=
229229{
230   kc85_fdc_interrupt,
230   DEVCB_LINE(kc85_fdc_interrupt),
231231   kc85_fdc_dma_drq,
232232   NULL,
233233   NEC765_RDY_PIN_CONNECTED   
src/mess/drivers/sg1000.c
r5483r5484
640640   floppy_drive_set_ready_state(image_from_devtype_and_index(device->machine, IO_FLOPPY, 0), 1, 0);
641641
642642   /* FDC terminal count */
643   nec765_set_tc_state(fdc, data & 0x04);
643   nec765_tc_w(fdc, data & 0x04);
644644
645645   /* FDC reset */
646646   if (data & 0x08)
r5483r5484
675675   }
676676};
677677
678static NEC765_INTERRUPT( sf7000_fdc_interrupt )
678static WRITE_LINE_DEVICE_HANDLER( sf7000_fdc_interrupt )
679679{
680680   sg1000_state *driver_state = device->machine->driver_data;
681681
r5483r5484
691691
692692static const struct nec765_interface sf7000_nec765_interface =
693693{
694   sf7000_fdc_interrupt,
694   DEVCB_LINE(sf7000_fdc_interrupt),
695695   NULL,
696696   NULL,
697697   NEC765_RDY_PIN_CONNECTED
src/mess/drivers/mikromik.c
r5483r5484
281281   mm1_state *driver_state = device->machine->driver_data;
282282
283283   /* floppy terminal count */
284   nec765_set_tc_state(driver_state->upd765, !state);
284   nec765_tc_w(driver_state->upd765, !state);
285285
286286   cputag_set_input_line(device->machine, I8085A_TAG, I8085_RST75_LINE, state ? CLEAR_LINE : ASSERT_LINE);
287287}
r5483r5484
299299
300300/* µPD765 Interface */
301301
302static NEC765_INTERRUPT( fdc_irq )
303{
304   cputag_set_input_line(device->machine, I8085A_TAG, I8085_RST55_LINE, state ? ASSERT_LINE : CLEAR_LINE);
305}
306
307302static NEC765_DMA_REQUEST( fdc_drq )
308303{
309304   mm1_state *driver_state = device->machine->driver_data;
r5483r5484
313308
314309static const nec765_interface mm1_nec765_intf =
315310{
316   fdc_irq,
311   DEVCB_CPU_INPUT_LINE(I8085A_TAG, I8085_RST55_LINE),
317312   fdc_drq,
318313   NULL,
319314   NEC765_RDY_PIN_CONNECTED // ???
src/mess/drivers/pcw.c
r5483r5484
105105#define VERBOSE 1
106106#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
107107
108static NEC765_INTERRUPT( pcw_fdc_interrupt );
108static WRITE_LINE_DEVICE_HANDLER( pcw_fdc_interrupt );
109109
110110// pointer to pcw ram
111111unsigned int roller_ram_addr;
r5483r5484
140140/NMI depending on choice (see system control below) */
141141static const nec765_interface pcw_nec765_interface =
142142{
143   pcw_fdc_interrupt,
143   DEVCB_LINE(pcw_fdc_interrupt),
144144   NULL,
145145   NULL,
146146   NEC765_RDY_PIN_CONNECTED
r5483r5484
188188}
189189
190190/* fdc interrupt callback. set/clear fdc int */
191static NEC765_INTERRUPT( pcw_fdc_interrupt )
191static WRITE_LINE_DEVICE_HANDLER( pcw_fdc_interrupt )
192192{
193193   if (state == CLEAR_LINE)
194194      pcw_system_status &= ~(1<<5);
r5483r5484
500500      /* set fdc terminal count */
501501      case 5:
502502      {
503         nec765_set_tc_state(fdc, 1);
503         nec765_tc_w(fdc, 1);
504504      }
505505      break;
506506
507507      /* clear fdc terminal count */
508508      case 6:
509509      {
510         nec765_set_tc_state(fdc, 0);
510         nec765_tc_w(fdc, 0);
511511      }
512512      break;
513513
src/mess/drivers/newbrain.c
r5483r5484
658658   floppy_drive_set_motor_state(image_from_devtype_and_index(space->machine, IO_FLOPPY, 0), BIT(data, 0));
659659   floppy_drive_set_ready_state(image_from_devtype_and_index(space->machine, IO_FLOPPY, 0), 1, 0);
660660
661   nec765_set_reset_state(state->nec765, BIT(data, 1));
661   nec765_reset_w(state->nec765, BIT(data, 1));
662662
663   nec765_set_tc_state(state->nec765, BIT(data, 2));
663   nec765_tc_w(state->nec765, BIT(data, 2));
664664}
665665
666666static READ8_HANDLER( fdc_control_r )
r5483r5484
12881288   DEVCB_LINE(acia_interrupt)
12891289};
12901290
1291static NEC765_INTERRUPT( newbrain_fdc_interrupt )
1291static WRITE_LINE_DEVICE_HANDLER( newbrain_fdc_interrupt )
12921292{
12931293   newbrain_state *driver_state = device->machine->driver_data;
12941294
r5483r5484
12971297
12981298static const nec765_interface newbrain_nec765_interface =
12991299{
1300   newbrain_fdc_interrupt,
1300   DEVCB_LINE(newbrain_fdc_interrupt),
13011301   NULL,
13021302   NULL,
13031303   NEC765_RDY_PIN_NOT_CONNECTED
src/mess/drivers/amstrad.c
r5483r5484
134134/* Amstrad NEC765 interface doesn't use interrupts or DMA! */
135135static const nec765_interface amstrad_nec765_interface =
136136{
137   DEVCB_NULL,
137138   NULL,
138139   NULL,
139   NULL,
140140   NEC765_RDY_PIN_CONNECTED
141141};
142142
143143/* Aleste uses an 8272A, with the interrupt flag visible on PPI port B */
144144static const nec765_interface aleste_8272_interface =
145145{
146   aleste_interrupt,
146   DEVCB_LINE(aleste_interrupt),
147147   NULL,
148148   NULL,
149149   NEC765_RDY_PIN_CONNECTED
src/mess/drivers/nanos.c
r5483r5484
2626static WRITE8_HANDLER(nanos_tc_w)
2727{
2828   const device_config *fdc = devtag_get_device(space->machine, "nec765");
29   nec765_set_tc_state(fdc, BIT(data,1));
29   nec765_tc_w(fdc, BIT(data,1));
3030}
3131
3232
r5483r5484
427427
428428static const nec765_interface nanos_nec765_interface =
429429{
430   DEVCB_NULL,
430431   NULL,
431432   NULL,
432   NULL,
433433   NEC765_RDY_PIN_NOT_CONNECTED
434434};
435435
src/mess/drivers/nc.c
r5483r5484
12911291};
12921292
12931293
1294static NEC765_INTERRUPT( nc200_fdc_interrupt )
1294static WRITE_LINE_DEVICE_HANDLER( nc200_fdc_interrupt )
12951295{
12961296#if 0
12971297    nc_irq_latch &=~(1<<5);
r5483r5484
13131313
13141314static const nec765_interface nc200_nec765_interface=
13151315{
1316    nc200_fdc_interrupt,
1316    DEVCB_LINE(nc200_fdc_interrupt),
13171317    NULL,
13181318    NULL,
13191319    NEC765_RDY_PIN_CONNECTED
r5483r5484
14771477   floppy_drive_set_motor_state(0, 1);
14781478   floppy_drive_set_ready_state(0, 1, 1);
14791479#endif
1480   nec765_set_tc_state(fdc, (data & 0x01));
1480   nec765_tc_w(fdc, (data & 0x01));
14811481}
14821482
14831483/* bit 2: backlight: 1=off, 0=on */
src/mess/drivers/sord.c
r5483r5484
139139static WRITE8_HANDLER(fd5_tc_w)
140140{
141141   const device_config *fdc = devtag_get_device(space->machine, "nec765");
142   nec765_set_tc_state(fdc, 1);
143   nec765_set_tc_state(fdc, 0);
142   nec765_tc_w(fdc, 1);
143   nec765_tc_w(fdc, 0);
144144}
145145
146146/* 0x020 fd5 writes to this port to communicate with m5 */
r5483r5484
159159ADDRESS_MAP_END
160160
161161/* nec765 data request is connected to interrupt of z80 inside fd5 interface */
162static NEC765_INTERRUPT( sord_fd5_fdc_interrupt )
162static WRITE_LINE_DEVICE_HANDLER( sord_fd5_fdc_interrupt )
163163{
164164   cputag_set_input_line(device->machine, "floppy", 0, state? HOLD_LINE : CLEAR_LINE);
165165}
166166
167167static const struct nec765_interface sord_fd5_nec765_interface=
168168{
169   sord_fd5_fdc_interrupt,
169   DEVCB_LINE(sord_fd5_fdc_interrupt),
170170   NULL,
171171   NULL,
172172   NEC765_RDY_PIN_CONNECTED
src/mess/drivers/bw12.c
r5483r5484
168168      break;
169169
170170   case 7: /* FDC TC */
171      nec765_set_tc_state(state->nec765, data);
171      nec765_tc_w(state->nec765, data);
172172      break;
173173   }
174174}
r5483r5484
423423
424424/* NEC765 Interface */
425425
426static NEC765_INTERRUPT( bw12_nec765_interrupt )
426static WRITE_LINE_DEVICE_HANDLER( bw12_nec765_interrupt )
427427{
428428   bw12_state *driver_state = device->machine->driver_data;
429429
r5483r5484
447447
448448static const struct nec765_interface bw12_nec765_interface =
449449{
450   bw12_nec765_interrupt,      /* interrupt */
450   DEVCB_LINE(bw12_nec765_interrupt),      /* interrupt */
451451   NULL,                  /* DMA request */
452452   bw12_nec765_get_image,      /* image lookup */
453453   NEC765_RDY_PIN_CONNECTED   /* ready pin */
src/mess/drivers/prof80.c
r5483r5484
932932
933933static const struct nec765_interface prof80_nec765_interface =
934934{
935   DEVCB_NULL,
935936   NULL,
936937   NULL,
937   NULL,
938938   NEC765_RDY_PIN_CONNECTED
939939};
940940
src/mess/drivers/specpls3.c
r5483r5484
169169
170170static const nec765_interface spectrum_plus3_nec765_interface =
171171{
172      NULL,
173      NULL,
174      NULL,
175      NEC765_RDY_PIN_CONNECTED
172   DEVCB_NULL,
173   NULL,
174   NULL,
175   NEC765_RDY_PIN_CONNECTED
176176};
177177
178178
src/mess/drivers/x68k.c
r5483r5484
10681068   }
10691069}
10701070
1071static NEC765_INTERRUPT( fdc_irq )
1071static WRITE_LINE_DEVICE_HANDLER( fdc_irq )
10721072{
10731073   if((x68k_sys.ioc.irqstatus & 0x04) && state == ASSERT_LINE)
10741074   {
r5483r5484
11291129   // CT1 and CT2 bits from YM2151 port 0x1b
11301130   // CT1 - ADPCM clock - 0 = 8MHz, 1 = 4MHz
11311131   // CT2 - 1 = Set ready state of FDC
1132   nec765_set_ready_state(fdc,data & 0x01);
1132   nec765_ready_w(fdc,data & 0x01);
11331133   x68k_sys.adpcm.clock = data & 0x02;
11341134   x68k_set_adpcm(device->machine);
11351135   okim6258_set_clock(okim, data & 0x02 ? 4000000 : 8000000);
r5483r5484
18961896
18971897static const nec765_interface fdc_interface =
18981898{
1899   fdc_irq,
1899   DEVCB_LINE(fdc_irq),
19001900   fdc_drq,
19011901   NULL,
19021902   NEC765_RDY_PIN_CONNECTED
src/mess/drivers/pyl601.c
r5483r5484
169169   
170170   floppy_drive_set_ready_state(get_floppy_image(space->machine, 0), BIT(data,2), 0);
171171   
172   nec765_set_tc_state(floppy, BIT(data,1));
172   nec765_tc_w(floppy, BIT(data,1));
173173   
174174   floppy_ctrl = data;
175175}
r5483r5484
180180
181181static const struct nec765_interface pyldin_nec765_interface =
182182{
183   NULL,                  /* interrupt */
183   DEVCB_NULL,                  /* interrupt */
184184   NULL,                  /* DMA request */
185185   pyldin_nec765_get_image,   /* image lookup */
186186   NEC765_RDY_PIN_CONNECTED   /* ready pin */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team