summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2022-06-15 15:23:56 +0200
committer Olivier Galibert <galibert@pobox.com>2022-06-15 15:23:56 +0200
commit67dee6278ce7ab83741d4d81181ce3be33902ff2 (patch)
treea01b49059c914cdae6de5a92ac2e1834311d87b3 /src/devices/sound
parent1ded6ae6d6ad0b0fbbaeea81fa2b480852c13206 (diff)
ics2115: Cleanup timer code
Diffstat (limited to 'src/devices/sound')
-rw-r--r--src/devices/sound/ics2115.cpp16
1 files changed, 4 insertions, 12 deletions
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);
}
}