Sunday, August 18, 2013

Using Rom Collection Browser to play NES games on XBMC 12 with Ubuntu

XBMC is by far my favorite IPTV software. I run it in my living room and use it to play my music collection and easily watch my entire DVD collection without ever needing to pop in CDs or DVDs. All my media is stored in a hard drive on my home server.

I had toyed around with using the Rom Collection Browser plugin to play Nintendo games, but getting it working right is not a trivial task. After a lot of messing around I finally have it working right. These instructions are using XBMC 12 on Ubuntu 13.10 and fceux for the emulator.

First things first. Never run with the version of XBMC packaged for Ubuntu. Team XBMC keeps an up to date version in their ppa at You can set it up with the following commands.
sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install xbmc
Next we need fceux to act as our NES emulator. You could install fceux with the following command.
sudo apt-get install fceux
However, I wanted to have the latest version of fceux. Since a ppa does not seem to be available I figured out how to compile it from source. It is not very hard and I have full instructions here. Whether you choose to use the version from apt or compile it should not affect it working with the following instructions. If you do install it from apt and have issues let me know in the comment section and I will look in to it for you.

Now that our system is setup we need to fire up XBMC. Choose Programs from the strip and then "Get More..." select "Rom Collection Browser and install it.

The first time you launch it you will get a menu asking you to create a config file. Choose Yes. Next choose "Scrape game info and artwork online." For the platform select NES.

Now it needs to know where the emulator is located at. Select "Root filesystem". Next choose the usr directory, followed by the bin directory. In here scroll down until you find fceux. Select it and click OK.

Your emulator params should be as follows.
-f 1 -x 1440 -y 900 "%ROM%"
You will need to change the 1440 and 900 to match your screen resolution. It can be any resolution your monitor/TV supports. The best way to get it is to either go to the Displays section in the Ubuntu Settings screen, or in XBMC under SYSTEM→Settings→System→Video output→Resolution.

Finally it ask you to tell it where you save your game roms. Usually it will be somewhere in your home folder so select "Home Folder" and browse down from there. When asked for the file mask type use *.nes, unless you keep all of your roms in a zip file, in which case choose *.zip. Theoretically you could use *.zip, *.nes but I had problems getting this to work. YMMV. I choose to just keep all my roms uncompressed since they are so small anyways.

The next question asks you about where to store artwork. You can create a separate directory for the artwork if you like. I chose the same directory as the roms. It creates subdirectories to store the art anyways. How you want to handle this is up to you.

Lastly, answer No when asked if we want to add another rom collection.

With all of our parameters setup click the Import Games button leaving all the settings in tact. Depending on the size of your rom collection this could take a while as it looks up each rom and downloads the metadata for each rom.

There is one last setting we need to make for convenience. Go to the main XBMC page and navigate to System→Settings→Appearance→Skin→Settings→Add-on. Under Home Page Programs Submenu choose Add-on 1 and then select Rom Collection Browser. Now the rom list can be loaded from the home screen.

Now you should be ready to play your favorite Nintendo games straight in XBMC. There are a few gotchas you should be aware of.

The default fceux keys are as follows.
Start: Enter
Select: s
A: f
B: d
Reset: F11

The next one that bit me is that fceux doesn't seem to support batteries so game saves are lost after you exit. Instead use F5 to save your game and F7 to restore from the save.

The delete key shuts down the emulator and takes you back to XBMC.

It is a good idea to log into the regular Ubuntu desktop and play with the fceux settings directly in fceux. My personal favorite is to go under Options→Video Config and set the special scalar to hq3x. This plays with the 8-bit graphics to make them look less blocky. You can also configure a gamepad, set hotkey bindings, etc. The changes you make here will be reflected when it is ran from XBMC.

Compiling fceux on Ubuntu

The following instructions are what I used to install fceux 2.2.1 on Ubuntu 13.10.

First you need to download the source. You can get it from Download the FCEUX src.

The rest of the instructions will assume that you are at the command line in the directory where you downloaded the file. Replace the file name in the instructions with the name of the file, which will be different if you downloaded a version different from 2.2.1.
sudo apt-get install libsdl1.2-dev scons libgtk-3-dev liblua5.1-0-dev libgd-dev
tar xzvf fceux-2.2.1.src.tar.gz
cd fceux-2.2.1
At this point you will need to open the file named SConstruct
vi SConstruct
Change lines 27 and 28 to look like this.
  BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 0),
  BoolVariable('GTK3', 'Enable GTK3 GUI (SDL only)', 1),
This will give us a modern GTK3 interface instead of using the now outdated GTK2 toolkit. Feel free to change any of the other settings if you wish. I turned off the debug symbols. Now we are ready to compile our binary.
This took about 10 - 15 minutes on my Dell 1420. Once it is done we can install it to the system.
sudo scons --prefix=/usr install
The last step is optional but provides a little more desktop integration. You can get a better fceux icon here.
sudo cp fceux.desktop /usr/share/applications
sudo cp fceux.png /usr/share/pixmaps
If you use Unity for your desktop you can change the contents of fceux.desktop in the /usr/share/applications directory to append the following to get some additional benefits when you right-click on the launcher icon.
[Desktop Action Fullscreen]
Name=Open in Fullscreen
Exec=fceux -f 1
[Desktop Action DefaultConfig]
Name=Start With the Default Configuration
Exec=fceux --no-config 1