From nowhere to katie

I tried various methods to get resources into a program, until I found a solution where I'm fine with.

Here are my experiences:

The 1st approach

I converted all graphics as seperate C files and included them as needed. This was a the most stupid decision ever! The build process took years to complete and it broke the code because of alignment problems.

The 2nd approach

I converted all graphics as seperate C files, then compiled and linked them. The build process got a bit faster and it fixed the alignment problems. However, I had hundreds of resources in the project and it still required too much time when I had to recompile them all.

The 3rd approach

I converted all graphics in seperate assembler files, and assembled and linked them. Furthermore, I had to add a declaration for each file to graphic.h. It was the file where I declared all graphics from the project. So I added this line:
external unsigned short obj_Palette[] __attribute__ ((aligned(2)));

But ... I need a way to find out the array size. The sizeof operator can do this if the exact array size is specified. To get the array size, I had to open the generated assembler file first, to see what the size is actually:

    .SECTION .rodata
    .ALIGN 2
    .GLOBAL obj_Palette
obj_Palette:
    .short 0x0000, 0x7fff, 0x001f ...
    @ lot of data here
    .short 0x0000, 0x0000, 0x0000 ...
    .SIZE obj_Palette, 512

Since the size in this file is specified in bytes, I have to divide it by two, because the declaration, in this case, uses halfwords. Finally I got this:

external unsigned short obj_Palette[512/2] __attribute__ ((aligned(2)));

Now it compiles pretty fast, but there are too much steps involved to get a resource into the program.

The katie approach

I convert all resources to binary files and then let katie process them. katie creates a header and an assembler file with all resouces (padded/aligned/whatever).

I have to add this assembler file once to the files to compile and don't need to touch it anymore, no matter if I add new resources or remove one. The generated c/c++ compatible header file has definitions to all the resources, plus the size of each resource in different formats.

No extra typing neccessary, katie does it for you. Plus, if you change the size of a graphic for example and convert the resources again, all changes are reflected automatically! No extra work is neccessary, like adjusting the array size!


Generated on Sat Aug 12 13:40:21 2006 for Katie by  doxygen 1.4.7