Previous 15994 Revisions Next

r11278 Friday 22nd April, 2011 at 21:42:52 UTC by Curt Coder
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]
[src/emu]dirtc.c* dirtc.h* emu.h emu.mak
[src/emu/machine]e0516.c e0516.h mc146818.c mc146818.h msm5832.c msm5832.h msm58321.c msm58321.h rp5c01.c rp5c01.h rp5c15.c rp5c15.h upd1990a.c upd1990a.h

src/emu/emu.h
r11277r11278
9090#include "diimage.h"
9191#include "disound.h"
9292#include "dinvram.h"
93#include "dirtc.h"
9394#include "didisasm.h"
9495#include "schedule.h"
9596#include "timer.h"
src/emu/dirtc.c
r0r11278
1/***************************************************************************
2
3    dirtc.c
4
5    Device Real Time Clock interfaces.
6
7***************************************************************************/
8
9#include "emu.h"
10
11
12
13//**************************************************************************
14//  DEVICE CONFIG RTC INTERFACE
15//**************************************************************************
16
17//-------------------------------------------------
18//  device_config_rtc_interface - constructor
19//-------------------------------------------------
20
21device_config_rtc_interface::device_config_rtc_interface(const machine_config &mconfig, device_config &devconfig)
22   : device_config_interface(mconfig, devconfig)
23{
24}
25
26
27//-------------------------------------------------
28//  ~device_config_rtc_interface - destructor
29//-------------------------------------------------
30
31device_config_rtc_interface::~device_config_rtc_interface()
32{
33}
34
35
36
37//**************************************************************************
38//  DEVICE RTC INTERFACE
39//**************************************************************************
40
41//-------------------------------------------------
42//  device_rtc_interface - constructor
43//-------------------------------------------------
44
45device_rtc_interface::device_rtc_interface(running_machine &machine, const device_config &config, device_t &device)
46   : device_interface(machine, config, device),
47     m_rtc_config(dynamic_cast<const device_config_rtc_interface &>(config))
48{
49}
50
51
52//-------------------------------------------------
53//  ~device_rtc_interface - destructor
54//-------------------------------------------------
55
56device_rtc_interface::~device_rtc_interface()
57{
58}
src/emu/dirtc.h
r0r11278
1/***************************************************************************
2
3    dirtc.h
4
5    Device Real Time Clock interfaces.
6
7***************************************************************************/
8
9#pragma once
10
11#ifndef __EMU_H__
12#error Dont include this file directly; include emu.h instead.
13#endif
14
15#ifndef __DIRTC_H__
16#define __DIRTC_H__
17
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23
24// ======================> device_config_rtc_interface
25
26// class representing interface-specific configuration rtc
27class device_config_rtc_interface : public device_config_interface
28{
29public:
30   // construction/destruction
31   device_config_rtc_interface(const machine_config &mconfig, device_config &device);
32   virtual ~device_config_rtc_interface();
33};
34
35
36
37// ======================> device_rtc_interface
38
39// class representing interface-specific live rtc
40class device_rtc_interface : public device_interface
41{
42public:
43   // construction/destruction
44   device_rtc_interface(running_machine &machine, const device_config &config, device_t &device);
45   virtual ~device_rtc_interface();
46
47   // configuration access
48   const device_config_rtc_interface &rtc_config() const { return m_rtc_config; }
49
50protected:
51   // derived class overrides
52   virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second) = 0;
53   virtual bool rtc_is_year_2000_compliant() = 0;
54
55   // configuration
56   const device_config_rtc_interface &m_rtc_config;   // reference to our device_config_execute_interface
57};
58
59
60#endif   /* __DIRTC_H__ */
src/emu/emu.mak
r11277r11278
6363   $(EMUOBJ)/diimage.o \
6464   $(EMUOBJ)/dimemory.o \
6565   $(EMUOBJ)/dinvram.o \
66   $(EMUOBJ)/dirtc.o \
6667   $(EMUOBJ)/disound.o \
6768   $(EMUOBJ)/distate.o \
6869   $(EMUOBJ)/drawgfx.o \
src/emu/machine/mc146818.h
r11277r11278
3535// ======================> mc146818_device_config
3636
3737class mc146818_device_config :   public device_config,
38                         public device_config_rtc_interface,
3839                        public device_config_nvram_interface
3940{
4041   friend class mc146818_device;
r11277r11278
6869// ======================> mc146818_device
6970
7071class mc146818_device :   public device_t,
72                   public device_rtc_interface,
7173                  public device_nvram_interface
7274{
7375   friend class mc146818_device_config;
r11277r11278
8587   virtual void device_start();
8688   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
8789
88   // device_mc146818_interface overrides
90   // device_rtc_interface overrides
91   virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second);
92   virtual bool rtc_is_year_2000_compliant() { return false; }
93
94   // device_nvram_interface overrides
8995   virtual void nvram_default();
9096   virtual void nvram_read(emu_file &file);
9197   virtual void nvram_write(emu_file &file);
src/emu/machine/upd1990a.c
r11277r11278
1717
1818#include "emu.h"
1919#include "upd1990a.h"
20#include "machine/devhelpr.h"
2120
2221
2322
r11277r11278
5655//  DEVICE CONFIGURATION
5756//**************************************************************************
5857
59GENERIC_DEVICE_CONFIG_SETUP(upd1990a, "uPD1990A")
58//-------------------------------------------------
59//  upd1990a_device_config - constructor
60//-------------------------------------------------
6061
62upd1990a_device_config::upd1990a_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
63   : device_config(mconfig, static_alloc_device_config, "uPD1990A", tag, owner, clock),
64     device_config_rtc_interface(mconfig, *this)
65{
66}
6167
68
6269//-------------------------------------------------
70//  static_alloc_device_config - allocate a new
71//  configuration object
72//-------------------------------------------------
73
74device_config *upd1990a_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
75{
76   return global_alloc(upd1990a_device_config(mconfig, tag, owner, clock));
77}
78
79
80//-------------------------------------------------
81//  alloc_device - allocate a new device object
82//-------------------------------------------------
83
84device_t *upd1990a_device_config::alloc_device(running_machine &machine) const
85{
86   return auto_alloc(machine, upd1990a_device(machine, *this));
87}
88
89
90//-------------------------------------------------
6391//  device_config_complete - perform any
6492//  operations now that the configuration is
6593//  complete
r11277r11278
176204
177205upd1990a_device::upd1990a_device(running_machine &_machine, const upd1990a_device_config &config)
178206    : device_t(_machine, config),
207     device_rtc_interface(_machine, config, *this),
179208      m_config(config)
180209{
181210}
r11277r11278
263292
264293
265294//-------------------------------------------------
295//  rtc_set_time - called to initialize the RTC to
296//  a known state
297//-------------------------------------------------
298
299void upd1990a_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second)
300{
301   m_time_counter[0] = convert_to_bcd(second);
302   m_time_counter[1] = convert_to_bcd(minute);
303   m_time_counter[2] = convert_to_bcd(hour);
304   m_time_counter[3] = convert_to_bcd(day);
305   m_time_counter[4] = (month << 4) | day_of_week;
306}
307
308
309//-------------------------------------------------
266310//  oe_w -
267311//-------------------------------------------------
268312
src/emu/machine/upd1990a.h
r11277r11278
6363// ======================> upd1990a_device_config
6464
6565class upd1990a_device_config :   public device_config,
66                                public upd1990a_interface
66                                 public upd1990a_interface,
67                         public device_config_rtc_interface
6768{
6869    friend class upd1990a_device;
6970
r11277r11278
8485
8586// ======================> upd1990a_device
8687
87class upd1990a_device :   public device_t
88class upd1990a_device :   public device_t,
89                  public device_rtc_interface
8890{
8991    friend class upd1990a_device_config;
9092
r11277r11278
109111    virtual void device_reset();
110112   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
111113
114   // device_rtc_interface overrides
115   virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second);
116   virtual bool rtc_is_year_2000_compliant() { return false; }
117
112118private:
113119   inline UINT8 convert_to_bcd(int val);
114120   inline int bcd_to_integer(UINT8 val);
src/emu/machine/rp5c15.c
r11277r11278
123123//-------------------------------------------------
124124
125125rp5c15_device_config::rp5c15_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
126   : device_config(mconfig, static_alloc_device_config, "RP5C15", tag, owner, clock)
126   : device_config(mconfig, static_alloc_device_config, "RP5C15", tag, owner, clock),
127     device_config_rtc_interface(mconfig, *this)
127128{
128129}
129130
r11277r11278
352353
353354rp5c15_device::rp5c15_device(running_machine &_machine, const rp5c15_device_config &config)
354355    : device_t(_machine, config),
356     device_rtc_interface(_machine, config, *this),
355357     m_alarm(1),
356358     m_alarm_on(1),
357359     m_1hz(1),
r11277r11278
426428
427429
428430//-------------------------------------------------
431//  rtc_set_time - called to initialize the RTC to
432//  a known state
433//-------------------------------------------------
434
435void rp5c15_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second)
436{
437   write_counter(REGISTER_1_YEAR, year);
438   write_counter(REGISTER_1_MONTH, month);
439   write_counter(REGISTER_1_DAY, day);
440   m_reg[MODE00][REGISTER_DAY_OF_THE_WEEK] = day_of_week;
441   write_counter(REGISTER_1_HOUR, hour);
442   write_counter(REGISTER_1_MINUTE, minute);
443   write_counter(REGISTER_1_SECOND, second);
444}
445
446
447//-------------------------------------------------
429448//  read -
430449//-------------------------------------------------
431450
src/emu/machine/rp5c15.h
r11277r11278
5959// ======================> rp5c15_device_config
6060
6161class rp5c15_device_config :   public device_config,
62                               public rp5c15_interface
62                               public rp5c15_interface,
63                        public device_config_rtc_interface
6364{
6465    friend class rp5c15_device;
6566
r11277r11278
8081
8182// ======================> rp5c15_device
8283
83class rp5c15_device :   public device_t
84class rp5c15_device :   public device_t,
85                  public device_rtc_interface
8486{
8587    friend class rp5c15_device_config;
8688
r11277r11278
9799    virtual void device_start();
98100   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
99101
102   // device_rtc_interface overrides
103   virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second);
104   virtual bool rtc_is_year_2000_compliant() { return false; }
105
100106private:
101107   inline void set_alarm_line();
102108   inline int read_counter(int counter);
src/emu/machine/msm5832.c
r11277r11278
2020*/
2121
2222#include "msm5832.h"
23#include "machine/devhelpr.h"
2423
2524
2625
r11277r11278
6968//  DEVICE CONFIGURATION
7069//**************************************************************************
7170
72GENERIC_DEVICE_CONFIG_SETUP(msm5832, "MSM5832")
71//-------------------------------------------------
72//  msm5832_device_config - constructor
73//-------------------------------------------------
7374
75msm5832_device_config::msm5832_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
76   : device_config(mconfig, static_alloc_device_config, "MSM5832", tag, owner, clock),
77     device_config_rtc_interface(mconfig, *this)
78{
79}
7480
7581
82//-------------------------------------------------
83//  static_alloc_device_config - allocate a new
84//  configuration object
85//-------------------------------------------------
86
87device_config *msm5832_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
88{
89   return global_alloc(msm5832_device_config(mconfig, tag, owner, clock));
90}
91
92
93//-------------------------------------------------
94//  alloc_device - allocate a new device object
95//-------------------------------------------------
96
97device_t *msm5832_device_config::alloc_device(running_machine &machine) const
98{
99   return auto_alloc(machine, msm5832_device(machine, *this));
100}
101
102
76103//**************************************************************************
77104//  INLINE HELPERS
78105//**************************************************************************
r11277r11278
189216
190217msm5832_device::msm5832_device(running_machine &_machine, const msm5832_device_config &config)
191218    : device_t(_machine, config),
219     device_rtc_interface(_machine, config, *this),
192220     m_hold(0),
193221     m_address(0),
194222     m_read(0),
r11277r11278
240268
241269
242270//-------------------------------------------------
271//  rtc_set_time - called to initialize the RTC to
272//  a known state
273//-------------------------------------------------
274
275void msm5832_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second)
276{
277   write_counter(REGISTER_Y1, year);
278   write_counter(REGISTER_MO1, month);
279   write_counter(REGISTER_D1, day);
280   m_reg[REGISTER_W] = day_of_week;
281   write_counter(REGISTER_H1, hour);
282   write_counter(REGISTER_MI1, minute);
283   write_counter(REGISTER_S1, second);
284}
285
286
287//-------------------------------------------------
243288//  data_r -
244289//-------------------------------------------------
245290
src/emu/machine/msm5832.h
r11277r11278
4343
4444// ======================> msm5832_device_config
4545
46class msm5832_device_config :   public device_config
46class msm5832_device_config :   public device_config,
47                        public device_config_rtc_interface
4748{
4849    friend class msm5832_device;
4950
r11277r11278
6061
6162// ======================> msm5832_device
6263
63class msm5832_device :   public device_t
64class msm5832_device :   public device_t,
65                  public device_rtc_interface
6466{
6567    friend class msm5832_device_config;
6668
r11277r11278
8688    virtual void device_start();
8789   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
8890
91   // device_rtc_interface overrides
92   virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second);
93   virtual bool rtc_is_year_2000_compliant() { return false; }
94
8995private:
9096   static const device_timer_id TIMER_CLOCK = 0;
9197
src/emu/machine/e0516.c
r11277r11278
99
1010#include "emu.h"
1111#include "e0516.h"
12#include "machine/devhelpr.h"
1312
1413
1514
r11277r11278
1716//  MACROS / CONSTANTS
1817//**************************************************************************
1918
20#define LOG 1
19#define LOG
2120
2221
2322// states
r11277r11278
5554//  DEVICE CONFIGURATION
5655//**************************************************************************
5756
58GENERIC_DEVICE_CONFIG_SETUP(e0516, "E05-16")
57//-------------------------------------------------
58//  e0516_device_config - constructor
59//-------------------------------------------------
5960
61e0516_device_config::e0516_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
62   : device_config(mconfig, static_alloc_device_config, "E05-16", tag, owner, clock),
63     device_config_rtc_interface(mconfig, *this)
64{
65}
6066
6167
68//-------------------------------------------------
69//  static_alloc_device_config - allocate a new
70//  configuration object
71//-------------------------------------------------
72
73device_config *e0516_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
74{
75   return global_alloc(e0516_device_config(mconfig, tag, owner, clock));
76}
77
78
79//-------------------------------------------------
80//  alloc_device - allocate a new device object
81//-------------------------------------------------
82
83device_t *e0516_device_config::alloc_device(running_machine &machine) const
84{
85   return auto_alloc(machine, e0516_device(machine, *this));
86}
87
88
6289//**************************************************************************
6390//  INLINE HELPERS
6491//**************************************************************************
6592
93//-------------------------------------------------
94//  advance_seconds -
95//-------------------------------------------------
6696
97inline void e0516_device::advance_seconds()
98{
99   m_register[SECOND]++;
67100
101   if (m_register[SECOND] == 60)
102   {
103      m_register[SECOND] = 0;
104      m_register[MINUTE]++;
105   }
106
107   if (m_register[MINUTE] == 60)
108   {
109      m_register[MINUTE] = 0;
110      m_register[HOUR]++;
111   }
112
113   if (m_register[HOUR] == 24)
114   {
115      m_register[HOUR] = 0;
116      m_register[DAY]++;
117      m_register[DAY_OF_WEEK]++;
118   }
119
120   if (m_register[DAY_OF_WEEK] == 8)
121   {
122      m_register[DAY_OF_WEEK] = 1;
123   }
124
125   if (m_register[DAY] == 32)
126   {
127      m_register[DAY] = 1;
128      m_register[MONTH]++;
129   }
130
131   if (m_register[MONTH] == 13)
132   {
133      m_register[MONTH] = 1;
134      m_register[YEAR]++;
135   }
136}
137
138
139
68140//**************************************************************************
69141//  LIVE DEVICE
70142//**************************************************************************
r11277r11278
75147
76148e0516_device::e0516_device(running_machine &_machine, const e0516_device_config &config)
77149    : device_t(_machine, config),
150     device_rtc_interface(_machine, config, *this),
78151      m_config(config)
79152{
80153}
r11277r11278
118191
119192void e0516_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
120193{
121   m_register[SECOND]++;
194   advance_seconds();
195}
122196
123   if (m_register[SECOND] == 60)
124   {
125      m_register[SECOND] = 0;
126      m_register[MINUTE]++;
127   }
128197
129   if (m_register[MINUTE] == 60)
130   {
131      m_register[MINUTE] = 0;
132      m_register[HOUR]++;
133   }
198//-------------------------------------------------
199//  rtc_set_time - called to initialize the RTC to
200//  a known state
201//-------------------------------------------------
134202
135   if (m_register[HOUR] == 24)
136   {
137      m_register[HOUR] = 0;
138      m_register[DAY]++;
139      m_register[DAY_OF_WEEK]++;
140   }
141
142   if (m_register[DAY_OF_WEEK] == 8)
143   {
144      m_register[DAY_OF_WEEK] = 1;
145   }
146
147   if (m_register[DAY] == 32)
148   {
149      m_register[DAY] = 1;
150      m_register[MONTH]++;
151   }
152
153   if (m_register[MONTH] == 13)
154   {
155      m_register[MONTH] = 1;
156      m_register[YEAR]++;
157   }
203void e0516_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second)
204{
205   m_register[YEAR] = year;
206   m_register[MONTH] = month;
207   m_register[DAY] = day;
208   m_register[DAY_OF_WEEK] = day_of_week + 1;
209   m_register[HOUR] = hour;
210   m_register[MINUTE] = minute;
211   m_register[SECOND] = second;
158212}
159213
160214
src/emu/machine/e0516.h
r11277r11278
2828
2929
3030//**************************************************************************
31//  MACROS / CONSTANTS
32//**************************************************************************
33
34
35
36
37//**************************************************************************
3831//  INTERFACE CONFIGURATION MACROS
3932//**************************************************************************
4033
r11277r11278
5043
5144// ======================> e0516_device_config
5245
53class e0516_device_config :   public device_config
46class e0516_device_config :   public device_config,
47                       public device_config_rtc_interface
5448{
5549    friend class e0516_device;
5650
r11277r11278
6862
6963// ======================> e0516_device
7064
71class e0516_device :  public device_t
65class e0516_device :  public device_t,
66                 public device_rtc_interface
7267{
7368    friend class e0516_device_config;
7469
r11277r11278
8782    virtual void device_reset();
8883   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
8984
85   // device_rtc_interface overrides
86   virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second);
87   virtual bool rtc_is_year_2000_compliant() { return false; }
88
9089private:
90   inline void advance_seconds();
91
9192   int m_cs;                  // chip select
9293   int m_clk;                  // clock
9394   int m_data_latch;            // data latch
src/emu/machine/rp5c01.c
r11277r11278
115115
116116rp5c01_device_config::rp5c01_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
117117   : device_config(mconfig, static_alloc_device_config, "RP5C01", tag, owner, clock),
118     device_config_rtc_interface(mconfig, *this),
118119     device_config_nvram_interface(mconfig, *this)
119120{
120121}
r11277r11278
343344
344345rp5c01_device::rp5c01_device(running_machine &_machine, const rp5c01_device_config &config)
345346    : device_t(_machine, config),
347     device_rtc_interface(_machine, config, *this),
346348     device_nvram_interface(_machine, config, *this),
347349     m_alarm(1),
348350     m_alarm_on(1),
r11277r11278
408410
409411
410412//-------------------------------------------------
413//  rtc_set_time - called to initialize the RTC to
414//  a known state
415//-------------------------------------------------
416
417void rp5c01_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second)
418{
419   write_counter(REGISTER_1_YEAR, year);
420   write_counter(REGISTER_1_MONTH, month);
421   write_counter(REGISTER_1_DAY, day);
422   m_reg[MODE00][REGISTER_DAY_OF_THE_WEEK] = day_of_week;
423   write_counter(REGISTER_1_HOUR, hour);
424   write_counter(REGISTER_1_MINUTE, minute);
425   write_counter(REGISTER_1_SECOND, second);
426}
427
428
429//-------------------------------------------------
411430//  nvram_default - called to initialize NVRAM to
412431//  its default state
413432//-------------------------------------------------
src/emu/machine/rp5c01.h
r11277r11278
5858// ======================> rp5c01_device_config
5959
6060class rp5c01_device_config :   public device_config,
61                        public device_config_nvram_interface,
62                               public rp5c01_interface
61                               public rp5c01_interface,
62                        public device_config_rtc_interface,
63                        public device_config_nvram_interface
6364{
6465    friend class rp5c01_device;
6566
r11277r11278
8182// ======================> rp5c01_device
8283
8384class rp5c01_device :   public device_t,
85                  public device_rtc_interface,
8486                  public device_nvram_interface
8587{
8688    friend class rp5c01_device_config;
r11277r11278
98100    virtual void device_start();
99101   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
100102
103   // device_rtc_interface overrides
104   virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second);
105   virtual bool rtc_is_year_2000_compliant() { return false; }
106
101107   // device_nvram_interface overrides
102108   virtual void nvram_default();
103109   virtual void nvram_read(emu_file &file);
src/emu/machine/msm58321.c
r11277r11278
2121*/
2222
2323#include "msm58321.h"
24#include "machine/devhelpr.h"
2524
2625
2726
r11277r11278
2928//  MACROS / CONSTANTS
3029//**************************************************************************
3130
32#define LOG 1
31#define LOG
3332
3433
3534// registers
r11277r11278
7271//  DEVICE CONFIGURATION
7372//**************************************************************************
7473
75GENERIC_DEVICE_CONFIG_SETUP(msm58321, "MSM58321")
74//-------------------------------------------------
75//  msm58321_device_config - constructor
76//-------------------------------------------------
7677
78msm58321_device_config::msm58321_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
79   : device_config(mconfig, static_alloc_device_config, "MSM58321", tag, owner, clock),
80     device_config_rtc_interface(mconfig, *this)
81{
82}
7783
84
7885//-------------------------------------------------
86//  static_alloc_device_config - allocate a new
87//  configuration object
88//-------------------------------------------------
89
90device_config *msm58321_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
91{
92   return global_alloc(msm58321_device_config(mconfig, tag, owner, clock));
93}
94
95
96//-------------------------------------------------
97//  alloc_device - allocate a new device object
98//-------------------------------------------------
99
100device_t *msm58321_device_config::alloc_device(running_machine &machine) const
101{
102   return auto_alloc(machine, msm58321_device(machine, *this));
103}
104
105//-------------------------------------------------
79106//  device_config_complete - perform any
80107//  operations now that the configuration is
81108//  complete
r11277r11278
213240
214241msm58321_device::msm58321_device(running_machine &_machine, const msm58321_device_config &config)
215242    : device_t(_machine, config),
243     device_rtc_interface(_machine, config, *this),
216244      m_config(config)
217245{
218246   for (int i = 0; i < 13; i++)
r11277r11278
270298
271299
272300//-------------------------------------------------
301//  rtc_set_time - called to initialize the RTC to
302//  a known state
303//-------------------------------------------------
304
305void msm58321_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second)
306{
307   write_counter(REGISTER_Y1, year);
308   write_counter(REGISTER_MO1, month);
309   write_counter(REGISTER_D1, day);
310   m_reg[REGISTER_W] = day_of_week;
311   write_counter(REGISTER_H1, hour);
312   write_counter(REGISTER_MI1, minute);
313   write_counter(REGISTER_S1, second);
314}
315
316
317//-------------------------------------------------
273318//  read -
274319//-------------------------------------------------
275320
src/emu/machine/msm58321.h
r11277r11278
5656// ======================> msm58321_device_config
5757
5858class msm58321_device_config :   public device_config,
59                                 public msm58321_interface
59                                 public msm58321_interface,
60                         public device_config_rtc_interface
6061{
6162    friend class msm58321_device;
6263
r11277r11278
7778
7879// ======================> msm58321_device
7980
80class msm58321_device :   public device_t
81class msm58321_device :   public device_t,
82                  public device_rtc_interface
8183{
8284    friend class msm58321_device_config;
8385
r11277r11278
102104    virtual void device_start();
103105   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
104106
107   // device_rtc_interface overrides
108   virtual void rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second);
109   virtual bool rtc_is_year_2000_compliant() { return false; }
110
105111private:
106112   static const device_timer_id TIMER_CLOCK = 0;
107113   static const device_timer_id TIMER_BUSY = 1;
src/emu/machine/mc146818.c
r11277r11278
118118
119119mc146818_device_config::mc146818_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
120120   : device_config(mconfig, static_alloc_device_config, "NVRAM", tag, owner, clock),
121     device_config_rtc_interface(mconfig, *this),
121122     device_config_nvram_interface(mconfig, *this),
122123     m_type(MC146818_STANDARD)
123124{
r11277r11278
167168
168169mc146818_device::mc146818_device(running_machine &_machine, const mc146818_device_config &config)
169170   : device_t(_machine, config),
171     device_rtc_interface(_machine, config, *this),
170172     device_nvram_interface(_machine, config, *this),
171173     m_config(config),
172174     m_index(0),
r11277r11278
331333}
332334
333335
336//-------------------------------------------------
337//  rtc_set_time - called to initialize the RTC to
338//  a known state
339//-------------------------------------------------
334340
341void mc146818_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second)
342{
343   YEAR = year;
344   MONTH = month;
345   DAY = day;
346   WEEK_DAY = day_of_week;
347   m_data[4] = hour;
348   m_data[2] = minute;
349   m_data[0] = second;
350}
351
352
335353//-------------------------------------------------
336354//  nvram_default - called to initialize NVRAM to
337355//  its default state

Previous 15994 Revisions Next


© 1998-2018 The MESS Team