From 137d1c61bd13e54fcaa0735defee2b8f6c8d31f0 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 23 Sep 2021 18:38:37 -0400 Subject: [PATCH] Allow for channel enables and blitting direction. --- Machines/Amiga/Blitter.cpp | 50 +++++++++++++++++++++++++------------- Machines/Amiga/Blitter.hpp | 9 ++++--- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/Machines/Amiga/Blitter.cpp b/Machines/Amiga/Blitter.cpp index ed881918e..7b68563b8 100644 --- a/Machines/Amiga/Blitter.cpp +++ b/Machines/Amiga/Blitter.cpp @@ -19,8 +19,13 @@ using namespace Amiga; void Blitter::set_control(int index, uint16_t value) { if(index) { line_mode_ = !(value & 1); + direction_ = (value & 2) ? uint32_t(-1) : uint32_t(1); } else { 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; 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? for(int y = 0; y < height_; y++) { for(int x = 0; x < width_; x++) { - a_ = (a_ << 16) | ram_[pointer_[0] & ram_mask_]; - b_ = (b_ << 16) | ram_[pointer_[1] & ram_mask_]; - const uint16_t c = ram_[pointer_[2] & ram_mask_]; + if(channel_enables_[0]) { + a_ = (a_ << 16) | ram_[pointer_[0] & 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_] = - apply_minterm( - uint16_t(a_ >> shifts_[0]), - uint16_t(b_ >> shifts_[1]), - c, - minterms_); + if(channel_enables_[3]) { + ram_[pointer_[3] & ram_mask_] = + apply_minterm( + uint16_t(a_ >> shifts_[0]), + uint16_t(b_ >> shifts_[1]), + c, + minterms_); - ++pointer_[0]; - ++pointer_[1]; - ++pointer_[2]; - ++pointer_[3]; + pointer_[3] += direction_; + } } - pointer_[0] += modulos_[0]; - pointer_[1] += modulos_[1]; - pointer_[2] += modulos_[2]; - pointer_[3] += modulos_[3]; + pointer_[0] += modulos_[0] * channel_enables_[0]; + pointer_[1] += modulos_[1] * channel_enables_[1]; + pointer_[2] += modulos_[2] * channel_enables_[2]; + pointer_[3] += modulos_[3] * channel_enables_[3]; } } diff --git a/Machines/Amiga/Blitter.hpp b/Machines/Amiga/Blitter.hpp index e76c3f511..ef3b8bfa0 100644 --- a/Machines/Amiga/Blitter.hpp +++ b/Machines/Amiga/Blitter.hpp @@ -41,13 +41,16 @@ class Blitter: public DMADevice<4> { bool advance(); private: - uint8_t minterms_ = 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 modulos_[4]{}; - int shifts_[2]{}; - bool line_mode_ = false; }; }