void running_machine::immediate_load(const char *filename) { // specify the filename to save or load set_saveload_filename(filename); // set up some parameters for handle_saveload() m_saveload_schedule = SLS_LOAD; m_saveload_schedule_time = this->time(); // jump right into the load, anonymous timers can't hurt us handle_saveload(); }
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 video_frame_update(this, false); /* handle save/load */ if (m_saveload_schedule != SLS_NONE) handle_saveload(); } }
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; } }
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; }
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; }
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; }
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; }