diff options
author | 2019-06-05 23:51:47 -0400 | |
---|---|---|
committer | 2019-06-05 23:53:44 -0400 | |
commit | 0990b9df663b0cee40bb7b142bbdf32383b51a23 (patch) | |
tree | 95c29743d59eef20c0d555a7e6ff7f2732eb90b9 | |
parent | 334af8082a2d24ff985382937707b8eee21c5835 (diff) |
ds1386: Make initialization of RTC registers from system time actually work; adopt more useful default value for command register
hp16500b: Add DS1286 (nw)
-rw-r--r-- | src/devices/machine/ds1386.cpp | 54 | ||||
-rw-r--r-- | src/devices/machine/ds1386.h | 11 | ||||
-rw-r--r-- | src/mame/drivers/hp16500.cpp | 7 |
3 files changed, 36 insertions, 36 deletions
diff --git a/src/devices/machine/ds1386.cpp b/src/devices/machine/ds1386.cpp index a5319451e8d..0f430413017 100644 --- a/src/devices/machine/ds1386.cpp +++ b/src/devices/machine/ds1386.cpp @@ -34,6 +34,7 @@ DEFINE_DEVICE_TYPE(DS1386_32K, ds1386_32k_device, "ds1386_32k", "DS1386-32K RAMi ds1386_device::ds1386_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, size_t size) : device_t(mconfig, type, tag, owner, clock) , device_nvram_interface(mconfig, *this) + , device_rtc_interface(mconfig, *this) , m_tod_alarm(0) , m_watchdog_alarm(0) , m_square(1) @@ -120,48 +121,36 @@ void ds1386_device::device_start() m_intb_timer= timer_alloc(INTB_TIMER); m_intb_timer->adjust(attotime::never); - set_current_time(); - // state saving save_item(NAME(m_tod_alarm)); save_item(NAME(m_watchdog_alarm)); save_item(NAME(m_square)); m_ram = std::make_unique<uint8_t[]>(m_ram_size); - memset(&m_ram[0], 0, m_ram_size); -} - -void ds1386_device::device_reset() -{ - m_tod_alarm = 0; - m_watchdog_alarm = 0; - m_square = 1; - - safe_inta_cb(0); - safe_intb_cb(0); - safe_sqw_cb(1); - - m_clock_timer->adjust(attotime::from_hz(100), 0, attotime::from_hz(100)); - m_square_timer->adjust(attotime::never); - m_watchdog_timer->adjust(attotime::never); - - set_current_time(); + save_pointer(NAME(m_ram), m_ram_size); } -void ds1386_device::set_current_time() +void ds1386_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) { - system_time systime; - machine().base_datetime(systime); - m_hundredths = 0; - m_seconds = time_helper::make_bcd(systime.local_time.second); - m_minutes = time_helper::make_bcd(systime.local_time.minute); - m_hours = time_helper::make_bcd(systime.local_time.hour); - m_days = time_helper::make_bcd(systime.local_time.weekday + 1); - m_date = time_helper::make_bcd(systime.local_time.mday); - m_months_enables = time_helper::make_bcd(systime.local_time.month + 1); - m_years = time_helper::make_bcd(systime.local_time.year % 100); + m_seconds = time_helper::make_bcd(second); + m_minutes = time_helper::make_bcd(minute); + if (m_hours & HOURS_12_24) + { + if (hour >= 12) + m_hours = time_helper::make_bcd(hour == 12 ? 12 : hour - 12) | HOURS_12_24 | HOURS_AM_PM; + else + m_hours = time_helper::make_bcd(hour == 0 ? 12 : hour) | HOURS_12_24; + } + else + m_hours = time_helper::make_bcd(hour); + m_days = time_helper::make_bcd(day_of_week); + m_date = time_helper::make_bcd(second); + m_months_enables = (time_helper::make_bcd(month) & 0x1f) | (m_months_enables & 0xc0); + m_years = time_helper::make_bcd(year); + + copy_registers_to_ram(); } void ds1386_device::time_of_day_alarm() @@ -419,7 +408,8 @@ void ds1386_device::check_tod_alarm() void ds1386_device::nvram_default() { - memset(&m_ram[0], 0, m_ram_size); + std::fill_n(&m_ram[0], m_ram_size, 0); + m_ram[REGISTER_COMMAND] = COMMAND_TE | COMMAND_WAM | COMMAND_TDM; } void ds1386_device::nvram_read(emu_file &file) diff --git a/src/devices/machine/ds1386.h b/src/devices/machine/ds1386.h index 032e7d73eb0..17e01b9f458 100644 --- a/src/devices/machine/ds1386.h +++ b/src/devices/machine/ds1386.h @@ -74,8 +74,11 @@ #pragma once +#include "dirtc.h" + class ds1386_device : public device_t, - public device_nvram_interface + public device_nvram_interface, + public device_rtc_interface { public: auto inta() { return m_inta_cb.bind(); } @@ -122,7 +125,6 @@ protected: // device-level overrides virtual void device_start() override; - virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // device_nvram_interface overrides @@ -130,6 +132,11 @@ protected: virtual void nvram_read(emu_file &file) override; virtual void nvram_write(emu_file &file) override; + // device_rtc_interface overrides + virtual bool rtc_feature_y2k() const override { return false; } + virtual bool rtc_feature_leap_year() const override { return true; } + virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override; + static constexpr device_timer_id CLOCK_TIMER = 0; static constexpr device_timer_id SQUAREWAVE_TIMER = 1; static constexpr device_timer_id WATCHDOG_TIMER = 2; diff --git a/src/mame/drivers/hp16500.cpp b/src/mame/drivers/hp16500.cpp index 8b4798c5589..00b7f368484 100644 --- a/src/mame/drivers/hp16500.cpp +++ b/src/mame/drivers/hp16500.cpp @@ -49,6 +49,7 @@ #include "emu.h" #include "cpu/m68000/m68000.h" +#include "machine/ds1386.h" #include "machine/mc2661.h" #include "bus/hp_hil/hp_hil.h" #include "bus/hp_hil/hil_devices.h" @@ -314,7 +315,8 @@ void hp16500_state::hp16500_map(address_map &map) map(0x00203000, 0x00203003).w(FUNC(hp16500_state::vbl_ack_w)); map(0x00209800, 0x00209803).r(FUNC(hp16500_state::vbl_state_r)); - map(0x0020b800, 0x0020b8ff).ram(); // system ram test is really strange. + map(0x0020b800, 0x0020b83f).rw("rtc", FUNC(ds1286_device::data_r), FUNC(ds1286_device::data_w)); + map(0x0020b840, 0x0020b843).noprw(); // system ram test is really strange. map(0x0020f800, 0x0020f80f).rw(m_mlc, FUNC(hp_hil_mlc_device::read), FUNC(hp_hil_mlc_device::write)); map(0x00600000, 0x0061ffff).w(FUNC(hp16500_state::vram_w)); @@ -483,7 +485,7 @@ void hp16500_state::hp16500a(machine_config &config) void hp16500_state::hp16500b(machine_config &config) { /* basic machine hardware */ - M68EC030(config, m_maincpu, 25'000'000); + M68EC030(config, m_maincpu, 50_MHz_XTAL / 2); m_maincpu->set_addrmap(AS_PROGRAM, &hp16500_state::hp16500_map); screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); @@ -502,6 +504,7 @@ void hp16500_state::hp16500b(machine_config &config) // later with a 16500b specific keyboard implementation HP_HIL_SLOT(config, "hil1", "mlc", hp_hil_devices, "hp_ipc_kbd"); + DS1286(config, "rtc", 32768); //WD37C65C(config, "fdc", 16_MHz_XTAL); SPEAKER(config, "lspeaker").front_left(); |