diff --git a/src/devices/sound/ics2115.cpp b/src/devices/sound/ics2115.cpp index a84a5c1208e..56c0cf607c4 100644 --- a/src/devices/sound/ics2115.cpp +++ b/src/devices/sound/ics2115.cpp @@ -1105,22 +1105,14 @@ TIMER_CALLBACK_MEMBER( ics2115_device::timer_cb_1 ) void ics2115_device::recalc_timer(int timer) { - //Old regression-based formula (minus constant) - //u64 period = m_timer[timer].preset * (m_timer[timer].scale << 16) / 60; - - //New formula based on O.Galibert's reverse engineering of ICS2115 card firmware - // TODO : Related to input clock? u64 period = ((m_timer[timer].scale & 0x1f) + 1) * (m_timer[timer].preset + 1); - period = (period << (4 + (m_timer[timer].scale >> 5)))*78125/2646; + period = period << (4 + (m_timer[timer].scale >> 5)); if (m_timer[timer].period != period) { - logerror("Timer %d period %dns (%dHz)\n", timer, period, 1e9/period); + attotime tp = attotime::from_ticks(period, clock()); + logerror("Timer %d period %dns (%dHz)\n", timer, int(tp.as_double()*1e9), int(1/tp.as_double())); m_timer[timer].period = period; - // Adjust the timer lengths - if (period) // Reset the length - m_timer[timer].timer->adjust(attotime::from_nsec(period), 0, attotime::from_nsec(period)); - else // Kill the timer if length == 0 - m_timer[timer].timer->adjust(attotime::never); + m_timer[timer].timer->adjust(tp, 0, tp); } }