1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Generalise PointSet to read or write.

This commit is contained in:
Thomas Harte 2023-03-13 22:51:01 -04:00
parent e703fa9cf8
commit 131784d007
4 changed files with 35 additions and 17 deletions

View File

@ -924,8 +924,8 @@ void Base<personality>::commit_register(int reg, uint8_t value) {
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 0b0100: Begin(Point<true>); break; // POINT [read a pixel colour].
case 0b0101: Begin(Point<false>); 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].
@ -1113,7 +1113,9 @@ uint8_t Base<personality>::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<personality>::colour_status_;
case 8: LOG("TODO: Yamaha status 8"); break;
case 9: LOG("TODO: Yamaha status 9"); break;
}

View File

@ -390,6 +390,13 @@ template <Personality personality> struct Base: public Storage<personality> {
case CommandStep::None:
break;
case CommandStep::CopySourcePixelToStatus:
Storage<personality>::colour_status_ = extract_colour(source[command_address(context.source, context.arguments & 0x10)], context.source);
Storage<personality>::command_->advance(pixels_per_byte(this->underlying_mode_));
Storage<personality>::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));

View File

@ -100,6 +100,9 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
// Sprite collection state.
bool sprites_enabled_ = true;
// Additional status.
uint8_t colour_status_ = 0;
/// Resets line-ephemeral state for a new line.
void begin_line(ScreenMode mode, bool is_refresh) {
if(is_refresh) {
@ -134,6 +137,8 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
enum class CommandStep {
None,
CopySourcePixelToStatus,
ReadSourcePixel,
ReadDestinationPixel,
WritePixel,
@ -158,6 +163,10 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
minimum_command_column_ = current_column + command_->cycles;
switch(command_->access) {
case Command::AccessType::ReadPoint:
next_command_step_ = CommandStep::CopySourcePixelToStatus;
break;
case Command::AccessType::CopyPoint:
next_command_step_ = CommandStep::ReadSourcePixel;
break;

View File

@ -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 <bool is_read> 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.