From f894d431116beab6318d208ac486e0daedd27db7 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 27 Jul 2019 22:23:40 -0400 Subject: [PATCH] Removes the video and audio base address latches. It now seems to me that these take effect immediately. --- Machines/Apple/Macintosh/Macintosh.cpp | 1 + Machines/Apple/Macintosh/Video.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Machines/Apple/Macintosh/Macintosh.cpp b/Machines/Apple/Macintosh/Macintosh.cpp index 6ae210205..802288ad9 100644 --- a/Machines/Apple/Macintosh/Macintosh.cpp +++ b/Machines/Apple/Macintosh/Macintosh.cpp @@ -405,6 +405,7 @@ template class ConcreteMachin } void set_use_alternate_buffers(bool use_alternate_screen_buffer, bool use_alternate_audio_buffer) { + update_video(); video_.set_use_alternate_buffers(use_alternate_screen_buffer, use_alternate_audio_buffer); } diff --git a/Machines/Apple/Macintosh/Video.cpp b/Machines/Apple/Macintosh/Video.cpp index 77cdcc5b9..0ab4ae4c5 100644 --- a/Machines/Apple/Macintosh/Video.cpp +++ b/Machines/Apple/Macintosh/Video.cpp @@ -49,6 +49,9 @@ void Video::set_scan_target(Outputs::Display::ScanTarget *scan_target) { } void Video::run_for(HalfCycles duration) { + // Determine the current video and audio bases. These values don't appear to be latched, they apply immediately. + const size_t video_base = (use_alternate_screen_buffer_ ? (0xffff2700 >> 1) : (0xffffa700 >> 1)) & ram_mask_; + const size_t audio_base = (use_alternate_audio_buffer_ ? (0xffffa100 >> 1) : (0xfffffd00 >> 1)) & ram_mask_; // The number of HalfCycles is literally the number of pixel clocks to move through, // since pixel output occurs at twice the processor clock. So divide by 16 to get @@ -85,7 +88,7 @@ void Video::run_for(HalfCycles duration) { if(pixel_buffer_) { for(int c = first_word; c < final_pixel_word; ++c) { - uint16_t pixels = ram_[video_address_] ^ 0xffff; + uint16_t pixels = ram_[video_base + video_address_] ^ 0xffff; ++video_address_; pixel_buffer_[15] = pixels & 0x01; @@ -135,7 +138,7 @@ void Video::run_for(HalfCycles duration) { // Audio and disk fetches occur "just before video data". if(final_word == 44) { - const uint16_t audio_word = ram_[audio_address_]; + const uint16_t audio_word = ram_[audio_address_ + audio_base]; ++audio_address_; audio_.audio.post_sample(audio_word >> 8); drive_speed_accumulator_.post_sample(audio_word & 0xff); @@ -149,13 +152,13 @@ void Video::run_for(HalfCycles duration) { /* Video: $1A700 and the alternate buffer starts at $12700; for a 512K Macintosh, add $60000 to these numbers. */ - video_address_ = (use_alternate_screen_buffer_ ? (0xffff2700 >> 1) : (0xffffa700 >> 1)) & ram_mask_; + video_address_ = 0; /* "The main sound buffer is at $1FD00 in a 128K Macintosh, and the alternate buffer is at $1A100; for a 512K Macintosh, add $60000 to these values." */ - audio_address_ = (use_alternate_audio_buffer_ ? (0xffffa100 >> 1) : (0xfffffd00 >> 1)) & ram_mask_; + audio_address_ = 0; } } }