all repos — mgba @ 4b51783589e432166bdfbfe357426c81edd6b835

mGBA Game Boy Advance Emulator

GB: Fix IRQs firing infinitely
Jeffrey Pfau jeffrey@endrift.com
Tue, 19 Jan 2016 23:16:16 -0800
commit

4b51783589e432166bdfbfe357426c81edd6b835

parent

dfaa06d0d2465d5e66b7dae0b720f2e87922bfc0

2 files changed, 7 insertions(+), 1 deletions(-)

jump to
M src/gb/gb.csrc/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.csrc/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; }