mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
Generalise axis steps; begin HMMV.
This commit is contained in:
parent
872b9e5021
commit
c5c722ae56
@ -915,7 +915,7 @@ void Base<personality>::commit_register(int reg, uint8_t value) {
|
||||
case 0b1010: break; // TODO: lmcm. [logical move, VRAM to CPU]
|
||||
case 0b1011: Begin(LogicalMoveFromCPU); break; // LMMC [logical move, CPU to VRAM]
|
||||
|
||||
case 0b1100: break; // TODO: hmmv. [high-speed move, VRAM to VDP]
|
||||
case 0b1100: Begin(HighSpeedFill); break; // HMMV [high-speed move, VDP to VRAM]
|
||||
case 0b1101: break; // TODO: 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]
|
||||
|
@ -192,6 +192,7 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
|
||||
None,
|
||||
ReadPixel,
|
||||
WritePixel,
|
||||
WriteByte,
|
||||
};
|
||||
CommandStep next_command_step_ = CommandStep::None;
|
||||
int minimum_command_column_ = 0;
|
||||
@ -217,6 +218,9 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
|
||||
// i.e. nothing to do until a colour is received.
|
||||
next_command_step_ = CommandStep::None;
|
||||
break;
|
||||
case Command::AccessType::WriteByte:
|
||||
next_command_step_ = CommandStep::WriteByte;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -706,6 +710,12 @@ template <Personality personality> struct Base: public Storage<personality> {
|
||||
Storage<personality>::command_->advance();
|
||||
Storage<personality>::update_command_step(access_column);
|
||||
} break;
|
||||
|
||||
case CommandStep::WriteByte:
|
||||
ram_[command_address()] = Storage<personality>::command_context_.colour;
|
||||
Storage<personality>::command_->advance();
|
||||
Storage<personality>::update_command_step(access_column);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,9 @@ struct Command {
|
||||
|
||||
/// Blocks until the next CPU write to the colour register.
|
||||
WaitForColourReceipt,
|
||||
|
||||
/// Writes an entire byte to the location containing the current @c location.
|
||||
WriteByte,
|
||||
};
|
||||
AccessType access = AccessType::PlotPoint;
|
||||
int cycles = 0;
|
||||
@ -94,6 +97,12 @@ struct Command {
|
||||
|
||||
/// Repopulates the fields above with the next action to take.
|
||||
virtual void advance() = 0;
|
||||
|
||||
protected:
|
||||
template <int axis> void advance_axis() {
|
||||
context.destination.add<axis>(context.arguments & (0x4 << axis) ? -1 : 1);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// MARK: - Line drawing.
|
||||
@ -140,9 +149,9 @@ struct Line: public Command {
|
||||
// b3: 1 => y direction is up;
|
||||
// 0 => y direction is down.
|
||||
if(context.arguments & 0x1) {
|
||||
location.add<1>(context.arguments & 0x8 ? -1 : 1);
|
||||
advance_axis<1>();
|
||||
} else {
|
||||
location.add<0>(context.arguments & 0x4 ? -1 : 1);
|
||||
advance_axis<0>();
|
||||
}
|
||||
|
||||
position_ -= numerator_;
|
||||
@ -151,9 +160,9 @@ struct Line: public Command {
|
||||
cycles += 32;
|
||||
|
||||
if(context.arguments & 0x1) {
|
||||
location.add<0>(context.arguments & 0x4 ? -1 : 1);
|
||||
advance_axis<0>();
|
||||
} else {
|
||||
location.add<1>(context.arguments & 0x8 ? -1 : 1);
|
||||
advance_axis<1>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -212,7 +221,7 @@ struct LogicalMoveFromCPU: public Command {
|
||||
case AccessType::PlotPoint:
|
||||
cycles = 0;
|
||||
access = AccessType::WaitForColourReceipt;
|
||||
context.destination.add<0>(context.arguments & 0x4 ? -1 : 1);
|
||||
advance_axis<0>();
|
||||
--context.size.v[0];
|
||||
|
||||
if(!context.size.v[0]) {
|
||||
@ -220,7 +229,7 @@ struct LogicalMoveFromCPU: public Command {
|
||||
context.size.v[0] = width_;
|
||||
context.destination.v[0] = start_x_;
|
||||
|
||||
context.destination.add<1>(context.arguments & 0x8 ? -1 : 1);
|
||||
advance_axis<1>();
|
||||
--context.size.v[1];
|
||||
}
|
||||
break;
|
||||
@ -235,6 +244,28 @@ struct LogicalMoveFromCPU: public Command {
|
||||
int start_x_ = 0, width_ = 0;
|
||||
};
|
||||
|
||||
struct HighSpeedFill: public Command {
|
||||
HighSpeedFill(CommandContext &context) : Command(context) {
|
||||
start_x_ = context.destination.v[0];
|
||||
width_ = context.size.v[0];
|
||||
|
||||
cycles = 56;
|
||||
access = AccessType::WriteByte;
|
||||
location = context.destination;
|
||||
}
|
||||
|
||||
bool done() final {
|
||||
return true;
|
||||
}
|
||||
|
||||
void advance() final {
|
||||
cycles = 48;
|
||||
}
|
||||
|
||||
private:
|
||||
int start_x_ = 0, width_ = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user