Closed Bunkai9448 closed 1 year ago
Seems that at some point mGBA gets into a loop where the STAT interrupt occurs within STAT interrupt handler. Game only enables mode 0 IRQ for STAT anyways. Interestingly, the game does write to STAT during the interrupt handler, and that ends up triggering the IRQ? Which that shouldn't be triggering the STAT IRQ in this case (especially since I was using CGB mode, might be some bug with STAT write handling?)
While I'm working on some other stuff, @CasualPokePlayer can you check if this is a regression? It was totally broken before #1473 was fixed, but there's a good range there in the middle.
The game crashes the same way on the commit that fixed that issue.
Although interesting, it doesn't crash if I select CGB mode on that commit. Which means some sort of regression is causing it to occur in CGB mode mode too (CGB-DMG mode having the STAT bug instead of not like before?). Suppose anyways that probably means STAT bug is triggering an IRQ (although it shouldn't be in this case).
https://github.com/LIJI32/SameBoy/blob/76b881c2e153e164485814257fee472572dd8482/Core/sm83_cpu.c#L148-L151 This comment from SameBoy's source seems interesting (as the mode 1->2 transition is "4" cycles away (according to mGBA debugger) when STAT is written to)
Game rom: Initial D Gaiden (Japan) (SGB Enhanced) CRC-32: 6CC56612
The game crashes right after entering in a race. It doesn't matter if it is in time attack (タイムアタック) or in story mode (シナリオ)
Here's the bug report from the PC (v0.9.3) version bug initial-d gb.zip
It also happens on the same version (v0.9.3) in the psVita.
PS: I've tried in the lastest version of hhugboy and BGB and it doesn't happen in those, that's why i think is a mgba bug.