Previous 15994 Revisions Next

r12911 Wednesday 21st September, 2011 at 19:51:26 UTC by Curt Coder
[ABC1600] Fixed CIO timers, now boots until "Root device mount error". (nw)
[src/emu/machine]z8536.c z8536.h
[src/mess/drivers]abc1600.c

src/emu/machine/z8536.c
r12910r12911
77
88**********************************************************************/
99
10/*
11   
12   TODO:
13   
14   - interrupts
15      - vector
16      - status affects vector
17      - IE/IP/IUS
18      - acknowledge
19      - daisy chain
20   - port I/O
21   - counters/timers
22
23*/
24
1025#include "emu.h"
1126#include "z8536.h"
1227#include "machine/devhelpr.h"
r12910r12911
306321
307322         if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_CT_VIS)
308323         {
309            vector = (vector & 0xf9) | 1;
324            vector = (vector & 0xf9) | 2;
310325         }
311326      }
312327      else if ((m_register[PORT_B_COMMAND_AND_STATUS] & (PCS_IP | PCS_IE)) == (PCS_IP | PCS_IE))
r12910r12911
331346
332347         if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_CT_VIS)
333348         {
334            vector = (vector & 0xf9) | 2;
349            vector = (vector & 0xf9) | 4;
335350         }
336351      }
337352      else
r12910r12911
575590      }
576591
577592      // gate command bit
578      gate(counter, (data & CTCS_GCB) ? 1 : 0);
579     
580593      m_register[offset] = (m_register[offset] & ~CTCS_GCB) | (data & CTCS_GCB);
581594     
582595      // trigger command bit
r12910r12911
685698     
686699   case PORT_A_HANDSHAKE_SPECIFICATION:
687700   case PORT_B_HANDSHAKE_SPECIFICATION:
701      // TODO
688702      break;
689703     
690704   case PORT_A_DATA_PATH_POLARITY:
r12910r12911
770784
771785
772786//-------------------------------------------------
787//   counter_external_output -
788//-------------------------------------------------
789
790inline bool z8536_device::counter_external_output(device_timer_id id)
791{
792   return (m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_EOE) ? true : false;
793}
794
795
796//-------------------------------------------------
797//   counter_external_count -
798//-------------------------------------------------
799
800inline bool z8536_device::counter_external_count(device_timer_id id)
801{
802   return (m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_ECE) ? true : false;
803}
804
805
806//-------------------------------------------------
807//   counter_external_trigger -
808//-------------------------------------------------
809
810inline bool z8536_device::counter_external_trigger(device_timer_id id)
811{
812   return (m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_ETE) ? true : false;
813}
814
815
816//-------------------------------------------------
817//   counter_external_gate -
818//-------------------------------------------------
819
820inline bool z8536_device::counter_external_gate(device_timer_id id)
821{
822   return (m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_EDE) ? true : false;
823}
824
825
826//-------------------------------------------------
827//   counter_gated -
828//-------------------------------------------------
829
830inline bool z8536_device::counter_gated(device_timer_id id)
831{
832   return (m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] & CTCS_GCB) ? true : false;
833}
834
835
836//-------------------------------------------------
773837//   count - count down
774838//-------------------------------------------------
775839
776840inline void z8536_device::count(device_timer_id id)
777841{
778   if (!m_gate[id]) return;
779
842   if (!counter_gated(id)) return;
843   if (!m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] & CTCS_CIP) return;
844   
780845   // count down
781846   m_counter[id]--;
782847
783   if (m_counter == 0)
848   if (m_counter[id] == 0)
784849   {
785      // clear count in progress bit
786      m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] &= ~CTCS_CIP;
787
788850      if (m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] & CTCS_IP)
789851      {
790852         // set interrupt error bit
791853         m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] |= CTCS_ERR;
792854      }
793
794      // set interrupt pending bit
795      m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] |= CTCS_IP;
855      else
856      {
857         // set interrupt pending bit
858         m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] |= CTCS_IP;
859      }
796860     
797861      if (m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_CSC)
798862      {
799         // reload time constant
800         trigger(id);
863         // reload counter with time constant
864         m_counter[id] = (m_register[COUNTER_TIMER_1_TIME_CONSTANT_MS_BYTE + (id << 1)] << 8) | m_register[COUNTER_TIMER_1_TIME_CONSTANT_LS_BYTE + (id << 1)];
801865      }
866      else
867      {
868         if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Terminal Count\n", machine().describe_context(), tag(), id + 1);
869         
870         // clear count in progress bit
871         m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] &= ~CTCS_CIP;
872      }
802873     
803874      check_interrupt();
804875   }
r12910r12911
814885   // ignore triggers during countdown if retrigger is disabled
815886   if (!(m_register[COUNTER_TIMER_1_MODE_SPECIFICATION + id] & CTMS_REB) && (m_register[COUNTER_TIMER_1_COMMAND_AND_STATUS + id] & CTCS_CIP)) return;
816887   
888   if (LOG) logerror("%s Z8536 '%s' Counter/Timer %u Trigger\n", machine().describe_context(), tag(), id + 1);
889   
817890   // load counter with time constant
818891   m_counter[id] = (m_register[COUNTER_TIMER_1_TIME_CONSTANT_MS_BYTE + (id << 1)] << 8) | m_register[COUNTER_TIMER_1_TIME_CONSTANT_LS_BYTE + (id << 1)];
819892
r12910r12911
828901
829902inline void z8536_device::gate(device_timer_id id, int state)
830903{
831   m_gate[id] = state;
904   // TODO
832905}
833906
834907
r12910r12911
9271000
9281001void z8536_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
9291002{
930   if (counter_enabled(TIMER_1) &&   !(m_register[COUNTER_TIMER_1_MODE_SPECIFICATION] & CTMS_ECE))
1003   if (counter_enabled(TIMER_1) &&   !counter_external_count(TIMER_1))
9311004   {
9321005      count(TIMER_1);
9331006   }
9341007
935   if (counter_enabled(TIMER_2) &&   !(m_register[COUNTER_TIMER_1_MODE_SPECIFICATION] & CTMS_ECE))
1008   if (counter_enabled(TIMER_2) &&   !counter_external_count(TIMER_2))
9361009   {
9371010      count(TIMER_2);
9381011   }
9391012
940   if (counter_enabled(TIMER_3) &&   !(m_register[COUNTER_TIMER_1_MODE_SPECIFICATION] & CTMS_ECE))
1013   if (counter_enabled(TIMER_3) &&   !counter_external_count(TIMER_3))
9411014   {
9421015      count(TIMER_3);
9431016   }
src/emu/machine/z8536.h
r12910r12911
144144   inline void write_register(offs_t offset, UINT8 data, UINT8 mask);
145145
146146   inline bool counter_enabled(device_timer_id id);
147   inline bool counter_external_output(device_timer_id id);
148   inline bool counter_external_count(device_timer_id id);
149   inline bool counter_external_trigger(device_timer_id id);
150   inline bool counter_external_gate(device_timer_id id);
151   inline bool counter_gated(device_timer_id id);
147152   inline void count(device_timer_id id);
148153   inline void trigger(device_timer_id id);
149154   inline void gate(device_timer_id id, int state);
r12910r12911
176181   // timers
177182   emu_timer *m_timer;
178183   UINT16 m_counter[3];
179   bool m_gate[3];
180184};
181185
182186
src/mess/drivers/abc1600.c
r12910r12911
14681468{
14691469   abc1600_state *state = device->machine().driver_data<abc1600_state>();
14701470   UINT8 data = 0;
1471
1471   
14721472   switch (irqline)
14731473   {
1474   case 5:
1474   case M68K_IRQ_2:
14751475      data = state->m_cio->intack_r();
14761476      break;
14771477   }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team