src/emu/dirtc.c
| r0 | r11278 | |
| 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 | |
| 21 | device_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 | |
| 31 | device_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 | |
| 45 | device_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 | |
| 56 | device_rtc_interface::~device_rtc_interface() |
| 57 | { |
| 58 | } |
src/emu/dirtc.h
| r0 | r11278 | |
| 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 |
| 27 | class device_config_rtc_interface : public device_config_interface |
| 28 | { |
| 29 | public: |
| 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 |
| 40 | class device_rtc_interface : public device_interface |
| 41 | { |
| 42 | public: |
| 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 | |
| 50 | protected: |
| 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/machine/mc146818.h
| r11277 | r11278 | |
| 35 | 35 | // ======================> mc146818_device_config |
| 36 | 36 | |
| 37 | 37 | class mc146818_device_config : public device_config, |
| 38 | public device_config_rtc_interface, |
| 38 | 39 | public device_config_nvram_interface |
| 39 | 40 | { |
| 40 | 41 | friend class mc146818_device; |
| r11277 | r11278 | |
| 68 | 69 | // ======================> mc146818_device |
| 69 | 70 | |
| 70 | 71 | class mc146818_device : public device_t, |
| 72 | public device_rtc_interface, |
| 71 | 73 | public device_nvram_interface |
| 72 | 74 | { |
| 73 | 75 | friend class mc146818_device_config; |
| r11277 | r11278 | |
| 85 | 87 | virtual void device_start(); |
| 86 | 88 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 87 | 89 | |
| 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 |
| 89 | 95 | virtual void nvram_default(); |
| 90 | 96 | virtual void nvram_read(emu_file &file); |
| 91 | 97 | virtual void nvram_write(emu_file &file); |
src/emu/machine/upd1990a.c
| r11277 | r11278 | |
| 17 | 17 | |
| 18 | 18 | #include "emu.h" |
| 19 | 19 | #include "upd1990a.h" |
| 20 | | #include "machine/devhelpr.h" |
| 21 | 20 | |
| 22 | 21 | |
| 23 | 22 | |
| r11277 | r11278 | |
| 56 | 55 | // DEVICE CONFIGURATION |
| 57 | 56 | //************************************************************************** |
| 58 | 57 | |
| 59 | | GENERIC_DEVICE_CONFIG_SETUP(upd1990a, "uPD1990A") |
| 58 | //------------------------------------------------- |
| 59 | // upd1990a_device_config - constructor |
| 60 | //------------------------------------------------- |
| 60 | 61 | |
| 62 | upd1990a_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 | } |
| 61 | 67 | |
| 68 | |
| 62 | 69 | //------------------------------------------------- |
| 70 | // static_alloc_device_config - allocate a new |
| 71 | // configuration object |
| 72 | //------------------------------------------------- |
| 73 | |
| 74 | device_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 | |
| 84 | device_t *upd1990a_device_config::alloc_device(running_machine &machine) const |
| 85 | { |
| 86 | return auto_alloc(machine, upd1990a_device(machine, *this)); |
| 87 | } |
| 88 | |
| 89 | |
| 90 | //------------------------------------------------- |
| 63 | 91 | // device_config_complete - perform any |
| 64 | 92 | // operations now that the configuration is |
| 65 | 93 | // complete |
| r11277 | r11278 | |
| 176 | 204 | |
| 177 | 205 | upd1990a_device::upd1990a_device(running_machine &_machine, const upd1990a_device_config &config) |
| 178 | 206 | : device_t(_machine, config), |
| 207 | device_rtc_interface(_machine, config, *this), |
| 179 | 208 | m_config(config) |
| 180 | 209 | { |
| 181 | 210 | } |
| r11277 | r11278 | |
| 263 | 292 | |
| 264 | 293 | |
| 265 | 294 | //------------------------------------------------- |
| 295 | // rtc_set_time - called to initialize the RTC to |
| 296 | // a known state |
| 297 | //------------------------------------------------- |
| 298 | |
| 299 | void 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 | //------------------------------------------------- |
| 266 | 310 | // oe_w - |
| 267 | 311 | //------------------------------------------------- |
| 268 | 312 | |
src/emu/machine/upd1990a.h
| r11277 | r11278 | |
| 63 | 63 | // ======================> upd1990a_device_config |
| 64 | 64 | |
| 65 | 65 | class upd1990a_device_config : public device_config, |
| 66 | | public upd1990a_interface |
| 66 | public upd1990a_interface, |
| 67 | public device_config_rtc_interface |
| 67 | 68 | { |
| 68 | 69 | friend class upd1990a_device; |
| 69 | 70 | |
| r11277 | r11278 | |
| 84 | 85 | |
| 85 | 86 | // ======================> upd1990a_device |
| 86 | 87 | |
| 87 | | class upd1990a_device : public device_t |
| 88 | class upd1990a_device : public device_t, |
| 89 | public device_rtc_interface |
| 88 | 90 | { |
| 89 | 91 | friend class upd1990a_device_config; |
| 90 | 92 | |
| r11277 | r11278 | |
| 109 | 111 | virtual void device_reset(); |
| 110 | 112 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 111 | 113 | |
| 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 | |
| 112 | 118 | private: |
| 113 | 119 | inline UINT8 convert_to_bcd(int val); |
| 114 | 120 | inline int bcd_to_integer(UINT8 val); |
src/emu/machine/rp5c15.c
| r11277 | r11278 | |
| 123 | 123 | //------------------------------------------------- |
| 124 | 124 | |
| 125 | 125 | rp5c15_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) |
| 127 | 128 | { |
| 128 | 129 | } |
| 129 | 130 | |
| r11277 | r11278 | |
| 352 | 353 | |
| 353 | 354 | rp5c15_device::rp5c15_device(running_machine &_machine, const rp5c15_device_config &config) |
| 354 | 355 | : device_t(_machine, config), |
| 356 | device_rtc_interface(_machine, config, *this), |
| 355 | 357 | m_alarm(1), |
| 356 | 358 | m_alarm_on(1), |
| 357 | 359 | m_1hz(1), |
| r11277 | r11278 | |
| 426 | 428 | |
| 427 | 429 | |
| 428 | 430 | //------------------------------------------------- |
| 431 | // rtc_set_time - called to initialize the RTC to |
| 432 | // a known state |
| 433 | //------------------------------------------------- |
| 434 | |
| 435 | void 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 | //------------------------------------------------- |
| 429 | 448 | // read - |
| 430 | 449 | //------------------------------------------------- |
| 431 | 450 | |
src/emu/machine/rp5c15.h
| r11277 | r11278 | |
| 59 | 59 | // ======================> rp5c15_device_config |
| 60 | 60 | |
| 61 | 61 | class rp5c15_device_config : public device_config, |
| 62 | | public rp5c15_interface |
| 62 | public rp5c15_interface, |
| 63 | public device_config_rtc_interface |
| 63 | 64 | { |
| 64 | 65 | friend class rp5c15_device; |
| 65 | 66 | |
| r11277 | r11278 | |
| 80 | 81 | |
| 81 | 82 | // ======================> rp5c15_device |
| 82 | 83 | |
| 83 | | class rp5c15_device : public device_t |
| 84 | class rp5c15_device : public device_t, |
| 85 | public device_rtc_interface |
| 84 | 86 | { |
| 85 | 87 | friend class rp5c15_device_config; |
| 86 | 88 | |
| r11277 | r11278 | |
| 97 | 99 | virtual void device_start(); |
| 98 | 100 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 99 | 101 | |
| 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 | |
| 100 | 106 | private: |
| 101 | 107 | inline void set_alarm_line(); |
| 102 | 108 | inline int read_counter(int counter); |
src/emu/machine/msm5832.c
| r11277 | r11278 | |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | #include "msm5832.h" |
| 23 | | #include "machine/devhelpr.h" |
| 24 | 23 | |
| 25 | 24 | |
| 26 | 25 | |
| r11277 | r11278 | |
| 69 | 68 | // DEVICE CONFIGURATION |
| 70 | 69 | //************************************************************************** |
| 71 | 70 | |
| 72 | | GENERIC_DEVICE_CONFIG_SETUP(msm5832, "MSM5832") |
| 71 | //------------------------------------------------- |
| 72 | // msm5832_device_config - constructor |
| 73 | //------------------------------------------------- |
| 73 | 74 | |
| 75 | msm5832_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 | } |
| 74 | 80 | |
| 75 | 81 | |
| 82 | //------------------------------------------------- |
| 83 | // static_alloc_device_config - allocate a new |
| 84 | // configuration object |
| 85 | //------------------------------------------------- |
| 86 | |
| 87 | device_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 | |
| 97 | device_t *msm5832_device_config::alloc_device(running_machine &machine) const |
| 98 | { |
| 99 | return auto_alloc(machine, msm5832_device(machine, *this)); |
| 100 | } |
| 101 | |
| 102 | |
| 76 | 103 | //************************************************************************** |
| 77 | 104 | // INLINE HELPERS |
| 78 | 105 | //************************************************************************** |
| r11277 | r11278 | |
| 189 | 216 | |
| 190 | 217 | msm5832_device::msm5832_device(running_machine &_machine, const msm5832_device_config &config) |
| 191 | 218 | : device_t(_machine, config), |
| 219 | device_rtc_interface(_machine, config, *this), |
| 192 | 220 | m_hold(0), |
| 193 | 221 | m_address(0), |
| 194 | 222 | m_read(0), |
| r11277 | r11278 | |
| 240 | 268 | |
| 241 | 269 | |
| 242 | 270 | //------------------------------------------------- |
| 271 | // rtc_set_time - called to initialize the RTC to |
| 272 | // a known state |
| 273 | //------------------------------------------------- |
| 274 | |
| 275 | void 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 | //------------------------------------------------- |
| 243 | 288 | // data_r - |
| 244 | 289 | //------------------------------------------------- |
| 245 | 290 | |
src/emu/machine/msm5832.h
| r11277 | r11278 | |
| 43 | 43 | |
| 44 | 44 | // ======================> msm5832_device_config |
| 45 | 45 | |
| 46 | | class msm5832_device_config : public device_config |
| 46 | class msm5832_device_config : public device_config, |
| 47 | public device_config_rtc_interface |
| 47 | 48 | { |
| 48 | 49 | friend class msm5832_device; |
| 49 | 50 | |
| r11277 | r11278 | |
| 60 | 61 | |
| 61 | 62 | // ======================> msm5832_device |
| 62 | 63 | |
| 63 | | class msm5832_device : public device_t |
| 64 | class msm5832_device : public device_t, |
| 65 | public device_rtc_interface |
| 64 | 66 | { |
| 65 | 67 | friend class msm5832_device_config; |
| 66 | 68 | |
| r11277 | r11278 | |
| 86 | 88 | virtual void device_start(); |
| 87 | 89 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 88 | 90 | |
| 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 | |
| 89 | 95 | private: |
| 90 | 96 | static const device_timer_id TIMER_CLOCK = 0; |
| 91 | 97 | |
src/emu/machine/e0516.c
| r11277 | r11278 | |
| 9 | 9 | |
| 10 | 10 | #include "emu.h" |
| 11 | 11 | #include "e0516.h" |
| 12 | | #include "machine/devhelpr.h" |
| 13 | 12 | |
| 14 | 13 | |
| 15 | 14 | |
| r11277 | r11278 | |
| 17 | 16 | // MACROS / CONSTANTS |
| 18 | 17 | //************************************************************************** |
| 19 | 18 | |
| 20 | | #define LOG 1 |
| 19 | #define LOG |
| 21 | 20 | |
| 22 | 21 | |
| 23 | 22 | // states |
| r11277 | r11278 | |
| 55 | 54 | // DEVICE CONFIGURATION |
| 56 | 55 | //************************************************************************** |
| 57 | 56 | |
| 58 | | GENERIC_DEVICE_CONFIG_SETUP(e0516, "E05-16") |
| 57 | //------------------------------------------------- |
| 58 | // e0516_device_config - constructor |
| 59 | //------------------------------------------------- |
| 59 | 60 | |
| 61 | e0516_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 | } |
| 60 | 66 | |
| 61 | 67 | |
| 68 | //------------------------------------------------- |
| 69 | // static_alloc_device_config - allocate a new |
| 70 | // configuration object |
| 71 | //------------------------------------------------- |
| 72 | |
| 73 | device_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 | |
| 83 | device_t *e0516_device_config::alloc_device(running_machine &machine) const |
| 84 | { |
| 85 | return auto_alloc(machine, e0516_device(machine, *this)); |
| 86 | } |
| 87 | |
| 88 | |
| 62 | 89 | //************************************************************************** |
| 63 | 90 | // INLINE HELPERS |
| 64 | 91 | //************************************************************************** |
| 65 | 92 | |
| 93 | //------------------------------------------------- |
| 94 | // advance_seconds - |
| 95 | //------------------------------------------------- |
| 66 | 96 | |
| 97 | inline void e0516_device::advance_seconds() |
| 98 | { |
| 99 | m_register[SECOND]++; |
| 67 | 100 | |
| 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 | |
| 68 | 140 | //************************************************************************** |
| 69 | 141 | // LIVE DEVICE |
| 70 | 142 | //************************************************************************** |
| r11277 | r11278 | |
| 75 | 147 | |
| 76 | 148 | e0516_device::e0516_device(running_machine &_machine, const e0516_device_config &config) |
| 77 | 149 | : device_t(_machine, config), |
| 150 | device_rtc_interface(_machine, config, *this), |
| 78 | 151 | m_config(config) |
| 79 | 152 | { |
| 80 | 153 | } |
| r11277 | r11278 | |
| 118 | 191 | |
| 119 | 192 | void e0516_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 120 | 193 | { |
| 121 | | m_register[SECOND]++; |
| 194 | advance_seconds(); |
| 195 | } |
| 122 | 196 | |
| 123 | | if (m_register[SECOND] == 60) |
| 124 | | { |
| 125 | | m_register[SECOND] = 0; |
| 126 | | m_register[MINUTE]++; |
| 127 | | } |
| 128 | 197 | |
| 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 | //------------------------------------------------- |
| 134 | 202 | |
| 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 | | } |
| 203 | void 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; |
| 158 | 212 | } |
| 159 | 213 | |
| 160 | 214 | |
src/emu/machine/e0516.h
| r11277 | r11278 | |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | //************************************************************************** |
| 31 | | // MACROS / CONSTANTS |
| 32 | | //************************************************************************** |
| 33 | | |
| 34 | | |
| 35 | | |
| 36 | | |
| 37 | | //************************************************************************** |
| 38 | 31 | // INTERFACE CONFIGURATION MACROS |
| 39 | 32 | //************************************************************************** |
| 40 | 33 | |
| r11277 | r11278 | |
| 50 | 43 | |
| 51 | 44 | // ======================> e0516_device_config |
| 52 | 45 | |
| 53 | | class e0516_device_config : public device_config |
| 46 | class e0516_device_config : public device_config, |
| 47 | public device_config_rtc_interface |
| 54 | 48 | { |
| 55 | 49 | friend class e0516_device; |
| 56 | 50 | |
| r11277 | r11278 | |
| 68 | 62 | |
| 69 | 63 | // ======================> e0516_device |
| 70 | 64 | |
| 71 | | class e0516_device : public device_t |
| 65 | class e0516_device : public device_t, |
| 66 | public device_rtc_interface |
| 72 | 67 | { |
| 73 | 68 | friend class e0516_device_config; |
| 74 | 69 | |
| r11277 | r11278 | |
| 87 | 82 | virtual void device_reset(); |
| 88 | 83 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 89 | 84 | |
| 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 | |
| 90 | 89 | private: |
| 90 | inline void advance_seconds(); |
| 91 | |
| 91 | 92 | int m_cs; // chip select |
| 92 | 93 | int m_clk; // clock |
| 93 | 94 | int m_data_latch; // data latch |
src/emu/machine/rp5c01.c
| r11277 | r11278 | |
| 115 | 115 | |
| 116 | 116 | rp5c01_device_config::rp5c01_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 117 | 117 | : device_config(mconfig, static_alloc_device_config, "RP5C01", tag, owner, clock), |
| 118 | device_config_rtc_interface(mconfig, *this), |
| 118 | 119 | device_config_nvram_interface(mconfig, *this) |
| 119 | 120 | { |
| 120 | 121 | } |
| r11277 | r11278 | |
| 343 | 344 | |
| 344 | 345 | rp5c01_device::rp5c01_device(running_machine &_machine, const rp5c01_device_config &config) |
| 345 | 346 | : device_t(_machine, config), |
| 347 | device_rtc_interface(_machine, config, *this), |
| 346 | 348 | device_nvram_interface(_machine, config, *this), |
| 347 | 349 | m_alarm(1), |
| 348 | 350 | m_alarm_on(1), |
| r11277 | r11278 | |
| 408 | 410 | |
| 409 | 411 | |
| 410 | 412 | //------------------------------------------------- |
| 413 | // rtc_set_time - called to initialize the RTC to |
| 414 | // a known state |
| 415 | //------------------------------------------------- |
| 416 | |
| 417 | void 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 | //------------------------------------------------- |
| 411 | 430 | // nvram_default - called to initialize NVRAM to |
| 412 | 431 | // its default state |
| 413 | 432 | //------------------------------------------------- |
src/emu/machine/rp5c01.h
| r11277 | r11278 | |
| 58 | 58 | // ======================> rp5c01_device_config |
| 59 | 59 | |
| 60 | 60 | class 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 |
| 63 | 64 | { |
| 64 | 65 | friend class rp5c01_device; |
| 65 | 66 | |
| r11277 | r11278 | |
| 81 | 82 | // ======================> rp5c01_device |
| 82 | 83 | |
| 83 | 84 | class rp5c01_device : public device_t, |
| 85 | public device_rtc_interface, |
| 84 | 86 | public device_nvram_interface |
| 85 | 87 | { |
| 86 | 88 | friend class rp5c01_device_config; |
| r11277 | r11278 | |
| 98 | 100 | virtual void device_start(); |
| 99 | 101 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 100 | 102 | |
| 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 | |
| 101 | 107 | // device_nvram_interface overrides |
| 102 | 108 | virtual void nvram_default(); |
| 103 | 109 | virtual void nvram_read(emu_file &file); |
src/emu/machine/msm58321.c
| r11277 | r11278 | |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | #include "msm58321.h" |
| 24 | | #include "machine/devhelpr.h" |
| 25 | 24 | |
| 26 | 25 | |
| 27 | 26 | |
| r11277 | r11278 | |
| 29 | 28 | // MACROS / CONSTANTS |
| 30 | 29 | //************************************************************************** |
| 31 | 30 | |
| 32 | | #define LOG 1 |
| 31 | #define LOG |
| 33 | 32 | |
| 34 | 33 | |
| 35 | 34 | // registers |
| r11277 | r11278 | |
| 72 | 71 | // DEVICE CONFIGURATION |
| 73 | 72 | //************************************************************************** |
| 74 | 73 | |
| 75 | | GENERIC_DEVICE_CONFIG_SETUP(msm58321, "MSM58321") |
| 74 | //------------------------------------------------- |
| 75 | // msm58321_device_config - constructor |
| 76 | //------------------------------------------------- |
| 76 | 77 | |
| 78 | msm58321_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 | } |
| 77 | 83 | |
| 84 | |
| 78 | 85 | //------------------------------------------------- |
| 86 | // static_alloc_device_config - allocate a new |
| 87 | // configuration object |
| 88 | //------------------------------------------------- |
| 89 | |
| 90 | device_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 | |
| 100 | device_t *msm58321_device_config::alloc_device(running_machine &machine) const |
| 101 | { |
| 102 | return auto_alloc(machine, msm58321_device(machine, *this)); |
| 103 | } |
| 104 | |
| 105 | //------------------------------------------------- |
| 79 | 106 | // device_config_complete - perform any |
| 80 | 107 | // operations now that the configuration is |
| 81 | 108 | // complete |
| r11277 | r11278 | |
| 213 | 240 | |
| 214 | 241 | msm58321_device::msm58321_device(running_machine &_machine, const msm58321_device_config &config) |
| 215 | 242 | : device_t(_machine, config), |
| 243 | device_rtc_interface(_machine, config, *this), |
| 216 | 244 | m_config(config) |
| 217 | 245 | { |
| 218 | 246 | for (int i = 0; i < 13; i++) |
| r11277 | r11278 | |
| 270 | 298 | |
| 271 | 299 | |
| 272 | 300 | //------------------------------------------------- |
| 301 | // rtc_set_time - called to initialize the RTC to |
| 302 | // a known state |
| 303 | //------------------------------------------------- |
| 304 | |
| 305 | void 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 | //------------------------------------------------- |
| 273 | 318 | // read - |
| 274 | 319 | //------------------------------------------------- |
| 275 | 320 | |
src/emu/machine/msm58321.h
| r11277 | r11278 | |
| 56 | 56 | // ======================> msm58321_device_config |
| 57 | 57 | |
| 58 | 58 | class msm58321_device_config : public device_config, |
| 59 | | public msm58321_interface |
| 59 | public msm58321_interface, |
| 60 | public device_config_rtc_interface |
| 60 | 61 | { |
| 61 | 62 | friend class msm58321_device; |
| 62 | 63 | |
| r11277 | r11278 | |
| 77 | 78 | |
| 78 | 79 | // ======================> msm58321_device |
| 79 | 80 | |
| 80 | | class msm58321_device : public device_t |
| 81 | class msm58321_device : public device_t, |
| 82 | public device_rtc_interface |
| 81 | 83 | { |
| 82 | 84 | friend class msm58321_device_config; |
| 83 | 85 | |
| r11277 | r11278 | |
| 102 | 104 | virtual void device_start(); |
| 103 | 105 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 104 | 106 | |
| 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 | |
| 105 | 111 | private: |
| 106 | 112 | static const device_timer_id TIMER_CLOCK = 0; |
| 107 | 113 | static const device_timer_id TIMER_BUSY = 1; |
src/emu/machine/mc146818.c
| r11277 | r11278 | |
| 118 | 118 | |
| 119 | 119 | mc146818_device_config::mc146818_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 120 | 120 | : device_config(mconfig, static_alloc_device_config, "NVRAM", tag, owner, clock), |
| 121 | device_config_rtc_interface(mconfig, *this), |
| 121 | 122 | device_config_nvram_interface(mconfig, *this), |
| 122 | 123 | m_type(MC146818_STANDARD) |
| 123 | 124 | { |
| r11277 | r11278 | |
| 167 | 168 | |
| 168 | 169 | mc146818_device::mc146818_device(running_machine &_machine, const mc146818_device_config &config) |
| 169 | 170 | : device_t(_machine, config), |
| 171 | device_rtc_interface(_machine, config, *this), |
| 170 | 172 | device_nvram_interface(_machine, config, *this), |
| 171 | 173 | m_config(config), |
| 172 | 174 | m_index(0), |
| r11277 | r11278 | |
| 331 | 333 | } |
| 332 | 334 | |
| 333 | 335 | |
| 336 | //------------------------------------------------- |
| 337 | // rtc_set_time - called to initialize the RTC to |
| 338 | // a known state |
| 339 | //------------------------------------------------- |
| 334 | 340 | |
| 341 | void 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 | |
| 335 | 353 | //------------------------------------------------- |
| 336 | 354 | // nvram_default - called to initialize NVRAM to |
| 337 | 355 | // its default state |