summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/machine.cpp')
-rw-r--r--src/emu/machine.cpp80
1 files changed, 52 insertions, 28 deletions
diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp
index 669f5fa27a5..a77140dba16 100644
--- a/src/emu/machine.cpp
+++ b/src/emu/machine.cpp
@@ -212,7 +212,9 @@ void running_machine::start()
add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(&running_machine::reset_all_devices, this));
add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&running_machine::stop_all_devices, this));
save().register_presave(save_prepost_delegate(FUNC(running_machine::presave_all_devices), this));
+ m_sound->before_devices_init();
start_all_devices();
+ m_sound->after_devices_init();
save().register_postload(save_prepost_delegate(FUNC(running_machine::postload_all_devices), this));
// save outputs created before start time
@@ -232,14 +234,28 @@ void running_machine::start()
if (filename[0] != 0 && !m_video->is_recording())
m_video->begin_recording(filename, movie_recording::format::AVI);
- // if we're coming in with a savegame request, process it now
const char *savegame = options().state();
if (savegame[0] != 0)
+ {
+ // if we're coming in with a savegame request, process it now
schedule_load(savegame);
-
- // if we're in autosave mode, schedule a load
- else if (options().autosave() && (m_system.flags & MACHINE_SUPPORTS_SAVE) != 0)
- schedule_load("auto");
+ }
+ else if (options().autosave())
+ {
+ // if we're in autosave mode, schedule a load
+ // m_save.supported() won't be set until save state registrations are finalised
+ bool supported = true;
+ for (device_t &device : device_enumerator(root_device()))
+ {
+ if (device.type().emulation_flags() & device_t::flags::SAVE_UNSUPPORTED)
+ {
+ supported = false;
+ break;
+ }
+ }
+ if (supported)
+ schedule_load("auto");
+ }
manager().update_machine();
}
@@ -284,15 +300,13 @@ int running_machine::run(bool quiet)
// then finish setting up our local machine
start();
+ // disallow save state registrations starting here
+ m_save.allow_registration(false);
+
// load the configuration settings
manager().before_load_settings(*this);
m_configuration->load_settings();
- // disallow save state registrations starting here.
- // Don't do it earlier, config load can create network
- // devices with timers.
- m_save.allow_registration(false);
-
// load the NVRAM
nvram_load();
@@ -331,9 +345,12 @@ int running_machine::run(bool quiet)
// execute CPUs if not paused
if (!m_paused)
m_scheduler.timeslice();
- // otherwise, just pump video updates through
+ // otherwise, just pump video updates and sound mapping updates through
else
+ {
m_video->frame_update();
+ sound().mapping_update();
+ }
// handle save/load
if (m_saveload_schedule != saveload_schedule::NONE)
@@ -408,7 +425,7 @@ void running_machine::schedule_exit()
m_scheduler.eat_all_cycles();
// if we're autosaving on exit, schedule a save as well
- if (options().autosave() && (m_system.flags & MACHINE_SUPPORTS_SAVE) && this->time() > attotime::zero)
+ if (options().autosave() && m_save.supported() && (this->time() > attotime::zero))
schedule_save("auto");
}
@@ -863,6 +880,7 @@ void running_machine::handle_saveload()
if (!m_saveload_pending_file.empty())
{
const char *const opname = (m_saveload_schedule == saveload_schedule::LOAD) ? "load" : "save";
+ const char *const preposname = (m_saveload_schedule == saveload_schedule::LOAD) ? "from" : "to";
// if there are anonymous timers, we can't save just yet, and we can't load yet either
// because the timers might overwrite data we have loaded
@@ -870,7 +888,7 @@ void running_machine::handle_saveload()
{
// if more than a second has passed, we're probably screwed
if ((this->time() - m_saveload_schedule_time) > attotime::from_seconds(1))
- popmessage("Unable to %s due to pending anonymous timers. See error.log for details.", opname);
+ popmessage("Error: Unable to %s state %s %s due to pending anonymous timers. See error.log for details.", opname, preposname, m_saveload_pending_file);
else
return; // return without cancelling the operation
}
@@ -883,39 +901,36 @@ void running_machine::handle_saveload()
auto const filerr = file.open(m_saveload_pending_file);
if (!filerr)
{
- const char *const opnamed = (m_saveload_schedule == saveload_schedule::LOAD) ? "loaded" : "saved";
-
// read/write the save state
save_error saverr = (m_saveload_schedule == saveload_schedule::LOAD) ? m_save.read_file(file) : m_save.write_file(file);
// handle the result
switch (saverr)
{
- case STATERR_ILLEGAL_REGISTRATIONS:
- popmessage("Error: Unable to %s state due to illegal registrations. See error.log for details.", opname);
- break;
-
case STATERR_INVALID_HEADER:
- popmessage("Error: Unable to %s state due to an invalid header. Make sure the save state is correct for this machine.", opname);
+ popmessage("Error: Unable to %s state %s %s due to an invalid header. Make sure the save state is correct for this system.", opname, preposname, m_saveload_pending_file);
break;
case STATERR_READ_ERROR:
- popmessage("Error: Unable to %s state due to a read error (file is likely corrupt).", opname);
+ popmessage("Error: Unable to %s state %s %s due to a read error (file is likely corrupt).", opname, preposname, m_saveload_pending_file);
break;
case STATERR_WRITE_ERROR:
- popmessage("Error: Unable to %s state due to a write error. Verify there is enough disk space.", opname);
+ popmessage("Error: Unable to %s state %s %s due to a write error. Verify there is enough disk space.", opname, preposname, m_saveload_pending_file);
break;
case STATERR_NONE:
- if (!(m_system.flags & MACHINE_SUPPORTS_SAVE))
- popmessage("State successfully %s.\nWarning: Save states are not officially supported for this machine.", opnamed);
+ {
+ const char *const opnamed = (m_saveload_schedule == saveload_schedule::LOAD) ? "Loaded" : "Saved";
+ if (!m_save.supported())
+ popmessage("%s state %s %s.\nWarning: Save states are not officially supported for this system.", opnamed, preposname, m_saveload_pending_file);
else
- popmessage("State successfully %s.", opnamed);
+ popmessage("%s state %s %s.", opnamed, preposname, m_saveload_pending_file);
break;
+ }
default:
- popmessage("Error: Unknown error during state %s.", opnamed);
+ popmessage("Error: Unknown error during %s state %s %s.", opname, preposname, m_saveload_pending_file);
break;
}
@@ -926,11 +941,11 @@ void running_machine::handle_saveload()
else if ((openflags == OPEN_FLAG_READ) && (std::errc::no_such_file_or_directory == filerr))
{
// attempt to load a non-existent savestate, report empty slot
- popmessage("Error: No savestate file to load.", opname);
+ popmessage("Error: Load state file %s not found.", m_saveload_pending_file);
}
else
{
- popmessage("Error: Failed to open file for %s operation.", opname);
+ popmessage("Error: Failed to open %s for %s state operation.", m_saveload_pending_file, opname);
}
}
}
@@ -1160,8 +1175,17 @@ void running_machine::nvram_save()
emu_file file(options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (!file.open(nvram_filename(nvram.device())))
{
+ bool error = false;
+
if (!nvram.nvram_save(file))
+ {
+ error = true;
osd_printf_error("Error writing NVRAM file %s\n", file.filename());
+ }
+
+ // close and perhaps delete the file
+ if (error || file.size() == 0)
+ file.remove_on_close();
file.close();
}
}