diff --git a/src/gb/gb.c b/src/gb/gb.c index 538d14412..703e79003 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -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); } } diff --git a/src/lr35902/lr35902.c b/src/lr35902/lr35902.c index 3b8001ba5..5e0d1bbea 100644 --- a/src/lr35902/lr35902.c +++ b/src/lr35902/lr35902.c @@ -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; }