SourMesen / Mesen-S

Mesen-S is a cross-platform (Windows & Linux) SNES emulator built in C++ and C#
GNU General Public License v3.0
414 stars 102 forks source link

GB: counter interrupt pushes off OAM Stat interrupt far enough to crash Pinball Deluxe (EU) #165

Open redacted173 opened 4 years ago

redacted173 commented 4 years ago

Pinball Deluxe (EU) and Pinball Fantasies (US, EU) are really timing sensitive and use the counter interrupt, OAM Stat interrupt, and LYC Stat interrupt along with the V-Blank interrupt. The counter interrupt, $50, can occur early in a scan line which pushes off the OAM Stat interrupt. The OAM Stat interrupt, $48, polls on the Stat mode for display (non H-Blank) but, in the case of Pinball Deluxe (EU), can miss it and spill into the next scanline. This leads into a delay of Stat interrupts which eventually results in the stack over flowing and the game crashing. Looks like delaying H-Blank by a few (4?) dot clocks may fix the problem so the LDH sees the right Stat mode. It's not clear what the correct solution is, though.

Pinball Fantasies seems to catch the mode in time. Not sure what is different with Pinball Deluxe.

The following breakpoint can help find the problem before the crash: Break on: Execution Address: $48 Condition: Cycle > 128 && Scanline < 144 && SP < $DFF0