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
or:
zcat /opt/download/retropie-4.1-rpi2_rpi3.img.gz |dd bs=1048576 of=/dev/sdX
Only a few packages are installed by default, so go to RetroPie-Setup and run:
sudo ./retropie_setup.sh
and build the emulators you need. I wanted the Atari800 and advmame packages.
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.
US Wifi Configuration¶
In /etc/default/crda
add:
REGDOMAIN=US
In /etc/wpa_supplicant/wpa_supplicant.conf
change the lines to:
#country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOUR NEWORK NAME"
psk="YOUR NEWORK PASSWORD"
}
Spinner¶
Use the spinner and trackball page on the wiki to find out which mouse and axis is registering the spinner, then change the definition in the advmame-1.4.rc file, like:
input_map[p1_dialx] mouse[0,x] mouse[1,x] mouse[2,x] mouse[3,x]
input_map[p1_paddlex] mouse[0,x] mouse[1,x] mouse[2,x] mouse[3,x]
which will map the X axis of each listed mouse controller to the spinner
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.
Note
Recently, I did find a blog post with a patch to fix this problem. There was also a modification to the mame.cfg file:
# turn on vsync waiting
vsync=yes
waitvsync=yes
inp=inp
I haven’t tried it since I’m happy with AdvMAME.
Other Software¶
To install RexMenu requires the pygame package:
sudo apt-get install python-pygame
Rexmenu¶
It doesn’t work correctly when the RetroPie splash screen is shown, so you have to disable the splash screen in the config:
sudo ~/RetroPie-Setup/retropie_setup.sh
and change the menu option Configuration/tools -> 825 splashscreen -> Disable
splashscreen
Keyboard Configuration¶
I-PAC default keys¶
Function |
Normal |
Shifted |
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 |
backquote |
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 Defaults¶
Editable through config file or UI
Key |
Function |
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 Defaults¶
Defaults for function keys appear hardcoded.
Key |
Function |
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¶
Install with sudo ~/RetroPie-Setup/retropie_setup.sh
in the Managed packages -> opt -> advmame
Config¶
Some of my changes to the ~/.advance/advmame-1.4.rc:
display_height 1024
display_magnify 1
display_width 1280
input_map[p1_dialx] mouse[0,x] mouse[1,x] mouse[2,x]
input_map[p1_paddlex] mouse[0,x] mouse[1,x] mouse[2,x]
input_map[ui_select] keyboard[0,enter] or keyboard[0,lcontrol]
tempest/input_setting[p1_dialx] keydelta:20,centerdelta:20,sensitivity:20,reverse:0
sbrkout/input_setting[p1_paddlex] keydelta:10,centerdelta:0,sensitivity:35,reverse:1
Recompiling¶
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¶
Install with sudo ~/RetroPie-Setup/retropie_setup.sh
in the Managed packages -> opt -> 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¶
Note
RetroPie 3.x doesn’t seem to have the problems listed below.
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 |
F10 |
Save Screenshot |
Save Screenshot |
||
(shifted) |
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 |
The cabaret has slightly different wiring on the console buttons, so:
I-PAC |
Keycode |
MAME |
Atari 800 |
Atari2600 |
1 A |
ESC |
ESC |
ESC |
ESC (used as shift key) |
2 A |
F10 |
Save Screenshot |
Save Screenshot |
|
2 B |
P |
Pause |
Pause |
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¶
Turning off EmulationStation¶
EmulationStation is autostarted from the /opt/retropie/configs/all/autostart.sh
file.
Old Notes¶
I don’t use EmulationStation any more, but here’s some notes from when I did.
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.
Screen Blanking¶
I have been leaving my monitor on 24/7, but this is both wasting energy and shortening the life of the monitor. There doesn’t appear to be any config option to enable a screen saver of any sort in AdvMAME, and most of the other emulators would forceably deactivate the screen savers anyway. It might be automatic in SDL.
I discovered some commands for the RPi that can manage the screen, so I’m attempting to write a python script to turn on screen blanking after some amount of inactivity. This is relatively easy for the moment because all my inputs are based on keyboard encoders, and with a python library it is possible to link into the evdev library to detect input.
tvservice
seems pretty flaky. tvservice -o
reliably turns the monitor
off, into DPMS powersave mode. But tvservice -p; fbset -depth 16
only seems
to work the first time.
Tried disabling the console screen blanking by changing /etc/kbd/console
to
BLANK_TIME=0
, but it didn’t seem to matter.
The addition of fbset -depth 8
seems to work a second time, but not the
third time as it causes the advmame to lock up. Finally, I found a forum post that
described how the framebuffer would get stuck and that changing some setting
provided a workable solution, using text acceleration because it was a trivial
setting:
off:
fbset -accel false; tvservice -o
on:
tvservice -p; fbset -accel true
Monitor Orientation¶
The pi can boot with the monitor with any side up using the display_rotate
command in /boot/config.txt
:
normal:
display_rotate=0
90 degrees ccw:
display_rotate=1
180 degrees:
display_rotate=2
90 degrees cw:
display_rotate=3