GB: Fix IRQs firing infinitely

This commit is contained in:
Jeffrey Pfau 2016-01-19 23:16:16 -08:00
parent dfaa06d0d2
commit 4b51783589
2 changed files with 7 additions and 1 deletions

View File

@ -137,24 +137,31 @@ void GBUpdateIRQs(struct GB* gb) {
if (!irqs) {
return;
}
gb->cpu->irqh.setInterrupts(gb->cpu, false);
if (irqs & (1 << GB_IRQ_VBLANK)) {
LR35902RaiseIRQ(gb->cpu, GB_VECTOR_VBLANK);
gb->memory.io[REG_IF] &= ~(1 << GB_IRQ_VBLANK);
return;
}
if (irqs & (1 << GB_IRQ_LCDSTAT)) {
LR35902RaiseIRQ(gb->cpu, GB_VECTOR_LCDSTAT);
gb->memory.io[REG_IF] &= ~(1 << GB_IRQ_LCDSTAT);
return;
}
if (irqs & (1 << GB_IRQ_TIMER)) {
LR35902RaiseIRQ(gb->cpu, GB_VECTOR_TIMER);
gb->memory.io[REG_IF] &= ~(1 << GB_IRQ_TIMER);
return;
}
if (irqs & (1 << GB_IRQ_SIO)) {
LR35902RaiseIRQ(gb->cpu, GB_VECTOR_SIO);
gb->memory.io[REG_IF] &= ~(1 << GB_IRQ_SIO);
return;
}
if (irqs & (1 << GB_IRQ_KEYPAD)) {
LR35902RaiseIRQ(gb->cpu, GB_VECTOR_KEYPAD);
gb->memory.io[REG_IF] &= ~(1 << GB_IRQ_KEYPAD);
}
}

View File

@ -101,7 +101,6 @@ void LR35902Tick(struct LR35902Core* cpu) {
if (cpu->irqPending) {
cpu->index = cpu->sp;
cpu->irqPending = false;
cpu->irqh.setInterrupts(cpu, false);
cpu->instruction = _LR35902InstructionIRQ;
break;
}