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.

Coding > using raw and pal files

#17748 - Darmstadium - Sat Mar 13, 2004 9:51 pm

Does anybody know of a good tutorial that tells you how to use raw files when programming in C? I also need a tutorial that tells you how to use pal files when using C. Your help would be greatly appreciated.

#17751 - dagamer34 - Sun Mar 14, 2004 3:40 am

Are you using that tool that I told you about?

All you have to do is copy the raw data to VRAM and the palette data to palette memory.
_________________
Little kids and Playstation 2's don't mix. :(

#17753 - Darmstadium - Sun Mar 14, 2004 4:12 am

yeah i'm using that tool you told me about
could you give me a example of copying the raw file to VRAM and the pal file to palette mem?

#17779 - dagamer34 - Sun Mar 14, 2004 6:49 pm

Well, I can't really give you an example since I only used the tool when I was still using the HAM SDK but it should be something like this:

Just suppose you had a 16x16 size sprite called sprite:

Code:

// How to copy the palette
u16* temp = (u16*)sprite_Palette;
for (loop = 0; loop < 256; loop++)
    OBJPaletteMem [loop] = temp [loop];

// How to copy the sprite data
u16 loop;
u16* temp = (u16*)sprite_Bitmap;
for (loop = 0; loop < 16 * 16 / 2; loop++)
     OAMData [loop] = temp [loop];


There is one more thing though. When copying to sprite mem that isn't at index 0, more math has to be done. But I have decided to do it for you. Here is an example of copying data to tile index 512 with a 16x16 sprite. Just replace 512 with the tile index you want.

Code:

u16 loop;
u16* temp = (u16*)sprite_Bitmap;
for (loop = 512*16; loop < (16 * 16 / 2) + (512 * 16); loop++)
     OAMData [loop] = temp [loop-(512*16)];


It should work. I just tested it.
_________________
Little kids and Playstation 2's don't mix. :(