From 3606f5befef530a0d23468f1a39a15cda52cf7fd Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 20 Feb 2023 22:32:36 -0500 Subject: [PATCH] Add expansion RAM to command engine, as far as it goes. --- Components/9918/Implementation/9918Base.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp index de92521ec..aa518a2c1 100644 --- a/Components/9918/Implementation/9918Base.hpp +++ b/Components/9918/Implementation/9918Base.hpp @@ -352,6 +352,9 @@ template struct Base: public Storage { // has yet to pass. if(queued_access_ == MemoryAccess::None || access_column < minimum_access_column_) { if constexpr (is_yamaha_vdp(personality)) { + const uint8_t *const source = (Storage::command_context_.arguments & 0x10) ? Storage::expansion_ram_.data() : ram_.data(); + uint8_t *const destination = (Storage::command_context_.arguments & 0x20) ? Storage::expansion_ram_.data() : ram_.data(); + using CommandStep = typename Storage::CommandStep; if( @@ -368,14 +371,14 @@ template struct Base: public Storage { break; case CommandStep::ReadSourcePixel: - context.latched_colour.set(extract_colour(ram_[command_address(context.source)], context.source)); + context.latched_colour.set(extract_colour(source[command_address(context.source)], context.source)); Storage::minimum_command_column_ = access_column + 32; Storage::next_command_step_ = CommandStep::ReadDestinationPixel; break; case CommandStep::ReadDestinationPixel: - Storage::command_latch_ = ram_[command_address(context.destination)]; + Storage::command_latch_ = source[command_address(context.destination)]; Storage::minimum_command_column_ = access_column + 24; Storage::next_command_step_ = CommandStep::WritePixel; @@ -411,21 +414,21 @@ template struct Base: public Storage { } } - ram_[address] = Storage::command_latch_; + destination[address] = Storage::command_latch_; Storage::command_->advance(pixels_per_byte(this->underlying_mode_)); Storage::update_command_step(access_column); } break; case CommandStep::ReadSourceByte: - context.latched_colour.set(ram_[command_address(context.source)]); + context.latched_colour.set(source[command_address(context.source)]); Storage::minimum_command_column_ = access_column + 24; Storage::next_command_step_ = CommandStep::WriteByte; break; case CommandStep::WriteByte: - ram_[command_address(context.destination)] = context.latched_colour.has_value() ? context.latched_colour.colour : context.colour.colour; + destination[command_address(context.destination)] = context.latched_colour.has_value() ? context.latched_colour.colour : context.colour.colour; context.latched_colour.reset(); Storage::command_->advance(pixels_per_byte(this->underlying_mode_));