Previous 15994 Revisions Next

r3597 Wednesday 26th November, 2008 at 20:29:29 UTC by Curt Coder
Fixed and re-enabled abc80/abc80x.
[src/emu]mconfig.h romload.h
[src/emu/machine]z80pio.c z80pio.h
[src/mess]mess.mak messdriv.c
[src/mess/drivers]abc80.c abc80x.c
[src/mess/machine]abc77.c abcbus.c abcbus.h conkort.c e0516.c
[src/mess/video]abc800.c abc802.c abc806.c

src/emu/romload.h
r3596r3597
220220
221221
222222/* ----- start/stop macros ----- */
223#define ROM_START(name)                        static const rom_entry rom_##name[] = {
223#define ROM_NAME(name)                        rom_##name
224#define ROM_START(name)                        static const rom_entry ROM_NAME(name)[] = {
224225#define ROM_END                              { NULL, NULL, 0, 0, ROMENTRYTYPE_END } };
225226
226227
src/emu/machine/z80pio.c
r3596r3597
11/***************************************************************************
22
3    Z80 PIO implementation
3    Z80 PIO Parallel Input/Output Controller emulation
44
5    based on original version (c) 1997, Tatsuyuki Satoh
6
75    Copyright Nicola Salmoria and the MAME Team.
86    Visit http://mamedev.org for licensing and usage restrictions.
97
r3596r3597
1412#include "cpu/z80/z80.h"
1513#include "cpu/z80/z80daisy.h"
1614
17
18
1915/***************************************************************************
2016    DEBUGGING
2117***************************************************************************/
2218
23#define VERBOSE     
19#define VERBOSE
2420
25#define VPRINTF(x) do { if (VERBOSE) logerror x; } while (0)
21#define LOGERROR if (VERBOSE) logerror
2622
27
28
2923/***************************************************************************
3024    CONSTANTS
3125***************************************************************************/
3226
33#define PIO_MODE0      0x00      /* output mode */
34#define PIO_MODE1      0x01      /* input  mode */
35#define PIO_MODE2      0x02      /* i/o    mode */
36#define PIO_MODE3      0x03      /* bit    mode */
27enum
28{
29   PIO_MODE_OUTPUT = 0,
30   PIO_MODE_INPUT,
31   PIO_MODE_BIDIRECTIONAL,
32   PIO_MODE_CONTROL
33};
3734
38/* pio controll port operation (bit 0-3) */
39#define PIO_OP_MODE      0x0f      /* mode select        */
40#define PIO_OP_INTC      0x07      /* interrupt controll */
41#define PIO_OP_INTE      0x03      /* interrupt enable   */
35enum
36{
37   PIO_STATE_NORMAL = 0,
38   PIO_STATE_DDR,
39   PIO_STATE_MASK
40};
4241
43/* pio interrupt controll nit */
44#define PIO_INT_ENABLE   0x80      /* ENABLE : 0=disable , 1=enable */
45#define PIO_INT_AND      0x40      /* LOGIC  : 0=OR      , 1=AND    */
46#define PIO_INT_HIGH   0x20      /* LEVEL  : 0=low     , 1=high   */
47#define PIO_INT_MASK   0x10      /* MASK   : 0=off     , 1=on     */
42enum
43{
44   PIO_PORT_A = 0,
45   PIO_PORT_B,
46   PIO_PORT_COUNT
47};
4848
49#define PIO_MODE_CONTROL_WORD   0x0f
50#define PIO_IRQ_CONTROL_WORD   0x07
51#define PIO_IRQ_DISABLE_WORD   0x03
4952
53#define PIO_IRQ_MASK_FOLLOWS   0x10
54#define PIO_IRQ_ACTIVE_HIGH      0x20
55#define PIO_IRQ_AND            0x40
56#define PIO_IRQ_ENABLE         0x80
5057
5158/***************************************************************************
5259    TYPE DEFINITIONS
r3596r3597
5562typedef struct _z80pio z80pio_t;
5663struct _z80pio
5764{
58   UINT8 vector[2];                      /* interrupt vector               */
59   void (*intr)(const device_config *, int which);            /* interrupt callbacks            */
60   void (*rdyr[2])(int data);          /* RDY active callback            */
61   read8_device_func  port_read[2];     /* port read callbacks            */
62   write8_device_func port_write[2];    /* port write callbacks           */
63   UINT8 mode[2];                        /* mode 00=in,01=out,02=i/o,03=bit*/
64   UINT8 enable[2];                      /* interrupt enable               */
65   UINT8 mask[2];                        /* mask folowers                  */
66   UINT8 dir[2];                         /* direction (bit mode)           */
67   UINT8 rdy[2];                         /* ready pin level                */
68   UINT8 in[2];                          /* input port data                */
69   UINT8 out[2];                         /* output port                    */
70   UINT8 strobe[2];                  /* strobe inputs */
71   UINT8 int_state[2];                   /* interrupt status (daisy chain) */
72};
65   const z80pio_interface *intf;         /* interface */
7366
67   int clock;                        /* clock frequency */
7468
69   int state[PIO_PORT_COUNT];            /* control register state */
70   int mode[PIO_PORT_COUNT];            /* mode control register */
71   int irq_enable[PIO_PORT_COUNT];         /* interrupt enable flag */
72   int irq_pending[PIO_PORT_COUNT];      /* interrupt pending flag */
73   int int_state[PIO_PORT_COUNT];         /* interrupt status */
74   UINT8 enable[PIO_PORT_COUNT];         /* interrupt control word */
75   UINT8 input[PIO_PORT_COUNT];         /* data input register */
76   UINT8 output[PIO_PORT_COUNT];         /* data output register */
77   UINT8 vector[PIO_PORT_COUNT];         /* interrupt vector */
78   UINT8 mask[PIO_PORT_COUNT];            /* mask register */
79   UINT8 ddr[PIO_PORT_COUNT];            /* input/output select register */
80   int strobe[PIO_PORT_COUNT];            /* strobe pulse */
81   int match[PIO_PORT_COUNT];            /* control mode bit logic equation match */
7582
83   /* timers */
84   emu_timer *poll_timer;               /* mode 3 poll timer */
85   emu_timer *irq_timer;               /* interrupt enable timer */
86};
87
7688/***************************************************************************
7789    FUNCTION PROTOTYPES
7890***************************************************************************/
r3596r3597
8193static int z80pio_irq_ack(const device_config *device);
8294static void z80pio_irq_reti(const device_config *device);
8395
84
85
8696/***************************************************************************
8797    INLINE FUNCTIONS
8898***************************************************************************/
r3596r3597
92102   assert(device != NULL);
93103   assert(device->token != NULL);
94104   assert(device->type == Z80PIO);
105
95106   return (z80pio_t *)device->token;
96107}
97108
98
99109/***************************************************************************
100110    INTERNAL STATE MANAGEMENT
101111***************************************************************************/
102112
103INLINE void set_rdy(const device_config *device, int ch, int state)
113static void z80pio_check_interrupt(const device_config *device)
104114{
105   z80pio_t *z80pio = get_safe_token( device );
106   /* set state */
107   z80pio->rdy[ch] = state;
115   z80pio_t *z80pio = get_safe_token(device);
116   int channel;
108117
109   /* call callback with state */
110   if (z80pio->rdyr[ch])
111      z80pio->rdyr[ch](z80pio->rdy[ch]);
118   for (channel = PIO_PORT_A; channel < PIO_PORT_COUNT; channel++)
119   {
120      if (z80pio->irq_enable[channel])
121      {
122         if (z80pio->irq_pending[channel])
123         {
124            /* trigger interrupt request */
125            z80pio->int_state[channel] |= Z80_DAISY_INT;
126
127            /* reset interrupt pending */
128            z80pio->irq_pending[channel] = 0;
129
130            LOGERROR("Z80PIO \"%s\" Port %c : Interrupt Request\n", device->tag, 'A' + channel);
131         }
132      }
133      else
134      {
135         /* clear interrupt request */
136         z80pio->int_state[channel] &= ~Z80_DAISY_INT;
137      }
138   }
139
140   if (z80pio->intf->on_int_changed)
141   {
142      z80pio->intf->on_int_changed(device, (z80pio_irq_state(device) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE);
143   }
112144}
113145
146static void z80pio_trigger_interrupt(const device_config *device, int channel)
147{
148   z80pio_t *z80pio = get_safe_token(device);
114149
115INLINE void interrupt_check(const device_config *device)
150   if (z80pio->irq_enable[channel])
151   {
152      z80pio->int_state[channel] |= Z80_DAISY_INT;
153      z80pio_check_interrupt(device);
154
155      LOGERROR("Z80PIO \"%s\" Port %c : Interrupt Request\n", device->tag, 'A' + channel);
156   }
157   else
158   {
159      /* set interrupt pending */
160      z80pio->irq_pending[channel] = 1;
161      z80pio_check_interrupt(device);
162
163      LOGERROR("Z80PIO \"%s\" Port %c : Interrupt Pending\n", device->tag, 'A' + channel);
164   }
165}
166
167static TIMER_CALLBACK( z80pio_irq_tick )
116168{
117   z80pio_t *z80pio = get_safe_token( device );
169   const device_config *device = (device_config *) ptr;
170   z80pio_t *z80pio = get_safe_token(device);
118171
119   /* if we have a callback, update it with the current state */
120   if (z80pio->intr)
121      z80pio->intr(device, (z80pio_irq_state(device) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE);
172   int channel = BIT(param, 1);
173   int state = BIT(param, 0);
174
175   /* set interrupt enable */
176   z80pio->irq_enable[channel] = state;
177
178   LOGERROR("Z80PIO \"%s\" Port %c : Interrupt Enable %u\n", device->tag, 'A' + channel, state);
179
180   /* check interrupt status */
181   z80pio_check_interrupt(device);
122182}
123183
184static void z80pio_set_irq_enable(const device_config *device, int channel, int state)
185{
186   z80pio_t *z80pio = get_safe_token(device);
124187
125static void update_irq_state(const device_config *device, int ch)
188   if (state)
189   {
190      /* enable interrupt on next _M1 */
191      int param = (channel << 1) | state;
192
193      timer_adjust_oneshot(z80pio->irq_timer, ATTOTIME_IN_HZ(z80pio->clock * 4), param);
194   }
195   else
196   {
197      /* disable interrupt immediately */
198      z80pio->irq_enable[channel] = state;
199
200      LOGERROR("Z80PIO \"%s\" Port %c : Interrupt Enable %u\n", device->tag, 'A' + channel, state);
201   }
202}
203
204static void z80pio_ready_w(const device_config *device, int channel, int state)
126205{
127   z80pio_t *z80pio = get_safe_token( device );
128   int old_state = z80pio->int_state[ch];
129   int irq = 0;
130   int data;
131   if (z80pio->mode[ch] == 0x13 || (z80pio->enable[ch] & PIO_INT_MASK)) return;
206   z80pio_t *z80pio = get_safe_token(device);
132207
133   /* only check if interrupts are enabled */
134   if (z80pio->enable[ch] & PIO_INT_ENABLE)
208   LOGERROR("Z80PIO \"%s\" Port %c : Ready %u\n", device->tag, 'A' + channel, state);
209
210   if (channel == PIO_PORT_A)
135211   {
136      /* in mode 3, interrupts are tricky */
137      if (z80pio->mode[ch] == PIO_MODE3)
212      if (z80pio->intf->on_ardy_changed)
138213      {
139         /* fetch input data (ignore output lines) */
140         data = z80pio->in[ch] & z80pio->dir[ch];
214         z80pio->intf->on_ardy_changed(device, state);
215      }
216   }
217   else
218   {
219      if (z80pio->intf->on_brdy_changed)
220      {
221         z80pio->intf->on_brdy_changed(device, state);
222      }
223   }
224}
141225
142         /* keep only relevant bits */
143         data &= ~z80pio->mask[ch];
226static UINT8 z80pio_port_r(const device_config *device, int channel)
227{
228   z80pio_t *z80pio = get_safe_token(device);
229   UINT8 data = 0;
144230
145         /* if active low, invert the bits */
146         if (!(z80pio->enable[ch] & PIO_INT_HIGH))
147            data ^= z80pio->mask[ch];
231   if (channel == PIO_PORT_A)
232   {
233      if (z80pio->intf->port_a_r)
234      {
235         data = z80pio->intf->port_a_r(device, 0);
236      }
237   }
238   else
239   {
240      if (z80pio->intf->port_b_r)
241      {
242         data = z80pio->intf->port_b_r(device, 0);
243      }
244   }
148245
149         /* if AND logic, interrupt if all bits are set */
150         if (z80pio->enable[ch] & PIO_INT_AND)
151            irq = (data == z80pio->mask[ch]);
246   //LOGERROR("Z80PIO \"%s\" Port %c : Input Data '%02x'\n", device->tag, 'A' + channel, data);
152247
153         /* otherwise, interrupt if at least one bit is set */
154         else
155            irq = (data != 0);
248   return data;
249}
156250
157         /* if portB, portA mode 2 check */
158         if (ch && (z80pio->mode[0] == PIO_MODE2))
159         {
160            if (z80pio->rdy[ch] == 0)
161               irq = 1;
162         }
163      }
251static void z80pio_port_w(const device_config *device, int channel)
252{
253   z80pio_t *z80pio = get_safe_token(device);
254   UINT8 data = z80pio->output[channel];
164255
165      /* otherwise, just interrupt when ready is cleared */
166      else
167         irq = (z80pio->rdy[ch] == 0);
256   if (z80pio->mode[channel] == PIO_MODE_CONTROL)
257   {
258      /* mask input pins */
259      data &= ~z80pio->ddr[channel];
168260   }
169261
170   if (irq)
171      z80pio->int_state[ch] |=  Z80_DAISY_INT;
262   if (channel == PIO_PORT_A)
263   {
264      if (z80pio->intf->port_a_w)
265      {
266         z80pio->intf->port_a_w(device, 0, data);
267      }
268   }
172269   else
173      z80pio->int_state[ch] &= ~Z80_DAISY_INT;
270   {
271      if (z80pio->intf->port_b_w)
272      {
273         z80pio->intf->port_b_w(device, 0, data);
274      }
275   }
174276
175   if (old_state != z80pio->int_state[ch])
176      interrupt_check(device);
277   //LOGERROR("Z80PIO \"%s\" Port %c : Output Data '%02x'\n", device->tag, 'A' + channel, data);
177278}
178279
280static void z80pio_set_mode(const device_config *device, int channel, UINT8 data)
281{
282   z80pio_t *z80pio = get_safe_token(device);
179283
284   int mode = data >> 6;
180285
286   switch (mode)
287   {
288   case PIO_MODE_OUTPUT:
289      LOGERROR("Z80PIO \"%s\" Port %c : Mode %u (Byte Output)\n", device->tag, 'A' + channel, mode);
290
291      /* set mode */
292      z80pio->mode[channel] = mode;
293
294      /* enable data output */
295      z80pio_port_w(device, channel);
296
297      /* assert ready line */
298      z80pio_ready_w(device, channel, 1);
299      break;
300
301   case PIO_MODE_INPUT:
302      LOGERROR("Z80PIO \"%s\" Port %c : Mode %u (Byte Input)\n", device->tag, 'A' + channel, mode);
303
304      /* set mode */
305      z80pio->mode[channel] = mode;
306      break;
307
308   case PIO_MODE_BIDIRECTIONAL:
309      if (channel == PIO_PORT_A)
310      {
311         LOGERROR("Z80PIO \"%s\" Port %c : Mode %u (Bidirectional)\n", device->tag, 'A' + channel, mode);
312
313         /* set mode */
314         z80pio->mode[channel] = mode;
315      }
316      break;
317
318   case PIO_MODE_CONTROL:
319      LOGERROR("Z80PIO \"%s\" Port %c : Mode %u (Bit Control)\n", device->tag, 'A' + channel, mode);
320
321      /* set mode */
322      z80pio->mode[channel] = mode;
323
324      if ((channel == PIO_PORT_A) || (z80pio->mode[PIO_PORT_A] != PIO_MODE_BIDIRECTIONAL))
325      {
326         /* clear ready line */
327         z80pio_ready_w(device, channel, 0);
328      }
329
330      /* disable interrupts until DDR is written */
331      z80pio_set_irq_enable(device, channel, 0);
332
333      /* set logic equation to false */
334      z80pio->match[channel] = 0;
335
336      /* next word is I/O control */
337      z80pio->state[channel] = PIO_STATE_DDR;
338      break;
339   }
340}
341
181342/***************************************************************************
182343    CONTROL REGISTER READ/WRITE
183344***************************************************************************/
184345
185WRITE8_DEVICE_HANDLER( z80pio_c_w )
346READ8_DEVICE_HANDLER( lh0081_c_r )
186347{
187   z80pio_t *z80pio = get_safe_token( device );
348   z80pio_t *z80pio = get_safe_token(device);
188349
189   /* There are only 2 channels */
190   offset &= 0x01;
350   return (z80pio->enable[PIO_PORT_A] & 0xc0) | (z80pio->enable[PIO_PORT_B] >> 4);
351}
191352
192   /* load direction phase ? */
193   if (z80pio->mode[offset] == 0x13)
194   {
195      VPRINTF(("PIO-%c Bits %02x\n", 'A' + offset, data));
196      z80pio->dir[offset] = data;
197      z80pio->mode[offset] = 0x03;
198      return;
199   }
353READ8_DEVICE_HANDLER( z80pio_c_r )
354{
355   return 0;
356}
200357
201   /* load mask folows phase ? */
202   if (z80pio->enable[offset] & PIO_INT_MASK)
203   {
204      /* load mask folows */
205      z80pio->mask[offset] = data;
206      z80pio->enable[offset] &= ~PIO_INT_MASK;
207      VPRINTF(("PIO-%c interrupt mask %02x\n",'A'+offset,data ));
208      return;
209   }
358WRITE8_DEVICE_HANDLER( z80pio_c_w )
359{
360   z80pio_t *z80pio = get_safe_token(device);
361   int channel = offset & 0x01;
210362
211   switch (data & 0x0f)
363   switch (z80pio->state[channel])
212364   {
213      case PIO_OP_MODE:   /* mode select 0=out,1=in,2=i/o,3=bit */
214         z80pio->mode[offset] = (data >> 6);
215         VPRINTF(("PIO-%c Mode %x\n", 'A' + offset, z80pio->mode[offset]));
216         if (z80pio->mode[offset] == 0x03)
217            z80pio->mode[offset] = 0x13;
218         return;
365   case PIO_STATE_NORMAL:
366      if (!BIT(data, 0))
367      {
368         LOGERROR("Z80PIO \"%s\" Port %c : Interrupt Vector Word '%02x'\n", device->tag, 'A' + channel, z80pio->vector[channel]);
219369
220      case PIO_OP_INTC:      /* interrupt control */
221         z80pio->enable[offset] = data & 0xf0;
222         z80pio->mask[offset] = 0x00;
223         /* when interrupt enable , set vector request flag */
224         VPRINTF(("PIO-%c Controll %02x\n", 'A' + offset, data));
225         break;
370         /* load interrupt vector */
371         z80pio->vector[channel] = data & 0xfe;
372      }
373      else if ((data & 0x0f) == PIO_IRQ_DISABLE_WORD)
374      {
375         LOGERROR("Z80PIO \"%s\" Port %c : Interrupt Disable Word '%02x'\n", device->tag, 'A' + channel, data);
226376
227      case PIO_OP_INTE:      /* interrupt enable controll */
228         z80pio->enable[offset] &= ~PIO_INT_ENABLE;
229         z80pio->enable[offset] |= (data & PIO_INT_ENABLE);
230         VPRINTF(("PIO-%c enable %02x\n", 'A' + offset, data & 0x80));
231         break;
377         /* set interrupt enable */
378         z80pio->enable[channel] = (data & 0x80) | (z80pio->enable[channel] & 0x7f);
379         z80pio_set_irq_enable(device, channel, BIT(data, 7));
380      }
381      else if ((data & 0x0f) == PIO_MODE_CONTROL_WORD)
382      {
383         LOGERROR("Z80PIO \"%s\" Port %c : Mode Control Word '%02x'\n", device->tag, 'A' + channel, data);
232384
233      default:
234         if (!(data & 1))
385         /* set operating mode */
386         z80pio_set_mode(device, channel, data);
387      }
388      else if ((data & 0x0f) == PIO_IRQ_CONTROL_WORD)
389      {
390         LOGERROR("Z80PIO \"%s\" Port %c : Interrupt Control Word '%02x'\n", device->tag, 'A' + channel, data);
391
392         /* set interrupt control word */
393         z80pio->enable[channel] = data & 0xf0;
394
395         if (data & PIO_IRQ_MASK_FOLLOWS)
235396         {
236            z80pio->vector[offset] = data;
237            VPRINTF(("PIO-%c vector %02x\n", 'A' + offset, data));
397            /* disable interrupts until mask is written */
398            z80pio_set_irq_enable(device, channel, 0);
399
400            /* reset pending interrupt */
401            z80pio->irq_pending[channel] = 0;
402
403            /* set logic equation to false */
404            z80pio->match[channel] = 0;
405
406            /* next word is mask control */
407            z80pio->state[channel] = PIO_STATE_MASK;
238408         }
239409         else
240            VPRINTF(("PIO-%c illegal command %02x\n", 'A' + offset, data));
241         break;
242   }
410         {
411            /* set interrupt enable */
412            z80pio_set_irq_enable(device, channel, BIT(data, 7));
413         }
414      }
415      break;
243416
244   /* interrupt check */
245   update_irq_state(device, offset);
246}
417   case PIO_STATE_DDR:
418      LOGERROR("Z80PIO \"%s\" Port %c : I/O Control Word '%02x'\n", device->tag, 'A' + channel, data);
247419
420      /* set data direction */
421      z80pio->ddr[channel] = data;
248422
249READ8_DEVICE_HANDLER( z80pio_c_r )
250{
251   /* There are only 2 channels */
252   offset &= 0x01;
423      /* set interrupt enable */
424      z80pio_set_irq_enable(device, channel, BIT(z80pio->enable[channel], 7));
253425
254   VPRINTF(("PIO-%c controll read\n", 'A' + offset ));
255   return 0;
256}
426      /* next word is indeterminate */
427      z80pio->state[channel] = PIO_STATE_NORMAL;
428      break;
257429
430   case PIO_STATE_MASK:
431      LOGERROR("Z80PIO \"%s\" Port %c : Mask Control Word '%02x'\n", device->tag, 'A' + channel, data);
258432
433      /* set interrupt mask */
434      z80pio->mask[channel] = data;
259435
436      /* set interrupt enable */
437      z80pio_set_irq_enable(device, channel, BIT(z80pio->enable[channel], 7));
438
439      /* next word is indeterminate */
440      z80pio->state[channel] = PIO_STATE_NORMAL;
441      break;
442   }
443}
444
260445/***************************************************************************
261446    DATA REGISTER READ/WRITE
262447***************************************************************************/
263448
264WRITE8_DEVICE_HANDLER( z80pio_d_w )
449READ8_DEVICE_HANDLER( z80pio_d_r )
265450{
266451   z80pio_t *z80pio = get_safe_token( device );
452   int channel = offset & 0x01;
453   UINT8 data = 0;
267454
268   /* There are only 2 channels */
269   offset &= 0x01;
455   switch (z80pio->mode[channel])
456   {
457   case PIO_MODE_OUTPUT:
458      data = z80pio->output[channel];
459      break;
270460
271   z80pio->out[offset] = data;   /* latch out data */
272   if(z80pio->port_write[offset])
273      z80pio->port_write[offset](device, 0, data);
461   case PIO_MODE_INPUT:
462      data = z80pio->input[channel];
274463
275   switch (z80pio->mode[offset])
276   {
277      case PIO_MODE0:         /* mode 0 output */
278      case PIO_MODE2:         /* mode 2 i/o */
279         set_rdy(device, offset, 1); /* ready = H */
280         update_irq_state(device, offset);
281         return;
464      /* clear ready line */
465      z80pio_ready_w(device, channel, 0);
282466
283      case PIO_MODE1:         /* mode 1 input */
284      case PIO_MODE3:         /* mode 0 bit */
285         return;
467      /* assert ready line */
468      z80pio_ready_w(device, channel, 1);
469      break;
286470
287      default:
288         VPRINTF(("PIO-%c data write,bad mode\n",'A'+offset ));
471   case PIO_MODE_BIDIRECTIONAL:
472      data = z80pio->input[PIO_PORT_A] | (z80pio->output[PIO_PORT_A] & (~z80pio->ddr[PIO_PORT_A]));
473
474      /* clear ready line */
475      z80pio_ready_w(device, 1, 0);
476
477      /* assert ready line */
478      z80pio_ready_w(device, 1, 1);
479      break;
480
481   case PIO_MODE_CONTROL:
482      z80pio->input[channel] = z80pio_port_r(device, channel);
483
484      data = (z80pio->input[channel] & z80pio->ddr[channel]) | (z80pio->output[channel] & (~z80pio->ddr[channel]));
485      break;
289486   }
487
488   LOGERROR("Z80PIO \"%s\" Port %c : Data Register Read '%02x'\n", device->tag, 'A' + channel, data);
489
490   return data;
290491}
291492
292
293READ8_DEVICE_HANDLER( z80pio_d_r )
493WRITE8_DEVICE_HANDLER( z80pio_d_w )
294494{
295495   z80pio_t *z80pio = get_safe_token( device );
496   int channel = offset & 0x01;
296497
297   /* There are only 2 channels */
298   offset &= 0x01;
498   LOGERROR("Z80PIO \"%s\" Port %c : Data Register Write '%02x'\n", device->tag, 'A' + channel, data);
299499
300   switch (z80pio->mode[offset])
500   switch (z80pio->mode[channel])
301501   {
302      case PIO_MODE0:         /* mode 0 output */
303         return z80pio->out[offset];
502   case PIO_MODE_OUTPUT:
503      /* clear ready line */
504      z80pio_ready_w(device, channel, 0);
304505
305      case PIO_MODE1:         /* mode 1 input */
306         set_rdy(device, offset, 1);   /* ready = H */
307         if(z80pio->port_read[offset])
308            z80pio->in[offset] = z80pio->port_read[offset](device, 0);
309         update_irq_state(device, offset);
310         return z80pio->in[offset];
506      /* output data */
507      z80pio->output[channel] = data;
508      z80pio_port_w(device, channel);
311509
312      case PIO_MODE2:         /* mode 2 i/o */
313         if (offset) VPRINTF(("PIO-B mode 2 \n"));
314         set_rdy(device, 1, 1); /* brdy = H */
315         if(z80pio->port_read[offset])
316            z80pio->in[offset] = z80pio->port_read[offset](device, 0);
317         update_irq_state(device, offset);
318         return z80pio->in[offset];
510      /* assert ready line */
511      z80pio_ready_w(device, channel, 1);
512      break;
319513
320      case PIO_MODE3:         /* mode 3 bit */
321         if(z80pio->port_read[offset])
322            z80pio->in[offset] = z80pio->port_read[offset](device, 0);
323         return (z80pio->in[offset] & z80pio->dir[offset]) | (z80pio->out[offset] & ~z80pio->dir[offset]);
514   case PIO_MODE_INPUT:
515      /* do nothing */
516      break;
517
518   case PIO_MODE_BIDIRECTIONAL:
519      /* clear ready line */
520      z80pio_ready_w(device, channel, 0);
521
522      /* latch output data */
523      z80pio->output[channel] = data;
524
525      if (!z80pio->strobe[channel])
526      {
527         /* output data if ASTB active */
528         z80pio_port_w(device, channel);
529      }
530
531      /* assert ready line */
532      z80pio_ready_w(device, channel, 1);
533      break;
534
535   case PIO_MODE_CONTROL:
536      /* output data */
537      z80pio->output[channel] = data;
538      z80pio_port_w(device, channel);
539      break;
324540   }
325   VPRINTF(("PIO-%c data read,bad mode\n",'A'+offset ));
326   return 0;
327541}
328542
329
330
331543/***************************************************************************
332    PORT I/O
544    STROBE STATE MANAGEMENT
333545***************************************************************************/
334546
335WRITE8_DEVICE_HANDLER( z80pio_p_w )
547static TIMER_CALLBACK( z80pio_poll_tick )
336548{
337   z80pio_t *z80pio = get_safe_token( device );
549   const device_config *device = (device_config *) ptr;
550   z80pio_t *z80pio = get_safe_token(device);
551   int channel;
338552
339   /* There are only 2 channels */
340   offset &= 0x01;
341
342   z80pio->in[offset]  = data;
343   switch (z80pio->mode[offset])
553   for (channel = PIO_PORT_A; channel < PIO_PORT_COUNT; channel++)
344554   {
345      case PIO_MODE0:
346         VPRINTF(("PIO-%c OUTPUT mode and data write\n",'A'+offset ));
347         break;
555      if ((z80pio->mode[channel] == PIO_MODE_CONTROL) && (z80pio->mask[channel] != 0xff))
556      {
557         int bit;
558         int match = 0;
348559
349      case PIO_MODE2:   /* only port A */
350         offset = 1;      /* handshake and IRQ is use portB */
560         int edge = (z80pio->enable[channel] & PIO_IRQ_ACTIVE_HIGH) ? 1 : 0;
351561
352      case PIO_MODE1:
353         set_rdy(device, offset, 0);
354         update_irq_state(device, offset);
355         break;
562         UINT8 mask = z80pio->mask[channel];
563         UINT8 ddr = z80pio->ddr[channel];
564         UINT8 old_data = z80pio->input[channel] & ddr;
565         UINT8 data = z80pio_port_r(device, channel) & ddr;
356566
357      case PIO_MODE3:
358         /* irq check */
359         update_irq_state(device, offset);
360         break;
361   }
362}
567         if (old_data == data) continue;
363568
569         for (bit = 0; bit < 8; bit++)
570         {
571            if (BIT(mask, bit)) continue; /* masked out */
572            if (!BIT(ddr, bit)) continue; /* output bit */
364573
365READ8_DEVICE_HANDLER( z80pio_p_r )
366{
367   z80pio_t *z80pio = get_safe_token( device );
574            if ((BIT(old_data, bit) ^ edge) && !(BIT(data, bit) ^ edge)) /* falling edge */
575            {
576               /* logic equation is true, until proven otherwise */
577               match = 1;
368578
369   /* There are only 2 channels */
370   offset &= 0x01;
579               LOGERROR("Z80PIO \"%s\" Port %c : Edge Transition detected on bit %u, data %02x %02x\n", device->tag, 'A' + channel, bit, old_data, data);
580            }
581            else if (z80pio->enable[channel] & PIO_IRQ_AND)
582            {
583               /* all bits must match in AND mode, so logic equation is false */
584               match = 0;
585               break;
586            }
587         }
371588
372   switch (z80pio->mode[offset])
373   {
374      case PIO_MODE2:      /* port A only */
375      case PIO_MODE0:
376         set_rdy(device, offset, 0);
377         update_irq_state(device, offset);
378         break;
589         if (!z80pio->match[channel] && match) /* rising edge */
590         {
591            /* trigger interrupt only once */
592            z80pio_trigger_interrupt(device, channel);
593            z80pio->input[channel] = data;
594         }
379595
380      case PIO_MODE1:
381         VPRINTF(("PIO-%c INPUT mode and data read\n",'A'+offset ));
382         break;
383
384      case PIO_MODE3:
385         return (z80pio->in[offset] & z80pio->dir[offset]) | (z80pio->out[offset] & ~z80pio->dir[offset]);
596         z80pio->match[channel] = match;
597      }
386598   }
387   return z80pio->out[offset];
388599}
389600
390
391601/***************************************************************************
392602    STROBE STATE MANAGEMENT
393603***************************************************************************/
394604
395static void z80pio_update_strobe(const device_config *device, int ch, int state)
605static void z80pio_strobe_bidirectional(const device_config *device, int channel, int state)
396606{
397   z80pio_t *z80pio = get_safe_token( device );
607   z80pio_t *z80pio = get_safe_token(device);
398608
399   switch (z80pio->mode[ch])
609   switch (channel)
400610   {
401      /* output mode: a positive edge is used by peripheral to acknowledge
402            the receipt of data */
403      case PIO_MODE0:
611   case PIO_PORT_A:
612      if (!state) /* low level */
404613      {
405         /* ensure valid */
406         state = state & 0x01;
614         /* output data */
615         z80pio_port_w(device, PIO_PORT_A);
616      }
617      else if (!z80pio->strobe[channel] && state) /* rising edge */
618      {
619         /* trigger interrupt */
620         z80pio_trigger_interrupt(device, channel);
407621
408         /* strobe changed state? */
409         if ((z80pio->strobe[ch] ^ state) != 0)
410         {
411            /* yes */
412            if (state != 0)
413            {
414               /* positive edge */
415               VPRINTF(("PIO-%c positive strobe\n",'A' + ch));
622         /* clear ready line */
623         z80pio_ready_w(device, channel, 0);
624      }
625      break;
416626
417               /* ready is now inactive */
418               set_rdy(device, ch, 0);
627   case PIO_PORT_B:
628      if (!state) /* low level */
629      {
630         /* input data */
631         z80pio->input[channel] = z80pio_port_r(device, PIO_PORT_A);
632      }
633      else if (!z80pio->strobe[channel] && state) /* rising edge */
634      {
635         /* trigger interrupt */
636         z80pio_trigger_interrupt(device, channel);
419637
420               /* int enabled? */
421               if (z80pio->enable[ch] & PIO_INT_ENABLE)
422               {
423                  /* trigger an int request */
424                  z80pio->int_state[ch] |= Z80_DAISY_INT;
425               }
426            }
427         }
638         /* clear ready line */
639         z80pio_ready_w(device, channel, 0);
640      }
641      break;
642   }
428643
429         /* store strobe state */
430         z80pio->strobe[ch] = state;
644   /* latch strobe state */
645   z80pio->strobe[channel] = state;
646}
431647
432         /* check interrupt */
433         interrupt_check(device);
648static void z80pio_strobe(const device_config *device, int channel, int state)
649{
650   z80pio_t *z80pio = get_safe_token(device);
651
652   switch (z80pio->mode[channel])
653   {
654   case PIO_MODE_OUTPUT:
655      if (!z80pio->strobe[channel] && state) /* rising edge */
656      {
657         /* trigger interrupt */
658         z80pio_trigger_interrupt(device, channel);
659
660         /* clear ready line */
661         z80pio_ready_w(device, channel, 0);
434662      }
435663      break;
436664
437      /* input mode: strobe is used by peripheral to load data from the peripheral
438            into port a input register, data loaded into pio when signal is active */
665   case PIO_MODE_INPUT:
666      if (!state) /* low level */
667      {
668         /* strobe data in */
669         z80pio->input[channel] = z80pio_port_r(device, channel);
670      }
671      else if (!z80pio->strobe[channel] && state) /* rising edge */
672      {
673         /* trigger interrupt */
674         z80pio_trigger_interrupt(device, channel);
439675
440      default:
441         break;
676         /* clear ready line */
677         z80pio_ready_w(device, channel, 0);
678      }
679      break;
680
681   case PIO_MODE_CONTROL:
682      /* ignore strobes */
683      break;
442684   }
685
686   /* latch strobe state */
687   z80pio->strobe[channel] = state;
443688}
444689
690static void z80pio_strobe_w(const device_config *device, int channel, int state)
691{
692   z80pio_t *z80pio = get_safe_token(device);
445693
446void z80pio_astb_w(const device_config *device, int state) { z80pio_update_strobe(device, 0, state); }
447void z80pio_bstb_w(const device_config *device, int state) { z80pio_update_strobe(device, 1, state); }
694   LOGERROR("Z80PIO \"%s\" Port %c : Strobe %u\n", device->tag, 'A' + channel, state);
448695
696   if (z80pio->mode[PIO_PORT_A] == PIO_MODE_BIDIRECTIONAL)
697   {
698      /* port A bidirectional mode */
699      z80pio_strobe_bidirectional(device, channel, state);
700   }
701   else
702   {
703      z80pio_strobe(device, channel, state);
704   }
705}
449706
707void z80pio_astb_w(const device_config *device, int state)
708{
709   z80pio_strobe_w(device, PIO_PORT_A, state);
710}
450711
712void z80pio_bstb_w(const device_config *device, int state)
713{
714   z80pio_strobe_w(device, PIO_PORT_B, state);
715}
716
451717/***************************************************************************
452718    DAISY CHAIN INTERFACE
453719***************************************************************************/
r3596r3597
456722{
457723   z80pio_t *z80pio = get_safe_token( device );
458724   int state = 0;
459   int ch;
725   int channel;
460726
461727   /* loop over all channels */
462   for (ch = 0; ch < 2; ch++)
728   for (channel = PIO_PORT_A; channel < PIO_PORT_COUNT; channel++)
463729   {
464730      /* if we're servicing a request, don't indicate more interrupts */
465      if (z80pio->int_state[ch] & Z80_DAISY_IEO)
731      if (z80pio->int_state[channel] & Z80_DAISY_IEO)
466732      {
467733         state |= Z80_DAISY_IEO;
468734         break;
469735      }
470      state |= z80pio->int_state[ch];
736
737      state |= z80pio->int_state[channel];
471738   }
739
740   LOGERROR("Z80PIO \"%s\" : Interrupt State %u\n", device->tag, state);
741
472742   return state;
473743}
474744
475
476745static int z80pio_irq_ack(const device_config *device)
477746{
478747   z80pio_t *z80pio = get_safe_token( device );
479   int ch;
748   int channel;
480749
750   LOGERROR("Z80PIO \"%s\" Interrupt Acknowledge\n", device->tag);
751
481752   /* loop over all channels */
482   for (ch = 0; ch < 2; ch++)
483
753   for (channel = PIO_PORT_A; channel < PIO_PORT_COUNT; channel++)
754   {
484755      /* find the first channel with an interrupt requested */
485      if (z80pio->int_state[ch] & Z80_DAISY_INT)
756      if (z80pio->int_state[channel] & Z80_DAISY_INT)
486757      {
487758         /* clear interrupt, switch to the IEO state, and update the IRQs */
488         z80pio->int_state[ch] = Z80_DAISY_IEO;
489         interrupt_check(device);
490         return z80pio->vector[ch];
759         z80pio->int_state[channel] = Z80_DAISY_IEO;
760         z80pio_check_interrupt(device);
761
762         return z80pio->vector[channel];
491763      }
764   }
492765
493   VPRINTF(("z80pio_irq_ack: failed to find an interrupt to ack!"));
766   LOGERROR("z80pio_irq_ack: failed to find an interrupt to ack!");
767
494768   return z80pio->vector[0];
495769}
496770
497
498771static void z80pio_irq_reti(const device_config *device)
499772{
500773   z80pio_t *z80pio = get_safe_token( device );
501   int ch;
774   int channel;
502775
776   LOGERROR("Z80PIO \"%s\" Return from Interrupt\n", device->tag);
777
503778   /* loop over all channels */
504   for (ch = 0; ch < 2; ch++)
505
779   for (channel = PIO_PORT_A; channel < PIO_PORT_COUNT; channel++)
780   {
506781      /* find the first channel with an IEO pending */
507      if (z80pio->int_state[ch] & Z80_DAISY_IEO)
782      if (z80pio->int_state[channel] & Z80_DAISY_IEO)
508783      {
509784         /* clear the IEO state and update the IRQs */
510         z80pio->int_state[ch] &= ~Z80_DAISY_IEO;
511         interrupt_check(device);
785         z80pio->int_state[channel] &= ~Z80_DAISY_IEO;
786         z80pio_check_interrupt(device);
787
512788         return;
513789      }
790   }
514791
515   VPRINTF(("z80pio_irq_reti: failed to find an interrupt to clear IEO on!"));
792   LOGERROR("z80pio_irq_reti: failed to find an interrupt to clear IEO on!");
516793}
517794
518
519795/***************************************************************************
520796    READ/WRITE HANDLERS
521797***************************************************************************/
798
522799READ8_DEVICE_HANDLER(z80pio_r)
523800{
524801   return (offset & 2) ? z80pio_c_r(device, offset & 1) : z80pio_d_r(device, offset & 1);
r3596r3597
532809      z80pio_d_w(device, offset & 1, data);
533810}
534811
812READ8_DEVICE_HANDLER(z80pio_alt_r)
813{
814   int channel = BIT(offset, 1);
535815
816   return (offset & 1) ? z80pio_c_r(device, channel) : z80pio_d_r(device, channel);
817}
818
819WRITE8_DEVICE_HANDLER(z80pio_alt_w)
820{
821   int channel = BIT(offset, 1);
822
823   if (offset & 1)
824      z80pio_c_w(device, channel, data);
825   else
826      z80pio_d_w(device, channel, data);
827}
828
829/***************************************************************************
830    DEVICE INTERFACE
831***************************************************************************/
832
536833static DEVICE_START( z80pio )
537834{
538835   const z80pio_interface *intf = device->static_config;
539836   z80pio_t *z80pio = get_safe_token( device );
837   int cpunum = -1;
540838
541   z80pio->intr = intf->intr;
542   z80pio->port_read[0] = intf->portAread;
543   z80pio->port_read[1] = intf->portBread;
544   z80pio->port_write[0] = intf->portAwrite;
545   z80pio->port_write[1] = intf->portBwrite;
546   z80pio->rdyr[0] = intf->rdyA;
547   z80pio->rdyr[1] = intf->rdyB;
839   assert(intf != NULL);
840   z80pio->intf = intf;
548841
549   /* register for save states */
550   state_save_register_item_array("z80pio", device->tag, 0, z80pio->vector);
842   /* get clock */
843
844   if (intf->cpu != NULL)
845   {
846      cpunum = mame_find_cpu_index(device->machine, intf->cpu);
847   }
848
849   if (cpunum != -1)
850   {
851      z80pio->clock = device->machine->config->cpu[cpunum].clock;
852   }
853   else
854   {
855      assert(intf->clock > 0);
856      z80pio->clock = intf->clock;
857   }
858
859   /* allocate poll timer */
860
861   z80pio->poll_timer = timer_alloc(z80pio_poll_tick, (void *)device);
862   timer_adjust_periodic(z80pio->poll_timer, attotime_zero, 0, ATTOTIME_IN_HZ(z80pio->clock / 16));
863
864   /* allocate interrupt enable timer */
865
866   z80pio->irq_timer = timer_alloc(z80pio_irq_tick, (void *)device);
867
868   /* register for state saving */
869
870   state_save_register_item_array("z80pio", device->tag, 0, z80pio->state);
551871   state_save_register_item_array("z80pio", device->tag, 0, z80pio->mode);
872   state_save_register_item_array("z80pio", device->tag, 0, z80pio->irq_enable);
873   state_save_register_item_array("z80pio", device->tag, 0, z80pio->irq_pending);
874   state_save_register_item_array("z80pio", device->tag, 0, z80pio->int_state);
552875   state_save_register_item_array("z80pio", device->tag, 0, z80pio->enable);
876   state_save_register_item_array("z80pio", device->tag, 0, z80pio->input);
877   state_save_register_item_array("z80pio", device->tag, 0, z80pio->output);
878   state_save_register_item_array("z80pio", device->tag, 0, z80pio->vector);
553879   state_save_register_item_array("z80pio", device->tag, 0, z80pio->mask);
554   state_save_register_item_array("z80pio", device->tag, 0, z80pio->dir);
555   state_save_register_item_array("z80pio", device->tag, 0, z80pio->rdy);
556   state_save_register_item_array("z80pio", device->tag, 0, z80pio->in);
557   state_save_register_item_array("z80pio", device->tag, 0, z80pio->out);
880   state_save_register_item_array("z80pio", device->tag, 0, z80pio->ddr);
558881   state_save_register_item_array("z80pio", device->tag, 0, z80pio->strobe);
559   state_save_register_item_array("z80pio", device->tag, 0, z80pio->int_state);
882   state_save_register_item_array("z80pio", device->tag, 0, z80pio->match);
560883
561884   return DEVICE_START_OK;
562885}
563886
564
565887static DEVICE_RESET( z80pio )
566888{
567   z80pio_t   *z80pio = get_safe_token( device );
568   int i;
889   z80pio_t *z80pio = get_safe_token(device);
890   int channel;
569891
570   for (i = 0; i < 2; i++)
892   LOGERROR("Z80PIO \"%s\" : Reset\n", device->tag);
893
894   for (channel = 0; channel < 2; channel++)
571895   {
572      z80pio->mask[i]   = 0xff;   /* mask all on */
573      z80pio->enable[i] = 0x00;   /* disable     */
574      z80pio->mode[i]   = 0x01;   /* mode input  */
575      z80pio->dir[i]    = 0x01;   /* dir  input  */
576      set_rdy(device, i, 0);   /* RDY = low   */
577      z80pio->out[i]    = 0x00;   /* outdata = 0 */
578      z80pio->int_state[i] = 0;
579      z80pio->strobe[i] = 0;
896      /* set mode 1 */
897      z80pio->mode[channel] = PIO_MODE_INPUT;
898
899      /* disable interrupt */
900      z80pio->enable[channel] &= 0x7f;
901      z80pio->irq_enable[channel] = 0;
902      z80pio->irq_pending[channel] = 0;
903      z80pio->int_state[channel] = 0;
904      z80pio->match[channel] = 0;
905
906      /* reset all bits of the data I/O register */
907      z80pio->ddr[channel] = 0;
908
909      /* set all bits of the mask control register */
910      z80pio->mask[channel] = 0xff;
911
912      /* reset output register */
913      z80pio->output[channel] = 0;
914
915      /* clear ready line */
916      z80pio_ready_w(device, channel, 0);
580917   }
581   interrupt_check(device);
918
919   z80pio_check_interrupt(device);
582920}
583921
584
585922static DEVICE_SET_INFO( z80pio )
586923{
587924   switch (state)
r3596r3597
590927   }
591928}
592929
593
594930DEVICE_GET_INFO( z80pio )
595931{
596932   switch (state)
r3596r3597
618954   }
619955}
620956
957DEVICE_GET_INFO( z8420 )
958{
959   switch (state)
960   {
961      /* --- the following bits of info are returned as NULL-terminated strings --- */
962      case DEVINFO_STR_NAME:                     info->s = "Zilog Z8420";            break;
963      case DEVINFO_STR_FAMILY:                  info->s = "Z80 PIO";               break;
964
965      default:                              DEVICE_GET_INFO_CALL(z80pio);
966   }
967}
968
969DEVICE_GET_INFO( lh0081 )
970{
971   switch (state)
972   {
973      /* --- the following bits of info are returned as NULL-terminated strings --- */
974      case DEVINFO_STR_NAME:                     info->s = "Sharp LH0081";            break;
975      case DEVINFO_STR_FAMILY:                  info->s = "Z80 PIO";               break;
976
977      default:                              DEVICE_GET_INFO_CALL(z80pio);
978   }
979}
980
981DEVICE_GET_INFO( mk3881 )
982{
983   switch (state)
984   {
985      /* --- the following bits of info are returned as NULL-terminated strings --- */
986      case DEVINFO_STR_NAME:                     info->s = "Mostek MK3881";            break;
987      case DEVINFO_STR_FAMILY:                  info->s = "Z80 PIO";               break;
988
989      default:                              DEVICE_GET_INFO_CALL(z80pio);
990   }
991}
src/emu/machine/z80pio.h
r3596r3597
11/***************************************************************************
22
3    Z80 PIO (Z8420) implementation
3    Z80 PIO Parallel Input/Output Controller emulation
44
55    Copyright Nicola Salmoria and the MAME Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
77
8***************************************************************************
8****************************************************************************
99                            _____   _____
1010                    D2   1 |*    \_/     | 40  D3
1111                    D7   2 |             | 39  D4
r3596r3597
3333#ifndef __Z80PIO_H__
3434#define __Z80PIO_H__
3535
36/***************************************************************************
37    CALLBACK FUNCTION PROTOTYPES
38***************************************************************************/
3639
40typedef void (*z80pio_on_int_changed_func) (const device_config *device, int state);
41#define Z80PIO_ON_INT_CHANGED(name) void name(const device_config *device, int state)
42
43typedef void (*z80pio_on_ardy_changed_func) (const device_config *device, int state);
44#define Z80PIO_ON_ARDY_CHANGED(name) void name(const device_config *device, int state)
45
46typedef void (*z80pio_on_brdy_changed_func) (const device_config *device, int state);
47#define Z80PIO_ON_BRDY_CHANGED(name) void name(const device_config *device, int state)
48
3749/***************************************************************************
3850    TYPE DEFINITIONS
3951***************************************************************************/
r3596r3597
4153typedef struct _z80pio_interface z80pio_interface;
4254struct _z80pio_interface
4355{
44   void (*intr)(const device_config *device, int which);    /* callback when change interrupt status */
45   read8_device_func portAread;    /* port A read callback */
46   read8_device_func portBread;    /* port B read callback */
47   write8_device_func portAwrite;  /* port A write callback */
48   write8_device_func portBwrite;  /* port B write callback */
49   void (*rdyA)(int data);     /* portA ready active callback (do not support yet)*/
50   void (*rdyB)(int data);     /* portB ready active callback (do not support yet)*/
51};
56   const char *cpu;            /* CPU whose clock we use for our base */
57   int clock;                  /* clock (pin 25) of the chip */
5258
59   /* this gets called for every change of the _INT pin (pin 23) */
60   z80pio_on_int_changed_func      on_int_changed;
5361
62   /* this gets called for every read from port A */
63   read8_device_func            port_a_r;
5464
65   /* this gets called for every read from port B */
66   read8_device_func            port_b_r;
67
68   /* this gets called for every write to port A */
69   write8_device_func            port_a_w;
70
71   /* this gets called for every write to port B */
72   write8_device_func            port_b_w;
73
74   /* this gets called for every change of the ARDY pin (pin 18) */
75   z80pio_on_ardy_changed_func      on_ardy_changed;
76
77   /* this gets called for every change of the BRDY pin (pin 21) */
78   z80pio_on_brdy_changed_func      on_brdy_changed;
79};
80#define Z80PIO_INTERFACE(name) const z80pio_interface (name)=
81
5582/***************************************************************************
5683    DEVICE CONFIGURATION MACROS
5784***************************************************************************/
r3596r3597
6390#define MDRV_Z80PIO_REMOVE(_tag) \
6491   MDRV_DEVICE_REMOVE(_tag, Z80PIO)
6592
66
67
6893/***************************************************************************
6994    CONTROL REGISTER READ/WRITE
7095***************************************************************************/
7196
97READ8_DEVICE_HANDLER( z80pio_c_r );
7298WRITE8_DEVICE_HANDLER( z80pio_c_w );
73READ8_DEVICE_HANDLER( z80pio_c_r );
7499
100READ8_DEVICE_HANDLER( lh0081_c_r );
75101
76102/***************************************************************************
77103    DATA REGISTER READ/WRITE
78104***************************************************************************/
79105
106READ8_DEVICE_HANDLER( z80pio_d_r );
80107WRITE8_DEVICE_HANDLER( z80pio_d_w );
81READ8_DEVICE_HANDLER( z80pio_d_r );
82108
83
84109/***************************************************************************
85    PORT I/O
86***************************************************************************/
87
88WRITE8_DEVICE_HANDLER( z80pio_p_w );
89READ8_DEVICE_HANDLER( z80pio_p_r );
90
91
92/***************************************************************************
93110    STROBE STATE MANAGEMENT
94111***************************************************************************/
95112
96113void z80pio_astb_w(const device_config *device, int state);
97114void z80pio_bstb_w(const device_config *device, int state);
98115
99
100116/***************************************************************************
101117    READ/WRITE HANDLERS
102118***************************************************************************/
119
120/* A0 = B/A
121   A1 = C/D */
103122READ8_DEVICE_HANDLER(z80pio_r);
104123WRITE8_DEVICE_HANDLER(z80pio_w);
105124
125/* A0 = C/D
126   A1 = B/A */
127READ8_DEVICE_HANDLER(z80pio_alt_r);
128WRITE8_DEVICE_HANDLER(z80pio_alt_w);
106129
107/* ----- device interface ----- */
130/***************************************************************************
131    DEVICE INTERFACE
132***************************************************************************/
108133
109134#define Z80PIO DEVICE_GET_INFO_NAME(z80pio)
110135DEVICE_GET_INFO( z80pio );
111136
137#define Z8420 DEVICE_GET_INFO_NAME(z8420)
138DEVICE_GET_INFO( z8420 );
139
140#define LH0081 DEVICE_GET_INFO_NAME(lh0081)
141DEVICE_GET_INFO( lh0081 );
142
143#define MK3881 DEVICE_GET_INFO_NAME(mk3881)
144DEVICE_GET_INFO( mk3881 );
145
112146#endif
src/emu/mconfig.h
r3596r3597
189189
190190
191191/* start/end tags for the machine driver */
192#define MACHINE_DRIVER_NAME(_name) \
193   machine_config_##_name
194
192195#define MACHINE_DRIVER_START(_name) \
193   const machine_config_token machine_config_##_name[] = {
196   const machine_config_token MACHINE_DRIVER_NAME(_name)[] = {
194197
195198#define MACHINE_DRIVER_END \
196199   TOKEN_UINT32_PACK1(MCONFIG_TOKEN_END, 8) };
src/mess/video/abc800.c
r3596r3597
2121 
2222READ8_HANDLER( abc800_charram_r )
2323{
24   abc800_state *state = machine->driver_data;
24   abc800_state *state = space->machine->driver_data;
2525 
2626   return state->charram[offset];
2727}
2828 
2929WRITE8_HANDLER( abc800_charram_w )
3030{
31   abc800_state *state = machine->driver_data;
31   abc800_state *state = space->machine->driver_data;
3232 
3333   state->charram[offset] = data;
3434}
r3596r3597
5757 
5858WRITE8_HANDLER( abc800_hrs_w )
5959{
60   abc800_state *state = machine->driver_data;
60   abc800_state *state = space->machine->driver_data;
6161 
6262   state->hrs = data;
6363}
6464 
6565WRITE8_HANDLER( abc800_hrc_w )
6666{
67   abc800_state *state = machine->driver_data;
67   abc800_state *state = space->machine->driver_data;
6868 
6969   state->fgctl = data;
7070}
src/mess/video/abc802.c
r3596r3597
2121 
2222READ8_HANDLER( abc802_charram_r )
2323{
24   abc802_state *state = machine->driver_data;
24   abc802_state *state = space->machine->driver_data;
2525 
2626   return state->charram[offset];
2727}
2828 
2929WRITE8_HANDLER( abc802_charram_w )
3030{
31   abc802_state *state = machine->driver_data;
31   abc802_state *state = space->machine->driver_data;
3232 
3333   state->charram[offset] = data;
3434}
src/mess/video/abc806.c
r3596r3597
5151
5252   */
5353
54   abc806_state *state = machine->driver_data;
54   abc806_state *state = space->machine->driver_data;
5555   
5656   state->hrs = data;
5757}
r3596r3597
6060
6161WRITE8_HANDLER( abc806_hrc_w )
6262{
63   abc806_state *state = machine->driver_data;
63   abc806_state *state = space->machine->driver_data;
6464
6565   int reg = (offset >> 8) & 0x0f;
6666
r3596r3597
7171
7272READ8_HANDLER( abc806_charram_r )
7373{
74   abc806_state *state = machine->driver_data;
74   abc806_state *state = space->machine->driver_data;
7575
7676   state->attr_data = state->colorram[offset];
7777
r3596r3597
8080
8181WRITE8_HANDLER( abc806_charram_w )
8282{
83   abc806_state *state = machine->driver_data;
83   abc806_state *state = space->machine->driver_data;
8484
8585   state->colorram[offset] = state->attr_data;
8686   state->charram[offset] = data;
r3596r3597
9090
9191READ8_HANDLER( abc806_ami_r )
9292{
93   abc806_state *state = machine->driver_data;
93   abc806_state *state = space->machine->driver_data;
9494
9595   return state->attr_data;
9696}
9797
9898WRITE8_HANDLER( abc806_amo_w )
9999{
100   abc806_state *state = machine->driver_data;
100   abc806_state *state = space->machine->driver_data;
101101
102102   state->attr_data = data;
103103}
r3596r3597
106106
107107READ8_HANDLER( abc806_cli_r )
108108{
109   abc806_state *state = machine->driver_data;
109   abc806_state *state = space->machine->driver_data;
110110
111111   /*
112112
r3596r3597
155155
156156WRITE8_HANDLER( abc806_sto_w )
157157{
158   abc806_state *state = machine->driver_data;
158   abc806_state *state = space->machine->driver_data;
159159
160160   int level = BIT(data, 7);
161161
r3596r3597
199199
200200WRITE8_HANDLER( abc806_sso_w )
201201{
202   abc806_state *state = machine->driver_data;
202   abc806_state *state = space->machine->driver_data;
203203
204204   state->sync = data & 0x3f;
205205}
src/mess/messdriv.c
r3596r3597
905905//128u4   DRIVER( tx0_8kw )   /* 1962 MIT TX-0 (8kw RAM)                     */
906906
907907   /* Luxor Datorer AB */
908//128u4   DRIVER( abc80 )
909//128u4   DRIVER( abc802 )
910//128u4   DRIVER( abc800m )
911//128u4   DRIVER( abc800c )
912//128u4   DRIVER( abc806 )
908   DRIVER( abc80 )
909   DRIVER( abc802 )
910   DRIVER( abc800m )
911   DRIVER( abc800c )
912   DRIVER( abc806 )
913913
914914   /* Be Incorporated */
915915//128u4   DRIVER( bebox )      /* BeBox Dual603-66                           */
src/mess/machine/conkort.c
r3596r3597
7171 
7272   Common
7373   ------
74   - remove cpunum references
7574   - separate wd17xx reset from init
7675 
7776   Slow Controller
r3596r3597
8584   Fast Controller
8685   ---------------
8786   - Z80 DMA interrupt
88   - Z80 DMA memory <-> IO transfer
8987   - FDC INT
9088   - FDC DRQ
9189 
r3596r3597
103101typedef struct _slow_t slow_t;
104102struct _slow_t
105103{
106   int cpunum;                  /* CPU index of the Z80 */
104   int cpunum;            /* CPU index of the Z80 */
107105 
108   UINT8 status;
109   UINT8 data;
110   int pio_ardy;
111   int fdc_irq;
106   UINT8 status;         /* ABC BUS status */
107   UINT8 data;            /* ABC BUS data */
108   int pio_ardy;         /* PIO port A ready */
109   int fdc_irq;         /* FDC interrupt */
112110 
111   /* devices */
113112   const device_config *z80pio;
114113};
115114 
116115typedef struct _fast_t fast_t;
117116struct _fast_t
118117{
119   int cpunum;                  /* CPU index of the Z80 */
118   int cpunum;            /* CPU index of the Z80 */
120119 
121   UINT8 status;
122   UINT8 data;
123   int fdc_irq;
120   UINT8 status;         /* ABC BUS status */
121   UINT8 data;            /* ABC BUS data */
122   int fdc_irq;         /* FDC interrupt */
124123 
124   /* devices */
125125   const device_config *z80dma;
126126};
127127 
r3596r3597
141141   return (fast_t *)device->token;
142142}
143143 
144INLINE slow_t *get_safe_token_machine_slow(running_machine *machine)
145{
146      const device_config *device = devtag_get_device(machine, LUXOR_55_10828, CONKORT_TAG);
147   return get_safe_token_slow(device);
148}
149 
150INLINE fast_t *get_safe_token_machine_fast(running_machine *machine)
151{
152      const device_config *device = devtag_get_device(machine, LUXOR_55_21046, CONKORT_TAG);
153   return get_safe_token_fast(device);
154}
155 
144156static const device_config *get_floppy_image(int drive)
145157{
146158   return image_from_devtype_and_index(IO_FLOPPY, drive);
r3596r3597
150162 
151163static READ8_HANDLER( slow_bus_data_r )
152164{
153   const device_config *device = devtag_get_device(machine, LUXOR_55_10828, CONKORT_TAG);
154   const device_config *z80pio = devtag_get_device(device->machine, Z80PIO, CONKORT_Z80PIO_TAG);
165   slow_t *conkort = get_safe_token_machine_slow(space->machine);
155166 
156   slow_t *conkort = get_safe_token_slow(device);
157 
158167   UINT8 data = 0xff;
159168 
160   z80pio_astb_w(z80pio, 0);
169   z80pio_astb_w(conkort->z80pio, 0);
161170 
162171   if (!BIT(conkort->status, 6))
163172   {
164173      data = conkort->data;
165174   }
166175 
167   z80pio_astb_w(z80pio, 1);
176   z80pio_astb_w(conkort->z80pio, 1);
168177 
169178   return data;
170179}
171180 
172181static WRITE8_HANDLER( slow_bus_data_w )
173182{
174   const device_config *device = devtag_get_device(machine, LUXOR_55_10828, CONKORT_TAG);
175   const device_config *z80pio = devtag_get_device(device->machine, Z80PIO, CONKORT_Z80PIO_TAG);
183   slow_t *conkort = get_safe_token_machine_slow(space->machine);
176184 
177   slow_t *conkort = get_safe_token_slow(device);
185   z80pio_astb_w(conkort->z80pio, 0);
178186 
179   z80pio_astb_w(z80pio, 0);
180 
181187   if (BIT(conkort->status, 6))
182188   {
183189      conkort->data = data;
184190   }
185191 
186   z80pio_astb_w(z80pio, 1);
192   z80pio_astb_w(conkort->z80pio, 1);
187193}
188194 
189195static READ8_HANDLER( slow_bus_stat_r )
190196{
191   const device_config *device = devtag_get_device(machine, LUXOR_55_10828, CONKORT_TAG);
192   slow_t *conkort = get_safe_token_slow(device);
197   slow_t *conkort = get_safe_token_machine_slow(space->machine);
193198 
194   return (conkort->pio_ardy << 7) | conkort->status;
199   return (conkort->status & 0xfe) | conkort->pio_ardy;
195200}
196201 
197202static WRITE8_HANDLER( slow_bus_c1_w )
198203{
199   const device_config *device = devtag_get_device(machine, LUXOR_55_10828, CONKORT_TAG);
200   slow_t *conkort = get_safe_token_slow(device);
204   slow_t *conkort = get_safe_token_machine_slow(space->machine);
201205 
202   cpunum_set_input_line(machine, conkort->cpunum, INPUT_LINE_NMI, PULSE_LINE);
206   cpu_set_input_line(space->machine->cpu[conkort->cpunum], INPUT_LINE_NMI, PULSE_LINE);
203207}
204208 
205209static WRITE8_HANDLER( slow_bus_c3_w )
206210{
207   const device_config *device = devtag_get_device(machine, LUXOR_55_10828, CONKORT_TAG);
208   slow_t *conkort = get_safe_token_slow(device);
211   slow_t *conkort = get_safe_token_machine_slow(space->machine);
209212 
210   cpunum_set_input_line(machine, conkort->cpunum, INPUT_LINE_RESET, PULSE_LINE);
213   cpu_set_input_line(space->machine->cpu[conkort->cpunum], INPUT_LINE_RESET, PULSE_LINE);
211214}
212215 
213static void slow_card_select(const device_config *device, UINT8 data)
216static ABCBUS_CARD_SELECT( luxor_55_10828 )
214217{
215218   slow_t *conkort = get_safe_token_slow(device);
216219 
217220   if (data == 0x2d) // TODO: bit 0 of this is configurable with S1
218221   {
219      memory_install_readwrite8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_INP, ABCBUS_OUT, 0x18, 0, slow_bus_data_r, slow_bus_data_w);
220      memory_install_read8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_STAT, ABCBUS_STAT, 0x18, 0, slow_bus_stat_r);
221      memory_install_write8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_C1, ABCBUS_C1, 0x18, 0, slow_bus_c1_w);
222      memory_install_write8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_C2, ABCBUS_C2, 0x18, 0, SMH_NOP);
223      memory_install_write8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_C3, ABCBUS_C3, 0x18, 0, slow_bus_c3_w);
224      memory_install_write8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_C4, ABCBUS_C4, 0x18, 0, SMH_NOP);
222      memory_install_readwrite8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_INP, ABCBUS_OUT, 0x18, 0, slow_bus_data_r, slow_bus_data_w);
223      memory_install_read8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_STAT, ABCBUS_STAT, 0x18, 0, slow_bus_stat_r);
224      memory_install_write8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C1, ABCBUS_C1, 0x18, 0, slow_bus_c1_w);
225      memory_install_write8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C2, ABCBUS_C2, 0x18, 0, SMH_NOP);
226      memory_install_write8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C3, ABCBUS_C3, 0x18, 0, slow_bus_c3_w);
227      memory_install_write8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C4, ABCBUS_C4, 0x18, 0, SMH_NOP);
225228   }
226229 
227   cpunum_set_input_line(device->machine, conkort->cpunum, INPUT_LINE_RESET, PULSE_LINE);
230   cpu_set_input_line(device->machine->cpu[conkort->cpunum], INPUT_LINE_RESET, PULSE_LINE);
228231}
229232 
230233static WRITE8_HANDLER( slow_ctrl_w )
r3596r3597
261264   if (!BIT(data, 7))
262265   {
263266      /* FDC master reset */
264      wd17xx_reset(machine);
267      wd17xx_reset(space->machine);
265268   }
266269}
267270 
268271static WRITE8_HANDLER( slow_status_w )
269272{
270   const device_config *device = devtag_get_device(machine, LUXOR_55_10828, CONKORT_TAG);
271   slow_t *conkort = get_safe_token_slow(device);
273   /*
272274 
273   conkort->status = data & 0x7f;
275      bit      description
274276 
275   cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, BIT(data, 7) ? ASSERT_LINE : CLEAR_LINE);
277      0      _INT to main Z80
278      1       
279      2       
280      3       
281      4       
282      5       
283      6      LS245 DIR
284      7       
285 
286   */
287 
288   slow_t *conkort = get_safe_token_machine_slow(space->machine);
289 
290   conkort->status = data;
291 
292   /* interrupt to main CPU */
293   cpu_set_input_line(space->machine->cpu[conkort->cpunum], INPUT_LINE_IRQ0, BIT(data, 7) ? ASSERT_LINE : CLEAR_LINE);
276294}
277295 
278296/* Fast Controller */
279297 
280298static READ8_HANDLER( fast_bus_data_r )
281299{
282   const device_config *device = devtag_get_device(machine, LUXOR_55_21046, CONKORT_TAG);
283   fast_t *conkort = get_safe_token_fast(device);
300   fast_t *conkort = get_safe_token_machine_fast(space->machine);
284301 
285302   UINT8 data = 0xff;
286303 
r3596r3597
294311 
295312static WRITE8_HANDLER( fast_bus_data_w )
296313{
297   const device_config *device = devtag_get_device(machine, LUXOR_55_21046, CONKORT_TAG);
298   fast_t *conkort = get_safe_token_fast(device);
314   fast_t *conkort = get_safe_token_machine_fast(space->machine);
299315 
300316   if (BIT(conkort->status, 6))
301317   {
302318      conkort->data = data;
303319   }
304 
305//   cpunum_set_input_line(machine, conkort->cpunum, INPUT_LINE_NMI, PULSE_LINE);
306320}
307321 
308322static READ8_HANDLER( fast_bus_stat_r )
309323{
310   const device_config *device = devtag_get_device(machine, LUXOR_55_21046, CONKORT_TAG);
311   fast_t *conkort = get_safe_token_fast(device);
324   fast_t *conkort = get_safe_token_machine_fast(space->machine);
312325 
313326   return conkort->status;
314327}
315328 
316329static WRITE8_HANDLER( fast_bus_c1_w )
317330{
318   const device_config *device = devtag_get_device(machine, LUXOR_55_21046, CONKORT_TAG);
319   fast_t *conkort = get_safe_token_fast(device);
331   fast_t *conkort = get_safe_token_machine_fast(space->machine);
320332 
321   cpunum_set_input_line(machine, conkort->cpunum, INPUT_LINE_NMI, PULSE_LINE);
333   cpu_set_input_line(space->machine->cpu[conkort->cpunum], INPUT_LINE_NMI, PULSE_LINE);
322334}
323335 
324336static WRITE8_HANDLER( fast_bus_c3_w )
325337{
326   const device_config *device = devtag_get_device(machine, LUXOR_55_21046, CONKORT_TAG);
327   fast_t *conkort = get_safe_token_fast(device);
338   fast_t *conkort = get_safe_token_machine_fast(space->machine);
328339 
329   cpunum_set_input_line(machine, conkort->cpunum, INPUT_LINE_RESET, PULSE_LINE);
340   cpu_set_input_line(space->machine->cpu[conkort->cpunum], INPUT_LINE_RESET, PULSE_LINE);
330341}
331342 
332static void fast_card_select(const device_config *device, UINT8 data)
343static ABCBUS_CARD_SELECT( luxor_55_21046 )
333344{
334345   fast_t *conkort = get_safe_token_fast(device);
335346 
336347   if (data == input_port_read(device->machine, "SW3"))
337348   {
338      memory_install_readwrite8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_INP, ABCBUS_OUT, 0x18, 0, fast_bus_data_r, fast_bus_data_w);
339      memory_install_read8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_STAT, ABCBUS_STAT, 0x18, 0, fast_bus_stat_r);
340      memory_install_write8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_C1, ABCBUS_C1, 0x18, 0, fast_bus_c1_w);
341      memory_install_write8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_C2, ABCBUS_C2, 0x18, 0, SMH_NOP);
342      memory_install_write8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_C3, ABCBUS_C3, 0x18, 0, fast_bus_c3_w);
343      memory_install_write8_handler(device->machine, 0, ADDRESS_SPACE_IO, ABCBUS_C4, ABCBUS_C4, 0x18, 0, SMH_NOP);
349      memory_install_readwrite8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_INP, ABCBUS_OUT, 0x18, 0, fast_bus_data_r, fast_bus_data_w);
350      memory_install_read8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_STAT, ABCBUS_STAT, 0x18, 0, fast_bus_stat_r);
351      memory_install_write8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C1, ABCBUS_C1, 0x18, 0, fast_bus_c1_w);
352      memory_install_write8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C2, ABCBUS_C2, 0x18, 0, SMH_NOP);
353      memory_install_write8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C3, ABCBUS_C3, 0x18, 0, fast_bus_c3_w);
354      memory_install_write8_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C4, ABCBUS_C4, 0x18, 0, SMH_NOP);
344355   }
345356 
346   cpunum_set_input_line(device->machine, conkort->cpunum, INPUT_LINE_RESET, PULSE_LINE);
357   cpu_set_input_line(device->machine->cpu[conkort->cpunum], INPUT_LINE_RESET, PULSE_LINE);
347358}
348359 
349static WRITE8_HANDLER( fast_1f_w )
360static READ8_HANDLER( fast_ctrl_r )
350361{
351   /*
352 
353      bit      description
354 
355      0       
356      1       
357      2       
358      3       
359      4       
360      5       
361      6       
362      7       
363 
364   */
365 
366   logerror("1F write %02x\n", data);
362   return 0xff; // TODO what is this?
367363}
368364 
369static WRITE8_HANDLER( fast_3f_w )
370{
371   /*
372 
373      bit      description
374 
375      0       
376      1       
377      2       
378      3       
379      4       
380      5       
381      6       
382      7       
383 
384   */
385 
386   logerror("3F write %02x\n", data);
387}
388 
389static WRITE8_HANDLER( fast_ctrl_w )
390{
391   /*
392 
393      bit      description
394 
395      0      _SEL 0
396      1      _SEL 1
397      2      _MOT
398      3      _SIDE
399      4       
400      5       
401      6       
402      7       
403 
404   */
405 
406   /* drive selection */
407   if (!BIT(data, 0)) wd17xx_set_drive(0);
408   if (!BIT(data, 1)) wd17xx_set_drive(1);
409 
410   /* motor enable */
411   floppy_drive_set_motor_state(get_floppy_image(0), !BIT(data, 2));
412   floppy_drive_set_motor_state(get_floppy_image(1), !BIT(data, 2));
413   floppy_drive_set_ready_state(get_floppy_image(0), 1, 1);
414   floppy_drive_set_ready_state(get_floppy_image(1), 1, 1);
415 
416   /* disk side selection */
417   wd17xx_set_side(!BIT(data, 3));
418}
419 
420365static READ8_HANDLER( fast_data_r )
421366{
422   const device_config *device = devtag_get_device(machine, LUXOR_55_21046, CONKORT_TAG);
423   fast_t *conkort = get_safe_token_fast(device);
367   fast_t *conkort = get_safe_token_machine_fast(space->machine);
424368 
425369   return conkort->data;
426370}
427371 
428372static WRITE8_HANDLER( fast_data_w )
429373{
430   const device_config *device = devtag_get_device(machine, LUXOR_55_21046, CONKORT_TAG);
431   fast_t *conkort = get_safe_token_fast(device);
374   fast_t *conkort = get_safe_token_machine_fast(space->machine);
432375 
433376   conkort->data = data;
434377}
435378 
436379static WRITE8_HANDLER( fast_status_w )
437380{
438   const device_config *device = devtag_get_device(machine, LUXOR_55_21046, CONKORT_TAG);
439   fast_t *conkort = get_safe_token_fast(device);
381   fast_t *conkort = get_safe_token_machine_fast(space->machine);
440382 
441383   conkort->status = data;
442384}
r3596r3597
446388// Slow Controller
447389 
448390static ADDRESS_MAP_START( slow_map, ADDRESS_SPACE_PROGRAM, 8 )
449   AM_RANGE(0x0000, 0x0fff) AM_ROM
391   AM_RANGE(0x0000, 0x0fff) AM_ROM AM_REGION("abc830", 0)
450392   AM_RANGE(0x1000, 0x13ff) AM_RAM
451393ADDRESS_MAP_END
452394 
r3596r3597
461403// Fast Controller
462404 
463405static ADDRESS_MAP_START( fast_map, ADDRESS_SPACE_PROGRAM, 8 )
464   AM_RANGE(0x0000, 0x1fff) AM_ROM
406   AM_RANGE(0x0000, 0x1fff) AM_ROM AM_REGION("conkort", 0)
465407   AM_RANGE(0x2000, 0x3fff) AM_RAM
466408ADDRESS_MAP_END
467409 
r3596r3597
472414   AM_RANGE(0x2f, 0x2f) AM_WRITE(fast_status_w)
473415//   AM_RANGE(0x3f, 0x3f) AM_WRITE()
474416//   AM_RANGE(0x4f, 0x4f) AM_WRITE()
475//   AM_RANGE(0x5d, 0x5d) AM_READ()
476 
417   AM_RANGE(0x5d, 0x5d) AM_READ(fast_ctrl_r)
477418   AM_RANGE(0x68, 0x6b) AM_READ(wd17xx_r)
478419   AM_RANGE(0x78, 0x7b) AM_WRITE(wd17xx_w)
479420   AM_RANGE(0x87, 0x87) AM_DEVREADWRITE(Z80DMA, CONKORT_Z80DMA_TAG, z80dma_r, z80dma_w)
r3596r3597
522463   PORT_DIPSETTING(    0x2c, "ABC 832/834/850" )
523464   PORT_DIPSETTING(    0x2d, "ABC 830" )
524465   PORT_DIPSETTING(    0x2e, "ABC 838" )
466 
467   PORT_START("CONKORT_ROM")
468   PORT_CONFNAME( 0x07, 0x00, "Controller PROM" )
469   PORT_CONFSETTING(    0x00, "Luxor v1.07" )
470   PORT_CONFSETTING(    0x01, "Luxor v1.08" )
471   PORT_CONFSETTING(    0x02, "DIAB v2.07" )
525472INPUT_PORTS_END
526473 
527474/* Z80 PIO */
528475 
529476static Z80PIO_ON_INT_CHANGED( pio_interrupt )
530477{
531   cpunum_set_input_line(device->machine, 1, INPUT_LINE_IRQ0, state); // TODO hardcoded
478   slow_t *conkort = get_safe_token_machine_slow(device->machine);
479 
480   cpu_set_input_line(device->machine->cpu[conkort->cpunum], INPUT_LINE_IRQ0, state);
532481}
533482 
534483static READ8_DEVICE_HANDLER( pio_port_a_r )
535484{
536   /*
485   slow_t *conkort = get_safe_token_machine_slow(device->machine);
537486 
538      bit      description
539 
540      0      _INT to main Z80
541      1       
542      2       
543      3       
544      4       
545      5       
546      6      LS245 DIR
547      7       
548 
549   */
550 
551   const device_config *conkort_device = devtag_get_device(device->machine, LUXOR_55_10828, CONKORT_TAG);
552   slow_t *conkort = get_safe_token_slow(conkort_device);
553 
554487   return conkort->data;
555488}
556489 
557490static WRITE8_DEVICE_HANDLER( pio_port_a_w )
558491{
559   const device_config *conkort_device = devtag_get_device(device->machine, LUXOR_55_10828, CONKORT_TAG);
560   slow_t *conkort = get_safe_token_slow(conkort_device);
492   slow_t *conkort = get_safe_token_machine_slow(device->machine);
561493 
562494   conkort->data = data;
563495}
r3596r3597
579511 
580512   */
581513 
582   const device_config *conkort_device = devtag_get_device(device->machine, LUXOR_55_10828, CONKORT_TAG);
583   slow_t *conkort = get_safe_token_slow(conkort_device);
514   slow_t *conkort = get_safe_token_machine_slow(device->machine);
584515 
585516   return conkort->fdc_irq << 7;
586517}
r3596r3597
606537 
607538static Z80PIO_ON_ARDY_CHANGED( pio_ardy_w )
608539{
609   const device_config *conkort_device = devtag_get_device(device->machine, LUXOR_55_10828, CONKORT_TAG);
610   slow_t *conkort = get_safe_token_slow(conkort_device);
540   slow_t *conkort = get_safe_token_machine_slow(device->machine);
611541 
612542   conkort->pio_ardy = state;
613543}
r3596r3597
615545static Z80PIO_INTERFACE( pio_intf )
616546{
617547   NULL,                  /* CPU (cannot use from within device) */
618   XTAL_4MHz/2,            /* clock (get from main CPU) */
619   pio_interrupt,            /* callback when change interrupt status */
548   XTAL_4MHz/2,            /* chip clock */
549   pio_interrupt,            /* interrupt callback */
620550   pio_port_a_r,            /* port A read callback */
621551   pio_port_b_r,            /* port B read callback */
622552   pio_port_a_w,            /* port A write callback */
623553   pio_port_b_w,            /* port B write callback */
624   pio_ardy_w,               /* portA ready active callback */
625   NULL                  /* portB ready active callback */
554   pio_ardy_w,               /* port A ready callback */
555   NULL                  /* port B ready callback */
626556};
627557 
628558static const z80_daisy_chain slow_daisy_chain[] =
r3596r3597
633563 
634564/* Z80 DMA */
635565 
566/*
567 
568   DMA Transfer Programs
569   ---------------------
570 
571   C3 14 28 95 6B 02 8A CF 01 AF CF 87
572 
573   C3   reset
574   14   port A is memory, port A address increments
575   28   port B is I/O, port B address fixed
576   95   byte mode, port B starting address low follows, interrupt control byte follows
577   6B   port B starting address 0x006B (FDC DATA read)
578   02   interrupt at end of block
579   8A   ready active high
580   CF   load
581   01   transfer B->A
582   AF   disable interrupts
583   CF   load
584   87   enable DMA
585 
586   C3 14 28 95 7B 02 8A CF 05 AF CF 87
587 
588   C3   reset
589   14   port A is memory, port A address increments
590   28   port B is I/O, port B address fixed
591   95   byte mode, port B starting address low follows, interrupt control byte follows
592   7B   port B starting address 0x007B (FDC DATA write)
593   02   interrupt at end of block
594   8A   ready active high
595   CF   load
596   05   transfer A->B
597   AF   disable interrupts
598   CF   load
599   87   enable DMA
600 
601   C3 91 40 8A AB
602 
603   C3   reset
604   91   byte mode, interrupt control byte follows
605   40   interrupt on RDY
606   8A   _CE only, ready active high, stop on end of block
607   AB   enable interrupts
608 
609*/
610 
636611#define Z80DMA_CPUNUM 1
637612 
638static dma_irq_callback(const device_config *device, int state)
613static void dma_irq_callback(const device_config *device, int state)
639614{
640   cpunum_set_input_line(device->machine, Z80DMA_CPUNUM, INPUT_LINE_IRQ0, state);
615   fast_t *conkort = get_safe_token_machine_fast(device->machine);
616 
617   cpu_set_input_line(device->machine->cpu[conkort->cpunum], INPUT_LINE_IRQ0, state);
641618}
642619 
643static READ8_DEVICE_HANDLER( dma_read_byte )
620static READ8_DEVICE_HANDLER( dma_port_a_r )
644621{
645   UINT8 data;
622   fast_t *conkort = get_safe_token_machine_fast(device->machine);
623   const address_space *program = cpu_get_address_space(device->machine->cpu[conkort->cpunum], ADDRESS_SPACE_PROGRAM);
646624 
647   cpuintrf_push_context(Z80DMA_CPUNUM);
648   data = program_read_byte(offset);
649   cpuintrf_pop_context();
625   UINT8 data = 0xff;
650626 
627   cpu_push_context(device->machine->cpu[conkort->cpunum]);
628 
629   data = memory_read_byte_8le(program, offset);
630   
631   cpu_pop_context();
632 
651633   return data;
652634}
653635 
654static WRITE8_DEVICE_HANDLER( dma_write_byte )
636static WRITE8_DEVICE_HANDLER( dma_port_a_w )
655637{
656   cpuintrf_push_context(Z80DMA_CPUNUM);
657   program_write_byte(offset, data);
658   cpuintrf_pop_context();
638   fast_t *conkort = get_safe_token_machine_fast(device->machine);
639   const address_space *program = cpu_get_address_space(device->machine->cpu[conkort->cpunum], ADDRESS_SPACE_PROGRAM);
640 
641   cpu_push_context(device->machine->cpu[conkort->cpunum]);
642   
643   memory_write_byte_8le(program, offset, data);
644   
645   cpu_pop_context();
659646}
660647 
661static READ8_DEVICE_HANDLER( wd17xx_read_byte )
648static READ8_DEVICE_HANDLER( dma_port_b_r )
662649{
663   return wd17xx_data_r(device->machine, offset);
650   fast_t *conkort = get_safe_token_machine_fast(device->machine);
651   const address_space *io = cpu_get_address_space(device->machine->cpu[conkort->cpunum], ADDRESS_SPACE_IO);
652 
653   UINT8 data = 0xff;
654 
655   cpu_push_context(device->machine->cpu[conkort->cpunum]);
656 
657   data = memory_read_byte_8le(io, offset);
658 
659   cpu_pop_context();
660 
661   return data;
664662}
665663 
666static WRITE8_DEVICE_HANDLER( wd17xx_write_byte )
664static WRITE8_DEVICE_HANDLER( dma_port_b_w )
667665{
668   wd17xx_data_w(device->machine, offset, data);
666   fast_t *conkort = get_safe_token_machine_fast(device->machine);
667   const address_space *io = cpu_get_address_space(device->machine->cpu[conkort->cpunum], ADDRESS_SPACE_IO);
668 
669   cpu_push_context(device->machine->cpu[conkort->cpunum]);
670 
671   memory_write_byte_8le(io, offset, data);
672 
673   cpu_pop_context();
669674}
670675 
671676static const z80dma_interface dma_intf =
672677{
673   Z80DMA_CPUNUM,         /* cpunum to HALT */
674   XTAL_16MHz/4,         /* chip clock */
675   dma_read_byte,         /* memory read */
676   dma_write_byte,         /* memory write */
677   wd17xx_read_byte,      /* port A read */
678   wd17xx_write_byte,      /* port A write */
679   0,                  /* port B read */
680   0,                  /* port B write */
681   dma_irq_callback      /* interrupt callback */
678   Z80DMA_CPUNUM,      /* cpunum to HALT */
679   XTAL_16MHz/4,      /* chip clock */
680   dma_port_a_r,      /* memory read */
681   dma_port_a_w,      /* memory write */
682   dma_port_a_r,      /* port A read */
683   dma_port_a_w,      /* port A write */
684   dma_port_b_r,      /* port B read */
685   dma_port_b_w,      /* port B write */
686   dma_irq_callback   /* interrupt callback */
682687};
683688 
684689static const z80_daisy_chain fast_daisy_chain[] =
r3596r3597
691696 
692697static void slow_wd1791_callback(running_machine *machine, wd17xx_state_t state, void *param)
693698{
694   const device_config *device = devtag_get_device(machine, LUXOR_55_10828, CONKORT_TAG);
695   slow_t *conkort = get_safe_token_slow(device);
699   slow_t *conkort = get_safe_token_machine_slow(machine);
696700 
697701   switch(state)
698702   {
r3596r3597
713717 
714718static void fast_wd1793_callback(running_machine *machine, wd17xx_state_t state, void *param)
715719{
716//   const device_config *z80dma = devtag_get_device(machine, Z80DMA, CONKORT_Z80DMA_TAG);
720   fast_t *conkort = get_safe_token_machine_fast(machine);
717721 
718722   switch(state)
719723   {
r3596r3597
722726      case WD17XX_IRQ_SET:
723727         break;
724728      case WD17XX_DRQ_CLR:
725         //z80dma_rdy_w(z80dma, 0, 0);
729         z80dma_rdy_w(conkort->z80dma, 0, 0);
726730         break;
727731      case WD17XX_DRQ_SET:
728         //z80dma_rdy_w(z80dma, 0, 1);
732         z80dma_rdy_w(conkort->z80dma, 0, 1);
729733         break;
730734   }
731735}
r3596r3597
753757 
754758/* ROMs */
755759 
756ROM_START( l5510828 )
757   ROM_REGION( 0x10000, CONKORT_Z80_TAG, 0 )
758   ROM_LOAD( "mpi02.bin",    0x0000, 0x0800, CRC(2aac9296) SHA1(c01a62e7933186bdf7068d2e9a5bc36590544349) ) // ABC830 with MPI drives. Styrkort Artnr 5510760-01
760ROM_START( luxor_55_10828 )
761   ROM_REGION( 0x1000, "abc830", ROMREGION_LOADBYNAME )
762   ROM_LOAD( "mpi02.bin",    0x0000, 0x0800, CRC(2aac9296) SHA1(c01a62e7933186bdf7068d2e9a5bc36590544349) ) // MPI 51
763   ROM_LOAD( "basf6106.bin", 0x0800, 0x0800, NO_DUMP ) // BASF 6106
759764 
760   ROM_REGION( 0x800, "abc830", 0 )
761   ROM_LOAD( "mpi02.bin",    0x0000, 0x0800, CRC(2aac9296) SHA1(c01a62e7933186bdf7068d2e9a5bc36590544349) ) // ABC830 with MPI drives. Styrkort Artnr 5510760-01
762 
763   ROM_REGION( 0x1800, "abc832", 0 )
765   ROM_REGION( 0x1800, "abc832", ROMREGION_LOADBYNAME )
764766   ROM_LOAD( "micr1015.bin", 0x0000, 0x0800, CRC(a7bc05fa) SHA1(6ac3e202b7ce802c70d89728695f1cb52ac80307) ) // Micropolis 1015
765767   ROM_LOAD( "micr1115.bin", 0x0800, 0x0800, CRC(f2fc5ccc) SHA1(86d6baadf6bf1d07d0577dc1e092850b5ff6dd1b) ) // Micropolis 1115
766768   ROM_LOAD( "basf6118.bin", 0x1000, 0x0800, CRC(9ca1a1eb) SHA1(04973ad69de8da403739caaebe0b0f6757e4a6b1) ) // BASF 6118
767769 
768   ROM_REGION( 0x1000, "abc850", 0 )
769   ROM_LOAD( "rodi202.bin",  0x0000, 0x0800, CRC(337b4dcf) SHA1(791ebeb4521ddc11fb9742114018e161e1849bdf) ) // Rodime 202
770   ROM_LOAD( "basf6185.bin", 0x0800, 0x0800, CRC(06f8fe2e) SHA1(e81f2a47c854e0dbb096bee3428d79e63591059d) ) // BASF 6185
770   ROM_REGION( 0x1000, "abc838", ROMREGION_LOADBYNAME )
771   ROM_LOAD( "basf6104.bin", 0x0800, 0x0800, NO_DUMP ) // BASF 6104
772   ROM_LOAD( "basf6115.bin", 0x0800, 0x0800, NO_DUMP ) // BASF 6115
773ROM_END
771774 
772   ROM_REGION( 0x1000, "abc852", 0 )
775ROM_START( luxor_55_21046 )
776   ROM_REGION( 0x10000, "conkort", ROMREGION_LOADBYNAME )
777   ROM_LOAD( "6490318-07.bin", 0x0000, 0x2000, CRC(06ae1fe8) SHA1(ad1d9d0c192539af70cb95223263915a09693ef8) ) // PROM v1.07, Art N/O 6490318-07. Luxor Styrkort Art. N/O 55 21046-41. Date 1985-07-03
778//   ROM_LOAD( "fast108.bin",   0x2000, 0x2000, CRC(229764cb) SHA1(a2e2f6f49c31b827efc62f894de9a770b65d109d) ) // Luxor v1.08
779//   ROM_LOAD( "fast207.bin",   0x4000, 0x2000, CRC(86622f52) SHA1(61ad271de53152c1640c0b364fce46d1b0b4c7e2) ) // DIAB v2.07
780ROM_END
781 
782ROM_START( hdd_controller ) // TODO: remove this!
783   ROM_REGION( 0x1000, "abc850", ROMREGION_LOADBYNAME )
784   ROM_LOAD( "rodi202.bin",  0x0000, 0x0800, CRC(337b4dcf) SHA1(791ebeb4521ddc11fb9742114018e161e1849bdf) ) // Rodime RO202 (http://artofhacking.com/th99/h/txt/3699.txt)
785   ROM_LOAD( "basf6185.bin", 0x0800, 0x0800, CRC(06f8fe2e) SHA1(e81f2a47c854e0dbb096bee3428d79e63591059d) ) // BASF 6185 (http://bk0010.narod.ru/hardware_specs/h/txt/178.txt)
786 
787   ROM_REGION( 0x1000, "abc852", ROMREGION_LOADBYNAME )
773788   ROM_LOAD( "nec5126.bin",  0x0000, 0x1000, CRC(17c247e7) SHA1(7339738b87751655cb4d6414422593272fe72f5d) ) // NEC 5126
774789 
775   ROM_REGION( 0x800, "abc856", 0 )
790   ROM_REGION( 0x800, "abc856", ROMREGION_LOADBYNAME )
776791   ROM_LOAD( "micr1325.bin", 0x0000, 0x0800, CRC(084af409) SHA1(342b8e214a8c4c2b014604e53c45ef1bd1c69ea3) ) // Micropolis 1325
777792 
778   ROM_REGION( 0x1000, "xebec", 0 )
793   ROM_REGION( 0x1000, "xebec", ROMREGION_LOADBYNAME )
779794   ROM_LOAD( "st4038.bin",   0x0000, 0x0800, CRC(4c803b87) SHA1(1141bb51ad9200fc32d92a749460843dc6af8953) ) // Seagate ST4038
780795   ROM_LOAD( "st225.bin",    0x0800, 0x0800, CRC(c9f68f81) SHA1(7ff8b2a19f71fe0279ab3e5a0a5fffcb6030360c) ) // Seagate ST225
781796ROM_END
782797 
783ROM_START( l5521046 )
784   ROM_REGION( 0x10000, CONKORT_Z80_TAG, 0 )
785   ROM_LOAD( "fast108.bin",   0x0000, 0x2000, CRC(229764cb) SHA1(a2e2f6f49c31b827efc62f894de9a770b65d109d) ) // Luxor v1.08
786   ROM_LOAD( "6490318-07.bin", 0x0000, 0x2000, CRC(06ae1fe8) SHA1(ad1d9d0c192539af70cb95223263915a09693ef8) ) // PROM v1.07, Art N/O 6490318-07. Luxor Styrkort Art. N/O 55 21046-41. Date 1985-07-03
787   ROM_LOAD( "fast207.bin",   0x0000, 0x2000, CRC(86622f52) SHA1(61ad271de53152c1640c0b364fce46d1b0b4c7e2) ) // DIAB v2.07
788ROM_END
789 
790798/* Device Interface */
791799 
792800static DEVICE_START( luxor_55_10828 )
793801{
794802   slow_t *conkort = device->token;
795   char unique_tag[30];
796803   astring *tempstring = astring_alloc();
797804 
798805   /* validate arguments */
799 
800806   assert(device->machine != NULL);
801807   assert(device->tag != NULL);
802808   assert(strlen(device->tag) < 20);
803809 
804810   /* find our CPU */
805 
806811   astring_printf(tempstring, "%s:%s", device->tag, CONKORT_Z80_TAG);
807812   conkort->cpunum = mame_find_cpu_index(device->machine, astring_c(tempstring));
808813   astring_free(tempstring);
809814 
815   /* find devices */
816   conkort->z80pio = devtag_get_device(device->machine, Z80PIO, "conkort:3a"); // TODO hardcoded
817 
810818   /* initialize FDC */
811 
812819   wd17xx_init(device->machine, WD_TYPE_179X, slow_wd1791_callback, NULL); // FD1791-01
813820 
814821   /* register for state saving */
815822 
816   state_save_combine_module_and_tag(unique_tag, "conkort", device->tag);
817 
818823   return DEVICE_START_OK;
819824}
820825 
826static DEVICE_RESET( luxor_55_10828 )
827{
828   wd17xx_reset(device->machine);
829}
830 
821831static DEVICE_SET_INFO( luxor_55_10828 )
822832{
823833   switch (state)
r3596r3597
826836   }
827837}
828838 
829static DEVICE_RESET( luxor_55_10828 )
830{
831   wd17xx_reset(device->machine);
832}
833 
834839DEVICE_GET_INFO( luxor_55_10828 )
835840{
836841   switch (state)
837842   {
838843      /* --- the following bits of info are returned as 64-bit signed integers --- */
839      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
840      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
841      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(slow_t);            break;
844      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                    break;
845      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                     break;
846      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(slow_t);                           break;
842847 
843848      /* --- the following bits of info are returned as pointers --- */
844      case DEVINFO_PTR_ROM_REGION:               info->romregion = rom_l5510828;            break;
845      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = machine_config_luxor_55_10828; break;
849      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(luxor_55_10828);               break;
850      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_DRIVER_NAME(luxor_55_10828);   break;
846851 
847852      /* --- the following bits of info are returned as pointers to data or functions --- */
848      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(luxor_55_10828); break;
849      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(luxor_55_10828);   break;
850      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
851      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(luxor_55_10828); break;
852      case DEVINFO_FCT_CARD_SELECT:               info->f = (genf *)slow_card_select;         break;
853      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(luxor_55_10828);      break;
854      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(luxor_55_10828);         break;
855      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
856      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(luxor_55_10828);         break;
857      case DEVINFO_FCT_ABCBUS_CARD_SELECT:         info->f = (genf *)ABCBUS_CARD_SELECT_NAME(luxor_55_10828);   break;
853858 
854859      /* --- the following bits of info are returned as NULL-terminated strings --- */
855      case DEVINFO_STR_NAME:                     info->s = "Luxor 55 10828";               break;
856      case DEVINFO_STR_FAMILY:                  info->s = "Luxor ABC";                  break;
857      case DEVINFO_STR_VERSION:                  info->s = "1.0";                     break;
858      case DEVINFO_STR_SOURCE_FILE:               info->s = __FILE__;                     break;
859      case DEVINFO_STR_CREDITS:                  info->s = "Copyright the MESS Team";       break;
860      case DEVINFO_STR_NAME:                     info->s = "Luxor 55 10828-01";                        break;
861      case DEVINFO_STR_FAMILY:                  info->s = "Luxor ABC";                              break;
862      case DEVINFO_STR_VERSION:                  info->s = "1.0";                                 break;
863      case DEVINFO_STR_SOURCE_FILE:               info->s = __FILE__;                                 break;
864      case DEVINFO_STR_CREDITS:                  info->s = "Copyright the MESS Team";                   break;
860865   }
861866}
862867 
863868static DEVICE_START( luxor_55_21046 )
864869{
865870   fast_t *conkort = device->token;
866   char unique_tag[30];
867871   astring *tempstring = astring_alloc();
868872 
869873   /* validate arguments */
870 
871874   assert(device->machine != NULL);
872875   assert(device->tag != NULL);
873876   assert(strlen(device->tag) < 20);
874877 
875878   /* find our CPU */
876 
877879   astring_printf(tempstring, "%s:%s", device->tag, CONKORT_Z80_TAG);
878880   conkort->cpunum = mame_find_cpu_index(device->machine, astring_c(tempstring));
879881   astring_free(tempstring);
880882 
883   /* find devices */
884   conkort->z80dma = devtag_get_device(device->machine, Z80DMA, "conkort:z80dma"); // TODO hardcoded
885 
881886   /* initialize FDC */
882 
883887   wd17xx_init(device->machine, WD_TYPE_1793, fast_wd1793_callback, NULL); // FD1793-01
884888 
885889   /* register for state saving */
886890 
887   state_save_combine_module_and_tag(unique_tag, "conkort", device->tag);
888 
889891   return DEVICE_START_OK;
890892}
891893 
894static DEVICE_RESET( luxor_55_21046 )
895{
896   /* reset the FDC */
897   wd17xx_reset(device->machine);
898}
899 
892900static DEVICE_SET_INFO( luxor_55_21046 )
893901{
894902   switch (state)
r3596r3597
897905   }
898906}
899907 
900static DEVICE_RESET( luxor_55_21046 )
901{
902   wd17xx_reset(device->machine);
903}
904 
905908DEVICE_GET_INFO( luxor_55_21046 )
906909{
907910   switch (state)
908911   {
909912      /* --- the following bits of info are returned as 64-bit signed integers --- */
910      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
911      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
912      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(slow_t);            break;
913      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                    break;
914      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                     break;
915      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(fast_t);                           break;
913916 
914917      /* --- the following bits of info are returned as pointers --- */
915      case DEVINFO_PTR_ROM_REGION:               info->romregion = rom_l5521046;            break;
916      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = machine_config_luxor_55_21046; break;
918      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(luxor_55_21046);               break;
919      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_DRIVER_NAME(luxor_55_21046);   break;
917920 
918921      /* --- the following bits of info are returned as pointers to data or functions --- */
919      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(luxor_55_21046); break;
920      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(luxor_55_21046); break;
921      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
922      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(luxor_55_21046); break;
923      case DEVINFO_FCT_CARD_SELECT:               info->f = (genf *)fast_card_select;         break;
922      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(luxor_55_21046);      break;
923      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(luxor_55_21046);         break;
924      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
925      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(luxor_55_21046);         break;
926      case DEVINFO_FCT_ABCBUS_CARD_SELECT:         info->f = (genf *)ABCBUS_CARD_SELECT_NAME(luxor_55_21046);   break;
924927 
925928      /* --- the following bits of info are returned as NULL-terminated strings --- */
926      case DEVINFO_STR_NAME:                     info->s = "Luxor Conkort 55 21046";         break;
927      case DEVINFO_STR_FAMILY:                  info->s = "Luxor ABC";                  break;
928      case DEVINFO_STR_VERSION:                  info->s = "1.0";                     break;
929      case DEVINFO_STR_SOURCE_FILE:               info->s = __FILE__;                     break;
930      case DEVINFO_STR_CREDITS:                  info->s = "Copyright the MESS Team";       break;
929      case DEVINFO_STR_NAME:                     info->s = "Luxor Conkort 55 21046-xx";                  break;
930      case DEVINFO_STR_FAMILY:                  info->s = "Luxor ABC";                              break;
931      case DEVINFO_STR_VERSION:                  info->s = "1.0";                                 break;
932      case DEVINFO_STR_SOURCE_FILE:               info->s = __FILE__;                                 break;
933      case DEVINFO_STR_CREDITS:                  info->s = "Copyright the MESS Team";                   break;
931934   }
932935}
src/mess/machine/abcbus.c
r3596r3597
2626      (*tailptr)->device = devtag_get_device(machine, daisy->devtype, device_inherit_tag(tempstring, cputag, daisy->devname));
2727      if ((*tailptr)->device == NULL)
2828         fatalerror("Unable to locate device '%s'", daisy->devname);
29      (*tailptr)->card_select = (abcbus_card_select)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_CARD_SELECT);
29      (*tailptr)->card_select = (abcbus_card_select)device_get_info_fct((*tailptr)->device, DEVINFO_FCT_ABCBUS_CARD_SELECT);
3030      tailptr = &(*tailptr)->next;
3131   }
3232   
r3596r3597
5252   for ( ; daisy != NULL; daisy = daisy->next)
5353      device_reset(daisy->device);
5454
55   /* uninstall I/O handlers */
56   memory_install_readwrite8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_INP, ABCBUS_OUT, 0x18, 0, SMH_NOP, SMH_NOP);
57   memory_install_read8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_STAT, ABCBUS_STAT, 0x18, 0, SMH_NOP);
58   memory_install_write8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C1, ABCBUS_C1, 0x18, 0, SMH_NOP);
59   memory_install_write8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C2, ABCBUS_C2, 0x18, 0, SMH_NOP);
60   memory_install_write8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C3, ABCBUS_C3, 0x18, 0, SMH_NOP);
61   memory_install_write8_handler(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), ABCBUS_C4, ABCBUS_C4, 0x18, 0, SMH_NOP);
62
5563   return 0xff;
5664}
5765
src/mess/machine/abcbus.h
r3596r3597
4949   IN 1   _STAT   status in
5050   IN 7   RST      reset
5151
52
53   ABCBUS_CHANNEL_ABC850_852_856 = 36,
54   ABCBUS_CHANNEL_ABC832_834_850 = 44,
55   ABCBUS_CHANNEL_ABC830 = 45,
56   ABCBUS_CHANNEL_ABC838 = 46
57
5258*/
5359
5460/*
r3596r3597
7480#ifndef __ABCBUS__
7581#define __ABCBUS__
7682
77enum
78{
79   DEVINFO_FCT_CARD_SELECT = DEVINFO_FCT_DEVICE_SPECIFIC,   /* R/O: abcbus_daisy_cs */
80};
83#define DEVINFO_FCT_ABCBUS_CARD_SELECT   DEVINFO_FCT_DEVICE_SPECIFIC
8184
8285enum
8386{
84   ABCBUS_CHANNEL_ABC850_852_856 = 36,
85   ABCBUS_CHANNEL_ABC832_834_850 = 44,
86   ABCBUS_CHANNEL_ABC830 = 45,
87   ABCBUS_CHANNEL_ABC838 = 46
88};
89
90enum
91{
9287   ABCBUS_OUT = 0,
9388   ABCBUS_INP = 0,
9489   ABCBUS_CS = 1,
r3596r3597
10095   ABCBUS_RST = 7
10196};
10297
98/* macros */
99#define ABCBUS_CARD_SELECT_NAME(name)   abcbus_card_select_##name
100#define ABCBUS_CARD_SELECT(name)      void ABCBUS_CARD_SELECT_NAME(name)(const device_config *device, UINT8 data)
101
103102/* per-device callback functions */
104103typedef void (*abcbus_card_select)(const device_config *device, UINT8 data);
105104
r3596r3597
107106typedef struct _abcbus_daisy_chain abcbus_daisy_chain;
108107struct _abcbus_daisy_chain
109108{
110   device_type      devtype;               /* type of device */
111   const char *   devname;               /* name of the device */
109   device_type      devtype;   /* type of device */
110   const char      *devname;   /* name of the device */
112111};
113112#define ABCBUS_CONFIG(name) const abcbus_daisy_chain (name)[] =
114113
src/mess/machine/e0516.c
r3596r3597
188188static DEVICE_START( e0516 )
189189{
190190   e0516_t *e0516 = get_safe_token(device);
191   char unique_tag[30];
192191
193192   /* validate arguments */
194193   assert(device != NULL);
r3596r3597
205204   timer_adjust_periodic(e0516->clock_timer, attotime_zero, 0, ATTOTIME_IN_HZ(e0516->intf->clock / 32768));
206205
207206   /* register for state saving */
208   state_save_combine_module_and_tag(unique_tag, "E0516", device->tag);
207   state_save_register_item("e0516", device->tag, 0, e0516->cs);
208   state_save_register_item("e0516", device->tag, 0, e0516->data_latch);
209   state_save_register_item("e0516", device->tag, 0, e0516->reg_latch);
210   state_save_register_item("e0516", device->tag, 0, e0516->read_write);
211   state_save_register_item("e0516", device->tag, 0, e0516->state);
212   state_save_register_item("e0516", device->tag, 0, e0516->bits);
213   state_save_register_item("e0516", device->tag, 0, e0516->dio);
209214
210   state_save_register_item(unique_tag, 0, e0516->cs);
211   state_save_register_item(unique_tag, 0, e0516->data_latch);
212   state_save_register_item(unique_tag, 0, e0516->reg_latch);
213   state_save_register_item(unique_tag, 0, e0516->read_write);
214   state_save_register_item(unique_tag, 0, e0516->state);
215   state_save_register_item(unique_tag, 0, e0516->bits);
216   state_save_register_item(unique_tag, 0, e0516->dio);
217
218   state_save_register_item_array(unique_tag, 0, e0516->reg);
215   state_save_register_item_array("e0516", device->tag, 0, e0516->reg);
219216   return DEVICE_START_OK;
220217}
221218
src/mess/machine/abc77.c
r3596r3597
4848{
4949   abc77_t *abc77 = get_safe_token(device);
5050
51   cpunum_set_input_line(device->machine, abc77->cpunum, MCS48_INPUT_IRQ, level ? CLEAR_LINE : ASSERT_LINE);
51   cpu_set_input_line(device->machine->cpu[abc77->cpunum], MCS48_INPUT_IRQ, level ? CLEAR_LINE : ASSERT_LINE);
5252}
5353
5454static TIMER_DEVICE_CALLBACK( clock_tick )
r3596r3597
6464   const device_config *device = ptr;
6565   abc77_t *abc77 = get_safe_token(device);
6666
67   cpunum_set_input_line(device->machine, abc77->cpunum, INPUT_LINE_RESET, CLEAR_LINE);
67   cpu_set_input_line(device->machine->cpu[abc77->cpunum], INPUT_LINE_RESET, CLEAR_LINE);
6868}
6969
7070void abc77_reset_w(const device_config *device, int level)
r3596r3597
7777      int t = 1.1 * RES_K(100) * CAP_N(100) * 1000; // t = 1.1 * R1 * C1
7878      int ea = BIT(input_port_read(device->machine, "ABC77_DSW"), 7);
7979
80      cpunum_set_input_line(device->machine, abc77->cpunum, INPUT_LINE_RESET, ASSERT_LINE);
80      cpu_set_input_line(device->machine->cpu[abc77->cpunum], INPUT_LINE_RESET, ASSERT_LINE);
8181      timer_adjust_oneshot(abc77->reset_timer, ATTOTIME_IN_MSEC(t), 0);
8282     
83      cpunum_set_input_line(device->machine, abc77->cpunum, MCS48_INPUT_EA, ea ? CLEAR_LINE : ASSERT_LINE);
83      cpu_set_input_line(device->machine->cpu[abc77->cpunum], MCS48_INPUT_EA, ea ? CLEAR_LINE : ASSERT_LINE);
8484   }
8585
8686   abc77->reset = level;
r3596r3597
8888
8989static READ8_HANDLER( abc77_clock_r )
9090{
91   const device_config *device = devtag_get_device(machine, ABC77, ABC77_TAG);
91   const device_config *device = devtag_get_device(space->machine, ABC77, ABC77_TAG);
9292   abc77_t *abc77 = get_safe_token(device);
9393
9494   return abc77->clock;
r3596r3597
9696
9797static READ8_HANDLER( abc77_data_r )
9898{
99   const device_config *device = devtag_get_device(machine, ABC77, ABC77_TAG);
99   const device_config *device = devtag_get_device(space->machine, ABC77, ABC77_TAG);
100100   abc77_t *abc77 = get_safe_token(device);
101101
102102   static const char *keynames[] = { "ABC77_X0", "ABC77_X1", "ABC77_X2", "ABC77_X3", "ABC77_X4", "ABC77_X5", "ABC77_X6", "ABC77_X7", "ABC77_X8", "ABC77_X9", "ABC77_X10", "ABC77_X11" };
r3596r3597
106106
107107static WRITE8_HANDLER( abc77_data_w )
108108{
109   const device_config *device = devtag_get_device(machine, ABC77, ABC77_TAG);
109   const device_config *device = devtag_get_device(space->machine, ABC77, ABC77_TAG);
110110   abc77_t *abc77 = get_safe_token(device);
111111
112112   abc77->keylatch = data & 0x0f;
r3596r3597
117117   }
118118
119119   /* beep */
120   discrete_sound_w(device->machine, NODE_01, BIT(data, 4));
120   discrete_sound_w(space, NODE_01, BIT(data, 4));
121121
122122   /* transmit data */
123123   abc77->intf->txd_w(device, BIT(data, 5));
r3596r3597
318318static DEVICE_START( abc77 )
319319{
320320   abc77_t *abc77 = device->token;
321   char unique_tag[30];
322321   astring *tempstring = astring_alloc();
323322
324323   /* validate arguments */
r3596r3597
343342
344343   /* register for state saving */
345344
346   state_save_combine_module_and_tag(unique_tag, "ABC77", device->tag);
345   state_save_register_item("abc77", device->tag, 0, abc77->keylatch);
346   state_save_register_item("abc77", device->tag, 0, abc77->clock);
347   state_save_register_item("abc77", device->tag, 0, abc77->hys);
348   state_save_register_item("abc77", device->tag, 0, abc77->reset);
347349
348   state_save_register_item(unique_tag, 0, abc77->keylatch);
349   state_save_register_item(unique_tag, 0, abc77->clock);
350   state_save_register_item(unique_tag, 0, abc77->hys);
351   state_save_register_item(unique_tag, 0, abc77->reset);
352
353350   return DEVICE_START_OK;
354351}
355352
src/mess/mess.mak
r3596r3597
377377   $(MESSOBJ)/homelab.a \
378378   $(MESSOBJ)/irisha.a \
379379   $(MESSOBJ)/kramermc.a \
380   $(MESSOBJ)/luxor.a \
380381   $(MESSOBJ)/mikro80.a \
381382   $(MESSOBJ)/mk2.a \
382383   $(MESSOBJ)/ondra.a \
r3596r3597
436437#   $(MESSOBJ)/jupiter.a \
437438#   $(MESSOBJ)/kaypro.a \
438439#   $(MESSOBJ)/kim1.a \
439#   $(MESSOBJ)/luxor.a \
440440#   $(MESSOBJ)/lviv.a \
441441#   $(MESSOBJ)/lynx.a \
442442#   $(MESSOBJ)/magnavox.a \
src/mess/drivers/abc80.c
r3596r3597
9393
9494static const device_config *cassette_device_image(running_machine *machine)
9595{
96   return device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" );
96   return devtag_get_device(machine, CASSETTE, "cassette");
9797}
9898
9999/* Read/Write Handlers */
r3596r3597
231231
232232static ADDRESS_MAP_START( abc80_io_map, ADDRESS_SPACE_IO, 8 )
233233   ADDRESS_MAP_UNMAP_HIGH
234   ADDRESS_MAP_GLOBAL_MASK(0xff)
234   ADDRESS_MAP_GLOBAL_MASK(0x17)
235235   AM_RANGE(0x01, 0x01) AM_WRITE(abcbus_channel_w)
236236   AM_RANGE(0x06, 0x06) AM_WRITE(abc80_sound_w)
237237   AM_RANGE(0x07, 0x07) AM_READ(abcbus_reset_r)
238   AM_RANGE(0x38, 0x3b) AM_DEVREADWRITE(Z80PIO, Z80PIO_TAG, z80pio_alt_r, z80pio_alt_w)
238   AM_RANGE(0x10, 0x13) AM_MIRROR(0x04) AM_DEVREADWRITE(Z80PIO, Z80PIO_TAG, z80pio_alt_r, z80pio_alt_w)
239239ADDRESS_MAP_END
240240
241241/* Input Ports */
r3596r3597
348348
349349static INTERRUPT_GEN( abc80_nmi_interrupt )
350350{
351   cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE);
351   cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE);
352352}
353353
354354/* Z80 PIO */
r3596r3597
365365
366366static Z80PIO_ON_INT_CHANGED( abc80_pio_interrupt )
367367{
368   cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, state);
368   cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_IRQ0, state);
369369}
370370
371371static READ8_DEVICE_HANDLER( abc80_pio_port_a_r )
src/mess/drivers/abc80x.c
r3596r3597
8787
8888static const device_config *cassette_device_image(running_machine *machine)
8989{
90   return device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" );
90   return devtag_get_device(machine, CASSETTE, "cassette");
9191}
9292
9393/* Discrete Sound */
r3596r3597
268268         //logerror("%04x-%04x: Video RAM %04x (32K)\n", start_addr, end_addr, videoram_offset);
269269
270270         memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), start_addr, end_addr, 0, 0, SMH_BANK(bank), SMH_BANK(bank));
271         memory_configure_bank(bank, 1, 1, state->videoram + videoram_offset, 0);
272         memory_set_bank(bank, 1);
271         memory_configure_bank(machine, bank, 1, 1, state->videoram + videoram_offset, 0);
272         memory_set_bank(machine, bank, 1);
273273      }
274274
275275      for (bank = 9; bank <= 16; bank++)
r3596r3597
282282         //logerror("%04x-%04x: Work RAM (32K)\n", start_addr, end_addr);
283283
284284         memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), start_addr, end_addr, 0, 0, SMH_BANK(bank), SMH_BANK(bank));
285         memory_set_bank(bank, 0);
285         memory_set_bank(machine, bank, 0);
286286      }
287287   }
288288   else
r3596r3597
302302            //logerror("%04x-%04x: Video RAM %04x (4K)\n", start_addr, end_addr, videoram_offset);
303303
304304            memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), start_addr, end_addr, 0, 0, SMH_BANK(bank), SMH_BANK(bank));
305            memory_configure_bank(bank, 1, 1, state->videoram + videoram_offset, 0);
306            memory_set_bank(bank, 1);
305            memory_configure_bank(machine, bank, 1, 1, state->videoram + videoram_offset, 0);
306            memory_set_bank(machine, bank, 1);
307307         }
308308         else
309309         {
r3596r3597
316316               //logerror("%04x-%04x: ROM (4K)\n", start_addr, end_addr);
317317
318318               memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), start_addr, end_addr, 0, 0, SMH_BANK(bank), SMH_UNMAP);
319               memory_set_bank(bank, 0);
319               memory_set_bank(machine, bank, 0);
320320               break;
321321
322322            case 8:
r3596r3597
325325
326326               memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x7000, 0x77ff, 0, 0, SMH_BANK(bank), SMH_UNMAP);
327327               memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x7800, 0x7fff, 0, 0, abc806_charram_r, abc806_charram_w);
328               memory_set_bank(bank, 0);
328               memory_set_bank(machine, bank, 0);
329329               break;
330330
331331            default:
r3596r3597
333333               //logerror("%04x-%04x: Work RAM (4K)\n", start_addr, end_addr);
334334
335335               memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), start_addr, end_addr, 0, 0, SMH_BANK(bank), SMH_BANK(bank));
336               memory_set_bank(bank, 0);
336               memory_set_bank(machine, bank, 0);
337337               break;
338338            }
339339         }
r3596r3597
366366            memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), start_addr, end_addr, 0, 0, SMH_BANK(bank), SMH_BANK(bank));
367367         }
368368
369         memory_configure_bank(bank, 1, 1, state->videoram + videoram_offset, 0);
370         memory_set_bank(bank, 1);
369         memory_configure_bank(machine, bank, 1, 1, state->videoram + videoram_offset, 0);
370         memory_set_bank(machine, bank, 1);
371371      }
372372   }
373373}
374374
375375static READ8_HANDLER( abc806_mai_r )
376376{
377   abc806_state *state = machine->driver_data;
377   abc806_state *state = space->machine->driver_data;
378378
379379   int bank = offset >> 12;
380380
r3596r3597
398398
399399   */
400400
401   abc806_state *state = machine->driver_data;
401   abc806_state *state = space->machine->driver_data;
402402
403403   int bank = offset >> 12;
404404
405405   state->map[bank] = data;
406406
407   abc806_bankswitch(machine);
407   abc806_bankswitch(space->machine);
408408}
409409
410410/* Z80 SIO/2 */
r3596r3597
449449
450450static READ8_HANDLER( abc800_pling_r )
451451{
452   abc800_state *state = machine->driver_data;
452   abc800_state *state = space->machine->driver_data;
453453
454454   state->pling = !state->pling;
455455
456   discrete_sound_w(machine, NODE_01, state->pling);
456   discrete_sound_w(space, NODE_01, state->pling);
457457
458458   return 0xff;
459459}
460460
461461static READ8_HANDLER( abc802_pling_r )
462462{
463   abc802_state *state = machine->driver_data;
463   abc802_state *state = space->machine->driver_data;
464464
465465   state->pling = !state->pling;
466466
467   discrete_sound_w(machine, NODE_01, state->pling);
467   discrete_sound_w(space, NODE_01, state->pling);
468468
469469   return 0xff;
470470}
r3596r3597
785785
786786static void ctc_interrupt(const device_config *device, int state)
787787{
788   cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, state);
788   cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_IRQ0, state);
789789}
790790
791791static WRITE8_DEVICE_HANDLER( ctc_z0_w )
r3596r3597
854854
855855static void sio_interrupt(const device_config *device, int state)
856856{
857   cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, state);
857   cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_IRQ0, state);
858858}
859859
860860static WRITE8_DEVICE_HANDLER( sio_dtr_w )
r3596r3597
900900
901901static Z80DART_ON_INT_CHANGED( dart_interrupt )
902902{
903   cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, state);
903   cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_IRQ0, state);
904904}
905905
906906static Z80DART_RXD_READ( abc800_dart_rxd_r )
r3596r3597
11931193
11941194   for (bank = 1; bank <= 16; bank++)
11951195   {
1196      memory_configure_bank(bank, 0, 1, mem + (0x1000 * (bank - 1)), 0);
1197      memory_configure_bank(bank, 1, 1, state->videoram, 0);
1198      memory_set_bank(bank, 0);
1196      memory_configure_bank(machine, bank, 0, 1, mem + (0x1000 * (bank - 1)), 0);
1197      memory_configure_bank(machine, bank, 1, 1, state->videoram, 0);
1198      memory_set_bank(machine, bank, 0);
11991199   }
12001200
12011201   /* register for state saving */
r3596r3597
12171217
12181218   for (bank = 1; bank <= 16; bank++)
12191219   {
1220      memory_set_bank(bank, 0);
1220      memory_set_bank(machine, bank, 0);
12211221   }
12221222
12231223   abc806_bankswitch(machine);
r3596r3597
16641664
16651665/* Driver Initialization */
16661666
1667static OPBASE_HANDLER( abc800_opbase_handler )
1667static DIRECT_UPDATE_HANDLER( abc800_direct_update_handler )
16681668{
1669   abc800_state *state = machine->driver_data;
1669   abc800_state *state = space->machine->driver_data;
16701670
16711671   if (address >= 0x7800 && address < 0x8000)
16721672   {
1673      opbase->rom = opbase->ram = memory_region(machine, Z80_TAG);
1673      direct->raw = direct->decrypted = memory_region(space->machine, Z80_TAG);
16741674
16751675      if (!state->fetch_charram)
16761676      {
16771677         state->fetch_charram = 1;
1678         abc800_bankswitch(machine);
1678         abc800_bankswitch(space->machine);
16791679      }
16801680
16811681      return ~0;
r3596r3597
16841684   if (state->fetch_charram)
16851685   {
16861686      state->fetch_charram = 0;
1687      abc800_bankswitch(machine);
1687      abc800_bankswitch(space->machine);
16881688   }
16891689
16901690   return address;
16911691}
16921692
1693static OPBASE_HANDLER( abc802_opbase_handler )
1693static DIRECT_UPDATE_HANDLER( abc802_direct_update_handler )
16941694{
1695   abc802_state *state = machine->driver_data;
1695   abc802_state *state = space->machine->driver_data;
16961696
16971697   if (state->lrs)
16981698   {
16991699      if (address >= 0x7800 && address < 0x8000)
17001700      {
1701         opbase->rom = opbase->ram = memory_region(machine, Z80_TAG);
1701         direct->raw = direct->decrypted = memory_region(space->machine, Z80_TAG);
17021702         return ~0;
17031703      }
17041704   }
17051705   else
17061706   {
1707      opbase->rom = opbase->ram = mess_ram;
1707      direct->raw = direct->decrypted = mess_ram;
17081708      return ~0;
17091709   }
17101710
17111711   return address;
17121712}
17131713
1714static OPBASE_HANDLER( abc806_opbase_handler )
1714static DIRECT_UPDATE_HANDLER( abc806_direct_update_handler )
17151715{
1716   abc806_state *state = machine->driver_data;
1716   abc806_state *state = space->machine->driver_data;
17171717
17181718   if (address >= 0x7800 && address < 0x8000)
17191719   {
1720      opbase->rom = opbase->ram = memory_region(machine, Z80_TAG);
1720      direct->raw = direct->decrypted = memory_region(space->machine, Z80_TAG);
17211721
17221722      if (!state->fetch_charram)
17231723      {
17241724         state->fetch_charram = 1;
1725         abc806_bankswitch(machine);
1725         abc806_bankswitch(space->machine);
17261726      }
17271727
17281728      return ~0;
r3596r3597
17311731   if (state->fetch_charram)
17321732   {
17331733      state->fetch_charram = 0;
1734      abc806_bankswitch(machine);
1734      abc806_bankswitch(space->machine);
17351735   }
17361736
17371737   return address;
r3596r3597
17391739
17401740static DRIVER_INIT( abc800 )
17411741{
1742   memory_set_opbase_handler(0, abc800_opbase_handler);
1742   memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), abc800_direct_update_handler);
17431743}
17441744
17451745static DRIVER_INIT( abc802 )
17461746{
1747   memory_set_opbase_handler(0, abc802_opbase_handler);
1747   memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), abc802_direct_update_handler);
17481748}
17491749
17501750static DRIVER_INIT( abc806 )
17511751{
1752   memory_set_opbase_handler(0, abc806_opbase_handler);
1752   memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), abc806_direct_update_handler);
17531753}
17541754
17551755/* System Drivers */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team