diff --git a/Machines/Amiga/Blitter.cpp b/Machines/Amiga/Blitter.cpp index 333558f29..4795f4cbc 100644 --- a/Machines/Amiga/Blitter.cpp +++ b/Machines/Amiga/Blitter.cpp @@ -14,7 +14,7 @@ using namespace Amiga; -Blitter::Blitter(uint16_t *ram, size_t size) : ram_(ram), ram_size_(size) {} +Blitter::Blitter(uint16_t *ram, size_t size) : ram_(ram), ram_mask_(uint32_t(size-1)) {} void Blitter::set_control(int index, uint16_t value) { LOG("Set control " << index << " to " << PADHEX(4) << value); @@ -61,5 +61,6 @@ uint16_t Blitter::get_status() { } bool Blitter::advance() { + ram_[addresses_[3] & ram_mask_] = 0xffff; return false; } diff --git a/Machines/Amiga/Blitter.hpp b/Machines/Amiga/Blitter.hpp index 7cebc1529..b8a372dcf 100644 --- a/Machines/Amiga/Blitter.hpp +++ b/Machines/Amiga/Blitter.hpp @@ -45,7 +45,7 @@ class Blitter { private: uint16_t *const ram_; - const size_t ram_size_; + const uint32_t ram_mask_; uint32_t addresses_[4]; uint8_t minterms_; diff --git a/Machines/Amiga/Chipset.cpp b/Machines/Amiga/Chipset.cpp index cfa83627e..12895da07 100644 --- a/Machines/Amiga/Chipset.cpp +++ b/Machines/Amiga/Chipset.cpp @@ -231,10 +231,37 @@ template <int cycle> void Chipset::output() { } if(pixels_) { - pixels_[0] = 0xffff; - pixels_[1] = 0x0000; - pixels_[2] = 0xffff; - pixels_[3] = 0x0000; + // TODO: this is obviously nonsense. + pixels_[0] = palette_[ + ((current_bitplanes_[0]&1) << 0) | + ((current_bitplanes_[1]&1) << 1) | + ((current_bitplanes_[2]&1) << 2) | + ((current_bitplanes_[3]&1) << 3) | + ((current_bitplanes_[4]&1) << 4) + ]; + pixels_[1] = palette_[ + ((current_bitplanes_[0]&2) >> 1) | + ((current_bitplanes_[1]&2) << 0) | + ((current_bitplanes_[2]&2) << 1) | + ((current_bitplanes_[3]&2) << 2) | + ((current_bitplanes_[4]&2) << 3) + ]; + pixels_[2] = palette_[ + ((current_bitplanes_[0]&4) >> 2) | + ((current_bitplanes_[1]&4) >> 1) | + ((current_bitplanes_[2]&4) << 0) | + ((current_bitplanes_[3]&4) << 1) | + ((current_bitplanes_[4]&4) << 2) + ]; + pixels_[3] = 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; } } @@ -408,9 +435,6 @@ template <bool stop_on_cpu> Chipset::Changes Chipset::run(HalfCycles length) { did_fetch_ = false; } - std::fill(even_playfield_.begin(), even_playfield_.end(), 0); - std::fill(odd_playfield_.begin(), odd_playfield_.end(), 0); - if(y_ == frame_height_) { ++changes.vsyncs; interrupt_requests_ |= InterruptMask<InterruptFlag::VerticalBlank>::value; @@ -430,18 +454,29 @@ template <bool stop_on_cpu> Chipset::Changes Chipset::run(HalfCycles length) { } void Chipset::post_bitplanes(const BitplaneData &data) { - // Convert to future pixels. - const int odd_offset = line_cycle_ + odd_delay_; - const int even_offset = line_cycle_ + odd_delay_; - for(int x = 0; x < 16; x++) { - const uint16_t mask = uint16_t(1 << x); - even_playfield_[x + even_offset] = uint8_t( - ((data[0] & mask) | ((data[2] & mask) << 1) | ((data[4] & mask) << 2)) >> x - ); - odd_playfield_[x + odd_offset] = uint8_t( - ((data[1] & mask) | ((data[3] & mask) << 1) | ((data[5] & mask) << 2)) >> x - ); + // 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; +// current_bitplanes_[3] = 0x1111; + + // Convert to future pixels. +// const int odd_offset = line_cycle_ + odd_delay_; +// const int even_offset = line_cycle_ + odd_delay_; +// for(int x = 0; x < 16; x++) { +// const uint16_t mask = uint16_t(1 << x); +// even_playfield_[x + even_offset] = uint8_t( +// ((data[0] & mask) | ((data[2] & mask) << 1) | ((data[4] & mask) << 2)) >> x +// ); +// odd_playfield_[x + odd_offset] = uint8_t( +// ((data[1] & mask) | ((data[3] & mask) << 1) | ((data[5] & mask) << 2)) >> x +// ); +// } } void Chipset::update_interrupts() { diff --git a/Machines/Amiga/Chipset.hpp b/Machines/Amiga/Chipset.hpp index b03fa36b4..271a19106 100644 --- a/Machines/Amiga/Chipset.hpp +++ b/Machines/Amiga/Chipset.hpp @@ -179,7 +179,17 @@ class Chipset { uint16_t *pixels_ = nullptr; void flush_output(); - using BitplaneData = std::array<uint16_t, 6>; + struct BitplaneData: public std::array<uint16_t, 6> { + BitplaneData &operator >>= (int c) { + (*this)[0] >>= c; + (*this)[1] >>= c; + (*this)[2] >>= c; + (*this)[3] >>= c; + (*this)[4] >>= c; + (*this)[5] >>= c; + return *this; + } + }; class Bitplanes: public DMADevice<6> { public: @@ -199,8 +209,9 @@ class Chipset { void post_bitplanes(const BitplaneData &data); - std::array<uint8_t, 912> even_playfield_; - std::array<uint8_t, 912> odd_playfield_; + BitplaneData current_bitplanes_, next_bitplanes_; +// std::array<uint8_t, 912> even_playfield_; +// std::array<uint8_t, 912> odd_playfield_; int odd_delay_ = 0, even_delay_ = 0; // MARK: - Copper. diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme index eb9346987..85c8c1e2c 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme +++ b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme @@ -65,7 +65,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - enableAddressSanitizer = "YES" enableASanStackUseAfterReturn = "YES" disableMainThreadChecker = "YES" launchStyle = "0" diff --git a/Processors/68000/Implementation/68000Implementation.hpp b/Processors/68000/Implementation/68000Implementation.hpp index 47245e6cc..ca8449fb4 100644 --- a/Processors/68000/Implementation/68000Implementation.hpp +++ b/Processors/68000/Implementation/68000Implementation.hpp @@ -1896,16 +1896,10 @@ template <class T, bool dtack_is_implicit, bool signal_will_perform> void Proces negative_flag_ = zero_result_ & 0x80000000; break; - case Operation::STOP: { - static int stops = 0; - ++stops; - if(stops == 559) { - printf(""); - } - + case Operation::STOP: apply_status(prefetch_queue_.halves.low.full); execution_state_ = ExecutionState::Stopped; - } break; + break; /* Development period debugging.