1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-16 19:08:08 +00:00

Reduces code duplication slightly.

This commit is contained in:
Thomas Harte 2021-03-21 20:34:58 -04:00
parent 388b136980
commit 6482303063

View File

@ -103,36 +103,14 @@ template <VideoTiming timing> class Video {
if(line < 3) {
// Output sync line.
crt_.output_sync(cycles_this_line);
} else if((line < first_line) || (line >= first_line+192)) {
} else {
if((line < first_line) || (line >= first_line+192)) {
// Output plain border line.
if(offset < sync_position) {
const int border_duration = std::min(sync_position, end_offset) - offset;
output_border(border_duration);
offset += border_duration;
}
if(offset >= sync_position && offset < sync_position + sync_length && end_offset > offset) {
const int sync_duration = std::min(sync_position + sync_length, end_offset) - offset;
crt_.output_sync(sync_duration);
offset += sync_duration;
}
if(offset >= sync_position + sync_length && offset < burst_position && end_offset > offset) {
const int blank_duration = std::min(burst_position, end_offset) - offset;
crt_.output_blank(blank_duration);
offset += blank_duration;
}
if(offset >= burst_position && offset < burst_position+burst_length && end_offset > offset) {
const int burst_duration = std::min(burst_position + burst_length, end_offset) - offset;
crt_.output_colour_burst(burst_duration, line, is_alternate_line_);
offset += burst_duration;
}
if(offset >= burst_position+burst_length && end_offset > offset) {
const int border_duration = end_offset - offset;
output_border(border_duration);
}
} else {
// Output pixel line.
if(offset < 256) {
@ -187,6 +165,9 @@ template <VideoTiming timing> class Video {
output_border(border_duration);
offset += border_duration;
}
}
// Output the common tail to border and pixel lines: sync, blank, colour burst, border.
if(offset >= sync_position && offset < sync_position + sync_length && end_offset > offset) {
const int sync_duration = std::min(sync_position + sync_length, end_offset) - offset;