mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 01:31:42 +00:00
Invest Colour with its own logic, including potential emptiness.
This commit is contained in:
parent
a892523c09
commit
a2786e6266
@ -829,17 +829,7 @@ void Base<personality>::commit_register(int reg, uint8_t value) {
|
||||
case 43: Storage<personality>::command_context_.size.template set<1, true>(value); break;
|
||||
|
||||
case 44:
|
||||
Storage<personality>::command_context_.colour = value;
|
||||
Storage<personality>::command_context_.colour4bpp = uint8_t(
|
||||
(value & 0xf) |
|
||||
(value << 4)
|
||||
);
|
||||
Storage<personality>::command_context_.colour2bpp = uint8_t(
|
||||
(value & 0x3) |
|
||||
((value & 0x3) << 2) |
|
||||
((value & 0x3) << 4) |
|
||||
((value & 0x3) << 6)
|
||||
);
|
||||
Storage<personality>::command_context_.colour.set(value);
|
||||
|
||||
// Check whether a command was blocked on this.
|
||||
if(
|
||||
|
@ -683,21 +683,21 @@ template <Personality personality> struct Base: public Storage<personality> {
|
||||
return
|
||||
std::make_pair(
|
||||
0xf0 >> ((location.v[0] & 1) << 2),
|
||||
Storage<personality>::command_context_.colour4bpp
|
||||
Storage<personality>::command_context_.colour.colour4bpp
|
||||
);
|
||||
|
||||
case ScreenMode::YamahaGraphics5: // 512 pixels @ 2bpp
|
||||
return
|
||||
std::make_pair(
|
||||
0xc0 >> ((location.v[0] & 3) << 1),
|
||||
Storage<personality>::command_context_.colour2bpp
|
||||
Storage<personality>::command_context_.colour.colour2bpp
|
||||
);
|
||||
|
||||
case ScreenMode::YamahaGraphics7: // 256 pixels @ 8bpp
|
||||
return
|
||||
std::make_pair(
|
||||
0xff,
|
||||
Storage<personality>::command_context_.colour
|
||||
Storage<personality>::command_context_.colour.colour
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -786,7 +786,7 @@ template <Personality personality> struct Base: public Storage<personality> {
|
||||
break;
|
||||
|
||||
case CommandStep::WriteByte:
|
||||
ram_[command_address(context.destination)] = context.colour;
|
||||
ram_[command_address(context.destination)] = context.colour.colour;
|
||||
Storage<personality>::command_->advance(pixels_per_byte(this->underlying_mode_));
|
||||
Storage<personality>::update_command_step(access_column);
|
||||
break;
|
||||
|
@ -42,18 +42,37 @@ struct Vector {
|
||||
}
|
||||
};
|
||||
|
||||
struct Colour {
|
||||
void set(uint8_t value) {
|
||||
colour = value;
|
||||
colour4bpp = uint8_t((value & 0xf) | (value << 4));
|
||||
colour2bpp = uint8_t((colour4bpp & 0x33) | ((colour4bpp & 0x33) << 2));
|
||||
}
|
||||
|
||||
void reset() {
|
||||
colour = 0x00;
|
||||
colour4bpp = 0xff;
|
||||
}
|
||||
|
||||
bool has_value() {
|
||||
return (colour & 0x3) == (colour4bpp & 0x3);
|
||||
}
|
||||
|
||||
/// Colour as written by the CPU.
|
||||
uint8_t colour = 0x00;
|
||||
/// The low four bits of the CPU-written colour, repeated twice.
|
||||
uint8_t colour4bpp = 0xff;
|
||||
/// The low two bits of the CPU-written colour, repeated four times.
|
||||
uint8_t colour2bpp = 0xff;
|
||||
};
|
||||
|
||||
struct CommandContext {
|
||||
Vector source;
|
||||
Vector destination;
|
||||
Vector size;
|
||||
|
||||
uint8_t arguments = 0;
|
||||
/// Colour as written by the CPU.
|
||||
uint8_t colour = 0;
|
||||
/// The low four bits of the CPU-written colour, repeated twice.
|
||||
uint8_t colour4bpp = 0;
|
||||
/// The low two bits of the CPU-written colour, repeated four times.
|
||||
uint8_t colour2bpp = 0;
|
||||
Colour colour;
|
||||
|
||||
enum class LogicalOperation {
|
||||
Copy = 0b0000,
|
||||
|
Loading…
Reference in New Issue
Block a user