From 98efae2536085eb64ed39ddfd4efd37862426734 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 30 Jul 2015 17:16:49 -0400 Subject: [PATCH] =?UTF-8?q?Reintroduced=20emergency=20vertical=20sync=20?= =?UTF-8?q?=E2=80=94=20so=20that=20output=20occurs=20even=20when=20the=20e?= =?UTF-8?q?mulation=20isn't=20catching=20syncs=20properly=20=E2=80=94=20an?= =?UTF-8?q?d=20switched=20some=20spaces=20to=20tabs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Machines/Atari2600.cpp | 22 +++++++++---------- Machines/Atari2600.hpp | 2 +- .../Mac/Clock Signal/Atari2600Document.swift | 2 +- Outputs/CRT.cpp | 15 +++++-------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Machines/Atari2600.cpp b/Machines/Atari2600.cpp index 40cd0ae36..17f004a6a 100644 --- a/Machines/Atari2600.cpp +++ b/Machines/Atari2600.cpp @@ -20,7 +20,7 @@ Machine::Machine() _lastOutputStateDuration = 0; _lastOutputState = OutputState::Sync; _crt = new Outputs::CRT(228, 256, 1, 4); - _piaTimerStatus = 0xff; + _piaTimerStatus = 0xff; reset(); } @@ -273,12 +273,12 @@ int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t add if ((address&0x1280) == 0x280) { if(isReadOperation(operation)) { switch(address & 0xf) { - case 0x04: returnValue &= _piaTimerValue >> _piaTimerShift; break; - case 0x05: returnValue &= _piaTimerStatus; _piaTimerStatus &= ~0x40; break; + case 0x04: returnValue &= _piaTimerValue >> _piaTimerShift; break; + case 0x05: returnValue &= _piaTimerStatus; _piaTimerStatus &= ~0x40; break; } } else { switch(address & 0x0f) { - case 0x04: _piaTimerShift = 0; _piaTimerValue = *value << 0; _piaTimerStatus &= ~0xc0; break; + case 0x04: _piaTimerShift = 0; _piaTimerValue = *value << 0; _piaTimerStatus &= ~0xc0; break; case 0x05: _piaTimerShift = 3; _piaTimerValue = *value << 3; _piaTimerStatus &= ~0xc0; break; case 0x06: _piaTimerShift = 6; _piaTimerValue = *value << 6; _piaTimerStatus &= ~0xc0; break; case 0x07: _piaTimerShift = 10; _piaTimerValue = *value << 10; _piaTimerStatus &= ~0xc0; break; @@ -291,13 +291,13 @@ int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t add *value = returnValue; } - if(_piaTimerValue < cycle_count) { - _piaTimerValue = 0x100 - cycle_count + _piaTimerValue; - _piaTimerShift = 0; - _piaTimerStatus |= 0xc0; - } - else - _piaTimerValue -= cycle_count; + if(_piaTimerValue < cycle_count) { + _piaTimerValue = 0x100 - cycle_count + _piaTimerValue; + _piaTimerShift = 0; + _piaTimerStatus |= 0xc0; + } + else + _piaTimerValue -= cycle_count; return cycle_count; } diff --git a/Machines/Atari2600.hpp b/Machines/Atari2600.hpp index 5923c5f11..8bd92e717 100644 --- a/Machines/Atari2600.hpp +++ b/Machines/Atari2600.hpp @@ -37,7 +37,7 @@ class Machine: public CPU6502::Processor { // the timer unsigned int _piaTimerValue; unsigned int _piaTimerShift; - uint8_t _piaTimerStatus; + uint8_t _piaTimerStatus; // graphics registers uint8_t _playfield[3], _playfieldControl; diff --git a/OSBindings/Mac/Clock Signal/Atari2600Document.swift b/OSBindings/Mac/Clock Signal/Atari2600Document.swift index ca15414f4..f3b611bba 100644 --- a/OSBindings/Mac/Clock Signal/Atari2600Document.swift +++ b/OSBindings/Mac/Clock Signal/Atari2600Document.swift @@ -11,7 +11,7 @@ import Cocoa class Atari2600Document: NSDocument, CSCathodeRayViewDelegate { override init() { - super.init() + super.init() // Add your subclass-specific initialization here. } diff --git a/Outputs/CRT.cpp b/Outputs/CRT.cpp index 05b3c8804..b93eaecf7 100644 --- a/Outputs/CRT.cpp +++ b/Outputs/CRT.cpp @@ -22,6 +22,7 @@ CRT::CRT(int cycles_per_line, int height_of_display, int number_of_buffers, ...) const int scanlinesVerticalRetraceTime = 10; // source: ibid _time_multiplier = (1000 + cycles_per_line - 1) / cycles_per_line; + height_of_display += (height_of_display / 20); // this is the overrun area we'll use to // store fundamental display configuration properties _height_of_display = height_of_display;// + (height_of_display / 10); @@ -105,14 +106,10 @@ CRT::SyncEvent CRT::next_vertical_sync_event(bool vsync_is_charging, int cycles_ int proposedSyncTime = cycles_to_run_for; // have we overrun the maximum permitted number of horizontal syncs for this frame? -// if (!_vretrace_counter) -// { -// float raster_distance = _scanSpeed.y * proposedSyncTime; -// if(_rasterPosition.y < 1.02f && _rasterPosition.y + raster_distance >= 1.02f) { -// proposedSyncTime = (int)(1.02f - _rasterPosition.y) / _scanSpeed.y; -// proposedEvent = SyncEvent::StartVSync; -// } -// } + if (!_vretrace_counter && _rasterPosition.y == 0xffffffff) { + proposedSyncTime = 0; + proposedEvent = SyncEvent::StartVSync; + } // will an acceptable vertical sync be triggered? if (vsync_is_charging && !_vretrace_counter) { @@ -430,7 +427,7 @@ void CRTFrameBuilder::allocate_write_area(int required_length) _write_x_position = _next_write_x_position; _write_y_position = _next_write_y_position; - _write_target_pointer = (_write_y_position * frame.size.width) + _write_x_position; + _write_target_pointer = (_write_y_position * frame.size.width) + _write_x_position; _next_write_x_position += required_length; frame.dirty_size.width = std::max(frame.dirty_size.width, _next_write_x_position); }