1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Reduces CRT chattiness.

This commit is contained in:
Thomas Harte 2018-11-03 23:47:41 -04:00
parent f6562de325
commit 05fb7db147
2 changed files with 11 additions and 5 deletions

View File

@ -78,7 +78,8 @@ class ScanTarget: public Outputs::Display::ScanTarget {
void set_modals(Modals) {} void set_modals(Modals) {}
Scan *get_scan() { Scan *get_scan() {
return &scan_; scans_.emplace_back();
return &scans_.back();
} }
uint8_t *allocate_write_area(size_t required_length, size_t required_alignment) { 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) { void submit(bool only_if_no_allocation_failures) {
scans_.clear();
} }
private: private:
Scan scan_; std::vector<Scan> scans_;
std::vector<uint8_t> write_area_; std::vector<uint8_t> write_area_;
}; };

View File

@ -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 bool is_output_run = ((type == Scan::Type::Level) || (type == Scan::Type::Data));
const auto total_cycles = number_of_cycles * time_multiplier_; const auto total_cycles = number_of_cycles * time_multiplier_;
bool did_output = false;
while(number_of_cycles) { 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); 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. // 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; hsync_requested = false;
vsync_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. // 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; 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 outputting, store the start location and
if(next_scan) { 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 // MARK: - stream feeding methods