patbier wrote:
Hello BlackAura, do you have more information about the 4 / 8 bit modes ? I'm still looking for using paletted textures in Dynamite Dreams. Thanks.
Sure.
You've got a single set of 1024 colour palette entries to work with. If you're using 8-bit textures, that appears as four separate colour palettes. If you're using 4-bit textures, it appears as 64 colour palettes.
You can configure the colour palettes to store colours in either 16-bit (ARGB1555, ARGB4444 or RGB565) or 32-bit (ARGB8888). You then set each palette entry with the pvr_set_pal_entry function, which is set up for ARGB8888 mode, which is far easier to set up and use than the 16-bit modes.
The paletted textures are in two formats - 4-bit (PVR_TXRFMT_PAL4BPP) and 8-bit (PVR_TXRFMT_PAL8BPP). The basic format for 4-bit is two palette indexes per byte, with the first pixel in the upper 4 bits, and the second pixel in the lower 4 bits. The 8-bit mode is just a single 8-bit palette index per byte.
The paletted textures must be twiddled. The bit flag that switches twiddled textures on and off is re-used as a colour palette index for paletted textures, so the PVR assumes the textures are twiddled. If you upload the texture data using pvr_txr_load_ex, it can take care of that for you:
Code:
pvr_txr_load_ex(source, destination, width, height, PVR_TXRLOAD_4BPP);
pvr_txr_load_ex(source, destination, width, height, PVR_TXRLOAD_8BPP);
If you just use a paletted texture by substituting PVR_TXRFMT_PAL4BPP or PVR_TXRFMT_PAL8BPP for the texture format, you'll end up always using the first 16 or 256 entries in the palette. To get at the remaining palette entries, you need to use the the PVR_TXRFMT_4BPP_PAL or PVR_TXRFMT_8BPP_PAL macros:
Code:
pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_PAL4BPP | PVR_TXRFMT_4BPP_PAL(1), width, height, texture_address, PVR_FILTER_NEAREST);
That example will use a 4bpp texture, and the pallete #1 (indexes 16 to 31) instead of #0 (indexes 0 through 15). The same apples to 8bpp, except palette #0 is indexes 0 through 255, and palette #1 is 256 through 511.
It should be possible to do something similar with Parallax as well. If not, adding a couple of extra #defines to the headers will do the trick. I've never used paletted textures with Parallax before, just with the raw PVR API (in Genesis Plus / DC). I don't think Tsunami or any of the KGL variants support paletted textures, but it shouldn't be that hard to add support.