Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IRQ dispatch bugfix: PIC emulation used a global variable to determine
whether to check for IRQs and dispatch! While it generally worked, running certain demos or games would eventually hit a corner case where one device raises an IRQ, and one device lowers an IRQ that was raised, that would cause IRQs to get stuck. Also responsible for stuck IRQs was the way that PIC_runIRQs() was written. It is written to dispatch one IRQ (in IRQ priority order) then break from the loop (or dispatch two IRQs if IRQ 9 -> IRQ 2 cascade). The bug in that routine is that despite handling only one IRQ it reset the flag as if all IRQs had been handled, which yet again can cause stuck IRQs. This fix changes the behavior of IRQ dispatch. When a device raises an IRQ, the global flag is set as before. The new code avoids stuck IRQs by NOT clearing the flag when the IRQ is lowered. PIC_runIRQs() has been changed to not clear the flag unless there are absolutely no IRQs pending to handle. Preliminary testing shows that this fix resolves problems with Crystal Dream II and GUS music getting stuck at a random point throughout the demo.
- Loading branch information