diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index 3a0c9815e..5da9d04a0 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -159,7 +159,7 @@ void TMS9918::run_for(const HalfCycles cycles) { #endif if(fetch_cycles_pool) { - // Determine how much writing to do. + // Determine how much writing to do; at the absolute most go to the end of this line. const int fetch_cycles = std::min( Timing::CyclesPerLine - this->fetch_pointer_.column, fetch_cycles_pool @@ -171,6 +171,15 @@ void TMS9918::run_for(const HalfCycles cycles) { this->minimum_access_column_ = this->fetch_pointer_.column + this->cycles_until_access_; this->cycles_until_access_ -= fetch_cycles; + // ... and to any pending Yamaha commands. + if constexpr (is_yamaha_vdp(personality)) { + if(Storage::command_) { + Storage::minimum_command_column_ = + this->fetch_pointer_.column + Storage::command_->cycles; + Storage::command_->cycles -= fetch_cycles; + } + } + // --------------------------------------- // Latch scrolling position, if necessary. diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp index 5032ebb64..d0f8a164b 100644 --- a/Components/9918/Implementation/9918Base.hpp +++ b/Components/9918/Implementation/9918Base.hpp @@ -187,6 +187,27 @@ template struct Storage command_ = nullptr; + enum class CommandStep { + None, + ReadPixel, + WritePixel, + }; + CommandStep next_command_step_ = CommandStep::None; + int minimum_command_column_ = 0; + + void update_command_step() { + if(!command_) { + next_command_step_ = CommandStep::None; + return; + } + + switch(command_->access) { + case Command::AccessType::PlotPoint: + next_command_step_ = CommandStep::ReadPixel; + break; + } + } + Storage() noexcept { // Perform sanity checks on the event lists. #ifndef NDEBUG @@ -552,6 +573,17 @@ template struct Base: public Storage { // Don't do anything if the required time for the access to become executable // has yet to pass. if(queued_access_ == MemoryAccess::None || access_column < minimum_access_column_) { + if constexpr (is_yamaha_vdp(personality)) { +// if( +// Storage::next_command_step_ == Storage::CommandStep::None || +// access_column < Storage::minimum_access_column_ +// ) { +// return; +// } + + // TODO: command-engine action. + } + return; }