diff options
author | 2021-04-30 14:49:12 +0900 | |
---|---|---|
committer | 2021-04-30 14:49:12 +0900 | |
commit | cf221c25e6f1c46123816a6a3aec9dd9e02a7704 (patch) | |
tree | e9a7f951c47d38f78d6299ef9b445f46f80b79c2 | |
parent | b9ad42595e6f5276616a0355f38438f2dbbf07cb (diff) |
rtc65271: Allow for default nvram data initialization using external data
-rw-r--r-- | src/devices/machine/rtc65271.cpp | 17 | ||||
-rw-r--r-- | src/devices/machine/rtc65271.h | 2 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/devices/machine/rtc65271.cpp b/src/devices/machine/rtc65271.cpp index 1eb84d89171..b39730fb372 100644 --- a/src/devices/machine/rtc65271.cpp +++ b/src/devices/machine/rtc65271.cpp @@ -162,10 +162,18 @@ static uint8_t BCD_to_binary(uint8_t data) void rtc65271_device::nvram_default() { - memset(m_regs,0, sizeof(m_regs)); - memset(m_xram,0, sizeof(m_xram)); - - m_regs[reg_B] |= reg_B_DM; // Firebeat assumes the chip factory defaults to non-BCD mode (or maybe Konami programs it that way?) + if (m_default_data.found()) + { + emu_file file(OPEN_FLAG_READ); + file.open_ram(m_default_data, m_default_data.bytes()); + nvram_read(file); + } + else + { + memset(m_regs, 0, sizeof(m_regs)); + memset(m_xram, 0, sizeof(m_xram)); + m_regs[reg_B] |= reg_B_DM; // Firebeat assumes the chip factory defaults to non-BCD mode (or maybe Konami programs it that way?) + } } //------------------------------------------------- @@ -660,6 +668,7 @@ rtc65271_device::rtc65271_device(const machine_config &mconfig, const char *tag, : device_t(mconfig, RTC65271, tag, owner, clock) , device_nvram_interface(mconfig, *this) , m_interrupt_cb(*this) + , m_default_data(*this, DEVICE_SELF) { } diff --git a/src/devices/machine/rtc65271.h b/src/devices/machine/rtc65271.h index 151344d6e7c..e249491cf48 100644 --- a/src/devices/machine/rtc65271.h +++ b/src/devices/machine/rtc65271.h @@ -63,6 +63,8 @@ private: /* callback called when interrupt pin state changes (may be nullptr) */ devcb_write_line m_interrupt_cb; + + optional_region_ptr<u8> m_default_data; }; // device type definition |