Using Color Palletes in psp
Using Color Palletes in psp
i'm about to start learning textures and they show how to load a text and set it as the texture i get that so far but what if i have an image like a gif or png that has a pallete how do i display that and i'm also not to familiar with palletes anyway could someone point me in the right direction because wiki doesnt seem to have much info on color palletes or i'm searching for it wrong because i'd like to know how they work
i have no idea what your are talking about i'm just learning the gu is there some sort of tuturial on this and could someone explain palletes in the first place i looked it up on wiki so i know what they are but the image also has pixels so are the image pixel data just numbers like 1,2,3,etc that are supposed to be used for the pallete and if so then how do i change colors in the image and how do i tell the gu to display this image
Paletted mode is simple - you have a color lookup table with a max of 256 entries. You use a GU command to set those entries. This color lookup table can have 16 bit or 32 bit entries, with the same values as the 16/32 bit texture pixel formats, like 8888. Once you have a lookup table with entries, the next thing is the texture itself. An eight bit palette mode uses one byte per pixel, with that byte being an index into the color lookup table. A four bit palette mode uses 4 four bits per pixel, with that nibble being an index into the color lookup table. Since you have two pixels per byte, the natural question is which nibble is which pixel? On every other system in the world, bits 7 to 4 of the byte are the first pixel (from left to right), and bits 3 to 0 are the second pixel. On the PSP, it's the opposite of that. So if you look at routines that work on PSP four bit textures, you'll see code that swaps those nibbles.
We can get more complex, as the PSP allows you to shift, mask, and offset the data used to form the index into the color table, but you should save that until you have a better grasp of paletted textures. So if you look at the eight bit code in B2, you find
sceGuClutMode sets the format of the entries, the shift, the mask, and the offset. For "normal" usage, just set the shift and offset to 0, and the mask to 255. sceGuClutLoad loads the entries of the lookup table, with the length specified as blocks of 32 bytes (because of minimum DMA sizes I imagine). That's all you need for the color lookup table. The rest is normal texture setting and drawing, but with the texture format specified as 8 bit (GU_PSM_T8). That's all there is to it.
We can get more complex, as the PSP allows you to shift, mask, and offset the data used to form the index into the color table, but you should save that until you have a better grasp of paletted textures. So if you look at the eight bit code in B2, you find
Code: Select all
sceGuStart(GU_DIRECT,list);
sceGuClutMode(GU_PSM_8888,0,0xFF,0); // 32-bit palette, shift = 0, mask = 0xFF, start = 0
sceGuClutLoad((256/(32/4)),clut256); // upload 32 blocks (each block is 32 bytes / bytesPerColorEntry)
sceGuEnable(GU_TEXTURE_2D);
sceGuTexMode(GU_PSM_T8,0,0,0);
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
sceGuTexFilter(GU_LINEAR, GU_LINEAR);