diff --git a/devices/video/appleramdac.cpp b/devices/video/appleramdac.cpp index bb6be7e..4bc9d43 100644 --- a/devices/video/appleramdac.cpp +++ b/devices/video/appleramdac.cpp @@ -87,10 +87,23 @@ void AppleRamdac::iodev_write(uint32_t address, uint16_t value) { case RamdacRegs::MULTI: switch (this->dac_addr) { case RamdacRegs::CURSOR_POS_HI: + if (this->cursor_timer_id) { + TimerManager::get_instance()->cancel_timer(this->cursor_timer_id); + cursor_timer_id = 0; + } this->cursor_xpos = (value << 8) | this->cursor_pos_lo; break; case RamdacRegs::CURSOR_POS_LO: - this->cursor_pos_lo = value; + if (this->cursor_timer_id) { + TimerManager::get_instance()->cancel_timer(this->cursor_timer_id); + this->cursor_xpos = (this->cursor_xpos & 0xff00) | (this->cursor_pos_lo & 0x00ff); + cursor_timer_id = 0; + } + this->cursor_pos_lo = value; + this->cursor_timer_id = TimerManager::get_instance()->add_oneshot_timer( + 1000000000 / 60, [this]() { + this->cursor_xpos = (this->cursor_xpos & 0xff00) | (this->cursor_pos_lo & 0x00ff); + }); break; case RamdacRegs::MISC_CTRL: if (bit_changed(this->dac_cr, value, 1)) { diff --git a/devices/video/appleramdac.h b/devices/video/appleramdac.h index f2ecaa6..7ed27c2 100644 --- a/devices/video/appleramdac.h +++ b/devices/video/appleramdac.h @@ -118,6 +118,7 @@ protected: int video_width = 0; int video_height = 0; uint32_t fb_pitch = 0; + uint32_t cursor_timer_id = 0; }; #endif // APPLE_RAMDAC_H