Example #1
0
void crosshair_init(running_machine *machine)
{
    const input_port_config *port;
    const input_field_config *field;

    /* request a callback upon exiting */
    add_exit_callback(machine, crosshair_exit);

    /* clear all the globals */
    memset(&global, 0, sizeof(global));

    /* setup the default auto visibility time */
    global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT;

    /* determine who needs crosshairs */
    for (port = machine->portconfig; port != NULL; port = port->next)
        for (field = port->fieldlist; field != NULL; field = field->next)
            if (field->crossaxis != CROSSHAIR_AXIS_NONE)
            {
                int player = field->player;

                assert(player < MAX_PLAYERS);

                /* mark as used and set the default visibility and mode */
                global.usage = TRUE;
                global.used[player] = TRUE;
                global.mode[player] = CROSSHAIR_VISIBILITY_DEFAULT;
                global.visible[player] = (CROSSHAIR_VISIBILITY_DEFAULT == CROSSHAIR_VISIBILITY_OFF) ? FALSE : TRUE;

                /* for now, use the main screen */
                global.screen[player] = machine->primary_screen;

                create_bitmap(machine, player);
            }

    /* register callbacks for when we load/save configurations */
    if (global.usage)
        config_register(machine, "crosshairs", crosshair_load, crosshair_save);

    /* register the animation callback */
    if (machine->primary_screen != NULL)
        video_screen_register_vblank_callback(machine->primary_screen, animate, NULL);
}
Example #2
0
void watchdog_reset(running_machine *machine)
{
	/* if we're not enabled, skip it */
	if (!watchdog_enabled)
		timer_adjust_oneshot(watchdog_timer, attotime_never, 0);

	/* VBLANK-based watchdog? */
	else if (machine->config->watchdog_vblank_count != 0)
	{
		watchdog_counter = machine->config->watchdog_vblank_count;

		/* register a VBLANK callback for the primary screen */
		if (machine->primary_screen != NULL)
			video_screen_register_vblank_callback(machine->primary_screen, on_vblank, NULL);
	}

	/* timer-based watchdog? */
	else if (attotime_compare(machine->config->watchdog_time, attotime_zero) != 0)
		timer_adjust_oneshot(watchdog_timer, machine->config->watchdog_time, 0);

	/* default to an obscene amount of time (3 seconds) */
	else
		timer_adjust_oneshot(watchdog_timer, ATTOTIME_IN_SEC(3), 0);
}