From cf839391db959370292361558fbbbe68d958ddb0 Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Fri, 8 Sep 2023 22:53:01 +0200 Subject: machine/rp5c15.cpp: implement set_year_offset setter, fix x68k default year setup to be current rather than -20 (#11530) * machine/rp5c15.cpp: implement set_year_offset setter, fix x68k default year setup to be current rather than -20 * machine/ds1386.cpp: remove non-existant set_current_time fn override --- src/devices/machine/ds1386.h | 2 -- src/devices/machine/rp5c15.cpp | 8 ++++++++ src/devices/machine/rp5c15.h | 5 +++++ src/emu/dirtc.h | 2 +- src/mame/sharp/x68k.cpp | 1 + 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/devices/machine/ds1386.h b/src/devices/machine/ds1386.h index 72740b7eeda..c7b15d16799 100644 --- a/src/devices/machine/ds1386.h +++ b/src/devices/machine/ds1386.h @@ -166,8 +166,6 @@ protected: void safe_intb_cb(int state); void safe_sqw_cb(int state); - void set_current_time(); - void check_tod_alarm(); void time_of_day_alarm(); void watchdog_alarm(); diff --git a/src/devices/machine/rp5c15.cpp b/src/devices/machine/rp5c15.cpp index 75481d24f7f..f2b8ff4a037 100644 --- a/src/devices/machine/rp5c15.cpp +++ b/src/devices/machine/rp5c15.cpp @@ -109,6 +109,14 @@ enum DEFINE_DEVICE_TYPE(RP5C15, rp5c15_device, "rp5c15", "Ricoh RP5C15 RTC") +// x68k wants an epoch base (1980-2079) on init, mz2500 do not ("print date$" under basicv2) +// megast_* tbd +void rp5c15_device::set_current_time(const system_time &systime) +{ + const system_time::full_time &time = m_use_utc ? systime.utc_time : systime.local_time; + set_time(true, time.year + m_year_offset, time.month + 1, time.mday, time.weekday + 1, + time.hour, time.minute, time.second); +} //************************************************************************** // INLINE HELPERS diff --git a/src/devices/machine/rp5c15.h b/src/devices/machine/rp5c15.h index 15936a02445..6630260fc8c 100644 --- a/src/devices/machine/rp5c15.h +++ b/src/devices/machine/rp5c15.h @@ -34,10 +34,13 @@ public: auto alarm() { return m_out_alarm_cb.bind(); } auto clkout() { return m_out_clkout_cb.bind(); } + void set_year_offset(int year) { m_year_offset = year; } uint8_t read(offs_t offset); void write(offs_t offset, uint8_t data); + virtual void set_current_time(const system_time &systime) override; + protected: // device-level overrides virtual void device_start() override; @@ -70,6 +73,8 @@ private: int m_16hz; // 16 Hz condition int m_clkout; // clock output + int m_year_offset = 0; + // timers emu_timer *m_clock_timer; emu_timer *m_16hz_timer; diff --git a/src/emu/dirtc.h b/src/emu/dirtc.h index e76a8d3dba3..e741cfc2628 100644 --- a/src/emu/dirtc.h +++ b/src/emu/dirtc.h @@ -51,7 +51,7 @@ public: void set_use_utc(bool use_utc) { m_use_utc = use_utc; } void set_time(bool update, int year, int month, int day, int day_of_week, int hour, int minute, int second); - void set_current_time(const system_time &systime); + virtual void set_current_time(const system_time &systime); bool has_battery() const { return rtc_battery_backed(); } diff --git a/src/mame/sharp/x68k.cpp b/src/mame/sharp/x68k.cpp index 45fa1b582f5..7565356a2ce 100644 --- a/src/mame/sharp/x68k.cpp +++ b/src/mame/sharp/x68k.cpp @@ -1282,6 +1282,7 @@ void x68k_state::x68000_base(machine_config &config) RP5C15(config, m_rtc, 32.768_kHz_XTAL); m_rtc->alarm().set(m_mfpdev, FUNC(mc68901_device::i0_w)); + m_rtc->set_year_offset(20); /* video hardware */ SCREEN(config, m_screen, SCREEN_TYPE_RASTER); -- cgit v1.2.3