From 59975ceb55b2face30b126f5132bbd97975b0129 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Sat, 13 Dec 2008 06:41:29 +0000 Subject: [PATCH] Expanded cpuexec cycles <-> attotime functions to handle UINT64s. --- src/emu/cpuexec.c | 12 ++++++++---- src/emu/cpuexec.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/emu/cpuexec.c b/src/emu/cpuexec.c index 3d0582df84e..24ad6806ee7 100644 --- a/src/emu/cpuexec.c +++ b/src/emu/cpuexec.c @@ -650,13 +650,17 @@ void cpu_set_clockscale(const device_config *device, double clockscale) clock ticks to an attotime -------------------------------------------------*/ -attotime cpu_clocks_to_attotime(const device_config *device, UINT32 clocks) +attotime cpu_clocks_to_attotime(const device_config *device, UINT64 clocks) { cpu_class_data *classdata = get_safe_classtoken(device); if (clocks < classdata->cycles_per_second) return attotime_make(0, clocks * classdata->attoseconds_per_cycle); else - return attotime_make(clocks / classdata->cycles_per_second, (clocks % classdata->cycles_per_second) * classdata->attoseconds_per_cycle); + { + UINT32 remainder; + UINT32 quotient = divu_64x32_rem(clocks, classdata->cycles_per_second, &remainder); + return attotime_make(quotient, (UINT64)remainder * (UINT64)classdata->attoseconds_per_cycle); + } } @@ -665,10 +669,10 @@ attotime cpu_clocks_to_attotime(const device_config *device, UINT32 clocks) as attotime to CPU clock ticks -------------------------------------------------*/ -UINT32 cpu_attotime_to_clocks(const device_config *device, attotime duration) +UINT64 cpu_attotime_to_clocks(const device_config *device, attotime duration) { cpu_class_data *classdata = get_safe_classtoken(device); - return duration.seconds * classdata->cycles_per_second + duration.attoseconds / classdata->attoseconds_per_cycle; + return mulu_32x32(duration.seconds, classdata->cycles_per_second) + (UINT64)duration.attoseconds * (UINT64)classdata->attoseconds_per_cycle; } diff --git a/src/emu/cpuexec.h b/src/emu/cpuexec.h index ba511f4b2ad..7b4bf284c9f 100644 --- a/src/emu/cpuexec.h +++ b/src/emu/cpuexec.h @@ -154,10 +154,10 @@ double cpu_get_clockscale(const device_config *device); void cpu_set_clockscale(const device_config *device, double clockscale); /* converts a number of clock ticks to an attotime */ -attotime cpu_clocks_to_attotime(const device_config *device, UINT32 clocks); +attotime cpu_clocks_to_attotime(const device_config *device, UINT64 clocks); /* converts a duration as attotime to CPU clock ticks */ -UINT32 cpu_attotime_to_clocks(const device_config *device, attotime duration); +UINT64 cpu_attotime_to_clocks(const device_config *device, attotime duration);