summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-12-13 06:41:29 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-12-13 06:41:29 +0000
commit59975ceb55b2face30b126f5132bbd97975b0129 (patch)
tree19bc26411f3a61a2b141143552d2f2530f7fb1a3
parent1c9b12c6441f4279888e852df6ed3a32fc7f450a (diff)
Expanded cpuexec cycles <-> attotime functions to handle UINT64s.
-rw-r--r--src/emu/cpuexec.c12
-rw-r--r--src/emu/cpuexec.h4
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);