From 4eaee5d7d058ff7e6e0b628d2cc51a0b150b3e83 Mon Sep 17 00:00:00 2001 From: Nathan Woods Date: Sun, 23 Dec 2012 05:28:04 +0000 Subject: [PATCH] [MSM6242] Fixing RTC regressions regarding interrupt callbacks --- src/emu/machine/msm6242.c | 42 ++++++++++++++++++++++++++++++++++++--- src/emu/machine/msm6242.h | 1 + 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/emu/machine/msm6242.c b/src/emu/machine/msm6242.c index 8210658736a..3993f506370 100644 --- a/src/emu/machine/msm6242.c +++ b/src/emu/machine/msm6242.c @@ -41,8 +41,9 @@ enum #define TIMER_RTC_CALLBACK 1 -#define LOG_UNMAPPED 1 -#define LOG_IRQ 1 +#define LOG_UNMAPPED 0 +#define LOG_IRQ 0 +#define LOG_IRQ_ENABLE 0 @@ -316,7 +317,17 @@ void msm6242_device::update_timer() // if set, convert ticks to an attotime if (callback_ticks > 0) { - callback_time = attotime::from_ticks(callback_ticks, clock()) - machine().time(); + // get the current time + UINT64 curtime = current_time(); + + // we need the absolute callback time, in ticks + UINT64 absolute_callback_ticks = curtime + callback_ticks; + + // convert that to an attotime + attotime absolute_callback_time = attotime::from_ticks(absolute_callback_ticks, clock()); + + // and finally get the delta as an attotime + callback_time = absolute_callback_time - machine().time(); } m_timer->adjust(callback_time); @@ -342,6 +353,7 @@ void msm6242_device::rtc_clock_updated(int year, int month, int day, int day_of_ void msm6242_device::rtc_timer_callback() { update_rtc_registers(); + update_timer(); } @@ -359,6 +371,24 @@ UINT8 msm6242_device::get_clock_nibble(int rtc_register, bool high) +//------------------------------------------------- +// get_clock_nibble +//------------------------------------------------- + +const char *msm6242_device::irq_type_string(UINT8 irq_type) +{ + switch(irq_type) + { + case IRQ_64THSECOND: return "1/64th second"; + case IRQ_SECOND: return "second"; + case IRQ_MINUTE: return "minute"; + case IRQ_HOUR: return "hour"; + default: return "???"; + } +} + + + //************************************************************************** // READ/WRITE HANDLERS //************************************************************************** @@ -487,12 +517,18 @@ WRITE8_MEMBER( msm6242_device::write ) { m_irq_flag = 1; m_irq_type = (data & 0xc) >> 2; + + if (LOG_IRQ_ENABLE) + logerror("%s: MSM6242 enabling irq '%s'\n", machine().describe_context(), irq_type_string(m_irq_type)); } else { m_irq_flag = 0; if ( !m_res_out_int_func.isnull() ) m_res_out_int_func( CLEAR_LINE ); + + if (LOG_IRQ_ENABLE) + logerror("%s: MSM6242 disabling irq\n", machine().describe_context()); } break; diff --git a/src/emu/machine/msm6242.h b/src/emu/machine/msm6242.h index db52a7653de..d3564cb5f83 100644 --- a/src/emu/machine/msm6242.h +++ b/src/emu/machine/msm6242.h @@ -81,6 +81,7 @@ private: void update_rtc_registers(); void update_timer(); UINT8 get_clock_nibble(int rtc_register, bool high); + static const char *irq_type_string(UINT8 irq_type); };