- removed FUNC_NULL macro

- made emu_timer register_save properly handle timer_expired_delegate()
- removed timer_expired_func and calls using it
This commit is contained in:
Miodrag Milanovic 2016-07-01 11:47:12 +02:00
parent 0630edb2bf
commit d34724b3ab
12 changed files with 24 additions and 32 deletions

View File

@ -1746,7 +1746,7 @@ static int OPL_LockTable(device_t *device)
{ {
cymfile = fopen("3812_.cym","wb"); cymfile = fopen("3812_.cym","wb");
if (cymfile) if (cymfile)
device->machine().scheduler().timer_pulse ( attotime::from_hz(110), FUNC(cymfile_callback)); /*110 Hz pulse timer*/ device->machine().scheduler().timer_pulse ( attotime::from_hz(110), timer_expired_delegate(FUNC(cymfile_callback),&device->machine())); /*110 Hz pulse timer*/
else else
device->logerror("Could not create file 3812_.cym\n"); device->logerror("Could not create file 3812_.cym\n");
} }

View File

@ -208,7 +208,6 @@ inline void operator--(_Type &value, int) { value = (_Type)((int)value - 1); }
// this macro wraps a function 'x' and can be used to pass a function followed by its name // this macro wraps a function 'x' and can be used to pass a function followed by its name
#define FUNC(x) &x, #x #define FUNC(x) &x, #x
#define FUNC_NULL nullptr, "(null)"
// standard assertion macros // standard assertion macros

View File

@ -243,10 +243,15 @@ void emu_timer::register_save()
// for non-device timers, it is an index based on the callback function name // for non-device timers, it is an index based on the callback function name
if (m_device == nullptr) if (m_device == nullptr)
{ {
name = m_callback.name(); name = m_callback.name() ? m_callback.name() : "unnamed";
for (emu_timer *curtimer = machine().scheduler().first_timer(); curtimer != nullptr; curtimer = curtimer->next()) for (emu_timer *curtimer = machine().scheduler().first_timer(); curtimer != nullptr; curtimer = curtimer->next())
if (!curtimer->m_temporary && curtimer->m_device == nullptr && strcmp(curtimer->m_callback.name(), m_callback.name()) == 0) if (!curtimer->m_temporary && curtimer->m_device == nullptr)
index++; {
if (curtimer->m_callback.name() != nullptr && m_callback.name() != nullptr && strcmp(curtimer->m_callback.name(), m_callback.name()) == 0)
index++;
else if (curtimer->m_callback.name() == nullptr && m_callback.name() == nullptr)
index++;
}
} }
// for device timers, it is an index based on the device and timer ID // for device timers, it is an index based on the device and timer ID

View File

@ -41,10 +41,6 @@
// timer callbacks look like this // timer callbacks look like this
typedef delegate<void (void *, INT32)> timer_expired_delegate; typedef delegate<void (void *, INT32)> timer_expired_delegate;
// old-skool callbacks are like this
typedef void (*timer_expired_func)(running_machine &machine, void *ptr, INT32 param);
// ======================> emu_timer // ======================> emu_timer
class emu_timer class emu_timer
@ -141,14 +137,6 @@ public:
void timer_pulse(const attotime &period, timer_expired_delegate callback, int param = 0, void *ptr = nullptr); void timer_pulse(const attotime &period, timer_expired_delegate callback, int param = 0, void *ptr = nullptr);
void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0, void *ptr = nullptr) { timer_set(attotime::zero, callback, param, ptr); } void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0, void *ptr = nullptr) { timer_set(attotime::zero, callback, param, ptr); }
// timers with old-skool callbacks
#ifdef USE_STATIC_DELEGATE
emu_timer *timer_alloc(timer_expired_func callback, const char *name, void *ptr = nullptr) { return timer_alloc(timer_expired_delegate(callback, name, &machine()), ptr); }
void timer_set(const attotime &duration, timer_expired_func callback, const char *name, int param = 0, void *ptr = nullptr) { timer_set(duration, timer_expired_delegate(callback, name, &machine()), param, ptr); }
void timer_pulse(const attotime &period, timer_expired_func callback, const char *name, int param = 0, void *ptr = nullptr) { timer_pulse(period, timer_expired_delegate(callback, name, &machine()), param, ptr); }
void synchronize(timer_expired_func callback, const char *name = nullptr, int param = 0, void *ptr = nullptr) { timer_set(attotime::zero, callback, name, param, ptr); }
#endif
// timers, specified by device/id; generally devices should use the device_t methods instead // 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 = nullptr); emu_timer *timer_alloc(device_t &device, device_timer_id id = 0, void *ptr = nullptr);
void timer_set(const attotime &duration, device_t &device, device_timer_id id = 0, int param = 0, void *ptr = nullptr); void timer_set(const attotime &duration, device_t &device, device_timer_id id = 0, int param = 0, void *ptr = nullptr);

View File

@ -646,7 +646,7 @@ MACHINE_START_MEMBER(combatsc_state,combatsc)
m_page[0] = MEM + 0x4000; m_page[0] = MEM + 0x4000;
m_page[1] = MEM + 0x6000; m_page[1] = MEM + 0x6000;
m_interleave_timer = machine().scheduler().timer_alloc(FUNC_NULL); m_interleave_timer = machine().scheduler().timer_alloc(timer_expired_delegate());
membank("bank1")->configure_entries(0, 10, memregion("maincpu")->base() + 0x10000, 0x4000); membank("bank1")->configure_entries(0, 10, memregion("maincpu")->base() + 0x10000, 0x4000);

View File

@ -72,8 +72,8 @@ static emu_timer *timer[2];
MACHINE_START_MEMBER(midzeus_state,midzeus) MACHINE_START_MEMBER(midzeus_state,midzeus)
{ {
timer[0] = machine().scheduler().timer_alloc(FUNC_NULL); timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate());
timer[1] = machine().scheduler().timer_alloc(FUNC_NULL); timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate());
gun_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(midzeus_state::invasn_gun_callback),this)); gun_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(midzeus_state::invasn_gun_callback),this));
gun_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(midzeus_state::invasn_gun_callback),this)); gun_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(midzeus_state::invasn_gun_callback),this));

View File

@ -176,17 +176,17 @@ MACHINE_RESET_MEMBER(tm990189_state,tm990_189)
MACHINE_START_MEMBER(tm990189_state,tm990_189) MACHINE_START_MEMBER(tm990189_state,tm990_189)
{ {
m_displayena_timer = machine().scheduler().timer_alloc(FUNC_NULL); m_displayena_timer = machine().scheduler().timer_alloc(timer_expired_delegate());
} }
MACHINE_START_MEMBER(tm990189_state,tm990_189_v) MACHINE_START_MEMBER(tm990189_state,tm990_189_v)
{ {
m_displayena_timer = machine().scheduler().timer_alloc(FUNC_NULL); m_displayena_timer = machine().scheduler().timer_alloc(timer_expired_delegate());
m_joy1x_timer = machine().scheduler().timer_alloc(FUNC_NULL); m_joy1x_timer = machine().scheduler().timer_alloc(timer_expired_delegate());
m_joy1y_timer = machine().scheduler().timer_alloc(FUNC_NULL); m_joy1y_timer = machine().scheduler().timer_alloc(timer_expired_delegate());
m_joy2x_timer = machine().scheduler().timer_alloc(FUNC_NULL); m_joy2x_timer = machine().scheduler().timer_alloc(timer_expired_delegate());
m_joy2y_timer = machine().scheduler().timer_alloc(FUNC_NULL); m_joy2y_timer = machine().scheduler().timer_alloc(timer_expired_delegate());
} }
MACHINE_RESET_MEMBER(tm990189_state,tm990_189_v) MACHINE_RESET_MEMBER(tm990189_state,tm990_189_v)

View File

@ -582,8 +582,8 @@ void vegas_state::machine_start()
m_voodoo = (voodoo_device*)machine().device("voodoo"); m_voodoo = (voodoo_device*)machine().device("voodoo");
/* allocate timers for the NILE */ /* allocate timers for the NILE */
m_timer[0] = machine().scheduler().timer_alloc(FUNC_NULL); m_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate());
m_timer[1] = machine().scheduler().timer_alloc(FUNC_NULL); m_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate());
m_timer[2] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vegas_state::nile_timer_callback),this)); m_timer[2] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vegas_state::nile_timer_callback),this));
m_timer[3] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vegas_state::nile_timer_callback),this)); m_timer[3] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vegas_state::nile_timer_callback),this));

View File

@ -132,7 +132,7 @@ TIMER_CALLBACK_MEMBER(mhavoc_state::delayed_gamma_w)
m_gamma->set_input_line(INPUT_LINE_NMI, PULSE_LINE); m_gamma->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
/* the sound CPU needs to reply in 250microseconds (according to Neil Bradley) */ /* the sound CPU needs to reply in 250microseconds (according to Neil Bradley) */
machine().scheduler().timer_set(attotime::from_usec(250), FUNC_NULL); machine().scheduler().timer_set(attotime::from_usec(250), timer_expired_delegate());
} }

View File

@ -2997,7 +2997,7 @@ void thomson_state::to8_kbd_reset()
void thomson_state::to8_kbd_init() void thomson_state::to8_kbd_init()
{ {
m_to8_kbd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(thomson_state::to8_kbd_timer_cb),this)); m_to8_kbd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(thomson_state::to8_kbd_timer_cb),this));
m_to8_kbd_signal = machine().scheduler().timer_alloc(FUNC_NULL); m_to8_kbd_signal = machine().scheduler().timer_alloc(timer_expired_delegate());
save_item(NAME(m_to8_kbd_ack)); save_item(NAME(m_to8_kbd_ack));
save_item(NAME(m_to8_kbd_data)); save_item(NAME(m_to8_kbd_data));
save_item(NAME(m_to8_kbd_step)); save_item(NAME(m_to8_kbd_step));

View File

@ -1161,7 +1161,7 @@ VIDEO_START_MEMBER( thomson_state, thom )
save_item(NAME(m_thom_floppy_rcount)); save_item(NAME(m_thom_floppy_rcount));
output().set_value( "floppy", 0 ); output().set_value( "floppy", 0 );
m_thom_video_timer = machine().scheduler().timer_alloc(FUNC_NULL); m_thom_video_timer = machine().scheduler().timer_alloc(timer_expired_delegate());
m_thom_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(thomson_state::thom_scanline_start),this)); m_thom_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(thomson_state::thom_scanline_start),this));

View File

@ -47,7 +47,7 @@ void victory_state::video_start()
m_scrollx = m_scrolly = 0; m_scrollx = m_scrolly = 0;
m_video_control = 0; m_video_control = 0;
memset(&m_micro, 0, sizeof(m_micro)); memset(&m_micro, 0, sizeof(m_micro));
m_micro.timer = machine().scheduler().timer_alloc(FUNC_NULL); m_micro.timer = machine().scheduler().timer_alloc(timer_expired_delegate());
/* register for state saving */ /* register for state saving */
save_item(NAME(m_paletteram)); save_item(NAME(m_paletteram));