From a9e26d7808cfe5bdea1fcce26ba66720dcbe7e95 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 23 Jan 2016 17:49:25 -0500 Subject: [PATCH] Introduced a scan's delay, as intended. --- Outputs/CRT.cpp | 28 +++++++++++----------------- Outputs/CRT.hpp | 4 ++-- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Outputs/CRT.cpp b/Outputs/CRT.cpp index 9e5b73204..80558c48b 100644 --- a/Outputs/CRT.cpp +++ b/Outputs/CRT.cpp @@ -170,18 +170,11 @@ CRT::SyncEvent CRT::get_next_horizontal_sync_event(bool hsync_is_requested, unsi return proposedEvent; } -void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divider, bool hsync_requested, bool vsync_requested, const bool vsync_charging, const Type type) +void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divider, bool hsync_requested, bool vsync_requested, const bool vsync_charging, const Type type, uint16_t tex_x, uint16_t tex_y) { number_of_cycles *= _time_multiplier; bool is_output_run = ((type == Type::Level) || (type == Type::Data)); - uint16_t tex_x = 0; - uint16_t tex_y = 0; - - if(is_output_run && _current_frame_builder) { - tex_x = _current_frame_builder->_write_x_position; - tex_y = _current_frame_builder->_write_y_position; - } while(number_of_cycles) { @@ -344,16 +337,17 @@ void CRT::set_delegate(Delegate *delegate) #pragma mark - stream feeding methods -void CRT::output_scan(Scan *scan) +void CRT::output_scan() { + _next_scan ^= 1; + Scan *scan = &_scans[_next_scan]; + bool this_is_sync = (scan->type == Type::Sync); bool hsync_requested = !_is_receiving_sync && this_is_sync; bool vsync_requested = _is_receiving_sync; _is_receiving_sync = this_is_sync; - advance_cycles(scan->number_of_cycles, scan->source_divider, hsync_requested, vsync_requested, this_is_sync, scan->type); - - _next_scan ^= 1; + advance_cycles(scan->number_of_cycles, scan->source_divider, hsync_requested, vsync_requested, this_is_sync, scan->type, scan->tex_x, scan->tex_y); } /* @@ -363,14 +357,14 @@ void CRT::output_sync(unsigned int number_of_cycles) { _scans[_next_scan].type = Type::Sync; _scans[_next_scan].number_of_cycles = number_of_cycles; - output_scan(&_scans[_next_scan]); + output_scan(); } void CRT::output_blank(unsigned int number_of_cycles) { _scans[_next_scan].type = Type::Blank; _scans[_next_scan].number_of_cycles = number_of_cycles; - output_scan(&_scans[_next_scan]); + output_scan(); } void CRT::output_level(unsigned int number_of_cycles) @@ -379,7 +373,7 @@ void CRT::output_level(unsigned int number_of_cycles) _scans[_next_scan].number_of_cycles = number_of_cycles; _scans[_next_scan].tex_x = _current_frame_builder ? _current_frame_builder->_write_x_position : 0; _scans[_next_scan].tex_y = _current_frame_builder ? _current_frame_builder->_write_y_position : 0; - output_scan(&_scans[_next_scan]); + output_scan(); } void CRT::output_colour_burst(unsigned int number_of_cycles, uint8_t phase, uint8_t magnitude) @@ -388,7 +382,7 @@ void CRT::output_colour_burst(unsigned int number_of_cycles, uint8_t phase, uint _scans[_next_scan].number_of_cycles = number_of_cycles; _scans[_next_scan].phase = phase; _scans[_next_scan].magnitude = magnitude; - output_scan(&_scans[_next_scan]); + output_scan(); } void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider) @@ -398,7 +392,7 @@ void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider _scans[_next_scan].tex_x = _current_frame_builder ? _current_frame_builder->_write_x_position : 0; _scans[_next_scan].tex_y = _current_frame_builder ? _current_frame_builder->_write_y_position : 0; _scans[_next_scan].source_divider = source_divider; - output_scan(&_scans[_next_scan]); + output_scan(); } #pragma mark - Buffer supply diff --git a/Outputs/CRT.hpp b/Outputs/CRT.hpp index 865e9dda7..dd17d6b28 100644 --- a/Outputs/CRT.hpp +++ b/Outputs/CRT.hpp @@ -146,7 +146,7 @@ class CRT { enum Type { Sync, Level, Data, Blank, ColourBurst } type; - void advance_cycles(unsigned int number_of_cycles, unsigned int source_divider, bool hsync_requested, bool vsync_requested, bool vsync_charging, Type type); + void advance_cycles(unsigned int number_of_cycles, unsigned int source_divider, bool hsync_requested, bool vsync_requested, const bool vsync_charging, const Type type, uint16_t tex_x, uint16_t tex_y); // the inner entry point that determines whether and when the next sync event will occur within // the current output window @@ -173,7 +173,7 @@ class CRT { }; } _scans[2]; int _next_scan; - void output_scan(Scan *scan); + void output_scan(); }; }