diff options
author | 2011-02-03 07:52:45 +0000 | |
---|---|---|
committer | 2011-02-03 07:52:45 +0000 | |
commit | 1e88333178b63ee0d5b914e181b19b3b161f807b (patch) | |
tree | ff1d59069ab151d3ea122c8a26931305157f9d17 /src/emu/sound | |
parent | 78005b8ffeaf34d10565466d794debf7f5d2ff73 (diff) |
Converted attotime to a class, with proper operators. Removed old
global functions which are now superceded by the operators and
methods on the class. [Aaron Giles]
Required mappings are:
attotime_make(a,b) => attotime(a,b)
attotime_to_double(t) => t.as_double()
double_to_attotime(d) => attotime::from_double(d)
attotime_to_attoseconds(t) => t.as_attoseconds()
attotime_to_ticks(t,f) => t.as_ticks(f)
ticks_to_attotime(t,f) => attotime::from_ticks(t,f)
attotime_add(a,b) => a + b
attotime_add_attoseconds(a,b) => a + attotime(0, b)
attotime_sub(a,b) => a - b
attotime_sub_attoseconds(a,b) => a - attotime(0, b)
attotime_compare(a,b) == 0 => a == b
attotime_compare(a,b) != 0 => a != b
attotime_compare(a,b) < 0 => a < b
attotime_compare(a,b) <= 0 => a <= b
attotime_compare(a,b) > 0 => a > b
attotime_compare(a,b) >= 0 => a >= b
attotime_mul(a,f) => a * f
attotime_div(a,f) => a / f
attotime_min(a,b) => min(a,b)
attotime_max(a,b) => max(a,b)
attotime_is_never(t) => t.is_never()
attotime_string(t,p) => t.as_string(p)
In addition, some existing #defines still exist but will go away:
attotime_zero => attotime::zero
attotime_never => attotime::never
ATTOTIME_IN_SEC(s) => attotime::from_seconds(s)
ATTOTIME_IN_MSEC(m) => attotime::from_msec(m)
ATTOTIME_IN_USEC(u) => attotime::from_usec(u)
ATTOTIME_IN_NSEC(n) => attotime::from_nsec(n)
ATTOTIME_IN_HZ(h) => attotime::from_hz(h)
Diffstat (limited to 'src/emu/sound')
-rw-r--r-- | src/emu/sound/2203intf.c | 2 | ||||
-rw-r--r-- | src/emu/sound/2608intf.c | 2 | ||||
-rw-r--r-- | src/emu/sound/2610intf.c | 2 | ||||
-rw-r--r-- | src/emu/sound/2612intf.c | 2 | ||||
-rw-r--r-- | src/emu/sound/262intf.c | 2 | ||||
-rw-r--r-- | src/emu/sound/3526intf.c | 2 | ||||
-rw-r--r-- | src/emu/sound/3812intf.c | 2 | ||||
-rw-r--r-- | src/emu/sound/8950intf.c | 2 | ||||
-rw-r--r-- | src/emu/sound/es5503.c | 2 | ||||
-rw-r--r-- | src/emu/sound/fm.h | 6 | ||||
-rw-r--r-- | src/emu/sound/fmopl.c | 8 | ||||
-rw-r--r-- | src/emu/sound/k053260.c | 2 | ||||
-rw-r--r-- | src/emu/sound/k056800.c | 2 | ||||
-rw-r--r-- | src/emu/sound/mos6560.c | 6 | ||||
-rw-r--r-- | src/emu/sound/msm5205.c | 4 | ||||
-rw-r--r-- | src/emu/sound/pokey.c | 28 | ||||
-rw-r--r-- | src/emu/sound/sp0250.c | 2 | ||||
-rw-r--r-- | src/emu/sound/speaker.c | 27 | ||||
-rw-r--r-- | src/emu/sound/upd7759.c | 2 | ||||
-rw-r--r-- | src/emu/sound/ym2151.c | 10 | ||||
-rw-r--r-- | src/emu/sound/ymf262.c | 8 | ||||
-rw-r--r-- | src/emu/sound/ymf271.c | 4 | ||||
-rw-r--r-- | src/emu/sound/ymf278b.c | 4 |
23 files changed, 65 insertions, 66 deletions
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); } |