omgmog_ [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=34880 Pico-8 on the Raspberry Pi with Game HAT <p><em>This is reposted from <a href="https://blog.omgmog.net/post/pico8-on-the-raspberrypi-with-gamehat/">my blog</a></em></p> <p><a href="https://www.lexaloffle.com/bbs/files/34880/IMG_20190210_103757.jpg" target=_view_image><img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/34880/IMG_20190210_103757.jpg" width=160 height=120 alt="" /></a></p> <p>I've been playing with <a href="https://www.lexaloffle.com/pico-8.php">Pico-8</a> a lot lately. I've got a small Pico-8 project site to launch soon, but in the mean time I'm more occupied with getting Pico-8 running on <em>things</em>.</p> <p>Enter Raspberry Pi, and with it the <a href="https://www.waveshare.com/wiki/Game_HAT">Waveshare Game HAT</a> -- this is a nifty bit of kit. A screen, controls, and battery circuit that you just plug a Raspberry Pi in to, and voila you have a portable games console.</p> <p>I've got mine set up with <a href="https://retropie.org.uk/">Retropie</a> and this works with the Game HAT pretty much out of the box.</p> <p>Here are the tweaks needed:</p> <h3>Configure the display in your /boot/config.txt</h3> <p>This seems to vary from one Game HAT to another (according to the <a href="https://retropie.org.uk/forum/topic/20308/waveshare-game-hat-thoughts/9">Retropie forum</a>) but I found that the following config lines worked when added to the end of the config.txt:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>framebuffer_width=512 framebuffer_height=384 hdmi_group=2 hdmi_mode=87 hdmi_cvt=512 384 60</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>Configure the buttons</h3> <p>The buttons on the Game HAT will work if you install the mk_arcade_joystick_rpi driver in ~/RetroPie-Setup/retropie_setup.sh and then edit /etc/modprobe.d/mk_arcade_joystick_rpi.conf to contain:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>options mk_arcade_joystick_rpi map=5 gpio=5,6,13,19,21,4,26,12,23,20,16,18</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>Installing Pico-8</h3> <p>This is straight-forward. First you download the Raspberry Pi zip from your Pico-8 downloads page, extract it to your home directory, and install wiringpi:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre># get Pico-8 $ cd $ wget &lt;your url to pico-8_0.1.11g_raspi.zip&gt; $ unzip pico-8_0.1.11g_raspi.zip # install wiringpi $ sudo apt install wiringpi</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>Boot to Pico-8 (and Retropie while holding L)</h3> <p>There are all sorts of approaches that people have detailed elsewhere online to launch Pico-8 from the Retropie launcher, but I prefer the approach of configuring this install to be Pico-8 first, and then Retropie only if we're holding the L shoulder button at boot. This took some fiddling, but it's quite elegant:</p> <p>First, edit your /etc/profile.d/10-retropie.sh, you can do this over ssh and run &quot;sudo nano /etc/profile.d/10-retropie.sh&quot;. Replace the contents with this:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre># launch our autostart apps (if we are on the correct tty) if [ &quot;`tty`&quot; = &quot;/dev/tty1&quot; ] &amp;&amp; [ &quot;$USER&quot; = &quot;pi&quot; ]; then # if holding L shoulder button, start retropie if [[ &quot;$(gpio -g read 23)&quot; = &quot;0&quot; ]]; then bash &quot;/opt/retropie/configs/all/autostart.sh&quot; else # otherwise start pico8 by default /home/pi/pico-8/pico8 -height 320 -width 480 -splore &amp;&amp; sudo reboot fi fi</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>We're using the gpio command from wiringpi to check the value of GPIO pin 23 (L shoulder button on the Game HAT). If it's 0 (pressed) we launch the usual Retropie autostart.sh, otherwise we default to running Pico-8.</p> <p>With the Pico-8 command, I'm specifying the output resolution and launching it with -splore to give us a games menu. The &quot;&amp;&amp; sudo reboot&quot; bit means that if you exit Pico-8 using the menu options, it will then reboot the Raspberry Pi so you can get back to Pico-8 or hold L and start with Retropie.</p> <p>And that's it. If you want to make the most out of this you'll need to have your Wi-fi configured in Retropie.</p> https://www.lexaloffle.com/bbs/?tid=33225 https://www.lexaloffle.com/bbs/?tid=33225 Sun, 10 Feb 2019 18:26:28 UTC