Wednesday, July 17, 2013

Games emulator on xbmc

During my vacation, which is rapidly approaching its end, I have been meaning to get a games emulator installed onto my HTPC. Mostly I wanted it for nostalgic reasons, I have fond memories from playing Nintendo as a boy. Now, finally, I have stopped procrastinating, and have done it.

I'm running Arch Linux with XBMC (Frodo), and I bought an XBOX 360 USB controller for this purpose. I was a little concerned if it would work or not, since I don't have any window manager installed, bit it seems that X is running with just XBMC, and that is enough.

I decided to start with the SNES emulator zsnes, since it's been around a while and seems to be at least somewhat stable. After I got it working I noticed two things. Number 1, I had forgotten how bad 8-bit graphics were. And number 2, I really suck at Super Mario Bros games.

Anyway, here is how I did it.
  • Make sure that you are using a skin that supports the "Program" menu item
  • Start by installing zsnes
    • pacman -Su zsnes
  • Then install Advanced Launcher
  • Restart the HTPC, WITH THE CONTROLLER CONNECTED
    • I wasn't able to get the controller to be recognized until I did this.
  • Now it's time to start the zsnes configuration tool
    • If you have a GUI (other than XBMC) installed, use that to execute /usr/bin/zsnes, otherwise you will need to use the Advance Launcher for this as well
      • Go to the Programs menu, Advanced Launcher, and click Default, then add a standalone type launcher for /usr/bin/zsnes. For the choices that follow, make sure to remove the default arguments, the others don't really matter
      • Open the context menu for the new item and select Edit Launcher -> Advanced Modifications -> Toggle XBMC into Windowed Mode and set it to "On"
  • Open zsnes (whichever method you use)
    • Under Config -> Video, you can set the resolution
      • I wasn't able to get 1080p working so I had to settle for 720p
      • There are also a lot of teaks that you can do to the video settings, but I haven't touched them so far
    • Under Config -> Input you can setup your controller. As long as it has been detected, once you clock "Set Keys" you just press whatever key it asks you to and it works
  • We need some games to play as well of course.
    • How you get them is none of my business, but once you do, place them in a folder somewhere on you drive
    • Copy you game ROMs to the folder you created
    • Create a sub-folder names "Images" or "Art", or really anything you like. This is where the thumbnails and fanart will be placed
  • At this point you might want to make some configurations for Advanced Launcher, under Settings -> Addons, such as what scraper to use and so forth, since they are not enabled by default and changing them seems to remove the launcher for the games that we are about to add
  • Create a new launcher in Advanced Launcher, this time a "File Launcher" type
    • Name it whatever you want, in my case "SNES" (not much imagination, I know)
    • Select the executable as /usr/bin/zsnes
    • Set the path to the ROMs to wherever you placed them
    • The file types are zip|smc|sfc, this was the default value for me
    • The arguments should be -m -s -v 22 %rom%, again this was default for me
    • Select the "Super Nintendo Entertainment System" as the type
    • Select the "Images" folder (or whatever you chose to call it) for thumbnails and fanart
  • For this launcher also, go to the context menu for the new item and select Edit Launcher -> Advanced Modifications -> Toggle XBMC into Windowed Mode and set it to "On"
  • Now go to the context menu again, select Add Items -> Scan For New Items and it should find you games (do this again when you add new games)
  • You may have some problems getting the audio to work (I did)
    • Give the command aplay -l, and remember the card and device that you want to use.
    • Check the home directory for whatever user runs XBMC (in my case the default xbmc user, which has home directory /var/lib/xbmc) for the file .asoundrc. If it exists, make a backup first. Them create/edit it to read (with the numbers on the line pcm "hw:0,3" being the card and device number from above):
pcm.dmixer {
   type dmix
   ipc_key 1024
   ipc_key_add_uid false
   ipc_perm 0660
   slave {
      pcm "hw:0,3"
      rate 48000
      channels 2
      format S32_LE
      period_time 0
      period_size 1024
      buffer_time 0
      buffer_size 4096
   }
}

pcm.!default {
   type plug
   slave.pcm "dmixer"
}
    • Reboot the HTPC
    • Start zsnes with the correct audio settings
      • zsnes -ad sdl
      • If you system is like mine, you will need to reboot again at this point, since the screen will go black.
  • Now try playing a game, here's hoping it works. 
The whole "Toggle XBMC into Windowed Mode" feature seems to be a little bit buggy. If you start a game and the screen just stays black, try attaching a keyboard and pressing "\", that is the switch between windowed mode and full screen mode. The same advice applies if, after shutting down a game (done with "ESC") you get a non-fullscreen version of XBMC. For me, I made sure that I have both "ESC" and "\" mapped on my remote just in case.

Edit: If you get a black screen after playing for a little while, Follow this guide to fix it.

No comments:

Post a Comment