From c6535bf03573c8d28e8158524b5a77539fef7c89 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 25 Oct 2021 13:34:36 -0700 Subject: [PATCH] Switches bitplane shifter to returning four high-res pixels at a time. --- Machines/Amiga/Chipset.cpp | 33 +++++++++++++-------------------- Machines/Amiga/Chipset.hpp | 19 ++++++++++++++----- Machines/Amiga/Copper.cpp | 5 +++-- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/Machines/Amiga/Chipset.cpp b/Machines/Amiga/Chipset.cpp index e3e45ef20..34382c61c 100644 --- a/Machines/Amiga/Chipset.cpp +++ b/Machines/Amiga/Chipset.cpp @@ -181,26 +181,13 @@ template void Chipset::output() { if(pixels_) { // TODO: this doesn't support dual playfields; use an alternative // palette table for that. + const uint32_t source = bitplane_pixels_.get(is_high_res_); + bitplane_pixels_.shift(is_high_res_); - if(is_high_res_) { - pixels_[0] = palette_[bitplane_pixels_.get()]; - bitplane_pixels_.shift(); - - pixels_[1] = palette_[bitplane_pixels_.get()]; - bitplane_pixels_.shift(); - - pixels_[2] = palette_[bitplane_pixels_.get()]; - bitplane_pixels_.shift(); - - pixels_[3] = palette_[bitplane_pixels_.get()]; - bitplane_pixels_.shift(); - } else { - pixels_[0] = pixels_[1] = palette_[bitplane_pixels_.get()]; - bitplane_pixels_.shift(); - - pixels_[2] = pixels_[3] = palette_[bitplane_pixels_.get()]; - bitplane_pixels_.shift(); - } + pixels_[0] = palette_[source >> 24]; + pixels_[1] = palette_[(source >> 16) & 0xff]; + pixels_[2] = palette_[(source >> 8) & 0xff]; + pixels_[3] = palette_[source & 0xff]; // QUICK HACK: dump sprite pixels: // @@ -1378,7 +1365,13 @@ int Chipset::Mouse::get_number_of_buttons() { } void Chipset::Mouse::set_button_pressed(int button, bool is_set) { - const uint8_t mask = 0x80 >> button; + // TODO: this is nothing like correct; the second and optional + // third buttons aren't exposed via CIA A like the first is, + // so there's not really a single location of buttons. + // + // Leaving as is for now, as this gives me a working left + // button in port 0 and that'll do. + const auto mask = uint8_t(0x40 << button); button_state = (button_state & ~mask) | (is_set ? 0 : mask); diff --git a/Machines/Amiga/Chipset.hpp b/Machines/Amiga/Chipset.hpp index 7e26578b6..ec14b5ddb 100644 --- a/Machines/Amiga/Chipset.hpp +++ b/Machines/Amiga/Chipset.hpp @@ -226,13 +226,22 @@ class Chipset: private ClockingHint::Observer { int odd_delay, int even_delay); - void shift() { - (*this)[1] = ((*this)[1] << 8) | ((*this)[0] >> 56); - (*this)[0] <<= 8; + void shift(bool high_res) { + constexpr int shifts[] = {16, 32}; + + (*this)[1] = ((*this)[1] << shifts[high_res]) | ((*this)[0] >> (64 - shifts[high_res])); + (*this)[0] <<= shifts[high_res]; } - uint8_t get() { - return uint8_t((*this)[1] >> 56); + uint32_t get(bool high_res) { + if(high_res) { + return uint32_t((*this)[1] >> 32); + } else { + uint32_t result = uint16_t((*this)[1] >> 48); + result = ((result & 0xff00) << 8) | (result & 0x00ff); + result |= result << 8; + return result; + } } } bitplane_pixels_; diff --git a/Machines/Amiga/Copper.cpp b/Machines/Amiga/Copper.cpp index 9c45797af..61777ddd6 100644 --- a/Machines/Amiga/Copper.cpp +++ b/Machines/Amiga/Copper.cpp @@ -6,9 +6,10 @@ // Copyright © 2021 Thomas Harte. All rights reserved. // -#include - +#ifndef NDEBUG #define NDEBUG +#endif + #define LOG_PREFIX "[Copper] " #include "../../Outputs/Log.hpp"