diff options
Diffstat (limited to 'src/emu/attotime.c')
-rw-r--r-- | src/emu/attotime.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/emu/attotime.c b/src/emu/attotime.c index 7eec042e8dd..7f7b2005b94 100644 --- a/src/emu/attotime.c +++ b/src/emu/attotime.c @@ -20,8 +20,6 @@ const attotime attotime::zero(0, 0); const attotime attotime::never(ATTOTIME_MAX_SECONDS, 0); - - //************************************************************************** // CORE MATH FUNCTIONS //************************************************************************** @@ -34,7 +32,7 @@ const attotime attotime::never(ATTOTIME_MAX_SECONDS, 0); attotime &attotime::operator*=(UINT32 factor) { // if one of the items is attotime::never, return attotime::never - if (seconds >= ATTOTIME_MAX_SECONDS) + if (m_seconds >= ATTOTIME_MAX_SECONDS) return *this = never; // 0 times anything is zero @@ -43,7 +41,7 @@ attotime &attotime::operator*=(UINT32 factor) // 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); + UINT32 attohi = divu_64x32_rem(m_attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo); // scale the lower half, then split into high/low parts UINT64 temp = mulu_32x32(attolo, factor); @@ -56,13 +54,13 @@ attotime &attotime::operator*=(UINT32 factor) temp = divu_64x32_rem(temp, ATTOSECONDS_PER_SECOND_SQRT, &reshi); // scale the seconds - temp += mulu_32x32(seconds, factor); + temp += mulu_32x32(m_seconds, factor); if (temp >= ATTOTIME_MAX_SECONDS) return *this = never; // build the result - seconds = temp; - attoseconds = (attoseconds_t)reslo + mul_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT); + m_seconds = temp; + m_attoseconds = (attoseconds_t)reslo + mul_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT); return *this; } @@ -74,7 +72,7 @@ attotime &attotime::operator*=(UINT32 factor) attotime &attotime::operator/=(UINT32 factor) { // if one of the items is attotime::never, return attotime::never - if (seconds >= ATTOTIME_MAX_SECONDS) + if (m_seconds >= ATTOTIME_MAX_SECONDS) return *this = never; // ignore divide by zero @@ -83,11 +81,11 @@ attotime &attotime::operator/=(UINT32 factor) // 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); + UINT32 attohi = divu_64x32_rem(m_attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo); // divide the seconds and get the remainder UINT32 remainder; - seconds = divu_64x32_rem(seconds, factor, &remainder); + m_seconds = divu_64x32_rem(m_seconds, 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); @@ -98,12 +96,12 @@ attotime &attotime::operator/=(UINT32 factor) UINT32 reslo = divu_64x32_rem(temp, factor, &remainder); // round based on the remainder - attoseconds = (attoseconds_t)reslo + mulu_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT); + m_attoseconds = (attoseconds_t)reslo + mulu_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT); if (remainder >= factor / 2) - if (++attoseconds >= ATTOSECONDS_PER_SECOND) + if (++m_attoseconds >= ATTOSECONDS_PER_SECOND) { - attoseconds = 0; - seconds++; + m_attoseconds = 0; + m_seconds++; } return *this; } @@ -126,33 +124,33 @@ const char *attotime::as_string(int precision) const // case 1: we want no precision; seconds only else if (precision == 0) - sprintf(buffer, "%d", seconds); + sprintf(buffer, "%d", m_seconds); // case 2: we want 9 or fewer digits of precision else if (precision <= 9) { - UINT32 upper = attoseconds / ATTOSECONDS_PER_SECOND_SQRT; + UINT32 upper = m_attoseconds / ATTOSECONDS_PER_SECOND_SQRT; int temp = precision; while (temp < 9) { upper /= 10; temp++; } - sprintf(buffer, "%d.%0*d", seconds, precision, upper); + sprintf(buffer, "%d.%0*d", m_seconds, precision, upper); } // case 3: more than 9 digits of precision else { UINT32 lower; - UINT32 upper = divu_64x32_rem(attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &lower); + UINT32 upper = divu_64x32_rem(m_attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &lower); int temp = precision; while (temp < 18) { lower /= 10; temp++; } - sprintf(buffer, "%d.%09d%0*d", seconds, upper, precision - 9, lower); + sprintf(buffer, "%d.%09d%0*d", m_seconds, upper, precision - 9, lower); } return buffer; } |