mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-16 18:30:32 +00:00
Implements get_scan_status, but for scale being incorrect.
This commit is contained in:
parent
d97a073d1b
commit
82e5def7c4
@ -469,5 +469,9 @@ Outputs::Display::Rect CRT::get_rect_for_area(int first_line_after_sync, int num
|
||||
}
|
||||
|
||||
Outputs::Display::ScanStatus CRT::get_scan_status() const {
|
||||
return Outputs::Display::ScanStatus();
|
||||
Outputs::Display::ScanStatus status;
|
||||
status.field_duration = vertical_flywheel_->get_locked_period();
|
||||
status.field_duration_gradient = vertical_flywheel_->get_last_period_adjustment();
|
||||
status.current_position = float(vertical_flywheel_->get_current_output_position()) / float(vertical_flywheel_->get_locked_period());
|
||||
return status;
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ struct Flywheel {
|
||||
inline SyncEvent get_next_event_in_period(bool sync_is_requested, int cycles_to_run_for, int *cycles_advanced) {
|
||||
// If sync is signalled _now_, consider adjusting expected_next_sync_.
|
||||
if(sync_is_requested) {
|
||||
const auto last_sync = expected_next_sync_;
|
||||
if(counter_ < sync_error_window_ || counter_ > expected_next_sync_ - sync_error_window_) {
|
||||
const int time_now = (counter_ < sync_error_window_) ? expected_next_sync_ + counter_ : counter_;
|
||||
expected_next_sync_ = (3*expected_next_sync_ + time_now) >> 2;
|
||||
@ -75,6 +76,7 @@ struct Flywheel {
|
||||
expected_next_sync_ = (3*expected_next_sync_ + standard_period_ - sync_error_window_) >> 2;
|
||||
}
|
||||
}
|
||||
last_adjustment_ = expected_next_sync_ - last_sync;
|
||||
}
|
||||
|
||||
SyncEvent proposed_event = SyncEvent::None;
|
||||
@ -165,6 +167,20 @@ struct Flywheel {
|
||||
return standard_period_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@returns the actual current period for a complete scan (including retrace).
|
||||
*/
|
||||
inline int get_locked_period() {
|
||||
return expected_next_sync_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@returns the amount by which the @c locked_period was adjusted, the last time that an adjustment was applied.
|
||||
*/
|
||||
inline int get_last_period_adjustment() {
|
||||
return last_adjustment_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@returns the number of synchronisation events that have seemed surprising since the last time this method was called;
|
||||
a low number indicates good synchronisation.
|
||||
@ -195,6 +211,8 @@ struct Flywheel {
|
||||
|
||||
int number_of_surprises_ = 0; // a count of the surprising syncs
|
||||
|
||||
int last_adjustment_ = 0; // The amount by which
|
||||
|
||||
/*
|
||||
Implementation notes:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user