1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-22 12:33:29 +00:00

Stabilises display, albeit that top border mode now appears to be off.

This commit is contained in:
Thomas Harte 2021-06-15 21:31:07 -04:00
parent 6a7eb832cc
commit 6c9dacbe89

View File

@ -105,6 +105,18 @@ void Nick::run_for(HalfCycles duration) {
++fetch_spot;
}
// Special: set mode as soon as it's known. It'll be needed at the end of HSYNC.
if(!window) {
mode_ = Mode((line_parameters_[1] >> 1)&7);
if(mode_ == Mode::Vsync) {
state_ = State::Blank;
} else {
// The first ten windows are occupied by the horizontal sync and
// colour burst; if left signalled before then, begin in pixels.
state_ = left_margin_ > 10 ? State::Border : State::Pixels;
}
}
// If all parameters have been loaded, set appropriate fields.
if(fetch_spot == 8) {
should_reload_line_parameters_ = false;
@ -117,21 +129,13 @@ void Nick::run_for(HalfCycles duration) {
line_data_pointer_[1] = uint16_t(line_parameters_[6] | (line_parameters_[7] << 8));
// Set the output mode and margin.
mode_ = Mode((line_parameters_[1] >> 1)&7);
left_margin_ = line_parameters_[2] & 0x3f;
right_margin_ = line_parameters_[3] & 0x3f;
if(mode_ == Mode::Vsync) {
state_ = State::Blank;
} else {
// The first ten windows are occupied by the horizontal sync and
// colour burst; if left signalled before then, begin in pixels.
state_ = left_margin_ > 10 ? State::Border : State::Pixels;
}
}
}
// HSYNC is signalled for four windows at the start of the line.
// I currently belive this happens regardless of Vsync mode.
if(window < 4 && end_window >= 4) {
crt_.output_sync(4);
window = 4;
@ -139,6 +143,7 @@ void Nick::run_for(HalfCycles duration) {
// Deal with vsync mode out here.
if(mode_ == Mode::Vsync) {
if(window >= 4) {
while(window < end_window) {
int next_event = end_window;
if(window < left_margin_) next_event = std::min(next_event, left_margin_);
@ -154,6 +159,7 @@ void Nick::run_for(HalfCycles duration) {
if(window == left_margin_) state_ = State::Sync;
if(window == right_margin_) state_ = State::Blank;
}
}
} else {
// If present then the colour burst is output for the period from
// the start of window 6 to the end of window 10.
@ -163,6 +169,7 @@ void Nick::run_for(HalfCycles duration) {
window = 10;
}
if(window >= 10) {
while(window < end_window) {
int next_event = end_window;
if(window < left_margin_) next_event = std::min(next_event, left_margin_);
@ -190,6 +197,7 @@ void Nick::run_for(HalfCycles duration) {
// TODO: probably output pixels here?
}
}
}
// Finish up the line.
if(!horizontal_counter_) {