Previous 15994 Revisions Next

r3453 Thursday 16th October, 2008 at 15:24:34 UTC by Curt Coder
[Z80PIO] Added pending interrupts.
[src/emu/machine]z80pio.c

src/emu/machine/z80pio.c
r3452r3453
6969   int state[PIO_PORT_COUNT];            /* control register state */
7070   int mode[PIO_PORT_COUNT];            /* mode control register */
7171   int irq_enable[PIO_PORT_COUNT];         /* interrupt enable flag */
72   int irq_pending[PIO_PORT_COUNT];      /* interrupt pending flag */
7273   int int_state[PIO_PORT_COUNT];         /* interrupt status */
7374   UINT8 enable[PIO_PORT_COUNT];         /* interrupt control word */
7475   UINT8 input[PIO_PORT_COUNT];         /* data input register */
r3452r3453
116117
117118   for (channel = PIO_PORT_A; channel < PIO_PORT_COUNT; channel++)
118119   {
119      if (!(z80pio->irq_enable[channel]))
120      if (z80pio->irq_enable[channel])
120121      {
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      {
121135         /* clear interrupt request */
122136         z80pio->int_state[channel] &= ~Z80_DAISY_INT;
123137      }
r3452r3453
140154
141155      LOGERROR("Z80PIO \"%s\" Port %c : Interrupt Request\n", device->tag, 'A' + channel);
142156   }
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   }
143165}
144166
145167static TIMER_CALLBACK( z80pio_irq_tick )
r3452r3453
154176   z80pio->irq_enable[channel] = state;
155177
156178   LOGERROR("Z80PIO \"%s\" Port %c : Interrupt Enable %u\n", device->tag, 'A' + channel, state);
179
180   /* check interrupt status */
181   z80pio_check_interrupt(device);
157182}
158183
159184static void z80pio_set_irq_enable(const device_config *device, int channel, int state)
r3452r3453
371396         {
372397            /* disable interrupts until mask is written */
373398            z80pio_set_irq_enable(device, channel, 0);
399     
400            /* reset pending interrupt */
401            z80pio->irq_pending[channel] = 0;
374402
403            /* set logic equation to false */
404            z80pio->match[channel] = 0;
405
375406            /* next word is mask control */
376407            z80pio->state[channel] = PIO_STATE_MASK;
377408         }
r3452r3453
533564         UINT8 old_data = z80pio->input[channel] & ddr;
534565         UINT8 data = z80pio_port_r(device, channel) & ddr;
535566
567         if (old_data == data) continue;
568
536569         for (bit = 0; bit < 8; bit++)
537570         {
538571            if (BIT(mask, bit)) continue; /* masked out */
r3452r3453
840873   state_save_register_item_array(unique_tag, 0, z80pio->state);
841874   state_save_register_item_array(unique_tag, 0, z80pio->mode);
842875   state_save_register_item_array(unique_tag, 0, z80pio->irq_enable);
876   state_save_register_item_array(unique_tag, 0, z80pio->irq_pending);
843877   state_save_register_item_array(unique_tag, 0, z80pio->int_state);
844878   state_save_register_item_array(unique_tag, 0, z80pio->enable);
845879   state_save_register_item_array(unique_tag, 0, z80pio->input);
r3452r3453
862896
863897   for (channel = 0; channel < 2; channel++)
864898   {
865      /* set port mask register to inhibit all port data bits */
866      z80pio->mask[channel] = 0xff;
867
868      /* clear ready line */
869      z80pio_ready_w(device, channel, 0);
870
871899      /* set mode 1 */
872900      z80pio->mode[channel] = PIO_MODE_INPUT;
873901
874      /* set all inputs */
875      z80pio->ddr[channel] = 0xff;
876
877      /* reset interrupt */
902      /* disable interrupt */
878903      z80pio->enable[channel] &= 0x7f;
879904      z80pio->irq_enable[channel] = 0;
905      z80pio->irq_pending[channel] = 0;
880906      z80pio->int_state[channel] = 0;
881907      z80pio->match[channel] = 0;
882908
909      /* reset all bits of the data I/O register */
910      z80pio->ddr[channel] = 0;
911
912      /* set all bits of the mask control register */
913      z80pio->mask[channel] = 0xff;
914
883915      /* reset output register */
884916      z80pio->output[channel] = 0;
917
918      /* clear ready line */
919      z80pio_ready_w(device, channel, 0);
885920   }
886921
887922   z80pio_check_interrupt(device);
r3452r3453
930965      case DEVINFO_STR_NAME:                     info->s = "Zilog Z8420";            break;
931966      case DEVINFO_STR_FAMILY:                  info->s = "Z80 PIO";               break;
932967
933      default: DEVICE_GET_INFO_CALL(z80pio);
968      default:                              DEVICE_GET_INFO_CALL(z80pio);
934969   }
935970}
936971
r3452r3453
942977      case DEVINFO_STR_NAME:                     info->s = "Sharp LH0081";            break;
943978      case DEVINFO_STR_FAMILY:                  info->s = "Z80 PIO";               break;
944979
945      default: DEVICE_GET_INFO_CALL(z80pio);
980      default:                              DEVICE_GET_INFO_CALL(z80pio);
946981   }
947982}
948983
r3452r3453
954989      case DEVINFO_STR_NAME:                     info->s = "Mostek MK3881";            break;
955990      case DEVINFO_STR_FAMILY:                  info->s = "Z80 PIO";               break;
956991
957      default: DEVICE_GET_INFO_CALL(z80pio);
992      default:                              DEVICE_GET_INFO_CALL(z80pio);
958993   }
959994}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team