Previous 15994 Revisions Next

r3443 Sunday 12th October, 2008 at 20:44:29 UTC by Curt Coder
[SUPER80] Fixed Z80PIO regression (bug #1701).
[src/emu/machine]z80pio.c
[src/mess/drivers]super80.c

src/emu/machine/z80pio.c
r3442r3443
179179      }
180180   }
181181
182   if (z80pio->mode[channel] == PIO_MODE_BIDIRECTIONAL)
183   {
184      /* mask out output bits */
185      data &= z80pio->ddr[channel];
186   }
187
188182   //if (LOG) logerror("Z80PIO Port %c Read Data %02x\n", 'A' + channel, data);
189183
190184   z80pio->input[channel] = data;
r3442r3443
195189   z80pio_t *z80pio = get_safe_token(device);
196190   UINT8 data = z80pio->output[channel];
197191
198   switch (z80pio->mode[channel])
199   {
200   case PIO_MODE_BIDIRECTIONAL:
201      /* mask out input bits */
202      data &= ~z80pio->ddr[channel];
203      break;
204   
205   default:
206      break;
207   }
208
209192   if (channel == PIO_PORT_A)
210193   {
211194      if (z80pio->intf->port_a_w)
r3442r3443
276259
277260READ8_DEVICE_HANDLER( z80pio_c_r )
278261{
279   return z80pio_d_r(device, offset);
262   return 0;
280263}
281264
282265WRITE8_DEVICE_HANDLER( z80pio_c_w )
r3442r3443
395378      break;
396379
397380   case PIO_MODE_CONTROL:
398      data = z80pio->input[channel] | (z80pio->output[channel] & (~z80pio->ddr[channel]));
381      data = (z80pio->input[channel] & z80pio->ddr[channel]) | (z80pio->output[channel] & (~z80pio->ddr[channel]));
399382      break;
400383   }
401384
r3442r3443
474457         /* input data */
475458         z80pio_port_read(device, channel);
476459
477         if (z80pio->enable[channel] & PIO_IRQ_HIGH_LOW)
478         {
479            /* active polarity is high */
480            data = z80pio->input[channel] & ~z80pio->mask[channel];
481         }
482         else
483         {
484            /* active polarity is low */
485            data = ~z80pio->input[channel] & ~z80pio->mask[channel];
486         }
460         data = z80pio->input[channel] & z80pio->ddr[channel];
461 
462         /* keep only relevant bits */
463         data &= ~z80pio->mask[channel];
487464
465         /* if active low, invert the bits */
466         if (!(z80pio->enable[channel] & PIO_IRQ_HIGH_LOW))
467            data ^= z80pio->mask[channel];
468
469         /* if AND logic, interrupt if all bits are set */
488470         if (z80pio->enable[channel] & PIO_IRQ_AND_OR)
489         {
490            /* logical operation is AND */
491            match = (data == ~z80pio->mask[channel]);
492         }
471            match = (data == z80pio->mask[channel]);
472         /* otherwise, interrupt if at least one bit is set */
493473         else
494         {
495            /* logical operation is OR */
496474            match = (data != 0);
497         }
498475
499476         if (match)
500477         {
r3442r3443
627604   int state = 0;
628605   int channel;
629606
630   logerror("Z80PIO IRQ STATE\n");
607   if (LOG) logerror("Z80PIO IRQ STATE\n");
631608
632609   /* loop over all channels */
633610   for (channel = PIO_PORT_A; channel < PIO_PORT_COUNT; channel++)
r3442r3443
650627   z80pio_t *z80pio = get_safe_token( device );
651628   int channel;
652629
653   logerror("Z80PIO IRQ ACK\n");
630   if (LOG) logerror("Z80PIO IRQ ACK\n");
654631
655632   /* loop over all channels */
656633   for (channel = PIO_PORT_A; channel < PIO_PORT_COUNT; channel++)
r3442r3443
676653   z80pio_t *z80pio = get_safe_token( device );
677654   int channel;
678655
679   logerror("Z80PIO IRQ RETI\n");
656   if (LOG) logerror("Z80PIO IRQ RETI\n");
680657
681658   /* loop over all channels */
682659   for (channel = PIO_PORT_A; channel < PIO_PORT_COUNT; channel++)
src/mess/drivers/super80.c
r3442r3443
342342
343343/**************************** PIO ******************************************************************************/
344344
345static UINT8 out_f8;
345static UINT8 keylatch;
346346
347347static Z80PIO_ON_INT_CHANGED( pio_interrupt )
348348{
r3442r3443
351351
352352static WRITE8_DEVICE_HANDLER( pio_port_a_w )
353353{
354   out_f8 = data;
354   keylatch = data;
355355};
356356
357357static READ8_DEVICE_HANDLER( pio_port_b_r )
358358{
359   UINT8 i, mask=1, in_fa=255;
360359   static const char *keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" };
361360
362   for ( i=0; i < 8;i++)
361   int bit;
362   UINT8 data = 0xff;
363
364   for (bit = 0; bit < 8; bit++)
363365   {
364      if (!(out_f8 & mask)) in_fa &= input_port_read(device->machine, keynames[i]);
365      mask<<=1;
366      if (!BIT(keylatch, bit)) data &= input_port_read(device->machine, keynames[bit]);
366367   }
367368
368   return in_fa;
369   return data;
369370};
370371
371372static Z80PIO_INTERFACE( pio_intf )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team