Nintendo GameBoy Advance (GBA) Programming Tips for Homebrew Software Development

David A. Wheeler, 2006-10-05

I've been learning about development tools for programming Nintendo's GameBoy Advance (GBA) handheld consoles, both in general and as a way to teach how to program. Here are a few things I learned along the way as of September 2006. I document it here in the hopes that you'll find it useful.

Development Kits/Libraries

You need a development kit (a compiler plus typically related goodies) to develop software. There are many development kits out there, but for the GBA the three most common (and primary) choices for someone without unlimited funds are the following:

  1. devkit advanced - at one time this was the most common GBA development environment, but it's aged, and is not as well-supported any more. So one of the following two choices is more likely.
  2. devkitPro/devkitARM - this is essentially the heir of devkit advanced; it works in a very similar way, and it appears to have replaced devkit advanced as the most common freely-available kit (TONC and the GBA FAQ both claim this). It has a saner development environment than devkit advanced. devkitPro is the overall project, designed to support many different consoles; you need to pick the pieces of devkitPro appropriate for the GBA, such as devkitARM (for the GBA's ARM chip) and libgba (the library for GameBoy Advance).
  3. HAM Gameboy Advance Development Kit - HAM is a closed-source programming library to make GBA programming easier. The HAM GBA development kit is a whole development kit built up around the HAM library.

All three of these have the GNU gcc compiler at their core, and support both the C and C++ programming languages.

The choice of whether or not to use HAM is complicated, if you're trying to teach GBA programming to a beginner. HAM seems especially well-suited for starting out beginners in an easier way. Positives of HAM:

But HAM has many negatives. Fundamentally, HAM is not open source software; if you demand completely open source software, then that's a disqualifier. Now if you don't demand that, at least its license is unusually generous for closed-source (the free version merely nags you with a splash screen, and registered versions are only $29). But source code is not provided, and you may not modify the library at all. This can be very limiting, and creates support risks too that you need to carefully consider. For example:

devkitPro comes with its own library, which does many things, and many who don't use HAM seem to create their own libraries.

One library that is an alternative to HAM and devkitPro's provided library is SGADE, which is an open source software library (there's a SourceForge SGADE site as well). SGADE uses a zlib style license, a permissive GPL-compatible license like the BSD-new license is, so you can use SGADE to create open source or proprietary programs. Unlike the BSD license, while it's suggested that you give credit in the running program, SGADE doesn't even require that - the only real requirement is that the source code give credit to the SGADE developer (and you'd want to do that anyway). SGADE has many capabilities, and it does have reasonable documentation. SGADE's original makefiles were designed to work with devkit advance, but this is not a problem, because the SGADE site also provides makefiles for devkitPro (but you have to get them!). You can get from the SGADE site the SGADE Devkitpro makefile (here's my local copy of the SGADE Devkitpro makefile) and the SGADE Devkitpro makefile for the bba tutorial (here's my local copy of the SGADE Devkitpro makefile for the bba tutorial). If you want to learn more about the changes that were made, Dave Murphy posted in May 2006 an explanation about how to use SGADE with devkitARM (here's a copy of Murphy's post about SGADE with devkitARM).

This page gives a lot of info on setting up using Linux.

I looked over the options, and eventually decided to use devkitPro/devkitARM. I don't like the risks and limitations of using the HAM library. Others may decide differently, of course.

Tutorials

There are lots of tutorials; they can be primarily divided into whether or not they use HAM.

Some useful tutorial options that use devkitPro/devkitARM (or its predecessor devkit advance) include:

If you're using the SGADE library (a library you could use instead of HAM), the SGADE tutorial is a very nice tutorial. It walks you through developing a game using SGADE, and if you're going to use SGADE it's hard to find a better place to start. As noted before if you're using SGADE with devkitPro, you need the SGADE Devkitpro makefile (here's my local copy of the SGADE Devkitpro makefile) and the SGADE Devkitpro makefile for the bba tutorial (here's my local copy of the SGADE Devkitpro makefile for the bba tutorial).

Probably one of the better tutorials is Harbour's free book on developing GBA programs - it's a whole book, but note that this is HAM-based. A college course used this book as their textbook. If you use HAM, you can also peek at Aaron Roger's tutorial, which is also HAM-focused.

Emulators

To develop software for a GBA, you really need at least one emulator.

One of the best is VisualBoy Advance, and it's open source too. Note that Windows NT can run VisualBoyAdvance, but on that platform use the SDL version (not the Windows version) and change the display settings from 256-color to 65536-colors.

Other reasonable emulators are BoycottAdvance and no$gba.

Information Sources

The Wikipedia GameBoy Advance and Wikipedia GameBoy Advance SP articles have some good overall (mostly non-technical) information.

gbadev.org is a good source for general information on GBA development, and has (as of October 2006) a very active "Coding" forum. They have a good Frequently Asked Questions (FAQ) file for GBA developers, but it's very hidden - to get to it, go to their forums, select the (development) "Beginners" section, and then select "Frequently Asked Questions" (and not the "FAQ" entry at the top, which only tells you how to post to a forum). The devrs.com GBA developers website is another useful website (the GBA devrs.com FAQ has useful info). devkitPro's links page lists links to many other information sources.

Here's detailed technical information about the GameBoy Advance, and here's a memory map.

For information on its hardware interface, Reiner Ziegler's GameBoy hardware information has lots of useful tidbits.

The State of Homebrew On All Consoles (July 2006) is a brief overview of the current state of homebrew software for various game consoles.

Programs

Most of the tutorials include code.

One funny project runs a really old version of Unix on a GameBoy - the GameBoy emulates a PDP-11, and then they load a very old Unix for PDP-11 onto it. For a more modern twist, someone has Linux running on a GBA.

Stay Legal

There are many legally-available games that can be downloaded and run on these emulators. Sadly, many people are illegally posting games which are not legal to copy to other people. Please do not download or run illegal ROMs.


You can view David A. Wheeler's home page.