Previous 15994 Revisions Next

r4965 Monday 8th June, 2009 at 13:00:35 UTC by Curt Coder
[PPI8255] Fixed handshaking signals for modes 1/2.
[src/emu/machine]8255ppi.c

src/emu/machine/8255ppi.c
r4964r4965
117117   UINT8 ibf_b;
118118   UINT8 inte_a;
119119   UINT8 inte_b;
120   UINT8 inte_1;
121   UINT8 inte_2;
120122
121   UINT8 in_mask[3];      /* input mask */
123   UINT8 in_mask[3];   /* input mask */
122124   UINT8 out_mask[3];   /* output mask */
123125   UINT8 read[3];      /* data read from ports */
124126   UINT8 latch[3];      /* data written to ports */
125127   UINT8 output[3];   /* actual output data */
128   UINT8 control;      /* mode control word */
126129};
127130
128131
r4964r4965
161164   }
162165   else if (ppi8255->group_a_mode == 2)
163166     {
164      handshake |= ppi8255->inte_a ? 0x08 : 0x00;
165167      handshake |= ppi8255->obf_a ? 0x00 : 0x80;
166168      handshake |= ppi8255->ibf_a ? 0x20 : 0x00;
169      handshake |= ((ppi8255->obf_a && ppi8255->inte_1) || (ppi8255->ibf_a && ppi8255->inte_2)) ? 0x08 : 0x00;
167170      mask |= 0xA8;
168171   }
169172
170173   /* group B */
171174   if (ppi8255->group_b_mode == 1)
172175     {
173      if (ppi8255->port_a_dir)
176      if (ppi8255->port_b_dir)
174177      {
175178         handshake |= ppi8255->ibf_b ? 0x02 : 0x00;
176179         handshake |= (ppi8255->ibf_b && ppi8255->inte_b) ? 0x01 : 0x00;
r4964r4965
210213         }
211214      }
212215
216      if (((ppi8255->group_a_mode == 1) && (ppi8255->port_a_dir == 1)) || (ppi8255->group_a_mode == 2))
217      {
218         /* is !STBA asserted? */
219         if (!ppi8255->ibf_a && !(data & 0x10))
220         {
221            ppi8255->ibf_a = 1;
222            changed = 1;
223         }
224      }
225
213226      if ((ppi8255->group_b_mode == 1) && (ppi8255->port_b_dir == 0))
214227      {
215228         /* is !ACKB asserted? */
r4964r4965
220233         }
221234      }
222235
236      if ((ppi8255->group_b_mode == 1) && (ppi8255->port_b_dir == 1))
237      {
238         /* is !STBB asserted? */
239         if (!ppi8255->ibf_b && !(data & 0x04))
240         {
241            ppi8255->ibf_b = 1;
242            changed = 1;
243         }
244      }
245
223246      if (changed)
224247         ppi8255_write_port(device, 2);
225248   }
r4964r4965
241264   }
242265   result |= ppi8255->latch[port] & ppi8255->out_mask[port];
243266
244   /* read special port 2 signals */
245   if (port == 2)
267   switch (port)
268   {
269   case 0:
270      /* clear input buffer full flag */
271      ppi8255->ibf_a = 0;
272      break;
273
274   case 1:
275      /* clear input buffer full flag */
276      ppi8255->ibf_b = 0;
277      break;
278
279   case 2:
280      /* read special port 2 signals */
246281      ppi8255_get_handshake_signals(ppi8255, 1, &result);
282      break;
283   }
247284
248285   return result;
249286}
r4964r4965
252289
253290READ8_DEVICE_HANDLER( ppi8255_r )
254291{
292   ppi8255_t   *ppi8255 = get_safe_token(device);
255293   UINT8 result = 0;
256294
257295   offset %= 4;
r4964r4965
265303         break;
266304
267305      case 3: /* Control word */
268         result = 0xFF;
306         result = ppi8255->control;
269307         break;
270308   }
271309
r4964r4965
340378              bit = (data >> 1) & 0x07;
341379
342380              if (data & 1)
343               ppi8255->latch[2] |= (1<<bit);      /* set bit */
381               ppi8255->latch[2] |= (1<<bit);   /* set bit */
344382              else
345383               ppi8255->latch[2] &= ~(1<<bit);   /* reset bit */
346384
385            if (bit == 2 && ppi8255->group_b_mode == 1)   ppi8255->inte_b = data & 1;
386            if (bit == 4 && ppi8255->group_a_mode == 1 && ppi8255->port_a_dir) ppi8255->inte_a = data & 1;
387            if (bit == 6 && ppi8255->group_a_mode == 1 && !ppi8255->port_a_dir) ppi8255->inte_a = data & 1;
388            if (bit == 4 && ppi8255->group_a_mode == 2) ppi8255->inte_2 = data & 1;
389            if (bit == 6 && ppi8255->group_a_mode == 2) ppi8255->inte_1 = data & 1;
390
347391            ppi8255_write_port(device, 2);
348392         }
349393         break;
r4964r4965
472516      for (i = 0; i < 3; i++)
473517         ppi8255_write_port(device, i);
474518   }
519
520   /* reset flip-flops */
521   ppi8255->obf_a = ppi8255->ibf_a = 0;
522   ppi8255->obf_b = ppi8255->ibf_b = 0;
523   ppi8255->inte_a = ppi8255->inte_b = ppi8255->inte_1 = ppi8255->inte_2 = 0;
524
525   /* store control word */
526   ppi8255->control = data;
475527}
476528
477529
r4964r4965
524576   state_save_register_device_item(device, 0, ppi8255->ibf_b);
525577   state_save_register_device_item(device, 0, ppi8255->inte_a);
526578   state_save_register_device_item(device, 0, ppi8255->inte_b);
579   state_save_register_device_item(device, 0, ppi8255->inte_1);
580   state_save_register_device_item(device, 0, ppi8255->inte_2);
527581   state_save_register_device_item_array(device, 0, ppi8255->in_mask);
528582   state_save_register_device_item_array(device, 0, ppi8255->out_mask);
529583   state_save_register_device_item_array(device, 0, ppi8255->read);
r4964r4965
541595   ppi8255->port_b_dir = 0;
542596   ppi8255->port_ch_dir = 0;
543597   ppi8255->port_cl_dir = 0;
544   ppi8255->obf_a = ppi8255->ibf_a = ppi8255->inte_a = 0;
545   ppi8255->obf_b = ppi8255->ibf_b = ppi8255->inte_b = 0;
598   ppi8255->obf_a = ppi8255->ibf_a = 0;
599   ppi8255->obf_b = ppi8255->ibf_b = 0;
600   ppi8255->inte_a = ppi8255->inte_b = ppi8255->inte_1 = ppi8255->inte_2 = 0;
546601
547602   for ( i = 0; i < 3; i++ ) {
548603      ppi8255->in_mask[i] = ppi8255->out_mask[i] = ppi8255->read[i] = ppi8255->latch[i] = ppi8255->output[i] = 0;
549604   }
550605
551   set_mode(device, 0x1b, 0);   /* Mode 0, all ports set to input */
606   set_mode(device, 0x9b, 0);   /* Mode 0, all ports set to input */
552607}
553608
554609

Previous 15994 Revisions Next


© 1998-2018 The MESS Team