From 05fb7db147252dfe03d10e7101ccbaf5f548c278 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 3 Nov 2018 23:47:41 -0400 Subject: [PATCH] Reduces CRT chattiness. --- OSBindings/Mac/Clock Signal/Machine/CSMachine.mm | 6 ++++-- Outputs/CRT/CRT.cpp | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm index b3b7c7bba..824eedfc1 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm @@ -78,7 +78,8 @@ class ScanTarget: public Outputs::Display::ScanTarget { void set_modals(Modals) {} Scan *get_scan() { - return &scan_; + scans_.emplace_back(); + return &scans_.back(); } uint8_t *allocate_write_area(size_t required_length, size_t required_alignment) { @@ -87,10 +88,11 @@ class ScanTarget: public Outputs::Display::ScanTarget { } void submit(bool only_if_no_allocation_failures) { + scans_.clear(); } private: - Scan scan_; + std::vector scans_; std::vector write_area_; }; diff --git a/Outputs/CRT/CRT.cpp b/Outputs/CRT/CRT.cpp index 61e0067bf..9fd56ede3 100644 --- a/Outputs/CRT/CRT.cpp +++ b/Outputs/CRT/CRT.cpp @@ -134,6 +134,7 @@ void CRT::advance_cycles(int number_of_cycles, bool hsync_requested, bool vsync_ const bool is_output_run = ((type == Scan::Type::Level) || (type == Scan::Type::Data)); const auto total_cycles = number_of_cycles * time_multiplier_; + bool did_output = false; while(number_of_cycles) { @@ -143,14 +144,15 @@ void CRT::advance_cycles(int number_of_cycles, bool hsync_requested, bool vsync_ Flywheel::SyncEvent next_horizontal_sync_event = get_next_horizontal_sync_event(hsync_requested, time_until_vertical_sync_event, &time_until_horizontal_sync_event); // Whichever event is scheduled to happen first is the one to advance to. - int next_run_length = std::min(time_until_vertical_sync_event, time_until_horizontal_sync_event); + const int next_run_length = std::min(time_until_vertical_sync_event, time_until_horizontal_sync_event); hsync_requested = false; vsync_requested = false; // Determine whether to output any data for this portion of the output; if so then grab somewhere to put it. - bool is_output_segment = ((is_output_run && next_run_length) && !horizontal_flywheel_->is_in_retrace() && !vertical_flywheel_->is_in_retrace()); + const bool is_output_segment = ((is_output_run && next_run_length) && !horizontal_flywheel_->is_in_retrace() && !vertical_flywheel_->is_in_retrace()); Outputs::Display::ScanTarget::Scan *const next_scan = is_output_segment ? scan_target_->get_scan() : nullptr; + did_output |= is_output_segment; // If outputting, store the start location and if(next_scan) { @@ -202,7 +204,9 @@ void CRT::advance_cycles(int number_of_cycles, bool hsync_requested, bool vsync_ } } - scan_target_->submit(); + if(did_output) { + scan_target_->submit(); + } } // MARK: - stream feeding methods