hd6301: don't save internal registers to nvram when it's not battery backed

This commit is contained in:
hap 2024-01-25 00:13:55 +01:00
parent 4c0957d7f0
commit cc7db139c2

View File

@ -1571,24 +1571,28 @@ bool hd6301_cpu_device::nvram_write(util::write_stream &file)
if (!m6801_cpu_device::nvram_write(file))
return false;
size_t actual;
uint8_t buf[7];
// skip if it's currently not battery-backed
if (m_nvram_battery)
{
size_t actual;
uint8_t buf[7];
// misc registers
buf[0] = m_s.b.h;
buf[1] = m_s.b.l;
buf[2] = m_x.b.h;
buf[3] = m_x.b.l;
buf[4] = m_d.b.h;
buf[5] = m_d.b.l;
buf[6] = m_tdr;
// misc registers
buf[0] = m_s.b.h;
buf[1] = m_s.b.l;
buf[2] = m_x.b.h;
buf[3] = m_x.b.l;
buf[4] = m_d.b.h;
buf[5] = m_d.b.l;
buf[6] = m_tdr;
if (file.write(&buf, sizeof(buf), actual) || (sizeof(buf) != actual))
return false;
if (file.write(&buf, sizeof(buf), actual) || (sizeof(buf) != actual))
return false;
// port output latches
if (file.write(&m_port_data[0], sizeof(m_port_data), actual) || sizeof(m_port_data) != actual)
return false;
// port output latches
if (file.write(&m_port_data[0], sizeof(m_port_data), actual) || sizeof(m_port_data) != actual)
return false;
}
return true;
}
@ -1598,11 +1602,15 @@ bool hd6301x_cpu_device::nvram_write(util::write_stream &file)
if (!hd6301_cpu_device::nvram_write(file))
return false;
size_t actual;
// skip if it's currently not battery-backed
if (m_nvram_battery)
{
size_t actual;
// port output latches
if (file.write(&m_portx_data[0], sizeof(m_portx_data), actual) || sizeof(m_portx_data) != actual)
return false;
// port output latches
if (file.write(&m_portx_data[0], sizeof(m_portx_data), actual) || sizeof(m_portx_data) != actual)
return false;
}
return true;
}