mirror of
https://github.com/holub/mame
synced 2025-06-16 17:29:27 +03:00
nvram: delete file on save if there's a write error or result file is 0 bytes
This commit is contained in:
parent
7fdaf9d48c
commit
a1e5795e34
@ -1508,10 +1508,9 @@ void mc68120_device::dpram_w(offs_t offset, uint8_t data)
|
||||
|
||||
bool m6801_cpu_device::nvram_write(util::write_stream &file)
|
||||
{
|
||||
// if it's currently not battery-backed, reinitialize nvram
|
||||
// so it won't load the previous nvram file on the next boot
|
||||
// if it's currently not battery-backed, don't save at all
|
||||
if (!m_nvram_battery)
|
||||
nvram_default();
|
||||
return true;
|
||||
|
||||
size_t actual;
|
||||
|
||||
@ -1568,6 +1567,10 @@ void m6801_cpu_device::nvram_default()
|
||||
|
||||
bool hd6301_cpu_device::nvram_write(util::write_stream &file)
|
||||
{
|
||||
// if it's currently not battery-backed, don't save at all
|
||||
if (!m_nvram_battery)
|
||||
return true;
|
||||
|
||||
if (!m6801_cpu_device::nvram_write(file))
|
||||
return false;
|
||||
|
||||
@ -1586,10 +1589,6 @@ bool hd6301_cpu_device::nvram_write(util::write_stream &file)
|
||||
// port output latches
|
||||
buf.insert(buf.end(), m_port_data, m_port_data + sizeof(m_port_data));
|
||||
|
||||
// zerofill if it's currently not battery-backed
|
||||
if (!m_nvram_battery)
|
||||
std::fill(buf.begin(), buf.end(), 0);
|
||||
|
||||
if (file.write(buf.data(), buf.size(), actual) || (buf.size() != actual))
|
||||
return false;
|
||||
|
||||
@ -1598,6 +1597,10 @@ bool hd6301_cpu_device::nvram_write(util::write_stream &file)
|
||||
|
||||
bool hd6301x_cpu_device::nvram_write(util::write_stream &file)
|
||||
{
|
||||
// if it's currently not battery-backed, don't save at all
|
||||
if (!m_nvram_battery)
|
||||
return true;
|
||||
|
||||
if (!hd6301_cpu_device::nvram_write(file))
|
||||
return false;
|
||||
|
||||
@ -1607,10 +1610,6 @@ bool hd6301x_cpu_device::nvram_write(util::write_stream &file)
|
||||
// port output latches
|
||||
buf.insert(buf.begin(), m_portx_data, m_portx_data + sizeof(m_portx_data));
|
||||
|
||||
// zerofill if it's currently not battery-backed
|
||||
if (!m_nvram_battery)
|
||||
std::fill(buf.begin(), buf.end(), 0);
|
||||
|
||||
if (file.write(buf.data(), buf.size(), actual) || (buf.size() != actual))
|
||||
return false;
|
||||
|
||||
|
@ -1160,8 +1160,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();
|
||||
}
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ u8 prisma_state::p7_r()
|
||||
if (BIT(m_inp_mux, i))
|
||||
data |= m_board->read_file(i);
|
||||
|
||||
return bitswap<8>(~data,1,7,6,0,5,4,2,3);
|
||||
return bitswap<8>(~data,6,5,3,2,0,1,7,4);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user