summaryrefslogtreecommitdiff
path: root/src/video/allegro_v.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video/allegro_v.cpp')
-rw-r--r--src/video/allegro_v.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp
index 20f0e65ed..493e5a81d 100644
--- a/src/video/allegro_v.cpp
+++ b/src/video/allegro_v.cpp
@@ -448,7 +448,7 @@ void VideoDriver_Allegro::Stop()
void VideoDriver_Allegro::MainLoop()
{
auto cur_ticks = std::chrono::steady_clock::now();
- auto last_cur_ticks = cur_ticks;
+ auto last_realtime_tick = cur_ticks;
auto next_tick = cur_ticks;
CheckPaletteAnim();
@@ -473,9 +473,15 @@ void VideoDriver_Allegro::MainLoop()
}
cur_ticks = std::chrono::steady_clock::now();
+
+ /* If more than a millisecond has passed, increase the _realtime_tick. */
+ if (cur_ticks - last_realtime_tick > std::chrono::milliseconds(1)) {
+ auto delta = std::chrono::duration_cast<std::chrono::milliseconds>(cur_ticks - last_realtime_tick);
+ _realtime_tick += delta.count();
+ last_realtime_tick += delta;
+ }
+
if (cur_ticks >= next_tick || (_fast_forward && !_pause_mode)) {
- _realtime_tick += std::chrono::duration_cast<std::chrono::milliseconds>(cur_ticks - last_cur_ticks).count();
- last_cur_ticks = cur_ticks;
next_tick = cur_ticks + std::chrono::milliseconds(MILLISECONDS_PER_TICK);
bool old_ctrl_pressed = _ctrl_pressed;