diff options
448 files changed, 2003 insertions, 2274 deletions
diff --git a/src/emu/audio/generic.c b/src/emu/audio/generic.c index 0fc16ba9c79..fc2919d9e54 100644 --- a/src/emu/audio/generic.c +++ b/src/emu/audio/generic.c @@ -87,7 +87,7 @@ static TIMER_CALLBACK( latch_callback ) INLINE void latch_w(address_space *space, int which, UINT16 value) { - timer_call_after_resynch(space->machine, NULL, which | (value << 8), latch_callback); + space->machine->scheduler().synchronize(FUNC(latch_callback), which | (value << 8)); } diff --git a/src/emu/cpu/cop400/cop400.c b/src/emu/cpu/cop400/cop400.c index 2064ab73865..8feb6f5d9cc 100644 --- a/src/emu/cpu/cop400/cop400.c +++ b/src/emu/cpu/cop400/cop400.c @@ -886,14 +886,14 @@ static void cop400_init(legacy_cpu_device *device, UINT8 g_mask, UINT8 d_mask, U /* allocate serial timer */ - cpustate->serial_timer = timer_alloc(device->machine, serial_tick, cpustate); + cpustate->serial_timer = device->machine->scheduler().timer_alloc(FUNC(serial_tick), cpustate); timer_adjust_periodic(cpustate->serial_timer, attotime::zero, 0, attotime::from_hz(device->clock() / 16)); /* allocate counter timer */ if (has_counter) { - cpustate->counter_timer = timer_alloc(device->machine, counter_tick, cpustate); + cpustate->counter_timer = device->machine->scheduler().timer_alloc(FUNC(counter_tick), cpustate); timer_adjust_periodic(cpustate->counter_timer, attotime::zero, 0, attotime::from_hz(device->clock() / 16 / 4)); } @@ -901,7 +901,7 @@ static void cop400_init(legacy_cpu_device *device, UINT8 g_mask, UINT8 d_mask, U if (has_inil) { - cpustate->inil_timer = timer_alloc(device->machine, inil_tick, cpustate); + cpustate->inil_timer = device->machine->scheduler().timer_alloc(FUNC(inil_tick), cpustate); timer_adjust_periodic(cpustate->inil_timer, attotime::zero, 0, attotime::from_hz(device->clock() / 16)); } @@ -909,7 +909,7 @@ static void cop400_init(legacy_cpu_device *device, UINT8 g_mask, UINT8 d_mask, U if (cpustate->intf->microbus == COP400_MICROBUS_ENABLED) { - cpustate->microbus_timer = timer_alloc(device->machine, microbus_tick, cpustate); + cpustate->microbus_timer = device->machine->scheduler().timer_alloc(FUNC(microbus_tick), cpustate); timer_adjust_periodic(cpustate->microbus_timer, attotime::zero, 0, attotime::from_hz(device->clock() / 16)); } diff --git a/src/emu/cpu/e132xs/e132xs.c b/src/emu/cpu/e132xs/e132xs.c index c1255e115e5..64543c2ffa4 100644 --- a/src/emu/cpu/e132xs/e132xs.c +++ b/src/emu/cpu/e132xs/e132xs.c @@ -1546,7 +1546,7 @@ static void hyperstone_init(legacy_cpu_device *device, device_irq_callback irqca cpustate->program = device->space(AS_PROGRAM); cpustate->direct = &cpustate->program->direct(); cpustate->io = device->space(AS_IO); - cpustate->timer = timer_alloc(device->machine, e132xs_timer_callback, (void *)device); + cpustate->timer = device->machine->scheduler().timer_alloc(FUNC(e132xs_timer_callback), (void *)device); cpustate->clock_scale_mask = scale_mask; } diff --git a/src/emu/cpu/h83002/h8_8.c b/src/emu/cpu/h83002/h8_8.c index 467385ecb0c..9f18e077b90 100644 --- a/src/emu/cpu/h83002/h8_8.c +++ b/src/emu/cpu/h83002/h8_8.c @@ -241,10 +241,10 @@ static CPU_INIT(h8bit) h8->direct = &h8->program->direct(); h8->io = device->space(AS_IO); - h8->timer[0] = timer_alloc(h8->device->machine, h8_timer_0_cb, h8); - h8->timer[1] = timer_alloc(h8->device->machine, h8_timer_1_cb, h8); - h8->timer[2] = timer_alloc(h8->device->machine, h8_timer_2_cb, h8); - h8->timer[3] = timer_alloc(h8->device->machine, h8_timer_3_cb, h8); + h8->timer[0] = h8->device->machine->scheduler().timer_alloc(FUNC(h8_timer_0_cb), h8); + h8->timer[1] = h8->device->machine->scheduler().timer_alloc(FUNC(h8_timer_1_cb), h8); + h8->timer[2] = h8->device->machine->scheduler().timer_alloc(FUNC(h8_timer_2_cb), h8); + h8->timer[3] = h8->device->machine->scheduler().timer_alloc(FUNC(h8_timer_3_cb), h8); state_save_register_device_item(device, 0, h8->h8err); state_save_register_device_item_array(device, 0, h8->regs); diff --git a/src/emu/cpu/h83002/h8periph.c b/src/emu/cpu/h83002/h8periph.c index adabe4ed52a..b016dee3c9f 100644 --- a/src/emu/cpu/h83002/h8periph.c +++ b/src/emu/cpu/h83002/h8periph.c @@ -766,20 +766,20 @@ void h8_3007_register1_write8(h83xx_state *h8, UINT32 address, UINT8 val) void h8_3007_itu_init(h83xx_state *h8) { - h8->timer[0] = timer_alloc(h8->device->machine, h8itu_3007_timer_0_cb, h8); - h8->timer[1] = timer_alloc(h8->device->machine, h8itu_3007_timer_1_cb, h8); - h8->timer[2] = timer_alloc(h8->device->machine, h8itu_3007_timer_2_cb, h8); + h8->timer[0] = h8->device->machine->scheduler().timer_alloc(FUNC(h8itu_3007_timer_0_cb), h8); + h8->timer[1] = h8->device->machine->scheduler().timer_alloc(FUNC(h8itu_3007_timer_1_cb), h8); + h8->timer[2] = h8->device->machine->scheduler().timer_alloc(FUNC(h8itu_3007_timer_2_cb), h8); h8_itu_reset(h8); } void h8_itu_init(h83xx_state *h8) { - h8->timer[0] = timer_alloc(h8->device->machine, h8itu_timer_0_cb, h8); - h8->timer[1] = timer_alloc(h8->device->machine, h8itu_timer_1_cb, h8); - h8->timer[2] = timer_alloc(h8->device->machine, h8itu_timer_2_cb, h8); - h8->timer[3] = timer_alloc(h8->device->machine, h8itu_timer_3_cb, h8); - h8->timer[4] = timer_alloc(h8->device->machine, h8itu_timer_4_cb, h8); + h8->timer[0] = h8->device->machine->scheduler().timer_alloc(FUNC(h8itu_timer_0_cb), h8); + h8->timer[1] = h8->device->machine->scheduler().timer_alloc(FUNC(h8itu_timer_1_cb), h8); + h8->timer[2] = h8->device->machine->scheduler().timer_alloc(FUNC(h8itu_timer_2_cb), h8); + h8->timer[3] = h8->device->machine->scheduler().timer_alloc(FUNC(h8itu_timer_3_cb), h8); + h8->timer[4] = h8->device->machine->scheduler().timer_alloc(FUNC(h8itu_timer_4_cb), h8); h8_itu_reset(h8); } diff --git a/src/emu/cpu/hd61700/hd61700.c b/src/emu/cpu/hd61700/hd61700.c index ce02bcfe41a..b67b5862eee 100644 --- a/src/emu/cpu/hd61700/hd61700.c +++ b/src/emu/cpu/hd61700/hd61700.c @@ -168,7 +168,7 @@ void hd61700_cpu_device::device_start() { m_program = this->space(AS_PROGRAM); - m_sec_timer = device_timer_alloc(*this, SEC_TIMER); + m_sec_timer = timer_alloc(SEC_TIMER); timer_adjust_periodic(m_sec_timer, attotime::from_seconds(1), 0, attotime::from_seconds(1)); // save state diff --git a/src/emu/cpu/lr35902/lr35902.c b/src/emu/cpu/lr35902/lr35902.c index b484a71b76d..e6fd5464391 100644 --- a/src/emu/cpu/lr35902/lr35902.c +++ b/src/emu/cpu/lr35902/lr35902.c @@ -47,8 +47,8 @@ #define FLAG_C 0x10 #define CYCLES_PASSED(X) cpustate->w.icount -= ((X) / (cpustate->w.gb_speed)); \ - if ( cpustate->w.timer_fired_func ) { \ - cpustate->w.timer_fired_func( cpustate->w.device, X ); \ + if ( cpustate->w.timer_expired_func ) { \ + cpustate->w.timer_expired_func( cpustate->w.device, X ); \ } typedef struct { @@ -69,7 +69,7 @@ typedef struct { address_space *program; int icount; /* Timer stuff */ - lr35902_timer_fired_func timer_fired_func; + lr35902_timer_fired_func timer_expired_func; /* Fetch & execute related */ int execution_state; UINT8 op; @@ -210,7 +210,7 @@ static CPU_RESET( lr35902 ) cpustate->w.HL = 0x0000; cpustate->w.SP = 0x0000; cpustate->w.PC = 0x0000; - cpustate->w.timer_fired_func = NULL; + cpustate->w.timer_expired_func = NULL; cpustate->w.features = LR35902_FEATURE_HALT_BUG; if (cpustate->w.config) { @@ -222,7 +222,7 @@ static CPU_RESET( lr35902 ) cpustate->w.SP = cpustate->w.config->regs[4]; cpustate->w.PC = cpustate->w.config->regs[5]; } - cpustate->w.timer_fired_func = cpustate->w.config->timer_fired_func; + cpustate->w.timer_expired_func = cpustate->w.config->timer_expired_func; cpustate->w.features = cpustate->w.config->features; } cpustate->w.enable = 0; diff --git a/src/emu/cpu/lr35902/lr35902.h b/src/emu/cpu/lr35902/lr35902.h index 54f7bd4f561..54f5717de9a 100644 --- a/src/emu/cpu/lr35902/lr35902.h +++ b/src/emu/cpu/lr35902/lr35902.h @@ -11,7 +11,7 @@ struct _lr35902_cpu_core { const UINT16 *regs; UINT8 features; - lr35902_timer_fired_func timer_fired_func; + lr35902_timer_fired_func timer_expired_func; }; enum diff --git a/src/emu/cpu/m37710/m37710.c b/src/emu/cpu/m37710/m37710.c index 61cbebf990a..e29b1ea8433 100644 --- a/src/emu/cpu/m37710/m37710.c +++ b/src/emu/cpu/m37710/m37710.c @@ -906,7 +906,7 @@ static CPU_INIT( m37710 ) cpustate->destination = 0; for (i = 0; i < 8; i++) - cpustate->timers[i] = timer_alloc(device->machine, m37710_timer_cb, cpustate); + cpustate->timers[i] = device->machine->scheduler().timer_alloc(FUNC(m37710_timer_cb), cpustate); state_save_register_device_item(device, 0, cpustate->a); state_save_register_device_item(device, 0, cpustate->b); diff --git a/src/emu/cpu/m6800/m6800.c b/src/emu/cpu/m6800/m6800.c index 6fdab202fdc..bb1c5b24a0f 100644 --- a/src/emu/cpu/m6800/m6800.c +++ b/src/emu/cpu/m6800/m6800.c @@ -1201,7 +1201,7 @@ static CPU_INIT( m6801 ) cpustate->io = device->space(AS_IO); cpustate->clock = device->clock() / 4; - cpustate->sci_timer = timer_alloc(device->machine, sci_tick, cpustate); + cpustate->sci_timer = device->machine->scheduler().timer_alloc(FUNC(sci_tick), cpustate); state_register(cpustate, "m6801"); @@ -1251,7 +1251,7 @@ static CPU_INIT( m6803 ) cpustate->io = device->space(AS_IO); cpustate->clock = device->clock() / 4; - cpustate->sci_timer = timer_alloc(device->machine, sci_tick, cpustate); + cpustate->sci_timer = device->machine->scheduler().timer_alloc(FUNC(sci_tick), cpustate); state_register(cpustate, "m6803"); @@ -1309,7 +1309,7 @@ static CPU_INIT( hd63701 ) cpustate->io = device->space(AS_IO); cpustate->clock = device->clock() / 4; - cpustate->sci_timer = timer_alloc(device->machine, sci_tick, cpustate); + cpustate->sci_timer = device->machine->scheduler().timer_alloc(FUNC(sci_tick), cpustate); state_register(cpustate, "hd63701"); } diff --git a/src/emu/cpu/mb88xx/mb88xx.c b/src/emu/cpu/mb88xx/mb88xx.c index db376f27434..13656e26d8a 100644 --- a/src/emu/cpu/mb88xx/mb88xx.c +++ b/src/emu/cpu/mb88xx/mb88xx.c @@ -149,7 +149,7 @@ static CPU_INIT( mb88 ) cpustate->data = device->space(AS_DATA); cpustate->io = device->space(AS_IO); - cpustate->serial = timer_alloc(device->machine, serial_timer, (void *)device); + cpustate->serial = device->machine->scheduler().timer_alloc(FUNC(serial_timer), (void *)device); state_save_register_device_item(device, 0, cpustate->PC); state_save_register_device_item(device, 0, cpustate->PA); diff --git a/src/emu/cpu/mcs48/mcs48.c b/src/emu/cpu/mcs48/mcs48.c index a32708a1bf9..581e9bd2456 100644 --- a/src/emu/cpu/mcs48/mcs48.c +++ b/src/emu/cpu/mcs48/mcs48.c @@ -1215,7 +1215,7 @@ static TIMER_CALLBACK( master_callback ) void upi41_master_w(device_t *_device, UINT8 a0, UINT8 data) { legacy_cpu_device *device = downcast<legacy_cpu_device *>(_device); - timer_call_after_resynch(device->machine, (void *)device, (a0 << 8) | data, master_callback); + device->machine->scheduler().synchronize(FUNC(master_callback), (a0 << 8) | data, (void *)device); } diff --git a/src/emu/cpu/mips/mips3com.c b/src/emu/cpu/mips/mips3com.c index a26fbbda93d..6c6d9601113 100644 --- a/src/emu/cpu/mips/mips3com.c +++ b/src/emu/cpu/mips/mips3com.c @@ -105,7 +105,7 @@ void mips3com_init(mips3_state *mips, mips3_flavor flavor, int bigendian, legacy mips->vtlb = vtlb_alloc(device, ADDRESS_SPACE_PROGRAM, 2 * mips->tlbentries + 2, 0); /* allocate a timer for the compare interrupt */ - mips->compare_int_timer = timer_alloc(device->machine, compare_int_callback, (void *)device); + mips->compare_int_timer = device->machine->scheduler().timer_alloc(FUNC(compare_int_callback), (void *)device); /* reset the state */ mips3com_reset(mips); diff --git a/src/emu/cpu/mn10200/mn10200.c b/src/emu/cpu/mn10200/mn10200.c index 1f125ce575b..af3e1111846 100644 --- a/src/emu/cpu/mn10200/mn10200.c +++ b/src/emu/cpu/mn10200/mn10200.c @@ -295,7 +295,7 @@ static CPU_INIT(mn10200) for (tmr = 0; tmr < NUM_TIMERS_8BIT; tmr++) { - cpustate->timer_timers[tmr] = timer_alloc(device->machine, simple_timer_cb, cpustate); + cpustate->timer_timers[tmr] = device->machine->scheduler().timer_alloc(FUNC(simple_timer_cb), cpustate); timer_adjust_oneshot(cpustate->timer_timers[tmr], attotime::never, tmr); } } diff --git a/src/emu/cpu/nec/v25.c b/src/emu/cpu/nec/v25.c index bd19a4919fb..e5291fe7d8e 100644 --- a/src/emu/cpu/nec/v25.c +++ b/src/emu/cpu/nec/v25.c @@ -430,7 +430,7 @@ static void v25_init(legacy_cpu_device *device, device_irq_callback irqcallback, nec_state->config = config; for (int i = 0; i < 4; i++) - nec_state->timers[i] = timer_alloc(device->machine, v25_timer_callback, nec_state); + nec_state->timers[i] = device->machine->scheduler().timer_alloc(FUNC(v25_timer_callback), nec_state); state_save_register_device_item_array(device, 0, nec_state->ram.w); state_save_register_device_item_array(device, 0, nec_state->intp_state); diff --git a/src/emu/cpu/powerpc/ppc.c b/src/emu/cpu/powerpc/ppc.c index f06b59feb6b..7abb4a5035f 100644 --- a/src/emu/cpu/powerpc/ppc.c +++ b/src/emu/cpu/powerpc/ppc.c @@ -947,8 +947,8 @@ static CPU_INIT( ppc403 ) // !!! why is rfci here !!! ppc.optable19[51] = ppc_rfci; - ppc.spu.rx_timer = timer_alloc(device->machine, ppc403_spu_rx_callback, NULL); - ppc.spu.tx_timer = timer_alloc(device->machine, ppc403_spu_tx_callback, NULL); + ppc.spu.rx_timer = device->machine->scheduler().timer_alloc(FUNC(ppc403_spu_rx_callback)); + ppc.spu.tx_timer = device->machine->scheduler().timer_alloc(FUNC(ppc403_spu_tx_callback)); ppc.read8 = ppc403_read8; ppc.read16 = ppc403_read16; diff --git a/src/emu/cpu/powerpc/ppccom.c b/src/emu/cpu/powerpc/ppccom.c index b7d764cca18..9a9e61a4eb6 100644 --- a/src/emu/cpu/powerpc/ppccom.c +++ b/src/emu/cpu/powerpc/ppccom.c @@ -328,14 +328,14 @@ void ppccom_init(powerpc_state *ppc, powerpc_flavor flavor, UINT8 cap, int tb_di /* allocate a timer for the compare interrupt */ if ((cap & PPCCAP_OEA) && (ppc->tb_divisor)) - ppc->decrementer_int_timer = timer_alloc(device->machine, decrementer_int_callback, ppc); + ppc->decrementer_int_timer = device->machine->scheduler().timer_alloc(FUNC(decrementer_int_callback), ppc); /* and for the 4XX interrupts if needed */ if (cap & PPCCAP_4XX) { - ppc->fit_timer = timer_alloc(device->machine, ppc4xx_fit_callback, ppc); - ppc->pit_timer = timer_alloc(device->machine, ppc4xx_pit_callback, ppc); - ppc->spu.timer = timer_alloc(device->machine, ppc4xx_spu_callback, ppc); + ppc->fit_timer = device->machine->scheduler().timer_alloc(FUNC(ppc4xx_fit_callback), ppc); + ppc->pit_timer = device->machine->scheduler().timer_alloc(FUNC(ppc4xx_pit_callback), ppc); + ppc->spu.timer = device->machine->scheduler().timer_alloc(FUNC(ppc4xx_spu_callback), ppc); } /* register for save states */ diff --git a/src/emu/cpu/sc61860/sc61860.c b/src/emu/cpu/sc61860/sc61860.c index f11c54e0f18..6c51c2088c9 100644 --- a/src/emu/cpu/sc61860/sc61860.c +++ b/src/emu/cpu/sc61860/sc61860.c @@ -104,7 +104,7 @@ static CPU_INIT( sc61860 ) { sc61860_state *cpustate = get_safe_token(device); cpustate->config = (sc61860_cpu_core *) device->baseconfig().static_config(); - timer_pulse(device->machine, attotime::from_hz(500), cpustate, 0, sc61860_2ms_tick); + device->machine->scheduler().timer_pulse(attotime::from_hz(500), FUNC(sc61860_2ms_tick), 0, cpustate); cpustate->device = device; cpustate->program = device->space(AS_PROGRAM); cpustate->direct = &cpustate->program->direct(); diff --git a/src/emu/cpu/sh2/sh2comn.c b/src/emu/cpu/sh2/sh2comn.c index f89e5d13012..cf2e6126bf8 100644 --- a/src/emu/cpu/sh2/sh2comn.c +++ b/src/emu/cpu/sh2/sh2comn.c @@ -923,13 +923,13 @@ void sh2_common_init(sh2_state *sh2, legacy_cpu_device *device, device_irq_callb const sh2_cpu_core *conf = (const sh2_cpu_core *)device->baseconfig().static_config(); int i; - sh2->timer = timer_alloc(device->machine, sh2_timer_callback, sh2); + sh2->timer = device->machine->scheduler().timer_alloc(FUNC(sh2_timer_callback), sh2); timer_adjust_oneshot(sh2->timer, attotime::never, 0); - sh2->dma_current_active_timer[0] = timer_alloc(device->machine, sh2_dma_current_active_callback, sh2); + sh2->dma_current_active_timer[0] = device->machine->scheduler().timer_alloc(FUNC(sh2_dma_current_active_callback), sh2); timer_adjust_oneshot(sh2->dma_current_active_timer[0], attotime::never, 0); - sh2->dma_current_active_timer[1] = timer_alloc(device->machine, sh2_dma_current_active_callback, sh2); + sh2->dma_current_active_timer[1] = device->machine->scheduler().timer_alloc(FUNC(sh2_dma_current_active_callback), sh2); timer_adjust_oneshot(sh2->dma_current_active_timer[1], attotime::never, 0); diff --git a/src/emu/cpu/sh4/sh4comn.c b/src/emu/cpu/sh4/sh4comn.c index 7675c24d757..033fed50f33 100644 --- a/src/emu/cpu/sh4/sh4comn.c +++ b/src/emu/cpu/sh4/sh4comn.c @@ -1160,21 +1160,21 @@ void sh4_common_init(device_t *device) for (i=0; i<3; i++) { - sh4->timer[i] = timer_alloc(device->machine, sh4_timer_callback, sh4); + sh4->timer[i] = device->machine->scheduler().timer_alloc(FUNC(sh4_timer_callback), sh4); timer_adjust_oneshot(sh4->timer[i], attotime::never, i); } for (i=0; i<4; i++) { - sh4->dma_timer[i] = timer_alloc(device->machine, sh4_dmac_callback, sh4); + sh4->dma_timer[i] = device->machine->scheduler().timer_alloc(FUNC(sh4_dmac_callback), sh4); timer_adjust_oneshot(sh4->dma_timer[i], attotime::never, i); } - sh4->refresh_timer = timer_alloc(device->machine, sh4_refresh_timer_callback, sh4); + sh4->refresh_timer = device->machine->scheduler().timer_alloc(FUNC(sh4_refresh_timer_callback), sh4); timer_adjust_oneshot(sh4->refresh_timer, attotime::never, 0); sh4->refresh_timer_base = 0; - sh4->rtc_timer = timer_alloc(device->machine, sh4_rtc_timer_callback, sh4); + sh4->rtc_timer = device->machine->scheduler().timer_alloc(FUNC(sh4_rtc_timer_callback), sh4); timer_adjust_oneshot(sh4->rtc_timer, attotime::never, 0); sh4->m = auto_alloc_array(device->machine, UINT32, 16384); diff --git a/src/emu/cpu/tlcs90/tlcs90.c b/src/emu/cpu/tlcs90/tlcs90.c index 88e762984d4..c0d045dd5d4 100644 --- a/src/emu/cpu/tlcs90/tlcs90.c +++ b/src/emu/cpu/tlcs90/tlcs90.c @@ -2725,9 +2725,9 @@ static CPU_INIT( t90 ) // Timers for (i = 0; i < 4; i++) - cpustate->timer[i] = timer_alloc(device->machine, t90_timer_callback, cpustate); + cpustate->timer[i] = device->machine->scheduler().timer_alloc(FUNC(t90_timer_callback), cpustate); - cpustate->timer[4] = timer_alloc(device->machine, t90_timer4_callback, cpustate); + cpustate->timer[4] = device->machine->scheduler().timer_alloc(FUNC(t90_timer4_callback), cpustate); } static ADDRESS_MAP_START(tmp90840_mem, ADDRESS_SPACE_PROGRAM, 8) diff --git a/src/emu/cpu/tms34010/tms34010.c b/src/emu/cpu/tms34010/tms34010.c index f7047d0e886..d340bd2863e 100644 --- a/src/emu/cpu/tms34010/tms34010.c +++ b/src/emu/cpu/tms34010/tms34010.c @@ -652,7 +652,7 @@ static CPU_INIT( tms34010 ) } /* allocate a scanline timer and set it to go off at the start */ - tms->scantimer = timer_alloc(device->machine, scanline_callback, tms); + tms->scantimer = device->machine->scheduler().timer_alloc(FUNC(scanline_callback), tms); timer_adjust_oneshot(tms->scantimer, attotime::zero, 0); /* allocate the shiftreg */ @@ -1200,7 +1200,7 @@ WRITE16_HANDLER( tms34010_io_register_w ) /* NMI issued? */ if (data & 0x0100) - timer_call_after_resynch(tms->device->machine, tms, 0, internal_interrupt_callback); + tms->device->machine->scheduler().synchronize(FUNC(internal_interrupt_callback), 0, tms); break; case REG_HSTCTLL: @@ -1235,7 +1235,7 @@ WRITE16_HANDLER( tms34010_io_register_w ) /* input interrupt? (should really be state-based, but the functions don't exist!) */ if (!(oldreg & 0x0008) && (newreg & 0x0008)) - timer_call_after_resynch(tms->device->machine, tms, TMS34010_HI, internal_interrupt_callback); + tms->device->machine->scheduler().synchronize(FUNC(internal_interrupt_callback), TMS34010_HI, tms); else if ((oldreg & 0x0008) && !(newreg & 0x0008)) IOREG(tms, REG_INTPEND) &= ~TMS34010_HI; break; @@ -1351,7 +1351,7 @@ WRITE16_HANDLER( tms34020_io_register_w ) /* NMI issued? */ if (data & 0x0100) - timer_call_after_resynch(tms->device->machine, tms, 0, internal_interrupt_callback); + tms->device->machine->scheduler().synchronize(FUNC(internal_interrupt_callback), 0, tms); break; case REG020_HSTCTLL: @@ -1386,7 +1386,7 @@ WRITE16_HANDLER( tms34020_io_register_w ) /* input interrupt? (should really be state-based, but the functions don't exist!) */ if (!(oldreg & 0x0008) && (newreg & 0x0008)) - timer_call_after_resynch(tms->device->machine, tms, TMS34010_HI, internal_interrupt_callback); + tms->device->machine->scheduler().synchronize(FUNC(internal_interrupt_callback), TMS34010_HI, tms); else if ((oldreg & 0x0008) && !(newreg & 0x0008)) IOREG(tms, REG020_INTPEND) &= ~TMS34010_HI; break; diff --git a/src/emu/cpu/tms9900/99xxcore.h b/src/emu/cpu/tms9900/99xxcore.h index 5cf4a00a169..6925f65c3aa 100644 --- a/src/emu/cpu/tms9900/99xxcore.h +++ b/src/emu/cpu/tms9900/99xxcore.h @@ -1298,7 +1298,7 @@ static CPU_INIT( tms99xx ) cpustate->io = device->space(AS_IO); #if (TMS99XX_MODEL == TMS9995_ID) - cpustate->timer = timer_alloc(device->machine, decrementer_callback, cpustate); + cpustate->timer = device->machine->scheduler().timer_alloc(FUNC(decrementer_callback), cpustate); #endif cpustate->idle_callback = param ? param->idle_callback : NULL; diff --git a/src/emu/cpu/z8/z8.c b/src/emu/cpu/z8/z8.c index 42ff8fd9dea..9f562c7462f 100644 --- a/src/emu/cpu/z8/z8.c +++ b/src/emu/cpu/z8/z8.c @@ -669,8 +669,8 @@ static CPU_INIT( z8 ) cpustate->io = device->space(AS_IO); /* allocate timers */ - cpustate->t0_timer = timer_alloc(device->machine, t0_tick, cpustate); - cpustate->t1_timer = timer_alloc(device->machine, t1_tick, cpustate); + cpustate->t0_timer = device->machine->scheduler().timer_alloc(FUNC(t0_tick), cpustate); + cpustate->t1_timer = device->machine->scheduler().timer_alloc(FUNC(t1_tick), cpustate); /* register for state saving */ state_save_register_device_item(device, 0, cpustate->pc); diff --git a/src/emu/devcpu.h b/src/emu/devcpu.h index b3e8412b65b..f4926dee28c 100644 --- a/src/emu/devcpu.h +++ b/src/emu/devcpu.h @@ -46,6 +46,8 @@ #ifndef __DEVCPU_H__ #define __DEVCPU_H__ +#include "devlegcy.h" + //************************************************************************** // CONSTANTS diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index 9f3d96e50da..bbf84ea0052 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -672,6 +672,28 @@ UINT64 device_t::attotime_to_clocks(attotime duration) const //------------------------------------------------- +// timer_alloc - allocate a timer for our device +// callback +//------------------------------------------------- + +emu_timer *device_t::timer_alloc(device_timer_id id, void *ptr) +{ + return m_machine.scheduler().timer_alloc(*this, id, ptr); +} + + +//------------------------------------------------- +// timer_set - set a temporary timer that will +// call our device callback +//------------------------------------------------- + +void device_t::timer_set(attotime duration, device_timer_id id, int param, void *ptr) +{ + m_machine.scheduler().timer_set(duration, *this, id, param, ptr); +} + + +//------------------------------------------------- // find_interfaces - locate fast interfaces //------------------------------------------------- diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index 986bbc8b2bf..0640da122de 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -430,7 +430,12 @@ public: void set_clock_scale(double clockscale); attotime clocks_to_attotime(UINT64 clocks) const; UINT64 attotime_to_clocks(attotime duration) const; - void timer_fired(emu_timer &timer, device_timer_id id, int param, void *ptr) { device_timer(timer, id, param, ptr); } + + // timer interfaces + emu_timer *timer_alloc(device_timer_id id = 0, void *ptr = NULL); + void timer_set(attotime duration, device_timer_id id = 0, int param = 0, void *ptr = NULL); + void synchronize(device_timer_id id = 0, int param = 0, void *ptr = NULL) { timer_set(attotime::zero, id, param, ptr); } + void timer_expired(emu_timer &timer, device_timer_id id, int param, void *ptr) { device_timer(timer, id, param, ptr); } // debugging device_debug *debug() const { return m_debug; } diff --git a/src/emu/diexec.c b/src/emu/diexec.c index 3d78cfc9d3d..872e39ed452 100644 --- a/src/emu/diexec.c +++ b/src/emu/diexec.c @@ -442,7 +442,7 @@ void device_execute_interface::spin_until_time(attotime duration) suspend_until_trigger(TRIGGER_SUSPENDTIME + timetrig, true); // then set a timer for it - timer_set(device().machine, duration, this, TRIGGER_SUSPENDTIME + timetrig, static_timed_trigger_callback); + device().machine->scheduler().timer_set(duration, FUNC(static_timed_trigger_callback), TRIGGER_SUSPENDTIME + timetrig, this); timetrig = (timetrig + 1) % 256; } @@ -558,9 +558,9 @@ 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); + m_partial_frame_timer = device().machine->scheduler().timer_alloc(FUNC(static_trigger_partial_frame_interrupt), (void *)this); if (m_execute_config.m_timed_interrupt_period != attotime::zero) - m_timedint_timer = timer_alloc(device().machine, static_trigger_periodic_interrupt, (void *)this); + m_timedint_timer = device().machine->scheduler().timer_alloc(FUNC(static_trigger_periodic_interrupt), (void *)this); // register for save states state_save_register_device_item(&m_device, 0, m_suspend); @@ -917,7 +917,7 @@ if (TEMPLOG) printf("setline(%s,%d,%d,%d)\n", m_device->tag(), m_linenum, state, // if this is the first one, set the timer if (event_index == 0) - timer_call_after_resynch(m_execute->device().machine, (void *)this, 0, static_empty_event_queue); + m_execute->device().machine->scheduler().synchronize(FUNC(static_empty_event_queue), 0, (void *)this); } } diff --git a/src/emu/emu.h b/src/emu/emu.h index 691a7e3ef1d..9f727a21986 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -85,8 +85,8 @@ typedef device_config * (*machine_config_constructor)(machine_config &config, de #include "disound.h" #include "dinvram.h" #include "didisasm.h" -#include "timer.h" #include "schedule.h" +#include "timer.h" // I/O #include "input.h" diff --git a/src/emu/emucore.h b/src/emu/emucore.h index dcd6a603ad1..12a72a7d420 100644 --- a/src/emu/emucore.h +++ b/src/emu/emucore.h @@ -428,6 +428,16 @@ public: m_tail = tail; m_count += count; } + + T &insert_after(T &object, T *insert_after) + { + if (insert_after == NULL) + return prepend(object); + object.m_next = insert_after->m_next; + insert_after->m_next = &object; + m_count++; + return object; + } T *detach_head() { diff --git a/src/emu/imagedev/bitbngr.c b/src/emu/imagedev/bitbngr.c index c55c2b9678f..a0af4b85631 100644 --- a/src/emu/imagedev/bitbngr.c +++ b/src/emu/imagedev/bitbngr.c @@ -344,10 +344,10 @@ static DEVICE_START(bitbanger) /* output config */ bi->build_count = 0; - bi->bitbanger_output_timer = timer_alloc(device->machine, bitbanger_output_timer, (void *) device); + bi->bitbanger_output_timer = device->machine->scheduler().timer_alloc(FUNC(bitbanger_output_timer), (void *) device); /* input config */ - bi->bitbanger_input_timer = timer_alloc(device->machine, bitbanger_input_timer, (void *) device ); + bi->bitbanger_input_timer = device->machine->scheduler().timer_alloc(FUNC(bitbanger_input_timer), (void *) device ); bi->idle_delay = attotime::from_seconds(1); bi->input_buffer_size = 0; bi->input_buffer_cursor = 0; diff --git a/src/emu/imagedev/flopdrv.c b/src/emu/imagedev/flopdrv.c index 786f8b3f134..314743ad731 100644 --- a/src/emu/imagedev/flopdrv.c +++ b/src/emu/imagedev/flopdrv.c @@ -214,7 +214,7 @@ static void floppy_drive_init(device_t *img) pDrive->flags = 0; pDrive->index_pulse_callback = NULL; pDrive->ready_state_change_callback = NULL; - pDrive->index_timer = timer_alloc(img->machine, floppy_drive_index_callback, (void *) img); + pDrive->index_timer = img->machine->scheduler().timer_alloc(FUNC(floppy_drive_index_callback), (void *) img); pDrive->idx = 0; floppy_drive_set_geometry(img, ((floppy_config*)img->baseconfig().static_config())->floppy_type); @@ -674,7 +674,7 @@ DEVICE_IMAGE_LOAD( floppy ) else next_wpt = CLEAR_LINE; - timer_set(image.device().machine, attotime::from_msec(250), flopimg, next_wpt, set_wpt); + image.device().machine->scheduler().timer_set(attotime::from_msec(250), FUNC(set_wpt), next_wpt, flopimg); return retVal; } @@ -702,7 +702,7 @@ DEVICE_IMAGE_UNLOAD( floppy ) devcb_call_write_line(&flopimg->out_wpt_func, flopimg->wpt); /* set timer for disk eject */ - timer_set(image.device().machine, attotime::from_msec(250), flopimg, ASSERT_LINE, set_wpt); + image.device().machine->scheduler().timer_set(attotime::from_msec(250), FUNC(set_wpt), ASSERT_LINE, flopimg); } device_t *floppy_get_device(running_machine *machine,int drive) diff --git a/src/emu/imagedev/snapquik.c b/src/emu/imagedev/snapquik.c index 804a9ac0107..aa61e9639f8 100644 --- a/src/emu/imagedev/snapquik.c +++ b/src/emu/imagedev/snapquik.c @@ -132,7 +132,7 @@ static DEVICE_START( snapquick ) snapquick_token *token = get_token(device); /* allocate a timer */ - token->timer = timer_alloc(device->machine, process_snapshot_or_quickload, (void *) dynamic_cast<device_image_interface *>(device)); + token->timer = device->machine->scheduler().timer_alloc(FUNC(process_snapshot_or_quickload), (void *) dynamic_cast<device_image_interface *>(device)); } diff --git a/src/emu/inptport.c b/src/emu/inptport.c index e93cb5ec030..364b0e9c6d4 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -4925,7 +4925,7 @@ static void clear_keybuffer(running_machine &machine) static void setup_keybuffer(running_machine *machine) { input_port_private *portdata = machine->input_port_data; - portdata->inputx_timer = timer_alloc(machine, inputx_timerproc, NULL); + portdata->inputx_timer = machine->scheduler().timer_alloc(FUNC(inputx_timerproc)); portdata->keybuffer = auto_alloc_clear(machine, key_buffer); machine->add_notifier(MACHINE_NOTIFY_EXIT, clear_keybuffer); } diff --git a/src/emu/machine.c b/src/emu/machine.c index a92cff83bfd..ac53f93395b 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -274,11 +274,11 @@ void running_machine::start() m_render = auto_alloc(this, render_manager(*this)); generic_machine_init(this); generic_sound_init(this); + + m_scheduler.register_for_save(); - // initialize the timers and allocate a soft_reset timer - // this must be done before cpu_init so that CPU's can allocate timers - timer_init(this); - m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL); + // allocate a soft_reset timer + m_soft_reset_timer = m_scheduler.timer_alloc(MFUNC(timer_expired, running_machine, soft_reset), this); // init the osd layer m_osd.init(*this); @@ -288,7 +288,7 @@ void running_machine::start() ui_init(this); // initialize the base time (needed for doing record/playback) - time(&m_base_time); + ::time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying @@ -386,7 +386,7 @@ int running_machine::run(bool firstrun) ui_display_startup_screens(this, firstrun, !settingsloaded); // perform a soft reset -- this takes us to the running phase - soft_reset(); + soft_reset(*this); // run the CPUs until a reset or exit m_hard_reset_pending = false; @@ -783,7 +783,7 @@ void running_machine::handle_saveload() // if there are anonymous timers, we can't save just yet, and we can't load yet either // because the timers might overwrite data we have loaded - if (timer_count_anonymous(this) > 0) + if (m_scheduler.can_save()) { // if more than a second has passed, we're probably screwed if ((timer_get_time(this) - m_saveload_schedule_time) > attotime::from_seconds(1)) @@ -856,9 +856,7 @@ cancel: // of the system //------------------------------------------------- -TIMER_CALLBACK( running_machine::static_soft_reset ) { machine->soft_reset(); } - -void running_machine::soft_reset() +void running_machine::soft_reset(running_machine &machine, int param) { logerror("Soft reset\n"); @@ -870,9 +868,6 @@ void running_machine::soft_reset() // now we're running m_current_phase = MACHINE_PHASE_RUNNING; - - // allow 0-time queued callbacks to run before any CPUs execute - timer_execute_timers(this); } diff --git a/src/emu/machine.h b/src/emu/machine.h index 78f418c5a93..8a5cee72b0e 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -187,15 +187,10 @@ class video_manager; class debug_view_manager; class osd_interface; -typedef struct _mame_private mame_private; -typedef struct _cpuexec_private cpuexec_private; -typedef struct _timer_private timer_private; typedef struct _state_private state_private; typedef struct _memory_private memory_private; typedef struct _palette_private palette_private; typedef struct _tilemap_private tilemap_private; -typedef struct _streams_private streams_private; -typedef struct _devices_private devices_private; typedef struct _romload_private romload_private; typedef struct _input_private input_private; typedef struct _input_port_private input_port_private; @@ -364,6 +359,7 @@ public: device_scheduler &scheduler() { return m_scheduler; } osd_interface &osd() const { return m_osd; } screen_device *first_screen() const { return primary_screen; } + attotime time() const { return m_scheduler.time(); } // immediate operations int run(bool firstrun); @@ -381,7 +377,7 @@ public: void schedule_save(const char *filename); void schedule_load(const char *filename); - // time + // date & time void base_datetime(system_time &systime); void current_datetime(system_time &systime); @@ -444,14 +440,10 @@ public: generic_pointers generic; // generic pointers // internal core information - mame_private * mame_data; // internal data from mame.c - timer_private * timer_data; // internal data from timer.c state_private * state_data; // internal data from state.c memory_private * memory_data; // internal data from memory.c palette_private * palette_data; // internal data from palette.c tilemap_private * tilemap_data; // internal data from tilemap.c - streams_private * streams_data; // internal data from streams.c - devices_private * devices_data; // internal data from devices.c romload_private * romload_data; // internal data from romload.c input_private * input_data; // internal data from input.c input_port_private * input_port_data; // internal data from inptport.c @@ -472,9 +464,7 @@ private: void set_saveload_filename(const char *filename); void fill_systime(system_time &systime, time_t t); void handle_saveload(); - - static TIMER_CALLBACK( static_soft_reset ); - void soft_reset(); + void soft_reset(running_machine &machine, int param = 0); static void logfile_callback(running_machine &machine, const char *buffer); diff --git a/src/emu/machine/6522via.c b/src/emu/machine/6522via.c index 832bed686da..8e9989fe3e9 100644 --- a/src/emu/machine/6522via.c +++ b/src/emu/machine/6522via.c @@ -218,9 +218,9 @@ void via6522_device::device_start() m_t2ll = 0xff; /* taken from vice */ m_t2lh = 0xff; m_time2 = m_time1 = timer_get_time(&m_machine); - m_t1 = device_timer_alloc(*this, TIMER_T1); - m_t2 = device_timer_alloc(*this, TIMER_T2); - m_shift_timer = device_timer_alloc(*this, TIMER_SHIFT); + m_t1 = timer_alloc(TIMER_T1); + m_t2 = timer_alloc(TIMER_T2); + m_shift_timer = timer_alloc(TIMER_SHIFT); /* Default clock is from CPU1 */ if (clock() == 0) diff --git a/src/emu/machine/6526cia.c b/src/emu/machine/6526cia.c index 10300b4b1d9..897bd343343 100644 --- a/src/emu/machine/6526cia.c +++ b/src/emu/machine/6526cia.c @@ -200,7 +200,7 @@ void mos6526_device::device_start() for (int t = 0; t < (sizeof(m_timer) / sizeof(m_timer[0])); t++) { cia_timer *timer = &m_timer[t]; - timer->m_timer = timer_alloc(&m_machine, timer_proc, (void*)this); + timer->m_timer = m_machine.scheduler().timer_alloc(FUNC(timer_proc), (void*)this); timer->m_cia = this; timer->m_irq = 0x01 << t; } @@ -208,7 +208,7 @@ void mos6526_device::device_start() /* setup TOD timer, if appropriate */ if (m_config.m_tod_clock != 0) { - timer_pulse(&m_machine, attotime::from_hz(m_config.m_tod_clock), (void *)this, 0, clock_tod_callback); + m_machine.scheduler().timer_pulse(attotime::from_hz(m_config.m_tod_clock), FUNC(clock_tod_callback), 0, (void *)this); } /* state save support */ diff --git a/src/emu/machine/6532riot.c b/src/emu/machine/6532riot.c index f159bf057f0..27f08cdb564 100644 --- a/src/emu/machine/6532riot.c +++ b/src/emu/machine/6532riot.c @@ -534,7 +534,7 @@ void riot6532_device::device_start() devcb_resolve_write_line(&m_irq_func, &m_config.m_irq_func, this); /* allocate timers */ - m_timer = timer_alloc(&m_machine, timer_end_callback, (void *)this); + m_timer = m_machine.scheduler().timer_alloc(FUNC(timer_end_callback), (void *)this); /* register for save states */ state_save_register_device_item(this, 0, m_port[0].m_in); diff --git a/src/emu/machine/6840ptm.c b/src/emu/machine/6840ptm.c index d7c3532e5ad..26c1ec2c621 100644 --- a/src/emu/machine/6840ptm.c +++ b/src/emu/machine/6840ptm.c @@ -132,9 +132,9 @@ void ptm6840_device::device_start() } - m_timer[0] = timer_alloc(&m_machine, ptm6840_timer1_cb, (void *)this); - m_timer[1] = timer_alloc(&m_machine, ptm6840_timer2_cb, (void *)this); - m_timer[2] = timer_alloc(&m_machine, ptm6840_timer3_cb, (void *)this); + m_timer[0] = m_machine.scheduler().timer_alloc(FUNC(ptm6840_timer1_cb), (void *)this); + m_timer[1] = m_machine.scheduler().timer_alloc(FUNC(ptm6840_timer2_cb), (void *)this); + m_timer[2] = m_machine.scheduler().timer_alloc(FUNC(ptm6840_timer3_cb), (void *)this); for (int i = 0; i < 3; i++) { diff --git a/src/emu/machine/6850acia.c b/src/emu/machine/6850acia.c index 5bbe021d3a5..31c8498e3f0 100644 --- a/src/emu/machine/6850acia.c +++ b/src/emu/machine/6850acia.c @@ -116,8 +116,8 @@ void acia6850_device::device_start() m_tx_clock = m_config.m_tx_clock; m_tx_counter = 0; m_rx_counter = 0; - m_rx_timer = timer_alloc(&m_machine, receive_event_callback, (void *)this); - m_tx_timer = timer_alloc(&m_machine, transmit_event_callback, (void *)this); + m_rx_timer = m_machine.scheduler().timer_alloc(FUNC(receive_event_callback), (void *)this); + m_tx_timer = m_machine.scheduler().timer_alloc(FUNC(transmit_event_callback), (void *)this); m_first_reset = 1; m_status_read = 0; m_brk = 0; diff --git a/src/emu/machine/68681.c b/src/emu/machine/68681.c index 4048899cefc..4189e8aaf92 100644 --- a/src/emu/machine/68681.c +++ b/src/emu/machine/68681.c @@ -710,9 +710,9 @@ static DEVICE_START(duart68681) duart68681->duart_config = (const duart68681_config *)device->baseconfig().static_config(); duart68681->device = device; - duart68681->channel[0].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device); - duart68681->channel[1].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device); - duart68681->duart_timer = timer_alloc(device->machine, duart_timer_callback, (void*)device); + duart68681->channel[0].tx_timer = device->machine->scheduler().timer_alloc(FUNC(tx_timer_callback), (void*)device); + duart68681->channel[1].tx_timer = device->machine->scheduler().timer_alloc(FUNC(tx_timer_callback), (void*)device); + duart68681->duart_timer = device->machine->scheduler().timer_alloc(FUNC(duart_timer_callback), (void*)device); state_save_register_device_item(device, 0, duart68681->ACR); state_save_register_device_item(device, 0, duart68681->IMR); diff --git a/src/emu/machine/74123.c b/src/emu/machine/74123.c index d10a29a29b1..5b90d9610c4 100644 --- a/src/emu/machine/74123.c +++ b/src/emu/machine/74123.c @@ -106,7 +106,7 @@ ttl74123_device::ttl74123_device(running_machine &_machine, const ttl74123_devic void ttl74123_device::device_start() { - m_timer = timer_alloc(&m_machine, clear_callback, (void *)this); + m_timer = m_machine.scheduler().timer_alloc(FUNC(clear_callback), (void *)this); /* start with the defaults */ m_a = m_config.m_a; @@ -202,7 +202,7 @@ void ttl74123_device::set_output() { int output = timer_running(); - timer_set( &m_machine, attotime::zero, (void *)this, output, output_callback ); + m_machine.scheduler().timer_set( attotime::zero, FUNC(output_callback ), output, (void *)this); if (LOG) logerror("74123 %s: Output: %d\n", tag(), output); } diff --git a/src/emu/machine/8042kbdc.c b/src/emu/machine/8042kbdc.c index 6e66911f248..9e9b92e96e8 100644 --- a/src/emu/machine/8042kbdc.c +++ b/src/emu/machine/8042kbdc.c @@ -279,7 +279,7 @@ void kbdc8042_init(running_machine *machine, const struct kbdc8042_interface *in kbdc8042.inport = 0xa0; at_8042_set_outport(machine, 0xfe, 1); - timer_pulse(machine, attotime::from_hz(60), NULL, 0, kbdc8042_time); + machine->scheduler().timer_pulse(attotime::from_hz(60), FUNC(kbdc8042_time)); } static void at_8042_receive(running_machine *machine, UINT8 data) diff --git a/src/emu/machine/8237dma.c b/src/emu/machine/8237dma.c index 822a2f8ab2c..67e83c10e19 100644 --- a/src/emu/machine/8237dma.c +++ b/src/emu/machine/8237dma.c @@ -124,7 +124,7 @@ void i8237_device::device_start() devcb_resolve_write_line(&m_chan[i].m_out_dack_func, &m_config.m_out_dack_func[i], this); } - m_timer = timer_alloc(&m_machine, i8237_timerproc_callback, (void *)this); + m_timer = m_machine.scheduler().timer_alloc(FUNC(i8237_timerproc_callback), (void *)this); } diff --git a/src/emu/machine/8257dma.c b/src/emu/machine/8257dma.c index cdc24d1bad6..d3eeb156bf7 100644 --- a/src/emu/machine/8257dma.c +++ b/src/emu/machine/8257dma.c @@ -137,8 +137,8 @@ void i8257_device::device_start() } /* set initial values */ - m_timer = device_timer_alloc(*this, TIMER_OPERATION); - m_msbflip_timer = device_timer_alloc(*this, TIMER_MSBFLIP); + m_timer = timer_alloc(TIMER_OPERATION); + m_msbflip_timer = timer_alloc(TIMER_MSBFLIP); /* register for state saving */ state_save_register_device_item_array(this, 0, m_address); @@ -449,7 +449,7 @@ void i8257_device::i8257_drq_w(int channel, int state) { int param = (channel << 1) | (state ? 1 : 0); - device_timer_call_after_resynch(*this, TIMER_DRQ_SYNC, param); + synchronize(TIMER_DRQ_SYNC, param); } WRITE_LINE_DEVICE_HANDLER( i8257_hlda_w ) { } diff --git a/src/emu/machine/am53cf96.c b/src/emu/machine/am53cf96.c index aea8ed38799..1119175f14b 100644 --- a/src/emu/machine/am53cf96.c +++ b/src/emu/machine/am53cf96.c @@ -159,10 +159,10 @@ WRITE32_HANDLER( am53cf96_w ) case 3: // reset SCSI bus scsi_regs[REG_INTSTATE] = 4; // command sent OK xfer_state = 0; - timer_set( space->machine, attotime::from_hz( 16384 ), NULL, 0, am53cf96_irq ); + space->machine->scheduler().timer_set( attotime::from_hz( 16384 ), FUNC(am53cf96_irq )); break; case 0x42: // select with ATN steps - timer_set( space->machine, attotime::from_hz( 16384 ), NULL, 0, am53cf96_irq ); + space->machine->scheduler().timer_set( attotime::from_hz( 16384 ), FUNC(am53cf96_irq )); if ((fifo[1] == 0) || (fifo[1] == 0x48) || (fifo[1] == 0x4b)) { scsi_regs[REG_INTSTATE] = 6; @@ -192,7 +192,7 @@ WRITE32_HANDLER( am53cf96_w ) case 0x10: // information transfer (must not change xfer_state) case 0x11: // second phase of information transfer case 0x12: // message accepted - timer_set( space->machine, attotime::from_hz( 16384 ), NULL, 0, am53cf96_irq ); + space->machine->scheduler().timer_set( attotime::from_hz( 16384 ), FUNC(am53cf96_irq )); scsi_regs[REG_INTSTATE] = 6; // command sent OK break; default: diff --git a/src/emu/machine/at28c16.c b/src/emu/machine/at28c16.c index 268747199b1..efc73d1bbe7 100644 --- a/src/emu/machine/at28c16.c +++ b/src/emu/machine/at28c16.c @@ -129,7 +129,7 @@ at28c16_device::at28c16_device( running_machine &_machine, const at28c16_device_ void at28c16_device::device_start() { - m_write_timer = timer_alloc( &m_machine, write_finished, this ); + m_write_timer = m_machine.scheduler().timer_alloc( FUNC(write_finished), this ); state_save_register_device_item( this, 0, m_a9_12v ); state_save_register_device_item( this, 0, m_oe_12v ); diff --git a/src/emu/machine/cdp1852.c b/src/emu/machine/cdp1852.c index 4cd891a7891..192709cbee2 100644 --- a/src/emu/machine/cdp1852.c +++ b/src/emu/machine/cdp1852.c @@ -165,7 +165,7 @@ static DEVICE_START( cdp1852 ) if (device->clock() > 0) { /* create the scan timer */ - cdp1852->scan_timer = timer_alloc(device->machine, cdp1852_scan_tick, (void *)device); + cdp1852->scan_timer = device->machine->scheduler().timer_alloc(FUNC(cdp1852_scan_tick), (void *)device); timer_adjust_periodic(cdp1852->scan_timer, attotime::zero, 0, attotime::from_hz(device->clock())); } diff --git a/src/emu/machine/ds2401.c b/src/emu/machine/ds2401.c index c27738b4679..6e52cd8ec21 100644 --- a/src/emu/machine/ds2401.c +++ b/src/emu/machine/ds2401.c @@ -153,8 +153,8 @@ void ds2401_init( running_machine *machine, int which, const UINT8 *data ) state_save_register_item(machine, "ds2401", NULL, which, c->rx ); state_save_register_item(machine, "ds2401", NULL, which, c->tx ); - c->timer = timer_alloc(machine, ds2401_tick , NULL); - c->reset_timer = timer_alloc(machine, ds2401_reset , NULL); + c->timer = machine->scheduler().timer_alloc(FUNC(ds2401_tick )); + c->reset_timer = machine->scheduler().timer_alloc(FUNC(ds2401_reset )); } void ds2401_write( running_machine *machine, int which, int data ) diff --git a/src/emu/machine/ds2404.c b/src/emu/machine/ds2404.c index eb8e4692f63..44de33b16a5 100644 --- a/src/emu/machine/ds2404.c +++ b/src/emu/machine/ds2404.c @@ -129,7 +129,7 @@ void ds2404_device::device_start() m_rtc[3] = (current_time >> 16) & 0xff; m_rtc[4] = (current_time >> 24) & 0xff; - emu_timer *timer = timer_alloc(&m_machine, ds2404_tick_callback, (void *)this); + emu_timer *timer = m_machine.scheduler().timer_alloc(FUNC(ds2404_tick_callback), (void *)this); timer_adjust_periodic(timer, attotime::from_hz(256), 0, attotime::from_hz(256)); } diff --git a/src/emu/machine/f3853.c b/src/emu/machine/f3853.c index aaac51edfc7..ad7d204e60d 100644 --- a/src/emu/machine/f3853.c +++ b/src/emu/machine/f3853.c @@ -134,7 +134,7 @@ void f3853_device::device_start() } } - m_timer = timer_alloc(&m_machine, f3853_timer_callback, (void *)this ); + m_timer = m_machine.scheduler().timer_alloc(FUNC(f3853_timer_callback), (void *)this ); state_save_register_device_item(this, 0, m_high ); state_save_register_device_item(this, 0, m_low ); diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c index 6df7926620d..847ef5c39ec 100644 --- a/src/emu/machine/generic.c +++ b/src/emu/machine/generic.c @@ -621,7 +621,7 @@ void generic_pulse_irq_line(device_t *device, int irqline) cpu_device *cpudevice = downcast<cpu_device *>(device); 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); + device->machine->scheduler().timer_set(target_time - timer_get_time(device->machine), FUNC(irq_pulse_clear), irqline, (void *)device); } @@ -638,7 +638,7 @@ void generic_pulse_irq_line_and_vector(device_t *device, int irqline, int vector cpu_device *cpudevice = downcast<cpu_device *>(device); 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); + device->machine->scheduler().timer_set(target_time - timer_get_time(device->machine), FUNC(irq_pulse_clear), irqline, (void *)device); } @@ -664,7 +664,7 @@ void cpu_interrupt_enable(device_t *device, int enabled) /* make sure there are no queued interrupts */ if (enabled == 0) - timer_call_after_resynch(device->machine, (void *)cpudevice, 0, clear_all_lines); + device->machine->scheduler().synchronize(FUNC(clear_all_lines), 0, (void *)cpudevice); } diff --git a/src/emu/machine/idectrl.c b/src/emu/machine/idectrl.c index ceeb86c1567..13466236a42 100644 --- a/src/emu/machine/idectrl.c +++ b/src/emu/machine/idectrl.c @@ -258,9 +258,9 @@ INLINE void signal_delayed_interrupt(ide_state *ide, attotime time, int buffer_r /* set a timer */ if (buffer_ready) - timer_set(ide->device->machine, time, ide, 0, delayed_interrupt_buffer_ready); + ide->device->machine->scheduler().timer_set(time, FUNC(delayed_interrupt_buffer_ready), 0, ide); else - timer_set(ide->device->machine, time, ide, 0, delayed_interrupt); + ide->device->machine->scheduler().timer_set(time, FUNC(delayed_interrupt), 0, ide); } @@ -625,7 +625,7 @@ static void security_error(ide_state *ide) ide->status &= ~IDE_STATUS_DRIVE_READY; /* just set a timer and mark ourselves error */ - timer_set(ide->device->machine, TIME_SECURITY_ERROR, ide, 0, security_error_done); + ide->device->machine->scheduler().timer_set(TIME_SECURITY_ERROR, FUNC(security_error_done), 0, ide); } @@ -806,10 +806,10 @@ static void read_first_sector(ide_state *ide) seek_time = TIME_SEEK_MULTISECTOR; ide->cur_lba = new_lba; - timer_set(ide->device->machine, seek_time, ide, 0, read_sector_done_callback); + ide->device->machine->scheduler().timer_set(seek_time, FUNC(read_sector_done_callback), 0, ide); } else - timer_set(ide->device->machine, TIME_PER_SECTOR, ide, 0, read_sector_done_callback); + ide->device->machine->scheduler().timer_set(TIME_PER_SECTOR, FUNC(read_sector_done_callback), 0, ide); } @@ -825,11 +825,11 @@ static void read_next_sector(ide_state *ide) read_sector_done(ide); else /* just set a timer */ - timer_set(ide->device->machine, attotime::from_usec(1), ide, 0, read_sector_done_callback); + ide->device->machine->scheduler().timer_set(attotime::from_usec(1), FUNC(read_sector_done_callback), 0, ide); } else /* just set a timer */ - timer_set(ide->device->machine, TIME_PER_SECTOR, ide, 0, read_sector_done_callback); + ide->device->machine->scheduler().timer_set(TIME_PER_SECTOR, FUNC(read_sector_done_callback), 0, ide); } @@ -862,13 +862,13 @@ static void continue_write(ide_state *ide) else { /* set a timer to do the write */ - timer_set(ide->device->machine, TIME_PER_SECTOR, ide, 0, write_sector_done_callback); + ide->device->machine->scheduler().timer_set(TIME_PER_SECTOR, FUNC(write_sector_done_callback), 0, ide); } } else { /* set a timer to do the write */ - timer_set(ide->device->machine, TIME_PER_SECTOR, ide, 0, write_sector_done_callback); + ide->device->machine->scheduler().timer_set(TIME_PER_SECTOR, FUNC(write_sector_done_callback), 0, ide); } } @@ -1836,8 +1836,8 @@ static DEVICE_START( ide_controller ) } /* create a timer for timing status */ - ide->last_status_timer = timer_alloc(device->machine, NULL, NULL); - ide->reset_timer = timer_alloc(device->machine, reset_callback, (void *)device); + ide->last_status_timer = device->machine->scheduler().timer_alloc(FUNC(NULL)); + ide->reset_timer = device->machine->scheduler().timer_alloc(FUNC(reset_callback), (void *)device); /* register ide states */ state_save_register_device_item(device, 0, ide->adapter_control); diff --git a/src/emu/machine/intelfsh.c b/src/emu/machine/intelfsh.c index 6a17f9d3594..49d16853c5f 100644 --- a/src/emu/machine/intelfsh.c +++ b/src/emu/machine/intelfsh.c @@ -268,7 +268,7 @@ intelfsh16_device::intelfsh16_device(running_machine &_machine, const intelfsh_d void intelfsh_device::device_start() { - m_timer = device_timer_alloc(*this); + m_timer = timer_alloc(); state_save_register_device_item( this, 0, m_status ); state_save_register_device_item( this, 0, m_flash_mode ); diff --git a/src/emu/machine/k056230.c b/src/emu/machine/k056230.c index 71c0735f397..02f9c194aab 100644 --- a/src/emu/machine/k056230.c +++ b/src/emu/machine/k056230.c @@ -128,7 +128,7 @@ WRITE8_DEVICE_HANDLER_TRAMPOLINE(k056230, k056230_w) { cpu_set_input_line(m_cpu, INPUT_LINE_IRQ2, ASSERT_LINE); } - timer_set(&m_machine, attotime::from_usec(10), (void*)this, 0, network_irq_clear_callback); + m_machine.scheduler().timer_set(attotime::from_usec(10), FUNC(network_irq_clear_callback), 0, (void*)this); } } // else diff --git a/src/emu/machine/latch8.c b/src/emu/machine/latch8.c index 8a994f72401..d43013ec962 100644 --- a/src/emu/machine/latch8.c +++ b/src/emu/machine/latch8.c @@ -105,7 +105,7 @@ WRITE8_DEVICE_HANDLER( latch8_w ) assert(offset == 0); if (latch8->intf->nosync != 0xff) - timer_call_after_resynch(device->machine, (void *)device, (0xFF << 8) | data, latch8_timerproc); + device->machine->scheduler().synchronize(FUNC(latch8_timerproc), (0xFF << 8) | data, (void *)device); else update(device, data, 0xFF); } @@ -165,7 +165,7 @@ INLINE void latch8_bitx_w(device_t *device, int bit, offs_t offset, UINT8 data) if (latch8->intf->nosync & mask) update(device, masked_data, mask); else - timer_call_after_resynch(device->machine, (void *) device, (mask << 8) | masked_data, latch8_timerproc); + device->machine->scheduler().synchronize(FUNC(latch8_timerproc), (mask << 8) | masked_data, (void *) device); } WRITE8_DEVICE_HANDLER( latch8_bit0_w ) { latch8_bitx_w(device, 0, offset, data); } diff --git a/src/emu/machine/ldcore.c b/src/emu/machine/ldcore.c index 365f27de97d..f7b31276549 100644 --- a/src/emu/machine/ldcore.c +++ b/src/emu/machine/ldcore.c @@ -305,7 +305,7 @@ static void vblank_state_changed(screen_device &screen, void *param, bool vblank (*ldcore->intf.vsync)(ld, &ldcore->metadata[ldcore->fieldnum], ldcore->fieldnum, curtime); /* set a timer to begin fetching the next frame just before the VBI data would be fetched */ - timer_set(screen.machine, screen.time_until_pos(16*2), ld, 0, perform_player_update); + screen.machine->scheduler().timer_set(screen.time_until_pos(16*2), FUNC(perform_player_update), 0, ld); } } diff --git a/src/emu/machine/ldpr8210.c b/src/emu/machine/ldpr8210.c index 2ba5b27af16..899194c4c51 100644 --- a/src/emu/machine/ldpr8210.c +++ b/src/emu/machine/ldpr8210.c @@ -380,10 +380,10 @@ 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, ld->screen->scan_period() * 4, ld, 0, vsync_off); + ld->device->machine->scheduler().timer_set(ld->screen->scan_period() * 4, FUNC(vsync_off), 0, ld); /* 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); + ld->device->machine->scheduler().timer_set(ld->screen->time_until_pos(19*2), FUNC(vbi_data_fetch), 0, ld); } @@ -1119,7 +1119,7 @@ static void simutrek_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fie if (LOG_SIMUTREK) printf("%3d:VSYNC IRQ\n", ld->screen->vpos()); cpu_set_input_line(player->simutrek.cpu, MCS48_INPUT_IRQ, ASSERT_LINE); - timer_set(ld->device->machine, ld->screen->scan_period(), ld, 0, irq_off); + ld->device->machine->scheduler().timer_set(ld->screen->scan_period(), FUNC(irq_off), 0, ld); } } @@ -1164,7 +1164,7 @@ static UINT8 simutrek_status_r(laserdisc_state *ld) static void simutrek_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data) { - timer_call_after_resynch(ld->device->machine, ld, data, simutrek_latched_data_w); + ld->device->machine->scheduler().synchronize(FUNC(simutrek_latched_data_w), data, ld); if (LOG_SIMUTREK) printf("%03d:**** Simutrek Command = %02X\n", ld->screen->vpos(), data); } diff --git a/src/emu/machine/ldv1000.c b/src/emu/machine/ldv1000.c index 4cc28707de2..b3771834872 100644 --- a/src/emu/machine/ldv1000.c +++ b/src/emu/machine/ldv1000.c @@ -257,10 +257,10 @@ 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, ld->screen->scan_period() * 4, ld, 0, vsync_off); + ld->device->machine->scheduler().timer_set(ld->screen->scan_period() * 4, FUNC(vsync_off), 0, ld); /* 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); + ld->device->machine->scheduler().timer_set(ld->screen->time_until_pos(19*2), FUNC(vbi_data_fetch), 0, ld); /* boost interleave for the first 1ms to improve communications */ cpuexec_boost_interleave(ld->device->machine, attotime::zero, attotime::from_msec(1)); diff --git a/src/emu/machine/ldvp931.c b/src/emu/machine/ldvp931.c index c52011baf64..0b2863d1581 100644 --- a/src/emu/machine/ldvp931.c +++ b/src/emu/machine/ldvp931.c @@ -233,7 +233,7 @@ static void vp931_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fieldn /* set the ERP signal to 1 to indicate start of frame, and set a timer to turn it off */ ld->player->daticerp = 1; - timer_set(ld->device->machine, ld->screen->time_until_pos(15*2), ld, 0, erp_off); + ld->device->machine->scheduler().timer_set(ld->screen->time_until_pos(15*2), FUNC(erp_off), 0, ld); } @@ -245,7 +245,7 @@ static void vp931_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fieldn static INT32 vp931_update(laserdisc_state *ld, const vbi_metadata *vbi, int fieldnum, attotime curtime) { /* set the first VBI timer to go at the start of line 16 */ - timer_set(ld->device->machine, ld->screen->time_until_pos(16*2), ld, LASERDISC_CODE_LINE16 << 2, vbi_data_fetch); + ld->device->machine->scheduler().timer_set(ld->screen->time_until_pos(16*2), FUNC(vbi_data_fetch), LASERDISC_CODE_LINE16 << 2, ld); /* play forward by default */ return fieldnum; @@ -260,7 +260,7 @@ static INT32 vp931_update(laserdisc_state *ld, const vbi_metadata *vbi, int fiel static void vp931_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data) { /* set a timer to synchronize execution before sending the data */ - timer_call_after_resynch(ld->device->machine, ld, data, deferred_data_w); + ld->device->machine->scheduler().synchronize(FUNC(deferred_data_w), data, ld); } @@ -335,7 +335,7 @@ static TIMER_CALLBACK( vbi_data_fetch ) if (which == 0) { cpu_set_input_line(player->cpu, MCS48_INPUT_IRQ, ASSERT_LINE); - timer_set(machine, attotime::from_nsec(5580), ld, 0, irq_off); + machine->scheduler().timer_set(attotime::from_nsec(5580), FUNC(irq_off), 0, ld); } /* clock the data strobe on each subsequent callback */ @@ -343,7 +343,7 @@ static TIMER_CALLBACK( vbi_data_fetch ) { player->daticval = code >> (8 * (3 - which)); player->datastrobe = 1; - timer_set(machine, attotime::from_nsec(5000), ld, 0, datastrobe_off); + machine->scheduler().timer_set(attotime::from_nsec(5000), FUNC(datastrobe_off), 0, ld); } /* determine the next bit to fetch and reprime ourself */ @@ -353,7 +353,7 @@ static TIMER_CALLBACK( vbi_data_fetch ) line++; } if (line <= LASERDISC_CODE_LINE18 + 1) - timer_set(machine, ld->screen->time_until_pos(line*2, which * 2 * ld->screen->width() / 4), ld, (line << 2) | which, vbi_data_fetch); + machine->scheduler().timer_set(ld->screen->time_until_pos(line*2, which * 2 * ld->screen->width() / 4), FUNC(vbi_data_fetch), (line << 2), ld); } diff --git a/src/emu/machine/mb3773.c b/src/emu/machine/mb3773.c index 166a8f7c7ab..d488e2b9464 100644 --- a/src/emu/machine/mb3773.c +++ b/src/emu/machine/mb3773.c @@ -105,7 +105,7 @@ mb3773_device::mb3773_device( running_machine &_machine, const mb3773_device_con void mb3773_device::device_start() { - m_watchdog_timer = timer_alloc( &m_machine, watchdog_timeout, this ); + m_watchdog_timer = m_machine.scheduler().timer_alloc( FUNC(watchdog_timeout), this ); reset_timer(); state_save_register_device_item( this, 0, m_ck ); diff --git a/src/emu/machine/mc146818.c b/src/emu/machine/mc146818.c index 4e7a7bbdcfb..452ab38b8ac 100644 --- a/src/emu/machine/mc146818.c +++ b/src/emu/machine/mc146818.c @@ -184,7 +184,7 @@ mc146818_device::mc146818_device(running_machine &_machine, const mc146818_devic void mc146818_device::device_start() { m_last_refresh = timer_get_time(&m_machine); - emu_timer *timer = device_timer_alloc(*this); + emu_timer *timer = timer_alloc(); if (m_config.m_type == mc146818_device_config::MC146818_UTC) { // hack: for apollo we increase the update frequency to stay in sync with real time timer_adjust_periodic(timer, attotime::from_hz(2), 0, attotime::from_hz(2)); diff --git a/src/emu/machine/mc68901.c b/src/emu/machine/mc68901.c index 8787e27ee27..b96daa1404d 100644 --- a/src/emu/machine/mc68901.c +++ b/src/emu/machine/mc68901.c @@ -801,20 +801,20 @@ void mc68901_device::device_start() m_timer_clock = m_config.timer_clock; /* create the timers */ - m_timer[TIMER_A] = device_timer_alloc(*this, TIMER_A); - m_timer[TIMER_B] = device_timer_alloc(*this, TIMER_B); - m_timer[TIMER_C] = device_timer_alloc(*this, TIMER_C); - m_timer[TIMER_D] = device_timer_alloc(*this, TIMER_D); + m_timer[TIMER_A] = timer_alloc(TIMER_A); + m_timer[TIMER_B] = timer_alloc(TIMER_B); + m_timer[TIMER_C] = timer_alloc(TIMER_C); + m_timer[TIMER_D] = timer_alloc(TIMER_D); if (m_config.rx_clock > 0) { - m_rx_timer = device_timer_alloc(*this, TIMER_RX); + m_rx_timer = timer_alloc(TIMER_RX); timer_adjust_periodic(m_rx_timer, attotime::zero, 0, attotime::from_hz(m_config.rx_clock)); } if (m_config.tx_clock > 0) { - m_tx_timer = device_timer_alloc(*this, TIMER_TX); + m_tx_timer = timer_alloc(TIMER_TX); timer_adjust_periodic(m_tx_timer, attotime::zero, 0, attotime::from_hz(m_config.tx_clock)); } diff --git a/src/emu/machine/microtch.c b/src/emu/machine/microtch.c index 122d40e7c4a..43f5bcd88df 100644 --- a/src/emu/machine/microtch.c +++ b/src/emu/machine/microtch.c @@ -159,7 +159,7 @@ void microtouch_init(running_machine *machine, microtouch_tx_func tx_cb, microto microtouch.tx_callback = tx_cb; microtouch.touch_callback = touch_cb; - microtouch.timer = timer_alloc(machine, microtouch_timer_callback, NULL); + microtouch.timer = machine->scheduler().timer_alloc(FUNC(microtouch_timer_callback)); timer_adjust_periodic(microtouch.timer, attotime::from_hz(167*5), 0, attotime::from_hz(167*5)); state_save_register_item(machine, "microtouch", NULL, 0, microtouch.reset_done); diff --git a/src/emu/machine/pc16552d.c b/src/emu/machine/pc16552d.c index cae0a6ed791..4b815d353de 100644 --- a/src/emu/machine/pc16552d.c +++ b/src/emu/machine/pc16552d.c @@ -400,10 +400,10 @@ void pc16552d_init(running_machine *machine, int chip, int frequency, void (* ir duart[chip].ch[1].pending_interrupt = 0; // allocate transmit timers - duart[chip].ch[0].tx_fifo_timer = timer_alloc(machine, tx_fifo_timer_callback, NULL); + duart[chip].ch[0].tx_fifo_timer = machine->scheduler().timer_alloc(FUNC(tx_fifo_timer_callback)); timer_adjust_oneshot(duart[chip].ch[0].tx_fifo_timer, attotime::never, (chip * 2) + 0); - duart[chip].ch[1].tx_fifo_timer = timer_alloc(machine, tx_fifo_timer_callback, NULL); + duart[chip].ch[1].tx_fifo_timer = machine->scheduler().timer_alloc(FUNC(tx_fifo_timer_callback)); timer_adjust_oneshot(duart[chip].ch[1].tx_fifo_timer, attotime::never, (chip * 2) + 1); } diff --git a/src/emu/machine/pic8259.c b/src/emu/machine/pic8259.c index 0b9cad3b283..fc8cacca9ca 100644 --- a/src/emu/machine/pic8259.c +++ b/src/emu/machine/pic8259.c @@ -406,7 +406,7 @@ static DEVICE_START( pic8259 ) assert(intf != NULL); - pic8259->timer = timer_alloc( device->machine, pic8259_timerproc, (void *)device ); + pic8259->timer = device->machine->scheduler().timer_alloc( FUNC(pic8259_timerproc), (void *)device ); /* resolve callbacks */ devcb_resolve_write_line(&pic8259->out_int_func, &intf->out_int_func, device); diff --git a/src/emu/machine/pit8253.c b/src/emu/machine/pit8253.c index 6dc2d8cd46c..6f642c998f7 100644 --- a/src/emu/machine/pit8253.c +++ b/src/emu/machine/pit8253.c @@ -1081,7 +1081,7 @@ static void common_start( device_t *device, int device_type ) { /* initialize timer */ timer->clockin = pit8253->config->timer[timerno].clockin; - timer->updatetimer = timer_alloc(device->machine, update_timer_cb, (void *)device); + timer->updatetimer = device->machine->scheduler().timer_alloc(FUNC(update_timer_cb), (void *)device); timer_adjust_oneshot(timer->updatetimer, attotime::never, timerno); /* resolve callbacks */ diff --git a/src/emu/machine/rtc65271.c b/src/emu/machine/rtc65271.c index 91016b64152..0ed057ebfae 100644 --- a/src/emu/machine/rtc65271.c +++ b/src/emu/machine/rtc65271.c @@ -522,7 +522,7 @@ static TIMER_CALLBACK( rtc_begin_update_callback ) state->regs[reg_A] |= reg_A_UIP; /* schedule end of update cycle */ - timer_set(device->machine, UPDATE_CYCLE_TIME, (void *)device, 0, rtc_end_update_callback); + device->machine->scheduler().timer_set(UPDATE_CYCLE_TIME, FUNC(rtc_end_update_callback), 0, (void *)device); } } @@ -688,9 +688,9 @@ static DEVICE_START( rtc65271 ) rtc65271_config *config = (rtc65271_config *)downcast<const legacy_device_config_base &>(device->baseconfig()).inline_config(); rtc65271_state *state = get_safe_token(device); - state->update_timer = timer_alloc(device->machine, rtc_begin_update_callback, (void *)device); + state->update_timer = device->machine->scheduler().timer_alloc(FUNC(rtc_begin_update_callback), (void *)device); timer_adjust_periodic(state->update_timer, attotime::from_seconds(1), 0, attotime::from_seconds(1)); - state->SQW_timer = timer_alloc(device->machine, rtc_SQW_callback, (void *)device); + state->SQW_timer = device->machine->scheduler().timer_alloc(FUNC(rtc_SQW_callback), (void *)device); state->interrupt_callback = config->interrupt_callback; state_save_register_device_item_array(device, 0, state->regs); diff --git a/src/emu/machine/s3c24xx.c b/src/emu/machine/s3c24xx.c index 9925cfaced9..72114ab2516 100644 --- a/src/emu/machine/s3c24xx.c +++ b/src/emu/machine/s3c24xx.c @@ -3168,14 +3168,14 @@ static DEVICE_START( s3c24xx ) { s3c24xx_t *s3c24xx = get_token( device); s3c24xx->iface = (const s3c24xx_interface *)device->baseconfig().static_config(); - for (int i = 0; i < 5; i++) s3c24xx->pwm.timer[i] = timer_alloc( device->machine, s3c24xx_pwm_timer_exp, (void*)device); - for (int i = 0; i < 4; i++) s3c24xx->dma[i].timer = timer_alloc( device->machine, s3c24xx_dma_timer_exp, (void*)device); - s3c24xx->iic.timer = timer_alloc( device->machine, s3c24xx_iic_timer_exp, (void*)device); - s3c24xx->iis.timer = timer_alloc( device->machine, s3c24xx_iis_timer_exp, (void*)device); - s3c24xx->lcd.timer = timer_alloc( device->machine, s3c24xx_lcd_timer_exp, (void*)device); - s3c24xx->rtc.timer_tick_count = timer_alloc( device->machine, s3c24xx_rtc_timer_tick_count_exp, (void*)device); - s3c24xx->rtc.timer_update = timer_alloc( device->machine, s3c24xx_rtc_timer_update_exp, (void*)device); - s3c24xx->wdt.timer = timer_alloc( device->machine, s3c24xx_wdt_timer_exp, (void*)device); + for (int i = 0; i < 5; i++) s3c24xx->pwm.timer[i] = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_pwm_timer_exp), (void*)device); + for (int i = 0; i < 4; i++) s3c24xx->dma[i].timer = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_dma_timer_exp), (void*)device); + s3c24xx->iic.timer = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_iic_timer_exp), (void*)device); + s3c24xx->iis.timer = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_iis_timer_exp), (void*)device); + s3c24xx->lcd.timer = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_lcd_timer_exp), (void*)device); + s3c24xx->rtc.timer_tick_count = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_rtc_timer_tick_count_exp), (void*)device); + s3c24xx->rtc.timer_update = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_rtc_timer_update_exp), (void*)device); + s3c24xx->wdt.timer = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_wdt_timer_exp), (void*)device); timer_adjust_periodic( s3c24xx->rtc.timer_update, attotime::from_msec( 1000), 0, attotime::from_msec( 1000)); s3c24xx_rtc_init( device); } diff --git a/src/emu/machine/timekpr.c b/src/emu/machine/timekpr.c index a0afe878723..a236ba202d4 100644 --- a/src/emu/machine/timekpr.c +++ b/src/emu/machine/timekpr.c @@ -227,7 +227,7 @@ void timekeeper_device::device_start() state_save_register_device_item( this, 0, m_century ); state_save_register_device_item_pointer( this, 0, m_data, m_size ); - timer = timer_alloc( &m_machine, timekeeper_tick_callback, (void *)this ); + timer = m_machine.scheduler().timer_alloc( FUNC(timekeeper_tick_callback), (void *)this ); duration = attotime::from_seconds(1); timer_adjust_periodic( timer, duration, 0, duration ); } diff --git a/src/emu/machine/tmp68301.c b/src/emu/machine/tmp68301.c index 18c69c3223f..2c33ba08a45 100644 --- a/src/emu/machine/tmp68301.c +++ b/src/emu/machine/tmp68301.c @@ -110,7 +110,7 @@ MACHINE_START( tmp68301 ) { int i; for (i = 0; i < 3; i++) - tmp68301_timer[i] = timer_alloc(machine, tmp68301_timer_callback, NULL); + tmp68301_timer[i] = machine->scheduler().timer_alloc(FUNC(tmp68301_timer_callback)); } MACHINE_RESET( tmp68301 ) diff --git a/src/emu/machine/wd33c93.c b/src/emu/machine/wd33c93.c index 073e0a97726..0c00a6f69ac 100644 --- a/src/emu/machine/wd33c93.c +++ b/src/emu/machine/wd33c93.c @@ -352,7 +352,7 @@ static CMD_HANDLER( wd33c93_select_cmd ) } /* queue up a service request out in the future */ - timer_set( machine, attotime::from_usec(50), NULL, 0, wd33c93_service_request ); + machine->scheduler().timer_set( attotime::from_usec(50), FUNC(wd33c93_service_request )); } else { @@ -424,7 +424,7 @@ static CMD_HANDLER( wd33c93_selectxfer_cmd ) scsi_data.busphase = PHS_MESS_IN; /* queue up a service request out in the future */ - timer_set( machine, attotime::from_msec(50), NULL, 0, wd33c93_service_request ); + machine->scheduler().timer_set( attotime::from_msec(50), FUNC(wd33c93_service_request )); } } else @@ -454,7 +454,7 @@ static CMD_HANDLER( wd33c93_xferinfo_cmd ) scsi_data.regs[WD_AUXILIARY_STATUS] |= ASR_CIP; /* the command will be completed once the data is transferred */ - timer_set( machine, attotime::from_msec(1), NULL, 0, wd33c93_deassert_cip ); + machine->scheduler().timer_set( attotime::from_msec(1), FUNC(wd33c93_deassert_cip )); } /* Command handlers */ @@ -795,7 +795,7 @@ void wd33c93_init( running_machine *machine, const struct WD33C93interface *inte } /* allocate a timer for commands */ - scsi_data.cmd_timer = timer_alloc(machine, wd33c93_complete_cb, NULL); + scsi_data.cmd_timer = machine->scheduler().timer_alloc(FUNC(wd33c93_complete_cb)); scsi_data.temp_input = auto_alloc_array( machine, UINT8, TEMP_INPUT_LEN ); diff --git a/src/emu/machine/z80ctc.c b/src/emu/machine/z80ctc.c index f66ea35eebe..9f7f9afb403 100644 --- a/src/emu/machine/z80ctc.c +++ b/src/emu/machine/z80ctc.c @@ -336,7 +336,7 @@ void z80ctc_device::ctc_channel::start(z80ctc_device *device, int index, bool no if (write_line != NULL) devcb_resolve_write_line(&m_zc, write_line, m_device); m_notimer = notimer; - m_timer = timer_alloc(&m_device->m_machine, static_timer_callback, this); + m_timer = m_device->machine->scheduler().timer_alloc(FUNC(static_timer_callback), this); // register for save states state_save_register_device_item(m_device, m_index, m_mode); diff --git a/src/emu/machine/z80dart.c b/src/emu/machine/z80dart.c index 63f6d595474..200b648565b 100644 --- a/src/emu/machine/z80dart.c +++ b/src/emu/machine/z80dart.c @@ -293,28 +293,28 @@ void z80dart_device::device_start() if (m_config.m_rx_clock_a != 0) { // allocate channel A receive timer - m_rxca_timer = timer_alloc(&m_machine, dart_channel::static_rxc_tick, (void *)&m_channel[CHANNEL_A]); + m_rxca_timer = m_machine.scheduler().timer_alloc(FUNC(dart_channel::static_rxc_tick), (void *)&m_channel[CHANNEL_A]); timer_adjust_periodic(m_rxca_timer, attotime::zero, 0, attotime::from_hz(m_config.m_rx_clock_a)); } if (m_config.m_tx_clock_a != 0) { // allocate channel A transmit timer - m_txca_timer = timer_alloc(&m_machine, dart_channel::static_txc_tick, (void *)&m_channel[CHANNEL_A]); + m_txca_timer = m_machine.scheduler().timer_alloc(FUNC(dart_channel::static_txc_tick), (void *)&m_channel[CHANNEL_A]); timer_adjust_periodic(m_txca_timer, attotime::zero, 0, attotime::from_hz(m_config.m_tx_clock_a)); } if (m_config.m_rx_clock_b != 0) { // allocate channel B receive timer - m_rxcb_timer = timer_alloc(&m_machine, dart_channel::static_rxc_tick, (void *)&m_channel[CHANNEL_B]); + m_rxcb_timer = m_machine.scheduler().timer_alloc(FUNC(dart_channel::static_rxc_tick), (void *)&m_channel[CHANNEL_B]); timer_adjust_periodic(m_rxcb_timer, attotime::zero, 0, attotime::from_hz(m_config.m_rx_clock_b)); } if (m_config.m_tx_clock_b != 0) { // allocate channel B transmit timer - m_txcb_timer = timer_alloc(&m_machine, dart_channel::static_txc_tick, (void *)&m_channel[CHANNEL_B]); + m_txcb_timer = m_machine.scheduler().timer_alloc(FUNC(dart_channel::static_txc_tick), (void *)&m_channel[CHANNEL_B]); timer_adjust_periodic(m_txcb_timer, attotime::zero, 0, attotime::from_hz(m_config.m_tx_clock_b)); } diff --git a/src/emu/machine/z80dma.c b/src/emu/machine/z80dma.c index 92f5dd61a1d..059703e0d40 100644 --- a/src/emu/machine/z80dma.c +++ b/src/emu/machine/z80dma.c @@ -238,7 +238,7 @@ void z80dma_device::device_start() devcb_resolve_write8(&m_out_iorq_func, &m_config.m_out_iorq_func, this); // allocate timer - m_timer = timer_alloc(&m_machine, static_timerproc, (void *)this); + m_timer = m_machine.scheduler().timer_alloc(FUNC(static_timerproc), (void *)this); // register for state saving state_save_register_device_item_array(this, 0, m_regs); @@ -876,7 +876,7 @@ void z80dma_device::rdy_write_callback(int state) void z80dma_device::rdy_w(int state) { if (LOG) logerror("Z80DMA '%s' RDY: %d Active High: %d\n", tag(), state, READY_ACTIVE_HIGH); - timer_call_after_resynch(&m_machine, (void *)this, state, static_rdy_write_callback); + m_machine.scheduler().synchronize(FUNC(static_rdy_write_callback), state, (void *)this); } diff --git a/src/emu/machine/z80sio.c b/src/emu/machine/z80sio.c index 71eb83a33fd..8c1bba849c0 100644 --- a/src/emu/machine/z80sio.c +++ b/src/emu/machine/z80sio.c @@ -524,7 +524,7 @@ void z80sio_device::sio_channel::start(z80sio_device *device, int index) { m_device = device; m_index = index; - m_receive_timer = timer_alloc(&m_device->m_machine, static_serial_callback, this); + m_receive_timer = device->machine->scheduler().timer_alloc(FUNC(static_serial_callback), this); } @@ -713,7 +713,7 @@ int z80sio_device::sio_channel::rts() void z80sio_device::sio_channel::set_cts(int state) { - timer_call_after_resynch(&m_device->m_machine, this, (SIO_RR0_CTS << 1) + (state != 0), static_change_input_line); + m_device->machine->scheduler().synchronize(FUNC(static_change_input_line), (SIO_RR0_CTS << 1) + (state != 0), this); } @@ -723,7 +723,7 @@ void z80sio_device::sio_channel::set_cts(int state) void z80sio_device::sio_channel::set_dcd(int state) { - timer_call_after_resynch(&m_device->m_machine, this, (SIO_RR0_DCD << 1) + (state != 0), static_change_input_line); + m_device->machine->scheduler().synchronize(FUNC(static_change_input_line), (SIO_RR0_DCD << 1) + (state != 0), this); } diff --git a/src/emu/machine/z80sti.c b/src/emu/machine/z80sti.c index 3c6f8a59b93..8b3c2e7b08a 100644 --- a/src/emu/machine/z80sti.c +++ b/src/emu/machine/z80sti.c @@ -244,22 +244,22 @@ void z80sti_device::device_start() devcb_resolve_write_line(&m_out_int_func, &m_config.m_out_int_func, this); // create the counter timers - m_timer[TIMER_A] = timer_alloc(&m_machine, static_timer_count, (void *)this); - m_timer[TIMER_B] = timer_alloc(&m_machine, static_timer_count, (void *)this); - m_timer[TIMER_C] = timer_alloc(&m_machine, static_timer_count, (void *)this); - m_timer[TIMER_D] = timer_alloc(&m_machine, static_timer_count, (void *)this); + m_timer[TIMER_A] = m_machine.scheduler().timer_alloc(FUNC(static_timer_count), (void *)this); + m_timer[TIMER_B] = m_machine.scheduler().timer_alloc(FUNC(static_timer_count), (void *)this); + m_timer[TIMER_C] = m_machine.scheduler().timer_alloc(FUNC(static_timer_count), (void *)this); + m_timer[TIMER_D] = m_machine.scheduler().timer_alloc(FUNC(static_timer_count), (void *)this); // create serial receive clock timer if (m_config.m_rx_clock > 0) { - m_rx_timer = timer_alloc(&m_machine, static_rx_tick, (void *)this); + m_rx_timer = m_machine.scheduler().timer_alloc(FUNC(static_rx_tick), (void *)this); timer_adjust_periodic(m_rx_timer, attotime::zero, 0, attotime::from_hz(m_config.m_rx_clock)); } // create serial transmit clock timer if (m_config.m_tx_clock > 0) { - m_tx_timer = timer_alloc(&m_machine, static_tx_tick, (void *)this); + m_tx_timer = m_machine.scheduler().timer_alloc(FUNC(static_tx_tick), (void *)this); timer_adjust_periodic(m_tx_timer, attotime::zero, 0, attotime::from_hz(m_config.m_tx_clock)); } diff --git a/src/emu/schedule.c b/src/emu/schedule.c index 21edcea390a..70220957c6d 100644 --- a/src/emu/schedule.c +++ b/src/emu/schedule.c @@ -50,8 +50,6 @@ #define LOG(x) do { if (VERBOSE) logerror x; } while (0) -#define TEMPLOG 0 - //************************************************************************** @@ -69,17 +67,252 @@ enum //************************************************************************** -// MACROS +// EMU TIMER //************************************************************************** -// these are macros to ensure inlining in device_scheduler::timeslice -#define ATTOTIME_LT(a,b) ((a).seconds < (b).seconds || ((a).seconds == (b).seconds && (a).attoseconds < (b).attoseconds)) -#define ATTOTIME_NORMALIZE(a) do { if ((a).attoseconds >= ATTOSECONDS_PER_SECOND) { (a).seconds++; (a).attoseconds -= ATTOSECONDS_PER_SECOND; } } while (0) +//------------------------------------------------- +// emu_timer - constructor +//------------------------------------------------- + +emu_timer::emu_timer() + : m_machine(NULL), + m_next(NULL), + m_prev(NULL), + m_callback(NULL), + m_param(0), + m_ptr(NULL), + m_func(NULL), + m_enabled(false), + m_temporary(false), + m_period(attotime::zero), + m_start(attotime::zero), + m_expire(attotime::never), + m_device(NULL), + m_id(0) +{ +} + + +//------------------------------------------------- +// init - completely initialize the state when +// re-allocated as a non-device timer +//------------------------------------------------- + +emu_timer &emu_timer::init(running_machine &machine, timer_expired_func callback, const char *name, void *ptr, bool temporary) +{ + // ensure the entire timer state is clean + m_machine = &machine; + m_next = NULL; + m_prev = NULL; + m_callback = callback; + m_param = 0; + m_ptr = ptr; + m_func = (name != NULL) ? name : "?"; + m_enabled = false; + m_temporary = temporary; + m_period = attotime::never; + m_start = machine.time(); + m_expire = attotime::never; + m_device = NULL; + m_id = 0; + + // if we're not temporary, register ourselves with the save state system + if (!m_temporary) + register_save(); + + // insert into the list + machine.scheduler().timer_list_insert(*this); + return *this; +} + + +//------------------------------------------------- +// init - completely initialize the state when +// re-allocated as a device timer +//------------------------------------------------- + +emu_timer &emu_timer::init(device_t &device, device_timer_id id, void *ptr, bool temporary) +{ + // ensure the entire timer state is clean + m_machine = device.machine; + m_next = NULL; + m_prev = NULL; + m_callback = NULL; + m_param = 0; + m_ptr = ptr; + m_func = NULL; + m_enabled = false; + m_temporary = temporary; + m_period = attotime::never; + m_start = machine().time(); + m_expire = attotime::never; + m_device = &device; + m_id = id; + + // if we're not temporary, register ourselves with the save state system + if (!m_temporary) + register_save(); + + // insert into the list + machine().scheduler().timer_list_insert(*this); + return *this; +} + + +//------------------------------------------------- +// release - release us from the global list +// management when deallocating +//------------------------------------------------- + +emu_timer &emu_timer::release() +{ + // unhook us from the global list + machine().scheduler().timer_list_remove(*this); + return *this; +} + + +//------------------------------------------------- +// enable - enable/disable a timer +//------------------------------------------------- + +bool emu_timer::enable(bool enable) +{ + // reschedule only if the state has changed + bool old = m_enabled; + if (old != enable) + { + // set the enable flag + m_enabled = enable; + + // remove the timer and insert back into the list + machine().scheduler().timer_list_remove(*this); + machine().scheduler().timer_list_insert(*this); + } + return old; +} + + +//------------------------------------------------- +// adjust - adjust the time when this timer will +// fire and specify a period for subsequent +// firings +//------------------------------------------------- + +void emu_timer::adjust(attotime start_delay, INT32 param, attotime period) +{ + // if this is the callback timer, mark it modified + device_scheduler &scheduler = machine().scheduler(); + if (scheduler.m_callback_timer == this) + scheduler.m_callback_timer_modified = true; + + // compute the time of the next firing and insert into the list + m_param = param; + m_enabled = true; + + // clamp negative times to 0 + if (start_delay.seconds < 0) + start_delay = attotime::zero; + + // set the start and expire times + m_start = scheduler.time(); + m_expire = m_start + start_delay; + m_period = period; + + // remove and re-insert the timer in its new order + scheduler.timer_list_remove(*this); + scheduler.timer_list_insert(*this); + + // if this was inserted as the head, abort the current timeslice and resync + if (this == scheduler.first_timer()) + scheduler.abort_timeslice(); +} + + +//------------------------------------------------- +// elapsed - return the amount of time since the +// timer was started +//------------------------------------------------- + +attotime emu_timer::elapsed() const +{ + return machine().time() - m_start; +} + + +//------------------------------------------------- +// remaining - return the amount of time +// remaining until the timer expires +//------------------------------------------------- + +attotime emu_timer::remaining() const +{ + return m_expire - machine().time(); +} + + +//------------------------------------------------- +// timer_register_save - register ourself with +// the save state system +//------------------------------------------------- + +void emu_timer::register_save() +{ + // determine our instance number and name + int index = 0; + astring name; + + // for non-device timers, it is an index based on the callback function name + if (m_device == NULL) + { + name = m_func; + for (emu_timer *curtimer = machine().scheduler().first_timer(); curtimer != NULL; curtimer = curtimer->next()) + if (!curtimer->m_temporary && curtimer->m_device == NULL && strcmp(curtimer->m_func, m_func) == 0) + index++; + } + + // for device timers, it is an index based on the device and timer ID + else + { + name.printf("%s/%d", m_device->tag(), m_id); + for (emu_timer *curtimer = machine().scheduler().first_timer(); curtimer != NULL; curtimer = curtimer->next()) + if (!curtimer->m_temporary && curtimer->m_device != NULL && curtimer->m_device == m_device && curtimer->m_id == m_id) + index++; + } + + // save the bits + state_save_register_item(m_machine, "timer", name, index, m_param); + state_save_register_item(m_machine, "timer", name, index, m_enabled); + state_save_register_item(m_machine, "timer", name, index, m_period.seconds); + state_save_register_item(m_machine, "timer", name, index, m_period.attoseconds); + state_save_register_item(m_machine, "timer", name, index, m_start.seconds); + state_save_register_item(m_machine, "timer", name, index, m_start.attoseconds); + state_save_register_item(m_machine, "timer", name, index, m_expire.seconds); + state_save_register_item(m_machine, "timer", name, index, m_expire.attoseconds); +} + + +//------------------------------------------------- +// schedule_next_period - schedule the next +// period +//------------------------------------------------- + +void emu_timer::schedule_next_period() +{ + // advance by one period + m_start = m_expire; + m_expire += m_period; + + // remove and re-insert us + device_scheduler &scheduler = machine().scheduler(); + scheduler.timer_list_remove(*this); + scheduler.timer_list_insert(*this); +} //************************************************************************** -// CORE CPU EXECUTION +// DEVICE SCHEDULER //************************************************************************** //------------------------------------------------- @@ -88,10 +321,31 @@ enum device_scheduler::device_scheduler(running_machine &machine) : m_machine(machine), - m_quantum_set(false), m_executing_device(NULL), - m_execute_list(NULL) + m_execute_list(NULL), + m_basetime(attotime::zero), + m_timer_list(NULL), + m_timer_allocator(machine.m_respool), + m_callback_timer(NULL), + m_callback_timer_modified(false), + m_callback_timer_expire_time(attotime::zero), + m_quantum_list(machine.m_respool), + m_quantum_allocator(machine.m_respool), + m_quantum_minimum(ATTOSECONDS_IN_NSEC(1) / 1000) +{ + // append a single never-expiring timer so there is always one in the list + m_timer_list = &m_timer_allocator.alloc()->init(m_machine, NULL, NULL, NULL, true); + m_timer_list->adjust(attotime::never); +} + + +// remove me once save state registration is embedded +void device_scheduler::register_for_save() { + // register global states + state_save_register_item(&m_machine, "timer", NULL, 0, m_basetime.seconds); + state_save_register_item(&m_machine, "timer", NULL, 0, m_basetime.attoseconds); + state_save_register_postload(&m_machine, &state_postload_stub<device_scheduler, &device_scheduler::postload>, this); } @@ -101,6 +355,42 @@ device_scheduler::device_scheduler(running_machine &machine) : device_scheduler::~device_scheduler() { + // remove all timers + while (m_timer_list != NULL) + m_timer_allocator.reclaim(m_timer_list->release()); +} + + +//------------------------------------------------- +// time - return the current time +//------------------------------------------------- + +attotime device_scheduler::time() const +{ + // if we're currently in a callback, use the timer's expiration time as a base + if (m_callback_timer != NULL) + return m_callback_timer_expire_time; + + // if we're executing as a particular CPU, use its local time as a base + // otherwise, return the global base time + return (m_executing_device != NULL) ? m_executing_device->local_time() : m_basetime; +} + + +//------------------------------------------------- +// can_save - return true if it's safe to save +// (i.e., no temporary timers outstanding) +//------------------------------------------------- + +bool device_scheduler::can_save() const +{ + // if any live temporary timers exit, fail + for (emu_timer *timer = m_timer_list; timer != NULL; timer = timer->next()) + if (timer->m_temporary) + return false; + + // otherwise, we're good + return true; } @@ -112,34 +402,23 @@ device_scheduler::~device_scheduler() void device_scheduler::timeslice() { bool call_debugger = ((m_machine.debug_flags & DEBUG_FLAG_ENABLED) != 0); - timer_execution_state *timerexec = timer_get_execution_state(&m_machine); -if (TEMPLOG) printf("Timeslice start\n"); // build the execution list if we don't have one yet if (m_execute_list == NULL) rebuild_execute_list(); + // execute timers + execute_timers(); + // loop until we hit the next timer - while (ATTOTIME_LT(timerexec->basetime, timerexec->nextfire)) + while (m_basetime < m_timer_list->m_expire) { -if (TEMPLOG) -{ - void timer_print_first_timer(running_machine *machine); - printf("Timeslice loop: basetime=%15.6f\n", timerexec->basetime.as_double()); - timer_print_first_timer(&m_machine); -} - - // by default, assume our target is the end of the next quantum - attotime target; - target.seconds = timerexec->basetime.seconds; - target.attoseconds = timerexec->basetime.attoseconds + timerexec->curquantum; - ATTOTIME_NORMALIZE(target); + attotime target = m_basetime + attotime(0, m_quantum_list.first()->m_actual); // however, if the next timer is going to fire before then, override - assert((timerexec->nextfire - target).seconds <= 0); - if (ATTOTIME_LT(timerexec->nextfire, target)) - target = timerexec->nextfire; + if (m_timer_list->m_expire < target) + target = m_timer_list->m_expire; LOG(("------------------\n")); LOG(("cpu_timeslice: target = %s\n", target.as_string())); @@ -148,7 +427,7 @@ if (TEMPLOG) UINT32 suspendchanged = 0; for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) { - suspendchanged |= (exec->m_suspend ^ exec->m_nextsuspend); + suspendchanged |= exec->m_suspend ^ exec->m_nextsuspend; exec->m_suspend = exec->m_nextsuspend; exec->m_nextsuspend &= ~SUSPEND_REASON_TIMESLICE; exec->m_eatcycles = exec->m_nexteatcycles; @@ -185,7 +464,6 @@ if (TEMPLOG) // note that this global variable cycles_stolen can be modified // via the call to cpu_execute exec->m_cycles_stolen = 0; -if (TEMPLOG) printf("Executing %s for %d cycles\n", exec->device().tag(), ran); m_executing_device = exec; *exec->m_icountptr = exec->m_cycles_running; if (!call_debugger) @@ -204,30 +482,19 @@ if (TEMPLOG) printf("Executing %s for %d cycles\n", exec->device().tag(), ran); ran -= exec->m_cycles_stolen; g_profiler.stop(); } -else -if (TEMPLOG) printf("Skipping %s for %d cycles\n", exec->device().tag(), ran); // account for these cycles exec->m_totalcycles += ran; // update the local time for this CPU - attoseconds_t actualdelta = exec->m_attoseconds_per_cycle * ran; - exec->m_localtime.attoseconds += actualdelta; - ATTOTIME_NORMALIZE(exec->m_localtime); + exec->m_localtime += attotime(0, exec->m_attoseconds_per_cycle * ran); 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)) + // if the new local CPU time is less than our target, move the target up, but not before the base + if (exec->m_localtime < target) { 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(target < timerexec->basetime); - target = timerexec->basetime; - } + target = max(exec->m_localtime, m_basetime); LOG((" (new target)\n")); } } @@ -236,12 +503,41 @@ if (TEMPLOG) printf("Skipping %s for %d cycles\n", exec->device().tag(), ran); m_executing_device = NULL; // update the base time - timerexec->basetime = target; + m_basetime = target; } -if (TEMPLOG) printf("Timeslice end\n"); +} - // execute timers - timer_execute_timers(&m_machine); + +//------------------------------------------------- +// abort_timeslice - abort execution for the +// current timeslice +//------------------------------------------------- + +void device_scheduler::abort_timeslice() +{ + if (m_executing_device != NULL) + m_executing_device->abort_timeslice(); +} + + +//------------------------------------------------- +// trigger - generate a global trigger +//------------------------------------------------- + +void device_scheduler::trigger(int trigid, attotime after) +{ + // ensure we have a list of executing devices + if (m_execute_list == NULL) + rebuild_execute_list(); + + // if we have a non-zero time, schedule a timer + if (after != attotime::zero) + timer_set(after, MFUNC(timer_expired, device_scheduler, timed_trigger), trigid, this); + + // send the trigger to everyone who cares + else + for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) + exec->trigger(trigid); } @@ -255,68 +551,116 @@ void device_scheduler::boost_interleave(attotime timeslice_time, attotime boost_ // ignore timeslices > 1 second if (timeslice_time.seconds > 0) return; - timer_add_scheduling_quantum(&m_machine, timeslice_time.attoseconds, boost_duration); + add_scheduling_quantum(timeslice_time, boost_duration); } //------------------------------------------------- -// eat_all_cycles - eat a ton of cycles on all -// CPUs to force a quick exit +// timer_alloc - allocate a global non-device +// timer and return a pointer //------------------------------------------------- -void device_scheduler::eat_all_cycles() +emu_timer *device_scheduler::timer_alloc(timer_expired_func callback, const char *name, void *ptr) { - for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) - exec->eat_cycles(1000000000); + return &m_timer_allocator.alloc()->init(m_machine, callback, name, ptr, false); } +//------------------------------------------------- +// timer_set - allocate an anonymous non-device +// timer and set it to go off after the given +// amount of time +//------------------------------------------------- + +void device_scheduler::timer_set(attotime duration, timer_expired_func callback, const char *name, int param, void *ptr) +{ + m_timer_allocator.alloc()->init(m_machine, callback, name, ptr, true).adjust(duration, param); +} -//************************************************************************** -// GLOBAL HELPERS -//************************************************************************** //------------------------------------------------- -// cpuexec_abort_timeslice - abort execution -// for the current timeslice +// timer_pulse - allocate an anonymous non-device +// timer and set it to go off at the given +// frequency //------------------------------------------------- -void device_scheduler::abort_timeslice() +void device_scheduler::timer_pulse(attotime period, timer_expired_func callback, const char *name, int param, void *ptr) { - if (m_executing_device != NULL) - m_executing_device->abort_timeslice(); + m_timer_allocator.alloc()->init(m_machine, callback, name, ptr, true).adjust(period, param, period); } //------------------------------------------------- -// trigger - generate a global trigger +// timer_alloc - allocate a global device timer +// and return a pointer //------------------------------------------------- -void device_scheduler::trigger(int trigid, attotime after) +emu_timer *device_scheduler::timer_alloc(device_t &device, device_timer_id id, void *ptr) { - // ensure we have a list of executing devices - if (m_execute_list == NULL) - rebuild_execute_list(); + return &m_timer_allocator.alloc()->init(device, id, ptr, false); +} - // if we have a non-zero time, schedule a timer - if (after.attoseconds != 0 || after.seconds != 0) - timer_set(&m_machine, after, (void *)this, trigid, static_timed_trigger); - // send the trigger to everyone who cares - else - for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) - exec->trigger(trigid); +//------------------------------------------------- +// timer_set - allocate an anonymous device timer +// and set it to go off after the given amount of +// time +//------------------------------------------------- + +void device_scheduler::timer_set(attotime duration, device_t &device, device_timer_id id, int param, void *ptr) +{ + m_timer_allocator.alloc()->init(device, id, ptr, true).adjust(duration, param); +} + + +//------------------------------------------------- +// eat_all_cycles - eat a ton of cycles on all +// CPUs to force a quick exit +//------------------------------------------------- + +void device_scheduler::eat_all_cycles() +{ + for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) + exec->eat_cycles(1000000000); } //------------------------------------------------- -// static_timed_trigger - generate a trigger -// after a given amount of time +// timed_trigger - generate a trigger after a +// given amount of time //------------------------------------------------- -TIMER_CALLBACK( device_scheduler::static_timed_trigger ) +void device_scheduler::timed_trigger(running_machine &machine, INT32 param) { - reinterpret_cast<device_scheduler *>(ptr)->trigger(param); + trigger(param); +} + + +//------------------------------------------------- +// postload - after loading a save state +//------------------------------------------------- + +void device_scheduler::postload() +{ + // remove all timers and make a private list of permanent ones + simple_list<emu_timer> private_list; + while (m_timer_list != NULL) + { + emu_timer &timer = *m_timer_list; + + // temporary timers go away entirely + if (timer.m_temporary) + m_timer_allocator.reclaim(timer.release()); + + // permanent ones get added to our private list + else + private_list.append(timer_list_remove(timer)); + } + + // now re-insert them; this effectively re-sorts them by time + emu_timer *timer; + while ((timer = private_list.detach_head()) != NULL) + timer_list_insert(*timer); } @@ -335,15 +679,13 @@ void device_scheduler::compute_perfect_interleave() device_execute_interface *first = m_execute_list; if (first != NULL) { + // start with a huge time factor and find the 2nd smallest cycle time attoseconds_t smallest = first->minimum_quantum(); attoseconds_t perfect = ATTOSECONDS_PER_SECOND - 1; - - // start with a huge time factor and find the 2nd smallest cycle time for (device_execute_interface *exec = first->m_nextexec; exec != NULL; exec = exec->m_nextexec) { - attoseconds_t curquantum = exec->minimum_quantum(); - // find the 2nd smallest cycle interval + attoseconds_t curquantum = exec->minimum_quantum(); if (curquantum < smallest) { perfect = smallest; @@ -353,10 +695,14 @@ void device_scheduler::compute_perfect_interleave() perfect = curquantum; } - // adjust the final value - timer_set_minimum_quantum(&m_machine, perfect); - - LOG(("Perfect interleave = %.9f, smallest = %.9f\n", ATTOSECONDS_TO_DOUBLE(perfect), ATTOSECONDS_TO_DOUBLE(smallest))); + // if this is a new minimum quantum, apply it + if (m_quantum_minimum != perfect) + { + // adjust all the actuals; this doesn't affect the current + m_quantum_minimum = perfect; + for (quantum_slot *quant = m_quantum_list.first(); quant != NULL; quant = quant->next()) + quant->m_actual = MAX(quant->m_requested, m_quantum_minimum); + } } } @@ -370,7 +716,7 @@ void device_scheduler::compute_perfect_interleave() void device_scheduler::rebuild_execute_list() { // if we haven't yet set a scheduling quantum, do it now - if (!m_quantum_set) + if (m_quantum_list.first() == NULL) { // set the core scheduling quantum attotime min_quantum = m_machine.config->m_minimum_quantum; @@ -393,11 +739,11 @@ void device_scheduler::rebuild_execute_list() min_quantum = min(attotime(0, exec->minimum_quantum()), min_quantum); } + // make sure it's no higher than 60Hz + min_quantum = min(min_quantum, attotime::from_hz(60)); + // inform the timer system of our decision - assert(min_quantum.seconds == 0); - timer_add_scheduling_quantum(&m_machine, min_quantum.attoseconds, attotime::never); -if (TEMPLOG) printf("Setting quantum: %08X%08X\n", (UINT32)(min_quantum.attoseconds >> 32), (UINT32)min_quantum.attoseconds); - m_quantum_set = true; + add_scheduling_quantum(min_quantum, attotime::never); } // start with an empty list @@ -428,11 +774,220 @@ if (TEMPLOG) printf("Setting quantum: %08X%08X\n", (UINT32)(min_quantum.attoseco // append the suspend list to the end of the active list *active_tailptr = suspend_list; -if (TEMPLOG) +} + + +//------------------------------------------------- +// timer_list_insert - insert a new timer into +// the list at the appropriate location +//------------------------------------------------- + +emu_timer &device_scheduler::timer_list_insert(emu_timer &timer) +{ + // disabled timers sort to the end + attotime expire = timer.m_enabled ? timer.m_expire : attotime::never; + + // loop over the timer list + emu_timer *prevtimer = NULL; + for (emu_timer *curtimer = m_timer_list; curtimer != NULL; prevtimer = curtimer, curtimer = curtimer->next()) + { + // if the current list entry expires after us, we should be inserted before it + if (curtimer->m_expire > expire) + { + // link the new guy in before the current list entry + timer.m_prev = curtimer->m_prev; + timer.m_next = curtimer; + + if (curtimer->m_prev != NULL) + curtimer->m_prev->m_next = &timer; + else + m_timer_list = &timer; + + curtimer->m_prev = &timer; + return timer; + } + } + + // need to insert after the last one + if (prevtimer != NULL) + prevtimer->m_next = &timer; + else + m_timer_list = &timer; + + timer.m_prev = prevtimer; + timer.m_next = NULL; + return timer; +} + + +//------------------------------------------------- +// timer_list_remove - remove a timer from the +// linked list +//------------------------------------------------- + +emu_timer &device_scheduler::timer_list_remove(emu_timer &timer) { - printf("Execute list:"); - for (exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) - printf(" %s", exec->device().tag()); - printf("\n"); + // remove it from the list + if (timer.m_prev != NULL) + timer.m_prev->m_next = timer.m_next; + else + m_timer_list = timer.m_next; + + if (timer.m_next != NULL) + timer.m_next->m_prev = timer.m_prev; + + return timer; } + + +//------------------------------------------------- +// execute_timers - execute timers and update +// scheduling quanta +//------------------------------------------------- + +void device_scheduler::execute_timers() +{ + // if the current quantum has expired, find a new one + while (m_basetime >= m_quantum_list.first()->m_expire) + m_quantum_allocator.reclaim(m_quantum_list.detach_head()); + + LOG(("timer_set_global_time: new=%s head->expire=%s\n", m_basetime.as_string(), m_timer_list->m_expire.as_string())); + + // now process any timers that are overdue + while (m_timer_list->m_expire <= m_basetime) + { + // if this is a one-shot timer, disable it now + emu_timer &timer = *m_timer_list; + bool was_enabled = timer.m_enabled; + if (timer.m_period == attotime::zero || timer.m_period == attotime::never) + timer.m_enabled = false; + + // set the global state of which callback we're in + m_callback_timer_modified = false; + m_callback_timer = &timer; + m_callback_timer_expire_time = timer.m_expire; + + // call the callback + if (was_enabled) + { + g_profiler.start(PROFILER_TIMER_CALLBACK); + + if (timer.m_device != NULL) + timer.m_device->timer_expired(timer, timer.m_id, timer.m_param, timer.m_ptr); + else if (timer.m_callback != NULL) + (*timer.m_callback)(&m_machine, timer.m_ptr, timer.m_param); + + g_profiler.stop(); + } + + // clear the callback timer global + m_callback_timer = NULL; + + // reset or remove the timer, but only if it wasn't modified during the callback + if (!m_callback_timer_modified) + { + // if the timer is temporary, remove it now + if (timer.m_temporary) + m_timer_allocator.reclaim(timer.release()); + + // otherwise, reschedule it + else + timer.schedule_next_period(); + } + } } + + +//------------------------------------------------- +// add_scheduling_quantum - add a scheduling +// quantum; the smallest active one is the one +// that is in use +//------------------------------------------------- + +void device_scheduler::add_scheduling_quantum(attotime quantum, attotime duration) +{ + assert(quantum.seconds == 0); + + attotime curtime = time(); + attotime expire = curtime + duration; + + // figure out where to insert ourselves, expiring any quanta that are out-of-date + quantum_slot *insert_after = NULL; + quantum_slot *next; + for (quantum_slot *quant = m_quantum_list.first(); quant != NULL; quant = next) + { + // if this quantum is expired, nuke it + next = quant->next(); + if (curtime >= quant->m_expire) + m_quantum_allocator.reclaim(m_quantum_list.detach(*quant)); + + // if this quantum is shorter than us, we need to be inserted afterwards + else if (quant->m_requested <= quantum.attoseconds) + insert_after = quant; + } + + // if we found an exact match, just take the maximum expiry time + if (insert_after != NULL && insert_after->m_requested == quantum.attoseconds) + insert_after->m_expire = max(insert_after->m_expire, expire); + + // otherwise, allocate a new quantum and insert it after the one we picked + else + { + quantum_slot &quant = *m_quantum_allocator.alloc(); + quant.m_requested = quantum.attoseconds; + quant.m_actual = MAX(quantum.attoseconds, m_quantum_minimum); + quant.m_expire = expire; + m_quantum_list.insert_after(quant, insert_after); + } +} + + + + + +attotime timer_get_time(running_machine *machine) { return machine->time(); } + + + +/*************************************************************************** +// DEBUGGING +***************************************************************************/ + +#if 0 +//------------------------------------------------- +// timer_logtimers - log all the timers +//------------------------------------------------- + +static void timer_logtimers(running_machine *machine) +{ + emu_timer *t; + + logerror("===============\n"); + logerror("TIMER LOG START\n"); + logerror("===============\n"); + + 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", + 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", + 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"); + logerror("==============\n"); +} + + +void timer_print_first_timer(running_machine *machine) +{ + emu_timer *t = global->activelist; + printf(" Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s)\n", + t->start.as_double(), t->expire.as_double(), t->period.as_double(), t->enabled, t->temporary, t->func); +} + + +#endif
\ No newline at end of file diff --git a/src/emu/schedule.h b/src/emu/schedule.h index 6e0aaccfdbf..ac0b9b5f36d 100644 --- a/src/emu/schedule.h +++ b/src/emu/schedule.h @@ -51,54 +51,218 @@ // MACROS //************************************************************************** +// this macro wraps a function 'x' and can be used to pass a function followed by its name +#define FUNC(x) x, #x + +// this macro wraps a member function 'x' from class 'c' using a templatized stub of type 's' +#define MFUNC(s,c,x) s##_stub<c, &c::x>, #c "::" #x + + // these must be macros because we are included before the running_machine #define cpuexec_describe_context(mach) (mach)->describe_context() #define cpuexec_boost_interleave(mach, slice, dur) (mach)->scheduler().boost_interleave(slice, dur) #define cpuexec_trigger(mach, trigid) (mach)->scheduler().trigger(trigid) #define cpuexec_triggertime(mach, trigid, dur) (mach)->scheduler().trigger(trigid, dur) +// macro for the RC time constant on a 74LS123 with C > 1000pF +// R is in ohms, C is in farads +#define TIME_OF_74LS123(r,c) (0.45 * (double)(r) * (double)(c)) + +// macros for the RC time constant on a 555 timer IC +// R is in ohms, C is in farads +#define PERIOD_OF_555_MONOSTABLE_NSEC(r,c) ((attoseconds_t)(1100000000 * (double)(r) * (double)(c))) +#define PERIOD_OF_555_ASTABLE_NSEC(r1,r2,c) ((attoseconds_t)( 693000000 * ((double)(r1) + 2.0 * (double)(r2)) * (double)(c))) +#define PERIOD_OF_555_MONOSTABLE(r,c) attotime::from_nsec(PERIOD_OF_555_MONOSTABLE_NSEC(r,c)) +#define PERIOD_OF_555_ASTABLE(r1,r2,c) attotime::from_nsec(PERIOD_OF_555_ASTABLE_NSEC(r1,r2,c)) + +#define TIMER_CALLBACK(name) void name(running_machine *machine, void *ptr, int param) + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** +// timer callbacks look like this +typedef void (*timer_expired_func)(running_machine *machine, void *ptr, INT32 param); + +// stub for when the ptr parameter points to a class +template<class T, void (T::*func)(running_machine &machine, INT32 param)> +void timer_expired_stub(running_machine *machine, void *ptr, INT32 param) +{ + T *target = reinterpret_cast<T *>(ptr); + (target->*func)(*machine, param); +} + + +// ======================> emu_timer + +class emu_timer +{ + friend class device_scheduler; + friend class simple_list<emu_timer>; + friend class fixed_allocator<emu_timer>; + + // construction/destruction + emu_timer(); + + // allocation and re-use + emu_timer &init(running_machine &machine, timer_expired_func callback, const char *name, void *ptr, bool temporary); + emu_timer &init(device_t &device, device_timer_id id, void *ptr, bool temporary); + emu_timer &release(); + +public: + // getters + emu_timer *next() const { return m_next; } + running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } + bool enabled() const { return m_enabled; } + int param() const { return m_param; } + void *ptr() const { return m_ptr; } + + // setters + bool enable(bool enable = true); + void set_param(int param) { m_param = param; } + void set_ptr(void *ptr) { m_ptr = ptr; } + + // control + void reset(attotime duration) { adjust(duration, m_param, m_period); } + void adjust(attotime duration, INT32 param = 0, attotime periodicity = attotime::never); + + // timing queries + attotime elapsed() const; + attotime remaining() const; + attotime start() const { return m_start; } + attotime expire() const { return m_expire; } + +private: + // internal helpers + void register_save(); + void schedule_next_period(); + + // internal state + running_machine * m_machine; // reference to the owning machine + emu_timer * m_next; // next timer in order in the list + emu_timer * m_prev; // previous timer in order in the list + timer_expired_func m_callback; // callback function + INT32 m_param; // integer parameter + void * m_ptr; // pointer parameter + const char * m_func; // string name of the callback function + bool m_enabled; // is the timer enabled? + bool m_temporary; // is the timer temporary? + attotime m_period; // the repeat frequency of the timer + attotime m_start; // time when the timer was started + attotime m_expire; // time when the timer will expire + device_t * m_device; // for device timers, a pointer to the device + device_timer_id m_id; // for device timers, the ID of the timer +}; + + // ======================> device_scheduler class device_scheduler { friend class device_execute_interface; + friend class emu_timer; public: + // construction/destruction device_scheduler(running_machine &machine); ~device_scheduler(); + void register_for_save(); - void timeslice(); + // getters + attotime time() const; + emu_timer *first_timer() const { return m_timer_list; } + device_execute_interface *currently_executing() const { return m_executing_device; } + bool can_save() const; + // execution + void timeslice(); + void abort_timeslice(); void trigger(int trigid, attotime after = attotime::zero); - void boost_interleave(attotime timeslice_time, attotime boost_duration); - void abort_timeslice(); + + // timers, specified by callback/name + emu_timer *timer_alloc(timer_expired_func callback, const char *name, void *ptr = NULL); + void timer_set(attotime duration, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL); + void timer_pulse(attotime period, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL); + void synchronize(timer_expired_func callback = NULL, const char *name = NULL, int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, name, param, ptr); } - device_execute_interface *currently_executing() const { return m_executing_device; } - - // for timer system only! - attotime override_local_time(attotime default_time); + // timers, specified by device/id; generally devices should use the device_t methods instead + emu_timer *timer_alloc(device_t &device, device_timer_id id = 0, void *ptr = NULL); + void timer_set(attotime duration, device_t &device, device_timer_id id = 0, int param = 0, void *ptr = NULL); // for emergencies only! void eat_all_cycles(); private: + // callbacks + void timed_trigger(running_machine &machine, INT32 param); + void postload(); + + // scheduling helpers void compute_perfect_interleave(); void rebuild_execute_list(); + void add_scheduling_quantum(attotime quantum, attotime duration); + + // timer helpers + emu_timer &timer_list_insert(emu_timer &timer); + emu_timer &timer_list_remove(emu_timer &timer); + void execute_timers(); + + // internal state + running_machine & m_machine; // reference to our machine + device_execute_interface * m_executing_device; // pointer to currently executing device + device_execute_interface * m_execute_list; // list of devices to be executed + attotime m_basetime; // global basetime; everything moves forward from here + + // list of active timers + emu_timer * m_timer_list; // head of the active list + fixed_allocator<emu_timer> m_timer_allocator; // allocator for timers - static TIMER_CALLBACK( static_timed_trigger ); + // other internal states + emu_timer * m_callback_timer; // pointer to the current callback timer + bool m_callback_timer_modified; // true if the current callback timer was modified + attotime m_callback_timer_expire_time; // the original expiration time - running_machine & m_machine; // reference to our owner - bool m_quantum_set; // have we set the scheduling quantum yet? - device_execute_interface * m_executing_device; // pointer to currently executing device - device_execute_interface * m_execute_list; // list of devices to be executed + // scheduling quanta + class quantum_slot + { + friend class simple_list<quantum_slot>; + + public: + quantum_slot *next() const { return m_next; } + + quantum_slot * m_next; + attoseconds_t m_actual; // actual duration of the quantum + attoseconds_t m_requested; // duration of the requested quantum + attotime m_expire; // absolute expiration time of this quantum + }; + simple_list<quantum_slot> m_quantum_list; // list of active quanta + fixed_allocator<quantum_slot> m_quantum_allocator; // allocator for quanta + attoseconds_t m_quantum_minimum; // duration of minimum quantum }; -#endif /* __SCHEDULE_H__ */ + + +// temporary stuff +attotime timer_get_time(running_machine *machine); + +inline void timer_adjust_oneshot(emu_timer *which, attotime duration, INT32 param) { which->adjust(duration, param); } +inline void timer_adjust_periodic(emu_timer *which, attotime start_delay, INT32 param, attotime period) { which->adjust(start_delay, param, period); } + +inline void timer_reset(emu_timer *which, attotime duration) { which->reset(duration); } +inline int timer_enable(emu_timer *which, int enable) { return which->enable(enable); } +inline int timer_enabled(emu_timer *which) { return which->enabled(); } +inline int timer_get_param(emu_timer *which) { return which->param(); } +inline void timer_set_param(emu_timer *which, int param) { which->set_param(param); } +inline void *timer_get_ptr(emu_timer *which) { return which->ptr(); } +inline void timer_set_ptr(emu_timer *which, void *ptr) { which->set_ptr(ptr); } + +inline attotime timer_timeelapsed(emu_timer *which) { return which->elapsed(); } +inline attotime timer_timeleft(emu_timer *which) { return which->remaining(); } +inline attotime timer_starttime(emu_timer *which) { return which->start(); } +inline attotime timer_firetime(emu_timer *which) { return which->expire(); } + +#endif // __SCHEDULE_H__ */ diff --git a/src/emu/screen.c b/src/emu/screen.c index 6596331d5ec..bdd9c04a105 100644 --- a/src/emu/screen.c +++ b/src/emu/screen.c @@ -341,15 +341,15 @@ void screen_device::device_start() m_container->set_user_settings(settings); // allocate the VBLANK timers - m_vblank_begin_timer = timer_alloc(machine, static_vblank_begin_callback, (void *)this); - m_vblank_end_timer = timer_alloc(machine, static_vblank_end_callback, (void *)this); + m_vblank_begin_timer = machine->scheduler().timer_alloc(FUNC(static_vblank_begin_callback), (void *)this); + m_vblank_end_timer = machine->scheduler().timer_alloc(FUNC(static_vblank_end_callback), (void *)this); // allocate a timer to reset partial updates - m_scanline0_timer = timer_alloc(machine, static_scanline0_callback, (void *)this); + m_scanline0_timer = machine->scheduler().timer_alloc(FUNC(static_scanline0_callback), (void *)this); // allocate a timer to generate per-scanline updates if ((machine->config->m_video_attributes & VIDEO_UPDATE_SCANLINE) != 0) - m_scanline_timer = timer_alloc(machine, static_scanline_update_callback, (void *)this); + m_scanline_timer = machine->scheduler().timer_alloc(FUNC(static_scanline_update_callback), (void *)this); // configure the screen with the default parameters configure(m_config.m_width, m_config.m_height, m_config.m_visarea, m_config.m_refresh); diff --git a/src/emu/sound.c b/src/emu/sound.c index d297d96d595..b8233e6a187 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -766,7 +766,7 @@ sound_stream::stream_output::stream_output() sound_manager::sound_manager(running_machine &machine) : m_machine(machine), - m_update_timer(timer_alloc(&machine, update_static, this)), + m_update_timer(machine.scheduler().timer_alloc(FUNC(update_static), this)), m_finalmix_leftover(0), m_finalmix(NULL), m_leftmix(NULL), diff --git a/src/emu/sound/2203intf.c b/src/emu/sound/2203intf.c index e8eb777602f..fc307c00ca1 100644 --- a/src/emu/sound/2203intf.c +++ b/src/emu/sound/2203intf.c @@ -134,8 +134,8 @@ static DEVICE_START( ym2203 ) assert_always(info->psg != NULL, "Error creating YM2203/AY8910 chip"); /* Timer Handler set */ - info->timer[0] = timer_alloc(device->machine, timer_callback_2203_0, info); - info->timer[1] = timer_alloc(device->machine, timer_callback_2203_1, info); + info->timer[0] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_2203_0), info); + info->timer[1] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_2203_1), info); /* stream system initialize */ info->stream = device->machine->sound().stream_alloc(*device,0,1,rate,info,ym2203_stream_update); diff --git a/src/emu/sound/2608intf.c b/src/emu/sound/2608intf.c index 3d2d7fed15f..ea7c554656f 100644 --- a/src/emu/sound/2608intf.c +++ b/src/emu/sound/2608intf.c @@ -152,8 +152,8 @@ static DEVICE_START( ym2608 ) assert_always(info->psg != NULL, "Error creating YM2608/AY8910 chip"); /* Timer Handler set */ - info->timer[0] = timer_alloc(device->machine, timer_callback_2608_0, info); - info->timer[1] = timer_alloc(device->machine, timer_callback_2608_1, info); + info->timer[0] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_2608_0), info); + info->timer[1] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_2608_1), info); /* stream system initialize */ info->stream = device->machine->sound().stream_alloc(*device,0,2,rate,info,ym2608_stream_update); diff --git a/src/emu/sound/2610intf.c b/src/emu/sound/2610intf.c index 829dc1ceae2..8f6c53877b7 100644 --- a/src/emu/sound/2610intf.c +++ b/src/emu/sound/2610intf.c @@ -156,8 +156,8 @@ static DEVICE_START( ym2610 ) assert_always(info->psg != NULL, "Error creating YM2610/AY8910 chip"); /* Timer Handler set */ - info->timer[0] = timer_alloc(device->machine, timer_callback_0, info); - info->timer[1] = timer_alloc(device->machine, timer_callback_1, info); + info->timer[0] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_0), info); + info->timer[1] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_1), info); /* stream system initialize */ info->stream = device->machine->sound().stream_alloc(*device,0,2,rate,info,(type == YM2610) ? ym2610_stream_update : ym2610b_stream_update); diff --git a/src/emu/sound/2612intf.c b/src/emu/sound/2612intf.c index 43ea0d97c73..7495d182bdc 100644 --- a/src/emu/sound/2612intf.c +++ b/src/emu/sound/2612intf.c @@ -108,8 +108,8 @@ static DEVICE_START( ym2612 ) /* FM init */ /* Timer Handler set */ - info->timer[0] = timer_alloc(device->machine, timer_callback_2612_0, info); - info->timer[1] = timer_alloc(device->machine, timer_callback_2612_1, info); + info->timer[0] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_2612_0), info); + info->timer[1] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_2612_1), info); /* stream system initialize */ info->stream = device->machine->sound().stream_alloc(*device,0,2,rate,info,ym2612_stream_update); diff --git a/src/emu/sound/262intf.c b/src/emu/sound/262intf.c index d093a1f4951..31ed8fb294a 100644 --- a/src/emu/sound/262intf.c +++ b/src/emu/sound/262intf.c @@ -95,8 +95,8 @@ static DEVICE_START( ymf262 ) ymf262_set_irq_handler (info->chip, IRQHandler_262, info); ymf262_set_update_handler(info->chip, _stream_update, info); - info->timer[0] = timer_alloc(device->machine, timer_callback_262_0, info); - info->timer[1] = timer_alloc(device->machine, timer_callback_262_1, info); + info->timer[0] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_262_0), info); + info->timer[1] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_262_1), info); } static DEVICE_STOP( ymf262 ) diff --git a/src/emu/sound/3526intf.c b/src/emu/sound/3526intf.c index 7d1add9c682..231c12c55a6 100644 --- a/src/emu/sound/3526intf.c +++ b/src/emu/sound/3526intf.c @@ -105,8 +105,8 @@ static DEVICE_START( ym3526 ) ym3526_set_irq_handler (info->chip, IRQHandler, info); ym3526_set_update_handler(info->chip, _stream_update, info); - info->timer[0] = timer_alloc(device->machine, timer_callback_0, info); - info->timer[1] = timer_alloc(device->machine, timer_callback_1, info); + info->timer[0] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_0), info); + info->timer[1] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_1), info); } static DEVICE_STOP( ym3526 ) diff --git a/src/emu/sound/3812intf.c b/src/emu/sound/3812intf.c index 7b1ff8fa8b0..2fc3f965efc 100644 --- a/src/emu/sound/3812intf.c +++ b/src/emu/sound/3812intf.c @@ -106,8 +106,8 @@ static DEVICE_START( ym3812 ) ym3812_set_irq_handler (info->chip, IRQHandler, info); ym3812_set_update_handler(info->chip, _stream_update, info); - info->timer[0] = timer_alloc(device->machine, timer_callback_0, info); - info->timer[1] = timer_alloc(device->machine, timer_callback_1, info); + info->timer[0] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_0), info); + info->timer[1] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_1), info); } static DEVICE_STOP( ym3812 ) diff --git a/src/emu/sound/8950intf.c b/src/emu/sound/8950intf.c index 4aac018173b..6a1ebc76d60 100644 --- a/src/emu/sound/8950intf.c +++ b/src/emu/sound/8950intf.c @@ -139,8 +139,8 @@ static DEVICE_START( y8950 ) y8950_set_irq_handler (info->chip, IRQHandler, info); y8950_set_update_handler(info->chip, _stream_update, info); - info->timer[0] = timer_alloc(device->machine, timer_callback_0, info); - info->timer[1] = timer_alloc(device->machine, timer_callback_1, info); + info->timer[0] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_0), info); + info->timer[1] = device->machine->scheduler().timer_alloc(FUNC(timer_callback_1), info); } static DEVICE_STOP( y8950 ) diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c index 16fa5668116..abaa3d72287 100644 --- a/src/emu/sound/aica.c +++ b/src/emu/sound/aica.c @@ -517,9 +517,9 @@ static void AICA_Init(device_t *device, aica_state *AICA, const aica_interface * } } - AICA->timerA = timer_alloc(device->machine, timerA_cb, AICA); - AICA->timerB = timer_alloc(device->machine, timerB_cb, AICA); - AICA->timerC = timer_alloc(device->machine, timerC_cb, AICA); + AICA->timerA = device->machine->scheduler().timer_alloc(FUNC(timerA_cb), AICA); + AICA->timerB = device->machine->scheduler().timer_alloc(FUNC(timerB_cb), AICA); + AICA->timerC = device->machine->scheduler().timer_alloc(FUNC(timerC_cb), AICA); for(i=0;i<0x400;++i) { diff --git a/src/emu/sound/asc.c b/src/emu/sound/asc.c index 0835801f4c8..06b2bd5770a 100644 --- a/src/emu/sound/asc.c +++ b/src/emu/sound/asc.c @@ -133,7 +133,7 @@ void asc_device::device_start() memset(m_regs, 0, sizeof(m_regs)); - m_sync_timer = timer_alloc(this->machine, sync_timer_cb, this); + m_sync_timer = this->machine->scheduler().timer_alloc(FUNC(sync_timer_cb), this); state_save_register_device_item(this, 0, m_fifo_a_rdptr); state_save_register_device_item(this, 0, m_fifo_b_rdptr); diff --git a/src/emu/sound/bsmt2000.c b/src/emu/sound/bsmt2000.c index 830282e2318..933a013a037 100644 --- a/src/emu/sound/bsmt2000.c +++ b/src/emu/sound/bsmt2000.c @@ -245,7 +245,7 @@ void bsmt2000_device::device_start() void bsmt2000_device::device_reset() { - device_timer_call_after_resynch(*this, TIMER_ID_RESET); + synchronize(TIMER_ID_RESET); } @@ -312,7 +312,7 @@ UINT16 bsmt2000_device::read_status() void bsmt2000_device::write_reg(UINT16 data) { - device_timer_call_after_resynch(*this, TIMER_ID_REG_WRITE, data); + synchronize(TIMER_ID_REG_WRITE, data); } @@ -323,7 +323,7 @@ void bsmt2000_device::write_reg(UINT16 data) void bsmt2000_device::write_data(UINT16 data) { - device_timer_call_after_resynch(*this, TIMER_ID_DATA_WRITE, data); + synchronize(TIMER_ID_DATA_WRITE, data); // boost the interleave on a write so that the caller detects the status more accurately m_machine.scheduler().boost_interleave(attotime::from_usec(1), attotime::from_usec(10)); diff --git a/src/emu/sound/cdp1864.c b/src/emu/sound/cdp1864.c index bf71f8b81e5..c27ef632f46 100644 --- a/src/emu/sound/cdp1864.c +++ b/src/emu/sound/cdp1864.c @@ -449,9 +449,9 @@ static DEVICE_START( cdp1864 ) cdp1864->stream = device->machine->sound().stream_alloc(*device, 0, 1, device->machine->sample_rate, cdp1864, cdp1864_stream_update); /* create the timers */ - cdp1864->int_timer = timer_alloc(device->machine, cdp1864_int_tick, (void *)device); - cdp1864->efx_timer = timer_alloc(device->machine, cdp1864_efx_tick, (void *)device); - cdp1864->dma_timer = timer_alloc(device->machine, cdp1864_dma_tick, (void *)device); + cdp1864->int_timer = device->machine->scheduler().timer_alloc(FUNC(cdp1864_int_tick), (void *)device); + cdp1864->efx_timer = device->machine->scheduler().timer_alloc(FUNC(cdp1864_efx_tick), (void *)device); + cdp1864->dma_timer = device->machine->scheduler().timer_alloc(FUNC(cdp1864_dma_tick), (void *)device); /* register for state saving */ state_save_register_device_item(device, 0, cdp1864->disp); diff --git a/src/emu/sound/cdp1869.c b/src/emu/sound/cdp1869.c index d05b55b9f6a..9ca72b470d9 100644 --- a/src/emu/sound/cdp1869.c +++ b/src/emu/sound/cdp1869.c @@ -427,7 +427,7 @@ void cdp1869_device::device_start() m_out_char_ram_func = m_config.out_char_ram_func; // allocate timers - m_prd_timer = device_timer_alloc(*this); + m_prd_timer = timer_alloc(); update_prd_changed_timer(); // initialize palette diff --git a/src/emu/sound/es5503.c b/src/emu/sound/es5503.c index 76270f4798b..63d86e5c6cd 100644 --- a/src/emu/sound/es5503.c +++ b/src/emu/sound/es5503.c @@ -259,7 +259,7 @@ static DEVICE_START( es5503 ) chip->oscillators[osc].irqpend = 0; chip->oscillators[osc].accumulator = 0; - chip->oscillators[osc].timer = timer_alloc(device->machine, es5503_timer_cb, &chip->oscillators[osc]); + chip->oscillators[osc].timer = device->machine->scheduler().timer_alloc(FUNC(es5503_timer_cb), &chip->oscillators[osc]); chip->oscillators[osc].chip = (void *)chip; } diff --git a/src/emu/sound/fmopl.c b/src/emu/sound/fmopl.c index 02e410727b9..a04c5db335c 100644 --- a/src/emu/sound/fmopl.c +++ b/src/emu/sound/fmopl.c @@ -1744,7 +1744,7 @@ static int OPL_LockTable(device_t *device) { cymfile = fopen("3812_.cym","wb"); if (cymfile) - timer_pulse ( device->machine, attotime::from_hz(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/ + device->machine->scheduler().timer_pulse ( attotime::from_hz(110), FUNC(cymfile_callback)); /*110 Hz pulse timer*/ else logerror("Could not create file 3812_.cym\n"); } diff --git a/src/emu/sound/ics2115.c b/src/emu/sound/ics2115.c index ae60548a1ad..82645070acd 100644 --- a/src/emu/sound/ics2115.c +++ b/src/emu/sound/ics2115.c @@ -47,8 +47,8 @@ ics2115_device::ics2115_device(running_machine &machine, const ics2115_device_co void ics2115_device::device_start() { m_rom = *region(); - m_timer[0].timer = timer_alloc(machine, timer_cb_0, this); - m_timer[1].timer = timer_alloc(machine, timer_cb_1, this); + m_timer[0].timer = machine->scheduler().timer_alloc(FUNC(timer_cb_0), this); + m_timer[1].timer = machine->scheduler().timer_alloc(FUNC(timer_cb_1), this); m_stream = m_machine.sound().stream_alloc(*this, 0, 2, 33075); //Exact formula as per patent 5809466 diff --git a/src/emu/sound/k053260.c b/src/emu/sound/k053260.c index 6a0088b7d1b..479df201061 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::from_hz(device->clock()) * 32, NULL, 0, ic->intf->irq ); + device->machine->scheduler().timer_pulse( attotime::from_hz(device->clock()) * 32, FUNC(ic->intf->irq )); } INLINE void check_bounds( k053260_state *ic, int channel ) diff --git a/src/emu/sound/k053260.h b/src/emu/sound/k053260.h index 468973b024a..658e6e52344 100644 --- a/src/emu/sound/k053260.h +++ b/src/emu/sound/k053260.h @@ -14,7 +14,7 @@ typedef struct _k053260_interface k053260_interface; struct _k053260_interface { const char *rgnoverride; - timer_fired_func irq; /* called on SH1 complete cycle ( clock / 32 ) */ + timer_expired_func irq; /* called on SH1 complete cycle ( clock / 32 ) */ }; diff --git a/src/emu/sound/k054539.c b/src/emu/sound/k054539.c index b745cd081f9..24ce125184c 100644 --- a/src/emu/sound/k054539.c +++ b/src/emu/sound/k054539.c @@ -470,7 +470,7 @@ static void k054539_init_chip(device_t *device, k054539_state *info) // One or more of the registers must be the timer period // And anyway, this particular frequency is probably wrong // 480 hz is TRUSTED by gokuparo disco stage - the looping sample doesn't line up otherwise - timer_pulse(device->machine, attotime::from_hz(480), info, 0, k054539_irq); + device->machine->scheduler().timer_pulse(attotime::from_hz(480), FUNC(k054539_irq), 0, info); info->stream = device->machine->sound().stream_alloc(*device, 0, 2, device->clock(), info, k054539_update); diff --git a/src/emu/sound/k056800.c b/src/emu/sound/k056800.c index 24ad2c2ffe5..8074aa95d6a 100644 --- a/src/emu/sound/k056800.c +++ b/src/emu/sound/k056800.c @@ -146,7 +146,7 @@ static DEVICE_START( k056800 ) k056800->irq_cb = intf->irq_cb; - k056800->sound_cpu_timer = timer_alloc(device->machine, k056800_sound_cpu_timer_tick, k056800); + k056800->sound_cpu_timer = device->machine->scheduler().timer_alloc(FUNC(k056800_sound_cpu_timer_tick), k056800); timer_adjust_periodic(k056800->sound_cpu_timer, timer_period, 0, timer_period); state_save_register_device_item_array(device, 0, k056800->host_reg); diff --git a/src/emu/sound/msm5205.c b/src/emu/sound/msm5205.c index 749a23836f3..fe1c41e3194 100644 --- a/src/emu/sound/msm5205.c +++ b/src/emu/sound/msm5205.c @@ -188,7 +188,7 @@ static DEVICE_START( msm5205 ) /* stream system initialize */ voice->stream = device->machine->sound().stream_alloc(*device,0,1,device->clock(),voice,MSM5205_update); - voice->timer = timer_alloc(device->machine, MSM5205_vclk_callback, voice); + voice->timer = device->machine->scheduler().timer_alloc(FUNC(MSM5205_vclk_callback), voice); /* initialize */ DEVICE_RESET_CALL(msm5205); diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c index f623b3a79b1..3c45eee4917 100644 --- a/src/emu/sound/pokey.c +++ b/src/emu/sound/pokey.c @@ -651,15 +651,15 @@ static DEVICE_START( pokey ) chip->clockmult = DIV_64; chip->KBCODE = 0x09; /* Atari 800 'no key' */ chip->SKCTL = SK_RESET; /* let the RNG run after reset */ - chip->rtimer = timer_alloc(device->machine, NULL, NULL); + chip->rtimer = device->machine->scheduler().timer_alloc(FUNC(NULL)); - chip->timer[0] = timer_alloc(device->machine, pokey_timer_expire, chip); - chip->timer[1] = timer_alloc(device->machine, pokey_timer_expire, chip); - chip->timer[2] = timer_alloc(device->machine, pokey_timer_expire, chip); + chip->timer[0] = device->machine->scheduler().timer_alloc(FUNC(pokey_timer_expire), chip); + chip->timer[1] = device->machine->scheduler().timer_alloc(FUNC(pokey_timer_expire), chip); + chip->timer[2] = device->machine->scheduler().timer_alloc(FUNC(pokey_timer_expire), chip); for (i=0; i<8; i++) { - chip->ptimer[i] = timer_alloc(device->machine, pokey_pot_trigger, chip); + chip->ptimer[i] = device->machine->scheduler().timer_alloc(FUNC(pokey_pot_trigger), chip); devcb_resolve_read8(&chip->pot_r[i], &chip->intf.pot_r[i], device); } devcb_resolve_read8(&chip->allpot_r, &chip->intf.allpot_r, device); @@ -1141,9 +1141,9 @@ WRITE8_DEVICE_HANDLER( pokey_w ) * loaders from Ballblazer and Escape from Fractalus * The real times are unknown */ - timer_set(device->machine, attotime::from_usec(200), p, 0, pokey_serout_ready_cb); + device->machine->scheduler().timer_set(attotime::from_usec(200), FUNC(pokey_serout_ready_cb), 0, p); /* 10 bits (assumption 1 start, 8 data and 1 stop bit) take how long? */ - timer_set(device->machine, attotime::from_usec(2000), p, 0, pokey_serout_complete); + device->machine->scheduler().timer_set(attotime::from_usec(2000), FUNC(pokey_serout_complete), 0, p); break; case IRQEN_C: @@ -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, p->clock_period * after, p, 0, pokey_serin_ready_cb); + device->machine->scheduler().timer_set(p->clock_period * after, FUNC(pokey_serin_ready_cb), 0, p); } void pokey_break_w(device_t *device, int shift) diff --git a/src/emu/sound/scsp.c b/src/emu/sound/scsp.c index 9efe9c06aae..1ca9e424b60 100644 --- a/src/emu/sound/scsp.c +++ b/src/emu/sound/scsp.c @@ -547,9 +547,9 @@ static void SCSP_Init(device_t *device, scsp_state *scsp, const scsp_interface * scsp->SCSPRAM += intf->roffset; } - scsp->timerA = timer_alloc(device->machine, timerA_cb, scsp); - scsp->timerB = timer_alloc(device->machine, timerB_cb, scsp); - scsp->timerC = timer_alloc(device->machine, timerC_cb, scsp); + scsp->timerA = device->machine->scheduler().timer_alloc(FUNC(timerA_cb), scsp); + scsp->timerB = device->machine->scheduler().timer_alloc(FUNC(timerB_cb), scsp); + scsp->timerC = device->machine->scheduler().timer_alloc(FUNC(timerC_cb), scsp); for(i=0;i<0x400;++i) { diff --git a/src/emu/sound/sp0250.c b/src/emu/sound/sp0250.c index 049dccbc440..322c9977484 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::from_hz(device->clock()) * CLOCK_DIVIDER, sp, 0, sp0250_timer_tick); + device->machine->scheduler().timer_pulse(attotime::from_hz(device->clock()) * CLOCK_DIVIDER, FUNC(sp0250_timer_tick), 0, sp); } sp->stream = device->machine->sound().stream_alloc(*device, 0, 1, device->clock() / CLOCK_DIVIDER, sp, sp0250_update); diff --git a/src/emu/sound/tms5110.c b/src/emu/sound/tms5110.c index aba0f52b51a..2a4152132b6 100644 --- a/src/emu/sound/tms5110.c +++ b/src/emu/sound/tms5110.c @@ -1048,7 +1048,7 @@ static DEVICE_START( tms5110 ) } tms->state = CTL_STATE_INPUT; /* most probably not defined */ - tms->romclk_hack_timer = timer_alloc(device->machine, romclk_hack_timer_cb, (void *) device); + tms->romclk_hack_timer = device->machine->scheduler().timer_alloc(FUNC(romclk_hack_timer_cb), (void *) device); register_for_save_states(tms); } @@ -1421,7 +1421,7 @@ static DEVICE_START( tmsprom ) tms->device = device; tms->clock = device->clock(); - tms->romclk_timer = timer_alloc(device->machine, tmsprom_step, device); + tms->romclk_timer = device->machine->scheduler().timer_alloc(FUNC(tmsprom_step), device); timer_adjust_periodic(tms->romclk_timer, attotime::zero, 0, attotime::from_hz(tms->clock)); tms->bit = 0; diff --git a/src/emu/sound/tms5220.c b/src/emu/sound/tms5220.c index 0a67d879379..56956fb985a 100644 --- a/src/emu/sound/tms5220.c +++ b/src/emu/sound/tms5220.c @@ -1696,7 +1696,7 @@ WRITE_LINE_DEVICE_HANDLER( tms5220_rsq_w ) tms->io_ready = 0; update_ready_state(tms); /* How long does /READY stay inactive, when /RS is pulled low? I believe its almost always ~16 clocks (25 usec at 800khz as shown on the datasheet) */ - timer_set(tms->device->machine, attotime::from_hz(device->clock()/16), tms, 1, io_ready_cb); // this should take around 10-16 (closer to ~11?) cycles to complete + tms->device->machine->scheduler().timer_set(attotime::from_hz(device->clock()/16), FUNC(io_ready_cb), 1, tms); // this should take around 10-16 (closer to ~11?) cycles to complete } } } @@ -1759,7 +1759,7 @@ WRITE_LINE_DEVICE_HANDLER( tms5220_wsq_w ) SET RATE (5220C only): ? cycles (probably ~16) */ // TODO: actually HANDLE the timing differences! currently just assuming always 16 cycles - timer_set(tms->device->machine, attotime::from_hz(device->clock()/16), tms, 1, io_ready_cb); // this should take around 10-16 (closer to ~15) cycles to complete for fifo writes, TODO: but actually depends on what command is written if in command mode + tms->device->machine->scheduler().timer_set(attotime::from_hz(device->clock()/16), FUNC(io_ready_cb), 1, tms); // this should take around 10-16 (closer to ~15) cycles to complete for fifo writes, TODO: but actually depends on what command is written if in command mode } } } diff --git a/src/emu/sound/upd7759.c b/src/emu/sound/upd7759.c index d8642a4ad4d..4e7846f6d9d 100644 --- a/src/emu/sound/upd7759.c +++ b/src/emu/sound/upd7759.c @@ -655,7 +655,7 @@ static DEVICE_START( upd7759 ) /* compute the ROM base or allocate a timer */ chip->rom = chip->rombase = *device->region(); if (chip->rom == NULL) - chip->timer = timer_alloc(device->machine, upd7759_slave_update, chip); + chip->timer = device->machine->scheduler().timer_alloc(FUNC(upd7759_slave_update), chip); /* set the DRQ callback */ chip->drqcallback = intf->drqcallback; diff --git a/src/emu/sound/ym2151.c b/src/emu/sound/ym2151.c index 34c5218a86e..582fc4dbc17 100644 --- a/src/emu/sound/ym2151.c +++ b/src/emu/sound/ym2151.c @@ -824,7 +824,7 @@ static TIMER_CALLBACK( timer_callback_a ) if (chip->irq_enable & 0x04) { chip->status |= 1; - timer_set(machine, attotime::zero,chip,0,irqAon_callback); + machine->scheduler().timer_set(attotime::zero, FUNC(irqAon_callback), 0, chip); } if (chip->irq_enable & 0x80) chip->csm_req = 2; /* request KEY ON / KEY OFF sequence */ @@ -837,7 +837,7 @@ static TIMER_CALLBACK( timer_callback_b ) if (chip->irq_enable & 0x08) { chip->status |= 2; - timer_set(machine, attotime::zero,chip,0,irqBon_callback); + machine->scheduler().timer_set(attotime::zero, FUNC(irqBon_callback), 0, chip); } } #if 0 @@ -1098,7 +1098,7 @@ void ym2151_write_reg(void *_chip, int r, int v) { #ifdef USE_MAME_TIMERS chip->status &= ~1; - timer_set(chip->device->machine, attotime::zero,chip,0,irqAoff_callback); + chip->device->machine->scheduler().timer_set(attotime::zero, FUNC(irqAoff_callback), 0, chip); #else int oldstate = chip->status & 3; chip->status &= ~1; @@ -1110,7 +1110,7 @@ void ym2151_write_reg(void *_chip, int r, int v) { #ifdef USE_MAME_TIMERS chip->status &= ~2; - timer_set(chip->device->machine, attotime::zero,chip,0,irqBoff_callback); + chip->device->machine->scheduler().timer_set(attotime::zero, FUNC(irqBoff_callback), 0, chip); #else int oldstate = chip->status & 3; chip->status &= ~2; @@ -1533,8 +1533,8 @@ void * ym2151_init(device_t *device, int clock, int rate) #ifdef USE_MAME_TIMERS /* this must be done _before_ a call to ym2151_reset_chip() */ - PSG->timer_A = timer_alloc(device->machine, timer_callback_a, PSG); - PSG->timer_B = timer_alloc(device->machine, timer_callback_b, PSG); + PSG->timer_A = device->machine->scheduler().timer_alloc(FUNC(timer_callback_a), PSG); + PSG->timer_B = device->machine->scheduler().timer_alloc(FUNC(timer_callback_b), PSG); #else PSG->tim_A = 0; PSG->tim_B = 0; @@ -1546,7 +1546,7 @@ void * ym2151_init(device_t *device, int clock, int rate) { cymfile = fopen("2151_.cym","wb"); if (cymfile) - timer_pulse ( device->machine, attotime::from_hz(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/ + device->machine->scheduler().timer_pulse ( attotime::from_hz(110), FUNC(cymfile_callback)); /*110 Hz pulse timer*/ else logerror("Could not create file 2151_.cym\n"); } diff --git a/src/emu/sound/ym2413.c b/src/emu/sound/ym2413.c index 8c706e47f85..a6469694e0e 100644 --- a/src/emu/sound/ym2413.c +++ b/src/emu/sound/ym2413.c @@ -1940,7 +1940,7 @@ static int OPLL_LockTable(device_t *device) { cymfile = fopen("2413_.cym","wb"); if (cymfile) - timer_pulse ( device->machine, attotime::from_hz(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/ + device->machine->scheduler().timer_pulse ( attotime::from_hz(110), FUNC(cymfile_callback)); /*110 Hz pulse timer*/ else logerror("Could not create file 2413_.cym\n"); } diff --git a/src/emu/sound/ymf262.c b/src/emu/sound/ymf262.c index 790bb192af0..0d6ab4d9353 100644 --- a/src/emu/sound/ymf262.c +++ b/src/emu/sound/ymf262.c @@ -2268,7 +2268,7 @@ static int OPL3_LockTable(device_t *device) { cymfile = fopen("ymf262_.cym","wb"); if (cymfile) - timer_pulse ( device->machine, attotime::from_hz(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/ + device->machine->scheduler().timer_pulse ( attotime::from_hz(110), FUNC(cymfile_callback)); /*110 Hz pulse timer*/ else logerror("Could not create ymf262_.cym file\n"); } diff --git a/src/emu/sound/ymf271.c b/src/emu/sound/ymf271.c index 7e26065929f..f008c6fb705 100644 --- a/src/emu/sound/ymf271.c +++ b/src/emu/sound/ymf271.c @@ -1752,8 +1752,8 @@ static void init_state(YMF271Chip *chip, device_t *device) static void ymf271_init(device_t *device, YMF271Chip *chip, UINT8 *rom, void (*cb)(device_t *,int), const devcb_read8 *ext_read, const devcb_write8 *ext_write) { - chip->timA = timer_alloc(device->machine, ymf271_timer_a_tick, chip); - chip->timB = timer_alloc(device->machine, ymf271_timer_b_tick, chip); + chip->timA = device->machine->scheduler().timer_alloc(FUNC(ymf271_timer_a_tick), chip); + chip->timB = device->machine->scheduler().timer_alloc(FUNC(ymf271_timer_b_tick), chip); chip->rom = rom; chip->irq_callback = cb; diff --git a/src/emu/sound/ymf278b.c b/src/emu/sound/ymf278b.c index 8ab7de0cc0c..1aa9d46bb2a 100644 --- a/src/emu/sound/ymf278b.c +++ b/src/emu/sound/ymf278b.c @@ -666,8 +666,8 @@ static void ymf278b_init(device_t *device, YMF278BChip *chip, void (*cb)(device_ { chip->rom = *device->region(); chip->irq_callback = cb; - chip->timer_a = timer_alloc(device->machine, ymf278b_timer_a_tick, chip); - chip->timer_b = timer_alloc(device->machine, ymf278b_timer_b_tick, chip); + chip->timer_a = device->machine->scheduler().timer_alloc(FUNC(ymf278b_timer_a_tick), chip); + chip->timer_b = device->machine->scheduler().timer_alloc(FUNC(ymf278b_timer_b_tick), chip); chip->irq_line = CLEAR_LINE; chip->clock = device->clock(); } diff --git a/src/emu/sound/ymz280b.c b/src/emu/sound/ymz280b.c index ba874ef01ae..61c7877dc4b 100644 --- a/src/emu/sound/ymz280b.c +++ b/src/emu/sound/ymz280b.c @@ -116,7 +116,7 @@ static TIMER_CALLBACK( update_irq_state_timer_5 ); static TIMER_CALLBACK( update_irq_state_timer_6 ); static TIMER_CALLBACK( update_irq_state_timer_7 ); -static const timer_fired_func update_irq_state_cb[] = +static const timer_expired_func update_irq_state_cb[] = { update_irq_state_timer_0, update_irq_state_timer_1, @@ -205,7 +205,7 @@ static STATE_POSTLOAD( YMZ280B_state_save_update_step ) struct YMZ280BVoice *voice = &chip->voice[j]; update_step(chip, voice); if(voice->irq_schedule) - timer_set(machine, attotime::zero, chip, 0, update_irq_state_cb[j]); + machine->scheduler().timer_set(attotime::zero, FUNC(update_irq_state_cb[j]), 0, chip); } } @@ -581,7 +581,7 @@ static STREAM_UPDATE( ymz280b_update ) voice->playing = 0; /* set update_irq_state_timer. IRQ is signaled on next CPU execution. */ - timer_set(chip->device->machine, attotime::zero, chip, 0, update_irq_state_cb[v]); + chip->device->machine->scheduler().timer_set(attotime::zero, FUNC(update_irq_state_cb[v]), 0, chip); voice->irq_schedule = 1; } } diff --git a/src/emu/timer.c b/src/emu/timer.c index e93a85fbd87..05f959ee95a 100644 --- a/src/emu/timer.c +++ b/src/emu/timer.c @@ -2,11 +2,38 @@ timer.c - Functions needed to generate timing and synchronization between several - CPUs. - - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. + Timer devices. + +**************************************************************************** + + 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. ***************************************************************************/ @@ -15,7 +42,7 @@ /*************************************************************************** - DEBUGGING +// DEBUGGING ***************************************************************************/ #define VERBOSE 0 @@ -25,944 +52,13 @@ /*************************************************************************** - CONSTANTS -***************************************************************************/ - -#define MAX_TIMERS 256 -#define MAX_QUANTA 16 - -#define DEFAULT_MINIMUM_QUANTUM ATTOSECONDS_IN_MSEC(100) - - - -/*************************************************************************** - DEVICE DEFINITIONS +// DEVICE DEFINITIONS ***************************************************************************/ const device_type TIMER = timer_device_config::static_alloc_device_config; -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -class emu_timer -{ -public: - running_machine * machine; /* pointer to the owning machine */ - emu_timer * next; /* next timer in order in the list */ - emu_timer * prev; /* previous timer in order in the list */ - timer_fired_func callback; /* callback function */ - INT32 param; /* integer parameter */ - void * ptr; /* pointer parameter */ - const char * file; /* file that created the timer */ - int line; /* line number that created the timer */ - const char * func; /* string name of the callback function */ - UINT8 enabled; /* is the timer enabled? */ - UINT8 temporary; /* is the timer temporary? */ - attotime period; /* the repeat frequency of the timer */ - attotime start; /* time when the timer was started */ - attotime expire; /* time when the timer will expire */ - device_t * device; /* for device timers, a pointer to the device */ - device_timer_id id; /* for device timers, the ID of the timer */ -}; - - -/* a single minimum quantum */ -typedef struct _quantum_slot quantum_slot; -struct _quantum_slot -{ - attoseconds_t actual; /* actual duration of the quantum */ - attoseconds_t requested; /* duration of the requested quantum */ - attotime expire; /* absolute expiration time of this quantum */ -}; - - -/* global private data */ -/* In mame.h: typedef struct _timer_private timer_private; */ -struct _timer_private -{ - /* list of active timers */ - emu_timer timers[MAX_TIMERS]; /* actual timers */ - emu_timer * activelist; /* head of the active list */ - emu_timer * freelist; /* head of the free list */ - emu_timer * freelist_tail; /* tail of the free list */ - - /* execution state */ - timer_execution_state exec; /* current global execution state */ - - /* other internal states */ - emu_timer * callback_timer; /* pointer to the current callback timer */ - UINT8 callback_timer_modified; /* TRUE if the current callback timer was modified */ - attotime callback_timer_expire_time; /* the original expiration time */ - - /* scheduling quanta */ - quantum_slot quantum_list[MAX_QUANTA]; /* list of scheduling quanta */ - quantum_slot * quantum_current; /* current minimum quantum */ - attoseconds_t quantum_minimum; /* duration of minimum quantum */ -}; - - - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -static STATE_POSTLOAD( timer_postload ); -static void timer_logtimers(running_machine *machine); -static void timer_remove(emu_timer *which); - - - -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ - -/*------------------------------------------------- - get_current_time - return the current time --------------------------------------------------*/ - -INLINE attotime get_current_time(running_machine *machine) -{ - timer_private *global = machine->timer_data; - - /* if we're currently in a callback, use the timer's expiration time as a base */ - if (global->callback_timer != NULL) - return global->callback_timer_expire_time; - - /* if we're executing as a particular CPU, use its local time as a base */ - /* otherwise, return the global base time */ - device_execute_interface *execdevice = machine->scheduler().currently_executing(); - return (execdevice != NULL) ? execdevice->local_time() : global->exec.basetime; -} - - -/*------------------------------------------------- - timer_new - allocate a new timer --------------------------------------------------*/ - -INLINE emu_timer *timer_new(running_machine *machine) -{ - timer_private *global = machine->timer_data; - emu_timer *timer; - - /* if nothing remains available, fatal error -- we should never hit this */ - if (global->freelist == NULL) - { - timer_logtimers(machine); - fatalerror("Out of timers!"); - } - - /* pull an entry from the free list */ - timer = global->freelist; - global->freelist = timer->next; - if (global->freelist == NULL) - global->freelist_tail = NULL; - - /* set up the machine */ - timer->machine = machine; - return timer; -} - - -/*------------------------------------------------- - timer_list_insert - insert a new timer into - the list at the appropriate location --------------------------------------------------*/ - -INLINE void timer_list_insert(emu_timer *timer) -{ - attotime expire = timer->enabled ? timer->expire : attotime::never; - timer_private *global = timer->machine->timer_data; - emu_timer *t, *lt = NULL; - - /* sanity checks for the debug build */ - #ifdef MAME_DEBUG - { - int tnum = 0; - - /* loop over the timer list */ - for (t = global->activelist; t; t = t->next, tnum++) - { - if (t == timer) - fatalerror("This timer is already inserted in the list!"); - if (tnum == MAX_TIMERS-1) - fatalerror("Timer list is full!"); - } - } - #endif - - /* loop over the timer list */ - 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 (t->expire > expire) - { - /* link the new guy in before the current list entry */ - timer->prev = t->prev; - timer->next = t; - - if (t->prev != NULL) - t->prev->next = timer; - else - { - global->activelist = timer; - global->exec.nextfire = timer->expire; - } - t->prev = timer; - return; - } - } - - /* need to insert after the last one */ - if (lt != NULL) - lt->next = timer; - else - { - global->activelist = timer; - global->exec.nextfire = timer->expire; - } - timer->prev = lt; - timer->next = NULL; -} - - -/*------------------------------------------------- - timer_list_remove - remove a timer from the - linked list --------------------------------------------------*/ - -INLINE void timer_list_remove(emu_timer *timer) -{ - timer_private *global = timer->machine->timer_data; - - /* sanity checks for the debug build */ - #ifdef MAME_DEBUG - { - emu_timer *t; - - /* loop over the timer list */ - for (t = global->activelist; t && t != timer; t = t->next) ; - if (t == NULL) - fatalerror("timer (%s from %s:%d) not found in list", timer->func, timer->file, timer->line); - } - #endif - - /* remove it from the list */ - if (timer->prev != NULL) - timer->prev->next = timer->next; - else - { - global->activelist = timer->next; - if (global->activelist != NULL) - global->exec.nextfire = global->activelist->expire; - } - if (timer->next != NULL) - timer->next->prev = timer->prev; -} - - - -/*************************************************************************** - INITIALIZATION -***************************************************************************/ - -/*------------------------------------------------- - timer_init - initialize the timer system --------------------------------------------------*/ - -void timer_init(running_machine *machine) -{ - timer_private *global; - int i; - - /* allocate global data */ - global = machine->timer_data = auto_alloc_clear(machine, timer_private); - - /* we need to wait until the first call to timer_cyclestorun before using real CPU times */ - global->exec.basetime = attotime::zero; - global->exec.nextfire = attotime::never; - global->exec.curquantum = DEFAULT_MINIMUM_QUANTUM; - global->callback_timer = NULL; - global->callback_timer_modified = FALSE; - - /* register with the save state system */ - state_save_register_item(machine, "timer", NULL, 0, global->exec.basetime.seconds); - state_save_register_item(machine, "timer", NULL, 0, global->exec.basetime.attoseconds); - state_save_register_postload(machine, timer_postload, NULL); - - /* initialize the lists */ - global->activelist = NULL; - global->freelist = &global->timers[0]; - for (i = 0; i < MAX_TIMERS-1; i++) - global->timers[i].next = &global->timers[i+1]; - global->timers[MAX_TIMERS-1].next = NULL; - global->freelist_tail = &global->timers[MAX_TIMERS-1]; - - /* reset the quanta */ - global->quantum_list[0].requested = DEFAULT_MINIMUM_QUANTUM; - global->quantum_list[0].actual = DEFAULT_MINIMUM_QUANTUM; - global->quantum_list[0].expire = attotime::never; - global->quantum_current = &global->quantum_list[0]; - global->quantum_minimum = ATTOSECONDS_IN_NSEC(1) / 1000; -} - - -/*------------------------------------------------- - timer_destructor - destruct a timer from a - pool callback --------------------------------------------------*/ - -void timer_destructor(void *ptr, size_t size) -{ - timer_remove((emu_timer *)ptr); -} - - - -/*************************************************************************** - SCHEDULING HELPERS -***************************************************************************/ - -/*------------------------------------------------- - timer_get_execution_state - return a pointer - to the execution state --------------------------------------------------*/ - -timer_execution_state *timer_get_execution_state(running_machine *machine) -{ - timer_private *global = machine->timer_data; - return &global->exec; -} - - -/*------------------------------------------------- - timer_execute_timers - execute timers and - update scheduling quanta --------------------------------------------------*/ - -void timer_execute_timers(running_machine *machine) -{ - timer_private *global = machine->timer_data; - emu_timer *timer; - - /* if the current quantum has expired, find a new one */ - if (global->exec.basetime >= global->quantum_current->expire) - { - int curr; - - global->quantum_current->requested = 0; - global->quantum_current = &global->quantum_list[0]; - for (curr = 1; curr < ARRAY_LENGTH(global->quantum_list); curr++) - if (global->quantum_list[curr].requested != 0 && global->quantum_list[curr].requested < global->quantum_current->requested) - global->quantum_current = &global->quantum_list[curr]; - global->exec.curquantum = global->quantum_current->actual; - } - - 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 (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 (timer->period == attotime::zero || timer->period == attotime::never) - timer->enabled = FALSE; - - /* set the global state of which callback we're in */ - global->callback_timer_modified = FALSE; - global->callback_timer = timer; - global->callback_timer_expire_time = timer->expire; - - /* call the callback */ - if (was_enabled) - { - if (timer->device != NULL) - 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, timer->expire.as_string())); - g_profiler.start(PROFILER_TIMER_CALLBACK); - (*timer->callback)(machine, timer->ptr, timer->param); - g_profiler.stop(); - } - } - - /* clear the callback timer global */ - global->callback_timer = NULL; - - /* reset or remove the timer, but only if it wasn't modified during the callback */ - if (!global->callback_timer_modified) - { - /* if the timer is temporary, remove it now */ - if (timer->temporary) - timer_remove(timer); - - /* otherwise, reschedule it */ - else - { - timer->start = timer->expire; - timer->expire += timer->period; - - timer_list_remove(timer); - timer_list_insert(timer); - } - } - } -} - - -/*------------------------------------------------- - timer_add_scheduling_quantum - add a - scheduling quantum; the smallest active one - is the one that is in use --------------------------------------------------*/ - -void timer_add_scheduling_quantum(running_machine *machine, attoseconds_t quantum, attotime duration) -{ - timer_private *global = machine->timer_data; - attotime curtime = timer_get_time(machine); - attotime expire = curtime + duration; - int curr, blank = -1; - - /* a 0 request (minimum) needs to be non-zero to occupy a slot */ - if (quantum == 0) - quantum = 1; - - /* find an equal-duration slot or an empty slot */ - for (curr = 1; curr < ARRAY_LENGTH(global->quantum_list); curr++) - { - quantum_slot *slot = &global->quantum_list[curr]; - - /* look for a matching quantum and extend it */ - if (slot->requested == quantum) - { - slot->expire = max(slot->expire, expire); - return; - } - - /* remember any empty slots in case of no match */ - if (slot->requested == 0) - { - if (blank == -1) - blank = curr; - } - - /* otherwise, expire any expired slots */ - else if (curtime >= slot->expire) - slot->requested = 0; - } - - /* fatal error if no slots left */ - assert_always(blank != -1, "Out of scheduling quantum slots!"); - - /* fill in the item */ - global->quantum_list[blank].requested = quantum; - global->quantum_list[blank].actual = MAX(global->quantum_list[blank].requested, global->quantum_minimum); - global->quantum_list[blank].expire = expire; - - /* update the minimum */ - if (quantum < global->quantum_current->requested) - { - global->quantum_current = &global->quantum_list[blank]; - global->exec.curquantum = global->quantum_current->actual; - } -} - - -/*------------------------------------------------- - timer_set_minimum_quantum - control the - minimum useful quantum (used by cpuexec only) --------------------------------------------------*/ - -void timer_set_minimum_quantum(running_machine *machine, attoseconds_t quantum) -{ - timer_private *global = machine->timer_data; - int curr; - - /* do nothing if nothing changed */ - if (global->quantum_minimum == quantum) - return; - global->quantum_minimum = quantum; - - /* adjust all the actuals; this doesn't affect the current */ - for (curr = 0; curr < ARRAY_LENGTH(global->quantum_list); curr++) - if (global->quantum_list[curr].requested != 0) - global->quantum_list[curr].actual = MAX(global->quantum_list[curr].requested, global->quantum_minimum); - - /* ensure that the live current quantum is up to date */ - global->exec.curquantum = global->quantum_current->actual; -} - - - -/*************************************************************************** - SAVE/RESTORE HELPERS -***************************************************************************/ - -/*------------------------------------------------- - timer_register_save - register ourself with - the save state system --------------------------------------------------*/ - -static void timer_register_save(emu_timer *timer) -{ - timer_private *global = timer->machine->timer_data; - int count = 0; - emu_timer *t; - - /* find other timers that match our func name */ - for (t = global->activelist; t; t = t->next) - if (!strcmp(t->func, timer->func)) - count++; - - /* use different instances to differentiate the bits */ - state_save_register_item(timer->machine, "timer", timer->func, count, timer->param); - state_save_register_item(timer->machine, "timer", timer->func, count, timer->enabled); - state_save_register_item(timer->machine, "timer", timer->func, count, timer->period.seconds); - state_save_register_item(timer->machine, "timer", timer->func, count, timer->period.attoseconds); - state_save_register_item(timer->machine, "timer", timer->func, count, timer->start.seconds); - state_save_register_item(timer->machine, "timer", timer->func, count, timer->start.attoseconds); - state_save_register_item(timer->machine, "timer", timer->func, count, timer->expire.seconds); - state_save_register_item(timer->machine, "timer", timer->func, count, timer->expire.attoseconds); - if (timer->device != NULL) - state_save_register_item(timer->machine, "timer", timer->func, count, timer->id); -} - - -/*------------------------------------------------- - timer_postload - after loading a save state --------------------------------------------------*/ - -static STATE_POSTLOAD( timer_postload ) -{ - timer_private *global = machine->timer_data; - emu_timer *privlist = NULL; - emu_timer *t; - - /* remove all timers and make a private list */ - while (global->activelist != NULL) - { - t = global->activelist; - - /* temporary timers go away entirely */ - if (t->temporary) - timer_remove(t); - - /* permanent ones get added to our private list */ - else - { - timer_list_remove(t); - t->next = privlist; - privlist = t; - } - } - - /* now add them all back in; this effectively re-sorts them by time */ - while (privlist != NULL) - { - t = privlist; - privlist = t->next; - timer_list_insert(t); - } -} - - -/*------------------------------------------------- - timer_count_anonymous - count the number of - anonymous (non-saveable) timers --------------------------------------------------*/ - -int timer_count_anonymous(running_machine *machine) -{ - timer_private *global = machine->timer_data; - emu_timer *t; - int count = 0; - - logerror("timer_count_anonymous:\n"); - for (t = global->activelist; t; t = t->next) - if (t->temporary && t != global->callback_timer) - { - count++; - logerror(" Temp. timer %p, file %s:%d[%s]\n", (void *) t, t->file, t->line, t->func); - } - logerror("%d temporary timers found\n", count); - - return count; -} - - - -/*************************************************************************** - CORE TIMER ALLOCATION -***************************************************************************/ - -/*------------------------------------------------- - timer_alloc - allocate a permament timer that - isn't primed yet --------------------------------------------------*/ - -INLINE emu_timer *_timer_alloc_common(running_machine *machine, device_t *device, device_timer_id id, timer_fired_func callback, void *ptr, const char *file, int line, const char *func, int temp) -{ - attotime time = get_current_time(machine); - emu_timer *timer = timer_new(machine); - - /* fill in the record */ - timer->callback = callback; - timer->ptr = ptr; - timer->param = 0; - timer->enabled = FALSE; - timer->temporary = temp; - timer->period = attotime::zero; - timer->file = file; - timer->line = line; - timer->func = func; - timer->device = device; - timer->id = id; - - /* compute the time of the next firing and insert into the list */ - timer->start = time; - timer->expire = attotime::never; - timer_list_insert(timer); - - /* if we're not temporary, register ourselves with the save state system */ - if (!temp) - { - if (!state_save_registration_allowed(machine)) - fatalerror("timer_alloc() called after save state registration closed! (file %s, line %d)\n", file, line); - timer_register_save(timer); - } - - /* return a handle */ - return timer; -} - -emu_timer *_timer_alloc_internal(running_machine *machine, timer_fired_func callback, void *ptr, const char *file, int line, const char *func) -{ - return _timer_alloc_common(machine, NULL, 0, callback, ptr, file, line, func, FALSE); -} - -emu_timer *device_timer_alloc(device_t &device, UINT32 id, void *ptr) -{ - return _timer_alloc_common(device.machine, &device, id, NULL, ptr, __FILE__, __LINE__, device.tag(), FALSE); -} - - -/*------------------------------------------------- - timer_remove - remove a timer from the - system --------------------------------------------------*/ - -static void timer_remove(emu_timer *which) -{ - timer_private *global = which->machine->timer_data; - - /* if this is a callback timer, note that */ - if (which == global->callback_timer) - global->callback_timer_modified = TRUE; - - /* remove it from the list */ - timer_list_remove(which); - - /* free it up by adding it back to the free list */ - if (global->freelist_tail) - global->freelist_tail->next = which; - else - global->freelist = which; - which->next = NULL; - global->freelist_tail = which; -} - - - -/*************************************************************************** - CORE TIMER ADJUSTMENT -***************************************************************************/ - -/*------------------------------------------------- - timer_adjust_oneshot - adjust the time when this timer - will fire and disable any periodic firings --------------------------------------------------*/ - -void timer_adjust_oneshot(emu_timer *which, attotime duration, INT32 param) -{ - timer_adjust_periodic(which, duration, param, attotime::never); -} - - -/*------------------------------------------------- - timer_adjust_periodic - adjust the time when - this timer will fire and specify a period for - subsequent firings --------------------------------------------------*/ - -void timer_adjust_periodic(emu_timer *which, attotime start_delay, INT32 param, attotime period) -{ - timer_private *global = which->machine->timer_data; - attotime time = get_current_time(which->machine); - - /* if this is the callback timer, mark it modified */ - if (which == global->callback_timer) - global->callback_timer_modified = TRUE; - - /* compute the time of the next firing and insert into the list */ - which->param = param; - which->enabled = TRUE; - - /* clamp negative times to 0 */ - if (start_delay.seconds < 0) - start_delay = attotime::zero; - - /* set the start and expire times */ - which->start = time; - which->expire = time + start_delay; - which->period = period; - - /* remove and re-insert the timer in its new order */ - timer_list_remove(which); - 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, which->expire.as_string())); - if (which == global->activelist) - which->machine->scheduler().abort_timeslice(); -} - - - -/*************************************************************************** - SIMPLIFIED ANONYMOUS TIMER MANAGEMENT -***************************************************************************/ - -void device_timer_call_after_resynch(device_t &device, device_timer_id id, INT32 param, void *ptr) -{ - emu_timer *timer = _timer_alloc_common(device.machine, &device, id, NULL, ptr, __FILE__, __LINE__, device.tag(), TRUE); - timer_adjust_oneshot(timer, attotime::zero, param); -} - - -/*------------------------------------------------- - timer_pulse - allocate a pulse timer, which - repeatedly calls the callback using the given - period --------------------------------------------------*/ - -void _timer_pulse_internal(running_machine *machine, attotime period, void *ptr, INT32 param, timer_fired_func callback, const char *file, int line, const char *func) -{ - emu_timer *timer = _timer_alloc_common(machine, NULL, 0, callback, ptr, file, line, func, FALSE); - timer_adjust_periodic(timer, period, param, period); -} - - -/*------------------------------------------------- - timer_set - allocate a one-shot timer, which - calls the callback after the given duration --------------------------------------------------*/ - -void _timer_set_internal(running_machine *machine, attotime duration, void *ptr, INT32 param, timer_fired_func callback, const char *file, int line, const char *func) -{ - emu_timer *timer = _timer_alloc_common(machine, NULL, 0, callback, ptr, file, line, func, TRUE); - timer_adjust_oneshot(timer, duration, param); -} - - - -/*************************************************************************** - MISCELLANEOUS CONTROLS -***************************************************************************/ - -/*------------------------------------------------- - timer_reset - reset the timing on a timer --------------------------------------------------*/ - -void timer_reset(emu_timer *which, attotime duration) -{ - timer_adjust_periodic(which, duration, which->param, which->period); -} - - -/*------------------------------------------------- - timer_enable - enable/disable a timer --------------------------------------------------*/ - -int timer_enable(emu_timer *which, int enable) -{ - int old = which->enabled; - - /* reschedule only if the state has changed */ - if (old != enable) - { - /* set the enable flag */ - which->enabled = enable; - - /* remove the timer and insert back into the list */ - timer_list_remove(which); - timer_list_insert(which); - } - - return old; -} - - -/*------------------------------------------------- - timer_enabled - determine if a timer is - enabled --------------------------------------------------*/ - -int timer_enabled(emu_timer *which) -{ - return which->enabled; -} - - -/*------------------------------------------------- - timer_get_param - returns the callback - parameter of a timer --------------------------------------------------*/ - -int timer_get_param(emu_timer *which) -{ - return which->param; -} - - -/*------------------------------------------------- - timer_set_param - changes the callback - parameter of a timer --------------------------------------------------*/ - -void timer_set_param(emu_timer *which, int param) -{ - which->param = param; -} - - -/*------------------------------------------------- - timer_get_ptr - returns the callback pointer - of a timer --------------------------------------------------*/ - -void *timer_get_ptr(emu_timer *which) -{ - return which->ptr; -} - - -/*------------------------------------------------- - timer_set_ptr - changes the callback pointer - of a timer --------------------------------------------------*/ - -void timer_set_ptr(emu_timer *which, void *ptr) -{ - which->ptr = ptr; -} - - - -/*************************************************************************** - TIMING FUNCTIONS -***************************************************************************/ - -/*------------------------------------------------- - timer_timeelapsed - return the time since the - last trigger --------------------------------------------------*/ - -attotime timer_timeelapsed(emu_timer *which) -{ - return get_current_time(which->machine) - which->start; -} - - -/*------------------------------------------------- - timer_timeleft - return the time until the - next trigger --------------------------------------------------*/ - -attotime timer_timeleft(emu_timer *which) -{ - return which->expire - get_current_time(which->machine); -} - - -/*------------------------------------------------- - timer_get_time - return the current time --------------------------------------------------*/ - -attotime timer_get_time(running_machine *machine) -{ - return get_current_time(machine); -} - - -/*------------------------------------------------- - timer_starttime - return the time when this - timer started counting --------------------------------------------------*/ - -attotime timer_starttime(emu_timer *which) -{ - return which->start; -} - - -/*------------------------------------------------- - timer_firetime - return the time when this - timer will fire next --------------------------------------------------*/ - -attotime timer_firetime(emu_timer *which) -{ - return which->expire; -} - - - -/*************************************************************************** - DEBUGGING -***************************************************************************/ - -/*------------------------------------------------- - timer_logtimers - log all the timers --------------------------------------------------*/ - -static void timer_logtimers(running_machine *machine) -{ - timer_private *global = machine->timer_data; - emu_timer *t; - - logerror("===============\n"); - logerror("TIMER LOG START\n"); - logerror("===============\n"); - - 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", - 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", - 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"); - logerror("==============\n"); -} - - -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", - t->start.as_double(), t->expire.as_double(), t->period.as_double(), t->enabled, t->temporary, t->func); -} - //************************************************************************** // TIMER DEVICE CONFIGURATION @@ -1187,7 +283,7 @@ void timer_device::device_start() m_screen = downcast<screen_device *>(machine->device(m_config.m_screen)); // allocate the timer - m_timer = timer_alloc(machine, (m_config.m_type == timer_device_config::TIMER_TYPE_SCANLINE) ? static_scanline_timer_callback : static_periodic_timer_callback, (void *)this); + m_timer = timer_alloc(); // register for save states state_save_register_device_item(this, 0, m_first_time); @@ -1235,41 +331,47 @@ void timer_device::device_reset() } -/*------------------------------------------------- - periodic_timer_callback - calls the timer - device specific callback --------------------------------------------------*/ +//------------------------------------------------- +// device_timer - handle timer expiration events +//------------------------------------------------- -void timer_device::periodic_timer_callback(int param) +void timer_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - if (m_config.m_callback != NULL) - (*m_config.m_callback)(*this, m_ptr, param); -} + switch (m_config.m_type) + { + // general periodic timers just call through + case timer_device_config::TIMER_TYPE_GENERIC: + case timer_device_config::TIMER_TYPE_PERIODIC: + if (m_config.m_type != timer_device_config::TIMER_TYPE_SCANLINE) + { + if (m_config.m_callback != NULL) + (*m_config.m_callback)(*this, m_ptr, param); + } + break; -/*------------------------------------------------- - scanline_timer_device_timer_callback - - manages the scanline based timer's state --------------------------------------------------*/ + // scanline timers have to do some additiona bookkeeping + case timer_device_config::TIMER_TYPE_SCANLINE: + { + // by default, we fire at the first position + int next_vpos = m_config.m_first_vpos; -void timer_device::scanline_timer_callback(int scanline) -{ - // by default, we fire at the first position - int next_vpos = m_config.m_first_vpos; + // the first time through we just go with the default position + if (!m_first_time) + { + // call the real callback + int vpos = m_screen->vpos(); + (*m_config.m_callback)(*this, m_ptr, vpos); - // the first time through we just go with the default position - if (!m_first_time) - { - // call the real callback - int vpos = m_screen->vpos(); - (*m_config.m_callback)(*this, m_ptr, vpos); + // advance by the increment only if we will still be within the screen bounds + if (m_config.m_increment != 0 && (vpos + m_config.m_increment) < m_screen->height()) + next_vpos = vpos + m_config.m_increment; + } + m_first_time = false; - // advance by the increment only if we will still be within the screen bounds - if (m_config.m_increment != 0 && (vpos + m_config.m_increment) < m_screen->height()) - next_vpos = vpos + m_config.m_increment; + // adjust the timer + timer_adjust_oneshot(m_timer, m_screen->time_until_pos(next_vpos), 0); + break; + } } - m_first_time = false; - - // adjust the timer - timer_adjust_oneshot(m_timer, m_screen->time_until_pos(next_vpos), 0); } diff --git a/src/emu/timer.h b/src/emu/timer.h index 6cd806645c5..7df6d824e22 100644 --- a/src/emu/timer.h +++ b/src/emu/timer.h @@ -2,11 +2,38 @@ timer.h - Functions needed to generate timing and synchronization between several - CPUs. - - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. + Timer devices. + +**************************************************************************** + + 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. ***************************************************************************/ @@ -19,58 +46,17 @@ #ifndef __TIMER_H__ #define __TIMER_H__ -#include "devlegcy.h" -/*************************************************************************** - MACROS -***************************************************************************/ +//************************************************************************** +// MACROS +//************************************************************************** -/* macro for the RC time constant on a 74LS123 with C > 1000pF */ -/* R is in ohms, C is in farads */ -#define TIME_OF_74LS123(r,c) (0.45 * (double)(r) * (double)(c)) - -/* macros for the RC time constant on a 555 timer IC */ -/* R is in ohms, C is in farads */ -#define PERIOD_OF_555_MONOSTABLE_NSEC(r,c) ((attoseconds_t)(1100000000 * (double)(r) * (double)(c))) -#define PERIOD_OF_555_ASTABLE_NSEC(r1,r2,c) ((attoseconds_t)( 693000000 * ((double)(r1) + 2.0 * (double)(r2)) * (double)(c))) -#define PERIOD_OF_555_MONOSTABLE(r,c) attotime::from_nsec(PERIOD_OF_555_MONOSTABLE_NSEC(r,c)) -#define PERIOD_OF_555_ASTABLE(r1,r2,c) attotime::from_nsec(PERIOD_OF_555_ASTABLE_NSEC(r1,r2,c)) - -/* macros that map all allocations to provide file/line/functions to the callee */ -#define timer_alloc(m,c,ptr) _timer_alloc_internal(m, c, ptr, __FILE__, __LINE__, #c) -#define timer_pulse(m,e,ptr,p,c) _timer_pulse_internal(m, e, ptr, p, c, __FILE__, __LINE__, #c) -#define timer_set(m,d,ptr,p,c) _timer_set_internal(m, d, ptr, p, c, __FILE__, __LINE__, #c) -#define timer_call_after_resynch(m,ptr,p,c) _timer_set_internal(m, attotime::zero, ptr, p, c, __FILE__, __LINE__, #c) - -/* macros for a timer callback functions */ -#define TIMER_CALLBACK(name) void name(running_machine *machine, void *ptr, int param) +// macros for a timer callback functions #define TIMER_DEVICE_CALLBACK(name) void name(timer_device &timer, void *ptr, INT32 param) -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -// forward declarations -class emu_timer; -class timer_device; - - -// a timer callback looks like this -typedef void (*timer_fired_func)(running_machine *machine, void *ptr, INT32 param); -typedef void (*timer_device_fired_func)(timer_device &timer, void *ptr, INT32 param); - - -struct timer_execution_state -{ - attotime nextfire; /* time that the head of the timer list will fire */ - attotime basetime; /* global basetime; everything moves forward from here */ - attoseconds_t curquantum; /* current quantum of execution */ -}; - - //************************************************************************** // TIMER DEVICE CONFIGURATION MACROS @@ -105,115 +91,16 @@ struct timer_execution_state -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - - -/* ----- initialization ----- */ - -/* initialize the timer system */ -void timer_init(running_machine *machine); - -/* destruct a timer from a pool callback */ -void timer_destructor(void *ptr, size_t size); - - - -/* ----- scheduling helpers ----- */ - -/* return a pointer to the execution state */ -timer_execution_state *timer_get_execution_state(running_machine *machine); - -/* execute timers and update scheduling quanta */ -void timer_execute_timers(running_machine *machine); - -/* add a scheduling quantum; the smallest active one is the one that is in use */ -void timer_add_scheduling_quantum(running_machine *machine, attoseconds_t quantum, attotime duration); - -/* control the minimum useful quantum (used by cpuexec only) */ -void timer_set_minimum_quantum(running_machine *machine, attoseconds_t quantum); - - - -/* ----- save/restore helpers ----- */ - -/* count the number of anonymous (non-saveable) timers */ -int timer_count_anonymous(running_machine *machine); - - - -/* ----- core timer management ----- */ - -/* allocate a permament timer that isn't primed yet */ -emu_timer *_timer_alloc_internal(running_machine *machine, timer_fired_func callback, void *param, const char *file, int line, const char *func); - -/* allocate a permament device timer that isn't primed yet */ -emu_timer *device_timer_alloc(device_t &device, device_timer_id id = 0, void *ptr = NULL); - -/* adjust the time when this timer will fire and disable any periodic firings */ -void timer_adjust_oneshot(emu_timer *which, attotime duration, INT32 param); - -/* adjust the time when this timer will fire and specify a period for subsequent firings */ -void timer_adjust_periodic(emu_timer *which, attotime start_delay, INT32 param, attotime period); - - - -/* ----- anonymous timer management ----- */ - -/* request a one-shot temporary timer for a device */ -void device_timer_call_after_resynch(device_t &device, device_timer_id id = 0, INT32 param = 0, void *ptr = NULL); - -/* allocate a one-shot timer, which calls the callback after the given duration */ -void _timer_set_internal(running_machine *machine, attotime duration, void *ptr, INT32 param, timer_fired_func callback, const char *file, int line, const char *func); - -/* allocate a pulse timer, which repeatedly calls the callback using the given period */ -void _timer_pulse_internal(running_machine *machine, attotime period, void *ptr, INT32 param, timer_fired_func callback, const char *file, int line, const char *func); - - - -/* ----- miscellaneous controls ----- */ - -/* reset the timing on a timer */ -void timer_reset(emu_timer *which, attotime duration); - -/* enable/disable a timer */ -int timer_enable(emu_timer *which, int enable); - -/* determine if a timer is enabled */ -int timer_enabled(emu_timer *which); - -/* returns the callback parameter of a timer */ -int timer_get_param(emu_timer *which); - -/* changes the callback parameter of a timer */ -void timer_set_param(emu_timer *which, int param); - -/* returns the callback pointer of a timer */ -void *timer_get_ptr(emu_timer *which); - -/* changes the callback pointer of a timer */ -void timer_set_ptr(emu_timer *which, void *ptr); - - - -/* ----- timing functions ----- */ - -/* return the time since the last trigger */ -attotime timer_timeelapsed(emu_timer *which); - -/* return the time until the next trigger */ -attotime timer_timeleft(emu_timer *which); - -/* return the current time */ -attotime timer_get_time(running_machine *machine); - -/* return the time when this timer started counting */ -attotime timer_starttime(emu_timer *which); +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** -/* return the time when this timer will fire next */ -attotime timer_firetime(emu_timer *which); +// forward declarations +class emu_timer; +class timer_device; +// a timer callback looks like this +typedef void (*timer_device_fired_func)(timer_device &timer, void *ptr, INT32 param); // ======================> timer_device_config @@ -221,7 +108,7 @@ attotime timer_firetime(emu_timer *which); class timer_device_config : public device_config { friend class timer_device; - + // construction/destruction timer_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); @@ -268,7 +155,6 @@ private: }; - // ======================> timer_device class timer_device : public device_t @@ -280,49 +166,47 @@ class timer_device : public device_t public: // property getters - int param() const { return timer_get_param(m_timer); } + int param() const { return m_timer->param(); } void *ptr() const { return m_ptr; } - bool enabled() const { return (timer_enabled(m_timer) != 0); } + bool enabled() const { return m_timer->enabled(); } // property setters - void set_param(int param) { assert(m_config.m_type == timer_device_config::TIMER_TYPE_GENERIC); timer_set_param(m_timer, param); } + void set_param(int param) { assert(m_config.m_type == timer_device_config::TIMER_TYPE_GENERIC); m_timer->set_param(param); } void set_ptr(void *ptr) { m_ptr = ptr; } - void enable(bool enable = true) { timer_enable(m_timer, enable); } + void enable(bool enable = true) { m_timer->enable(enable); } // adjustments void reset() { adjust(attotime::never, 0, attotime::never); } - void adjust(attotime duration, INT32 param = 0, attotime period = attotime::never) { assert(m_config.m_type == timer_device_config::TIMER_TYPE_GENERIC); timer_adjust_periodic(m_timer, duration, param, period); } + void adjust(attotime duration, INT32 param = 0, attotime period = attotime::never) { assert(m_config.m_type == timer_device_config::TIMER_TYPE_GENERIC); m_timer->adjust(duration, param, period); } // timing information - attotime time_elapsed() const { return timer_timeelapsed(m_timer); } - attotime time_left() const { return timer_timeleft(m_timer); } - attotime start_time() const { return timer_starttime(m_timer); } - attotime fire_time() const { return timer_firetime(m_timer); } + attotime time_elapsed() const { return m_timer->elapsed(); } + attotime time_left() const { return m_timer->remaining(); } + attotime start_time() const { return m_timer->start(); } + attotime fire_time() const { return m_timer->expire(); } private: // device-level overrides virtual void device_start(); virtual void device_reset(); - - // internal helpers - static TIMER_CALLBACK( static_periodic_timer_callback ) { reinterpret_cast<timer_device *>(ptr)->periodic_timer_callback(param); } - void periodic_timer_callback(int param); - - static TIMER_CALLBACK( static_scanline_timer_callback ) { reinterpret_cast<timer_device *>(ptr)->scanline_timer_callback(param); } - void scanline_timer_callback(int scanline); + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); // internal state - const timer_device_config &m_config; - emu_timer * m_timer; // the backing timer - void * m_ptr; // the pointer parameter passed to the timer callback + const timer_device_config & m_config; + emu_timer * m_timer; // the backing timer + void * m_ptr; // the pointer parameter passed to the timer callback // scanline timers only - screen_device *m_screen; // pointer to the screen - bool m_first_time; // indicates that the system is starting + screen_device * m_screen; // pointer to the screen + bool m_first_time; // indicates that the system is starting }; -// device type definition + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + extern const device_type TIMER; diff --git a/src/emu/video.c b/src/emu/video.c index e066fb8949c..5ee6aa77d2b 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -180,7 +180,7 @@ video_manager::video_manager(running_machine &machine) // if no screens, create a periodic timer to drive updates if (machine.primary_screen == NULL) { - m_screenless_frame_timer = timer_alloc(&machine, &screenless_update_callback, this); + m_screenless_frame_timer = machine.scheduler().timer_alloc(FUNC(&screenless_update_callback), this); timer_adjust_periodic(m_screenless_frame_timer, screen_device::DEFAULT_FRAME_PERIOD, 0, screen_device::DEFAULT_FRAME_PERIOD); } } diff --git a/src/emu/video/mc6845.c b/src/emu/video/mc6845.c index 49478bc7529..80d34d85256 100644 --- a/src/emu/video/mc6845.c +++ b/src/emu/video/mc6845.c @@ -208,7 +208,7 @@ INLINE void call_on_update_address(device_t *device, int strobe) mc6845_t *mc6845 = get_safe_token(device); if (mc6845->intf->on_update_addr_changed) - timer_set(device->machine, attotime::zero, (void *) device, (mc6845->update_addr << 8) | strobe, on_update_address_cb); + device->machine->scheduler().timer_set(attotime::zero, FUNC(on_update_address_cb), (mc6845->update_addr << 8) | strobe, (void *) device); else fatalerror("M6845: transparent memory mode without handler\n"); } @@ -889,19 +889,19 @@ static void common_start(device_t *device, int device_type) mc6845->screen = NULL; /* create the timers */ - mc6845->line_timer = timer_alloc(device->machine, line_timer_cb, (void *)device); + mc6845->line_timer = device->machine->scheduler().timer_alloc(FUNC(line_timer_cb), (void *)device); - mc6845->de_off_timer = timer_alloc(device->machine, de_off_timer_cb, (void *)device); - mc6845->upd_adr_timer = timer_alloc(device->machine, upd_adr_timer_cb, (void *)device); + mc6845->de_off_timer = device->machine->scheduler().timer_alloc(FUNC(de_off_timer_cb), (void *)device); + mc6845->upd_adr_timer = device->machine->scheduler().timer_alloc(FUNC(upd_adr_timer_cb), (void *)device); - mc6845->cur_on_timer = timer_alloc(device->machine, cur_on_timer_cb, (void *)device); - mc6845->cur_off_timer = timer_alloc(device->machine, cur_off_timer_cb, (void *)device); + mc6845->cur_on_timer = device->machine->scheduler().timer_alloc(FUNC(cur_on_timer_cb), (void *)device); + mc6845->cur_off_timer = device->machine->scheduler().timer_alloc(FUNC(cur_off_timer_cb), (void *)device); - mc6845->hsync_on_timer = timer_alloc(device->machine, hsync_on_timer_cb, (void *)device); - mc6845->hsync_off_timer = timer_alloc(device->machine, hsync_off_timer_cb, (void *)device); + mc6845->hsync_on_timer = device->machine->scheduler().timer_alloc(FUNC(hsync_on_timer_cb), (void *)device); + mc6845->hsync_off_timer = device->machine->scheduler().timer_alloc(FUNC(hsync_off_timer_cb), (void *)device); } - mc6845->light_pen_latch_timer = timer_alloc(device->machine, light_pen_latch_timer_cb, (void *)device); + mc6845->light_pen_latch_timer = device->machine->scheduler().timer_alloc(FUNC(light_pen_latch_timer_cb), (void *)device); /* Use some large startup values */ mc6845->horiz_char_total = 0xff; diff --git a/src/emu/video/pc_vga.c b/src/emu/video/pc_vga.c index 4abc6f7bcc8..d6cf1276828 100644 --- a/src/emu/video/pc_vga.c +++ b/src/emu/video/pc_vga.c @@ -1325,7 +1325,7 @@ static VIDEO_START( ega ) vga.monitor.get_columns = ega_get_crtc_columns; vga.monitor.get_sync_lines = vga_get_crtc_sync_lines; vga.monitor.get_sync_columns = vga_get_crtc_sync_columns; - timer_pulse(machine, attotime::from_hz(60), NULL, 0, vga_timer); + machine->scheduler().timer_pulse(attotime::from_hz(60), FUNC(vga_timer)); pc_video_start(machine, pc_ega_choosevideomode, 0); } @@ -1340,7 +1340,7 @@ static VIDEO_START( vga ) vga.monitor.get_columns=vga_get_crtc_columns; vga.monitor.get_sync_lines=vga_get_crtc_sync_lines; vga.monitor.get_sync_columns=vga_get_crtc_sync_columns; - timer_pulse(machine, attotime::from_hz(60), NULL, 0, vga_timer); + machine->scheduler().timer_pulse(attotime::from_hz(60), FUNC(vga_timer)); pc_video_start(machine, pc_vga_choosevideomode, 0); } diff --git a/src/emu/video/tms34061.c b/src/emu/video/tms34061.c index c71d10f6b33..7f7beabbc52 100644 --- a/src/emu/video/tms34061.c +++ b/src/emu/video/tms34061.c @@ -119,7 +119,7 @@ void tms34061_start(running_machine *machine, const struct tms34061_interface *i tms34061.regs[TMS34061_VERCOUNTER] = 0x0000; /* start vertical interrupt timer */ - tms34061.timer = timer_alloc(machine, tms34061_interrupt, NULL); + tms34061.timer = machine->scheduler().timer_alloc(FUNC(tms34061_interrupt)); } diff --git a/src/emu/video/voodoo.c b/src/emu/video/voodoo.c index 1e4841dbe6e..059eebb865a 100644 --- a/src/emu/video/voodoo.c +++ b/src/emu/video/voodoo.c @@ -523,7 +523,7 @@ static void init_fbi(voodoo_state *v, fbi_state *f, void *memory, int fbmem) } /* allocate a VBLANK timer */ - f->vblank_timer = timer_alloc(v->device->machine, vblank_callback, v); + f->vblank_timer = v->device->machine->scheduler().timer_alloc(FUNC(vblank_callback), v); f->vblank = FALSE; /* initialize the memory FIFO */ @@ -1034,7 +1034,7 @@ static TIMER_CALLBACK( vblank_callback ) swap_buffers(v); /* set a timer for the next off state */ - timer_set(machine, v->screen->time_until_pos(0), v, 0, vblank_off_callback); + machine->scheduler().timer_set(v->screen->time_until_pos(0), FUNC(vblank_off_callback), 0, v); /* set internal state and call the client */ v->fbi.vblank = TRUE; @@ -4595,7 +4595,7 @@ static DEVICE_START( voodoo ) v->pci.fifo.size = 64*2; v->pci.fifo.in = v->pci.fifo.out = 0; v->pci.stall_state = NOT_STALLED; - v->pci.continue_timer = timer_alloc(v->device->machine, stall_cpu_callback, v); + v->pci.continue_timer = v->device->machine->scheduler().timer_alloc(FUNC(stall_cpu_callback), v); /* allocate memory */ tmumem0 = config->tmumem0; diff --git a/src/emu/watchdog.c b/src/emu/watchdog.c index 340813dab5f..6646c8fc60d 100644 --- a/src/emu/watchdog.c +++ b/src/emu/watchdog.c @@ -39,7 +39,7 @@ static TIMER_CALLBACK( watchdog_callback ); void watchdog_init(running_machine *machine) { /* allocate a timer for the watchdog */ - watchdog_timer = timer_alloc(machine, watchdog_callback, NULL); + watchdog_timer = machine->scheduler().timer_alloc(FUNC(watchdog_callback)); machine->add_notifier(MACHINE_NOTIFY_RESET, watchdog_internal_reset); diff --git a/src/ldplayer/ldplayer.c b/src/ldplayer/ldplayer.c index 6964598e332..72abce2c5cb 100644 --- a/src/ldplayer/ldplayer.c +++ b/src/ldplayer/ldplayer.c @@ -238,7 +238,7 @@ static TIMER_CALLBACK( vsync_update ) /* set a timer to go off on the next VBLANK */ vblank_scanline = machine->primary_screen->visible_area().max_y + 1; target = machine->primary_screen->time_until_pos(vblank_scanline); - timer_set(machine, target, NULL, 0, vsync_update); + machine->scheduler().timer_set(target, FUNC(vsync_update)); } @@ -261,7 +261,7 @@ static TIMER_CALLBACK( autoplay ) static MACHINE_RESET( ldplayer ) { /* set up a timer to start playing immediately */ - timer_set(machine, attotime::zero, NULL, 0, autoplay); + machine->scheduler().timer_set(attotime::zero, FUNC(autoplay)); /* indicate the name of the file we opened */ popmessage("Opened %s\n", filename.cstr()); @@ -303,7 +303,7 @@ static TIMER_CALLBACK( pr8210_bit_callback ) { /* assert the line and set a timer for deassertion */ laserdisc_line_w(laserdisc, LASERDISC_LINE_CONTROL, ASSERT_LINE); - timer_set(machine, attotime::from_usec(250), ptr, 0, pr8210_bit_off_callback); + machine->scheduler().timer_set(attotime::from_usec(250), FUNC(pr8210_bit_off_callback), 0, ptr); /* space 0 bits apart by 1msec, and 1 bits by 2msec */ duration = attotime::from_msec((data & 0x80) ? 2 : 1); @@ -325,7 +325,7 @@ static MACHINE_START( pr8210 ) { device_t *laserdisc = machine->m_devicelist.first(LASERDISC); MACHINE_START_CALL(ldplayer); - pr8210_bit_timer = timer_alloc(machine, pr8210_bit_callback, (void *)laserdisc); + pr8210_bit_timer = machine->scheduler().timer_alloc(FUNC(pr8210_bit_callback), (void *)laserdisc); } diff --git a/src/mame/audio/8080bw.c b/src/mame/audio/8080bw.c index dc576a17894..eb34c5c6bc3 100644 --- a/src/mame/audio/8080bw.c +++ b/src/mame/audio/8080bw.c @@ -918,7 +918,7 @@ MACHINE_START( schaser_sh ) { mw8080bw_state *state = machine->driver_data<mw8080bw_state>(); - state->schaser_effect_555_timer = timer_alloc(machine, schaser_effect_555_cb, NULL); + state->schaser_effect_555_timer = machine->scheduler().timer_alloc(FUNC(schaser_effect_555_cb)); state_save_register_global(machine, state->schaser_explosion); state_save_register_global(machine, state->schaser_effect_555_is_low); diff --git a/src/mame/audio/amiga.c b/src/mame/audio/amiga.c index a2d0115b778..270e9094aff 100644 --- a/src/mame/audio/amiga.c +++ b/src/mame/audio/amiga.c @@ -270,7 +270,7 @@ static DEVICE_START( amiga_sound ) for (i = 0; i < 4; i++) { audio_state->channel[i].index = i; - audio_state->channel[i].irq_timer = timer_alloc(device->machine, signal_irq, NULL); + audio_state->channel[i].irq_timer = device->machine->scheduler().timer_alloc(FUNC(signal_irq)); } /* create the stream */ diff --git a/src/mame/audio/cage.c b/src/mame/audio/cage.c index 865149be50d..b7bf9020bf0 100644 --- a/src/mame/audio/cage.c +++ b/src/mame/audio/cage.c @@ -541,7 +541,7 @@ void main_to_cage_w(UINT16 data) running_machine *machine = cage_cpu->machine; if (LOG_COMM) logerror("%s:Command to CAGE = %04X\n", cpuexec_describe_context(machine), data); - timer_call_after_resynch(machine, NULL, data, deferred_cage_w); + machine->scheduler().synchronize(FUNC(deferred_cage_w), data); } diff --git a/src/mame/audio/cinemat.c b/src/mame/audio/cinemat.c index 961ae50815e..f47f1fca85f 100644 --- a/src/mame/audio/cinemat.c +++ b/src/mame/audio/cinemat.c @@ -1471,7 +1471,7 @@ static void demon_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_ /* watch for a 0->1 edge on bit 4 ("shift in") to clock in the new data */ if ((bits_changed & 0x10) && (sound_val & 0x10)) - timer_call_after_resynch(machine, NULL, sound_val & 0x0f, synced_sound_w); + machine->scheduler().synchronize(FUNC(synced_sound_w), sound_val & 0x0f); } diff --git a/src/mame/audio/dcs.c b/src/mame/audio/dcs.c index f9f4ea1cd73..cd70d0ac6a7 100644 --- a/src/mame/audio/dcs.c +++ b/src/mame/audio/dcs.c @@ -1515,7 +1515,7 @@ void dcs_reset_w(int state) logerror("%s: DCS reset = %d\n", cpuexec_describe_context(dcs.cpu->machine), state); /* just run through the init code again */ - timer_call_after_resynch(dcs.cpu->machine, NULL, 0, dcs_reset); + dcs.cpu->machine->scheduler().synchronize(FUNC(dcs_reset)); cpu_set_input_line(dcs.cpu, INPUT_LINE_RESET, ASSERT_LINE); } @@ -1589,7 +1589,7 @@ void dcs_data_w(int data) /* if we are DCS1, set a timer to latch the data */ if (dcs.sport_timer == NULL) - timer_call_after_resynch(dcs.cpu->machine, NULL, data, dcs_delayed_data_w_callback); + dcs.cpu->machine->scheduler().synchronize(FUNC(dcs_delayed_data_w_callback), data); else dcs_delayed_data_w(dcs.cpu->machine, data); } @@ -1632,7 +1632,7 @@ static WRITE16_HANDLER( output_latch_w ) { if (LOG_DCS_IO) logerror("%08X:output_latch_w(%04X) (empty=%d)\n", cpu_get_pc(space->cpu), data, IS_OUTPUT_EMPTY()); - timer_call_after_resynch(space->machine, NULL, data, latch_delayed_w); + space->machine->scheduler().synchronize(FUNC(latch_delayed_w), data); } @@ -1650,7 +1650,7 @@ static TIMER_CALLBACK( delayed_ack_w_callback ) void dcs_ack_w(void) { - timer_call_after_resynch(dcs.cpu->machine, NULL, 0, delayed_ack_w_callback); + dcs.cpu->machine->scheduler().synchronize(FUNC(delayed_ack_w_callback)); } @@ -1686,7 +1686,7 @@ static WRITE16_HANDLER( output_control_w ) { if (LOG_DCS_IO) logerror("%04X:output_control = %04X\n", cpu_get_pc(space->cpu), data); - timer_call_after_resynch(space->machine, NULL, data, output_control_delayed_w); + space->machine->scheduler().synchronize(FUNC(output_control_delayed_w), data); } @@ -2122,7 +2122,7 @@ static TIMER_CALLBACK( s1_ack_callback2 ) /* if the output is full, stall for a usec */ if (IS_OUTPUT_FULL()) { - timer_set(machine, attotime::from_usec(1), NULL, param, s1_ack_callback2); + machine->scheduler().timer_set(attotime::from_usec(1), FUNC(s1_ack_callback2), param); return; } output_latch_w(cpu_get_address_space(dcs.cpu, ADDRESS_SPACE_PROGRAM), 0, 0x000a, 0xffff); @@ -2134,13 +2134,13 @@ static TIMER_CALLBACK( s1_ack_callback1 ) /* if the output is full, stall for a usec */ if (IS_OUTPUT_FULL()) { - timer_set(machine, attotime::from_usec(1), NULL, param, s1_ack_callback1); + machine->scheduler().timer_set(attotime::from_usec(1), FUNC(s1_ack_callback1), param); return; } output_latch_w(cpu_get_address_space(dcs.cpu, ADDRESS_SPACE_PROGRAM), 0, param, 0xffff); /* chain to the next word we need to write back */ - timer_set(machine, attotime::from_usec(1), NULL, 0, s1_ack_callback2); + machine->scheduler().timer_set(attotime::from_usec(1), FUNC(s1_ack_callback2)); } @@ -2256,7 +2256,7 @@ static int preprocess_stage_1(running_machine *machine, UINT16 data) /* if we're done, start a timer to send the response words */ if (transfer.state == 0) - timer_set(machine, attotime::from_usec(1), NULL, transfer.sum, s1_ack_callback1); + machine->scheduler().timer_set(attotime::from_usec(1), FUNC(s1_ack_callback1), transfer.sum); return 1; } break; @@ -2272,7 +2272,7 @@ static TIMER_CALLBACK( s2_ack_callback ) /* if the output is full, stall for a usec */ if (IS_OUTPUT_FULL()) { - timer_set(machine, attotime::from_usec(1), NULL, param, s2_ack_callback); + machine->scheduler().timer_set(attotime::from_usec(1), FUNC(s2_ack_callback), param); return; } output_latch_w(space, 0, param, 0xffff); @@ -2369,7 +2369,7 @@ static int preprocess_stage_2(running_machine *machine, UINT16 data) /* if we're done, start a timer to send the response words */ if (transfer.state == 0) { - timer_set(machine, attotime::from_usec(1), NULL, transfer.sum, s2_ack_callback); + machine->scheduler().timer_set(attotime::from_usec(1), FUNC(s2_ack_callback), transfer.sum); transfer.watchdog->reset(); } return 1; diff --git a/src/mame/audio/exidy.c b/src/mame/audio/exidy.c index 3bf977ecf42..d0174cdd4fa 100644 --- a/src/mame/audio/exidy.c +++ b/src/mame/audio/exidy.c @@ -1008,7 +1008,7 @@ WRITE8_DEVICE_HANDLER( victory_sound_command_w ) if (VICTORY_LOG_SOUND) logerror("%04X:!!!! Sound command = %02X\n", cpu_get_previouspc(state->maincpu), data); - timer_call_after_resynch(device->machine, state->pia1, data, delayed_command_w); + device->machine->scheduler().synchronize(FUNC(delayed_command_w), data, state->pia1); } diff --git a/src/mame/audio/geebee.c b/src/mame/audio/geebee.c index c6a5e5d2e50..09ac2765154 100644 --- a/src/mame/audio/geebee.c +++ b/src/mame/audio/geebee.c @@ -141,7 +141,7 @@ static DEVICE_START( geebee_sound ) state->channel = device->machine->sound().stream_alloc(*device, 0, 1, 18432000 / 3 / 2 / 384, NULL, geebee_sound_update); state->vcount = 0; - state->volume_timer = timer_alloc(machine, volume_decay, state); + state->volume_timer = machine->scheduler().timer_alloc(FUNC(volume_decay), state); } DEVICE_GET_INFO( geebee_sound ) diff --git a/src/mame/audio/gottlieb.c b/src/mame/audio/gottlieb.c index b74c5824dd2..3e837e843fa 100644 --- a/src/mame/audio/gottlieb.c +++ b/src/mame/audio/gottlieb.c @@ -272,7 +272,7 @@ logerror("Votrax: intonation %d, phoneme %02x %s\n",data >> 6,data & 0x3f,Phonem } /* generate a NMI after a while to make the CPU continue to send data */ - timer_set(space->machine, attotime::from_usec(50), NULL, 0, gottlieb_nmi_generate); + space->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(gottlieb_nmi_generate)); } static WRITE8_HANDLER( speech_clock_dac_w ) @@ -446,7 +446,7 @@ static TIMER_CALLBACK( nmi_callback ) nmi_state_update(machine); /* set a timer to turn it off again on hte next SOUND_CLOCK/16 */ - timer_set(machine, attotime::from_hz(SOUND2_CLOCK/16), NULL, 0, nmi_clear); + machine->scheduler().timer_set(attotime::from_hz(SOUND2_CLOCK/16), FUNC(nmi_clear)); /* adjust the NMI timer for the next time */ nmi_timer_adjust(); @@ -526,7 +526,7 @@ static WRITE8_HANDLER( speech_control_w ) static SOUND_START( gottlieb2 ) { /* set up the NMI timer */ - nmi_timer = timer_alloc(machine, nmi_callback, NULL); + nmi_timer = machine->scheduler().timer_alloc(FUNC(nmi_callback)); nmi_rate = 0; nmi_timer_adjust(); diff --git a/src/mame/audio/harddriv.c b/src/mame/audio/harddriv.c index 1ad2290fa3f..9baaf3886d1 100644 --- a/src/mame/audio/harddriv.c +++ b/src/mame/audio/harddriv.c @@ -78,7 +78,7 @@ static TIMER_CALLBACK( delayed_68k_w ) WRITE16_HANDLER( hd68k_snd_data_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_68k_w); + space->machine->scheduler().synchronize(FUNC(delayed_68k_w), data); logerror("%06X:main write to sound=%04X\n", cpu_get_previouspc(space->cpu), data); } diff --git a/src/mame/audio/jedi.c b/src/mame/audio/jedi.c index 2ac55ff1ef9..61f6e6334c7 100644 --- a/src/mame/audio/jedi.c +++ b/src/mame/audio/jedi.c @@ -88,7 +88,7 @@ static TIMER_CALLBACK( delayed_audio_latch_w ) WRITE8_HANDLER( jedi_audio_latch_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_audio_latch_w); + space->machine->scheduler().synchronize(FUNC(delayed_audio_latch_w), data); } diff --git a/src/mame/audio/leland.c b/src/mame/audio/leland.c index 9597429f387..dbfab624c29 100644 --- a/src/mame/audio/leland.c +++ b/src/mame/audio/leland.c @@ -557,17 +557,17 @@ static DEVICE_START( common_sh_start ) /* create timers here so they stick around */ state->i80186.cpu = dmaspace->cpu; - state->i80186.timer[0].int_timer = timer_alloc(machine, internal_timer_int, device); - state->i80186.timer[1].int_timer = timer_alloc(machine, internal_timer_int, device); - state->i80186.timer[2].int_timer = timer_alloc(machine, internal_timer_int, device); - state->i80186.timer[0].time_timer = timer_alloc(machine, NULL, NULL); - state->i80186.timer[1].time_timer = timer_alloc(machine, NULL, NULL); - state->i80186.timer[2].time_timer = timer_alloc(machine, NULL, NULL); - state->i80186.dma[0].finish_timer = timer_alloc(machine, dma_timer_callback, device); - state->i80186.dma[1].finish_timer = timer_alloc(machine, dma_timer_callback, device); + state->i80186.timer[0].int_timer = machine->scheduler().timer_alloc(FUNC(internal_timer_int), device); + state->i80186.timer[1].int_timer = machine->scheduler().timer_alloc(FUNC(internal_timer_int), device); + state->i80186.timer[2].int_timer = machine->scheduler().timer_alloc(FUNC(internal_timer_int), device); + state->i80186.timer[0].time_timer = machine->scheduler().timer_alloc(FUNC(NULL)); + state->i80186.timer[1].time_timer = machine->scheduler().timer_alloc(FUNC(NULL)); + state->i80186.timer[2].time_timer = machine->scheduler().timer_alloc(FUNC(NULL)); + state->i80186.dma[0].finish_timer = machine->scheduler().timer_alloc(FUNC(dma_timer_callback), device); + state->i80186.dma[1].finish_timer = machine->scheduler().timer_alloc(FUNC(dma_timer_callback), device); for (i = 0; i < 9; i++) - state->counter[i].timer = timer_alloc(machine, NULL, NULL); + state->counter[i].timer = machine->scheduler().timer_alloc(FUNC(NULL)); } static DEVICE_START( leland_80186_sound ) @@ -1814,7 +1814,7 @@ static TIMER_CALLBACK( command_lo_sync ) WRITE8_DEVICE_HANDLER( leland_80186_command_lo_w ) { - timer_call_after_resynch(device->machine, device, data, command_lo_sync); + device->machine->scheduler().synchronize(FUNC(command_lo_sync), data, device); } @@ -1877,7 +1877,7 @@ READ8_DEVICE_HANDLER( leland_80186_response_r ) if (LOG_COMM) logerror("%04X:Read sound response latch = %02X\n", pc, state->sound_response); /* synchronize the response */ - timer_call_after_resynch(device->machine, device, pc + 2, delayed_response_r); + device->machine->scheduler().synchronize(FUNC(delayed_response_r), pc + 2, device); return state->sound_response; } diff --git a/src/mame/audio/m72.c b/src/mame/audio/m72.c index 578cc957467..0f9981c569e 100644 --- a/src/mame/audio/m72.c +++ b/src/mame/audio/m72.c @@ -118,9 +118,9 @@ SOUND_RESET( m72 ) void m72_ym2151_irq_handler(device_t *device, int irq) { if (irq) - timer_call_after_resynch(device->machine, NULL, YM2151_ASSERT,setvector_callback); + device->machine->scheduler().synchronize(FUNC(setvector_callback), YM2151_ASSERT); else - timer_call_after_resynch(device->machine, NULL, YM2151_CLEAR,setvector_callback); + device->machine->scheduler().synchronize(FUNC(setvector_callback), YM2151_CLEAR); } WRITE16_HANDLER( m72_sound_command_w ) @@ -128,19 +128,19 @@ WRITE16_HANDLER( m72_sound_command_w ) if (ACCESSING_BITS_0_7) { soundlatch_w(space,offset,data); - timer_call_after_resynch(space->machine, NULL, Z80_ASSERT,setvector_callback); + space->machine->scheduler().synchronize(FUNC(setvector_callback), Z80_ASSERT); } } WRITE8_HANDLER( m72_sound_command_byte_w ) { soundlatch_w(space,offset,data); - timer_call_after_resynch(space->machine, NULL, Z80_ASSERT,setvector_callback); + space->machine->scheduler().synchronize(FUNC(setvector_callback), Z80_ASSERT); } WRITE8_HANDLER( m72_sound_irq_ack_w ) { - timer_call_after_resynch(space->machine, NULL, Z80_CLEAR,setvector_callback); + space->machine->scheduler().synchronize(FUNC(setvector_callback), Z80_CLEAR); } diff --git a/src/mame/audio/mcr.c b/src/mame/audio/mcr.c index 915a310679f..867eea2447a 100644 --- a/src/mame/audio/mcr.c +++ b/src/mame/audio/mcr.c @@ -358,7 +358,7 @@ static WRITE8_DEVICE_HANDLER( ssio_portb1_w ) /********* external interfaces ***********/ WRITE8_HANDLER( ssio_data_w ) { - timer_call_after_resynch(space->machine, NULL, (offset << 8) | (data & 0xff), ssio_delayed_data_w); + space->machine->scheduler().synchronize(FUNC(ssio_delayed_data_w), (offset << 8) | (data & 0xff)); } READ8_HANDLER( ssio_status_r ) @@ -548,7 +548,7 @@ static WRITE16_DEVICE_HANDLER( csdeluxe_pia_w ) /********* external interfaces ***********/ WRITE8_HANDLER( csdeluxe_data_w ) { - timer_call_after_resynch(space->machine, NULL, data, csdeluxe_delayed_data_w); + space->machine->scheduler().synchronize(FUNC(csdeluxe_delayed_data_w), data); } READ8_HANDLER( csdeluxe_status_r ) @@ -666,7 +666,7 @@ static TIMER_CALLBACK( soundsgood_delayed_data_w ) /********* external interfaces ***********/ WRITE8_HANDLER( soundsgood_data_w ) { - timer_call_after_resynch(space->machine, NULL, data, soundsgood_delayed_data_w); + space->machine->scheduler().synchronize(FUNC(soundsgood_delayed_data_w), data); } READ8_HANDLER( soundsgood_status_r ) @@ -770,7 +770,7 @@ static TIMER_CALLBACK( turbocs_delayed_data_w ) /********* external interfaces ***********/ WRITE8_HANDLER( turbocs_data_w ) { - timer_call_after_resynch(space->machine, NULL, data, turbocs_delayed_data_w); + space->machine->scheduler().synchronize(FUNC(turbocs_delayed_data_w), data); } READ8_HANDLER( turbocs_status_r ) @@ -903,7 +903,7 @@ static TIMER_CALLBACK( squawkntalk_delayed_data_w ) /********* external interfaces ***********/ WRITE8_HANDLER( squawkntalk_data_w ) { - timer_call_after_resynch(space->machine, NULL, data, squawkntalk_delayed_data_w); + space->machine->scheduler().synchronize(FUNC(squawkntalk_delayed_data_w), data); } void squawkntalk_reset_w(running_machine *machine, int state) diff --git a/src/mame/audio/n8080.c b/src/mame/audio/n8080.c index 5cc615fcf26..5f7002b588e 100644 --- a/src/mame/audio/n8080.c +++ b/src/mame/audio/n8080.c @@ -329,12 +329,12 @@ static TIMER_CALLBACK( delayed_sound_2_callback ) WRITE8_HANDLER( n8080_sound_1_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_sound_1_callback); /* force CPUs to sync */ + space->machine->scheduler().synchronize(FUNC(delayed_sound_1_callback), data); /* force CPUs to sync */ } WRITE8_HANDLER( n8080_sound_2_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_sound_2_callback); /* force CPUs to sync */ + space->machine->scheduler().synchronize(FUNC(delayed_sound_2_callback), data); /* force CPUs to sync */ } @@ -470,9 +470,9 @@ MACHINE_START( spacefev_sound ) { n8080_state *state = machine->driver_data<n8080_state>(); - state->sound_timer[0] = timer_alloc(machine, stop_mono_flop_callback, NULL); - state->sound_timer[1] = timer_alloc(machine, stop_mono_flop_callback, NULL); - state->sound_timer[2] = timer_alloc(machine, stop_mono_flop_callback, NULL); + state->sound_timer[0] = machine->scheduler().timer_alloc(FUNC(stop_mono_flop_callback)); + state->sound_timer[1] = machine->scheduler().timer_alloc(FUNC(stop_mono_flop_callback)); + state->sound_timer[2] = machine->scheduler().timer_alloc(FUNC(stop_mono_flop_callback)); state_save_register_global(machine, state->prev_snd_data); state_save_register_global(machine, state->prev_sound_pins); @@ -502,8 +502,8 @@ MACHINE_START( sheriff_sound ) { n8080_state *state = machine->driver_data<n8080_state>(); - state->sound_timer[0] = timer_alloc(machine, stop_mono_flop_callback, NULL); - state->sound_timer[1] = timer_alloc(machine, stop_mono_flop_callback, NULL); + state->sound_timer[0] = machine->scheduler().timer_alloc(FUNC(stop_mono_flop_callback)); + state->sound_timer[1] = machine->scheduler().timer_alloc(FUNC(stop_mono_flop_callback)); state_save_register_global(machine, state->prev_snd_data); state_save_register_global(machine, state->prev_sound_pins); diff --git a/src/mame/audio/namco52.c b/src/mame/audio/namco52.c index 2522b3ecdde..9fd9d4195eb 100644 --- a/src/mame/audio/namco52.c +++ b/src/mame/audio/namco52.c @@ -142,7 +142,7 @@ WRITE8_DEVICE_HANDLER( namco_52xx_write ) { namco_52xx_state *state = get_safe_token(device); - timer_call_after_resynch(device->machine, (void *)device, data, namco_52xx_latch_callback); + device->machine->scheduler().synchronize(FUNC(namco_52xx_latch_callback), data, (void *)device); cpu_set_input_line(state->cpu, 0, ASSERT_LINE); @@ -154,7 +154,7 @@ WRITE8_DEVICE_HANDLER( namco_52xx_write ) /* the 52xx uses TSTI to check for an interrupt; it also may be handling a timer interrupt, so we need to ensure the IRQ line is held long enough */ - timer_set(device->machine, attotime::from_usec(5*21), (void *)device, 0, namco_52xx_irq_clear); + device->machine->scheduler().timer_set(attotime::from_usec(5*21), FUNC(namco_52xx_irq_clear), 0, (void *)device); } @@ -220,7 +220,7 @@ static DEVICE_START( namco_52xx ) /* start the external clock */ if (intf->extclock != 0) - timer_pulse(device->machine, attotime(0, intf->extclock), (void *)device, 0, external_clock_pulse); + device->machine->scheduler().timer_pulse(attotime(0, intf->extclock), FUNC(external_clock_pulse), 0, device); } diff --git a/src/mame/audio/namco54.c b/src/mame/audio/namco54.c index 7bb681e5bc4..a7bce265c67 100644 --- a/src/mame/audio/namco54.c +++ b/src/mame/audio/namco54.c @@ -120,7 +120,7 @@ WRITE8_DEVICE_HANDLER( namco_54xx_write ) { namco_54xx_state *state = get_safe_token(device); - timer_call_after_resynch(device->machine, (void *)device, data, namco_54xx_latch_callback); + device->machine->scheduler().synchronize(FUNC(namco_54xx_latch_callback), data, (void *)device); cpu_set_input_line(state->cpu, 0, ASSERT_LINE); @@ -129,7 +129,7 @@ WRITE8_DEVICE_HANDLER( namco_54xx_write ) // The input clock to the 06XX interface chip is 64H, that is // 18432000/6/64 = 48kHz, so it makes sense for the irq line to be // asserted for one clock cycle ~= 21us. - timer_set(device->machine, attotime::from_usec(21), (void *)device, 0, namco_54xx_irq_clear); + device->machine->scheduler().timer_set(attotime::from_usec(21), FUNC(namco_54xx_irq_clear), 0, (void *)device); } diff --git a/src/mame/audio/qix.c b/src/mame/audio/qix.c index b60f00bd03c..75a7e869fc3 100644 --- a/src/mame/audio/qix.c +++ b/src/mame/audio/qix.c @@ -109,7 +109,7 @@ static TIMER_CALLBACK( deferred_sndpia1_porta_w ) static WRITE8_DEVICE_HANDLER( sync_sndpia1_porta_w ) { /* we need to synchronize this so the sound CPU doesn't drop anything important */ - timer_call_after_resynch(device->machine, (void *)device, data, deferred_sndpia1_porta_w); + device->machine->scheduler().synchronize(FUNC(deferred_sndpia1_porta_w), data, (void *)device); } diff --git a/src/mame/audio/segag80r.c b/src/mame/audio/segag80r.c index ed23f0495e3..48916c9573c 100644 --- a/src/mame/audio/segag80r.c +++ b/src/mame/audio/segag80r.c @@ -582,7 +582,7 @@ static DEVICE_START( sega005_sound ) sega005_stream = device->machine->sound().stream_alloc(*device, 0, 1, SEGA005_COUNTER_FREQ, NULL, sega005_stream_update); /* create a timer for the 555 */ - sega005_sound_timer = timer_alloc(machine, sega005_auto_timer, NULL); + sega005_sound_timer = machine->scheduler().timer_alloc(FUNC(sega005_auto_timer)); /* set the initial sound data */ sound_data = 0x00; diff --git a/src/mame/audio/segasnd.c b/src/mame/audio/segasnd.c index 8909d8f34bc..647fd59b7cd 100644 --- a/src/mame/audio/segasnd.c +++ b/src/mame/audio/segasnd.c @@ -222,7 +222,7 @@ static TIMER_CALLBACK( delayed_speech_w ) WRITE8_HANDLER( sega_speech_data_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_speech_w); + space->machine->scheduler().synchronize(FUNC(delayed_speech_w), data); } @@ -356,7 +356,7 @@ static TIMER_CALLBACK( delayed_usb_data_w ) WRITE8_HANDLER( sega_usb_data_w ) { LOG(("%04X:usb_data_w = %02X\n", cpu_get_pc(space->cpu), data)); - timer_call_after_resynch(space->machine, NULL, data, delayed_usb_data_w); + space->machine->scheduler().synchronize(FUNC(delayed_usb_data_w), data); /* boost the interleave so that sequences can be sent */ cpuexec_boost_interleave(space->machine, attotime::zero, attotime::from_usec(250)); diff --git a/src/mame/audio/senjyo.c b/src/mame/audio/senjyo.c index 04fcbc1dd8f..99a7ddf314e 100644 --- a/src/mame/audio/senjyo.c +++ b/src/mame/audio/senjyo.c @@ -90,5 +90,5 @@ SAMPLES_START( senjyo_sh_start ) sample_set_volume(device, 0, state->single_volume / 15.0); sample_start_raw(device, 0, state->single_data, SINGLE_LENGTH, state->single_rate, 1); - timer_pulse(machine, machine->primary_screen->frame_period(), NULL, 0, senjyo_sh_update); + machine->scheduler().timer_pulse(machine->primary_screen->frame_period(), FUNC(senjyo_sh_update)); } diff --git a/src/mame/audio/snes_snd.c b/src/mame/audio/snes_snd.c index 55458e1f3d2..653206c8e08 100644 --- a/src/mame/audio/snes_snd.c +++ b/src/mame/audio/snes_snd.c @@ -1320,13 +1320,13 @@ static DEVICE_START( snes_sound ) memcpy(spc700->ipl_region, machine->region("user5")->base(), 64); /* Initialize the timers */ - spc700->timer[0] = timer_alloc(machine, snes_spc_timer, spc700); + spc700->timer[0] = machine->scheduler().timer_alloc(FUNC(snes_spc_timer), spc700); timer_adjust_periodic(spc700->timer[0], attotime::from_hz(8000), 0, attotime::from_hz(8000)); timer_enable(spc700->timer[0], 0); - spc700->timer[1] = timer_alloc(machine, snes_spc_timer, spc700); + spc700->timer[1] = machine->scheduler().timer_alloc(FUNC(snes_spc_timer), spc700); timer_adjust_periodic(spc700->timer[1], attotime::from_hz(8000), 1, attotime::from_hz(8000)); timer_enable(spc700->timer[1], 0); - spc700->timer[2] = timer_alloc(machine, snes_spc_timer, spc700); + spc700->timer[2] = machine->scheduler().timer_alloc(FUNC(snes_spc_timer), spc700); timer_adjust_periodic(spc700->timer[2], attotime::from_hz(64000), 2, attotime::from_hz(64000)); timer_enable(spc700->timer[2], 0); diff --git a/src/mame/audio/starwars.c b/src/mame/audio/starwars.c index 5efe8958e0a..2fcda85cfc8 100644 --- a/src/mame/audio/starwars.c +++ b/src/mame/audio/starwars.c @@ -100,7 +100,7 @@ READ8_HANDLER( starwars_sin_r ) WRITE8_HANDLER( starwars_sout_w ) { - timer_call_after_resynch(space->machine, NULL, data, sound_callback); + space->machine->scheduler().synchronize(FUNC(sound_callback), data); } @@ -138,7 +138,7 @@ static TIMER_CALLBACK( main_callback ) WRITE8_HANDLER( starwars_main_wr_w ) { - timer_call_after_resynch(space->machine, NULL, data, main_callback); + space->machine->scheduler().synchronize(FUNC(main_callback), data); } diff --git a/src/mame/audio/t5182.c b/src/mame/audio/t5182.c index 6126a81bea0..2daa7bed5d6 100644 --- a/src/mame/audio/t5182.c +++ b/src/mame/audio/t5182.c @@ -206,25 +206,25 @@ static TIMER_CALLBACK( setirq_callback ) WRITE8_HANDLER( t5182_sound_irq_w ) { - timer_call_after_resynch(space->machine, NULL, CPU_ASSERT,setirq_callback); + space->machine->scheduler().synchronize(FUNC(setirq_callback), CPU_ASSERT); } static WRITE8_HANDLER( t5182_ym2151_irq_ack_w ) { - timer_call_after_resynch(space->machine, NULL, YM2151_ACK,setirq_callback); + space->machine->scheduler().synchronize(FUNC(setirq_callback), YM2151_ACK); } static WRITE8_HANDLER( t5182_cpu_irq_ack_w ) { - timer_call_after_resynch(space->machine, NULL, CPU_CLEAR,setirq_callback); + space->machine->scheduler().synchronize(FUNC(setirq_callback), CPU_CLEAR); } static void t5182_ym2151_irq_handler(device_t *device, int irq) { if (irq) - timer_call_after_resynch(device->machine, NULL, YM2151_ASSERT,setirq_callback); + device->machine->scheduler().synchronize(FUNC(setirq_callback), YM2151_ASSERT); else - timer_call_after_resynch(device->machine, NULL, YM2151_CLEAR,setirq_callback); + device->machine->scheduler().synchronize(FUNC(setirq_callback), YM2151_CLEAR); } diff --git a/src/mame/audio/turbo.c b/src/mame/audio/turbo.c index c1c6018661f..69ddf0d82f5 100644 --- a/src/mame/audio/turbo.c +++ b/src/mame/audio/turbo.c @@ -111,7 +111,7 @@ WRITE8_DEVICE_HANDLER( turbo_sound_a_w ) #else if (((data ^ last_sound_a) & 0x1e) && (last_sound_a & 0x1e) != 0x1e) - timer_set(space->machine, attotime::from_hz(20000), NULL, data, update_sound_a); + space->machine->scheduler().timer_set(attotime::from_hz(20000), FUNC(update_sound_a), data); else update_sound_a(data); diff --git a/src/mame/audio/vicdual.c b/src/mame/audio/vicdual.c index 27d43e787cf..03b89263813 100644 --- a/src/mame/audio/vicdual.c +++ b/src/mame/audio/vicdual.c @@ -139,7 +139,7 @@ static TIMER_CALLBACK( frogs_croak_callback ) MACHINE_START( frogs_audio ) { - frogs_croak_timer = timer_alloc(machine, frogs_croak_callback, NULL); + frogs_croak_timer = machine->scheduler().timer_alloc(FUNC(frogs_croak_callback)); } diff --git a/src/mame/audio/warpwarp.c b/src/mame/audio/warpwarp.c index 5eb015c964d..e476fc6df97 100644 --- a/src/mame/audio/warpwarp.c +++ b/src/mame/audio/warpwarp.c @@ -236,8 +236,8 @@ static DEVICE_START( warpwarp_sound ) state->channel = device->machine->sound().stream_alloc(*device, 0, 1, CLOCK_16H, NULL, warpwarp_sound_update); - state->sound_volume_timer = timer_alloc(machine, sound_volume_decay, state); - state->music_volume_timer = timer_alloc(machine, music_volume_decay, state); + state->sound_volume_timer = machine->scheduler().timer_alloc(FUNC(sound_volume_decay), state); + state->music_volume_timer = machine->scheduler().timer_alloc(FUNC(music_volume_decay), state); } diff --git a/src/mame/audio/williams.c b/src/mame/audio/williams.c index 6a2297ae067..c1e3862ed22 100644 --- a/src/mame/audio/williams.c +++ b/src/mame/audio/williams.c @@ -480,7 +480,7 @@ static TIMER_CALLBACK( williams_cvsd_delayed_data_w ) void williams_cvsd_data_w(running_machine *machine, int data) { - timer_call_after_resynch(machine, NULL, data, williams_cvsd_delayed_data_w); + machine->scheduler().synchronize(FUNC(williams_cvsd_delayed_data_w), data); } @@ -554,7 +554,7 @@ static TIMER_CALLBACK( narc_sync_clear ) static WRITE8_HANDLER( narc_master_sync_w ) { - timer_set(space->machine, attotime::from_double(TIME_OF_74LS123(180000, 0.000001)), NULL, 0x01, narc_sync_clear); + space->machine->scheduler().timer_set(attotime::from_double(TIME_OF_74LS123(180000, 0.000001)), FUNC(narc_sync_clear), 0x01); 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, attotime::from_double(TIME_OF_74LS123(180000, 0.000001)), NULL, 0x02, narc_sync_clear); + space->machine->scheduler().timer_set(attotime::from_double(TIME_OF_74LS123(180000, 0.000001)), FUNC(narc_sync_clear), 0x02); audio_sync |= 0x02; logerror("Slave sync = %02X\n", data); } @@ -649,7 +649,7 @@ static READ8_HANDLER( adpcm_command_r ) /* don't clear the external IRQ state for a short while; this allows the self-tests to pass */ - timer_set(space->machine, attotime::from_usec(10), NULL, 0, clear_irq_state); + space->machine->scheduler().timer_set(attotime::from_usec(10), FUNC(clear_irq_state)); return soundlatch_r(space, 0); } diff --git a/src/mame/drivers/2mindril.c b/src/mame/drivers/2mindril.c index 51c77d3b23e..06ce0d162cd 100644 --- a/src/mame/drivers/2mindril.c +++ b/src/mame/drivers/2mindril.c @@ -213,23 +213,23 @@ static WRITE16_HANDLER( sensors_w ) /*---- ---- ---- -x-- lamp*/ if (data & 1) { - //timer_set(space->machine, attotime::from_seconds(2), NULL, 0x100, shutter_req ); + //space->machine->scheduler().timer_set(attotime::from_seconds(2), FUNC(shutter_req ), 0x100); state->shutter_sensor = 0x100; } else if (data & 2) { - //timer_set( space->machine, attotime::from_seconds(2), NULL, 0x200, shutter_req ); + //space->machine->scheduler().timer_set( attotime::from_seconds(2), FUNC(shutter_req ), 0x200); state->shutter_sensor = 0x200; } if (data & 0x1000 || data & 0x4000) { - //timer_set( space->machine, attotime::from_seconds(2), NULL, 0x800, defender_req ); + //space->machine->scheduler().timer_set( attotime::from_seconds(2), FUNC(defender_req ), 0x800); state->defender_sensor = 0x800; } else if (data & 0x2000 || data & 0x8000) { - //timer_set( space->machine, attotime::from_seconds(2), NULL, 0x400, defender_req ); + //space->machine->scheduler().timer_set( attotime::from_seconds(2), FUNC(defender_req ), 0x400); state->defender_sensor = 0x400; } } diff --git a/src/mame/drivers/39in1.c b/src/mame/drivers/39in1.c index a00ad642f57..facda0376ad 100644 --- a/src/mame/drivers/39in1.c +++ b/src/mame/drivers/39in1.c @@ -1542,21 +1542,21 @@ static void pxa255_start(running_machine* machine) for(index = 0; index < 16; index++) { state->dma_regs.dcsr[index] = 0x00000008; - state->dma_regs.timer[index] = timer_alloc(machine, pxa255_dma_dma_end, 0); + state->dma_regs.timer[index] = machine->scheduler().timer_alloc(FUNC(pxa255_dma_dma_end)); } memset(&state->ostimer_regs, 0, sizeof(state->ostimer_regs)); for(index = 0; index < 4; index++) { state->ostimer_regs.osmr[index] = 0; - state->ostimer_regs.timer[index] = timer_alloc(machine, pxa255_ostimer_match, 0); + state->ostimer_regs.timer[index] = machine->scheduler().timer_alloc(FUNC(pxa255_ostimer_match)); } memset(&state->intc_regs, 0, sizeof(state->intc_regs)); memset(&state->lcd_regs, 0, sizeof(state->lcd_regs)); - state->lcd_regs.dma[0].eof = timer_alloc(machine, pxa255_lcd_dma_eof, 0); - state->lcd_regs.dma[1].eof = timer_alloc(machine, pxa255_lcd_dma_eof, 0); + state->lcd_regs.dma[0].eof = machine->scheduler().timer_alloc(FUNC(pxa255_lcd_dma_eof)); + state->lcd_regs.dma[1].eof = machine->scheduler().timer_alloc(FUNC(pxa255_lcd_dma_eof)); state->lcd_regs.trgbr = 0x00aa5500; state->lcd_regs.tcr = 0x0000754f; diff --git a/src/mame/drivers/40love.c b/src/mame/drivers/40love.c index 6a343ae5972..1bce8349fe8 100644 --- a/src/mame/drivers/40love.c +++ b/src/mame/drivers/40love.c @@ -237,7 +237,7 @@ static TIMER_CALLBACK( nmi_callback ) static WRITE8_HANDLER( sound_command_w ) { soundlatch_w(space, 0, data); - timer_call_after_resynch(space->machine, NULL, data, nmi_callback); + space->machine->scheduler().synchronize(FUNC(nmi_callback), data); } static WRITE8_HANDLER( nmi_disable_w ) diff --git a/src/mame/drivers/acefruit.c b/src/mame/drivers/acefruit.c index 074b427cf7c..830ee0131d0 100644 --- a/src/mame/drivers/acefruit.c +++ b/src/mame/drivers/acefruit.c @@ -52,7 +52,7 @@ static TIMER_CALLBACK( acefruit_refresh ) static VIDEO_START( acefruit ) { - acefruit_refresh_timer = timer_alloc(machine, acefruit_refresh, NULL); + acefruit_refresh_timer = machine->scheduler().timer_alloc(FUNC(acefruit_refresh)); } static INTERRUPT_GEN( acefruit_vblank ) diff --git a/src/mame/drivers/alg.c b/src/mame/drivers/alg.c index 28e66ec7439..9a00e6eba76 100644 --- a/src/mame/drivers/alg.c +++ b/src/mame/drivers/alg.c @@ -98,7 +98,7 @@ static MACHINE_START( alg ) alg_state *state = machine->driver_data<alg_state>(); state->laserdisc = machine->device("laserdisc"); - state->serial_timer = timer_alloc(machine, response_timer, NULL); + state->serial_timer = machine->scheduler().timer_alloc(FUNC(response_timer)); state->serial_timer_active = FALSE; } diff --git a/src/mame/drivers/aristmk4.c b/src/mame/drivers/aristmk4.c index 96db82e708f..d339a82a892 100644 --- a/src/mame/drivers/aristmk4.c +++ b/src/mame/drivers/aristmk4.c @@ -446,7 +446,7 @@ static READ8_DEVICE_HANDLER(via_b_r) case 0x02: ret=ret^0x20; inscrd++; - timer_set(device->machine, attotime::from_msec(150), NULL, 0, coin_input_reset); + device->machine->scheduler().timer_set(attotime::from_msec(150), FUNC(coin_input_reset)); break; default: @@ -460,7 +460,7 @@ static READ8_DEVICE_HANDLER(via_b_r) { case 0x00: ret=ret^0x40; - timer_set(device->machine, attotime::from_msec(175), NULL, 0, hopper_reset); + device->machine->scheduler().timer_set(attotime::from_msec(175), FUNC(hopper_reset)); hopper_motor=0x02; break; case 0x01: diff --git a/src/mame/drivers/aristmk5.c b/src/mame/drivers/aristmk5.c index 7bd9491fb2f..8b5d4ac50d5 100644 --- a/src/mame/drivers/aristmk5.c +++ b/src/mame/drivers/aristmk5.c @@ -231,7 +231,7 @@ static MACHINE_START( aristmk5 ) // reset the DAC to centerline //dac_signed_data_w(machine->device("dac"), 0x80); - mk5_2KHz_timer = timer_alloc(machine, mk5_2KHz_callback, 0); + mk5_2KHz_timer = machine->scheduler().timer_alloc(FUNC(mk5_2KHz_callback)); } static MACHINE_RESET( aristmk5 ) diff --git a/src/mame/drivers/artmagic.c b/src/mame/drivers/artmagic.c index 56a29432ecd..4eeb9db5a6b 100644 --- a/src/mame/drivers/artmagic.c +++ b/src/mame/drivers/artmagic.c @@ -161,7 +161,7 @@ static READ16_HANDLER( ultennis_hack_r ) { hack_irq = 1; update_irq_state(space->machine); - timer_set(space->machine, attotime::from_usec(1), NULL, 0, irq_off); + space->machine->scheduler().timer_set(attotime::from_usec(1), FUNC(irq_off)); } return input_port_read(space->machine, "300000"); } diff --git a/src/mame/drivers/asterix.c b/src/mame/drivers/asterix.c index c83e6f70ce6..9b554e09dab 100644 --- a/src/mame/drivers/asterix.c +++ b/src/mame/drivers/asterix.c @@ -82,7 +82,7 @@ static WRITE8_HANDLER( sound_arm_nmi_w ) asterix_state *state = space->machine->driver_data<asterix_state>(); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE); - timer_set(space->machine, attotime::from_usec(5), NULL, 0, nmi_callback); + space->machine->scheduler().timer_set(attotime::from_usec(5), FUNC(nmi_callback)); } static WRITE16_HANDLER( sound_irq_w ) diff --git a/src/mame/drivers/astinvad.c b/src/mame/drivers/astinvad.c index ea693efdbac..301763bfe7e 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, attotime::from_double(300 * 0.1e-6), NULL, 0, kamikaze_int_off); + machine->scheduler().timer_set(attotime::from_double(300 * 0.1e-6), FUNC(kamikaze_int_off)); } @@ -232,7 +232,7 @@ static MACHINE_START( kamikaze ) state->ppi8255_1 = machine->device("ppi8255_1"); state->samples = machine->device("samples"); - state->int_timer = timer_alloc(machine, kamizake_int_gen, NULL); + state->int_timer = machine->scheduler().timer_alloc(FUNC(kamizake_int_gen)); timer_adjust_oneshot(state->int_timer, machine->primary_screen->time_until_pos(128), 128); state_save_register_global(machine, state->screen_flip); diff --git a/src/mame/drivers/asuka.c b/src/mame/drivers/asuka.c index 37ff0ad5bfc..7e5f9a421b6 100644 --- a/src/mame/drivers/asuka.c +++ b/src/mame/drivers/asuka.c @@ -238,7 +238,7 @@ static TIMER_CALLBACK( cadash_interrupt5 ) static INTERRUPT_GEN( cadash_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(500), NULL, 0, cadash_interrupt5); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(500), FUNC(cadash_interrupt5)); cpu_set_input_line(device, 4, HOLD_LINE); /* interrupt vector 4 */ } diff --git a/src/mame/drivers/atarisy2.c b/src/mame/drivers/atarisy2.c index c6859b6c352..b687deaf732 100644 --- a/src/mame/drivers/atarisy2.c +++ b/src/mame/drivers/atarisy2.c @@ -299,7 +299,7 @@ static TIMER_CALLBACK( delayed_int_enable_w ) static WRITE16_HANDLER( int_enable_w ) { if (offset == 0 && ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, data, delayed_int_enable_w); + space->machine->scheduler().synchronize(FUNC(delayed_int_enable_w), data); } diff --git a/src/mame/drivers/atetris.c b/src/mame/drivers/atetris.c index 26ebc86d783..2dc073f369d 100644 --- a/src/mame/drivers/atetris.c +++ b/src/mame/drivers/atetris.c @@ -114,7 +114,7 @@ static MACHINE_START( atetris ) atetris_state *state = machine->driver_data<atetris_state>(); /* Allocate interrupt timer */ - state->interrupt_timer = timer_alloc(machine, interrupt_gen, NULL); + state->interrupt_timer = machine->scheduler().timer_alloc(FUNC(interrupt_gen)); /* Set up save state */ state_save_register_global(machine, state->current_bank); diff --git a/src/mame/drivers/beaminv.c b/src/mame/drivers/beaminv.c index 0ede01a379d..43b67294f3a 100644 --- a/src/mame/drivers/beaminv.c +++ b/src/mame/drivers/beaminv.c @@ -110,7 +110,7 @@ static TIMER_CALLBACK( interrupt_callback ) static void create_interrupt_timer( running_machine *machine ) { beaminv_state *state = machine->driver_data<beaminv_state>(); - state->interrupt_timer = timer_alloc(machine, interrupt_callback, NULL); + state->interrupt_timer = machine->scheduler().timer_alloc(FUNC(interrupt_callback)); } diff --git a/src/mame/drivers/berzerk.c b/src/mame/drivers/berzerk.c index 7dbafa76d85..8ae427a7c20 100644 --- a/src/mame/drivers/berzerk.c +++ b/src/mame/drivers/berzerk.c @@ -174,7 +174,7 @@ static TIMER_CALLBACK( irq_callback ) static void create_irq_timer(running_machine *machine) { - irq_timer = timer_alloc(machine, irq_callback, NULL); + irq_timer = machine->scheduler().timer_alloc(FUNC(irq_callback)); } @@ -251,7 +251,7 @@ static TIMER_CALLBACK( nmi_callback ) static void create_nmi_timer(running_machine *machine) { - nmi_timer = timer_alloc(machine, nmi_callback, NULL); + nmi_timer = machine->scheduler().timer_alloc(FUNC(nmi_callback)); } diff --git a/src/mame/drivers/bigevglf.c b/src/mame/drivers/bigevglf.c index 44aa0b8c19f..b3b54bb8894 100644 --- a/src/mame/drivers/bigevglf.c +++ b/src/mame/drivers/bigevglf.c @@ -83,14 +83,14 @@ static TIMER_CALLBACK( from_sound_latch_callback ) } static WRITE8_HANDLER( beg_fromsound_w ) /* write to D800 sets bit 1 in status */ { - timer_call_after_resynch(space->machine, NULL, (cpu_get_pc(space->cpu) << 16) | data, from_sound_latch_callback); + space->machine->scheduler().synchronize(FUNC(from_sound_latch_callback), (cpu_get_pc(space->cpu) << 16) | data); } static READ8_HANDLER( beg_fromsound_r ) { bigevglf_state *state = space->machine->driver_data<bigevglf_state>(); /* set a timer to force synchronization after the read */ - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return state->from_sound; } @@ -99,7 +99,7 @@ static READ8_HANDLER( beg_soundstate_r ) bigevglf_state *state = space->machine->driver_data<bigevglf_state>(); UINT8 ret = state->sound_state; /* set a timer to force synchronization after the read */ - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); state->sound_state &= ~2; /* read from port 21 clears bit 1 in status */ return ret; } @@ -108,7 +108,7 @@ static READ8_HANDLER( soundstate_r ) { bigevglf_state *state = space->machine->driver_data<bigevglf_state>(); /* set a timer to force synchronization after the read */ - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return state->sound_state; } @@ -127,7 +127,7 @@ static WRITE8_HANDLER( sound_command_w ) /* write to port 20 clears bit 0 in sta { bigevglf_state *state = space->machine->driver_data<bigevglf_state>(); state->for_sound = data; - timer_call_after_resynch(space->machine, NULL, data, nmi_callback); + space->machine->scheduler().synchronize(FUNC(nmi_callback), data); } static READ8_HANDLER( sound_command_r ) /* read from D800 sets bit 0 in status */ @@ -165,22 +165,22 @@ static TIMER_CALLBACK( deferred_ls74_w ) /* do this on a timer to let the CPUs synchronize */ static WRITE8_HANDLER( beg13_a_clr_w ) { - timer_call_after_resynch(space->machine, NULL, (0 << 8) | 0, deferred_ls74_w); + space->machine->scheduler().synchronize(FUNC(deferred_ls74_w), (0 << 8) | 0); } static WRITE8_HANDLER( beg13_b_clr_w ) { - timer_call_after_resynch(space->machine, NULL, (1 << 8) | 0, deferred_ls74_w); + space->machine->scheduler().synchronize(FUNC(deferred_ls74_w), (1 << 8) | 0); } static WRITE8_HANDLER( beg13_a_set_w ) { - timer_call_after_resynch(space->machine, NULL, (0 << 8) | 1, deferred_ls74_w); + space->machine->scheduler().synchronize(FUNC(deferred_ls74_w), (0 << 8) | 1); } static WRITE8_HANDLER( beg13_b_set_w ) { - timer_call_after_resynch(space->machine, NULL, (1 << 8) | 1, deferred_ls74_w); + space->machine->scheduler().synchronize(FUNC(deferred_ls74_w), (1 << 8) | 1); } static READ8_HANDLER( beg_status_r ) @@ -197,7 +197,7 @@ static READ8_HANDLER( beg_status_r ) */ /* set a timer to force synchronization after the read */ - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return (state->beg13_ls74[0] << 0) | (state->beg13_ls74[1] << 1); } diff --git a/src/mame/drivers/bombjack.c b/src/mame/drivers/bombjack.c index 6ca28be74c1..83ee2ce08c1 100644 --- a/src/mame/drivers/bombjack.c +++ b/src/mame/drivers/bombjack.c @@ -110,7 +110,7 @@ static TIMER_CALLBACK( soundlatch_callback ) static WRITE8_HANDLER( bombjack_soundlatch_w ) { /* make all the CPUs synchronize, and only AFTER that write the new command to the latch */ - timer_call_after_resynch(space->machine, NULL, data, soundlatch_callback); + space->machine->scheduler().synchronize(FUNC(soundlatch_callback), data); } static READ8_HANDLER( bombjack_soundlatch_r ) diff --git a/src/mame/drivers/boxer.c b/src/mame/drivers/boxer.c index 95de761281a..119f7a8adc4 100644 --- a/src/mame/drivers/boxer.c +++ b/src/mame/drivers/boxer.c @@ -80,7 +80,7 @@ static TIMER_CALLBACK( periodic_callback ) for (i = 1; i < 256; i++) if (mask[i] != 0) - timer_set(machine, machine->primary_screen->time_until_pos(i), NULL, mask[i], pot_interrupt); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(i), FUNC(pot_interrupt), mask[i]); state->pot_state = 0; } @@ -90,7 +90,7 @@ static TIMER_CALLBACK( periodic_callback ) if (scanline >= 262) scanline = 0; - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, periodic_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(periodic_callback), scanline); } @@ -428,7 +428,7 @@ static MACHINE_START( boxer ) static MACHINE_RESET( boxer ) { boxer_state *state = machine->driver_data<boxer_state>(); - timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, periodic_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(0), FUNC(periodic_callback)); state->pot_state = 0; state->pot_latch = 0; diff --git a/src/mame/drivers/btoads.c b/src/mame/drivers/btoads.c index 95274e89e2b..5dad10e5a40 100644 --- a/src/mame/drivers/btoads.c +++ b/src/mame/drivers/btoads.c @@ -66,14 +66,14 @@ static TIMER_CALLBACK( delayed_sound_w ) cpu_triggerint(machine->device("audiocpu")); /* use a timer to make long transfers faster */ - timer_set(machine, attotime::from_usec(50), NULL, 0, 0); + machine->scheduler().timer_set(attotime::from_usec(50), FUNC(0)); } static WRITE16_HANDLER( main_sound_w ) { if (ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, data & 0xff, delayed_sound_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_w), data & 0xff); } diff --git a/src/mame/drivers/buggychl.c b/src/mame/drivers/buggychl.c index 465d55779ec..17056b80da2 100644 --- a/src/mame/drivers/buggychl.c +++ b/src/mame/drivers/buggychl.c @@ -105,7 +105,7 @@ static TIMER_CALLBACK( nmi_callback ) static WRITE8_HANDLER( sound_command_w ) { soundlatch_w(space, 0, data); - timer_call_after_resynch(space->machine, NULL, data, nmi_callback); + space->machine->scheduler().synchronize(FUNC(nmi_callback), data); } static WRITE8_HANDLER( nmi_disable_w ) diff --git a/src/mame/drivers/capbowl.c b/src/mame/drivers/capbowl.c index 187ee4016b8..a7538e74496 100644 --- a/src/mame/drivers/capbowl.c +++ b/src/mame/drivers/capbowl.c @@ -126,7 +126,7 @@ static TIMER_CALLBACK( capbowl_update ) machine->primary_screen->update_partial(scanline - 1); scanline += 32; if (scanline > 240) scanline = 32; - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, capbowl_update); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(capbowl_update), scanline); } @@ -354,7 +354,7 @@ static MACHINE_RESET( capbowl ) { capbowl_state *state = machine->driver_data<capbowl_state>(); - timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, capbowl_update); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(32), FUNC(capbowl_update), 32); state->blitter_addr = 0; state->last_trackball_val[0] = 0; diff --git a/src/mame/drivers/cave.c b/src/mame/drivers/cave.c index 11c0c0f419b..d4021d437af 100644 --- a/src/mame/drivers/cave.c +++ b/src/mame/drivers/cave.c @@ -120,7 +120,7 @@ static TIMER_DEVICE_CALLBACK( cave_vblank_start ) update_irq_state(timer.machine); cave_get_sprite_info(timer.machine); state->agallet_vblank_irq = 1; - timer_set(timer.machine, attotime::from_usec(2000), NULL, 0, cave_vblank_end); + timer.machine->scheduler().timer_set(attotime::from_usec(2000), FUNC(cave_vblank_end)); } /* Called once/frame to generate the VBLANK interrupt */ diff --git a/src/mame/drivers/cball.c b/src/mame/drivers/cball.c index d4ef51f9859..508d33b9e5c 100644 --- a/src/mame/drivers/cball.c +++ b/src/mame/drivers/cball.c @@ -80,7 +80,7 @@ static TIMER_CALLBACK( interrupt_callback ) if (scanline >= 262) scanline = 16; - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(interrupt_callback), scanline); } @@ -92,7 +92,7 @@ static MACHINE_START( cball ) static MACHINE_RESET( cball ) { - timer_set(machine, machine->primary_screen->time_until_pos(16), NULL, 16, interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(16), FUNC(interrupt_callback), 16); } diff --git a/src/mame/drivers/ccastles.c b/src/mame/drivers/ccastles.c index 4ec96db5e44..4b15cbb52db 100644 --- a/src/mame/drivers/ccastles.c +++ b/src/mame/drivers/ccastles.c @@ -220,7 +220,7 @@ static MACHINE_START( ccastles ) memory_configure_bank(machine, "bank1", 0, 2, machine->region("maincpu")->base() + 0xa000, 0x6000); /* create a timer for IRQs and set up the first callback */ - state->irq_timer = timer_alloc(machine, clock_irq, NULL); + state->irq_timer = machine->scheduler().timer_alloc(FUNC(clock_irq)); state->irq_state = 0; schedule_next_irq(machine, 0); diff --git a/src/mame/drivers/cclimber.c b/src/mame/drivers/cclimber.c index fe53b7d3505..60d41b85b9c 100644 --- a/src/mame/drivers/cclimber.c +++ b/src/mame/drivers/cclimber.c @@ -267,7 +267,7 @@ static MACHINE_RESET( cclimber ) /* we must do this on a timer in order to have it take effect */ /* otherwise, the reset process will override our changes */ - timer_call_after_resynch(machine, NULL, 0, disable_interrupts); + machine->scheduler().synchronize(FUNC(disable_interrupts)); toprollr_rombank = 0; } diff --git a/src/mame/drivers/champbas.c b/src/mame/drivers/champbas.c index 41bd2161d49..356cdfa82a9 100644 --- a/src/mame/drivers/champbas.c +++ b/src/mame/drivers/champbas.c @@ -582,7 +582,7 @@ static MACHINE_START( exctsccr ) state->audiocpu = machine->device("audiocpu"); // FIXME - timer_pulse(machine, attotime::from_hz(75), NULL, 0, exctsccr_fm_callback); /* updates fm */ + machine->scheduler().timer_pulse(attotime::from_hz(75), FUNC(exctsccr_fm_callback)); /* updates fm */ MACHINE_START_CALL(champbas); } diff --git a/src/mame/drivers/cidelsa.c b/src/mame/drivers/cidelsa.c index db7100e3d17..966306719fc 100644 --- a/src/mame/drivers/cidelsa.c +++ b/src/mame/drivers/cidelsa.c @@ -471,7 +471,7 @@ void cidelsa_state::machine_reset() { /* reset the CPU */ m_reset = 0; - timer_set(&m_machine, attotime::from_msec(200), NULL, 0, set_cpu_mode); + m_machine.scheduler().timer_set(attotime::from_msec(200), FUNC(set_cpu_mode)); } /* Machine Drivers */ diff --git a/src/mame/drivers/clayshoo.c b/src/mame/drivers/clayshoo.c index f1885415e3b..dd47e867fb2 100644 --- a/src/mame/drivers/clayshoo.c +++ b/src/mame/drivers/clayshoo.c @@ -132,8 +132,8 @@ static READ8_HANDLER( analog_r ) static void create_analog_timers( running_machine *machine ) { clayshoo_state *state = machine->driver_data<clayshoo_state>(); - state->analog_timer_1 = timer_alloc(machine, reset_analog_bit, NULL); - state->analog_timer_2 = timer_alloc(machine, reset_analog_bit, NULL); + state->analog_timer_1 = machine->scheduler().timer_alloc(FUNC(reset_analog_bit)); + state->analog_timer_2 = machine->scheduler().timer_alloc(FUNC(reset_analog_bit)); } diff --git a/src/mame/drivers/cliffhgr.c b/src/mame/drivers/cliffhgr.c index 96093ef8ac8..4f4a18d61c5 100644 --- a/src/mame/drivers/cliffhgr.c +++ b/src/mame/drivers/cliffhgr.c @@ -217,7 +217,7 @@ static void vdp_interrupt(running_machine *machine, int state) static MACHINE_START( cliffhgr ) { laserdisc = machine->device("laserdisc"); - irq_timer = timer_alloc(machine, cliff_irq_callback, NULL); + irq_timer = machine->scheduler().timer_alloc(FUNC(cliff_irq_callback)); } static MACHINE_RESET( cliffhgr ) diff --git a/src/mame/drivers/cloud9.c b/src/mame/drivers/cloud9.c index 3123037029e..f494ec692d1 100644 --- a/src/mame/drivers/cloud9.c +++ b/src/mame/drivers/cloud9.c @@ -186,7 +186,7 @@ static MACHINE_START( cloud9 ) machine->primary_screen->configure(320, 256, visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL); /* create a timer for IRQs and set up the first callback */ - state->irq_timer = timer_alloc(machine, clock_irq, NULL); + state->irq_timer = machine->scheduler().timer_alloc(FUNC(clock_irq)); state->irq_state = 0; schedule_next_irq(machine, 0-64); diff --git a/src/mame/drivers/cojag.c b/src/mame/drivers/cojag.c index 0132ba4c956..55331d28a41 100644 --- a/src/mame/drivers/cojag.c +++ b/src/mame/drivers/cojag.c @@ -595,7 +595,7 @@ static TIMER_CALLBACK( gpu_sync_timer ) cojag_state *state = machine->driver_data<cojag_state>(); /* if a command is still pending, and we haven't maxed out our timer, set a new one */ if (state->gpu_command_pending && param < 1000) - timer_set(machine, attotime::from_usec(50), NULL, ++param, gpu_sync_timer); + machine->scheduler().timer_set(attotime::from_usec(50), FUNC(gpu_sync_timer), ++param); } @@ -610,7 +610,7 @@ static WRITE32_HANDLER( gpu_jump_w ) jaguar_gpu_resume(space->machine); /* start the sync timer going, and note that there is a command pending */ - timer_call_after_resynch(space->machine, NULL, 0, gpu_sync_timer); + space->machine->scheduler().synchronize(FUNC(gpu_sync_timer)); state->gpu_command_pending = 1; } diff --git a/src/mame/drivers/combatsc.c b/src/mame/drivers/combatsc.c index 47f74217374..4ea23b587ae 100644 --- a/src/mame/drivers/combatsc.c +++ b/src/mame/drivers/combatsc.c @@ -689,7 +689,7 @@ static MACHINE_START( combatsc ) state->page[0] = MEM + 0x4000; state->page[1] = MEM + 0x6000; - state->interleave_timer = timer_alloc(machine, NULL, NULL); + state->interleave_timer = machine->scheduler().timer_alloc(FUNC(NULL)); state->audiocpu = machine->device<cpu_device>("audiocpu"); state->k007121_1 = machine->device("k007121_1"); diff --git a/src/mame/drivers/coolpool.c b/src/mame/drivers/coolpool.c index c7bc107b968..b85b95e9106 100644 --- a/src/mame/drivers/coolpool.c +++ b/src/mame/drivers/coolpool.c @@ -484,7 +484,7 @@ static TIMER_CALLBACK( deferred_iop_w ) static WRITE16_HANDLER( coolpool_iop_w ) { logerror("%08x:IOP write %04x\n", cpu_get_pc(space->cpu), data); - timer_call_after_resynch(space->machine, NULL, data, deferred_iop_w); + space->machine->scheduler().synchronize(FUNC(deferred_iop_w), data); } diff --git a/src/mame/drivers/crgolf.c b/src/mame/drivers/crgolf.c index 3134a17f58c..8da415201fb 100644 --- a/src/mame/drivers/crgolf.c +++ b/src/mame/drivers/crgolf.c @@ -139,7 +139,7 @@ static TIMER_CALLBACK( main_to_sound_callback ) static WRITE8_HANDLER( main_to_sound_w ) { - timer_call_after_resynch(space->machine, NULL, data, main_to_sound_callback); + space->machine->scheduler().synchronize(FUNC(main_to_sound_callback), data); } @@ -170,7 +170,7 @@ static TIMER_CALLBACK( sound_to_main_callback ) static WRITE8_HANDLER( sound_to_main_w ) { - timer_call_after_resynch(space->machine, NULL, data, sound_to_main_callback); + space->machine->scheduler().synchronize(FUNC(sound_to_main_callback), data); } diff --git a/src/mame/drivers/crystal.c b/src/mame/drivers/crystal.c index fbb56cb2a6c..deaa8531b17 100644 --- a/src/mame/drivers/crystal.c +++ b/src/mame/drivers/crystal.c @@ -569,7 +569,7 @@ static MACHINE_START( crystal ) cpu_set_irq_callback(machine->device("maincpu"), icallback); for (i = 0; i < 4; i++) - state->Timer[i] = timer_alloc(machine, Timercb, (void*)(FPTR)i); + state->Timer[i] = machine->scheduler().timer_alloc(FUNC(Timercb), (void*)(FPTR)i); PatchReset(machine); diff --git a/src/mame/drivers/cubeqst.c b/src/mame/drivers/cubeqst.c index 5bd939cdd43..0556447e228 100644 --- a/src/mame/drivers/cubeqst.c +++ b/src/mame/drivers/cubeqst.c @@ -250,7 +250,7 @@ static TIMER_CALLBACK( delayed_bank_swap ) static void swap_linecpu_banks(running_machine *machine) { /* Best sync up before we switch banks around */ - timer_call_after_resynch(machine, NULL, 0, delayed_bank_swap); + machine->scheduler().synchronize(FUNC(delayed_bank_swap)); } diff --git a/src/mame/drivers/cvs.c b/src/mame/drivers/cvs.c index 65cd74cb846..c2a789bba7d 100644 --- a/src/mame/drivers/cvs.c +++ b/src/mame/drivers/cvs.c @@ -321,7 +321,7 @@ static TIMER_CALLBACK( cvs_393hz_timer_cb ) static void start_393hz_timer(running_machine *machine) { cvs_state *state = machine->driver_data<cvs_state>(); - state->cvs_393hz_timer = timer_alloc(machine, cvs_393hz_timer_cb, NULL); + state->cvs_393hz_timer = machine->scheduler().timer_alloc(FUNC(cvs_393hz_timer_cb)); timer_adjust_periodic(state->cvs_393hz_timer, attotime::from_hz(30*393), 0, attotime::from_hz(30*393)); } diff --git a/src/mame/drivers/dec8.c b/src/mame/drivers/dec8.c index f7ad74c61ff..6ccff50dbbf 100644 --- a/src/mame/drivers/dec8.c +++ b/src/mame/drivers/dec8.c @@ -131,7 +131,7 @@ static WRITE8_HANDLER( dec8_i8751_w ) case 0: /* High byte - SECIRQ is trigged on activating this latch */ state->i8751_value = (state->i8751_value & 0xff) | (data << 8); cpu_set_input_line(state->mcu, MCS51_INT1_LINE, ASSERT_LINE); - timer_set(space->machine, state->mcu->clocks_to_attotime(64), NULL, 0, dec8_i8751_timer_callback); // 64 clocks not confirmed + space->machine->scheduler().timer_set(state->mcu->clocks_to_attotime(64), FUNC(dec8_i8751_timer_callback)); // 64 clocks not confirmed break; case 1: /* Low byte */ state->i8751_value = (state->i8751_value & 0xff00) | data; diff --git a/src/mame/drivers/destroyr.c b/src/mame/drivers/destroyr.c index 04fa495d551..968e2307841 100644 --- a/src/mame/drivers/destroyr.c +++ b/src/mame/drivers/destroyr.c @@ -130,8 +130,8 @@ static TIMER_CALLBACK( destroyr_frame_callback ) state->potsense[1] = 0; /* PCB supports two dials, but cab has only got one */ - timer_set(machine, machine->primary_screen->time_until_pos(input_port_read(machine, "PADDLE"), 0), NULL, 0, destroyr_dial_callback); - timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, destroyr_frame_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(input_port_read(machine, "PADDLE")), FUNC(destroyr_dial_callback)); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(0), FUNC(destroyr_frame_callback)); } @@ -139,7 +139,7 @@ static MACHINE_RESET( destroyr ) { destroyr_state *state = machine->driver_data<destroyr_state>(); - timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, destroyr_frame_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(0), FUNC(destroyr_frame_callback)); state->cursor = 0; state->wavemod = 0; diff --git a/src/mame/drivers/enigma2.c b/src/mame/drivers/enigma2.c index 0923f948ab5..97b19198a0a 100644 --- a/src/mame/drivers/enigma2.c +++ b/src/mame/drivers/enigma2.c @@ -135,8 +135,8 @@ static TIMER_CALLBACK( interrupt_assert_callback ) static void create_interrupt_timers( running_machine *machine ) { enigma2_state *state = machine->driver_data<enigma2_state>(); - state->interrupt_clear_timer = timer_alloc(machine, interrupt_clear_callback, NULL); - state->interrupt_assert_timer = timer_alloc(machine, interrupt_assert_callback, NULL); + state->interrupt_clear_timer = machine->scheduler().timer_alloc(FUNC(interrupt_clear_callback)); + state->interrupt_assert_timer = machine->scheduler().timer_alloc(FUNC(interrupt_assert_callback)); } diff --git a/src/mame/drivers/equites.c b/src/mame/drivers/equites.c index 97aed99c1d8..d4e770951ae 100644 --- a/src/mame/drivers/equites.c +++ b/src/mame/drivers/equites.c @@ -414,9 +414,9 @@ static TIMER_CALLBACK( equites_frq_adjuster_callback ) static SOUND_START(equites) { equites_state *state = machine->driver_data<equites_state>(); - state->nmi_timer = timer_alloc(machine, equites_nmi_callback, NULL); + state->nmi_timer = machine->scheduler().timer_alloc(FUNC(equites_nmi_callback)); - state->adjuster_timer = timer_alloc(machine, equites_frq_adjuster_callback, NULL); + state->adjuster_timer = machine->scheduler().timer_alloc(FUNC(equites_frq_adjuster_callback)); timer_adjust_periodic(state->adjuster_timer, attotime::from_hz(60), 0, attotime::from_hz(60)); } diff --git a/src/mame/drivers/esh.c b/src/mame/drivers/esh.c index 670680bcb94..55f8f2ab878 100644 --- a/src/mame/drivers/esh.c +++ b/src/mame/drivers/esh.c @@ -268,7 +268,7 @@ static INTERRUPT_GEN( vblank_callback_esh ) { // IRQ cpu_set_input_line(device, 0, ASSERT_LINE); - timer_set(device->machine, attotime::from_usec(50), NULL, 0, irq_stop); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(irq_stop)); } static MACHINE_START( esh ) diff --git a/src/mame/drivers/espial.c b/src/mame/drivers/espial.c index 5f93dad1509..15099310068 100644 --- a/src/mame/drivers/espial.c +++ b/src/mame/drivers/espial.c @@ -55,7 +55,7 @@ static MACHINE_RESET( espial ) state->flipscreen = 0; /* we must start with NMI interrupts disabled */ - timer_call_after_resynch(machine, NULL, 0, interrupt_disable); + machine->scheduler().synchronize(FUNC(interrupt_disable)); state->sound_nmi_enabled = FALSE; } diff --git a/src/mame/drivers/esripsys.c b/src/mame/drivers/esripsys.c index bf60dd01126..4406a09b6fb 100644 --- a/src/mame/drivers/esripsys.c +++ b/src/mame/drivers/esripsys.c @@ -207,7 +207,7 @@ static TIMER_CALLBACK( delayed_bank_swap ) static WRITE8_HANDLER( frame_w ) { - timer_call_after_resynch(space->machine, NULL, 0, delayed_bank_swap); + space->machine->scheduler().synchronize(FUNC(delayed_bank_swap)); esripsys_frame_vbl = 1; } diff --git a/src/mame/drivers/exidy440.c b/src/mame/drivers/exidy440.c index 6dab2f3c899..4425c07f3c9 100644 --- a/src/mame/drivers/exidy440.c +++ b/src/mame/drivers/exidy440.c @@ -371,7 +371,7 @@ static TIMER_CALLBACK( delayed_sound_command_w ) static WRITE8_HANDLER( sound_command_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_sound_command_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_command_w), data); } diff --git a/src/mame/drivers/exterm.c b/src/mame/drivers/exterm.c index db8fbfbfc35..622fe7a575c 100644 --- a/src/mame/drivers/exterm.c +++ b/src/mame/drivers/exterm.c @@ -198,7 +198,7 @@ static TIMER_CALLBACK( sound_delayed_w ) static WRITE16_HANDLER( sound_latch_w ) { if (ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, data & 0xff, sound_delayed_w); + space->machine->scheduler().synchronize(FUNC(sound_delayed_w), data & 0xff); } diff --git a/src/mame/drivers/fgoal.c b/src/mame/drivers/fgoal.c index 478689e7f2d..e829333580a 100644 --- a/src/mame/drivers/fgoal.c +++ b/src/mame/drivers/fgoal.c @@ -86,7 +86,7 @@ static TIMER_CALLBACK( interrupt_callback ) if (scanline > 256) scanline = 0; - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, 0, interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(interrupt_callback)); } @@ -356,7 +356,7 @@ static MACHINE_RESET( fgoal ) { fgoal_state *state = machine->driver_data<fgoal_state>(); - timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(0), FUNC(interrupt_callback)); state->xpos = 0; state->ypos = 0; diff --git a/src/mame/drivers/firebeat.c b/src/mame/drivers/firebeat.c index 1d32365a069..f14a43a3645 100644 --- a/src/mame/drivers/firebeat.c +++ b/src/mame/drivers/firebeat.c @@ -2215,7 +2215,7 @@ static DRIVER_INIT(ppd) static void init_keyboard(running_machine *machine) { // set keyboard timer - keyboard_timer = timer_alloc(machine, keyboard_timer_callback, NULL); + keyboard_timer = machine->scheduler().timer_alloc(FUNC(keyboard_timer_callback)); timer_adjust_periodic(keyboard_timer, attotime::from_msec(10), 0, attotime::from_msec(10)); } diff --git a/src/mame/drivers/firetrk.c b/src/mame/drivers/firetrk.c index 7c27dbaa64a..62c62674787 100644 --- a/src/mame/drivers/firetrk.c +++ b/src/mame/drivers/firetrk.c @@ -72,7 +72,7 @@ static TIMER_CALLBACK( periodic_callback ) if (scanline > 262) scanline = 0; - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, periodic_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(periodic_callback), scanline); } @@ -172,7 +172,7 @@ static MACHINE_RESET( firetrk ) { set_service_mode(machine, 0); - timer_call_after_resynch(machine, NULL, 0, periodic_callback); + machine->scheduler().synchronize(FUNC(periodic_callback)); } diff --git a/src/mame/drivers/flstory.c b/src/mame/drivers/flstory.c index 8d4871685e1..1a57b6ad893 100644 --- a/src/mame/drivers/flstory.c +++ b/src/mame/drivers/flstory.c @@ -50,7 +50,7 @@ static TIMER_CALLBACK( nmi_callback ) static WRITE8_HANDLER( sound_command_w ) { soundlatch_w(space, 0, data); - timer_call_after_resynch(space->machine, NULL, data, nmi_callback); + space->machine->scheduler().synchronize(FUNC(nmi_callback), data); } diff --git a/src/mame/drivers/flyball.c b/src/mame/drivers/flyball.c index a9a0966df52..d0a9abd541c 100644 --- a/src/mame/drivers/flyball.c +++ b/src/mame/drivers/flyball.c @@ -136,12 +136,12 @@ static TIMER_CALLBACK( flyball_quarter_callback ) for (i = 0; i < 64; i++) if (potsense[i] != 0) - timer_set(machine, machine->primary_screen->time_until_pos(scanline + i), NULL, potsense[i], flyball_joystick_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline + i), FUNC(flyball_joystick_callback), potsense[i]); scanline += 0x40; scanline &= 0xff; - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, flyball_quarter_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(flyball_quarter_callback), scanline); state->potsense = 0; state->potmask = 0; @@ -387,7 +387,7 @@ static MACHINE_RESET( flyball ) machine->device("maincpu")->reset(); - timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, flyball_quarter_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(0), FUNC(flyball_quarter_callback)); state->pitcher_vert = 0; state->pitcher_horz = 0; diff --git a/src/mame/drivers/fromance.c b/src/mame/drivers/fromance.c index aa3d9a97ddc..efdadedfa25 100644 --- a/src/mame/drivers/fromance.c +++ b/src/mame/drivers/fromance.c @@ -71,7 +71,7 @@ static TIMER_CALLBACK( deferred_commanddata_w ) static WRITE8_HANDLER( fromance_commanddata_w ) { /* do this on a timer to let the slave CPU synchronize */ - timer_call_after_resynch(space->machine, NULL, data, deferred_commanddata_w); + space->machine->scheduler().synchronize(FUNC(deferred_commanddata_w), data); } @@ -80,7 +80,7 @@ static READ8_HANDLER( fromance_busycheck_main_r ) fromance_state *state = space->machine->driver_data<fromance_state>(); /* set a timer to force synchronization after the read */ - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); if (!state->directionflag) return 0x00; // standby diff --git a/src/mame/drivers/fuukifg2.c b/src/mame/drivers/fuukifg2.c index b991a455dfd..35e5d21a272 100644 --- a/src/mame/drivers/fuukifg2.c +++ b/src/mame/drivers/fuukifg2.c @@ -401,7 +401,7 @@ static TIMER_CALLBACK( level_1_interrupt_callback ) { fuuki16_state *state = machine->driver_data<fuuki16_state>(); cpu_set_input_line(state->maincpu, 1, HOLD_LINE); - timer_set(machine, machine->primary_screen->time_until_pos(248), NULL, 0, level_1_interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(248), FUNC(level_1_interrupt_callback)); } @@ -409,7 +409,7 @@ static TIMER_CALLBACK( vblank_interrupt_callback ) { fuuki16_state *state = machine->driver_data<fuuki16_state>(); cpu_set_input_line(state->maincpu, 3, HOLD_LINE); // VBlank IRQ - timer_set(machine, machine->primary_screen->time_until_vblank_start(), NULL, 0, vblank_interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_vblank_start(), FUNC(vblank_interrupt_callback)); } @@ -432,7 +432,7 @@ static MACHINE_START( fuuki16 ) state->maincpu = machine->device("maincpu"); state->audiocpu = machine->device("audiocpu"); - state->raster_interrupt_timer = timer_alloc(machine, raster_interrupt_callback, NULL); + state->raster_interrupt_timer = machine->scheduler().timer_alloc(FUNC(raster_interrupt_callback)); } @@ -441,8 +441,8 @@ static MACHINE_RESET( fuuki16 ) fuuki16_state *state = machine->driver_data<fuuki16_state>(); const rectangle &visarea = machine->primary_screen->visible_area(); - timer_set(machine, machine->primary_screen->time_until_pos(248), NULL, 0, level_1_interrupt_callback); - timer_set(machine, machine->primary_screen->time_until_vblank_start(), NULL, 0, vblank_interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(248), FUNC(level_1_interrupt_callback)); + machine->scheduler().timer_set(machine->primary_screen->time_until_vblank_start(), FUNC(vblank_interrupt_callback)); timer_adjust_oneshot(state->raster_interrupt_timer, machine->primary_screen->time_until_pos(0, visarea.max_x + 1), 0); } diff --git a/src/mame/drivers/fuukifg3.c b/src/mame/drivers/fuukifg3.c index eb3e9f0ac9c..8c4726cd09c 100644 --- a/src/mame/drivers/fuukifg3.c +++ b/src/mame/drivers/fuukifg3.c @@ -487,7 +487,7 @@ static TIMER_CALLBACK( level_1_interrupt_callback ) { fuuki32_state *state = machine->driver_data<fuuki32_state>(); cpu_set_input_line(state->maincpu, 1, HOLD_LINE); - timer_set(machine, machine->primary_screen->time_until_pos(248), NULL, 0, level_1_interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(248), FUNC(level_1_interrupt_callback)); } @@ -495,7 +495,7 @@ static TIMER_CALLBACK( vblank_interrupt_callback ) { fuuki32_state *state = machine->driver_data<fuuki32_state>(); cpu_set_input_line(state->maincpu, 3, HOLD_LINE); // VBlank IRQ - timer_set(machine, machine->primary_screen->time_until_vblank_start(), NULL, 0, vblank_interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_vblank_start(), FUNC(vblank_interrupt_callback)); } @@ -518,7 +518,7 @@ static MACHINE_START( fuuki32 ) state->maincpu = machine->device("maincpu"); state->audiocpu = machine->device("soundcpu"); - state->raster_interrupt_timer = timer_alloc(machine, raster_interrupt_callback, NULL); + state->raster_interrupt_timer = machine->scheduler().timer_alloc(FUNC(raster_interrupt_callback)); state_save_register_global_array(machine, state->spr_buffered_tilebank); state_save_register_global_array(machine, state->shared_ram); @@ -530,8 +530,8 @@ static MACHINE_RESET( fuuki32 ) fuuki32_state *state = machine->driver_data<fuuki32_state>(); const rectangle &visarea = machine->primary_screen->visible_area(); - timer_set(machine, machine->primary_screen->time_until_pos(248), NULL, 0, level_1_interrupt_callback); - timer_set(machine, machine->primary_screen->time_until_vblank_start(), NULL, 0, vblank_interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(248), FUNC(level_1_interrupt_callback)); + machine->scheduler().timer_set(machine->primary_screen->time_until_vblank_start(), FUNC(vblank_interrupt_callback)); timer_adjust_oneshot(state->raster_interrupt_timer, machine->primary_screen->time_until_pos(0, visarea.max_x + 1), 0); } diff --git a/src/mame/drivers/gaelco3d.c b/src/mame/drivers/gaelco3d.c index 4dbc9e5bf0e..8da38b6f9ec 100644 --- a/src/mame/drivers/gaelco3d.c +++ b/src/mame/drivers/gaelco3d.c @@ -376,7 +376,7 @@ static WRITE16_HANDLER( sound_data_w ) if (LOG) logerror("%06X:sound_data_w(%02X) = %08X & %08X\n", cpu_get_pc(space->cpu), offset, data, mem_mask); if (ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, data & 0xff, delayed_sound_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_w), data & 0xff); } diff --git a/src/mame/drivers/galaga.c b/src/mame/drivers/galaga.c index e5e9d3b5253..9dca896cb1d 100644 --- a/src/mame/drivers/galaga.c +++ b/src/mame/drivers/galaga.c @@ -880,7 +880,7 @@ static TIMER_CALLBACK( cpu3_interrupt_callback ) static MACHINE_START( galaga ) { /* create the interrupt timer */ - cpu3_interrupt_timer = timer_alloc(machine, cpu3_interrupt_callback, NULL); + cpu3_interrupt_timer = machine->scheduler().timer_alloc(FUNC(cpu3_interrupt_callback)); custom_mod = 0; state_save_register_global(machine, custom_mod); } diff --git a/src/mame/drivers/galastrm.c b/src/mame/drivers/galastrm.c index e247d6d91de..ff4b9e272ff 100644 --- a/src/mame/drivers/galastrm.c +++ b/src/mame/drivers/galastrm.c @@ -166,7 +166,7 @@ static READ32_HANDLER( galastrm_adstick_ctrl_r ) static WRITE32_HANDLER( galastrm_adstick_ctrl_w ) { - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(1000), NULL, 0, galastrm_interrupt6); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(1000), FUNC(galastrm_interrupt6)); } /*********************************************************** diff --git a/src/mame/drivers/gaplus.c b/src/mame/drivers/gaplus.c index 5a78da67248..31e4e175156 100644 --- a/src/mame/drivers/gaplus.c +++ b/src/mame/drivers/gaplus.c @@ -259,10 +259,10 @@ static INTERRUPT_GEN( gaplus_interrupt_1 ) // so don't replace with cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); if (!namcoio_read_reset_line(io58xx)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 0, namcoio_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(namcoio_run)); if (!namcoio_read_reset_line(io56xx)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 1, namcoio_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(namcoio_run), 1); } diff --git a/src/mame/drivers/gcpinbal.c b/src/mame/drivers/gcpinbal.c index 19333791c97..623ec9a33d9 100644 --- a/src/mame/drivers/gcpinbal.c +++ b/src/mame/drivers/gcpinbal.c @@ -64,8 +64,8 @@ static INTERRUPT_GEN( gcpinbal_interrupt ) { /* Unsure of actual sequence */ - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(500), NULL, 0, gcpinbal_interrupt1); -// timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(1000), NULL, 0, gcpinbal_interrupt3); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(500), FUNC(gcpinbal_interrupt1)); +// device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(1000), FUNC(gcpinbal_interrupt3)); cpu_set_input_line(device, 4, HOLD_LINE); } diff --git a/src/mame/drivers/gijoe.c b/src/mame/drivers/gijoe.c index b610e87230f..c2e86d98e17 100644 --- a/src/mame/drivers/gijoe.c +++ b/src/mame/drivers/gijoe.c @@ -285,7 +285,7 @@ static MACHINE_START( gijoe ) state->k053246 = machine->device("k053246"); state->k053251 = machine->device("k053251"); - state->dmadelay_timer = timer_alloc(machine, dmaend_callback, NULL); + state->dmadelay_timer = machine->scheduler().timer_alloc(FUNC(dmaend_callback)); state_save_register_global(machine, state->cur_control2); } diff --git a/src/mame/drivers/gottlieb.c b/src/mame/drivers/gottlieb.c index 354a9927234..0b95d44b138 100644 --- a/src/mame/drivers/gottlieb.c +++ b/src/mame/drivers/gottlieb.c @@ -279,8 +279,8 @@ static MACHINE_START( gottlieb ) memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x05806, 0x05806, 0, 0x07f8, laserdisc_select_w); /* allocate a timer for serial transmission, and one for philips code processing */ - laserdisc_bit_timer = timer_alloc(machine, laserdisc_bit_callback, NULL); - laserdisc_philips_timer = timer_alloc(machine, laserdisc_philips_callback, NULL); + laserdisc_bit_timer = machine->scheduler().timer_alloc(FUNC(laserdisc_bit_callback)); + laserdisc_philips_timer = machine->scheduler().timer_alloc(FUNC(laserdisc_philips_callback)); /* create some audio RAM */ laserdisc_audio_buffer = auto_alloc_array(machine, UINT8, AUDIORAM_SIZE); @@ -487,7 +487,7 @@ 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, LASERDISC_CLOCK * 10, NULL, 0, laserdisc_bit_off_callback); + machine->scheduler().timer_set(LASERDISC_CLOCK * 10, FUNC(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 @@ -689,7 +689,7 @@ static INTERRUPT_GEN( gottlieb_interrupt ) { /* assert the NMI and set a timer to clear it at the first visible line */ cpu_set_input_line(device, INPUT_LINE_NMI, ASSERT_LINE); - timer_set(device->machine, device->machine->primary_screen->time_until_pos(0), NULL, 0, nmi_clear); + device->machine->scheduler().timer_set(device->machine->primary_screen->time_until_pos(0), FUNC(nmi_clear)); /* if we have a laserdisc, update it */ if (laserdisc != NULL) diff --git a/src/mame/drivers/gpworld.c b/src/mame/drivers/gpworld.c index ec83655170e..9495ca01f7f 100644 --- a/src/mame/drivers/gpworld.c +++ b/src/mame/drivers/gpworld.c @@ -422,7 +422,7 @@ static INTERRUPT_GEN( vblank_callback_gpworld ) /* The time the IRQ line stays high is set just long enough to happen after the NMI - hacky? */ cpu_set_input_line(device, 0, ASSERT_LINE); - timer_set(device->machine, attotime::from_usec(100), NULL, 0, irq_stop); + device->machine->scheduler().timer_set(attotime::from_usec(100), FUNC(irq_stop)); } static const gfx_layout gpworld_tile_layout = diff --git a/src/mame/drivers/grchamp.c b/src/mame/drivers/grchamp.c index 9528bf4bcb6..81e1f000cb7 100644 --- a/src/mame/drivers/grchamp.c +++ b/src/mame/drivers/grchamp.c @@ -404,7 +404,7 @@ static TIMER_CALLBACK( main_to_sub_comm_sync_w ) static WRITE8_HANDLER( main_to_sub_comm_w ) { - timer_call_after_resynch(space->machine, NULL, data | (offset << 8), main_to_sub_comm_sync_w); + space->machine->scheduler().synchronize(FUNC(main_to_sub_comm_sync_w), data | (offset << 8)); } diff --git a/src/mame/drivers/gridlee.c b/src/mame/drivers/gridlee.c index 7f1657f804c..3b9dcefd7a6 100644 --- a/src/mame/drivers/gridlee.c +++ b/src/mame/drivers/gridlee.c @@ -163,10 +163,10 @@ static MACHINE_START( gridlee ) state_save_register_global_array(machine, last_analog_input); state_save_register_global_array(machine, last_analog_output); - irq_off = timer_alloc(machine, irq_off_tick, 0); - irq_timer = timer_alloc(machine, irq_timer_tick, 0); - firq_off = timer_alloc(machine, firq_off_tick, 0); - firq_timer = timer_alloc(machine, firq_timer_tick, 0); + irq_off = machine->scheduler().timer_alloc(FUNC(irq_off_tick)); + irq_timer = machine->scheduler().timer_alloc(FUNC(irq_timer_tick)); + firq_off = machine->scheduler().timer_alloc(FUNC(firq_off_tick)); + firq_timer = machine->scheduler().timer_alloc(FUNC(firq_timer_tick)); } diff --git a/src/mame/drivers/groundfx.c b/src/mame/drivers/groundfx.c index fe59e96dc92..1ac0a65f582 100644 --- a/src/mame/drivers/groundfx.c +++ b/src/mame/drivers/groundfx.c @@ -177,7 +177,7 @@ static WRITE32_HANDLER( groundfx_adc_w ) { /* One interrupt per input port (4 per frame, though only 2 used). 1000 cycle delay is arbitrary */ - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(1000), NULL, 0, groundfx_interrupt5); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(1000), FUNC(groundfx_interrupt5)); } static WRITE32_HANDLER( rotate_control_w ) /* only a guess that it's rotation */ diff --git a/src/mame/drivers/gticlub.c b/src/mame/drivers/gticlub.c index 14e0073c75a..7f9525c047e 100644 --- a/src/mame/drivers/gticlub.c +++ b/src/mame/drivers/gticlub.c @@ -730,7 +730,7 @@ static void sound_irq_callback( running_machine *machine, int irq ) int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2; cputag_set_input_line(machine, "audiocpu", line, ASSERT_LINE); - timer_set(machine, attotime::from_usec(1), NULL, line, irq_off); + machine->scheduler().timer_set(attotime::from_usec(1), FUNC(irq_off), line); } static const k056800_interface gticlub_k056800_interface = diff --git a/src/mame/drivers/guab.c b/src/mame/drivers/guab.c index 13a0aecc44d..36ed2a31915 100644 --- a/src/mame/drivers/guab.c +++ b/src/mame/drivers/guab.c @@ -752,7 +752,7 @@ INPUT_PORTS_END static MACHINE_START( guab ) { - fdc_timer = timer_alloc(machine, fdc_data_callback, NULL); + fdc_timer = machine->scheduler().timer_alloc(FUNC(fdc_data_callback)); } static MACHINE_RESET( guab ) diff --git a/src/mame/drivers/gunbustr.c b/src/mame/drivers/gunbustr.c index 3a69148fc31..1da4716681f 100644 --- a/src/mame/drivers/gunbustr.c +++ b/src/mame/drivers/gunbustr.c @@ -63,7 +63,7 @@ static TIMER_CALLBACK( gunbustr_interrupt5 ) static INTERRUPT_GEN( gunbustr_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(200000-500), NULL, 0, gunbustr_interrupt5); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(200000-500), FUNC(gunbustr_interrupt5)); cpu_set_input_line(device, 4, HOLD_LINE); } @@ -184,7 +184,7 @@ static READ32_HANDLER( gunbustr_gun_r ) static WRITE32_HANDLER( gunbustr_gun_w ) { /* 10000 cycle delay is arbitrary */ - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(10000), NULL, 0, gunbustr_interrupt5); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(10000), FUNC(gunbustr_interrupt5)); } diff --git a/src/mame/drivers/halleys.c b/src/mame/drivers/halleys.c index c82d823508c..4c70a6552ac 100644 --- a/src/mame/drivers/halleys.c +++ b/src/mame/drivers/halleys.c @@ -2215,7 +2215,7 @@ static DRIVER_INIT( benberob ) init_common(machine); - blitter_reset_timer = timer_alloc(machine, blitter_reset, NULL); + blitter_reset_timer = machine->scheduler().timer_alloc(FUNC(blitter_reset)); } diff --git a/src/mame/drivers/hng64.c b/src/mame/drivers/hng64.c index f0e250019a0..ba321915950 100644 --- a/src/mame/drivers/hng64.c +++ b/src/mame/drivers/hng64.c @@ -1661,7 +1661,7 @@ static INTERRUPT_GEN( irq_start ) } cpu_set_input_line(device, 0, ASSERT_LINE); - timer_set(device->machine, attotime::from_usec(50), NULL, 0, irq_stop); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(irq_stop)); } diff --git a/src/mame/drivers/hornet.c b/src/mame/drivers/hornet.c index 8456dc9eee7..4d3b82ba248 100644 --- a/src/mame/drivers/hornet.c +++ b/src/mame/drivers/hornet.c @@ -848,7 +848,7 @@ static MACHINE_START( hornet ) state_save_register_global_pointer(machine, jvs_sdata, 1024); state_save_register_global(machine, jvs_sdata_ptr); - sound_irq_timer = timer_alloc(machine, irq_off, 0); + sound_irq_timer = machine->scheduler().timer_alloc(FUNC(irq_off)); } static MACHINE_RESET( hornet ) diff --git a/src/mame/drivers/hyprduel.c b/src/mame/drivers/hyprduel.c index 22d5ce73d62..875ca4f3933 100644 --- a/src/mame/drivers/hyprduel.c +++ b/src/mame/drivers/hyprduel.c @@ -71,7 +71,7 @@ static INTERRUPT_GEN( hyprduel_interrupt ) state->requested_int |= 0x20; cpu_set_input_line(device, 2, HOLD_LINE); /* the duration is a guess */ - timer_set(device->machine, attotime::from_usec(2500), NULL, 0x20, vblank_end_callback); + device->machine->scheduler().timer_set(attotime::from_usec(2500), FUNC(vblank_end_callback), 0x20); } else state->requested_int |= 0x12; /* hsync */ @@ -342,7 +342,7 @@ static WRITE16_HANDLER( hyprduel_blitter_w ) another blit. */ if (b1 == 0) { - timer_set(space->machine, attotime::from_usec(500), NULL, 0, hyprduel_blit_done); + space->machine->scheduler().timer_set(attotime::from_usec(500), FUNC(hyprduel_blit_done)); return; } @@ -823,7 +823,7 @@ static DRIVER_INIT( magerror ) hyprduel_state *state = machine->driver_data<hyprduel_state>(); state->int_num = 0x01; - state->magerror_irq_timer = timer_alloc(machine, magerror_irq_callback, NULL); + state->magerror_irq_timer = machine->scheduler().timer_alloc(FUNC(magerror_irq_callback)); } diff --git a/src/mame/drivers/itech32.c b/src/mame/drivers/itech32.c index 7814ecdd473..8a047839835 100644 --- a/src/mame/drivers/itech32.c +++ b/src/mame/drivers/itech32.c @@ -678,7 +678,7 @@ static TIMER_CALLBACK( delayed_sound_data_w ) static WRITE16_HANDLER( sound_data_w ) { if (ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, data & 0xff, delayed_sound_data_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_data_w), data & 0xff); } @@ -691,7 +691,7 @@ static READ32_HANDLER( sound_data32_r ) static WRITE32_HANDLER( sound_data32_w ) { if (ACCESSING_BITS_16_23) - timer_call_after_resynch(space->machine, NULL, (data >> 16) & 0xff, delayed_sound_data_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_data_w), (data >> 16) & 0xff); } diff --git a/src/mame/drivers/itech8.c b/src/mame/drivers/itech8.c index 3b46edebe10..272315d03a0 100644 --- a/src/mame/drivers/itech8.c +++ b/src/mame/drivers/itech8.c @@ -632,7 +632,7 @@ static INTERRUPT_GEN( generate_nmi ) { /* signal the NMI */ itech8_update_interrupts(device->machine, 1, -1, -1); - timer_set(device->machine, attotime::from_usec(1), NULL, 0, irq_off); + device->machine->scheduler().timer_set(attotime::from_usec(1), FUNC(irq_off)); if (FULL_LOGGING) logerror("------------ VBLANK (%d) --------------\n", device->machine->primary_screen->vpos()); } @@ -664,7 +664,7 @@ static TIMER_CALLBACK( behind_the_beam_update ); static MACHINE_START( sstrike ) { /* we need to update behind the beam as well */ - timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 32, behind_the_beam_update); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(0), FUNC(behind_the_beam_update), 32); } static MACHINE_RESET( itech8 ) @@ -707,7 +707,7 @@ static TIMER_CALLBACK( behind_the_beam_update ) if (scanline >= 256) scanline = 0; /* set a new timer */ - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, (scanline << 8) + interval, behind_the_beam_update); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(behind_the_beam_update), (scanline << 8) + interval); } @@ -806,7 +806,7 @@ static TIMER_CALLBACK( delayed_sound_data_w ) static WRITE8_HANDLER( sound_data_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_sound_data_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_data_w), data); } @@ -817,7 +817,7 @@ static WRITE8_HANDLER( gtg2_sound_data_w ) ((data & 0x5d) << 1) | ((data & 0x20) >> 3) | ((data & 0x02) << 5); - timer_call_after_resynch(space->machine, NULL, data, delayed_sound_data_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_data_w), data); } diff --git a/src/mame/drivers/jangou.c b/src/mame/drivers/jangou.c index 960c3055129..95261bbd435 100644 --- a/src/mame/drivers/jangou.c +++ b/src/mame/drivers/jangou.c @@ -894,7 +894,7 @@ static SOUND_START( jangou ) jangou_state *state = machine->driver_data<jangou_state>(); /* Create a timer to feed the CVSD DAC with sample bits */ - state->cvsd_bit_timer = timer_alloc(machine, cvsd_bit_timer_callback, NULL); + state->cvsd_bit_timer = machine->scheduler().timer_alloc(FUNC(cvsd_bit_timer_callback)); timer_adjust_periodic(state->cvsd_bit_timer, attotime::from_hz(MASTER_CLOCK / 1024), 0, attotime::from_hz(MASTER_CLOCK / 1024)); } diff --git a/src/mame/drivers/jedi.c b/src/mame/drivers/jedi.c index 30e5dac0b47..9bca0a67f7c 100644 --- a/src/mame/drivers/jedi.c +++ b/src/mame/drivers/jedi.c @@ -158,7 +158,7 @@ static MACHINE_START( jedi ) jedi_state *state = machine->driver_data<jedi_state>(); /* set a timer to run the interrupts */ - state->interrupt_timer = timer_alloc(machine, generate_interrupt, NULL); + state->interrupt_timer = machine->scheduler().timer_alloc(FUNC(generate_interrupt)); timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(32), 32); /* configure the banks */ diff --git a/src/mame/drivers/jpmsys5.c b/src/mame/drivers/jpmsys5.c index 7b51a33566b..28dec3c17b2 100644 --- a/src/mame/drivers/jpmsys5.c +++ b/src/mame/drivers/jpmsys5.c @@ -577,7 +577,7 @@ static ACIA6850_INTERFACE( acia2_if ) static MACHINE_START( jpmsys5v ) { memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base()); - touch_timer = timer_alloc(machine, touch_cb, NULL); + touch_timer = machine->scheduler().timer_alloc(FUNC(touch_cb)); } static MACHINE_RESET( jpmsys5v ) diff --git a/src/mame/drivers/kinst.c b/src/mame/drivers/kinst.c index 9a64fda674d..117f8f220c3 100644 --- a/src/mame/drivers/kinst.c +++ b/src/mame/drivers/kinst.c @@ -261,7 +261,7 @@ static TIMER_CALLBACK( irq0_stop ) static INTERRUPT_GEN( irq0_start ) { cpu_set_input_line(device, 0, ASSERT_LINE); - timer_set(device->machine, attotime::from_usec(50), NULL, 0, irq0_stop); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(irq0_stop)); } diff --git a/src/mame/drivers/konamigx.c b/src/mame/drivers/konamigx.c index 688e93f4512..36598f2b0df 100644 --- a/src/mame/drivers/konamigx.c +++ b/src/mame/drivers/konamigx.c @@ -3756,7 +3756,7 @@ static DRIVER_INIT(konamigx) snd020_hack = 0; resume_trigger = 0; - dmadelay_timer = timer_alloc(machine, dmaend_callback, NULL); + dmadelay_timer = machine->scheduler().timer_alloc(FUNC(dmaend_callback)); i = match = 0; while ((gameDefs[i].cfgport != -1) && (!match)) diff --git a/src/mame/drivers/ksys573.c b/src/mame/drivers/ksys573.c index 86369f71a34..b0c390d69ec 100644 --- a/src/mame/drivers/ksys573.c +++ b/src/mame/drivers/ksys573.c @@ -1051,7 +1051,7 @@ static void atapi_init(running_machine *machine) state->atapi_data_len = 0; state->atapi_cdata_wait = 0; - state->atapi_timer = timer_alloc(machine, atapi_xfer_end, NULL); + state->atapi_timer = machine->scheduler().timer_alloc(FUNC(atapi_xfer_end)); timer_adjust_oneshot(state->atapi_timer, attotime::never, 0); for( i = 0; i < 2; i++ ) @@ -1589,7 +1589,7 @@ static DRIVER_INIT( konami573 ) for (i = 0; i < 3; i++) { - state->m_p_timer_root[i] = timer_alloc(machine, root_finished, NULL); + state->m_p_timer_root[i] = machine->scheduler().timer_alloc(FUNC(root_finished)); } state_save_register_global( machine, state->m_n_security_control ); diff --git a/src/mame/drivers/ladyfrog.c b/src/mame/drivers/ladyfrog.c index 730108bfa5e..52471b243e8 100644 --- a/src/mame/drivers/ladyfrog.c +++ b/src/mame/drivers/ladyfrog.c @@ -87,7 +87,7 @@ static TIMER_CALLBACK( nmi_callback ) static WRITE8_HANDLER( sound_command_w ) { soundlatch_w(space, 0, data); - timer_call_after_resynch(space->machine, NULL, data, nmi_callback); + space->machine->scheduler().synchronize(FUNC(nmi_callback), data); } static WRITE8_HANDLER( nmi_disable_w ) diff --git a/src/mame/drivers/lgp.c b/src/mame/drivers/lgp.c index 0fdf919cd6d..935f76fedd3 100644 --- a/src/mame/drivers/lgp.c +++ b/src/mame/drivers/lgp.c @@ -336,7 +336,7 @@ static INTERRUPT_GEN( vblank_callback_lgp ) static MACHINE_START( lgp ) { laserdisc = machine->device("laserdisc"); - irq_timer = timer_alloc(machine, irq_stop, 0); + irq_timer = machine->scheduler().timer_alloc(FUNC(irq_stop)); } diff --git a/src/mame/drivers/lkage.c b/src/mame/drivers/lkage.c index 616023aa010..f8ad8bfd881 100644 --- a/src/mame/drivers/lkage.c +++ b/src/mame/drivers/lkage.c @@ -107,7 +107,7 @@ static TIMER_CALLBACK( nmi_callback ) static WRITE8_HANDLER( lkage_sound_command_w ) { soundlatch_w(space, offset, data); - timer_call_after_resynch(space->machine, NULL, data, nmi_callback); + space->machine->scheduler().synchronize(FUNC(nmi_callback), data); } static WRITE8_HANDLER( lkage_sh_nmi_disable_w ) diff --git a/src/mame/drivers/m10.c b/src/mame/drivers/m10.c index b93809132f1..12189d06a4f 100644 --- a/src/mame/drivers/m10.c +++ b/src/mame/drivers/m10.c @@ -520,12 +520,12 @@ static TIMER_CALLBACK( interrupt_callback ) if (param == 0) { cpu_set_input_line(state->maincpu, 0, ASSERT_LINE); - timer_set(machine, machine->primary_screen->time_until_pos(IREMM10_VBSTART + 16), NULL, 1, interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(IREMM10_VBSTART + 16), FUNC(interrupt_callback), 1); } if (param == 1) { cpu_set_input_line(state->maincpu, 0, ASSERT_LINE); - timer_set(machine, machine->primary_screen->time_until_pos(IREMM10_VBSTART + 24), NULL, 2, interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(IREMM10_VBSTART + 24), FUNC(interrupt_callback), 2); } if (param == -1) cpu_set_input_line(state->maincpu, 0, CLEAR_LINE); @@ -536,7 +536,7 @@ static TIMER_CALLBACK( interrupt_callback ) static INTERRUPT_GEN( m11_interrupt ) { cpu_set_input_line(device, 0, ASSERT_LINE); - //timer_set(device->machine, machine->primary_screen->time_until_pos(IREMM10_VBEND), NULL, -1, interrupt_callback); + //device->machine->scheduler().timer_set(machine->primary_screen->time_until_pos(IREMM10_VBEND), FUNC(interrupt_callback), -1); } static INTERRUPT_GEN( m10_interrupt ) @@ -548,7 +548,7 @@ static INTERRUPT_GEN( m10_interrupt ) static INTERRUPT_GEN( m15_interrupt ) { cpu_set_input_line(device, 0, ASSERT_LINE); - timer_set(device->machine, device->machine->primary_screen->time_until_pos(IREMM10_VBSTART + 1, 80), NULL, -1, interrupt_callback); + device->machine->scheduler().timer_set(device->machine->primary_screen->time_until_pos(IREMM10_VBSTART + 1, 80), FUNC(interrupt_callback), -1); } /************************************* diff --git a/src/mame/drivers/m107.c b/src/mame/drivers/m107.c index e2026d753d7..a5f758dae3f 100644 --- a/src/mame/drivers/m107.c +++ b/src/mame/drivers/m107.c @@ -56,7 +56,7 @@ static WRITE16_HANDLER( bankswitch_w ) static MACHINE_START( m107 ) { m107_state *state = machine->driver_data<m107_state>(); - state->scanline_timer = timer_alloc(machine, m107_scanline_interrupt, NULL); + state->scanline_timer = machine->scheduler().timer_alloc(FUNC(m107_scanline_interrupt)); } static MACHINE_RESET( m107 ) @@ -132,7 +132,7 @@ static TIMER_CALLBACK( setvector_callback ) static WRITE16_HANDLER( m107_soundlatch_w ) { - timer_call_after_resynch(space->machine, NULL, V30_ASSERT, setvector_callback); + space->machine->scheduler().synchronize(FUNC(setvector_callback), V30_ASSERT); soundlatch_w(space, 0, data & 0xff); // logerror("soundlatch_w %02x\n",data); } @@ -151,7 +151,7 @@ static READ16_HANDLER( m107_soundlatch_r ) static WRITE16_HANDLER( m107_sound_irq_ack_w ) { - timer_call_after_resynch(space->machine, NULL, V30_CLEAR,setvector_callback); + space->machine->scheduler().synchronize(FUNC(setvector_callback), V30_CLEAR); } static WRITE16_HANDLER( m107_sound_status_w ) @@ -805,9 +805,9 @@ GFXDECODE_END static void sound_irq(device_t *device, int state) { if (state) - timer_call_after_resynch(device->machine, NULL, YM2151_ASSERT,setvector_callback); + device->machine->scheduler().synchronize(FUNC(setvector_callback), YM2151_ASSERT); else - timer_call_after_resynch(device->machine, NULL, YM2151_CLEAR,setvector_callback); + device->machine->scheduler().synchronize(FUNC(setvector_callback), YM2151_CLEAR); } static const ym2151_interface ym2151_config = diff --git a/src/mame/drivers/m63.c b/src/mame/drivers/m63.c index 67439f95967..9e9a8e69024 100644 --- a/src/mame/drivers/m63.c +++ b/src/mame/drivers/m63.c @@ -357,7 +357,7 @@ static WRITE8_HANDLER( snd_irq_w ) { m63_state *state = space->machine->driver_data<m63_state>(); cpu_set_input_line(state->soundcpu, 0, ASSERT_LINE); - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); } static WRITE8_HANDLER( snddata_w ) diff --git a/src/mame/drivers/m72.c b/src/mame/drivers/m72.c index 279c409cdae..7bcfb1e37e4 100644 --- a/src/mame/drivers/m72.c +++ b/src/mame/drivers/m72.c @@ -106,7 +106,7 @@ static TIMER_CALLBACK( kengo_scanline_interrupt ); static MACHINE_START( m72 ) { m72_state *state = machine->driver_data<m72_state>(); - state->scanline_timer = timer_alloc(machine, m72_scanline_interrupt, NULL); + state->scanline_timer = machine->scheduler().timer_alloc(FUNC(m72_scanline_interrupt)); state_save_register_global(machine, state->mcu_sample_addr); state_save_register_global(machine, state->mcu_snd_cmd_latch); @@ -115,7 +115,7 @@ static MACHINE_START( m72 ) static MACHINE_START( kengo ) { m72_state *state = machine->driver_data<m72_state>(); - state->scanline_timer = timer_alloc(machine, kengo_scanline_interrupt, NULL); + state->scanline_timer = machine->scheduler().timer_alloc(FUNC(kengo_scanline_interrupt)); state_save_register_global(machine, state->mcu_sample_addr); state_save_register_global(machine, state->mcu_snd_cmd_latch); @@ -135,7 +135,7 @@ static MACHINE_RESET( m72 ) state->mcu_snd_cmd_latch = 0; timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(0), 0); - timer_call_after_resynch(machine, NULL, 0, synch_callback); + machine->scheduler().synchronize(FUNC(synch_callback)); } static MACHINE_RESET( xmultipl ) @@ -259,11 +259,11 @@ static WRITE16_HANDLER( m72_main_mcu_w) state->protection_ram[offset] = val; cputag_set_input_line(space->machine, "mcu", 0, ASSERT_LINE); /* Line driven, most likely by write line */ - //timer_set(space->machine, space->machine->device<cpu_device>("mcu")->cycles_to_attotime(2), NULL, 0, mcu_irq0_clear); - //timer_set(space->machine, space->machine->device<cpu_device>("mcu")->cycles_to_attotime(0), NULL, 0, mcu_irq0_raise); + //space->machine->scheduler().timer_set(space->machine->device<cpu_device>("mcu")->cycles_to_attotime(2), FUNC(mcu_irq0_clear)); + //space->machine->scheduler().timer_set(space->machine->device<cpu_device>("mcu")->cycles_to_attotime(0), FUNC(mcu_irq0_raise)); } else - timer_call_after_resynch( space->machine, state->protection_ram, (offset<<16) | val, delayed_ram16_w); + space->machine->scheduler().synchronize( FUNC(delayed_ram16_w), (offset<<16) | val, state->protection_ram); } static WRITE8_HANDLER( m72_mcu_data_w ) @@ -273,7 +273,7 @@ static WRITE8_HANDLER( m72_mcu_data_w ) if (offset&1) val = (state->protection_ram[offset/2] & 0x00ff) | (data << 8); else val = (state->protection_ram[offset/2] & 0xff00) | (data&0xff); - timer_call_after_resynch( space->machine, state->protection_ram, ((offset >>1 ) << 16) | val, delayed_ram16_w); + space->machine->scheduler().synchronize( FUNC(delayed_ram16_w), ((offset >>1 ) << 16) | val, state->protection_ram); } static READ8_HANDLER(m72_mcu_data_r ) diff --git a/src/mame/drivers/m92.c b/src/mame/drivers/m92.c index 91ca91f9a84..6cb004e7170 100644 --- a/src/mame/drivers/m92.c +++ b/src/mame/drivers/m92.c @@ -235,7 +235,7 @@ static MACHINE_START( m92 ) state_save_register_global(machine, state->bankaddress); state_save_register_postload(machine, m92_postload, NULL); - state->scanline_timer = timer_alloc(machine, m92_scanline_interrupt, NULL); + state->scanline_timer = machine->scheduler().timer_alloc(FUNC(m92_scanline_interrupt)); } static MACHINE_RESET( m92 ) @@ -348,7 +348,7 @@ static TIMER_CALLBACK( setvector_callback ) static WRITE16_HANDLER( m92_soundlatch_w ) { - timer_call_after_resynch(space->machine, NULL, V30_ASSERT, setvector_callback); + space->machine->scheduler().synchronize(FUNC(setvector_callback), V30_ASSERT); soundlatch_w(space, 0, data & 0xff); } @@ -366,7 +366,7 @@ static READ16_HANDLER( m92_soundlatch_r ) static WRITE16_HANDLER( m92_sound_irq_ack_w ) { - timer_call_after_resynch(space->machine, NULL, V30_CLEAR, setvector_callback); + space->machine->scheduler().synchronize(FUNC(setvector_callback), V30_CLEAR); } static WRITE16_HANDLER( m92_sound_status_w ) @@ -911,9 +911,9 @@ GFXDECODE_END static void sound_irq(device_t *device, int state) { if (state) - timer_call_after_resynch(device->machine, NULL, YM2151_ASSERT, setvector_callback); + device->machine->scheduler().synchronize(FUNC(setvector_callback), YM2151_ASSERT); else - timer_call_after_resynch(device->machine, NULL, YM2151_CLEAR, setvector_callback); + device->machine->scheduler().synchronize(FUNC(setvector_callback), YM2151_CLEAR); } static const ym2151_interface ym2151_config = diff --git a/src/mame/drivers/magmax.c b/src/mame/drivers/magmax.c index 2b17b8e9a25..70ee1afcca4 100644 --- a/src/mame/drivers/magmax.c +++ b/src/mame/drivers/magmax.c @@ -83,7 +83,7 @@ static TIMER_CALLBACK( scanline_callback ) static MACHINE_START( magmax ) { /* Create interrupt timer */ - interrupt_timer = timer_alloc(machine, scanline_callback, NULL); + interrupt_timer = machine->scheduler().timer_alloc(FUNC(scanline_callback)); /* Set up save state */ state_save_register_global(machine, sound_latch); diff --git a/src/mame/drivers/mappy.c b/src/mame/drivers/mappy.c index 17a279bab8d..98a548ce424 100644 --- a/src/mame/drivers/mappy.c +++ b/src/mame/drivers/mappy.c @@ -772,10 +772,10 @@ static INTERRUPT_GEN( superpac_interrupt_1 ) // so don't replace with cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); if (!namcoio_read_reset_line(namcoio_1)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 0, superpac_io_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(superpac_io_run)); if (!namcoio_read_reset_line(namcoio_2)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 1, superpac_io_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(superpac_io_run), 1); } static TIMER_CALLBACK( pacnpal_io_run ) @@ -803,10 +803,10 @@ static INTERRUPT_GEN( pacnpal_interrupt_1 ) // so don't replace with cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); if (!namcoio_read_reset_line(namcoio_1)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 0, pacnpal_io_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(pacnpal_io_run)); if (!namcoio_read_reset_line(namcoio_2)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 1, pacnpal_io_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(pacnpal_io_run), 1); } static TIMER_CALLBACK( phozon_io_run ) @@ -834,10 +834,10 @@ static INTERRUPT_GEN( phozon_interrupt_1 ) // so don't replace with cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); if (!namcoio_read_reset_line(namcoio_1)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 0, phozon_io_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(phozon_io_run)); if (!namcoio_read_reset_line(namcoio_2)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 1, phozon_io_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(phozon_io_run), 1); } static TIMER_CALLBACK( mappy_io_run ) @@ -865,10 +865,10 @@ static INTERRUPT_GEN( mappy_interrupt_1 ) // so don't replace with cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); if (!namcoio_read_reset_line(namcoio_1)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 0, mappy_io_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(mappy_io_run)); if (!namcoio_read_reset_line(namcoio_2)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 1, mappy_io_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(mappy_io_run), 1); } diff --git a/src/mame/drivers/marineb.c b/src/mame/drivers/marineb.c index 1cee52b4e80..5f0bdb9bbd6 100644 --- a/src/mame/drivers/marineb.c +++ b/src/mame/drivers/marineb.c @@ -59,7 +59,7 @@ static MACHINE_RESET( marineb ) state->marineb_active_low_flipscreen = 0; /* we must start with NMI interrupts disabled */ - timer_call_after_resynch(machine, NULL, 0, interrupt_disable); + machine->scheduler().synchronize(FUNC(interrupt_disable)); } static MACHINE_RESET( springer ) diff --git a/src/mame/drivers/mazerbla.c b/src/mame/drivers/mazerbla.c index 746431ab9b2..ef2ac743ae3 100644 --- a/src/mame/drivers/mazerbla.c +++ b/src/mame/drivers/mazerbla.c @@ -742,7 +742,7 @@ static READ8_HANDLER( ls670_0_r ) mazerbla_state *state = space->machine->driver_data<mazerbla_state>(); /* set a timer to force synchronization after the read */ - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return state->ls670_0[offset]; } @@ -759,7 +759,7 @@ static TIMER_CALLBACK( deferred_ls670_0_w ) static WRITE8_HANDLER( ls670_0_w ) { /* do this on a timer to let the CPUs synchronize */ - timer_call_after_resynch(space->machine, NULL, (offset << 8) | data, deferred_ls670_0_w); + space->machine->scheduler().synchronize(FUNC(deferred_ls670_0_w), (offset << 8) | data); } static READ8_HANDLER( ls670_1_r ) @@ -767,7 +767,7 @@ static READ8_HANDLER( ls670_1_r ) mazerbla_state *state = space->machine->driver_data<mazerbla_state>(); /* set a timer to force synchronization after the read */ - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return state->ls670_1[offset]; } @@ -784,7 +784,7 @@ static TIMER_CALLBACK( deferred_ls670_1_w ) static WRITE8_HANDLER( ls670_1_w ) { /* do this on a timer to let the CPUs synchronize */ - timer_call_after_resynch(space->machine, NULL, (offset << 8) | data, deferred_ls670_1_w); + space->machine->scheduler().synchronize(FUNC(deferred_ls670_1_w), (offset << 8) | data); } @@ -928,7 +928,7 @@ static TIMER_CALLBACK( delayed_sound_w ) static WRITE8_HANDLER( main_sound_w ) { - timer_call_after_resynch(space->machine, NULL, data & 0xff, delayed_sound_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_w), data & 0xff); } static WRITE8_HANDLER( sound_int_clear_w ) diff --git a/src/mame/drivers/megadriv.c b/src/mame/drivers/megadriv.c index 687b8408464..51d98924d54 100644 --- a/src/mame/drivers/megadriv.c +++ b/src/mame/drivers/megadriv.c @@ -295,7 +295,7 @@ static void mess_init_6buttons_pad(running_machine *machine) for (i = 0; i < 3; i++) { - mess_io_timeout[i] = timer_alloc(machine, mess_io_timeout_timer_callback, (void*)(FPTR)i); + mess_io_timeout[i] = machine->scheduler().timer_alloc(FUNC(mess_io_timeout_timer_callback), (void*)(FPTR)i); mess_io_stage[i] = -1; } } diff --git a/src/mame/drivers/megatech.c b/src/mame/drivers/megatech.c index 5f4d8759d29..11f7d34c89e 100644 --- a/src/mame/drivers/megatech.c +++ b/src/mame/drivers/megatech.c @@ -272,7 +272,7 @@ static TIMER_CALLBACK( megatech_z80_stop_state ) if (game_region) { { - timer_set( machine, attotime::zero, NULL, param, megatech_z80_run_state ); + machine->scheduler().timer_set( attotime::zero, FUNC(megatech_z80_run_state ), param); } } else @@ -287,7 +287,7 @@ static TIMER_CALLBACK( megatech_z80_stop_state ) static void megatech_select_game(running_machine *machine, int gameno) { - timer_set( machine, attotime::zero, NULL, gameno, megatech_z80_stop_state ); + machine->scheduler().timer_set( attotime::zero, FUNC(megatech_z80_stop_state ), gameno); } static WRITE8_HANDLER( megatech_cart_select_w ) diff --git a/src/mame/drivers/metro.c b/src/mame/drivers/metro.c index 22a4ec5e43d..7ffd0025ba3 100644 --- a/src/mame/drivers/metro.c +++ b/src/mame/drivers/metro.c @@ -256,7 +256,7 @@ static INTERRUPT_GEN( karatour_interrupt ) state->requested_int[0] = 1; state->requested_int[5] = 1; // write the scroll registers /* the duration is a guess */ - timer_set(device->machine, attotime::from_usec(2500), NULL, 0, vblank_end_callback); + device->machine->scheduler().timer_set(attotime::from_usec(2500), FUNC(vblank_end_callback)); update_irq_state(device->machine); break; @@ -729,7 +729,7 @@ static WRITE16_HANDLER( metro_blitter_w ) another blit. */ if (b1 == 0) { - timer_set(space->machine, attotime::from_usec(500), NULL, 0, metro_blit_done); + space->machine->scheduler().timer_set(attotime::from_usec(500), FUNC(metro_blit_done)); return; } @@ -6123,7 +6123,7 @@ static DRIVER_INIT( mouja ) metro_state *state = machine->driver_data<metro_state>(); metro_common(machine); state->irq_line = -1; /* split interrupt handlers */ - state->mouja_irq_timer = timer_alloc(machine, mouja_irq_callback, NULL); + state->mouja_irq_timer = machine->scheduler().timer_alloc(FUNC(mouja_irq_callback)); } static DRIVER_INIT( gakusai ) diff --git a/src/mame/drivers/mgolf.c b/src/mame/drivers/mgolf.c index 4aee5402262..9c80782ee6f 100644 --- a/src/mame/drivers/mgolf.c +++ b/src/mame/drivers/mgolf.c @@ -119,7 +119,7 @@ static TIMER_CALLBACK( interrupt_callback ) if (scanline >= 262) scanline = 16; - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(interrupt_callback), scanline); } @@ -312,7 +312,7 @@ static MACHINE_START( mgolf ) static MACHINE_RESET( mgolf ) { mgolf_state *state = machine->driver_data<mgolf_state>(); - timer_set(machine, machine->primary_screen->time_until_pos(16), NULL, 16, interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(16), FUNC(interrupt_callback), 16); state->mask = 0; state->prev = 0; diff --git a/src/mame/drivers/midvunit.c b/src/mame/drivers/midvunit.c index 487ba38d0d9..cad4bde67f9 100644 --- a/src/mame/drivers/midvunit.c +++ b/src/mame/drivers/midvunit.c @@ -161,7 +161,7 @@ static WRITE32_HANDLER( midvunit_adc_w ) if (which < 0 || which > 2) logerror("adc_w: unexpected which = %02X\n", which + 4); adc_data = input_port_read_safe(space->machine, adcnames[which], 0); - timer_set(space->machine, attotime::from_msec(1), NULL, 0, adc_ready); + space->machine->scheduler().timer_set(attotime::from_msec(1), FUNC(adc_ready)); } else logerror("adc_w without enabling writes!\n"); diff --git a/src/mame/drivers/midzeus.c b/src/mame/drivers/midzeus.c index e5874249cd1..a3b4472e097 100644 --- a/src/mame/drivers/midzeus.c +++ b/src/mame/drivers/midzeus.c @@ -78,11 +78,11 @@ static TIMER_CALLBACK( invasn_gun_callback ); static MACHINE_START( midzeus ) { - timer[0] = timer_alloc(machine, NULL, NULL); - timer[1] = timer_alloc(machine, NULL, NULL); + timer[0] = machine->scheduler().timer_alloc(FUNC(NULL)); + timer[1] = machine->scheduler().timer_alloc(FUNC(NULL)); - gun_timer[0] = timer_alloc(machine, invasn_gun_callback, NULL); - gun_timer[1] = timer_alloc(machine, invasn_gun_callback, NULL); + gun_timer[0] = machine->scheduler().timer_alloc(FUNC(invasn_gun_callback)); + gun_timer[1] = machine->scheduler().timer_alloc(FUNC(invasn_gun_callback)); state_save_register_global(machine, gun_control); state_save_register_global(machine, gun_irq_state); @@ -118,7 +118,7 @@ static TIMER_CALLBACK( display_irq_off ) static INTERRUPT_GEN( display_irq ) { cpu_set_input_line(device, 0, ASSERT_LINE); - timer_set(device->machine, attotime::from_hz(30000000), NULL, 0, display_irq_off); + device->machine->scheduler().timer_set(attotime::from_hz(30000000), FUNC(display_irq_off)); } diff --git a/src/mame/drivers/missile.c b/src/mame/drivers/missile.c index c432acc877b..2da3f309509 100644 --- a/src/mame/drivers/missile.c +++ b/src/mame/drivers/missile.c @@ -518,11 +518,11 @@ static MACHINE_START( missile ) space->set_direct_update_handler(direct_update_delegate_create_static(missile_direct_handler, *machine)); /* create a timer to speed/slow the CPU */ - state->cpu_timer = timer_alloc(machine, adjust_cpu_speed, NULL); + state->cpu_timer = machine->scheduler().timer_alloc(FUNC(adjust_cpu_speed)); timer_adjust_oneshot(state->cpu_timer, machine->primary_screen->time_until_pos(v_to_scanline(state, 0), 0), 0); /* create a timer for IRQs and set up the first callback */ - state->irq_timer = timer_alloc(machine, clock_irq, NULL); + state->irq_timer = machine->scheduler().timer_alloc(FUNC(clock_irq)); state->irq_state = 0; schedule_next_irq(machine, -32); diff --git a/src/mame/drivers/mjsister.c b/src/mame/drivers/mjsister.c index a94821dda43..6f6c7bb5a5c 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::from_hz(MCLK) * 1024, NULL, 0, dac_callback); + machine->scheduler().timer_set(attotime::from_hz(MCLK) * 1024, FUNC(dac_callback)); else state->dac_busy = 0; } @@ -178,7 +178,7 @@ static WRITE8_HANDLER( mjsister_dac_adr_e_w ) state->dac_adr = state->dac_adr_s << 8; if (state->dac_busy == 0) - timer_call_after_resynch(space->machine, NULL, 0, dac_callback); + space->machine->scheduler().synchronize(FUNC(dac_callback)); state->dac_busy = 1; } diff --git a/src/mame/drivers/mlanding.c b/src/mame/drivers/mlanding.c index 1e9af93d138..4ff729fa9c8 100644 --- a/src/mame/drivers/mlanding.c +++ b/src/mame/drivers/mlanding.c @@ -284,7 +284,7 @@ static WRITE16_HANDLER( ml_sub_reset_w ) if (pixels) { dma_active = 1; - timer_set(space->machine, attotime::from_msec(20), NULL, 0, dma_complete); + space->machine->scheduler().timer_set(attotime::from_msec(20), FUNC(dma_complete)); } if(!(data & 0x40)) // unknown line used diff --git a/src/mame/drivers/moo.c b/src/mame/drivers/moo.c index f583912a945..db8f9b7f550 100644 --- a/src/mame/drivers/moo.c +++ b/src/mame/drivers/moo.c @@ -448,7 +448,7 @@ static MACHINE_START( moo ) state_save_register_global_array(machine, state->layerpri); state_save_register_global_array(machine, state->protram); - state->dmaend_timer = timer_alloc(machine, dmaend_callback, 0); + state->dmaend_timer = machine->scheduler().timer_alloc(FUNC(dmaend_callback)); } static MACHINE_RESET( moo ) diff --git a/src/mame/drivers/mpu4.c b/src/mame/drivers/mpu4.c index f903c11c556..238e5105c52 100644 --- a/src/mame/drivers/mpu4.c +++ b/src/mame/drivers/mpu4.c @@ -1921,7 +1921,7 @@ static const stepper_interface barcrest_opto1_interface = /* Common configurations */ static void mpu4_config_common(running_machine *machine) { - ic24_timer = timer_alloc(machine, ic24_timeout, NULL); + ic24_timer = machine->scheduler().timer_alloc(FUNC(ic24_timeout)); } static void mpu4_config_common_reels(running_machine *machine,int reels) diff --git a/src/mame/drivers/mpu4drvr.c b/src/mame/drivers/mpu4drvr.c index 8eaa4e0d9c8..3c85b7be6d8 100644 --- a/src/mame/drivers/mpu4drvr.c +++ b/src/mame/drivers/mpu4drvr.c @@ -2262,7 +2262,7 @@ static int linecounter = 0; static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) { int current_scanline=param; - timer_call_after_resynch(timer.machine, NULL, 0, 0); + timer.machine->scheduler().synchronize(FUNC(0)); if (current_scanline==0) diff --git a/src/mame/drivers/msisaac.c b/src/mame/drivers/msisaac.c index 7d3eb612678..631bf4e8ca7 100644 --- a/src/mame/drivers/msisaac.c +++ b/src/mame/drivers/msisaac.c @@ -34,7 +34,7 @@ static TIMER_CALLBACK( nmi_callback ) static WRITE8_HANDLER( sound_command_w ) { soundlatch_w(space, 0, data); - timer_call_after_resynch(space->machine, NULL, data, nmi_callback); + space->machine->scheduler().synchronize(FUNC(nmi_callback), data); } static WRITE8_HANDLER( nmi_disable_w ) diff --git a/src/mame/drivers/multigam.c b/src/mame/drivers/multigam.c index fb4dc598cce..2a445383438 100644 --- a/src/mame/drivers/multigam.c +++ b/src/mame/drivers/multigam.c @@ -654,7 +654,7 @@ static WRITE8_HANDLER( mmc1_rom_switch_w ) else { multigam_mmc1_reg_write_enable = 0; - timer_call_after_resynch(space->machine, NULL, 0, mmc1_resync_callback); + space->machine->scheduler().synchronize(FUNC(mmc1_resync_callback)); } int reg = (offset >> 13); diff --git a/src/mame/drivers/mustache.c b/src/mame/drivers/mustache.c index 3e22970be7b..515225d5e56 100644 --- a/src/mame/drivers/mustache.c +++ b/src/mame/drivers/mustache.c @@ -192,7 +192,7 @@ static INTERRUPT_GEN( assert_irq ) static MACHINE_START( mustache ) { mustache_state *state = machine->driver_data<mustache_state>(); - state->clear_irq_timer = timer_alloc(machine, clear_irq_cb, 0); + state->clear_irq_timer = machine->scheduler().timer_alloc(FUNC(clear_irq_cb)); } static MACHINE_CONFIG_START( mustache, mustache_state ) diff --git a/src/mame/drivers/mw8080bw.c b/src/mame/drivers/mw8080bw.c index dafd270dde7..260bf1dee06 100644 --- a/src/mame/drivers/mw8080bw.c +++ b/src/mame/drivers/mw8080bw.c @@ -893,7 +893,7 @@ static MACHINE_START( maze ) mw8080bw_state *state = machine->driver_data<mw8080bw_state>(); /* create astable timer for IC B1 */ - timer_pulse(machine, MAZE_555_B1_PERIOD, NULL, 0, maze_tone_timing_timer_callback); + machine->scheduler().timer_pulse(MAZE_555_B1_PERIOD, FUNC(maze_tone_timing_timer_callback)); /* initialize state of Tone Timing FF, IC C1 */ state->maze_tone_timing_state = 0; diff --git a/src/mame/drivers/namcofl.c b/src/mame/drivers/namcofl.c index 2d04f63585e..dc4f344b2ce 100644 --- a/src/mame/drivers/namcofl.c +++ b/src/mame/drivers/namcofl.c @@ -535,14 +535,14 @@ GFXDECODE_END static TIMER_CALLBACK( network_interrupt_callback ) { cputag_set_input_line(machine, "maincpu", I960_IRQ0, ASSERT_LINE); - timer_set(machine, machine->primary_screen->frame_period(), NULL, 0, network_interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->frame_period(), FUNC(network_interrupt_callback)); } static TIMER_CALLBACK( vblank_interrupt_callback ) { cputag_set_input_line(machine, "maincpu", I960_IRQ2, ASSERT_LINE); - timer_set(machine, machine->primary_screen->frame_period(), NULL, 0, vblank_interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->frame_period(), FUNC(vblank_interrupt_callback)); } @@ -571,14 +571,14 @@ static INTERRUPT_GEN( mcu_interrupt ) static MACHINE_START( namcofl ) { - raster_interrupt_timer = timer_alloc(machine, raster_interrupt_callback, NULL); + raster_interrupt_timer = machine->scheduler().timer_alloc(FUNC(raster_interrupt_callback)); } static MACHINE_RESET( namcofl ) { - timer_set(machine, machine->primary_screen->time_until_pos(machine->primary_screen->visible_area().max_y + 3, 0), NULL, 0, network_interrupt_callback); - timer_set(machine, machine->primary_screen->time_until_pos(machine->primary_screen->visible_area().max_y + 1, 0), NULL, 0, vblank_interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(machine->primary_screen->visible_area().max_y + 3), FUNC(network_interrupt_callback)); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(machine->primary_screen->visible_area().max_y + 1), FUNC(vblank_interrupt_callback)); memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() ); memory_set_bankptr(machine, "bank2", namcofl_workram ); diff --git a/src/mame/drivers/namconb1.c b/src/mame/drivers/namconb1.c index 55ccb36ba86..77ed7ea8783 100644 --- a/src/mame/drivers/namconb1.c +++ b/src/mame/drivers/namconb1.c @@ -348,7 +348,7 @@ static INTERRUPT_GEN( namconb1_interrupt ) } if( scanline < NAMCONB1_VBSTART ) { - timer_set( device->machine, device->machine->primary_screen->time_until_pos(scanline), NULL, scanline, namconb1_TriggerPOSIRQ ); + device->machine->scheduler().timer_set( device->machine->primary_screen->time_until_pos(scanline), FUNC(namconb1_TriggerPOSIRQ ), scanline); } } /* namconb1_interrupt */ @@ -417,7 +417,7 @@ static INTERRUPT_GEN( namconb2_interrupt ) scanline = 0; if( scanline < NAMCONB1_VBSTART ) - timer_set( device->machine, device->machine->primary_screen->time_until_pos(scanline), NULL, scanline, namconb2_TriggerPOSIRQ ); + device->machine->scheduler().timer_set( device->machine->primary_screen->time_until_pos(scanline), FUNC(namconb2_TriggerPOSIRQ ), scanline); } /* namconb2_interrupt */ static void namconb1_cpureg8_w(running_machine *machine, int reg, UINT8 data) diff --git a/src/mame/drivers/namcos22.c b/src/mame/drivers/namcos22.c index 439740f5425..c7bf1d8b00e 100644 --- a/src/mame/drivers/namcos22.c +++ b/src/mame/drivers/namcos22.c @@ -2188,7 +2188,7 @@ static WRITE32_HANDLER( namcos22_system_controller_w ) { /* SUBCPU enable on System 22 (guessed, but too early crashes Rave Racer so it's a good test) */ if (data == 0xff00) { - timer_set(space->machine, attotime::from_msec(50), NULL, 0, start_subcpu); + space->machine->scheduler().timer_set(attotime::from_msec(50), FUNC(start_subcpu)); } } } diff --git a/src/mame/drivers/namcos23.c b/src/mame/drivers/namcos23.c index 8686f12bb30..158dcaab1fa 100644 --- a/src/mame/drivers/namcos23.c +++ b/src/mame/drivers/namcos23.c @@ -2040,7 +2040,7 @@ static INTERRUPT_GEN(s23_interrupt) static MACHINE_START( s23 ) { - c361_timer = timer_alloc(machine, c361_timer_cb, 0); + c361_timer = machine->scheduler().timer_alloc(FUNC(c361_timer_cb)); timer_adjust_oneshot(c361_timer, attotime::never, 0); } diff --git a/src/mame/drivers/neodrvr.c b/src/mame/drivers/neodrvr.c index 816fc9d3e7d..e40a6102a2c 100644 --- a/src/mame/drivers/neodrvr.c +++ b/src/mame/drivers/neodrvr.c @@ -7968,8 +7968,8 @@ static DRIVER_INIT( ms5pcb ) DRIVER_INIT_CALL(neogeo); /* start a timer that will check the BIOS select DIP every second */ - timer_set(machine, attotime::zero, NULL, 0, ms5pcb_bios_timer_callback); - timer_pulse(machine, attotime::from_msec(1000), NULL, 0, ms5pcb_bios_timer_callback); + machine->scheduler().timer_set(attotime::zero, FUNC(ms5pcb_bios_timer_callback)); + machine->scheduler().timer_pulse(attotime::from_msec(1000), FUNC(ms5pcb_bios_timer_callback)); mslug5_decrypt_68k(machine); svcpcb_gfx_decrypt(machine); @@ -8005,8 +8005,8 @@ static DRIVER_INIT( svcpcb ) DRIVER_INIT_CALL(neogeo); /* start a timer that will check the BIOS select DIP every second */ - timer_set(machine, attotime::zero, NULL, 0, svcpcb_bios_timer_callback); - timer_pulse(machine, attotime::from_msec(1000), NULL, 0, svcpcb_bios_timer_callback); + machine->scheduler().timer_set(attotime::zero, FUNC(svcpcb_bios_timer_callback)); + machine->scheduler().timer_pulse(attotime::from_msec(1000), FUNC(svcpcb_bios_timer_callback)); svc_px_decrypt(machine); svcpcb_gfx_decrypt(machine); diff --git a/src/mame/drivers/neogeo.c b/src/mame/drivers/neogeo.c index e9d3776a221..7861e4fbc86 100644 --- a/src/mame/drivers/neogeo.c +++ b/src/mame/drivers/neogeo.c @@ -369,9 +369,9 @@ static TIMER_CALLBACK( vblank_interrupt_callback ) static void create_interrupt_timers( running_machine *machine ) { neogeo_state *state = machine->driver_data<neogeo_state>(); - state->display_position_interrupt_timer = timer_alloc(machine, display_position_interrupt_callback, NULL); - state->display_position_vblank_timer = timer_alloc(machine, display_position_vblank_callback, NULL); - state->vblank_interrupt_timer = timer_alloc(machine, vblank_interrupt_callback, NULL); + state->display_position_interrupt_timer = machine->scheduler().timer_alloc(FUNC(display_position_interrupt_callback)); + state->display_position_vblank_timer = machine->scheduler().timer_alloc(FUNC(display_position_vblank_callback)); + state->vblank_interrupt_timer = machine->scheduler().timer_alloc(FUNC(vblank_interrupt_callback)); } diff --git a/src/mame/drivers/nycaptor.c b/src/mame/drivers/nycaptor.c index 7bca7677859..99023311098 100644 --- a/src/mame/drivers/nycaptor.c +++ b/src/mame/drivers/nycaptor.c @@ -290,7 +290,7 @@ static TIMER_CALLBACK( nmi_callback ) static WRITE8_HANDLER( sound_command_w ) { soundlatch_w(space, 0, data); - timer_call_after_resynch(space->machine, NULL, data, nmi_callback); + space->machine->scheduler().synchronize(FUNC(nmi_callback), data); } static WRITE8_HANDLER( nmi_disable_w ) diff --git a/src/mame/drivers/orbit.c b/src/mame/drivers/orbit.c index 94e21222137..a3c0204cc89 100644 --- a/src/mame/drivers/orbit.c +++ b/src/mame/drivers/orbit.c @@ -50,7 +50,7 @@ static TIMER_CALLBACK( irq_off ) static INTERRUPT_GEN( orbit_interrupt ) { cpu_set_input_line(device, 0, ASSERT_LINE); - timer_set(device->machine, device->machine->primary_screen->time_until_vblank_end(), NULL, 0, irq_off); + device->machine->scheduler().timer_set(device->machine->primary_screen->time_until_vblank_end(), FUNC(irq_off)); } diff --git a/src/mame/drivers/othunder.c b/src/mame/drivers/othunder.c index 80054ec90f1..83dc27138c9 100644 --- a/src/mame/drivers/othunder.c +++ b/src/mame/drivers/othunder.c @@ -385,7 +385,7 @@ static WRITE16_HANDLER( othunder_lightgun_w ) The ADC60808 clock is 512kHz. Conversion takes between 0 and 8 clock cycles, so would end in a maximum of 15.625us. We'll use 10. */ - timer_set(space->machine, attotime::from_usec(10), NULL,0, ad_interrupt); + space->machine->scheduler().timer_set(attotime::from_usec(10), FUNC(ad_interrupt)); } diff --git a/src/mame/drivers/parodius.c b/src/mame/drivers/parodius.c index 0e76e5cc018..01c42adee0b 100644 --- a/src/mame/drivers/parodius.c +++ b/src/mame/drivers/parodius.c @@ -139,7 +139,7 @@ static WRITE8_HANDLER( sound_arm_nmi_w ) parodius_state *state = space->machine->driver_data<parodius_state>(); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE); - timer_set(space->machine, attotime::from_usec(50), NULL, 0, nmi_callback); /* kludge until the K053260 is emulated correctly */ + space->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(nmi_callback)); /* kludge until the K053260 is emulated correctly */ } /********************************************/ diff --git a/src/mame/drivers/peplus.c b/src/mame/drivers/peplus.c index 114cbb8abb2..fef9e2beeeb 100644 --- a/src/mame/drivers/peplus.c +++ b/src/mame/drivers/peplus.c @@ -334,7 +334,7 @@ static void handle_lightpen( device_t *device ) xt = x_val * (vis_area.max_x - vis_area.min_x) / 1024 + vis_area.min_x; yt = y_val * (vis_area.max_y - vis_area.min_y) / 1024 + vis_area.min_y; - timer_set(device->machine, device->machine->primary_screen->time_until_pos(yt, xt), (void *) device, 0, assert_lp_cb); + device->machine->scheduler().timer_set(device->machine->primary_screen->time_until_pos(yt, xt), FUNC(assert_lp_cb), 0, device); } static WRITE_LINE_DEVICE_HANDLER(crtc_vsync) diff --git a/src/mame/drivers/pgm.c b/src/mame/drivers/pgm.c index 69b135383cd..ceef801db2d 100644 --- a/src/mame/drivers/pgm.c +++ b/src/mame/drivers/pgm.c @@ -752,7 +752,7 @@ static READ32_HANDLER( kovsh_arm7_protlatch_r ) { pgm_state *state = space->machine->driver_data<pgm_state>(); - timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync + space->machine->scheduler().synchronize(FUNC(0)); // force resync return (state->kovsh_highlatch_68k_w << 16) | (state->kovsh_lowlatch_68k_w); } @@ -761,7 +761,7 @@ static WRITE32_HANDLER( kovsh_arm7_protlatch_w ) { pgm_state *state = space->machine->driver_data<pgm_state>(); - timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync + space->machine->scheduler().synchronize(FUNC(0)); // force resync if (ACCESSING_BITS_16_31) { @@ -779,7 +779,7 @@ static READ16_HANDLER( kovsh_68k_protlatch_r ) { pgm_state *state = space->machine->driver_data<pgm_state>(); - timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync + space->machine->scheduler().synchronize(FUNC(0)); // force resync switch (offset) { @@ -793,7 +793,7 @@ static WRITE16_HANDLER( kovsh_68k_protlatch_w ) { pgm_state *state = space->machine->driver_data<pgm_state>(); - timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync + space->machine->scheduler().synchronize(FUNC(0)); // force resync switch (offset) { diff --git a/src/mame/drivers/pipedrm.c b/src/mame/drivers/pipedrm.c index bec04922e4b..18d121d3ae3 100644 --- a/src/mame/drivers/pipedrm.c +++ b/src/mame/drivers/pipedrm.c @@ -224,13 +224,13 @@ static TIMER_CALLBACK( delayed_command_w ) static WRITE8_HANDLER( sound_command_w ) { - timer_call_after_resynch(space->machine, NULL, data | 0x100, delayed_command_w); + space->machine->scheduler().synchronize(FUNC(delayed_command_w), data | 0x100); } static WRITE8_HANDLER( sound_command_nonmi_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_command_w); + space->machine->scheduler().synchronize(FUNC(delayed_command_w), data); } diff --git a/src/mame/drivers/pipeline.c b/src/mame/drivers/pipeline.c index 35d724407bd..e7d34087b51 100644 --- a/src/mame/drivers/pipeline.c +++ b/src/mame/drivers/pipeline.c @@ -161,7 +161,7 @@ static TIMER_CALLBACK( protection_deferred_w ) static WRITE8_DEVICE_HANDLER(protection_w) { - timer_call_after_resynch(device->machine, NULL, data, protection_deferred_w); + device->machine->scheduler().synchronize(FUNC(protection_deferred_w), data); cpuexec_boost_interleave(device->machine, attotime::zero, attotime::from_usec(100)); } diff --git a/src/mame/drivers/policetr.c b/src/mame/drivers/policetr.c index 037a255367d..3aa6b8474b4 100644 --- a/src/mame/drivers/policetr.c +++ b/src/mame/drivers/policetr.c @@ -127,7 +127,7 @@ static TIMER_CALLBACK( irq5_gen ) static INTERRUPT_GEN( irq4_gen ) { cpu_set_input_line(device, R3000_IRQ4, ASSERT_LINE); - timer_set(device->machine, device->machine->primary_screen->time_until_pos(0), NULL, 0, irq5_gen); + device->machine->scheduler().timer_set(device->machine->primary_screen->time_until_pos(0), FUNC(irq5_gen)); } diff --git a/src/mame/drivers/psikyo.c b/src/mame/drivers/psikyo.c index 434cefc97ce..79f1afd390c 100644 --- a/src/mame/drivers/psikyo.c +++ b/src/mame/drivers/psikyo.c @@ -88,7 +88,7 @@ static CUSTOM_INPUT( z80_nmi_r ) /* main CPU might be waiting for sound CPU to finish NMI, so set a timer to give sound CPU a chance to run */ - timer_call_after_resynch(field->port->machine, NULL, 0, NULL); + field->port->machine->scheduler().synchronize(); // logerror("%s - Read coin port during Z80 NMI\n", cpuexec_describe_context(machine)); } @@ -157,7 +157,7 @@ static TIMER_CALLBACK( psikyo_soundlatch_callback ) static WRITE32_HANDLER( psikyo_soundlatch_w ) { if (ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, data & 0xff, psikyo_soundlatch_callback); + space->machine->scheduler().synchronize(FUNC(psikyo_soundlatch_callback), data & 0xff); } /*************************************************************************** @@ -167,7 +167,7 @@ static WRITE32_HANDLER( psikyo_soundlatch_w ) static WRITE32_HANDLER( s1945_soundlatch_w ) { if (ACCESSING_BITS_16_23) - timer_call_after_resynch(space->machine, NULL, (data >> 16) & 0xff, psikyo_soundlatch_callback); + space->machine->scheduler().synchronize(FUNC(psikyo_soundlatch_callback), (data >> 16) & 0xff); } static const UINT8 s1945_table[256] = { diff --git a/src/mame/drivers/qdrmfgp.c b/src/mame/drivers/qdrmfgp.c index 4c25679bac6..1a49b68601c 100644 --- a/src/mame/drivers/qdrmfgp.c +++ b/src/mame/drivers/qdrmfgp.c @@ -616,7 +616,7 @@ static MACHINE_START( qdrmfgp ) static MACHINE_START( qdrmfgp2 ) { /* sound irq (CCU? 240Hz) */ - timer_pulse(machine, attotime::from_hz(18432000/76800), NULL, 0, gp2_timer_callback); + machine->scheduler().timer_pulse(attotime::from_hz(18432000/76800), FUNC(gp2_timer_callback)); MACHINE_START_CALL( qdrmfgp ); } diff --git a/src/mame/drivers/rabbit.c b/src/mame/drivers/rabbit.c index b36802f65a8..a67ed4b46e4 100644 --- a/src/mame/drivers/rabbit.c +++ b/src/mame/drivers/rabbit.c @@ -633,7 +633,7 @@ static void rabbit_do_blit(running_machine *machine) if (!blt_amount) { if(BLITLOG) mame_printf_debug("end of blit list\n"); - timer_set(machine, attotime::from_usec(500), NULL,0,rabbit_blit_done); + machine->scheduler().timer_set(attotime::from_usec(500), FUNC(rabbit_blit_done)); return; } diff --git a/src/mame/drivers/rollerg.c b/src/mame/drivers/rollerg.c index 7900f4dce3a..f91cb41f14a 100644 --- a/src/mame/drivers/rollerg.c +++ b/src/mame/drivers/rollerg.c @@ -72,7 +72,7 @@ static WRITE8_HANDLER( sound_arm_nmi_w ) { rollerg_state *state = space->machine->driver_data<rollerg_state>(); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE); - timer_set(space->machine, attotime::from_usec(50), NULL, 0, nmi_callback); /* kludge until the K053260 is emulated correctly */ + space->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(nmi_callback)); /* kludge until the K053260 is emulated correctly */ } static READ8_HANDLER( pip_r ) diff --git a/src/mame/drivers/rpunch.c b/src/mame/drivers/rpunch.c index d61ee93a495..5fc1e28d368 100644 --- a/src/mame/drivers/rpunch.c +++ b/src/mame/drivers/rpunch.c @@ -173,7 +173,7 @@ static TIMER_CALLBACK( sound_command_w_callback ) static WRITE16_HANDLER( sound_command_w ) { if (ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, data & 0xff, sound_command_w_callback); + space->machine->scheduler().synchronize(FUNC(sound_command_w_callback), data & 0xff); } diff --git a/src/mame/drivers/runaway.c b/src/mame/drivers/runaway.c index 92c26ff591d..a896a4a1b82 100644 --- a/src/mame/drivers/runaway.c +++ b/src/mame/drivers/runaway.c @@ -36,7 +36,7 @@ static TIMER_CALLBACK( interrupt_callback ) static MACHINE_START( runaway ) { runaway_state *state = machine->driver_data<runaway_state>(); - state->interrupt_timer = timer_alloc(machine, interrupt_callback, NULL); + state->interrupt_timer = machine->scheduler().timer_alloc(FUNC(interrupt_callback)); } static MACHINE_RESET( runaway ) diff --git a/src/mame/drivers/sbrkout.c b/src/mame/drivers/sbrkout.c index 4ceddb34d57..05570b67b8d 100644 --- a/src/mame/drivers/sbrkout.c +++ b/src/mame/drivers/sbrkout.c @@ -88,8 +88,8 @@ static MACHINE_START( sbrkout ) sbrkout_state *state = machine->driver_data<sbrkout_state>(); UINT8 *videoram = state->videoram; memory_set_bankptr(machine, "bank1", &videoram[0x380]); - state->scanline_timer = timer_alloc(machine, scanline_callback, NULL); - state->pot_timer = timer_alloc(machine, pot_trigger_callback, NULL); + state->scanline_timer = machine->scheduler().timer_alloc(FUNC(scanline_callback)); + state->pot_timer = machine->scheduler().timer_alloc(FUNC(pot_trigger_callback)); state_save_register_global(machine, state->sync2_value); state_save_register_global_array(machine, state->pot_mask); diff --git a/src/mame/drivers/seattle.c b/src/mame/drivers/seattle.c index 300271e0c72..617a9f93259 100644 --- a/src/mame/drivers/seattle.c +++ b/src/mame/drivers/seattle.c @@ -515,10 +515,10 @@ static MACHINE_START( seattle ) voodoo = machine->device("voodoo"); /* allocate timers for the galileo */ - galileo.timer[0].timer = timer_alloc(machine, galileo_timer_callback, NULL); - galileo.timer[1].timer = timer_alloc(machine, galileo_timer_callback, NULL); - galileo.timer[2].timer = timer_alloc(machine, galileo_timer_callback, NULL); - galileo.timer[3].timer = timer_alloc(machine, galileo_timer_callback, NULL); + galileo.timer[0].timer = machine->scheduler().timer_alloc(FUNC(galileo_timer_callback)); + galileo.timer[1].timer = machine->scheduler().timer_alloc(FUNC(galileo_timer_callback)); + galileo.timer[2].timer = machine->scheduler().timer_alloc(FUNC(galileo_timer_callback)); + galileo.timer[3].timer = machine->scheduler().timer_alloc(FUNC(galileo_timer_callback)); /* set the fastest DRC options, but strict verification */ mips3drc_set_options(machine->device("maincpu"), MIPS3DRC_FASTEST_OPTIONS + MIPS3DRC_STRICT_VERIFY); diff --git a/src/mame/drivers/segahang.c b/src/mame/drivers/segahang.c index 796d475eeac..fa83523c701 100644 --- a/src/mame/drivers/segahang.c +++ b/src/mame/drivers/segahang.c @@ -133,7 +133,7 @@ static MACHINE_RESET( hangon ) /* if we have a fake i8751 handler, disable the actual 8751 */ if (state->i8751_vblank_hook != NULL) - timer_call_after_resynch(machine, NULL, 0, suspend_i8751); + machine->scheduler().synchronize(FUNC(suspend_i8751)); /* reset global state */ state->adc_select = 0; @@ -204,7 +204,7 @@ static WRITE16_HANDLER( hangon_io_w ) case 0x0000/2: /* PPI @ 4B */ /* the port C handshaking signals control the Z80 NMI, */ /* so we have to sync whenever we access this PPI */ - timer_call_after_resynch(space->machine, NULL, ((offset & 3) << 8) | (data & 0xff), delayed_ppi8255_w); + space->machine->scheduler().synchronize(FUNC(delayed_ppi8255_w), ((offset & 3) << 8) | (data & 0xff)); return; case 0x3000/2: /* PPI @ 4C */ @@ -260,7 +260,7 @@ static WRITE16_HANDLER( sharrier_io_w ) case 0x0000/2: /* the port C handshaking signals control the Z80 NMI, */ /* so we have to sync whenever we access this PPI */ - timer_call_after_resynch(space->machine, NULL, ((offset & 3) << 8) | (data & 0xff), delayed_ppi8255_w); + space->machine->scheduler().synchronize(FUNC(delayed_ppi8255_w), ((offset & 3) << 8) | (data & 0xff)); return; case 0x0020/2: /* PPI @ 4C */ diff --git a/src/mame/drivers/segaorun.c b/src/mame/drivers/segaorun.c index 15cb6ac9936..7841766e840 100644 --- a/src/mame/drivers/segaorun.c +++ b/src/mame/drivers/segaorun.c @@ -375,7 +375,7 @@ static TIMER_CALLBACK( delayed_sound_data_w ) static void sound_data_w(running_machine *machine, UINT8 data) { - timer_call_after_resynch(machine, NULL, data, delayed_sound_data_w); + machine->scheduler().synchronize(FUNC(delayed_sound_data_w), data); } @@ -474,7 +474,7 @@ static TIMER_DEVICE_CALLBACK( scanline_callback ) case 65: case 129: case 193: - timer_set(timer.machine, timer.machine->primary_screen->time_until_pos(scanline, timer.machine->primary_screen->visible_area().max_x + 1), NULL, 0, irq2_gen); + timer.machine->scheduler().timer_set(timer.machine->primary_screen->time_until_pos(scanline, timer.machine->primary_screen->visible_area().max_x + 1), FUNC(irq2_gen)); next_scanline = scanline + 1; break; diff --git a/src/mame/drivers/segas16a.c b/src/mame/drivers/segas16a.c index f6a60259b6c..ffd8bd32675 100644 --- a/src/mame/drivers/segas16a.c +++ b/src/mame/drivers/segas16a.c @@ -265,7 +265,7 @@ static MACHINE_RESET( system16a ) /* if we have a fake i8751 handler, disable the actual 8751 */ if (state->i8751_vblank_hook != NULL) - timer_call_after_resynch(machine, NULL, 0, suspend_i8751); + machine->scheduler().synchronize(FUNC(suspend_i8751)); state->mcu_control = 0x00; } @@ -317,7 +317,7 @@ static WRITE16_HANDLER( standard_io_w ) /* the port C handshaking signals control the Z80 NMI, */ /* so we have to sync whenever we access this PPI */ if (ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, ((offset & 3) << 8) | (data & 0xff), delayed_ppi8255_w); + space->machine->scheduler().synchronize(FUNC(delayed_ppi8255_w), ((offset & 3) << 8) | (data & 0xff)); return; } logerror("%06X:standard_io_w - unknown write access to address %04X = %04X & %04X\n", cpu_get_pc(space->cpu), offset * 2, data, mem_mask); diff --git a/src/mame/drivers/segas16b.c b/src/mame/drivers/segas16b.c index 2f28e8e565d..af5e5f6a742 100644 --- a/src/mame/drivers/segas16b.c +++ b/src/mame/drivers/segas16b.c @@ -1130,9 +1130,9 @@ static MACHINE_RESET( system16b ) /* if we have a fake i8751 handler, disable the actual 8751, otherwise crank the interleave */ if (state->i8751_vblank_hook != NULL) - timer_call_after_resynch(machine, NULL, 0, suspend_i8751); + machine->scheduler().synchronize(FUNC(suspend_i8751)); else - timer_call_after_resynch(machine, NULL, 0, boost_interleave); + machine->scheduler().synchronize(FUNC(boost_interleave)); /* configure sprite banks */ for (i = 0; i < 16; i++) diff --git a/src/mame/drivers/segas18.c b/src/mame/drivers/segas18.c index 864167c38d2..ea30491e64a 100644 --- a/src/mame/drivers/segas18.c +++ b/src/mame/drivers/segas18.c @@ -219,7 +219,7 @@ static MACHINE_RESET( system18 ) /* if we are running with a real live 8751, we need to boost the interleave at startup */ if (state->mcu != NULL && state->mcu->type() == I8751) - timer_call_after_resynch(machine, NULL, 0, boost_interleave); + machine->scheduler().synchronize(FUNC(boost_interleave)); } diff --git a/src/mame/drivers/segas32.c b/src/mame/drivers/segas32.c index 341f97870f3..7bdba2264e2 100644 --- a/src/mame/drivers/segas32.c +++ b/src/mame/drivers/segas32.c @@ -615,7 +615,7 @@ static INTERRUPT_GEN( start_of_vblank_int ) { signal_v60_irq(device->machine, MAIN_IRQ_VBSTART); system32_set_vblank(device->machine, 1); - timer_set(device->machine, device->machine->primary_screen->time_until_pos(0), NULL, 0, end_of_vblank_int); + device->machine->scheduler().timer_set(device->machine->primary_screen->time_until_pos(0), FUNC(end_of_vblank_int)); if (system32_prot_vblank) (*system32_prot_vblank)(device); } diff --git a/src/mame/drivers/segaxbd.c b/src/mame/drivers/segaxbd.c index 2bed4ff9933..12210d77e97 100644 --- a/src/mame/drivers/segaxbd.c +++ b/src/mame/drivers/segaxbd.c @@ -385,7 +385,7 @@ static TIMER_CALLBACK( delayed_sound_data_w ) static void sound_data_w(running_machine *machine, UINT8 data) { - timer_call_after_resynch(machine, NULL, data, delayed_sound_data_w); + machine->scheduler().synchronize(FUNC(delayed_sound_data_w), data); } diff --git a/src/mame/drivers/segaybd.c b/src/mame/drivers/segaybd.c index ab6f33d87ea..4fcbb64c5f1 100644 --- a/src/mame/drivers/segaybd.c +++ b/src/mame/drivers/segaybd.c @@ -245,7 +245,7 @@ static TIMER_CALLBACK( delayed_sound_data_w ) static WRITE16_HANDLER( sound_data_w ) { if (ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, data & 0xff, delayed_sound_data_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_data_w), data & 0xff); } diff --git a/src/mame/drivers/seta.c b/src/mame/drivers/seta.c index 4361c22265c..5e9ce52b81b 100644 --- a/src/mame/drivers/seta.c +++ b/src/mame/drivers/seta.c @@ -1370,7 +1370,7 @@ static void uPD71054_timer_init( running_machine *machine ) uPD71054->max[no] = 0xffff; } for( no = 0; no < USED_TIMER_NUM; no++ ) { - uPD71054->timer[no] = timer_alloc( machine, uPD71054_timer_callback , NULL); + uPD71054->timer[no] = machine->scheduler().timer_alloc( FUNC(uPD71054_timer_callback )); } } @@ -2064,7 +2064,7 @@ static WRITE16_HANDLER( keroppi_prize_w ) if ((data & 0x0010) && !state->keroppi_prize_hop) { state->keroppi_prize_hop = 1; - timer_set(space->machine, attotime::from_seconds(3), NULL, 0x20, keroppi_prize_hop_callback); /* 3 seconds */ + space->machine->scheduler().timer_set(attotime::from_seconds(3), FUNC(keroppi_prize_hop_callback), 0x20); /* 3 seconds */ } } diff --git a/src/mame/drivers/simpsons.c b/src/mame/drivers/simpsons.c index 0148b9adc01..1c5fdb5ca1f 100644 --- a/src/mame/drivers/simpsons.c +++ b/src/mame/drivers/simpsons.c @@ -130,7 +130,7 @@ static WRITE8_HANDLER( z80_arm_nmi_w ) { simpsons_state *state = space->machine->driver_data<simpsons_state>(); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE); - timer_set(space->machine, attotime::from_usec(25), NULL, 0, nmi_callback); /* kludge until the K053260 is emulated correctly */ + space->machine->scheduler().timer_set(attotime::from_usec(25), FUNC(nmi_callback)); /* kludge until the K053260 is emulated correctly */ } static ADDRESS_MAP_START( z80_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -269,7 +269,7 @@ static INTERRUPT_GEN( simpsons_irq ) { simpsons_objdma(device->machine); // 32+256us delay at 8MHz dotclock; artificially shortened since actual V-blank length is unknown - timer_set(device->machine, attotime::from_usec(30), NULL, 0, dmaend_callback); + device->machine->scheduler().timer_set(attotime::from_usec(30), FUNC(dmaend_callback)); } if (k052109_is_irq_enabled(state->k052109)) diff --git a/src/mame/drivers/skullxbo.c b/src/mame/drivers/skullxbo.c index d5249d2dae4..6bf03492e72 100644 --- a/src/mame/drivers/skullxbo.c +++ b/src/mame/drivers/skullxbo.c @@ -56,7 +56,7 @@ static void alpha_row_update(screen_device &screen, int scanline) { int width = screen.width(); attotime period = screen.time_until_pos(screen.vpos() + 6, width * 0.9); - timer_set(screen.machine, period, NULL, 0, irq_gen); + screen.machine->scheduler().timer_set(period, FUNC(irq_gen)); } /* update the playfield and motion objects */ diff --git a/src/mame/drivers/slapshot.c b/src/mame/drivers/slapshot.c index 690eaa0d037..29729fa6198 100644 --- a/src/mame/drivers/slapshot.c +++ b/src/mame/drivers/slapshot.c @@ -182,7 +182,7 @@ static TIMER_CALLBACK( slapshot_interrupt6 ) static INTERRUPT_GEN( slapshot_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), NULL, 0, slapshot_interrupt6); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), FUNC(slapshot_interrupt6)); cpu_set_input_line(device, 5, HOLD_LINE); } diff --git a/src/mame/drivers/snk.c b/src/mame/drivers/snk.c index 2e4a382f13d..624aab2a0b1 100644 --- a/src/mame/drivers/snk.c +++ b/src/mame/drivers/snk.c @@ -372,18 +372,18 @@ static TIMER_CALLBACK( sgladiat_sndirq_update_callback ) static WRITE8_HANDLER( sgladiat_soundlatch_w ) { soundlatch_w(space, offset, data); - timer_call_after_resynch(space->machine, NULL, CMDIRQ_BUSY_ASSERT, sgladiat_sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sgladiat_sndirq_update_callback), CMDIRQ_BUSY_ASSERT); } static READ8_HANDLER( sgladiat_soundlatch_r ) { - timer_call_after_resynch(space->machine, NULL, BUSY_CLEAR, sgladiat_sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sgladiat_sndirq_update_callback), BUSY_CLEAR); return soundlatch_r(space,0); } static READ8_HANDLER( sgladiat_sound_nmi_ack_r ) { - timer_call_after_resynch(space->machine, NULL, CMDIRQ_CLEAR, sgladiat_sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sgladiat_sndirq_update_callback), CMDIRQ_CLEAR); return 0xff; } @@ -460,13 +460,13 @@ static TIMER_CALLBACK( sndirq_update_callback ) static void ymirq_callback_1(device_t *device, int irq) { if (irq) - timer_call_after_resynch(device->machine, NULL, YM1IRQ_ASSERT, sndirq_update_callback); + device->machine->scheduler().synchronize(FUNC(sndirq_update_callback), YM1IRQ_ASSERT); } static void ymirq_callback_2(device_t *device, int irq) { if (irq) - timer_call_after_resynch(device->machine, NULL, YM2IRQ_ASSERT, sndirq_update_callback); + device->machine->scheduler().synchronize(FUNC(sndirq_update_callback), YM2IRQ_ASSERT); } @@ -495,7 +495,7 @@ static const y8950_interface y8950_config_2 = static WRITE8_HANDLER( snk_soundlatch_w ) { soundlatch_w(space, offset, data); - timer_call_after_resynch(space->machine, NULL, CMDIRQ_BUSY_ASSERT, sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sndirq_update_callback), CMDIRQ_BUSY_ASSERT); } static CUSTOM_INPUT( snk_sound_busy ) @@ -517,29 +517,29 @@ static READ8_HANDLER( snk_sound_status_r ) static WRITE8_HANDLER( snk_sound_status_w ) { if (~data & 0x10) // ack YM1 irq - timer_call_after_resynch(space->machine, NULL, YM1IRQ_CLEAR, sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sndirq_update_callback), YM1IRQ_CLEAR); if (~data & 0x20) // ack YM2 irq - timer_call_after_resynch(space->machine, NULL, YM2IRQ_CLEAR, sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sndirq_update_callback), YM2IRQ_CLEAR); if (~data & 0x40) // clear busy flag - timer_call_after_resynch(space->machine, NULL, BUSY_CLEAR, sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sndirq_update_callback), BUSY_CLEAR); if (~data & 0x80) // ack command from main cpu - timer_call_after_resynch(space->machine, NULL, CMDIRQ_CLEAR, sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sndirq_update_callback), CMDIRQ_CLEAR); } static READ8_HANDLER( tnk3_cmdirq_ack_r ) { - timer_call_after_resynch(space->machine, NULL, CMDIRQ_CLEAR, sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sndirq_update_callback), CMDIRQ_CLEAR); return 0xff; } static READ8_HANDLER( tnk3_ymirq_ack_r ) { - timer_call_after_resynch(space->machine, NULL, YM1IRQ_CLEAR, sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sndirq_update_callback), YM1IRQ_CLEAR); return 0xff; } @@ -547,7 +547,7 @@ static READ8_HANDLER( tnk3_busy_clear_r ) { // it's uncertain whether the latch should be cleared here or when it's read soundlatch_clear_w(space, 0, 0); - timer_call_after_resynch(space->machine, NULL, BUSY_CLEAR, sndirq_update_callback); + space->machine->scheduler().synchronize(FUNC(sndirq_update_callback), BUSY_CLEAR); return 0xff; } diff --git a/src/mame/drivers/sothello.c b/src/mame/drivers/sothello.c index cf5533237bb..d8471f2c511 100644 --- a/src/mame/drivers/sothello.c +++ b/src/mame/drivers/sothello.c @@ -84,14 +84,14 @@ static TIMER_CALLBACK( subcpu_resume ) static READ8_HANDLER( subcpu_halt_set ) { - timer_call_after_resynch(space->machine, NULL, 0, subcpu_suspend); + space->machine->scheduler().synchronize(FUNC(subcpu_suspend)); subcpu_status|=2; return 0; } static READ8_HANDLER( subcpu_halt_clear ) { - timer_call_after_resynch(space->machine,NULL, 0, subcpu_resume); + space->machine->scheduler().synchronize(FUNC(subcpu_resume)); subcpu_status&=~1; subcpu_status&=~2; return 0; diff --git a/src/mame/drivers/spacefb.c b/src/mame/drivers/spacefb.c index 2b713d7056a..c6035b5cfda 100644 --- a/src/mame/drivers/spacefb.c +++ b/src/mame/drivers/spacefb.c @@ -147,7 +147,7 @@ static TIMER_CALLBACK( interrupt_callback ) static void create_interrupt_timer(running_machine *machine) { - interrupt_timer = timer_alloc(machine, interrupt_callback, NULL); + interrupt_timer = machine->scheduler().timer_alloc(FUNC(interrupt_callback)); } diff --git a/src/mame/drivers/sprint4.c b/src/mame/drivers/sprint4.c index ed850873489..1edf8ef6b61 100644 --- a/src/mame/drivers/sprint4.c +++ b/src/mame/drivers/sprint4.c @@ -107,14 +107,14 @@ static TIMER_CALLBACK( nmi_callback ) if (input_port_read(machine, "IN0") & 0x40) cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, nmi_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(nmi_callback), scanline); } static MACHINE_RESET( sprint4 ) { sprint4_state *state = machine->driver_data<sprint4_state>(); - timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, nmi_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(32), FUNC(nmi_callback), 32); memset(state->steer_FF1, 0, sizeof state->steer_FF1); memset(state->steer_FF2, 0, sizeof state->steer_FF2); diff --git a/src/mame/drivers/ssfindo.c b/src/mame/drivers/ssfindo.c index 36ee4dda8a0..2caf82cca3b 100644 --- a/src/mame/drivers/ssfindo.c +++ b/src/mame/drivers/ssfindo.c @@ -692,15 +692,15 @@ ROM_END static DRIVER_INIT(ssfindo) { flashType=0; - PS7500timer0 = timer_alloc(machine, PS7500_Timer0_callback, NULL); - PS7500timer1 = timer_alloc(machine, PS7500_Timer1_callback, NULL); + PS7500timer0 = machine->scheduler().timer_alloc(FUNC(PS7500_Timer0_callback)); + PS7500timer1 = machine->scheduler().timer_alloc(FUNC(PS7500_Timer1_callback)); } static DRIVER_INIT(ppcar) { flashType=1; - PS7500timer0 = timer_alloc(machine, PS7500_Timer0_callback, NULL); - PS7500timer1 = timer_alloc(machine, PS7500_Timer1_callback, NULL); + PS7500timer0 = machine->scheduler().timer_alloc(FUNC(PS7500_Timer0_callback)); + PS7500timer1 = machine->scheduler().timer_alloc(FUNC(PS7500_Timer1_callback)); } GAME( 1999, ssfindo, 0, ssfindo, ssfindo, ssfindo, ROT0, "Icarus", "See See Find Out", GAME_NO_SOUND ) diff --git a/src/mame/drivers/sslam.c b/src/mame/drivers/sslam.c index ad797d01c64..2be67118333 100644 --- a/src/mame/drivers/sslam.c +++ b/src/mame/drivers/sslam.c @@ -938,7 +938,7 @@ static DRIVER_INIT( sslam ) state_save_register_global(machine, state->bar); state_save_register_global(machine, state->snd_bank); - state->music_timer = timer_alloc(machine, music_playback, NULL); + state->music_timer = machine->scheduler().timer_alloc(FUNC(music_playback)); } static DRIVER_INIT( powerbls ) diff --git a/src/mame/drivers/ssv.c b/src/mame/drivers/ssv.c index b6d48378e86..309745031c1 100644 --- a/src/mame/drivers/ssv.c +++ b/src/mame/drivers/ssv.c @@ -933,7 +933,7 @@ static WRITE32_HANDLER(latch32_w) if(!offset) state->latches[2]|=1; COMBINE_DATA(&state->latches[offset]); - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); } static READ16_HANDLER(latch16_r) @@ -952,7 +952,7 @@ static WRITE16_HANDLER(latch16_w) if(!offset) state->latches[2]|=2; state->latches[offset]=data; - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); } static ADDRESS_MAP_START( jsk_map, ADDRESS_SPACE_PROGRAM, 16 ) diff --git a/src/mame/drivers/st0016.c b/src/mame/drivers/st0016.c index b7c2e6e9533..fe11782b9f3 100644 --- a/src/mame/drivers/st0016.c +++ b/src/mame/drivers/st0016.c @@ -111,7 +111,7 @@ static WRITE32_HANDLER(latch32_w) if(!offset) latches[2]|=1; COMBINE_DATA(&latches[offset]); - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); } static READ8_HANDLER(latch8_r) @@ -126,7 +126,7 @@ static WRITE8_HANDLER(latch8_w) if(!offset) latches[2]|=2; latches[offset]=data; - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); } static ADDRESS_MAP_START( v810_mem,ADDRESS_SPACE_PROGRAM, 32 ) diff --git a/src/mame/drivers/stv.c b/src/mame/drivers/stv.c index 5a697d08f55..6742c83ab67 100644 --- a/src/mame/drivers/stv.c +++ b/src/mame/drivers/stv.c @@ -1531,7 +1531,7 @@ static void dma_direct_lv0(address_space *space) if(LOG_SCU) logerror("DMA transfer END\n"); /*TODO: timing of this*/ - timer_set(space->machine, attotime::from_usec(300), NULL, 0, dma_lv0_ended); + space->machine->scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv0_ended)); if(scu_add_tmp & 0x80000000) { @@ -1632,7 +1632,7 @@ static void dma_direct_lv1(address_space *space) if(LOG_SCU) logerror("DMA transfer END\n"); - timer_set(space->machine, attotime::from_usec(300), NULL, 0, dma_lv1_ended); + space->machine->scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv1_ended)); if(scu_add_tmp & 0x80000000) { @@ -1733,7 +1733,7 @@ static void dma_direct_lv2(address_space *space) if(LOG_SCU) logerror("DMA transfer END\n"); - timer_set(space->machine, attotime::from_usec(300), NULL, 0, dma_lv2_ended); + space->machine->scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv2_ended)); if(scu_add_tmp & 0x80000000) { @@ -1808,7 +1808,7 @@ static void dma_indirect_lv0(address_space *space) }while(job_done == 0); - timer_set(space->machine, attotime::from_usec(300), NULL, 0, dma_lv0_ended); + space->machine->scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv0_ended)); } static void dma_indirect_lv1(address_space *space) @@ -1877,7 +1877,7 @@ static void dma_indirect_lv1(address_space *space) }while(job_done == 0); - timer_set(space->machine, attotime::from_usec(300), NULL, 0, dma_lv1_ended); + space->machine->scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv1_ended)); } static void dma_indirect_lv2(address_space *space) @@ -1945,7 +1945,7 @@ static void dma_indirect_lv2(address_space *space) }while(job_done == 0); - timer_set(space->machine, attotime::from_usec(300), NULL, 0, dma_lv2_ended); + space->machine->scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv2_ended)); } @@ -2633,7 +2633,7 @@ static MACHINE_START( stv ) smpc_ram[0x2d] = DectoBCD(systime.local_time.minute); smpc_ram[0x2f] = DectoBCD(systime.local_time.second); - stv_rtc_timer = timer_alloc(machine, stv_rtc_increment, 0); + stv_rtc_timer = machine->scheduler().timer_alloc(FUNC(stv_rtc_increment)); } /* @@ -2816,7 +2816,7 @@ static INTERRUPT_GEN( stv_interrupt ) /*TODO: timing of this one (related to the VDP1 speed)*/ /* (NOTE: value shouldn't be at h_sync/v_sync position (will break shienryu))*/ - timer_set(device->machine, device->machine->primary_screen->time_until_pos(0), NULL, 0, vdp1_irq); + device->machine->scheduler().timer_set(device->machine->primary_screen->time_until_pos(0), FUNC(vdp1_irq)); } static MACHINE_RESET( stv ) diff --git a/src/mame/drivers/superqix.c b/src/mame/drivers/superqix.c index 9e6d4bca2f1..67499629696 100644 --- a/src/mame/drivers/superqix.c +++ b/src/mame/drivers/superqix.c @@ -199,7 +199,7 @@ static TIMER_CALLBACK( mcu_acknowledge_callback ) static READ8_HANDLER( mcu_acknowledge_r ) { - timer_call_after_resynch(space->machine, NULL, 0, mcu_acknowledge_callback); + space->machine->scheduler().synchronize(FUNC(mcu_acknowledge_callback)); return 0; } @@ -463,7 +463,7 @@ logerror("%04x: z80 reads command %02x\n",cpu_get_pc(space->cpu),state->from_z80 break; case 0x5: // answer to Z80 - timer_call_after_resynch(space->machine, NULL, state->portB_out, delayed_mcu_z80_w); + space->machine->scheduler().synchronize(FUNC(delayed_mcu_z80_w), state->portB_out); break; case 0x6: @@ -479,7 +479,7 @@ logerror("%04x: z80 reads command %02x\n",cpu_get_pc(space->cpu),state->from_z80 static WRITE8_HANDLER( hotsmash_z80_mcu_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_z80_mcu_w); + space->machine->scheduler().synchronize(FUNC(delayed_z80_mcu_w), data); } static READ8_HANDLER(hotsmash_from_mcu_r) diff --git a/src/mame/drivers/suprridr.c b/src/mame/drivers/suprridr.c index 49f7ea1a112..7f8c3c546cd 100644 --- a/src/mame/drivers/suprridr.c +++ b/src/mame/drivers/suprridr.c @@ -124,7 +124,7 @@ static TIMER_CALLBACK( delayed_sound_w ) static WRITE8_HANDLER( sound_data_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_sound_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_w), data); } diff --git a/src/mame/drivers/taito_b.c b/src/mame/drivers/taito_b.c index eef01d19bcc..c8507e8058c 100644 --- a/src/mame/drivers/taito_b.c +++ b/src/mame/drivers/taito_b.c @@ -194,7 +194,7 @@ static TIMER_CALLBACK( rsaga2_interrupt2 ) static INTERRUPT_GEN( rastansaga2_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(5000), NULL, 0, rsaga2_interrupt2); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(5000), FUNC(rsaga2_interrupt2)); cpu_set_input_line(device, 4, HOLD_LINE); } @@ -207,7 +207,7 @@ static TIMER_CALLBACK( crimec_interrupt3 ) static INTERRUPT_GEN( crimec_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(5000), NULL, 0, crimec_interrupt3); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(5000), FUNC(crimec_interrupt3)); cpu_set_input_line(device, 5, HOLD_LINE); } @@ -220,7 +220,7 @@ static TIMER_CALLBACK( hitice_interrupt6 ) static INTERRUPT_GEN( hitice_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(5000), NULL, 0, hitice_interrupt6); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(5000), FUNC(hitice_interrupt6)); cpu_set_input_line(device, 4, HOLD_LINE); } @@ -233,7 +233,7 @@ static TIMER_CALLBACK( rambo3_interrupt1 ) static INTERRUPT_GEN( rambo3_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(5000), NULL, 0, rambo3_interrupt1); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(5000), FUNC(rambo3_interrupt1)); cpu_set_input_line(device, 6, HOLD_LINE); } @@ -246,7 +246,7 @@ static TIMER_CALLBACK( pbobble_interrupt5 ) static INTERRUPT_GEN( pbobble_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(5000), NULL, 0, pbobble_interrupt5); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(5000), FUNC(pbobble_interrupt5)); cpu_set_input_line(device, 3, HOLD_LINE); } @@ -258,7 +258,7 @@ static TIMER_CALLBACK( viofight_interrupt1 ) static INTERRUPT_GEN( viofight_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(5000), NULL, 0, viofight_interrupt1); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(5000), FUNC(viofight_interrupt1)); cpu_set_input_line(device, 4, HOLD_LINE); } @@ -270,7 +270,7 @@ static TIMER_CALLBACK( masterw_interrupt4 ) static INTERRUPT_GEN( masterw_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(5000), NULL, 0, masterw_interrupt4); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(5000), FUNC(masterw_interrupt4)); cpu_set_input_line(device, 5, HOLD_LINE); } @@ -282,7 +282,7 @@ static TIMER_CALLBACK( silentd_interrupt4 ) static INTERRUPT_GEN( silentd_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(5000), NULL, 0, silentd_interrupt4); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(5000), FUNC(silentd_interrupt4)); cpu_set_input_line(device, 6, HOLD_LINE); } @@ -294,7 +294,7 @@ static TIMER_CALLBACK( selfeena_interrupt4 ) static INTERRUPT_GEN( selfeena_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(5000), NULL, 0, selfeena_interrupt4); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(5000), FUNC(selfeena_interrupt4)); cpu_set_input_line(device, 6, HOLD_LINE); } @@ -306,7 +306,7 @@ static TIMER_CALLBACK( sbm_interrupt5 )//4 static INTERRUPT_GEN( sbm_interrupt )//5 { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(10000), NULL, 0, sbm_interrupt5); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(10000), FUNC(sbm_interrupt5)); cpu_set_input_line(device, 4, HOLD_LINE); } diff --git a/src/mame/drivers/taito_f2.c b/src/mame/drivers/taito_f2.c index e177166221f..07272f13d8b 100644 --- a/src/mame/drivers/taito_f2.c +++ b/src/mame/drivers/taito_f2.c @@ -583,7 +583,7 @@ static TIMER_CALLBACK( taitof2_interrupt6 ) static INTERRUPT_GEN( taitof2_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(500), NULL, 0, taitof2_interrupt6); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(500), FUNC(taitof2_interrupt6)); cpu_set_input_line(device, 5, HOLD_LINE); } diff --git a/src/mame/drivers/taito_f3.c b/src/mame/drivers/taito_f3.c index a19a9e16a80..4326585f99f 100644 --- a/src/mame/drivers/taito_f3.c +++ b/src/mame/drivers/taito_f3.c @@ -363,7 +363,7 @@ static TIMER_CALLBACK( f3_interrupt3 ) static INTERRUPT_GEN( f3_interrupt2 ) { cpu_set_input_line(device, 2, HOLD_LINE); // vblank - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(10000), NULL, 0, f3_interrupt3); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(10000), FUNC(f3_interrupt3)); } static SOUND_RESET( f3 ) diff --git a/src/mame/drivers/taito_z.c b/src/mame/drivers/taito_z.c index 9c34ddfa316..7bdb9f94e39 100644 --- a/src/mame/drivers/taito_z.c +++ b/src/mame/drivers/taito_z.c @@ -965,7 +965,7 @@ static INTERRUPT_GEN( sci_interrupt ) state->sci_int6 = !state->sci_int6; if (state->sci_int6) - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), NULL, 0, taitoz_interrupt6); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), FUNC(taitoz_interrupt6)); cpu_set_input_line(device, 4, HOLD_LINE); } @@ -983,7 +983,7 @@ static INTERRUPT_GEN( dblaxle_interrupt ) state->dblaxle_int6 = !state->dblaxle_int6; if (state->dblaxle_int6) - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), NULL, 0, taitoz_interrupt6); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), FUNC(taitoz_interrupt6)); cpu_set_input_line(device, 4, HOLD_LINE); } @@ -991,7 +991,7 @@ static INTERRUPT_GEN( dblaxle_interrupt ) static INTERRUPT_GEN( dblaxle_cpub_interrupt ) { // Unsure how many int6's per frame - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), NULL, 0, taitoz_interrupt6); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), FUNC(taitoz_interrupt6)); cpu_set_input_line(device, 4, HOLD_LINE); } @@ -1208,7 +1208,7 @@ static WRITE16_HANDLER( bshark_stick_w ) but we don't want CPUA to have an int6 before int4 is over (?) */ - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(10000), NULL, 0, taitoz_interrupt6); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(10000), FUNC(taitoz_interrupt6)); } @@ -1293,7 +1293,7 @@ static WRITE16_HANDLER( spacegun_lightgun_w ) Four lightgun interrupts happen before the collected coords are moved to shared ram where CPUA can use them. */ - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(10000), NULL, 0, taitoz_cpub_interrupt5); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(10000), FUNC(taitoz_cpub_interrupt5)); } static WRITE16_HANDLER( spacegun_gun_output_w ) diff --git a/src/mame/drivers/taitogn.c b/src/mame/drivers/taitogn.c index 280cf667aaf..2cc15ab5ef1 100644 --- a/src/mame/drivers/taitogn.c +++ b/src/mame/drivers/taitogn.c @@ -884,7 +884,7 @@ static DRIVER_INIT( coh3002t ) znsec_init(0, tt10); znsec_init(1, tt16); psx_sio_install_handler(machine, 0, sio_pad_handler); - state->dip_timer = timer_alloc( machine, dip_timer_fired, NULL ); + state->dip_timer = machine->scheduler().timer_alloc( FUNC(dip_timer_fired), NULL ); memset(state->cis, 0xff, 512); if (get_disk_handle(machine, "card") != NULL) diff --git a/src/mame/drivers/tankbust.c b/src/mame/drivers/tankbust.c index 5c1497f46ab..90f08d9b240 100644 --- a/src/mame/drivers/tankbust.c +++ b/src/mame/drivers/tankbust.c @@ -32,7 +32,7 @@ static TIMER_CALLBACK( soundlatch_callback ) static WRITE8_HANDLER( tankbust_soundlatch_w ) { - timer_call_after_resynch(space->machine, NULL, data,soundlatch_callback); + space->machine->scheduler().synchronize(FUNC(soundlatch_callback), data); } static READ8_DEVICE_HANDLER( tankbust_soundlatch_r ) @@ -81,7 +81,7 @@ static WRITE8_HANDLER( tankbust_e0xx_w ) break; case 1: /* 0xe001 (value 0 then 1) written right after the soundlatch_w */ - timer_call_after_resynch(space->machine, NULL, data,soundirqline_callback); + space->machine->scheduler().synchronize(FUNC(soundirqline_callback), data); break; case 2: /* 0xe002 coin counter */ diff --git a/src/mame/drivers/tehkanwc.c b/src/mame/drivers/tehkanwc.c index d5594e9a224..9d2f4a3c310 100644 --- a/src/mame/drivers/tehkanwc.c +++ b/src/mame/drivers/tehkanwc.c @@ -158,7 +158,7 @@ static WRITE8_HANDLER( sound_answer_w ) /* in Gridiron, the sound CPU goes in a tight loop after the self test, */ /* probably waiting to be reset by a watchdog */ - if (cpu_get_pc(space->cpu) == 0x08bc) timer_set(space->machine, attotime::from_seconds(1), NULL, 0, reset_callback); + if (cpu_get_pc(space->cpu) == 0x08bc) space->machine->scheduler().timer_set(attotime::from_seconds(1), FUNC(reset_callback)); } diff --git a/src/mame/drivers/tetrisp2.c b/src/mame/drivers/tetrisp2.c index 51e1be5f190..0beeeefe092 100644 --- a/src/mame/drivers/tetrisp2.c +++ b/src/mame/drivers/tetrisp2.c @@ -1044,8 +1044,8 @@ static TIMER_CALLBACK( rockn_timer_sub_level1_callback ) static void init_rockn_timer(running_machine *machine) { - timer_pulse(machine, attotime::from_msec(32), NULL, 0, rockn_timer_level1_callback); - rockn_timer_l4 = timer_alloc(machine, rockn_timer_level4_callback, NULL); + machine->scheduler().timer_pulse(attotime::from_msec(32), FUNC(rockn_timer_level1_callback)); + rockn_timer_l4 = machine->scheduler().timer_alloc(FUNC(rockn_timer_level4_callback)); state_save_register_global_array(machine, tetrisp2_systemregs); state_save_register_global_array(machine, rocknms_sub_systemregs); @@ -1076,8 +1076,8 @@ static DRIVER_INIT( rocknms ) { init_rockn_timer(machine); - timer_pulse(machine, attotime::from_msec(32), NULL, 0, rockn_timer_sub_level1_callback); - rockn_timer_sub_l4 = timer_alloc(machine, rockn_timer_sub_level4_callback, NULL); + machine->scheduler().timer_pulse(attotime::from_msec(32), FUNC(rockn_timer_sub_level1_callback)); + rockn_timer_sub_l4 = machine->scheduler().timer_alloc(FUNC(rockn_timer_sub_level4_callback)); rockn_protectdata = 3; diff --git a/src/mame/drivers/thayers.c b/src/mame/drivers/thayers.c index c50e6fa1067..fdcc23053da 100644 --- a/src/mame/drivers/thayers.c +++ b/src/mame/drivers/thayers.c @@ -64,7 +64,7 @@ static WRITE8_HANDLER( intrq_w ) cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_IRQ0, HOLD_LINE); - timer_set(space->machine, attotime::from_usec(8250), NULL, 0, intrq_tick); + space->machine->scheduler().timer_set(attotime::from_usec(8250), FUNC(intrq_tick)); } static READ8_HANDLER( irqstate_r ) @@ -459,11 +459,11 @@ static WRITE8_HANDLER( ssi263_register_w ) case 0: case 1: // phoneme timing response - timer_set(space->machine, attotime::from_usec(phoneme_time), NULL, 0, ssi263_phoneme_tick); + space->machine->scheduler().timer_set(attotime::from_usec(phoneme_time), FUNC(ssi263_phoneme_tick)); break; case 2: // frame timing response - timer_set(space->machine, attotime::from_usec(frame_time), NULL, 0, ssi263_phoneme_tick); + space->machine->scheduler().timer_set(attotime::from_usec(frame_time), FUNC(ssi263_phoneme_tick)); break; case 3: // disable A/_R output diff --git a/src/mame/drivers/thunderx.c b/src/mame/drivers/thunderx.c index 2964f0f226a..ac30d67dcb8 100644 --- a/src/mame/drivers/thunderx.c +++ b/src/mame/drivers/thunderx.c @@ -313,7 +313,7 @@ static WRITE8_HANDLER( thunderx_1f98_w ) calculate_collisions(space->machine); /* 100 cycle delay is arbitrary */ - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(100), NULL, 0, thunderx_firq_callback); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(100), FUNC(thunderx_firq_callback)); } state->_1f98_data = data; diff --git a/src/mame/drivers/tickee.c b/src/mame/drivers/tickee.c index 168859a80ef..2c88fa7c1bd 100644 --- a/src/mame/drivers/tickee.c +++ b/src/mame/drivers/tickee.c @@ -101,13 +101,13 @@ static TIMER_CALLBACK( setup_gun_interrupts ) /* generate interrupts for player 1's gun */ get_crosshair_xy(machine, 0, &beamx, &beamy); - timer_set(machine, machine->primary_screen->time_until_pos(beamy + beamyadd, beamx + beamxadd), NULL, 0, trigger_gun_interrupt); - timer_set(machine, machine->primary_screen->time_until_pos(beamy + beamyadd + 1, beamx + beamxadd), NULL, 0, clear_gun_interrupt); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + beamyadd, beamx + beamxadd), FUNC(trigger_gun_interrupt), 0); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + beamyadd + 1, beamx + beamxadd), FUNC(clear_gun_interrupt), 0); /* generate interrupts for player 2's gun */ get_crosshair_xy(machine, 1, &beamx, &beamy); - timer_set(machine, machine->primary_screen->time_until_pos(beamy + beamyadd, beamx + beamxadd), NULL, 1, trigger_gun_interrupt); - timer_set(machine, machine->primary_screen->time_until_pos(beamy + beamyadd + 1, beamx + beamxadd), NULL, 1, clear_gun_interrupt); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + beamyadd, beamx + beamxadd), FUNC(trigger_gun_interrupt), 1); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + beamyadd + 1, beamx + beamxadd), FUNC(clear_gun_interrupt), 1); } @@ -121,7 +121,7 @@ static TIMER_CALLBACK( setup_gun_interrupts ) static VIDEO_START( tickee ) { /* start a timer going on the first scanline of every frame */ - setup_gun_timer = timer_alloc(machine, setup_gun_interrupts, NULL); + setup_gun_timer = machine->scheduler().timer_alloc(FUNC(setup_gun_interrupts)); timer_adjust_oneshot(setup_gun_timer, machine->primary_screen->time_until_pos(0), 0); } diff --git a/src/mame/drivers/tmmjprd.c b/src/mame/drivers/tmmjprd.c index a0388148294..71ed68d7245 100644 --- a/src/mame/drivers/tmmjprd.c +++ b/src/mame/drivers/tmmjprd.c @@ -396,7 +396,7 @@ static void tmmjprd_do_blit(running_machine *machine) if (!blt_amount) { if(BLITLOG) mame_printf_debug("end of blit list\n"); - timer_set(machine, attotime::from_usec(500), NULL,0,tmmjprd_blit_done); + machine->scheduler().timer_set(attotime::from_usec(500), FUNC(tmmjprd_blit_done)); return; } diff --git a/src/mame/drivers/tmnt.c b/src/mame/drivers/tmnt.c index dcb9ebda5ba..b85f0c11736 100644 --- a/src/mame/drivers/tmnt.c +++ b/src/mame/drivers/tmnt.c @@ -348,7 +348,7 @@ static WRITE8_HANDLER( sound_arm_nmi_w ) tmnt_state *state = space->machine->driver_data<tmnt_state>(); // sound_nmi_enabled = 1; cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE); - timer_set(space->machine, attotime::from_usec(50), NULL, 0, nmi_callback); /* kludge until the K053260 is emulated correctly */ + space->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(nmi_callback)); /* kludge until the K053260 is emulated correctly */ } diff --git a/src/mame/drivers/toaplan2.c b/src/mame/drivers/toaplan2.c index c84a8fdb257..2d769362c44 100644 --- a/src/mame/drivers/toaplan2.c +++ b/src/mame/drivers/toaplan2.c @@ -542,7 +542,7 @@ static TIMER_CALLBACK( toaplan2_raise_irq ) static void toaplan2_vblank_irq(running_machine *machine, int irq_line) { /* the IRQ appears to fire at line 0xe6 */ - timer_set(machine, machine->primary_screen->time_until_pos(0xe6), NULL, irq_line, toaplan2_raise_irq); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(0xe6), FUNC(toaplan2_raise_irq), irq_line); } static INTERRUPT_GEN( toaplan2_vblank_irq1 ) { toaplan2_vblank_irq(device->machine, 1); } diff --git a/src/mame/drivers/topspeed.c b/src/mame/drivers/topspeed.c index 276ba6a1f38..7aacf44bbc9 100644 --- a/src/mame/drivers/topspeed.c +++ b/src/mame/drivers/topspeed.c @@ -303,14 +303,14 @@ static TIMER_CALLBACK( topspeed_cpub_interrupt6 ) static INTERRUPT_GEN( topspeed_interrupt ) { /* Unsure how many int6's per frame */ - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), NULL, 0, topspeed_interrupt6); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), FUNC(topspeed_interrupt6)); cpu_set_input_line(device, 5, HOLD_LINE); } static INTERRUPT_GEN( topspeed_cpub_interrupt ) { /* Unsure how many int6's per frame */ - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), NULL, 0, topspeed_cpub_interrupt6); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(200000 - 500), FUNC(topspeed_cpub_interrupt6)); cpu_set_input_line(device, 5, HOLD_LINE); } diff --git a/src/mame/drivers/toypop.c b/src/mame/drivers/toypop.c index 75f5cd44876..0321a03bf32 100644 --- a/src/mame/drivers/toypop.c +++ b/src/mame/drivers/toypop.c @@ -110,13 +110,13 @@ static INTERRUPT_GEN( toypop_main_interrupt ) // so don't replace with cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); if (!namcoio_read_reset_line(namcoio_0)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 0, namcoio_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(namcoio_run)); if (!namcoio_read_reset_line(namcoio_1)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 1, namcoio_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(namcoio_run), 1); if (!namcoio_read_reset_line(namcoio_2)) /* give the cpu a tiny bit of time to write the command before processing it */ - timer_set(device->machine, attotime::from_usec(50), NULL, 2, namcoio_run); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(namcoio_run), 2); } @@ -154,7 +154,7 @@ static MACHINE_RESET( toypop ) { /* we must do this on a timer in order to have it take effect */ /* otherwise, the reset process will override our changes */ - timer_call_after_resynch(machine, NULL, 0, disable_interrupts); + machine->scheduler().synchronize(FUNC(disable_interrupts)); } static INTERRUPT_GEN( toypop_m68000_interrupt ) diff --git a/src/mame/drivers/trucocl.c b/src/mame/drivers/trucocl.c index 6ec64428635..1008e4f8cc0 100644 --- a/src/mame/drivers/trucocl.c +++ b/src/mame/drivers/trucocl.c @@ -76,7 +76,7 @@ static WRITE8_DEVICE_HANDLER( audio_dac_w ) dac_data_w( device, rom[dac_address+cur_dac_address_index] ); - timer_set( device->machine, attotime::from_hz( 16000 ), NULL, 0, dac_irq ); + device->machine->scheduler().timer_set( attotime::from_hz( 16000 ), FUNC(dac_irq )); } static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) diff --git a/src/mame/drivers/trvquest.c b/src/mame/drivers/trvquest.c index 85e774ccfa2..bdfa833c17a 100644 --- a/src/mame/drivers/trvquest.c +++ b/src/mame/drivers/trvquest.c @@ -160,7 +160,7 @@ static void via_irq( device_t *device, int state ) /* Kaos sits in a tight loop polling the VIA irq flags register, but that register is cleared by the irq handler. Therefore, I wait a bit before triggering the irq to leave time for the program to see the flag change. */ - timer_set(device->machine, attotime::from_usec(50), NULL, state, via_irq_delayed); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(via_irq_delayed), state); } diff --git a/src/mame/drivers/tubep.c b/src/mame/drivers/tubep.c index 89e238dd026..83c45d47a46 100644 --- a/src/mame/drivers/tubep.c +++ b/src/mame/drivers/tubep.c @@ -349,7 +349,7 @@ static void tubep_setup_save_state(running_machine *machine) static MACHINE_START( tubep ) { /* Create interrupt timer */ - interrupt_timer = timer_alloc(machine, tubep_scanline_callback, NULL); + interrupt_timer = machine->scheduler().timer_alloc(FUNC(tubep_scanline_callback)); tubep_setup_save_state(machine); } @@ -512,7 +512,7 @@ static TIMER_CALLBACK( rjammer_scanline_callback ) static MACHINE_START( rjammer ) { /* Create interrupt timer */ - interrupt_timer = timer_alloc(machine, rjammer_scanline_callback, NULL); + interrupt_timer = machine->scheduler().timer_alloc(FUNC(rjammer_scanline_callback)); tubep_setup_save_state(machine); } diff --git a/src/mame/drivers/tugboat.c b/src/mame/drivers/tugboat.c index 1887f475af5..6e5608ebdbb 100644 --- a/src/mame/drivers/tugboat.c +++ b/src/mame/drivers/tugboat.c @@ -188,12 +188,12 @@ static const pia6821_interface pia1_intf = static TIMER_CALLBACK( interrupt_gen ) { cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); - timer_set(machine, machine->primary_screen->frame_period(), NULL, 0, interrupt_gen); + machine->scheduler().timer_set(machine->primary_screen->frame_period(), FUNC(interrupt_gen)); } static MACHINE_RESET( tugboat ) { - timer_set(machine, machine->primary_screen->time_until_pos(30*8+4), NULL, 0, interrupt_gen); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(30*8+4), FUNC(interrupt_gen)); } diff --git a/src/mame/drivers/turbo.c b/src/mame/drivers/turbo.c index 53804841484..ad72ebe8d08 100644 --- a/src/mame/drivers/turbo.c +++ b/src/mame/drivers/turbo.c @@ -727,7 +727,7 @@ static WRITE8_DEVICE_HANDLER( buckrog_ppi8255_0_w ) { /* the port C handshaking signals control the sub CPU IRQ, */ /* so we have to sync whenever we access this PPI */ - timer_call_after_resynch(device->machine, NULL, ((offset & 3) << 8) | (data & 0xff), delayed_ppi8255_w); + device->machine->scheduler().synchronize(FUNC(delayed_ppi8255_w), ((offset & 3) << 8) | (data & 0xff)); } diff --git a/src/mame/drivers/ultratnk.c b/src/mame/drivers/ultratnk.c index f2c6472cc6e..3e25cfe593b 100644 --- a/src/mame/drivers/ultratnk.c +++ b/src/mame/drivers/ultratnk.c @@ -57,13 +57,13 @@ static TIMER_CALLBACK( nmi_callback ) if (input_port_read(machine, "IN0") & 0x40) cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, nmi_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(nmi_callback), scanline); } static MACHINE_RESET( ultratnk ) { - timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, nmi_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(32), FUNC(nmi_callback), 32); } diff --git a/src/mame/drivers/undrfire.c b/src/mame/drivers/undrfire.c index 2575c5bf8b7..d51ca5faf85 100644 --- a/src/mame/drivers/undrfire.c +++ b/src/mame/drivers/undrfire.c @@ -365,7 +365,7 @@ static READ32_HANDLER( unknown_hardware_r ) static WRITE32_HANDLER( unknown_int_req_w ) { /* 10000 cycle delay is arbitrary */ - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(10000), NULL, 0, interrupt5); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(10000), FUNC(interrupt5)); } @@ -456,7 +456,7 @@ static WRITE32_HANDLER( cbombers_adc_w ) { /* One interrupt per input port (4 per frame, though only 2 used). 1000 cycle delay is arbitrary */ - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(1000), NULL, 0, interrupt5); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(1000), FUNC(interrupt5)); } /*********************************************************** diff --git a/src/mame/drivers/vaportra.c b/src/mame/drivers/vaportra.c index 941d90fa4c2..02ad6ad2552 100644 --- a/src/mame/drivers/vaportra.c +++ b/src/mame/drivers/vaportra.c @@ -24,7 +24,7 @@ static WRITE16_HANDLER( vaportra_sound_w ) vaportra_state *state = space->machine->driver_data<vaportra_state>(); /* Force synchronisation between CPUs with fake timer */ - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); soundlatch_w(space, 0, data & 0xff); cpu_set_input_line(state->audiocpu, 0, ASSERT_LINE); } diff --git a/src/mame/drivers/vegas.c b/src/mame/drivers/vegas.c index a87e2172e64..53c1c607b0a 100644 --- a/src/mame/drivers/vegas.c +++ b/src/mame/drivers/vegas.c @@ -531,10 +531,10 @@ static MACHINE_START( vegas ) voodoo = machine->device("voodoo"); /* allocate timers for the NILE */ - timer[0] = timer_alloc(machine, NULL, NULL); - timer[1] = timer_alloc(machine, NULL, NULL); - timer[2] = timer_alloc(machine, nile_timer_callback, NULL); - timer[3] = timer_alloc(machine, nile_timer_callback, NULL); + timer[0] = machine->scheduler().timer_alloc(FUNC(NULL)); + timer[1] = machine->scheduler().timer_alloc(FUNC(NULL)); + timer[2] = machine->scheduler().timer_alloc(FUNC(nile_timer_callback)); + timer[3] = machine->scheduler().timer_alloc(FUNC(nile_timer_callback)); /* identify our sound board */ if (machine->device("dsio") != NULL) diff --git a/src/mame/drivers/vendetta.c b/src/mame/drivers/vendetta.c index 23d08571eaa..07bfe1a2b26 100644 --- a/src/mame/drivers/vendetta.c +++ b/src/mame/drivers/vendetta.c @@ -212,7 +212,7 @@ static WRITE8_HANDLER( z80_arm_nmi_w ) vendetta_state *state = space->machine->driver_data<vendetta_state>(); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE); - timer_set(space->machine, attotime::from_usec(25), NULL, 0, z80_nmi_callback); + space->machine->scheduler().timer_set(attotime::from_usec(25), FUNC(z80_nmi_callback)); } static WRITE8_HANDLER( z80_irq_w ) diff --git a/src/mame/drivers/vicdual.c b/src/mame/drivers/vicdual.c index 5b820e6d949..ba073e8dcf6 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, 4 * field->port->machine->primary_screen->frame_period(), NULL, 0, clear_coin_status); + field->port->machine->scheduler().timer_set(4 * field->port->machine->primary_screen->frame_period(), FUNC(clear_coin_status)); } } diff --git a/src/mame/drivers/videopin.c b/src/mame/drivers/videopin.c index 4aacec471bd..a6eee0ce1e8 100644 --- a/src/mame/drivers/videopin.c +++ b/src/mame/drivers/videopin.c @@ -57,7 +57,7 @@ static TIMER_CALLBACK( interrupt_callback ) if (scanline >= 263) scanline = 32; - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(interrupt_callback), scanline); } @@ -65,7 +65,7 @@ static MACHINE_RESET( videopin ) { device_t *discrete = machine->device("discrete"); - timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, interrupt_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(32), FUNC(interrupt_callback), 32); /* both output latches are cleared on reset */ diff --git a/src/mame/drivers/wgp.c b/src/mame/drivers/wgp.c index d7e1d5f55a6..4b349920d6e 100644 --- a/src/mame/drivers/wgp.c +++ b/src/mame/drivers/wgp.c @@ -477,7 +477,7 @@ static TIMER_CALLBACK( wgp_cpub_interrupt6 ) static INTERRUPT_GEN( wgp_cpub_interrupt ) { - timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(200000-500), NULL, 0, wgp_cpub_interrupt6); + device->machine->scheduler().timer_set(downcast<cpu_device *>(device)->cycles_to_attotime(200000-500), FUNC(wgp_cpub_interrupt6)); cpu_set_input_line(device, 4, HOLD_LINE); } @@ -601,7 +601,7 @@ static WRITE16_HANDLER( wgp_adinput_w ) hardware has got the next a/d conversion ready. We set a token delay of 10000 cycles although our inputs are always ready. */ - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(10000), NULL, 0, wgp_interrupt6); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(10000), FUNC(wgp_interrupt6)); } diff --git a/src/mame/drivers/wheelfir.c b/src/mame/drivers/wheelfir.c index 5548fc0996f..49a2b332a1e 100644 --- a/src/mame/drivers/wheelfir.c +++ b/src/mame/drivers/wheelfir.c @@ -637,7 +637,7 @@ static WRITE16_HANDLER(wheelfir_snd_w) wheelfir_state *state = space->machine->driver_data<wheelfir_state>(); COMBINE_DATA(&state->soundlatch); cputag_set_input_line(space->machine, "subcpu", 1, HOLD_LINE); /* guess, tested also with periodic interrupts and latch clear*/ - timer_call_after_resynch(space->machine, NULL, 0, 0); + space->machine->scheduler().synchronize(FUNC(0)); } static READ16_HANDLER( wheelfir_snd_r ) @@ -721,7 +721,7 @@ INPUT_PORTS_END static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) { wheelfir_state *state = timer.machine->driver_data<wheelfir_state>(); - timer_call_after_resynch(timer.machine, NULL, 0, 0); + timer.machine->scheduler().synchronize(FUNC(0)); state->current_scanline=param; if(state->current_scanline<NUM_SCANLINES) diff --git a/src/mame/drivers/wink.c b/src/mame/drivers/wink.c index 7c5d187e671..736d2afa8ab 100644 --- a/src/mame/drivers/wink.c +++ b/src/mame/drivers/wink.c @@ -98,7 +98,7 @@ static WRITE8_HANDLER( sound_irq_w ) { cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE); //sync with sound cpu (but it still loses some soundlatches...) - //timer_call_after_resynch(space->machine, NULL, 0, NULL); + //space->machine->scheduler().synchronize(); } static ADDRESS_MAP_START( wink_map, ADDRESS_SPACE_PROGRAM, 8 ) diff --git a/src/mame/drivers/wolfpack.c b/src/mame/drivers/wolfpack.c index 686527d224d..212d55fed27 100644 --- a/src/mame/drivers/wolfpack.c +++ b/src/mame/drivers/wolfpack.c @@ -20,13 +20,13 @@ static TIMER_CALLBACK( periodic_callback ) if (scanline >= 262) scanline = 0; - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, periodic_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(periodic_callback), scanline); } static MACHINE_RESET( wolfpack ) { - timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, periodic_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(0), FUNC(periodic_callback)); } diff --git a/src/mame/drivers/xexex.c b/src/mame/drivers/xexex.c index 567c4c16311..7902a0d8734 100644 --- a/src/mame/drivers/xexex.c +++ b/src/mame/drivers/xexex.c @@ -495,7 +495,7 @@ static MACHINE_START( xexex ) state_save_register_global(machine, state->cur_sound_region); state_save_register_postload(machine, xexex_postload, NULL); - state->dmadelay_timer = timer_alloc(machine, dmaend_callback, NULL); + state->dmadelay_timer = machine->scheduler().timer_alloc(FUNC(dmaend_callback)); } static MACHINE_RESET( xexex ) diff --git a/src/mame/drivers/zn.c b/src/mame/drivers/zn.c index d84a8620b0f..8c95c78ed14 100644 --- a/src/mame/drivers/zn.c +++ b/src/mame/drivers/zn.c @@ -482,7 +482,7 @@ static void zn_driver_init( running_machine *machine ) n_game++; } - state->dip_timer = timer_alloc( machine, dip_timer_fired, NULL ); + state->dip_timer = machine->scheduler().timer_alloc( FUNC(dip_timer_fired), NULL ); } static void psx_spu_irq(device_t *device, UINT32 data) diff --git a/src/mame/drivers/zodiack.c b/src/mame/drivers/zodiack.c index 5299cd1fcc5..e120b173107 100644 --- a/src/mame/drivers/zodiack.c +++ b/src/mame/drivers/zodiack.c @@ -143,7 +143,7 @@ static MACHINE_RESET( zodiack ) zodiack_state *state = machine->driver_data<zodiack_state>(); /* we must start with NMI interrupts disabled */ - timer_call_after_resynch(machine, NULL, 0, interrupt_disable); + machine->scheduler().synchronize(FUNC(interrupt_disable)); state->sound_nmi_enabled = FALSE; } diff --git a/src/mame/drivers/zr107.c b/src/mame/drivers/zr107.c index ae33fc94c1d..f27ec8c97ec 100644 --- a/src/mame/drivers/zr107.c +++ b/src/mame/drivers/zr107.c @@ -677,7 +677,7 @@ static void sound_irq_callback( running_machine *machine, int irq ) int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2; cputag_set_input_line(machine, "audiocpu", line, ASSERT_LINE); - timer_set(machine, attotime::from_usec(1), NULL, line, irq_off); + machine->scheduler().timer_set(attotime::from_usec(1), FUNC(irq_off), line); } static const k056800_interface zr107_k056800_interface = diff --git a/src/mame/machine/amiga.c b/src/mame/machine/amiga.c index 805057fd113..8ac30b7b2a3 100644 --- a/src/mame/machine/amiga.c +++ b/src/mame/machine/amiga.c @@ -251,8 +251,8 @@ void amiga_machine_config(running_machine *machine, const amiga_machine_interfac } /* setup the timers */ - state->irq_timer = timer_alloc(machine, amiga_irq_proc, NULL); - state->blitter_timer = timer_alloc(machine, amiga_blitter_proc, NULL); + state->irq_timer = machine->scheduler().timer_alloc(FUNC(amiga_irq_proc)); + state->blitter_timer = machine->scheduler().timer_alloc(FUNC(amiga_blitter_proc)); state->sound_device = machine->device("amiga"); } @@ -297,7 +297,7 @@ MACHINE_RESET( amiga ) (*state->intf->reset_callback)(machine); /* start the scanline timer */ - timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, scanline_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(0), FUNC(scanline_callback)); } @@ -346,7 +346,7 @@ static TIMER_CALLBACK( scanline_callback ) /* set timer for next line */ scanline = (scanline + 1) % machine->primary_screen->height(); - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, scanline_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(scanline_callback), scanline); } @@ -1281,7 +1281,7 @@ WRITE16_HANDLER( amiga_custom_w ) if (state->intf->serdat_w != NULL) (*state->intf->serdat_w)(space->machine, data); CUSTOM_REG(REG_SERDATR) &= ~0x3000; - timer_set(space->machine, amiga_get_serial_char_period(space->machine), NULL, 0, finish_serial_write); + space->machine->scheduler().timer_set(amiga_get_serial_char_period(space->machine), FUNC(finish_serial_write)); break; case REG_BLTSIZE: diff --git a/src/mame/machine/archimds.c b/src/mame/machine/archimds.c index eccbef49321..a2f75902f94 100644 --- a/src/mame/machine/archimds.c +++ b/src/mame/machine/archimds.c @@ -231,20 +231,20 @@ void archimedes_init(running_machine *machine) { memc_pagesize = 0; - vbl_timer = timer_alloc(machine, vidc_vblank, NULL); + vbl_timer = machine->scheduler().timer_alloc(FUNC(vidc_vblank)); timer_adjust_oneshot(vbl_timer, attotime::never, 0); - timer[0] = timer_alloc(machine, ioc_timer, NULL); - timer[1] = timer_alloc(machine, ioc_timer, NULL); - timer[2] = timer_alloc(machine, ioc_timer, NULL); - timer[3] = timer_alloc(machine, ioc_timer, NULL); + timer[0] = machine->scheduler().timer_alloc(FUNC(ioc_timer)); + timer[1] = machine->scheduler().timer_alloc(FUNC(ioc_timer)); + timer[2] = machine->scheduler().timer_alloc(FUNC(ioc_timer)); + timer[3] = machine->scheduler().timer_alloc(FUNC(ioc_timer)); timer_adjust_oneshot(timer[0], attotime::never, 0); timer_adjust_oneshot(timer[1], attotime::never, 0); timer_adjust_oneshot(timer[2], attotime::never, 0); timer_adjust_oneshot(timer[3], attotime::never, 0); - vid_timer = timer_alloc(machine, vidc_video_tick, NULL); - snd_timer = timer_alloc(machine, vidc_audio_tick, NULL); + vid_timer = machine->scheduler().timer_alloc(FUNC(vidc_video_tick)); + snd_timer = machine->scheduler().timer_alloc(FUNC(vidc_audio_tick)); timer_adjust_oneshot(snd_timer, attotime::never, 0); } diff --git a/src/mame/machine/arkanoid.c b/src/mame/machine/arkanoid.c index b0a63292c25..53a40441455 100644 --- a/src/mame/machine/arkanoid.c +++ b/src/mame/machine/arkanoid.c @@ -34,7 +34,7 @@ static TIMER_CALLBACK( test ) WRITE8_HANDLER( arkanoid_Z80_mcu_w ) { - timer_call_after_resynch(space->machine, NULL, data, test); + space->machine->scheduler().synchronize(FUNC(test), data); /* boost the interleave for a few usecs to make sure it is read successfully */ cpuexec_boost_interleave(space->machine, attotime::zero, attotime::from_usec(10)); } diff --git a/src/mame/machine/asic65.c b/src/mame/machine/asic65.c index 843379470bd..4d6955cebed 100644 --- a/src/mame/machine/asic65.c +++ b/src/mame/machine/asic65.c @@ -192,7 +192,7 @@ WRITE16_HANDLER( asic65_data_w ) /* rom-based use a deferred write mechanism */ if (asic65.type == ASIC65_ROMBASED) { - timer_call_after_resynch(space->machine, NULL, data | (offset << 16), m68k_asic65_deferred_w); + space->machine->scheduler().synchronize(FUNC(m68k_asic65_deferred_w), data | (offset << 16)); cpuexec_boost_interleave(space->machine, attotime::zero, attotime::from_usec(20)); return; } diff --git a/src/mame/machine/atarigen.c b/src/mame/machine/atarigen.c index 0945cd7cdad..c464d1ad36d 100644 --- a/src/mame/machine/atarigen.c +++ b/src/mame/machine/atarigen.c @@ -119,9 +119,9 @@ void atarigen_init(running_machine *machine) for (i = 0, screen = machine->first_screen(); screen != NULL; i++, screen = screen->next_screen()) { state->screen_timer[i].screen = screen; - state->screen_timer[i].scanline_interrupt_timer = timer_alloc(machine, scanline_interrupt_callback, (void *)screen); - state->screen_timer[i].scanline_timer = timer_alloc(machine, scanline_timer_callback, (void *)screen); - state->screen_timer[i].atarivc_eof_update_timer = timer_alloc(machine, atarivc_eof_update, (void *)screen); + state->screen_timer[i].scanline_interrupt_timer = machine->scheduler().timer_alloc(FUNC(scanline_interrupt_callback), (void *)screen); + state->screen_timer[i].scanline_timer = machine->scheduler().timer_alloc(FUNC(scanline_timer_callback), (void *)screen); + state->screen_timer[i].atarivc_eof_update_timer = machine->scheduler().timer_alloc(FUNC(atarivc_eof_update), (void *)screen); } state_save_register_global(machine, state->scanline_int_state); @@ -639,7 +639,7 @@ void atarigen_ym2151_irq_gen(device_t *device, int irq) WRITE16_HANDLER( atarigen_sound_reset_w ) { - timer_call_after_resynch(space->machine, NULL, 0, delayed_sound_reset); + space->machine->scheduler().synchronize(FUNC(delayed_sound_reset)); } @@ -650,7 +650,7 @@ WRITE16_HANDLER( atarigen_sound_reset_w ) void atarigen_sound_reset(running_machine *machine) { - timer_call_after_resynch(machine, NULL, 1, delayed_sound_reset); + machine->scheduler().synchronize(FUNC(delayed_sound_reset), 1); } @@ -664,19 +664,19 @@ void atarigen_sound_reset(running_machine *machine) WRITE16_HANDLER( atarigen_sound_w ) { if (ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, data & 0xff, delayed_sound_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_w), data & 0xff); } WRITE16_HANDLER( atarigen_sound_upper_w ) { if (ACCESSING_BITS_8_15) - timer_call_after_resynch(space->machine, NULL, (data >> 8) & 0xff, delayed_sound_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_w), (data >> 8) & 0xff); } WRITE32_HANDLER( atarigen_sound_upper32_w ) { if (ACCESSING_BITS_24_31) - timer_call_after_resynch(space->machine, NULL, (data >> 24) & 0xff, delayed_sound_w); + space->machine->scheduler().synchronize(FUNC(delayed_sound_w), (data >> 24) & 0xff); } @@ -719,7 +719,7 @@ READ32_HANDLER( atarigen_sound_upper32_r ) WRITE8_HANDLER( atarigen_6502_sound_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_6502_sound_w); + space->machine->scheduler().synchronize(FUNC(delayed_6502_sound_w), data); } @@ -1382,7 +1382,7 @@ void atarigen_halt_until_hblank_0(screen_device &screen) hblank += width; /* halt and set a timer to wake up */ - timer_set(screen.machine, screen.scan_period() * (hblank - hpos) / width, (void *)cpu, 0, unhalt_cpu); + screen.machine->scheduler().timer_set(screen.scan_period() * (hblank - hpos) / width, FUNC(unhalt_cpu), 0, (void *)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 d3e038bd1ea..7a6eeb4951b 100644 --- a/src/mame/machine/balsente.c +++ b/src/mame/machine/balsente.c @@ -49,7 +49,7 @@ TIMER_DEVICE_CALLBACK( balsente_interrupt_timer ) cputag_set_input_line(timer.machine, "maincpu", M6809_IRQ_LINE, ASSERT_LINE); /* it will turn off on the next HBLANK */ - timer_set(timer.machine, timer.machine->primary_screen->time_until_pos(param, BALSENTE_HBSTART), NULL, 0, irq_off); + timer.machine->scheduler().timer_set(timer.machine->primary_screen->time_until_pos(param, BALSENTE_HBSTART), FUNC(irq_off)); /* if this is Grudge Match, update the steering */ if (state->grudge_steering_result & 0x80) @@ -482,7 +482,7 @@ static TIMER_CALLBACK( m6850_w_callback ) /* set a timer for 500usec later to actually transmit the data */ /* (this is very important for several games, esp Snacks'n Jaxson) */ - timer_set(machine, attotime::from_usec(500), NULL, param, m6850_data_ready_callback); + machine->scheduler().timer_set(attotime::from_usec(500), FUNC(m6850_data_ready_callback), param); } @@ -501,7 +501,7 @@ WRITE8_HANDLER( balsente_m6850_w ) /* output register is at offset 1; set a timer to synchronize the CPUs */ else - timer_call_after_resynch(space->machine, NULL, data, m6850_w_callback); + space->machine->scheduler().synchronize(FUNC(m6850_w_callback), data); } @@ -628,7 +628,7 @@ WRITE8_HANDLER( balsente_adc_select_w ) /* set a timer to go off and read the value after 50us */ /* it's important that we do this for Mini Golf */ logerror("adc_select %d\n", offset & 7); - timer_set(space->machine, attotime::from_usec(50), NULL, offset & 7, adc_finished); + space->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(adc_finished), offset & 7); } diff --git a/src/mame/machine/bublbobl.c b/src/mame/machine/bublbobl.c index 06f540a97ce..4e1a11e6d46 100644 --- a/src/mame/machine/bublbobl.c +++ b/src/mame/machine/bublbobl.c @@ -103,7 +103,7 @@ static TIMER_CALLBACK( nmi_callback ) WRITE8_HANDLER( bublbobl_sound_command_w ) { soundlatch_w(space, offset, data); - timer_call_after_resynch(space->machine, NULL, data, nmi_callback); + space->machine->scheduler().synchronize(FUNC(nmi_callback), data); } WRITE8_HANDLER( bublbobl_sh_nmi_disable_w ) diff --git a/src/mame/machine/cdi070.c b/src/mame/machine/cdi070.c index caf3e329d5f..c89e628da26 100644 --- a/src/mame/machine/cdi070.c +++ b/src/mame/machine/cdi070.c @@ -1143,13 +1143,13 @@ void scc68070_register_globals(running_machine *machine, scc68070_regs_t *scc680 state_save_register_global(machine, scc68070->mmu.desc[7].segment); state_save_register_global(machine, scc68070->mmu.desc[7].base); - scc68070->timers.timer0_timer = timer_alloc(machine, scc68070_timer0_callback, 0); + scc68070->timers.timer0_timer = machine->scheduler().timer_alloc(FUNC(scc68070_timer0_callback)); timer_adjust_oneshot(scc68070->timers.timer0_timer, attotime::never, 0); - scc68070->uart.rx_timer = timer_alloc(machine, scc68070_rx_callback, 0); + scc68070->uart.rx_timer = machine->scheduler().timer_alloc(FUNC(scc68070_rx_callback)); timer_adjust_oneshot(scc68070->uart.rx_timer, attotime::never, 0); - scc68070->uart.tx_timer = timer_alloc(machine, scc68070_tx_callback, 0); + scc68070->uart.tx_timer = machine->scheduler().timer_alloc(FUNC(scc68070_tx_callback)); timer_adjust_oneshot(scc68070->uart.tx_timer, attotime::never, 0); } diff --git a/src/mame/machine/cdicdic.c b/src/mame/machine/cdicdic.c index 1908669a46d..9bc3bd7a5ee 100644 --- a/src/mame/machine/cdicdic.c +++ b/src/mame/machine/cdicdic.c @@ -1216,10 +1216,10 @@ void cdicdic_device::device_start() { register_globals(); - m_interrupt_timer = timer_alloc(&m_machine, trigger_readback_int, 0); + m_interrupt_timer = m_machine.scheduler().timer_alloc(FUNC(trigger_readback_int)); timer_adjust_oneshot(m_interrupt_timer, attotime::never, 0); - m_audio_sample_timer = timer_alloc(&m_machine, audio_sample_trigger, 0); + m_audio_sample_timer = m_machine.scheduler().timer_alloc(FUNC(audio_sample_trigger)); timer_adjust_oneshot(m_audio_sample_timer, attotime::never, 0); m_ram = auto_alloc_array(&m_machine, UINT16, 0x3c00/2); diff --git a/src/mame/machine/cdislave.c b/src/mame/machine/cdislave.c index f604b2212b0..60aeb15ae54 100644 --- a/src/mame/machine/cdislave.c +++ b/src/mame/machine/cdislave.c @@ -474,7 +474,7 @@ void cdislave_device::device_start() { register_globals(); - m_interrupt_timer = timer_alloc(&m_machine, trigger_readback_int, 0); + m_interrupt_timer = m_machine.scheduler().timer_alloc(FUNC(trigger_readback_int)); timer_adjust_oneshot(m_interrupt_timer, attotime::never, 0); } diff --git a/src/mame/machine/cubocd32.c b/src/mame/machine/cubocd32.c index ec5064167fc..4ea86aeb599 100644 --- a/src/mame/machine/cubocd32.c +++ b/src/mame/machine/cubocd32.c @@ -197,8 +197,8 @@ static DEVICE_START( akiko ) state->cdrom_cmd_resp = 0; state->cdrom_toc = NULL; - state->dma_timer = timer_alloc(machine, akiko_dma_proc, state); - state->frame_timer = timer_alloc(machine, akiko_frame_proc, state); + state->dma_timer = machine->scheduler().timer_alloc(FUNC(akiko_dma_proc), state); + state->frame_timer = machine->scheduler().timer_alloc(FUNC(akiko_frame_proc), state); state->i2cmem = machine->device("i2cmem"); @@ -702,7 +702,7 @@ static void akiko_update_cdrom(akiko_state *state) { state->cdrom_cmd_start = (state->cdrom_cmd_start+3) & 0xff; - timer_set( state->machine, attotime::from_msec(1), state, resp[0], akiko_cd_delayed_cmd ); + state->machine->scheduler().timer_set( attotime::from_msec(1), FUNC(akiko_cd_delayed_cmd ), resp[0], state); break; } diff --git a/src/mame/machine/dc.c b/src/mame/machine/dc.c index 8bda8b8fadc..190586df2c6 100644 --- a/src/mame/machine/dc.c +++ b/src/mame/machine/dc.c @@ -265,7 +265,7 @@ static void wave_dma_execute(address_space *space) wave_dma.flag = (wave_dma.indirect & 1) ? 1 : 0; /* Note: if you trigger an instant DMA IRQ trigger, sfz3upper doesn't play any bgm. */ /* TODO: timing of this */ - timer_set(space->machine, attotime::from_usec(300), NULL, 0, aica_dma_irq); + space->machine->scheduler().timer_set(attotime::from_usec(300), FUNC(aica_dma_irq)); } static void pvr_dma_execute(address_space *space) @@ -303,7 +303,7 @@ static void pvr_dma_execute(address_space *space) } /* Note: do not update the params, since this DMA type doesn't support it. */ /* TODO: timing of this */ - timer_set(space->machine, attotime::from_usec(250), NULL, 0, pvr_dma_irq); + space->machine->scheduler().timer_set(attotime::from_usec(250), FUNC(pvr_dma_irq)); } // register decode helpers @@ -689,10 +689,10 @@ WRITE64_HANDLER( dc_sysctrl_w ) dc_sysctrl_regs[SB_C2DSTAT]=address+ddtdata.length; /* 200 usecs breaks sfz3upper */ - timer_set(space->machine, attotime::from_usec(50), NULL, 0, ch2_dma_irq); + space->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(ch2_dma_irq)); /* simulate YUV FIFO processing here */ if((address & 0x1800000) == 0x0800000) - timer_set(space->machine, attotime::from_usec(500), NULL, 0, yuv_fifo_irq); + space->machine->scheduler().timer_set(attotime::from_usec(500), FUNC(yuv_fifo_irq)); } break; @@ -1066,7 +1066,7 @@ WRITE64_HANDLER( naomi_maple_w ) if (endflag) { - timer_set(space->machine, attotime::from_usec(200), NULL, 0, maple_dma_irq); + space->machine->scheduler().timer_set(attotime::from_usec(200), FUNC(maple_dma_irq)); break; } // skip fixed packet header @@ -1215,7 +1215,7 @@ WRITE64_HANDLER( dc_maple_w ) if (endflag) { - timer_set(space->machine, attotime::from_usec(200), NULL, 0, maple_dma_irq); + space->machine->scheduler().timer_set(attotime::from_usec(200), FUNC(maple_dma_irq)); break; } // skip fixed packet header @@ -1333,7 +1333,7 @@ WRITE64_HANDLER( dc_g1_ctrl_w ) sh4_dma_ddt(space->machine->device("maincpu"), &ddtdata); /* Note: KOF Neowave definitely wants this to be delayed (!) */ /* FIXME: timing of this */ - timer_set(space->machine, attotime::from_usec(500), NULL, 0, gdrom_dma_irq); + space->machine->scheduler().timer_set(attotime::from_usec(500), FUNC(gdrom_dma_irq)); } break; } @@ -1609,7 +1609,7 @@ static void rtc_initial_setup(running_machine *machine) dc_rtcregister[RTC2] = current_time & 0x0000ffff; dc_rtcregister[RTC1] = (current_time & 0xffff0000) >> 16; - dc_rtc_timer = timer_alloc(machine, dc_rtc_increment, 0); + dc_rtc_timer = machine->scheduler().timer_alloc(FUNC(dc_rtc_increment)); } MACHINE_START( dc ) diff --git a/src/mame/machine/decocass.c b/src/mame/machine/decocass.c index f304a9fdb91..22b12947c7e 100644 --- a/src/mame/machine/decocass.c +++ b/src/mame/machine/decocass.c @@ -2178,7 +2178,7 @@ static DEVICE_START( decocass_tape ) assert(device->machine->config != NULL); /* fetch the data pointer */ - tape->timer = timer_alloc(device->machine, tape_clock_callback, (void *)device); + tape->timer = device->machine->scheduler().timer_alloc(FUNC(tape_clock_callback), (void *)device); if (device->region() == NULL) return; UINT8 *regionbase = *device->region(); diff --git a/src/mame/machine/gaelco3d.c b/src/mame/machine/gaelco3d.c index 2b9bc7d68fc..4352229b679 100644 --- a/src/mame/machine/gaelco3d.c +++ b/src/mame/machine/gaelco3d.c @@ -275,8 +275,8 @@ static TIMER_CALLBACK( set_status_cb ) static void set_status(gaelco_serial_state *state, UINT8 mask, UINT8 set, int wait) { - timer_set(state->device->machine, attotime::from_hz(wait), - state, (mask << 8)|set, set_status_cb); + state->device->machine->scheduler().timer_set(attotime::from_hz(wait), FUNC(set_status_cb), (mask << 8)|set, + state); } static void process_in(gaelco_serial_state *state) @@ -465,7 +465,7 @@ static DEVICE_START( gaelco_serial ) state->device = device; devcb_resolve_write_line(&state->irq_func, &intf->irq_func, device); - state->sync_timer = timer_alloc(device->machine, link_cb, state); + state->sync_timer = device->machine->scheduler().timer_alloc(FUNC(link_cb), state); /* register for save states */ //state_save_register_device_item(device, 0, earom->offset); diff --git a/src/mame/machine/harddriv.c b/src/mame/machine/harddriv.c index ec9df4537a1..ddba8d933de 100644 --- a/src/mame/machine/harddriv.c +++ b/src/mame/machine/harddriv.c @@ -697,7 +697,7 @@ INLINE void stmsp_sync_w(address_space *space, offs_t offset, UINT16 data, UINT1 /* if being written from the 68000, synchronize on it */ if (state->hd34010_host_access) - timer_call_after_resynch(space->machine, NULL, newdata | (offset << 16) | (which << 28), stmsp_sync_update); + space->machine->scheduler().synchronize(FUNC(stmsp_sync_update), newdata | (offset << 16) | (which << 28)); /* otherwise, just update */ else @@ -790,7 +790,7 @@ WRITE16_HANDLER( hd68k_adsp_data_w ) if (offset == 0x1fff) { logerror("%06X:ADSP sync address written (%04X)\n", cpu_get_previouspc(space->cpu), data); - timer_call_after_resynch(space->machine, NULL, 0, 0); + space->machine->scheduler().synchronize(FUNC(0)); cpu_triggerint(state->adsp); } else @@ -897,7 +897,7 @@ WRITE16_HANDLER( hd68k_adsp_control_w ) case 3: logerror("ADSP bank = %d (deferred)\n", val); - timer_call_after_resynch(space->machine, NULL, val, deferred_adsp_bank_switch); + space->machine->scheduler().synchronize(FUNC(deferred_adsp_bank_switch), val); break; case 5: @@ -1520,7 +1520,7 @@ WRITE32_HANDLER( rddsp32_sync0_w ) COMBINE_DATA(&newdata); state->dataptr[state->next_msp_sync % MAX_MSP_SYNC] = dptr; state->dataval[state->next_msp_sync % MAX_MSP_SYNC] = newdata; - timer_call_after_resynch(space->machine, NULL, state->next_msp_sync++ % MAX_MSP_SYNC, rddsp32_sync_cb); + space->machine->scheduler().synchronize(FUNC(rddsp32_sync_cb), state->next_msp_sync++ % MAX_MSP_SYNC); } else COMBINE_DATA(&state->rddsp32_sync[0][offset]); @@ -1537,7 +1537,7 @@ WRITE32_HANDLER( rddsp32_sync1_w ) COMBINE_DATA(&newdata); state->dataptr[state->next_msp_sync % MAX_MSP_SYNC] = dptr; state->dataval[state->next_msp_sync % MAX_MSP_SYNC] = newdata; - timer_call_after_resynch(space->machine, NULL, state->next_msp_sync++ % MAX_MSP_SYNC, rddsp32_sync_cb); + space->machine->scheduler().synchronize(FUNC(rddsp32_sync_cb), state->next_msp_sync++ % MAX_MSP_SYNC); } else COMBINE_DATA(&state->rddsp32_sync[1][offset]); diff --git a/src/mame/machine/irobot.c b/src/mame/machine/irobot.c index cb647d4f418..a94c417c3ad 100644 --- a/src/mame/machine/irobot.c +++ b/src/mame/machine/irobot.c @@ -169,7 +169,7 @@ static TIMER_CALLBACK( scanline_callback ) /* set a callback for the next 32-scanline increment */ scanline += 32; if (scanline >= 256) scanline = 0; - timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, scanline_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(scanline), FUNC(scanline_callback), scanline); } MACHINE_RESET( irobot ) @@ -190,7 +190,7 @@ MACHINE_RESET( irobot ) state->irmb_timer = machine->device<timer_device>("irmb_timer"); /* set an initial timer to go off on scanline 0 */ - timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, scanline_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(0), FUNC(scanline_callback)); irobot_rom_banksel_w(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),0,0); irobot_out0_w(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),0,0); diff --git a/src/mame/machine/leland.c b/src/mame/machine/leland.c index fb069b1832a..33060f795ac 100644 --- a/src/mame/machine/leland.c +++ b/src/mame/machine/leland.c @@ -366,7 +366,7 @@ MACHINE_START( leland ) battery_ram = reinterpret_cast<UINT8 *>(memory_get_shared(*machine, "battery")); /* start scanline interrupts going */ - master_int_timer = timer_alloc(machine, leland_interrupt_callback, NULL); + master_int_timer = machine->scheduler().timer_alloc(FUNC(leland_interrupt_callback)); } @@ -415,7 +415,7 @@ MACHINE_START( ataxx ) extra_tram = auto_alloc_array(machine, UINT8, ATAXX_EXTRA_TRAM_SIZE); /* start scanline interrupts going */ - master_int_timer = timer_alloc(machine, ataxx_interrupt_callback, NULL); + master_int_timer = machine->scheduler().timer_alloc(FUNC(ataxx_interrupt_callback)); } diff --git a/src/mame/machine/lsasquad.c b/src/mame/machine/lsasquad.c index 14ac307ab5f..72e8e72d5b7 100644 --- a/src/mame/machine/lsasquad.c +++ b/src/mame/machine/lsasquad.c @@ -43,7 +43,7 @@ WRITE8_HANDLER( lsasquad_sound_command_w ) state->sound_cmd = data; //logerror("%04x: sound cmd %02x\n", cpu_get_pc(space->cpu), data); - timer_call_after_resynch(space->machine, NULL, data, nmi_callback); + space->machine->scheduler().synchronize(FUNC(nmi_callback), data); } READ8_HANDLER( lsasquad_sh_sound_command_r ) diff --git a/src/mame/machine/mcr.c b/src/mame/machine/mcr.c index 5614c6cac86..cee11c5963e 100644 --- a/src/mame/machine/mcr.c +++ b/src/mame/machine/mcr.c @@ -168,7 +168,7 @@ MACHINE_START( mcr ) MACHINE_START( nflfoot ) { /* allocate a timer for the IPU watchdog */ - ipu_watchdog_timer = timer_alloc(machine, ipu_watchdog_reset, NULL); + ipu_watchdog_timer = machine->scheduler().timer_alloc(FUNC(ipu_watchdog_reset)); } diff --git a/src/mame/machine/mcr68.c b/src/mame/machine/mcr68.c index 2b3c81ef329..647e161ccca 100644 --- a/src/mame/machine/mcr68.c +++ b/src/mame/machine/mcr68.c @@ -48,7 +48,7 @@ static UINT8 m6840_irq_vector; static UINT8 v493_irq_state; static UINT8 v493_irq_vector; -static timer_fired_func v493_callback; +static timer_expired_func v493_callback; static UINT8 zwackery_sound_data; @@ -169,7 +169,7 @@ MACHINE_START( mcr68 ) { struct counter_state *m6840 = &m6840_state[i]; - m6840->timer = timer_alloc(machine, counter_fired_callback, NULL); + m6840->timer = machine->scheduler().timer_alloc(FUNC(counter_fired_callback)); state_save_register_item(machine, "m6840", NULL, i, m6840->control); state_save_register_item(machine, "m6840", NULL, i, m6840->latch); @@ -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::from_hz(30) - mcr68_timing_factor, NULL, 0, v493_callback); + device->machine->scheduler().timer_set(attotime::from_hz(30) - mcr68_timing_factor, FUNC(v493_callback)); } @@ -296,7 +296,7 @@ static TIMER_CALLBACK( mcr68_493_callback ) { v493_irq_state = 1; update_mcr68_interrupts(machine); - timer_set(machine, machine->primary_screen->scan_period(), NULL, 0, mcr68_493_off_callback); + machine->scheduler().timer_set(machine->primary_screen->scan_period(), FUNC(mcr68_493_off_callback)); logerror("--- (INT1) ---\n"); } @@ -351,7 +351,7 @@ static TIMER_CALLBACK( zwackery_493_callback ) device_t *pia = machine->device("pia0"); pia6821_ca1_w(pia, 1); - timer_set(machine, machine->primary_screen->scan_period(), NULL, 0, zwackery_493_off_callback); + machine->scheduler().timer_set(machine->primary_screen->scan_period(), FUNC(zwackery_493_off_callback)); } diff --git a/src/mame/machine/megadriv.c b/src/mame/machine/megadriv.c index f8090060577..348973d9108 100644 --- a/src/mame/machine/megadriv.c +++ b/src/mame/machine/megadriv.c @@ -1659,7 +1659,7 @@ static void init_megadri6_io(running_machine *machine) for (i=0; i<3; i++) { - io_timeout[i] = timer_alloc(machine, io_timeout_timer_callback, (void*)(FPTR)i); + io_timeout[i] = machine->scheduler().timer_alloc(FUNC(io_timeout_timer_callback), (void*)(FPTR)i); } } @@ -2269,7 +2269,7 @@ static WRITE16_HANDLER( megadriv_68k_req_z80_bus ) /* If the z80 is running, sync the z80 execution state */ if ( ! genz80.z80_is_reset ) - timer_set( space->machine, attotime::zero, NULL, 0, megadriv_z80_run_state ); + space->machine->scheduler().timer_set( attotime::zero, FUNC(megadriv_z80_run_state )); } static WRITE16_HANDLER ( megadriv_68k_req_z80_reset ) @@ -2313,7 +2313,7 @@ static WRITE16_HANDLER ( megadriv_68k_req_z80_reset ) genz80.z80_is_reset = 1; } } - timer_set( space->machine, attotime::zero, NULL, 0, megadriv_z80_run_state ); + space->machine->scheduler().timer_set( attotime::zero, FUNC(megadriv_z80_run_state )); } @@ -2977,7 +2977,7 @@ static UINT16 commsram[8]; // reads static READ16_HANDLER( _32x_68k_commsram_r ) { - if (_32X_COMMS_PORT_SYNC) timer_call_after_resynch(space->machine, NULL, 0, NULL); + if (_32X_COMMS_PORT_SYNC) space->machine->scheduler().synchronize(); return commsram[offset]; } @@ -2985,7 +2985,7 @@ static READ16_HANDLER( _32x_68k_commsram_r ) static WRITE16_HANDLER( _32x_68k_commsram_w ) { COMBINE_DATA(&commsram[offset]); - if (_32X_COMMS_PORT_SYNC) timer_call_after_resynch(space->machine, NULL, 0, NULL); + if (_32X_COMMS_PORT_SYNC) space->machine->scheduler().synchronize(); } /**********************************************************************************************/ @@ -4145,7 +4145,7 @@ static UINT16 segacd_comms_flags = 0x0000; static READ16_HANDLER( segacd_comms_flags_r ) { - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return segacd_comms_flags; } @@ -4154,7 +4154,7 @@ static WRITE16_HANDLER( segacd_comms_flags_subcpu_w ) if (ACCESSING_BITS_0_7) { segacd_comms_flags = (segacd_comms_flags & 0xff00) | (data & 0x00ff); - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); } if (ACCESSING_BITS_8_15) @@ -4180,7 +4180,7 @@ static WRITE16_HANDLER( segacd_comms_flags_maincpu_w ) if (ACCESSING_BITS_8_15) { segacd_comms_flags = (segacd_comms_flags & 0x00ff) | (data & 0xff00); - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); } } @@ -4216,19 +4216,19 @@ UINT16 segacd_comms_part2[0x8]; static READ16_HANDLER( segacd_comms_main_part1_r ) { - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return segacd_comms_part1[offset]; } static WRITE16_HANDLER( segacd_comms_main_part1_w ) { - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); COMBINE_DATA(&segacd_comms_part1[offset]); } static READ16_HANDLER( segacd_comms_main_part2_r ) { - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return segacd_comms_part2[offset]; } @@ -4240,7 +4240,7 @@ static WRITE16_HANDLER( segacd_comms_main_part2_w ) static READ16_HANDLER( segacd_comms_sub_part1_r ) { - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return segacd_comms_part1[offset]; } @@ -4251,13 +4251,13 @@ static WRITE16_HANDLER( segacd_comms_sub_part1_w ) static READ16_HANDLER( segacd_comms_sub_part2_r ) { - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return segacd_comms_part2[offset]; } static WRITE16_HANDLER( segacd_comms_sub_part2_w ) { - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); COMBINE_DATA(&segacd_comms_part2[offset]); } @@ -5021,16 +5021,16 @@ void segacd_init_main_cpu( running_machine* machine ) memory_install_read16_handler (space, 0x0000070, 0x0000073, 0, 0, scd_hint_vector_r ); - segacd_gfx_conversion_timer = timer_alloc(machine, segacd_gfx_conversion_timer_callback, 0); + segacd_gfx_conversion_timer = machine->scheduler().timer_alloc(FUNC(segacd_gfx_conversion_timer_callback)); timer_adjust_oneshot(segacd_gfx_conversion_timer, attotime::never, 0); - segacd_dmna_ret_timer = timer_alloc(machine, segacd_dmna_ret_timer_callback, 0); + segacd_dmna_ret_timer = machine->scheduler().timer_alloc(FUNC(segacd_dmna_ret_timer_callback)); timer_adjust_oneshot(segacd_gfx_conversion_timer, attotime::never, 0); - segacd_hock_timer = timer_alloc(machine, segacd_hock_callback, 0); + segacd_hock_timer = machine->scheduler().timer_alloc(FUNC(segacd_hock_callback)); timer_adjust_oneshot(segacd_hock_timer, attotime::never, 0); - segacd_irq3_timer = timer_alloc(machine, segacd_irq3_timer_callback, 0); + segacd_irq3_timer = machine->scheduler().timer_alloc(FUNC(segacd_irq3_timer_callback)); timer_adjust_oneshot(segacd_irq3_timer, attotime::never, 0); @@ -5259,7 +5259,7 @@ static void cdd_hock_irq(running_machine *machine,UINT8 dir) if((segacd_cdd.ctrl & 4 || dir) && segacd_irq_mask & 0x10) // export status, check if bit 2 (HOst ClocK) and irq is enabled { segacd_cdd.ctrl |= 4; // enable Hock bit if it isn't already active - timer_set(machine, attotime::from_hz(75), NULL,0, execute_hock_irq); // 1 / 75th of a second + machine->scheduler().timer_set(attotime::from_hz(75), FUNC(execute_hock_irq)); // 1 / 75th of a second } } #endif @@ -8246,7 +8246,7 @@ static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) top-left of the screen. The first scanline is scanline 0 (we set scanline to -1 in VIDEO_EOF) */ - timer_call_after_resynch(timer.machine, NULL, 0, 0); + timer.machine->scheduler().synchronize(FUNC(0)); /* Compensate for some rounding errors When the counter reaches 261 we should have reached the end of the frame, however due @@ -8424,7 +8424,7 @@ MACHINE_RESET( megadriv ) genz80.z80_has_bus = 1; genz80.z80_bank_addr = 0; genesis_scanline_counter = -1; - timer_set( machine, attotime::zero, NULL, 0, megadriv_z80_run_state ); + machine->scheduler().timer_set( attotime::zero, FUNC(megadriv_z80_run_state )); } megadrive_imode = 0; @@ -8959,7 +8959,7 @@ static void megadriv_init_common(running_machine *machine) if(_32x_is_connected) { - _32x_pwm_timer = timer_alloc(machine, _32x_pwm_callback, 0); + _32x_pwm_timer = machine->scheduler().timer_alloc(FUNC(_32x_pwm_callback)); timer_adjust_oneshot(_32x_pwm_timer, attotime::never, 0); } diff --git a/src/mame/machine/meters.c b/src/mame/machine/meters.c index 5c4b368fc69..bfb3db7e361 100644 --- a/src/mame/machine/meters.c +++ b/src/mame/machine/meters.c @@ -39,7 +39,7 @@ void MechMtr_config(running_machine *machine, int number) meter_info[i].state = 0; meter_info[i].count = 0; meter_info[i].on = 0; - meter_info[i].meter_timer = timer_alloc(machine, meter_callback, (void*)(FPTR)i); + meter_info[i].meter_timer = machine->scheduler().timer_alloc(FUNC(meter_callback), (void*)(FPTR)i); timer_reset(meter_info[i].meter_timer, attotime::never); } number_mtr = number; diff --git a/src/mame/machine/mhavoc.c b/src/mame/machine/mhavoc.c index c2cc938229f..a8e13f2e36a 100644 --- a/src/mame/machine/mhavoc.c +++ b/src/mame/machine/mhavoc.c @@ -136,7 +136,7 @@ static TIMER_CALLBACK( delayed_gamma_w ) cputag_set_input_line(machine, "gamma", INPUT_LINE_NMI, PULSE_LINE); /* the sound CPU needs to reply in 250microseconds (according to Neil Bradley) */ - timer_set(machine, attotime::from_usec(250), NULL, 0, 0); + machine->scheduler().timer_set(attotime::from_usec(250), FUNC(0)); } @@ -144,7 +144,7 @@ WRITE8_HANDLER( mhavoc_gamma_w ) { mhavoc_state *state = space->machine->driver_data<mhavoc_state>(); logerror(" writing to gamma processor: %02x (%d %d)\n", data, state->gamma_rcvd, state->alpha_xmtd); - timer_call_after_resynch(space->machine, NULL, data, delayed_gamma_w); + space->machine->scheduler().synchronize(FUNC(delayed_gamma_w), data); } diff --git a/src/mame/machine/micro3d.c b/src/mame/machine/micro3d.c index 7838cd000be..2306f379c2b 100644 --- a/src/mame/machine/micro3d.c +++ b/src/mame/machine/micro3d.c @@ -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::from_hz(MAC_CLK) * mac_cycles, NULL, 0, mac_done_callback); + space->machine->scheduler().timer_set(attotime::from_hz(MAC_CLK) * mac_cycles, FUNC(mac_done_callback)); state->mrab11 = mrab11; state->vtx_addr = vtx_addr; @@ -658,7 +658,7 @@ WRITE16_HANDLER( micro3d_adc_w ) return; } - timer_set(space->machine, attotime::from_usec(40), NULL, data & ~4, adc_done_callback); + space->machine->scheduler().timer_set(attotime::from_usec(40), FUNC(adc_done_callback), data & ~4); } CUSTOM_INPUT( botssa_hwchk_r ) @@ -757,7 +757,7 @@ DRIVER_INIT( micro3d ) non-zero on a reset, otherwise the 3D object data doesn't get uploaded! */ space->write_dword(0x00470000, 0xa5a5a5a5); - state->mc68901.timer_a = timer_alloc(machine, mfp_timer_a_cb, NULL); + state->mc68901.timer_a = machine->scheduler().timer_alloc(FUNC(mfp_timer_a_cb)); /* TODO? BOTSS crashes when starting the final stage because the 68000 overwrites memory in use by the Am29000. Slowing down the 68000 slightly diff --git a/src/mame/machine/midwayic.c b/src/mame/machine/midwayic.c index d1807d6aa31..fea897383f7 100644 --- a/src/mame/machine/midwayic.c +++ b/src/mame/machine/midwayic.c @@ -281,7 +281,7 @@ void midway_serial_pic2_init(running_machine *machine, int upper, int yearoffs) pic.yearoffs = yearoffs; pic.time_just_written = 0; - pic.time_write_timer = timer_alloc(machine, reset_timer, NULL); + pic.time_write_timer = machine->scheduler().timer_alloc(FUNC(reset_timer)); memset(pic.default_nvram, 0xff, sizeof(pic.default_nvram)); generate_serial_data(machine, upper); } diff --git a/src/mame/machine/midwunit.c b/src/mame/machine/midwunit.c index 14f4d2692c1..0899b7afa5f 100644 --- a/src/mame/machine/midwunit.c +++ b/src/mame/machine/midwunit.c @@ -302,7 +302,7 @@ READ16_HANDLER( midxunit_uart_r ) int temp = midwunit_sound_state_r(space, 0, 0xffff); result |= (temp & 0x800) >> 9; result |= (~temp & 0x400) >> 10; - timer_call_after_resynch(space->machine, NULL, 0, 0); + space->machine->scheduler().synchronize(FUNC(0)); } break; @@ -329,7 +329,7 @@ READ16_HANDLER( midxunit_uart_r ) int temp = midwunit_sound_state_r(space, 0, 0xffff); result |= (temp & 0x800) >> 11; result |= (~temp & 0x400) >> 8; - timer_call_after_resynch(space->machine, NULL, 0, 0); + space->machine->scheduler().synchronize(FUNC(0)); } break; diff --git a/src/mame/machine/model1.c b/src/mame/machine/model1.c index fa34278eb0d..36b52057c13 100644 --- a/src/mame/machine/model1.c +++ b/src/mame/machine/model1.c @@ -2037,7 +2037,7 @@ static UINT32 copro_fifoout_pop(address_space *space) // Reading from empty FIFO causes the v60 to enter wait state v60_stall(space->machine->device("maincpu")); - timer_call_after_resynch(space->machine, NULL, 0, NULL); + space->machine->scheduler().synchronize(); return 0; } diff --git a/src/mame/machine/mw8080bw.c b/src/mame/machine/mw8080bw.c index 1dc85bfba74..381661fcdb1 100644 --- a/src/mame/machine/mw8080bw.c +++ b/src/mame/machine/mw8080bw.c @@ -75,7 +75,7 @@ static TIMER_CALLBACK( mw8080bw_interrupt_callback ) static void mw8080bw_create_interrupt_timer( running_machine *machine ) { mw8080bw_state *state = machine->driver_data<mw8080bw_state>(); - state->interrupt_timer = timer_alloc(machine, mw8080bw_interrupt_callback, NULL); + state->interrupt_timer = machine->scheduler().timer_alloc(FUNC(mw8080bw_interrupt_callback)); } diff --git a/src/mame/machine/n64.c b/src/mame/machine/n64.c index f967a7ba392..641feb0d8ba 100644 --- a/src/mame/machine/n64.c +++ b/src/mame/machine/n64.c @@ -2023,7 +2023,7 @@ MACHINE_START( n64 ) rspdrc_set_options(machine->device("rsp"), RSPDRC_STRICT_VERIFY); rspdrc_flush_drc_cache(machine->device("rsp")); - audio_timer = timer_alloc(machine, audio_timer_callback, NULL); + audio_timer = machine->scheduler().timer_alloc(FUNC(audio_timer_callback)); } MACHINE_RESET( n64 ) diff --git a/src/mame/machine/namco06.c b/src/mame/machine/namco06.c index c82dc9aee51..184923d3d54 100644 --- a/src/mame/machine/namco06.c +++ b/src/mame/machine/namco06.c @@ -271,7 +271,7 @@ static DEVICE_START( namco_06xx ) } /* allocate a timer */ - state->nmi_timer = timer_alloc(device->machine, nmi_generate, (void *)device); + state->nmi_timer = device->machine->scheduler().timer_alloc(FUNC(nmi_generate), (void *)device); state_save_register_device_item(device, 0, state->control); } diff --git a/src/mame/machine/namco50.c b/src/mame/machine/namco50.c index 16a34557f50..265fbeb4eb5 100644 --- a/src/mame/machine/namco50.c +++ b/src/mame/machine/namco50.c @@ -219,12 +219,12 @@ static void namco_50xx_irq_set(device_t *device) // The input clock to the 06XX interface chip is 64H, that is // 18432000/6/64 = 48kHz, so it makes sense for the irq line to be // asserted for one clock cycle ~= 21us. - timer_set(device->machine, attotime::from_usec(21), (void *)device, 0, namco_50xx_irq_clear); + device->machine->scheduler().timer_set(attotime::from_usec(21), FUNC(namco_50xx_irq_clear), 0, (void *)device); } WRITE8_DEVICE_HANDLER( namco_50xx_write ) { - timer_call_after_resynch(device->machine, (void *)device, data, namco_50xx_latch_callback); + device->machine->scheduler().synchronize(FUNC(namco_50xx_latch_callback), data, (void *)device); namco_50xx_irq_set(device); } @@ -232,7 +232,7 @@ WRITE8_DEVICE_HANDLER( namco_50xx_write ) void namco_50xx_read_request(device_t *device) { - timer_call_after_resynch(device->machine, (void *)device, 0, namco_50xx_readrequest_callback); + device->machine->scheduler().synchronize(FUNC(namco_50xx_readrequest_callback), 0, (void *)device); namco_50xx_irq_set(device); } diff --git a/src/mame/machine/namco53.c b/src/mame/machine/namco53.c index 2f58c35c9a4..0db99af2c75 100644 --- a/src/mame/machine/namco53.c +++ b/src/mame/machine/namco53.c @@ -126,7 +126,7 @@ void namco_53xx_read_request(device_t *device) // The input clock to the 06XX interface chip is 64H, that is // 18432000/6/64 = 48kHz, so it makes sense for the irq line to be // asserted for one clock cycle ~= 21us. - timer_set(device->machine, attotime::from_usec(21), (void *)device, 0, namco_53xx_irq_clear); + device->machine->scheduler().timer_set(attotime::from_usec(21), FUNC(namco_53xx_irq_clear), 0, (void *)device); } READ8_DEVICE_HANDLER( namco_53xx_read ) diff --git a/src/mame/machine/namcos2.c b/src/mame/machine/namcos2.c index e9b94dbe3a8..5f310d92a47 100644 --- a/src/mame/machine/namcos2.c +++ b/src/mame/machine/namcos2.c @@ -107,7 +107,7 @@ MACHINE_START( namcos2 ) { namcos2_eeprom = auto_alloc_array(machine, UINT8, namcos2_eeprom_size); machine->device<nvram_device>("nvram")->set_base(namcos2_eeprom, namcos2_eeprom_size); - namcos2_posirq_timer = timer_alloc(machine, namcos2_posirq_tick, NULL); + namcos2_posirq_timer = machine->scheduler().timer_alloc(FUNC(namcos2_posirq_tick)); } MACHINE_RESET( namcos2 ) diff --git a/src/mame/machine/nb1413m3.c b/src/mame/machine/nb1413m3.c index fd75d3ea24f..8702903befe 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::from_hz(NB1413M3_TIMER_BASE) * 256, NULL, 0, nb1413m3_timer_callback); + machine->scheduler().timer_set(attotime::from_hz(NB1413M3_TIMER_BASE) * 256, FUNC(nb1413m3_timer_callback)); nb1413m3_74ls193_counter++; nb1413m3_74ls193_counter &= 0x0f; @@ -140,7 +140,7 @@ MACHINE_RESET( nb1413m3 ) nb1413m3_74ls193_counter = 0; - timer_call_after_resynch(machine, NULL, 0, nb1413m3_timer_callback); + machine->scheduler().synchronize(FUNC(nb1413m3_timer_callback)); } WRITE8_HANDLER( nb1413m3_nmi_clock_w ) diff --git a/src/mame/machine/nmk004.c b/src/mame/machine/nmk004.c index 92563852705..406bf7f13ed 100644 --- a/src/mame/machine/nmk004.c +++ b/src/mame/machine/nmk004.c @@ -1046,7 +1046,7 @@ static TIMER_CALLBACK( real_nmk004_init ) void NMK004_init(running_machine *machine) { /* we have to do this via a timer because we get called before the sound reset */ - timer_call_after_resynch(machine, NULL, 0, real_nmk004_init); + machine->scheduler().synchronize(FUNC(real_nmk004_init)); } diff --git a/src/mame/machine/opwolf.c b/src/mame/machine/opwolf.c index a8979e16f0b..59edd0b2f81 100644 --- a/src/mame/machine/opwolf.c +++ b/src/mame/machine/opwolf.c @@ -695,7 +695,7 @@ static TIMER_CALLBACK( cchip_timer ) { // Simulate time for command to execute (exact timing unknown, this is close) state->current_cmd = 0xf5; - timer_set(machine, state->maincpu->cycles_to_attotime(80000), NULL, 0, opwolf_timer_callback); + machine->scheduler().timer_set(state->maincpu->cycles_to_attotime(80000), FUNC(opwolf_timer_callback)); } state->cchip_last_7a = state->cchip_ram[0x7a]; @@ -752,5 +752,5 @@ void opwolf_cchip_init( running_machine *machine ) state->cchip_coins_for_credit[1] = 1; state->cchip_credits_for_coin[1] = 1; - timer_pulse(machine, attotime::from_hz(60), NULL, 0, cchip_timer); + machine->scheduler().timer_pulse(attotime::from_hz(60), FUNC(cchip_timer)); } diff --git a/src/mame/machine/pcshare.c b/src/mame/machine/pcshare.c index 9de67bc11b2..ba32b63ba90 100644 --- a/src/mame/machine/pcshare.c +++ b/src/mame/machine/pcshare.c @@ -69,7 +69,7 @@ void init_pc_common(running_machine *machine, UINT32 flags, void (*set_keyb_int_ memset(&pc_keyb, 0, sizeof(pc_keyb)); pc_keyb.machine = machine; pc_keyb.int_cb = set_keyb_int_func; - pc_keyb.timer = timer_alloc(machine, pc_keyb_timer, NULL); + pc_keyb.timer = machine->scheduler().timer_alloc(FUNC(pc_keyb_timer)); } UINT8 pc_keyb_read(void) diff --git a/src/mame/machine/pitnrun.c b/src/mame/machine/pitnrun.c index c649242f57b..6807029884f 100644 --- a/src/mame/machine/pitnrun.c +++ b/src/mame/machine/pitnrun.c @@ -29,7 +29,7 @@ static TIMER_CALLBACK( pitnrun_mcu_real_data_r ) READ8_HANDLER( pitnrun_mcu_data_r ) { pitnrun_state *state = space->machine->driver_data<pitnrun_state>(); - timer_call_after_resynch(space->machine, NULL, 0,pitnrun_mcu_real_data_r); + space->machine->scheduler().synchronize(FUNC(pitnrun_mcu_real_data_r)); return state->toz80; } @@ -43,7 +43,7 @@ static TIMER_CALLBACK( pitnrun_mcu_real_data_w ) WRITE8_HANDLER( pitnrun_mcu_data_w ) { - timer_call_after_resynch(space->machine, NULL, data,pitnrun_mcu_real_data_w); + space->machine->scheduler().synchronize(FUNC(pitnrun_mcu_real_data_w), data); cpuexec_boost_interleave(space->machine, attotime::zero, attotime::from_usec(5)); } @@ -115,14 +115,14 @@ WRITE8_HANDLER( pitnrun_68705_portB_w ) if (~data & 0x02) { /* 68705 is going to read data from the Z80 */ - timer_call_after_resynch(space->machine, NULL, 0,pitnrun_mcu_data_real_r); + space->machine->scheduler().synchronize(FUNC(pitnrun_mcu_data_real_r)); cputag_set_input_line(space->machine, "mcu",0,CLEAR_LINE); state->portA_in = state->fromz80; } if (~data & 0x04) { /* 68705 is writing data for the Z80 */ - timer_call_after_resynch(space->machine, NULL, state->portA_out,pitnrun_mcu_status_real_w); + space->machine->scheduler().synchronize(FUNC(pitnrun_mcu_status_real_w), state->portA_out); } if (~data & 0x10) { diff --git a/src/mame/machine/psx.c b/src/mame/machine/psx.c index 8bb25e0f6fe..26607e48ccc 100644 --- a/src/mame/machine/psx.c +++ b/src/mame/machine/psx.c @@ -1661,19 +1661,19 @@ void psx_driver_init( running_machine *machine ) for( n = 0; n < 7; n++ ) { - p_psx->channel[ n ].timer = timer_alloc( machine, dma_finished_callback, machine ); + p_psx->channel[ n ].timer = machine->scheduler().timer_alloc( FUNC(dma_finished_callback), machine ); p_psx->channel[ n ].fn_read = NULL; p_psx->channel[ n ].fn_write = NULL; } for( n = 0; n < 3; n++ ) { - p_psx->root[ n ].timer = timer_alloc( machine, root_finished , NULL); + p_psx->root[ n ].timer = machine->scheduler().timer_alloc( FUNC(root_finished )); } for( n = 0; n < 2; n++ ) { - p_psx->sio[ n ].timer = timer_alloc( machine, sio_clock , NULL); + p_psx->sio[ n ].timer = machine->scheduler().timer_alloc( FUNC(sio_clock )); p_psx->sio[ n ].fn_handler = NULL; } diff --git a/src/mame/machine/qix.c b/src/mame/machine/qix.c index c54fc648690..95318adf20b 100644 --- a/src/mame/machine/qix.c +++ b/src/mame/machine/qix.c @@ -480,7 +480,7 @@ WRITE8_DEVICE_HANDLER( qix_pia_w ) { /* make all the CPUs synchronize, and only AFTER that write the command to the PIA */ /* otherwise the 68705 will miss commands */ - timer_call_after_resynch(device->machine, (void *)device, data | (offset << 8), pia_w_callback); + device->machine->scheduler().synchronize(FUNC(pia_w_callback), data | (offset << 8), (void *)device); } diff --git a/src/mame/machine/rainbow.c b/src/mame/machine/rainbow.c index a617fdec20f..fd78a0d3658 100644 --- a/src/mame/machine/rainbow.c +++ b/src/mame/machine/rainbow.c @@ -833,5 +833,5 @@ void rainbow_cchip_init( running_machine *machine, int version ) state_save_register_item(machine, "cchip", NULL, 0, state->current_bank); - timer_pulse(machine, attotime::from_hz(60), NULL, 0, cchip_timer); + machine->scheduler().timer_pulse(attotime::from_hz(60), FUNC(cchip_timer)); } diff --git a/src/mame/machine/segamsys.c b/src/mame/machine/segamsys.c index 2ffdfb453b5..e9b6bb595f9 100644 --- a/src/mame/machine/segamsys.c +++ b/src/mame/machine/segamsys.c @@ -438,7 +438,7 @@ static void *start_vdp(running_machine *machine, int type) chip->writemode = 0; chip->r_bitmap = auto_bitmap_alloc(machine, 256, 256, BITMAP_FORMAT_RGB15); - chip->sms_scanline_timer = timer_alloc(machine, sms_scanline_timer_callback, chip); + chip->sms_scanline_timer = machine->scheduler().timer_alloc(FUNC(sms_scanline_timer_callback), chip); return chip; } diff --git a/src/mame/machine/slikshot.c b/src/mame/machine/slikshot.c index f7fb4e8171b..f5a2b686d49 100644 --- a/src/mame/machine/slikshot.c +++ b/src/mame/machine/slikshot.c @@ -525,7 +525,7 @@ static TIMER_CALLBACK( delayed_z80_control_w ) WRITE8_HANDLER( slikshot_z80_control_w ) { - timer_call_after_resynch(space->machine, NULL, data, delayed_z80_control_w); + space->machine->scheduler().synchronize(FUNC(delayed_z80_control_w), data); } diff --git a/src/mame/machine/snes.c b/src/mame/machine/snes.c index 39c77d7d96d..7611a431d70 100644 --- a/src/mame/machine/snes.c +++ b/src/mame/machine/snes.c @@ -213,7 +213,7 @@ static TIMER_CALLBACK( snes_scanline_tick ) /* Start of VBlank */ if (snes_ppu.beam.current_vert == snes_ppu.beam.last_visible_line) { - timer_set(machine, machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert, 10), NULL, 0, snes_reset_oam_address); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert, 10), FUNC(snes_reset_oam_address)); snes_ram[HVBJOY] |= 0x81; /* Set vblank bit to on & indicate controllers being read */ snes_ram[RDNMI] |= 0x80; /* Set NMI occured bit */ @@ -766,7 +766,7 @@ WRITE8_HANDLER( snes_w_io ) break; case HDMAEN: /* HDMA channel designation */ if (data) //if a HDMA is enabled, data is inited at the next scanline - timer_set(space->machine, space->machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert + 1), NULL, 0, snes_reset_hdma); + space->machine->scheduler().timer_set(space->machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert + 1), FUNC(snes_reset_hdma)); break; case MEMSEL: /* Access cycle designation in memory (2) area */ /* FIXME: Need to adjust the speed only during access of banks 0x80+ @@ -1708,19 +1708,19 @@ static void snes_init_timers( running_machine *machine ) snes_state *state = machine->driver_data<snes_state>(); /* init timers and stop them */ - state->scanline_timer = timer_alloc(machine, snes_scanline_tick, NULL); + state->scanline_timer = machine->scheduler().timer_alloc(FUNC(snes_scanline_tick)); timer_adjust_oneshot(state->scanline_timer, attotime::never, 0); - state->hblank_timer = timer_alloc(machine, snes_hblank_tick, NULL); + state->hblank_timer = machine->scheduler().timer_alloc(FUNC(snes_hblank_tick)); timer_adjust_oneshot(state->hblank_timer, attotime::never, 0); - state->nmi_timer = timer_alloc(machine, snes_nmi_tick, NULL); + state->nmi_timer = machine->scheduler().timer_alloc(FUNC(snes_nmi_tick)); timer_adjust_oneshot(state->nmi_timer, attotime::never, 0); - state->hirq_timer = timer_alloc(machine, snes_hirq_tick_callback, NULL); + state->hirq_timer = machine->scheduler().timer_alloc(FUNC(snes_hirq_tick_callback)); timer_adjust_oneshot(state->hirq_timer, attotime::never, 0); - state->div_timer = timer_alloc(machine, snes_div_callback, NULL); + state->div_timer = machine->scheduler().timer_alloc(FUNC(snes_div_callback)); timer_adjust_oneshot(state->div_timer, attotime::never, 0); - state->mult_timer = timer_alloc(machine, snes_mult_callback, NULL); + state->mult_timer = machine->scheduler().timer_alloc(FUNC(snes_mult_callback)); timer_adjust_oneshot(state->mult_timer, attotime::never, 0); - state->io_timer = timer_alloc(machine, snes_update_io, NULL); + state->io_timer = machine->scheduler().timer_alloc(FUNC(snes_update_io)); timer_adjust_oneshot(state->io_timer, attotime::never, 0); // SNES hcounter has a 0-339 range. hblank starts at counter 260. diff --git a/src/mame/machine/starwars.c b/src/mame/machine/starwars.c index 8d684ad3ae1..c402a3cc8f7 100644 --- a/src/mame/machine/starwars.c +++ b/src/mame/machine/starwars.c @@ -178,7 +178,7 @@ void starwars_mproc_init(running_machine *machine) state->PROM_AM[cnt] = (val >> 7) & 0x0001; } - state->math_timer = timer_alloc(machine, math_run_clear, NULL); + state->math_timer = machine->scheduler().timer_alloc(FUNC(math_run_clear)); } diff --git a/src/mame/machine/stfight.c b/src/mame/machine/stfight.c index b198c0af9b1..7b1f83a6150 100644 --- a/src/mame/machine/stfight.c +++ b/src/mame/machine/stfight.c @@ -130,7 +130,7 @@ INTERRUPT_GEN( stfight_vb_interrupt ) { // Do a RST10 cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0xd7); - timer_set(device->machine, attotime::from_hz(120), NULL, 0, stfight_interrupt_1); + device->machine->scheduler().timer_set(attotime::from_hz(120), FUNC(stfight_interrupt_1)); } /* diff --git a/src/mame/machine/tait8741.c b/src/mame/machine/tait8741.c index bb073891cec..94869b0bbd0 100644 --- a/src/mame/machine/tait8741.c +++ b/src/mame/machine/tait8741.c @@ -204,7 +204,7 @@ static void taito8741_update(address_space *space, int num) st->txd[0] = st->portHandler ? st->portHandler(space,0) : st->portName ? input_port_read(space->machine, st->portName) : 0; if( sst ) { - timer_call_after_resynch(space->machine, NULL, num, taito8741_serial_tx); + space->machine->scheduler().synchronize(FUNC(taito8741_serial_tx), num); st->serial_out = 0; st->status |= 0x04; st->phase = CMD_08; @@ -440,7 +440,7 @@ static void josvolly_8741_do(running_machine *machine, int num) if( (i8741[num].sts & 0x02) ) { /* transmit data */ - timer_set (machine, attotime::from_usec(1), NULL, num, josvolly_8741_tx); + machine->scheduler().timer_set (attotime::from_usec(1), FUNC(josvolly_8741_tx), num); } } diff --git a/src/mame/machine/taitosj.c b/src/mame/machine/taitosj.c index 0ac7f8702d5..ee44493cc44 100644 --- a/src/mame/machine/taitosj.c +++ b/src/mame/machine/taitosj.c @@ -116,7 +116,7 @@ static TIMER_CALLBACK( taitosj_mcu_real_data_w ) WRITE8_HANDLER( taitosj_mcu_data_w ) { LOG(("%04x: protection write %02x\n",cpu_get_pc(space->cpu),data)); - timer_call_after_resynch(space->machine, NULL, data,taitosj_mcu_real_data_w); + space->machine->scheduler().synchronize(FUNC(taitosj_mcu_real_data_w), data); /* temporarily boost the interleave to sync things up */ cpuexec_boost_interleave(space->machine, attotime::zero, attotime::from_usec(10)); } @@ -200,7 +200,7 @@ WRITE8_HANDLER( taitosj_68705_portB_w ) if (~data & 0x02) { /* 68705 is going to read data from the Z80 */ - timer_call_after_resynch(space->machine, NULL, 0, taitosj_mcu_data_real_r); + space->machine->scheduler().synchronize(FUNC(taitosj_mcu_data_real_r)); cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE); state->portA_in = state->fromz80; LOG(("%04x: 68705 <- Z80 %02x\n", cpu_get_pc(space->cpu), state->portA_in)); @@ -214,7 +214,7 @@ WRITE8_HANDLER( taitosj_68705_portB_w ) LOG(("%04x: 68705 -> Z80 %02x\n", cpu_get_pc(space->cpu), state->portA_out)); /* 68705 is writing data for the Z80 */ - timer_call_after_resynch(space->machine, NULL, state->portA_out, taitosj_mcu_status_real_w); + space->machine->scheduler().synchronize(FUNC(taitosj_mcu_status_real_w), state->portA_out); } if (~data & 0x10) { diff --git a/src/mame/machine/ticket.c b/src/mame/machine/ticket.c index 5060260b450..a94cff90897 100644 --- a/src/mame/machine/ticket.c +++ b/src/mame/machine/ticket.c @@ -133,7 +133,7 @@ static DEVICE_START( ticket ) state->ticketdispensed = config->statushigh ? state->active_bit : 0; state->ticketnotdispensed = state->ticketdispensed ^ state->active_bit; - state->timer = timer_alloc(device->machine, ticket_dispenser_toggle, (void *)device); + state->timer = device->machine->scheduler().timer_alloc(FUNC(ticket_dispenser_toggle), (void *)device); state_save_register_device_item(device, 0, state->status); state_save_register_device_item(device, 0, state->power); diff --git a/src/mame/machine/tnzs.c b/src/mame/machine/tnzs.c index 2f0a6564da2..aaf4a576ba5 100644 --- a/src/mame/machine/tnzs.c +++ b/src/mame/machine/tnzs.c @@ -484,7 +484,7 @@ static TIMER_CALLBACK( kludge_callback ) static WRITE8_HANDLER( tnzs_sync_kludge_w ) { - timer_call_after_resynch(space->machine, NULL, data,kludge_callback); + space->machine->scheduler().synchronize(FUNC(kludge_callback), data); } */ diff --git a/src/mame/machine/vertigo.c b/src/mame/machine/vertigo.c index 65bfb3e31fe..431f077efb7 100644 --- a/src/mame/machine/vertigo.c +++ b/src/mame/machine/vertigo.c @@ -186,7 +186,7 @@ static TIMER_CALLBACK( sound_command_w ) WRITE16_HANDLER( vertigo_audio_w ) { if (ACCESSING_BITS_0_7) - timer_call_after_resynch(space->machine, NULL, data & 0xff, sound_command_w); + space->machine->scheduler().synchronize(FUNC(sound_command_w), data & 0xff); } diff --git a/src/mame/machine/volfied.c b/src/mame/machine/volfied.c index 605307527e5..7d3ff103d2e 100644 --- a/src/mame/machine/volfied.c +++ b/src/mame/machine/volfied.c @@ -392,12 +392,12 @@ WRITE16_HANDLER( volfied_cchip_ram_w ) // Palette request cmd - verified to take around 122242 68000 cycles to complete if (state->current_cmd >= 0x1 && state->current_cmd < 0x12) { - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(122242), NULL, 0, volfied_timer_callback); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(122242), FUNC(volfied_timer_callback)); } // Unknown cmd - verified to take around 105500 68000 cycles to complete else if (state->current_cmd >= 0x81 && state->current_cmd < 0x92) { - timer_set(space->machine, downcast<cpu_device *>(space->cpu)->cycles_to_attotime(105500), NULL, 0, volfied_timer_callback); + space->machine->scheduler().timer_set(downcast<cpu_device *>(space->cpu)->cycles_to_attotime(105500), FUNC(volfied_timer_callback)); } else { diff --git a/src/mame/machine/williams.c b/src/mame/machine/williams.c index 9eb8d67f9f0..71c6a6cd97d 100644 --- a/src/mame/machine/williams.c +++ b/src/mame/machine/williams.c @@ -280,7 +280,7 @@ TIMER_DEVICE_CALLBACK( williams_count240_callback ) pia6821_ca1_w(pia_1, 1); /* set a timer to turn it off once the scanline counter resets */ - timer_set(timer.machine, timer.machine->primary_screen->time_until_pos(0), NULL, 0, williams_count240_off_callback); + timer.machine->scheduler().timer_set(timer.machine->primary_screen->time_until_pos(0), FUNC(williams_count240_off_callback)); /* set a timer for next frame */ timer.adjust(timer.machine->primary_screen->time_until_pos(240)); @@ -425,7 +425,7 @@ TIMER_DEVICE_CALLBACK( williams2_endscreen_callback ) pia6821_ca1_w(pia_0, 0); /* set a timer to turn it off once the scanline counter resets */ - timer_set(timer.machine, timer.machine->primary_screen->time_until_pos(8), NULL, 0, williams2_endscreen_off_callback); + timer.machine->scheduler().timer_set(timer.machine->primary_screen->time_until_pos(8), FUNC(williams2_endscreen_off_callback)); /* set a timer for next frame */ timer.adjust(timer.machine->primary_screen->time_until_pos(254)); @@ -546,12 +546,12 @@ static TIMER_CALLBACK( williams_deferred_snd_cmd_w ) WRITE8_DEVICE_HANDLER( williams_snd_cmd_w ) { /* the high two bits are set externally, and should be 1 */ - timer_call_after_resynch(device->machine, NULL, data | 0xc0, williams_deferred_snd_cmd_w); + device->machine->scheduler().synchronize(FUNC(williams_deferred_snd_cmd_w), data | 0xc0); } WRITE8_DEVICE_HANDLER( playball_snd_cmd_w ) { - timer_call_after_resynch(device->machine, NULL, data, williams_deferred_snd_cmd_w); + device->machine->scheduler().synchronize(FUNC(williams_deferred_snd_cmd_w), data); } @@ -564,7 +564,7 @@ static TIMER_CALLBACK( williams2_deferred_snd_cmd_w ) static WRITE8_DEVICE_HANDLER( williams2_snd_cmd_w ) { - timer_call_after_resynch(device->machine, NULL, data, williams2_deferred_snd_cmd_w); + device->machine->scheduler().synchronize(FUNC(williams2_deferred_snd_cmd_w), data); } @@ -983,5 +983,5 @@ static WRITE8_DEVICE_HANDLER( joust2_snd_cmd_w ) { joust2_current_sound_data = (joust2_current_sound_data & ~0xff) | (data & 0xff); williams_cvsd_data_w(device->machine, joust2_current_sound_data); - timer_call_after_resynch(device->machine, NULL, joust2_current_sound_data, joust2_deferred_snd_cmd_w); + device->machine->scheduler().synchronize(FUNC(joust2_deferred_snd_cmd_w), joust2_current_sound_data); } diff --git a/src/mame/video/astrocde.c b/src/mame/video/astrocde.c index ae22395eb0f..7298cc2b7ae 100644 --- a/src/mame/video/astrocde.c +++ b/src/mame/video/astrocde.c @@ -222,7 +222,7 @@ PALETTE_INIT( profpac ) VIDEO_START( astrocde ) { /* allocate a per-scanline timer */ - scanline_timer = timer_alloc(machine, scanline_callback, NULL); + scanline_timer = machine->scheduler().timer_alloc(FUNC(scanline_callback)); timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(1), 1); /* register for save states */ @@ -237,7 +237,7 @@ VIDEO_START( astrocde ) VIDEO_START( profpac ) { /* allocate a per-scanline timer */ - scanline_timer = timer_alloc(machine, scanline_callback, NULL); + scanline_timer = machine->scheduler().timer_alloc(FUNC(scanline_callback)); timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(1), 1); /* allocate videoram */ @@ -443,14 +443,14 @@ static void astrocade_trigger_lightpen(running_machine *machine, UINT8 vfeedback if ((interrupt_enable & 0x01) == 0) { cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, interrupt_vector & 0xf0); - timer_set(machine, machine->primary_screen->time_until_pos(vfeedback), NULL, 0, interrupt_off); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(vfeedback), FUNC(interrupt_off)); } /* mode 1 means assert for 1 instruction */ else { cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, interrupt_vector & 0xf0); - timer_set(machine, machine->device<cpu_device>("maincpu")->cycles_to_attotime(1), NULL, 0, interrupt_off); + machine->scheduler().timer_set(machine->device<cpu_device>("maincpu")->cycles_to_attotime(1), FUNC(interrupt_off)); } /* latch the feedback registers */ @@ -483,14 +483,14 @@ static TIMER_CALLBACK( scanline_callback ) if ((interrupt_enable & 0x04) == 0) { cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, interrupt_vector); - timer_set(machine, machine->primary_screen->time_until_vblank_end(), NULL, 0, interrupt_off); + machine->scheduler().timer_set(machine->primary_screen->time_until_vblank_end(), FUNC(interrupt_off)); } /* mode 1 means assert for 1 instruction */ else { cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, interrupt_vector); - timer_set(machine, machine->device<cpu_device>("maincpu")->cycles_to_attotime(1), NULL, 0, interrupt_off); + machine->scheduler().timer_set(machine->device<cpu_device>("maincpu")->cycles_to_attotime(1), FUNC(interrupt_off)); } } diff --git a/src/mame/video/atari.c b/src/mame/video/atari.c index 6f394cca1be..24efb03adc8 100644 --- a/src/mame/video/atari.c +++ b/src/mame/video/atari.c @@ -1051,12 +1051,12 @@ static int cycle(running_machine *machine) return machine->primary_screen->hpos() * CYCLES_PER_LINE / machine->primary_screen->width(); } -static void after(running_machine *machine, int cycles, timer_fired_func function, const char *funcname) +static void after(running_machine *machine, int cycles, timer_expired_func function, const char *funcname) { attotime duration = machine->primary_screen->scan_period() * cycles / CYCLES_PER_LINE; (void)funcname; LOG((" after %3d (%5.1f us) %s\n", cycles, duration.as_double() * 1.0e6, funcname)); - timer_set(machine, duration, NULL, 0, function); + machine->scheduler().timer_set(duration, function, funcname); } static TIMER_CALLBACK( antic_issue_dli ) @@ -1158,7 +1158,7 @@ static TIMER_CALLBACK( antic_line_done ) static TIMER_CALLBACK( antic_steal_cycles ) { LOG((" @cycle #%3d steal %d cycles\n", cycle(machine), antic.steal_cycles)); - after(machine, antic.steal_cycles, antic_line_done, "antic_line_done"); + after(machine, antic.steal_cycles, FUNC(antic_line_done)); antic.steal_cycles = 0; cpu_spinuntil_trigger( machine->device("maincpu"), TRIGGER_STEAL ); } @@ -1229,7 +1229,7 @@ static TIMER_CALLBACK( antic_scanline_render ) antic.steal_cycles += CYCLES_REFRESH; LOG((" run CPU for %d cycles\n", CYCLES_HSYNC - CYCLES_HSTART - antic.steal_cycles)); - after(machine, CYCLES_HSYNC - CYCLES_HSTART - antic.steal_cycles, antic_steal_cycles, "antic_steal_cycles"); + after(machine, CYCLES_HSYNC - CYCLES_HSTART - antic.steal_cycles, FUNC(antic_steal_cycles)); } @@ -1341,7 +1341,7 @@ static void antic_scanline_dma(running_machine *machine, int param) { /* remove the DLI bit */ new_cmd &= ~ANTIC_DLI; - after(machine, CYCLES_DLI_NMI, antic_issue_dli, "antic_issue_dli"); + after(machine, CYCLES_DLI_NMI, FUNC(antic_issue_dli)); } /* load memory scan bit set ? */ if( new_cmd & ANTIC_LMS ) @@ -1473,9 +1473,9 @@ static void antic_scanline_dma(running_machine *machine, int param) antic.r.nmist &= ~DLI_NMI; if( antic.modelines == 1 && (antic.cmd & antic.w.nmien & DLI_NMI) ) - after(machine, CYCLES_DLI_NMI, antic_issue_dli, "antic_issue_dli"); + after(machine, CYCLES_DLI_NMI, FUNC(antic_issue_dli)); - after(machine, CYCLES_HSTART, antic_scanline_render, "antic_scanline_render"); + after(machine, CYCLES_HSTART, FUNC(antic_scanline_render)); } /***************************************************************************** diff --git a/src/mame/video/atarimo.c b/src/mame/video/atarimo.c index b9a8ae351db..56b94b96b21 100644 --- a/src/mame/video/atarimo.c +++ b/src/mame/video/atarimo.c @@ -440,7 +440,7 @@ void atarimo_init(running_machine *machine, int map, const atarimo_desc *desc) init_gfxelement(mo, desc->gfxindex); /* start a timer to update a few times during refresh */ - force_update_timer = timer_alloc(machine, force_update, NULL); + force_update_timer = machine->scheduler().timer_alloc(FUNC(force_update)); timer_adjust_oneshot(force_update_timer,machine->primary_screen->time_until_pos(0), 0); init_savestate(machine, map, mo); diff --git a/src/mame/video/atarisy2.c b/src/mame/video/atarisy2.c index 20eeacafca5..9b870da100a 100644 --- a/src/mame/video/atarisy2.c +++ b/src/mame/video/atarisy2.c @@ -110,7 +110,7 @@ VIDEO_START( atarisy2 ) tilemap_set_transparent_pen(state->alpha_tilemap, 0); /* reset the statics */ - state->yscroll_reset_timer = timer_alloc(machine, reset_yscroll_callback, NULL); + state->yscroll_reset_timer = machine->scheduler().timer_alloc(FUNC(reset_yscroll_callback)); state->videobank = 0; /* save states */ diff --git a/src/mame/video/avgdvg.c b/src/mame/video/avgdvg.c index 0391723770d..a2b814ddb8e 100644 --- a/src/mame/video/avgdvg.c +++ b/src/mame/video/avgdvg.c @@ -1504,8 +1504,8 @@ static VIDEO_START( avg_common ) flip_x = flip_y = 0; - vg_halt_timer = timer_alloc(machine, vg_set_halt_callback, NULL); - vg_run_timer = timer_alloc(machine, run_state_machine, NULL); + vg_halt_timer = machine->scheduler().timer_alloc(FUNC(vg_set_halt_callback)); + vg_run_timer = machine->scheduler().timer_alloc(FUNC(run_state_machine)); /* * The x and y DACs use 10 bit of the counter values which are in @@ -1530,8 +1530,8 @@ VIDEO_START( dvg ) xmin = visarea.min_x; ymin = visarea.min_y; - vg_halt_timer = timer_alloc(machine, vg_set_halt_callback, NULL); - vg_run_timer = timer_alloc(machine, run_state_machine, NULL); + vg_halt_timer = machine->scheduler().timer_alloc(FUNC(vg_set_halt_callback)); + vg_run_timer = machine->scheduler().timer_alloc(FUNC(run_state_machine)); register_state (machine); diff --git a/src/mame/video/blstroid.c b/src/mame/video/blstroid.c index 1a19ae0d56f..4188f470b1e 100644 --- a/src/mame/video/blstroid.c +++ b/src/mame/video/blstroid.c @@ -130,8 +130,8 @@ void blstroid_scanline_update(screen_device &screen, int scanline) period_on = screen.time_until_pos(vpos + 7, width * 0.9); period_off = screen.time_until_pos(vpos + 8, width * 0.9); - timer_set(screen.machine, period_on, NULL, 0, irq_on); - timer_set(screen.machine, period_off, NULL, 0, irq_off); + screen.machine->scheduler().timer_set(period_on, FUNC(irq_on)); + screen.machine->scheduler().timer_set(period_off, FUNC(irq_off)); } } diff --git a/src/mame/video/cchasm.c b/src/mame/video/cchasm.c index ec43282e318..0498fe48e1c 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::from_hz(6000000) * total_length, NULL, 0, cchasm_refresh_end); + machine->scheduler().timer_set (attotime::from_hz(6000000) * total_length, FUNC(cchasm_refresh_end)); } diff --git a/src/mame/video/changela.c b/src/mame/video/changela.c index cdfe15d4f18..ad0806d8a31 100644 --- a/src/mame/video/changela.c +++ b/src/mame/video/changela.c @@ -29,7 +29,7 @@ VIDEO_START( changela ) state->tree0_bitmap = machine->primary_screen->alloc_compatible_bitmap(); state->tree1_bitmap = machine->primary_screen->alloc_compatible_bitmap(); - state->scanline_timer = timer_alloc(machine, changela_scanline_callback, NULL); + state->scanline_timer = machine->scheduler().timer_alloc(FUNC(changela_scanline_callback)); timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(30), 30); state_save_register_global_pointer(machine, state->memory_devices, 4 * 0x800); diff --git a/src/mame/video/dc.c b/src/mame/video/dc.c index 40e83416689..c6230e40fea 100644 --- a/src/mame/video/dc.c +++ b/src/mame/video/dc.c @@ -1399,11 +1399,11 @@ static void process_ta_fifo(running_machine* machine) /* FIXME: timing of these */ switch (state_ta.tafifo_listtype) { - case 0: timer_set(machine, attotime::from_usec(100), NULL, 0, transfer_opaque_list_irq); break; - case 1: timer_set(machine, attotime::from_usec(100), NULL, 0, transfer_opaque_modifier_volume_list_irq); break; - case 2: timer_set(machine, attotime::from_usec(100), NULL, 0, transfer_translucent_list_irq); break; - case 3: timer_set(machine, attotime::from_usec(100), NULL, 0, transfer_translucent_modifier_volume_list_irq); break; - case 4: timer_set(machine, attotime::from_usec(100), NULL, 0, transfer_punch_through_list_irq); break; + case 0: machine->scheduler().timer_set(attotime::from_usec(100), FUNC(transfer_opaque_list_irq)); break; + case 1: machine->scheduler().timer_set(attotime::from_usec(100), FUNC(transfer_opaque_modifier_volume_list_irq)); break; + case 2: machine->scheduler().timer_set(attotime::from_usec(100), FUNC(transfer_translucent_list_irq)); break; + case 3: machine->scheduler().timer_set(attotime::from_usec(100), FUNC(transfer_translucent_modifier_volume_list_irq)); break; + case 4: machine->scheduler().timer_set(attotime::from_usec(100), FUNC(transfer_punch_through_list_irq)); break; } state_ta.tafifo_listtype= -1; // no list being received state_ta.listtype_used |= (2+8); @@ -2551,21 +2551,21 @@ VIDEO_START(dc) computedilated(); - vbout_timer = timer_alloc(machine, vbout, 0); + vbout_timer = machine->scheduler().timer_alloc(FUNC(vbout)); timer_adjust_oneshot(vbout_timer, machine->primary_screen->time_until_pos(spg_vblank_out_irq_line_num), 0); - vbin_timer = timer_alloc(machine, vbin, 0); + vbin_timer = machine->scheduler().timer_alloc(FUNC(vbin)); timer_adjust_oneshot(vbin_timer, machine->primary_screen->time_until_pos(spg_vblank_in_irq_line_num), 0); - hbin_timer = timer_alloc(machine, hbin, 0); + hbin_timer = machine->scheduler().timer_alloc(FUNC(hbin)); timer_adjust_oneshot(hbin_timer, machine->primary_screen->time_until_pos(0, spg_hblank_in_irq-1), 0); scanline = 0; next_y = 0; - endofrender_timer_isp = timer_alloc(machine, endofrender_isp, 0); - endofrender_timer_tsp = timer_alloc(machine, endofrender_tsp, 0); - endofrender_timer_video = timer_alloc(machine, endofrender_video, 0); + endofrender_timer_isp = machine->scheduler().timer_alloc(FUNC(endofrender_isp)); + endofrender_timer_tsp = machine->scheduler().timer_alloc(FUNC(endofrender_tsp)); + endofrender_timer_video = machine->scheduler().timer_alloc(FUNC(endofrender_video)); timer_adjust_oneshot(endofrender_timer_isp, attotime::never, 0); timer_adjust_oneshot(endofrender_timer_tsp, attotime::never, 0); diff --git a/src/mame/video/dcheese.c b/src/mame/video/dcheese.c index e13c41c9c4d..5c7dd54a6df 100644 --- a/src/mame/video/dcheese.c +++ b/src/mame/video/dcheese.c @@ -98,7 +98,7 @@ VIDEO_START( dcheese ) state->dstbitmap = auto_bitmap_alloc(machine, DSTBITMAP_WIDTH, DSTBITMAP_HEIGHT, machine->primary_screen->format()); /* create a timer */ - state->blitter_timer = timer_alloc(machine, blitter_scanline_callback, NULL); + state->blitter_timer = machine->scheduler().timer_alloc(FUNC(blitter_scanline_callback)); /* register for saving */ state_save_register_global_array(machine, state->blitter_color); @@ -151,7 +151,7 @@ static void do_clear( running_machine *machine ) memset(BITMAP_ADDR16(state->dstbitmap, y % DSTBITMAP_HEIGHT, 0), 0, DSTBITMAP_WIDTH * 2); /* signal an IRQ when done (timing is just a guess) */ - timer_set(machine, machine->primary_screen->scan_period(), NULL, 1, dcheese_signal_irq_callback); + machine->scheduler().timer_set(machine->primary_screen->scan_period(), FUNC(dcheese_signal_irq_callback), 1); } @@ -206,7 +206,7 @@ static void do_blit( running_machine *machine ) } /* signal an IRQ when done (timing is just a guess) */ - timer_set(machine, machine->primary_screen->scan_period() / 2, NULL, 2, dcheese_signal_irq_callback); + machine->scheduler().timer_set(machine->primary_screen->scan_period() / 2, FUNC(dcheese_signal_irq_callback), 2); /* 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/dday.c b/src/mame/video/dday.c index f47af2e8ea4..98612a22568 100644 --- a/src/mame/video/dday.c +++ b/src/mame/video/dday.c @@ -39,7 +39,7 @@ static void start_countdown_timer(running_machine *machine) state->timer_value = 0; - timer_pulse(machine, attotime::from_seconds(1), NULL, 0, countdown_timer_callback); + machine->scheduler().timer_pulse(attotime::from_seconds(1), FUNC(countdown_timer_callback)); } diff --git a/src/mame/video/dkong.c b/src/mame/video/dkong.c index 89db6e760d9..fbc643cf8f5 100644 --- a/src/mame/video/dkong.c +++ b/src/mame/video/dkong.c @@ -944,7 +944,7 @@ VIDEO_START( dkong ) VIDEO_START_CALL(dkong_base); - state->scanline_timer = timer_alloc(machine, scanline_callback, NULL); + state->scanline_timer = machine->scheduler().timer_alloc(FUNC(scanline_callback)); timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(0), 0); switch (state->hardware_type) diff --git a/src/mame/video/esripsys.c b/src/mame/video/esripsys.c index b8df1876bfc..cb8cbbb6fb2 100644 --- a/src/mame/video/esripsys.c +++ b/src/mame/video/esripsys.c @@ -104,8 +104,8 @@ VIDEO_START( esripsys ) line_buffer[1].priority_buf = auto_alloc_array(machine, UINT8, 512); /* Create and initialise the HBLANK timers */ - hblank_start_timer = timer_alloc(machine, hblank_start_callback, NULL); - hblank_end_timer = timer_alloc(machine, hblank_end_callback, NULL); + hblank_start_timer = machine->scheduler().timer_alloc(FUNC(hblank_start_callback)); + hblank_end_timer = machine->scheduler().timer_alloc(FUNC(hblank_end_callback)); timer_adjust_oneshot(hblank_start_timer, machine->primary_screen->time_until_pos(0, ESRIPSYS_HBLANK_START), 0); /* Create the sprite scaling table */ diff --git a/src/mame/video/exidy.c b/src/mame/video/exidy.c index 1a5e43296da..8c4fe40836e 100644 --- a/src/mame/video/exidy.c +++ b/src/mame/video/exidy.c @@ -361,7 +361,7 @@ static void check_collision(running_machine *machine) /* if we got one, trigger an interrupt */ if ((current_collision_mask & collision_mask) && (count++ < 128)) - timer_set(machine, machine->primary_screen->time_until_pos(org_1_x + sx, org_1_y + sy), NULL, current_collision_mask, collision_irq_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(org_1_x + sx, org_1_y + sy), FUNC(collision_irq_callback), current_collision_mask); } if (*BITMAP_ADDR16(motion_object_2_vid, sy, sx) != 0xff) @@ -369,7 +369,7 @@ static void check_collision(running_machine *machine) /* check for background collision (M2CHAR) */ if (*BITMAP_ADDR16(background_bitmap, org_2_y + sy, org_2_x + sx) != 0) if ((collision_mask & 0x08) && (count++ < 128)) - timer_set(machine, machine->primary_screen->time_until_pos(org_2_x + sx, org_2_y + sy), NULL, 0x08, collision_irq_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(org_2_x + sx, org_2_y + sy), FUNC(collision_irq_callback), 0x08); } } } diff --git a/src/mame/video/exidy440.c b/src/mame/video/exidy440.c index 6baaaf13339..531cf599618 100644 --- a/src/mame/video/exidy440.c +++ b/src/mame/video/exidy440.c @@ -374,7 +374,7 @@ static void draw_sprites(screen_device &screen, bitmap_t *bitmap, const rectangl /* check the collisions bit */ if (check_collision && (palette[2 * pen] & 0x80) && (count++ < 128)) - timer_set(screen.machine, screen.time_until_pos(yoffs, currx), NULL, currx, collide_firq_callback); + screen.machine->scheduler().timer_set(screen.time_until_pos(yoffs, currx), FUNC(collide_firq_callback), currx); } currx++; @@ -387,7 +387,7 @@ static void draw_sprites(screen_device &screen, bitmap_t *bitmap, const rectangl /* check the collisions bit */ if (check_collision && (palette[2 * pen] & 0x80) && (count++ < 128)) - timer_set(screen.machine, screen.time_until_pos(yoffs, currx), NULL, currx, collide_firq_callback); + screen.machine->scheduler().timer_set(screen.time_until_pos(yoffs, currx), FUNC(collide_firq_callback), currx); } currx++; } @@ -458,7 +458,7 @@ static VIDEO_UPDATE( exidy440 ) 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); + screen->machine->scheduler().timer_set(time, FUNC(beam_firq_callback), beamx); time += increment; } } diff --git a/src/mame/video/fromance.c b/src/mame/video/fromance.c index 726e1b8e3bc..2385a069a45 100644 --- a/src/mame/video/fromance.c +++ b/src/mame/video/fromance.c @@ -70,7 +70,7 @@ static void init_common( running_machine *machine ) tilemap_set_transparent_pen(state->fg_tilemap, 15); /* reset the timer */ - state->crtc_timer = timer_alloc(machine, crtc_interrupt_gen, NULL); + state->crtc_timer = machine->scheduler().timer_alloc(FUNC(crtc_interrupt_gen)); /* state save */ state_save_register_global(machine, state->selected_videoram); diff --git a/src/mame/video/galaxold.c b/src/mame/video/galaxold.c index 1ac3c0e03d4..0ba2cfef2f2 100644 --- a/src/mame/video/galaxold.c +++ b/src/mame/video/galaxold.c @@ -1500,8 +1500,8 @@ void galaxold_init_stars(running_machine *machine, int colors_offset) galaxold_stars_on = 0; stars_blink_state = 0; - stars_blink_timer = timer_alloc(machine, stars_blink_callback, NULL); - stars_scroll_timer = timer_alloc(machine, stars_scroll_callback, NULL); + stars_blink_timer = machine->scheduler().timer_alloc(FUNC(stars_blink_callback)); + stars_scroll_timer = machine->scheduler().timer_alloc(FUNC(stars_scroll_callback)); timer_adjusted = 0; stars_colors_start = colors_offset; diff --git a/src/mame/video/gameplan.c b/src/mame/video/gameplan.c index db9c085cb75..abbcc299eca 100644 --- a/src/mame/video/gameplan.c +++ b/src/mame/video/gameplan.c @@ -203,7 +203,7 @@ static WRITE_LINE_DEVICE_HANDLER( video_command_trigger_w ) /* set a timer for an arbitrarily short period. The real time it takes to clear to screen is not important to the software */ - timer_call_after_resynch(device->machine, NULL, 0, clear_screen_done_callback); + device->machine->scheduler().synchronize(FUNC(clear_screen_done_callback)); break; } @@ -223,7 +223,7 @@ static void via_irq(device_t *device, int state) /* Kaos sits in a tight loop polling the VIA irq flags register, but that register is cleared by the irq handler. Therefore, I wait a bit before triggering the irq to leave time for the program to see the flag change. */ - timer_set(device->machine, attotime::from_usec(50), NULL, state, via_irq_delayed); + device->machine->scheduler().timer_set(attotime::from_usec(50), FUNC(via_irq_delayed), state); } @@ -291,7 +291,7 @@ static VIDEO_START( common ) state->videoram_size = (HBSTART - HBEND) * (VBSTART - VBEND); state->videoram = auto_alloc_array(machine, UINT8, state->videoram_size); - state->via_0_ca1_timer = timer_alloc(machine, via_0_ca1_timer_callback, NULL); + state->via_0_ca1_timer = machine->scheduler().timer_alloc(FUNC(via_0_ca1_timer_callback)); /* register for save states */ state_save_register_global_pointer(machine, state->videoram, state->videoram_size); diff --git a/src/mame/video/hyhoo.c b/src/mame/video/hyhoo.c index 4d29b1dc94d..1776a9b75dc 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::from_hz(400000) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); + machine->scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, FUNC(blitter_timer_callback)); } diff --git a/src/mame/video/itech32.c b/src/mame/video/itech32.c index 9281855da9a..6e19d53abfe 100644 --- a/src/mame/video/itech32.c +++ b/src/mame/video/itech32.c @@ -232,7 +232,7 @@ VIDEO_START( itech32 ) /* reset statics */ memset(itech32_video, 0, 0x80); - scanline_timer = timer_alloc(machine, scanline_interrupt, NULL); + scanline_timer = machine->scheduler().timer_alloc(FUNC(scanline_interrupt)); enable_latch[0] = 1; enable_latch[1] = (itech32_planes > 1) ? 1 : 0; diff --git a/src/mame/video/itech8.c b/src/mame/video/itech8.c index dc2c2f21210..5202b1b7ae9 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::from_hz(12000000/4) * (BLITTER_WIDTH * BLITTER_HEIGHT + 12), NULL, 0, blitter_done); + space->machine->scheduler().timer_set(attotime::from_hz(12000000/4) * (BLITTER_WIDTH * BLITTER_HEIGHT + 12), FUNC(blitter_done)); } /* debugging */ diff --git a/src/mame/video/jaguar.c b/src/mame/video/jaguar.c index 0cd5e0a9265..8f2f7b1af65 100644 --- a/src/mame/video/jaguar.c +++ b/src/mame/video/jaguar.c @@ -628,7 +628,7 @@ WRITE32_HANDLER( jaguar_blitter_w ) if (offset == B_CMD) { blitter_status = 0; - timer_set(space->machine, attotime::from_usec(100), NULL, 0, blitter_done); + space->machine->scheduler().timer_set(attotime::from_usec(100), FUNC(blitter_done)); blitter_run(space->machine); } @@ -688,7 +688,7 @@ static TIMER_CALLBACK( jaguar_pit ) if (gpu_regs[PIT0]) { sample_period = attotime::from_nsec(((machine->device("gpu")->unscaled_clock()*PIT_MULT_DBG_HACK) / (1+gpu_regs[PIT0])) / (1+gpu_regs[PIT1])); - timer_set(machine, sample_period, NULL, 0, jaguar_pit); + machine->scheduler().timer_set(sample_period, FUNC(jaguar_pit)); } } @@ -713,7 +713,7 @@ WRITE16_HANDLER( jaguar_tom_regs_w ) if (gpu_regs[PIT0] && gpu_regs[PIT0] != 0xffff) //FIXME: avoid too much small timers for now { sample_period = attotime::from_nsec(((space->machine->device("gpu")->unscaled_clock()*PIT_MULT_DBG_HACK) / (1+gpu_regs[PIT0])) / (1+gpu_regs[PIT1])); - timer_set(space->machine, sample_period, NULL, 0, jaguar_pit); + space->machine->scheduler().timer_set(sample_period, FUNC(jaguar_pit)); } break; @@ -902,7 +902,7 @@ VIDEO_START( cojag ) memset(&gpu_regs, 0, sizeof(gpu_regs)); cpu_irq_state = 0; - object_timer = timer_alloc(machine, cojag_scanline_update, NULL); + object_timer = machine->scheduler().timer_alloc(FUNC(cojag_scanline_update)); adjust_object_timer(machine, 0); screen_bitmap = auto_bitmap_alloc(machine, 760, 512, BITMAP_FORMAT_RGB32); diff --git a/src/mame/video/leland.c b/src/mame/video/leland.c index 8d69c7c6cb5..9cac8f2052d 100644 --- a/src/mame/video/leland.c +++ b/src/mame/video/leland.c @@ -83,7 +83,7 @@ static VIDEO_START( leland ) leland_video_ram = auto_alloc_array_clear(machine, UINT8, VRAM_SIZE); /* scanline timer */ - scanline_timer = timer_alloc(machine, scanline_callback, NULL); + scanline_timer = machine->scheduler().timer_alloc(FUNC(scanline_callback)); timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0); } @@ -318,7 +318,7 @@ static TIMER_CALLBACK( leland_delayed_mvram_w ) WRITE8_HANDLER( leland_mvram_port_w ) { - timer_call_after_resynch(space->machine, NULL, 0x00000 | (offset << 8) | data, leland_delayed_mvram_w); + space->machine->scheduler().synchronize(FUNC(leland_delayed_mvram_w), 0x00000 | (offset << 8) | data); } @@ -363,7 +363,7 @@ READ8_HANDLER( leland_svram_port_r ) WRITE8_HANDLER( ataxx_mvram_port_w ) { offset = ((offset >> 1) & 0x07) | ((offset << 3) & 0x08) | (offset & 0x10); - timer_call_after_resynch(space->machine, NULL, 0x00000 | (offset << 8) | data, leland_delayed_mvram_w); + space->machine->scheduler().synchronize(FUNC(leland_delayed_mvram_w), 0x00000 | (offset << 8) | data); } diff --git a/src/mame/video/lethalj.c b/src/mame/video/lethalj.c index a0bdddf8365..3aba9a112d8 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::from_hz(XTAL_32MHz) * ((blitter_data[5] + 1) * (blitter_data[7] + 1)), NULL, 0, gen_ext1_int); + space->machine->scheduler().timer_set(attotime::from_hz(XTAL_32MHz) * ((blitter_data[5] + 1) * (blitter_data[7] + 1)), FUNC(gen_ext1_int)); } /* clear the IRQ on offset 0 */ diff --git a/src/mame/video/lockon.c b/src/mame/video/lockon.c index d3af2eaca8c..8ea6bb0518d 100644 --- a/src/mame/video/lockon.c +++ b/src/mame/video/lockon.c @@ -918,10 +918,10 @@ VIDEO_START( lockon ) state->obj_pal_ram = auto_alloc_array(machine, UINT8, 2048); /* Timer for ground display list callback */ - state->bufend_timer = timer_alloc(machine, bufend_callback, NULL); + state->bufend_timer = machine->scheduler().timer_alloc(FUNC(bufend_callback)); /* Timer for the CRTC cursor pulse */ - state->cursor_timer = timer_alloc(machine, cursor_callback, NULL); + state->cursor_timer = machine->scheduler().timer_alloc(FUNC(cursor_callback)); timer_adjust_oneshot(state->cursor_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0); state_save_register_global_bitmap(machine, state->back_buffer); diff --git a/src/mame/video/m92.c b/src/mame/video/m92.c index 359c89663fc..b5b60d25e58 100644 --- a/src/mame/video/m92.c +++ b/src/mame/video/m92.c @@ -79,7 +79,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::from_hz(26666000) * 0x400, NULL, 0, spritebuffer_callback); + space->machine->scheduler().timer_set(attotime::from_hz(26666000) * 0x400, FUNC(spritebuffer_callback)); } // logerror("%04x: m92_spritecontrol_w %08x %08x\n",cpu_get_pc(space->cpu),offset,data); } diff --git a/src/mame/video/mcd212.c b/src/mame/video/mcd212.c index ea754e1cd1b..e76af4e6610 100644 --- a/src/mame/video/mcd212.c +++ b/src/mame/video/mcd212.c @@ -1655,7 +1655,7 @@ VIDEO_START( cdimono1 ) VIDEO_START_CALL(generic_bitmapped); mcd212_ab_init(&state->mcd212_ab); mcd212_init(machine, &state->mcd212_regs); - state->mcd212_regs.scan_timer = timer_alloc(machine, mcd212_perform_scan, 0); + state->mcd212_regs.scan_timer = machine->scheduler().timer_alloc(FUNC(mcd212_perform_scan)); timer_adjust_oneshot(state->mcd212_regs.scan_timer, machine->primary_screen->time_until_pos(0, 0), 0); state->lcdbitmap = downcast<screen_device *>(machine->device("lcd"))->alloc_compatible_bitmap(); diff --git a/src/mame/video/midtunit.c b/src/mame/video/midtunit.c index 01ea0fabfa9..28ed5453396 100644 --- a/src/mame/video/midtunit.c +++ b/src/mame/video/midtunit.c @@ -787,7 +787,7 @@ if (LOG_DMA) /* signal we're done */ skipdma: - timer_set(space->machine, attotime::from_nsec(41 * pixels), NULL, 0, dma_callback); + space->machine->scheduler().timer_set(attotime::from_nsec(41 * pixels), FUNC(dma_callback)); g_profiler.stop(); } diff --git a/src/mame/video/midvunit.c b/src/mame/video/midvunit.c index 83334fbf4dd..f9a4e4f7475 100644 --- a/src/mame/video/midvunit.c +++ b/src/mame/video/midvunit.c @@ -61,7 +61,7 @@ static TIMER_CALLBACK( scanline_timer_cb ) { cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline + 1), scanline); - timer_set(machine, attotime::from_hz(25000000), NULL, -1, scanline_timer_cb); + machine->scheduler().timer_set(attotime::from_hz(25000000), FUNC(scanline_timer_cb), -1); } else cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); @@ -76,7 +76,7 @@ static void midvunit_exit(running_machine &machine) VIDEO_START( midvunit ) { - scanline_timer = timer_alloc(machine, scanline_timer_cb, NULL); + scanline_timer = machine->scheduler().timer_alloc(FUNC(scanline_timer_cb)); poly = poly_alloc(machine, 4000, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS); machine->add_notifier(MACHINE_NOTIFY_EXIT, midvunit_exit); diff --git a/src/mame/video/midyunit.c b/src/mame/video/midyunit.c index 0d5ae825a95..a6c5b11a8fb 100644 --- a/src/mame/video/midyunit.c +++ b/src/mame/video/midyunit.c @@ -541,7 +541,7 @@ if (LOG_DMA) } /* signal we're done */ - timer_set(space->machine, attotime::from_nsec(41 * dma_state.width * dma_state.height), NULL, 0, dma_callback); + space->machine->scheduler().timer_set(attotime::from_nsec(41 * dma_state.width * dma_state.height), FUNC(dma_callback)); g_profiler.stop(); } @@ -580,5 +580,5 @@ void midyunit_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanl /* if this is the last update of the screen, set a timer to clear out the final line */ /* (since we update one behind) */ if (scanline == screen.visible_area().max_y) - timer_set(screen.machine, screen.time_until_pos(scanline + 1, 0), NULL, params->rowaddr, autoerase_line); + screen.machine->scheduler().timer_set(screen.time_until_pos(scanline + 1), FUNC(autoerase_line), params->rowaddr); } diff --git a/src/mame/video/midzeus2.c b/src/mame/video/midzeus2.c index 3fef8c3bc34..b7a6b6e8476 100644 --- a/src/mame/video/midzeus2.c +++ b/src/mame/video/midzeus2.c @@ -280,7 +280,7 @@ VIDEO_START( midzeus2 ) texel_width = 256; zeus_renderbase = waveram[1]; - int_timer = timer_alloc(machine, int_timer_callback, NULL); + int_timer = machine->scheduler().timer_alloc(FUNC(int_timer_callback)); /* save states */ state_save_register_global_pointer(machine, waveram[0], WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8 / sizeof(waveram[0][0])); diff --git a/src/mame/video/mystston.c b/src/mame/video/mystston.c index 7e2a14c4b2a..52939bd2ca0 100644 --- a/src/mame/video/mystston.c +++ b/src/mame/video/mystston.c @@ -228,7 +228,7 @@ static VIDEO_START( mystston ) tilemap_set_transparent_pen(state->fg_tilemap, 0); /* create the interrupt timer */ - state->interrupt_timer = timer_alloc(machine, interrupt_callback, NULL); + state->interrupt_timer = machine->scheduler().timer_alloc(FUNC(interrupt_callback)); } diff --git a/src/mame/video/n8080.c b/src/mame/video/n8080.c index 6cbcebab982..7ae24233316 100644 --- a/src/mame/video/n8080.c +++ b/src/mame/video/n8080.c @@ -93,7 +93,7 @@ VIDEO_START( spacefev ) { n8080_state *state = machine->driver_data<n8080_state>(); - state->cannon_timer = timer_alloc(machine, spacefev_stop_red_cannon, NULL); + state->cannon_timer = machine->scheduler().timer_alloc(FUNC(spacefev_stop_red_cannon)); flip_screen_set_no_update(machine, 0); diff --git a/src/mame/video/nbmj8688.c b/src/mame/video/nbmj8688.c index 6ed21794362..90baa34b241 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::from_hz(400000) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); + machine->scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, FUNC(blitter_timer_callback)); else - timer_set(machine, attotime::from_hz(400000) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); + machine->scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, FUNC(blitter_timer_callback)); } diff --git a/src/mame/video/nbmj8891.c b/src/mame/video/nbmj8891.c index 4199e3d4966..4e499b24b58 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::from_hz(400000) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); + machine->scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, FUNC(blitter_timer_callback)); } /****************************************************************************** diff --git a/src/mame/video/nbmj8900.c b/src/mame/video/nbmj8900.c index 6d1c0c22aaa..9fd8d400dc0 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::from_nsec(2500) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); + machine->scheduler().timer_set(attotime::from_nsec(2500) * nb1413m3_busyctr, FUNC(blitter_timer_callback)); } /****************************************************************************** diff --git a/src/mame/video/nbmj8991.c b/src/mame/video/nbmj8991.c index 6354368bbda..f4277f2aa0d 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::from_nsec(1650) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); + machine->scheduler().timer_set(attotime::from_nsec(1650) * nb1413m3_busyctr, FUNC(blitter_timer_callback)); } /****************************************************************************** diff --git a/src/mame/video/nbmj9195.c b/src/mame/video/nbmj9195.c index b7c0403722b..3efe3ff4fde 100644 --- a/src/mame/video/nbmj9195.c +++ b/src/mame/video/nbmj9195.c @@ -387,7 +387,7 @@ static void nbmj9195_gfxdraw(running_machine *machine, int vram) nb19010_busyflag = 0; /* 1650ns per count */ - timer_set(machine, attotime::from_nsec(nb19010_busyctr * 1650), NULL, 0, blitter_timer_callback); + machine->scheduler().timer_set(attotime::from_nsec(nb19010_busyctr * 1650), FUNC(blitter_timer_callback)); } /****************************************************************************** diff --git a/src/mame/video/neogeo.c b/src/mame/video/neogeo.c index 334ecbcdf3f..d67e8edefe4 100644 --- a/src/mame/video/neogeo.c +++ b/src/mame/video/neogeo.c @@ -243,7 +243,7 @@ static TIMER_CALLBACK( auto_animation_timer_callback ) static void create_auto_animation_timer( running_machine *machine ) { neogeo_state *state = machine->driver_data<neogeo_state>(); - state->auto_animation_timer = timer_alloc(machine, auto_animation_timer_callback, NULL); + state->auto_animation_timer = machine->scheduler().timer_alloc(FUNC(auto_animation_timer_callback)); } @@ -664,7 +664,7 @@ static TIMER_CALLBACK( sprite_line_timer_callback ) static void create_sprite_line_timer( running_machine *machine ) { neogeo_state *state = machine->driver_data<neogeo_state>(); - state->sprite_line_timer = timer_alloc(machine, sprite_line_timer_callback, NULL); + state->sprite_line_timer = machine->scheduler().timer_alloc(FUNC(sprite_line_timer_callback)); } diff --git a/src/mame/video/niyanpai.c b/src/mame/video/niyanpai.c index 014de98fd4a..818e9191d21 100644 --- a/src/mame/video/niyanpai.c +++ b/src/mame/video/niyanpai.c @@ -347,7 +347,7 @@ static void niyanpai_gfxdraw(running_machine *machine, int vram) } nb19010_busyflag = 0; - timer_set(machine, attotime::from_nsec(1650 * nb19010_busyctr), NULL, 0, blitter_timer_callback); + machine->scheduler().timer_set(attotime::from_nsec(1650 * nb19010_busyctr), FUNC(blitter_timer_callback)); } /****************************************************************************** diff --git a/src/mame/video/pastelg.c b/src/mame/video/pastelg.c index 43441a1a71a..ccb52818252 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::from_hz(400000) * nb1413m3_busyctr, NULL, 0, blitter_timer_callback); + machine->scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, FUNC(blitter_timer_callback)); } /****************************************************************************** diff --git a/src/mame/video/ppu2c0x.c b/src/mame/video/ppu2c0x.c index d9d9cca4f5a..5177c424210 100644 --- a/src/mame/video/ppu2c0x.c +++ b/src/mame/video/ppu2c0x.c @@ -1301,13 +1301,13 @@ static DEVICE_START( ppu2c0x ) ppu2c0x->security_value = 0x1b; /* initialize the scanline handling portion */ - ppu2c0x->scanline_timer = timer_alloc(device->machine, scanline_callback, (void *) device); + ppu2c0x->scanline_timer = device->machine->scheduler().timer_alloc(FUNC(scanline_callback), (void *) device); timer_adjust_oneshot(ppu2c0x->scanline_timer, device->machine->primary_screen->time_until_pos(1), 0); - ppu2c0x->hblank_timer = timer_alloc(device->machine, hblank_callback, (void *) device); + ppu2c0x->hblank_timer = device->machine->scheduler().timer_alloc(FUNC(hblank_callback), (void *) device); timer_adjust_oneshot(ppu2c0x->hblank_timer, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(86.67), 0); // ??? FIXME - hardcoding NTSC, need better calculation - ppu2c0x->nmi_timer = timer_alloc(device->machine, nmi_callback, (void *) device); + ppu2c0x->nmi_timer = device->machine->scheduler().timer_alloc(FUNC(nmi_callback), (void *) device); timer_adjust_oneshot(ppu2c0x->nmi_timer, attotime::never, 0); ppu2c0x->nmi_callback_proc = intf->nmi_handler; diff --git a/src/mame/video/rpunch.c b/src/mame/video/rpunch.c index 66c09ad5e20..0593decb580 100644 --- a/src/mame/video/rpunch.c +++ b/src/mame/video/rpunch.c @@ -100,7 +100,7 @@ VIDEO_START( rpunch ) memset(rpunch_bitmapram, 0xff, rpunch_bitmapram_size); /* reset the timer */ - crtc_timer = timer_alloc(machine, crtc_interrupt_gen, NULL); + crtc_timer = machine->scheduler().timer_alloc(FUNC(crtc_interrupt_gen)); } diff --git a/src/mame/video/segag80r.c b/src/mame/video/segag80r.c index 0897c26996c..4268bb781d4 100644 --- a/src/mame/video/segag80r.c +++ b/src/mame/video/segag80r.c @@ -52,7 +52,7 @@ static void vblank_latch_set(running_machine *machine) /* set a timer to mimic the 555 timer that drives the EDGINT signal */ /* the 555 is run in monostable mode with R=56000 and C=1000pF */ vblank_latch = 1; - timer_set(machine, PERIOD_OF_555_MONOSTABLE(CAP_P(1000), RES_K(56)), NULL, 0, vblank_latch_clear); + machine->scheduler().timer_set(PERIOD_OF_555_MONOSTABLE(CAP_P(1000), RES_K(56)), FUNC(vblank_latch_clear)); /* latch the current flip state at the same time */ video_flip = video_control & 1; diff --git a/src/mame/video/segaic16.c b/src/mame/video/segaic16.c index 303772bbccd..240e61452cc 100644 --- a/src/mame/video/segaic16.c +++ b/src/mame/video/segaic16.c @@ -1095,14 +1095,14 @@ static TIMER_CALLBACK( segaic16_tilemap_16b_latch_values ) } /* set a timer to do this again next frame */ - timer_adjust_oneshot(info->latch_timer, machine->primary_screen->time_until_pos(261), param); + info->latch_timer->adjust(machine->primary_screen->time_until_pos(261), param); } static void segaic16_tilemap_16b_reset(running_machine *machine, struct tilemap_info *info) { /* set a timer to latch values on scanline 261 */ - timer_adjust_oneshot(info->latch_timer, machine->primary_screen->time_until_pos(261), info->index); + info->latch_timer->adjust(machine->primary_screen->time_until_pos(261), info->index); } @@ -1169,7 +1169,7 @@ void segaic16_tilemap_init(running_machine *machine, int which, int type, int co info->numpages = 16; info->draw_layer = segaic16_tilemap_16b_draw_layer; info->reset = segaic16_tilemap_16b_reset; - info->latch_timer = timer_alloc(machine, segaic16_tilemap_16b_latch_values, NULL); + info->latch_timer = machine->scheduler().timer_alloc(FUNC(segaic16_tilemap_16b_latch_values)); break; case SEGAIC16_TILEMAP_16B_ALT: @@ -1178,7 +1178,7 @@ void segaic16_tilemap_init(running_machine *machine, int which, int type, int co info->numpages = 16; info->draw_layer = segaic16_tilemap_16b_draw_layer; info->reset = segaic16_tilemap_16b_reset; - info->latch_timer = timer_alloc(machine, segaic16_tilemap_16b_latch_values, NULL); + info->latch_timer = machine->scheduler().timer_alloc(FUNC(segaic16_tilemap_16b_latch_values)); break; default: diff --git a/src/mame/video/segas32.c b/src/mame/video/segas32.c index d80e7434d28..d05a6d94a9e 100644 --- a/src/mame/video/segas32.c +++ b/src/mame/video/segas32.c @@ -373,7 +373,7 @@ void system32_set_vblank(running_machine *machine, int state) { /* at the end of VBLANK is when automatic sprite rendering happens */ if (!state) - timer_set(machine, attotime::from_usec(50), NULL, 1, update_sprites); + machine->scheduler().timer_set(attotime::from_usec(50), FUNC(update_sprites), 1); } diff --git a/src/mame/video/sprint8.c b/src/mame/video/sprint8.c index 722964931c6..a9df711151d 100644 --- a/src/mame/video/sprint8.c +++ b/src/mame/video/sprint8.c @@ -188,8 +188,8 @@ VIDEO_EOF( sprint8 ) for (x = visarea.min_x; x <= visarea.max_x; x++) if (p1[x] != 0x20 && p2[x] == 0x23) - timer_set(machine, machine->primary_screen->time_until_pos(y + 24, x), NULL, - colortable_entry_get_value(machine->colortable, p1[x]), - sprint8_collision_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(y + 24, x), + FUNC(sprint8_collision_callback), + colortable_entry_get_value(machine->colortable, p1[x])); } } diff --git a/src/mame/video/starfire.c b/src/mame/video/starfire.c index 1df91557eac..d095c8d2af1 100644 --- a/src/mame/video/starfire.c +++ b/src/mame/video/starfire.c @@ -20,7 +20,7 @@ VIDEO_START( starfire ) starfire_state *state = machine->driver_data<starfire_state>(); state->starfire_screen = machine->primary_screen->alloc_compatible_bitmap(); - state->scanline_timer = timer_alloc(machine, starfire_scanline_callback, NULL); + state->scanline_timer = machine->scheduler().timer_alloc(FUNC(starfire_scanline_callback)); timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(STARFIRE_VBEND), STARFIRE_VBEND); /* register for state saving */ diff --git a/src/mame/video/tank8.c b/src/mame/video/tank8.c index 9d4f16731b6..a71dea990c7 100644 --- a/src/mame/video/tank8.c +++ b/src/mame/video/tank8.c @@ -284,7 +284,7 @@ VIDEO_EOF( tank8 ) index |= 0x80; /* collision on right side */ } - timer_set(machine, machine->primary_screen->time_until_pos(y, x), NULL, index, tank8_collision_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(y, x), FUNC(tank8_collision_callback), index); _state = 1; } diff --git a/src/mame/video/triplhnt.c b/src/mame/video/triplhnt.c index ee57ee6722d..af0eadfd48a 100644 --- a/src/mame/video/triplhnt.c +++ b/src/mame/video/triplhnt.c @@ -124,7 +124,7 @@ static void draw_sprites(running_machine *machine, bitmap_t* bitmap, const recta } if (hit_line != 999 && hit_code != 999) - timer_set(machine, machine->primary_screen->time_until_pos(hit_line), NULL, hit_code, triplhnt_hit_callback); + machine->scheduler().timer_set(machine->primary_screen->time_until_pos(hit_line), FUNC(triplhnt_hit_callback), hit_code); } diff --git a/src/mame/video/tubep.c b/src/mame/video/tubep.c index f010e70a80f..c84089e1c73 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::from_hz(19968000/8) * ((XSize+1)*(YSize+1)), NULL, 0, sprite_timer_callback); + space->machine->scheduler().timer_set( attotime::from_hz(19968000/8) * ((XSize+1)*(YSize+1)), FUNC(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 26cfa7bc7e4..5f35a40b183 100644 --- a/src/mame/video/twin16.c +++ b/src/mame/video/twin16.c @@ -504,7 +504,7 @@ VIDEO_START( twin16 ) memset(twin16_sprite_buffer,0xff,0x800*sizeof(UINT16)); twin16_sprite_busy = 0; - twin16_sprite_timer = timer_alloc(machine, twin16_sprite_tick, NULL); + twin16_sprite_timer = machine->scheduler().timer_alloc(FUNC(twin16_sprite_tick)); timer_adjust_oneshot(twin16_sprite_timer, attotime::never, 0); /* register for savestates */ diff --git a/src/mame/video/tx1.c b/src/mame/video/tx1.c index 398f6d0177b..af3e8392b4d 100644 --- a/src/mame/video/tx1.c +++ b/src/mame/video/tx1.c @@ -1128,7 +1128,7 @@ VIDEO_START( tx1 ) tx1_rod_bmp = auto_alloc_array(machine, UINT8, 256 * 3 * 240); /* Set a timer to run the interrupts */ - interrupt_timer = timer_alloc(machine, interrupt_callback, NULL); + interrupt_timer = machine->scheduler().timer_alloc(FUNC(interrupt_callback)); /* /CUDISP CRTC interrupt */ timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0); @@ -3047,7 +3047,7 @@ VIDEO_START( buggyboy ) bb_rod_bmp = auto_alloc_array(machine, UINT8, 3 * 256 * 240); /* Set a timer to run the interrupts */ - interrupt_timer = timer_alloc(machine, interrupt_callback, NULL); + interrupt_timer = machine->scheduler().timer_alloc(FUNC(interrupt_callback)); /* /CUDISP CRTC interrupt */ timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0); @@ -3061,7 +3061,7 @@ VIDEO_START( buggybjr ) bb_rod_bmp = auto_alloc_array(machine, UINT8, 256 * 240); /* Set a timer to run the interrupts */ - interrupt_timer = timer_alloc(machine, interrupt_callback, NULL); + interrupt_timer = machine->scheduler().timer_alloc(FUNC(interrupt_callback)); /* /CUDISP CRTC interrupt */ timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0); diff --git a/src/mame/video/victory.c b/src/mame/video/victory.c index 8ceb7fe936d..fc97cd0f8af 100644 --- a/src/mame/video/victory.c +++ b/src/mame/video/victory.c @@ -86,7 +86,7 @@ VIDEO_START( victory ) scrollx = scrolly = 0; video_control = 0; memset(µ, 0, sizeof(micro)); - micro.timer = timer_alloc(machine, NULL, NULL); + micro.timer = machine->scheduler().timer_alloc(FUNC(NULL)); /* register for state saving */ state_save_register_global_array(machine, victory_paletteram); @@ -1125,7 +1125,7 @@ VIDEO_UPDATE( victory ) int bpix = bg[(x + scrollx) & 255]; scanline[x] = bpix | (fpix << 3); if (fpix && (bpix & bgcollmask) && count++ < 128) - timer_set(screen->machine, screen->time_until_pos(y, x), NULL, x | (y << 8), bgcoll_irq_callback); + screen->machine->scheduler().timer_set(screen->time_until_pos(y, x), FUNC(bgcoll_irq_callback), x | (y << 8)); } } |