1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-27 18:55:48 +00:00

Looked up normal retrace time (it's a lot less than 16µs and 26 scanlines — more like 7 and 10) and that the visible portion of a line is defined to start about 12 µs after the start of hsync, put the first two numbers into my CRT to make that more accurate, then derived a newer guess about what the Atari 2600 does for each of its 228 cycles. The text version of a frame is now looking pretty good. So it's probably time to hit OpenGL and the OS X side of things. Though I'll have a quick look to find out whether I can learn the exact real Atari 2600 timings before moving on.

This commit is contained in:
Thomas Harte 2015-07-23 19:24:25 -04:00
parent 33c06baffa
commit d72287a776
2 changed files with 12 additions and 9 deletions

View File

@ -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) {

View File

@ -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;