From debdad350d80222815154bb0750ef0c550795c5d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 2 Feb 2023 12:03:33 -0500 Subject: [PATCH] Don't allow a disabled screen to interfere with Yamaha addressing. --- Components/9918/Implementation/9918.cpp | 9 +++++---- Components/9918/Implementation/9918Base.hpp | 13 ++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index 871a21bcc..730a4c639 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -308,7 +308,8 @@ void TMS9918::run_for(const HalfCycles cycles) { // Establish the current screen output mode, which will be captured as a // line mode momentarily. - this->screen_mode_ = this->current_screen_mode(); + this->screen_mode_ = this->template current_screen_mode(); + this->underlying_mode_ = this->template current_screen_mode(); // Based on the output mode, pick a line mode. next_line_buffer.first_pixel_output_column = Timing::FirstPixelCycle; @@ -723,7 +724,7 @@ void Base::commit_register(int reg, uint8_t value) { // b5: enable light pen interrupts // b6: set colour bus to input or output mode - LOG("Screen mode: " << int(current_screen_mode())); + LOG("Screen mode: " << int(current_screen_mode())); break; case 1: @@ -733,7 +734,7 @@ void Base::commit_register(int reg, uint8_t value) { ((value & 0x08) >> 2) ); - LOG("Screen mode: " << int(current_screen_mode())); + LOG("Screen mode: " << int(current_screen_mode())); break; case 8: @@ -845,7 +846,7 @@ void Base::commit_register(int reg, uint8_t value) { Storage::command_ && Storage::command_->access == Command::AccessType::WaitForColourReceipt ) { - Storage::command_->advance(pixels_per_byte(this->screen_mode_)); + Storage::command_->advance(pixels_per_byte(this->underlying_mode_)); Storage::update_command_step(fetch_pointer_.column); } break; diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp index abb85a747..01da6f176 100644 --- a/Components/9918/Implementation/9918Base.hpp +++ b/Components/9918/Implementation/9918Base.hpp @@ -543,7 +543,7 @@ template struct Base: public Storage { bool enable_line_interrupts_ = false; bool line_interrupt_pending_ = false; - ScreenMode screen_mode_; + ScreenMode screen_mode_, underlying_mode_; LineBuffer line_buffers_[313]; void posit_sprite(LineBuffer &buffer, int sprite_number, int sprite_y, int screen_row); @@ -570,8 +570,8 @@ template struct Base: public Storage { void commit_register(int reg, uint8_t value); - ScreenMode current_screen_mode() const { - if(blank_display_) { + template ScreenMode current_screen_mode() const { + if(check_blank && blank_display_) { return ScreenMode::Blank; } @@ -737,13 +737,13 @@ template struct Base: public Storage { ram_[address] = Storage::command_latch_; - Storage::command_->advance(pixels_per_byte(this->screen_mode_)); + Storage::command_->advance(pixels_per_byte(this->underlying_mode_)); Storage::update_command_step(access_column); } break; case CommandStep::WriteByte: ram_[command_address()] = Storage::command_context_.colour; - Storage::command_->advance(pixels_per_byte(this->screen_mode_)); + Storage::command_->advance(pixels_per_byte(this->underlying_mode_)); Storage::update_command_step(access_column); break; } @@ -756,8 +756,7 @@ template struct Base: public Storage { ++ram_pointer_; if constexpr (is_yamaha_vdp(personality)) { - const ScreenMode mode = current_screen_mode(); - if(mode == ScreenMode::YamahaGraphics6 || mode == ScreenMode::YamahaGraphics7) { + if(this->underlying_mode_ == ScreenMode::YamahaGraphics6 || this->underlying_mode_ == ScreenMode::YamahaGraphics7) { // Rotate address one to the right as the hardware accesses // the underlying banks of memory alternately but presents // them as if linear.