mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-07 23:25:00 +00:00
Unify existing moves.
This commit is contained in:
@@ -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_);
|
#define Begin(x) Storage<personality>::command_ = std::make_unique<Commands::x>(Storage<personality>::command_context_);
|
||||||
|
using MoveType = Commands::MoveType;
|
||||||
switch(value >> 4) {
|
switch(value >> 4) {
|
||||||
// All codes not listed below are invalid; treat them as STOP.
|
// All codes not listed below are invalid; treat them as STOP.
|
||||||
default:
|
default:
|
||||||
case 0b0000: Storage<personality>::command_ = nullptr; break; // STOP.
|
case 0b0000: Storage<personality>::command_ = nullptr; break; // STOP.
|
||||||
|
|
||||||
case 0b0100: break; // TODO: point. [read a pixel colour]
|
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 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 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 0b1001: Begin(Move<MoveType::Logical>); break; // LMMM [logical move, VRAM to VRAM].
|
||||||
case 0b1010: break; // TODO: lmcm. [logical move, VRAM to CPU]
|
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 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 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 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
|
#undef Begin
|
||||||
|
|
||||||
|
@@ -328,30 +328,26 @@ template <bool logical> struct MoveFromCPU: public Rectangle<logical, false> {
|
|||||||
|
|
||||||
// MARK: - Rectangular moves within VRAM.
|
// MARK: - Rectangular moves within VRAM.
|
||||||
|
|
||||||
struct HighSpeedMove: public Rectangle<false, true> {
|
enum class MoveType {
|
||||||
HighSpeedMove(CommandContext &context) : Rectangle(context) {
|
Logical,
|
||||||
access = AccessType::CopyByte;
|
HighSpeed,
|
||||||
cycles = 64;
|
YOnly,
|
||||||
}
|
|
||||||
|
|
||||||
void advance(int pixels_per_byte) final {
|
|
||||||
cycles = 64;
|
|
||||||
if(advance_pixel(pixels_per_byte)) {
|
|
||||||
cycles += 64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LogicalMove: public Rectangle<true, true> {
|
template <MoveType type> struct Move: public Rectangle<type == MoveType::Logical, true> {
|
||||||
LogicalMove(CommandContext &context) : Rectangle(context) {
|
static constexpr bool is_logical = type == MoveType::Logical;
|
||||||
access = AccessType::CopyPoint;
|
static constexpr bool is_y_only = type == MoveType::YOnly;
|
||||||
cycles = 64;
|
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 {
|
void advance(int pixels_per_byte) final {
|
||||||
cycles = 64;
|
Command::cycles = is_y_only ? 40 : 64;
|
||||||
if(advance_pixel(pixels_per_byte)) {
|
if(Rectangle::advance_pixel(pixels_per_byte)) {
|
||||||
cycles += 64;
|
Command::cycles += is_y_only ? 0 : 64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user