Repository navigation
Fixed button delays while playing NES games.
Before, button presses were read at the start of each emulated frame. Most games read the controller in the vertical-blank interrupt, about 14 ms (roughly 0.85 of a frame) later, so they were acting on a press that was already 14 ms old.
Now the game gets the press as it reads the controller, so that staleness is essentially gone. Expect about 14 ms less delay on most games.
What's still there:
Display: a picture still goes through Windows' desktop compositor, which adds roughly a frame (16 ms), and sometimes two, before you see it. This is probably the biggest remaining delay and I haven't touched it.
Sound: I restored the original audio code, so sound delay is unchanged. The default setting is about 160 ms in total (100 ms from the Latency setting, plus 60 ms in the device queue).
Games themselves: many NES games respond a frame or two after a press by design, and that is built into the game and not something to fix.
Rough picture"Before, button presses were read at the start of each emulated frame. Most games read the controller in the vertical-blank interrupt, about 14 ms (roughly 0.85 of a frame) later, so they were acting on a press that was already 14 ms old.
Now the game gets the press as it reads the controller, so that staleness is essentially gone. Expect about 14 ms less delay on most games.
Rough picture:
If the total delay from pressing a button to seeing the result was about 50–65 ms, it should now be about 35–50 ms. You'll feel a difference in fast games, but it won't feel like a different emulator.
What would possibly help more:
Lower the Latency setting (Audio > Latency > Low or Lowest). This only changes the sound, but if what you notice is sound arriving late, it's the biggest single gain, up to roughly 100 ms.
Switch the display to DirectX with a low-latency swap chain. This could save another frame or two. It's a bigger change and I'd want to test it carefully, since my last speed-up attempt broke the audio.
Add an optional "run-ahead" mode that emulates a frame or two early and discards it, which can remove the game's own built-in delay. It's most effective on games that respond one or two frames late, and it uses extra CPU.
If the total delay from pressing a button to seeing the result was about 50–65 ms, it should now be about 35–50 ms. You'll feel a difference in fast games, but it won't feel like a different emulator.