From 1c0077d3b9ae6481d6be1040aa383536ef778917 Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 26 Nov 2023 21:49:07 +0100 Subject: hd44780: adjust blink timer in device_clock_changed --- src/devices/video/hd44780.cpp | 15 ++++++++++++++- src/devices/video/hd44780.h | 1 + src/mame/hegenerglaser/modular_tm.cpp | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/devices/video/hd44780.cpp b/src/devices/video/hd44780.cpp index ce60a911c76..ade4187a027 100644 --- a/src/devices/video/hd44780.cpp +++ b/src/devices/video/hd44780.cpp @@ -274,7 +274,6 @@ void hd44780_device::device_start() m_busy_timer = timer_alloc(FUNC(hd44780_device::clear_busy_flag), this); m_blink_timer = timer_alloc(FUNC(hd44780_device::blink_tick), this); - m_blink_timer->adjust(attotime::from_ticks(102400, clock()), 0, attotime::from_ticks(102400, clock())); // blink happens every 102400 cycles // state saving save_item(NAME(m_busy_factor)); @@ -335,9 +334,23 @@ void hd44780_device::device_reset() set_busy_flag(410); } +//------------------------------------------------- +// device_clock_changed +//------------------------------------------------- + +void hd44780_device::device_clock_changed() +{ + // (re)adjust blink timer + attotime period = attotime::from_ticks(102400, clock()); // blink happens every 102400 cycles + attotime remain = m_blink_timer->remaining(); + + m_blink_timer->adjust((remain > period) ? period : remain, 0, period); +} + //------------------------------------------------- // device validity check //------------------------------------------------- + void hd44780_device::device_validity_check(validity_checker &valid) const { if (clock() == 0) diff --git a/src/devices/video/hd44780.h b/src/devices/video/hd44780.h index a998d1979f4..71bb5b30058 100644 --- a/src/devices/video/hd44780.h +++ b/src/devices/video/hd44780.h @@ -63,6 +63,7 @@ protected: // device_t implementation virtual void device_start() override; virtual void device_reset() override; + virtual void device_clock_changed() override; virtual void device_validity_check(validity_checker &valid) const override; virtual const tiny_rom_entry *device_rom_region() const override; diff --git a/src/mame/hegenerglaser/modular_tm.cpp b/src/mame/hegenerglaser/modular_tm.cpp index 4f0a74a5c37..04c7fd7959e 100644 --- a/src/mame/hegenerglaser/modular_tm.cpp +++ b/src/mame/hegenerglaser/modular_tm.cpp @@ -141,7 +141,7 @@ void mmtm_state::set_cpu_freq() m_maincpu->set_unscaled_clock(xtal[val]); // lcd busy flag timing problem when overclocked - subdevice("display:hd44780")->set_busy_factor((val > 1) ? 0.75 : 1.0); + subdevice("display:hd44780")->set_clock((val > 1) ? 350'000 : 270'000); } -- cgit v1.2.3