make_ci8_tex.c 1.11 KB
/*
 *  make color index lut for 256 entries, a linear ramp
 *  make color index tex, a linear ramp
 */
#include <stdio.h>
#include <stdlib.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;
  char            *qstr;
  char            flags[] = "HW_FLAGS";

  quadricate = 1;
  qstr = getenv(flags);
  *argv++;
  if (qstr != 0) {
     if (strcmp(qstr, "-D_HW_VERSION_2") == 0) quadricate = 0;
  }
 
  printf("unsigned short palette256[] = {");
  for(i = 0; i < 256; i++)
  {
    if(!(i % 8))
      printf("\n");

    if(quadricate)
      printf("0x%02xff, 0x%02xff, 0x%02xff, 0x%02xff,\n", i, i, i, i);
    else
      printf("0x%02xff, ", i);
  }
  printf("};\n");
  printf("\n");

  printf("static Gfx CI8ramp_dummy_aligner[] = { gsSPEndDisplayList() };\n");
  printf("unsigned char CI8ramp[] = {\n");
  for(j = 0; j < 256; j++)
  {
    if(!(j % 8))
      printf("\n");

    printf("0x%02x, ", j);
  }
  printf("};\n");
}