Raspberry Pi

RetroPie

I downloaded the RetroPie image and installed onto a 4GB SD card using:

sudo dd bs=1048576 if=RetroPieImage_ver1.9.1.img of=/dev/sdX

There’s a detailed walkthrough, although the first time I followed the instructions I couldn’t ssh into it. I ended up using the vanilla RetroPie image and worked from that.

sudo raspi-config select option 4 choose locales to build (en.us.UTF-8) select default locale (C.UTF-8)

Firmware

There was a problem with sound latency increasing as time goes on; noticable in Stella. I had read reports that the solution was to update firmware using:

sudo rpi-update
sudo reboot

but it still seems to be a problem for me. Hmmm.

Mouse Polling

For trackball and spinner emulation, the default polling rate is apparently slow enough that fast movements can cause emulators to see movement in the opposite direction. The solution is to decrease the polling interval by changing a boot parameter by editing /boot/cmdline.txt and adding usbhid.mousepoll={number in ms} where the number to add is:

1000 hz = 1 ms
500 hz = 2 ms
250 hz = 4 ms
125 hz = 8 ms
100 hz = 10 ms

Another reference: from Arcade Controls Wiki

Audio Issues

From the RetroPie wiki: add the line `disable_audio_dither=1` to /boot/config.txt and use alsamixer to turn up the PCM volume to 100%

On the RPi2, I couldn’t figure out the sound latency issues with MAME4All-Pi, so switched to using AdvMAME 1.2 which is on the RetroPi distribution.

Keyboard Configuration

I-PAC default keys

NORMAL CODES CODES WITH SHIFT (hold 1 player start)

COIN 1 5 COIN 2 6 START 1 1 START 2 2 ESC 1 RIGHT R arrow Tab 1 LEFT L arrow Enter 1 UP U arrow Key Below ESC (Volume, gamma, etc ) 1 DOWN D arrow P (pause) 1 SW 1 L-ctrl 5 (Coin A) 1 SW 2 L-alt 1 SW 3 space 1 SW 4 L-shift 1 SW 5 Z 1 SW 6 X 1 SW 7 C 1 SW 8 V 1 A P 1 B ENTER START 1 1 START 2 2 Esc 2 RIGHT G 2 LEFT D 2 UP R 2 DOWN F 2 SW 1 A 2 SW 2 S 2 SW 3 Q 2 SW 4 W 2 SW 5 I 2 SW 6 K 2 SW 7 J 2 SW 8 L 2 A TAB 2 B ESC

MAME4ALL / AdvMAME

Default keys:

5 - Insert Coin
1 - Start
Arrows - Move
Ctrl - Action Button 1
Alt - Action Button 2
Space - Action Button 3
Mouse - Analog Control (needed for some games)
P - Pause
ESC - Quit MAME
F2 - Service Mode
Tab - MAME Options Menu
F-12 - Take a screenshot

Atari800

Default keys (can’t be changed???):

F1     Built in user interface
F2     Option key
F3     Select key
F4     Start key
F5     Reset key ("warm reset")
Shift+F5
      Reboot ("cold reset")
F6     Help key (XL/XE only)
F7     Break key
F8     Enter monitor
F9     Exit emulator
F10    Save screenshot

Stella

Default keys:

Exit emulator       Control + q     Cmd + q
Exit game mode/enter launcher mode  Escape  Escape
Enter/exit options mode     Tab     Tab
Enter/exit command mode     Backslash (\)   Backslash (\)
Enter/exit debugger Backquote (`)   Backquote (`)
Select Game F1      F1
Reset Game  F2      F2
Color TV    F3      F3
Black/White TV      F4      F4
Left Player Difficulty A    F5      F5
Left Player Difficulty B    F6      F6
Right Player Difficulty A   F7      F7
Right Player Difficulty B   F8      F8
Save state to current slot  F9      F9
Change current state slot   F10     F10
Load state from current slot        F11     F11
Save PNG snapshot   F12     F12
Pause/resume emulation      Pause

Setting Up Emulators

MAME4ALL

AdvMAME

  • Screenshots are saved in /opt/retropie/configs/mame-advmame/snap

  • hiscore.dat is included in the retropie distro as /opt/retropie/emulators/advmame/1.2/share/advance/hiscore.dat

  • vector game resolution appears to be hardcoded at 640x480, which is terrible. Changing the code is the only way I’ve found that works:

    $ diff -u advance/osd/frame.c.orig advance/osd/frame.c
    --- advance/osd/frame.c.orig    2016-03-24 19:38:51.397223765 -0700
    +++ advance/osd/frame.c 2016-03-24 19:26:03.331435328 -0700
    @@ -2432,8 +2432,8 @@
                    unsigned game_size_x;
                    unsigned game_size_y;
    
    -               mode_size_x = 640;
    -               mode_size_y = 480;
    +               mode_size_x = 1280;
    +               mode_size_y = 1024;
    
                    log_std(("emu:video: insert vector video modes\n"));
    

I recompiled with:

./configure --enable-expat --enable-sdl --enable-zlib --disable-slang --disable-svaglib --disable-static --enable-alsa --enable-fb --disable-oss --enable-freetype --with-emu=mame
make

Atari800

There’s no standard location for atari 800 OS ROM images AFAICT, so I did:

mkdir /usr/share/games/atari800

and put them there. Then the config file in ~/.atari800.cfg specified those locations:

OS/B_ROM=/usr/share/games/atari800/ATARIOSB.ROM
XL/XE_ROM=/usr/share/games/atari800/ATARIXL.ROM
BASIC_ROM=/usr/share/games/atari800/ATARIBAS.ROM

Stella

Stella on the RetroPie 2.x image loses sound syncronization for some reason. I compiled my own version from a tutorial for building RetroArch on the pi and it seems to work fine:

sudo apt-get install libasound2-dev git-core
mkdir ~/src
cd src
git clone  git://github.com/libretro/RetroArch.git
cd RetroArch/
make
mkdir ~/bin
cp retroarch ~/bin
git clone https://github.com/libretro/stella-libretro
cd stella-libretro/
make
cp stella_libretro.so ~/bin
cd ~/bin
./retroarch --features

The default aspect ratio wasn’t correct, so I had to change it using the F1 key to get into the libretro config menu, then specified the 5:4 aspect ratio there.

Keyboard configuration

I want to have the emulators use the same layout, obviously, so the I-PAC will send the correct info regardless of what’s being played.

I-PAC Keycode MAME Atari 800 Atari2600  
COIN 1 Coin 1        
COIN 2 Shift        
START 1 1 Start 1 1    
START 2 2 Start 2 2    
1 RIGHT RIGHT Right Right Right  
1 LEFT LEFT Left Left Left  
1 UP UP Up Up Up  
1 DOWN DOWN Down Down Down  
1 SW 1 lctrl Button 1 Fire Fire  
1 SW 2 space Button 2 Space    
1 SW 3 enter Button 3      
1 SW 4 lshift Button 4      
1 SW 5          
1 SW 6          
1 SW 7          
1 SW 8 P Pause   Pause  
1 A ESC ESC ESC ESC (used as shift key)  
1 B Tab Menu      
2 RIGHT G        
2 LEFT D        
2 UP R        
2 DOWN F        
2 SW 1 A        
2 SW 2 S        
2 SW 3 Q        
2 SW 4 W        
2 SW 5 F2   Option    
2 SW 6 F3   Select Select  
2 SW 7 F4   Start Reset  
2 SW 8 F10   Save Screenshot Snapshot (i.e. screenshot)  
(shifted) F9   Quit Quit  
2 A          
2 B          

RetroArch

The retroarch config files are stored in /opt/retropie/emulators/retroarch/configs and uses the following specification:

input_player1_a = x input_player1_b = z input_player1_y = a input_player1_x = s input_player1_start = enter input_player1_select = rshift input_player1_l = q input_player1_r = w input_player1_left = left input_player1_right = right input_player1_up = up input_player1_down = down

Can also use /opt/retropie/emulators/retroarch/bin/retroarch-joyconfig –timeout 5 >> ~/RetroPie/configs/all/retroarch.cfg to prompt for controls

For some reason, the default input remapping options (in the Retroarch config using the F1 key) the B button is mapped as the primary fire button.

Core input remapping broken? http://blog.petrockblock.com/forums/topic/how-can-i-use-core-specific-button-remapping-for-retroarch-emulators-3-0-beta-2/

EmulationStation

http://blog.petrockblock.com/forums/topic/updated-python-scraper-for-emulationstation/

game databases:

  • thegamesdb.net
  • archive.vg

Procedure to scrape, but EmulationStation must not be running or the generated metadata file stored in /home/pi/.emulationstation/gamelists/[platform]/gamelist.xml will be overwritten:

sudo apt-get install python-imaging
git clone https://github.com/thadmiller/ES-scraper.git
cd ES-scraper
python scraper.py -pisize -name atari2600 -platform atari2600
  • Removing retropie config menu from emulation station: rename the ~/RetroPie/retropiemenu folder to something else and it won’t show up
  • Change F4 to F9 to exit

F4 appears to be hard-coded as the exit key. The SDL keycode for F4 is defined in input files:

$ grep SDL_SCANCODE_F4 /usr/include/SDL2/*
/usr/include/SDL2/SDL_keycode.h:129:    SDLK_F4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4),
/usr/include/SDL2/SDL_scancode.h:156:    SDL_SCANCODE_F4 = 61,

and SDL_SCANCODE_TO_KEYCODE is defined as (1<<30), so the hex value is:

$ python
Python 2.7.5 (default, Oct 11 2013, 13:42:33)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> hex(1<<30|61)
'0x4000003d'

So, the RPi being little endian, searching for the byte string “3d000040” yields one hit:

$ grep -obUaP "\x3d\x00\x00\x40" /opt/retropie/supplementary/emulationstation/emulationstation

113685:=@

It only occurs once, so we’ll assume that’s the right place. I want to change it to F9, which is SDL_SCANCODE_F9 or 61 (hex 42). So, need to change byte 0x1bc15 to 0x42

UPDATE: Nope, that didn’t work:

./emulationstation: relocation error: ./emulationstation: symbol nfo_injectorISt13runtime_errorEEE5cloneEv, version CXXABI_1.3 not defined in file libstdc++.so.6 with link time reference

UPDATE #2: Six hours later, I compiled emulationstation from source following the instructions, the only change being:

diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp
index 3bd26b8..9827e51 100644
--- a/es-core/src/InputManager.cpp
+++ b/es-core/src/InputManager.cpp
@@ -210,7 +210,7 @@ bool InputManager::parseEvent(const SDL_Event& ev, Window* window)
                if(ev.key.repeat)
                        return false;

-               if(ev.key.keysym.sym == SDLK_F4)
+               if(ev.key.keysym.sym == SDLK_F9)
                {
                        SDL_Event* quit = new SDL_Event();
                        quit->type = SDL_QUIT;

and compiling on the master branch, not the unstable branch as recommended in the instructions.

AdvMAME 1.2

On the RPi2, I couldn’t figure out the sound latency issues, so switch to trying AdvMAME 1.2 which is on the RetroPi distribution.