GP32 GpLcdFade() and palette values


nutribrain

Still Fresh
Joined
Mar 26, 2003
Messages
39
Age
51
Location
Germany
Website
home.wtal.de
Hello everyone,

it's me again. After I solved my troubles with the palette generation and correct display of 8bit images with your help, again I have some questions.

First I wanted to make some sort of slideshow where the images are blended out and then a new image is blended in. For that I tried the GpLcdFade() function. With that function I am able to fade the Lcd to black but when I was trying to fade from black to normal Lcd condition the GpLcdFade() only return 0 when it faded the screen to complete white. It doesn't stop at the normal Lcd condition I get when calling GpLcdNoFade().

So I tried to change each value of the palette array as I'm working with 8bit images. As far as I understand, this palette holds the colour values of each palette entry as a hex value, e.g. '0x2109'. I've read in the starter manual from Gamepark, that the colour values for the GP32 consists of a RGB 5551. 5bit for ®ed(G)reen(B)lue and 1bit for Intensity.

My question now is in which these hex values are constructed. When take the example above you have a hex value '0x2109' which I think could mean that the 2 is the value for ®ed and 1 for (G)reen and 0 for (B)lue but what is the 9 for? Intensity? And if I take another example the hex value '0x1', what does it stands for, why it has only one digit?

It would be very kind if someone could help me with this or point me to a good internet page where this stuff is explained.

BTW, I used the 'GPConverter 1.3' application Edorul to convert my images.

Ciao Chris
 
Hi nutribrain,

I replied to your post gp32dev. To recap heres your answer:
the hex value 0x2019 has 16 bits.

0010000000011001

0010 = 2
0000 = 0
0001 = 1
1001 = 9

But as you said your value is made up of 5551 bit pattern so:

00100 = RED
00000 = GREEN
01100 = BLUE
1 = INTENSITY

so a value of 0x1 is actually 0000000000000001 which would be bright black!! I guess.
You need to do some bit shifting to build the value.
 
Thank you very much Gubber!

With your help I finally made it.

In case anyone is interested the bitshift I use for seperating the color values from the hex value looks like:

long colorShift(long tmpPalEntry){

int i;
unsigned short rgbArray[4];

// splits the color values and store it into an array
rgbArray[0] = tmpPalEntry >> 11;
rgbArray[1] = (((tmpPalEntry>>6)<<6) ^ ((tmpPalEntry>>11)<<11)) >> 6;
rgbArray[2] = (((tmpPalEntry>>1)<<1) ^ ((tmpPalEntry>>6)<<6)) >> 1;
rgbArray[3] = tmpPalEntry ^ (tmpPalEntry>>1)<<1;

// here you can manipulate every color channel individual if you want e.g. fade the color:
//
// for (i=0;i<3;i++){
// rgbArray /= 2;
// }

// construct the whole rgb value out of the array values
tmpPalEntry = rgbArray[0]<<11 | rgbArray[1]<<6 | rgbArray[2]<<1 | rgbArray[3];

return tmpPalEntry;
}

void paletteFade(){

int i,j;
long* tmpPal = (long*) 0x14a00400;

for(j=0;j<5;j++){
for(i=0;i<256;i++){
tmpPal = colorShift(tmpPal);
}
setTimeout(200);
}

setTimeout(5000);
}

I know that I have to optimize the code a bit but I just want to post this to help anyone who probably facing the same problem as I was.
 
Back
Top