Gameboy Advance development - smgbalib library
Last updated on December 26, 2011, 15:09 by Sebastian Mihai
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!
If you use the materials on this page, or any other page on this web site, you do so at your own risk. They are provided "as is". No warranty is provided or implied. I neither guarantee that the materials will work, nor that they will not be harmful in any way.

Intellivision development - Hotel Bunny

Coverage of my projects

Interviewed in the Retro Gamer magazine

My homebrew cartridges

ZX Spectrum development - Husband Chores (in Z80 assembly language)

No Snakes! - a multiplayer game over serial port

Sega Dreamcast development - Overbearing Burgers

Snowdrop OS - my operating system from scratch, in assembly language

libzx - ZX Spectrum game programming library (Z80 assembly language)

Compact Pong - game in C# for the Pocket PC (Windows Mobile 2003)

TOTP (time-based one-time password) authenticator in C# (.Net)

aSMtris - Tetris in assembly language (x86, 16-bit)

Balanced Diet (GBA) limited edition

Gameboy Advance development - Balanced Diet

Atari 7800 development - Poetiru

Arcade ROM hacking - Knights of the Round translation

PocketStation development - Pocket Worm

Sega Game Gear development - Burgers of Hanoi GG

Pokemon Mini development - Mini Cookie

Magnavox Odyssey2 development - Red Green

Sega Dreamcast VMU development - Raining Squares

Nintendo GameCube development - Mama Bear Puzzle

Nintendo Wii development - Groundhog Puzzle

Sega Saturn development - Saturnade

Atari Jaguar development - Jagmatch

Sega CD development - Blackjack CD

Nintendo 64 development - Don't Be Square

Commodore 64 development - Tube64

Sega 32x development - Eight Queens

WonderSwan (Mono) development - Swan Driving BW

WonderSwan Color development - Swan Driving

Animal Keeper - a JavaScript and HTML5 Canvas game

3DO development - Space Invaders Invaders

Sony PlayStation development - The 11th Power

Sony PSP development - Newton Voyage

Nintendo DS development - Geoincursion

Gold of the Kingdoms - an XNA/C# homebrew game

Blue Elf 2 309-in-1 JAMMA PCB - troubleshoot controls not working

Fractals in JavaScript and HTML5 Canvas

Angry Video Game Nerd (AVGN) theme song on the Gameboy Advance

Novice calligraphy - Gothic hand, with letter guide

Video compilation of my classic console homebrew games

Seven segment display circuit with the 4511 decoder and the 4029 counter

A simple Atari 2600 joystick tester circuit

555 timer and 4017 decade counter - traffic lights circuit

Catch That LED! - an electronic game circuit

Capacitor study circuit

BlackBerry PlayBook development - Sheepish Bearings (Native SDK, OpenGL)

Neo Geo Pocket Color development - NGCollector

Neo Geo development - Neo Thunder

Atari 5200 development - Shooting Gallery

ZX Spectrum development - simple input/graphics example

Vectrex development - Scalar Ownage

Nintendo Virtual Boy development - Real Danger

Gameboy Color development - Burly Bear vs. The Mean Foxes (GBC version)

Sega Master System development - Burgers of Hanoi

Colecovision development - Mowleco

TurboGrafx-16/PC Engine development - Alddee

Atari Lynx development - Catkanoid

Nintendo NES development - Invaders must die!

Atari 2600 development - Snappy (batari basic)

Super Nintendo development - Bucket

Gameboy Advance development - smgbalib library

Airplane Vegas slot machine

Sega Genesis development - Gen Poker

(2004) Project One - first university game programming club project

Gameboy development - Burly Bear vs. The Mean Foxes

(2006) RGB Overdose - university programming contest entry