From 338744269445c1c32920480553517d9808d0f3fd Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 27 Jun 2017 12:36:30 -0400 Subject: Fix scheduler overflow when a device executes for more cycles than there are in a second --- src/emu/schedule.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/emu/schedule.cpp b/src/emu/schedule.cpp index 5fac93c713e..2a2ec550dcb 100644 --- a/src/emu/schedule.cpp +++ b/src/emu/schedule.cpp @@ -498,7 +498,15 @@ void device_scheduler::timeslice() exec->m_totalcycles += ran; // update the local time for this CPU - attotime deltatime(0, exec->m_attoseconds_per_cycle * ran); + attotime deltatime; + if (ran < exec->m_cycles_per_second) + deltatime = attotime(0, exec->m_attoseconds_per_cycle * ran); + else + { + u32 remainder; + s32 secs = divu_64x32_rem(ran, exec->m_cycles_per_second, &remainder); + deltatime = attotime(secs, u64(remainder) * exec->m_attoseconds_per_cycle); + } assert(deltatime >= attotime::zero); exec->m_localtime += deltatime; LOG((" %d ran, %d total, time = %s\n", ran, s32(exec->m_totalcycles), exec->m_localtime.as_string(PRECISION))); -- cgit v1.2.3