From a6251f436ae3efd78d1e0e46f64bb6025b3b8111 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 18 Mar 2023 13:39:47 -0400 Subject: [PATCH] Provide commands with [unpopulated] mode parameters. --- Components/9918/Implementation/9918.cpp | 2 +- Components/9918/Implementation/Storage.hpp | 1 + .../9918/Implementation/YamahaCommands.hpp | 23 ++++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index 77bfa1f17..3027ff900 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -928,7 +928,7 @@ void Base::commit_register(int reg, uint8_t value) { break; } -#define Begin(x) Storage::command_ = std::make_unique(Storage::command_context_); +#define Begin(x) Storage::command_ = std::make_unique(Storage::command_context_, Storage::mode_description_); using MoveType = Commands::MoveType; switch(value >> 4) { // All codes not listed below are invalid; treat them as STOP. diff --git a/Components/9918/Implementation/Storage.hpp b/Components/9918/Implementation/Storage.hpp index 22a728210..b98c74892 100644 --- a/Components/9918/Implementation/Storage.hpp +++ b/Components/9918/Implementation/Storage.hpp @@ -134,6 +134,7 @@ template struct Storage command_ = nullptr; enum class CommandStep { diff --git a/Components/9918/Implementation/YamahaCommands.hpp b/Components/9918/Implementation/YamahaCommands.hpp index dea62a229..3037f247b 100644 --- a/Components/9918/Implementation/YamahaCommands.hpp +++ b/Components/9918/Implementation/YamahaCommands.hpp @@ -86,6 +86,12 @@ struct CommandContext { bool test_source; }; +struct ModeDescription { + int width = 256; + int pixels_per_byte = 4; + bool rotate_address = false; +}; + struct Command { // In net: // @@ -124,7 +130,8 @@ struct Command { /// Current command parameters. CommandContext &context; - Command(CommandContext &context) : context(context) {} + ModeDescription &mode_description; + Command(CommandContext &context, ModeDescription &mode_description) : context(context), mode_description(mode_description) {} virtual ~Command() {} /// @returns @c true if all output from this command is done; @c false otherwise. @@ -155,7 +162,7 @@ namespace Commands { /// * plus an additional 32 cycles if a step along the minor axis is taken. struct Line: public Command { public: - Line(CommandContext &context) : Command(context) { + Line(CommandContext &context, ModeDescription &mode_description) : Command(context, mode_description) { // context.destination = start position; // context.size.v[0] = long side dots; // context.size.v[1] = short side dots; @@ -215,7 +222,7 @@ struct Line: public Command { /// No timings are documented, so this'll output or input as quickly as possible. template struct Point: public Command { public: - Point(CommandContext &context) : Command(context) { + Point(CommandContext &context, ModeDescription &mode_description) : Command(context, mode_description) { cycles = 0; // TODO. access = is_read ? AccessType::ReadPoint : AccessType::PlotPoint; } @@ -237,7 +244,7 @@ template struct Point: public Command { /// Useful base class for anything that does logical work in a rectangle. template struct Rectangle: public Command { public: - Rectangle(CommandContext &context) : Command(context) { + Rectangle(CommandContext &context, ModeDescription &mode_description) : Command(context, mode_description) { if constexpr (include_source) { start_x_[0] = context.source.v[0]; } @@ -297,7 +304,7 @@ template struct Rectangle: public Command { // MARK: - Rectangular moves to/from CPU. template struct MoveFromCPU: public Rectangle { - MoveFromCPU(CommandContext &context) : Rectangle(context) { + MoveFromCPU(CommandContext &context, ModeDescription &mode_description) : Rectangle(context, mode_description) { Command::is_cpu_transfer = true; // This command is started with the first colour ready to transfer. @@ -340,7 +347,7 @@ template struct Move: public Rectangle; - Move(CommandContext &context) : RectangleBase(context) { + Move(CommandContext &context, ModeDescription &mode_description) : RectangleBase(context, mode_description) { Command::access = is_logical ? Command::AccessType::CopyPoint : Command::AccessType::CopyByte; Command::cycles = is_y_only ? 0 : 64; Command::y_only = is_y_only; @@ -357,7 +364,7 @@ template struct Move: public Rectangle { - HighSpeedFill(CommandContext &context) : Rectangle(context) { + HighSpeedFill(CommandContext &context, ModeDescription &mode_description) : Rectangle(context, mode_description) { cycles = 56; access = AccessType::WriteByte; } @@ -371,7 +378,7 @@ struct HighSpeedFill: public Rectangle { }; struct LogicalFill: public Rectangle { - LogicalFill(CommandContext &context) : Rectangle(context) { + LogicalFill(CommandContext &context, ModeDescription &mode_description) : Rectangle(context, mode_description) { cycles = 64; access = AccessType::PlotPoint; }