diff --git a/Machines/Atari2600.cpp b/Machines/Atari2600.cpp index e904ba20d..502e456dc 100644 --- a/Machines/Atari2600.cpp +++ b/Machines/Atari2600.cpp @@ -54,9 +54,10 @@ void Machine::output_pixels(int count) // blank is decoded as 68 counts; sync and colour burst as 16 counts - // guesses, until I can find information: 26 cycles blank, 16 sync, 26 blank, 160 pixels - if(_horizontalTimer < 26) output_state(OutputState::Blank, nullptr); - else if (_horizontalTimer < 42) output_state(OutputState::Sync, nullptr); + // it'll be about 43 cycles from start of hsync to start of visible frame, so... + // guesses, until I can find information: 26 cycles blank, 16 sync, 40 blank, 160 pixels + if(_horizontalTimer < 13) output_state(OutputState::Blank, nullptr); + else if (_horizontalTimer < 39) output_state(OutputState::Sync, nullptr); else if (_horizontalTimer < 68) output_state(OutputState::Blank, nullptr); else { if(_vBlankEnabled) { diff --git a/Outputs/CRT.cpp b/Outputs/CRT.cpp index 2d0194da0..47f3b45ce 100644 --- a/Outputs/CRT.cpp +++ b/Outputs/CRT.cpp @@ -15,8 +15,8 @@ using namespace Outputs; CRT::CRT(int cycles_per_line, int height_of_display, int number_of_buffers, ...) { const int syncCapacityLineChargeThreshold = 3; - const int millisecondsHorizontalRetraceTime = 16; - const int scanlinesVerticalRetraceTime = 26; + const int millisecondsHorizontalRetraceTime = 7; // source: Dictionary of Video and Television Technology, p. 234 + const int scanlinesVerticalRetraceTime = 10; // source: ibid // store fundamental display configuration properties _height_of_display = height_of_display; @@ -113,11 +113,13 @@ CRT::SyncEvent CRT::next_vertical_sync_event(bool vsync_is_charging, int cycles_ CRT::SyncEvent CRT::next_horizontal_sync_event(bool hsync_is_requested, int cycles_to_run_for, int *cycles_advanced) { // do we recognise this hsync, thereby adjusting future time expectations? - if ((_horizontal_counter < _hsync_error_window || _horizontal_counter >= _expected_next_hsync - _hsync_error_window) && hsync_is_requested) { - _did_detect_hsync = true; + if(hsync_is_requested) { + if (_horizontal_counter < _hsync_error_window || _horizontal_counter >= _expected_next_hsync - _hsync_error_window) { + _did_detect_hsync = true; - int time_now = (_horizontal_counter < _hsync_error_window) ? _expected_next_hsync + _horizontal_counter : _horizontal_counter; - _expected_next_hsync = (_expected_next_hsync + time_now) >> 1; + int time_now = (_horizontal_counter < _hsync_error_window) ? _expected_next_hsync + _horizontal_counter : _horizontal_counter; + _expected_next_hsync = (_expected_next_hsync + time_now) >> 1; + } } SyncEvent proposedEvent = SyncEvent::None;