From 0ea1da10d69af247bd0e73a3a8d3c8f2af5a65f1 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 3 Mar 2023 21:40:48 -0500 Subject: [PATCH] Attempt to generalise moving from CPU. --- Components/9918/Implementation/9918.cpp | 4 +-- .../9918/Implementation/YamahaCommands.hpp | 31 ++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index db40daa87..0c6183224 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -921,12 +921,12 @@ void Base::commit_register(int reg, uint8_t value) { case 0b1000: Begin(LogicalFill); break; // LMMV [logical move, VDP to VRAM, i.e. solid-colour fill]. case 0b1001: Begin(LogicalMove); break; // LMMM [logical move, VRAM to VRAM]. case 0b1010: break; // TODO: lmcm. [logical move, VRAM to CPU] - case 0b1011: Begin(LogicalMoveFromCPU); 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(HighSpeedMove); break; // HMMM [high-speed move, VRAM to VRAM]. case 0b1110: break; // TODO: ymmm. [high-speed move, y only, VRAM to VRAM] - case 0b1111: break; // TODO: hmmc. [high-speed move, CPU to VRAM] + case 0b1111: Begin(MoveFromCPU); break; // HMMC [high-speed move, CPU to VRAM]. } #undef Begin diff --git a/Components/9918/Implementation/YamahaCommands.hpp b/Components/9918/Implementation/YamahaCommands.hpp index 142229966..b09ca19f0 100644 --- a/Components/9918/Implementation/YamahaCommands.hpp +++ b/Components/9918/Implementation/YamahaCommands.hpp @@ -295,29 +295,30 @@ template struct Rectangle: public Command { // MARK: - Rectangular moves to/from CPU. -struct LogicalMoveFromCPU: public Rectangle { - LogicalMoveFromCPU(CommandContext &context) : Rectangle(context) { - is_cpu_transfer = true; +template struct MoveFromCPU: public Rectangle { + MoveFromCPU(CommandContext &context) : Rectangle(context) { + Command::is_cpu_transfer = true; // This command is started with the first colour ready to transfer. - cycles = 32; - access = AccessType::PlotPoint; + Command::cycles = 32; + Command::access = logical ? Command::AccessType::PlotPoint : Command::AccessType::WriteByte; } - void advance(int) final { - switch(access) { + void advance(int pixels_per_byte) final { + switch(Command::access) { default: break; - case AccessType::WaitForColourReceipt: - cycles = 32; - access = AccessType::PlotPoint; + case Command::AccessType::WaitForColourReceipt: + Command::cycles = 32; + Command::access = logical ? Command::AccessType::PlotPoint : Command::AccessType::WriteByte; break; - case AccessType::PlotPoint: - cycles = 0; - access = AccessType::WaitForColourReceipt; - if(advance_pixel()) { - cycles = 64; + case Command::AccessType::WriteByte: + case Command::AccessType::PlotPoint: + Command::cycles = 0; + Command::access = Command::AccessType::WaitForColourReceipt; + if(Rectangle::advance_pixel(pixels_per_byte)) { + Command::cycles = 64; // TODO: I'm not sure this will be honoured per the outer wrapping. } break;