mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-13 00:25:26 +00:00
Clean up repetition.
This commit is contained in:
@@ -805,71 +805,20 @@ void Base<personality>::commit_register(int reg, uint8_t value) {
|
|||||||
// i.e. scrolling.
|
// i.e. scrolling.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 32:
|
case 32: Storage<personality>::command_context_.source.template set<0, false>(value); break;
|
||||||
Storage<personality>::command_context_.source_x =
|
case 33: Storage<personality>::command_context_.source.template set<0, true>(value); break;
|
||||||
(Storage<personality>::command_context_.source_x & ~0xff) |
|
case 34: Storage<personality>::command_context_.source.template set<1, false>(value); break;
|
||||||
value;
|
case 35: Storage<personality>::command_context_.source.template set<1, true>(value); break;
|
||||||
break;
|
|
||||||
case 33:
|
|
||||||
Storage<personality>::command_context_.source_x =
|
|
||||||
(Storage<personality>::command_context_.source_x & ~0x100) |
|
|
||||||
((value & 1) << 8);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 34:
|
case 36: Storage<personality>::command_context_.destination.template set<0, false>(value); break;
|
||||||
Storage<personality>::command_context_.source_y =
|
case 37: Storage<personality>::command_context_.destination.template set<0, true>(value); break;
|
||||||
(Storage<personality>::command_context_.source_y & ~0xff) |
|
case 38: Storage<personality>::command_context_.destination.template set<1, false>(value); break;
|
||||||
value;
|
case 39: Storage<personality>::command_context_.destination.template set<1, true>(value); break;
|
||||||
break;
|
|
||||||
case 35:
|
|
||||||
Storage<personality>::command_context_.source_y =
|
|
||||||
(Storage<personality>::command_context_.source_y & ~0x300) |
|
|
||||||
((value & 3) << 8);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 36:
|
case 40: Storage<personality>::command_context_.size.template set<0, false>(value); break;
|
||||||
Storage<personality>::command_context_.destination_x =
|
case 41: Storage<personality>::command_context_.size.template set<0, true>(value); break;
|
||||||
(Storage<personality>::command_context_.destination_x & ~0xff) |
|
case 42: Storage<personality>::command_context_.size.template set<1, false>(value); break;
|
||||||
value;
|
case 43: Storage<personality>::command_context_.size.template set<1, true>(value); break;
|
||||||
break;
|
|
||||||
case 37:
|
|
||||||
Storage<personality>::command_context_.destination_x =
|
|
||||||
(Storage<personality>::command_context_.destination_x & ~0x100) |
|
|
||||||
((value & 1) << 8);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 38:
|
|
||||||
Storage<personality>::command_context_.destination_y =
|
|
||||||
(Storage<personality>::command_context_.destination_y & ~0xff) |
|
|
||||||
value;
|
|
||||||
break;
|
|
||||||
case 39:
|
|
||||||
Storage<personality>::command_context_.destination_y =
|
|
||||||
(Storage<personality>::command_context_.destination_y & ~0x300) |
|
|
||||||
((value & 3) << 8);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 40:
|
|
||||||
Storage<personality>::command_context_.size_x =
|
|
||||||
(Storage<personality>::command_context_.size_x & ~0xff) |
|
|
||||||
value;
|
|
||||||
break;
|
|
||||||
case 41:
|
|
||||||
Storage<personality>::command_context_.size_x =
|
|
||||||
(Storage<personality>::command_context_.size_x & ~0x100) |
|
|
||||||
((value & 1) << 8);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 42:
|
|
||||||
Storage<personality>::command_context_.size_y =
|
|
||||||
(Storage<personality>::command_context_.size_y & ~0xff) |
|
|
||||||
value;
|
|
||||||
break;
|
|
||||||
case 43:
|
|
||||||
Storage<personality>::command_context_.size_y =
|
|
||||||
(Storage<personality>::command_context_.size_y & ~0x300) |
|
|
||||||
((value & 3) << 8);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 44:
|
case 44:
|
||||||
Storage<personality>::command_context_.colour = value;
|
Storage<personality>::command_context_.colour = value;
|
||||||
|
@@ -16,10 +16,26 @@ namespace TMS {
|
|||||||
|
|
||||||
// MARK: - Generics.
|
// MARK: - Generics.
|
||||||
|
|
||||||
|
struct Vector {
|
||||||
|
int v[2]{};
|
||||||
|
|
||||||
|
template <int offset, bool high> void set(uint8_t value) {
|
||||||
|
constexpr uint8_t mask = high ? (offset ? 0x3 : 0x1) : 0xff;
|
||||||
|
constexpr int shift = high ? 8 : 0;
|
||||||
|
v[offset] = (v[offset] & ~(mask << shift)) | (value << shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector & operator += (const Vector &rhs) {
|
||||||
|
v[0] += rhs.v[0];
|
||||||
|
v[1] += rhs.v[1];
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct CommandContext {
|
struct CommandContext {
|
||||||
int source_x = 0, source_y = 0;
|
Vector source;
|
||||||
int destination_x = 0, destination_y = 0;
|
Vector destination;
|
||||||
int size_x = 0, size_y = 0;
|
Vector size;
|
||||||
uint8_t colour = 0;
|
uint8_t colour = 0;
|
||||||
uint8_t arguments = 0;
|
uint8_t arguments = 0;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user