Previous 15994 Revisions Next

r6434 Saturday 21st November, 2009 at 23:34:55 UTC by Curt Coder
[I8257] Improved interface and updated all drivers to use the new implementation.
[src/mess/drivers]apogee.c mikrosha.c partner.c pc8001.c radio86.c rt1715.c
[src/mess/includes]partner.h pc8001.h radio86.h
[src/mess/machine]i8257.c i8257.h partner.c radio86.c

src/mess/includes/radio86.h
r6433r6434
88#define radio86_H_
99
1010#include "machine/i8255a.h"
11#include "machine/8257dma.h"
11#include "machine/i8257.h"
1212#include "video/i8275.h"
1313
1414/*----------- defined in drivers/radio86.c -----------*/
src/mess/includes/pc8001.h
r6433r6434
2323   int vrtc;
2424   int width80;
2525   int color;
26   int dack2;
2726 
2827   /* printer state */
2928   int ack;
src/mess/includes/partner.h
r6433r6434
88#define partner_H_
99
1010#include "machine/i8255a.h"
11#include "machine/8257dma.h"
11#include "machine/i8257.h"
1212#include "machine/wd17xx.h"
1313
1414/*----------- defined in machine/partner.c -----------*/
src/mess/machine/radio86.c
r6433r6434
1111#include "cpu/i8085/i8085.h"
1212#include "devices/cassette.h"
1313#include "machine/i8255a.h"
14#include "machine/8257dma.h"
14#include "machine/i8257.h"
1515#include "video/i8275.h"
1616#include "includes/radio86.h"
1717
r6433r6434
129129   DEVCB_HANDLER(radio86_8255_portc_w2),
130130};
131131
132static WRITE_LINE_DEVICE_HANDLER( hrq_w )
133{
134   /* HACK - this should be connected to the BUSREQ line of Z80 */
135   cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_HALT, state);
136   
137   /* HACK - this should be connected to the BUSACK line of Z80 */
138   i8257_hlda_w(device, state);
139}
140
132141I8257_INTERFACE( radio86_dma )
133142{
134   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_HALT),
143   DEVCB_LINE(hrq_w),
135144   DEVCB_NULL,
136145   DEVCB_NULL,
137   DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, memory_read_byte),
138   DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, memory_write_byte),
146   I8257_MEMORY_HANDLER("maincpu", PROGRAM, memory_read_byte),
147   I8257_MEMORY_HANDLER("maincpu", PROGRAM, memory_write_byte),
139148   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
140149   { DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_HANDLER("i8275", i8275_dack_w), DEVCB_NULL },
150   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }
141151};
142152
143153static TIMER_CALLBACK( radio86_reset )
src/mess/machine/partner.c
r6433r6434
1111#include "cpu/i8085/i8085.h"
1212#include "devices/cassette.h"
1313#include "machine/i8255a.h"
14#include "machine/8257dma.h"
14#include "machine/i8257.h"
1515#include "machine/wd17xx.h"
1616#include "video/i8275.h"
1717#include "includes/radio86.h"
r6433r6434
345345   partner_bank_switch(space->machine);
346346}
347347
348static WRITE_LINE_DEVICE_HANDLER( hrq_w )
349{
350   /* HACK - this should be connected to the BUSREQ line of Z80 */
351   cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_HALT, state);
352   
353   /* HACK - this should be connected to the BUSACK line of Z80 */
354   i8257_hlda_w(device, state);
355}
356
348357I8257_INTERFACE( partner_dma )
349358{
350   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_HALT),
359   DEVCB_LINE(hrq_w),
351360   DEVCB_NULL,
352361   DEVCB_NULL,
353   DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, memory_read_byte),
354   DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, memory_write_byte),
362   I8257_MEMORY_HANDLER("maincpu", PROGRAM, memory_read_byte),
363   I8257_MEMORY_HANDLER("maincpu", PROGRAM, memory_write_byte),
355364   { DEVCB_DEVICE_HANDLER("wd1793", wd17xx_data_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
356   { DEVCB_DEVICE_HANDLER("wd1793", wd17xx_data_w), DEVCB_NULL, DEVCB_DEVICE_HANDLER("i8275", i8275_dack_w), DEVCB_NULL }
365   { DEVCB_DEVICE_HANDLER("wd1793", wd17xx_data_w), DEVCB_NULL, DEVCB_DEVICE_HANDLER("i8275", i8275_dack_w), DEVCB_NULL },
366   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }
357367};
358368
359369
src/mess/machine/i8257.c
r6433r6434
22 
33    Intel 8257 Programmable DMA Controller emulation
44 
5    Copyright Nicola Salmoria and the MAME Team.
5    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
77 
88***************************************************************************/
99 
10/*
11 
12   TODO:
13 
14   - use cr/ar directly
15 
16*/
17 
1018#include "driver.h"
1119#include "i8257.h"
1220 
r6433r6434
6169   devcb_resolved_write_line   out_hrq_func;
6270   devcb_resolved_write_line   out_tc_func;
6371   devcb_resolved_write_line   out_mark_func;
64   devcb_resolved_read8      in_memr_func;
65   devcb_resolved_write8      out_memw_func;
66   devcb_resolved_read8      in_ior_func;
67   devcb_resolved_write8      out_iow_func;
68   devcb_resolved_write_line   out_dack_func[4];
72   devcb_resolved_read8      in_memr_func[I8257_CHANNELS];
73   devcb_resolved_write8      out_memw_func[I8257_CHANNELS];
74   devcb_resolved_read8      in_ior_func[I8257_CHANNELS];
75   devcb_resolved_write8      out_iow_func[I8257_CHANNELS];
76   devcb_resolved_write_line   out_dack_func[I8257_CHANNELS];
6977 
7078   /* registers */
7179   UINT8 mr;               /* mode register */
7280   UINT8 sr;               /* status register */
73   UINT16 ar[4];            /* address register */
74   UINT16 cr[4];            /* count register */
81   UINT16 ar[I8257_CHANNELS];   /* address register */
82   UINT16 cr[I8257_CHANNELS];   /* count register */
7583   int fl;                  /* first/last flip-flop */
7684 
7785   /* inputs */
78   int drq[4];               /* data request */
86   int drq[I8257_CHANNELS];   /* data request */
7987   int hlda;               /* hold acknowledge */
8088   int ready;               /* ready */
8189 
r6433r6434
157165   i8257_t *i8257 = get_safe_token(device);
158166   int ch;
159167 
160   for (ch = 0; ch < 4; ch++)
168   for (ch = 0; ch < I8257_CHANNELS; ch++)
161169   {
162170      int state = (ch != active_channel);
163171       
r6433r6434
172180   i8257_t *i8257 = get_safe_token(device);
173181   int ch;
174182 
175   for (ch = 0; ch < 4; ch++)
183   for (ch = 0; ch < I8257_CHANNELS; ch++)
176184   {
177185      if (i8257->drq[ch] && BIT(i8257->mr, ch))
178186      {
r6433r6434
188196   i8257_t *i8257 = get_safe_token(device);
189197   int i;
190198 
191   for (i = 0; i < 4; i++)
199   for (i = 0; i < I8257_CHANNELS; i++)
192200   {
193      int ch = (i + i8257->priority) % 4;
201      int ch = (i + i8257->priority) % I8257_CHANNELS;
194202 
195203      if (i8257->drq[ch] && BIT(i8257->mr, ch))
196204      {
r6433r6434
213221      break;
214222 
215223   case MODE_WRITE:
216      i8257->data = devcb_call_read8(&i8257->in_memr_func, i8257->address);
224      i8257->data = devcb_call_read8(&i8257->in_memr_func[i8257->channel], i8257->address);
217225      if (LOG) logerror("I8257 '%s' DMA Memory Read %04x: %02x\n", device->tag, i8257->address, i8257->data);
218226      break;
219227 
220228   case MODE_READ:
221      i8257->data = devcb_call_read8(&i8257->in_ior_func, i8257->address);
229      i8257->data = devcb_call_read8(&i8257->in_ior_func[i8257->channel], i8257->address);
222230      if (LOG) logerror("I8257 '%s' DMA I/O Read %04x: %02x\n", device->tag, i8257->address, i8257->data);
223231      break;
224232 
r6433r6434
237245      break;
238246 
239247   case MODE_WRITE:
240      devcb_call_write8(&i8257->out_iow_func, i8257->address, i8257->data);
248      devcb_call_write8(&i8257->out_iow_func[i8257->channel], i8257->address, i8257->data);
241249      if (LOG) logerror("I8257 '%s' DMA I/O Write %04x: %02x\n", device->tag, i8257->address, i8257->data);
242250      break;
243251 
244252   case MODE_READ:
245      devcb_call_write8(&i8257->out_memw_func, i8257->address, i8257->data);
253      devcb_call_write8(&i8257->out_memw_func[i8257->channel], i8257->address, i8257->data);
246254      if (LOG) logerror("I8257 '%s' DMA Memory Write %04x: %02x\n", device->tag, i8257->address, i8257->data);
247255      break;
248256 
r6433r6434
310318 
311319   case STATE_S3:
312320      /* activate write command */
313      dma_write(device);
321      if (!(i8257->mr & I8257_MODE_EW))
322      {
323         dma_write(device);
324      }
314325 
315326      i8257->address++;
316327      i8257->count--;
r6433r6434
365376      i8257->ar[2] = i8257->ar[3];
366377      i8257->cr[2] = i8257->cr[3];
367378 
379      if (LOG)
380      {
381         logerror("I8257 '%s' DMA Channel 2 Address Register: %04x\n", device->tag, i8257->ar[2]);
382         logerror("I8257 '%s' DMA Channel 2 Count Register: %04x\n", device->tag, i8257->cr[2] & 0x3fff);
383         logerror("I8257 '%s' DMA Channel 2 Mode: %u\n", device->tag, i8257->cr[2] >> 14);
384      }
385 
368386      i8257->state = STATE_S4;
369387      break;
370388 
r6433r6434
377395         if ((i8257->mr & I8257_MODE_TCS) && 
378396            !((i8257->channel == 2) && (i8257->mr & I8257_MODE_AL)))
379397         {
380            i8257->mr &= (1 << i8257->channel);
398            i8257->mr &= ~(1 << i8257->channel);
399            if (LOG) logerror("I8257 '%s' DMA Channel %u: disabled\n", device->tag, i8257->channel);
381400         }
382401 
383402         if (i8257->mr & I8257_MODE_RP)
384403         {
385            i8257->priority = (i8257->channel + 1) % 4;
404            i8257->priority = (i8257->channel + 1) % I8257_CHANNELS;
386405         }
387406 
388407         /* resolve DRQ priorities */
r6433r6434
481500      if (i8257->fl)
482501      {
483502         i8257->ar[ch] = (data << 8) | (i8257->ar[ch] & 0xff);
484         if (LOG) logerror("I8257 '%s' Address Register %u: %04x\n", device->tag, ch, i8257->ar[ch]);
503         if (LOG) logerror("I8257 '%s' DMA Channel %u Address Register: %04x\n", device->tag, ch, i8257->ar[ch]);
485504      }
486505      else
487506      {
r6433r6434
505524      if (i8257->fl)
506525      {
507526         i8257->cr[ch] = (data << 8) | (i8257->cr[ch] & 0xff);
508         if (LOG) logerror("I8257 '%s' Count Register %u: %04x\n", device->tag, ch, i8257->cr[ch] & 0x3fff);
509         if (LOG) logerror("I8257 '%s' Mode: %u\n", device->tag, i8257->cr[ch] >> 14);
527         if (LOG) logerror("I8257 '%s' DMA Channel %u Count Register: %04x\n", device->tag, ch, i8257->cr[ch] & 0x3fff);
528         if (LOG) logerror("I8257 '%s' DMA Channel %u Mode: %u\n", device->tag, ch, i8257->cr[ch] >> 14);
510529      }
511530      else
512531      {
r6433r6434
525544      i8257->mr = data;
526545      i8257->fl = 0;
527546 
547      if ((i8257->state == STATE_SI) && sample_drq(device))
548      {
549         timer_enable(i8257->dma_timer, 1);
550      }
551 
528552      if (LOG)
529553      {
530554         logerror("I8257 '%s' DMA Channel 0: %s\n", device->tag, BIT(i8257->mr, 0) ? "enabled" : "disabled");
r6433r6434
566590 
567591   if (LOG) logerror("I8257 '%s' Data Request %u: %u\n", device->tag, ch, state);
568592 
569   if (state)
593   if (state && (i8257->state == STATE_SI))
570594   {
571595      timer_enable(i8257->dma_timer, 1);
572596   }
r6433r6434
585609{
586610   i8257_t *i8257 = get_safe_token(device);
587611   i8257_interface *intf = (i8257_interface *)device->static_config;
612   int ch;
588613 
589614   /* resolve callbacks */
590615   devcb_resolve_write_line(&i8257->out_hrq_func, &intf->out_hrq_func, device);
591616   devcb_resolve_write_line(&i8257->out_tc_func, &intf->out_tc_func, device);
592617   devcb_resolve_write_line(&i8257->out_mark_func, &intf->out_mark_func, device);
593   devcb_resolve_read8(&i8257->in_memr_func, &intf->in_memr_func, device);
594   devcb_resolve_write8(&i8257->out_memw_func, &intf->out_memw_func, device);
595   devcb_resolve_read8(&i8257->in_ior_func, &intf->in_ior_func, device);
596   devcb_resolve_write8(&i8257->out_iow_func, &intf->out_iow_func, device);
597   devcb_resolve_write_line(&i8257->out_dack_func[0], &intf->out_dack_func[0], device);
598   devcb_resolve_write_line(&i8257->out_dack_func[1], &intf->out_dack_func[1], device);
599   devcb_resolve_write_line(&i8257->out_dack_func[2], &intf->out_dack_func[2], device);
600   devcb_resolve_write_line(&i8257->out_dack_func[3], &intf->out_dack_func[3], device);
618   
619   for (ch = 0; ch < I8257_CHANNELS; ch++)
620   {
621      devcb_resolve_read8(&i8257->in_memr_func[ch], &intf->in_memr_func[ch], device);
622      devcb_resolve_write8(&i8257->out_memw_func[ch], &intf->out_memw_func[ch], device);
623      devcb_resolve_read8(&i8257->in_ior_func[ch], &intf->in_ior_func[ch], device);
624      devcb_resolve_write8(&i8257->out_iow_func[ch], &intf->out_iow_func[ch], device);
625      devcb_resolve_write_line(&i8257->out_dack_func[ch], &intf->out_dack_func[ch], device);
626   }
601627 
602628   /* create the DMA timer */
603629   i8257->dma_timer = timer_alloc(device->machine, dma_tick, (void *)device);
r6433r6434
636662   i8257->sr = 0;
637663   i8257->state = STATE_SI;
638664   i8257->priority = 0;
665   i8257->ready = 1;
639666 
640667   set_hrq(device, 0);
641668   set_mark(device, 0);
src/mess/machine/i8257.h
r6433r6434
22 
33    Intel 8257 Programmable DMA Controller emulation
44 
5    Copyright Nicola Salmoria and the MAME Team.
5    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
77 
88****************************************************************************
r6433r6434
4848#define I8257_INTERFACE(_name) \
4949   const i8257_interface (_name) =
5050 
51#define I8257_MEMORY_HANDLER(_tag, _space, _func) \
52   { DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
53     DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
54     DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
55     DEVCB_MEMORY_HANDLER(_tag, _space, _func) }
56
57#define I8257_CHANNELS   4
58 
5159/***************************************************************************
5260    TYPE DEFINITIONS
5361***************************************************************************/
r6433r6434
6068   devcb_write_line   out_mark_func;
6169 
6270   /* memory */
63   devcb_read8         in_memr_func;
64   devcb_write8      out_memw_func;
71   devcb_read8         in_memr_func[I8257_CHANNELS];
72   devcb_write8      out_memw_func[I8257_CHANNELS];
6573 
6674   /* I/O */
67   devcb_read8         in_ior_func;
68   devcb_write8      out_iow_func;
75   devcb_read8         in_ior_func[I8257_CHANNELS];
76   devcb_write8      out_iow_func[I8257_CHANNELS];
6977 
7078   /* DMA acknowledge */
71   devcb_write_line   out_dack_func[4];
79   devcb_write_line   out_dack_func[I8257_CHANNELS];
7280};
7381 
7482/***************************************************************************
src/mess/drivers/radio86.c
r6433r6434
1111#include "cpu/i8085/i8085.h"
1212#include "sound/wave.h"
1313#include "machine/i8255a.h"
14#include "machine/8257dma.h"
14#include "machine/i8257.h"
1515#include "video/i8275.h"
1616#include "devices/cassette.h"
1717#include "formats/rk_cas.h"
src/mess/drivers/rt1715.c
r6433r6434
1111#include "cpu/z80/z80.h"
1212#include "cpu/i8085/i8085.h"
1313#include "machine/i8255a.h"
14#include "machine/8257dma.h"
14#include "machine/i8257.h"
1515#include "video/i8275.h"
1616#include "devices/cassette.h"
1717#include "formats/rk_cas.h"
src/mess/drivers/mikrosha.c
r6433r6434
1111#include "cpu/i8085/i8085.h"
1212#include "sound/wave.h"
1313#include "machine/i8255a.h"
14#include "machine/8257dma.h"
14#include "machine/i8257.h"
1515#include "machine/pit8253.h"
1616#include "video/i8275.h"
1717#include "devices/cassette.h"
src/mess/drivers/pc8001.c
r6433r6434
473473   i8257_hlda_w(device, state);
474474}
475475
476static WRITE8_DEVICE_HANDLER( mem_w )
477{
478   pc8001_state *driver_state = device->machine->driver_data;
479
480   if (!driver_state->dack2)
481   {
482      upd3301_dack_w(driver_state->upd3301, 0, data);
483   }
484}
485
486static WRITE_LINE_DEVICE_HANDLER( dack2_w )
487{
488   pc8001_state *driver_state = device->machine->driver_data;
489
490   driver_state->dack2 = state;
491}
492
493476static I8257_INTERFACE( pc8001_8257_intf )
494477{
495478   DEVCB_LINE(hrq_w),
496479   DEVCB_NULL,
497480   DEVCB_NULL,
498   DEVCB_NULL,
499   DEVCB_HANDLER(mem_w),
500   DEVCB_MEMORY_HANDLER(Z80_TAG, PROGRAM, memory_read_byte),
501   DEVCB_MEMORY_HANDLER(Z80_TAG, PROGRAM, memory_write_byte),
502   { DEVCB_NULL, DEVCB_NULL, DEVCB_LINE(dack2_w), DEVCB_NULL }
481   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
482   { DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_HANDLER(UPD3301_TAG, upd3301_dack_w), DEVCB_NULL },
483   I8257_MEMORY_HANDLER(Z80_TAG, PROGRAM, memory_read_byte),
484   I8257_MEMORY_HANDLER(Z80_TAG, PROGRAM, memory_write_byte),
485   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }
503486};
504487
505488/* uPD1990A Interface */
src/mess/drivers/partner.c
r6433r6434
1111#include "cpu/i8085/i8085.h"
1212#include "sound/wave.h"
1313#include "machine/i8255a.h"
14#include "machine/8257dma.h"
14#include "machine/i8257.h"
1515#include "machine/wd17xx.h"
1616#include "video/i8275.h"
1717#include "devices/cassette.h"
src/mess/drivers/apogee.c
r6433r6434
1111#include "cpu/i8085/i8085.h"
1212#include "sound/wave.h"
1313#include "machine/i8255a.h"
14#include "machine/8257dma.h"
14#include "machine/i8257.h"
1515#include "video/i8275.h"
1616#include "devices/cassette.h"
1717#include "formats/rk_cas.h"

Previous 15994 Revisions Next


© 1998-2018 The MESS Team