libretro / snes9x2002

Snes9x 2002. Port of SNES9x 1.39 for libretro (was previously called PocketSNES). Heavily optimized for ARM.
37 stars 46 forks source link

Two frames of input lag added to all games #31

Closed Brunnis closed 5 years ago

Brunnis commented 5 years ago

I just noticed that this core has not one, but up to two added frames of input lag compared to the snes9x2005, snes2010 and snes9x cores. I believe this is a systematic issue affecting all games and all input running through this core. In practice, I think the added input lag should vary between one and two frames, depending on the frame processing time.

Testing can easily be carried out in the following way:

  1. Run a game.
  2. Press 'p' on the keyboard to pause emulation.
  3. Press and hold input such as the jump or fire button in the game.
  4. While still holding the button, press 'k' on the keyboard to single step the emulator until a response can be seen on the screen. Count the number of frames needed to see the response.

Examples:

Super Mario World (jumping) snes9x2002: 5 frames snes9x2005: 3 frames

Donkey Kong Country (jumping) snes9x2002: 4 frames snes9x2005: 2 frames

Brunnis commented 5 years ago

After just a quick check in libretro.c, it looks like input is polled after running the emulator, which is the wrong way of doing it. See here:

https://github.com/libretro/snes9x2002/blob/master/libretro/libretro.c#L482

EDIT: And that would explain one of the two additional frames. The other one could well be caused by the main loop entry/exit point issue that was fixed a few years ago in the other snes9x cores (ifdef called LAG_FIX, if I remember correctly).

Brunnis commented 5 years ago

Pull request to fix this issue: https://github.com/libretro/snes9x2002/pull/33