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.

DS development > palib sprite Palettes?

#55876 - chrissieboy - Mon Oct 03, 2005 5:53 pm

i got a problem, when i load 3 sprites and 3 palettes they all use the last loaded palette?

Code:

PA_LoadPal(PAL_SPRITE0, master_Palette);
PA_CreateSprite(0, 0,(void*)spr_Bitmap, OBJ_SIZE_32X32,1, 0, 50, 50);
PA_LoadPal(PAL_SPRITE0, master2_Palette);
PA_CreateSprite(0, 1,(void*)spri_Bitmap, OBJ_SIZE_32X32,1, 1, 100, 50);
PA_LoadPal(PAL_SPRITE0, master3_Palette);
PA_CreateSprite(0, 2,(void*)sprit_Bitmap, OBJ_SIZE_32X32,1, 2, 100, 100);


with the palette function i even can't assign a number or something to. It only has 2 variables.
Code:
PA_LoadPal(PAL_SPRITE0, master_Palette);


and in the sprite function i can give the palette number but it doesn't matters, does anyone know a solution?

greets!

#55892 - Cidrick - Mon Oct 03, 2005 9:25 pm

When you convert all your sprites with gfx2gba, convert them all at once instead of seperately. This way, all the sprites you run through it will use one single palette instead of three different ones.

Say your sprites are all called sprite01.bmp and sprite02.bmp, etc. You would use:

gfx2gba -D -fsrc -pSprites.pal -t8 sprite*.bmp

#56231 - Mollusk - Fri Oct 07, 2005 8:35 am

Other solution : PAlib has a sprite extended palette system built in.

I would recommend
1. Coming on http://mollusk.tk/ (official PAlib forum) for help :p
2. Either doing as Cidrick told you (only one palette), or using the extended palettes (16 possible palettes). There's an example for that in the latest versions of the lib...

Code:

PA_InitSpriteExtPal();

// Load 8bit palettes
PA_LoadSpriteExtPal(0,0,(void*)ds_Palette);
PA_LoadSpriteExtPal(0,1,(void*)giz_Palette);
PA_LoadSpriteExtPal(0,2,(void*)gp_Palette);
PA_LoadSpriteExtPal(0,3,(void*)psp_Palette);
   
// Create sprites
PA_CreateSprite(0,0,(void*)ds_Bitmap,OBJ_SIZE_64X64,1,0,x0,y0);
PA_CreateSprite(0,1,(void*)giz_Bitmap,OBJ_SIZE_64X64,1,1,x1,y1);
PA_CreateSprite(0,2,(void*)gp_Bitmap,OBJ_SIZE_64X64,1,2,x2,y2);
PA_CreateSprite(0,3,(void*)psp_Bitmap,OBJ_SIZE_64X64,1,3,x3,y3);


(this is part of the code from the example, shows how to load the extended palettes...)