-
Notifications
You must be signed in to change notification settings - Fork 12
/
palinit.c
170 lines (139 loc) · 5.18 KB
/
palinit.c
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <stdlib.h>
#include "handy.h"
#include "acidwarp.h"
#include "palinit.h"
static void add_sparkles_to_palette (UCHAR *palArray, int sparkle_amount);
static void init_rgbw_palArray (UCHAR *palArray);
static void init_w_palArray (UCHAR *palArray);
static void init_w_half_palArray (UCHAR *palArray);
static void init_pastel_palArray (UCHAR *palArray);
/* Initialzes a palette array to one of the palette types */
void initPalArray (UCHAR *palArray, int pal_type)
{
switch (pal_type)
{
case RGBW_PAL:
init_rgbw_palArray (palArray);
break;
case W_PAL:
init_w_palArray (palArray);
break;
case W_HALF_PAL:
init_w_half_palArray (palArray);
break;
case PASTEL_PAL:
init_pastel_palArray (palArray);
break;
case RGBW_LIGHTNING_PAL:
init_rgbw_palArray (palArray);
add_sparkles_to_palette (palArray, 9);
break;
case W_LIGHTNING_PAL:
init_w_palArray (palArray);
add_sparkles_to_palette (palArray, 9);
break;
case W_HALF_LIGHTNING_PAL:
init_w_half_palArray (palArray);
add_sparkles_to_palette (palArray, 9);
break;
case PASTEL_LIGHTNING_PAL:
init_pastel_palArray (palArray);
add_sparkles_to_palette (palArray, 9);
break;
default:
init_w_palArray(palArray);
break;
}
}
static void add_sparkles_to_palette (UCHAR *palArray, int sparkle_amount)
{
int palRegNum;
for (palRegNum = 1; palRegNum < 256; palRegNum += 4)
{
palArray[palRegNum * 3 ] = (UCHAR)MIN(63, palArray[palRegNum * 3 ] + sparkle_amount);
palArray[palRegNum * 3 + 1] = (UCHAR)MIN(63, palArray[palRegNum * 3 + 1] + sparkle_amount);
palArray[palRegNum * 3 + 2] = (UCHAR)MIN(63, palArray[palRegNum * 3 + 2] + sparkle_amount);
}
}
static void init_rgbw_palArray (UCHAR *palArray)
{
int palRegNum;
for (palRegNum = 0; palRegNum < 32; ++palRegNum)
{
palArray[ palRegNum * 3 ] = (UCHAR)palRegNum * 2;
palArray[(palRegNum + 64) * 3 ] = (UCHAR)0;
palArray[(palRegNum + 128) * 3 ] = (UCHAR)0;
palArray[(palRegNum + 192) * 3 ] = (UCHAR)palRegNum * 2;
palArray[ palRegNum * 3 + 1] = (UCHAR)0;
palArray[(palRegNum + 64) * 3 + 1] = (UCHAR)palRegNum * 2;
palArray[(palRegNum + 128) * 3 + 1] = (UCHAR)0;
palArray[(palRegNum + 192) * 3 + 1] = (UCHAR)palRegNum * 2;
palArray[ palRegNum * 3 + 2] = (UCHAR)0;
palArray[(palRegNum + 64) * 3 + 2] = (UCHAR)0;
palArray[(palRegNum + 128) * 3 + 2] = (UCHAR)palRegNum * 2;
palArray[(palRegNum + 192) * 3 + 2] = (UCHAR)palRegNum * 2;
}
for (palRegNum = 32; palRegNum < 64; ++palRegNum)
{
palArray[ palRegNum * 3 ] = (UCHAR)(63 - palRegNum) * 2;
palArray[(palRegNum + 64) * 3 ] = (UCHAR)0;
palArray[(palRegNum + 128) * 3 ] = (UCHAR)0;
palArray[(palRegNum + 192) * 3 ] = (UCHAR)(63 - palRegNum) * 2;
palArray[ palRegNum * 3 + 1] = (UCHAR)0;
palArray[(palRegNum + 64) * 3 + 1] = (UCHAR)(63 - palRegNum) * 2;
palArray[(palRegNum + 128) * 3 + 1] = (UCHAR)0;
palArray[(palRegNum + 192) * 3 + 1] = (UCHAR)(63 - palRegNum) * 2;
palArray[ palRegNum * 3 + 2] = (UCHAR)0;
palArray[(palRegNum + 64) * 3 + 2] = (UCHAR)0;
palArray[(palRegNum + 128) * 3 + 2] = (UCHAR)(63 - palRegNum) * 2;
palArray[(palRegNum + 192) * 3 + 2] = (UCHAR)(63 - palRegNum) * 2;
}
}
static void init_w_palArray (UCHAR *palArray)
{
int palRegNum;
for (palRegNum = 0; palRegNum < 128; ++palRegNum)
{
palArray[palRegNum * 3 ] = (UCHAR)palRegNum/2;
palArray[palRegNum * 3 + 1] = (UCHAR)palRegNum/2;
palArray[palRegNum * 3 + 2] = (UCHAR)palRegNum/2;
}
for (palRegNum = 128; palRegNum < 256; ++palRegNum)
{
palArray[palRegNum * 3 ] = (UCHAR)(255 - palRegNum)/2;
palArray[palRegNum * 3 + 1] = (UCHAR)(255 - palRegNum)/2;
palArray[palRegNum * 3 + 2] = (UCHAR)(255 - palRegNum)/2;
}
}
static void init_w_half_palArray (UCHAR *palArray)
{
int palRegNum;
for (palRegNum = 0; palRegNum < 64; ++palRegNum)
{
palArray[palRegNum * 3 ] = (UCHAR)palRegNum;
palArray[palRegNum * 3 + 1] = (UCHAR)palRegNum;
palArray[palRegNum * 3 + 2] = (UCHAR)palRegNum;
palArray[(palRegNum + 64) * 3 ] = (UCHAR)(63 - palRegNum);
palArray[(palRegNum + 64) * 3 + 1] = (UCHAR)(63 - palRegNum);
palArray[(palRegNum + 64) * 3 + 2] = (UCHAR)(63 - palRegNum);
}
for (palRegNum = 128; palRegNum < 256; ++palRegNum)
{
palArray[palRegNum * 3 ] = 0;
palArray[palRegNum * 3 + 1] = 0;
palArray[palRegNum * 3 + 2] = 0;
}
}
static void init_pastel_palArray (UCHAR *palArray)
{
int palRegNum;
for (palRegNum = 0; palRegNum < 128; ++palRegNum)
{
palArray[ palRegNum * 3 ] = (UCHAR)31 + palRegNum/4;
palArray[ palRegNum * 3 + 1] = (UCHAR)31 + palRegNum/4;
palArray[ palRegNum * 3 + 2] = (UCHAR)31 + palRegNum/4;
palArray[(palRegNum + 128) * 3 ] = (UCHAR)31 + (127 - palRegNum)/4;
palArray[(palRegNum + 128) * 3 + 1] = (UCHAR)31 + (127 - palRegNum)/4;
palArray[(palRegNum + 128) * 3 + 2] = (UCHAR)31 + (127 - palRegNum)/4;
}
}