[back]
Gameboy Advance development - smgbalib library
After being quite frustrated by compatibility issues with DirectX, DirectDraw, and .NET, I decided to abandon the PC as a game development platform. I turned to the Gameboy Advance instead. I liked the GBA very much when it was released, mainly because of the SP variant, which has been the best handheld console form to date, in my opinion. After going through a few demo programs for the GBA, I liked what I saw, and decided that I may make several small games for it. To support this, I started separating reusable functionality into a library I called smgbalib. The main design principle of it was that it be as easy as possible to use. There are many people who would otherwise start small game projects on older systems, but are hindered by the steep learning curve.

smgbalib trades speed and performance for ease of use, and readability. On this page you can also find an easy to set up and complete GBA development kit based on GCC (devkitadv), along with several examples built on smgbalib, which should present the basics, and should be within the grasp of anyone with some C knowledge.

Getting up and running is very easy:
  • download devkitadv
  • unzip devkitadv to C:\
  • download and unzip an example (they come with smgbalib) OR
  • download and unzip smgbalib in a directory where you can start coding

Downloads


smgbalib - the library itself. It is made up of just two files, a header file (smgbalib.h), and the compiled file (smgbalib.a). Take a look at the examples to see how to use the library yourself. All examples contain smgbalib in their directories.
smgbalib source - grab the source if you'd like to modify the library. It compiles under devkitadv
devkitadv - a solid GBA devkit. You will need this to develop for the GBA. All makefiles I provide assume that the directory devkitadv is unzipped in C:\ . Of course, you can change this, but you'll have to change some paths and/or makefiles.
Virtualboy Advance - A great emulator to use when testing your code!

Features


  • Text output based on a fixed-width font; displaying scores, instructions, menus is trivial.
  • Simplified input (keypad, buttons) reading
  • Support for loading and displaying bitmaps (wholly or partially), generated easily from PCX files
  • Demystified sound functions. Sound output on the Gameboy platforms is notoriously complicated, and I chose a few calls which can output sounds in a simple fashion, but of good diversity for game development
  • Random number generation

Examples


I supply several examples which use smgbalib, and which range in difficulty. Check the comments for additional answers, and clarifications. Each example comes packaged with a make.bat makefile, and smgbalib. Running make.bat should create a .gba file if the devkit was installed correctly.

Example 1 - text outputDownload here
This is a trivial example of how to display text on the screen. Due to its simplicity, it's a great starting point.
Example 2 - drawing pixelsDownload here
Pixels are the building blocks of graphics!
Example 3 - inputDownload here
This one is useful because it shows how to read input from all buttons and keypad directions.
Example 4 - soundDownload here
Getting sounds out of older systems was quite difficult. I have wrapped most of the ugliness, and have provided four functions to create sound effects. They are all demonstrated in this example.
Example 5 - bitmapsDownload here
Shows how to draw backgrounds and bitmaps on the screen.
Example 6 - animationDownload here
This example builds on the previous, and animates the bitmaps.
Example 7 - fancier animationDownload here
This one is simply meant to show that even simple animation can look amazing if the graphics are well done.
Example 8 - random numbersDownload here
Random numbers are crucial, since they can make your game feel different every time it is played.


smgbalib API


All calls available to developers can be found towards the end of the smgbalib.h file. I gladly welcome any emails with questions or suggestions, and will try my best to help beginning GBA developers in any way I can.

Happy Gameboy Advance homebrewing!