Previous 199869 Revisions Next

r19445 Monday 10th December, 2012 at 11:32:53 UTC by Nathan Woods
[MSM6242] More cleanups (nw), implemented save states
[src/emu/machine]msm6242.c msm6242.h

trunk/src/emu/machine/msm6242.c
r19444r19445
8080
8181   if(m_irq_flag == 1 && m_irq_type == 0 && ((m_tick % 0x200) == 0)) // 1/64 of second
8282   {
83      if ( !m_out_int_func.isnull() )
84         m_out_int_func( ASSERT_LINE );
83      if ( !m_res_out_int_func.isnull() )
84         m_res_out_int_func( ASSERT_LINE );
8585   }
8686
8787   if(m_tick & 0x8000) // 32,768 KHz == 0x8000 ticks
r19444r19445
9090      m_rtc.sec++;
9191
9292      if(m_irq_flag == 1 && m_irq_type == 1) // 1 second clock
93         if ( !m_out_int_func.isnull() )
94            m_out_int_func(ASSERT_LINE);
93         if ( !m_res_out_int_func.isnull() )
94            m_res_out_int_func(ASSERT_LINE);
9595
9696      if(m_rtc.sec >= 60)
9797      {
9898         m_rtc.min++; m_rtc.sec = 0;
9999         if(m_irq_flag == 1 && m_irq_type == 2) // 1 minute clock
100            if ( !m_out_int_func.isnull() )
101               m_out_int_func(ASSERT_LINE);
100            if ( !m_res_out_int_func.isnull() )
101               m_res_out_int_func(ASSERT_LINE);
102102      }
103103      if(m_rtc.min >= 60)
104104      {
105105         m_rtc.hour++; m_rtc.min = 0;
106106         if(m_irq_flag == 1 && m_irq_type == 3) // 1 hour clock
107            if ( !m_out_int_func.isnull() )
108               m_out_int_func(ASSERT_LINE);
107            if ( !m_res_out_int_func.isnull() )
108               m_res_out_int_func(ASSERT_LINE);
109109      }
110110      if(m_rtc.hour >= 24)         { m_rtc.day++; m_rtc.wday++; m_rtc.hour = 0; }
111111      if(m_rtc.wday >= 6)            { m_rtc.wday = 1; }
r19444r19445
143143
144144
145145//-------------------------------------------------
146//  device_validity_check - perform validity checks
147//  on this device
148//-------------------------------------------------
149
150void msm6242_device::device_validity_check(validity_checker &valid) const
151{
152}
153
154
155
156//-------------------------------------------------
157146//  device_start - device-specific startup
158147//-------------------------------------------------
159148
160149void msm6242_device::device_start()
161150{
162   m_out_int_func.resolve( m_out_int_cb, *this );
151   const msm6242_interface *intf = reinterpret_cast<const msm6242_interface *>(static_config());
152   if (intf != NULL)
153      m_res_out_int_func.resolve(intf->m_out_int_func, *this);
163154
164155   // let's call the timer callback every tick
165156   m_timer = timer_alloc(TIMER_RTC_CALLBACK);
r19444r19445
185176   m_reg[0] = 0;
186177   m_reg[1] = 0x6;
187178   m_reg[2] = 0x4;
179
180   // save states
181   save_item(NAME(m_reg));
182   save_item(NAME(m_irq_flag));
183   save_item(NAME(m_irq_type));
184   save_item(NAME(m_tick));
185   save_item(NAME(m_rtc.sec));
186   save_item(NAME(m_rtc.min));
187   save_item(NAME(m_rtc.hour));
188   save_item(NAME(m_rtc.wday));
189   save_item(NAME(m_rtc.day));
190   save_item(NAME(m_rtc.month));
191   save_item(NAME(m_rtc.year));
188192}
189193
190194
r19444r19445
195199
196200void msm6242_device::device_reset()
197201{
198   if ( !m_out_int_func.isnull() )
199      m_out_int_func( CLEAR_LINE );
202   if ( !m_res_out_int_func.isnull() )
203      m_res_out_int_func( CLEAR_LINE );
200204}
201205
202206
203207
204//-------------------------------------------------
205//  device_config_complete - perform any
206//  operations now that the configuration is
207//  complete
208//-------------------------------------------------
209
210void msm6242_device::device_config_complete()
211{
212   const msm6242_interface *intf = reinterpret_cast<const msm6242_interface *>(static_config());
213
214   if ( intf != NULL )
215   {
216      m_out_int_cb = intf->m_out_int_cb;
217   }
218   else
219   {
220      memset(&m_out_int_cb, 0, sizeof(m_out_int_cb));
221   }
222}
223
224
225
226208//**************************************************************************
227209//  READ/WRITE HANDLERS
228210//**************************************************************************
r19444r19445
320302         else
321303         {
322304            m_irq_flag = 0;
323            if ( !m_out_int_func.isnull() )
324               m_out_int_func( CLEAR_LINE );
305            if ( !m_res_out_int_func.isnull() )
306               m_res_out_int_func( CLEAR_LINE );
325307         }
326308
327309         return;
trunk/src/emu/machine/msm6242.h
r19444r19445
2626
2727struct msm6242_interface
2828{
29   devcb_write_line   m_out_int_cb;
29   devcb_write_line   m_out_int_func;
3030};
3131
3232struct rtc_regs_t
r19444r19445
3838
3939// ======================> msm6242_device
4040
41class msm6242_device :   public device_t,
42                  public msm6242_interface
41class msm6242_device :   public device_t
4342{
4443public:
4544   // construction/destruction
r19444r19445
5150
5251protected:
5352   // device-level overrides
54   virtual void device_config_complete();
55   virtual void device_validity_check(validity_checker &valid) const;
5653   virtual void device_start();
5754   virtual void device_reset();
5855   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
5956
6057private:
58   // state
6159   UINT8                  m_reg[3];
6260   UINT8                  m_irq_flag;
6361   UINT8                  m_irq_type;
6462   UINT16                  m_tick;
65
6663   rtc_regs_t               m_rtc;
67   rtc_regs_t               m_hold;
68   devcb_resolved_write_line   m_out_int_func;
64
65   // incidentals
66   devcb_resolved_write_line   m_res_out_int_func;
6967   emu_timer *               m_timer;
7068
69   // callbacks
7170   void rtc_timer_callback();
7271};
7372

Previous 199869 Revisions Next


© 1997-2024 The MAME Team