make_ci4_tex.c
2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* 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");
}