bmp2gbtile

Download

Download latest bmp2gbtile (v 1.0 , 07/02/04)

Abstract

This utility is intended for Gameboy Advance software development. The utility will take a set of one or more .bmp files and creates a single C or C++ source representation. This source can be compiled and linked into a GBA project and used for on screen sprites (from 8x8 to 64x64 pixels in size) or background tiles.

Program Features

Those who are familiar with GBA development know that there are a number of programs available that accomplish the same basic task as bmp2gbtile. There are features of bmp2gbtile, however, that differentiate it from other programs. These features include:

Usage


usage: bmp2gbtile   ?file2.bmp? ... ?-classname ? ?-obj_offset ?

This program converts a set of 16/256 color bmp files into GBA sprite/tile data

The program takes one or more .bmp files as input and generates 
a single header file based on all read files.  This header will 
contain a single '1D' binary stream of the tile data along with an 
enumeration of palette information for each sprite.

This program also generates an index structure that will give correct
GBA hardware settings for each object.  The format of this structure
will be the OBJ format

This program will perform limited palette mactching using the following algorithm:
  1) All bitmaps are loaded into memory 16x16 palettes are cleared
  2) bitmaps are split into 2 groups (A,B) where 0 < A <= 16 < B < 256 colors
  3) For each group A_i from A from the most colors to the least:
     a) select a palette that has the lowest palette delta from A_i,
        expand the palette to support A_i, remap A_i, and continue
  4) Try to fit group B into existing palette.

If any of the above steps fail, the program will not complete and
will return an error

Options include:

  -classname [name]      The header file will be generated as a static
                         class with a default classname of .
                         This option can be used to override this name.

  -lang [name]           The language format to use.  Currently c or c++ is
                         accepted as input

  -obj_offset [n]        This can be used to set the object offset.  This
                         parameter is useful when using bitmapped graphics
                         modes (set obj_offset to 512 in these modes for
                         correct header information

  -tile                  This puts the bmp2gbtile program in tile mode.  In tile
                         mode, any bmp dimension that is a multiple of 8 is accepted.
                         in this mode, the bitmap is scanned from left to right and 8x8
                         chunks are outputted

  -no_attr               This surpresses attrN data from the output files

  -no_palette            This surpresses palette data from the output files

  -palette_file [file]   This loads a specially formatted palette constraint file
                         that can be used to manually constrain parts of a palette
                         This is useful when combining the results of multiple
                         Invovations on bmp2gbtile, when it makes sence to do things
                         this way.

The format of the palette file is simple, here is an example:

# This is a comment

# start a palette by stating 'pal' followed by a palette number (0-15)
# if using 256 colors, simply use '0'

pal 0
# The rest is the colors in 5 bpp, BGR format, the same as the GBA
# hardware would expect.  The color idx always starts at zero, there
# is currently no way to start at a non zero index.  Palette data is
# assumed hex
#Here are two colors (0 and 1):
7FFF
0000

Future Enhancements

Example

The bmp2gbtile program includes two examples, one in C++ and one in C, that demonstrates how to use the program in actual GBA code:



As you can see, the example also demonstrates how to use tiles and bmp2gbtile to produce on-screen text.