diff options
166 files changed, 967 insertions, 933 deletions
diff --git a/src/emu/attotime.c b/src/emu/attotime.c index f961da0fd4c..6268cdd8189 100644 --- a/src/emu/attotime.c +++ b/src/emu/attotime.c @@ -4,8 +4,36 @@ Support functions for working with attotime data. - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ @@ -14,148 +42,142 @@ #include "attotime.h" -/*************************************************************************** - GLOBAL VARIABLES -***************************************************************************/ +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** -const attotime attotime_zero = STATIC_ATTOTIME_IN_SEC(0); -const attotime attotime_never = STATIC_ATTOTIME_IN_SEC(ATTOTIME_MAX_SECONDS); +const attotime attotime::zero(0, 0); +const attotime attotime::never(ATTOTIME_MAX_SECONDS, 0); -/*************************************************************************** - CORE MATH FUNCTIONS -***************************************************************************/ +//************************************************************************** +// CORE MATH FUNCTIONS +//************************************************************************** -/*------------------------------------------------- - attotime_mul - multiply an attotime by - a constant --------------------------------------------------*/ +//------------------------------------------------- +// operator*= - multiply an attotime by a +// constant +//------------------------------------------------- -attotime attotime_mul(attotime _time1, UINT32 factor) +attotime &attotime::operator*=(UINT32 factor) { - UINT32 attolo, attohi, reslo, reshi; - UINT64 temp; - - /* if one of the items is attotime_never, return attotime_never */ - if (_time1.seconds >= ATTOTIME_MAX_SECONDS) - return attotime_never; + // if one of the items is attotime_never, return attotime_never + if (seconds >= ATTOTIME_MAX_SECONDS) + return *this = never; - /* 0 times anything is zero */ + // 0 times anything is zero if (factor == 0) - return attotime_zero; + return *this = zero; - /* split attoseconds into upper and lower halves which fit into 32 bits */ - attohi = divu_64x32_rem(_time1.attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo); + // split attoseconds into upper and lower halves which fit into 32 bits + UINT32 attolo; + UINT32 attohi = divu_64x32_rem(attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo); - /* scale the lower half, then split into high/low parts */ - temp = mulu_32x32(attolo, factor); + // scale the lower half, then split into high/low parts + UINT64 temp = mulu_32x32(attolo, factor); + UINT32 reslo; temp = divu_64x32_rem(temp, ATTOSECONDS_PER_SECOND_SQRT, &reslo); - /* scale the upper half, then split into high/low parts */ + // scale the upper half, then split into high/low parts temp += mulu_32x32(attohi, factor); + UINT32 reshi; temp = divu_64x32_rem(temp, ATTOSECONDS_PER_SECOND_SQRT, &reshi); - /* scale the seconds */ - temp += mulu_32x32(_time1.seconds, factor); + // scale the seconds + temp += mulu_32x32(seconds, factor); if (temp >= ATTOTIME_MAX_SECONDS) - return attotime_never; + return *this = never; - /* build the result */ - return attotime_make(temp, (attoseconds_t)reslo + mul_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT)); + // build the result + seconds = temp; + attoseconds = (attoseconds_t)reslo + mul_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT); + return *this; } -/*------------------------------------------------- - attotime_div - divide an attotime by - a constant --------------------------------------------------*/ +//------------------------------------------------- +// operator/= - divide an attotime by a constant +//------------------------------------------------- -attotime attotime_div(attotime _time1, UINT32 factor) +attotime &attotime::operator/=(UINT32 factor) { - UINT32 attolo, attohi, reshi, reslo, remainder; - attotime result; - UINT64 temp; + // if one of the items is attotime_never, return attotime_never + if (seconds >= ATTOTIME_MAX_SECONDS) + return *this = never; - /* if one of the items is attotime_never, return attotime_never */ - if (_time1.seconds >= ATTOTIME_MAX_SECONDS) - return attotime_never; - - /* ignore divide by zero */ + // ignore divide by zero if (factor == 0) - return _time1; + return *this; - /* split attoseconds into upper and lower halves which fit into 32 bits */ - attohi = divu_64x32_rem(_time1.attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo); + // split attoseconds into upper and lower halves which fit into 32 bits + UINT32 attolo; + UINT32 attohi = divu_64x32_rem(attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo); - /* divide the seconds and get the remainder */ - result.seconds = divu_64x32_rem(_time1.seconds, factor, &remainder); + // divide the seconds and get the remainder + UINT32 remainder; + seconds = divu_64x32_rem(seconds, factor, &remainder); - /* combine the upper half of attoseconds with the remainder and divide that */ - temp = (INT64)attohi + mulu_32x32(remainder, ATTOSECONDS_PER_SECOND_SQRT); - reshi = divu_64x32_rem(temp, factor, &remainder); + // combine the upper half of attoseconds with the remainder and divide that + UINT64 temp = (INT64)attohi + mulu_32x32(remainder, ATTOSECONDS_PER_SECOND_SQRT); + UINT32 reshi = divu_64x32_rem(temp, factor, &remainder); - /* combine the lower half of attoseconds with the remainder and divide that */ + // combine the lower half of attoseconds with the remainder and divide that temp = attolo + mulu_32x32(remainder, ATTOSECONDS_PER_SECOND_SQRT); - reslo = divu_64x32_rem(temp, factor, &remainder); + UINT32 reslo = divu_64x32_rem(temp, factor, &remainder); - /* round based on the remainder */ - result.attoseconds = (attoseconds_t)reslo + mulu_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT); + // round based on the remainder + attoseconds = (attoseconds_t)reslo + mulu_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT); if (remainder >= factor / 2) - if (++result.attoseconds >= ATTOSECONDS_PER_SECOND) + if (++attoseconds >= ATTOSECONDS_PER_SECOND) { - result.attoseconds = 0; - result.seconds++; + attoseconds = 0; + seconds++; } - return result; + return *this; } +//------------------------------------------------- +// as_string - return a temporary printable +// string describing an attotime +//------------------------------------------------- -/*************************************************************************** - MISC UTILITIES -***************************************************************************/ - -/*------------------------------------------------- - attotime_string - return a temporary - printable string describing an attotime --------------------------------------------------*/ - -const char *attotime_string(attotime _time, int precision) +const char *attotime::as_string(int precision) const { static char buffers[8][30]; static int nextbuf; char *buffer = &buffers[nextbuf++ % 8][0]; - /* case 1: we want no precision; seconds only */ + // case 1: we want no precision; seconds only if (precision == 0) - sprintf(buffer, "%d", _time.seconds); + sprintf(buffer, "%d", seconds); - /* case 2: we want 9 or fewer digits of precision */ + // case 2: we want 9 or fewer digits of precision else if (precision <= 9) { - UINT32 upper = _time.attoseconds / ATTOSECONDS_PER_SECOND_SQRT; + UINT32 upper = attoseconds / ATTOSECONDS_PER_SECOND_SQRT; int temp = precision; while (temp < 9) { upper /= 10; temp++; } - sprintf(buffer, "%d.%0*d", _time.seconds, precision, upper); + sprintf(buffer, "%d.%0*d", seconds, precision, upper); } - /* case 3: more than 9 digits of precision */ + // case 3: more than 9 digits of precision else { UINT32 lower; - UINT32 upper = divu_64x32_rem(_time.attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &lower); + UINT32 upper = divu_64x32_rem(attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &lower); int temp = precision; while (temp < 18) { lower /= 10; temp++; } - sprintf(buffer, "%d.%09d%0*d", _time.seconds, upper, precision - 9, lower); + sprintf(buffer, "%d.%09d%0*d", seconds, upper, precision - 9, lower); } return buffer; } diff --git a/src/emu/attotime.h b/src/emu/attotime.h index 60b4f827d67..573f497056d 100644 --- a/src/emu/attotime.h +++ b/src/emu/attotime.h @@ -4,8 +4,36 @@ Support functions for working with attotime data. - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. **************************************************************************** @@ -39,400 +67,392 @@ #include <math.h> -/*************************************************************************** - CONSTANTS -***************************************************************************/ +//************************************************************************** +// CONSTANTS +//************************************************************************** -#define ATTOSECONDS_PER_SECOND_SQRT ((attoseconds_t)1000000000) -#define ATTOSECONDS_PER_SECOND (ATTOSECONDS_PER_SECOND_SQRT * ATTOSECONDS_PER_SECOND_SQRT) -#define ATTOSECONDS_PER_MILLISECOND (ATTOSECONDS_PER_SECOND / 1000) -#define ATTOSECONDS_PER_MICROSECOND (ATTOSECONDS_PER_SECOND / 1000000) -#define ATTOSECONDS_PER_NANOSECOND (ATTOSECONDS_PER_SECOND / 1000000000) +// core components of the attotime structure +typedef INT64 attoseconds_t; +typedef INT32 seconds_t; -#define ATTOTIME_MAX_SECONDS ((seconds_t)1000000000) +// core definitions +const attoseconds_t ATTOSECONDS_PER_SECOND_SQRT = 1000000000; +const attoseconds_t ATTOSECONDS_PER_SECOND = ATTOSECONDS_PER_SECOND_SQRT * ATTOSECONDS_PER_SECOND_SQRT; +const attoseconds_t ATTOSECONDS_PER_MILLISECOND = ATTOSECONDS_PER_SECOND / 1000; +const attoseconds_t ATTOSECONDS_PER_MICROSECOND = ATTOSECONDS_PER_SECOND / 1000000; +const attoseconds_t ATTOSECONDS_PER_NANOSECOND = ATTOSECONDS_PER_SECOND / 1000000000; +const seconds_t ATTOTIME_MAX_SECONDS = 1000000000; -/*************************************************************************** - MACROS -***************************************************************************/ -/* convert between a double and attoseconds */ +//************************************************************************** +// MACROS +//************************************************************************** + +// convert between a double and attoseconds #define ATTOSECONDS_TO_DOUBLE(x) ((double)(x) * 1e-18) #define DOUBLE_TO_ATTOSECONDS(x) ((attoseconds_t)((x) * 1e18)) -/* convert between hertz (as a double) and attoseconds */ +// convert between hertz (as a double) and attoseconds #define ATTOSECONDS_TO_HZ(x) ((double)ATTOSECONDS_PER_SECOND / (double)(x)) #define HZ_TO_ATTOSECONDS(x) ((attoseconds_t)(ATTOSECONDS_PER_SECOND / (x))) -/* macros for converting other seconds types to attoseconds */ +// macros for converting other seconds types to attoseconds #define ATTOSECONDS_IN_SEC(x) ((attoseconds_t)(x) * ATTOSECONDS_PER_SECOND) #define ATTOSECONDS_IN_MSEC(x) ((attoseconds_t)(x) * ATTOSECONDS_PER_MILLISECOND) #define ATTOSECONDS_IN_USEC(x) ((attoseconds_t)(x) * ATTOSECONDS_PER_MICROSECOND) #define ATTOSECONDS_IN_NSEC(x) ((attoseconds_t)(x) * ATTOSECONDS_PER_NANOSECOND) -/* macros for building attotimes from other types at runtime */ -#define ATTOTIME_IN_HZ(hz) attotime_make((0), (HZ_TO_ATTOSECONDS(hz))) -#define ATTOTIME_IN_SEC(s) attotime_make(((s) / 1), ((s) % 1)) -#define ATTOTIME_IN_MSEC(ms) attotime_make(((ms) / 1000), (ATTOSECONDS_IN_MSEC((ms) % 1000))) -#define ATTOTIME_IN_USEC(us) attotime_make(((us) / 1000000), (ATTOSECONDS_IN_USEC((us) % 1000000))) -#define ATTOTIME_IN_NSEC(ns) attotime_make(((ns) / 1000000000), (ATTOSECONDS_IN_NSEC((ns) % 1000000000))) - -/* macros for building attotimes from other types at compile time */ -#define STATIC_ATTOTIME_IN_HZ(hz) { (0), (HZ_TO_ATTOSECONDS(hz)) } -#define STATIC_ATTOTIME_IN_SEC(s) { ((s) / 1), ((s) % 1) } -#define STATIC_ATTOTIME_IN_MSEC(ms) { ((ms) / 1000), (ATTOSECONDS_IN_MSEC((ms) % 1000)) } -#define STATIC_ATTOTIME_IN_USEC(us) { ((us) / 1000000), (ATTOSECONDS_IN_USEC((us) % 1000000)) } -#define STATIC_ATTOTIME_IN_NSEC(ns) { ((ns) / 1000000000), (ATTOSECONDS_IN_NSEC((ns) % 1000000000)) } - -/* macros for building a reduced-resolution attotime for tokenized storage in a UINT64 */ -/* this form supports up to 1000 seconds and sacrifices 1/1000 of the full attotime resolution */ +// macros for building attotimes from other types at runtime +#define ATTOTIME_IN_HZ(hz) attotime::from_hz(hz) +#define ATTOTIME_IN_SEC(s) attotime::from_seconds(s) +#define ATTOTIME_IN_MSEC(ms) attotime::from_msec(ms) +#define ATTOTIME_IN_USEC(us) attotime::from_usec(us) +#define ATTOTIME_IN_NSEC(ns) attotime::from_nsec(ns) + +// macros for building a reduced-resolution attotime for tokenized storage in a UINT64 +// this form supports up to 1000 seconds and sacrifices 1/1000 of the full attotime resolution #define UINT64_ATTOTIME_IN_HZ(hz) ((UINT64)((ATTOSECONDS_PER_SECOND / 1000) / (hz))) #define UINT64_ATTOTIME_IN_SEC(s) ((UINT64)(s) * (ATTOSECONDS_PER_SECOND / 1000)) #define UINT64_ATTOTIME_IN_MSEC(ms) ((UINT64)(ms) * (ATTOSECONDS_PER_SECOND / 1000 / 1000)) #define UINT64_ATTOTIME_IN_USEC(us) ((UINT64)(us) * (ATTOSECONDS_PER_SECOND / 1000 / 1000 / 1000)) #define UINT64_ATTOTIME_IN_NSEC(ns) ((UINT64)(ns) * (ATTOSECONDS_PER_SECOND / 1000 / 1000 / 1000 / 1000)) -/* macros for converting a UINT64 attotime to a full attotime */ -#define UINT64_ATTOTIME_TO_ATTOTIME(v) attotime_make((v) / (ATTOSECONDS_PER_SECOND / 1000), ((v) % (ATTOSECONDS_PER_SECOND / 1000)) * 1000) - +// macros for converting a UINT64 attotime to a full attotime +#define UINT64_ATTOTIME_TO_ATTOTIME(v) attotime((v) / (ATTOSECONDS_PER_SECOND / 1000), ((v) % (ATTOSECONDS_PER_SECOND / 1000)) * 1000) -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -/* core components of the attotime structure */ -typedef INT64 attoseconds_t; -typedef INT32 seconds_t; +//************************************************************************** +// TYPE DEFINITIONS +//***************************************************************************/ -/* the attotime structure itself */ -typedef struct _attotime attotime; -struct _attotime +// the attotime structure itself +class attotime { +public: + // construction/destruction + attotime() + : seconds(0), + attoseconds(0) { } + + attotime(seconds_t secs, attoseconds_t attos) + : seconds(secs), + attoseconds(attos) { } + + // queries + bool is_zero() const { return (seconds == 0 && attoseconds == 0); } + bool is_never() const { return (seconds >= ATTOTIME_MAX_SECONDS); } + + // conversion to other forms + double as_double() const { return double(seconds) + ATTOSECONDS_TO_DOUBLE(attoseconds); } + attoseconds_t as_attoseconds() const; + UINT64 as_ticks(UINT32 frequency) const; + const char *as_string(int precision = 9) const; + + // conversion from other forms + static attotime from_double(double _time); + static attotime from_ticks(UINT64 ticks, UINT32 frequency); + static attotime from_seconds(INT32 seconds) { return attotime(seconds, 0); } + static attotime from_msec(INT64 msec) { return attotime(msec / 1000, (msec % 1000) * (ATTOSECONDS_PER_SECOND / 1000)); } + static attotime from_usec(INT64 usec) { return attotime(usec / 1000000, (usec % 1000000) * (ATTOSECONDS_PER_SECOND / 1000000)); } + static attotime from_nsec(INT64 nsec) { return attotime(nsec / 1000000000, (nsec % 1000000000) * (ATTOSECONDS_PER_SECOND / 1000000000)); } + static attotime from_hz(double frequency) { return attotime(0, double(ATTOSECONDS_PER_SECOND) / frequency); } + + // math + attotime &operator+=(const attotime &right); + attotime &operator-=(const attotime &right); + attotime &operator*=(UINT32 factor); + attotime &operator/=(UINT32 factor); + + // members seconds_t seconds; attoseconds_t attoseconds; -}; + // constants + static const attotime never; + static const attotime zero; +}; -/*************************************************************************** - GLOBAL VARIABLES -***************************************************************************/ - -/* constant times for zero and never */ -extern const attotime attotime_zero; -extern const attotime attotime_never; - - - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -/* ----- core math functions ----- */ - -/* multiply an attotime by a constant */ -attotime attotime_mul(attotime _time1, UINT32 factor); - -/* divide an attotime by a constant */ -attotime attotime_div(attotime _time1, UINT32 factor); - -/* ----- misc utilities ----- */ +//************************************************************************** +// INLINE FUNCTIONS +//************************************************************************** -/* return a temporary printable string describing an attotime */ -const char *attotime_string(attotime _time, int precision); +//------------------------------------------------- +// operator+ - handle addition between two +// attotimes +//------------------------------------------------- +inline attotime operator+(const attotime &left, const attotime &right) +{ + attotime result; + // if one of the items is never, return never + if (left.seconds >= ATTOTIME_MAX_SECONDS || right.seconds >= ATTOTIME_MAX_SECONDS) + return attotime::never; -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ + // add the seconds and attoseconds + result.attoseconds = left.attoseconds + right.attoseconds; + result.seconds = left.seconds + right.seconds; -/*------------------------------------------------- - attotime_make - assemble an attotime from - seconds and attoseconds components --------------------------------------------------*/ + // normalize and return + if (result.attoseconds >= ATTOSECONDS_PER_SECOND) + { + result.attoseconds -= ATTOSECONDS_PER_SECOND; + result.seconds++; + } -INLINE attotime attotime_make(seconds_t _secs, attoseconds_t _subsecs) -{ - attotime result; - result.seconds = _secs; - result.attoseconds = _subsecs; + // overflow + if (result.seconds >= ATTOTIME_MAX_SECONDS) + return attotime::never; return result; } +inline attotime &attotime::operator+=(const attotime &right) +{ + // if one of the items is never, return never + if (this->seconds >= ATTOTIME_MAX_SECONDS || right.seconds >= ATTOTIME_MAX_SECONDS) + return *this = never; -/*------------------------------------------------- - attotime_to_double - convert from attotime - to double --------------------------------------------------*/ + // add the seconds and attoseconds + attoseconds += right.attoseconds; + seconds += right.seconds; -INLINE double attotime_to_double(attotime _time) -{ - return (double)_time.seconds + ATTOSECONDS_TO_DOUBLE(_time.attoseconds); + // normalize and return + if (this->attoseconds >= ATTOSECONDS_PER_SECOND) + { + this->attoseconds -= ATTOSECONDS_PER_SECOND; + this->seconds++; + } + + // overflow + if (this->seconds >= ATTOTIME_MAX_SECONDS) + return *this = never; + return *this; } -/*------------------------------------------------- - double_to_attotime - convert from double to - attotime --------------------------------------------------*/ +//------------------------------------------------- +// operator- - handle subtraction between two +// attotimes +//------------------------------------------------- -INLINE attotime double_to_attotime(double _time) +inline attotime operator-(const attotime &left, const attotime &right) { attotime result; - /* set seconds to the integral part */ - result.seconds = floor(_time); + // if time1 is never, return never + if (left.seconds >= ATTOTIME_MAX_SECONDS) + return attotime::never; + + // add the seconds and attoseconds + result.attoseconds = left.attoseconds - right.attoseconds; + result.seconds = left.seconds - right.seconds; - /* set attoseconds to the fractional part */ - _time -= (double)result.seconds; - result.attoseconds = DOUBLE_TO_ATTOSECONDS(_time); + // normalize and return + if (result.attoseconds < 0) + { + result.attoseconds += ATTOSECONDS_PER_SECOND; + result.seconds--; + } return result; } - -/*------------------------------------------------- - attotime_to_attoseconds - convert a attotime - to attoseconds, clamping to maximum positive/ - negative values --------------------------------------------------*/ - -INLINE attoseconds_t attotime_to_attoseconds(attotime _time) +inline attotime &attotime::operator-=(const attotime &right) { - /* positive values between 0 and 1 second */ - if (_time.seconds == 0) - return _time.attoseconds; - - /* negative values between -1 and 0 seconds */ - else if (_time.seconds == -1) - return _time.attoseconds - ATTOSECONDS_PER_SECOND; + // if time1 is never, return never + if (this->seconds >= ATTOTIME_MAX_SECONDS) + return *this = never; - /* out-of-range positive values */ - else if (_time.seconds > 0) - return ATTOSECONDS_PER_SECOND; + // add the seconds and attoseconds + attoseconds -= right.attoseconds; + seconds -= right.seconds; - /* out-of-range negative values */ - else - return -ATTOSECONDS_PER_SECOND; + // normalize and return + if (this->attoseconds < 0) + { + this->attoseconds += ATTOSECONDS_PER_SECOND; + this->seconds--; + } + return *this; } -/*------------------------------------------------- - attotime_to_ticks - convert an attotime to - clock ticks at the given frequency --------------------------------------------------*/ +//------------------------------------------------- +// operator* - handle multiplication/division by +// an integral factor; defined in terms of the +// assignment operators +//------------------------------------------------- -INLINE UINT64 attotime_to_ticks(attotime _time, UINT32 frequency) +inline attotime operator*(const attotime &left, UINT32 factor) { - UINT32 fracticks = attotime_mul(attotime_make(0, _time.attoseconds), frequency).seconds; - return mulu_32x32(_time.seconds, frequency) + fracticks; + attotime result = left; + result *= factor; + return result; } - -/*------------------------------------------------- - ticks_to_attotime - convert clock ticks at - the given frequency to an attotime --------------------------------------------------*/ - -INLINE attotime ticks_to_attotime(UINT64 ticks, UINT32 frequency) +inline attotime operator*(UINT32 factor, const attotime &right) { - attoseconds_t attos_per_tick = HZ_TO_ATTOSECONDS(frequency); - attotime result; - - if (ticks < frequency) - { - result.seconds = 0; - result.attoseconds = ticks * attos_per_tick; - } - else - { - UINT32 remainder; - result.seconds = divu_64x32_rem(ticks, frequency, &remainder); - result.attoseconds = (UINT64)remainder * attos_per_tick; - } + attotime result = right; + result *= factor; return result; } - -/*------------------------------------------------- - attotime_add - add two attotimes --------------------------------------------------*/ - -INLINE attotime attotime_add(attotime _time1, attotime _time2) +inline attotime operator/(const attotime &left, UINT32 factor) { - attotime result; - - /* if one of the items is attotime_never, return attotime_never */ - if (_time1.seconds >= ATTOTIME_MAX_SECONDS || _time2.seconds >= ATTOTIME_MAX_SECONDS) - return attotime_never; - - /* add the seconds and attoseconds */ - result.attoseconds = _time1.attoseconds + _time2.attoseconds; - result.seconds = _time1.seconds + _time2.seconds; - - /* normalize and return */ - if (result.attoseconds >= ATTOSECONDS_PER_SECOND) - { - result.attoseconds -= ATTOSECONDS_PER_SECOND; - result.seconds++; - } - - /* overflow */ - if (result.seconds >= ATTOTIME_MAX_SECONDS) - return attotime_never; + attotime result = left; + result /= factor; return result; } -/*------------------------------------------------- - attotime_add_attoseconds - add attoseconds - to a attotime --------------------------------------------------*/ +//------------------------------------------------- +// operator== - handle comparisons between +// attotimes +//------------------------------------------------- -INLINE attotime attotime_add_attoseconds(attotime _time1, attoseconds_t _attoseconds) +inline bool operator==(const attotime &left, const attotime &right) { - attotime result; + return (left.seconds == right.seconds && left.attoseconds == right.attoseconds); +} - /* if one of the items is attotime_never, return attotime_never */ - if (_time1.seconds >= ATTOTIME_MAX_SECONDS) - return attotime_never; +inline bool operator!=(const attotime &left, const attotime &right) +{ + return (left.seconds != right.seconds || left.attoseconds != right.attoseconds); +} - /* add the seconds and attoseconds */ - result.attoseconds = _time1.attoseconds + _attoseconds; - result.seconds = _time1.seconds; +inline bool operator<(const attotime &left, const attotime &right) +{ + return (left.seconds < right.seconds || (left.seconds == right.seconds && left.attoseconds < right.attoseconds)); +} - /* normalize and return */ - if (result.attoseconds >= ATTOSECONDS_PER_SECOND) - { - result.attoseconds -= ATTOSECONDS_PER_SECOND; - result.seconds++; - } +inline bool operator<=(const attotime &left, const attotime &right) +{ + return (left.seconds < right.seconds || (left.seconds == right.seconds && left.attoseconds <= right.attoseconds)); +} - /* overflow */ - if (result.seconds >= ATTOTIME_MAX_SECONDS) - return attotime_never; - return result; +inline bool operator>(const attotime &left, const attotime &right) +{ + return (left.seconds > right.seconds || (left.seconds == right.seconds && left.attoseconds > right.attoseconds)); } +inline bool operator>=(const attotime &left, const attotime &right) +{ + return (left.seconds > right.seconds || (left.seconds == right.seconds && left.attoseconds >= right.attoseconds)); +} -/*------------------------------------------------- - attotime_sub - subtract two attotimes --------------------------------------------------*/ -INLINE attotime attotime_sub(attotime _time1, attotime _time2) +//------------------------------------------------- +// min - return the minimum of two attotimes +//------------------------------------------------- + +inline attotime min(const attotime &left, const attotime &right) { - attotime result; + if (left.seconds > right.seconds) + return right; + if (left.seconds < right.seconds) + return left; + if (left.attoseconds > right.attoseconds) + return right; + return left; +} - /* if time1 is attotime_never, return attotime_never */ - if (_time1.seconds >= ATTOTIME_MAX_SECONDS) - return attotime_never; - /* add the seconds and attoseconds */ - result.attoseconds = _time1.attoseconds - _time2.attoseconds; - result.seconds = _time1.seconds - _time2.seconds; +//------------------------------------------------- +// max - return the maximum of two attotimes +//------------------------------------------------- - /* normalize and return */ - if (result.attoseconds < 0) - { - result.attoseconds += ATTOSECONDS_PER_SECOND; - result.seconds--; - } - return result; +inline attotime max(const attotime &left, const attotime &right) +{ + if (left.seconds > right.seconds) + return right; + if (left.seconds < right.seconds) + return left; + if (left.attoseconds > right.attoseconds) + return right; + return left; } -/*------------------------------------------------- - attotime_sub_attoseconds - subtract - attoseconds from a attotime --------------------------------------------------*/ +//------------------------------------------------- +// as_attoseconds - convert to an attoseconds +// value, clamping to +/- 1 second +//------------------------------------------------- -INLINE attotime attotime_sub_attoseconds(attotime _time1, attoseconds_t _attoseconds) +inline attoseconds_t attotime::as_attoseconds() const { - attotime result; + // positive values between 0 and 1 second + if (seconds == 0) + return attoseconds; - /* if time1 is attotime_never, return attotime_never */ - if (_time1.seconds >= ATTOTIME_MAX_SECONDS) - return attotime_never; + // negative values between -1 and 0 seconds + else if (seconds == -1) + return attoseconds - ATTOSECONDS_PER_SECOND; - /* add the seconds and attoseconds */ - result.attoseconds = _time1.attoseconds - _attoseconds; - result.seconds = _time1.seconds; + // out-of-range positive values + else if (seconds > 0) + return ATTOSECONDS_PER_SECOND; - /* normalize and return */ - if (result.attoseconds < 0) - { - result.attoseconds += ATTOSECONDS_PER_SECOND; - result.seconds--; - } - return result; + // out-of-range negative values + else + return -ATTOSECONDS_PER_SECOND; } -/*------------------------------------------------- - attotime_compare - compare two attotimes --------------------------------------------------*/ +//------------------------------------------------- +// as_ticks - convert to ticks at the given +// frequency +//------------------------------------------------- -INLINE int attotime_compare(attotime _time1, attotime _time2) +inline UINT64 attotime::as_ticks(UINT32 frequency) const { - if (_time1.seconds > _time2.seconds) - return 1; - if (_time1.seconds < _time2.seconds) - return -1; - if (_time1.attoseconds > _time2.attoseconds) - return 1; - if (_time1.attoseconds < _time2.attoseconds) - return -1; - return 0; + UINT32 fracticks = (attotime(0, attoseconds) * frequency).seconds; + return mulu_32x32(seconds, frequency) + fracticks; } + +//------------------------------------------------- +// from_ticks - create an attotime from a tick +// count at the given frequency +//------------------------------------------------- -/*------------------------------------------------- - attotime_min - return the minimum of two - attotimes --------------------------------------------------*/ - -INLINE attotime attotime_min(attotime _time1, attotime _time2) +inline attotime attotime::from_ticks(UINT64 ticks, UINT32 frequency) { - if (_time1.seconds > _time2.seconds) - return _time2; - if (_time1.seconds < _time2.seconds) - return _time1; - if (_time1.attoseconds > _time2.attoseconds) - return _time2; - return _time1; -} + attoseconds_t attos_per_tick = HZ_TO_ATTOSECONDS(frequency); + + if (ticks < frequency) + return attotime(0, ticks * attos_per_tick); + UINT32 remainder; + INT32 secs = divu_64x32_rem(ticks, frequency, &remainder); + return attotime(secs, (UINT64)remainder * attos_per_tick); +} + -/*------------------------------------------------- - attotime_max - return the maximum of two - attotimes --------------------------------------------------*/ +//------------------------------------------------- +// from_double - create an attotime from floating +// point count of seconds +//------------------------------------------------- -INLINE attotime attotime_max(attotime _time1, attotime _time2) +inline attotime attotime::from_double(double _time) { - if (_time1.seconds > _time2.seconds) - return _time1; - if (_time1.seconds < _time2.seconds) - return _time2; - if (_time1.attoseconds > _time2.attoseconds) - return _time1; - return _time2; + seconds_t secs = floor(_time); + _time -= double(secs); + attoseconds_t attos = DOUBLE_TO_ATTOSECONDS(_time); + return attotime(secs, attos); } + -/*------------------------------------------------- - attotime_is_never - return whether or not an - attotime is attotime_never --------------------------------------------------*/ +//************************************************************************** +// LEGACY MAPPINGS +//************************************************************************** -INLINE int attotime_is_never(attotime _time) -{ - return (_time.seconds >= ATTOTIME_MAX_SECONDS); -} +#define attotime_zero attotime::zero +#define attotime_never attotime::never -#endif /* __ATTOTIME_H__ */ +#endif // __ATTOTIME_H__ diff --git a/src/emu/cpu/h83002/h8periph.c b/src/emu/cpu/h83002/h8periph.c index a0cc7959431..85aa8d8e3e3 100644 --- a/src/emu/cpu/h83002/h8periph.c +++ b/src/emu/cpu/h83002/h8periph.c @@ -96,7 +96,7 @@ static void h8_itu_refresh_timer(h83xx_state *h8, int tnum) ourTCR = h8->per_regs[tcr[tnum]]; ourTVAL = h8->h8TCNT[tnum]; - period = attotime_mul(ATTOTIME_IN_HZ(h8->device->unscaled_clock()), tscales[ourTCR & 3] * (65536 - ourTVAL)); + period = attotime::from_hz(h8->device->unscaled_clock()) * tscales[ourTCR & 3] * (65536 - ourTVAL); if (ourTCR & 4) { @@ -115,10 +115,10 @@ static void h8_itu_sync_timers(h83xx_state *h8, int tnum) ourTCR = h8->per_regs[tcr[tnum]]; // get the time per unit - cycle_time = attotime_mul(ATTOTIME_IN_HZ(h8->device->unscaled_clock()), tscales[ourTCR & 3]); + cycle_time = attotime::from_hz(h8->device->unscaled_clock()) * tscales[ourTCR & 3]; cur = timer_timeelapsed(h8->timer[tnum]); - ratio = attotime_to_double(cur) / attotime_to_double(cycle_time); + ratio = cur.as_double() / cycle_time.as_double(); h8->h8TCNT[tnum] = ratio; } @@ -457,7 +457,7 @@ static void h8_3007_itu_refresh_timer(h83xx_state *h8, int tnum) attotime period; int ourTCR = h8->per_regs[0x68+(tnum*8)]; - period = attotime_mul(ATTOTIME_IN_HZ(h8->device->unscaled_clock()), tscales[ourTCR & 3]); + period = attotime::from_hz(h8->device->unscaled_clock()) * tscales[ourTCR & 3]; if (ourTCR & 4) { diff --git a/src/emu/cpu/m37710/m37710.c b/src/emu/cpu/m37710/m37710.c index b8a250b610d..61cbebf990a 100644 --- a/src/emu/cpu/m37710/m37710.c +++ b/src/emu/cpu/m37710/m37710.c @@ -327,11 +327,11 @@ static void m37710_recalc_timer(m37710i_cpu_struct *cpustate, int timer) switch (cpustate->m37710_regs[0x56+timer] & 0x3) { case 0: // timer mode - time = attotime_mul(ATTOTIME_IN_HZ(cpustate->device->unscaled_clock()), tscales[cpustate->m37710_regs[tcr[timer]]>>6]); - time = attotime_mul(time, tval + 1); + time = attotime::from_hz(cpustate->device->unscaled_clock()) * tscales[cpustate->m37710_regs[tcr[timer]]>>6]; + time *= tval + 1; #if M37710_DEBUG - mame_printf_debug("Timer %d in timer mode, %f Hz\n", timer, 1.0 / attotime_to_double(time)); + mame_printf_debug("Timer %d in timer mode, %f Hz\n", timer, 1.0 / time.as_double()); #endif timer_adjust_oneshot(cpustate->timers[timer], time, timer); @@ -362,11 +362,11 @@ static void m37710_recalc_timer(m37710i_cpu_struct *cpustate, int timer) switch (cpustate->m37710_regs[0x56+timer] & 0x3) { case 0: // timer mode - time = attotime_mul(ATTOTIME_IN_HZ(cpustate->device->unscaled_clock()), tscales[cpustate->m37710_regs[tcr[timer]]>>6]); - time = attotime_mul(time, tval + 1); + time = attotime::from_hz(cpustate->device->unscaled_clock()) * tscales[cpustate->m37710_regs[tcr[timer]]>>6]; + time *= tval + 1; #if M37710_DEBUG - mame_printf_debug("Timer %d in timer mode, %f Hz\n", timer, 1.0 / attotime_to_double(time)); + mame_printf_debug("Timer %d in timer mode, %f Hz\n", timer, 1.0 / time.as_double()); #endif timer_adjust_oneshot(cpustate->timers[timer], time, timer); diff --git a/src/emu/cpu/nec/v25.c b/src/emu/cpu/nec/v25.c index 8c321c43d65..c4ce9aaade7 100644 --- a/src/emu/cpu/nec/v25.c +++ b/src/emu/cpu/nec/v25.c @@ -191,7 +191,7 @@ static CPU_RESET( v25 ) nec_state->IDB = 0xFFE00; tmp = nec_state->PCK << nec_state->TB; - time = attotime_mul(ATTOTIME_IN_HZ(nec_state->device->unscaled_clock()), tmp); + time = attotime::from_hz(nec_state->device->unscaled_clock()) * tmp; timer_adjust_periodic(nec_state->timers[3], time, INTTB, time); timer_adjust_oneshot(nec_state->timers[0], attotime_never, 0); diff --git a/src/emu/cpu/nec/v25sfr.c b/src/emu/cpu/nec/v25sfr.c index 6734e67a994..9da85ad5ced 100644 --- a/src/emu/cpu/nec/v25sfr.c +++ b/src/emu/cpu/nec/v25sfr.c @@ -193,7 +193,7 @@ static void write_sfr(v25_state_t *nec_state, unsigned o, UINT8 d) if(d & 0x80) { tmp = nec_state->TM0 * nec_state->PCK * ((d & 0x40) ? 128 : 12 ); - time = attotime_mul(ATTOTIME_IN_HZ(nec_state->device->unscaled_clock()), tmp); + time = attotime::from_hz(nec_state->device->unscaled_clock()) * tmp; timer_adjust_oneshot(nec_state->timers[0], time, INTTU0); } else @@ -202,7 +202,7 @@ static void write_sfr(v25_state_t *nec_state, unsigned o, UINT8 d) if(d & 0x20) { tmp = nec_state->MD0 * nec_state->PCK * ((d & 0x10) ? 128 : 12 ); - time = attotime_mul(ATTOTIME_IN_HZ(nec_state->device->unscaled_clock()), tmp); + time = attotime::from_hz(nec_state->device->unscaled_clock()) * tmp; timer_adjust_oneshot(nec_state->timers[1], time, INTTU1); } else @@ -213,7 +213,7 @@ static void write_sfr(v25_state_t *nec_state, unsigned o, UINT8 d) if(d & 0x80) { tmp = nec_state->MD0 * nec_state->PCK * ((d & 0x40) ? 128 : 6 ); - time = attotime_mul(ATTOTIME_IN_HZ(nec_state->device->unscaled_clock()), tmp); + time = attotime::from_hz(nec_state->device->unscaled_clock()) * tmp; timer_adjust_periodic(nec_state->timers[0], time, INTTU0, time); timer_adjust_oneshot(nec_state->timers[1], attotime_never, 0); nec_state->TM0 = nec_state->MD0; @@ -230,7 +230,7 @@ static void write_sfr(v25_state_t *nec_state, unsigned o, UINT8 d) if(d & 0x80) { tmp = nec_state->MD1 * nec_state->PCK * ((d & 0x40) ? 128 : 6 ); - time = attotime_mul(ATTOTIME_IN_HZ(nec_state->device->unscaled_clock()), tmp); + time = attotime::from_hz(nec_state->device->unscaled_clock()) * tmp; timer_adjust_periodic(nec_state->timers[2], time, INTTU2, time); nec_state->TM1 = nec_state->MD1; } @@ -262,7 +262,7 @@ static void write_sfr(v25_state_t *nec_state, unsigned o, UINT8 d) nec_state->PCK = 8; } tmp = nec_state->PCK << nec_state->TB; - time = attotime_mul(ATTOTIME_IN_HZ(nec_state->device->unscaled_clock()), tmp); + time = attotime::from_hz(nec_state->device->unscaled_clock()) * tmp; timer_adjust_periodic(nec_state->timers[3], time, INTTB, time); logerror(" Internal RAM %sabled\n", (nec_state->RAMEN ? "en" : "dis")); logerror(" Time base set to 2^%d\n", nec_state->TB); diff --git a/src/emu/cpu/powerpc/ppccom.c b/src/emu/cpu/powerpc/ppccom.c index 39e532aef92..1404acb8099 100644 --- a/src/emu/cpu/powerpc/ppccom.c +++ b/src/emu/cpu/powerpc/ppccom.c @@ -1911,7 +1911,7 @@ static void ppc4xx_spu_timer_reset(powerpc_state *ppc) attotime clockperiod = ATTOTIME_IN_HZ((ppc->dcr[DCR4XX_IOCR] & 0x02) ? 3686400 : 33333333); int divisor = ((ppc->spu.regs[SPU4XX_BAUD_DIVISOR_H] * 256 + ppc->spu.regs[SPU4XX_BAUD_DIVISOR_L]) & 0xfff) + 1; int bpc = 7 + ((ppc->spu.regs[SPU4XX_CONTROL] & 8) >> 3) + 1 + (ppc->spu.regs[SPU4XX_CONTROL] & 1); - attotime charperiod = attotime_mul(clockperiod, divisor * 16 * bpc); + attotime charperiod = clockperiod * (divisor * 16 * bpc); timer_adjust_periodic(ppc->spu.timer, charperiod, 0, charperiod); if (PRINTF_SPU) printf("ppc4xx_spu_timer_reset: baud rate = %.0f\n", ATTOSECONDS_TO_HZ(charperiod.attoseconds) * bpc); diff --git a/src/emu/cpu/sh4/sh4comn.c b/src/emu/cpu/sh4/sh4comn.c index 0180bfca84c..6deae7852d9 100644 --- a/src/emu/cpu/sh4/sh4comn.c +++ b/src/emu/cpu/sh4/sh4comn.c @@ -212,7 +212,7 @@ static UINT32 compute_ticks_refresh_timer(emu_timer *timer, int hertz, int base, // elapsed:total = x : ticks // x=elapsed*tics/total -> x=elapsed*(double)100000000/rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] // ticks/total=ticks / ((rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] * ticks) / 100000000)=1/((rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] / 100000000)=100000000/rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] - return base + (UINT32)((attotime_to_double(timer_timeelapsed(timer)) * (double)hertz) / (double)divisor); + return base + (UINT32)((timer_timeelapsed(timer).as_double() * (double)hertz) / (double)divisor); } static void sh4_refresh_timer_recompute(sh4_state *sh4) @@ -224,7 +224,7 @@ UINT32 ticks; ticks = sh4->m[RTCOR]-sh4->m[RTCNT]; if (ticks <= 0) ticks = 256 + ticks; - timer_adjust_oneshot(sh4->refresh_timer, attotime_mul(attotime_mul(ATTOTIME_IN_HZ(sh4->bus_clock), rtcnt_div[(sh4->m[RTCSR] >> 3) & 7]), ticks), 0); + timer_adjust_oneshot(sh4->refresh_timer, attotime::from_hz(sh4->bus_clock) * rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] * ticks, 0); sh4->refresh_timer_base = sh4->m[RTCNT]; } @@ -235,14 +235,14 @@ UINT32 ticks; INLINE attotime sh4_scale_up_mame_time(attotime _time1, UINT32 factor1) { - return attotime_add(attotime_mul(_time1, factor1), _time1); + return _time1 * factor1 + _time1; } static UINT32 compute_ticks_timer(emu_timer *timer, int hertz, int divisor) { double ret; - ret=((attotime_to_double(timer_timeleft(timer)) * (double)hertz) / (double)divisor) - 1; + ret=((timer_timeleft(timer).as_double() * (double)hertz) / (double)divisor) - 1; return (UINT32)ret; } @@ -251,7 +251,7 @@ static void sh4_timer_recompute(sh4_state *sh4, int which) double ticks; ticks = sh4->m[tcnt[which]]; - timer_adjust_oneshot(sh4->timer[which], sh4_scale_up_mame_time(attotime_mul(ATTOTIME_IN_HZ(sh4->pm_clock), tcnt_div[sh4->m[tcr[which]] & 7]), ticks), which); + timer_adjust_oneshot(sh4->timer[which], sh4_scale_up_mame_time(attotime::from_hz(sh4->pm_clock) * tcnt_div[sh4->m[tcr[which]] & 7], ticks), which); } static TIMER_CALLBACK( sh4_refresh_timer_callback ) diff --git a/src/emu/cpu/tlcs90/tlcs90.c b/src/emu/cpu/tlcs90/tlcs90.c index 2f4606dd086..4e424d19378 100644 --- a/src/emu/cpu/tlcs90/tlcs90.c +++ b/src/emu/cpu/tlcs90/tlcs90.c @@ -2352,11 +2352,11 @@ static void t90_start_timer(t90_Regs *cpustate, int i) } - period = attotime_mul(cpustate->timer_period, prescaler); + period = cpustate->timer_period * prescaler; timer_adjust_periodic(cpustate->timer[i], period, i, period); - logerror("%04X: CPU Timer %d started at %lf Hz\n", cpustate->pc.w.l, i, 1.0 / attotime_to_double(period)); + logerror("%04X: CPU Timer %d started at %lf Hz\n", cpustate->pc.w.l, i, 1.0 / period.as_double()); } static void t90_start_timer4(t90_Regs *cpustate) @@ -2374,11 +2374,11 @@ static void t90_start_timer4(t90_Regs *cpustate) return; } - period = attotime_mul(cpustate->timer_period, prescaler); + period = cpustate->timer_period * prescaler; timer_adjust_periodic(cpustate->timer[4], period, 4, period); - logerror("%04X: CPU Timer 4 started at %lf Hz\n", cpustate->pc.w.l, 1.0 / attotime_to_double(period)); + logerror("%04X: CPU Timer 4 started at %lf Hz\n", cpustate->pc.w.l, 1.0 / period.as_double()); } @@ -2715,7 +2715,7 @@ static CPU_INIT( t90 ) cpustate->program = device->space(AS_PROGRAM); cpustate->io = device->space(AS_IO); - cpustate->timer_period = attotime_mul(ATTOTIME_IN_HZ(device->unscaled_clock()), 8); + cpustate->timer_period = attotime::from_hz(device->unscaled_clock()) * 8; // Reset registers to their initial values diff --git a/src/emu/cpu/tms34010/tms34010.c b/src/emu/cpu/tms34010/tms34010.c index f4e23a2486e..e51b52d1295 100644 --- a/src/emu/cpu/tms34010/tms34010.c +++ b/src/emu/cpu/tms34010/tms34010.c @@ -1040,7 +1040,7 @@ static TIMER_CALLBACK( scanline_callback ) /* note that we add !master (0 or 1) as a attoseconds value; this makes no practical difference */ /* but helps ensure that masters are updated first before slaves */ - timer_adjust_oneshot(tms->scantimer, attotime_add_attoseconds(tms->screen->time_until_pos(vcount), !master), vcount); + timer_adjust_oneshot(tms->scantimer, tms->screen->time_until_pos(vcount) + attotime(0, !master), vcount); } @@ -1494,7 +1494,7 @@ READ16_HANDLER( tms34010_io_register_r ) /* have an IRQ handler. For this reason, we return it signalled a bit early in order */ /* to make it past these loops. */ if (SMART_IOREG(tms, VCOUNT) + 1 == SMART_IOREG(tms, DPYINT) && - attotime_compare(timer_timeleft(tms->scantimer), ATTOTIME_IN_HZ(40000000/8/3)) < 0) + timer_timeleft(tms->scantimer) < attotime::from_hz(40000000/8/3)) result |= TMS34010_DI; return result; } diff --git a/src/emu/cpu/tms9900/99xxcore.h b/src/emu/cpu/tms9900/99xxcore.h index bf55f1eb7b3..751657e4d1e 100644 --- a/src/emu/cpu/tms9900/99xxcore.h +++ b/src/emu/cpu/tms9900/99xxcore.h @@ -933,7 +933,7 @@ WRITE8_HANDLER(tms9995_internal2_w) /* read decrementer */ if (cpustate->decrementer_enabled && !(cpustate->flag & 1)) /* timer mode, timer enabled */ - return cpustate->device->attotime_to_cycles(attotime_div(timer_timeleft(cpustate->timer), 16)); + return cpustate->device->attotime_to_cycles(timer_timeleft(cpustate->timer) / 16); else /* event counter mode or timer mode, timer disabled */ return cpustate->decrementer_count; @@ -997,7 +997,7 @@ WRITE8_HANDLER(tms9995_internal2_w) if (cpustate->decrementer_enabled && !(cpustate->flag & 1)) /* timer mode, timer enabled */ - value = cpustate->device->attotime_to_cycles(attotime_div(timer_timeleft(cpustate->timer), 16)); + value = cpustate->device->attotime_to_cycles(timer_timeleft(cpustate->timer) / 16); else /* event counter mode or timer mode, timer disabled */ value = cpustate->decrementer_count; diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 5f162b8253a..d29230036dd 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -1906,9 +1906,9 @@ void device_debug::instruction_hook(offs_t curpc) if (global->execution_state != EXECUTION_STATE_STOPPED && (m_flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) { // see if we hit a target time - if ((m_flags & DEBUG_FLAG_STOP_TIME) != 0 && attotime_compare(timer_get_time(&machine), m_stoptime) >= 0) + if ((m_flags & DEBUG_FLAG_STOP_TIME) != 0 && timer_get_time(&machine) >= m_stoptime) { - debug_console_printf(&machine, "Stopped at time interval %.1g\n", attotime_to_double(timer_get_time(&machine))); + debug_console_printf(&machine, "Stopped at time interval %.1g\n", timer_get_time(&machine).as_double()); global->execution_state = EXECUTION_STATE_STOPPED; } @@ -2222,7 +2222,7 @@ void device_debug::go_milliseconds(UINT64 milliseconds) assert(m_exec != NULL); - m_stoptime = attotime_add(timer_get_time(m_device.machine), ATTOTIME_IN_MSEC(milliseconds)); + m_stoptime = timer_get_time(m_device.machine) + attotime::from_msec(milliseconds); m_flags |= DEBUG_FLAG_STOP_TIME; global->execution_state = EXECUTION_STATE_RUNNING; } @@ -2777,7 +2777,7 @@ void device_debug::compute_debug_flags() machine->debug_flags |= DEBUG_FLAG_CALL_HOOK; // if we are stopping at a particular time and that time is within the current timeslice, we need to be called - if ((m_flags & DEBUG_FLAG_STOP_TIME) && attotime_compare(m_endexectime, m_stoptime) <= 0) + if ((m_flags & DEBUG_FLAG_STOP_TIME) && m_endexectime <= m_stoptime) machine->debug_flags |= DEBUG_FLAG_CALL_HOOK; } diff --git a/src/emu/devimage.c b/src/emu/devimage.c index 4986e56468f..b3d727ecf4c 100644 --- a/src/emu/devimage.c +++ b/src/emu/devimage.c @@ -500,7 +500,7 @@ done: } else { /* do we need to reset the CPU? only schedule it if load/create is successful */ - if ((attotime_compare(timer_get_time(device().machine), attotime_zero) > 0) && m_image_config.is_reset_on_load()) + if (timer_get_time(device().machine) > attotime::zero && m_image_config.is_reset_on_load()) device().machine->schedule_hard_reset(); else { diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index 77ab7b12a8c..9f3d96e50da 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -650,12 +650,12 @@ void device_t::set_clock_scale(double clockscale) attotime device_t::clocks_to_attotime(UINT64 numclocks) const { if (numclocks < m_clock) - return attotime_make(0, numclocks * m_attoseconds_per_clock); + return attotime(0, numclocks * m_attoseconds_per_clock); else { UINT32 remainder; UINT32 quotient = divu_64x32_rem(numclocks, m_clock, &remainder); - return attotime_make(quotient, (UINT64)remainder * (UINT64)m_attoseconds_per_clock); + return attotime(quotient, (UINT64)remainder * (UINT64)m_attoseconds_per_clock); } } diff --git a/src/emu/diexec.c b/src/emu/diexec.c index c22d5e87155..96a76f4b0ec 100644 --- a/src/emu/diexec.c +++ b/src/emu/diexec.c @@ -246,12 +246,12 @@ bool device_config_execute_interface::interface_validity_check(const game_driver error = true; } - if (m_timed_interrupt != NULL && attotime_compare(m_timed_interrupt_period, attotime_zero) == 0) + if (m_timed_interrupt != NULL && m_timed_interrupt_period == attotime::zero) { mame_printf_error("%s: %s device '%s' has a timer interrupt handler with 0 period!\n", driver.source_file, driver.name, devconfig->tag()); error = true; } - else if (m_timed_interrupt == NULL && attotime_compare(m_timed_interrupt_period, attotime_zero) != 0) + else if (m_timed_interrupt == NULL && m_timed_interrupt_period != attotime::zero) { mame_printf_error("%s: %s device '%s' has a no timer interrupt handler but has a non-0 period given!\n", driver.source_file, driver.name, devconfig->tag()); error = true; @@ -493,7 +493,7 @@ attotime device_execute_interface::local_time() const { assert(m_cycles_running >= *m_icountptr); int cycles = m_cycles_running - *m_icountptr; - result = attotime_add(result, cycles_to_attotime(cycles)); + result += cycles_to_attotime(cycles); } return result; } @@ -559,7 +559,7 @@ void device_execute_interface::interface_pre_start() // allocate timers if we need them if (m_execute_config.m_vblank_interrupts_per_frame > 1) m_partial_frame_timer = timer_alloc(device().machine, static_trigger_partial_frame_interrupt, (void *)this); - if (attotime_compare(m_execute_config.m_timed_interrupt_period, attotime_zero) != 0) + if (m_execute_config.m_timed_interrupt_period != attotime::zero) m_timedint_timer = timer_alloc(device().machine, static_trigger_periodic_interrupt, (void *)this); // register for save states @@ -635,7 +635,7 @@ void device_execute_interface::interface_post_reset() } // reconfigure periodic interrupts - if (attotime_compare(m_execute_config.m_timed_interrupt_period, attotime_zero) != 0) + if (m_execute_config.m_timed_interrupt_period != attotime::zero) { attotime timedint_period = m_execute_config.m_timed_interrupt_period; assert(m_timedint_timer != NULL); @@ -741,7 +741,7 @@ void device_execute_interface::on_vblank_start(screen_device &screen) // if we have more than one interrupt per frame, start the timer now to trigger the rest of them if (m_execute_config.m_vblank_interrupts_per_frame > 1 && !suspended(SUSPEND_REASON_DISABLE)) { - m_partial_frame_period = attotime_div(device().machine->primary_screen->frame_period(), m_execute_config.m_vblank_interrupts_per_frame); + m_partial_frame_period = device().machine->primary_screen->frame_period() / m_execute_config.m_vblank_interrupts_per_frame; timer_adjust_oneshot(m_partial_frame_timer, m_partial_frame_period, 0); } } diff --git a/src/emu/imagedev/bitbngr.c b/src/emu/imagedev/bitbngr.c index a0c3651f18f..0482f73868b 100644 --- a/src/emu/imagedev/bitbngr.c +++ b/src/emu/imagedev/bitbngr.c @@ -409,7 +409,7 @@ static TIMER_CALLBACK(bitbanger_input_timer) if(bi->input_buffer_size == 0) { /* no more data, wait and try again */ - bi->idle_delay = attotime_min(attotime_add(bi->idle_delay, ATTOTIME_IN_MSEC(100)), ATTOTIME_IN_SEC(1)); + bi->idle_delay = min(bi->idle_delay + attotime::from_msec(100), attotime::from_seconds(1)); timer_adjust_oneshot(bi->bitbanger_input_timer, bi->idle_delay, 0); @@ -449,11 +449,11 @@ void bitbanger_output(device_t *device, int value) bi->build_count = 9; bi->build_byte = 0; - one_point_five_baud = attotime_add(bi->current_baud, attotime_div(bi->current_baud,2)); + one_point_five_baud = bi->current_baud + bi->current_baud / 2; timer_adjust_periodic(bi->bitbanger_output_timer, one_point_five_baud, 0, bi->current_baud); } - //fprintf(stderr,"%s, %d\n", attotime_string(timer_get_time(device->machine),9), value); + //fprintf(stderr,"%s, %d\n", timer_get_time(device->machine).as_string(9), value); bi->output_value = value; } diff --git a/src/emu/imagedev/cassette.c b/src/emu/imagedev/cassette.c index ec2018efa81..294f90eecca 100644 --- a/src/emu/imagedev/cassette.c +++ b/src/emu/imagedev/cassette.c @@ -71,7 +71,7 @@ INLINE int cassette_is_motor_on(device_t *device) static void cassette_update(device_t *device) { dev_cassette_t *cassette = get_safe_token( device ); - double cur_time = attotime_to_double(timer_get_time(device->machine)); + double cur_time = timer_get_time(device->machine).as_double(); if (cassette_is_motor_on(device)) { @@ -187,7 +187,7 @@ double cassette_get_position(device_t *device) position = cassette->position; if (cassette_is_motor_on(device)) - position += attotime_to_double(timer_get_time(device->machine)) - cassette->position_time; + position += timer_get_time(device->machine).as_double() - cassette->position_time; return position; } @@ -302,7 +302,7 @@ static DEVICE_IMAGE_LOAD( cassette ) /* reset the position */ cassette->position = 0.0; - cassette->position_time = attotime_to_double(timer_get_time(device->machine)); + cassette->position_time = timer_get_time(device->machine).as_double(); return IMAGE_INIT_PASS; diff --git a/src/emu/imagedev/flopdrv.c b/src/emu/imagedev/flopdrv.c index 8295839a1df..6f22d8dea71 100644 --- a/src/emu/imagedev/flopdrv.c +++ b/src/emu/imagedev/flopdrv.c @@ -244,12 +244,12 @@ static void floppy_drive_index_func(device_t *img) if (drive->idx) { drive->idx = 0; - timer_adjust_oneshot((emu_timer*)drive->index_timer, double_to_attotime(ms*19/20/1000.0), 0); + timer_adjust_oneshot((emu_timer*)drive->index_timer, attotime::from_double(ms*19/20/1000.0), 0); } else { drive->idx = 1; - timer_adjust_oneshot((emu_timer*)drive->index_timer, double_to_attotime(ms/20/1000.0), 0); + timer_adjust_oneshot((emu_timer*)drive->index_timer, attotime::from_double(ms/20/1000.0), 0); } devcb_call_write_line(&drive->out_idx_func, drive->idx); diff --git a/src/emu/imagedev/snapquik.c b/src/emu/imagedev/snapquik.c index 460f2455cb9..804a9ac0107 100644 --- a/src/emu/imagedev/snapquik.c +++ b/src/emu/imagedev/snapquik.c @@ -153,7 +153,7 @@ static DEVICE_IMAGE_LOAD( snapquick ) /* adjust the timer */ timer_adjust_oneshot( token->timer, - attotime_make(config->delay_seconds, config->delay_attoseconds), + attotime(config->delay_seconds, config->delay_attoseconds), 0); return IMAGE_INIT_PASS; diff --git a/src/emu/inptport.c b/src/emu/inptport.c index a4e32ac8a68..e93cb5ec030 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -1536,7 +1536,7 @@ input_port_value input_port_read_direct(const input_port_config *port) /* interpolate if appropriate and if time has passed since the last update */ if (analog->interpolate && !(analog->field->flags & ANALOG_FLAG_RESET) && portdata->last_delta_nsec != 0) { - attoseconds_t nsec_since_last = attotime_to_attoseconds(attotime_sub(timer_get_time(port->machine), portdata->last_frame_time)) / ATTOSECONDS_PER_NANOSECOND; + attoseconds_t nsec_since_last = (timer_get_time(port->machine) - portdata->last_frame_time).as_attoseconds() / ATTOSECONDS_PER_NANOSECOND; value = analog->previous + ((INT64)(analog->accum - analog->previous) * nsec_since_last / portdata->last_delta_nsec); } @@ -2479,7 +2479,7 @@ g_profiler.start(PROFILER_INPUT); record_frame(machine, curtime); /* track the duration of the previous frame */ - portdata->last_delta_nsec = attotime_to_attoseconds(attotime_sub(curtime, portdata->last_frame_time)) / ATTOSECONDS_PER_NANOSECOND; + portdata->last_delta_nsec = (curtime - portdata->last_frame_time).as_attoseconds() / ATTOSECONDS_PER_NANOSECOND; portdata->last_frame_time = curtime; /* update the digital joysticks */ @@ -4478,7 +4478,7 @@ static void playback_frame(running_machine *machine, attotime curtime) /* first the absolute time */ readtime.seconds = playback_read_uint32(machine); readtime.attoseconds = playback_read_uint64(machine); - if (attotime_compare(readtime, curtime) != 0) + if (readtime != curtime) playback_end(machine, "Out of sync"); /* then the speed */ @@ -5024,29 +5024,28 @@ static int can_post_key_alternate(running_machine *machine, unicode_char ch) static attotime choose_delay(input_port_private *portdata, unicode_char ch) { - attoseconds_t delay = 0; - - if (attotime_compare(portdata->current_rate, attotime_zero) != 0) + if (portdata->current_rate != attotime::zero) return portdata->current_rate; + attotime delay = attotime::zero; if (portdata->queue_chars) { /* systems with queue_chars can afford a much smaller delay */ - delay = DOUBLE_TO_ATTOSECONDS(0.01); + delay = attotime::from_msec(10); } else { switch(ch) { case '\r': - delay = DOUBLE_TO_ATTOSECONDS(0.2); + delay = attotime::from_msec(200); break; default: - delay = DOUBLE_TO_ATTOSECONDS(0.05); + delay = attotime::from_msec(50); break; } } - return attotime_make(0, delay); + return delay; } @@ -5156,7 +5155,7 @@ static TIMER_CALLBACK(inputx_timerproc) keybuf->begin_pos++; keybuf->begin_pos %= ARRAY_LENGTH(keybuf->buffer); - if (attotime_compare(portdata->current_rate, attotime_zero) != 0) + if (portdata->current_rate != attotime::zero) break; } } @@ -5282,7 +5281,7 @@ static void inputx_postc_rate(running_machine *machine, unicode_char ch, attotim void inputx_postc(running_machine *machine, unicode_char ch) { - inputx_postc_rate(machine, ch, attotime_make(0, 0)); + inputx_postc_rate(machine, ch, attotime::zero); } static void inputx_postn_utf8_rate(running_machine *machine, const char *text, size_t text_len, attotime rate) @@ -5296,7 +5295,7 @@ static void inputx_postn_utf8_rate(running_machine *machine, const char *text, s { if (len == ARRAY_LENGTH(buf)) { - inputx_postn_rate(machine, buf, len, attotime_make(0, 0)); + inputx_postn_rate(machine, buf, len, attotime::zero); len = 0; } @@ -5315,7 +5314,7 @@ static void inputx_postn_utf8_rate(running_machine *machine, const char *text, s void inputx_post_utf8(running_machine *machine, const char *text) { - inputx_postn_utf8_rate(machine, text, strlen(text), attotime_make(0, 0)); + inputx_postn_utf8_rate(machine, text, strlen(text), attotime::zero); } void inputx_post_utf8_rate(running_machine *machine, const char *text, attotime rate) @@ -5512,7 +5511,7 @@ int input_category_active(running_machine *machine, int category) static void execute_input(running_machine *machine, int ref, int params, const char *param[]) { - inputx_postn_coded_rate(machine, param[0], strlen(param[0]), attotime_make(0, 0)); + inputx_postn_coded_rate(machine, param[0], strlen(param[0]), attotime::zero); } diff --git a/src/emu/machine.c b/src/emu/machine.c index fd700bfea72..a849db02b87 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -466,7 +466,7 @@ void running_machine::schedule_exit() m_scheduler.eat_all_cycles(); // if we're autosaving on exit, schedule a save as well - if (options_get_bool(&m_options, OPTION_AUTOSAVE) && (m_game.flags & GAME_SUPPORTS_SAVE) && attotime_compare(timer_get_time(this), attotime_zero) > 0) + if (options_get_bool(&m_options, OPTION_AUTOSAVE) && (m_game.flags & GAME_SUPPORTS_SAVE) && timer_get_time(this) > attotime::zero) schedule_save("auto"); } @@ -786,7 +786,7 @@ void running_machine::handle_saveload() if (timer_count_anonymous(this) > 0) { // if more than a second has passed, we're probably screwed - if (attotime_sub(timer_get_time(this), m_saveload_schedule_time).seconds > 0) + if ((timer_get_time(this) - m_saveload_schedule_time) > attotime::from_seconds(1)) { popmessage("Unable to %s due to pending anonymous timers. See error.log for details.", opname); goto cancel; diff --git a/src/emu/machine/6522via.c b/src/emu/machine/6522via.c index cdcefc1d6bc..832bed686da 100644 --- a/src/emu/machine/6522via.c +++ b/src/emu/machine/6522via.c @@ -149,13 +149,13 @@ void via6522_device_config::device_config_complete() attotime via6522_device::cycles_to_time(int c) { - return attotime_mul(ATTOTIME_IN_HZ(clock()), c); + return attotime::from_hz(clock()) * c; } UINT32 via6522_device::time_to_cycles(attotime t) { - return attotime_to_double(attotime_mul(t, clock())); + return (t * clock()).as_double(); } @@ -169,7 +169,7 @@ UINT16 via6522_device::get_counter1_value() } else { - val = 0xffff - time_to_cycles(attotime_sub(timer_get_time(&m_machine), m_time1)); + val = 0xffff - time_to_cycles(timer_get_time(&m_machine) - m_time1); } return val; @@ -605,7 +605,7 @@ READ8_MEMBER( via6522_device::read ) } else { - val = (0x10000 - (time_to_cycles(attotime_sub(timer_get_time(&m_machine), m_time2)) & 0xffff) - 1) & 0xff; + val = (0x10000 - (time_to_cycles(timer_get_time(&m_machine) - m_time2) & 0xffff) - 1) & 0xff; } } break; @@ -623,7 +623,7 @@ READ8_MEMBER( via6522_device::read ) } else { - val = (0x10000 - (time_to_cycles(attotime_sub(timer_get_time(&m_machine), m_time2)) & 0xffff) - 1) >> 8; + val = (0x10000 - (time_to_cycles(timer_get_time(&m_machine) - m_time2) & 0xffff) - 1) >> 8; } } break; diff --git a/src/emu/machine/6526cia.c b/src/emu/machine/6526cia.c index f4b19bbf8d3..3b328a26419 100644 --- a/src/emu/machine/6526cia.c +++ b/src/emu/machine/6526cia.c @@ -857,7 +857,7 @@ void mos6526_device::reg_w(UINT8 offset, UINT8 data) static int is_timer_active(emu_timer *timer) { attotime t = timer_firetime(timer); - return attotime_compare(t, attotime_never) != 0; + return (t != attotime::never); } /*------------------------------------------------- @@ -873,7 +873,7 @@ void mos6526_device::cia_timer::update(int which, INT32 new_count) /* update the timer count, if necessary */ if ((new_count == -1) && is_timer_active(m_timer)) { - UINT16 current_count = attotime_to_double(attotime_mul(timer_timeelapsed(m_timer), m_clock)); + UINT16 current_count = (timer_timeelapsed(m_timer) * m_clock).as_double(); m_count = m_count - MIN(m_count, current_count); } @@ -887,7 +887,7 @@ void mos6526_device::cia_timer::update(int which, INT32 new_count) if ((m_mode & 0x01) && ((m_mode & (which ? 0x60 : 0x20)) == 0x00)) { /* timer is on and is connected to clock */ - attotime period = attotime_mul(ATTOTIME_IN_HZ(m_clock), (m_count ? m_count : 0x10000)); + attotime period = attotime::from_hz(m_clock) * (m_count ? m_count : 0x10000); timer_adjust_oneshot(m_timer, period, which); } else @@ -908,7 +908,7 @@ UINT16 mos6526_device::cia_timer::get_count() if (is_timer_active(m_timer)) { - UINT16 current_count = attotime_to_double(attotime_mul(timer_timeelapsed(m_timer), m_clock)); + UINT16 current_count = (timer_timeelapsed(m_timer) * m_clock).as_double(); count = m_count - MIN(m_count, current_count); } else diff --git a/src/emu/machine/6532riot.c b/src/emu/machine/6532riot.c index 2402ba66985..d8e8c2862a6 100644 --- a/src/emu/machine/6532riot.c +++ b/src/emu/machine/6532riot.c @@ -171,13 +171,13 @@ UINT8 riot6532_device::get_timer() /* if counting, return the number of ticks remaining */ else if (m_timerstate == TIMER_COUNTING) { - return attotime_to_ticks(timer_timeleft(m_timer), clock()) >> m_timershift; + return timer_timeleft(m_timer).as_ticks(clock()) >> m_timershift; } /* if finishing, return the number of ticks without the shift */ else { - return attotime_to_ticks(timer_timeleft(m_timer), clock()); + return timer_timeleft(m_timer).as_ticks(clock()); } } @@ -202,7 +202,7 @@ void riot6532_device::timer_end() if(m_timerstate == TIMER_COUNTING) { m_timerstate = TIMER_FINISHING; - timer_adjust_oneshot(m_timer, ticks_to_attotime(256, clock()), 0); + timer_adjust_oneshot(m_timer, attotime::from_ticks(256, clock()), 0); /* signal timer IRQ as well */ m_irqstate |= TIMER_FLAG; @@ -212,7 +212,7 @@ void riot6532_device::timer_end() /* if we finished finishing, keep spinning */ else if (m_timerstate == TIMER_FINISHING) { - timer_adjust_oneshot(m_timer, ticks_to_attotime(256, clock()), 0); + timer_adjust_oneshot(m_timer, attotime::from_ticks(256, clock()), 0); } } @@ -259,8 +259,8 @@ void riot6532_device::reg_w(UINT8 offset, UINT8 data) /* update the timer */ m_timerstate = TIMER_COUNTING; - target = attotime_to_ticks(curtime, clock()) + 1 + (data << m_timershift); - timer_adjust_oneshot(m_timer, attotime_sub(ticks_to_attotime(target, clock()), curtime), 0); + target = curtime.as_ticks(clock()) + 1 + (data << m_timershift); + timer_adjust_oneshot(m_timer, attotime::from_ticks(target, clock()) - curtime, 0); } /* if A4 == 0 and A2 == 1, we are writing to the edge detect control */ diff --git a/src/emu/machine/6840ptm.c b/src/emu/machine/6840ptm.c index 27610fcde31..d7c3532e5ad 100644 --- a/src/emu/machine/6840ptm.c +++ b/src/emu/machine/6840ptm.c @@ -292,11 +292,11 @@ void ptm6840_device::subtract_from_counter(int counter, int count) if (m_enabled[counter]) { - attotime duration = attotime_mul(ATTOTIME_IN_HZ(clock), m_counter[counter]); + attotime duration = attotime::from_hz(clock) * m_counter[counter]; if (counter == 2) { - duration = attotime_mul(duration, m_t3_divisor); + duration *= m_t3_divisor; } timer_adjust_oneshot(m_timer[counter], duration, 0); @@ -390,7 +390,7 @@ UINT16 ptm6840_device::compute_counter( int counter ) PLOG(("MC6840 #%s: %d external clock freq %f \n", tag(), counter, clock)); } /* See how many are left */ - int remaining = attotime_to_double(attotime_mul(timer_timeleft(m_timer[counter]), clock)); + int remaining = (timer_timeleft(m_timer[counter]) * clock).as_double(); /* Adjust the count for dual byte mode */ if (m_control_reg[counter] & 0x04) @@ -454,13 +454,13 @@ void ptm6840_device::reload_count(int idx) /* Set the timer */ PLOG(("MC6840 #%s: reload_count(%d): clock = %f count = %d\n", tag(), idx, clock, count)); - attotime duration = attotime_mul(ATTOTIME_IN_HZ(clock), count); + attotime duration = attotime::from_hz(clock) * count; if (idx == 2) { - duration = attotime_mul(duration, m_t3_divisor); + duration *= m_t3_divisor; } - PLOG(("MC6840 #%s: reload_count(%d): output = %lf\n", tag(), idx, attotime_to_double(duration))); + PLOG(("MC6840 #%s: reload_count(%d): output = %lf\n", tag(), idx, duration.as_double())); #if 0 if (!(m_control_reg[idx] & 0x02)) @@ -833,11 +833,11 @@ void ptm6840_device::ptm6840_set_ext_clock(int counter, double clock) count = count + 1; } - duration = attotime_mul(ATTOTIME_IN_HZ(clock), count); + duration = attotime::from_hz(clock) * count; if (counter == 2) { - duration = attotime_mul(duration, m_t3_divisor); + duration *= m_t3_divisor; } m_enabled[counter] = 1; diff --git a/src/emu/machine/6850acia.c b/src/emu/machine/6850acia.c index 9ae997f8725..110787a720b 100644 --- a/src/emu/machine/6850acia.c +++ b/src/emu/machine/6850acia.c @@ -291,13 +291,13 @@ WRITE8_DEVICE_HANDLER_TRAMPOLINE(acia6850, acia6850_ctrl_w ) { if (m_rx_clock) { - attotime rx_period = attotime_mul(ATTOTIME_IN_HZ(m_rx_clock), m_divide); + attotime rx_period = attotime::from_hz(m_rx_clock) * m_divide; timer_adjust_periodic(m_rx_timer, rx_period, 0, rx_period); } if (m_tx_clock) { - attotime tx_period = attotime_mul(ATTOTIME_IN_HZ(m_tx_clock), m_divide); + attotime tx_period = attotime::from_hz(m_tx_clock) * m_divide; timer_adjust_periodic(m_tx_timer, tx_period, 0, tx_period); } } @@ -745,7 +745,7 @@ void acia6850_device::set_rx_clock(int clock) if (m_rx_clock) { - attotime rx_period = attotime_mul(ATTOTIME_IN_HZ(m_rx_clock), m_divide); + attotime rx_period = attotime::from_hz(m_rx_clock) * m_divide; timer_adjust_periodic(m_rx_timer, rx_period, 0, rx_period); } } @@ -772,7 +772,7 @@ void acia6850_device::set_tx_clock(int clock) if (m_tx_clock) { - attotime tx_period = attotime_mul(ATTOTIME_IN_HZ(m_tx_clock), m_divide); + attotime tx_period = attotime::from_hz(m_tx_clock) * m_divide; timer_adjust_periodic(m_tx_timer, tx_period, 0, tx_period); } } diff --git a/src/emu/machine/68681.c b/src/emu/machine/68681.c index c327a11ee94..88f8abe7d44 100644 --- a/src/emu/machine/68681.c +++ b/src/emu/machine/68681.c @@ -571,7 +571,7 @@ READ8_DEVICE_HANDLER(duart68681_r) case 0x07: /* Timer, CLK/16 */ { //double hz; - //attotime rate = attotime_mul(ATTOTIME_IN_HZ(duart68681->clock), 16*duart68681->CTR.w.l); + //attotime rate = attotime::from_hz(duart68681->clock) * (16*duart68681->CTR.w.l); attotime rate = ATTOTIME_IN_HZ(2*device->clock()/(2*16*16*duart68681->CTR.w.l)); //hz = ATTOSECONDS_TO_HZ(rate.attoseconds); timer_adjust_periodic(duart68681->duart_timer, rate, 0, rate); diff --git a/src/emu/machine/74123.c b/src/emu/machine/74123.c index 551f0351182..9f72e7b3845 100644 --- a/src/emu/machine/74123.c +++ b/src/emu/machine/74123.c @@ -163,7 +163,7 @@ attotime ttl74123_device::compute_duration() break; } - return double_to_attotime(duration); + return attotime::from_double(duration); } @@ -173,8 +173,8 @@ attotime ttl74123_device::compute_duration() int ttl74123_device::timer_running() { - return (attotime_compare(timer_timeleft(m_timer), attotime_zero) > 0) && - (attotime_compare(timer_timeleft(m_timer), attotime_never) != 0); + return (timer_timeleft(m_timer) > attotime::zero) && + (timer_timeleft(m_timer) != attotime::never); } @@ -237,13 +237,13 @@ void ttl74123_device::start_pulse() if(timer_running()) { /* retriggering, but not if we are called to quickly */ - attotime delay_time = attotime_make(0, ATTOSECONDS_PER_SECOND * m_config.m_cap * 220); + attotime delay_time = attotime(0, ATTOSECONDS_PER_SECOND * m_config.m_cap * 220); - if(attotime_compare(timer_timeelapsed(m_timer), delay_time) >= 0) + if(timer_timeelapsed(m_timer) >= delay_time) { timer_adjust_oneshot(m_timer, duration, 0); - if (LOG) logerror("74123 %s: Retriggering pulse. Duration: %f\n", tag(), attotime_to_double(duration)); + if (LOG) logerror("74123 %s: Retriggering pulse. Duration: %f\n", tag(), duration.as_double()); } else { @@ -257,7 +257,7 @@ void ttl74123_device::start_pulse() set_output(); - if (LOG) logerror("74123 %s: Starting pulse. Duration: %f\n", tag(), attotime_to_double(duration)); + if (LOG) logerror("74123 %s: Starting pulse. Duration: %f\n", tag(), duration.as_double()); } } diff --git a/src/emu/machine/f3853.c b/src/emu/machine/f3853.c index e9aa8da6b5d..aaac51edfc7 100644 --- a/src/emu/machine/f3853.c +++ b/src/emu/machine/f3853.c @@ -188,7 +188,7 @@ void f3853_device::f3853_set_interrupt_request_line() void f3853_device::f3853_timer_start(UINT8 value) { - attotime period = (value != 0xff) ? attotime_mul(ATTOTIME_IN_HZ(clock()), m_value_to_cycle[value]*31) : attotime_never; + attotime period = (value != 0xff) ? attotime::from_hz(clock()) * (m_value_to_cycle[value]*31) : attotime::never; timer_adjust_oneshot(m_timer, period, 0); } diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c index f05ed50b004..6df7926620d 100644 --- a/src/emu/machine/generic.c +++ b/src/emu/machine/generic.c @@ -620,8 +620,8 @@ void generic_pulse_irq_line(device_t *device, int irqline) cpu_set_input_line(device, irqline, ASSERT_LINE); cpu_device *cpudevice = downcast<cpu_device *>(device); - attotime target_time = attotime_add(cpudevice->local_time(), cpudevice->cycles_to_attotime(cpudevice->min_cycles())); - timer_set(device->machine, attotime_sub(target_time, timer_get_time(device->machine)), (void *)device, irqline, irq_pulse_clear); + attotime target_time = cpudevice->local_time() + cpudevice->cycles_to_attotime(cpudevice->min_cycles()); + timer_set(device->machine, target_time - timer_get_time(device->machine), (void *)device, irqline, irq_pulse_clear); } @@ -637,8 +637,8 @@ void generic_pulse_irq_line_and_vector(device_t *device, int irqline, int vector cpu_set_input_line_and_vector(device, irqline, ASSERT_LINE, vector); cpu_device *cpudevice = downcast<cpu_device *>(device); - attotime target_time = attotime_add(cpudevice->local_time(), cpudevice->cycles_to_attotime(cpudevice->min_cycles())); - timer_set(device->machine, attotime_sub(target_time, timer_get_time(device->machine)), (void *)device, irqline, irq_pulse_clear); + attotime target_time = cpudevice->local_time() + cpudevice->cycles_to_attotime(cpudevice->min_cycles()); + timer_set(device->machine, target_time - timer_get_time(device->machine), (void *)device, irqline, irq_pulse_clear); } diff --git a/src/emu/machine/idectrl.c b/src/emu/machine/idectrl.c index b05730a3372..71a931cac7d 100644 --- a/src/emu/machine/idectrl.c +++ b/src/emu/machine/idectrl.c @@ -1314,7 +1314,7 @@ static UINT32 ide_controller_read(device_t *device, int bank, offs_t offset, int /* return the current status but don't clear interrupts */ case IDE_BANK1_STATUS_CONTROL: result = ide->status; - if (attotime_compare(timer_timeelapsed(ide->last_status_timer), TIME_PER_ROTATION) > 0) + if (timer_timeelapsed(ide->last_status_timer) > TIME_PER_ROTATION) { result |= IDE_STATUS_HIT_INDEX; timer_adjust_oneshot(ide->last_status_timer, attotime_never, 0); diff --git a/src/emu/machine/ldcore.c b/src/emu/machine/ldcore.c index 43e5e377e49..365f27de97d 100644 --- a/src/emu/machine/ldcore.c +++ b/src/emu/machine/ldcore.c @@ -260,7 +260,7 @@ static void update_slider_pos(ldcore_data *ldcore, attotime curtime) /* otherwise, compute the number of tracks covered */ else { - attoseconds_t delta = attotime_to_attoseconds(attotime_sub(curtime, ldcore->sliderupdate)); + attoseconds_t delta = (curtime - ldcore->sliderupdate).as_attoseconds(); INT32 tracks_covered; /* determine how many tracks we covered and advance */ @@ -269,14 +269,14 @@ static void update_slider_pos(ldcore_data *ldcore, attotime curtime) tracks_covered = delta / ldcore->attospertrack; add_and_clamp_track(ldcore, tracks_covered); if (tracks_covered != 0) - ldcore->sliderupdate = attotime_add_attoseconds(ldcore->sliderupdate, tracks_covered * ldcore->attospertrack); + ldcore->sliderupdate += attotime(0, tracks_covered * ldcore->attospertrack); } else { tracks_covered = delta / -ldcore->attospertrack; add_and_clamp_track(ldcore, -tracks_covered); if (tracks_covered != 0) - ldcore->sliderupdate = attotime_add_attoseconds(ldcore->sliderupdate, tracks_covered * -ldcore->attospertrack); + ldcore->sliderupdate += attotime(0, tracks_covered * -ldcore->attospertrack); } } } @@ -562,11 +562,11 @@ void ldcore_set_slider_speed(laserdisc_state *ld, INT32 tracks_per_vsync) /* positive values store positive times */ else if (tracks_per_vsync > 0) - ldcore->attospertrack = attotime_to_attoseconds(attotime_div(vsyncperiod, tracks_per_vsync)); + ldcore->attospertrack = (vsyncperiod / tracks_per_vsync).as_attoseconds(); /* negative values store negative times */ else - ldcore->attospertrack = -attotime_to_attoseconds(attotime_div(vsyncperiod, -tracks_per_vsync)); + ldcore->attospertrack = -(vsyncperiod / -tracks_per_vsync).as_attoseconds(); if (LOG_SLIDER) printf("Slider speed = %d\n", tracks_per_vsync); @@ -640,7 +640,7 @@ INT32 ldcore_generic_update(laserdisc_state *ld, const vbi_metadata *vbi, int fi { case LDSTATE_EJECTING: /* when time expires, switch to the ejected state */ - if (attotime_compare(curtime, ld->state.endtime) >= 0) + if (curtime >= ld->state.endtime) newstate->state = LDSTATE_EJECTED; break; @@ -654,14 +654,14 @@ INT32 ldcore_generic_update(laserdisc_state *ld, const vbi_metadata *vbi, int fi case LDSTATE_LOADING: /* when time expires, switch to the spinup state */ - if (attotime_compare(curtime, ld->state.endtime) >= 0) + if (curtime >= ld->state.endtime) newstate->state = LDSTATE_SPINUP; advanceby = -GENERIC_SEARCH_SPEED; break; case LDSTATE_SPINUP: /* when time expires, switch to the playing state */ - if (attotime_compare(curtime, ld->state.endtime) >= 0) + if (curtime >= ld->state.endtime) newstate->state = LDSTATE_PLAYING; advanceby = -GENERIC_SEARCH_SPEED; break; diff --git a/src/emu/machine/ldpr8210.c b/src/emu/machine/ldpr8210.c index 347ca7df977..c61db6f28b7 100644 --- a/src/emu/machine/ldpr8210.c +++ b/src/emu/machine/ldpr8210.c @@ -380,7 +380,7 @@ static void pr8210_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int field /* signal VSYNC and set a timer to turn it off */ player->vsync = TRUE; - timer_set(ld->device->machine, attotime_mul(ld->screen->scan_period(), 4), ld, 0, vsync_off); + timer_set(ld->device->machine, ld->screen->scan_period() * 4, ld, 0, vsync_off); /* also set a timer to fetch the VBI data when it is ready */ timer_set(ld->device->machine, ld->screen->time_until_pos(19*2), ld, 0, vbi_data_fetch); @@ -457,12 +457,12 @@ static void pr8210_control_w(laserdisc_state *ld, UINT8 prev, UINT8 data) /* get the time difference from the last assert */ /* and update our internal command time */ - delta = attotime_sub(curtime, player->lastbittime); + delta = curtime - player->lastbittime; player->lastbittime = curtime; /* if we timed out since the first bit, reset the accumulator */ - overalldelta = attotime_sub(curtime, player->firstbittime); - if (attotime_compare(overalldelta, SERIAL_MAX_WORD_TIME) > 0 || attotime_compare(delta, SERIAL_MAX_BIT_TIME) > 0) + overalldelta = curtime - player->firstbittime; + if (overalldelta > SERIAL_MAX_WORD_TIME || delta > SERIAL_MAX_BIT_TIME) { player->firstbittime = curtime; player->accumulator = 0x5555; @@ -471,7 +471,7 @@ static void pr8210_control_w(laserdisc_state *ld, UINT8 prev, UINT8 data) } /* 0 bit delta is 1.05 msec, 1 bit delta is 2.11 msec */ - longpulse = (attotime_compare(delta, SERIAL_MIDPOINT_TIME) < 0) ? 0 : 1; + longpulse = (delta < SERIAL_MIDPOINT_TIME) ? 0 : 1; player->accumulator = (player->accumulator << 1) | longpulse; /* log the deltas for debugging */ @@ -494,9 +494,9 @@ static void pr8210_control_w(laserdisc_state *ld, UINT8 prev, UINT8 data) /* the MCU logic requires a 0 to execute many commands; however, nobody consistently sends a 0, whereas they do tend to send duplicate commands... if we assume that each duplicate causes a 0, we get the correct results */ - rejectuntil = attotime_add(player->lastcommandtime, SERIAL_REJECT_DUPLICATE_TIME); + rejectuntil = player->lastcommandtime + SERIAL_REJECT_DUPLICATE_TIME; player->lastcommandtime = curtime; - if (player->pia.porta == player->lastcommand && attotime_compare(curtime, rejectuntil) < 0) + if (player->pia.porta == player->lastcommand && curtime < rejectuntil) player->pia.porta = 0x00; else player->lastcommand = player->pia.porta; @@ -506,7 +506,7 @@ static void pr8210_control_w(laserdisc_state *ld, UINT8 prev, UINT8 data) printf("--- Command = %02X\n", player->pia.porta >> 3); /* reset the first bit time so that the accumulator clears on the next write */ - player->firstbittime = attotime_sub(curtime, SERIAL_MAX_WORD_TIME); + player->firstbittime = curtime - SERIAL_MAX_WORD_TIME; } } } @@ -746,7 +746,6 @@ static READ8_HANDLER( pr8210_bus_r ) result |= 0x02; /* bus bit 0: SLOW TIMER OUT */ -// if (attotime_compare(attotime_sub(timer_get_time(ld->device->machine), player->slowtrg), /* loop at beginning waits for $40=0, $02=1 */ return result; diff --git a/src/emu/machine/ldv1000.c b/src/emu/machine/ldv1000.c index b0d4b25fa43..ffbdb8fc91f 100644 --- a/src/emu/machine/ldv1000.c +++ b/src/emu/machine/ldv1000.c @@ -257,7 +257,7 @@ static void ldv1000_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fiel /* signal VSYNC and set a timer to turn it off */ player->vsync = TRUE; - timer_set(ld->device->machine, attotime_mul(ld->screen->scan_period(), 4), ld, 0, vsync_off); + timer_set(ld->device->machine, ld->screen->scan_period() * 4, ld, 0, vsync_off); /* also set a timer to fetch the VBI data when it is ready */ timer_set(ld->device->machine, ld->screen->time_until_pos(19*2), ld, 0, vbi_data_fetch); diff --git a/src/emu/machine/ldvp931.c b/src/emu/machine/ldvp931.c index 24cd7b77fd6..77dc586e838 100644 --- a/src/emu/machine/ldvp931.c +++ b/src/emu/machine/ldvp931.c @@ -282,7 +282,7 @@ static UINT8 vp931_data_r(laserdisc_state *ld) } /* also boost interleave for 4 scanlines to ensure proper communications */ - cpuexec_boost_interleave(ld->device->machine, attotime_zero, attotime_mul(ld->screen->scan_period(), 4)); + cpuexec_boost_interleave(ld->device->machine, attotime_zero, ld->screen->scan_period() * 4); return player->tocontroller; } @@ -616,7 +616,7 @@ static WRITE8_HANDLER( to_controller_w ) (*player->data_ready_cb)(ld->device, TRUE); /* also boost interleave for 4 scanlines to ensure proper communications */ - cpuexec_boost_interleave(ld->device->machine, attotime_zero, attotime_mul(ld->screen->scan_period(), 4)); + cpuexec_boost_interleave(ld->device->machine, attotime_zero, ld->screen->scan_period() * 4); } diff --git a/src/emu/machine/mc146818.c b/src/emu/machine/mc146818.c index 5e6127111dc..3b638286300 100644 --- a/src/emu/machine/mc146818.c +++ b/src/emu/machine/mc146818.c @@ -436,7 +436,7 @@ READ8_MEMBER( mc146818_device::read ) switch (m_index % MC146818_DATA_SIZE) { case 0xa: data = m_data[m_index % MC146818_DATA_SIZE]; - if (attotime_compare(attotime_sub(timer_get_time(space.machine), m_last_refresh), ATTOTIME_IN_HZ(32768)) < 0) + if ((timer_get_time(space.machine) - m_last_refresh) < ATTOTIME_IN_HZ(32768)) data |= 0x80; #if 0 /* for pc1512 bios realtime clock test */ diff --git a/src/emu/machine/pc16552d.c b/src/emu/machine/pc16552d.c index b892b59ebce..6d93fe215d2 100644 --- a/src/emu/machine/pc16552d.c +++ b/src/emu/machine/pc16552d.c @@ -170,7 +170,7 @@ static void duart_push_tx_fifo(int chip, int channel, UINT8 data) ch->tx_fifo[ch->tx_fifo_num] = data; ch->tx_fifo_num++; - period = attotime_mul(ATTOTIME_IN_HZ(duart[chip].frequency), ch->divisor * 16 * 16 * 8); + period = attotime::from_hz(duart[chip].frequency) * (ch->divisor * 16 * 16 * 8); timer_adjust_oneshot(duart[chip].ch[channel].tx_fifo_timer, period, (chip * 2) + channel); } diff --git a/src/emu/machine/pit8253.c b/src/emu/machine/pit8253.c index 3ee19454f24..befe85fa28f 100644 --- a/src/emu/machine/pit8253.c +++ b/src/emu/machine/pit8253.c @@ -612,9 +612,9 @@ static void simulate2(device_t *device, struct pit8253_timer *timer, INT64 elaps } else { - attotime next_fire_time = attotime_add( timer->last_updated, double_to_attotime( cycles_to_output / timer->clockin ) ); + attotime next_fire_time = timer->last_updated + cycles_to_output * attotime::from_hz( timer->clockin ); - timer_adjust_oneshot(timer->updatetimer, attotime_sub( next_fire_time, timer_get_time(device->machine) ), timer->index ); + timer_adjust_oneshot(timer->updatetimer, next_fire_time - timer_get_time(device->machine), timer->index ); } LOG2(("pit8253: simulate2(): simulating %d cycles for %d in mode %d, bcd = %d, phase = %d, gate = %d, output %d, value = 0x%04x, cycles_to_output = %04x\n", @@ -645,7 +645,7 @@ static void simulate(device_t *device, struct pit8253_timer *timer, INT64 elapse simulate2(device, timer, elapsed_cycles); else if ( timer->clockin ) - timer_adjust_oneshot(timer->updatetimer, double_to_attotime( 1 / timer->clockin ), timer->index ); + timer_adjust_oneshot(timer->updatetimer, attotime::from_hz( timer->clockin ), timer->index ); } @@ -655,14 +655,14 @@ static void update(device_t *device, struct pit8253_timer *timer) /* With the 82C54's maximum clockin of 10MHz, 64 bits is nearly 60,000 years of time. Should be enough for now. */ attotime now = timer_get_time(device->machine); - attotime elapsed_time = attotime_sub(now,timer->last_updated); - INT64 elapsed_cycles = attotime_to_double(elapsed_time) * timer->clockin; + attotime elapsed_time = now - timer->last_updated; + INT64 elapsed_cycles = elapsed_time.as_double() * timer->clockin; LOG1(("pit8253: update(): timer %d, %" I64FMT "d elapsed_cycles\n", timer->index, elapsed_cycles)); if ( timer->clockin ) { - timer->last_updated = attotime_add(timer->last_updated,double_to_attotime(elapsed_cycles/timer->clockin)); + timer->last_updated += elapsed_cycles * attotime::from_hz(timer->clockin); } else { @@ -916,7 +916,7 @@ WRITE8_DEVICE_HANDLER( pit8253_w ) update(device, timer); - if ( attotime_compare( timer_get_time(device->machine), timer->last_updated ) > 0 && timer->clockin != 0 ) + if ( timer_get_time(device->machine) > timer->last_updated && timer->clockin != 0 ) { middle_of_a_cycle = 1; } @@ -931,7 +931,7 @@ WRITE8_DEVICE_HANDLER( pit8253_w ) /* check if we should compensate for not being on a cycle boundary */ if ( middle_of_a_cycle ) - timer->last_updated = attotime_add(timer->last_updated,double_to_attotime(1/timer->clockin)); + timer->last_updated += attotime::from_hz(timer->clockin); load_count(device, timer, data); simulate2(device, timer, 0 ); @@ -946,7 +946,7 @@ WRITE8_DEVICE_HANDLER( pit8253_w ) /* check if we should compensate for not being on a cycle boundary */ if ( middle_of_a_cycle ) - timer->last_updated = attotime_add(timer->last_updated,double_to_attotime(1/timer->clockin)); + timer->last_updated += attotime::from_hz(timer->clockin); load_count(device, timer, data << 8); simulate2(device, timer, 0 ); @@ -958,7 +958,7 @@ WRITE8_DEVICE_HANDLER( pit8253_w ) { /* check if we should compensate for not being on a cycle boundary */ if ( middle_of_a_cycle ) - timer->last_updated = attotime_add(timer->last_updated,double_to_attotime(1/timer->clockin)); + timer->last_updated += attotime::from_hz(timer->clockin); load_count(device, timer,timer->lowcount | (data << 8)); simulate2(device, timer, 0 ); diff --git a/src/emu/machine/rtc65271.c b/src/emu/machine/rtc65271.c index 4861aa4c9b3..642efa3d117 100644 --- a/src/emu/machine/rtc65271.c +++ b/src/emu/machine/rtc65271.c @@ -409,11 +409,11 @@ void rtc65271_w(device_t *device, int xramsel, offs_t offset, UINT8 data) if (data & reg_A_RS) { attotime period = ATTOTIME_IN_HZ(SQW_freq_table[data & reg_A_RS]); - attotime half_period = attotime_div(period, 2); + attotime half_period = period / 2; attotime elapsed = timer_timeelapsed(state->update_timer); - if (attotime_compare(half_period, elapsed) > 0) - timer_adjust_oneshot(state->SQW_timer, attotime_sub(half_period, elapsed), 0); + if (half_period > elapsed) + timer_adjust_oneshot(state->SQW_timer, half_period - elapsed, 0); else timer_adjust_oneshot(state->SQW_timer, half_period, 0); } @@ -505,7 +505,7 @@ static TIMER_CALLBACK( rtc_SQW_callback ) field_interrupts(device); } - half_period = attotime_div(ATTOTIME_IN_HZ(SQW_freq_table[state->regs[reg_A] & reg_A_RS]), 2); + half_period = attotime::from_hz(SQW_freq_table[state->regs[reg_A] & reg_A_RS]) / 2; timer_adjust_oneshot(state->SQW_timer, half_period, 0); } diff --git a/src/emu/machine/s3c24xx.c b/src/emu/machine/s3c24xx.c index c370c3a4397..b0a160eaecf 100644 --- a/src/emu/machine/s3c24xx.c +++ b/src/emu/machine/s3c24xx.c @@ -1232,7 +1232,7 @@ static UINT16 s3c24xx_pwm_calc_observation( device_t *device, int ch) s3c24xx_t *s3c24xx = get_token( device); double timeleft, x1, x2; UINT32 cnto; - timeleft = attotime_to_double( timer_timeleft( s3c24xx->pwm.timer[ch])); + timeleft = timer_timeleft( s3c24xx->pwm.timer[ch]).as_double(); // printf( "timeleft %f freq %d cntb %d cmpb %d\n", timeleft, s3c24xx->pwm.freq[ch], s3c24xx->pwm.cnt[ch], s3c24xx->pwm.cmp[ch]); x1 = 1 / ((double)s3c24xx->pwm.freq[ch] / (s3c24xx->pwm.cnt[ch]- s3c24xx->pwm.cmp[ch] + 1)); x2 = x1 / timeleft; @@ -2004,7 +2004,7 @@ static UINT16 s3c24xx_wdt_calc_current_count( device_t *device) s3c24xx_t *s3c24xx = get_token( device); double timeleft, x1, x2; UINT32 cnt; - timeleft = attotime_to_double( timer_timeleft( s3c24xx->wdt.timer)); + timeleft = timer_timeleft( s3c24xx->wdt.timer).as_double(); // printf( "timeleft %f freq %d cnt %d\n", timeleft, s3c24xx->wdt.freq, s3c24xx->wdt.cnt); x1 = 1 / ((double)s3c24xx->wdt.freq / s3c24xx->wdt.cnt); x2 = x1 / timeleft; diff --git a/src/emu/machine/tmp68301.c b/src/emu/machine/tmp68301.c index 4ea0dedb3fe..8376ada4ce7 100644 --- a/src/emu/machine/tmp68301.c +++ b/src/emu/machine/tmp68301.c @@ -90,7 +90,7 @@ static void tmp68301_update_timer( running_machine *machine, int i ) { int scale = (TCR & 0x3c00)>>10; // P4..1 if (scale > 8) scale = 8; - duration = attotime_mul(ATTOTIME_IN_HZ(machine->firstcpu->unscaled_clock()), (1 << scale) * max); + duration = attotime::from_hz(machine->firstcpu->unscaled_clock()) * ((1 << scale) * max); } break; } @@ -99,7 +99,7 @@ static void tmp68301_update_timer( running_machine *machine, int i ) if (!(TCR & 0x0002)) // CS { - if (attotime_compare(duration, attotime_zero)) + if (duration != attotime::zero) timer_adjust_oneshot(tmp68301_timer[i],duration,i); else logerror("%s: TMP68301 error, timer %d duration is 0\n",cpuexec_describe_context(machine),i); diff --git a/src/emu/machine/z80ctc.c b/src/emu/machine/z80ctc.c index a99d8ef5551..22d9f91a6c3 100644 --- a/src/emu/machine/z80ctc.c +++ b/src/emu/machine/z80ctc.c @@ -160,8 +160,8 @@ z80ctc_device::z80ctc_device(running_machine &_machine, const z80ctc_device_conf void z80ctc_device::device_start() { - m_period16 = attotime_mul(ATTOTIME_IN_HZ(m_clock), 16); - m_period256 = attotime_mul(ATTOTIME_IN_HZ(m_clock), 256); + m_period16 = attotime::from_hz(m_clock) * 16; + m_period256 = attotime::from_hz(m_clock) * 256; // resolve callbacks devcb_resolve_write_line(&m_intr, &m_config.m_intr, this); @@ -379,7 +379,7 @@ attotime z80ctc_device::ctc_channel::period() const // compute the period attotime period = ((m_mode & PRESCALER) == PRESCALER_16) ? m_device->m_period16 : m_device->m_period256; - return attotime_mul(period, m_tconst); + return period * m_tconst; } @@ -401,7 +401,7 @@ UINT8 z80ctc_device::ctc_channel::read() VPRINTF(("CTC clock %f\n",ATTOSECONDS_TO_HZ(period.attoseconds))); if (m_timer != NULL) - return ((int)(attotime_to_double(timer_timeleft(m_timer)) / attotime_to_double(period)) + 1) & 0xff; + return ((int)(timer_timeleft(m_timer).as_double() / period.as_double()) + 1) & 0xff; else return 0; } @@ -506,7 +506,7 @@ void z80ctc_device::ctc_channel::trigger(UINT8 data) if (!m_notimer) { attotime curperiod = period(); - VPRINTF(("CTC period %s\n", attotime_string(curperiod, 9))); + VPRINTF(("CTC period %s\n", curperiod.as_string())); timer_adjust_periodic(m_timer, curperiod, m_index, curperiod); } else diff --git a/src/emu/machine/z80sio.c b/src/emu/machine/z80sio.c index 7cc4f4bca0e..71eb83a33fd 100644 --- a/src/emu/machine/z80sio.c +++ b/src/emu/machine/z80sio.c @@ -289,7 +289,7 @@ inline void z80sio_device::sio_channel::clear_interrupt(int type) inline attotime z80sio_device::sio_channel::compute_time_per_character() { // fix me -- should compute properly and include data, stop, parity bit - return attotime_mul(ATTOTIME_IN_HZ(9600), 10); + return attotime::from_hz(9600) * 10; } diff --git a/src/emu/schedule.c b/src/emu/schedule.c index e3a8fc84d80..98c1541e16a 100644 --- a/src/emu/schedule.c +++ b/src/emu/schedule.c @@ -125,7 +125,7 @@ if (TEMPLOG) printf("Timeslice start\n"); if (TEMPLOG) { void timer_print_first_timer(running_machine *machine); - printf("Timeslice loop: basetime=%15.6f\n", attotime_to_double(timerexec->basetime)); + printf("Timeslice loop: basetime=%15.6f\n", timerexec->basetime.as_double()); timer_print_first_timer(&m_machine); } @@ -137,12 +137,12 @@ if (TEMPLOG) ATTOTIME_NORMALIZE(target); // however, if the next timer is going to fire before then, override - assert(attotime_sub(timerexec->nextfire, target).seconds <= 0); + assert((timerexec->nextfire - target).seconds <= 0); if (ATTOTIME_LT(timerexec->nextfire, target)) target = timerexec->nextfire; LOG(("------------------\n")); - LOG(("cpu_timeslice: target = %s\n", attotime_string(target, 9))); + LOG(("cpu_timeslice: target = %s\n", target.as_string())); // apply pending suspension changes UINT32 suspendchanged = 0; @@ -168,7 +168,7 @@ if (TEMPLOG) attoseconds_t delta = target.attoseconds - exec->m_localtime.attoseconds; if (delta < 0 && target.seconds > exec->m_localtime.seconds) delta += ATTOSECONDS_PER_SECOND; - assert(delta == attotime_to_attoseconds(attotime_sub(target, exec->m_localtime))); + assert(delta == (target - exec->m_localtime).as_attoseconds()); // if we have enough for at least 1 cycle, do the math if (delta >= exec->m_attoseconds_per_cycle) @@ -214,18 +214,18 @@ if (TEMPLOG) printf("Skipping %s for %d cycles\n", exec->device().tag(), ran); attoseconds_t actualdelta = exec->m_attoseconds_per_cycle * ran; exec->m_localtime.attoseconds += actualdelta; ATTOTIME_NORMALIZE(exec->m_localtime); - LOG((" %d ran, %d total, time = %s\n", ran, (INT32)exec->m_totalcycles, attotime_string(exec->m_localtime, 9))); + LOG((" %d ran, %d total, time = %s\n", ran, (INT32)exec->m_totalcycles, exec->m_localtime.as_string())); // if the new local CPU time is less than our target, move the target up if (ATTOTIME_LT(exec->m_localtime, target)) { - assert(attotime_compare(exec->m_localtime, target) < 0); + assert(exec->m_localtime < target); target = exec->m_localtime; // however, if this puts us before the base, clamp to the base as a minimum if (ATTOTIME_LT(target, timerexec->basetime)) { - assert(attotime_compare(target, timerexec->basetime) < 0); + assert(target < timerexec->basetime); target = timerexec->basetime; } LOG((" (new target)\n")); @@ -376,7 +376,7 @@ void device_scheduler::rebuild_execute_list() attotime min_quantum = m_machine.config->m_minimum_quantum; // if none specified default to 60Hz - if (attotime_compare(min_quantum, attotime_zero) == 0) + if (min_quantum == attotime::zero) min_quantum = ATTOTIME_IN_HZ(60); // if the configuration specifies a device to make perfect, pick that as the minimum @@ -390,8 +390,7 @@ void device_scheduler::rebuild_execute_list() if (!device->interface(exec)) fatalerror("Device '%s' specified for perfect interleave is not an executing device!", m_machine.config->m_perfect_cpu_quantum); - attotime cpu_quantum = attotime_make(0, exec->minimum_quantum()); - min_quantum = attotime_min(cpu_quantum, min_quantum); + min_quantum = min(attotime(0, exec->minimum_quantum()), min_quantum); } // inform the timer system of our decision diff --git a/src/emu/screen.c b/src/emu/screen.c index 6ff3088f95e..d61fe083acf 100644 --- a/src/emu/screen.c +++ b/src/emu/screen.c @@ -59,7 +59,7 @@ const device_type SCREEN = screen_device_config::static_alloc_device_config; -const attotime screen_device::DEFAULT_FRAME_PERIOD = STATIC_ATTOTIME_IN_HZ(DEFAULT_FRAME_RATE); +const attotime screen_device::DEFAULT_FRAME_PERIOD(attotime::from_hz(DEFAULT_FRAME_RATE)); @@ -355,8 +355,8 @@ void screen_device::device_start() configure(m_config.m_width, m_config.m_height, m_config.m_visarea, m_config.m_refresh); // reset VBLANK timing - m_vblank_start_time = attotime_zero; - m_vblank_end_time = attotime_make(0, m_vblank_period); + m_vblank_start_time = attotime::zero; + m_vblank_end_time = attotime(0, m_vblank_period); // start the timer to generate per-scanline updates if ((machine->config->m_video_attributes & VIDEO_UPDATE_SCANLINE) != 0) @@ -468,8 +468,8 @@ void screen_device::reset_origin(int beamy, int beamx) { // compute the effective VBLANK start/end times attotime curtime = timer_get_time(machine); - m_vblank_end_time = attotime_sub_attoseconds(curtime, beamy * m_scantime + beamx * m_pixeltime); - m_vblank_start_time = attotime_sub_attoseconds(m_vblank_end_time, m_vblank_period); + m_vblank_end_time = curtime - attotime(0, beamy * m_scantime + beamx * m_pixeltime); + m_vblank_start_time = m_vblank_end_time - attotime(0, m_vblank_period); // if we are resetting relative to (0,0) == VBLANK end, call the // scanline 0 timer by hand now; otherwise, adjust it for the future @@ -667,7 +667,7 @@ void screen_device::update_now() int screen_device::vpos() const { - attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(machine), m_vblank_start_time)); + attoseconds_t delta = (timer_get_time(machine) - m_vblank_start_time).as_attoseconds(); int vpos; // round to the nearest pixel @@ -688,7 +688,7 @@ int screen_device::vpos() const int screen_device::hpos() const { - attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(machine), m_vblank_start_time)); + attoseconds_t delta = (timer_get_time(machine) - m_vblank_start_time).as_attoseconds(); // round to the nearest pixel delta += m_pixeltime / 2; @@ -724,14 +724,14 @@ attotime screen_device::time_until_pos(int vpos, int hpos) const attoseconds_t targetdelta = (attoseconds_t)vpos * m_scantime + (attoseconds_t)hpos * m_pixeltime; // if we're past that time (within 1/2 of a pixel), head to the next frame - attoseconds_t curdelta = attotime_to_attoseconds(attotime_sub(timer_get_time(machine), m_vblank_start_time)); + attoseconds_t curdelta = (timer_get_time(machine) - m_vblank_start_time).as_attoseconds(); if (targetdelta <= curdelta + m_pixeltime / 2) targetdelta += m_frame_period; while (targetdelta <= curdelta) targetdelta += m_frame_period; // return the difference - return attotime_make(0, targetdelta - curdelta); + return attotime(0, targetdelta - curdelta); } @@ -747,8 +747,8 @@ attotime screen_device::time_until_vblank_end() const // if we are in the VBLANK region, compute the time until the end of the current VBLANK period attotime target_time = m_vblank_end_time; if (!vblank()) - target_time = attotime_add_attoseconds(target_time, m_frame_period); - return attotime_sub(target_time, timer_get_time(machine)); + target_time += attotime(0, m_frame_period); + return target_time - timer_get_time(machine); } @@ -788,7 +788,7 @@ void screen_device::vblank_begin_callback() { // reset the starting VBLANK time m_vblank_start_time = timer_get_time(machine); - m_vblank_end_time = attotime_add_attoseconds(m_vblank_start_time, m_vblank_period); + m_vblank_end_time = m_vblank_start_time + attotime(0, m_vblank_period); // call the screen specific callbacks for (callback_item *item = m_callback_list; item != NULL; item = item->m_next) diff --git a/src/emu/screen.h b/src/emu/screen.h index 4b053cd8e4c..0f04f5b9f9c 100644 --- a/src/emu/screen.h +++ b/src/emu/screen.h @@ -166,7 +166,7 @@ public: // beam positioning and state int vpos() const; int hpos() const; - bool vblank() const { return attotime_compare(timer_get_time(machine), m_vblank_end_time) < 0; } + bool vblank() const { return (timer_get_time(machine) < m_vblank_end_time); } bool hblank() const { int curpos = hpos(); return (curpos < m_visarea.min_x || curpos > m_visarea.max_x); } // timing @@ -174,8 +174,8 @@ public: attotime time_until_vblank_start() const { return time_until_pos(m_visarea.max_y + 1); } attotime time_until_vblank_end() const; attotime time_until_update() const { return (machine->config->m_video_attributes & VIDEO_UPDATE_AFTER_VBLANK) ? time_until_vblank_end() : time_until_vblank_start(); } - attotime scan_period() const { return attotime_make(0, m_scantime); } - attotime frame_period() const { return (this == NULL || !started()) ? DEFAULT_FRAME_PERIOD : attotime_make(0, m_frame_period); }; + attotime scan_period() const { return attotime(0, m_scantime); } + attotime frame_period() const { return (this == NULL || !started()) ? DEFAULT_FRAME_PERIOD : attotime(0, m_frame_period); }; UINT64 frame_number() const { return m_frame_number; } int partial_updates() const { return m_partial_updates_this_frame; } diff --git a/src/emu/sound.c b/src/emu/sound.c index 19a9a9443ab..685a335da8d 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -139,9 +139,7 @@ sound_stream::sound_stream(device_t &device, int inputs, int outputs, int sample attotime sound_stream::sample_time() const { - attotime base = m_device.machine->sound().last_update(); - base.attoseconds = 0; - return attotime_add_attoseconds(base, m_output_sampindex * m_attoseconds_per_sample); + return attotime(m_device.machine->sound().last_update().seconds, 0) + attotime(0, m_output_sampindex * m_attoseconds_per_sample); } diff --git a/src/emu/sound.h b/src/emu/sound.h index c483ce66293..5ea47565304 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -128,7 +128,7 @@ public: device_t &device() const { return m_device; } int sample_rate() const { return (m_new_sample_rate != 0) ? m_new_sample_rate : m_sample_rate; } attotime sample_time() const; - attotime sample_period() const { return attotime_make(0, m_attoseconds_per_sample); } + attotime sample_period() const { return attotime(0, m_attoseconds_per_sample); } int input_count() const { return m_inputs; } int output_count() const { return m_outputs; } float input_gain(int inputnum) const; diff --git a/src/emu/sound/2203intf.c b/src/emu/sound/2203intf.c index 70b99c5050d..e8eb777602f 100644 --- a/src/emu/sound/2203intf.c +++ b/src/emu/sound/2203intf.c @@ -93,7 +93,7 @@ static void timer_handler(void *param,int c,int count,int clock) } else { /* Start FM Timer */ - attotime period = attotime_mul(ATTOTIME_IN_HZ(clock), count); + attotime period = attotime::from_hz(clock) * count; if (!timer_enable(info->timer[c], 1)) timer_adjust_oneshot(info->timer[c], period, 0); } diff --git a/src/emu/sound/2608intf.c b/src/emu/sound/2608intf.c index 6048fcf2d79..3d2d7fed15f 100644 --- a/src/emu/sound/2608intf.c +++ b/src/emu/sound/2608intf.c @@ -99,7 +99,7 @@ static void timer_handler(void *param,int c,int count,int clock) } else { /* Start FM Timer */ - attotime period = attotime_mul(ATTOTIME_IN_HZ(clock), count); + attotime period = attotime::from_hz(clock) * count; if (!timer_enable(info->timer[c], 1)) timer_adjust_oneshot(info->timer[c], period, 0); } diff --git a/src/emu/sound/2610intf.c b/src/emu/sound/2610intf.c index 345dadaafc4..829dc1ceae2 100644 --- a/src/emu/sound/2610intf.c +++ b/src/emu/sound/2610intf.c @@ -98,7 +98,7 @@ static void timer_handler(void *param,int c,int count,int clock) } else { /* Start FM Timer */ - attotime period = attotime_mul(ATTOTIME_IN_HZ(clock), count); + attotime period = attotime::from_hz(clock) * count; if (!timer_enable(info->timer[c], 1)) timer_adjust_oneshot(info->timer[c], period, 0); diff --git a/src/emu/sound/2612intf.c b/src/emu/sound/2612intf.c index c2895103298..43ea0d97c73 100644 --- a/src/emu/sound/2612intf.c +++ b/src/emu/sound/2612intf.c @@ -66,7 +66,7 @@ static void timer_handler(void *param,int c,int count,int clock) } else { /* Start FM Timer */ - attotime period = attotime_mul(ATTOTIME_IN_HZ(clock), count); + attotime period = attotime::from_hz(clock) * count; if (!timer_enable(info->timer[c], 1)) timer_adjust_oneshot(info->timer[c], period, 0); } diff --git a/src/emu/sound/262intf.c b/src/emu/sound/262intf.c index 8770258437c..d093a1f4951 100644 --- a/src/emu/sound/262intf.c +++ b/src/emu/sound/262intf.c @@ -52,7 +52,7 @@ static TIMER_CALLBACK( timer_callback_262_1 ) static void timer_handler_262(void *param,int timer, attotime period) { ymf262_state *info = (ymf262_state *)param; - if( attotime_compare(period, attotime_zero) == 0 ) + if( period == attotime::zero ) { /* Reset FM Timer */ timer_enable(info->timer[timer], 0); } diff --git a/src/emu/sound/3526intf.c b/src/emu/sound/3526intf.c index 7f9ecf70ed0..7d1add9c682 100644 --- a/src/emu/sound/3526intf.c +++ b/src/emu/sound/3526intf.c @@ -62,7 +62,7 @@ static TIMER_CALLBACK( timer_callback_1 ) static void TimerHandler(void *param,int c,attotime period) { ym3526_state *info = (ym3526_state *)param; - if( attotime_compare(period, attotime_zero) == 0 ) + if( period == attotime::zero ) { /* Reset FM Timer */ timer_enable(info->timer[c], 0); } diff --git a/src/emu/sound/3812intf.c b/src/emu/sound/3812intf.c index 6e69421f300..7b1ff8fa8b0 100644 --- a/src/emu/sound/3812intf.c +++ b/src/emu/sound/3812intf.c @@ -62,7 +62,7 @@ static TIMER_CALLBACK( timer_callback_1 ) static void TimerHandler(void *param,int c,attotime period) { ym3812_state *info = (ym3812_state *)param; - if( attotime_compare(period, attotime_zero) == 0 ) + if( period == attotime::zero ) { /* Reset FM Timer */ timer_enable(info->timer[c], 0); } diff --git a/src/emu/sound/8950intf.c b/src/emu/sound/8950intf.c index ce6709581d8..4aac018173b 100644 --- a/src/emu/sound/8950intf.c +++ b/src/emu/sound/8950intf.c @@ -59,7 +59,7 @@ static TIMER_CALLBACK( timer_callback_1 ) static void TimerHandler(void *param,int c,attotime period) { y8950_state *info = (y8950_state *)param; - if( attotime_compare(period, attotime_zero) == 0 ) + if( period == attotime::zero ) { /* Reset FM Timer */ timer_enable(info->timer[c], 0); } diff --git a/src/emu/sound/es5503.c b/src/emu/sound/es5503.c index cc2c8f55c98..913fedce84e 100644 --- a/src/emu/sound/es5503.c +++ b/src/emu/sound/es5503.c @@ -444,7 +444,7 @@ WRITE8_DEVICE_HANDLER( es5503_w ) } // ok, we run for this long - period = attotime_mul(ATTOTIME_IN_HZ(chip->output_rate), length); + period = attotime::from_hz(chip->output_rate) * length; timer_adjust_periodic(chip->oscillators[osc].timer, period, 0, period); } diff --git a/src/emu/sound/fm.h b/src/emu/sound/fm.h index a49f470f2da..0a3101f74c2 100644 --- a/src/emu/sound/fm.h +++ b/src/emu/sound/fm.h @@ -43,9 +43,9 @@ struct _ssg_callbacks #define TIME_TYPE attotime #define UNDEFINED_TIME attotime_zero #define FM_GET_TIME_NOW(machine) timer_get_time(machine) -#define ADD_TIMES(t1, t2) attotime_add((t1), (t2)) -#define COMPARE_TIMES(t1, t2) attotime_compare((t1), (t2)) -#define MULTIPLY_TIME_BY_INT(t,i) attotime_mul(t, i) +#define ADD_TIMES(t1, t2) ((t1) + (t2)) +#define COMPARE_TIMES(t1, t2) (((t1) == (t2)) ? 0 : ((t1) < (t2)) ? -1 : 1) +#define MULTIPLY_TIME_BY_INT(t,i) ((t) * (i)) #endif #if BUILD_YM2203 diff --git a/src/emu/sound/fmopl.c b/src/emu/sound/fmopl.c index b5aa064534f..5375c870627 100644 --- a/src/emu/sound/fmopl.c +++ b/src/emu/sound/fmopl.c @@ -1271,7 +1271,7 @@ static void OPL_initalize(FM_OPL *OPL) /*logerror("freqbase=%f\n", OPL->freqbase);*/ /* Timer base time */ - OPL->TimerBase = attotime_mul(ATTOTIME_IN_HZ(OPL->clock), 72); + OPL->TimerBase = attotime::from_hz(OPL->clock) * 72; /* make fnumber -> increment counter table */ for( i=0 ; i < 1024 ; i++ ) @@ -1498,14 +1498,14 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v) /* timer 2 */ if(OPL->st[1] != st2) { - attotime period = st2 ? attotime_mul(OPL->TimerBase, OPL->T[1]) : attotime_zero; + attotime period = st2 ? (OPL->TimerBase * OPL->T[1]) : attotime::zero; OPL->st[1] = st2; if (OPL->timer_handler) (OPL->timer_handler)(OPL->TimerParam,1,period); } /* timer 1 */ if(OPL->st[0] != st1) { - attotime period = st1 ? attotime_mul(OPL->TimerBase, OPL->T[0]) : attotime_zero; + attotime period = st1 ? (OPL->TimerBase * OPL->T[0]) : attotime::zero; OPL->st[0] = st1; if (OPL->timer_handler) (OPL->timer_handler)(OPL->TimerParam,0,period); } @@ -2142,7 +2142,7 @@ static int OPLTimerOver(FM_OPL *OPL,int c) } } /* reload timer */ - if (OPL->timer_handler) (OPL->timer_handler)(OPL->TimerParam,c,attotime_mul(OPL->TimerBase, OPL->T[c])); + if (OPL->timer_handler) (OPL->timer_handler)(OPL->TimerParam,c,OPL->TimerBase * OPL->T[c]); return OPL->status>>7; } diff --git a/src/emu/sound/k053260.c b/src/emu/sound/k053260.c index 37a25745db4..6a0088b7d1b 100644 --- a/src/emu/sound/k053260.c +++ b/src/emu/sound/k053260.c @@ -258,7 +258,7 @@ static DEVICE_START( k053260 ) /* setup SH1 timer if necessary */ if ( ic->intf->irq ) - timer_pulse( device->machine, attotime_mul(ATTOTIME_IN_HZ(device->clock()), 32), NULL, 0, ic->intf->irq ); + timer_pulse( device->machine, attotime::from_hz(device->clock()) * 32, NULL, 0, ic->intf->irq ); } INLINE void check_bounds( k053260_state *ic, int channel ) diff --git a/src/emu/sound/k056800.c b/src/emu/sound/k056800.c index 9f4067d9a38..24ad2c2ffe5 100644 --- a/src/emu/sound/k056800.c +++ b/src/emu/sound/k056800.c @@ -142,7 +142,7 @@ static DEVICE_START( k056800 ) { k056800_state *k056800 = k056800_get_safe_token(device); const k056800_interface *intf = k056800_get_interface(device); - attotime timer_period = attotime_mul(ATTOTIME_IN_HZ(44100), 128); // roughly 2.9us + attotime timer_period = attotime::from_hz(44100) * 128; // roughly 2.9us k056800->irq_cb = intf->irq_cb; diff --git a/src/emu/sound/mos6560.c b/src/emu/sound/mos6560.c index ae6afa7fc0f..d2d3b835cf0 100644 --- a/src/emu/sound/mos6560.c +++ b/src/emu/sound/mos6560.c @@ -145,7 +145,7 @@ INLINE const mos6560_interface *get_interface( device_t *device ) if(VERBOSE_LEVEL >= N) \ { \ if( M ) \ - logerror("%11.6f: %-24s", attotime_to_double(timer_get_time(device->machine)), (char*) M ); \ + logerror("%11.6f: %-24s", timer_get_time(device->machine).as_double(), (char*) M ); \ logerror A; \ } \ } while (0) @@ -460,7 +460,7 @@ READ8_DEVICE_HANDLER( mos6560_port_r ) break; case 6: /*lightpen horizontal */ case 7: /*lightpen vertical */ - if (LIGHTPEN_BUTTON && ((attotime_to_double(timer_get_time(device->machine)) - mos6560->lightpenreadtime) * MOS656X_VRETRACERATE >= 1)) + if (LIGHTPEN_BUTTON && ((timer_get_time(device->machine).as_double() - mos6560->lightpenreadtime) * MOS656X_VRETRACERATE >= 1)) { /* only 1 update each frame */ /* and diode must recognize light */ @@ -469,7 +469,7 @@ READ8_DEVICE_HANDLER( mos6560_port_r ) mos6560->reg[6] = MOS656X_X_VALUE; mos6560->reg[7] = MOS656X_Y_VALUE; } - mos6560->lightpenreadtime = attotime_to_double(timer_get_time(device->machine)); + mos6560->lightpenreadtime = timer_get_time(device->machine).as_double(); } val = mos6560->reg[offset]; break; diff --git a/src/emu/sound/msm5205.c b/src/emu/sound/msm5205.c index 6a607edd238..7a2630b7675 100644 --- a/src/emu/sound/msm5205.c +++ b/src/emu/sound/msm5205.c @@ -274,7 +274,7 @@ static void msm5205_playmode(msm5205_state *voice,int select) /* timer set */ if( prescaler ) { - attotime period = attotime_mul(ATTOTIME_IN_HZ(voice->clock), prescaler); + attotime period = attotime::from_hz(voice->clock) * prescaler; timer_adjust_periodic(voice->timer, period, 0, period); } else @@ -304,7 +304,7 @@ void msm5205_change_clock_w(device_t *device, INT32 clock) voice->clock = clock; - period = attotime_mul(ATTOTIME_IN_HZ(voice->clock), voice->prescaler); + period = attotime::from_hz(voice->clock) * voice->prescaler; timer_adjust_periodic(voice->timer, period, 0, period); } diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c index 8d2bb878d81..8be62d40198 100644 --- a/src/emu/sound/pokey.c +++ b/src/emu/sound/pokey.c @@ -630,8 +630,8 @@ static DEVICE_START( pokey ) * In quick mode (SK_PADDLE set) the conversion is done very fast * (takes two scanlines) but the result is not as accurate. */ - chip->ad_time_fast = attotime_div(attotime_mul(ATTOTIME_IN_NSEC(64000*2/228), FREQ_17_EXACT), device->clock()); - chip->ad_time_slow = attotime_div(attotime_mul(ATTOTIME_IN_NSEC(64000 ), FREQ_17_EXACT), device->clock()); + chip->ad_time_fast = (attotime::from_nsec(64000*2/228) * FREQ_17_EXACT) / device->clock(); + chip->ad_time_slow = (attotime::from_nsec(64000 ) * FREQ_17_EXACT) / device->clock(); /* initialize the poly counters */ poly_init(chip->poly4, 4, 3, 1, 0x00004); @@ -781,7 +781,7 @@ static TIMER_CALLBACK( pokey_pot_trigger ) { pokey_state *p = (pokey_state *)ptr; int pot = param; - LOG(("POKEY #%p POT%d triggers after %dus\n", p, pot, (int)(1000000 * attotime_to_double(timer_timeelapsed(p->ptimer[pot]))))); + LOG(("POKEY #%p POT%d triggers after %dus\n", p, pot, (int)(1000000 * timer_timeelapsed(p->ptimer[pot]).as_double()))); p->ALLPOT &= ~(1 << pot); /* set the enabled timer irq status bits */ } @@ -810,7 +810,7 @@ static void pokey_potgo(pokey_state *p) /* final value */ p->POTx[pot] = r; - timer_adjust_oneshot(p->ptimer[pot], attotime_mul(AD_TIME, r), pot); + timer_adjust_oneshot(p->ptimer[pot], AD_TIME * r, pot); } } } @@ -886,7 +886,7 @@ READ8_DEVICE_HANDLER( pokey_r ) ****************************************************************/ if( p->SKCTL & SK_RESET ) { - adjust = attotime_to_double(timer_timeelapsed(p->rtimer)) / attotime_to_double(p->clock_period); + adjust = timer_timeelapsed(p->rtimer).as_double() / p->clock_period.as_double(); p->r9 = (p->r9 + adjust) % 0x001ff; p->r17 = (p->r17 + adjust) % 0x1ffff; } @@ -1061,7 +1061,7 @@ WRITE8_DEVICE_HANDLER( pokey_w ) { LOG_TIMER(("POKEY '%s' timer1+2 after %d clocks\n", p->device->tag(), p->divisor[CHAN2])); /* set timer #1 _and_ #2 event after timer_div clocks of joined CHAN1+CHAN2 */ - p->timer_period[TIMER2] = attotime_mul(p->clock_period, p->divisor[CHAN2]); + p->timer_period[TIMER2] = p->clock_period * p->divisor[CHAN2]; p->timer_param[TIMER2] = IRQ_TIMR2|IRQ_TIMR1; timer_adjust_periodic(p->timer[TIMER2], p->timer_period[TIMER2], p->timer_param[TIMER2], p->timer_period[TIMER2]); } @@ -1072,7 +1072,7 @@ WRITE8_DEVICE_HANDLER( pokey_w ) { LOG_TIMER(("POKEY '%s' timer1 after %d clocks\n", p->device->tag(), p->divisor[CHAN1])); /* set timer #1 event after timer_div clocks of CHAN1 */ - p->timer_period[TIMER1] = attotime_mul(p->clock_period, p->divisor[CHAN1]); + p->timer_period[TIMER1] = p->clock_period * p->divisor[CHAN1]; p->timer_param[TIMER1] = IRQ_TIMR1; timer_adjust_periodic(p->timer[TIMER1], p->timer_period[TIMER1], p->timer_param[TIMER1], p->timer_period[TIMER1]); } @@ -1081,7 +1081,7 @@ WRITE8_DEVICE_HANDLER( pokey_w ) { LOG_TIMER(("POKEY '%s' timer2 after %d clocks\n", p->device->tag(), p->divisor[CHAN2])); /* set timer #2 event after timer_div clocks of CHAN2 */ - p->timer_period[TIMER2] = attotime_mul(p->clock_period, p->divisor[CHAN2]); + p->timer_period[TIMER2] = p->clock_period * p->divisor[CHAN2]; p->timer_param[TIMER2] = IRQ_TIMR2; timer_adjust_periodic(p->timer[TIMER2], p->timer_period[TIMER2], p->timer_param[TIMER2], p->timer_period[TIMER2]); } @@ -1098,7 +1098,7 @@ WRITE8_DEVICE_HANDLER( pokey_w ) { LOG_TIMER(("POKEY '%s' timer4 after %d clocks\n", p->device->tag(), p->divisor[CHAN4])); /* set timer #4 event after timer_div clocks of CHAN4 */ - p->timer_period[TIMER4] = attotime_mul(p->clock_period, p->divisor[CHAN4]); + p->timer_period[TIMER4] = p->clock_period * p->divisor[CHAN4]; p->timer_param[TIMER4] = IRQ_TIMR4; timer_adjust_periodic(p->timer[TIMER4], p->timer_period[TIMER4], p->timer_param[TIMER4], p->timer_period[TIMER4]); } @@ -1110,7 +1110,7 @@ WRITE8_DEVICE_HANDLER( pokey_w ) { LOG_TIMER(("POKEY '%s' timer4 after %d clocks\n", p->device->tag(), p->divisor[CHAN4])); /* set timer #4 event after timer_div clocks of CHAN4 */ - p->timer_period[TIMER4] = attotime_mul(p->clock_period, p->divisor[CHAN4]); + p->timer_period[TIMER4] = p->clock_period * p->divisor[CHAN4]; p->timer_param[TIMER4] = IRQ_TIMR4; timer_adjust_periodic(p->timer[TIMER4], p->timer_period[TIMER4], p->timer_param[TIMER4], p->timer_period[TIMER4]); } @@ -1208,7 +1208,7 @@ WRITE8_DEVICE_HANDLER( pokey_w ) if( new_val < p->counter[CHAN1] ) p->counter[CHAN1] = new_val; if( p->interrupt_cb && p->timer[TIMER1] ) - timer_adjust_periodic(p->timer[TIMER1], attotime_mul(p->clock_period, new_val), p->timer_param[TIMER1], p->timer_period[TIMER1]); + timer_adjust_periodic(p->timer[TIMER1], p->clock_period * new_val, p->timer_param[TIMER1], p->timer_period[TIMER1]); p->audible[CHAN1] = !( (p->AUDC[CHAN1] & VOLUME_ONLY) || (p->AUDC[CHAN1] & VOLUME_MASK) == 0 || @@ -1244,7 +1244,7 @@ WRITE8_DEVICE_HANDLER( pokey_w ) if( new_val < p->counter[CHAN2] ) p->counter[CHAN2] = new_val; if( p->interrupt_cb && p->timer[TIMER2] ) - timer_adjust_periodic(p->timer[TIMER2], attotime_mul(p->clock_period, new_val), p->timer_param[TIMER2], p->timer_period[TIMER2]); + timer_adjust_periodic(p->timer[TIMER2], p->clock_period * new_val, p->timer_param[TIMER2], p->timer_period[TIMER2]); p->audible[CHAN2] = !( (p->AUDC[CHAN2] & VOLUME_ONLY) || (p->AUDC[CHAN2] & VOLUME_MASK) == 0 || @@ -1309,7 +1309,7 @@ WRITE8_DEVICE_HANDLER( pokey_w ) if( new_val < p->counter[CHAN4] ) p->counter[CHAN4] = new_val; if( p->interrupt_cb && p->timer[TIMER4] ) - timer_adjust_periodic(p->timer[TIMER4], attotime_mul(p->clock_period, new_val), p->timer_param[TIMER4], p->timer_period[TIMER4]); + timer_adjust_periodic(p->timer[TIMER4], p->clock_period * new_val, p->timer_param[TIMER4], p->timer_period[TIMER4]); p->audible[CHAN4] = !( (p->AUDC[CHAN4] & VOLUME_ONLY) || (p->AUDC[CHAN4] & VOLUME_MASK) == 0 || @@ -1338,7 +1338,7 @@ WRITE8_HANDLER( quad_pokey_w ) void pokey_serin_ready(device_t *device, int after) { pokey_state *p = get_safe_token(device); - timer_set(device->machine, attotime_mul(p->clock_period, after), p, 0, pokey_serin_ready_cb); + timer_set(device->machine, p->clock_period * after, p, 0, pokey_serin_ready_cb); } void pokey_break_w(device_t *device, int shift) diff --git a/src/emu/sound/sp0250.c b/src/emu/sound/sp0250.c index 91340b2a411..049dccbc440 100644 --- a/src/emu/sound/sp0250.c +++ b/src/emu/sound/sp0250.c @@ -208,7 +208,7 @@ static DEVICE_START( sp0250 ) if (sp->drq != NULL) { sp->drq(sp->device, ASSERT_LINE); - timer_pulse(device->machine, attotime_mul(ATTOTIME_IN_HZ(device->clock()), CLOCK_DIVIDER), sp, 0, sp0250_timer_tick); + timer_pulse(device->machine, attotime::from_hz(device->clock()) * CLOCK_DIVIDER, sp, 0, sp0250_timer_tick); } sp->stream = device->machine->sound().stream_alloc(*device, 0, 1, device->clock() / CLOCK_DIVIDER, sp, sp0250_update); diff --git a/src/emu/sound/speaker.c b/src/emu/sound/speaker.c index 5d6112d2c06..cc4d331055c 100644 --- a/src/emu/sound/speaker.c +++ b/src/emu/sound/speaker.c @@ -165,8 +165,8 @@ static DEVICE_START( speaker ) sp->interm_sample_period = sp->channel_sample_period / RATE_MULTIPLIER; sp->interm_sample_period_secfrac = ATTOSECONDS_TO_DOUBLE(sp->interm_sample_period); sp->channel_last_sample_time = sp->channel->sample_time(); - sp->channel_next_sample_time = attotime_add_attoseconds(sp->channel_last_sample_time, sp->channel_sample_period); - sp->next_interm_sample_time = attotime_add_attoseconds(sp->channel_last_sample_time, sp->interm_sample_period); + sp->channel_next_sample_time = sp->channel_last_sample_time + attotime(0, sp->channel_sample_period); + sp->next_interm_sample_time = sp->channel_last_sample_time + attotime(0, sp->interm_sample_period); sp->interm_sample_index = 0; /* Note: To avoid time drift due to floating point inaccuracies, * it is good if the speaker time synchronizes itself with the stream timing regularly. @@ -224,9 +224,9 @@ static STREAM_UPDATE( speaker_sound_update ) if (samples > 0) { /* Prepare to update time state */ - sampled_time = attotime_make(0, sp->channel_sample_period); + sampled_time = attotime(0, sp->channel_sample_period); if (samples > 1) - sampled_time = attotime_mul(sampled_time, samples); + sampled_time *= samples; /* Note: since the stream is in the process of being updated, * stream->sample_time() will return the time before the update! (MAME 0.130) @@ -250,9 +250,9 @@ static STREAM_UPDATE( speaker_sound_update ) } /* Update the time state */ - sp->channel_last_sample_time = attotime_add(sp->channel_last_sample_time, sampled_time); - sp->channel_next_sample_time = attotime_add_attoseconds(sp->channel_last_sample_time, sp->channel_sample_period); - sp->next_interm_sample_time = attotime_add_attoseconds(sp->channel_last_sample_time, sp->interm_sample_period); + sp->channel_last_sample_time += sampled_time; + sp->channel_next_sample_time = sp->channel_last_sample_time + attotime(0, sp->channel_sample_period); + sp->next_interm_sample_time = sp->channel_last_sample_time + attotime(0, sp->interm_sample_period); sp->last_update_time = sp->channel_last_sample_time; } @@ -277,7 +277,7 @@ void speaker_level_w(device_t *device, int new_level) volume = sp->levels[sp->level]; time = timer_get_time(device->machine); - if (attotime_compare(time, sp->channel_next_sample_time) < 0) + if (time < sp->channel_next_sample_time) { /* Stream sample is yet unfinished, but we may have one or more interm. samples */ update_interm_samples(sp, time, volume); @@ -298,8 +298,8 @@ void speaker_level_w(device_t *device, int new_level) * however this ensures synchronization between the speaker and stream timing: */ sp->channel_last_sample_time = sp->channel->sample_time(); - sp->channel_next_sample_time = attotime_add_attoseconds(sp->channel_last_sample_time, sp->channel_sample_period); - sp->next_interm_sample_time = attotime_add_attoseconds(sp->channel_last_sample_time, sp->interm_sample_period); + sp->channel_next_sample_time = sp->channel_last_sample_time + attotime(0, sp->channel_sample_period); + sp->next_interm_sample_time = sp->channel_last_sample_time + attotime(0, sp->interm_sample_period); sp->last_update_time = sp->channel_last_sample_time; /* Assertion: time - last_update_time < channel_sample_period, i.e. time < channel_next_sample_time */ @@ -318,7 +318,7 @@ static void update_interm_samples(speaker_state *sp, attotime time, int volume) double fraction; /* We may have completed zero, one or more interm. samples: */ - while (attotime_compare(time, sp->next_interm_sample_time) >= 0) + while (time >= sp->next_interm_sample_time) { /* First interm. sample may be composed, subsequent samples will be homogeneous. */ /* Treat all the same general way. */ @@ -373,8 +373,7 @@ static void finalize_interm_sample(speaker_state *sp, int volume) sp->composed_volume[sp->composed_sample_index] += volume * fraction; /* Update time state */ sp->last_update_time = sp->next_interm_sample_time; - sp->next_interm_sample_time = attotime_add_attoseconds(sp->next_interm_sample_time, - sp->interm_sample_period); + sp->next_interm_sample_time += attotime(0, sp->interm_sample_period); /* For compatibility with filtering, do not incr. index and initialise next sample yet. */ } @@ -396,7 +395,7 @@ static void init_next_interm_sample(speaker_state *sp) static double make_fraction(attotime a, attotime b, double timediv) { /* fraction = (a - b) / timediv */ - return attotime_to_double(attotime_sub(a, b)) / timediv; + return (a - b).as_double() / timediv; } diff --git a/src/emu/sound/upd7759.c b/src/emu/sound/upd7759.c index 3349b3a98f6..a20d3dbdcf4 100644 --- a/src/emu/sound/upd7759.c +++ b/src/emu/sound/upd7759.c @@ -547,7 +547,7 @@ static TIMER_CALLBACK( upd7759_slave_update ) /* set a timer to go off when that is done */ if (chip->state != STATE_IDLE) - timer_adjust_oneshot(chip->timer, attotime_mul(chip->clock_period, chip->clocks_left), 0); + timer_adjust_oneshot(chip->timer, chip->clock_period * chip->clocks_left, 0); } diff --git a/src/emu/sound/ym2151.c b/src/emu/sound/ym2151.c index 767743b6215..c6be72bfeef 100644 --- a/src/emu/sound/ym2151.c +++ b/src/emu/sound/ym2151.c @@ -690,21 +690,21 @@ static void init_chip_tables(YM2151 *chip) for (i=0; i<1024; i++) { /* ASG 980324: changed to compute both tim_A_tab and timer_A_time */ - pom= attotime_mul(ATTOTIME_IN_HZ(chip->clock), 64 * (1024 - i)); + pom= attotime::from_hz(chip->clock) * (64 * (1024 - i)); #ifdef USE_MAME_TIMERS chip->timer_A_time[i] = pom; #else - chip->tim_A_tab[i] = attotime_to_double(pom) * (double)chip->sampfreq * mult; /* number of samples that timer period takes (fixed point) */ + chip->tim_A_tab[i] = pom.as_double() * (double)chip->sampfreq * mult; /* number of samples that timer period takes (fixed point) */ #endif } for (i=0; i<256; i++) { /* ASG 980324: changed to compute both tim_B_tab and timer_B_time */ - pom= attotime_mul(ATTOTIME_IN_HZ(chip->clock), 1024 * (256 - i)); + pom= attotime::from_hz(chip->clock) * (1024 * (256 - i)); #ifdef USE_MAME_TIMERS chip->timer_B_time[i] = pom; #else - chip->tim_B_tab[i] = attotime_to_double(pom) * (double)chip->sampfreq * mult; /* number of samples that timer period takes (fixed point) */ + chip->tim_B_tab[i] = pom.as_double() * (double)chip->sampfreq * mult; /* number of samples that timer period takes (fixed point) */ #endif } @@ -1049,7 +1049,7 @@ void ym2151_write_reg(void *_chip, int r, int v) #if 0 /* There is no info on what YM2151 really does when busy flag is set */ if ( chip->status & 0x80 ) return; - timer_set ( attotime_mul(ATTOTIME_IN_HZ(chip->clock), 64), chip, 0, timer_callback_chip_busy); + timer_set ( attotime::from_hz(chip->clock) * 64, chip, 0, timer_callback_chip_busy); chip->status |= 0x80; /* set busy flag for 64 chip clock cycles */ #endif diff --git a/src/emu/sound/ymf262.c b/src/emu/sound/ymf262.c index cafd3f147e0..3c57e047168 100644 --- a/src/emu/sound/ymf262.c +++ b/src/emu/sound/ymf262.c @@ -1317,7 +1317,7 @@ static void OPL3_initalize(OPL3 *chip) /* logerror("YMF262: freqbase=%f\n", chip->freqbase); */ /* Timer base time */ - chip->TimerBase = attotime_mul(ATTOTIME_IN_HZ(chip->clock), 8*36); + chip->TimerBase = attotime::from_hz(chip->clock) * (8*36); /* make fnumber -> increment counter table */ for( i=0 ; i < 1024 ; i++ ) @@ -1742,14 +1742,14 @@ static void OPL3WriteReg(OPL3 *chip, int r, int v) /* timer 2 */ if(chip->st[1] != st2) { - attotime period = st2 ? attotime_mul(chip->TimerBase, chip->T[1]) : attotime_zero; + attotime period = st2 ? chip->TimerBase * chip->T[1] : attotime::zero; chip->st[1] = st2; if (chip->timer_handler) (chip->timer_handler)(chip->TimerParam,1,period); } /* timer 1 */ if(chip->st[0] != st1) { - attotime period = st1 ? attotime_mul(chip->TimerBase, chip->T[0]) : attotime_zero; + attotime period = st1 ? chip->TimerBase * chip->T[0] : attotime::zero; chip->st[0] = st1; if (chip->timer_handler) (chip->timer_handler)(chip->TimerParam,0,period); } @@ -2454,7 +2454,7 @@ static int OPL3TimerOver(OPL3 *chip,int c) OPL3_STATUS_SET(chip,0x40); } /* reload timer */ - if (chip->timer_handler) (chip->timer_handler)(chip->TimerParam,c,attotime_mul(chip->TimerBase, chip->T[c])); + if (chip->timer_handler) (chip->timer_handler)(chip->TimerParam,c,chip->TimerBase * chip->T[c]); return chip->status>>7; } diff --git a/src/emu/sound/ymf271.c b/src/emu/sound/ymf271.c index f60ed3a7ea3..7e26065929f 100644 --- a/src/emu/sound/ymf271.c +++ b/src/emu/sound/ymf271.c @@ -1484,7 +1484,7 @@ static void ymf271_write_timer(YMF271Chip *chip, int data) if (chip->irq_callback) chip->irq_callback(chip->device, 0); //period = (double)(256.0 - chip->timerAVal ) * ( 384.0 * 4.0 / (double)CLOCK); - period = attotime_mul(ATTOTIME_IN_HZ(chip->clock), 384 * (1024 - chip->timerAVal)); + period = attotime::from_hz(chip->clock) * (384 * (1024 - chip->timerAVal)); timer_adjust_periodic(chip->timA, period, 0, period); } @@ -1495,7 +1495,7 @@ static void ymf271_write_timer(YMF271Chip *chip, int data) if (chip->irq_callback) chip->irq_callback(chip->device, 0); - period = attotime_mul(ATTOTIME_IN_HZ(chip->clock), 384 * 16 * (256 - chip->timerBVal)); + period = attotime::from_hz(chip->clock) * (384 * 16 * (256 - chip->timerBVal)); timer_adjust_periodic(chip->timB, period, 0, period); } diff --git a/src/emu/sound/ymf278b.c b/src/emu/sound/ymf278b.c index 8cc602cf0a9..456861820e9 100644 --- a/src/emu/sound/ymf278b.c +++ b/src/emu/sound/ymf278b.c @@ -375,7 +375,7 @@ static void ymf278b_timer_a_reset(YMF278BChip *chip) attotime period = ATTOTIME_IN_NSEC((256-chip->timer_a_count) * 80800); if (chip->clock != YMF278B_STD_CLOCK) - period = attotime_div(attotime_mul(period, chip->clock), YMF278B_STD_CLOCK); + period = (period * chip->clock) / YMF278B_STD_CLOCK; timer_adjust_periodic(chip->timer_a, period, 0, period); } @@ -390,7 +390,7 @@ static void ymf278b_timer_b_reset(YMF278BChip *chip) attotime period = ATTOTIME_IN_NSEC((256-chip->timer_b_count) * 323100); if (chip->clock != YMF278B_STD_CLOCK) - period = attotime_div(attotime_mul(period, chip->clock), YMF278B_STD_CLOCK); + period = (period * chip->clock) / YMF278B_STD_CLOCK; timer_adjust_periodic(chip->timer_b, period, 0, period); } diff --git a/src/emu/timer.c b/src/emu/timer.c index 3ebe0e614c7..0c82b1d8a43 100644 --- a/src/emu/timer.c +++ b/src/emu/timer.c @@ -197,7 +197,7 @@ INLINE void timer_list_insert(emu_timer *timer) for (t = global->activelist; t != NULL; lt = t, t = t->next) { /* if the current list entry expires after us, we should be inserted before it */ - if (attotime_compare(t->expire, expire) > 0) + if (t->expire > expire) { /* link the new guy in before the current list entry */ timer->prev = t->prev; @@ -348,7 +348,7 @@ void timer_execute_timers(running_machine *machine) emu_timer *timer; /* if the current quantum has expired, find a new one */ - if (attotime_compare(global->exec.basetime, global->quantum_current->expire) >= 0) + if (global->exec.basetime >= global->quantum_current->expire) { int curr; @@ -360,16 +360,16 @@ void timer_execute_timers(running_machine *machine) global->exec.curquantum = global->quantum_current->actual; } - LOG(("timer_set_global_time: new=%s head->expire=%s\n", attotime_string(global->exec.basetime, 9), attotime_string(global->activelist->expire, 9))); + LOG(("timer_set_global_time: new=%s head->expire=%s\n", global->exec.basetime.as_string(), global->activelist->expire.as_string())); /* now process any timers that are overdue */ - while (attotime_compare(global->activelist->expire, global->exec.basetime) <= 0) + while (global->activelist->expire <= global->exec.basetime) { int was_enabled = global->activelist->enabled; /* if this is a one-shot timer, disable it now */ timer = global->activelist; - if (attotime_compare(timer->period, attotime_zero) == 0 || attotime_compare(timer->period, attotime_never) == 0) + if (timer->period == attotime::zero || timer->period == attotime::never) timer->enabled = FALSE; /* set the global state of which callback we're in */ @@ -384,7 +384,7 @@ void timer_execute_timers(running_machine *machine) timer->device->timer_fired(*timer, timer->id, timer->param, timer->ptr); else if (timer->callback != NULL) { - LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9))); + LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, timer->expire.as_string())); g_profiler.start(PROFILER_TIMER_CALLBACK); (*timer->callback)(machine, timer->ptr, timer->param); g_profiler.stop(); @@ -405,7 +405,7 @@ void timer_execute_timers(running_machine *machine) else { timer->start = timer->expire; - timer->expire = attotime_add(timer->expire, timer->period); + timer->expire += timer->period; timer_list_remove(timer); timer_list_insert(timer); @@ -425,7 +425,7 @@ void timer_add_scheduling_quantum(running_machine *machine, attoseconds_t quantu { timer_private *global = machine->timer_data; attotime curtime = timer_get_time(machine); - attotime expire = attotime_add(curtime, duration); + attotime expire = curtime + duration; int curr, blank = -1; /* a 0 request (minimum) needs to be non-zero to occupy a slot */ @@ -440,7 +440,7 @@ void timer_add_scheduling_quantum(running_machine *machine, attoseconds_t quantu /* look for a matching quantum and extend it */ if (slot->requested == quantum) { - slot->expire = attotime_max(slot->expire, expire); + slot->expire = max(slot->expire, expire); return; } @@ -452,7 +452,7 @@ void timer_add_scheduling_quantum(running_machine *machine, attoseconds_t quantu } /* otherwise, expire any expired slots */ - else if (attotime_compare(curtime, slot->expire) >= 0) + else if (curtime >= slot->expire) slot->requested = 0; } @@ -718,7 +718,7 @@ void timer_adjust_periodic(emu_timer *which, attotime start_delay, INT32 param, /* set the start and expire times */ which->start = time; - which->expire = attotime_add(time, start_delay); + which->expire = time + start_delay; which->period = period; /* remove and re-insert the timer in its new order */ @@ -726,7 +726,7 @@ void timer_adjust_periodic(emu_timer *which, attotime start_delay, INT32 param, timer_list_insert(which); /* if this was inserted as the head, abort the current timeslice and resync */ - LOG(("timer_adjust_oneshot %s.%s:%d to expire @ %s\n", which->file, which->func, which->line, attotime_string(which->expire, 9))); + LOG(("timer_adjust_oneshot %s.%s:%d to expire @ %s\n", which->file, which->func, which->line, which->expire.as_string())); if (which == global->activelist) which->machine->scheduler().abort_timeslice(); } @@ -874,7 +874,7 @@ void timer_set_ptr(emu_timer *which, void *ptr) attotime timer_timeelapsed(emu_timer *which) { - return attotime_sub(get_current_time(which->machine), which->start); + return get_current_time(which->machine) - which->start; } @@ -885,7 +885,7 @@ attotime timer_timeelapsed(emu_timer *which) attotime timer_timeleft(emu_timer *which) { - return attotime_sub(which->expire, get_current_time(which->machine)); + return which->expire - get_current_time(which->machine); } @@ -942,12 +942,12 @@ static void timer_logtimers(running_machine *machine) logerror("Enqueued timers:\n"); for (t = global->activelist; t; t = t->next) logerror(" Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s:%d[%s])\n", - attotime_to_double(t->start), attotime_to_double(t->expire), attotime_to_double(t->period), t->enabled, t->temporary, t->file, t->line, t->func); + t->start.as_double(), t->expire.as_double(), t->period.as_double(), t->enabled, t->temporary, t->file, t->line, t->func); logerror("Free timers:\n"); for (t = global->freelist; t; t = t->next) logerror(" Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s:%d[%s])\n", - attotime_to_double(t->start), attotime_to_double(t->expire), attotime_to_double(t->period), t->enabled, t->temporary, t->file, t->line, t->func); + t->start.as_double(), t->expire.as_double(), t->period.as_double(), t->enabled, t->temporary, t->file, t->line, t->func); logerror("==============\n"); logerror("TIMER LOG STOP\n"); @@ -960,7 +960,7 @@ void timer_print_first_timer(running_machine *machine) timer_private *global = machine->timer_data; emu_timer *t = global->activelist; printf(" Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s)\n", - attotime_to_double(t->start), attotime_to_double(t->expire), attotime_to_double(t->period), t->enabled, t->temporary, t->func); + t->start.as_double(), t->expire.as_double(), t->period.as_double(), t->enabled, t->temporary, t->func); } @@ -1112,16 +1112,16 @@ bool timer_device_config::device_validity_check(const game_driver &driver) const switch (m_type) { case TIMER_TYPE_GENERIC: - if (m_screen != NULL || m_first_vpos != 0 || attotime_compare(m_start_delay, attotime_zero) != 0) + if (m_screen != NULL || m_first_vpos != 0 || m_start_delay != attotime::zero) mame_printf_warning("%s: %s generic timer '%s' specified parameters for a scanline timer\n", driver.source_file, driver.name, tag()); - if (attotime_compare(m_period, attotime_zero) != 0 || attotime_compare(m_start_delay, attotime_zero) != 0) + if (m_period != attotime::zero || m_start_delay != attotime::zero) mame_printf_warning("%s: %s generic timer '%s' specified parameters for a periodic timer\n", driver.source_file, driver.name, tag()); break; case TIMER_TYPE_PERIODIC: if (m_screen != NULL || m_first_vpos != 0) mame_printf_warning("%s: %s periodic timer '%s' specified parameters for a scanline timer\n", driver.source_file, driver.name, tag()); - if (attotime_compare(m_period, attotime_zero) <= 0) + if (m_period <= attotime::zero) { mame_printf_error("%s: %s periodic timer '%s' specified invalid period\n", driver.source_file, driver.name, tag()); error = true; @@ -1129,7 +1129,7 @@ bool timer_device_config::device_validity_check(const game_driver &driver) const break; case TIMER_TYPE_SCANLINE: - if (attotime_compare(m_period, attotime_zero) != 0 || attotime_compare(m_start_delay, attotime_zero) != 0) + if (m_period != attotime::zero || m_start_delay != attotime::zero) mame_printf_warning("%s: %s scanline timer '%s' specified parameters for a periodic timer\n", driver.source_file, driver.name, tag()); if (m_param != 0) mame_printf_warning("%s: %s scanline timer '%s' specified parameter which is ignored\n", driver.source_file, driver.name, tag()); @@ -1208,13 +1208,13 @@ void timer_device::device_reset() { // convert the period into attotime attotime period = attotime_never; - if (attotime_compare(m_config.m_period, attotime_zero) > 0) + if (m_config.m_period > attotime::zero) { period = m_config.m_period; // convert the start_delay into attotime attotime start_delay = attotime_zero; - if (attotime_compare(m_config.m_start_delay, attotime_zero) > 0) + if (m_config.m_start_delay > attotime_zero) start_delay = m_config.m_start_delay; // allocate and start the backing timer diff --git a/src/emu/video.c b/src/emu/video.c index 0efb08adebd..a066fadae11 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -435,7 +435,7 @@ void video_manager::begin_recording(const char *name, movie_format format) filerr = mame_fopen_next(SEARCHPATH_MOVIE, "avi", tempfile); // compute the frame time - m_movie_frame_period = attotime_div(ATTOTIME_IN_SEC(1000), info.video_timescale); + m_movie_frame_period = attotime::from_seconds(1000) / info.video_timescale; // if we succeeded, make a copy of the name and create the real file over top if (filerr == FILERR_NONE) @@ -551,8 +551,8 @@ void video_manager::exit() { osd_ticks_t tps = osd_ticks_per_second(); double final_real_time = (double)m_overall_real_seconds + (double)m_overall_real_ticks / (double)tps; - double final_emu_time = attotime_to_double(m_overall_emutime); - mame_printf_info("Average speed: %.2f%% (%d seconds)\n", 100 * final_emu_time / final_real_time, attotime_add_attoseconds(m_overall_emutime, ATTOSECONDS_PER_SECOND / 2).seconds); + double final_emu_time = m_overall_emutime.as_double(); + mame_printf_info("Average speed: %.2f%% (%d seconds)\n", 100 * final_emu_time / final_real_time, (m_overall_emutime + attotime(0, ATTOSECONDS_PER_SECOND / 2)).seconds); } } @@ -741,7 +741,7 @@ void video_manager::update_throttle(attotime emutime) if (m_speed != 0 && m_speed != 100) { // multiply emutime by 100, then divide by the global speed factor - emutime = attotime_div(attotime_mul(emutime, 100), m_speed); + emutime = (emutime * 100) / m_speed; } // compute conversion factors up front @@ -755,7 +755,7 @@ void video_manager::update_throttle(attotime emutime) // ago, and was in sync in both real and emulated time if (m_machine.paused()) { - m_throttle_emutime = attotime_sub_attoseconds(emutime, ATTOSECONDS_PER_SECOND / PAUSED_REFRESH_RATE); + m_throttle_emutime = emutime - attotime(0, ATTOSECONDS_PER_SECOND / PAUSED_REFRESH_RATE); m_throttle_realtime = m_throttle_emutime; } @@ -763,11 +763,11 @@ void video_manager::update_throttle(attotime emutime) // reported value from our current value; this should be a small value somewhere // between 0 and 1/10th of a second ... anything outside of this range is obviously // wrong and requires a resync - attoseconds_t emu_delta_attoseconds = attotime_to_attoseconds(attotime_sub(emutime, m_throttle_emutime)); + attoseconds_t emu_delta_attoseconds = (emutime - m_throttle_emutime).as_attoseconds(); if (emu_delta_attoseconds < 0 || emu_delta_attoseconds > ATTOSECONDS_PER_SECOND / 10) { if (LOG_THROTTLE) - logerror("Resync due to weird emutime delta: %s\n", attotime_string(attotime_make(0, emu_delta_attoseconds), 18)); + logerror("Resync due to weird emutime delta: %s\n", attotime(0, emu_delta_attoseconds).as_string(18)); break; } @@ -791,7 +791,7 @@ void video_manager::update_throttle(attotime emutime) // now update our real and emulated timers with the current values m_throttle_emutime = emutime; - m_throttle_realtime = attotime_add_attoseconds(m_throttle_realtime, real_delta_attoseconds); + m_throttle_realtime += attotime(0, real_delta_attoseconds); // keep a history of whether or not emulated time beat real time over the last few // updates; this can be used for future heuristics @@ -800,7 +800,7 @@ void video_manager::update_throttle(attotime emutime) // determine how far ahead real time is versus emulated time; note that we use the // accumulated times for this instead of the deltas for the current update because // we want to track time over a longer duration than a single update - attoseconds_t real_is_ahead_attoseconds = attotime_to_attoseconds(attotime_sub(m_throttle_emutime, m_throttle_realtime)); + attoseconds_t real_is_ahead_attoseconds = (m_throttle_emutime - m_throttle_realtime).as_attoseconds(); // if we're more than 1/10th of a second out, or if we are behind at all and emulation // is taking longer than the real frame, we just need to resync @@ -808,7 +808,7 @@ void video_manager::update_throttle(attotime emutime) (real_is_ahead_attoseconds < 0 && popcount[m_throttle_history & 0xff] < 6)) { if (LOG_THROTTLE) - logerror("Resync due to being behind: %s (history=%08X)\n", attotime_string(attotime_make(0, -real_is_ahead_attoseconds), 18), m_throttle_history); + logerror("Resync due to being behind: %s (history=%08X)\n", attotime(0, -real_is_ahead_attoseconds).as_string(18), m_throttle_history); break; } @@ -822,7 +822,7 @@ void video_manager::update_throttle(attotime emutime) // throttle until we read the target, and update real time to match the final time diff_ticks = throttle_until_ticks(target_ticks) - m_throttle_last_ticks; m_throttle_last_ticks += diff_ticks; - m_throttle_realtime = attotime_add_attoseconds(m_throttle_realtime, diff_ticks * attoseconds_per_tick); + m_throttle_realtime += attotime(0, diff_ticks * attoseconds_per_tick); return; } @@ -997,14 +997,14 @@ void video_manager::recompute_speed(attotime emutime) } // if it has been more than the update interval, update the time - attoseconds_t delta_emutime = attotime_to_attoseconds(attotime_sub(emutime, m_speed_last_emutime)); - if (delta_emutime > SUBSECONDS_PER_SPEED_UPDATE) + attotime delta_emutime = emutime - m_speed_last_emutime; + if (delta_emutime > attotime(0, ATTOSECONDS_PER_SPEED_UPDATE)) { // convert from ticks to attoseconds osd_ticks_t realtime = osd_ticks(); osd_ticks_t delta_realtime = realtime - m_speed_last_realtime; osd_ticks_t tps = osd_ticks_per_second(); - m_speed_percent = (double)delta_emutime * (double)tps / ((double)delta_realtime * (double)ATTOSECONDS_PER_SECOND); + m_speed_percent = delta_emutime.as_double() * (double)tps / (double)delta_realtime; // remember the last times m_speed_last_realtime = realtime; @@ -1025,7 +1025,7 @@ void video_manager::recompute_speed(attotime emutime) m_overall_real_ticks -= tps; m_overall_real_seconds++; } - m_overall_emutime = attotime_add_attoseconds(m_overall_emutime, delta_emutime); + m_overall_emutime += delta_emutime; } } @@ -1235,7 +1235,7 @@ void video_manager::record_frame() create_snapshot_bitmap(NULL); // loop until we hit the right time - while (attotime_compare(m_movie_next_frame_time, curtime) <= 0) + while (m_movie_next_frame_time <= curtime) { // handle an AVI recording if (m_avifile != NULL) @@ -1274,7 +1274,7 @@ void video_manager::record_frame() } // advance time - m_movie_next_frame_time = attotime_add(m_movie_next_frame_time, m_movie_frame_period); + m_movie_next_frame_time += m_movie_frame_period; m_movie_frame++; } g_profiler.stop(); diff --git a/src/emu/video.h b/src/emu/video.h index 6dc0a04c86d..677f34157eb 100644 --- a/src/emu/video.h +++ b/src/emu/video.h @@ -195,7 +195,7 @@ private: static const UINT8 s_skiptable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS]; - static const attoseconds_t SUBSECONDS_PER_SPEED_UPDATE = ATTOSECONDS_PER_SECOND / 4; + static const attoseconds_t ATTOSECONDS_PER_SPEED_UPDATE = ATTOSECONDS_PER_SECOND / 4; static const int PAUSED_REFRESH_RATE = 30; }; diff --git a/src/emu/video/mc6845.c b/src/emu/video/mc6845.c index 8a6d8467f70..e32c1cc95f9 100644 --- a/src/emu/video/mc6845.c +++ b/src/emu/video/mc6845.c @@ -384,7 +384,7 @@ static void recompute_parameters(mc6845_t *mc6845, int postload) vert_sync_pix_width = 0x10; /* determine the transparent update cycle time, 1 update every 4 character clocks */ - mc6845->upd_time = attotime_mul(ATTOTIME_IN_HZ(mc6845->clock), 4 * mc6845->hpixels_per_column); + mc6845->upd_time = attotime::from_hz(mc6845->clock) * (4 * mc6845->hpixels_per_column); hsync_on_pos = mc6845->horiz_sync_pos * mc6845->hpixels_per_column; hsync_off_pos = hsync_on_pos + (horiz_sync_char_width * mc6845->hpixels_per_column); @@ -447,11 +447,11 @@ static void recompute_parameters(mc6845_t *mc6845, int postload) INLINE void mc6845_update_counters(mc6845_t *mc6845) { - mc6845->character_counter = attotime_to_ticks( timer_timeelapsed( mc6845->line_timer ), mc6845->clock ); + mc6845->character_counter = timer_timeelapsed( mc6845->line_timer ).as_ticks( mc6845->clock ); if ( timer_enabled( mc6845->hsync_off_timer ) ) { - mc6845->hsync_width_counter = attotime_to_ticks( timer_timeelapsed( mc6845->hsync_off_timer ), mc6845->clock ); + mc6845->hsync_width_counter = timer_timeelapsed( mc6845->hsync_off_timer ).as_ticks( mc6845->clock ); } } @@ -549,7 +549,7 @@ static TIMER_CALLBACK( cur_on_timer_cb ) mc6845_set_cur( mc6845, TRUE ); /* Schedule CURSOR off signal */ - timer_adjust_oneshot( mc6845->cur_off_timer, ticks_to_attotime( 1, mc6845->clock ), 0 ); + timer_adjust_oneshot( mc6845->cur_off_timer, attotime::from_ticks( 1, mc6845->clock ), 0 ); } @@ -572,7 +572,7 @@ static TIMER_CALLBACK( hsync_on_timer_cb ) mc6845_set_hsync( mc6845, TRUE ); /* Schedule HSYNC off signal */ - timer_adjust_oneshot( mc6845->hsync_off_timer, ticks_to_attotime( hsync_width, mc6845->clock ), 0 ); + timer_adjust_oneshot( mc6845->hsync_off_timer, attotime::from_ticks( hsync_width, mc6845->clock ), 0 ); } @@ -668,7 +668,7 @@ static TIMER_CALLBACK( line_timer_cb ) if ( mc6845->line_enable_ff ) { /* Schedule DE off signal change */ - timer_adjust_oneshot(mc6845->de_off_timer, ticks_to_attotime( mc6845->horiz_disp, mc6845->clock ), 0); + timer_adjust_oneshot(mc6845->de_off_timer, attotime::from_ticks( mc6845->horiz_disp, mc6845->clock ), 0); /* Is cursor visible on this line? */ if ( mc6845->cursor_state && @@ -680,15 +680,15 @@ static TIMER_CALLBACK( line_timer_cb ) mc6845->cursor_x = mc6845->cursor_addr - mc6845->line_address; /* Schedule CURSOR ON signal */ - timer_adjust_oneshot( mc6845->cur_on_timer, ticks_to_attotime( mc6845->cursor_x, mc6845->clock ), 0 ); + timer_adjust_oneshot( mc6845->cur_on_timer, attotime::from_ticks( mc6845->cursor_x, mc6845->clock ), 0 ); } } /* Schedule HSYNC on signal */ - timer_adjust_oneshot( mc6845->hsync_on_timer, ticks_to_attotime( mc6845->horiz_sync_pos, mc6845->clock ), 0 ); + timer_adjust_oneshot( mc6845->hsync_on_timer, attotime::from_ticks( mc6845->horiz_sync_pos, mc6845->clock ), 0 ); /* Schedule our next callback */ - timer_adjust_oneshot( mc6845->line_timer, ticks_to_attotime( mc6845->horiz_char_total + 1, mc6845->clock ), 0 ); + timer_adjust_oneshot( mc6845->line_timer, attotime::from_ticks( mc6845->horiz_char_total + 1, mc6845->clock ), 0 ); /* Set VSYNC and DE signals */ mc6845_set_vsync( mc6845, new_vsync ); @@ -730,7 +730,7 @@ void mc6845_assert_light_pen_input(device_t *device) /* compute the pixel coordinate of the NEXT character -- this is when the light pen latches */ /* set the timer that will latch the display address into the light pen registers */ - timer_adjust_oneshot(mc6845->light_pen_latch_timer, ticks_to_attotime( 1, mc6845->clock ), 0); + timer_adjust_oneshot(mc6845->light_pen_latch_timer, attotime::from_ticks( 1, mc6845->clock ), 0); } @@ -1011,7 +1011,7 @@ static DEVICE_RESET( mc6845 ) if ( ! timer_enabled( mc6845->line_timer ) ) { - timer_adjust_oneshot( mc6845->line_timer, ticks_to_attotime( mc6845->horiz_char_total + 1, mc6845->clock ), 0 ); + timer_adjust_oneshot( mc6845->line_timer, attotime::from_ticks( mc6845->horiz_char_total + 1, mc6845->clock ), 0 ); } mc6845->light_pen_latched = FALSE; diff --git a/src/emu/video/pc_vga.c b/src/emu/video/pc_vga.c index 3d2d1008373..22af28f0462 100644 --- a/src/emu/video/pc_vga.c +++ b/src/emu/video/pc_vga.c @@ -781,7 +781,7 @@ static READ8_HANDLER(vga_crtc_r) int clock=vga.monitor.get_clock(); int lines=vga.monitor.get_lines(); int columns=vga.monitor.get_columns(); - int diff = (attotime_mul(attotime_sub(timer_get_time(space->machine), vga.monitor.start_time), clock).seconds) + int diff = (((timer_get_time(space->machine) - vga.monitor.start_time) * clock).seconds) %(lines*columns); if (diff<columns*vga.monitor.get_sync_lines()) data|=8; diff=diff/lines; @@ -791,7 +791,7 @@ static READ8_HANDLER(vga_crtc_r) if (vga.monitor.retrace) { data |= 1; - if (attotime_compare(attotime_sub(timer_get_time(space->machine), vga.monitor.start_time), ATTOTIME_IN_USEC(300)) > 0) + if ((timer_get_time(space->machine) - vga.monitor.start_time) > attotime::from_usec(300)) { data |= 8; vga.monitor.retrace=0; @@ -799,7 +799,7 @@ static READ8_HANDLER(vga_crtc_r) } else { - if (attotime_compare(attotime_sub(timer_get_time(space->machine), vga.monitor.start_time), ATTOTIME_IN_MSEC(15)) > 0) + if ((timer_get_time(space->machine) - vga.monitor.start_time) > attotime::from_msec(15)) vga.monitor.retrace=1; vga.monitor.start_time=timer_get_time(space->machine); } diff --git a/src/emu/video/voodoo.c b/src/emu/video/voodoo.c index 9751969338b..1e4841dbe6e 100644 --- a/src/emu/video/voodoo.c +++ b/src/emu/video/voodoo.c @@ -984,7 +984,7 @@ static void adjust_vblank_timer(voodoo_state *v) attotime vblank_period = v->screen->time_until_pos(v->fbi.vsyncscan); /* if zero, adjust to next frame, otherwise we may get stuck in an infinite loop */ - if (attotime_compare(vblank_period, attotime_zero) == 0) + if (vblank_period == attotime::zero) vblank_period = v->screen->frame_period(); timer_adjust_oneshot(v->fbi.vblank_timer, vblank_period, 0); } @@ -2003,7 +2003,7 @@ static void cmdfifo_w(voodoo_state *v, cmdfifo_info *f, offs_t offset, UINT32 da if (cycles > 0) { v->pci.op_pending = TRUE; - v->pci.op_end_time = attotime_add_attoseconds(timer_get_time(v->device->machine), (attoseconds_t)cycles * v->attoseconds_per_cycle); + v->pci.op_end_time = timer_get_time(v->device->machine) + attotime(0, (attoseconds_t)cycles * v->attoseconds_per_cycle); if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:direct write start at %d.%08X%08X end at %d.%08X%08X\n", v->index, timer_get_time(v->device->machine).seconds, (UINT32)(timer_get_time(v->device->machine).attoseconds >> 32), (UINT32)timer_get_time(v->device->machine).attoseconds, @@ -2076,7 +2076,7 @@ static void check_stalled_cpu(voodoo_state *v, attotime current_time) /* if not, set a timer for the next one */ else { - timer_adjust_oneshot(v->pci.continue_timer, attotime_sub(v->pci.op_end_time, current_time), 0); + timer_adjust_oneshot(v->pci.continue_timer, v->pci.op_end_time - current_time, 0); } } @@ -2097,7 +2097,7 @@ static void stall_cpu(voodoo_state *v, int state, attotime current_time) cpu_spinuntil_trigger(v->cpu, v->trigger); /* set a timer to clear the stall */ - timer_adjust_oneshot(v->pci.continue_timer, attotime_sub(v->pci.op_end_time, current_time), 0); + timer_adjust_oneshot(v->pci.continue_timer, v->pci.op_end_time - current_time, 0); } @@ -3338,7 +3338,7 @@ static void flush_fifos(voodoo_state *v, attotime current_time) current_time.seconds, (UINT32)(current_time.attoseconds >> 32), (UINT32)current_time.attoseconds); /* loop while we still have cycles to burn */ - while (attotime_compare(v->pci.op_end_time, current_time) <= 0) + while (v->pci.op_end_time <= current_time) { INT32 extra_cycles = 0; INT32 cycles; @@ -3429,7 +3429,7 @@ static void flush_fifos(voodoo_state *v, attotime current_time) cycles += extra_cycles; /* account for those cycles */ - v->pci.op_end_time = attotime_add_attoseconds(v->pci.op_end_time, (attoseconds_t)cycles * v->attoseconds_per_cycle); + v->pci.op_end_time += attotime(0, (attoseconds_t)cycles * v->attoseconds_per_cycle); if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:update -- pending=%d.%08X%08X cur=%d.%08X%08X\n", v->index, v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.attoseconds >> 32), (UINT32)v->pci.op_end_time.attoseconds, @@ -3544,7 +3544,7 @@ WRITE32_DEVICE_HANDLER( voodoo_w ) if (cycles) { v->pci.op_pending = TRUE; - v->pci.op_end_time = attotime_add_attoseconds(timer_get_time(device->machine), (attoseconds_t)cycles * v->attoseconds_per_cycle); + v->pci.op_end_time = timer_get_time(device->machine) + attotime(0, (attoseconds_t)cycles * v->attoseconds_per_cycle); if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:direct write start at %d.%08X%08X end at %d.%08X%08X\n", v->index, timer_get_time(device->machine).seconds, (UINT32)(timer_get_time(device->machine).attoseconds >> 32), (UINT32)timer_get_time(device->machine).attoseconds, diff --git a/src/emu/watchdog.c b/src/emu/watchdog.c index 8f8c63d819a..c5a6f498fb1 100644 --- a/src/emu/watchdog.c +++ b/src/emu/watchdog.c @@ -57,7 +57,7 @@ void watchdog_init(running_machine *machine) static void watchdog_internal_reset(running_machine &machine) { /* set up the watchdog timer; only start off enabled if explicitly configured */ - watchdog_enabled = (machine.m_config.m_watchdog_vblank_count != 0 || attotime_compare(machine.m_config.m_watchdog_time, attotime_zero) != 0); + watchdog_enabled = (machine.m_config.m_watchdog_vblank_count != 0 || machine.m_config.m_watchdog_time != attotime::zero); watchdog_reset(&machine); watchdog_enabled = TRUE; } @@ -122,7 +122,7 @@ void watchdog_reset(running_machine *machine) } /* timer-based watchdog? */ - else if (attotime_compare(machine->config->m_watchdog_time, attotime_zero) != 0) + else if (machine->config->m_watchdog_time != attotime::zero) timer_adjust_oneshot(watchdog_timer, machine->config->m_watchdog_time, 0); /* default to an obscene amount of time (3 seconds) */ diff --git a/src/ldplayer/ldplayer.c b/src/ldplayer/ldplayer.c index 5e96e99f3b6..f2c960f8b98 100644 --- a/src/ldplayer/ldplayer.c +++ b/src/ldplayer/ldplayer.c @@ -306,7 +306,7 @@ static TIMER_CALLBACK( pr8210_bit_callback ) timer_set(machine, ATTOTIME_IN_USEC(250), ptr, 0, pr8210_bit_off_callback); /* space 0 bits apart by 1msec, and 1 bits by 2msec */ - duration = attotime_mul(ATTOTIME_IN_MSEC(1), (data & 0x80) ? 2 : 1); + duration = attotime::from_msec((data & 0x80) ? 2 : 1); data <<= 1; bitsleft--; } diff --git a/src/mame/audio/8080bw.c b/src/mame/audio/8080bw.c index df4cbaab833..74e970d6086 100644 --- a/src/mame/audio/8080bw.c +++ b/src/mame/audio/8080bw.c @@ -812,7 +812,7 @@ WRITE8_HANDLER( schaser_sh_port_1_w ) { if (effect) { - if (attotime_compare(state->schaser_effect_555_time_remain, attotime_zero) != 0) + if (state->schaser_effect_555_time_remain != attotime::zero) { /* timer re-enabled, use up remaining 555 high time */ timer_adjust_oneshot(state->schaser_effect_555_timer, state->schaser_effect_555_time_remain, effect); @@ -820,7 +820,7 @@ WRITE8_HANDLER( schaser_sh_port_1_w ) else if (!state->schaser_effect_555_is_low) { /* set 555 high time */ - attotime new_time = attotime_make(0, ATTOSECONDS_PER_SECOND * .8873 * schaser_effect_rc[effect]); + attotime new_time = attotime(0, ATTOSECONDS_PER_SECOND * .8873 * schaser_effect_rc[effect]); timer_adjust_oneshot(state->schaser_effect_555_timer, new_time, effect); } } @@ -830,7 +830,7 @@ WRITE8_HANDLER( schaser_sh_port_1_w ) if (!state->schaser_effect_555_is_low) { state->schaser_effect_555_time_remain = timer_timeleft(state->schaser_effect_555_timer); - state->schaser_effect_555_time_remain_savable = attotime_to_double(state->schaser_effect_555_time_remain); + state->schaser_effect_555_time_remain_savable = state->schaser_effect_555_time_remain.as_double(); timer_adjust_oneshot(state->schaser_effect_555_timer, attotime_never, 0); } } @@ -888,16 +888,16 @@ static TIMER_CALLBACK( schaser_effect_555_cb ) /* Toggle 555 output */ state->schaser_effect_555_is_low = !state->schaser_effect_555_is_low; state->schaser_effect_555_time_remain = attotime_zero; - state->schaser_effect_555_time_remain_savable = attotime_to_double(state->schaser_effect_555_time_remain); + state->schaser_effect_555_time_remain_savable = state->schaser_effect_555_time_remain.as_double(); if (state->schaser_effect_555_is_low) - new_time = attotime_div(PERIOD_OF_555_ASTABLE(0, RES_K(20), CAP_U(1)), 2); + new_time = PERIOD_OF_555_ASTABLE(0, RES_K(20), CAP_U(1)) / 2; else { if (effect) - new_time = attotime_make(0, ATTOSECONDS_PER_SECOND * .8873 * schaser_effect_rc[effect]); + new_time = attotime(0, ATTOSECONDS_PER_SECOND * .8873 * schaser_effect_rc[effect]); else - new_time = attotime_never; + new_time = attotime::never; } timer_adjust_oneshot(state->schaser_effect_555_timer, new_time, effect); sn76477_enable_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion)); @@ -909,7 +909,7 @@ static STATE_POSTLOAD( schaser_reinit_555_time_remain ) { mw8080bw_state *state = machine->driver_data<mw8080bw_state>(); address_space *space = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM); - state->schaser_effect_555_time_remain = double_to_attotime(state->schaser_effect_555_time_remain_savable); + state->schaser_effect_555_time_remain = attotime::from_double(state->schaser_effect_555_time_remain_savable); schaser_sh_port_2_w(space, 0, state->port_2_last_extra); } @@ -938,7 +938,7 @@ MACHINE_RESET( schaser_sh ) schaser_sh_port_1_w(space, 0, 0); schaser_sh_port_2_w(space, 0, 0); state->schaser_effect_555_time_remain = attotime_zero; - state->schaser_effect_555_time_remain_savable = attotime_to_double(state->schaser_effect_555_time_remain); + state->schaser_effect_555_time_remain_savable = state->schaser_effect_555_time_remain.as_double(); } diff --git a/src/mame/audio/cage.c b/src/mame/audio/cage.c index f54ab519446..7f790a8e43a 100644 --- a/src/mame/audio/cage.c +++ b/src/mame/audio/cage.c @@ -165,7 +165,7 @@ void cage_init(running_machine *machine, offs_t speedup) cage_cpu = machine->device<cpu_device>("cage"); cage_cpu_clock_period = ATTOTIME_IN_HZ(cage_cpu->clock()); - cage_cpu_h1_clock_period = attotime_mul(cage_cpu_clock_period, 2); + cage_cpu_h1_clock_period = cage_cpu_clock_period * 2; dma_timer = machine->device<timer_device>("cage_dma_timer"); timer[0] = machine->device<timer_device>("cage_timer0"); @@ -271,7 +271,7 @@ static void update_dma_state(address_space *space) /* compute the time of the interrupt and set the timer */ if (!dma_timer_enabled) { - attotime period = attotime_mul(serial_period_per_word, tms32031_io_regs[DMA_TRANSFER_COUNT]); + attotime period = serial_period_per_word * tms32031_io_regs[DMA_TRANSFER_COUNT]; dma_timer->adjust(period, addr, period); dma_timer_enabled = 1; } @@ -316,7 +316,7 @@ static void update_timer(int which) /* see if we turned on */ if (enabled && !cage_timer_enabled[which]) { - attotime period = attotime_mul(cage_cpu_h1_clock_period, 2 * tms32031_io_regs[base + TIMER0_PERIOD]); + attotime period = cage_cpu_h1_clock_period * (2 * tms32031_io_regs[base + TIMER0_PERIOD]); /* make sure our assumptions are correct */ if (tms32031_io_regs[base + TIMER0_GLOBAL_CTL] != 0x2c1) @@ -349,17 +349,17 @@ static void update_serial(running_machine *machine) UINT32 freq; /* we start out at half the H1 frequency (or 2x the H1 period) */ - serial_clock_period = attotime_mul(cage_cpu_h1_clock_period, 2); + serial_clock_period = cage_cpu_h1_clock_period * 2; /* if we're in clock mode, muliply by another factor of 2 */ if (tms32031_io_regs[SPORT_GLOBAL_CTL] & 4) - serial_clock_period = attotime_mul(serial_clock_period, 2); + serial_clock_period *= 2; /* now multiply by the timer period */ - bit_clock_period = attotime_mul(serial_clock_period, (tms32031_io_regs[SPORT_TIMER_PERIOD] & 0xffff)); + bit_clock_period = serial_clock_period * (tms32031_io_regs[SPORT_TIMER_PERIOD] & 0xffff); /* and times the number of bits per sample */ - serial_period_per_word = attotime_mul(bit_clock_period, 8 * (((tms32031_io_regs[SPORT_GLOBAL_CTL] >> 18) & 3) + 1)); + serial_period_per_word = bit_clock_period * (8 * (((tms32031_io_regs[SPORT_GLOBAL_CTL] >> 18) & 3) + 1)); /* compute the step value to stretch this to the sample_rate */ freq = ATTOSECONDS_TO_HZ(serial_period_per_word.attoseconds) / DAC_BUFFER_CHANNELS; diff --git a/src/mame/audio/dcs.c b/src/mame/audio/dcs.c index cd52fa35b32..de5baefe133 100644 --- a/src/mame/audio/dcs.c +++ b/src/mame/audio/dcs.c @@ -1991,17 +1991,17 @@ static void recompute_sample_rate(running_machine *machine) /* calculate how long until we generate an interrupt */ /* frequency the time per each bit sent */ - attotime sample_period = attotime_mul(ATTOTIME_IN_HZ(dcs.cpu->unscaled_clock()), 2 * (dcs.control_regs[S1_SCLKDIV_REG] + 1)); + attotime sample_period = attotime::from_hz(dcs.cpu->unscaled_clock()) * (2 * (dcs.control_regs[S1_SCLKDIV_REG] + 1)); /* now put it down to samples, so we know what the channel frequency has to be */ - sample_period = attotime_mul(sample_period, 16 * dcs.channels); + sample_period = sample_period * (16 * dcs.channels); dmadac_set_frequency(&dcs.dmadac[0], dcs.channels, ATTOSECONDS_TO_HZ(sample_period.attoseconds)); dmadac_enable(&dcs.dmadac[0], dcs.channels, 1); /* fire off a timer wich will hit every half-buffer */ if (dcs.incs) { - attotime period = attotime_div(attotime_mul(sample_period, dcs.size), (2 * dcs.channels * dcs.incs)); + attotime period = (sample_period * dcs.size) / (2 * dcs.channels * dcs.incs); dcs.reg_timer->adjust(period, 0, period); } } diff --git a/src/mame/audio/exidy.c b/src/mame/audio/exidy.c index 7746ddfa88a..3bf977ecf42 100644 --- a/src/mame/audio/exidy.c +++ b/src/mame/audio/exidy.c @@ -495,7 +495,7 @@ static WRITE8_DEVICE_HANDLER( r6532_porta_w ) if (state->tms != NULL) { - logerror("(%f)%s:TMS5220 data write = %02X\n", attotime_to_double(timer_get_time(device->machine)), cpuexec_describe_context(device->machine), riot6532_porta_out_get(state->riot)); + logerror("(%f)%s:TMS5220 data write = %02X\n", timer_get_time(device->machine).as_double(), cpuexec_describe_context(device->machine), riot6532_porta_out_get(state->riot)); tms5220_data_w(state->tms, 0, data); } } @@ -505,7 +505,7 @@ static READ8_DEVICE_HANDLER( r6532_porta_r ) exidy_sound_state *state = get_safe_token(device); if (state->tms != NULL) { - logerror("(%f)%s:TMS5220 status read = %02X\n", attotime_to_double(timer_get_time(device->machine)), cpuexec_describe_context(device->machine), tms5220_status_r(state->tms, 0)); + logerror("(%f)%s:TMS5220 status read = %02X\n", timer_get_time(device->machine).as_double(), cpuexec_describe_context(device->machine), tms5220_status_r(state->tms, 0)); return tms5220_status_r(state->tms, 0); } else diff --git a/src/mame/audio/geebee.c b/src/mame/audio/geebee.c index 298a6a530c3..c6a5e5d2e50 100644 --- a/src/mame/audio/geebee.c +++ b/src/mame/audio/geebee.c @@ -58,7 +58,7 @@ WRITE8_DEVICE_HANDLER( geebee_sound_w ) * Decay: * discharge C33 (1uF) through R50 (22k) -> 0.14058s */ - attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 14058), 100000); + attotime period = attotime::from_hz(32768) * 14058 / 100000; timer_adjust_periodic(state->volume_timer, period, 0, period); } else @@ -70,7 +70,7 @@ WRITE8_DEVICE_HANDLER( geebee_sound_w ) * I can only guess here that the decay should be slower, * maybe half as fast? */ - attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 29060), 100000); + attotime period = attotime::from_hz(32768) * 29060 / 100000; timer_adjust_periodic(state->volume_timer, period, 0, period); } } diff --git a/src/mame/audio/gottlieb.c b/src/mame/audio/gottlieb.c index f24318ec137..6eb55a9734c 100644 --- a/src/mame/audio/gottlieb.c +++ b/src/mame/audio/gottlieb.c @@ -420,7 +420,7 @@ static WRITE8_HANDLER( signal_audio_nmi_w ) INLINE void nmi_timer_adjust(void) { /* adjust timer to go off in the future based on the current rate */ - timer_adjust_oneshot(nmi_timer, attotime_mul(ATTOTIME_IN_HZ(SOUND2_CLOCK/16), 256 * (256 - nmi_rate)), 0); + timer_adjust_oneshot(nmi_timer, attotime::from_hz(SOUND2_CLOCK/16) * (256 * (256 - nmi_rate)), 0); } diff --git a/src/mame/audio/jaguar.c b/src/mame/audio/jaguar.c index 3c37a2d6e37..b7326a8411a 100644 --- a/src/mame/audio/jaguar.c +++ b/src/mame/audio/jaguar.c @@ -435,7 +435,7 @@ WRITE32_HANDLER( jaguar_serial_w ) logerror("Unexpected write to SMODE = %X\n", data); if ((data & 0x3f) == 0x15) { - attotime rate = attotime_mul(ATTOTIME_IN_HZ(26000000), 32 * 2 * (serial_frequency + 1)); + attotime rate = attotime::from_hz(26000000) * (32 * 2 * (serial_frequency + 1)); timer_device *serial_timer = space->machine->device<timer_device>("serial_timer"); serial_timer->adjust(rate, 0, rate); } diff --git a/src/mame/audio/leland.c b/src/mame/audio/leland.c index 6d382db47cb..ee9bfb4493e 100644 --- a/src/mame/audio/leland.c +++ b/src/mame/audio/leland.c @@ -694,7 +694,7 @@ static DEVICE_RESET( leland_80186_sound ) static IRQ_CALLBACK( int_callback ) { leland_sound_state *state = get_safe_token(device->machine->device("custom")); - if (LOG_INTERRUPTS) logerror("(%f) **** Acknowledged interrupt vector %02X\n", attotime_to_double(timer_get_time(device->machine)), state->i80186.intr.poll_status & 0x1f); + if (LOG_INTERRUPTS) logerror("(%f) **** Acknowledged interrupt vector %02X\n", timer_get_time(device->machine).as_double(), state->i80186.intr.poll_status & 0x1f); /* clear the interrupt */ cpu_set_input_line(state->i80186.cpu, 0, CLEAR_LINE); @@ -809,7 +809,7 @@ generate_int: if (!state->i80186.intr.pending) cputag_set_input_line(machine, "audiocpu", 0, ASSERT_LINE); state->i80186.intr.pending = 1; - if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", attotime_to_double(timer_get_time(machine)), new_vector); + if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", timer_get_time(machine).as_double(), new_vector); } @@ -836,7 +836,7 @@ static void handle_eoi(device_t *device, int data) case 0x0f: state->i80186.intr.in_service &= ~0x80; break; default: logerror("%s:ERROR - 80186 EOI with unknown vector %02X\n", cpuexec_describe_context(machine), data & 0x1f); } - if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", attotime_to_double(timer_get_time(machine)), data & 0x1f); + if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", timer_get_time(machine).as_double(), data & 0x1f); } /* non-specific case */ @@ -849,7 +849,7 @@ static void handle_eoi(device_t *device, int data) if ((state->i80186.intr.timer & 7) == i && (state->i80186.intr.in_service & 0x01)) { state->i80186.intr.in_service &= ~0x01; - if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", attotime_to_double(timer_get_time(machine))); + if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", timer_get_time(machine).as_double()); return; } @@ -858,7 +858,7 @@ static void handle_eoi(device_t *device, int data) if ((state->i80186.intr.dma[j] & 7) == i && (state->i80186.intr.in_service & (0x04 << j))) { state->i80186.intr.in_service &= ~(0x04 << j); - if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", attotime_to_double(timer_get_time(machine)), j); + if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", timer_get_time(machine).as_double(), j); return; } @@ -867,7 +867,7 @@ static void handle_eoi(device_t *device, int data) if ((state->i80186.intr.ext[j] & 7) == i && (state->i80186.intr.in_service & (0x10 << j))) { state->i80186.intr.in_service &= ~(0x10 << j); - if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", attotime_to_double(timer_get_time(machine)), j); + if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", timer_get_time(machine).as_double(), j); return; } } @@ -906,7 +906,7 @@ static TIMER_CALLBACK( internal_timer_int ) if (t->control & 0x0001) { int count = t->maxA ? t->maxA : 0x10000; - timer_adjust_oneshot(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), count), which); + timer_adjust_oneshot(t->int_timer, attotime::from_hz(2000000) * count, which); if (LOG_TIMER) logerror(" Repriming interrupt\n"); } else @@ -922,7 +922,7 @@ static void internal_timer_sync(leland_sound_state *state, int which) if (t->time_timer_active) { attotime current_time = timer_timeelapsed(t->time_timer); - int net_clocks = attotime_to_double(attotime_mul(attotime_sub(current_time, t->last_time), 2000000)); + int net_clocks = ((current_time - t->last_time) * 2000000).as_double(); t->last_time = current_time; /* set the max count bit if we passed the max */ @@ -1062,7 +1062,7 @@ static void internal_timer_update(leland_sound_state *state, int which, int new_ { int diff = t->maxA - t->count; if (diff <= 0) diff += 0x10000; - timer_adjust_oneshot(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), diff), which); + timer_adjust_oneshot(t->int_timer, attotime::from_hz(2000000) * diff, which); if (LOG_TIMER) logerror("Set interrupt timer for %d\n", which); } else @@ -1153,7 +1153,7 @@ static void update_dma_control(leland_sound_state *state, int which, int new_con if (LOG_DMA) logerror("Initiated DMA %d - count = %04X, source = %04X, dest = %04X\n", which, d->count, d->source, d->dest); d->finished = 0; - timer_adjust_oneshot(d->finish_timer, attotime_mul(ATTOTIME_IN_HZ(state->dac[dacnum].frequency), count), which); + timer_adjust_oneshot(d->finish_timer, attotime::from_hz(state->dac[dacnum].frequency) * count, which); } } @@ -1612,7 +1612,7 @@ INLINE void counter_update_count(struct counter_state *ctr) if (ctr->timer) { /* determine how many 2MHz cycles are remaining */ - int count = attotime_to_double(attotime_mul(timer_timeleft(ctr->timer), 2000000)); + int count = (timer_timeleft(ctr->timer) * 2000000).as_double(); ctr->count = (count < 0) ? 0 : count; } } diff --git a/src/mame/audio/n8080.c b/src/mame/audio/n8080.c index 9d7148ed923..bf4c9038fa3 100644 --- a/src/mame/audio/n8080.c +++ b/src/mame/audio/n8080.c @@ -431,7 +431,7 @@ static WRITE8_HANDLER( helifire_sound_ctrl_w ) state->helifire_dac_timing = DECAY_RATE * log(state->helifire_dac_volume); } - state->helifire_dac_timing += attotime_to_double(timer_get_time(space->machine)); + state->helifire_dac_timing += timer_get_time(space->machine).as_double(); } @@ -443,7 +443,7 @@ static TIMER_DEVICE_CALLBACK( spacefev_vco_voltage_timer ) if (state->mono_flop[2]) { - voltage = 5 * (1 - exp(- attotime_to_double(timer_timeelapsed(state->sound_timer[2])) / 0.22)); + voltage = 5 * (1 - exp(- timer_timeelapsed(state->sound_timer[2]).as_double() / 0.22)); } sn76477_vco_voltage_w(sn, voltage); @@ -453,7 +453,7 @@ static TIMER_DEVICE_CALLBACK( spacefev_vco_voltage_timer ) static TIMER_DEVICE_CALLBACK( helifire_dac_volume_timer ) { n8080_state *state = timer.machine->driver_data<n8080_state>(); - double t = state->helifire_dac_timing - attotime_to_double(timer_get_time(timer.machine)); + double t = state->helifire_dac_timing - timer_get_time(timer.machine).as_double(); if (state->helifire_dac_phase) { diff --git a/src/mame/audio/namco52.c b/src/mame/audio/namco52.c index 0991d30629a..53d5bf79715 100644 --- a/src/mame/audio/namco52.c +++ b/src/mame/audio/namco52.c @@ -220,7 +220,7 @@ static DEVICE_START( namco_52xx ) /* start the external clock */ if (intf->extclock != 0) - timer_pulse(device->machine, attotime_make(0, intf->extclock), (void *)device, 0, external_clock_pulse); + timer_pulse(device->machine, attotime(0, intf->extclock), (void *)device, 0, external_clock_pulse); } diff --git a/src/mame/audio/senjyo.c b/src/mame/audio/senjyo.c index 1568370f6f1..04fcbc1dd8f 100644 --- a/src/mame/audio/senjyo.c +++ b/src/mame/audio/senjyo.c @@ -64,7 +64,7 @@ static TIMER_CALLBACK( senjyo_sh_update ) /* ctc2 timer single tone generator frequency */ z80ctc_device *ctc = machine->device<z80ctc_device>("z80ctc"); attotime period = ctc->period(2); - if (attotime_compare(period, attotime_zero) != 0 ) + if (period != attotime::zero) state->single_rate = ATTOSECONDS_TO_HZ(period.attoseconds); else state->single_rate = 0; diff --git a/src/mame/audio/vicdual.c b/src/mame/audio/vicdual.c index fc7c2661812..27d43e787cf 100644 --- a/src/mame/audio/vicdual.c +++ b/src/mame/audio/vicdual.c @@ -170,7 +170,7 @@ WRITE8_HANDLER( frogs_audio_w ) if (last_croak) { /* The croak will keep playing until .429s after being disabled */ - timer_adjust_oneshot(frogs_croak_timer, double_to_attotime(1.1 * RES_K(390) * CAP_U(1)), 0); + timer_adjust_oneshot(frogs_croak_timer, attotime::from_double(1.1 * RES_K(390) * CAP_U(1)), 0); } } if (new_buzzz) diff --git a/src/mame/audio/warpwarp.c b/src/mame/audio/warpwarp.c index 9fe6ec91862..5eb015c964d 100644 --- a/src/mame/audio/warpwarp.c +++ b/src/mame/audio/warpwarp.c @@ -72,7 +72,7 @@ WRITE8_DEVICE_HANDLER( warpwarp_sound_w ) * discharge C90(?) (1uF) through R13||R14 (22k||47k) * 0.639 * 15k * 1uF -> 0.9585s */ - attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 95850), 100000); + attotime period = attotime::from_hz(32768) * 95850 / 100000; timer_adjust_periodic(state->sound_volume_timer, period, 0, period); } else @@ -84,8 +84,8 @@ WRITE8_DEVICE_HANDLER( warpwarp_sound_w ) * ...but this is not very realistic for the game sound :( * maybe there _is_ a discharge through the diode D17? */ - //attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 702900), 100000); - attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 191700), 100000); + //attotime period = attotime::from_hz(32768) * 702900 / 100000; + attotime period = attotime::from_hz(32768) * 191700 / 100000; timer_adjust_periodic(state->sound_volume_timer, period, 0, period); } } @@ -124,7 +124,7 @@ WRITE8_DEVICE_HANDLER( warpwarp_music2_w ) * 0.639 * 15k * 10uF -> 9.585s * ...I'm sure this is off by one number of magnitude :/ */ - attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 95850), 100000); + attotime period = attotime::from_hz(32768) * 95850 / 100000; timer_adjust_periodic(state->music_volume_timer, period, 0, period); } else @@ -134,8 +134,8 @@ WRITE8_DEVICE_HANDLER( warpwarp_music2_w ) * discharge C95(?) (10uF) through R14 (47k) * 0.639 * 47k * 10uF -> 30.033s */ - //attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 3003300), 100000); - attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 300330), 100000); + //attotime period = attotime::from_hz(32768) * 3003300 / 100000; + attotime period = attotime::from_hz(32768) * 300330 / 100000; timer_adjust_periodic(state->music_volume_timer, period, 0, period); } diff --git a/src/mame/audio/williams.c b/src/mame/audio/williams.c index 952759ad0ab..bea0585f3dd 100644 --- a/src/mame/audio/williams.c +++ b/src/mame/audio/williams.c @@ -554,7 +554,7 @@ static TIMER_CALLBACK( narc_sync_clear ) static WRITE8_HANDLER( narc_master_sync_w ) { - timer_set(space->machine, double_to_attotime(TIME_OF_74LS123(180000, 0.000001)), NULL, 0x01, narc_sync_clear); + timer_set(space->machine, attotime::from_double(TIME_OF_74LS123(180000, 0.000001)), NULL, 0x01, narc_sync_clear); audio_sync |= 0x01; logerror("Master sync = %02X\n", data); } @@ -568,7 +568,7 @@ static WRITE8_HANDLER( narc_slave_talkback_w ) static WRITE8_HANDLER( narc_slave_sync_w ) { - timer_set(space->machine, double_to_attotime(TIME_OF_74LS123(180000, 0.000001)), NULL, 0x02, narc_sync_clear); + timer_set(space->machine, attotime::from_double(TIME_OF_74LS123(180000, 0.000001)), NULL, 0x02, narc_sync_clear); audio_sync |= 0x02; logerror("Slave sync = %02X\n", data); } diff --git a/src/mame/drivers/39in1.c b/src/mame/drivers/39in1.c index 9b8dd4f5f95..cc62bd6cb55 100644 --- a/src/mame/drivers/39in1.c +++ b/src/mame/drivers/39in1.c @@ -270,10 +270,10 @@ static void pxa255_dma_load_descriptor_and_start(running_machine* machine, int c switch(channel) { case 3: - period = attotime_mul(ATTOTIME_IN_HZ((147600000 / state->i2s_regs.sadiv) / (4 * 64)), dma_regs->dcmd[channel] & 0x00001fff); + period = attotime::from_hz((147600000 / state->i2s_regs.sadiv) / (4 * 64)) * (dma_regs->dcmd[channel] & 0x00001fff); break; default: - period = attotime_mul(ATTOTIME_IN_HZ(100000000), dma_regs->dcmd[channel] & 0x00001fff); + period = attotime::from_hz(100000000) * (dma_regs->dcmd[channel] & 0x00001fff); break; } @@ -624,7 +624,7 @@ static WRITE32_HANDLER( pxa255_ostimer_w ) ostimer_regs->osmr[0] = data; if(ostimer_regs->oier & PXA255_OIER_E0) { - attotime period = attotime_mul(ATTOTIME_IN_HZ(3846400), ostimer_regs->osmr[0] - ostimer_regs->oscr); + attotime period = attotime::from_hz(3846400) * (ostimer_regs->osmr[0] - ostimer_regs->oscr); //printf( "Adjusting one-shot timer to 200MHz * %08x\n", ostimer_regs->osmr[0]); timer_adjust_oneshot(ostimer_regs->timer[0], period, 0); @@ -635,7 +635,7 @@ static WRITE32_HANDLER( pxa255_ostimer_w ) ostimer_regs->osmr[1] = data; if(ostimer_regs->oier & PXA255_OIER_E1) { - attotime period = attotime_mul(ATTOTIME_IN_HZ(3846400), ostimer_regs->osmr[1] - ostimer_regs->oscr); + attotime period = attotime::from_hz(3846400) * (ostimer_regs->osmr[1] - ostimer_regs->oscr); timer_adjust_oneshot(ostimer_regs->timer[1], period, 1); } @@ -645,7 +645,7 @@ static WRITE32_HANDLER( pxa255_ostimer_w ) ostimer_regs->osmr[2] = data; if(ostimer_regs->oier & PXA255_OIER_E2) { - attotime period = attotime_mul(ATTOTIME_IN_HZ(3846400), ostimer_regs->osmr[2] - ostimer_regs->oscr); + attotime period = attotime::from_hz(3846400) * (ostimer_regs->osmr[2] - ostimer_regs->oscr); timer_adjust_oneshot(ostimer_regs->timer[2], period, 2); } @@ -655,7 +655,7 @@ static WRITE32_HANDLER( pxa255_ostimer_w ) ostimer_regs->osmr[3] = data; if(ostimer_regs->oier & PXA255_OIER_E3) { - //attotime period = attotime_mul(ATTOTIME_IN_HZ(3846400), ostimer_regs->osmr[3] - ostimer_regs->oscr); + //attotime period = attotime::from_hz(3846400) * (ostimer_regs->osmr[3] - ostimer_regs->oscr); //timer_adjust_oneshot(ostimer_regs->timer[3], period, 3); } @@ -682,7 +682,7 @@ static WRITE32_HANDLER( pxa255_ostimer_w ) { if(ostimer_regs->oier & (1 << index)) { - //attotime period = attotime_mul(ATTOTIME_IN_HZ(200000000), ostimer_regs->osmr[index]); + //attotime period = attotime::from_hz(200000000) * ostimer_regs->osmr[index]; //timer_adjust_oneshot(ostimer_regs->timer[index], period, index); } @@ -1088,7 +1088,7 @@ static void pxa255_lcd_dma_kickoff(running_machine* machine, int channel) if(lcd_regs->dma[channel].fdadr != 0) { - attotime period = attotime_mul(ATTOTIME_IN_HZ(20000000), lcd_regs->dma[channel].ldcmd & 0x000fffff); + attotime period = attotime::from_hz(20000000) * (lcd_regs->dma[channel].ldcmd & 0x000fffff); timer_adjust_oneshot(lcd_regs->dma[channel].eof, period, channel); diff --git a/src/mame/drivers/astinvad.c b/src/mame/drivers/astinvad.c index 731b95fe2cc..ea693efdbac 100644 --- a/src/mame/drivers/astinvad.c +++ b/src/mame/drivers/astinvad.c @@ -219,7 +219,7 @@ static TIMER_CALLBACK( kamizake_int_gen ) timer_adjust_oneshot(state->int_timer, machine->primary_screen->time_until_pos(param), param); /* an RC circuit turns the interrupt off after a short amount of time */ - timer_set(machine, double_to_attotime(300 * 0.1e-6), NULL, 0, kamikaze_int_off); + timer_set(machine, attotime::from_double(300 * 0.1e-6), NULL, 0, kamikaze_int_off); } diff --git a/src/mame/drivers/beathead.c b/src/mame/drivers/beathead.c index 07bc6c23e63..133278c0c5c 100644 --- a/src/mame/drivers/beathead.c +++ b/src/mame/drivers/beathead.c @@ -136,7 +136,7 @@ static TIMER_DEVICE_CALLBACK( scanline_callback ) state->update_interrupts(); /* set the timer for the next one */ - timer.adjust(double_to_attotime(attotime_to_double(timer.machine->primary_screen->time_until_pos(scanline)) - state->m_hblank_offset), scanline); + timer.adjust(timer.machine->primary_screen->time_until_pos(scanline) - state->m_hblank_offset, scanline); } @@ -159,9 +159,9 @@ void beathead_state::machine_reset() memcpy(m_ram_base, m_rom_base, 0x40); /* compute the timing of the HBLANK interrupt and set the first timer */ - m_hblank_offset = attotime_to_double(m_machine.primary_screen->scan_period()) * ((455. - 336. - 25.) / 455.); + m_hblank_offset = m_machine.primary_screen->scan_period() * (455 - 336 - 25) / 455; timer_device *scanline_timer = m_machine.device<timer_device>("scan_timer"); - scanline_timer->adjust(double_to_attotime(attotime_to_double(m_machine.primary_screen->time_until_pos(0)) - m_hblank_offset)); + scanline_timer->adjust(m_machine.primary_screen->time_until_pos(0) - m_hblank_offset); /* reset IRQs */ m_irq_line_state = CLEAR_LINE; diff --git a/src/mame/drivers/crystal.c b/src/mame/drivers/crystal.c index 326873c17af..3a172ae788f 100644 --- a/src/mame/drivers/crystal.c +++ b/src/mame/drivers/crystal.c @@ -287,7 +287,7 @@ INLINE void Timer_w( address_space *space, int which, UINT32 data, UINT32 mem_ma { int PD = (data >> 8) & 0xff; int TCV = space->read_dword(0x01801404 + which * 8); - attotime period = attotime_mul(ATTOTIME_IN_HZ(43000000), (PD + 1) * (TCV + 1)); + attotime period = attotime::from_hz(43000000) * ((PD + 1) * (TCV + 1)); if (state->Timerctrl[which] & 2) timer_adjust_periodic(state->Timer[which], period, 0, period); diff --git a/src/mame/drivers/exterm.c b/src/mame/drivers/exterm.c index 20273ba0d2c..b944e83bd53 100644 --- a/src/mame/drivers/exterm.c +++ b/src/mame/drivers/exterm.c @@ -229,7 +229,7 @@ static WRITE8_HANDLER( sound_nmi_rate_w ) /* rate is controlled by the value written here */ /* this value is latched into up-counters, which are clocked at the */ /* input clock / 256 */ - attotime nmi_rate = attotime_mul(ATTOTIME_IN_HZ(4000000), 4096 * (256 - data)); + attotime nmi_rate = attotime::from_hz(4000000) * (4096 * (256 - data)); timer_device *nmi_timer = space->machine->device<timer_device>("snd_nmi_timer"); nmi_timer->adjust(nmi_rate, 0, nmi_rate); } diff --git a/src/mame/drivers/gaelco3d.c b/src/mame/drivers/gaelco3d.c index d88668fa6e1..f938cc61690 100644 --- a/src/mame/drivers/gaelco3d.c +++ b/src/mame/drivers/gaelco3d.c @@ -694,16 +694,16 @@ static void adsp_tx_callback(adsp21xx_device &device, int port, INT32 data) /* calculate how long until we generate an interrupt */ /* period per each bit sent */ - sample_period = attotime_mul(ATTOTIME_IN_HZ(device.clock()), 2 * (adsp_control_regs[S1_SCLKDIV_REG] + 1)); + sample_period = attotime::from_hz(device.clock()) * (2 * (adsp_control_regs[S1_SCLKDIV_REG] + 1)); /* now put it down to samples, so we know what the channel frequency has to be */ - sample_period = attotime_mul(sample_period, 16 * SOUND_CHANNELS); + sample_period *= 16 * SOUND_CHANNELS; dmadac_set_frequency(&dmadac[0], SOUND_CHANNELS, ATTOSECONDS_TO_HZ(sample_period.attoseconds)); dmadac_enable(&dmadac[0], SOUND_CHANNELS, 1); /* fire off a timer wich will hit every half-buffer */ - sample_period = attotime_div(attotime_mul(sample_period, adsp_size), SOUND_CHANNELS * adsp_incs); + sample_period = (sample_period * adsp_size) / (SOUND_CHANNELS * adsp_incs); adsp_autobuffer_timer->adjust(sample_period, 0, sample_period); diff --git a/src/mame/drivers/gijoe.c b/src/mame/drivers/gijoe.c index 691f37d6bd7..b610e87230f 100644 --- a/src/mame/drivers/gijoe.c +++ b/src/mame/drivers/gijoe.c @@ -43,7 +43,7 @@ Known Issues #include "includes/gijoe.h" #define JOE_DEBUG 0 -#define JOE_DMADELAY attotime_add(ATTOTIME_IN_NSEC(42700), ATTOTIME_IN_NSEC(341300)) +#define JOE_DMADELAY (attotime::from_nsec(42700 + 341300)) static const eeprom_interface eeprom_intf = diff --git a/src/mame/drivers/gottlieb.c b/src/mame/drivers/gottlieb.c index cbaecf5dca5..91bd2707e06 100644 --- a/src/mame/drivers/gottlieb.c +++ b/src/mame/drivers/gottlieb.c @@ -438,7 +438,7 @@ static WRITE8_HANDLER( laserdisc_command_w ) a sequence of events that sends serial data to the player */ /* set a timer to clock the bits through; a total of 12 bits are clocked */ - timer_adjust_oneshot(laserdisc_bit_timer, attotime_mul(LASERDISC_CLOCK, 10), (12 << 16) | data); + timer_adjust_oneshot(laserdisc_bit_timer, LASERDISC_CLOCK * 10, (12 << 16) | data); /* it also clears bit 4 of the status (will be set when transmission is complete) */ laserdisc_status &= ~0x10; @@ -487,14 +487,14 @@ static TIMER_CALLBACK( laserdisc_bit_callback ) /* assert the line and set a timer for deassertion */ laserdisc_line_w(laserdisc, LASERDISC_LINE_CONTROL, ASSERT_LINE); - timer_set(machine, attotime_mul(LASERDISC_CLOCK, 10), NULL, 0, laserdisc_bit_off_callback); + timer_set(machine, LASERDISC_CLOCK * 10, NULL, 0, laserdisc_bit_off_callback); /* determine how long for the next command; there is a 555 timer with a variable resistor controlling the timing of the pulses. Nominally, the 555 runs at 40083Hz, is divided by 10, and then is divided by 4 for a 0 bit or 8 for a 1 bit. This gives 998usec per 0 pulse or 1996usec per 1 pulse. */ - duration = attotime_mul(LASERDISC_CLOCK, 10 * ((data & 0x80) ? 8 : 4)); + duration = LASERDISC_CLOCK * (10 * ((data & 0x80) ? 8 : 4)); data <<= 1; /* if we're not out of bits, set a timer for the next one; else set the ready bit */ @@ -568,12 +568,12 @@ static void audio_process_clock(int logit) static void audio_handle_zero_crossing(attotime zerotime, int logit) { /* compute time from last clock */ - attotime deltaclock = attotime_sub(zerotime, laserdisc_last_clock); + attotime deltaclock = zerotime - laserdisc_last_clock; if (logit) - logerror(" -- zero @ %s (delta=%s)", attotime_string(zerotime, 6), attotime_string(deltaclock, 6)); + logerror(" -- zero @ %s (delta=%s)", zerotime.as_string(6), deltaclock.as_string(6)); /* if we are within 150usec, we count as a bit */ - if (attotime_compare(deltaclock, ATTOTIME_IN_USEC(150)) < 0) + if (deltaclock < attotime::from_usec(150)) { if (logit) logerror(" -- count as bit"); @@ -582,7 +582,7 @@ static void audio_handle_zero_crossing(attotime zerotime, int logit) } /* if we are within 215usec, we count as a clock */ - else if (attotime_compare(deltaclock, ATTOTIME_IN_USEC(215)) < 0) + else if (deltaclock < attotime::from_usec(215)) { if (logit) logerror(" -- clock, bit=%d", laserdisc_zero_seen); @@ -592,11 +592,11 @@ static void audio_handle_zero_crossing(attotime zerotime, int logit) /* if we are outside of 215usec, we are technically a missing clock however, due to sampling errors, it is best to assume this is just an out-of-skew clock, so we correct it if we are within 75usec */ - else if (attotime_compare(deltaclock, ATTOTIME_IN_USEC(275)) < 0) + else if (deltaclock < attotime::from_usec(275)) { if (logit) logerror(" -- skewed clock, correcting"); - laserdisc_last_clock = attotime_add(laserdisc_last_clock, ATTOTIME_IN_USEC(200)); + laserdisc_last_clock += attotime::from_usec(200); } /* we'll count anything more than 275us as an actual missing clock */ @@ -625,7 +625,7 @@ static void laserdisc_audio_process(device_t *device, int samplerate, int sample /* if no data, reset it all */ if (ch1 == NULL) { - laserdisc_last_time = attotime_add(curtime, attotime_mul(time_per_sample, samples)); + laserdisc_last_time = curtime + time_per_sample * samples; return; } @@ -636,10 +636,10 @@ static void laserdisc_audio_process(device_t *device, int samplerate, int sample /* start by logging the current sample and time */ if (logit) - logerror("%s: %d", attotime_string(attotime_add(attotime_add(curtime, time_per_sample), time_per_sample), 6), sample); + logerror("%s: %d", (curtime + time_per_sample + time_per_sample).as_string(6), sample); /* if we are past the "break in transmission" time, reset everything */ - if (attotime_compare(attotime_sub(curtime, laserdisc_last_clock), ATTOTIME_IN_USEC(400)) > 0) + if ((curtime - laserdisc_last_clock) > attotime::from_usec(400)) audio_end_state(); /* if this sample reinforces that the previous one ended a zero crossing, count it */ @@ -653,7 +653,7 @@ static void laserdisc_audio_process(device_t *device, int samplerate, int sample fractime = (-laserdisc_last_samples[0] * 1000) / (laserdisc_last_samples[1] - laserdisc_last_samples[0]); /* use this fraction to compute the approximate actual zero crossing time */ - zerotime = attotime_add(curtime, attotime_div(attotime_mul(time_per_sample, fractime), 1000)); + zerotime = curtime + time_per_sample * fractime / 1000; /* determine if this is a clock; if it is, process */ audio_handle_zero_crossing(zerotime, logit); @@ -664,7 +664,7 @@ static void laserdisc_audio_process(device_t *device, int samplerate, int sample /* update our sample tracking and advance time */ laserdisc_last_samples[0] = laserdisc_last_samples[1]; laserdisc_last_samples[1] = sample; - curtime = attotime_add(curtime, time_per_sample); + curtime += time_per_sample; } /* remember the last time */ diff --git a/src/mame/drivers/hitme.c b/src/mame/drivers/hitme.c index fa86725bc61..c31b45be315 100644 --- a/src/mame/drivers/hitme.c +++ b/src/mame/drivers/hitme.c @@ -138,7 +138,7 @@ static UINT8 read_port_and_t0( running_machine *machine, int port ) static const char *const portnames[] = { "IN0", "IN1", "IN2", "IN3" }; UINT8 val = input_port_read(machine, portnames[port]); - if (attotime_compare(timer_get_time(machine), state->timeout_time) > 0) + if (timer_get_time(machine) > state->timeout_time) val ^= 0x80; return val; } @@ -195,8 +195,8 @@ static WRITE8_DEVICE_HANDLER( output_port_0_w ) hitme_state *state = device->machine->driver_data<hitme_state>(); UINT8 raw_game_speed = input_port_read(device->machine, "R3"); double resistance = raw_game_speed * 25000 / 100; - attotime duration = attotime_make(0, ATTOSECONDS_PER_SECOND * 0.45 * 6.8e-6 * resistance * (data + 1)); - state->timeout_time = attotime_add(timer_get_time(device->machine), duration); + attotime duration = attotime(0, ATTOSECONDS_PER_SECOND * 0.45 * 6.8e-6 * resistance * (data + 1)); + state->timeout_time = timer_get_time(device->machine) + duration; discrete_sound_w(device, HITME_DOWNCOUNT_VAL, data); discrete_sound_w(device, HITME_OUT0, 1); diff --git a/src/mame/drivers/itech32.c b/src/mame/drivers/itech32.c index cce7712b536..80c2cabe5e1 100644 --- a/src/mame/drivers/itech32.c +++ b/src/mame/drivers/itech32.c @@ -522,7 +522,7 @@ static READ32_HANDLER( trackball32_4bit_r ) static attotime lasttime; attotime curtime = timer_get_time(space->machine); - if (attotime_compare(attotime_sub(curtime, lasttime), space->machine->primary_screen->scan_period()) > 0) + if ((curtime - lasttime) > space->machine->primary_screen->scan_period()) { int upper, lower; int dx, dy; @@ -561,7 +561,7 @@ static READ32_HANDLER( trackball32_4bit_p2_r ) static attotime lasttime; attotime curtime = timer_get_time(space->machine); - if (attotime_compare(attotime_sub(curtime, lasttime), space->machine->primary_screen->scan_period()) > 0) + if ((curtime - lasttime) > space->machine->primary_screen->scan_period()) { int upper, lower; int dx, dy; diff --git a/src/mame/drivers/jpmimpct.c b/src/mame/drivers/jpmimpct.c index b276cc4fc8a..9794e06e1fe 100644 --- a/src/mame/drivers/jpmimpct.c +++ b/src/mame/drivers/jpmimpct.c @@ -292,7 +292,7 @@ static READ16_HANDLER( duart_1_r ) } case 0xe: { - attotime rate = attotime_mul(ATTOTIME_IN_HZ(MC68681_1_CLOCK), 16 * duart_1.CT); + attotime rate = attotime::from_hz(MC68681_1_CLOCK) * (16 * duart_1.CT); timer_device *duart_timer = space->machine->device<timer_device>("duart_1_timer"); duart_timer->adjust(rate, 0, rate); break; diff --git a/src/mame/drivers/jpmsys5.c b/src/mame/drivers/jpmsys5.c index c31af859d47..b81889e4c68 100644 --- a/src/mame/drivers/jpmsys5.c +++ b/src/mame/drivers/jpmsys5.c @@ -368,7 +368,7 @@ static INPUT_CHANGED( touchscreen_press ) { if (newval == 0) { - attotime rx_period = attotime_mul(ATTOTIME_IN_HZ(10000), 16); + attotime rx_period = attotime::from_hz(10000) * 16; /* Each touch screen packet is 3 bytes */ touch_data[0] = 0x2a; diff --git a/src/mame/drivers/ksys573.c b/src/mame/drivers/ksys573.c index b3fb8c81beb..354b327ae01 100644 --- a/src/mame/drivers/ksys573.c +++ b/src/mame/drivers/ksys573.c @@ -1338,7 +1338,7 @@ static void root_timer_adjust( running_machine *machine, int n_counter ) n_duration *= root_divider( machine, n_counter ); - timer_adjust_oneshot( state->m_p_timer_root[ n_counter ], attotime_mul(ATTOTIME_IN_HZ(33868800), n_duration), n_counter); + timer_adjust_oneshot( state->m_p_timer_root[ n_counter ], attotime::from_hz(33868800) * n_duration, n_counter); } } diff --git a/src/mame/drivers/maxaflex.c b/src/mame/drivers/maxaflex.c index a7cddadd2c5..3da767042ae 100644 --- a/src/mame/drivers/maxaflex.c +++ b/src/mame/drivers/maxaflex.c @@ -199,7 +199,7 @@ static WRITE8_HANDLER( mcu_tcr_w ) divider = divider * (1 << (tcr & 0x7)); } - period = attotime_mul(ATTOTIME_IN_HZ(3579545), divider); + period = attotime::from_hz(3579545) * divider; mcu_timer->adjust(period, 0, period); } } diff --git a/src/mame/drivers/mcr68.c b/src/mame/drivers/mcr68.c index ea9e3d37089..e7a0e495d58 100644 --- a/src/mame/drivers/mcr68.c +++ b/src/mame/drivers/mcr68.c @@ -1537,7 +1537,7 @@ static DRIVER_INIT( zwackery ) mcr68_common_init(machine, MCR_CHIP_SQUEAK_DELUXE, 0, 0); /* Zwackery doesn't care too much about this value; currently taken from Blasted */ - mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16)); + mcr68_timing_factor = attotime::from_hz(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16); } @@ -1546,7 +1546,7 @@ static DRIVER_INIT( xenophob ) mcr68_common_init(machine, MCR_SOUNDS_GOOD, 0, -4); /* Xenophobe doesn't care too much about this value; currently taken from Blasted */ - mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16)); + mcr68_timing_factor = attotime::from_hz(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16); /* install control port handler */ memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0c0000, 0x0cffff, 0, 0, xenophobe_control_w); @@ -1558,7 +1558,7 @@ static DRIVER_INIT( spyhunt2 ) mcr68_common_init(machine, MCR_TURBO_CHIP_SQUEAK | MCR_SOUNDS_GOOD, 0, -6); /* Spy Hunter 2 doesn't care too much about this value; currently taken from Blasted */ - mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16)); + mcr68_timing_factor = attotime::from_hz(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16); /* analog port handling is a bit tricky */ memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0c0000, 0x0cffff, 0, 0, spyhunt2_control_w); @@ -1574,7 +1574,7 @@ static DRIVER_INIT( blasted ) /* Blasted checks the timing of VBLANK relative to the 493 interrupt */ /* VBLANK is required to come within 220-256 E clocks (i.e., 2200-2560 CPU clocks) */ /* after the 493; we also allow 16 E clocks for latency */ - mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16)); + mcr68_timing_factor = attotime::from_hz(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16); /* handle control writes */ memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0c0000, 0x0cffff, 0, 0, blasted_control_w); @@ -1588,7 +1588,7 @@ static DRIVER_INIT( intlaser ) mcr68_common_init(machine, MCR_SOUNDS_GOOD, 0, 0); /* Copied from Blasted */ - mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16)); + mcr68_timing_factor = attotime::from_hz(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16); /* handle control writes */ memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0c0000, 0x0cffff, 0, 0, blasted_control_w); @@ -1602,7 +1602,7 @@ static DRIVER_INIT( archrivl ) mcr68_common_init(machine, MCR_WILLIAMS_SOUND, 16, 0); /* Arch Rivals doesn't care too much about this value; currently taken from Blasted */ - mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16)); + mcr68_timing_factor = attotime::from_hz(cputag_get_clock(machine, "maincpu") / 10) * (256 + 16); /* handle control writes */ memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0c0000, 0x0cffff, 0, 0, archrivl_control_w); @@ -1620,7 +1620,7 @@ static DRIVER_INIT( pigskin ) mcr68_common_init(machine, MCR_WILLIAMS_SOUND, 16, 0); /* Pigskin doesn't care too much about this value; currently taken from Tri-Sports */ - mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(cputag_get_clock(machine, "maincpu") / 10) * 115); + mcr68_timing_factor = attotime::from_hz(cputag_get_clock(machine, "maincpu") / 10) * 115; state_save_register_global_array(machine, protection_data); } @@ -1633,7 +1633,7 @@ static DRIVER_INIT( trisport ) /* Tri-Sports checks the timing of VBLANK relative to the 493 interrupt */ /* VBLANK is required to come within 87-119 E clocks (i.e., 870-1190 CPU clocks) */ /* after the 493 */ - mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(cputag_get_clock(machine, "maincpu") / 10) * 115); + mcr68_timing_factor = attotime::from_hz(cputag_get_clock(machine, "maincpu") / 10) * 115; } diff --git a/src/mame/drivers/mgolf.c b/src/mame/drivers/mgolf.c index 40a4bda2904..4aee5402262 100644 --- a/src/mame/drivers/mgolf.c +++ b/src/mame/drivers/mgolf.c @@ -126,7 +126,7 @@ static TIMER_CALLBACK( interrupt_callback ) static double calc_plunger_pos(running_machine *machine) { mgolf_state *state = machine->driver_data<mgolf_state>(); - return (attotime_to_double(timer_get_time(machine)) - attotime_to_double(state->time_released)) * (attotime_to_double(state->time_released) - attotime_to_double(state->time_pushed) + 0.2); + return (timer_get_time(machine).as_double() - state->time_released.as_double()) * (state->time_released.as_double() - state->time_pushed.as_double() + 0.2); } diff --git a/src/mame/drivers/midvunit.c b/src/mame/drivers/midvunit.c index 58bc69c31b9..3a7ecd6f664 100644 --- a/src/mame/drivers/midvunit.c +++ b/src/mame/drivers/midvunit.c @@ -264,7 +264,7 @@ static READ32_HANDLER( tms32031_control_r ) { /* timer is clocked at 100ns */ int which = (offset >> 4) & 1; - INT32 result = attotime_to_double(attotime_mul(timer[which]->time_elapsed(), timer_rate)); + INT32 result = (timer[which]->time_elapsed() * timer_rate).as_double(); // logerror("%06X:tms32031_control_r(%02X) = %08X\n", cpu_get_pc(space->cpu), offset, result); return result; } diff --git a/src/mame/drivers/midzeus.c b/src/mame/drivers/midzeus.c index 55e13bb74fa..066b144a77a 100644 --- a/src/mame/drivers/midzeus.c +++ b/src/mame/drivers/midzeus.c @@ -388,7 +388,7 @@ static READ32_HANDLER( tms32031_control_r ) { /* timer is clocked at 100ns */ int which = (offset >> 4) & 1; - INT32 result = attotime_to_double(attotime_mul(timer_timeelapsed(timer[which]), 10000000)); + INT32 result = (timer_timeelapsed(timer[which]) * 10000000).as_double(); return result; } diff --git a/src/mame/drivers/mjsister.c b/src/mame/drivers/mjsister.c index 270e452fd11..a94821dda43 100644 --- a/src/mame/drivers/mjsister.c +++ b/src/mame/drivers/mjsister.c @@ -160,7 +160,7 @@ static TIMER_CALLBACK( dac_callback ) dac_data_w(state->dac, DACROM[(state->dac_bank * 0x10000 + state->dac_adr++) & 0x1ffff]); if (((state->dac_adr & 0xff00 ) >> 8) != state->dac_adr_e) - timer_set(machine, attotime_mul(ATTOTIME_IN_HZ(MCLK), 1024), NULL, 0, dac_callback); + timer_set(machine, attotime::from_hz(MCLK) * 1024, NULL, 0, dac_callback); else state->dac_busy = 0; } diff --git a/src/mame/drivers/model2.c b/src/mame/drivers/model2.c index 64b7e25db9c..4bc1ca7eb79 100644 --- a/src/mame/drivers/model2.c +++ b/src/mame/drivers/model2.c @@ -288,7 +288,7 @@ static READ32_HANDLER( timers_r ) if (model2_timerrun[offset]) { // get elapsed time, convert to units of 25 MHz - UINT32 cur = attotime_to_double(attotime_mul(model2_timers[offset]->time_elapsed(), 25000000)); + UINT32 cur = (model2_timers[offset]->time_elapsed() * 25000000).as_double(); // subtract units from starting value model2_timervals[offset] = model2_timerorig[offset] - cur; @@ -305,7 +305,7 @@ static WRITE32_HANDLER( timers_w ) COMBINE_DATA(&model2_timervals[offset]); model2_timerorig[offset] = model2_timervals[offset]; - period = attotime_mul(ATTOTIME_IN_HZ(25000000), model2_timerorig[offset]); + period = attotime::from_hz(25000000) * model2_timerorig[offset]; model2_timers[offset]->adjust(period); model2_timerrun[offset] = 1; } diff --git a/src/mame/drivers/mpu4.c b/src/mame/drivers/mpu4.c index a47c03ca39f..6dd2d27f97f 100644 --- a/src/mame/drivers/mpu4.c +++ b/src/mame/drivers/mpu4.c @@ -615,7 +615,7 @@ static void ic24_setup(void) { ic23_active=1; ic24_output(0); - timer_adjust_oneshot(ic24_timer, double_to_attotime(duration), 0); + timer_adjust_oneshot(ic24_timer, attotime::from_double(duration), 0); } } } diff --git a/src/mame/drivers/neogeo.c b/src/mame/drivers/neogeo.c index 20d8affa961..c8dd024a838 100644 --- a/src/mame/drivers/neogeo.c +++ b/src/mame/drivers/neogeo.c @@ -245,7 +245,7 @@ static void adjust_display_position_interrupt_timer( running_machine *machine ) if ((state->display_counter + 1) != 0) { - attotime period = attotime_mul(ATTOTIME_IN_HZ(NEOGEO_PIXEL_CLOCK), state->display_counter + 1); + attotime period = attotime::from_hz(NEOGEO_PIXEL_CLOCK) * (state->display_counter + 1); if (LOG_VIDEO_SYSTEM) logerror("adjust_display_position_interrupt_timer current y: %02x current x: %02x target y: %x target x: %x\n", machine->primary_screen->vpos(), machine->primary_screen->hpos(), (state->display_counter + 1) / NEOGEO_HTOTAL, (state->display_counter + 1) % NEOGEO_HTOTAL); timer_adjust_oneshot(state->display_position_interrupt_timer, period, 0); diff --git a/src/mame/drivers/seattle.c b/src/mame/drivers/seattle.c index 1c06bf6477d..378fc01104a 100644 --- a/src/mame/drivers/seattle.c +++ b/src/mame/drivers/seattle.c @@ -920,7 +920,7 @@ static TIMER_CALLBACK( galileo_timer_callback ) /* if we're a timer, adjust the timer to fire again */ if (galileo.reg[GREG_TIMER_CONTROL] & (2 << (2 * which))) - timer_adjust_oneshot(timer->timer, attotime_mul(TIMER_PERIOD, timer->count), which); + timer_adjust_oneshot(timer->timer, TIMER_PERIOD * timer->count, which); else timer->active = timer->count = 0; @@ -1100,7 +1100,7 @@ static READ32_HANDLER( galileo_r ) result = timer->count; if (timer->active) { - UINT32 elapsed = attotime_to_double(attotime_mul(timer_timeelapsed(timer->timer), SYSTEM_CLOCK)); + UINT32 elapsed = (timer_timeelapsed(timer->timer) * SYSTEM_CLOCK).as_double(); result = (result > elapsed) ? (result - elapsed) : 0; } @@ -1231,13 +1231,13 @@ static WRITE32_HANDLER( galileo_w ) if (which != 0) timer->count &= 0xffffff; } - timer_adjust_oneshot(timer->timer, attotime_mul(TIMER_PERIOD, timer->count), which); + timer_adjust_oneshot(timer->timer, TIMER_PERIOD * timer->count, which); if (LOG_TIMERS) - logerror("Adjusted timer to fire in %f secs\n", attotime_to_double(attotime_mul(TIMER_PERIOD, timer->count))); + logerror("Adjusted timer to fire in %f secs\n", (TIMER_PERIOD * timer->count).as_double()); } else if (timer->active && !(data & mask)) { - UINT32 elapsed = attotime_to_double(attotime_mul(timer_timeelapsed(timer->timer), SYSTEM_CLOCK)); + UINT32 elapsed = (timer_timeelapsed(timer->timer) * SYSTEM_CLOCK).as_double(); timer->active = 0; timer->count = (timer->count > elapsed) ? (timer->count - elapsed) : 0; timer_adjust_oneshot(timer->timer, attotime_never, which); diff --git a/src/mame/drivers/segas32.c b/src/mame/drivers/segas32.c index 86b06c81759..341f97870f3 100644 --- a/src/mame/drivers/segas32.c +++ b/src/mame/drivers/segas32.c @@ -524,7 +524,7 @@ static void int_control_w(address_space *space, int offset, UINT8 data) duration = v60_irq_control[8] + ((v60_irq_control[9] << 8) & 0xf00); if (duration) { - attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_0_CLOCK)) * duration); + attotime period = attotime::from_hz(TIMER_0_CLOCK) * duration; v60_irq_timer[0]->adjust(period, MAIN_IRQ_TIMER0); } break; @@ -535,7 +535,7 @@ static void int_control_w(address_space *space, int offset, UINT8 data) duration = v60_irq_control[10] + ((v60_irq_control[11] << 8) & 0xf00); if (duration) { - attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_1_CLOCK)) * duration); + attotime period = attotime::from_hz(TIMER_1_CLOCK) * duration; v60_irq_timer[1]->adjust(period, MAIN_IRQ_TIMER1); } break; diff --git a/src/mame/drivers/seta.c b/src/mame/drivers/seta.c index 608120c2154..1b2c1bb68a9 100644 --- a/src/mame/drivers/seta.c +++ b/src/mame/drivers/seta.c @@ -1333,7 +1333,7 @@ static void uPD71054_update_timer( running_machine *machine, device_t *cpu, int UINT16 max = uPD71054->max[no]&0xffff; if( max != 0 ) { - attotime period = attotime_mul(ATTOTIME_IN_HZ(cputag_get_clock(machine, "maincpu")), 16 * max); + attotime period = attotime::from_hz(cputag_get_clock(machine, "maincpu")) * (16 * max); timer_adjust_oneshot( uPD71054->timer[no], period, no ); } else { timer_adjust_oneshot( uPD71054->timer[no], attotime_never, no); diff --git a/src/mame/drivers/tetrisp2.c b/src/mame/drivers/tetrisp2.c index 34184016bda..1389eb2e52c 100644 --- a/src/mame/drivers/tetrisp2.c +++ b/src/mame/drivers/tetrisp2.c @@ -76,7 +76,7 @@ static WRITE16_HANDLER( rockn_systemregs_w ) tetrisp2_systemregs[offset] = data; if (offset == 0x0c) { - attotime timer = attotime_mul(ROCKN_TIMER_BASE, 4096 - data); + attotime timer = ROCKN_TIMER_BASE * (4096 - data); timer_adjust_periodic(rockn_timer_l4, timer, 0, timer); } } @@ -90,7 +90,7 @@ static WRITE16_HANDLER( rocknms_sub_systemregs_w ) rocknms_sub_systemregs[offset] = data; if (offset == 0x0c) { - attotime timer = attotime_mul(ROCKN_TIMER_BASE, 4096 - data); + attotime timer = ROCKN_TIMER_BASE * (4096 - data); timer_adjust_periodic(rockn_timer_sub_l4, timer, 0, timer); } } diff --git a/src/mame/drivers/vegas.c b/src/mame/drivers/vegas.c index 5fe7301d825..a40d4b9f14b 100644 --- a/src/mame/drivers/vegas.c +++ b/src/mame/drivers/vegas.c @@ -948,7 +948,7 @@ static TIMER_CALLBACK( nile_timer_callback ) if (regs[1] & 2) logerror("Unexpected value: timer %d is prescaled\n", which); if (scale != 0) - timer_adjust_oneshot(timer[which], attotime_mul(TIMER_PERIOD, scale), which); + timer_adjust_oneshot(timer[which], TIMER_PERIOD * scale, which); } /* trigger the interrupt */ @@ -1031,7 +1031,7 @@ static READ32_HANDLER( nile_r ) { if (nile_regs[offset] & 2) logerror("Unexpected value: timer %d is prescaled\n", which); - result = nile_regs[offset + 1] = attotime_to_double(timer_timeleft(timer[which])) * (double)SYSTEM_CLOCK; + result = nile_regs[offset + 1] = timer_timeleft(timer[which]).as_double() * (double)SYSTEM_CLOCK; } if (LOG_TIMERS) logerror("%08X:NILE READ: timer %d counter(%03X) = %08X\n", cpu_get_pc(space->cpu), which, offset*4, result); @@ -1161,8 +1161,8 @@ static WRITE32_HANDLER( nile_w ) if (nile_regs[offset] & 2) logerror("Unexpected value: timer %d is prescaled\n", which); if (scale != 0) - timer_adjust_oneshot(timer[which], attotime_mul(TIMER_PERIOD, scale), which); - if (LOG_TIMERS) logerror("Starting timer %d at a rate of %d Hz\n", which, (int)ATTOSECONDS_TO_HZ(attotime_mul(TIMER_PERIOD, nile_regs[offset + 1] + 1).attoseconds)); + timer_adjust_oneshot(timer[which], TIMER_PERIOD * scale, which); + if (LOG_TIMERS) logerror("Starting timer %d at a rate of %d Hz\n", which, (int)ATTOSECONDS_TO_HZ((TIMER_PERIOD * (nile_regs[offset + 1] + 1)).attoseconds)); } /* timer disabled? */ @@ -1170,7 +1170,7 @@ static WRITE32_HANDLER( nile_w ) { if (nile_regs[offset] & 2) logerror("Unexpected value: timer %d is prescaled\n", which); - nile_regs[offset + 1] = attotime_to_double(timer_timeleft(timer[which])) * SYSTEM_CLOCK; + nile_regs[offset + 1] = timer_timeleft(timer[which]).as_double() * SYSTEM_CLOCK; timer_adjust_oneshot(timer[which], attotime_never, which); } break; @@ -1187,7 +1187,7 @@ static WRITE32_HANDLER( nile_w ) { if (nile_regs[offset - 1] & 2) logerror("Unexpected value: timer %d is prescaled\n", which); - timer_adjust_oneshot(timer[which], attotime_mul(TIMER_PERIOD, nile_regs[offset]), which); + timer_adjust_oneshot(timer[which], TIMER_PERIOD * nile_regs[offset], which); } break; diff --git a/src/mame/drivers/vicdual.c b/src/mame/drivers/vicdual.c index 88ce4f6cc26..5b820e6d949 100644 --- a/src/mame/drivers/vicdual.c +++ b/src/mame/drivers/vicdual.c @@ -98,7 +98,7 @@ static INPUT_CHANGED( coin_changed ) cputag_set_input_line(field->port->machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE); /* simulate the coin switch being closed for a while */ - timer_set(field->port->machine, double_to_attotime(4 * attotime_to_double(field->port->machine->primary_screen->frame_period())), NULL, 0, clear_coin_status); + timer_set(field->port->machine, 4 * field->port->machine->primary_screen->frame_period(), NULL, 0, clear_coin_status); } } @@ -155,7 +155,7 @@ static CUSTOM_INPUT( vicdual_get_composite_blank_comp ) static CUSTOM_INPUT( vicdual_get_timer_value ) { /* return the state of the timer (old code claims "4MHz square wave", but it was toggled once every 2msec, or 500Hz) */ - return attotime_to_ticks(timer_get_time(field->port->machine), 500) & 1; + return timer_get_time(field->port->machine).as_ticks(500) & 1; } diff --git a/src/mame/drivers/videopin.c b/src/mame/drivers/videopin.c index caa41b3c3a6..4aacec471bd 100644 --- a/src/mame/drivers/videopin.c +++ b/src/mame/drivers/videopin.c @@ -77,7 +77,7 @@ static MACHINE_RESET( videopin ) static double calc_plunger_pos(running_machine *machine) { videopin_state *state = machine->driver_data<videopin_state>(); - return (attotime_to_double(timer_get_time(machine)) - attotime_to_double(state->time_released)) * (attotime_to_double(state->time_released) - attotime_to_double(state->time_pushed) + 0.2); + return (timer_get_time(machine).as_double() - state->time_released.as_double()) * (state->time_released.as_double() - state->time_pushed.as_double() + 0.2); } diff --git a/src/mame/includes/beathead.h b/src/mame/includes/beathead.h index b536b201864..7219134f704 100644 --- a/src/mame/includes/beathead.h +++ b/src/mame/includes/beathead.h @@ -42,7 +42,7 @@ public: UINT32 * m_ram_base; UINT32 * m_rom_base; - double m_hblank_offset; + attotime m_hblank_offset; UINT8 m_irq_line_state; UINT8 m_irq_enable[3]; diff --git a/src/mame/machine/amiga.c b/src/mame/machine/amiga.c index f3aee484fa6..6f530763696 100644 --- a/src/mame/machine/amiga.c +++ b/src/mame/machine/amiga.c @@ -1515,7 +1515,7 @@ attotime amiga_get_serial_char_period(running_machine *machine) UINT32 divisor = (CUSTOM_REG(REG_SERPER) & 0x7fff) + 1; UINT32 baud = cputag_get_clock(machine, "maincpu") / 2 / divisor; UINT32 numbits = 2 + ((CUSTOM_REG(REG_SERPER) & 0x8000) ? 9 : 8); - return attotime_mul(ATTOTIME_IN_HZ(baud), numbits); + return attotime::from_hz(baud) * numbits; } diff --git a/src/mame/machine/archimds.c b/src/mame/machine/archimds.c index df72b15bf40..14f8f3577f2 100644 --- a/src/mame/machine/archimds.c +++ b/src/mame/machine/archimds.c @@ -381,7 +381,7 @@ static const char *const ioc_regnames[] = static void latch_timer_cnt(int tmr) { - double time = attotime_to_double(timer_timeelapsed(timer[tmr])); + double time = timer_timeelapsed(timer[tmr]).as_double(); time *= 2000000.0; // find out how many 2 MHz ticks have gone by ioc_timerout[tmr] = ioc_timercnt[tmr] - (UINT32)time; } diff --git a/src/mame/machine/atarigen.c b/src/mame/machine/atarigen.c index 4322959fc14..3bc858f42ef 100644 --- a/src/mame/machine/atarigen.c +++ b/src/mame/machine/atarigen.c @@ -1376,15 +1376,13 @@ void atarigen_halt_until_hblank_0(screen_device &screen) int hpos = screen.hpos(); int width = screen.width(); int hblank = width * 9 / 10; - double fraction; /* if we're in hblank, set up for the next one */ if (hpos >= hblank) hblank += width; /* halt and set a timer to wake up */ - fraction = (double)(hblank - hpos) / (double)width; - timer_set(screen.machine, double_to_attotime(attotime_to_double(screen.scan_period()) * fraction), (void *)cpu, 0, unhalt_cpu); + timer_set(screen.machine, screen.scan_period() * (hblank - hpos) / width, (void *)cpu, 0, unhalt_cpu); cpu_set_input_line(cpu, INPUT_LINE_HALT, ASSERT_LINE); } diff --git a/src/mame/machine/balsente.c b/src/mame/machine/balsente.c index 81853e917c4..52a3a6559c7 100644 --- a/src/mame/machine/balsente.c +++ b/src/mame/machine/balsente.c @@ -650,7 +650,7 @@ INLINE void counter_start(balsente_state *state, int which) if (state->counter[which].gate && !state->counter[which].timer_active) { state->counter[which].timer_active = 1; - state->counter[which].timer->adjust(attotime_mul(ATTOTIME_IN_HZ(2000000), state->counter[which].count), which); + state->counter[which].timer->adjust(attotime::from_hz(2000000) * state->counter[which].count, which); } } } @@ -671,7 +671,7 @@ INLINE void counter_update_count(balsente_state *state, int which) if (state->counter[which].timer_active) { /* determine how many 2MHz cycles are remaining */ - int count = attotime_to_double(attotime_mul(state->counter[which].timer->time_left(), 2000000)); + int count = (state->counter[which].timer->time_left() * 2000000).as_double(); state->counter[which].count = (count < 0) ? 0 : count; } } diff --git a/src/mame/machine/cdi070.c b/src/mame/machine/cdi070.c index 596a770df4a..9588a98f02f 100644 --- a/src/mame/machine/cdi070.c +++ b/src/mame/machine/cdi070.c @@ -52,7 +52,7 @@ static void scc68070_set_timer_callback(scc68070_regs_t *scc68070, int channel) { case 0: compare = 0x10000 - scc68070->timers.timer0; - period = attotime_mul(ATTOTIME_IN_HZ(CLOCK_A/192), compare); + period = attotime::from_hz(CLOCK_A/192) * compare; timer_adjust_oneshot(scc68070->timers.timer0_timer, period, 0); break; default: @@ -118,7 +118,7 @@ static void scc68070_uart_tx_check(running_machine *machine, scc68070_regs_t *sc scc68070->uart.status_register |= USR_TXRDY; } - if(attotime_compare(timer_timeleft(scc68070->uart.tx_timer), attotime_never) == 0) + if(timer_timeleft(scc68070->uart.tx_timer) == attotime::never) { UINT32 div = 0x10000 >> (scc68070->uart.clock_select & 7); timer_adjust_oneshot(scc68070->uart.tx_timer, ATTOTIME_IN_HZ((49152000 / div) / 8), 0); diff --git a/src/mame/machine/cdicdic.c b/src/mame/machine/cdicdic.c index 204fca15839..34e51cbece4 100644 --- a/src/mame/machine/cdicdic.c +++ b/src/mame/machine/cdicdic.c @@ -607,7 +607,7 @@ void cdicdic_device::sample_trigger() //// Delay for Frequency * (18*28*2*size in bytes) before requesting more data verboselog(&m_machine, 0, "Data is valid, setting up a new callback\n" ); - m_decode_period = attotime_mul(ATTOTIME_IN_HZ(CDIC_SAMPLE_BUF_FREQ(m_ram, m_decode_addr & 0x3ffe)), 18*28*2*CDIC_SAMPLE_BUF_SIZE(m_ram, m_decode_addr & 0x3ffe)); + m_decode_period = attotime::from_hz(CDIC_SAMPLE_BUF_FREQ(m_ram, m_decode_addr & 0x3ffe)) * (18*28*2*CDIC_SAMPLE_BUF_SIZE(m_ram, m_decode_addr & 0x3ffe)); timer_adjust_oneshot(m_audio_sample_timer, m_decode_period, 0); //dmadac_enable(&dmadac[0], 2, 0); } @@ -999,7 +999,7 @@ UINT16 cdicdic_device::register_read(const UINT32 offset, const UINT16 mem_mask) case 0x3ffa/2: // AUDCTL { - if(attotime_is_never(timer_timeleft(m_audio_sample_timer))) + if(timer_timeleft(m_audio_sample_timer).is_never()) { m_z_buffer ^= 0x0001; } @@ -1119,7 +1119,7 @@ void cdicdic_device::register_write(const UINT32 offset, const UINT16 data, cons if(m_z_buffer & 0x2000) { attotime period = timer_timeleft(m_audio_sample_timer); - if(attotime_is_never(period)) + if(period.is_never()) { m_decode_addr = m_z_buffer & 0x3a00; m_decode_delay = 1; @@ -1164,7 +1164,7 @@ void cdicdic_device::register_write(const UINT32 offset, const UINT16 data, cons case 0x2c: // Seek { attotime period = timer_timeleft(m_interrupt_timer); - if(!attotime_is_never(period)) + if(!period.is_never()) { timer_adjust_oneshot(m_interrupt_timer, period, 0); } diff --git a/src/mame/machine/decocass.c b/src/mame/machine/decocass.c index f81b217f81b..212530e3f65 100644 --- a/src/mame/machine/decocass.c +++ b/src/mame/machine/decocass.c @@ -208,7 +208,7 @@ READ8_HANDLER( decocass_input_r ) WRITE8_HANDLER( decocass_reset_w ) { decocass_state *state = space->machine->driver_data<decocass_state>(); - LOG(1,("%10s 6502-PC: %04x decocass_reset_w(%02x): $%02x\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(1,("%10s 6502-PC: %04x decocass_reset_w(%02x): $%02x\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); state->decocass_reset = data; /* CPU #1 active high reset */ @@ -288,7 +288,7 @@ static READ8_HANDLER( decocass_type1_latch_26_pass_3_inv_2_r ) data = (BIT(data, 0) << 0) | (BIT(data, 1) << 1) | 0x7c; LOG(4,("%10s 6502-PC: %04x decocass_type1_latch_26_pass_3_inv_2_r(%02x): $%02x <- (%s %s)\n", - attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data & 1) ? "OBF" : "-", (data & 2) ? "IBF" : "-")); } @@ -336,7 +336,7 @@ static READ8_HANDLER( decocass_type1_latch_26_pass_3_inv_2_r ) (((prom[promaddr] >> 4) & 1) << MAP7(state->type1_outmap)); LOG(3,("%10s 6502-PC: %04x decocass_type1_latch_26_pass_3_inv_2_r(%02x): $%02x\n", - attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); state->latch1 = save; /* latch the data for the next A0 == 0 read */ } @@ -368,7 +368,7 @@ static READ8_HANDLER( decocass_type1_pass_136_r ) data = (BIT(data, 0) << 0) | (BIT(data, 1) << 1) | 0x7c; LOG(4,("%10s 6502-PC: %04x decocass_type1_pass_136_r(%02x): $%02x <- (%s %s)\n", - attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data & 1) ? "OBF" : "-", (data & 2) ? "IBF" : "-")); } @@ -416,7 +416,7 @@ static READ8_HANDLER( decocass_type1_pass_136_r ) (((prom[promaddr] >> 4) & 1) << MAP7(state->type1_outmap)); LOG(3,("%10s 6502-PC: %04x decocass_type1_pass_136_r(%02x): $%02x\n", - attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); state->latch1 = save; /* latch the data for the next A0 == 0 read */ } @@ -448,7 +448,7 @@ static READ8_HANDLER( decocass_type1_latch_27_pass_3_inv_2_r ) data = (BIT(data, 0) << 0) | (BIT(data, 1) << 1) | 0x7c; LOG(4,("%10s 6502-PC: %04x decocass_type1_latch_27_pass_3_inv_2_r(%02x): $%02x <- (%s %s)\n", - attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data & 1) ? "OBF" : "-", (data & 2) ? "IBF" : "-")); } @@ -496,7 +496,7 @@ static READ8_HANDLER( decocass_type1_latch_27_pass_3_inv_2_r ) (((state->latch1 >> MAP7(state->type1_inmap)) & 1) << MAP7(state->type1_outmap)); LOG(3,("%10s 6502-PC: %04x decocass_type1_latch_27_pass_3_inv_2_r(%02x): $%02x\n", - attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); state->latch1 = save; /* latch the data for the next A0 == 0 read */ } @@ -528,7 +528,7 @@ static READ8_HANDLER( decocass_type1_latch_26_pass_5_inv_2_r ) data = (BIT(data, 0) << 0) | (BIT(data, 1) << 1) | 0x7c; LOG(4,("%10s 6502-PC: %04x decocass_type1_latch_26_pass_5_inv_2_r(%02x): $%02x <- (%s %s)\n", - attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data & 1) ? "OBF" : "-", (data & 2) ? "IBF" : "-")); } @@ -576,7 +576,7 @@ static READ8_HANDLER( decocass_type1_latch_26_pass_5_inv_2_r ) (((prom[promaddr] >> 4) & 1) << MAP7(state->type1_outmap)); LOG(3,("%10s 6502-PC: %04x decocass_type1_latch_26_pass_5_inv_2_r(%02x): $%02x\n", - attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); state->latch1 = save; /* latch the data for the next A0 == 0 read */ } @@ -610,7 +610,7 @@ static READ8_HANDLER( decocass_type1_latch_16_pass_3_inv_1_r ) data = (BIT(data, 0) << 0) | (BIT(data, 1) << 1) | 0x7c; LOG(4,("%10s 6502-PC: %04x decocass_type1_latch_16_pass_3_inv_1_r(%02x): $%02x <- (%s %s)\n", - attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data & 1) ? "OBF" : "-", (data & 2) ? "IBF" : "-")); } @@ -658,7 +658,7 @@ static READ8_HANDLER( decocass_type1_latch_16_pass_3_inv_1_r ) (((prom[promaddr] >> 4) & 1) << MAP7(state->type1_outmap)); LOG(3,("%10s 6502-PC: %04x decocass_type1_latch_16_pass_3_inv_1_r(%02x): $%02x\n", - attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); state->latch1 = save; /* latch the data for the next A0 == 0 read */ } @@ -688,7 +688,7 @@ static READ8_HANDLER( decocass_type2_r ) { UINT8 *prom = space->machine->region("dongle")->base(); data = prom[256 * state->type2_d2_latch + state->type2_promaddr]; - LOG(3,("%10s 6502-PC: %04x decocass_type2_r(%02x): $%02x <- prom[%03x]\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, 256 * state->type2_d2_latch + state->type2_promaddr)); + LOG(3,("%10s 6502-PC: %04x decocass_type2_r(%02x): $%02x <- prom[%03x]\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, 256 * state->type2_d2_latch + state->type2_promaddr)); } else { @@ -702,7 +702,7 @@ static READ8_HANDLER( decocass_type2_r ) else data = offset & 0xff; - LOG(3,("%10s 6502-PC: %04x decocass_type2_r(%02x): $%02x <- 8041-%s\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "STATUS" : "DATA")); + LOG(3,("%10s 6502-PC: %04x decocass_type2_r(%02x): $%02x <- 8041-%s\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "STATUS" : "DATA")); } return data; } @@ -714,18 +714,18 @@ static WRITE8_HANDLER( decocass_type2_w ) { if (1 == (offset & 1)) { - LOG(4,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> set PROM+D2 latch", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> set PROM+D2 latch", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } else { state->type2_promaddr = data; - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> set PROM addr $%02x\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, state->type2_promaddr)); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> set PROM addr $%02x\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, state->type2_promaddr)); return; } } else { - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s ", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "8041-CMND" : "8041 DATA")); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s ", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "8041-CMND" : "8041 DATA")); } if (1 == (offset & 1)) { @@ -770,7 +770,7 @@ static READ8_HANDLER( decocass_type3_r ) { UINT8 *prom = space->machine->region("dongle")->base(); data = prom[state->type3_ctrs]; - LOG(3,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x <- prom[$%03x]\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, state->type3_ctrs)); + LOG(3,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x <- prom[$%03x]\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, state->type3_ctrs)); if (++state->type3_ctrs == 4096) state->type3_ctrs = 0; } @@ -779,12 +779,12 @@ static READ8_HANDLER( decocass_type3_r ) if (0 == (offset & E5XX_MASK)) { data = upi41_master_r(state->mcu, 1); - LOG(4,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x <- 8041 STATUS\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x <- 8041 STATUS\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } else { data = 0xff; /* open data bus? */ - LOG(4,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x <- open bus\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x <- open bus\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } } } @@ -793,7 +793,7 @@ static READ8_HANDLER( decocass_type3_r ) if (1 == state->type3_pal_19) { save = data = 0xff; /* open data bus? */ - LOG(3,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x <- open bus", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(3,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x <- open bus", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } else { @@ -924,7 +924,7 @@ static READ8_HANDLER( decocass_type3_r ) (BIT(save, 7) << 7); } state->type3_d0_latch = save & 1; - LOG(3,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x '%c' <- 8041-DATA\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); + LOG(3,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x '%c' <- 8041-DATA\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); } else { @@ -938,7 +938,7 @@ static READ8_HANDLER( decocass_type3_r ) (BIT(save, 5) << 5) | (BIT(save, 6) << 7) | (BIT(save, 7) << 6); - LOG(3,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); + LOG(3,("%10s 6502-PC: %04x decocass_type3_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); state->type3_d0_latch = save & 1; } } @@ -955,7 +955,7 @@ static WRITE8_HANDLER( decocass_type3_w ) if (1 == state->type3_pal_19) { state->type3_ctrs = data << 4; - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, "LDCTRS")); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, "LDCTRS")); return; } else @@ -967,11 +967,11 @@ static WRITE8_HANDLER( decocass_type3_w ) if (1 == state->type3_pal_19) { /* write nowhere?? */ - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, "nowhere?")); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, "nowhere?")); return; } } - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA")); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA")); upi41_master_w(state->mcu, offset, data); } @@ -997,12 +997,12 @@ static READ8_HANDLER( decocass_type4_r ) if (0 == (offset & E5XX_MASK)) { data = upi41_master_r(state->mcu, 1); - LOG(4,("%10s 6502-PC: %04x decocass_type4_r(%02x): $%02x <- 8041 STATUS\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_type4_r(%02x): $%02x <- 8041 STATUS\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } else { data = 0xff; /* open data bus? */ - LOG(4,("%10s 6502-PC: %04x decocass_type4_r(%02x): $%02x <- open bus\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_type4_r(%02x): $%02x <- open bus\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } } else @@ -1012,7 +1012,7 @@ static READ8_HANDLER( decocass_type4_r ) UINT8 *prom = space->machine->region("dongle")->base(); data = prom[state->type4_ctrs]; - LOG(3,("%10s 6502-PC: %04x decocass_type4_r(%02x): $%02x '%c' <- PROM[%04x]\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.', state->type4_ctrs)); + LOG(3,("%10s 6502-PC: %04x decocass_type4_r(%02x): $%02x '%c' <- PROM[%04x]\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.', state->type4_ctrs)); state->type4_ctrs = (state->type4_ctrs + 1) & 0x7fff; } else @@ -1020,12 +1020,12 @@ static READ8_HANDLER( decocass_type4_r ) if (0 == (offset & E5XX_MASK)) { data = upi41_master_r(state->mcu, 0); - LOG(3,("%10s 6502-PC: %04x decocass_type4_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); + LOG(3,("%10s 6502-PC: %04x decocass_type4_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); } else { data = 0xff; /* open data bus? */ - LOG(4,("%10s 6502-PC: %04x decocass_type4_r(%02x): $%02x <- open bus\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_type4_r(%02x): $%02x <- open bus\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } } } @@ -1041,7 +1041,7 @@ static WRITE8_HANDLER( decocass_type4_w ) if (1 == state->type4_latch) { state->type4_ctrs = (state->type4_ctrs & 0x00ff) | ((data & 0x7f) << 8); - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> CTRS MSB (%04x)\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, state->type4_ctrs)); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> CTRS MSB (%04x)\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, state->type4_ctrs)); return; } else @@ -1055,11 +1055,11 @@ static WRITE8_HANDLER( decocass_type4_w ) if (state->type4_latch) { state->type4_ctrs = (state->type4_ctrs & 0xff00) | data; - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> CTRS LSB (%04x)\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, state->type4_ctrs)); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> CTRS LSB (%04x)\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, state->type4_ctrs)); return; } } - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA")); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA")); upi41_master_w(state->mcu, offset, data); } @@ -1082,12 +1082,12 @@ static READ8_HANDLER( decocass_type5_r ) if (0 == (offset & E5XX_MASK)) { data = upi41_master_r(state->mcu, 1); - LOG(4,("%10s 6502-PC: %04x decocass_type5_r(%02x): $%02x <- 8041 STATUS\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_type5_r(%02x): $%02x <- 8041 STATUS\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } else { data = 0xff; /* open data bus? */ - LOG(4,("%10s 6502-PC: %04x decocass_type5_r(%02x): $%02x <- open bus\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_type5_r(%02x): $%02x <- open bus\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } } else @@ -1095,19 +1095,19 @@ static READ8_HANDLER( decocass_type5_r ) if (state->type5_latch) { data = 0x55; /* Only a fixed value? It looks like this is all we need to do */ - LOG(3,("%10s 6502-PC: %04x decocass_type5_r(%02x): $%02x '%c' <- fixed value???\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); + LOG(3,("%10s 6502-PC: %04x decocass_type5_r(%02x): $%02x '%c' <- fixed value???\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); } else { if (0 == (offset & E5XX_MASK)) { data = upi41_master_r(state->mcu, 0); - LOG(3,("%10s 6502-PC: %04x decocass_type5_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); + LOG(3,("%10s 6502-PC: %04x decocass_type5_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); } else { data = 0xff; /* open data bus? */ - LOG(4,("%10s 6502-PC: %04x decocass_type5_r(%02x): $%02x <- open bus\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_type5_r(%02x): $%02x <- open bus\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } } } @@ -1122,7 +1122,7 @@ static WRITE8_HANDLER( decocass_type5_w ) { if (1 == state->type5_latch) { - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, "latch #2??")); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, "latch #2??")); return; } else @@ -1134,11 +1134,11 @@ static WRITE8_HANDLER( decocass_type5_w ) if (state->type5_latch) { /* write nowhere?? */ - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, "nowhere?")); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, "nowhere?")); return; } } - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA")); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA")); upi41_master_w(state->mcu, offset, data); } @@ -1160,12 +1160,12 @@ static READ8_HANDLER( decocass_nodong_r ) if (0 == (offset & E5XX_MASK)) { data = upi41_master_r(state->mcu, 1); - LOG(4,("%10s 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- 8041 STATUS\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- 8041 STATUS\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } else { data = 0xff; /* open data bus? */ - LOG(4,("%10s 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- open bus\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- open bus\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } } else @@ -1173,12 +1173,12 @@ static READ8_HANDLER( decocass_nodong_r ) if (0 == (offset & E5XX_MASK)) { data = upi41_master_r(state->mcu, 0); - LOG(3,("%10s 6502-PC: %04x decocass_nodong_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); + LOG(3,("%10s 6502-PC: %04x decocass_nodong_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, (data >= 32) ? data : '.')); } else { data = 0xff; /* open data bus? */ - LOG(4,("%10s 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- open bus\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(4,("%10s 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- open bus\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } } @@ -1212,7 +1212,7 @@ READ8_HANDLER( decocass_e5xx_r ) (!tape_is_present(state->cassette) << 7); /* D7 = cassette present */ LOG(4,("%10s 6502-PC: %04x decocass_e5xx_r(%02x): $%02x <- STATUS (%s%s%s%s%s%s%s%s)\n", - attotime_string(timer_get_time(space->machine), 6), + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, data & 0x01 ? "" : "REQ/", @@ -1245,7 +1245,7 @@ WRITE8_HANDLER( decocass_e5xx_w ) if (0 == (offset & E5XX_MASK)) { - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA")); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA")); upi41_master_w(state->mcu, offset & 1, data); #ifdef MAME_DEBUG decocass_fno(space->machine, offset, data); @@ -1253,7 +1253,7 @@ WRITE8_HANDLER( decocass_e5xx_w ) } else { - LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> dongle\n", attotime_string(timer_get_time(space->machine), 6), cpu_get_previouspc(space->cpu), offset, data)); + LOG(3,("%10s 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> dongle\n", timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), offset, data)); } } @@ -1702,7 +1702,7 @@ WRITE8_HANDLER( i8041_p1_w ) if (data != state->i8041_p1_write_latch) { LOG(4,("%10s 8041-PC: %03x i8041_p1_w: $%02x (%s%s%s%s%s%s%s%s)\n", - attotime_string(timer_get_time(space->machine), 6), + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), data, data & 0x01 ? "" : "DATA-WRT", @@ -1739,7 +1739,7 @@ READ8_HANDLER( i8041_p1_r ) if (data != state->i8041_p1_read_latch) { LOG(4,("%10s 8041-PC: %03x i8041_p1_r: $%02x (%s%s%s%s%s%s%s%s)\n", - attotime_string(timer_get_time(space->machine), 6), + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), data, data & 0x01 ? "" : "DATA-WRT", @@ -1761,7 +1761,7 @@ WRITE8_HANDLER( i8041_p2_w ) if (data != state->i8041_p2_write_latch) { LOG(4,("%10s 8041-PC: %03x i8041_p2_w: $%02x (%s%s%s%s%s%s%s%s)\n", - attotime_string(timer_get_time(space->machine), 6), + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), data, data & 0x01 ? "" : "FNO/", @@ -1787,7 +1787,7 @@ READ8_HANDLER( i8041_p2_r ) if (data != state->i8041_p2_read_latch) { LOG(4,("%10s 8041-PC: %03x i8041_p2_r: $%02x (%s%s%s%s%s%s%s%s)\n", - attotime_string(timer_get_time(space->machine), 6), + timer_get_time(space->machine).as_string(6), cpu_get_previouspc(space->cpu), data, data & 0x01 ? "" : "FNO/", diff --git a/src/mame/machine/harddriv.c b/src/mame/machine/harddriv.c index 5a38e5d80df..3d6e7abb9f6 100644 --- a/src/mame/machine/harddriv.c +++ b/src/mame/machine/harddriv.c @@ -534,7 +534,7 @@ TIMER_DEVICE_CALLBACK( hd68k_duart_callback ) state->duart_irq_state = (state->duart_read_data[0x05] & state->duart_write_data[0x05]) != 0; atarigen_update_interrupts(timer.machine); } - timer.adjust(attotime_mul(duart_clock_period(state), 65536)); + timer.adjust(duart_clock_period(state) * 65536); } @@ -562,13 +562,13 @@ READ16_HANDLER( hd68k_duart_r ) case 0x0e: /* Start-Counter Command 3 */ { int reps = (state->duart_write_data[0x06] << 8) | state->duart_write_data[0x07]; - state->duart_timer->adjust(attotime_mul(duart_clock_period(state), reps)); - logerror("DUART timer started (period=%f)\n", attotime_to_double(attotime_mul(duart_clock_period(state), reps))); + state->duart_timer->adjust(duart_clock_period(state) * reps); + logerror("DUART timer started (period=%f)\n", (duart_clock_period(state) * reps).as_double()); return 0x00ff; } case 0x0f: /* Stop-Counter Command 3 */ { - int reps = attotime_to_double(attotime_mul(state->duart_timer->time_left(), duart_clock(state))); + int reps = (state->duart_timer->time_left() * duart_clock(state)).as_double(); state->duart_timer->reset(); state->duart_read_data[0x06] = reps >> 8; state->duart_read_data[0x07] = reps & 0xff; diff --git a/src/mame/machine/irobot.c b/src/mame/machine/irobot.c index e1599f8372b..8c9700b5ea0 100644 --- a/src/mame/machine/irobot.c +++ b/src/mame/machine/irobot.c @@ -822,7 +822,7 @@ default: case 0x3f: IXOR(irmb_din(state, curop), 0); break; #if IR_TIMING if (state->irmb_running == 0) { - state->irmb_timer->adjust(attotime_mul(ATTOTIME_IN_HZ(12000000), icount)); + state->irmb_timer->adjust(attotime::from_hz(12000000) * icount); logerror("mb start "); IR_CPU_STATE(machine); } @@ -830,7 +830,7 @@ default: case 0x3f: IXOR(irmb_din(state, curop), 0); break; { logerror("mb start [busy!] "); IR_CPU_STATE(machine); - state->irmb_timer->adjust(attotime_mul(ATTOTIME_IN_NSEC(200), icount)); + state->irmb_timer->adjust(attotime::from_hz(200) * icount); } #else cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE); diff --git a/src/mame/machine/mcr68.c b/src/mame/machine/mcr68.c index 60700f38747..15a9f93ad40 100644 --- a/src/mame/machine/mcr68.c +++ b/src/mame/machine/mcr68.c @@ -267,7 +267,7 @@ INTERRUPT_GEN( mcr68_interrupt ) /* also set a timer to generate the 493 signal at a specific time before the next VBLANK */ /* the timing of this is crucial for Blasted and Tri-Sports, which check the timing of */ /* VBLANK and 493 using counter 2 */ - timer_set(device->machine, attotime_sub(ATTOTIME_IN_HZ(30), mcr68_timing_factor), NULL, 0, v493_callback); + timer_set(device->machine, attotime::from_hz(30) - mcr68_timing_factor, NULL, 0, v493_callback); } @@ -479,8 +479,8 @@ static void reload_count(int counter) count = count + 1; /* set the timer */ - total_period = attotime_make(0, attotime_to_attoseconds(period) * count); -LOG(("reload_count(%d): period = %f count = %d\n", counter, attotime_to_double(period), count)); + total_period = period * count; +LOG(("reload_count(%d): period = %f count = %d\n", counter, period.as_double(), count)); timer_adjust_oneshot(m6840_state[counter].timer, total_period, (count << 2) + counter); m6840_state[counter].timer_active = 1; } @@ -502,7 +502,7 @@ static UINT16 compute_counter(int counter) period = m6840_counter_periods[counter]; /* see how many are left */ - remaining = attotime_to_attoseconds(timer_timeleft(m6840_state[counter].timer)) / attotime_to_attoseconds(period); + remaining = timer_timeleft(m6840_state[counter].timer).as_attoseconds() / period.as_attoseconds(); /* adjust the count for dual byte mode */ if (m6840_state[counter].control & 0x04) diff --git a/src/mame/machine/megadriv.c b/src/mame/machine/megadriv.c index c692dec9456..0914c8764ff 100644 --- a/src/mame/machine/megadriv.c +++ b/src/mame/machine/megadriv.c @@ -8258,7 +8258,7 @@ static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) { genesis_scanline_counter++; // mame_printf_debug("scanline %d\n",genesis_scanline_counter); - scanline_timer->adjust(attotime_div(ATTOTIME_IN_HZ(megadriv_framerate), megadrive_total_scanlines)); + scanline_timer->adjust(attotime::from_hz(megadriv_framerate) / megadrive_total_scanlines); render_timer->adjust(ATTOTIME_IN_USEC(1)); if (genesis_scanline_counter==megadrive_irq6_scanline ) diff --git a/src/mame/machine/micro3d.c b/src/mame/machine/micro3d.c index 3c2d2d57938..dc5a6dae66b 100644 --- a/src/mame/machine/micro3d.c +++ b/src/mame/machine/micro3d.c @@ -190,7 +190,7 @@ WRITE16_HANDLER( micro3d_mc68901_w ) case 7: divisor = 200; break; } - period = attotime_mul(ATTOTIME_IN_HZ(4000000 / divisor), data); + period = attotime::from_hz(4000000 / divisor) * data; timer_adjust_periodic(state->mc68901.timer_a, period, 0, period); } @@ -594,7 +594,7 @@ WRITE32_HANDLER( micro3d_mac2_w ) /* TODO: Calculate a better estimate for timing */ if (state->mac_stat) - timer_set(space->machine, attotime_mul(ATTOTIME_IN_HZ(MAC_CLK), mac_cycles), NULL, 0, mac_done_callback); + timer_set(space->machine, attotime::from_hz(MAC_CLK) * mac_cycles, NULL, 0, mac_done_callback); state->mrab11 = mrab11; state->vtx_addr = vtx_addr; diff --git a/src/mame/machine/midwayic.c b/src/mame/machine/midwayic.c index 06dd0d1caaf..7f16e3fdf25 100644 --- a/src/mame/machine/midwayic.c +++ b/src/mame/machine/midwayic.c @@ -300,7 +300,7 @@ UINT8 midway_serial_pic2_status_r(address_space *space) /* if we're still holding the data ready bit high, do it */ if (pic.latch & 0xf00) { - if (attotime_compare(timer_get_time(space->machine), pic.latch_expire_time) > 0) + if (timer_get_time(space->machine) > pic.latch_expire_time) pic.latch &= 0xff; else pic.latch -= 0x100; @@ -347,7 +347,7 @@ void midway_serial_pic2_w(address_space *space, UINT8 data) /* store in the latch, along with a bit to indicate we have data */ pic.latch = (data & 0x00f) | 0x480; - pic.latch_expire_time = attotime_add(timer_get_time(machine), ATTOTIME_IN_MSEC(1)); + pic.latch_expire_time = timer_get_time(machine) + attotime::from_msec(1); if (data & 0x10) { int cmd = pic.state ? (pic.state & 0x0f) : (pic.latch & 0x0f); diff --git a/src/mame/machine/n64.c b/src/mame/machine/n64.c index 847164325e7..a75a4b1aa45 100644 --- a/src/mame/machine/n64.c +++ b/src/mame/machine/n64.c @@ -1124,7 +1124,7 @@ static void start_audio_dma(running_machine *machine) ai_status |= 0x40000000; // adjust the timer - period = attotime_mul(ATTOTIME_IN_HZ(DACRATE_NTSC), (ai_dacrate + 1) * (current->length / 4)); + period = attotime::from_hz(DACRATE_NTSC) * ((ai_dacrate + 1) * (current->length / 4)); timer_adjust_oneshot(audio_timer, period, 0); } @@ -1156,7 +1156,7 @@ READ32_HANDLER( n64_ai_reg_r ) } else if (ai_status & 0x40000000) { - double secs_left = attotime_to_double(attotime_sub(timer_firetime(audio_timer),timer_get_time(space->machine))); + double secs_left = (timer_firetime(audio_timer) - timer_get_time(space->machine)).as_double(); unsigned int samples_left = secs_left * DACRATE_NTSC / (ai_dacrate + 1); return samples_left * 4; } diff --git a/src/mame/machine/nb1413m3.c b/src/mame/machine/nb1413m3.c index 1d8a81e52bb..fd75d3ea24f 100644 --- a/src/mame/machine/nb1413m3.c +++ b/src/mame/machine/nb1413m3.c @@ -43,7 +43,7 @@ static int nb1413m3_outcoin_flag; #define NB1413M3_TIMER_BASE 20000000 static TIMER_CALLBACK( nb1413m3_timer_callback ) { - timer_set(machine, attotime_mul(ATTOTIME_IN_HZ(NB1413M3_TIMER_BASE), 256), NULL, 0, nb1413m3_timer_callback); + timer_set(machine, attotime::from_hz(NB1413M3_TIMER_BASE) * 256, NULL, 0, nb1413m3_timer_callback); nb1413m3_74ls193_counter++; nb1413m3_74ls193_counter &= 0x0f; diff --git a/src/mame/machine/pcshare.c b/src/mame/machine/pcshare.c index 533785cc333..4afa09354d2 100644 --- a/src/mame/machine/pcshare.c +++ b/src/mame/machine/pcshare.c @@ -31,11 +31,11 @@ #define VERBOSE_DBG 0 /* general debug messages */ #define DBG_LOG(N,M,A) \ - if(VERBOSE_DBG>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time(pc_keyb.machine)),(char*)M ); logerror A; } + if(VERBOSE_DBG>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(pc_keyb.machine).as_double(),(char*)M ); logerror A; } #define VERBOSE_JOY 0 /* JOY (joystick port) */ #define JOY_LOG(N,M,A) \ - if(VERBOSE_JOY>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time(pc_keyb.machine)),(char*)M ); logerror A; } + if(VERBOSE_JOY>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(pc_keyb.machine).as_double(),(char*)M ); logerror A; } static TIMER_CALLBACK( pc_keyb_timer ); diff --git a/src/mame/machine/psx.c b/src/mame/machine/psx.c index 4808a951da1..5478ac53000 100644 --- a/src/mame/machine/psx.c +++ b/src/mame/machine/psx.c @@ -245,7 +245,7 @@ static void dma_start_timer( psx_machine *p_psx, int n_channel, UINT32 n_ticks ) { psx_dma_channel *dma = &p_psx->channel[ n_channel ]; - timer_adjust_oneshot( dma->timer, attotime_mul(ATTOTIME_IN_HZ(33868800), n_ticks), n_channel); + timer_adjust_oneshot( dma->timer, attotime::from_hz(33868800) * n_ticks, n_channel); dma->n_ticks = n_ticks; dma->b_running = 1; } @@ -670,7 +670,7 @@ static void root_timer_adjust( psx_machine *p_psx, int n_counter ) n_duration *= root_divider( p_psx, n_counter ); - timer_adjust_oneshot( root->timer, attotime_mul(ATTOTIME_IN_HZ(33868800), n_duration), n_counter); + timer_adjust_oneshot( root->timer, attotime::from_hz(33868800) * n_duration, n_counter); } } @@ -813,8 +813,8 @@ static void sio_timer_adjust( psx_machine *p_psx, int n_port ) if( sio->n_baud != 0 && n_prescaler != 0 ) { - n_time = attotime_mul(ATTOTIME_IN_HZ(33868800), n_prescaler * sio->n_baud); - verboselog( p_psx, 2, "sio_timer_adjust( %d ) = %s ( %d x %d )\n", n_port, attotime_string(n_time, 9), n_prescaler, sio->n_baud ); + n_time = attotime::from_hz(33868800) * (n_prescaler * sio->n_baud); + verboselog( p_psx, 2, "sio_timer_adjust( %d ) = %s ( %d x %d )\n", n_port, n_time.as_string(), n_prescaler, sio->n_baud ); } else { diff --git a/src/mame/machine/slapstic.c b/src/mame/machine/slapstic.c index 42f93100438..d9a58acb40c 100644 --- a/src/mame/machine/slapstic.c +++ b/src/mame/machine/slapstic.c @@ -1145,7 +1145,7 @@ static void slapstic_log(running_machine *machine, offs_t offset) { attotime time = timer_get_time(machine); - if (attotime_compare(attotime_sub(time, last_time), ATTOTIME_IN_SEC(1)) > 0) + if ((time - last_time) > attotime::from_seconds(1)) fprintf(slapsticlog, "------------------------------------\n"); last_time = time; diff --git a/src/mame/machine/slikshot.c b/src/mame/machine/slikshot.c index 9a45d14db83..4f7b5913584 100644 --- a/src/mame/machine/slikshot.c +++ b/src/mame/machine/slikshot.c @@ -415,7 +415,7 @@ static void compute_sensors(running_machine *machine) inters_to_words(inter1, inter2, inter3, &beams, &word1, &word2, &word3); words_to_sensors(word1, word2, word3, beams, &sensor0, &sensor1, &sensor2, &sensor3); - logerror("%15f: Sensor values: %04x %04x %04x %04x\n", attotime_to_double(timer_get_time(machine)), sensor0, sensor1, sensor2, sensor3); + logerror("%15f: Sensor values: %04x %04x %04x %04x\n", timer_get_time(machine).as_double(), sensor0, sensor1, sensor2, sensor3); } diff --git a/src/mame/machine/starwars.c b/src/mame/machine/starwars.c index d49bda21bcb..d8fccad1771 100644 --- a/src/mame/machine/starwars.c +++ b/src/mame/machine/starwars.c @@ -360,7 +360,7 @@ static void run_mproc(running_machine *machine) M_STOP--; /* Decrease count */ } - timer_adjust_oneshot(state->math_timer, attotime_mul(ATTOTIME_IN_HZ(MASTER_CLOCK), mptime), 1); + timer_adjust_oneshot(state->math_timer, attotime::from_hz(MASTER_CLOCK) * mptime, 1); } diff --git a/src/mame/machine/vertigo.c b/src/mame/machine/vertigo.c index 9bc76f2c07c..ee23bd245f5 100644 --- a/src/mame/machine/vertigo.c +++ b/src/mame/machine/vertigo.c @@ -95,7 +95,7 @@ static void update_irq_encoder(running_machine *machine, int line, int state) static WRITE_LINE_DEVICE_HANDLER( v_irq4_w ) { update_irq_encoder(device->machine, INPUT_LINE_IRQ4, state); - vertigo_vproc(device->machine->device<cpu_device>("maincpu")->attotime_to_cycles(attotime_sub(timer_get_time(device->machine), irq4_time)), state); + vertigo_vproc(device->machine->device<cpu_device>("maincpu")->attotime_to_cycles(timer_get_time(device->machine) - irq4_time), state); irq4_time = timer_get_time(device->machine); } diff --git a/src/mame/video/artmagic.c b/src/mame/video/artmagic.c index 7c5e40b3a8a..65ad26c5117 100644 --- a/src/mame/video/artmagic.c +++ b/src/mame/video/artmagic.c @@ -308,7 +308,7 @@ static void execute_blit(running_machine *machine) g_profiler.stop(); #if (!INSTANT_BLIT) - blitter_busy_until = attotime_add(timer_get_time(machine), ATTOTIME_IN_NSEC(w*h*20)); + blitter_busy_until = timer_get_time(machine) + attotime::from_nsec(w*h*20); #endif } @@ -322,7 +322,7 @@ READ16_HANDLER( artmagic_blitter_r ) */ UINT16 result = 0xffef | (blitter_page << 4); #if (!INSTANT_BLIT) - if (attotime_compare(timer_get_time(space->machine), blitter_busy_until) < 0) + if (timer_get_time(space->machine) < blitter_busy_until) result ^= 6; #endif return result; diff --git a/src/mame/video/atari.c b/src/mame/video/atari.c index cd820fd671e..6f394cca1be 100644 --- a/src/mame/video/atari.c +++ b/src/mame/video/atari.c @@ -1053,9 +1053,9 @@ static int cycle(running_machine *machine) static void after(running_machine *machine, int cycles, timer_fired_func function, const char *funcname) { - attotime duration = attotime_make(0, attotime_to_attoseconds(machine->primary_screen->scan_period()) * cycles / CYCLES_PER_LINE); + attotime duration = machine->primary_screen->scan_period() * cycles / CYCLES_PER_LINE; (void)funcname; - LOG((" after %3d (%5.1f us) %s\n", cycles, attotime_to_double(duration) * 1.0e6, funcname)); + LOG((" after %3d (%5.1f us) %s\n", cycles, duration.as_double() * 1.0e6, funcname)); timer_set(machine, duration, NULL, 0, function); } diff --git a/src/mame/video/avgdvg.c b/src/mame/video/avgdvg.c index 3e35baab333..2d0dfc0340f 100644 --- a/src/mame/video/avgdvg.c +++ b/src/mame/video/avgdvg.c @@ -1223,13 +1223,13 @@ static TIMER_CALLBACK( run_state_machine ) /* If halt flag was set, let CPU catch up before we make halt visible */ if (vg->halt && !(vg->state_latch & 0x10)) - timer_adjust_oneshot(vg_halt_timer, attotime_mul(ATTOTIME_IN_HZ(MASTER_CLOCK), cycles), 1); + timer_adjust_oneshot(vg_halt_timer, attotime::from_hz(MASTER_CLOCK) * cycles, 1); vg->state_latch = (vg->halt << 4) | (vg->state_latch & 0xf); cycles += 8; } - timer_adjust_oneshot(vg_run_timer, attotime_mul(ATTOTIME_IN_HZ(MASTER_CLOCK), cycles), 0); + timer_adjust_oneshot(vg_run_timer, attotime::from_hz(MASTER_CLOCK) * cycles, 0); } diff --git a/src/mame/video/cchasm.c b/src/mame/video/cchasm.c index 1b1398931f0..ec43282e318 100644 --- a/src/mame/video/cchasm.c +++ b/src/mame/video/cchasm.c @@ -100,7 +100,7 @@ static void cchasm_refresh (running_machine *machine) } } /* Refresh processor runs with 6 MHz */ - timer_set (machine, attotime_mul(ATTOTIME_IN_HZ(6000000), total_length), NULL, 0, cchasm_refresh_end); + timer_set (machine, attotime::from_hz(6000000) * total_length, NULL, 0, cchasm_refresh_end); } diff --git a/src/mame/video/dcheese.c b/src/mame/video/dcheese.c index b9583a39523..e13c41c9c4d 100644 --- a/src/mame/video/dcheese.c +++ b/src/mame/video/dcheese.c @@ -64,8 +64,8 @@ static void update_scanline_irq( running_machine *machine ) /* determine the time; if it's in this scanline, bump to the next frame */ time = machine->primary_screen->time_until_pos(effscan); - if (attotime_compare(time, machine->primary_screen->scan_period()) < 0) - time = attotime_add(time, machine->primary_screen->frame_period()); + if (time < machine->primary_screen->scan_period()) + time += machine->primary_screen->frame_period(); timer_adjust_oneshot(state->blitter_timer, time, 0); } } @@ -206,7 +206,7 @@ static void do_blit( running_machine *machine ) } /* signal an IRQ when done (timing is just a guess) */ - timer_set(machine, attotime_make(0, attotime_to_attoseconds(machine->primary_screen->scan_period()) / 2), NULL, 2, dcheese_signal_irq_callback); + timer_set(machine, machine->primary_screen->scan_period() / 2, NULL, 2, dcheese_signal_irq_callback); /* these extra parameters are written but they are always zero, so I don't know what they do */ if (state->blitter_xparam[8] != 0 || state->blitter_xparam[9] != 0 || state->blitter_xparam[10] != 0 || state->blitter_xparam[11] != 0 || diff --git a/src/mame/video/exidy440.c b/src/mame/video/exidy440.c index 5d95e07ac01..6baaaf13339 100644 --- a/src/mame/video/exidy440.c +++ b/src/mame/video/exidy440.c @@ -454,12 +454,12 @@ static VIDEO_UPDATE( exidy440 ) From this, it appears that they are expecting to get beams over a 12 scanline period, and trying to pick roughly the middle one. This is how it is implemented. */ - attoseconds_t increment = attotime_to_attoseconds(screen->scan_period()); - attotime time = attotime_sub(screen->time_until_pos(beamy, beamx), attotime_make(0, increment * 6)); + attotime increment = screen->scan_period(); + attotime time = screen->time_until_pos(beamy, beamx) - increment * 6; for (i = 0; i <= 12; i++) { timer_set(screen->machine, time, NULL, beamx, beam_firq_callback); - time = attotime_add(time, attotime_make(0, increment)); + time += increment; } } diff --git a/src/mame/video/fromance.c b/src/mame/video/fromance.c index bf69e78f9d3..726e1b8e3bc 100644 --- a/src/mame/video/fromance.c +++ b/src/mame/video/fromance.c @@ -266,7 +266,7 @@ static TIMER_CALLBACK( crtc_interrupt_gen ) fromance_state *state = machine->driver_data<fromance_state>(); cpu_set_input_line(state->subcpu, 0, HOLD_LINE); if (param != 0) - timer_adjust_periodic(state->crtc_timer, attotime_div(machine->primary_screen->frame_period(), param), 0, attotime_div(machine->primary_screen->frame_period(), param)); + timer_adjust_periodic(state->crtc_timer, machine->primary_screen->frame_period() / param, 0, machine->primary_screen->frame_period() / param); } diff --git a/src/mame/video/hyhoo.c b/src/mame/video/hyhoo.c index 65cfdd6c3d9..4d29b1dc94d 100644 --- a/src/mame/video/hyhoo.c +++ b/src/mame/video/hyhoo.c @@ -228,7 +228,7 @@ static void hyhoo_gfxdraw(running_machine *machine) } nb1413m3_busyflag = 0; - timer_set(machine, attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), NULL, 0, blitter_timer_callback); + timer_set(machine, attotime::from_hz(400000) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); } diff --git a/src/mame/video/itech8.c b/src/mame/video/itech8.c index 6cb6188364a..dc2c2f21210 100644 --- a/src/mame/video/itech8.c +++ b/src/mame/video/itech8.c @@ -523,7 +523,7 @@ WRITE8_HANDLER( itech8_blitter_w ) blit_in_progress = 1; /* set a timer to go off when we're done */ - timer_set(space->machine, attotime_mul(ATTOTIME_IN_HZ(12000000/4), BLITTER_WIDTH * BLITTER_HEIGHT + 12), NULL, 0, blitter_done); + timer_set(space->machine, attotime::from_hz(12000000/4) * (BLITTER_WIDTH * BLITTER_HEIGHT + 12), NULL, 0, blitter_done); } /* debugging */ diff --git a/src/mame/video/lethalj.c b/src/mame/video/lethalj.c index c3f23054cb6..a0bdddf8365 100644 --- a/src/mame/video/lethalj.c +++ b/src/mame/video/lethalj.c @@ -165,7 +165,7 @@ WRITE16_HANDLER( lethalj_blitter_w ) else do_blit(); - timer_set(space->machine, attotime_mul(ATTOTIME_IN_HZ(XTAL_32MHz), (blitter_data[5] + 1) * (blitter_data[7] + 1)), NULL, 0, gen_ext1_int); + timer_set(space->machine, attotime::from_hz(XTAL_32MHz) * ((blitter_data[5] + 1) * (blitter_data[7] + 1)), NULL, 0, gen_ext1_int); } /* clear the IRQ on offset 0 */ diff --git a/src/mame/video/lockon.c b/src/mame/video/lockon.c index 291b1a5d75b..d3af2eaca8c 100644 --- a/src/mame/video/lockon.c +++ b/src/mame/video/lockon.c @@ -388,7 +388,7 @@ static void ground_draw( running_machine *machine ) /* End of list marker */ if (state->ground_ram[offs + 2] & 0x8000) { - timer_adjust_oneshot(state->bufend_timer, attotime_mul(ATTOTIME_IN_HZ(FRAMEBUFFER_CLOCK), FRAMEBUFFER_MAX_X * y), 0); + timer_adjust_oneshot(state->bufend_timer, attotime::from_hz(FRAMEBUFFER_CLOCK) * (FRAMEBUFFER_MAX_X * y), 0); } } } diff --git a/src/mame/video/m92.c b/src/mame/video/m92.c index 7d3bd7b87d6..cca3ef25a01 100644 --- a/src/mame/video/m92.c +++ b/src/mame/video/m92.c @@ -98,7 +98,7 @@ WRITE16_HANDLER( m92_spritecontrol_w ) /* Pixel clock is 26.6666 MHz, we have 0x800 bytes, or 0x400 words to copy from spriteram to the buffer. It seems safe to assume 1 word can be copied per clock.*/ - timer_set(space->machine, attotime_mul(ATTOTIME_IN_HZ(26666000), 0x400), NULL, 0, spritebuffer_callback); + timer_set(space->machine, attotime::from_hz(26666000) * 0x400, NULL, 0, spritebuffer_callback); } // logerror("%04x: m92_spritecontrol_w %08x %08x\n",cpu_get_pc(space->cpu),offset,data); } diff --git a/src/mame/video/nbmj8688.c b/src/mame/video/nbmj8688.c index 384b202d5f0..6ed21794362 100644 --- a/src/mame/video/nbmj8688.c +++ b/src/mame/video/nbmj8688.c @@ -548,9 +548,9 @@ static void mbmj8688_gfxdraw(running_machine *machine, int gfxtype) nb1413m3_busyflag = 0; if (gfxtype == GFXTYPE_8BIT) - timer_set(machine, attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), NULL, 0, blitter_timer_callback); + timer_set(machine, attotime::from_hz(400000) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); else - timer_set(machine, attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), NULL, 0, blitter_timer_callback); + timer_set(machine, attotime::from_hz(400000) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); } diff --git a/src/mame/video/nbmj8891.c b/src/mame/video/nbmj8891.c index 68b2affb179..4199e3d4966 100644 --- a/src/mame/video/nbmj8891.c +++ b/src/mame/video/nbmj8891.c @@ -486,7 +486,7 @@ static void nbmj8891_gfxdraw(running_machine *machine) } nb1413m3_busyflag = 0; - timer_set(machine, attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), NULL, 0, blitter_timer_callback); + timer_set(machine, attotime::from_hz(400000) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); } /****************************************************************************** diff --git a/src/mame/video/nbmj8900.c b/src/mame/video/nbmj8900.c index 726a12c06c7..6d1c0c22aaa 100644 --- a/src/mame/video/nbmj8900.c +++ b/src/mame/video/nbmj8900.c @@ -376,7 +376,7 @@ static void nbmj8900_gfxdraw(running_machine *machine) } nb1413m3_busyflag = 0; - timer_set(machine, attotime_mul(ATTOTIME_IN_NSEC(2500), nb1413m3_busyctr), NULL, 0, blitter_timer_callback); + timer_set(machine, attotime::from_nsec(2500) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); } /****************************************************************************** diff --git a/src/mame/video/nbmj8991.c b/src/mame/video/nbmj8991.c index 085b47765d9..6354368bbda 100644 --- a/src/mame/video/nbmj8991.c +++ b/src/mame/video/nbmj8991.c @@ -294,7 +294,7 @@ static void nbmj8991_gfxdraw(running_machine *machine) } nb1413m3_busyflag = 0; - timer_set(machine, attotime_mul(ATTOTIME_IN_NSEC(1650), nb1413m3_busyctr), NULL, 0, blitter_timer_callback); + timer_set(machine, attotime::from_nsec(1650) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); } /****************************************************************************** diff --git a/src/mame/video/pastelg.c b/src/mame/video/pastelg.c index 0c3f47eb5d7..43441a1a71a 100644 --- a/src/mame/video/pastelg.c +++ b/src/mame/video/pastelg.c @@ -286,7 +286,7 @@ static void pastelg_gfxdraw(running_machine *machine) } nb1413m3_busyflag = 0; - timer_set(machine, attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), NULL, 0, blitter_timer_callback); + timer_set(machine, attotime::from_hz(400000) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); } /****************************************************************************** diff --git a/src/mame/video/rpunch.c b/src/mame/video/rpunch.c index 9a5e8fb9112..66c09ad5e20 100644 --- a/src/mame/video/rpunch.c +++ b/src/mame/video/rpunch.c @@ -83,7 +83,7 @@ static TIMER_CALLBACK( crtc_interrupt_gen ) { cputag_set_input_line(machine, "maincpu", 1, HOLD_LINE); if (param != 0) - timer_adjust_periodic(crtc_timer, attotime_div(machine->primary_screen->frame_period(), param), 0, attotime_div(machine->primary_screen->frame_period(), param)); + timer_adjust_periodic(crtc_timer, machine->primary_screen->frame_period() / param, 0, machine->primary_screen->frame_period() / param); } diff --git a/src/mame/video/tubep.c b/src/mame/video/tubep.c index 654c128f855..f010e70a80f 100644 --- a/src/mame/video/tubep.c +++ b/src/mame/video/tubep.c @@ -590,7 +590,7 @@ WRITE8_HANDLER( tubep_sprite_control_w ) cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE); /* 2.assert /SINT again after this time */ - timer_set( space->machine, attotime_mul(ATTOTIME_IN_HZ(19968000/8), (XSize+1)*(YSize+1)), NULL, 0, sprite_timer_callback); + timer_set( space->machine, attotime::from_hz(19968000/8) * ((XSize+1)*(YSize+1)), NULL, 0, sprite_timer_callback); /* 3.clear of /SINT starts sprite drawing circuit */ draw_sprite(space->machine); diff --git a/src/mame/video/twin16.c b/src/mame/video/twin16.c index d3523b65c65..63c2e9f8863 100644 --- a/src/mame/video/twin16.c +++ b/src/mame/video/twin16.c @@ -156,7 +156,7 @@ static int twin16_set_sprite_timer( running_machine *machine ) // sprite system busy, maybe a dma? time is guessed, assume 4 scanlines twin16_sprite_busy = 1; - timer_adjust_oneshot(twin16_sprite_timer, attotime_make(0,machine->primary_screen->frame_period().attoseconds / machine->primary_screen->height() * 4), 0); + timer_adjust_oneshot(twin16_sprite_timer, machine->primary_screen->frame_period() / machine->primary_screen->height() * 4, 0); return 0; } diff --git a/src/mame/video/victory.c b/src/mame/video/victory.c index 11e34b50f8e..5c2682efc1b 100644 --- a/src/mame/video/victory.c +++ b/src/mame/video/victory.c @@ -192,7 +192,7 @@ READ8_HANDLER( victory_video_control_r ) // D5 = 5VIRQ // D4 = 5BCIRQ (3B1) // D3 = SL256 - if (micro.timer_active && attotime_compare(timer_timeelapsed(micro.timer), micro.endtime) < 0) + if (micro.timer_active && timer_timeelapsed(micro.timer) < micro.endtime) result |= 0x80; result |= (~fgcoll & 1) << 6; result |= (~vblank_irq & 1) << 5; @@ -526,7 +526,7 @@ Registers: INLINE void count_states(int states) { - attotime state_time = attotime_make(0, attotime_to_attoseconds(MICRO_STATE_CLOCK_PERIOD) * states); + attotime state_time = MICRO_STATE_CLOCK_PERIOD * states; if (!micro.timer) { @@ -534,14 +534,14 @@ INLINE void count_states(int states) micro.timer_active = 1; micro.endtime = state_time; } - else if (attotime_compare(timer_timeelapsed(micro.timer), micro.endtime) > 0) + else if (timer_timeelapsed(micro.timer) > micro.endtime) { timer_adjust_oneshot(micro.timer, attotime_never, 0); micro.timer_active = 1; micro.endtime = state_time; } else - micro.endtime = attotime_add(micro.endtime, state_time); + micro.endtime += state_time; } diff --git a/src/osd/osdmini/minimain.c b/src/osd/osdmini/minimain.c index 326d18f21fb..cae5662072d 100644 --- a/src/osd/osdmini/minimain.c +++ b/src/osd/osdmini/minimain.c @@ -179,7 +179,7 @@ void mini_osd_interface::update(bool skip_redraw) primlist.release_lock(); // after 5 seconds, exit - if (attotime_compare(timer_get_time(&machine()), attotime_make(5, 0)) > 0) + if (timer_get_time(&machine()) > attotime::from_seconds(5)) machine().schedule_exit(); } |