trunk/src/emu/machine/upd1990a.c
| r19671 | r19672 | |
| 21 | 21 | |
| 22 | 22 | // device type definition |
| 23 | 23 | const device_type UPD1990A = &device_creator<upd1990a_device>; |
| 24 | const device_type UPD4990A = &device_creator<upd4990a_device>; |
| 24 | 25 | |
| 25 | 26 | |
| 26 | 27 | //************************************************************************** |
| r19671 | r19672 | |
| 53 | 54 | // upd1990a_device - constructor |
| 54 | 55 | //------------------------------------------------- |
| 55 | 56 | |
| 56 | | upd1990a_device::upd1990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 57 | | : device_t(mconfig, UPD1990A, "uPD1990A", tag, owner, clock), |
| 57 | upd1990a_rtc_device::upd1990a_rtc_device(const machine_config &mconfig, device_type type, const char* name, const char *tag, device_t *owner, UINT32 clock) |
| 58 | : device_t(mconfig, type, name, tag, owner, clock), |
| 58 | 59 | device_rtc_interface(mconfig, *this), |
| 59 | 60 | m_data_out(0) |
| 60 | 61 | { |
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | |
| 65 | upd1990a_device::upd1990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 66 | : upd1990a_rtc_device(mconfig, UPD1990A, "uPD1990A", tag, owner, clock) |
| 67 | { |
| 68 | m_device_type = TYPE_UPD1990A; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | upd4990a_device::upd4990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 73 | : upd1990a_rtc_device(mconfig, UPD4990A, "uPD4990A", tag, owner, clock) |
| 74 | { |
| 75 | m_device_type = TYPE_UPD4990A; |
| 76 | } |
| 77 | |
| 78 | |
| 64 | 79 | //------------------------------------------------- |
| 65 | 80 | // device_config_complete - perform any |
| 66 | 81 | // operations now that the configuration is |
| 67 | 82 | // complete |
| 68 | 83 | //------------------------------------------------- |
| 69 | 84 | |
| 70 | | void upd1990a_device::device_config_complete() |
| 85 | void upd1990a_rtc_device::device_config_complete() |
| 71 | 86 | { |
| 72 | 87 | // inherit a copy of the static data |
| 73 | 88 | const upd1990a_interface *intf = reinterpret_cast<const upd1990a_interface *>(static_config()); |
| r19671 | r19672 | |
| 87 | 102 | // device_start - device-specific startup |
| 88 | 103 | //------------------------------------------------- |
| 89 | 104 | |
| 90 | | void upd1990a_device::device_start() |
| 105 | void upd1990a_rtc_device::device_start() |
| 91 | 106 | { |
| 92 | 107 | // resolve callbacks |
| 93 | 108 | m_out_data_func.resolve(m_out_data_cb, *this); |
| r19671 | r19672 | |
| 119 | 134 | // device_reset - device-specific reset |
| 120 | 135 | //------------------------------------------------- |
| 121 | 136 | |
| 122 | | void upd1990a_device::device_reset() |
| 137 | void upd1990a_rtc_device::device_reset() |
| 123 | 138 | { |
| 124 | 139 | set_current_time(machine()); |
| 125 | 140 | } |
| r19671 | r19672 | |
| 129 | 144 | // device_timer - handler timer events |
| 130 | 145 | //------------------------------------------------- |
| 131 | 146 | |
| 132 | | void upd1990a_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 147 | void upd1990a_rtc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 133 | 148 | { |
| 134 | 149 | switch (id) |
| 135 | 150 | { |
| r19671 | r19672 | |
| 194 | 209 | // rtc_clock_updated - |
| 195 | 210 | //------------------------------------------------- |
| 196 | 211 | |
| 197 | | void upd1990a_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) |
| 212 | void upd1990a_rtc_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) |
| 198 | 213 | { |
| 199 | 214 | m_time_counter[0] = convert_to_bcd(second); |
| 200 | 215 | m_time_counter[1] = convert_to_bcd(minute); |
| r19671 | r19672 | |
| 208 | 223 | // oe_w - |
| 209 | 224 | //------------------------------------------------- |
| 210 | 225 | |
| 211 | | WRITE_LINE_MEMBER( upd1990a_device::oe_w ) |
| 226 | WRITE_LINE_MEMBER( upd1990a_rtc_device::oe_w ) |
| 212 | 227 | { |
| 213 | 228 | if (LOG) logerror("uPD1990A '%s' OE %u\n", tag(), state); |
| 214 | 229 | |
| r19671 | r19672 | |
| 220 | 235 | // cs_w - |
| 221 | 236 | //------------------------------------------------- |
| 222 | 237 | |
| 223 | | WRITE_LINE_MEMBER( upd1990a_device::cs_w ) |
| 238 | WRITE_LINE_MEMBER( upd1990a_rtc_device::cs_w ) |
| 224 | 239 | { |
| 225 | 240 | if (LOG) logerror("uPD1990A '%s' CS %u\n", tag(), state); |
| 226 | 241 | |
| r19671 | r19672 | |
| 232 | 247 | // stb_w - |
| 233 | 248 | //------------------------------------------------- |
| 234 | 249 | |
| 235 | | WRITE_LINE_MEMBER( upd1990a_device::stb_w ) |
| 250 | WRITE_LINE_MEMBER( upd1990a_rtc_device::stb_w ) |
| 236 | 251 | { |
| 237 | 252 | if (LOG) logerror("uPD1990A '%s' STB %u\n", tag(), state); |
| 238 | 253 | |
| r19671 | r19672 | |
| 380 | 395 | // clk_w - |
| 381 | 396 | //------------------------------------------------- |
| 382 | 397 | |
| 383 | | WRITE_LINE_MEMBER( upd1990a_device::clk_w ) |
| 398 | WRITE_LINE_MEMBER( upd1990a_rtc_device::clk_w ) |
| 384 | 399 | { |
| 385 | 400 | if (LOG) logerror("uPD1990A '%s' CLK %u\n", tag(), state); |
| 386 | 401 | |
| r19671 | r19672 | |
| 422 | 437 | // c0_w - |
| 423 | 438 | //------------------------------------------------- |
| 424 | 439 | |
| 425 | | WRITE_LINE_MEMBER( upd1990a_device::c0_w ) |
| 440 | WRITE_LINE_MEMBER( upd1990a_rtc_device::c0_w ) |
| 426 | 441 | { |
| 427 | 442 | if (LOG) logerror("uPD1990A '%s' C0 %u\n", tag(), state); |
| 428 | 443 | |
| r19671 | r19672 | |
| 434 | 449 | // c1_w - |
| 435 | 450 | //------------------------------------------------- |
| 436 | 451 | |
| 437 | | WRITE_LINE_MEMBER( upd1990a_device::c1_w ) |
| 452 | WRITE_LINE_MEMBER( upd1990a_rtc_device::c1_w ) |
| 438 | 453 | { |
| 439 | 454 | if (LOG) logerror("uPD1990A '%s' C1 %u\n", tag(), state); |
| 440 | 455 | |
| r19671 | r19672 | |
| 446 | 461 | // c2_w - |
| 447 | 462 | //------------------------------------------------- |
| 448 | 463 | |
| 449 | | WRITE_LINE_MEMBER( upd1990a_device::c2_w ) |
| 464 | WRITE_LINE_MEMBER( upd1990a_rtc_device::c2_w ) |
| 450 | 465 | { |
| 451 | 466 | if (LOG) logerror("uPD1990A '%s' C2 %u\n", tag(), state); |
| 452 | 467 | |
| r19671 | r19672 | |
| 458 | 473 | // data_in_w - |
| 459 | 474 | //------------------------------------------------- |
| 460 | 475 | |
| 461 | | WRITE_LINE_MEMBER( upd1990a_device::data_in_w ) |
| 476 | WRITE_LINE_MEMBER( upd1990a_rtc_device::data_in_w ) |
| 462 | 477 | { |
| 463 | 478 | if (LOG) logerror("uPD1990A '%s' DATA IN %u\n", tag(), state); |
| 464 | 479 | |
| r19671 | r19672 | |
| 470 | 485 | // data_out_r - |
| 471 | 486 | //------------------------------------------------- |
| 472 | 487 | |
| 473 | | READ_LINE_MEMBER( upd1990a_device::data_out_r ) |
| 488 | READ_LINE_MEMBER( upd1990a_rtc_device::data_out_r ) |
| 474 | 489 | { |
| 475 | 490 | return m_data_out; |
| 476 | 491 | } |
| r19671 | r19672 | |
| 480 | 495 | // tp_r - |
| 481 | 496 | //------------------------------------------------- |
| 482 | 497 | |
| 483 | | READ_LINE_MEMBER( upd1990a_device::tp_r ) |
| 498 | READ_LINE_MEMBER( upd1990a_rtc_device::tp_r ) |
| 484 | 499 | { |
| 485 | 500 | return m_tp; |
| 486 | 501 | } |
trunk/src/emu/machine/upd1990a.h
| r19671 | r19672 | |
| 61 | 61 | |
| 62 | 62 | // ======================> upd1990a_device |
| 63 | 63 | |
| 64 | | class upd1990a_device : public device_t, |
| 65 | | public device_rtc_interface, |
| 66 | | public upd1990a_interface |
| 64 | class upd1990a_rtc_device : public device_t, |
| 65 | public device_rtc_interface, |
| 66 | public upd1990a_interface |
| 67 | 67 | { |
| 68 | 68 | public: |
| 69 | 69 | // construction/destruction |
| 70 | | upd1990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 70 | upd1990a_rtc_device(const machine_config &mconfig, device_type type, const char* name, const char *tag, device_t *owner, UINT32 clock); |
| 71 | 71 | |
| 72 | 72 | DECLARE_WRITE_LINE_MEMBER( oe_w ); |
| 73 | 73 | DECLARE_WRITE_LINE_MEMBER( cs_w ); |
| r19671 | r19672 | |
| 89 | 89 | |
| 90 | 90 | // device_rtc_interface overrides |
| 91 | 91 | virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second); |
| 92 | enum { |
| 93 | TYPE_UPD1990A = 0, |
| 94 | TYPE_UPD4990A |
| 95 | }; |
| 96 | int m_device_type; |
| 92 | 97 | |
| 93 | 98 | private: |
| 94 | 99 | static const device_timer_id TIMER_CLOCK = 0; |
| r19671 | r19672 | |
| 119 | 124 | emu_timer *m_timer_test_mode; |
| 120 | 125 | }; |
| 121 | 126 | |
| 127 | class upd1990a_device : public upd1990a_rtc_device |
| 128 | { |
| 129 | public: |
| 130 | upd1990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 131 | }; |
| 122 | 132 | |
| 133 | |
| 134 | class upd4990a_device : public upd1990a_rtc_device |
| 135 | { |
| 136 | public: |
| 137 | upd4990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 138 | }; |
| 139 | |
| 123 | 140 | // device type definition |
| 124 | 141 | extern const device_type UPD1990A; |
| 142 | extern const device_type UPD4990A; |
| 125 | 143 | |
| 126 | | |
| 127 | | |
| 128 | 144 | #endif |
trunk/src/emu/machine/pd4990a.c
| r19671 | r19672 | |
| 84 | 84 | INLINE upd4990a_state *get_safe_token(device_t *device) |
| 85 | 85 | { |
| 86 | 86 | assert(device != NULL); |
| 87 | | assert((device->type() == UPD4990A)); |
| 88 | | return (upd4990a_state *)downcast<upd4990a_device *>(device)->token(); |
| 87 | assert((device->type() == UPD4990A_OLD)); |
| 88 | return (upd4990a_state *)downcast<upd4990a_old_device *>(device)->token(); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | INLINE UINT8 convert_to_bcd(int val) |
| r19671 | r19672 | |
| 520 | 520 | upd4990a->command_line = 0; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | | const device_type UPD4990A = &device_creator<upd4990a_device>; |
| 523 | const device_type UPD4990A_OLD = &device_creator<upd4990a_old_device>; |
| 524 | 524 | |
| 525 | | upd4990a_device::upd4990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 526 | | : device_t(mconfig, UPD4990A, "NEC uPD4990A", tag, owner, clock) |
| 525 | upd4990a_old_device::upd4990a_old_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 526 | : device_t(mconfig, UPD4990A_OLD, "NEC uPD4990A", tag, owner, clock) |
| 527 | 527 | { |
| 528 | 528 | m_token = global_alloc_clear(upd4990a_state); |
| 529 | 529 | } |
| r19671 | r19672 | |
| 534 | 534 | // complete |
| 535 | 535 | //------------------------------------------------- |
| 536 | 536 | |
| 537 | | void upd4990a_device::device_config_complete() |
| 537 | void upd4990a_old_device::device_config_complete() |
| 538 | 538 | { |
| 539 | 539 | } |
| 540 | 540 | |
| r19671 | r19672 | |
| 542 | 542 | // device_start - device-specific startup |
| 543 | 543 | //------------------------------------------------- |
| 544 | 544 | |
| 545 | | void upd4990a_device::device_start() |
| 545 | void upd4990a_old_device::device_start() |
| 546 | 546 | { |
| 547 | 547 | DEVICE_START_NAME( upd4990a )(this); |
| 548 | 548 | } |
| r19671 | r19672 | |
| 551 | 551 | // device_reset - device-specific reset |
| 552 | 552 | //------------------------------------------------- |
| 553 | 553 | |
| 554 | | void upd4990a_device::device_reset() |
| 554 | void upd4990a_old_device::device_reset() |
| 555 | 555 | { |
| 556 | 556 | DEVICE_RESET_NAME( upd4990a )(this); |
| 557 | 557 | } |
trunk/src/emu/machine/pd4990a.h
| r19671 | r19672 | |
| 6 | 6 | |
| 7 | 7 | ***************************************************************************/ |
| 8 | 8 | |
| 9 | | #ifndef __PD4990A_H__ |
| 10 | | #define __PD4990A_H__ |
| 9 | #ifndef __PD4990A_OLD_H__ |
| 10 | #define __PD4990A_OLD_H__ |
| 11 | 11 | |
| 12 | 12 | #include "devlegcy.h" |
| 13 | 13 | |
| r19671 | r19672 | |
| 16 | 16 | MACROS / CONSTANTS |
| 17 | 17 | ***************************************************************************/ |
| 18 | 18 | |
| 19 | | class upd4990a_device : public device_t |
| 19 | class upd4990a_old_device : public device_t |
| 20 | 20 | { |
| 21 | 21 | public: |
| 22 | | upd4990a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 23 | | ~upd4990a_device() { global_free(m_token); } |
| 22 | upd4990a_old_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 23 | ~upd4990a_old_device() { global_free(m_token); } |
| 24 | 24 | |
| 25 | 25 | // access to legacy token |
| 26 | 26 | void *token() const { assert(m_token != NULL); return m_token; } |
| r19671 | r19672 | |
| 34 | 34 | void *m_token; |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | | extern const device_type UPD4990A; |
| 37 | extern const device_type UPD4990A_OLD; |
| 38 | 38 | |
| 39 | 39 | |
| 40 | | #define MCFG_UPD4990A_ADD(_tag) \ |
| 41 | | MCFG_DEVICE_ADD(_tag, UPD4990A, 0) |
| 40 | #define MCFG_UPD4990A_OLD_ADD(_tag) \ |
| 41 | MCFG_DEVICE_ADD(_tag, UPD4990A_OLD, 0) |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /*************************************************************************** |