36
36
watchdog_init - one time initialization
37
37
-------------------------------------------------*/
39
void watchdog_init(running_machine *machine)
39
void watchdog_init(running_machine &machine)
41
41
/* allocate a timer for the watchdog */
42
watchdog_timer = timer_alloc(machine, watchdog_callback, NULL);
42
watchdog_timer = machine.scheduler().timer_alloc(FUNC(watchdog_callback));
44
machine->add_notifier(MACHINE_NOTIFY_RESET, watchdog_internal_reset);
44
machine.add_notifier(MACHINE_NOTIFY_RESET, watchdog_internal_reset);
46
46
/* save some stuff in the default tag */
47
state_save_register_item(machine, "watchdog", NULL, 0, watchdog_enabled);
48
state_save_register_item(machine, "watchdog", NULL, 0, watchdog_counter);
47
machine.state().save_item(NAME(watchdog_enabled));
48
machine.state().save_item(NAME(watchdog_counter));
57
57
static void watchdog_internal_reset(running_machine &machine)
59
59
/* set up the watchdog timer; only start off enabled if explicitly configured */
60
watchdog_enabled = (machine.m_config.m_watchdog_vblank_count != 0 || attotime_compare(machine.m_config.m_watchdog_time, attotime_zero) != 0);
61
watchdog_reset(&machine);
60
watchdog_enabled = (machine.config().m_watchdog_vblank_count != 0 || machine.config().m_watchdog_time != attotime::zero);
61
watchdog_reset(machine);
62
62
watchdog_enabled = TRUE;
90
90
if (vblank_state && watchdog_enabled)
92
92
/* check the watchdog */
93
if (screen.machine->config->m_watchdog_vblank_count != 0)
93
if (screen.machine().config().m_watchdog_vblank_count != 0)
95
95
watchdog_counter = watchdog_counter - 1;
97
97
if (watchdog_counter == 0)
98
watchdog_callback(screen.machine, NULL, 0);
98
watchdog_callback(screen.machine(), NULL, 0);
105
105
watchdog_reset - reset the watchdog timer
106
106
-------------------------------------------------*/
108
void watchdog_reset(running_machine *machine)
108
void watchdog_reset(running_machine &machine)
110
110
/* if we're not enabled, skip it */
111
111
if (!watchdog_enabled)
112
timer_adjust_oneshot(watchdog_timer, attotime_never, 0);
112
watchdog_timer->adjust(attotime::never);
114
114
/* VBLANK-based watchdog? */
115
else if (machine->config->m_watchdog_vblank_count != 0)
115
else if (machine.config().m_watchdog_vblank_count != 0)
117
watchdog_counter = machine->config->m_watchdog_vblank_count;
117
watchdog_counter = machine.config().m_watchdog_vblank_count;
119
119
/* register a VBLANK callback for the primary screen */
120
if (machine->primary_screen != NULL)
121
machine->primary_screen->register_vblank_callback(on_vblank, NULL);
120
if (machine.primary_screen != NULL)
121
machine.primary_screen->register_vblank_callback(on_vblank, NULL);
124
124
/* timer-based watchdog? */
125
else if (attotime_compare(machine->config->m_watchdog_time, attotime_zero) != 0)
126
timer_adjust_oneshot(watchdog_timer, machine->config->m_watchdog_time, 0);
125
else if (machine.config().m_watchdog_time != attotime::zero)
126
watchdog_timer->adjust(machine.config().m_watchdog_time);
128
128
/* default to an obscene amount of time (3 seconds) */
130
timer_adjust_oneshot(watchdog_timer, ATTOTIME_IN_SEC(3), 0);
130
watchdog_timer->adjust(attotime::from_seconds(3));
135
135
watchdog_enable - reset the watchdog timer
136
136
-------------------------------------------------*/
138
void watchdog_enable(running_machine *machine, int enable)
138
void watchdog_enable(running_machine &machine, int enable)
140
140
/* when re-enabled, we reset our state */
141
141
if (watchdog_enabled != enable)