From 021d4dbaf10d931c107534e088fcfd8d88a389f9 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 8 Oct 2019 23:06:50 -0400 Subject: [PATCH] Makes an attempt at tracking video sequence points. --- Machines/AtariST/AtariST.cpp | 12 +++++++++++- Machines/AtariST/Video.cpp | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Machines/AtariST/AtariST.cpp b/Machines/AtariST/AtariST.cpp index 68303d23c..cfb29d714 100644 --- a/Machines/AtariST/AtariST.cpp +++ b/Machines/AtariST/AtariST.cpp @@ -272,9 +272,18 @@ class ConcreteMachine: private: forceinline void advance_time(HalfCycles length) { - video_ += length; cycles_since_audio_update_ += length; mfp_ += length; + + while(length >= cycles_until_video_event_) { + length -= cycles_until_video_event_; + video_ += cycles_until_video_event_; + cycles_until_video_event_ = video_->get_next_sequence_point(); + + // TODO: push v/hsync/display_enable elsewhere. + } + cycles_until_video_event_ -= length; + video_ += length; } void update_audio() { @@ -284,6 +293,7 @@ class ConcreteMachine: CPU::MC68000::Processor mc68000_; JustInTimeActor video_; JustInTimeActor mfp_; + HalfCycles cycles_until_video_event_; Concurrency::DeferringAsyncTaskQueue audio_queue_; GI::AY38910::AY38910 ay_; diff --git a/Machines/AtariST/Video.cpp b/Machines/AtariST/Video.cpp index 9c5e2a2d4..976e8e5c6 100644 --- a/Machines/AtariST/Video.cpp +++ b/Machines/AtariST/Video.cpp @@ -167,6 +167,7 @@ HalfCycles Video::get_next_sequence_point() { } else if(y >= mode_params.final_video_line ) { vertical_lines = mode_params.first_video_line + mode_params.lines_per_frame - y; } + if(horizontal_cycles < 0) ++vertical_lines; cycles_until_display_enable = HalfCycles(horizontal_cycles + vertical_lines * mode_params.line_length); }