Ejemplo n.º 1
0
//-------------------------------------------------
// announce_init_phase - mark the running_machine as being [pct_complete]
// percent finished with init phase [init_phase], and call all notify
// callbacks
//-------------------------------------------------
void running_machine::announce_init_phase(machine_init_phase init_phase,
                                          int pct_complete)
{
    m_current_init_phase = init_phase;
    m_current_init_phase_pct_complete = pct_complete;
    call_notifiers(MACHINE_NOTIFY_STARTUP);
}
Ejemplo n.º 2
0
void running_machine::resume()
{
	// ignore if nothing has changed
	if (!m_paused)
		return;
	m_paused = false;

	// call the callbacks
	call_notifiers(MACHINE_NOTIFY_RESUME);
}
Ejemplo n.º 3
0
void running_machine::pause()
{
	// ignore if nothing has changed
	if (m_paused)
		return;
	m_paused = true;

	// call the callbacks
	call_notifiers(MACHINE_NOTIFY_PAUSE);
}
Ejemplo n.º 4
0
void running_machine::soft_reset(void *ptr, INT32 param)
{
	logerror("Soft reset\n");

	// temporarily in the reset phase
	m_current_phase = MACHINE_PHASE_RESET;

	// call all registered reset callbacks
	call_notifiers(MACHINE_NOTIFY_RESET);

	// now we're running
	m_current_phase = MACHINE_PHASE_RUNNING;
}
Ejemplo n.º 5
0
void running_machine::retro_machineexit(){

	// and out via the exit phase
	m_current_phase = MACHINE_PHASE_EXIT;

	// save the NVRAM and configuration
	sound().ui_mute(true);
	nvram_save();
	config_save_settings(*this);
	call_notifiers(MACHINE_NOTIFY_EXIT);
	printf("retro exit machine\n");
	zip_file_cache_clear();

	m_logfile.reset();
}
Ejemplo n.º 6
0
void running_machine::retro_machineexit()
{   
    retro_log(RETRO_LOG_INFO, "beginning retro_machineexit()\n");

   /* and out via the exit phase */
   m_current_phase = MACHINE_PHASE_EXIT;

   /* save the NVRAM and configuration */
   sound_mute(this, true);
   nvram_save(this);
   config_save_settings(this);
   
   /* call all exit callbacks registered */
   call_notifiers(MACHINE_NOTIFY_EXIT);

}
Ejemplo n.º 7
0
void running_machine::soft_reset(void *ptr, INT32 param)
{
	logerror("Soft reset\n");

	// temporarily in the reset phase
	m_current_phase = MACHINE_PHASE_RESET;

	// set up the watchdog timer; only start off enabled if explicitly configured
	m_watchdog_enabled = (config().m_watchdog_vblank_count != 0 || config().m_watchdog_time != attotime::zero);
	watchdog_reset();
	m_watchdog_enabled = true;

	// call all registered reset callbacks
	call_notifiers(MACHINE_NOTIFY_RESET);

	// now we're running
	m_current_phase = MACHINE_PHASE_RUNNING;
}
Ejemplo n.º 8
0
void running_machine::schedule_hard_reset()
{
    retro_log(RETRO_LOG_INFO, "[MAME 2010] schedule_hard_reset for current MAME machine.\n");
    
	m_hard_reset_pending = true;

	/* if we're executing, abort out immediately */
	m_scheduler.eat_all_cycles();

    /* and out via the exit phase */
    m_current_phase = MACHINE_PHASE_EXIT;

    /* save the NVRAM and configuration */
    sound_mute(this, true);
    nvram_save(this);
    config_save_settings(this);

    /* call all exit callbacks registered */
    call_notifiers(MACHINE_NOTIFY_EXIT);

    ENDEXEC=1;
}
Ejemplo n.º 9
0
void running_machine::retro_loop(){

	while (RLOOP==1)
   {
		// execute CPUs if not paused
		if (!m_paused)
			m_scheduler.timeslice();

		// otherwise, just pump video updates through
		else
			m_video->frame_update();

		// handle save/load
		if (m_saveload_schedule != SLS_NONE)
			handle_saveload();

	}

	if( (m_hard_reset_pending || m_exit_pending) && m_saveload_schedule == SLS_NONE){

	 	// and out via the exit phase
		m_current_phase = MACHINE_PHASE_EXIT;

		// save the NVRAM and configuration
		sound().ui_mute(true);
		nvram_save();
		config_save_settings(*this);

		// call all exit callbacks registered
		call_notifiers(MACHINE_NOTIFY_EXIT);
	
		zip_file_cache_clear();

		m_logfile.reset();		

		ENDEXEC=1;
	}

}
Ejemplo n.º 10
0
void running_machine::soft_reset()
{
	retro_log(RETRO_LOG_INFO, "[MAME 2010] Soft reset now.\n");

	/* temporarily in the reset phase */
	m_current_phase = MACHINE_PHASE_RESET;

	/* call all registered reset callbacks */
	call_notifiers(MACHINE_NOTIFY_RESET);

	/* run the driver's reset callbacks */
	if (m_config.m_machine_reset != NULL)
		(*m_config.m_machine_reset)(this);
	if (m_config.m_sound_reset != NULL)
		(*m_config.m_sound_reset)(this);
	if (m_config.m_video_reset != NULL)
		(*m_config.m_video_reset)(this);

	/* 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);
}
Ejemplo n.º 11
0
void running_machine::soft_reset()
{
	logerror("Soft reset\n");

	// temporarily in the reset phase
	m_current_phase = MACHINE_PHASE_RESET;

	// call all registered reset callbacks
	call_notifiers(MACHINE_NOTIFY_RESET);

	// run the driver's reset callbacks
	if (m_config.m_machine_reset != NULL)
		(*m_config.m_machine_reset)(this);
	if (m_config.m_sound_reset != NULL)
		(*m_config.m_sound_reset)(this);
	if (m_config.m_video_reset != NULL)
		(*m_config.m_video_reset)(this);

	// 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);
}
Ejemplo n.º 12
0
int running_machine::run(bool firstrun)
{
	int error = MAMERR_NONE;

	// use try/catch for deep error recovery
	try
	{
		// move to the init phase
		m_current_phase = MACHINE_PHASE_INIT;

		// if we have a logfile, set up the callback
		if (options().log())
		{
			m_logfile = auto_alloc(*this, emu_file(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
			file_error filerr = m_logfile->open("error.log");
			assert_always(filerr == FILERR_NONE, "unable to open log file");
			add_logerror_callback(logfile_callback);
		}

		// then finish setting up our local machine
		start();

		// load the configuration settings and NVRAM
		bool settingsloaded = config_load_settings(*this);
		nvram_load(*this);
		sound().ui_mute(false);

		// display the startup screens
		ui_display_startup_screens(*this, firstrun, !settingsloaded);

		// perform a soft reset -- this takes us to the running phase
		soft_reset();

		// run the CPUs until a reset or exit
		m_hard_reset_pending = false;
		while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE)
		{
			g_profiler.start(PROFILER_EXTRA);

			// execute CPUs if not paused
			if (!m_paused)
				m_scheduler.timeslice();

			// otherwise, just pump video updates through
			else
				m_video->frame_update();

			// handle save/load
			if (m_saveload_schedule != SLS_NONE)
				handle_saveload();

			g_profiler.stop();
		}

		// and out via the exit phase
		m_current_phase = MACHINE_PHASE_EXIT;

		// save the NVRAM and configuration
		sound().ui_mute(true);
		nvram_save(*this);
		config_save_settings(*this);
	}
	catch (emu_fatalerror &fatal)
	{
		mame_printf_error("%s\n", fatal.string());
		error = MAMERR_FATALERROR;
		if (fatal.exitcode() != 0)
			error = fatal.exitcode();
	}
	catch (emu_exception &)
	{
		mame_printf_error("Caught unhandled emulator exception\n");
		error = MAMERR_FATALERROR;
	}
	catch (std::bad_alloc &)
	{
		mame_printf_error("Out of memory!\n");
		error = MAMERR_FATALERROR;
	}

	// call all exit callbacks registered
	call_notifiers(MACHINE_NOTIFY_EXIT);
	zip_file_cache_clear();

	// close the logfile
	auto_free(*this, m_logfile);
	return error;
}
Ejemplo n.º 13
0
int running_machine::run(bool firstrun)
{
	int error = MAMERR_NONE;

	// use try/catch for deep error recovery
	try
	{
		// move to the init phase
		m_current_phase = MACHINE_PHASE_INIT;

		// if we have a logfile, set up the callback
		if (options().log())
		{
			m_logfile = auto_alloc(*this, emu_file(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
			file_error filerr = m_logfile->open("error.log");
			assert_always(filerr == FILERR_NONE, "unable to open log file");
			add_logerror_callback(logfile_callback);
		}

		// then finish setting up our local machine
		start();

		// load the configuration settings and NVRAM
		bool settingsloaded = config_load_settings(*this);
		nvram_load(*this);
		sound().ui_mute(false);

		// initialize ui lists
		ui_initialize(*this);

		// display the startup screens
		ui_display_startup_screens(*this, firstrun, !settingsloaded);

		// perform a soft reset -- this takes us to the running phase
		soft_reset();

		// run the CPUs until a reset or exit
		m_hard_reset_pending = false;
		while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE)
		{
			g_profiler.start(PROFILER_EXTRA);

			#ifdef SDLMAME_EMSCRIPTEN
			//break out to our async javascript loop and halt
			js_set_main_loop(m_scheduler);
			#endif

			// execute CPUs if not paused
			if (!m_paused)
				m_scheduler.timeslice();

			// otherwise, just pump video updates through
			else
				m_video->frame_update();

			// handle save/load
			if (m_saveload_schedule != SLS_NONE)
				handle_saveload();

			g_profiler.stop();
		}

		// and out via the exit phase
		m_current_phase = MACHINE_PHASE_EXIT;

		// save the NVRAM and configuration
		sound().ui_mute(true);
		nvram_save(*this);
		config_save_settings(*this);
	}
	catch (emu_fatalerror &fatal)
	{
		mame_printf_error("%s\n", fatal.string());
		error = MAMERR_FATALERROR;
		if (fatal.exitcode() != 0)
			error = fatal.exitcode();
	}
	catch (emu_exception &)
	{
		mame_printf_error("Caught unhandled emulator exception\n");
		error = MAMERR_FATALERROR;
	}
	catch (binding_type_exception &btex)
	{
		mame_printf_error("Error performing a late bind of type %s to %s\n", btex.m_actual_type.name(), btex.m_target_type.name());
		error = MAMERR_FATALERROR;
	}
	catch (std::exception &ex)
	{
		mame_printf_error("Caught unhandled %s exception: %s\n", typeid(ex).name(), ex.what());
		error = MAMERR_FATALERROR;
	}
	catch (...)
	{
		mame_printf_error("Caught unhandled exception\n");
		error = MAMERR_FATALERROR;
	}

	// make sure our phase is set properly before cleaning up,
	// in case we got here via exception
	m_current_phase = MACHINE_PHASE_EXIT;

	// call all exit callbacks registered
	call_notifiers(MACHINE_NOTIFY_EXIT);
	zip_file_cache_clear();

	// close the logfile
	auto_free(*this, m_logfile);
	return error;
}
Ejemplo n.º 14
0
int running_machine::run(bool firstrun, bool benchmarking)
{
	int error = MAMERR_NONE;

	// use try/catch for deep error recovery
	try
	{
		// move to the init phase
		m_current_phase = MACHINE_PHASE_INIT;

		// if we have a logfile, set up the callback
		if (options().log())
		{
			m_logfile = auto_alloc(*this, emu_file(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
			file_error filerr = m_logfile->open("error.log");
			assert_always(filerr == FILERR_NONE, "unable to open log file");
			add_logerror_callback(logfile_callback);
		}

		// then finish setting up our local machine
		start();

		// load the configuration settings and NVRAM
		bool settingsloaded = config_load_settings(*this);
		nvram_load(*this);
		sound().ui_mute(false);

        // this point is chosen arbitrarily to be represented as 50% complete
        // with the "initializing state" init phase
        announce_init_phase(STARTUP_PHASE_INITIALIZING_STATE, 50);

		// display the startup screens, unless benchmarking, in which case
        // there is no user interaction expected and no need to show the
        // startup screens
        if (!benchmarking) {
            ui_display_startup_screens(*this, firstrun, !settingsloaded);
        }

		// perform a soft reset -- this takes us to the running phase
		soft_reset();

        // now initialization is 100% complete and the next thing that will
        // happen is the game will start running
        announce_init_phase(STARTUP_PHASE_INITIALIZING_STATE, 100);

		// run the CPUs until a reset or exit
		m_hard_reset_pending = false;
		while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE)
		{
			g_profiler.start(PROFILER_EXTRA);

			// execute CPUs if not paused
			if (!m_paused)
				m_scheduler.timeslice();

			// otherwise, just pump video updates through
			else
				m_video->frame_update();

			// handle save/load
			if (m_saveload_schedule != SLS_NONE)
				handle_saveload();

			g_profiler.stop();
		}

		// and out via the exit phase
		m_current_phase = MACHINE_PHASE_EXIT;

		// save the NVRAM and configuration
		sound().ui_mute(true);
		nvram_save(*this);
		config_save_settings(*this);
	}
	catch (emu_fatalerror &fatal)
	{
		mame_printf_error("%s\n", fatal.string());
		error = MAMERR_FATALERROR;
		if (fatal.exitcode() != 0)
			error = fatal.exitcode();
	}
	catch (emu_exception &)
	{
		mame_printf_error("Caught unhandled emulator exception\n");
		error = MAMERR_FATALERROR;
	}
	catch (std::bad_alloc &)
	{
		mame_printf_error("Out of memory!\n");
		error = MAMERR_FATALERROR;
	}

	// make sure our phase is set properly before cleaning up,
	// in case we got here via exception
	m_current_phase = MACHINE_PHASE_EXIT;

	// call all exit callbacks registered
	call_notifiers(MACHINE_NOTIFY_EXIT);
	zip_file_cache_clear();

	// close the logfile
	auto_free(*this, m_logfile);
	return error;
}
Ejemplo n.º 15
0
int running_machine::run(bool firstrun)
{
   int error = MAMERR_NONE;

   // move to the init phase
   m_current_phase = MACHINE_PHASE_INIT;

   // if we have a logfile, set up the callback
   if (options().log())
   {
      m_logfile.reset(global_alloc(emu_file(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)));
      file_error filerr = m_logfile->open("error.log");
      assert_always(filerr == FILERR_NONE, "unable to open log file");
      add_logerror_callback(logfile_callback);
   }

   // then finish setting up our local machine
   start();

   // load the configuration settings and NVRAM
   bool settingsloaded = config_load_settings(*this);

   //MKCHAMP - INITIALIZING THE HISCORE ENGINE
   if (! options().disable_hiscore_patch())
      hiscore_init(*this);

   // disallow save state registrations starting here.
   // Don't do it earlier, config load can create network
   // devices with timers.
   m_save.allow_registration(false);

   nvram_load();
   sound().ui_mute(false);

   // initialize ui lists
   ui().initialize(*this);

   // display the startup screens
   ui().display_startup_screens(firstrun, !options().skip_nagscreen());

   // perform a soft reset -- this takes us to the running phase
   soft_reset();

   // handle initial load
   if (m_saveload_schedule != SLS_NONE)
      handle_saveload();

   // run the CPUs until a reset or exit
   m_hard_reset_pending = false;
   while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE)
      return 0;

   // and out via the exit phase
   m_current_phase = MACHINE_PHASE_EXIT;

   // save the NVRAM and configuration
   sound().ui_mute(true);
   nvram_save();
   config_save_settings(*this);

   // make sure our phase is set properly before cleaning up,
   // in case we got here via exception
   m_current_phase = MACHINE_PHASE_EXIT;

   // call all exit callbacks registered
   call_notifiers(MACHINE_NOTIFY_EXIT);
   zip_file_cache_clear();

   // close the logfile
   m_logfile.reset();
   return error;
}