1.1 --- a/src/pvr2/texcache.c Wed Mar 15 13:16:50 2006 +0000
1.2 +++ b/src/pvr2/texcache.c Thu Mar 16 12:42:39 2006 +0000
1.5 - * $Id: texcache.c,v 1.3 2006-03-15 13:16:50 nkeynes Exp $
1.6 + * $Id: texcache.c,v 1.4 2006-03-16 12:42:39 nkeynes Exp $
1.8 * Texture cache. Responsible for maintaining a working set of OpenGL
1.10 @@ -179,6 +179,21 @@
1.14 +static void detwiddle_pal8_to_24(int x1, int y1, int size, int totsize,
1.15 + char **in, uint32_t *out, uint32_t *pal) {
1.17 + out[y1 * totsize + x1] = pal[**in];
1.21 + detwiddle_pal8_to_24(x1, y1, ns, totsize, in, out, pal);
1.22 + detwiddle_pal8_to_24(x1, y1+ns, ns, totsize, in, out, pal);
1.23 + detwiddle_pal8_to_24(x1+ns, y1, ns, totsize, in, out, pal);
1.24 + detwiddle_pal8_to_24(x1+ns, y1+ns, ns, totsize, in, out, pal);
1.30 * Load texture data from the given address and parameters into the currently
1.31 * bound OpenGL texture.
1.32 @@ -210,24 +225,29 @@
1.35 intFormat = GL_RGBA8;
1.37 - type = GL_UNSIGNED_INT_8_8_8_8;
1.39 + type = GL_UNSIGNED_INT_8_8_8_8_REV;
1.44 if( tex_format == PVR2_TEX_FORMAT_IDX8 ) {
1.45 + unsigned char data[bytes<<shift];
1.46 int bank = (mode >> 25) &0x03;
1.47 - unsigned char data[bytes<<shift];
1.48 char *palette = mmio_region_PVR2PAL.mem + (bank * (256 << shift));
1.50 - pvr2_vram64_read( &data, texture_addr, bytes );
1.51 - for( i=bytes-1; i>=0; i-- ) {
1.52 - char ch = data[i];
1.54 - ((uint32_t *)data)[i] = ((uint32_t *)palette)[ch];
1.56 + if( shift == 2 ) {
1.59 + pvr2_vram64_read( tmp, texture_addr, bytes );
1.60 + detwiddle_pal8_to_24( 0, 0, width, width, &p,
1.61 + (uint32_t *)data, (uint32_t *)palette );
1.63 + pvr2_vram64_read( &data, texture_addr, bytes );
1.64 + for( i=bytes-1; i>=0; i-- ) {
1.65 + char ch = data[i];
1.66 ((uint16_t *)data)[i] = ((uint16_t *)palette)[ch];
1.69 /* TODO: Detwiddle */
1.70 glTexImage2D( GL_TEXTURE_2D, 0, intFormat, width, height, 0, format, type,