Home  ·  Downloads  ·  Your Account  ·  Submit News
Documentation Homepage
HAMLib reference
Back to HAM Homepage


Hello World Tutorial

What we want to do
Display a sentence on the GBA screen
Which source are we talking about?
You can find the source code for this example in samples/helloworld. the source code in question resides in main.c
  
#include "mygba.h"

MULTIBOOT

Every HAM based GBA program should start like this. The include line is to make the compiler aware of all the HAM macros and functions available MULTIBOOT should only be set if you want to run this program directly from the RAM of the GBA, instead of from ROM. In most cases you want to delete this line of code, but it can be handy if you are writing programs that need to run form a GBA without a ROM attached (for example if you have a MBV2 but no flash cart).

  
int main(void)
{
    // initialize HAMlib
    ham_Init();

Every HAM program starts execution at function main() . After program starts, it is mandatory hat you initialize HAM by calling ham_Init() once. If you do not do this, HAM will not operate correctly.

  
    // init the Text display system on the bg of your choice
    ham_InitText(0);

Here we initialize the Text system. We need to do this in order to use the ham_DrawText() function.

  
        // lets draw some text
        ham_DrawText(2,10,"HAMlib text display example");

...and now we draw the actual Text to location x=2 and y=10.

  
    while(1)
    {
    }    
}

after that, we halt the program by looping it endlessly in a while loop.

Starting the program
Use Explorer to navigate to your HAM installation folder and invoke the start script (windows: startham_win.bat). In the resulting shell, type the following commands:
  
cd samples
cd helloworld
make vba

Then, change a few lines of code in main.c and retry "make vba". Have fun!

I need mooooooore tutorials!
Well you got them. Several nice people have built whole series of tutorials for HAM, including Aaron Rogers infamous ones at http://www.aaronrogers.com/ham/ , Peter's at http://www.console-dev.de and even some in german at http://www.devgba.de.


Documentation Homepage | HAMLib reference | Back to HAM Homepage
documentation created with Doxygen