Previous 15994 Revisions Next

r12915 Thursday 22nd September, 2011 at 13:08:02 UTC by Curt Coder
[Z8536] Interrupts WIP. (nw)
[src/emu/machine]z8536.c z8536.h

src/emu/machine/z8536.c
r12914r12915
290290
291291   if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_MIE)
292292   {
293      if ((m_register[COUNTER_TIMER_3_COMMAND_AND_STATUS] & CTCS_IUS) ||
294         (m_register[PORT_A_COMMAND_AND_STATUS] & PCS_IUS) ||
295         (m_register[COUNTER_TIMER_2_COMMAND_AND_STATUS] & CTCS_IUS) ||
296         (m_register[PORT_B_COMMAND_AND_STATUS] & PCS_IUS) ||
297         (m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS] & CTCS_IUS))
298      {
299         // interrupt under service
300         return;
301      }
302     
293303      if ((m_register[COUNTER_TIMER_3_COMMAND_AND_STATUS] & (CTCS_IP | CTCS_IE)) == (CTCS_IP | CTCS_IE))
294304      {
295305         vector = m_register[COUNTER_TIMER_INTERRUPT_VECTOR];
r12914r12915
303313      {
304314         vector = m_register[PORT_A_INTERRUPT_VECTOR];
305315
306         if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_CT_VIS)
316         if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_PA_VIS)
307317         {
308            if ((m_register[PORT_A_MODE_SPECIFICATION] & PMS_PMS_MASK) == PMS_OR_PEV)
318            vector &= 0xf1;
319           
320            if (((m_register[PORT_A_MODE_SPECIFICATION] & PMS_PMS_MASK) >> 1) == PMS_OR_PEV)
309321            {
310               vector = (vector & 0xf1) | (m_match[0] << 1);
322               if       (m_match[PORT_A] & 0x80) vector |= 7;
323               else if (m_match[PORT_A] & 0x40) vector |= 6;
324               else if (m_match[PORT_A] & 0x20) vector |= 5;
325               else if (m_match[PORT_A] & 0x10) vector |= 4;
326               else if (m_match[PORT_A] & 0x08) vector |= 3;
327               else if (m_match[PORT_A] & 0x04) vector |= 2;
328               else if (m_match[PORT_A] & 0x02) vector |= 1;
329               else if (m_match[PORT_A] & 0x01) vector |= 0;
311330            }
312331            else
313332            {
314               vector = (vector & 0xf1) | (m_register[PORT_A_COMMAND_AND_STATUS] & 0x0e);
333               vector |= (m_register[PORT_A_COMMAND_AND_STATUS] & 0x0e);
315334            }
316335         }
317336      }
r12914r12915
328347      {
329348         vector = m_register[PORT_B_INTERRUPT_VECTOR];
330349
331         if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_CT_VIS)
350         if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_PB_VIS)
332351         {
333            if ((m_register[PORT_B_MODE_SPECIFICATION] & PMS_PMS_MASK) == PMS_OR_PEV)
352            vector &= 0xf1;
353           
354            if (((m_register[PORT_B_MODE_SPECIFICATION] & PMS_PMS_MASK) >> 1) == PMS_OR_PEV)
334355            {
335               vector = (vector & 0xf1) | (m_match[1] << 1);
356               if       (m_match[PORT_B] & 0x80) vector |= 7;
357               else if (m_match[PORT_B] & 0x40) vector |= 6;
358               else if (m_match[PORT_B] & 0x20) vector |= 5;
359               else if (m_match[PORT_B] & 0x10) vector |= 4;
360               else if (m_match[PORT_B] & 0x08) vector |= 3;
361               else if (m_match[PORT_B] & 0x04) vector |= 2;
362               else if (m_match[PORT_B] & 0x02) vector |= 1;
363               else if (m_match[PORT_B] & 0x01) vector |= 0;
336364            }
337365            else
338366            {
339               vector = (vector & 0xf1) | (m_register[PORT_B_COMMAND_AND_STATUS] & 0x0e);
367               vector |= (m_register[PORT_B_COMMAND_AND_STATUS] & 0x0e);
340368            }
341369         }
342370      }
r12914r12915
905933}
906934
907935
936//-------------------------------------------------
937//  external_port_w - external port write
938//-------------------------------------------------
908939
940inline void z8536_device::external_port_w(int port, int bit, int state)
941{
942   switch (port)
943   {
944   case PORT_A:
945      break;
946     
947   case PORT_B:
948      {
949      UINT8 pms = m_register[PORT_B_MODE_SPECIFICATION];
950      UINT8 ddr = m_register[PORT_B_DATA_DIRECTION];
951      UINT8 pm = m_register[PORT_B_PATTERN_MASK];
952     
953      if (!BIT(ddr, bit)) return;
954   
955      m_input[port] = (m_input[port] & ~(1 << bit)) | (state << bit);
956     
957      switch ((pms & PMS_PMS_MASK) >> 1)
958      {
959      case PMS_OR_PEV:
960         m_match[port] = m_input[port] & ddr & pm;
961         
962         if (m_match[port])
963         {
964            if (LOG) logerror("%s Z8536 '%s' Port B Match on Bit %u\n", machine().describe_context(), tag(), bit);
965            m_register[PORT_B_COMMAND_AND_STATUS] |= PCS_IP;
966            check_interrupt();
967         }
968         break;
969         
970      default:
971         fatalerror("Unsupported pattern matching mode!\n");
972      }
973      }
974      break;
975     
976   case PORT_C:
977      break;
978   }
979}
980
981
982
909983//**************************************************************************
910984//  LIVE DEVICE
911985//**************************************************************************
r12914r12915
9551029
9561030void z8536_device::device_start()
9571031{
1032   for (int i = 0; i < 3; i++)
1033   {
1034      m_input[i] = 0;
1035      m_output[i] = 0;
1036      m_buffer[i] = 0;
1037      m_match[i] = 0;
1038   }
1039   
9581040   // allocate timer
9591041   m_timer = timer_alloc();
9601042   m_timer->adjust(attotime::from_hz(clock() / 2), 0, attotime::from_hz(clock() / 2));
r12914r12915
11971279//  pa*_w - port A bits 0-7 write
11981280//-------------------------------------------------
11991281
1200WRITE_LINE_MEMBER( z8536_device::pa0_w ) { }
1201WRITE_LINE_MEMBER( z8536_device::pa1_w ) { }
1202WRITE_LINE_MEMBER( z8536_device::pa2_w ) { }
1203WRITE_LINE_MEMBER( z8536_device::pa3_w ) { }
1204WRITE_LINE_MEMBER( z8536_device::pa4_w ) { }
1205WRITE_LINE_MEMBER( z8536_device::pa5_w ) { }
1206WRITE_LINE_MEMBER( z8536_device::pa6_w ) { }
1207WRITE_LINE_MEMBER( z8536_device::pa7_w ) { }
1282WRITE_LINE_MEMBER( z8536_device::pa0_w ) { external_port_w(PORT_A, 0, state); }
1283WRITE_LINE_MEMBER( z8536_device::pa1_w ) { external_port_w(PORT_A, 1, state); }
1284WRITE_LINE_MEMBER( z8536_device::pa2_w ) { external_port_w(PORT_A, 2, state); }
1285WRITE_LINE_MEMBER( z8536_device::pa3_w ) { external_port_w(PORT_A, 3, state); }
1286WRITE_LINE_MEMBER( z8536_device::pa4_w ) { external_port_w(PORT_A, 4, state); }
1287WRITE_LINE_MEMBER( z8536_device::pa5_w ) { external_port_w(PORT_A, 5, state); }
1288WRITE_LINE_MEMBER( z8536_device::pa6_w ) { external_port_w(PORT_A, 6, state); }
1289WRITE_LINE_MEMBER( z8536_device::pa7_w ) { external_port_w(PORT_A, 7, state); }
12081290
12091291
12101292//-------------------------------------------------
12111293//  pb*_w - port B bits 0-7 write
12121294//-------------------------------------------------
12131295
1214WRITE_LINE_MEMBER( z8536_device::pb0_w ) { }
1215WRITE_LINE_MEMBER( z8536_device::pb1_w ) { }
1216WRITE_LINE_MEMBER( z8536_device::pb2_w ) { }
1217WRITE_LINE_MEMBER( z8536_device::pb3_w ) { }
1218WRITE_LINE_MEMBER( z8536_device::pb4_w ) { }
1219WRITE_LINE_MEMBER( z8536_device::pb5_w ) { }
1220WRITE_LINE_MEMBER( z8536_device::pb6_w ) { }
1221WRITE_LINE_MEMBER( z8536_device::pb7_w ) { }
1296WRITE_LINE_MEMBER( z8536_device::pb0_w ) { external_port_w(PORT_B, 0, state); }
1297WRITE_LINE_MEMBER( z8536_device::pb1_w ) { external_port_w(PORT_B, 1, state); }
1298WRITE_LINE_MEMBER( z8536_device::pb2_w ) { external_port_w(PORT_B, 2, state); }
1299WRITE_LINE_MEMBER( z8536_device::pb3_w ) { external_port_w(PORT_B, 3, state); }
1300WRITE_LINE_MEMBER( z8536_device::pb4_w ) { external_port_w(PORT_B, 4, state); }
1301WRITE_LINE_MEMBER( z8536_device::pb5_w ) { external_port_w(PORT_B, 5, state); }
1302WRITE_LINE_MEMBER( z8536_device::pb6_w ) { external_port_w(PORT_B, 6, state); }
1303WRITE_LINE_MEMBER( z8536_device::pb7_w ) { external_port_w(PORT_B, 7, state); }
12221304
12231305
12241306//-------------------------------------------------
12251307//  pc*_w - port C bits 0-3 write
12261308//-------------------------------------------------
12271309
1228WRITE_LINE_MEMBER( z8536_device::pc0_w ) { }
1229WRITE_LINE_MEMBER( z8536_device::pc1_w ) { }
1230WRITE_LINE_MEMBER( z8536_device::pc2_w ) { }
1231WRITE_LINE_MEMBER( z8536_device::pc3_w ) { }
1310WRITE_LINE_MEMBER( z8536_device::pc0_w ) { external_port_w(PORT_C, 0, state); }
1311WRITE_LINE_MEMBER( z8536_device::pc1_w ) { external_port_w(PORT_C, 1, state); }
1312WRITE_LINE_MEMBER( z8536_device::pc2_w ) { external_port_w(PORT_C, 2, state); }
1313WRITE_LINE_MEMBER( z8536_device::pc3_w ) { external_port_w(PORT_C, 3, state); }
src/emu/machine/z8536.h
r12914r12915
135135   static const device_timer_id TIMER_1 = 0;
136136   static const device_timer_id TIMER_2 = 1;
137137   static const device_timer_id TIMER_3 = 2;
138   
139   static const int PORT_A = 0;
140   static const int PORT_B = 1;
141   static const int PORT_C = 2;
138142
139143   inline void check_interrupt();
140144
r12914r12915
152156   inline void count(device_timer_id id);
153157   inline void trigger(device_timer_id id);
154158   inline void gate(device_timer_id id, int state);
159   inline void external_port_w(int port, int bit, int state);
155160
156161   devcb_resolved_write_line      m_out_int_func;
157162
r12914r12915
176181   UINT8 m_input[3];
177182   UINT8 m_output[3];
178183   UINT8 m_buffer[3];
179   int m_match[2];
184   UINT8 m_match[3];
180185
181186   // timers
182187   emu_timer *m_timer;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team