From e7bf0799b6355c92d8ed3a057ec06cf8be21cf3a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 21 Sep 2019 17:25:20 -0400 Subject: [PATCH] Implements every-other-cycle-during-pixels RAM timing. --- Machines/Apple/Macintosh/Macintosh.cpp | 12 ++++++------ Machines/Apple/Macintosh/Video.cpp | 12 ------------ Machines/Apple/Macintosh/Video.hpp | 13 ++++++++++++- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Machines/Apple/Macintosh/Macintosh.cpp b/Machines/Apple/Macintosh/Macintosh.cpp index 0915abed9..7aad02719 100644 --- a/Machines/Apple/Macintosh/Macintosh.cpp +++ b/Machines/Apple/Macintosh/Macintosh.cpp @@ -337,12 +337,12 @@ template class ConcreteMachin memory_base = ram_.data(); word_address &= ram_mask_; - // Apply a delay due to video contention if applicable; technically this is - // incorrectly placed — strictly speaking here I'm extending the part of the - // bus cycle after DTACK rather than delaying DTACK. But it adds up to the - // same thing. - if(ram_subcycle_ < 4) { - delay = HalfCycles(4 - ram_subcycle_); + // Apply a delay due to video contention if applicable; scheme applied: + // only every other access slot is available during the period of video + // output. I believe this to be correct for the 128k, 512k and Plus. + // More research to do on other models. + if(video_is_outputting() && ram_subcycle_ < 8) { + delay = HalfCycles(8 - ram_subcycle_); advance_time(delay); } } break; diff --git a/Machines/Apple/Macintosh/Video.cpp b/Machines/Apple/Macintosh/Video.cpp index e1b3254c8..07de6fab9 100644 --- a/Machines/Apple/Macintosh/Video.cpp +++ b/Machines/Apple/Macintosh/Video.cpp @@ -14,11 +14,6 @@ using namespace Apple::Macintosh; namespace { -const HalfCycles line_length(704); -const int number_of_lines = 370; -const HalfCycles frame_length(line_length * HalfCycles(number_of_lines)); -const int sync_start = 36; -const int sync_end = 38; } @@ -183,13 +178,6 @@ HalfCycles Video::get_next_sequence_point() { } } -bool Video::is_outputting(HalfCycles offset) { - const auto offset_position = frame_position_ + offset % frame_length; - const int column = (offset_position % line_length).as_int() >> 4; - const int line = (offset_position / line_length).as_int(); - return line < 342 && column < 32; -} - void Video::set_use_alternate_buffers(bool use_alternate_screen_buffer, bool use_alternate_audio_buffer) { use_alternate_screen_buffer_ = use_alternate_screen_buffer; use_alternate_audio_buffer_ = use_alternate_audio_buffer; diff --git a/Machines/Apple/Macintosh/Video.hpp b/Machines/Apple/Macintosh/Video.hpp index ab4d0bac8..cc719f321 100644 --- a/Machines/Apple/Macintosh/Video.hpp +++ b/Machines/Apple/Macintosh/Video.hpp @@ -17,6 +17,12 @@ namespace Apple { namespace Macintosh { +static const HalfCycles line_length(704); +static const int number_of_lines = 370; +static const HalfCycles frame_length(line_length * HalfCycles(number_of_lines)); +static const int sync_start = 36; +static const int sync_end = 38; + /*! Models the 68000-era Macintosh video hardware, producing a 512x348 pixel image, within a total scanning area of 370 lines, at 352 cycles per line. @@ -61,7 +67,12 @@ class Video { @returns @c true if in @c offset half cycles from now, the video will be outputting pixels; @c false otherwise. */ - bool is_outputting(HalfCycles offset = HalfCycles(0)); + bool is_outputting(HalfCycles offset = HalfCycles(0)) { + const auto offset_position = frame_position_ + offset % frame_length; + const int column = (offset_position % line_length).as_int() >> 4; + const int line = (offset_position / line_length).as_int(); + return line < 342 && column < 32; + } /*! @returns the amount of time until there is next a transition on the