From 83ed6a82cff072b2a30e8235ada300a2b6d9e775 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 18 May 2016 18:49:40 -0400 Subject: [PATCH] Fixed: asserting vertical blank doesn't affect underlying timing. --- Machines/Atari2600/Atari2600.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index 0f149b59e..46fd0d8de 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -129,6 +129,7 @@ void Machine::update_upcoming_events() } _objectCounter[c] = (_objectCounter[c] + 1)%160; +// if(c == 0) printf("."); } } @@ -243,11 +244,6 @@ void Machine::output_pixels(unsigned int count) state = (state = OutputState::Sync) ? OutputState::Blank : OutputState::Sync; } - // honour the vertical blank flag - if(_vBlankEnabled && state == OutputState::Pixel) { - state = OutputState::Blank; - } - // write that state as the one that will become effective in four clocks _upcomingEvents[(_upcomingEventsPointer+4)%number_of_upcoming_events].state = state; @@ -293,7 +289,8 @@ void Machine::output_pixels(unsigned int count) if(_hMoveFlags & (1 << c)) { _objectCounter[c] = (_objectCounter[c] + 1)%160; - _pixelCounter[c] ++; + _pixelCounter[c] ++; // TODO: this isn't always a straight increment +// if(c == 0) printf("+"); } } } @@ -301,10 +298,16 @@ void Machine::output_pixels(unsigned int count) // read that state state = _upcomingEvents[_upcomingEventsPointer].state; + OutputState actingState = state; + + // honour the vertical blank flag + if(_vBlankEnabled && state == OutputState::Pixel) { + actingState = OutputState::Blank; + } // decide what that means needs to be communicated to the CRT _lastOutputStateDuration++; - if(state != _lastOutputState) { + if(actingState != _lastOutputState) { switch(_lastOutputState) { case OutputState::Blank: _crt->output_blank(_lastOutputStateDuration); break; case OutputState::Sync: _crt->output_sync(_lastOutputStateDuration); break; @@ -312,9 +315,9 @@ void Machine::output_pixels(unsigned int count) case OutputState::Pixel: _crt->output_data(_lastOutputStateDuration, 1); break; } _lastOutputStateDuration = 0; - _lastOutputState = state; + _lastOutputState = actingState; - if(state == OutputState::Pixel) { + if(actingState == OutputState::Pixel) { _outputBuffer = _crt->allocate_write_area(160); } else { _outputBuffer = nullptr; @@ -339,6 +342,7 @@ void Machine::output_pixels(unsigned int count) _horizontalTimer = (_horizontalTimer + 1) % horizontalTimerPeriod; if(!_horizontalTimer) { +// printf("\n"); _vBlankExtend = false; set_ready_line(false); }