diff --git a/Machines/Amiga/Blitter.cpp b/Machines/Amiga/Blitter.cpp index 1e4d38a69..671398ba6 100644 --- a/Machines/Amiga/Blitter.cpp +++ b/Machines/Amiga/Blitter.cpp @@ -59,6 +59,6 @@ uint16_t Blitter::get_status() { } bool Blitter::advance() { - ram_[(pointer_[3] >> 1) & ram_mask_] = 0xffff; + ram_[pointer_[3] & ram_mask_] = 0xffff; return false; } diff --git a/Machines/Amiga/Chipset.cpp b/Machines/Amiga/Chipset.cpp index 714e4a6a0..52c3213fc 100644 --- a/Machines/Amiga/Chipset.cpp +++ b/Machines/Amiga/Chipset.cpp @@ -32,11 +32,11 @@ template struct DMAMask: Mask {}; } -Chipset::Chipset(uint16_t *ram, size_t size) : - blitter_(*this, ram, size), - bitplanes_(*this, ram, size), - copper_(*this, ram, size), - disk_(*this, ram, size), +Chipset::Chipset(uint16_t *ram, size_t word_size) : + blitter_(*this, ram, word_size), + bitplanes_(*this, ram, word_size), + copper_(*this, ram, word_size), + disk_(*this, ram, word_size), crt_(908, 4, Outputs::Display::Type::PAL50, Outputs::Display::InputDataType::Red4Green4Blue4) { } @@ -231,7 +231,9 @@ template void Chipset::output() { } if(pixels_) { - // TODO: this is obviously nonsense. + // TODO: this is obviously nonsense. Probably do a table-based + // planar-to-chunky up front into 8-bit pockets, and just shift that. + pixels_[0] = palette_[ ((current_bitplanes_[0]&1) << 0) | ((current_bitplanes_[1]&1) << 1) | @@ -253,13 +255,13 @@ template void Chipset::output() { ((current_bitplanes_[3]&4) << 1) | ((current_bitplanes_[4]&4) << 2) ]; - pixels_[3] = palette_[ + pixels_[3] = 0;/*palette_[ ((current_bitplanes_[0]&8) >> 3) | ((current_bitplanes_[1]&8) >> 2) | ((current_bitplanes_[2]&8) >> 1) | ((current_bitplanes_[3]&8) << 0) | ((current_bitplanes_[4]&8) << 1) - ]; + ];*/ current_bitplanes_ >>= 4; pixels_ += 4; @@ -457,9 +459,6 @@ void Chipset::post_bitplanes(const BitplaneData &data) { // TODO: should probably store for potential delay? current_bitplanes_ = data; - if(data[0] || data[1]) { - printf(""); - } // current_bitplanes_[0] = 0xaaaa; // current_bitplanes_[1] = 0x3333; // current_bitplanes_[2] = 0x4444; @@ -958,4 +957,3 @@ void Chipset::set_display_type(Outputs::Display::DisplayType type) { Outputs::Display::DisplayType Chipset::get_display_type() const { return crt_.get_display_type(); } - diff --git a/Machines/Amiga/Chipset.hpp b/Machines/Amiga/Chipset.hpp index fd4f02a4b..3cb31818a 100644 --- a/Machines/Amiga/Chipset.hpp +++ b/Machines/Amiga/Chipset.hpp @@ -55,7 +55,7 @@ enum class DMAFlag: uint16_t { class Chipset { public: - Chipset(uint16_t *ram, size_t size); + Chipset(uint16_t *ram, size_t word_size); struct Changes { int hsyncs = 0; diff --git a/Machines/Amiga/DMADevice.hpp b/Machines/Amiga/DMADevice.hpp index 9b1fe10ec..7a3da7d1c 100644 --- a/Machines/Amiga/DMADevice.hpp +++ b/Machines/Amiga/DMADevice.hpp @@ -19,8 +19,8 @@ class Chipset; class DMADeviceBase { public: - DMADeviceBase(Chipset &chipset, uint16_t *ram, size_t size) : - chipset_(chipset), ram_(ram), ram_mask_(uint32_t((size - 1) >> 1)) {} + DMADeviceBase(Chipset &chipset, uint16_t *ram, size_t word_size) : + chipset_(chipset), ram_(ram), ram_mask_(uint32_t(word_size - 1)) {} protected: Chipset &chipset_; @@ -36,11 +36,23 @@ template class DMADevice: public DMADeviceBase { template void set_pointer(uint16_t value) { static_assert(id < num_addresses); static_assert(shift == 0 || shift == 16); - pointer_[id] = (pointer_[id] & (0xffff'0000 >> shift)) | uint32_t(value << shift); + byte_pointer_[id] = (byte_pointer_[id] & (0xffff'0000 >> shift)) | uint32_t(value << shift); + pointer_[id] = byte_pointer_[id] >> 1; + } + + template uint16_t get_pointer() { + // Restore the original least-significant bit. + const uint32_t source = (pointer_[id] << 1) | (byte_pointer_[id] & 1); + return uint16_t(source >> shift); } protected: + // These are shifted right one to provide word-indexing pointers; + // subclasses should use e.g. ram_[pointer_[0] & ram_mask_] directly. std::array pointer_{}; + + private: + std::array byte_pointer_{}; }; }