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

Moves vertical state decisions back to cycle 502.

This commit is contained in:
Thomas Harte 2019-11-08 21:42:05 -05:00
parent 7caef46c05
commit d1259f829e
2 changed files with 23 additions and 16 deletions

View File

@ -213,6 +213,25 @@ void Video::run_for(HalfCycles duration) {
// Check for whether line length should have been latched during this run.
if(x <= 54*2 && (x + run_length) > 54*2) line_length_ = horizontal_timings.length;
// Make a decision about vertical state on cycle 502.
if(x <= 502*2 && (x + run_length) > 502*2) {
next_y = y + 1;
next_vertical_ = vertical_;
// Use vertical_parameters to get parameters for the current output frequency.
if(y == vertical_timings.set_enable) {
next_vertical_.enable = true;
} else if(y == vertical_timings.reset_enable) {
next_vertical_.enable = false;
} else if(y == vertical_timings.height) {
next_y = 0;
next_vertical_.sync = true;
current_address_ = base_address_ >> 1;
} else if(y == 3) {
next_vertical_.sync = false;
}
}
// Apply the next event.
x += run_length;
integer_duration -= run_length;
@ -228,20 +247,8 @@ void Video::run_for(HalfCycles duration) {
// the vertical bits of state.
if(x == line_length_) {
x = 0;
++y;
// Use vertical_parameters to get parameters for the current output frequency.
if(y == vertical_timings.set_enable) {
vertical_.enable = true;
} else if(y == vertical_timings.reset_enable) {
vertical_.enable = false;
} else if(y == vertical_timings.height) {
y = 0;
vertical_.sync = true;
current_address_ = base_address_ >> 1;
} else if(y == 3) {
vertical_.sync = false;
}
vertical_ = next_vertical_;
y = next_y;
}
}
}

View File

@ -59,7 +59,7 @@ class Video {
uint16_t *ram_;
uint16_t line_buffer_[256];
int x = 0, y = 0;
int x = 0, y = 0, next_y = 0;
void output_border(int duration);
uint16_t video_mode_ = 0;
@ -75,7 +75,7 @@ class Video {
bool enable = false;
bool blank = false;
bool sync = false;
} horizontal_, vertical_;
} horizontal_, vertical_, next_vertical_;
int line_length_ = 1024;
int data_latch_position_ = 0;