GP32 8 Bit Palette (8bpp)


I'm not a good C programmer but here is what I done:

declare palette variable:
Code:
GP_PALETTEENTRY arda_Pal[256] = {
      0x1, 0xFFFF, 0xDF7F, 0xBEFB.... <fill your palette entries here>}

after you create gpsurface and set it,
Code:
  	GP_HPALETTE  h_pal, old_pal;
  	h_pal = GpPaletteCreate(256, arda_Pal);
  	GpPaletteSelect(h_pal);  	
  	GpPaletteRealize();
that's all..
I've extracted this code from gameparkSDK, and make it work on gcc that way. This may be totally wrong. :) I'm a lame newbie anyway :)
Hope this helps..
 
Thanks for that Arda, I didn't find that in any of the docs, and (being a bit of a cowboy/fool) I didn't check all the tutorials.

Cheers.
 
I wrote a palette wrapper function for my game flipover:

Code:
void Palette(int index, int red, int grn, int blu, int lgt)
{
        // Palette Wrapper Procedure
        //
        // For easier setup of palette.
        // index = color (0...255)
        // red = red value (0...31)
        // grn = green value (0...31)
        // blu = blue value (0...31)
        // lgt = Intensity bit (0 or 1)

        GP_PALETTEENTRY color;

        color = lgt + blu*2 + grn*64 + red*2048;
        GpPaletteEntryChange(index,1,&color,0);
}

It's quite easy to use:

Code:
Palette(1,31,0,0,1); // Sets colour 1 to bright red
Palette(2,31,31,31,1); // Sets colour 2 to bright white

Hope this is useful for you.
 
don posted on Feb 1 2004 at 01:20 PM said:
I wrote a palette wrapper function for my game flipover:

Code:
void Palette(int index, int red, int grn, int blu, int lgt)
{
        // Palette Wrapper Procedure
        //
        // For easier setup of palette.
        // index = color (0...255)
        // red = red value (0...31)
        // grn = green value (0...31)
        // blu = blue value (0...31)
        // lgt = Intensity bit (0 or 1)

        GP_PALETTEENTRY color;

        color = lgt + blu*2 + grn*64 + red*2048;
        GpPaletteEntryChange(index,1,&color,0);
}

It's quite easy to use:

Code:
Palette(1,31,0,0,1); // Sets colour 1 to bright red
Palette(2,31,31,31,1); // Sets colour 2 to bright white

Hope this is useful for you.
any idea what the Mirko SDK translation of this would be??

maybe
Code:
void Palette(int index, int red, int grn, int blu, int lgt)
{
         //...

         gp_SetPaletteColor(255, color);

         color = lgt +blu*2 +grn*64 +red&2048;

         // okay, I just realised I have no idea what to do about the
         // 'GpPaletteEntryChange()' thing... and yes, I do know that 
         // (as far as I know) I am nowhere near the right thing here...

as you can see, I'm a total noob.
of course, the function call would stay the same... unless there's something they aren't telling me... :unsure: :ph34r: :blink:
 
Last edited by a moderator:
actually, i don't need that anymore... i've had to give up on Mirko's SDK...
so then, using the official sdk, how would you actually incorporate that into changing screen color or something?
 
Back
Top