 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
ayatollah
Joined: 04 Sep 2005 Posts: 15
|
Posted: Thu Oct 20, 2005 5:31 am Post subject: Setting up a gradient Like Palette |
|
|
Hi
I am trying to setup a 32Bit Palette to use as Texture which generally works just fine using:
| Code: |
sceGuClutMode(GU_PSM_8888,0,0xff,0); // 32-bit palette
sceGuClutLoad((256/8),clut256); // upload 32*8 entries (256)
sceGuTexMode(GU_PSM_T8,0,0,0); // 8-bit image
|
now the (for me) tricky part.. I am trying to compute the Color Palette and I found varous sources on the net.. All of them deal with VGA Mode where it appears that one needs to call:
| Code: |
outp(0x3C8,col);
outp(0x3C9,R);
outp(0x3C9,G);
outp(0x3C9,B);
|
and this loop does the trick:
| Code: |
for (x=1; x<=32; x++) {
setrgb(x, 0, 0, x*2-1); /* Blue part */
setrgb(x+32, x*2-1, 0, 63);
setrgb(x+64, 63, x*2-1, 63);
setrgb(x+96, 63, 63, 63);
setrgb(x+128, 63, 63, 63);
setrgb(x+160, 63, 63, 63-(x*2-1));
setrgb(x+192, 63, 63-(x*2-1), 0);
setrgb(x+224, 63-(x*2-1), 0, 0); /* Red part */
}
|
I found in the CLUT Sample of the SDK a Routine that does set up the Plaette like
| Code: |
unsigned int* clut = (unsigned int*)(((unsigned int)clut256)|0x40000000);
for (i = 0; i < 256; ++i)
{
unsigned int j = (i + offset)&0xff;
*(clut++) = (j << 24)|(j << 16)|(j << 8)|(j);
}
|
Now if I use this, it gives me a GREYScale Palette only..
I tried to do:
| Code: |
for (i=1; i<=32; i++)
{
*clut+i = (0xff << 24) | ((i*2-1) << 16) | (0 << 8) | 0;
*clut+i+32 = (0xff << 24) | (63 << 16) | (0 << 8) | (i*2-1);
*clut+i+64 = (0xff << 24) | (63 << 16) | ((i*2-1) << 8) | 63;
*clut+i+96 = (0xff << 24) | (63 << 16) | (63 << 8) | 63;
*clut+i+128 = (0xff << 24) | (63 << 16) | (63 << 8) | 63;
*clut+i+160 = (0xff << 24) | (63-(i*2-1) << 16) | (63 << 8) | 63;
*clut+i+192 = (0xff << 24) | (0 << 16) | (63-(i*2-1) << 8) | 63;
*clut+i+224 = (0xff << 24) | (0 << 16) | (0 << 8) | 63-(i*2-1); */
}
}
|
but obviously that does not work. It gives the Error Message:
error: invalid lvalue in assignment
Anyhow.. I am really bad at pointers and not really sure how to get this done.. Is there anybody out that that can help me?? I am aware that this is a general C problem and the topic will most likely be closed but maybe somebody can shed some light ?!??!
THANK YOU SO MUCH! |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Thu Oct 20, 2005 5:44 am Post subject: |
|
|
look at the CLUT sample again. especialy this line:
| Code: | | *(clut++) = (j << 24)|(j << 16)|(j << 8)|(j); |
then look at your code, here for example:
if you still don't see it, try this ;)
_________________ infj |
|
| Back to top |
|
 |
ayatollah
Joined: 04 Sep 2005 Posts: 15
|
Posted: Thu Oct 20, 2005 7:41 am Post subject: |
|
|
| ouch... Thanx.. it works like a charm now !!!! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|