Adventures in retro gaming: NES in Mednafen on Ubuntu

Mednafen running Super Mario 3

Every once in a while I get an urge to revisit some of the cookie fueled nights of gaming that I remember so well from my early teens. The actual games are easy enough to find, a google search for “nes roms” will turn up all your sentimental favourites. The big question is how to play them.

I worked this out once on windows but found the most common program (GFCEU) for playing ROMS on Ubuntu really aggravating. Aggravating and crashy. A little digging turned up an alternative called “Mednafen”. Happily its already in the repositories and can be installed with the command:

mike@sleepycat:~$ sudo aptitude install mednafen

Its a command line program and the manual for it is pretty terrible, the helpfile isn’t helpful and their website isn’t much better. It fact it doesn’t have much going for it other than the fact that its a really good emulator.

Since the documentation seems to only offer two levels of detail (“none” and “everything but with out explaining what anything is”) here is what worked for me.

Getting it going is as easy as pointing it to one of your existing ROMS:

mike@sleepycat:~$ mednafen Desktop/NESgames/Mario3.nes

Assuming you like the default keyboard layout thats really all that needs to happen.

My difficulties came from my strong dislike of the default keyboard keys chosen for up,down,left and right as well as not finding any keys at all that operated the A or B buttons. You can set the buttons you care about by passing them as parameters on the command line but that really seemed like more trouble than it was worth so I edited the config file directly.

Open the file ~/.mednafen/mednafen.cfg in something like gedit and do a search for “;nes, Port 1, Gamepad: A ”.

Initially I thought I could put the letter “Q” or whatever I wanted beside the correct option and that would be that. When I realised they wanted “keyboard 107” as a value, was at a bit of a loss about how to find those keycodes. It turns out that its really easy to get them with a little program called showkey which is already included in Ubuntu.

mike@sleepycat:~$ showkey -a

Press any keys – Ctrl-D will terminate this program

a 97 0141 0x61

s 115 0163 0x73

d 100 0144 0x64

f 102 0146 0x66

g 103 0147 0x67

^D 4 0004 0x04

Quoth the man page “showkey prints to the standard output the decimal, octal, and hexadecimal value(s) of the key pressed, according to he present keymap.” Its the first (decimal) value that is needed for the mednafen config file. Use showkey to figure out the the key numbers you want and then add them to the config file like this:

;nes, Port 1, Gamepad: A

nes.input.port1.gamepad.a keyboard 44

The only other config option I was interested in was the fullscreen mode:

;Enable fullscreen mode.

fs 1

I have to say that I don’t mind the fact that Mednafen is command line only. It seems to do a great job playing the games and seems very stable. Getting it set up the first time is a bit of an adventure, but once its set up you don’t need to fool with it any more and can get down to a little 8 bit gaming mayhem. Which is exactly what I am going to do now…

;Enable fullscreen mode.

fs 1

Advertisements

One thought on “Adventures in retro gaming: NES in Mednafen on Ubuntu”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s