make_ci4_tex.c 2.26 KB
/*
 *  make color index lut for 16 entries, a linear ramp
 *  make color index tex, a linear ramp
 */
#include <stdio.h>
#include <stdlib.h>
#include <ultra64.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);
  if (qstr != 0) {
    if (strcmp(qstr, "-D_HW_VERSION_2") == 0) quadricate = 0;
  }
 
  for(j = 0; j < 16; j++)
  {
    printf("unsigned short palette%d[] = {\n", j );
    for(i = 0; i < 16; i++)
    {

      switch(j)
      {
        case  0: red = i*8 + 128; grn = 0; blu = 0; break;
        case  1: red = i*8 + 128; grn = 64; blu = 0; break;
        case  2: red = i*8 + 128; grn = 96; blu = 0; break;
        case  3: red = i*8 + 128; grn = 128; blu = 0; break;
        case  4: red = 0; grn = i*8 + 128; blu = 0; break;
        case  5: red = 64; grn = i*8 + 128; blu = 0; break;
        case  6: red = 96; grn = i*8 + 128; blu = 0; break;
        case  7: red = 128; grn = i*8 + 128; blu = 0; break;
        case  8: red = 0; grn = 0; blu = i*8 + 128; break;
        case  9: red = 0; grn = 64; blu = i*8 + 128; break;
        case 10: red = 0; grn = 96; blu = i*8 + 128; break;
        case 11: red = 0; grn = 192; blu = i*8 + 128; break;
        case 12: red = i*8; grn = i*8; blu = i*8; break;
        case 13: red = i*8+64; grn = i*8; blu = i*8; break;
        case 14: red = i*8+96; grn = i*8; blu = i*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, \n", 
		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, \n", 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++)
  {
    i = (2*j)<<4|(2*j + 1);
    printf("0x%02x, ", i);
  }
  printf("};\n");
}