From 600abc55b576be876ecae11489969f381757309a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 12 Dec 2021 17:26:33 -0500 Subject: [PATCH] Compare x and y separately, wake immediately from a sleep, log more. --- Machines/Amiga/Copper.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Machines/Amiga/Copper.cpp b/Machines/Amiga/Copper.cpp index ced0a4b43..1006256e0 100644 --- a/Machines/Amiga/Copper.cpp +++ b/Machines/Amiga/Copper.cpp @@ -23,8 +23,9 @@ namespace { bool satisfies_raster(uint16_t position, uint16_t blitter_status, uint16_t *instruction) { const uint16_t mask = 0x8000 | (instruction[1] & 0x7ffe); return - (position & mask) >= (instruction[0] & mask) - && (!(blitter_status & 0x4000) || (instruction[1] & 0x8000)); + (position & mask & 0xff00) >= (instruction[0] & mask & 0xff00) && + (position & mask & 0x00ff) >= (instruction[0] & mask & 0x00ff) && + (!(blitter_status & 0x4000) || (instruction[1] & 0x8000)); } } @@ -80,16 +81,18 @@ bool Copper::advance_dma(uint16_t position, uint16_t blitter_status) { default: return false; case State::Waiting: - if(satisfies_raster(position, blitter_status, instruction_)) { - LOG("Unblocked waiting for " << PADHEX(4) << instruction_[0] << " at " << position); - state_ = State::FetchFirstWord; + if(!satisfies_raster(position, blitter_status, instruction_)) { + return false; } - return false; + LOG("Unblocked waiting for " << PADHEX(4) << instruction_[0] << " at " << PADHEX(4) << position << " with mask " << PADHEX(4) << (instruction_[1] & 0x7ffe)); + state_ = State::FetchFirstWord; + [[fallthrough]]; case State::FetchFirstWord: instruction_[0] = ram_[address_ & ram_mask_]; ++address_; state_ = State::FetchSecondWord; + LOG("First word fetch at " << PADHEX(4) << position); break; case State::FetchSecondWord: { @@ -100,6 +103,7 @@ bool Copper::advance_dma(uint16_t position, uint16_t blitter_status) { // Read in the second instruction word. instruction_[1] = ram_[address_ & ram_mask_]; ++address_; + LOG("Second word fetch at " << PADHEX(4) << position); // Check for a MOVE. if(!(instruction_[0] & 1)) { @@ -130,9 +134,10 @@ bool Copper::advance_dma(uint16_t position, uint16_t blitter_status) { // Got to here => this is a WAIT or a SKIP. if(!(instruction_[1] & 1)) { - // A WAIT. Just note that this is now waiting; the proper test - // will be applied from the next potential `advance_dma` onwards. + // A WAIT. Empirically, I don't think this waits at all if the test is + // already satisfied. state_ = State::Waiting; + LOG("Will wait from " << PADHEX(4) << position); break; }