Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Dwarf Fortress on Raspberry Pi and ARM devices  (Read 5091 times)

delphonso

  • Bay Watcher
  • menaces with spikes of pine
    • View Profile
Dwarf Fortress on Raspberry Pi and ARM devices
« on: November 29, 2021, 10:28:49 pm »

Look... I don't know why you'd want to do this - maybe you want to make an interactive coffee table that only plays DF. Maybe you're committed to having bad FPS. Either way, here's how to play DF on a Raspberry Pi (or presumably any ARM SBC)

I've been tossing this problem around in my head and in action for a while now and messaged methylatedspirit about the issue as well - there are a couple methods to tackle the problem, but first, let's discuss "the problem".

Raspberry Pi are built on ARM architecture - meaning they don't run most programs natively (most programs are x64 or x86 architecture [likely your PC is x86_64, for example]). DF isn't released for ARM architecture - as it's relatively a niche market for home computers and the great Toad's time is limited. But you're not completely out of luck.

If you're going for some sort of record for "playing DF on the most devices possible", Eniteris wrote a guide to play DF on a phone on the DF Reddit. This is an excellent guide and far better than what follows.

Solution 1: The Bad One.
WINE will run the Windows version of DF on a Raspberry Pi. WINE isn't too hard to set up on the Debian-based OSes (and comes included in most of them like Raspbian and Twister), however it isn't available on every OS for the Pi. WINE (and really, whatever software is being used to emulate the architecture, such as QEMU) takes up a bit of processing power and even on a Raspberry Pi 4 - the impact will be obvious.
Not recommended, but if you have a fresh OS install, it might just work right away. It works just like Windows - run the Windows version of the game after unzipping it somewhere.


Solution 2: The Easy One
Cut out the middle-man and just use the architecture emulator.
Before anything, chuck an ol'
Code: [Select]
sudo apt update && sudo apt upgrade in the terminal and then get to work with the following:

Box86 is a tool which mimics the architecture of x86 devices - it is also very low-impact and probably the best bet for running DF. QEMU and a few others could potentially provide the same service, but Box86 seems to be the best option and easiest to set up. If you know more about QEMU, let me know - and I'll update how to run DF through it (no matter how convoluted).

Box86 only runs x86 architecture (that's 32-bit) So, run over to the bay12games page and download the 32-bit version of DF. Unzip and double-check the libraries:
Code: [Select]
$ sudo apt install libsdl1.2debian libsdl-image1.2 libsdl-ttf2.0-0 libgtk2.0-0 libopenal1 libsndfile1 libncursesw5My test last night returned mostly "already up to date" on these - so it may not be necessary at all.

-=-=-=-Solution 2-a: TwisterOS
If you don't care much about the OS and just really want to play DF like...within 30 minutes: TwisterOS comes with Box86 ready and loaded. Navigate to the df_linux folder (probably $ cd ~/Downloads/df_linux) in the terminal and just run ./df and you're off to the races! It certainly works. It's slow, but it runs and is playable, if you have the patience.

-=-=-=-Solution 2-b: Pi-Apps
If you're already on 32-bit Debian (Ubuntu or Raspbian being the most common choices), you can install Pi-Apps to grab Box86 and keep it up to date. methylatedspirit explains how:
Quote from: methylatedspirit
Started with base Raspbian OS, installed Pi-Apps on it. To save you time, here's the command you need:
Code: [Select]
wget -qO- https://raw.githubusercontent.com/Botspot/pi-apps/master/install | bash
Went through its menus to install Box86. That'll get you the weekly builds of Box86, which should be recent enough. Thankfully, DF is available as an x86 Linux binary, so just download that. Run these to fix the exec permissions:
Code: [Select]
chmod +x df_linux/df
chmod +x df_linux/libs/Dwarf_Fortress
cd into the df_linux directory, run the ./df script to run DF. If all goes well, it'll work first try.
Note: methylatedspirit says this might depreciate in the next few years - check their post below for more info, if you use this method.

-=-=-=-Solution 2-c: Synaptic Package Manager
Presumably, you have a visual package manager install - just go there and search for Box86. Install, then follow the same instructions as above.
[psst, I need to double-check if it's there or not...This could be total bullshit, it's not on my laptop's graphical package manager but it's also not an ARM device, so...]


Solution 3: The More Options One
Any 32-bit, Debian based OS should be able to do this, and presumably a 64-bit OS (which RPi does also support, perhaps with Box64).
Grab Box86 through your package manager (apt, most likely, if you're on Debian).
sudo apt install box86
I have no clue if this will work with a 64-bit debian-based OS on the Pi (are there any?) If not, you may want to use Box64 and run the 64-bit version of DF. All other things should be equal.
Unzip, update libraries, navigate and ./df


Additional, possibly useful information
Here's a github specific issue on box64. Here's the Box86 github and the Box64 one.

The necessary libraries for DF on Arch can be picked up with:
Code: [Select]
$ pamac install gcc-libs glew glib2 glu gtk2 gtk3 libsndfile openal sdl_image sdl_ttfOr will be picked up and fixed themselves if you can build it from AUR (I don't know how to do this, but in theory, it should work.)
I haven't managed to get DF to run on Manjaro on a Pi, but rna's guide from the manjaro forums suggests it is possible (but this thing is really poorly written...)

Avoid the DF package from the Debian repos - it is out of date (47.04 last I checked) and also makes it very hard to change init and raws.

So! Good luck, intrepid adventurer, and enjoy a very slow DF experience. But hey - $40 bucks is pretty cheap for a computer that can run DF.
I'm no expert on all this - just been messing around with it for a while and trying to get DF to run on something that isn't Debian. Any advice below is appreciated. Mostly - this is just a thread for anyone who googles "df on raspberry pi" or searches the forums for an answer.
« Last Edit: December 06, 2021, 12:33:43 am by delphonso »
Logged

Clément

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #1 on: December 02, 2021, 05:05:08 am »

Wine has very little impact on performance, but it won't help you run x86/x64 applications on arm. It's not a bad solution, it's just not a solution at all.
Logged

methylatedspirit

  • Bay Watcher
  • it/its
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #2 on: December 02, 2021, 06:59:02 am »

Ain't no rule says you can't optimize your past self. I'm writing this to satisfy the command-line addict in me, but I hope this'll be of use to someone else.
Quote from: methylatedspirit
Started with base Raspbian OS, installed Pi-Apps on it. (...)

A little look through how Pi-Apps modified the apt sources list(s) at /etc/apt/sources.list.d/box86.list reveals that it's just pointing to someone's deb repo. Yes, it's just a deb repository; it's just the easiest and most maintainable way to do updates. A tiny bit more digging, and it's this page that has the instructions. If all you wanted was Box86, just follow that page's instructions.

If you're paranoid and did the manual install instead of trusting some script off the Internet and running it as root:

Code: [Select]
sudo apt update

Regardless of how you added the repo, you'll want to do:

Code: [Select]
sudo apt install box86

and that should get you Box86. Pi-Apps appears to be a graphical frontend to this exact process, but I haven't read through its Box86 install script yet. 

« Last Edit: December 02, 2021, 07:21:16 am by methylatedspirit »
Logged

Eniteris

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #3 on: December 02, 2021, 01:49:57 pm »

So I stumbled upon this thread, and therefore have been attempting to install Dwarf Fortress on my phone.

I'm using Pixel3 > termux > proot > arch > box64 > df, and managed to find all the libs and made symlinks between .so.6 and .so.5s, but I don't have a display to send the output to, and [PRINT_MODE:TEXT] is segfaulting on nc_numpad and I can't seem to get around that.

It seems like people have more success on debian? So I'm working on that now. And your post was useful for finding the source/keyring for the package (to save me from finding a compiler to rebuild it)

EDIT2: IT WORKS! (on debian, probably because its using libncursesw5 rather than trying to symlink 6 to 5. PRINT_MODE:TEXT and no sound. Time to try fps)

Edit 3: Worldgen Pocket world was zippy, two weeks before embark was also super fast. 3x3 seems to be reasonably fast, but I had to change the font because the dwarves are emojis. I also need an external keyboard.
« Last Edit: December 02, 2021, 02:30:36 pm by Eniteris »
Logged

delphonso

  • Bay Watcher
  • menaces with spikes of pine
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #4 on: December 03, 2021, 04:13:54 am »

Wine has very little impact on performance, but it won't help you run x86/x64 applications on arm. It's not a bad solution, it's just not a solution at all.

You're probably right about this. I used Wine to run the windows version of DF, but I don't know if Box86 was involved in either running wine or running the game. I'll look at it closer and change the post.

Ain't no rule says you can't optimize your past self. I'm writing this to satisfy the command-line addict in me, but I hope this'll be of use to someone else.
Quote from: methylatedspirit
Started with base Raspbian OS, installed Pi-Apps on it. (...)

A little look through how Pi-Apps modified the apt sources list(s) at /etc/apt/sources.list.d/box86.list reveals that it's just pointing to someone's deb repo. Yes, it's just a deb repository; it's just the easiest and most maintainable way to do updates. A tiny bit more digging, and it's this page that has the instructions. If all you wanted was Box86, just follow that page's instructions.

If you're paranoid and did the manual install instead of trusting some script off the Internet and running it as root:

Code: [Select]
sudo apt update

Regardless of how you added the repo, you'll want to do:

Code: [Select]
sudo apt install box86

and that should get you Box86. Pi-Apps appears to be a graphical frontend to this exact process, but I haven't read through its Box86 install script yet. 


I'll be sure to add the simpler 'just install box86' information as well. Seems odd that I didn't and instead recommended software.

So I stumbled upon this thread, and therefore have been attempting to install Dwarf Fortress on my phone.

I'm using Pixel3 > termux > proot > arch > box64 > df, and managed to find all the libs and made symlinks between .so.6 and .so.5s, but I don't have a display to send the output to, and [PRINT_MODE:TEXT] is segfaulting on nc_numpad and I can't seem to get around that.

It seems like people have more success on debian? So I'm working on that now. And your post was useful for finding the source/keyring for the package (to save me from finding a compiler to rebuild it)

EDIT2: IT WORKS! (on debian, probably because its using libncursesw5 rather than trying to symlink 6 to 5. PRINT_MODE:TEXT and no sound. Time to try fps)

Edit 3: Worldgen Pocket world was zippy, two weeks before embark was also super fast. 3x3 seems to be reasonably fast, but I had to change the font because the dwarves are emojis. I also need an external keyboard.

This is amazing. I can't believe they're emojis! Can you post a screenshot of that?

feelotraveller

  • Bay Watcher
  • (y-sqrt{|x|})^2+x^2=1
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #5 on: December 03, 2021, 05:10:12 am »

Wine has very little impact on performance, but it won't help you run x86/x64 applications on arm. It's not a bad solution, it's just not a solution at all.

It can be a solution if QEMU is used to run wine but then negative performance impacts exist... from qemu.  ;)
See this for example: Guide: How to Run x86 on ARM (hackers might find this of interest, but the original gloss of wine being a bad solution is correct if going about it this way).

The necessary libraries for DF on Arch can be picked up with:
Code: [Select]
$ pamac install gcc-libs glew glib2 glu gtk2 libsndfile openal sdl_image sdl_ttfThough most of these are probably already present. The main issue seems to be with gtk and the libgraphics.so which is provided by DF. I'll see what I can get up to. If you've got any recommendations, I'm happy to hear them.

I'm guessing you might also be installing DF through Manjaro? If so then they will be grabbing it from the Arch repository.  Arch patches the df libgraphics.so to not depend upon gtk2, but also lists gtk3 as a dependency for the overall package.  So either install gtk3, or use the unpatched libgraphics.so from the bay12 dwarf fortress download.  Heck, you could just straight up use the bay12 linux version... well apart from deleting/renaming that pesky libstdc++.so.6 which it includes.
« Last Edit: December 03, 2021, 05:16:58 am by feelotraveller »
Logged

delphonso

  • Bay Watcher
  • menaces with spikes of pine
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #6 on: December 03, 2021, 06:29:56 am »

I suppose you could, with the right jiggering of pamac or pacman. I just grabbed it from the bay12 site rather than trying to track down and install it through command line.

feelotraveller

  • Bay Watcher
  • (y-sqrt{|x|})^2+x^2=1
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #7 on: December 03, 2021, 07:42:31 am »

Ah, okay disregard my musings on that then.

In terms of jiggering to install from within manjaro
Code: [Select]
sudo pacman -Syu dwarffortressshould do it, and take care of installing any required but missing dependencies at the same time.
(Note that it will also do a system update, because rolling is rolling.)

Edit: maybe you can find something useful here: https://github.com/ptitSeb/box64/issues/101?
« Last Edit: December 03, 2021, 07:55:41 am by feelotraveller »
Logged

delphonso

  • Bay Watcher
  • menaces with spikes of pine
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #8 on: December 03, 2021, 08:54:44 am »

Pacman and pamac won't grab files from non-ARM architecture (I'm sure you could search the rest of the repositories, but I don't know the arguments off the top of my head) if you put that in on a pi. Pacman -Ss dwarffortress returns nothing, and presumably pamac search dwarffortress would do the same.

Ah, that is quite interesting. I'll dig into it deeper and update the op.

Eniteris

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #9 on: December 03, 2021, 09:30:14 am »

This is amazing. I can't believe they're emojis! Can you post a screenshot of that?

Ask and ye shall receive:


I also wrote up installation instructions on the Reddit
« Last Edit: December 03, 2021, 09:54:35 am by Eniteris »
Logged

LordBaal

  • Bay Watcher
  • System Lord and Hanslanda lees evil twin.
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #10 on: December 03, 2021, 11:33:02 am »

This is madness...
Logged
I'm curious as to how a tank would evolve. Would it climb out of the primordial ooze wiggling it's track-nubs, feeding on smaller jeeps before crawling onto the shore having evolved proper treds?
My ship exploded midflight, but all the shrapnel totally landed on Alpha Centauri before anyone else did.  Bow before me world leaders!

delphonso

  • Bay Watcher
  • menaces with spikes of pine
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #11 on: December 06, 2021, 12:35:18 am »

Ask and ye shall receive:


I also wrote up installation instructions on the Reddit

This is such a well-written guide, Eniteris - well done! AnySoftKeyboard (open-source available through f-droid) has a "terminal" layout, which includes the numberpad and arrow keys/page up, etc. Perhaps that could be used to not need the additional button bindings?

I updated the OP and feel ashamed of its quality in comparison. Feel free to let me know of any clear mistakes, anyone.

This is madness...

I won't be satisfied until I'm playing DF on a Casio calculator watch.
« Last Edit: December 06, 2021, 12:37:38 am by delphonso »
Logged

Eniteris

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #12 on: December 06, 2021, 07:12:24 am »

AnySoftKeyboard (open-source available through f-droid) has a "terminal" layout, which includes the numberpad and arrow keys/page up, etc. Perhaps that could be used to not need the additional button bindings?

I haven't tried AnySoft, but with Termux you can customize the topbar keyboard, so you don't need to put in multiple buttonpresses to get commonly used keys (>, <, +, -, etc.).

And I wouldn't have tried running it on the phone if you I didn't read your post first. It was very helpful to get it up and running!
Logged

Thisfox

  • Bay Watcher
  • Vixen.
    • View Profile
Re: Dwarf Fortress on Raspberry Pi
« Reply #13 on: December 06, 2021, 06:01:13 pm »

This is amazing. I can't believe they're emojis! Can you post a screenshot of that?
Ask and ye shall receive:

♡♡♡ OMG ♡♡♡
Wow. Big phone screen or possibly very tiny map.

Look... I don't know why you'd want to do this - maybe you want to make an interactive coffee table that only plays DF.
...Well I didn't before, but I do NOW.

(several edits, I had to relearn how to end a quote, sorry)
« Last Edit: December 06, 2021, 06:03:26 pm by Thisfox »
Logged
Mules gotta spleen. Dwarfs gotta eat.
Thisfox likes aquifers, olivine, Forgotten Beasts for their imagination, & dorfs for their stupidity. She prefers to consume gin & tonic. She absolutely detests Facebook.
"Urist McMason died out of pure spite to make you wonder why he was suddenly dead"
Oh god... Plump Helmet Man Mimes!

Homo carbonis

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress on Raspberry Pi and ARM devices
« Reply #14 on: February 12, 2024, 11:09:59 am »

I know this is an old thread but I would like to add that DF runs remarkably well on my RPi 400 with box64. Just install box64 and DF for linux, then change the last line in run_df to
LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}${DF_DIR}" box64 ./dwarfort "$@"
.

Everything works as it should. The framerate is not great but it is quite playable. I have seen worse playing on an old PC.
Logged
Pages: [1] 2