summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/save.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/save.cpp')
-rw-r--r--src/emu/save.cpp60
1 files changed, 24 insertions, 36 deletions
diff --git a/src/emu/save.cpp b/src/emu/save.cpp
index ab1fc5a854d..35599c2e679 100644
--- a/src/emu/save.cpp
+++ b/src/emu/save.cpp
@@ -27,7 +27,6 @@
#include "main.h"
-#include "util/coreutil.h"
#include "util/ioprocs.h"
#include "util/ioprocsfilter.h"
@@ -68,7 +67,7 @@ enum
save_manager::save_manager(running_machine &machine)
: m_machine(machine)
, m_reg_allowed(true)
- , m_illegal_regs(0)
+ , m_supported(false)
{
m_rewind = std::make_unique<rewinder>(*this);
}
@@ -102,6 +101,16 @@ void save_manager::allow_registration(bool allowed)
if (dupes_found)
fatalerror("%d duplicate save state entries found.\n", dupes_found);
+ m_supported = true;
+ for (device_t &device : device_enumerator(machine().root_device()))
+ {
+ if (device.type().emulation_flags() & device_t::flags::SAVE_UNSUPPORTED)
+ {
+ m_supported = false;
+ break;
+ }
+ }
+
dump_registry();
// everything is registered by now, evaluate the savestate size
@@ -187,9 +196,7 @@ void save_manager::save_memory(device_t *device, const char *module, const char
if (!m_reg_allowed)
{
machine().logerror("Attempt to register save state entry after state registration is closed!\nModule %s tag %s name %s\n", module, tag, name);
- if (machine().system().flags & machine_flags::SUPPORTS_SAVE)
- fatalerror("Attempt to register save state entry after state registration is closed!\nModule %s tag %s name %s\n", module, tag, name);
- m_illegal_regs++;
+ fatalerror("Attempt to register save state entry after state registration is closed!\nModule %s tag %s name %s\n", module, tag, name);
return;
}
@@ -219,8 +226,8 @@ save_error save_manager::check_file(running_machine &machine, util::core_file &f
// seek to the beginning and read the header
file.seek(0, SEEK_SET);
u8 header[HEADER_SIZE];
- size_t actual(0);
- if (file.read(header, sizeof(header), actual) || actual != sizeof(header))
+ auto const [err, actual] = read(file, header, sizeof(header));
+ if (err || (actual != sizeof(header)))
{
if (errormsg != nullptr)
(*errormsg)("Could not read %s save file header", emulator_info::get_appname());
@@ -267,9 +274,8 @@ save_error save_manager::write_file(util::core_file &file)
[] (size_t total_size) { return true; },
[&writer] (const void *data, size_t size)
{
- size_t written;
- std::error_condition filerr = writer->write(data, size, written);
- return !filerr && (size == written);
+ auto const [filerr, written] = write(*writer, data, size);
+ return !filerr;
},
[&file, &writer] ()
{
@@ -300,9 +306,8 @@ save_error save_manager::read_file(util::core_file &file)
[] (size_t total_size) { return true; },
[&reader] (void *data, size_t size)
{
- std::size_t read;
- std::error_condition filerr = reader->read(data, size, read);
- return !filerr && (read == size);
+ auto const [filerr, actual] = read(*reader, data, size);
+ return !filerr && (actual == size);
},
[&file, &reader] ()
{
@@ -408,10 +413,6 @@ save_error save_manager::read_buffer(const void *buf, size_t size)
template <typename T, typename U, typename V, typename W>
inline save_error save_manager::do_write(T check_space, U write_block, V start_header, W start_data)
{
- // if we have illegal registrations, return an error
- if (m_illegal_regs > 0)
- return STATERR_ILLEGAL_REGISTRATIONS;
-
// check for sufficient space
size_t total_size = HEADER_SIZE;
for (const auto &entry : m_entry_list)
@@ -455,10 +456,6 @@ inline save_error save_manager::do_write(T check_space, U write_block, V start_h
template <typename T, typename U, typename V, typename W>
inline save_error save_manager::do_read(T check_length, U read_block, V start_header, W start_data)
{
- // if we have illegal registrations, return an error
- if (m_illegal_regs > 0)
- return STATERR_ILLEGAL_REGISTRATIONS;
-
// check for sufficient space
size_t total_size = HEADER_SIZE;
for (const auto &entry : m_entry_list)
@@ -508,21 +505,21 @@ inline save_error save_manager::do_read(T check_length, U read_block, V start_he
u32 save_manager::signature() const
{
// iterate over entries
- u32 crc = 0;
+ util::crc32_creator crc;
for (auto &entry : m_entry_list)
{
// add the entry name to the CRC
- crc = core_crc32(crc, (u8 *)entry->m_name.c_str(), entry->m_name.length());
+ crc.append(entry->m_name.data(), entry->m_name.length());
// add the type and size to the CRC
u32 temp[4];
temp[0] = little_endianize_int32(entry->m_typesize);
temp[1] = little_endianize_int32(entry->m_typecount);
temp[2] = little_endianize_int32(entry->m_blockcount);
- temp[3] = little_endianize_int32(entry->m_stride);
- crc = core_crc32(crc, (u8 *)&temp[0], sizeof(temp));
+ temp[3] = 0;
+ crc.append(&temp[0], sizeof(temp));
}
- return crc;
+ return crc.finish();
}
@@ -663,10 +660,6 @@ save_error ram_state::load()
// initialize
m_data.seekg(0);
- // if we have illegal registrations, return an error
- if (m_save.m_illegal_regs > 0)
- return STATERR_ILLEGAL_REGISTRATIONS;
-
// get the save manager to load state
return m_save.read_stream(m_data);
}
@@ -916,11 +909,6 @@ void rewinder::report_error(save_error error, rewind_operation operation)
switch (error)
{
// internal saveload failures
- case STATERR_ILLEGAL_REGISTRATIONS:
- m_save.machine().logerror("Rewind error: Unable to %s state due to illegal registrations.", opname);
- m_save.machine().popmessage("Rewind error occured. See error.log for details.");
- break;
-
case STATERR_INVALID_HEADER:
m_save.machine().logerror("Rewind error: Unable to %s state due to an invalid header. "
"Make sure the save state is correct for this machine.\n", opname);
@@ -957,7 +945,7 @@ void rewinder::report_error(save_error error, rewind_operation operation)
// success
case STATERR_NONE:
{
- const u64 supported = m_save.machine().system().flags & MACHINE_SUPPORTS_SAVE;
+ const u64 supported = m_save.supported();
const char *const warning = supported || !m_first_time_warning ? "" :
"Rewind warning: Save states are not officially supported for this machine.\n";
const char *const opnamed = (operation == rewind_operation::LOAD) ? "loaded" : "captured";