diff options
Diffstat (limited to 'src/devices/machine/rtc9701.cpp')
-rw-r--r-- | src/devices/machine/rtc9701.cpp | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/devices/machine/rtc9701.cpp b/src/devices/machine/rtc9701.cpp index f224f9c8f87..7f521d43063 100644 --- a/src/devices/machine/rtc9701.cpp +++ b/src/devices/machine/rtc9701.cpp @@ -12,7 +12,7 @@ ***************************************************************************/ #include "emu.h" -#include "machine/rtc9701.h" +#include "rtc9701.h" ALLOW_SAVE_TYPE(rtc9701_device::state_t); @@ -37,6 +37,7 @@ DEFINE_DEVICE_TYPE(RTC9701, rtc9701_device, "rtc9701", "Epson RTC-9701-JE RTC/EE rtc9701_device::rtc9701_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, RTC9701, tag, owner, clock) , device_nvram_interface(mconfig, *this) + , device_rtc_interface(mconfig, *this) , m_latch(0) , m_reset_line(CLEAR_LINE) , m_clock_line(CLEAR_LINE) @@ -92,20 +93,9 @@ void rtc9701_device::device_validity_check(validity_checker &valid) const void rtc9701_device::device_start() { /* let's call the timer callback every second */ - m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rtc9701_device::timer_callback), this)); + m_timer = timer_alloc(FUNC(rtc9701_device::timer_callback), this); m_timer->adjust(attotime::from_hz(clock() / XTAL(32'768)), 0, attotime::from_hz(clock() / XTAL(32'768))); - system_time systime; - machine().base_datetime(systime); - - m_rtc.day = ((systime.local_time.mday / 10)<<4) | ((systime.local_time.mday % 10) & 0xf); - m_rtc.month = (((systime.local_time.month+1) / 10) << 4) | (((systime.local_time.month+1) % 10) & 0xf); - m_rtc.wday = 1 << systime.local_time.weekday; - m_rtc.year = (((systime.local_time.year % 100)/10)<<4) | ((systime.local_time.year % 10) & 0xf); - m_rtc.hour = ((systime.local_time.hour / 10)<<4) | ((systime.local_time.hour % 10) & 0xf); - m_rtc.min = ((systime.local_time.minute / 10)<<4) | ((systime.local_time.minute % 10) & 0xf); - m_rtc.sec = ((systime.local_time.second / 10)<<4) | ((systime.local_time.second % 10) & 0xf); - rtc_state = state_t::CMD_WAIT; cmd_stream_pos = 0; current_cmd = 0; @@ -132,6 +122,22 @@ void rtc9701_device::device_start() //------------------------------------------------- +// rtc_clock_updated - update clock with real time +//------------------------------------------------- + +void rtc9701_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) +{ + m_rtc.day = ((day / 10)<<4) | ((day % 10) & 0xf); + m_rtc.month = ((month / 10) << 4) | ((month % 10) & 0xf); + m_rtc.wday = 1 << (day_of_week - 1); + m_rtc.year = (((year % 100)/10)<<4) | ((year % 10) & 0xf); + m_rtc.hour = ((hour / 10)<<4) | ((hour % 10) & 0xf); + m_rtc.min = ((minute / 10)<<4) | ((minute % 10) & 0xf); + m_rtc.sec = ((second / 10)<<4) | ((second % 10) & 0xf); +} + + +//------------------------------------------------- // device_reset - device-specific reset //------------------------------------------------- @@ -160,9 +166,10 @@ void rtc9701_device::nvram_default() // .nv file //------------------------------------------------- -void rtc9701_device::nvram_read(emu_file &file) +bool rtc9701_device::nvram_read(util::read_stream &file) { - file.read(rtc9701_data, 0x200); + auto const [err, actual] = read(file, rtc9701_data, 0x200); + return !err && (actual == 0x200); } @@ -171,9 +178,10 @@ void rtc9701_device::nvram_read(emu_file &file) // .nv file //------------------------------------------------- -void rtc9701_device::nvram_write(emu_file &file) +bool rtc9701_device::nvram_write(util::write_stream &file) { - file.write(rtc9701_data, 0x200); + auto const [err, actual] = write(file, rtc9701_data, 0x200); + return !err; } //------------------------------------------------- @@ -220,13 +228,13 @@ inline void rtc9701_device::rtc_write(uint8_t offset,uint8_t data) // READ/WRITE HANDLERS //************************************************************************** -WRITE_LINE_MEMBER( rtc9701_device::write_bit ) +void rtc9701_device::write_bit(int state) { m_latch = state; } -READ_LINE_MEMBER( rtc9701_device::read_bit ) +int rtc9701_device::read_bit() { if (rtc_state == state_t::RTC_READ) { @@ -251,7 +259,7 @@ READ_LINE_MEMBER( rtc9701_device::read_bit ) } -WRITE_LINE_MEMBER( rtc9701_device::set_cs_line ) +void rtc9701_device::set_cs_line(int state) { //logerror("set reset line %d\n",state); m_reset_line = state; @@ -271,7 +279,7 @@ WRITE_LINE_MEMBER( rtc9701_device::set_cs_line ) -WRITE_LINE_MEMBER( rtc9701_device::set_clock_line ) +void rtc9701_device::set_clock_line(int state) { //logerror("set clock line %d\n",state); @@ -377,7 +385,7 @@ WRITE_LINE_MEMBER( rtc9701_device::set_clock_line ) if (cmd_stream_pos>4) { rtc9701_data_pos++; - rtc9701_current_data = (rtc9701_current_data << 1) | (m_latch&1);; + rtc9701_current_data = (rtc9701_current_data << 1) | (m_latch&1); } if (cmd_stream_pos==12) @@ -438,7 +446,7 @@ WRITE_LINE_MEMBER( rtc9701_device::set_clock_line ) if (cmd_stream_pos>12) { rtc9701_data_pos++; - rtc9701_current_data = (rtc9701_current_data << 1) | (m_latch&1);; + rtc9701_current_data = (rtc9701_current_data << 1) | (m_latch&1); } if (cmd_stream_pos==28) |