Sunday, September 29, 2013

Compiling Snes9x on Ubuntu

After looking into the various SNES emulators available for Linux it looks like Snes9x is the only one that is of high quality and currently maintained. ZSNES seems to work pretty well, but it won't compile on 64-bit, giving you a very old emulator running as a 32-bit binary for the foreseeable future.

I used these instructions on a 64-bit Ubuntu 12.04 machine and a 32-bit Ubuntu 13.10 machine. There are two sets of instructions here. One is for compiling the Unix version of Snes9x and the other is for install the GTK3 version. Theses instructions worked perfectly on 12.04 but on 13.10 the GTK3 version segfaults. I don't know if the issue is with 13.10 or perhaps an incompatibility with my laptop's hardware and Snes9x GTK.

The currently maintained codebase of Snes9x is hosted up on github so we will need to install git. We'll get all the tools required to build the source code while we are at it.
sudo apt-get install git build-essential
Now we can check out the codebase.
git clone https://github.com/snes9xgit/snes9x.git
cd snes9x

Part 1 - Building the Unix version of Snes9x
The Unix version does not contain any sort of interface save for the running game itself. It supports a number of command-line switches. Unfortunately it does not seem to provide any way of running in fullscreen mode.

First we need the dependent libraries.
sudo apt-get install zlib1g-dev libpng12-dev xorg-dev
Now we can compile.
cd unix
autoconf
./configure --enable-netplay
make
sudo cp snes9x /usr/bin/
sudo chown root:root /usr/bin/snes9x
Now we have an executable binary named snes9x. You can go ahead and execute it passing in a SNES rom as the first argument or with no arguments for a list of acceptable options.

To create an entry in our desktop menu create the following file and save it as /usr/share/applications/snes9x.desktop
[Desktop Entry]
Version=1.0
Name=Snes9x
Comment=A portable, freeware Super Nintendo Entertainment System (SNES) emulator.
GenericName=Snes9x
Keywords=Games
Exec=snes9x
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/usr/share/pixmaps/snes9x.png
Categories=Game
StartupWMClass=Snes9x
StartupNotify=true
Finally, find an icon you want to use and save it as /usr/share/pixmaps/snes9x.png You can get a good icon to use here.
sudo wget http://maxolasersquad.com/snes9x.png -O /usr/share/pixmaps/snes9x.png

Part 2 - Building the GTK3 version of Snes9x
The GTK3 version includes a nice GTK interface with all sorts of configurable options, including fullscreen.

First we need to get the dependent libraries.
sudo apt-get install intltool autoconf automake libglib2.0-dev gawk libgtk-3-dev libxml2-dev libxv-dev libsdl1.2-dev libpulse-dev libportaudio-dev 
As of Ubuntu 15.10, instead of libportaudio-dev you need to install portaudio19-dev.
If you want a GTK2 build then install libgtk2.0-dev and you can leave out libgtk-3-dev.
Now we can generate the install scripts and compile.
cd gtk
./autogen.sh
./configure --with-gtk3
make

sudo cp snes9x-gtk /usr/bin/
sudo chown root:root /usr/bin/snes9x-gtk
You can leave out --with-gtk3 if you want a gtk2 build instead.

Now we have an executable binary named snes9x-gtk.

To create an entry in our desktop menu create the following file and save it as /usr/share/applications/snes9x.desktop
[Desktop Entry]
Version=1.0
Name=Snes9x GTK
Comment=A portable, freeware Super Nintendo Entertainment System (SNES) emulator.
GenericName=Snes9x GTK
Keywords=Games
Exec=snes9x-gtk
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/usr/share/pixmaps/snes9x.png
Categories=Game
StartupWMClass=Snes9x
StartupNotify=true
Finally, find an icon you want to use and save it as /usr/share/pixmaps/snes9x.png You can get a good icon to use here.
sudo wget http://maxolasersquad.com/snes9x.png -O /usr/share/pixmaps/snes9x.png

Thursday, September 5, 2013

How to flush your swap on Unix machines

After your computer has been running for some time you may find that some memory is stuck living in swap while your RAM has space readily available. The data in your swap will be accessed much slower than if it was living in proper RAM space and it may be to your advantage to force it to RAM. I use the following to clean out the swap on my Ubuntu 12.04 workstation.
sudo swapoff -a && sudo swapon -a
Of course, if you are running as root you can omit sudo from the above command.

Plenty of room to move the swap in to.


Swap has been flushed to RAM.