From d72287a7761d6fabf3cb28fcedcb7d3a2fa17d14 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 23 Jul 2015 19:24:25 -0400 Subject: [PATCH] =?UTF-8?q?Looked=20up=20normal=20retrace=20time=20(it's?= =?UTF-8?q?=20a=20lot=20less=20than=2016=C2=B5s=20and=2026=20scanlines=20?= =?UTF-8?q?=E2=80=94=20more=20like=207=20and=2010)=20and=20that=20the=20vi?= =?UTF-8?q?sible=20portion=20of=20a=20line=20is=20defined=20to=20start=20a?= =?UTF-8?q?bout=2012=20=C2=B5s=20after=20the=20start=20of=20hsync,=20put?= =?UTF-8?q?=20the=20first=20two=20numbers=20into=20my=20CRT=20to=20make=20?= =?UTF-8?q?that=20more=20accurate,=20then=20derived=20a=20newer=20guess=20?= =?UTF-8?q?about=20what=20the=20Atari=202600=20does=20for=20each=20of=20it?= =?UTF-8?q?s=20228=20cycles.=20The=20text=20version=20of=20a=20frame=20is?= =?UTF-8?q?=20now=20looking=20pretty=20good.=20So=20it's=20probably=20time?= =?UTF-8?q?=20to=20hit=20OpenGL=20and=20the=20OS=20X=20side=20of=20things.?= =?UTF-8?q?=20Though=20I'll=20have=20a=20quick=20look=20to=20find=20out=20?= =?UTF-8?q?whether=20I=20can=20learn=20the=20exact=20real=20Atari=202600?= =?UTF-8?q?=20timings=20before=20moving=20on.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Machines/Atari2600.cpp | 7 ++++--- Outputs/CRT.cpp | 14 ++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) 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;