Sunday, December 18, 2011

SNES emulator with original pads

If you are a retro gamer like me then you know emulators. With emulators you can play variuos games of old consoles. Less known is the ability to connect the original gamepads to your computer. In most cases you need to build or buy an adapter. With this article I want you to show how to connect the original SNES gamepads to your parallel port on your PC and play games with them. I have build an adapter out of my old SNES console to keep the original gamepads intact. Before youthink about building an adapter for yourself make sure that your parallel port supports EPP: 

# dmesg | grep parport
[   12.133671] parport0: PC-style at 0x378 [PCSPP,TRISTATE,EPP]

If your parallel port supports EPP then you can continue building the adapter. The following image shows how to connect your SNES pads to your parallel port:

The 6 diodes on the pins 4-9 on your parallel port are connected at the end and then connected to pin 7 of every SNES pad you want to use. The other pins can be wired directly. For each gamepad you want to connect you need a seperate data line. With this layout you are able to use up to five SNES gamepads. I have only drawed a image with one connected gamepad to keep it clear. When you have created your own adapter then connect it to the parallel port of your pc. The next image is my adapter:

Then load the driver. First remove the lp driver if necessary:

# rmmod lp

Next load the gamecon driver:

# modprobe gamecon map=0,1,1,0,0,0

Check the logs:

# dmesg
input: SNES pad as /devices/virtual/input/input6
input: SNES pad as /devices/virtual/input/input7

And check if the input devices were created:

# ls /dev/input/js*
/dev/input/js0  /dev/input/js1

Then do a simple check if the gamepads work. Execute cat on one of the js devices and press any button on your gamepad. You should see some weird characters on your screen:

# cat /dev/input/js0

About the map parameter of the gamecon driver: the first 0 in the array defines which parallel port to use (0 = first parallel port, 1 = second parallel port). The five coming digits define which gamepad you want to use:

0 None
1 SNES pad
2 NES pad
9 SNES mouse

I use the first parallel port on my pc with two SNES gamepads.
Now you need an emulator to play the SNES games. I like to use xe. First get the xe binary. It is available precompile and should meet your needs:

# cd /usr/src/
# wget

Then extract the tar file and change into the new directory:

# tar xf xe-x86-32-bin.2.16.2.tar.bz2
# cd xe-x86

Then Link the binary and install it:

# make
# make install
xe successfully installed

The xe binary should be available under /usr/local/bin:

# ls -lah /usr/local/bin/xe
lrwxrwxrwx 1 root root 20 2011-12-17 23:20 /usr/local/bin/xe -> /usr/local/lib/xe/xe

Obviously it is not a binary, it is a symbolic link. But that should not matter. Start xe with a game:

$ xe custom_rom.smc

A simple gui will open and the game will start. Press CTRL+1 simultanously to activate gamepad 1 and CTRL+2 to activate gamepad 2. Have fun.

Documentation how to set up an adapter and which gamepads are supported: