C Code Generation

NOTE: This section assumes you understand the C programming language and Gameboy Advance programming.

This dialog is presented when you select the Generate C option. The Directory field lets you select which directory the generated source and header will be written into.

The Filename allows you to enter what the sources will be called. Note that no extensions are required; entering foo here will create foo.c and foo.h.

The Array entry allows you to provide a basename for the generated arrays and #defines. For example, entering bar here will create the following header file:

#ifndef FOO_H
#define FOO_H

#ifdef _cplusplus
extern "C" {
#endif

#define BAR_ROT 0

#define BAR_COL 128

#define BAR_SIZE 0

#define BAR_DATA_LEN 1024
extern const unsigned short bar_data[1024];

#ifdef _cplusplus
}
#endif


#endif

Going from the top of the header, these definitions and arrays are created:

BAR_ROT
This is set to one if the map is a rotate/scale map.

BAR_COL
This is the colour setting to use in the REG_BG?CNT register for this map.

BAR_SIZE
This is the size setting to use in the REG_BG?CNT register for this map.

bar_data[]
This is the map data itself.


Using the generated code

To use code generated, simply #include the created header where needed, compile the source file to an object file and link it in with your executable.

Note that the source file is not dependent on (i.e. does not include) the header!