From 0e29c6b0ab47d3cc0b754a0b18a771e4882e180c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 28 Jan 2020 23:26:37 -0500 Subject: [PATCH] On further reflection, I think events should occur after the running period. I'm testing this now for sanity in 2/4bpp mode. --- Machines/Atari/ST/AtariST.cpp | 2 +- Machines/Atari/ST/Video.cpp | 46 ++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Machines/Atari/ST/AtariST.cpp b/Machines/Atari/ST/AtariST.cpp index bcf0c09d6..187ee2af1 100644 --- a/Machines/Atari/ST/AtariST.cpp +++ b/Machines/Atari/ST/AtariST.cpp @@ -567,7 +567,7 @@ class ConcreteMachine: GPIP 0: centronics busy */ mfp_->set_port_input( - 0x00 | // b7: Monochrome monitor detect (0 = is monochrome). + 0x80 | // b7: Monochrome monitor detect (0 = is monochrome). 0x40 | // b6: RS-232 ring indicator. (dma_->get_interrupt_line() ? 0x00 : 0x20) | // b5: FD/HS interrupt (0 = interrupt requested). ((keyboard_acia_->get_interrupt_line() || midi_acia_->get_interrupt_line()) ? 0x00 : 0x10) | // b4: Keyboard/MIDI interrupt (0 = interrupt requested). diff --git a/Machines/Atari/ST/Video.cpp b/Machines/Atari/ST/Video.cpp index f96e00abc..df2bea066 100644 --- a/Machines/Atari/ST/Video.cpp +++ b/Machines/Atari/ST/Video.cpp @@ -120,13 +120,13 @@ const int vsync_delay_period = hsync_delay_period; // Signal vsync with the same Video::Video() : deferrer_([=] (HalfCycles duration) { advance(duration); }), -// crt_(2048, 2, Outputs::Display::Type::PAL50, Outputs::Display::InputDataType::Red4Green4Blue4), - crt_(896, 1, 500, Outputs::Display::ColourSpace::YIQ, 100, 50, 5, false, Outputs::Display::InputDataType::Red4Green4Blue4), + crt_(2048, 2, Outputs::Display::Type::PAL50, Outputs::Display::InputDataType::Red4Green4Blue4), +// crt_(896, 1, 500, Outputs::Display::ColourSpace::YIQ, 100, 50, 5, false, Outputs::Display::InputDataType::Red4Green4Blue4), video_stream_(crt_, palette_) { // Show a total of 260 lines; a little short for PAL but a compromise between that and the ST's // usual output height of 200 lines. -// crt_.set_visible_area(crt_.get_rect_for_area(33, 260, 440, 1700, 4.0f / 3.0f)); + crt_.set_visible_area(crt_.get_rect_for_area(33, 260, 440, 1700, 4.0f / 3.0f)); } void Video::set_ram(uint16_t *ram, size_t size) { @@ -154,25 +154,6 @@ void Video::advance(HalfCycles duration) { const auto vertical_timings = vertical_parameters(field_frequency_); int integer_duration = int(duration.as_integral()); - // Effect any changes in visible state out here; they're not relevant in the inner loop. - if(!pending_events_.empty()) { - auto erase_iterator = pending_events_.begin(); - int duration_remaining = integer_duration; - while(erase_iterator != pending_events_.end()) { - erase_iterator->delay -= duration_remaining; - if(erase_iterator->delay <= 0) { - duration_remaining = -erase_iterator->delay; - erase_iterator->apply(public_state_); - ++erase_iterator; - } else { - break; - } - } - if(erase_iterator != pending_events_.begin()) { - pending_events_.erase(pending_events_.begin(), erase_iterator); - } - } - while(integer_duration) { // Seed next event to end of line. int next_event = line_length_.length; @@ -362,6 +343,27 @@ void Video::advance(HalfCycles duration) { add_event(vsync_delay_period - integer_duration, vertical_.sync ? Event::Type::SetVsync : Event::Type::ResetVsync); } } + + // Effect any changes in visible state out here; they've been supplied as sequence points, so + // a conforming caller can't hit them within the inner loop. + integer_duration = int(duration.as_integral()); + if(!pending_events_.empty()) { + auto erase_iterator = pending_events_.begin(); + int duration_remaining = integer_duration; + while(erase_iterator != pending_events_.end()) { + erase_iterator->delay -= duration_remaining; + if(erase_iterator->delay <= 0) { + duration_remaining = -erase_iterator->delay; + erase_iterator->apply(public_state_); + ++erase_iterator; + } else { + break; + } + } + if(erase_iterator != pending_events_.begin()) { + pending_events_.erase(pending_events_.begin(), erase_iterator); + } + } } void Video::push_latched_data() {