Expanded cpuexec cycles <-> attotime functions to handle UINT64s.

This commit is contained in:
Aaron Giles 2008-12-13 06:41:29 +00:00
parent 1c9b12c644
commit 59975ceb55
2 changed files with 10 additions and 6 deletions

View File

@ -650,13 +650,17 @@ void cpu_set_clockscale(const device_config *device, double clockscale)
clock ticks to an attotime 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); cpu_class_data *classdata = get_safe_classtoken(device);
if (clocks < classdata->cycles_per_second) if (clocks < classdata->cycles_per_second)
return attotime_make(0, clocks * classdata->attoseconds_per_cycle); return attotime_make(0, clocks * classdata->attoseconds_per_cycle);
else 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 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); 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;
} }

View File

@ -154,10 +154,10 @@ double cpu_get_clockscale(const device_config *device);
void cpu_set_clockscale(const device_config *device, double clockscale); void cpu_set_clockscale(const device_config *device, double clockscale);
/* converts a number of clock ticks to an attotime */ /* 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 */ /* 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);