1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-27 02:55:07 +00:00

Unify existing moves.

This commit is contained in:
Thomas Harte 2023-03-08 22:36:06 -05:00
parent f3a84021ed
commit 82659e7924
2 changed files with 24 additions and 27 deletions

View File

@ -916,25 +916,26 @@ void Base<personality>::commit_register(int reg, uint8_t value) {
}
#define Begin(x) Storage<personality>::command_ = std::make_unique<Commands::x>(Storage<personality>::command_context_);
using MoveType = Commands::MoveType;
switch(value >> 4) {
// All codes not listed below are invalid; treat them as STOP.
default:
case 0b0000: Storage<personality>::command_ = nullptr; break; // STOP.
case 0b0100: break; // TODO: point. [read a pixel colour]
case 0b0101: Begin(PointSet); break; // PSET [plot a pixel].
case 0b0101: Begin(PointSet); 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(LogicalMove); 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<MoveType::Logical>); break; // LMMM [logical move, VRAM to VRAM].
case 0b1010: break; // TODO: lmcm. [logical move, VRAM to CPU]
case 0b1011: Begin(MoveFromCPU<true>); break; // LMMC [logical move, CPU to VRAM].
case 0b1011: Begin(MoveFromCPU<true>); 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 0b1100: Begin(HighSpeedFill); break; // HMMV [high-speed move, VDP to VRAM, i.e. single-byte fill].
case 0b1101: Begin(Move<MoveType::HighSpeed>); break; // HMMM [high-speed move, VRAM to VRAM].
case 0b1110: break; // TODO: ymmm. [high-speed move, y only, VRAM to VRAM]
case 0b1111: Begin(MoveFromCPU<false>); break; // HMMC [high-speed move, CPU to VRAM].
case 0b1111: Begin(MoveFromCPU<false>); break; // HMMC [high-speed move, CPU to VRAM].
}
#undef Begin

View File

@ -328,30 +328,26 @@ template <bool logical> struct MoveFromCPU: public Rectangle<logical, false> {
// MARK: - Rectangular moves within VRAM.
struct HighSpeedMove: public Rectangle<false, true> {
HighSpeedMove(CommandContext &context) : Rectangle(context) {
access = AccessType::CopyByte;
cycles = 64;
}
void advance(int pixels_per_byte) final {
cycles = 64;
if(advance_pixel(pixels_per_byte)) {
cycles += 64;
}
}
enum class MoveType {
Logical,
HighSpeed,
YOnly,
};
struct LogicalMove: public Rectangle<true, true> {
LogicalMove(CommandContext &context) : Rectangle(context) {
access = AccessType::CopyPoint;
cycles = 64;
template <MoveType type> struct Move: public Rectangle<type == MoveType::Logical, true> {
static constexpr bool is_logical = type == MoveType::Logical;
static constexpr bool is_y_only = type == MoveType::YOnly;
using Rectangle = Rectangle<is_logical, true>;
Move(CommandContext &context) : Rectangle(context) {
Command::access = is_logical ? Command::AccessType::CopyPoint : Command::AccessType::CopyByte;
Command::cycles = is_y_only ? 0 : 64;
}
void advance(int pixels_per_byte) final {
cycles = 64;
if(advance_pixel(pixels_per_byte)) {
cycles += 64;
Command::cycles = is_y_only ? 40 : 64;
if(Rectangle::advance_pixel(pixels_per_byte)) {
Command::cycles += is_y_only ? 0 : 64;
}
}
};