From dd5b4b484a4b43940b6b9a8f2327f4390905a5b5 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 7 Jan 2023 14:34:33 -0500 Subject: [PATCH] Avoid double responsibility for state. --- Components/9918/Implementation/9918.cpp | 2 +- Components/9918/Implementation/9918Base.hpp | 24 +++++++-------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index 79221be58..5ebe4761b 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -266,7 +266,7 @@ void TMS9918::run_for(const HalfCycles cycles) { LineBuffer &next_line_buffer = this->line_buffers_[this->write_pointer_.row]; // Establish the output mode for the next line. - this->set_current_screen_mode(); + this->screen_mode_ = this->current_screen_mode(); // Based on the output mode, pick a line mode. next_line_buffer.first_pixel_output_column = Timing::FirstPixelCycle; diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp index 495247913..6eba4be8d 100644 --- a/Components/9918/Implementation/9918Base.hpp +++ b/Components/9918/Implementation/9918Base.hpp @@ -298,43 +298,35 @@ template struct Base { size_t sprite_generator_table_address; } master_system_; - void set_current_screen_mode() { + ScreenMode current_screen_mode() const { if(blank_display_) { - screen_mode_ = ScreenMode::Blank; - return; + return ScreenMode::Blank; } if constexpr (is_sega_vdp(personality)) { if(master_system_.mode4_enable) { - screen_mode_ = ScreenMode::SMSMode4; - mode_timing_.maximum_visible_sprites = 8; - return; + return ScreenMode::SMSMode4; } } - mode_timing_.maximum_visible_sprites = 4; if(!mode1_enable_ && !mode2_enable_ && !mode3_enable_) { - screen_mode_ = ScreenMode::ColouredText; - return; + return ScreenMode::ColouredText; } if(mode1_enable_ && !mode2_enable_ && !mode3_enable_) { - screen_mode_ = ScreenMode::Text; - return; + return ScreenMode::Text; } if(!mode1_enable_ && mode2_enable_ && !mode3_enable_) { - screen_mode_ = ScreenMode::Graphics; - return; + return ScreenMode::Graphics; } if(!mode1_enable_ && !mode2_enable_ && mode3_enable_) { - screen_mode_ = ScreenMode::MultiColour; - return; + return ScreenMode::MultiColour; } // TODO: undocumented TMS modes. - screen_mode_ = ScreenMode::Blank; + return ScreenMode::Blank; } void do_external_slot(int access_column) {