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 https://launchpad.net/~team-xbmc/+archive/ppa. 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.