make_ci4_tex.c
2.33 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
79
80
81
82
/*
* 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");
}