From cf221c25e6f1c46123816a6a3aec9dd9e02a7704 Mon Sep 17 00:00:00 2001 From: 987123879113 <63495610+987123879113@users.noreply.github.com> Date: Fri, 30 Apr 2021 14:49:12 +0900 Subject: rtc65271: Allow for default nvram data initialization using external data --- src/devices/machine/rtc65271.cpp | 17 +++++++++++++---- 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 m_default_data; }; // device type definition -- cgit v1.2.3