RetroArch on Raspbian: the tutorial
Posted: Thu Sep 19, 2013 6:07 pm
Why RetroArch?
Because it offers a common backend for emulators and other ports like native engine reimplementations (scummvm, prboom, cavestory) so they can run as intended:
-No slow X11 protocol involved (wich causes high CPU usage and audio/video/control lag)
RetroArch CAN use a direct EGL backend. Even better, it can use Raspberry Pi native 2D API, Dispmanx! You can't get better than this, really
-Butter-smooth scroll at native phisical monitor refresh rates: for example, if a NES emulator runs at 60.1Hz and your monitor runs at 59.995 Hz, you would get occasional desynced audio OR video frames (jerky scroll not caused by internal emulated system slowdowns). That's UGLY. RetroArch makes it's NES emulator run at your monitor refresh rate, so unless you use some CPU while playing, you'll always get perfect srcoll.
-No need for a specialized GNU/Linux distro: just use your X-less Raspbian system to play these classics!
-Native linux input, no SDL required AT ALL!
-Of course, full screen scaling with adjustable ratio, size and pixed shaders for simulation phosphor crt magic (without the radiation
) or the GameBoy screen.
TUTORIAL ITSELF
Making RetroArch and some cores work on the Pi is very easy! In fact, it's easier than it is on an X86 PC.
First, we are going to install some development libraries an the git utility, wich we need:
Next, we will create the directory where our RetroArch+libraries will go:
We are first building the main executable (RetroArch) and then we will build some dynamic libs (wich are the "libretro ports", ie, emulation libraries for each system, or native source ports):
1) We clone the git repo:
2) We enter the cloned sources directory:
3) We configure the sources for compilation. We disable some features here, to get a lighter executable with just the stuff we need. GLES and VG will be disabled with these. My dispmanx driver the most optimal solution on the Pi:
3.5) Optionally, we can add some optimization flags. We edit config.mk and leave CFLAGS, CXXFLAGS and ASFLAGS lines like this:
Then we can edit Makefile.common and comment this line if we're not doing debug work:
4) We compile RetroArch!
5) Now we move it to our RetroArch directory:
Now, let's go for some emulation libraries. What about a fullspeed MegaDrive + MegaCD emulator running fullscreen at a constant and solid 60FPS with NO TEARING and smooooooth scroll as in real hardware? (My Pi is running at 950 MHz) 
1) We clone the repo:
2)We make some adjustments to the sources:
3)We configure the sources.
4)We build them:
We will get a file called picodrive_libretro.so. That's our sega emulation library 
We move it to the same directory where RetroArch is:
Now let's go for PC-Engine emulation!
The process is very similar to the other two: clone, configure, build, and move the resulting *.so file to our retro dir, so I won't be detailing the steps:
Now for the NES core:
....and so on 
Now, we go to our retro dir and run some Sega MegaDrive game:
We can use joysticks, etc. But that's beyond the scope of this tutorial.
Now let's say we want to run a Nintendo game:
..etc.
Other tested cores wich work perfectly are: prboom, nxengine, gambatte...
You can find their repositories here:
https://github.com/libretro
Have fun!
Because it offers a common backend for emulators and other ports like native engine reimplementations (scummvm, prboom, cavestory) so they can run as intended:
-No slow X11 protocol involved (wich causes high CPU usage and audio/video/control lag)
RetroArch CAN use a direct EGL backend. Even better, it can use Raspberry Pi native 2D API, Dispmanx! You can't get better than this, really
-Butter-smooth scroll at native phisical monitor refresh rates: for example, if a NES emulator runs at 60.1Hz and your monitor runs at 59.995 Hz, you would get occasional desynced audio OR video frames (jerky scroll not caused by internal emulated system slowdowns). That's UGLY. RetroArch makes it's NES emulator run at your monitor refresh rate, so unless you use some CPU while playing, you'll always get perfect srcoll.
-No need for a specialized GNU/Linux distro: just use your X-less Raspbian system to play these classics!
-Native linux input, no SDL required AT ALL!
-Of course, full screen scaling with adjustable ratio, size and pixed shaders for simulation phosphor crt magic (without the radiation
TUTORIAL ITSELF
Making RetroArch and some cores work on the Pi is very easy! In fact, it's easier than it is on an X86 PC.
First, we are going to install some development libraries an the git utility, wich we need:
Code: Select all
sudo apt-get install libasound2-dev git-coreCode: Select all
mkdir ~/retro1) We clone the git repo:
Code: Select all
git clone --depth 1 git://github.com/libretro/RetroArch.gitCode: Select all
cd RetroArchCode: Select all
./configure --disable-vg --disable-opengl --disable-gles --disable-fbo --disable-egl --enable-dispmanx --disable-x11 --disable-sdl2 --enable-floathard --disable-ffmpeg --disable-netplay --enable-udev --disable-sdl --disable-pulse --disable-oss --disable-freetype --disable-7zip --disable-libxml2
Code: Select all
CFLAGS = -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-sCode: Select all
DEBUG_FLAG = -g
Code: Select all
make V=1Code: Select all
mv retroarch ~/retro1) We clone the repo:
Code: Select all
git clone https://github.com/libretro/picodrive.gitCode: Select all
git submodule init && git submodule updateCode: Select all
./configureCode: Select all
make -f Makefile.libretro platform=armv6eWe move it to the same directory where RetroArch is:
Code: Select all
mv picodrive_libretro.so ~/retroThe process is very similar to the other two: clone, configure, build, and move the resulting *.so file to our retro dir, so I won't be detailing the steps:
Code: Select all
git clone https://github.com/petrockblog/mednafen-pce-libretro.git
make
mv *.so ~/retro
Code: Select all
git clone git://github.com/libretro/fceu-next.git
pushd fceumm-code
make -f Makefile.libretro
mv *.so ~/retro
Now, we go to our retro dir and run some Sega MegaDrive game:
Code: Select all
cd ~/retro
./retroarch -L picodrive_libretro.so sega/Sonic.md
Now let's say we want to run a Nintendo game:
Code: Select all
cd ~/retro
./retroarch -L fceumm_libretro.so nes/Mario.nes
Other tested cores wich work perfectly are: prboom, nxengine, gambatte...
You can find their repositories here:
https://github.com/libretro
Have fun!