From 131784d0076cd065045b82f37d1035d2bbcbdc41 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 13 Mar 2023 22:51:01 -0400 Subject: [PATCH] Generalise PointSet to read or write. --- Components/9918/Implementation/9918.cpp | 24 ++++++++++--------- Components/9918/Implementation/9918Base.hpp | 7 ++++++ Components/9918/Implementation/Storage.hpp | 9 +++++++ .../9918/Implementation/YamahaCommands.hpp | 12 +++++----- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index 4368f7647..1153467ff 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -924,20 +924,20 @@ void Base::commit_register(int reg, uint8_t value) { default: case 0b0000: Storage::command_ = nullptr; break; // STOP. - case 0b0100: break; // TODO: point. [read a pixel colour] - case 0b0101: Begin(PointSet); break; // PSET [plot a pixel]. + case 0b0100: Begin(Point); break; // POINT [read a pixel colour]. + case 0b0101: Begin(Point); break; // PSET [plot a pixel]. case 0b0110: break; // TODO: srch. [search horizontally for a colour] - case 0b0111: Begin(Line); break; // LINE [draw a Bresenham line]. + case 0b0111: Begin(Line); break; // LINE [draw a Bresenham line]. - case 0b1000: Begin(LogicalFill); break; // LMMV [logical move, VDP to VRAM, i.e. solid-colour fill]. - case 0b1001: Begin(Move); break; // LMMM [logical move, VRAM to VRAM]. + case 0b1000: Begin(LogicalFill); break; // LMMV [logical move, VDP to VRAM, i.e. solid-colour fill]. + case 0b1001: Begin(Move); break; // LMMM [logical move, VRAM to VRAM]. case 0b1010: break; // TODO: lmcm. [logical move, VRAM to CPU] - case 0b1011: Begin(MoveFromCPU); break; // LMMC [logical move, CPU to VRAM]. + case 0b1011: Begin(MoveFromCPU); break; // LMMC [logical move, CPU to VRAM]. - case 0b1100: Begin(HighSpeedFill); break; // HMMV [high-speed move, VDP to VRAM, i.e. single-byte fill]. - case 0b1101: Begin(Move); break; // HMMM [high-speed move, VRAM to VRAM]. - case 0b1110: Begin(Move); break; // YMMM [high-speed move, y only, VRAM to VRAM]. - case 0b1111: Begin(MoveFromCPU); break; // HMMC [high-speed move, CPU to VRAM]. + case 0b1100: Begin(HighSpeedFill); break; // HMMV [high-speed move, VDP to VRAM, i.e. single-byte fill]. + case 0b1101: Begin(Move); break; // HMMM [high-speed move, VRAM to VRAM]. + case 0b1110: Begin(Move); break; // YMMM [high-speed move, y only, VRAM to VRAM]. + case 0b1111: Begin(MoveFromCPU); break; // HMMC [high-speed move, CPU to VRAM]. } #undef Begin @@ -1113,7 +1113,9 @@ uint8_t Base::read_register() { case 4: LOG("TODO: Yamaha status 4"); break; case 5: LOG("TODO: Yamaha status 5"); break; case 6: LOG("TODO: Yamaha status 6"); break; - case 7: LOG("TODO: Yamaha status 7"); break; + + case 7: return Storage::colour_status_; + case 8: LOG("TODO: Yamaha status 8"); break; case 9: LOG("TODO: Yamaha status 9"); break; } diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp index 88983a646..bdf698b9d 100644 --- a/Components/9918/Implementation/9918Base.hpp +++ b/Components/9918/Implementation/9918Base.hpp @@ -390,6 +390,13 @@ template struct Base: public Storage { case CommandStep::None: break; + case CommandStep::CopySourcePixelToStatus: + Storage::colour_status_ = extract_colour(source[command_address(context.source, context.arguments & 0x10)], context.source); + + Storage::command_->advance(pixels_per_byte(this->underlying_mode_)); + Storage::update_command_step(access_column); + break; + case CommandStep::ReadSourcePixel: context.latched_colour.set(extract_colour(source[command_address(context.source, context.arguments & 0x10)], context.source)); diff --git a/Components/9918/Implementation/Storage.hpp b/Components/9918/Implementation/Storage.hpp index f83d8acac..f88d2eb70 100644 --- a/Components/9918/Implementation/Storage.hpp +++ b/Components/9918/Implementation/Storage.hpp @@ -100,6 +100,9 @@ template struct Storage struct Storage struct Storagecycles; switch(command_->access) { + case Command::AccessType::ReadPoint: + next_command_step_ = CommandStep::CopySourcePixelToStatus; + break; + case Command::AccessType::CopyPoint: next_command_step_ = CommandStep::ReadSourcePixel; break; diff --git a/Components/9918/Implementation/YamahaCommands.hpp b/Components/9918/Implementation/YamahaCommands.hpp index 6e27d67bf..7545180cb 100644 --- a/Components/9918/Implementation/YamahaCommands.hpp +++ b/Components/9918/Implementation/YamahaCommands.hpp @@ -111,7 +111,9 @@ struct Command { /// being a read, a 24-cycle gap, then a write. CopyByte, -// ReadPoint, + /// Copies a single pixel from @c source to the colour status register. + ReadPoint, + // ReadByte, // WaitForColourSend, }; @@ -211,11 +213,11 @@ struct Line: public Command { /// Implements the PSET command, which plots a single pixel. /// /// No timings are documented, so this'll output as quickly as possible. -struct PointSet: public Command { +template struct Point: public Command { public: - PointSet(CommandContext &context) : Command(context) { + Point(CommandContext &context) : Command(context) { cycles = 0; // TODO. - access = AccessType::PlotPoint; + access = is_read ? AccessType::ReadPoint : AccessType::PlotPoint; } bool done() final { @@ -230,8 +232,6 @@ struct PointSet: public Command { bool done_ = false; }; -// TODO: point. - // MARK: - Rectangular base. /// Useful base class for anything that does logical work in a rectangle.