Skip to content

Instantly share code, notes, and snippets.

@Lokathor
Last active February 22, 2024 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Lokathor/f9af27465f30ede545a7801f2f2a5d75 to your computer and use it in GitHub Desktop.
Save Lokathor/f9af27465f30ede545a7801f2f2a5d75 to your computer and use it in GitHub Desktop.

Here are the steps to setup mgba as well as the development tools that you'll need to build GBA roms on your Raspberry Pi. I did this on a Pi4, but it should work on a Pi3 or even a Pi2 just as well.

  • un-comment the sources repo in /etc/apt/sources.list using your editor of choice (requires root of course).

  • sudo apt-get update to get fresh sources info

  • sudo apt build-dep mgba-qt to install all the dependencies of the Qt version of mGBA (which also will allow the non-Qt version of course). We don't want to grab mGBA itself from the repositories. It's there, but the version they have is not the latest (0.7.0, in current stable). Instead, we just tell apt to get us the dependencies needed for building the old version ourselves, because the new version (0.7.2) has basically the same dependency list.

  • git clone https://github.com/mgba-emu/mgba.git to get the source files in a local folder.

  • cd mgba && mkdir build && cd build to go into the mgba folder, make a folder for just the build junk to sit in, and then go into that.

  • cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local .. will run the system configuration checks to setup the build and print out a status report of the selected features.

    • You might get a big message about Qt5 Linguist Tools being missing, but if you only care about mgba being in English that's okay.
    • The install prefix can be changed, I'm just suggesting /usr/local as a good default.
  • If the feature selection output looks good then you're ready to actually build mgba. Just type make and it'll get to work. You can also use time make and it'll print out how long it actually took at the end. With my rpi4 and a good heat sink it took 10m:57s. I was also browsing the web and writing this guide at the time but I don't think that had a big effect.

  • sudo make install to install the completed programs.

    • mgba will run a rom directly from the command line
    • mgba-qt will open a window with a blank panel and let you use the GUI to select a rom and change settings and so on.
  • sudo apt-get install binutils-arm-none-eabi will pull in the binutils that work with the GBA.

    • Remember, when running a GBA game the device uses its ARM7TDMI CPU, which implements the ARMv4 instruction set.
    • Yeah, the ARM naming scheme is totally stupid, but try to remember at least that "ARM7TDMI implements ARMv4", if you can.
  • Be sure to grab yourself a copy of the various manuals involved with GBA programming:

    • ARM7TDMI Technical Reference Manual is the official guide for the GBA's core.
    • Thumb16 Instruction Set Quick Reference Card has info on the Thumb instruction set, which is the main instruction set you'll be using with a GBA game whenever you do assembly.
    • ARM and Thumb-2 Instruction Set Quick Reference Card has info on the ARM instruction set, which you sometimes have to use as well. Because of the GBA's design, ARM instructions load more slowly when fetching them from the ROM, so ARM code should generally be avoided, but for a few things it's necessary to use ARM instead of Thumb. Note that this file also shows stuff about the Thumb-2 instruction set, but that is NOT supported by the GBA, and you should not attempt to use it.
    • GBATEK is most commonly used document for GBA information (also DS, and DSi). In addition to having listings of all the GBA's tech specs and all Memory Mapped IO (MMIO) addresses, it has a full ARM CPU Reference section, complete with descriptions of the ARM and Thumb instruction sets. Most folks just suggest GBATEK as the guide of choice, but I thought I'd link the official ARM manuals earlier in the list because sometimes GBATEK is a little terse, and the ARM manuals are a good source if you feel confused about any CPU stuff when reading GBATEK. The HTML file is quite large and takes a moment to load because of it, so you might want to save a local copy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment