diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index 4aa3de41a..36398d457 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -866,7 +866,31 @@ void Base::commit_register(int reg, uint8_t value) { // Seed timing information if a command was found. if(Storage::command_) { - // TODO. + // TODO: eliminate SUPER HACK. + // This is currently here primarily to help me to hash out the + // proper interface, and also because I'm just not persuaded + // that minimum_access_column_ works properly. Why doesn't it + // ever end up out of bounds? + + + // TODO: undo temporary assumption of Graphics Mode 5. + uint8_t packed_colour = Storage::command_context_.colour & 3; + packed_colour |= packed_colour << 2; + packed_colour |= packed_colour << 4; + + while(!Storage::command_->done()) { + const int address = + (Storage::command_->location.v[0] >> 2) + + (Storage::command_->location.v[1] << 7); + + const uint8_t mask = 0xc0 >> ((Storage::command_->location.v[0] & 3) << 1); + uint8_t v = ram_[address]; + v &= ~mask; + v |= packed_colour & mask; + ram_[address] = v; + + Storage::command_->advance(); + } } // TODO: record logical mode. diff --git a/Components/9918/Implementation/YamahaCommands.hpp b/Components/9918/Implementation/YamahaCommands.hpp index 4eacab086..89e785eef 100644 --- a/Components/9918/Implementation/YamahaCommands.hpp +++ b/Components/9918/Implementation/YamahaCommands.hpp @@ -59,11 +59,11 @@ struct Command { CommandContext &context; Command(CommandContext &context) : context(context) {} - /// Request that the fields above are updated given that the previously-request access - /// was completed. - /// - /// @returns @c true if another access has been enqueued; @c false if this command is done. - virtual bool next() = 0; + /// @returns @c true if all output from this command is done; @c false otherwise. + virtual bool done() = 0; + + /// Repopulates the fields above with the next action to take. + virtual void advance() = 0; }; // MARK: - Line drawing. @@ -104,9 +104,11 @@ struct Line: public Command { location = context.destination; } - bool next() { - if(!duration_) return false; + bool done() final { + return !duration_; + } + void advance() final { --duration_; cycles = 88; location += major_; @@ -116,8 +118,6 @@ struct Line: public Command { location += minor_; position_ += denominator_; } - - return true; } private: