1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-29 15:29:36 +00:00

Allow for channel enables and blitting direction.

This commit is contained in:
Thomas Harte 2021-09-23 18:38:37 -04:00
parent adc071ed7a
commit 137d1c61bd
2 changed files with 39 additions and 20 deletions

View File

@ -19,8 +19,13 @@ using namespace Amiga;
void Blitter::set_control(int index, uint16_t value) { void Blitter::set_control(int index, uint16_t value) {
if(index) { if(index) {
line_mode_ = !(value & 1); line_mode_ = !(value & 1);
direction_ = (value & 2) ? uint32_t(-1) : uint32_t(1);
} else { } else {
minterms_ = value & 0xff; minterms_ = value & 0xff;
channel_enables_[3] = value & 0x100;
channel_enables_[2] = value & 0x20;
channel_enables_[1] = value & 0x400;
channel_enables_[0] = value & 0x800;
} }
shifts_[index] = value >> 12; shifts_[index] = value >> 12;
LOG("Set control " << index << " to " << PADHEX(4) << value); LOG("Set control " << index << " to " << PADHEX(4) << value);
@ -132,27 +137,38 @@ bool Blitter::advance() {
// Quick hack: do the entire action atomically. Isn't life fabulous? // Quick hack: do the entire action atomically. Isn't life fabulous?
for(int y = 0; y < height_; y++) { for(int y = 0; y < height_; y++) {
for(int x = 0; x < width_; x++) { for(int x = 0; x < width_; x++) {
a_ = (a_ << 16) | ram_[pointer_[0] & ram_mask_]; if(channel_enables_[0]) {
b_ = (b_ << 16) | ram_[pointer_[1] & ram_mask_]; a_ = (a_ << 16) | ram_[pointer_[0] & ram_mask_];
const uint16_t c = ram_[pointer_[2] & ram_mask_]; pointer_[0] += direction_;
}
if(channel_enables_[1]) {
b_ = (b_ << 16) | ram_[pointer_[1] & ram_mask_];
pointer_[1] += direction_;
}
uint16_t c;
if(channel_enables_[2]) {
c = ram_[pointer_[2] & ram_mask_];
} else {
c = 0;
pointer_[2] += direction_;
}
ram_[pointer_[3] & ram_mask_] = if(channel_enables_[3]) {
apply_minterm( ram_[pointer_[3] & ram_mask_] =
uint16_t(a_ >> shifts_[0]), apply_minterm(
uint16_t(b_ >> shifts_[1]), uint16_t(a_ >> shifts_[0]),
c, uint16_t(b_ >> shifts_[1]),
minterms_); c,
minterms_);
++pointer_[0]; pointer_[3] += direction_;
++pointer_[1]; }
++pointer_[2];
++pointer_[3];
} }
pointer_[0] += modulos_[0]; pointer_[0] += modulos_[0] * channel_enables_[0];
pointer_[1] += modulos_[1]; pointer_[1] += modulos_[1] * channel_enables_[1];
pointer_[2] += modulos_[2]; pointer_[2] += modulos_[2] * channel_enables_[2];
pointer_[3] += modulos_[3]; pointer_[3] += modulos_[3] * channel_enables_[3];
} }
} }

View File

@ -41,13 +41,16 @@ class Blitter: public DMADevice<4> {
bool advance(); bool advance();
private: private:
uint8_t minterms_ = 0;
int width_ = 0, height_ = 0; int width_ = 0, height_ = 0;
int shifts_[2]{};
bool line_mode_ = false;
bool channel_enables_[4]{};
uint32_t direction_ = 1;
uint8_t minterms_ = 0;
uint32_t a_ = 0, b_ = 0; uint32_t a_ = 0, b_ = 0;
uint32_t modulos_[4]{}; uint32_t modulos_[4]{};
int shifts_[2]{};
bool line_mode_ = false;
}; };
} }