Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
64 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

Contents
 Getting the Compiler
 Working

 Screen modes
 Drawing a
 pre-made image


 Printable version
 Discuss this article

The Series
 Volume I
 Volume II
 Volume III

What will this article cover?

This article will describe how to change the screen mode for the GBA and how to draw images in the bitmap modes 3, 4, and 5.

Let's begin.

Getting the Compiler Working

I hope you downloaded ALL the files needed for your operating system from the DevKitAdv site, as they will all be indispensable (except for maybe the C++ additions, but I like C++ and will probably use it in this article). Unzip all the files to the root directory, and you should have a new directory called DevKitAdv. Congratulations, you just installed DevKitAdv with everything you need.

Now open your friendly Notepad and type in some code. Save this code as anything you want with a .c extension (I'll use test.c for this example).

#include<stdio.h>

int main()
{
  return 0;
}

Yes, I know it doesn't do anything. This is just an example to get the compiler working. Also, make sure you hit return after the final brace or else your compiler will whine at you (for some reason there has to be a new line at the end of every file).

Now open up your text editor again and type in the following:

path=c:\devkitadv\bin
gcc -o test.elf test.c
objcopy -O binary test.elf test.bin

Save this file as Make.bat. Note that some of the information in the file might have to change depending on the name of your file and what drive DevKitAdvance is installed on.

Now double click on Make.bat. Wait for the program to end. Congratulations, you just wrote your first program. What the make file does is call gcc to create test.elf from test.c, then it calls objcopy to create test.bin from test.elf. You might want to read that a few times if you didn't get it. However, regardless of if you understand that or not, those are the only three lines you'll need to put in a make file to get your program to compile (although those lines may have to vary depending on how many source files you use and the names of these files). For example, if you were using two source files named test.c and input.c, you'd simply change the second line to:

gcc -o test.elf test.c input.c

I hope you understand, because things only get more complicated from here. :-)

Now that we know how to compile a simple program, let's move on.

Using What You Create

When you compile your program, two files should be created - a .elf and a .bin. You want to use the .bin. Simply run this .bin using your respective emulator to view your creations.

If you have a linker and a cart, use the linker (instructions are included and more info can be found at www.visoly.com) to write the .bin to the cart. Push the cart in your GBA, turn the GBA on, and viola! Your creations are running on hardware!





Next : Screen modes