mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.63k stars 770 forks source link

[Wii] Framerate not locked? #332

Closed SuperrSonic closed 8 years ago

SuperrSonic commented 8 years ago

I noticed that when a game is constantly dropping fps like FFVI, and the game suddenly switches to an area that's full speed the framerate will go up to 70+ for a few moments until it goes back to normal. During this period there is noticeable tearing.

Similarly in a specific Sonic Adv2 stage(ice paradise) going too fast causes a jerky motion kind of thing, not exactly tearing, but the framerate counter is constantly 60.00 throughout the acts, sound is also perfect.

endrift commented 8 years ago

Thanks for filing this issue. I've been aware of it for a while, but keep forgetting to fix it, so this is a good kick in the ass. What's going on is the way the framerate locking works is by counting the vblanks that have occurred since you started drawing a frame. If it's >0, then it doesn't wait for a frame sync, as that would halve framerate if it's running just under 60fps.

The bug here is that it doesn't reset that counter between frames, so if a game slows down, then it turns off the frame limiter, and when it is back up to speed, the frame limiter is still off until it catches up to the expected number of blanks.

SuperrSonic commented 8 years ago

I have a doubt about this change, shouldn't line 398 use > instead of >= ? I get noticeable fps drops otherwise.