The Problem With Gaming On The Raspberry PI

I must apologize for this giant mess of  post, but I think it will be interesting to the right people. I'll keep working on streamlining this process so it's far easier for the average person to actually get games running on the Raspberry Pi.

This started out as the guide page for Stardew Valley on my website. I quickly realized that this is far too in depth for a new user of the Pi or Linux, and decided to start with a blog post while I refine and simplify the process. It's a simple process for me, but very tedious for most people. I didn't want to put this convoluted mess up as the first guide.

The first game I wanted to showcase is one of my all time favorites: Stardew Valley. This wholesome, fun, colorful farming simulator is more than just a fun and calming game. It's a labor of love, created by a single person. The story behind this game is lovely, and shows what's possible, even without access to a large team and near endless resources.

Fair warning: Getting this game to run on the Raspberry Pi 5 is not as easy as just double clicking on a file or shortcut. It requires installing some extra software, and running it in a way that most non Linux users might not be familiar with. I find it worth the effort to set this up though, as it's a great game. I spent countless hours looking into making this game run natively (without any emulation or extra software), but was unable to do so, as the source code is not available to work with. It's a locked down game, and for good reason. The creator needs to get paid for the immense effort that went into this game, and protect it from random changes and such.

-------------------------------------------------------------------------------------------------------------------

Hardware required: Raspberry Pi 5, CM5, 500, or 500+

Operating system: Raspberry Pi OS "Trixie"

Extra software required: Box64 and Pi Apps

Here's a quick overview of the process to get this game running, for anyone who knows how to do this stuff already:

1) Download the Linux version of the game from https://www.gog.com/en/game/stardew_valley

2) Right click the file and change the permissions to make it executable by "Anyone".

3) Install Pi Apps using the following terminal command: 

wget -qO- https://raw.githubusercontent.com/Botspot/pi-apps/master/install | bash

4) Install Box64 from within Pi Apps.

5) Right click on the downloaded installer file, click "copy path".

6) Type "box64" into a terminal window and then paste the path you copied:
box64 /home/dustin/Games/Linux/X86/Stardew_Valley_1.6.15/stardew_valley_1_6_15_24357_8705766150_78675.sh

7) Run this command and go through the installer program.

8) Start the game from either the desktop shortcut or the Games menu shortcut.

-------------------------------------------------------------------------------------------------------------------

I chose this game to start with because it's an excellent example of the problems with gaming on the Raspberry Pi computer and Linux. This is not an easy and fast process for the average computer user, especially those without any Linux or command line experience. It's not impossible, but it is tedious. 

Start here at the official website to learn more about this game, if you're not already familiar. The website is quite nice, and has links at the top for everything you need, including a detailed wiki that details nearly every detail of the game.

To actually acquire this game, especially for the Raspberry Pi, I recommend buying it at www.gog.com. GoG (Good Old Games) is an online game store that works to preserve and distribute games by removing software restrictions, modernizing older games for newer computers, and allowing you to simply download the and run the game files without the need for constant internet, CD keys, or other nonsense that eventually stops games from working. It's a great example of how things should be, but usually aren't. I donate monthly to GoG, as well as Wikipedia to show some support and keep things rolling. Even if only a little bit.

After you've paid for and downloaded the LINUX version of the game from GoG, you need to get it ready to run on the Raspberry Pi. Go to the folder where you downloaded the "stardew_valley_1_6_15_24357_8705766150_78675.sh" file (numbers might be different, depending on the version downloaded), right click on that file, click "properties", then go over to the "Permissions" tab at the top. Change the "Execute" option from "Nobody" to "Anyone" to allow the game to be launched. As I type this out, I realize I should make a video on how to do this as well. And a script to automate it. I'll add those to the massive list of things to do...

Once the file is executable, you need to install the Box64 emulation software. This translates the software for Intel and AMD processors to work on the ARM processor in the Pi. ARM processors are most commonly found inside of smartphones. Nearly every single smartphone uses an ARM processor these days. Using Box64 will use more processing power and slow the game down slightly, being an emulation layer, but the Pi 5 is powerful enough to play it. The easiest way to install Box64 is to first install Pi Apps, which is a small software installer that makes it very easy to install useful programs on the Raspberry Pi.

To install Pi Apps, open a terminal window by holding the "CTRL" key and the "T" key on the keyboard. A black window with text pops up. Type or paste the following into that box and press "enter":

wget -qO- https://raw.githubusercontent.com/Botspot/pi-apps/master/install | bash

This will install Pi Apps. After installation finishes, click on the Raspberry Pi logo in the top left of the screen, go down to "preferences", and click on "Pi-Apps" to open the installer. Click the magnifying glass search button in the bottom left, type in "box64", and press "enter". In the window that pops up, click the "Install" button and wait.

After this is done, you can install the game. Go back to the game file with the long name that you downloaded, and right click it. Click on "Copy Path". Go back to your black terminal window, or open a new one, type in "box64", press the spacebar, then press "CTRL", "Shift", and "v" at the same time to paste the path into the window. It should look something like this:

box64 /home/dustin/Games/Linux/X86/Stardew_Valley_1.6.15/stardew_valley_1_6_15_24357_8705766150_78675.sh

Press "enter" to run the command. This tells the Box64 emulation software to run the game installer. Without this, the installer will crash and fail because the system doesn't know how to run this game, which is meant for AMD and Intel processors.

If all went well, the installer program for Stardew Valley should start up, and you can install the game. Leave all of the options as defaults and install the game.

After this completes, hopefully without any errors, you can run the game from the desktop shortcut or the menu shortcut under "Games". The game takes about a minute to actually start, so be patient. I've done some digging into why this takes so long to load, despite the Raspberry Pi 5 being plenty fast enough to copy the entire game into memory in just a few seconds. It turns out that loading the game only uses 1 of the 4 processor cores to unpack and load the game into memory. It's a single threaded application. On most modern computers, the processor is so ridiculously fast that you would never notice this. On the Raspberry Pi 5, even overclocked to 3.0Ghz, a single core is just not fast enough to open the game quickly. I found that there is no way to modify the game to fix this, as the source code is not available, and would require the game to be heavily modified to support running on multiple processor cores. For now, and probably ever, you just have to wait about a minute for it to start running. Once it does, it runs well, and is fully playable on the Raspberry Pi 5. I did find a potential way around this: saving a snapshot of the code in memory, after the game has loaded, and loading that snapshot from the save point. This would eliminate the processing time and replace it with file loading time, which is much shorter. This is quite an advanced technique that I haven't gotten into just yet. It's on the list though.

My Raspberry Pi 5 development system has an AMD Radeon RX460 4GB graphics card installed to allow me to run more intensive games and programs, but I have played Stardew Valley on a stock Raspberry Pi 5. Overclocking the Pi 5 to 3.0Ghz does help performance quite a bit. At 1080p resolution, this game runs well and is very enjoyable.

To learn more about my retro themed Raspberry Pi development system, check out this blog post.

I hope this helps a few people get this game running on their Raspberry Pis. This is just a small part of a much bigger project to make a proper cartridge based computer system using the Raspberry Pi.

Back to blog

Leave a comment