1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-22 12:33:29 +00:00

Compare x and y separately, wake immediately from a sleep, log more.

This commit is contained in:
Thomas Harte 2021-12-12 17:26:33 -05:00
parent f3ec7d54bb
commit 600abc55b5

View File

@ -23,8 +23,9 @@ namespace {
bool satisfies_raster(uint16_t position, uint16_t blitter_status, uint16_t *instruction) { bool satisfies_raster(uint16_t position, uint16_t blitter_status, uint16_t *instruction) {
const uint16_t mask = 0x8000 | (instruction[1] & 0x7ffe); const uint16_t mask = 0x8000 | (instruction[1] & 0x7ffe);
return return
(position & mask) >= (instruction[0] & mask) (position & mask & 0xff00) >= (instruction[0] & mask & 0xff00) &&
&& (!(blitter_status & 0x4000) || (instruction[1] & 0x8000)); (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; default: return false;
case State::Waiting: case State::Waiting:
if(satisfies_raster(position, blitter_status, instruction_)) { if(!satisfies_raster(position, blitter_status, instruction_)) {
LOG("Unblocked waiting for " << PADHEX(4) << instruction_[0] << " at " << position);
state_ = State::FetchFirstWord;
}
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: case State::FetchFirstWord:
instruction_[0] = ram_[address_ & ram_mask_]; instruction_[0] = ram_[address_ & ram_mask_];
++address_; ++address_;
state_ = State::FetchSecondWord; state_ = State::FetchSecondWord;
LOG("First word fetch at " << PADHEX(4) << position);
break; break;
case State::FetchSecondWord: { case State::FetchSecondWord: {
@ -100,6 +103,7 @@ bool Copper::advance_dma(uint16_t position, uint16_t blitter_status) {
// Read in the second instruction word. // Read in the second instruction word.
instruction_[1] = ram_[address_ & ram_mask_]; instruction_[1] = ram_[address_ & ram_mask_];
++address_; ++address_;
LOG("Second word fetch at " << PADHEX(4) << position);
// Check for a MOVE. // Check for a MOVE.
if(!(instruction_[0] & 1)) { 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. // Got to here => this is a WAIT or a SKIP.
if(!(instruction_[1] & 1)) { if(!(instruction_[1] & 1)) {
// A WAIT. Just note that this is now waiting; the proper test // A WAIT. Empirically, I don't think this waits at all if the test is
// will be applied from the next potential `advance_dma` onwards. // already satisfied.
state_ = State::Waiting; state_ = State::Waiting;
LOG("Will wait from " << PADHEX(4) << position);
break; break;
} }