Overclocking In An SNES Emulator
The bsnes emulator has a new overclocking mode to eliminate slowdowns in SNES games while keeping the gameplay speed accurate. We’re emulating old SNES hardware on modern machines that are vastly more powerful. Eliminating slowdowns should be trivial, right? For an emulator such as bsnes, which is written to achieve essentially pixel-perfect accuracy when emulating, the problem is decidedly non-trivial. Stick around to learn why.
The Super Nintendo was an impressive system, for its time — mostly. The SNES framerate is locked to 60 FPS, which is a bit surprising considering the NTSC standard was only 30 FPS. NTSC calls for 30 frames per second, but those are interlaced frames. 30 times a second the even scanlines are updated, and 30 times a second the odd scanlines are updated. So 60 times a second, half of the screen is updated, alternating between the even and odd lines.
At the top of each frame the equivalent of half a scanline marks whether the rest of the frame is even or odd scanlines. In order to produce a clean 60 FPS, the SNES didn’t interlace, and just always wrote to the same 240 scanlines. This is also why retro consoles can look so terrible on modern monitors. The blank scanlines were hidden by the analog fuzziness of CRT TVs.
The SNES primary processor runs all the game logic and updates the graphics 60 times per second, finishing each frame’s calculations before the TV began writing that frame to the screen. Games were generally carefully written to make sure each frame’s processing would finish within that 16 millisecond window.
Most games have a few scenarios where lots of things are happening at once, and the processor just can’t keep up with the framerate. In this case, the game begins to lag. Since the framerate is hard synced to 60fps, the previous frame is simply shown again, and the game is paused for that frame while processing finishes.
The bsnes solution is a clever one. Virtual scanlines are added, but the audio and video emulation is paused. This allows the whole process to happen very rapidly, and yet continue to sync with the normal 60 FPS. Below is the Gradius III demo, showing off the results.
Header image: Sandos (CC BY-SA 3.0).
from Hackaday https://ift.tt/2N4WnsX
via IFTTT