1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-16 22:28:57 +00:00

Corrects output glitches: channel de sync and improper border beginnings.

This commit is contained in:
Thomas Harte 2019-11-06 22:37:05 -05:00
parent 0971bbeebe
commit ec68bc5047

View File

@ -138,9 +138,11 @@ void Video::run_for(HalfCycles duration) {
} else { } else {
if(run_length < 32) { if(run_length < 32) {
shift_out(run_length); // TODO: this might end up overrunning. shift_out(run_length); // TODO: this might end up overrunning.
if(!output_shifter) pixel_buffer_.flush(crt_);
} else { } else {
shift_out(32); shift_out(32);
output_shifter = 0; output_shifter = 0;
pixel_buffer_.flush(crt_);
output_border(run_length - 32); output_border(run_length - 32);
} }
} }
@ -152,6 +154,12 @@ void Video::run_for(HalfCycles duration) {
int start_column = x >> 3; int start_column = x >> 3;
const int end_column = (x + run_length) >> 3; const int end_column = (x + run_length) >> 3;
// Rules obeyed below:
//
// Video fetches occur as the first act of business in a column. Each
// fetch is then followed by 8 shift clocks. Whether or not the shifter
// was reloaded by the fetch depends on the FIFO.
if(start_column == end_column) { if(start_column == end_column) {
shift_out(run_length); shift_out(run_length);
} else { } else {
@ -162,18 +170,18 @@ void Video::run_for(HalfCycles duration) {
// so go for the entirety of it. // so go for the entirety of it.
shift_out(8 - (x & 7)); shift_out(8 - (x & 7));
++start_column; ++start_column;
latch_word();
} }
// Run for all columns that have their starts in this time period. // Run for all columns that have their starts in this time period.
int complete_columns = end_column - start_column; int complete_columns = end_column - start_column;
while(complete_columns--) { while(complete_columns--) {
latch_word();
shift_out(8); shift_out(8);
latch_word();
} }
// Output the start of the next column, if necessary. // Output the start of the next column, if necessary.
if(start_column != end_column && (x + run_length) & 7) { if(start_column != end_column && (x + run_length) & 7) {
latch_word();
shift_out((x + run_length) & 7); shift_out((x + run_length) & 7);
} }
} }