gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > gfx2gba - bitmap to .h

#52450 - hey_suburbia - Wed Aug 31, 2005 1:10 am

I tried the GUI version, but I just got .c files.

How can I output to an .h file...

EDIT:

More specifically I need to come up with an output like:

Quote:
const u16 titlebmp[] ={

#52474 - wintermute - Wed Aug 31, 2005 4:40 am

hey_suburbia wrote:
I tried the GUI version, but I just got .c files.

How can I output to an .h file...

EDIT:

More specifically I need to come up with an output like:

Quote:
const u16 titlebmp[] ={


No you don't. Never, ever put data in header files. You want a C file with
Code:
const u16 tilebmp[] = { ... };

and a header file with
Code:
extern const u16 tilebmp[];

I'm not sure if gfx2gba can do this but you should be able to create the header manually.

#52477 - yamaneko - Wed Aug 31, 2005 4:59 am

Why we must not put data in .h file? I do that all the time and I have no trouble.
_________________
山猫

#52492 - Quirky - Wed Aug 31, 2005 8:21 am

You will have problems if you try to use data like that across multiple C source files. Not to mention the extra compilation time when you change the C file that includes the data, but no changes are made to the data itself.

#52495 - Peter - Wed Aug 31, 2005 8:40 am

wintermute wrote:
I'm not sure if gfx2gba can do this but you should be able to create the header manually.


If he is using gfx2gba from Trinity, then he must create the header manually. I use the following method to convert and 'include' resources in my game:

I also use gfx2gba, but with -fraw option. It will create .raw files in this case. Then I made a tool which just concatenates files and pad them inside the concatenated data on a 4byte boundary. It will also output a header file which offsets to each file inside the data. The concatenated output can be .s, .c or .raw. Then just link the generated .s file and include the header which has the offsets. This makes it actually pretty easy, takes less time, you don't have extra work with creating headers and avoids errors since everything is done automatically.

The program is called "katie" and included in HEL v1.6. See "tools/win32".

Hope it helps