hd44780: adjust blink timer in device_clock_changed

This commit is contained in:
hap 2023-11-26 21:49:07 +01:00
parent 2e68a82e38
commit 1c0077d3b9
3 changed files with 16 additions and 2 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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<hd44780_device>("display:hd44780")->set_busy_factor((val > 1) ? 0.75 : 1.0);
subdevice<hd44780_device>("display:hd44780")->set_clock((val > 1) ? 350'000 : 270'000);
}