{"id":1398,"date":"2014-06-28T18:54:13","date_gmt":"2014-06-29T01:54:13","guid":{"rendered":"http:\/\/zsprawl.com\/iOS\/?p=1398"},"modified":"2014-06-28T22:24:18","modified_gmt":"2014-06-29T05:24:18","slug":"playing-old-skool-games-on-a-raspberry-pi","status":"publish","type":"post","link":"http:\/\/zsprawl.com\/iOS\/2014\/06\/playing-old-skool-games-on-a-raspberry-pi\/","title":{"rendered":"Playing Old Skool Games on a Raspberry Pi"},"content":{"rendered":"<p>I&#8217;ve been playing games since my best friend Nathan had a Nintendo that my parents wouldn&#8217;t let me have. We would play hours of Mario Brothers and Zelda, much like many kids at the time. While there are a lot of cool new games today, some of that old school fun has been lost forever in this era of shooters and online play. <\/p>\n<p><a href=\"http:\/\/zsprawl.com\/iOS\/wp-content\/uploads\/2014\/06\/20140629_013151231_iOS.jpg\"><img decoding=\"async\" src=\"http:\/\/zsprawl.com\/iOS\/wp-content\/uploads\/2014\/06\/20140629_013151231_iOS-1024x768.jpg\" alt=\"20140629_013151231_iOS\" width=\"500\" class=\"aligncenter size-large wp-image-1404\" \/><\/a><\/p>\n<p>Since I have a pretty extensive collection of Nintendo, Super Nintendo, Sega Genesis, Master System, Atari, and Turbographx games, I picked up a $35 Raspberry Pi to emulate these machines. This blog post is for anyone else that wants to do the same. A lot of the super hard work has been done already. Someone has already written the emulators. Someone has already figured out how to run them in linux. Someone else has created drivers, and most important perhaps, someone has packaged it up into a nice little image file called: RetroPie.<br \/>\n<!--more--><\/p>\n<p>1)\tDownload the latest version of <a href=\"http:\/\/blog.petrockblock.com\/download\/retropie-project-image\/\" target=\"_blank\">RetroPie&#8217;s SD image.<\/a><\/p>\n<p>2)\tDownload and use <a href=\"http:\/\/sourceforge.net\/projects\/win32diskimager\/\" target=\"_blank\">Win32 Disk Imager<\/a> to apply the above SD image to a 4 GB or larger SD card. 8 GB is really recommended.<\/p>\n<p>3)\tBoot the SD Image on your Raspberry Pi. <\/p>\n<p>4)\tThe first time the system boots up into Emulation Station, you will need to setup your joystick. <\/p>\n<p>5)\tI purchased a EW-7811Un USB wifi, which is supported by the Raspberry Pi out of the box.<\/p>\n<p>6)\tNow we need to setup wifi. Edit \/etc\/network\/interfaces to configure wlan0.<\/p>\n<p><code>allow-hotplug wlan0<br \/>\nauto wlan0<br \/>\niface wlan0 inet dhcp<br \/>\nwpa-ssid zInternet<br \/>\nwpa-psk *******<\/code><\/p>\n<p>7)\tBefore we can move to configuring everything via SSH, we need to configure our joystick for the emulators themselves.<\/p>\n<p><code>cd ~\/RetroPie\/emulators\/RetroArch\/installdir\/bin<br \/>\n.\/retroarch-joyconfig -j 1 >> ~\/RetroPie\/configs\/all\/retroarch.cfg<\/code><\/p>\n<p><strong>Note:<\/strong> Depending on your keyboard, the ~ may be invoked with shift+|<\/p>\n<p>8)\tGrab the IP address and SSH into the device to continue configuration. The default user\/password that comes with Raspbian is used: The username is &#8220;pi&#8221;, the password is &#8220;raspberry&#8221;.<\/p>\n<p>9)\tLet&#8217;s setup the player 2 controller for our emulators before we forget.<\/p>\n<p><code>cd ~\/RetroPie\/configs\/all<br \/>\nvi retroarch.cfg<\/code><\/p>\n<p>Copy and paste the entire section that begins with &#8220;input_player1_&#8221; and change it to &#8220;input_player2_&#8221;. Don&#8217;t forget to change the &#8220;input_player_joypad_index&#8221; to 1 or 2 as well.<\/p>\n<p><strong>Note:<\/strong> If you have a keyboard connected, things can be a little odd. You may need to change the joypad index to 0 and 1 if you remove the keyboard, which I&#8217;m going to do.<\/p>\n<p>At the end of the retroarch.cfg file, it is a good idea to add the following to allow you to press select+start to exit the game.<\/p>\n<p><code>input_enable_hotkey_btn = \"6\"<br \/>\ninput_exit_emulator_btn = \"7\"<\/code><\/p>\n<p>I also like to take advantage of the save and load states in emulation, which some people consider cheating. Add the following lines to enable these buttons on your joypad.<\/p>\n<p><code>input_save_state_btn = \"8\"<br \/>\ninput_load_state_btn = \"10\"<\/code><\/p>\n<p>After this has been done, pressing select+center or select+r3 will save and load respectively (assuming an X-Box controller).<\/p>\n<p>10)\tRun configuration.<\/p>\n<p><code>sudo raspi-config<\/code><\/p>\n<p>11)\tChange password.<\/p>\n<p>12)\tChange Memory-split to 384.<\/p>\n<p>13)\tExpand root file system to fill entire SD card.<\/p>\n<p>14)\tForce audio out of audio jack (instead of HDMI).<\/p>\n<p>15)\tExit from tool and reboot.<\/p>\n<p>16)\tSSH back in (if you are using DHCP, the resizing of the file system can cause an IP change).<\/p>\n<p>17)\tNow we need to configure RetroPie to use pisnes (the better Super NES emulator).<\/p>\n<p><code>cd ~\/RetroPie-Setup<br \/>\nsudo .\/retropie_setup.sh<\/code><\/p>\n<p>18)\tSelect Option 3 to perform post-installation tasks. <\/p>\n<p>19)\tWhile we are here, let&#8217;s change the RetroPie splashscreen to something a bit more sexy.<\/p>\n<p>20)\tNow hit cancel to go back to the main menu.<\/p>\n<p>21)\tSelect option 2 for Source-based Installation. We will need to deselect EVERYTHING except pisnes (option 52) because the preinstalled copy is missing some files.<\/p>\n<p>22)\tNow we need to ensure that pisnes is the active emulator in Emulation station.<\/p>\n<p><code>cd ~\/.emulationstation<br \/>\nvi es_systems.cfg<\/code><\/p>\n<p>Change the section for SNES by uncommenting out the line for pisnes, and commenting out the current line. It should look like this when you&#8217;re done.<\/p>\n<p><code>DESCNAME=Super Nintendo<br \/>\nNAME=snes<br \/>\nPATH=\/home\/pi\/RetroPie\/roms\/snes<br \/>\nEXTENSION=.smc .sfc .fig .swc .SMC .SFC .FIG .SWC<br \/>\n#COMMAND=\/home\/pi\/RetroPie\/supplementary\/runcommand\/runcommand.sh 4 \"\/home\/pi\/RetroPie\/emulators\/RetroArch\/installdir\/bin\/retroarch -L \/home\/pi\/RetroPie\/emulatorcores\/pocketsnes-libretro\/libretro.so --config \/home\/pi\/RetroPie\/configs\/all\/retroarch.cfg --appendconfig \/home\/pi\/RetroPie\/configs\/snes\/retroarch.cfg   %ROM%\"<br \/>\n# alternatively: COMMAND=\/home\/pi\/RetroPie\/emulators\/snes9x-rpi\/snes9x %ROM%<br \/>\nCOMMAND=\/home\/pi\/RetroPie\/emulators\/pisnes\/snes9x %ROM%<br \/>\nPLATFORMID=6<\/code><\/p>\n<p>You can also edit this file to remove other emulators. I deleted Cave Story, Doom, Duke Nukem, Apple II, and the DOS emulators by commenting out their respective sections.<\/p>\n<p>23)\tNow we need to configure the controller for pisnes.<\/p>\n<p><code>cd ~\/RetroPie\/emulators\/pisnes<br \/>\nvi snes9x.cfg<\/code><\/p>\n<p>Edit this file to match your controller. Here is the section for my X-Box controller:<\/p>\n<p><center><a href=\"http:\/\/wiki.unity3d.com\/index.php?title=Xbox360Controller\" target=\"_blank\"><img decoding=\"async\" src=\"http:\/\/wiki.unity3d.com\/images\/a\/a7\/X360Controller2.png\" alt=\"\" width=\"520\" align=\"center\" \/><\/center><\/a><code>A_1=0<br \/>\nB_1=1<br \/>\nX_1=2<br \/>\nY_1=3<br \/>\nL_1=4<br \/>\nR_1=5<br \/>\nSTART_1=7<br \/>\nSELECT_1=6<br \/>\nQUIT=99<br \/>\nACCEL=11<br \/>\nQLOAD=10<br \/>\nQSAVE=8<br \/>\n#Joystick axis<br \/>\nJA_LR=0<br \/>\nJA_UD=1<br \/>\nA_2=0<br \/>\nB_2=1<br \/>\nX_2=2<br \/>\nY_2=3<br \/>\nL_2=4<br \/>\nR_2=5<br \/>\nSTART_2=7<br \/>\nSELECT_2=6<br \/>\n#Joystick axis<br \/>\nJA_LR_2=0<br \/>\nJA_UD_2=1<\/code><\/p>\n<p>24)\tI had problems with the built in compiled version of pisnes, so I downloaded the source and copied it over top of the existing files.<\/p>\n<p><code>cd ~\/RetroPie\/emulators\/pisnes<br \/>\ncp snes9x.cfg snes9x.cfg.bak<br \/>\nrm pisnes.zip<br \/>\nwget http:\/\/pisnes.googlecode.com\/git\/pisnes.zip<br \/>\nunzip pisnes.zip<\/code><\/p>\n<p><strong>Note:<\/strong> Don&#8217;t copy over your snes9x.cfg file or you&#8217;ll have to restore the joystick settings.<\/p>\n<p>25)\tNow copy your Roms to the SMB shares (ex. \\\\RaspberryPi\\snes is where the Super Nintendo ROMs go). I&#8217;m using <a href=\"http:\/\/blog.petrockblock.com\/forums\/topic\/scrape-without-es-scrapper\/\" target=\"_blank\">ES-Scrapper<\/a> to help sort my roms, but you can also setup the internal scrapper to run on a cron job.<\/p>\n<p>26)\tI&#8217;m using monitor speakers so I need to turn the volume on the audio jack up. You may or may not need to do this. Add the following lines to the end of ~\/.bashrc<\/p>\n<p><code># Increase volume by 5%<br \/>\nalias volu='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's\/%\/\/')+5]%'<br \/>\n# Decrease volume by 5%<br \/>\nalias vold='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's\/%\/\/')-5]%'<\/code><\/p>\n<p>27)\tNow when you logout and log back in, you can turn up the volume (or down) by typing &#8220;volu&#8221;. <\/p>\n<p><code>Simple mixer control 'PCM',0<br \/>\nCapabilities: pvolume pvolume-joined pswitch pswitch-joined penum<br \/>\nPlayback channels: Mono<br \/>\nLimits: Playback -10239 - 400<br \/>\nMono: Playback -1195 [85%] [-11.95dB] [on]<\/code><\/p>\n<p>28)\tAll done? Reboot and game on.<\/p>\n<p><code>sudo reboot<\/code><\/p>\n<p>29)\tAnd once you are happy for a few days, go back into &#8220;raspi-config&#8221; and overclock your pi, if you are feeling daring. It will iron out some of the annoying blips in audio. I purchased a few heat sinks just in case.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been playing games since my best friend Nathan had a Nintendo that my parents wouldn&#8217;t let me have. We would play hours of Mario Brothers and Zelda, much like many kids at the time. While there are a lot of cool new games today, some of that old school fun has been lost forever <a href=\"http:\/\/zsprawl.com\/iOS\/2014\/06\/playing-old-skool-games-on-a-raspberry-pi\/#more-'\" class=\"more-link\"><br \/>more \u00bb<\/a><\/p>\n","protected":false},"author":318,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,95],"tags":[101,102,98,97,130,96,100,99],"class_list":["post-1398","post","type-post","status-publish","format-standard","hentry","category-blog","category-raspberry-pi","tag-genesis","tag-megadrive","tag-nes","tag-nintendo","tag-raspberry-pi","tag-retropie","tag-sega","tag-snes"],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/zsprawl.com\/iOS\/wp-json\/wp\/v2\/posts\/1398"}],"collection":[{"href":"http:\/\/zsprawl.com\/iOS\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zsprawl.com\/iOS\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zsprawl.com\/iOS\/wp-json\/wp\/v2\/users\/318"}],"replies":[{"embeddable":true,"href":"http:\/\/zsprawl.com\/iOS\/wp-json\/wp\/v2\/comments?post=1398"}],"version-history":[{"count":8,"href":"http:\/\/zsprawl.com\/iOS\/wp-json\/wp\/v2\/posts\/1398\/revisions"}],"predecessor-version":[{"id":1407,"href":"http:\/\/zsprawl.com\/iOS\/wp-json\/wp\/v2\/posts\/1398\/revisions\/1407"}],"wp:attachment":[{"href":"http:\/\/zsprawl.com\/iOS\/wp-json\/wp\/v2\/media?parent=1398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zsprawl.com\/iOS\/wp-json\/wp\/v2\/categories?post=1398"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zsprawl.com\/iOS\/wp-json\/wp\/v2\/tags?post=1398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}