zeta0134 / LuaGB

A gameboy emulator written in pure Lua. Work in progress.
BSD 3-Clause "New" or "Revised" License
410 stars 33 forks source link

Emulation runs too fast when the LCD is disabled #17

Open zeta0134 opened 5 years ago

zeta0134 commented 5 years ago

Games can turn off the LCD entirely, which blanks the screen to white and turns off any graphics related timings and interrupts until it is re-enabled. The Love2D shell presently relies on vBlank timing to determine how long to run the emulator for inbetween each host frame, and targets 60 Hz for the host timing. This mostly works, but fails when games disable the LCD, causing a single host frame to run for many hardware frames and desync the timing. This can cause considerable problems with audio sync depending on how long the game leaves the display powered off.

This is particularly noticeable in Pokemon Pinball, which blanks the display in this manner every time the ball moves from the top of the table to the bottom, or vice versa. Many retail Gameboy Color games do this during screen transitions to load new graphics more quickly, so it's a widespread bug.