I’ve finally got the time to finish the software of my second arcade build, so I guess it was time to make a post about it and cover some of the challenges I’ve faced.



While I’m currently developing my own front-end for Windows-based arcade machines, I didn’t want to do the same for this arcade since will be running on a Raspberry Pi 2 and there already exists optimized distributions for this purpose. RetroPie is one of these distributions and works pretty much out of the box, but I wanted to make a few small changes.

Before I started on the project I had the following objectives:

Minimal changes. I don’t want to make it difficult to upgrade to a newer version of RetroPie

Only list games that actually work in terms of compatibility and features (number of buttons required). This was especially with regard to MAME

Pre-scrape all game information and images and make small “packages” for each compatible system. I’ve heard the scraper in EmulationStation isn’t great while my own is getting quite good.

Configure all the buttons so they match the original controller in terms of placement relative to each other

Custom theme that matches my RetroBox brand

Initial setup

First of all download Win32 Disk Imager in order to write the RetroPie disk image to the micro SD card. It’s really simple and once done it can be safely removed and inserted into your Raspberry Pi 2. The next steps are similar to the original Raspberry Pi image. You’ll have to extend the partition to use all of the available disk space. In order to do so just boot the system, navigate to RetroPie and then select “Raspberry Pi Configuration Tool Raspi-config”. From here you should run “Expand Filesystem” and “Advanced Options->Enable SSH”. SSH will be used to configure RetroPie later on.

Adding games

When it comes to games you can run EmulationStation in two modes. You can tell EmulationStation to display all games in your /home/pi/RetroPie/roms/ directory (default) or tell it to only show games that exists in the gamelist.xml files located in /home/pi/.emulationstation/gamelists/ . While this might not matter much when it comes to most systems such as Super Nintendo, Nintendo or Master System, using gamelists is way easier then keeping your roms folder clean when it comes to MAME. The issue with MAME is that some roms depend on each other (parent/child and clones/samples), so I though it was easier to make a script generating the xml instead of trying to figure out the relationship between the different roms.

In order to be able to generate all the xml files I used one of my previous projects. Using this I managed to get almost all information and images used by EmulationStation. I also had to write some few snippets in order to mass move, match and convert files. The only system I had some real struggle with was of cause MAME. After finding a suitable romset for advmame 1.2 I used the awesome project ROMlister in order to scan my romset and make an xml file with all the games that would work on my arcade. While the official romset consists of over 6.000 roms “only” about 4000 work on an arcade with only 6 buttons. This way I know that at least most roms work without issues.

Anyway, in order to force EmulationStation to only list games that are defined in the gamelist.xml file you simply have to add –gamelist-only at the end of the line in /etc/profile.d/10-emulationstation.sh:

# Only show games in gamelist.xml sudo nano /etc/profile.d/10-emulationstation.sh [ "`tty`" = "/dev/tty1" ] && emulationstation --gamelist-only

Updating the controls

While RetroPie does a good job on automatically mapping the keys, I didn’t agree on the default button configuration. Fortunately it’s very easy to override the default button configuration on a per system basis. The configuration files are stored in /opt/retropie/configs and you override a given system simply by editing retroarch.cfg.

Here’s an example on how to override the button configuration for Super Nintendo (snes):

# Settings made here will only override settings in the global retroarch.cfg if placed above the #include line # Override default key layout input_player1_joypad_index = 0 input_player1_b_btn = 3 input_player1_a_btn = 4 input_player1_y_btn = 0 input_player1_x_btn = 1 input_player1_l_btn = 2 input_player1_r_btn = 5 input_player1_start_btn = 6 input_player1_select_btn = 7 input_player2_joypad_index = 1 input_player2_b_btn = 3 input_player2_a_btn = 4 input_player2_y_btn = 0 input_player2_x_btn = 1 input_player2_l_btn = 2 input_player2_r_btn = 5 input_player2_start_btn = 6 input_player2_select_btn = 7 input_remapping_directory = /opt/retropie/configs/snes/ # video_smooth = false video_shader = /opt/retropie/emulators/retroarch/shader/snes_phosphor.glslp # video_shader_enable = true #include "/opt/retropie/configs/all/retroarch.cfg"

Branding

While the default theme simple isn’t bad, I wanted to make a few changes. Since the arcade is mostly black and my logo is white on a black background, I also wanted the theme to match those colors instead of the default “50 shades of grey” look. I compared the simple theme with es-theme-carbon and combined them into a suitable theme. It wasn’t difficult at all since all system-specific xml files are equal while only the artwork differs.

I also changed the splashscreen to match the RetroBox logo. Just remember to change the path to the image:

# Change splashscreen sudo nano /etc/splashscreen.list /home/pi/RetroPie-Setup/supplementary/splashscreens/retrobox/splashscreen.png

Known bugs

I brought my arcade controls from Ultracabs mainly because I like the controller board (at least on windows). On Linux however, it’s detected as a single joystick instead of two individual. Because of this you won’t be able to map all buttons in MAME and maybe other systems as well. Fortunately the solution is simple, though it is far from self-explanatory:

# Split Xin-Mo controller into 2 individual joypads sudo nano /boot/cmdline.txt usbhid.quirks=0x16c0:0x05e1:0x040

Remember that you always can test your joystick by running the following command from the terminal:

# Test your joystick. # Replace 0 with your joystick id (normally 0 and 1 for player 1 and 2) jstest /dev/input/js0

Another bug I noticed is that the default Super Nintendo emulator crashes (segfaults) on a lot of games. This issue is related to a bug in the lr-snes9x-next emulator and should be fixed in the next version of RetroPie. Meanwhile it’s easy to upgrade the emulator just by navigating to RetroPi and then launching the RetroPie-Setup. From here select Install individual emulators from binary or source, choose lr-snes9x-next and select From binary. Give it a few seconds to update and the issue should be resolved.

Another thing worth mentioning is that EmulationStation is slow. My arcade consists of around 7.000 games and the system boots up in almost exactly one minute. Adding more games significantly increases boot time. Hopefully EmulationStation will one day utilize a SQLite database or similar to improve the speed. As a comparison, my front-end boots up in under just a few seconds with over 22.000 games.