diff options
author | 2016-10-09 21:53:38 -0400 | |
---|---|---|
committer | 2016-10-09 22:04:32 -0400 | |
commit | 0d2d4cab4fdfa14d2ef65f2245e82ca4a5c8f2fd (patch) | |
tree | e7b7ee41c5f392d750f2268d459f81d3c6839f7d /src | |
parent | fd94538c211312aff801ee3decfb1e090ad40218 (diff) |
Soft resets no longer turn back clocks on devices
device_rtc_interface: Cleanups and refinements (nw)
- Give RTCs their own phase of machine initialization, right after NVRAM loading
- Make RTC feature flag overrides const, including one new one
- Make rtc_clock_updated a required override
Diffstat (limited to 'src')
37 files changed, 127 insertions, 157 deletions
diff --git a/src/devices/machine/aicartc.cpp b/src/devices/machine/aicartc.cpp index b4ebca893eb..e4ed8fa44b0 100644 --- a/src/devices/machine/aicartc.cpp +++ b/src/devices/machine/aicartc.cpp @@ -54,40 +54,43 @@ void aicartc_device::device_start() { m_clock_timer = timer_alloc(); m_clock_timer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock())); +} - { - UINT32 current_time; - int year_count,cur_year,i; - const int month_to_day_conversion[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; - system_time systime; - machine().base_datetime(systime); - - /* put the seconds */ - current_time = systime.local_time.second; - /* put the minutes */ - current_time+= systime.local_time.minute*60; - /* put the hours */ - current_time+= systime.local_time.hour*60*60; - /* put the days (note -1) */ - current_time+= (systime.local_time.mday-1)*60*60*24; - /* take the current year here for calculating leaps */ - cur_year = (systime.local_time.year); - - /* take the months - despite popular beliefs, leap years aren't just evenly divisible by 4 */ - if(((((cur_year % 4) == 0) && ((cur_year % 100) != 0)) || ((cur_year % 400) == 0)) && systime.local_time.month > 2) - current_time+= (month_to_day_conversion[systime.local_time.month]+1)*60*60*24; - else - current_time+= (month_to_day_conversion[systime.local_time.month])*60*60*24; - - /* put the years */ - year_count = (cur_year-1949); - - for(i=0;i<year_count-1;i++) - current_time += (((((i+1950) % 4) == 0) && (((i+1950) % 100) != 0)) || (((i+1950) % 400) == 0)) ? 60*60*24*366 : 60*60*24*365; - - m_rtc_reg_lo = current_time & 0x0000ffff; - m_rtc_reg_hi = (current_time & 0xffff0000) >> 16; - } + +//------------------------------------------------- +// rtc_clock_updated - +//------------------------------------------------- + +void aicartc_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) +{ + const int month_to_day_conversion[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; + + // put the seconds + UINT32 current_time = second; + + // put the minutes + current_time += minute * 60; + + // put the hours + current_time += hour * 60 * 60; + + // put the days (note -1) */ + current_time += (day - 1) * 60 * 60 * 24; + + // take the months - despite popular beliefs, leap years aren't just evenly divisible by 4 */ + if (((((year % 4) == 0) && ((year % 100) != 0)) || ((year % 400) == 0)) && month > 2) + current_time += (month_to_day_conversion[month - 1] + 1) * 60 * 60 * 24; + else + current_time += (month_to_day_conversion[month - 1]) * 60 * 60 * 24; + + // put the years + int year_count = (year - 1949); + + for (int i = 0; i < year_count - 1; i++) + current_time += (((((i+1950) % 4) == 0) && (((i+1950) % 100) != 0)) || (((i+1950) % 400) == 0)) ? 60*60*24*366 : 60*60*24*365; + + m_rtc_reg_lo = current_time & 0x0000ffff; + m_rtc_reg_hi = (current_time & 0xffff0000) >> 16; } diff --git a/src/devices/machine/aicartc.h b/src/devices/machine/aicartc.h index 6e1d9e2183e..f923ce073ca 100644 --- a/src/devices/machine/aicartc.h +++ b/src/devices/machine/aicartc.h @@ -11,6 +11,7 @@ Template for skeleton device #ifndef __AICARTCDEV_H__ #define __AICARTCDEV_H__ +#include "dirtc.h" //************************************************************************** @@ -48,6 +49,11 @@ protected: virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + // device_rtc_interface overrides + virtual bool rtc_feature_y2k() const override { return true; } + virtual bool rtc_feature_leap_year() const override { return true; } + virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; + private: emu_timer *m_clock_timer; }; diff --git a/src/devices/machine/ds1302.cpp b/src/devices/machine/ds1302.cpp index c2cd23b560f..b6f6b0675b4 100644 --- a/src/devices/machine/ds1302.cpp +++ b/src/devices/machine/ds1302.cpp @@ -113,8 +113,6 @@ void ds1302_device::device_start() void ds1302_device::device_reset() { - set_current_time(machine()); - m_clk = 0; m_ce = 0; m_state = STATE_COMMAND; diff --git a/src/devices/machine/ds1302.h b/src/devices/machine/ds1302.h index 515613579b2..6afbc9ea9a4 100644 --- a/src/devices/machine/ds1302.h +++ b/src/devices/machine/ds1302.h @@ -18,7 +18,7 @@ #ifndef __DS1302_H__ #define __DS1302_H__ -#include "emu.h" +#include "dirtc.h" @@ -63,7 +63,7 @@ protected: // device_rtc_interface overrides virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; - virtual bool rtc_feature_leap_year() override { return true; } + virtual bool rtc_feature_leap_year() const override { return true; } private: void load_shift_register(); diff --git a/src/devices/machine/e0516.cpp b/src/devices/machine/e0516.cpp index f80cad5bdb5..acd6c2d0193 100644 --- a/src/devices/machine/e0516.cpp +++ b/src/devices/machine/e0516.cpp @@ -68,16 +68,6 @@ void e0516_device::device_start() //------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void e0516_device::device_reset() -{ - set_current_time(machine()); -} - - -//------------------------------------------------- // device_timer - handler timer events //------------------------------------------------- @@ -196,3 +186,12 @@ READ_LINE_MEMBER( e0516_device::dio_r ) { return m_dio; } + + +//------------------------------------------------- +// rtc_clock_updated - +//------------------------------------------------- + +void e0516_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) +{ +} diff --git a/src/devices/machine/e0516.h b/src/devices/machine/e0516.h index 7e95be0dfc1..227c65dd2a5 100644 --- a/src/devices/machine/e0516.h +++ b/src/devices/machine/e0516.h @@ -22,7 +22,7 @@ #ifndef __E0516__ #define __E0516__ -#include "emu.h" +#include "dirtc.h" @@ -56,9 +56,11 @@ public: protected: // device-level overrides virtual void device_start() override; - virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + // device_rtc_interface overrides + virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; + private: int m_cs; // chip select int m_clk; // clock diff --git a/src/devices/machine/hd64610.cpp b/src/devices/machine/hd64610.cpp index d4639892e17..f006b2a65d2 100644 --- a/src/devices/machine/hd64610.cpp +++ b/src/devices/machine/hd64610.cpp @@ -183,16 +183,6 @@ void hd64610_device::device_start() //------------------------------------------------- -// device_start - device-specific reset -//------------------------------------------------- - -void hd64610_device::device_reset() -{ - set_current_time(machine()); -} - - -//------------------------------------------------- // device_timer - handler timer events //------------------------------------------------- diff --git a/src/devices/machine/hd64610.h b/src/devices/machine/hd64610.h index 021cf181c27..81147baede3 100644 --- a/src/devices/machine/hd64610.h +++ b/src/devices/machine/hd64610.h @@ -26,7 +26,7 @@ #ifndef __HD64610__ #define __HD64610__ -#include "emu.h" +#include "dirtc.h" @@ -67,7 +67,6 @@ public: protected: // device-level overrides virtual void device_start() override; - virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // device_rtc_interface overrides diff --git a/src/devices/machine/mccs1850.cpp b/src/devices/machine/mccs1850.cpp index 72fb12a667a..28d29bab8bc 100644 --- a/src/devices/machine/mccs1850.cpp +++ b/src/devices/machine/mccs1850.cpp @@ -299,14 +299,18 @@ mccs1850_device::mccs1850_device(const machine_config &mconfig, const char *tag, //------------------------------------------------- -// set_counter - set the counter at startup time +// rtc_clock_changed - //------------------------------------------------- -void mccs1850_device::set_counter(UINT32 value) +void mccs1850_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) { - m_counter = value; + // FIXME: implement this properly + system_time systime; + machine().base_datetime(systime); + m_counter = systime.time; } + //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- diff --git a/src/devices/machine/mccs1850.h b/src/devices/machine/mccs1850.h index e4179c47e82..f7643f1465e 100644 --- a/src/devices/machine/mccs1850.h +++ b/src/devices/machine/mccs1850.h @@ -22,7 +22,7 @@ #ifndef __MCCS1850__ #define __MCCS1850__ -#include "emu.h" +#include "dirtc.h" @@ -67,9 +67,6 @@ public: DECLARE_WRITE_LINE_MEMBER( por_w ); DECLARE_WRITE_LINE_MEMBER( test_w ); - // For setting the time at startup - void set_counter(UINT32 value); - protected: // device-level overrides virtual void device_start() override; @@ -81,6 +78,9 @@ protected: virtual void nvram_read(emu_file &file) override; virtual void nvram_write(emu_file &file) override; + // device_rtc_interface overrides + virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; + private: inline void check_interrupt(); inline void set_pse_line(bool state); diff --git a/src/devices/machine/mm58167.cpp b/src/devices/machine/mm58167.cpp index ed66df7603f..75e9e799004 100644 --- a/src/devices/machine/mm58167.cpp +++ b/src/devices/machine/mm58167.cpp @@ -83,8 +83,6 @@ void mm58167_device::device_start() void mm58167_device::device_reset() { - set_current_time(machine()); - m_regs[R_CTL_STATUS] = 0; // not busy m_regs[R_CTL_IRQSTATUS] = 0; m_regs[R_CTL_IRQCONTROL] = 0; diff --git a/src/devices/machine/mm58167.h b/src/devices/machine/mm58167.h index c1a7e0b320e..6a02497341d 100644 --- a/src/devices/machine/mm58167.h +++ b/src/devices/machine/mm58167.h @@ -11,7 +11,7 @@ #ifndef __MM58167_H__ #define __MM58167_H__ -#include "emu.h" +#include "dirtc.h" //************************************************************************** @@ -50,7 +50,7 @@ protected: // device_rtc_interface overrides virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; - virtual bool rtc_feature_leap_year() override { return true; } + virtual bool rtc_feature_leap_year() const override { return true; } void set_irq(int bit); void update_rtc(); diff --git a/src/devices/machine/msm5832.cpp b/src/devices/machine/msm5832.cpp index 21fdeb3ba63..e87396bcee8 100644 --- a/src/devices/machine/msm5832.cpp +++ b/src/devices/machine/msm5832.cpp @@ -122,16 +122,6 @@ void msm5832_device::device_start() //------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void msm5832_device::device_reset() -{ - set_current_time(machine()); -} - - -//------------------------------------------------- // device_timer - handler timer events //------------------------------------------------- diff --git a/src/devices/machine/msm5832.h b/src/devices/machine/msm5832.h index a437501f23b..aeb6e512f01 100644 --- a/src/devices/machine/msm5832.h +++ b/src/devices/machine/msm5832.h @@ -23,7 +23,7 @@ #ifndef __MSM5832__ #define __MSM5832__ -#include "emu.h" +#include "dirtc.h" @@ -65,7 +65,6 @@ public: protected: // device-level overrides virtual void device_start() override; - virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // device_rtc_interface overrides diff --git a/src/devices/machine/msm58321.cpp b/src/devices/machine/msm58321.cpp index 7bdd77713ea..a66f0ba9865 100644 --- a/src/devices/machine/msm58321.cpp +++ b/src/devices/machine/msm58321.cpp @@ -243,10 +243,6 @@ void msm58321_device::device_start() save_item(NAME(m_cs1)); save_item(NAME(m_address)); save_item(NAME(m_reg)); - - set_current_time(machine()); - - update_output(); } diff --git a/src/devices/machine/msm58321.h b/src/devices/machine/msm58321.h index 04d174eedc2..0013f7901cf 100644 --- a/src/devices/machine/msm58321.h +++ b/src/devices/machine/msm58321.h @@ -22,7 +22,7 @@ #ifndef __MSM58321__ #define __MSM58321__ -#include "emu.h" +#include "dirtc.h" @@ -89,7 +89,7 @@ protected: // device_rtc_interface overrides virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; - virtual bool rtc_feature_y2k() override { return m_year0 != 0; } + virtual bool rtc_feature_y2k() const override { return m_year0 != 0; } // device_nvram_interface overrides virtual void nvram_default() override; diff --git a/src/devices/machine/msm6242.cpp b/src/devices/machine/msm6242.cpp index a4a188cbcb6..9b0b35df2c3 100644 --- a/src/devices/machine/msm6242.cpp +++ b/src/devices/machine/msm6242.cpp @@ -86,9 +86,6 @@ void msm6242_device::device_start() m_timer = timer_alloc(TIMER_RTC_CALLBACK); m_timer->adjust(attotime::zero); - // get real time from system - set_current_time(machine()); - // set up registers m_tick = 0; m_irq_flag = 0; diff --git a/src/devices/machine/msm6242.h b/src/devices/machine/msm6242.h index f53e4b60f01..f59902474c4 100644 --- a/src/devices/machine/msm6242.h +++ b/src/devices/machine/msm6242.h @@ -11,7 +11,7 @@ #ifndef __MSM6242DEV_H__ #define __MSM6242DEV_H__ -#include "emu.h" +#include "dirtc.h" #define MCFG_MSM6242_OUT_INT_HANDLER(_devcb) \ diff --git a/src/devices/machine/pcf8593.h b/src/devices/machine/pcf8593.h index 63b3befe6b9..addf666d9fb 100644 --- a/src/devices/machine/pcf8593.h +++ b/src/devices/machine/pcf8593.h @@ -11,7 +11,7 @@ #ifndef __PCF8593_H__ #define __PCF8593_H__ -#include "emu.h" +#include "dirtc.h" //************************************************************************** @@ -45,7 +45,7 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // device_rtc_interface overrides - virtual bool rtc_feature_y2k() override { return true; } + virtual bool rtc_feature_y2k() const override { return true; } virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; // device_nvram_interface overrides diff --git a/src/devices/machine/rp5c01.cpp b/src/devices/machine/rp5c01.cpp index 5ac56b4b415..f3112eab607 100644 --- a/src/devices/machine/rp5c01.cpp +++ b/src/devices/machine/rp5c01.cpp @@ -224,9 +224,6 @@ void rp5c01_device::device_reset() // 24 hour mode m_reg[MODE01][REGISTER_12_24_SELECT] = 1; - - if (m_battery_backed && clock() > 0) - set_current_time(machine()); } diff --git a/src/devices/machine/rp5c01.h b/src/devices/machine/rp5c01.h index f9cf0a12609..cba2566fcab 100644 --- a/src/devices/machine/rp5c01.h +++ b/src/devices/machine/rp5c01.h @@ -23,7 +23,7 @@ #ifndef __RP5C01__ #define __RP5C01__ -#include "emu.h" +#include "dirtc.h" @@ -68,7 +68,8 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // device_rtc_interface overrides - virtual bool rtc_feature_leap_year() override { return true; } + virtual bool rtc_feature_leap_year() const override { return true; } + virtual bool rtc_battery_backed() const override { return m_battery_backed; } virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; // device_nvram_interface overrides diff --git a/src/devices/machine/rp5c15.cpp b/src/devices/machine/rp5c15.cpp index 7967366c349..88989b41d7c 100644 --- a/src/devices/machine/rp5c15.cpp +++ b/src/devices/machine/rp5c15.cpp @@ -238,16 +238,6 @@ void rp5c15_device::device_start() //------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void rp5c15_device::device_reset() -{ - set_current_time(machine()); -} - - -//------------------------------------------------- // device_timer - handler timer events //------------------------------------------------- diff --git a/src/devices/machine/rp5c15.h b/src/devices/machine/rp5c15.h index 1e36dfaf60f..4aa3c721662 100644 --- a/src/devices/machine/rp5c15.h +++ b/src/devices/machine/rp5c15.h @@ -23,7 +23,7 @@ #ifndef __RP5C15__ #define __RP5C15__ -#include "emu.h" +#include "dirtc.h" @@ -59,11 +59,10 @@ public: protected: // device-level overrides virtual void device_start() override; - virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // device_rtc_interface overrides - virtual bool rtc_feature_leap_year() override { return true; } + virtual bool rtc_feature_leap_year() const override { return true; } virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; private: diff --git a/src/devices/machine/rtc4543.cpp b/src/devices/machine/rtc4543.cpp index b068e44f882..619ae57ad4a 100644 --- a/src/devices/machine/rtc4543.cpp +++ b/src/devices/machine/rtc4543.cpp @@ -89,8 +89,6 @@ void rtc4543_device::device_start() void rtc4543_device::device_reset() { - set_current_time(machine()); - m_ce = 0; m_wr = 0; m_clk = 0; diff --git a/src/devices/machine/rtc4543.h b/src/devices/machine/rtc4543.h index 966e15ab0b9..bd94c2eb918 100644 --- a/src/devices/machine/rtc4543.h +++ b/src/devices/machine/rtc4543.h @@ -12,7 +12,7 @@ #ifndef __RTC4543_H__ #define __RTC4543_H__ -#include "emu.h" +#include "dirtc.h" @@ -63,7 +63,7 @@ protected: // device_rtc_interface overrides virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; - virtual bool rtc_feature_leap_year() override { return true; } + virtual bool rtc_feature_leap_year() const override { return true; } // helpers virtual void ce_rising(); diff --git a/src/devices/machine/upd1990a.cpp b/src/devices/machine/upd1990a.cpp index 59f85d9c4ca..cfce446ba37 100644 --- a/src/devices/machine/upd1990a.cpp +++ b/src/devices/machine/upd1990a.cpp @@ -83,9 +83,6 @@ void upd1990a_device::device_start() m_write_data.resolve_safe(); m_write_tp.resolve_safe(); - // initialize - set_current_time(machine()); - for (auto & elem : m_shift_reg) elem = 0; diff --git a/src/devices/machine/upd1990a.h b/src/devices/machine/upd1990a.h index 3c80670ec8e..9071d843cc2 100644 --- a/src/devices/machine/upd1990a.h +++ b/src/devices/machine/upd1990a.h @@ -21,7 +21,7 @@ #ifndef __UPD1990A__ #define __UPD1990A__ -#include "emu.h" +#include "dirtc.h" diff --git a/src/devices/machine/upd4992.cpp b/src/devices/machine/upd4992.cpp index 5e53da565a6..29535e60c94 100644 --- a/src/devices/machine/upd4992.cpp +++ b/src/devices/machine/upd4992.cpp @@ -61,16 +61,6 @@ void upd4992_device::device_start() } -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void upd4992_device::device_reset() -{ - set_current_time(machine()); -} - - void upd4992_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) diff --git a/src/devices/machine/upd4992.h b/src/devices/machine/upd4992.h index 23d7dc50cea..dc907fed516 100644 --- a/src/devices/machine/upd4992.h +++ b/src/devices/machine/upd4992.h @@ -11,6 +11,7 @@ #ifndef __UPD4992DEV_H__ #define __UPD4992DEV_H__ +#include "dirtc.h" //************************************************************************** @@ -41,7 +42,6 @@ protected: // device-level overrides virtual void device_validity_check(validity_checker &valid) const override; virtual void device_start() override; - virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; diff --git a/src/emu/dirtc.cpp b/src/emu/dirtc.cpp index 912c49d538d..3dd961c2aa6 100644 --- a/src/emu/dirtc.cpp +++ b/src/emu/dirtc.cpp @@ -9,7 +9,7 @@ ***************************************************************************/ #include "emu.h" - +#include "dirtc.h" //************************************************************************** @@ -76,11 +76,8 @@ void device_rtc_interface::set_time(bool update, int year, int month, int day, i // to the current system time //------------------------------------------------- -void device_rtc_interface::set_current_time(running_machine &machine) +void device_rtc_interface::set_current_time(const system_time &systime) { - system_time systime; - machine.base_datetime(systime); - set_time(true, systime.local_time.year, systime.local_time.month + 1, systime.local_time.mday, systime.local_time.weekday + 1, systime.local_time.hour, systime.local_time.minute, systime.local_time.second); } diff --git a/src/emu/dirtc.h b/src/emu/dirtc.h index 758157233ea..cbae4dfecd8 100644 --- a/src/emu/dirtc.h +++ b/src/emu/dirtc.h @@ -10,10 +10,6 @@ #pragma once -#ifndef __EMU_H__ -#error Dont include this file directly; include emu.h instead. -#endif - #ifndef __DIRTC_H__ #define __DIRTC_H__ @@ -52,7 +48,9 @@ public: virtual ~device_rtc_interface(); 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(running_machine &machine); + void set_current_time(const system_time &systime); + + bool has_battery() const { return rtc_battery_backed(); } protected: static UINT8 convert_to_bcd(int val); @@ -68,12 +66,16 @@ protected: void adjust_seconds(); // derived class overrides - virtual bool rtc_feature_y2k() { return false; } - virtual bool rtc_feature_leap_year() { return false; } - virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) { } + virtual bool rtc_feature_y2k() const { return false; } + virtual bool rtc_feature_leap_year() const { return false; } + virtual bool rtc_battery_backed() const { return true; } + virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) = 0; int m_register[7]; }; +// iterator +typedef device_interface_iterator<device_rtc_interface> rtc_interface_iterator; + #endif /* __DIRTC_H__ */ diff --git a/src/emu/emu.h b/src/emu/emu.h index f170fc6295a..de2105fc68c 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -78,7 +78,6 @@ typedef device_t * (*machine_config_constructor)(machine_config &config, device_ #include "disound.h" #include "divideo.h" #include "dinvram.h" -#include "dirtc.h" #include "didisasm.h" #include "schedule.h" #include "timer.h" diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 5e8c5f478d1..adce482a19c 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -79,6 +79,7 @@ #include "unzip.h" #include "debug/debugvw.h" #include "debug/debugcpu.h" +#include "dirtc.h" #include "image.h" #include "network.h" #include "ui/uimain.h" @@ -267,7 +268,6 @@ void running_machine::start() else if (options().autosave() && (m_system.flags & MACHINE_SUPPORTS_SAVE) != 0) schedule_load("auto"); - manager().update_machine(); } @@ -300,7 +300,7 @@ int running_machine::run(bool quiet) // then finish setting up our local machine start(); - // load the configuration settings and NVRAM + // load the configuration settings m_configuration->load_settings(); // disallow save state registrations starting here. @@ -308,7 +308,12 @@ int running_machine::run(bool quiet) // devices with timers. m_save.allow_registration(false); + // load the NVRAM nvram_load(); + + // set the time on RTCs (this may overwrite parts of NVRAM) + set_rtc_datetime(system_time(m_base_time)); + sound().ui_mute(false); if (!quiet) sound().start_recording(); @@ -796,6 +801,19 @@ void running_machine::current_datetime(system_time &systime) //------------------------------------------------- +// set_rtc_datetime - set the current time on +// battery-backed RTCs +//------------------------------------------------- + +void running_machine::set_rtc_datetime(const system_time &systime) +{ + for (device_rtc_interface &rtc : rtc_interface_iterator(root_device())) + if (rtc.has_battery()) + rtc.set_current_time(systime); +} + + +//------------------------------------------------- // rand - standardized random numbers //------------------------------------------------- @@ -1171,6 +1189,11 @@ system_time::system_time() set(0); } +system_time::system_time(time_t t) +{ + set(t); +} + //------------------------------------------------- // set - fills out a system_time structure diff --git a/src/emu/machine.h b/src/emu/machine.h index 788a6cff7fd..38f64247991 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -107,6 +107,7 @@ class system_time { public: system_time(); + explicit system_time(time_t t); void set(time_t t); struct full_time @@ -226,6 +227,7 @@ public: // date & time void base_datetime(system_time &systime); void current_datetime(system_time &systime); + void set_rtc_datetime(const system_time &systime); // misc void popmessage() const { popmessage(static_cast<char const *>(nullptr)); } diff --git a/src/mame/drivers/next.cpp b/src/mame/drivers/next.cpp index 26c29072d18..96bc17eca26 100644 --- a/src/mame/drivers/next.cpp +++ b/src/mame/drivers/next.cpp @@ -874,10 +874,6 @@ void next_state::machine_start() } timer_tm = timer_alloc(0); - - system_time systime; - machine().base_datetime(systime); - rtc->set_counter(systime.time); } void next_state::machine_reset() diff --git a/src/mame/machine/macrtc.cpp b/src/mame/machine/macrtc.cpp index dd047014c0f..1a20c08811d 100644 --- a/src/mame/machine/macrtc.cpp +++ b/src/mame/machine/macrtc.cpp @@ -62,8 +62,6 @@ void rtc3430042_device::device_start() void rtc3430042_device::device_reset() { - set_current_time(machine()); - m_rtc_rTCEnb = 0; m_rtc_rTCClk = 0; m_rtc_bit_count = 0; diff --git a/src/mame/machine/macrtc.h b/src/mame/machine/macrtc.h index ea8726a8fd2..dc969e93f82 100644 --- a/src/mame/machine/macrtc.h +++ b/src/mame/machine/macrtc.h @@ -12,7 +12,7 @@ #ifndef __RTC3430042_H__ #define __RTC3430042_H__ -#include "emu.h" +#include "dirtc.h" //************************************************************************** @@ -51,7 +51,7 @@ protected: // device_rtc_interface overrides virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; - virtual bool rtc_feature_leap_year() override { return true; } + virtual bool rtc_feature_leap_year() const override { return true; } // device_nvram_interface overrides virtual void nvram_default() override; |