From ef67205ce85e039ff55779d9397489e5351392d0 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 8 Jan 2023 21:31:00 -0500 Subject: [PATCH] Set pixel count per mode. --- Components/9918/Implementation/9918.cpp | 9 +++++---- Components/9918/Implementation/9918Base.hpp | 1 + Machines/MSX/MSX.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index dd447d963..af47dffd0 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -272,12 +272,14 @@ void TMS9918::run_for(const HalfCycles cycles) { // Based on the output mode, pick a line mode. next_line_buffer.first_pixel_output_column = Timing::FirstPixelCycle; next_line_buffer.next_border_column = Timing::CyclesPerLine; + next_line_buffer.pixel_count = 256; this->mode_timing_.maximum_visible_sprites = 4; switch(this->screen_mode_) { case ScreenMode::Text: next_line_buffer.line_mode = LineMode::Text; next_line_buffer.first_pixel_output_column = Timing::FirstTextCycle; next_line_buffer.next_border_column = Timing::LastTextCycle; + next_line_buffer.pixel_count = 240; break; case ScreenMode::SMSMode4: next_line_buffer.line_mode = LineMode::SMS; @@ -418,9 +420,8 @@ void TMS9918::run_for(const HalfCycles cycles) { if(!this->asked_for_write_area_) { this->asked_for_write_area_ = true; - // TODO: how many pixels across is this mode? this->pixel_origin_ = this->pixel_target_ = reinterpret_cast( - this->crt_.begin_data(256) + this->crt_.begin_data(line_buffer.pixel_count) ); } @@ -435,8 +436,8 @@ void TMS9918::run_for(const HalfCycles cycles) { } if(end == line_buffer.next_border_column) { - const int length = 256;//line_buffer.next_border_column - line_buffer.first_pixel_output_column; // TODO: proper number of pixels, as above. - this->crt_.output_data(this->clock_converter_.to_crt_clock(length), size_t(length)); + const int length = line_buffer.next_border_column - line_buffer.first_pixel_output_column; + this->crt_.output_data(this->clock_converter_.to_crt_clock(length), line_buffer.pixel_count); this->pixel_origin_ = this->pixel_target_ = nullptr; this->asked_for_write_area_ = false; } diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp index 6eba4be8d..355ca85e4 100644 --- a/Components/9918/Implementation/9918Base.hpp +++ b/Components/9918/Implementation/9918Base.hpp @@ -101,6 +101,7 @@ struct LineBuffer { */ int first_pixel_output_column = 94; int next_border_column = 334; + size_t pixel_count = 256; // An active sprite is one that has been selected for composition onto // this line. diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index 2ec502788..6bc06bda0 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -743,7 +743,7 @@ class ConcreteMachine: }; CPU::Z80::Processor z80_; - JustInTimeActor> vdp_; + JustInTimeActor> vdp_; Intel::i8255::i8255 i8255_; Concurrency::AsyncTaskQueue audio_queue_;