GB: Fix IRQs firing infinitely
Jeffrey Pfau jeffrey@endrift.com
Tue, 19 Jan 2016 23:16:16 -0800
2 files changed,
7 insertions(+),
1 deletions(-)
M
src/gb/gb.c
→
src/gb/gb.c
@@ -137,24 +137,31 @@ int irqs = gb->memory.ie & gb->memory.io[REG_IF];
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); } }
M
src/lr35902/lr35902.c
→
src/lr35902/lr35902.c
@@ -101,7 +101,6 @@ case LR35902_CORE_FETCH:
if (cpu->irqPending) { cpu->index = cpu->sp; cpu->irqPending = false; - cpu->irqh.setInterrupts(cpu, false); cpu->instruction = _LR35902InstructionIRQ; break; }