Wednesday, 2 March 2016

Super NES emulation: snes9x-sdl

The SNES emulation on snes9x-sdl has been one of my disappointments on this project. Although some games are playable, I frequenty encounter huge slowdowns that I have not been able to fix. The strange thing is that, as the slowdowns appear suddenly in the middle of a game, they seem to be triggered by some event that I have not been able to identify.

You can find the original source code right here:

Anyway, I might take some time in the future to work on this, but in the meantime, you might be interested by some tweaks that I have done in snes9x-sdl.

  • I have made a minor optimization in the 2x upscale filter, and written a 3x upscale filter (file filter/blit.cpp). This enables quasi-fullscreen on a 720p display. The calls to this filter have been hard-coded, along with other optimizations, in sdl/sdlvideo.cpp
  • I have hard-coded my key setup in sdl/sdlinput.cpp. I've done that 2 years ago, so I don't remember exactly why this was needed, but it must have been convenient :-)
  • I have changed an audio rate setting in sdl/sdlmain.cpp. This one has been a pain to fix. I did not have sound at first, and through debugging, I noticed that this value was the culprit. Changing it made everything fine afterward.

My own version of the emulator is on my github page: The pixbox.patch file at the root lists all the changes I have made.

To compile, make sure the following environment variables are set, and gcc/g++ are the 4.9.1 versions (not sure this is very important in practice):
 CC = gcc  
 CXX = g++  
 AS = as  
 CFLAGS += -O3 -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=vfpv3-d16   

/media/BBB/lib is the path where the SDL libraries have been installed. And then, just compile, in the classical Linux way:
 ./configure --prefix=/media/BBB/bin --enable-mtune=cortex-a8 --disable-gamepad

You can now run the emulator as follows (adapt to your own path):
 /media/BBB/sources/snes9x-sdl-master-optim/sdl/snes9x-sdl -nomp5 -nojustifier -nomouse -nosuperscope -port1 pad1 -port2 pad2 -playbackrate 40960 /media/BBB/roms/snes/your_rom  

No comments:

Post a Comment