I'm trying to implement the MMC3 IRQ, but I'm failing the first of blargg's tests called clocking. I get the error "Should reload when clocked when counter is 0", but from my code I'm definitely reloading the counter. Looking at the source of the test, I'm presuming that it's a timing issue, but I've looked at the wiki and other forum posts, and I'm not sure where I'm going wrong. Am I missing something?
This code runs every time CHR is being read:
This code runs every time CHR is being read:
Code:
if(this->prevA12 == 0 && (addr >> 15)) {
if(this->CPUcycleCount - this->prevCPUCycleCount > 2) {
if(this->IRQReload) {
this->IRQReload = false;
this->IRQCounter = this->IRQLatch;
} else {
this->IRQCounter--;
if(this->IRQCounter == 0) {
this->IRQCounter = this->IRQLatch;
if(this->IRQEnabled) this->IRQCalled = true;
}
}
}
this->prevCPUCycleCount = this->CPUcycleCount;
}
this->prevA12 = addr >> 15;
if(this->CPUcycleCount - this->prevCPUCycleCount > 2) {
if(this->IRQReload) {
this->IRQReload = false;
this->IRQCounter = this->IRQLatch;
} else {
this->IRQCounter--;
if(this->IRQCounter == 0) {
this->IRQCounter = this->IRQLatch;
if(this->IRQEnabled) this->IRQCalled = true;
}
}
}
this->prevCPUCycleCount = this->CPUcycleCount;
}
this->prevA12 = addr >> 15;