diff options
| author | 2011-04-22 21:41:30 +0000 | |
|---|---|---|
| committer | 2011-04-22 21:41:30 +0000 | |
| commit | 65c39d05961cbc522d94836609035ae6ad221300 (patch) | |
| tree | d5b09770538fb05c37a362b49ba52a932ecbaccb /src | |
| parent | 2b40cd4e3484af0db87e5ca8d4f0eea885e30ced (diff) | |
Created device_rtc_interface which can be used to initialize RTC's to a certain date/time at driver startup, useful for regression testing. Implemented the interface in most of the modern RTC devices. Note: this is not yet plumbed down to the command line. [Curt Coder]
Diffstat (limited to 'src')
| -rw-r--r-- | src/emu/emu.h | 1 | ||||
| -rw-r--r-- | src/emu/emu.mak | 1 | ||||
| -rw-r--r-- | src/emu/machine/e0516.c | 128 | ||||
| -rw-r--r-- | src/emu/machine/e0516.h | 19 | ||||
| -rw-r--r-- | src/emu/machine/mc146818.c | 18 | ||||
| -rw-r--r-- | src/emu/machine/mc146818.h | 8 | ||||
| -rw-r--r-- | src/emu/machine/msm5832.c | 49 | ||||
| -rw-r--r-- | src/emu/machine/msm5832.h | 10 | ||||
| -rw-r--r-- | src/emu/machine/msm58321.c | 51 | ||||
| -rw-r--r-- | src/emu/machine/msm58321.h | 10 | ||||
| -rw-r--r-- | src/emu/machine/rp5c01.c | 19 | ||||
| -rw-r--r-- | src/emu/machine/rp5c01.h | 10 | ||||
| -rw-r--r-- | src/emu/machine/rp5c15.c | 21 | ||||
| -rw-r--r-- | src/emu/machine/rp5c15.h | 10 | ||||
| -rw-r--r-- | src/emu/machine/upd1990a.c | 48 | ||||
| -rw-r--r-- | src/emu/machine/upd1990a.h | 10 |
16 files changed, 348 insertions, 65 deletions
diff --git a/src/emu/emu.h b/src/emu/emu.h index ac384409d58..50d7756ef45 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -90,6 +90,7 @@ typedef device_config * (*machine_config_constructor)(machine_config &config, de #include "diimage.h" #include "disound.h" #include "dinvram.h" +#include "dirtc.h" #include "didisasm.h" #include "schedule.h" #include "timer.h" diff --git a/src/emu/emu.mak b/src/emu/emu.mak index 11e5f306f82..1c6c59064da 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -63,6 +63,7 @@ EMUOBJS = \ $(EMUOBJ)/diimage.o \ $(EMUOBJ)/dimemory.o \ $(EMUOBJ)/dinvram.o \ + $(EMUOBJ)/dirtc.o \ $(EMUOBJ)/disound.o \ $(EMUOBJ)/distate.o \ $(EMUOBJ)/drawgfx.o \ diff --git a/src/emu/machine/e0516.c b/src/emu/machine/e0516.c index 463814ffb91..a686d9cd959 100644 --- a/src/emu/machine/e0516.c +++ b/src/emu/machine/e0516.c @@ -9,7 +9,6 @@ #include "emu.h" #include "e0516.h" -#include "machine/devhelpr.h" @@ -17,7 +16,7 @@ // MACROS / CONSTANTS //************************************************************************** -#define LOG 1 +#define LOG 0 // states @@ -55,14 +54,87 @@ const device_type E0516 = e0516_device_config::static_alloc_device_config; // DEVICE CONFIGURATION //************************************************************************** -GENERIC_DEVICE_CONFIG_SETUP(e0516, "E05-16") +//------------------------------------------------- +// e0516_device_config - constructor +//------------------------------------------------- +e0516_device_config::e0516_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, "E05-16", tag, owner, clock), + device_config_rtc_interface(mconfig, *this) +{ +} + + +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- + +device_config *e0516_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(e0516_device_config(mconfig, tag, owner, clock)); +} + + +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- + +device_t *e0516_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(machine, e0516_device(machine, *this)); +} //************************************************************************** // INLINE HELPERS //************************************************************************** +//------------------------------------------------- +// advance_seconds - +//------------------------------------------------- + +inline void e0516_device::advance_seconds() +{ + m_register[SECOND]++; + + if (m_register[SECOND] == 60) + { + m_register[SECOND] = 0; + m_register[MINUTE]++; + } + + if (m_register[MINUTE] == 60) + { + m_register[MINUTE] = 0; + m_register[HOUR]++; + } + + if (m_register[HOUR] == 24) + { + m_register[HOUR] = 0; + m_register[DAY]++; + m_register[DAY_OF_WEEK]++; + } + + if (m_register[DAY_OF_WEEK] == 8) + { + m_register[DAY_OF_WEEK] = 1; + } + + if (m_register[DAY] == 32) + { + m_register[DAY] = 1; + m_register[MONTH]++; + } + + if (m_register[MONTH] == 13) + { + m_register[MONTH] = 1; + m_register[YEAR]++; + } +} + //************************************************************************** @@ -75,6 +147,7 @@ GENERIC_DEVICE_CONFIG_SETUP(e0516, "E05-16") e0516_device::e0516_device(running_machine &_machine, const e0516_device_config &config) : device_t(_machine, config), + device_rtc_interface(_machine, config, *this), m_config(config) { } @@ -118,43 +191,24 @@ void e0516_device::device_reset() void e0516_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - m_register[SECOND]++; - - if (m_register[SECOND] == 60) - { - m_register[SECOND] = 0; - m_register[MINUTE]++; - } - - if (m_register[MINUTE] == 60) - { - m_register[MINUTE] = 0; - m_register[HOUR]++; - } - - if (m_register[HOUR] == 24) - { - m_register[HOUR] = 0; - m_register[DAY]++; - m_register[DAY_OF_WEEK]++; - } + advance_seconds(); +} - if (m_register[DAY_OF_WEEK] == 8) - { - m_register[DAY_OF_WEEK] = 1; - } - if (m_register[DAY] == 32) - { - m_register[DAY] = 1; - m_register[MONTH]++; - } +//------------------------------------------------- +// rtc_set_time - called to initialize the RTC to +// a known state +//------------------------------------------------- - if (m_register[MONTH] == 13) - { - m_register[MONTH] = 1; - m_register[YEAR]++; - } +void e0516_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second) +{ + m_register[YEAR] = year; + m_register[MONTH] = month; + m_register[DAY] = day; + m_register[DAY_OF_WEEK] = day_of_week + 1; + m_register[HOUR] = hour; + m_register[MINUTE] = minute; + m_register[SECOND] = second; } diff --git a/src/emu/machine/e0516.h b/src/emu/machine/e0516.h index 223b317ebb7..9ebce2e92ce 100644 --- a/src/emu/machine/e0516.h +++ b/src/emu/machine/e0516.h @@ -28,13 +28,6 @@ //************************************************************************** -// MACROS / CONSTANTS -//************************************************************************** - - - - -//************************************************************************** // INTERFACE CONFIGURATION MACROS //************************************************************************** @@ -50,7 +43,8 @@ // ======================> e0516_device_config -class e0516_device_config : public device_config +class e0516_device_config : public device_config, + public device_config_rtc_interface { friend class e0516_device; @@ -68,7 +62,8 @@ protected: // ======================> e0516_device -class e0516_device : public device_t +class e0516_device : public device_t, + public device_rtc_interface { friend class e0516_device_config; @@ -87,7 +82,13 @@ protected: virtual void device_reset(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + // device_rtc_interface overrides + virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second); + virtual bool rtc_is_year_2000_compliant() { return false; } + private: + inline void advance_seconds(); + int m_cs; // chip select int m_clk; // clock int m_data_latch; // data latch diff --git a/src/emu/machine/mc146818.c b/src/emu/machine/mc146818.c index a80fe6784ac..3120cca44f0 100644 --- a/src/emu/machine/mc146818.c +++ b/src/emu/machine/mc146818.c @@ -118,6 +118,7 @@ const device_type MC146818 = mc146818_device_config::static_alloc_device_config; mc146818_device_config::mc146818_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) : device_config(mconfig, static_alloc_device_config, "NVRAM", tag, owner, clock), + device_config_rtc_interface(mconfig, *this), device_config_nvram_interface(mconfig, *this), m_type(MC146818_STANDARD) { @@ -167,6 +168,7 @@ void mc146818_device_config::static_set_type(device_config *device, mc146818_typ mc146818_device::mc146818_device(running_machine &_machine, const mc146818_device_config &config) : device_t(_machine, config), + device_rtc_interface(_machine, config, *this), device_nvram_interface(_machine, config, *this), m_config(config), m_index(0), @@ -331,6 +333,22 @@ void mc146818_device::device_timer(emu_timer &timer, device_timer_id id, int par } +//------------------------------------------------- +// rtc_set_time - called to initialize the RTC to +// a known state +//------------------------------------------------- + +void mc146818_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second) +{ + YEAR = year; + MONTH = month; + DAY = day; + WEEK_DAY = day_of_week; + m_data[4] = hour; + m_data[2] = minute; + m_data[0] = second; +} + //------------------------------------------------- // nvram_default - called to initialize NVRAM to diff --git a/src/emu/machine/mc146818.h b/src/emu/machine/mc146818.h index 50ad18f69db..da35b90ecc4 100644 --- a/src/emu/machine/mc146818.h +++ b/src/emu/machine/mc146818.h @@ -35,6 +35,7 @@ class mc146818_device; // ======================> mc146818_device_config class mc146818_device_config : public device_config, + public device_config_rtc_interface, public device_config_nvram_interface { friend class mc146818_device; @@ -68,6 +69,7 @@ protected: // ======================> mc146818_device class mc146818_device : public device_t, + public device_rtc_interface, public device_nvram_interface { friend class mc146818_device_config; @@ -85,7 +87,11 @@ protected: virtual void device_start(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - // device_mc146818_interface overrides + // device_rtc_interface overrides + virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second); + virtual bool rtc_is_year_2000_compliant() { return false; } + + // device_nvram_interface overrides virtual void nvram_default(); virtual void nvram_read(emu_file &file); virtual void nvram_write(emu_file &file); diff --git a/src/emu/machine/msm5832.c b/src/emu/machine/msm5832.c index ee11ae78044..9a0af084775 100644 --- a/src/emu/machine/msm5832.c +++ b/src/emu/machine/msm5832.c @@ -20,7 +20,6 @@ */ #include "msm5832.h" -#include "machine/devhelpr.h" @@ -69,8 +68,36 @@ const device_type MSM5832 = msm5832_device_config::static_alloc_device_config; // DEVICE CONFIGURATION //************************************************************************** -GENERIC_DEVICE_CONFIG_SETUP(msm5832, "MSM5832") +//------------------------------------------------- +// msm5832_device_config - constructor +//------------------------------------------------- + +msm5832_device_config::msm5832_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, "MSM5832", tag, owner, clock), + device_config_rtc_interface(mconfig, *this) +{ +} + + +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- + +device_config *msm5832_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(msm5832_device_config(mconfig, tag, owner, clock)); +} + + +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- +device_t *msm5832_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(machine, msm5832_device(machine, *this)); +} //************************************************************************** @@ -189,6 +216,7 @@ inline void msm5832_device::advance_minutes() msm5832_device::msm5832_device(running_machine &_machine, const msm5832_device_config &config) : device_t(_machine, config), + device_rtc_interface(_machine, config, *this), m_hold(0), m_address(0), m_read(0), @@ -240,6 +268,23 @@ void msm5832_device::device_timer(emu_timer &timer, device_timer_id id, int para //------------------------------------------------- +// rtc_set_time - called to initialize the RTC to +// a known state +//------------------------------------------------- + +void msm5832_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second) +{ + write_counter(REGISTER_Y1, year); + write_counter(REGISTER_MO1, month); + write_counter(REGISTER_D1, day); + m_reg[REGISTER_W] = day_of_week; + write_counter(REGISTER_H1, hour); + write_counter(REGISTER_MI1, minute); + write_counter(REGISTER_S1, second); +} + + +//------------------------------------------------- // data_r - //------------------------------------------------- diff --git a/src/emu/machine/msm5832.h b/src/emu/machine/msm5832.h index 4b6b39bf301..9a220af11cc 100644 --- a/src/emu/machine/msm5832.h +++ b/src/emu/machine/msm5832.h @@ -43,7 +43,8 @@ // ======================> msm5832_device_config -class msm5832_device_config : public device_config +class msm5832_device_config : public device_config, + public device_config_rtc_interface { friend class msm5832_device; @@ -60,7 +61,8 @@ public: // ======================> msm5832_device -class msm5832_device : public device_t +class msm5832_device : public device_t, + public device_rtc_interface { friend class msm5832_device_config; @@ -86,6 +88,10 @@ protected: virtual void device_start(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + // device_rtc_interface overrides + virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second); + virtual bool rtc_is_year_2000_compliant() { return false; } + private: static const device_timer_id TIMER_CLOCK = 0; diff --git a/src/emu/machine/msm58321.c b/src/emu/machine/msm58321.c index ddbb02fd286..28f324c1002 100644 --- a/src/emu/machine/msm58321.c +++ b/src/emu/machine/msm58321.c @@ -21,7 +21,6 @@ */ #include "msm58321.h" -#include "machine/devhelpr.h" @@ -29,7 +28,7 @@ // MACROS / CONSTANTS //************************************************************************** -#define LOG 1 +#define LOG 0 // registers @@ -72,8 +71,36 @@ const device_type MSM58321 = msm58321_device_config::static_alloc_device_config; // DEVICE CONFIGURATION //************************************************************************** -GENERIC_DEVICE_CONFIG_SETUP(msm58321, "MSM58321") +//------------------------------------------------- +// msm58321_device_config - constructor +//------------------------------------------------- + +msm58321_device_config::msm58321_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, "MSM58321", tag, owner, clock), + device_config_rtc_interface(mconfig, *this) +{ +} + + +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- + +device_config *msm58321_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(msm58321_device_config(mconfig, tag, owner, clock)); +} + + +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- +device_t *msm58321_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(machine, msm58321_device(machine, *this)); +} //------------------------------------------------- // device_config_complete - perform any @@ -213,6 +240,7 @@ inline void msm58321_device::advance_minutes() msm58321_device::msm58321_device(running_machine &_machine, const msm58321_device_config &config) : device_t(_machine, config), + device_rtc_interface(_machine, config, *this), m_config(config) { for (int i = 0; i < 13; i++) @@ -270,6 +298,23 @@ void msm58321_device::device_timer(emu_timer &timer, device_timer_id id, int par //------------------------------------------------- +// rtc_set_time - called to initialize the RTC to +// a known state +//------------------------------------------------- + +void msm58321_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second) +{ + write_counter(REGISTER_Y1, year); + write_counter(REGISTER_MO1, month); + write_counter(REGISTER_D1, day); + m_reg[REGISTER_W] = day_of_week; + write_counter(REGISTER_H1, hour); + write_counter(REGISTER_MI1, minute); + write_counter(REGISTER_S1, second); +} + + +//------------------------------------------------- // read - //------------------------------------------------- diff --git a/src/emu/machine/msm58321.h b/src/emu/machine/msm58321.h index b03541e2683..dce7eedc7e5 100644 --- a/src/emu/machine/msm58321.h +++ b/src/emu/machine/msm58321.h @@ -56,7 +56,8 @@ struct msm58321_interface // ======================> msm58321_device_config class msm58321_device_config : public device_config, - public msm58321_interface + public msm58321_interface, + public device_config_rtc_interface { friend class msm58321_device; @@ -77,7 +78,8 @@ protected: // ======================> msm58321_device -class msm58321_device : public device_t +class msm58321_device : public device_t, + public device_rtc_interface { friend class msm58321_device_config; @@ -102,6 +104,10 @@ protected: virtual void device_start(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + // device_rtc_interface overrides + virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second); + virtual bool rtc_is_year_2000_compliant() { return false; } + private: static const device_timer_id TIMER_CLOCK = 0; static const device_timer_id TIMER_BUSY = 1; diff --git a/src/emu/machine/rp5c01.c b/src/emu/machine/rp5c01.c index b4eb4531f34..ff1f047dc5e 100644 --- a/src/emu/machine/rp5c01.c +++ b/src/emu/machine/rp5c01.c @@ -115,6 +115,7 @@ const device_type RP5C01 = rp5c01_device_config::static_alloc_device_config; rp5c01_device_config::rp5c01_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) : device_config(mconfig, static_alloc_device_config, "RP5C01", tag, owner, clock), + device_config_rtc_interface(mconfig, *this), device_config_nvram_interface(mconfig, *this) { } @@ -343,6 +344,7 @@ inline void rp5c01_device::check_alarm() rp5c01_device::rp5c01_device(running_machine &_machine, const rp5c01_device_config &config) : device_t(_machine, config), + device_rtc_interface(_machine, config, *this), device_nvram_interface(_machine, config, *this), m_alarm(1), m_alarm_on(1), @@ -408,6 +410,23 @@ void rp5c01_device::device_timer(emu_timer &timer, device_timer_id id, int param //------------------------------------------------- +// rtc_set_time - called to initialize the RTC to +// a known state +//------------------------------------------------- + +void rp5c01_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second) +{ + write_counter(REGISTER_1_YEAR, year); + write_counter(REGISTER_1_MONTH, month); + write_counter(REGISTER_1_DAY, day); + m_reg[MODE00][REGISTER_DAY_OF_THE_WEEK] = day_of_week; + write_counter(REGISTER_1_HOUR, hour); + write_counter(REGISTER_1_MINUTE, minute); + write_counter(REGISTER_1_SECOND, second); +} + + +//------------------------------------------------- // nvram_default - called to initialize NVRAM to // its default state //------------------------------------------------- diff --git a/src/emu/machine/rp5c01.h b/src/emu/machine/rp5c01.h index 9e32d136d86..c5ef20c8050 100644 --- a/src/emu/machine/rp5c01.h +++ b/src/emu/machine/rp5c01.h @@ -58,8 +58,9 @@ struct rp5c01_interface // ======================> rp5c01_device_config class rp5c01_device_config : public device_config, - public device_config_nvram_interface, - public rp5c01_interface + public rp5c01_interface, + public device_config_rtc_interface, + public device_config_nvram_interface { friend class rp5c01_device; @@ -81,6 +82,7 @@ protected: // ======================> rp5c01_device class rp5c01_device : public device_t, + public device_rtc_interface, public device_nvram_interface { friend class rp5c01_device_config; @@ -98,6 +100,10 @@ protected: virtual void device_start(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + // device_rtc_interface overrides + virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second); + virtual bool rtc_is_year_2000_compliant() { return false; } + // device_nvram_interface overrides virtual void nvram_default(); virtual void nvram_read(emu_file &file); diff --git a/src/emu/machine/rp5c15.c b/src/emu/machine/rp5c15.c index 034dc2324b6..3da17c9c6be 100644 --- a/src/emu/machine/rp5c15.c +++ b/src/emu/machine/rp5c15.c @@ -123,7 +123,8 @@ const device_type RP5C15 = rp5c15_device_config::static_alloc_device_config; //------------------------------------------------- rp5c15_device_config::rp5c15_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) - : device_config(mconfig, static_alloc_device_config, "RP5C15", tag, owner, clock) + : device_config(mconfig, static_alloc_device_config, "RP5C15", tag, owner, clock), + device_config_rtc_interface(mconfig, *this) { } @@ -352,6 +353,7 @@ inline void rp5c15_device::check_alarm() rp5c15_device::rp5c15_device(running_machine &_machine, const rp5c15_device_config &config) : device_t(_machine, config), + device_rtc_interface(_machine, config, *this), m_alarm(1), m_alarm_on(1), m_1hz(1), @@ -426,6 +428,23 @@ void rp5c15_device::device_timer(emu_timer &timer, device_timer_id id, int param //------------------------------------------------- +// rtc_set_time - called to initialize the RTC to +// a known state +//------------------------------------------------- + +void rp5c15_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second) +{ + write_counter(REGISTER_1_YEAR, year); + write_counter(REGISTER_1_MONTH, month); + write_counter(REGISTER_1_DAY, day); + m_reg[MODE00][REGISTER_DAY_OF_THE_WEEK] = day_of_week; + write_counter(REGISTER_1_HOUR, hour); + write_counter(REGISTER_1_MINUTE, minute); + write_counter(REGISTER_1_SECOND, second); +} + + +//------------------------------------------------- // read - //------------------------------------------------- diff --git a/src/emu/machine/rp5c15.h b/src/emu/machine/rp5c15.h index df32413de83..0deebc55401 100644 --- a/src/emu/machine/rp5c15.h +++ b/src/emu/machine/rp5c15.h @@ -59,7 +59,8 @@ struct rp5c15_interface // ======================> rp5c15_device_config class rp5c15_device_config : public device_config, - public rp5c15_interface + public rp5c15_interface, + public device_config_rtc_interface { friend class rp5c15_device; @@ -80,7 +81,8 @@ protected: // ======================> rp5c15_device -class rp5c15_device : public device_t +class rp5c15_device : public device_t, + public device_rtc_interface { friend class rp5c15_device_config; @@ -97,6 +99,10 @@ protected: virtual void device_start(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + // device_rtc_interface overrides + virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second); + virtual bool rtc_is_year_2000_compliant() { return false; } + private: inline void set_alarm_line(); inline int read_counter(int counter); diff --git a/src/emu/machine/upd1990a.c b/src/emu/machine/upd1990a.c index b89d7820569..bc3d4f11d9d 100644 --- a/src/emu/machine/upd1990a.c +++ b/src/emu/machine/upd1990a.c @@ -17,7 +17,6 @@ #include "emu.h" #include "upd1990a.h" -#include "machine/devhelpr.h" @@ -56,7 +55,36 @@ const device_type UPD1990A = upd1990a_device_config::static_alloc_device_config; // DEVICE CONFIGURATION //************************************************************************** -GENERIC_DEVICE_CONFIG_SETUP(upd1990a, "uPD1990A") +//------------------------------------------------- +// upd1990a_device_config - constructor +//------------------------------------------------- + +upd1990a_device_config::upd1990a_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, "uPD1990A", tag, owner, clock), + device_config_rtc_interface(mconfig, *this) +{ +} + + +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- + +device_config *upd1990a_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(upd1990a_device_config(mconfig, tag, owner, clock)); +} + + +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- + +device_t *upd1990a_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(machine, upd1990a_device(machine, *this)); +} //------------------------------------------------- @@ -176,6 +204,7 @@ inline void upd1990a_device::advance_seconds() upd1990a_device::upd1990a_device(running_machine &_machine, const upd1990a_device_config &config) : device_t(_machine, config), + device_rtc_interface(_machine, config, *this), m_config(config) { } @@ -263,6 +292,21 @@ void upd1990a_device::device_timer(emu_timer &timer, device_timer_id id, int par //------------------------------------------------- +// rtc_set_time - called to initialize the RTC to +// a known state +//------------------------------------------------- + +void upd1990a_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second) +{ + m_time_counter[0] = convert_to_bcd(second); + m_time_counter[1] = convert_to_bcd(minute); + m_time_counter[2] = convert_to_bcd(hour); + m_time_counter[3] = convert_to_bcd(day); + m_time_counter[4] = (month << 4) | day_of_week; +} + + +//------------------------------------------------- // oe_w - //------------------------------------------------- diff --git a/src/emu/machine/upd1990a.h b/src/emu/machine/upd1990a.h index 14fbaa8a55f..be89551e670 100644 --- a/src/emu/machine/upd1990a.h +++ b/src/emu/machine/upd1990a.h @@ -63,7 +63,8 @@ struct upd1990a_interface // ======================> upd1990a_device_config class upd1990a_device_config : public device_config, - public upd1990a_interface + public upd1990a_interface, + public device_config_rtc_interface { friend class upd1990a_device; @@ -84,7 +85,8 @@ protected: // ======================> upd1990a_device -class upd1990a_device : public device_t +class upd1990a_device : public device_t, + public device_rtc_interface { friend class upd1990a_device_config; @@ -109,6 +111,10 @@ protected: virtual void device_reset(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + // device_rtc_interface overrides + virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second); + virtual bool rtc_is_year_2000_compliant() { return false; } + private: inline UINT8 convert_to_bcd(int val); inline int bcd_to_integer(UINT8 val); |
