make_ci4_tex.c 2.33 KB
/*
 *  make color index lut for 16 entries, a linear ramp
 *  make color index tex, a linear ramp
 */
#include <stdio.h>
#include "mbi.h"

#define DEF_RED		0x80
#define DEF_GRN		0x80
#define DEF_BLU		0x80
#define DEF_ALP		0xff


main(int argc, char **argv)
{
  int i, j, flag, clr, red, grn, blu;
  int		  quadricate = 0; 
  int		  c; 
  extern int      optind;
  extern char     *optarg;

  while ((c = getopt (argc, argv, "Q")) != EOF) {
      switch (c) {
			case 'Q':
                                quadricate = 1;
                                break;
			default:
				break;
      }
  }

 
  for(j = 0; j < 16; j++)
  {
    printf("unsigned short palette%d[] = {", j );
    for(i = 0; i < 16; i++)
    {
      if(!(i % 8))
        printf("\n");

      switch(j)
      {
        case  0: red = i*16 + 8; grn = 0; blu = 0; break;
        case  1: red = 0; grn = i*16 + 8; blu = 0; break;
        case  2: red = 0; grn = 0; blu = i*16 + 8; break;
        case  3: red = i*16 + 8; grn = i*16 + 8; blu = 0; break;
        case  4: red = 0; grn = i*16 + 8; blu = i*16 + 8; break;
        case  5: red = i*16 + 8; grn = 0; blu = i*16 + 8; break;
        case  6: red = i*16 + 8; grn = i*16 + 8; blu = i*16 + 8; break;
        case  7: red = i*16 + 8; grn = 128; blu = 0; break;
        case  8: red = 128; grn = i*16 + 8; blu = 0; break;
        case  9: red = 0; grn = 128; blu = i*16 + 8; break;
        case 10: red = 128; grn = 128; blu = i*16 + 8; break;
        case 11: red = 128; grn = i*16 + 8; blu = 128; break;
        case 12: red = 255; grn = i*16+8; blu = 255; break;
        case 13: red = i*16+8; grn = 255; blu = 255; break;
        case 14: red = 255; grn = 255; blu = i*16 + 8; break;
        case 15: red = i*8+128; grn = i*8; blu = i*8; break;
      }

      if(quadricate)
        printf("0x%04x, 0x%04x, 0x%04x, 0x%04x, ", 
		GPACK_RGBA5551(red, grn, blu, DEF_ALP),
		GPACK_RGBA5551(red, grn, blu, DEF_ALP),
		GPACK_RGBA5551(red, grn, blu, DEF_ALP),
		GPACK_RGBA5551(red, grn, blu, DEF_ALP));
      else 
        printf("0x%04x, ", GPACK_RGBA5551(red, grn, blu, DEF_ALP));
    }
    printf("};\n\n");
  }

  printf("static Gfx CI4ramp_dummy_aligner[] = { gsSPEndDisplayList() };\n");
  printf("unsigned char CI4ramp[] = {\n");
  for(j = 0; j < 8; j++)
  {
    if(!(j % 4))
      printf("\n");
    printf("0x%02x, ", ((j*2) << 4) | (j*2)+1);
  }
  printf("};\n");
}