Previous 199869 Revisions Next

r36969 Sunday 5th April, 2015 at 21:42:28 UTC by Curt Coder
z80pio: Fixed bit control mode interrupt handling. [Curt Coder]
[src/emu/machine]z80pio.c z80pio.h

trunk/src/emu/machine/z80pio.c
r245480r245481
99
1010***************************************************************************/
1111
12/*
13
14   TODO:
15
16   - if port A is bidirectional, port B does not issue interrupts in bit mode
17
18*/
19
1220#include "emu.h"
1321#include "z80pio.h"
1422#include "cpu/z80/z80daisy.h"
r245480r245481
150158
151159      if (port.m_ip)
152160      {
153         if (LOG) logerror("Z80PIO '%s' Interrupt Acknowledge\n", tag());
161         if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Acknowledge\n", tag(), 'A' + index);
154162
155163         // clear interrupt pending flag
156164         port.m_ip = false;
r245480r245481
183191
184192      if (port.m_ius)
185193      {
186         if (LOG) logerror("Z80PIO '%s' Return from Interrupt\n", tag());
194         if (LOG) logerror("Z80PIO '%s' Port %c Return from Interrupt\n", tag(), 'A' + index);
187195
188196         // clear interrupt under service flag
189197         port.m_ius = false;
r245480r245481
266274void z80pio_device::check_interrupts()
267275{
268276   int state = CLEAR_LINE;
277   bool ius = (m_port[PORT_A].m_ius || m_port[PORT_B].m_ius);
269278
270279   for (int index = PORT_A; index < PORT_COUNT; index++)
271      if (m_port[index].interrupt_signalled())
280   {
281      if (LOG) logerror("Z80PIO '%s' Port %c IE %s IP %s IUS %s\n", tag(), 'A' + index, m_port[index].m_ie ? "1":"0", m_port[index].m_ip ? "1":"0", m_port[index].m_ius ? "1":"0");
282     
283      if (!ius && m_port[index].m_ie && m_port[index].m_ip)
284      {
272285         state = ASSERT_LINE;
286      }
287   }
273288
289   if (LOG) logerror("Z80PIO '%s' INT %u\n", tag(), state);
290
274291   m_out_int_cb(state);
275292}
276293
r245480r245481
284301//  pio_port - constructor
285302//-------------------------------------------------
286303
287z80pio_device::pio_port::pio_port()
288   : m_device(NULL),
289      m_index(0),
290      m_mode(0),
291      m_next_control_word(0),
292      m_input(0),
293      m_output(0),
294      m_ior(0),
295      m_rdy(false),
296      m_stb(false),
297      m_ie(false),
298      m_ip(false),
299      m_ius(false),
300      m_icw(0),
301      m_vector(0),
302      m_mask(0),
303      m_match(false)
304z80pio_device::pio_port::pio_port() :
305   m_device(NULL),
306   m_index(0),
307   m_mode(0),
308   m_next_control_word(0),
309   m_input(0),
310   m_output(0),
311   m_ior(0),
312   m_rdy(false),
313   m_stb(false),
314   m_ie(false),
315   m_ip(false),
316   m_ius(false),
317   m_icw(0),
318   m_vector(0),
319   m_mask(0),
320   m_match(false)
304321{
305322}
306323
r245480r245481
363380
364381
365382//-------------------------------------------------
366//  interrupt_signalled - return true if an
367//  interrupt is signalled
368//-------------------------------------------------
369
370bool z80pio_device::pio_port::interrupt_signalled()
371{
372   if (m_mode == MODE_BIT_CONTROL)
373   {
374      // fetch input data (ignore output lines)
375      UINT8 data = (m_input & m_ior) | (m_output & ~m_ior);
376      UINT8 mask = ~m_mask;
377      bool match = false;
378
379      data &= mask;
380
381      if ((m_icw & 0x60) == 0 && data != mask) match = true;
382      else if ((m_icw & 0x60) == 0x20 && data != 0) match = true;
383      else if ((m_icw & 0x60) == 0x40 && data == 0) match = true;
384      else if ((m_icw & 0x60) == 0x60 && data == mask) match = true;
385
386      if (!m_match && match)
387      {
388         // trigger interrupt
389         m_ip = true;
390         if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Pending\n", m_device->tag(), 'A' + m_index);
391      }
392
393      m_match = match;
394   }
395
396   return (m_ie && m_ip && !m_ius);
397}
398
399
400//-------------------------------------------------
401383//  trigger_interrupt - trigger an interrupt from
402384//  this port
403385//-------------------------------------------------
r245480r245481
405387void z80pio_device::pio_port::trigger_interrupt()
406388{
407389   m_ip = true;
408   if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Pending\n", m_device->tag(), 'A' + m_index);
390   if (LOG) logerror("Z80PIO '%s' Port %c Transfer Mode Interrupt Pending\n", m_device->tag(), 'A' + m_index);
409391
410392   check_interrupts();
411393}
r245480r245481
601583   {
602584      // latch data
603585      m_input = data;
586
587      // fetch input data (ignore output lines)
588      UINT8 data = (m_input & m_ior) | (m_output & ~m_ior);
589      UINT8 mask = ~m_mask;
590      bool match = false;
591
592      data &= mask;
593
594      if ((m_icw & 0x60) == 0 && data != mask) match = true;
595      else if ((m_icw & 0x60) == 0x20 && data != 0) match = true;
596      else if ((m_icw & 0x60) == 0x40 && data == 0) match = true;
597      else if ((m_icw & 0x60) == 0x60 && data == mask) match = true;
598
599      if (!m_match && match && !m_ius)
600      {
601         // trigger interrupt
602         m_ip = true;
603         if (LOG) logerror("Z80PIO '%s' Port %c Bit Control Mode Interrupt Pending\n", m_device->tag(), 'A' + m_index);
604      }
605
606      m_match = match;
607
604608      check_interrupts();
605609   }
606610}
trunk/src/emu/machine/z80pio.h
r245480r245481
159159      void start(z80pio_device *device, int index);
160160      void reset();
161161
162      bool interrupt_signalled();
163162      void trigger_interrupt();
164163
165164      int rdy() const { return m_rdy; }


Previous 199869 Revisions Next


© 1997-2024 The MAME Team