Source

mupen64plus-video-glide64mk2 / src / Glide64 / TexMod.h

  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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002  Dave2001
* Copyright (c) 2003-2009  Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified.  Take out your modified code sections, and tell me where to put them.  If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************

static void mod_tex_inter_color_using_factor (wxUint16 *dst, int size, wxUint32 color, wxUint32 factor)
{
	float percent = factor / 255.0f;
	float percent_i = 1 - percent;
	wxUint32 cr, cg, cb;
	wxUint16 col, a;
	wxUint8 r, g, b;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		r = (wxUint8)(percent_i * ((col >> 8) & 0xF) + percent * cr);
		g = (wxUint8)(percent_i * ((col >> 4) & 0xF) + percent * cg);
		b = (wxUint8)(percent_i * (col & 0xF) + percent * cb);
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_tex_inter_col_using_col1 (wxUint16 *dst, int size, wxUint32 color0, wxUint32 color1)
{
	wxUint32 cr, cg, cb;
	wxUint16 col, a;
	wxUint8 r, g, b;

	float percent_r = ((color1 >> 12) & 0xF) / 15.0f;
	float percent_g = ((color1 >> 8) & 0xF) / 15.0f;
	float percent_b = ((color1 >> 4) & 0xF) / 15.0f;
	float percent_r_i = 1.0f - percent_r;
	float percent_g_i = 1.0f - percent_g;
	float percent_b_i = 1.0f - percent_b;

	cr = (color0 >> 12) & 0xF;
	cg = (color0 >> 8) & 0xF;
	cb = (color0 >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		r = (wxUint8)(percent_r_i * ((col >> 8) & 0xF) + percent_r * cr);
		g = (wxUint8)(percent_g_i * ((col >> 4) & 0xF) + percent_g * cg);
		b = (wxUint8)(percent_b_i * (col & 0xF) + percent_b * cb);
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_full_color_sub_tex (wxUint16 *dst, int size, wxUint32 color)
{
	wxUint32 cr, cg, cb, ca;
	wxUint16 col;
	wxUint8 a, r, g, b;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;
	ca = color & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = (wxUint8)(ca - ((col >> 12) & 0xF));
		r = (wxUint8)(cr - ((col >> 8) & 0xF));
		g = (wxUint8)(cg - ((col >> 4) & 0xF));
		b = (wxUint8)(cb - (col & 0xF));
		*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
	}
}

static void mod_col_inter_col1_using_tex (wxUint16 *dst, int size, wxUint32 color0, wxUint32 color1)
{
	wxUint32 cr0, cg0, cb0, cr1, cg1, cb1;
	wxUint16 col;
	wxUint8 r, g, b;
	wxUint16 a;
	float percent_r, percent_g, percent_b;

	cr0 = (color0 >> 12) & 0xF;
	cg0 = (color0 >> 8) & 0xF;
	cb0 = (color0 >> 4) & 0xF;
	cr1 = (color1 >> 12) & 0xF;
	cg1 = (color1 >> 8) & 0xF;
	cb1 = (color1 >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		percent_r = ((col >> 8) & 0xF) / 15.0f;
		percent_g = ((col >> 4) & 0xF) / 15.0f;
		percent_b = (col & 0xF) / 15.0f;
		r = min(15, (wxUint8)((1.0f-percent_r) * cr0 + percent_r * cr1 + 0.0001f));
		g = min(15, (wxUint8)((1.0f-percent_g) * cg0 + percent_g * cg1 + 0.0001f));
		b = min(15, (wxUint8)((1.0f-percent_b) * cb0 + percent_b * cb1 + 0.0001f));
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_col_inter_col1_using_texa (wxUint16 *dst, int size, wxUint32 color0, wxUint32 color1)
{
	wxUint32 cr0, cg0, cb0, cr1, cg1, cb1;
	wxUint16 col;
	wxUint8 r, g, b;
	wxUint16 a;
	float percent, percent_i;

	cr0 = (color0 >> 12) & 0xF;
	cg0 = (color0 >> 8) & 0xF;
	cb0 = (color0 >> 4) & 0xF;
	cr1 = (color1 >> 12) & 0xF;
	cg1 = (color1 >> 8) & 0xF;
	cb1 = (color1 >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		percent = (a >> 12) / 15.0f;
		percent_i = 1.0f - percent;
		r = (wxUint8)(percent_i * cr0 + percent * cr1);
		g = (wxUint8)(percent_i * cg0 + percent * cg1);
		b = (wxUint8)(percent_i * cb0 + percent * cb1);
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_col_inter_col1_using_texa__mul_tex (wxUint16 *dst, int size, wxUint32 color0, wxUint32 color1)
{
	wxUint32 cr0, cg0, cb0, cr1, cg1, cb1;
	wxUint16 col;
	wxUint8 r, g, b;
	wxUint16 a;
	float percent, percent_i;

	cr0 = (color0 >> 12) & 0xF;
	cg0 = (color0 >> 8) & 0xF;
	cb0 = (color0 >> 4) & 0xF;
	cr1 = (color1 >> 12) & 0xF;
	cg1 = (color1 >> 8) & 0xF;
	cb1 = (color1 >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		percent = (a >> 12) / 15.0f;
		percent_i = 1.0f - percent;
		r = (wxUint8)(((percent_i * cr0 + percent * cr1) / 15.0f) * (((col & 0x0F00) >> 8) / 15.0f) * 15.0f);
		g = (wxUint8)(((percent_i * cg0 + percent * cg1) / 15.0f) * (((col & 0x00F0) >> 4) / 15.0f) * 15.0f);
		b = (wxUint8)(((percent_i * cb0 + percent * cb1) / 15.0f) * ((col & 0x000F) / 15.0f) * 15.0f);
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_col_inter_tex_using_tex (wxUint16 *dst, int size, wxUint32 color)
{
	wxUint32 cr, cg, cb;
	wxUint16 col;
	wxUint8 r, g, b;
	wxUint16 a;
	float percent_r, percent_g, percent_b;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		percent_r = ((col >> 8) & 0xF) / 15.0f;
		percent_g = ((col >> 4) & 0xF) / 15.0f;
		percent_b = (col & 0xF) / 15.0f;
		r = (wxUint8)((1.0f-percent_r) * cr + percent_r * ((col & 0x0F00) >> 8));
		g = (wxUint8)((1.0f-percent_g) * cg + percent_g * ((col & 0x00F0) >> 4));
		b = (wxUint8)((1.0f-percent_b) * cb + percent_b * (col & 0x000F));       
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_col_inter_tex_using_texa (wxUint16 *dst, int size, wxUint32 color)
{
	wxUint32 cr, cg, cb;
	wxUint16 col;
	wxUint8 r, g, b;
	wxUint16 a;
	float percent, percent_i;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		percent = (a >> 12) / 15.0f;
		percent_i = 1.0f - percent;
		r = (wxUint8)(percent_i * cr + percent * ((col & 0x0F00) >> 8));
		g = (wxUint8)(percent_i * cg + percent * ((col & 0x00F0) >> 4));
		b = (wxUint8)(percent_i * cb + percent * (col & 0x000F));
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_col2_inter__col_inter_col1_using_tex__using_texa (wxUint16 *dst, int size,
																  wxUint32 color0, wxUint32 color1,
																  wxUint32 color2)
{
	wxUint32 cr0, cg0, cb0, cr1, cg1, cb1, cr2, cg2, cb2;
	wxUint16 col;
	wxUint8 r, g, b;
	wxUint16 a;
	float percent_r, percent_g, percent_b, percent_a;

	cr0 = (color0 >> 12) & 0xF;
	cg0 = (color0 >> 8) & 0xF;
	cb0 = (color0 >> 4) & 0xF;
	cr1 = (color1 >> 12) & 0xF;
	cg1 = (color1 >> 8) & 0xF;
	cb1 = (color1 >> 4) & 0xF;
	cr2 = (color2 >> 12) & 0xF;
	cg2 = (color2 >> 8) & 0xF;
	cb2 = (color2 >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		percent_a = (a >> 12) / 15.0f;
		percent_r = ((col >> 8) & 0xF) / 15.0f;
		percent_g = ((col >> 4) & 0xF) / 15.0f;
		percent_b = (col & 0xF) / 15.0f;
		r = (wxUint8)(((1.0f-percent_r) * cr0 + percent_r * cr1) * percent_a + cr2 * (1.0f-percent_a));
		g = (wxUint8)(((1.0f-percent_g) * cg0 + percent_g * cg1) * percent_a + cg2 * (1.0f-percent_a));
		b = (wxUint8)(((1.0f-percent_b) * cb0 + percent_b * cb1) * percent_a + cb2 * (1.0f-percent_a));
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_tex_scale_fac_add_fac (wxUint16 *dst, int size, wxUint32 factor)
{
	float percent = factor / 255.0f;
	wxUint16 col;
	wxUint8 a;
	float base_a = (1.0f - percent) * 15.0f;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = (wxUint8)(base_a + percent * (col>>12));
		*(dst++) = (a<<12) | (col & 0x0FFF);
	}
}

static void mod_tex_sub_col_mul_fac_add_tex (wxUint16 *dst, int size, wxUint32 color, wxUint32 factor)
{
	float percent = factor / 255.0f;
	wxUint32 cr, cg, cb;
	wxUint16 col, a;
	float r, g, b;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		r = (float)((col >> 8) & 0xF);
		r = /*max(*/(r - cr) * percent/*, 0.0f)*/ + r;
		if (r > 15.0f) r = 15.0f;
		if (r < 0.0f) r = 0.0f;
		g = (float)((col >> 4) & 0xF);
		g = /*max(*/(g - cg) * percent/*, 0.0f)*/ + g;
		if (g > 15.0f) g = 15.0f;
		if (g < 0.0f) g = 0.0f;
		b = (float)(col & 0xF);
		b = /*max(*/(b - cb) * percent/*, 0.0f)*/ + b;
		if (b > 15.0f) b = 15.0f;
		if (b < 0.0f) b = 0.0f;

		*(dst++) = a | ((wxUint16)r << 8) | ((wxUint16)g << 4) | (wxUint16)b;
	}
}

static void mod_tex_scale_col_add_col (wxUint16 *dst, int size, wxUint32 color0, wxUint32 color1)
{
	wxUint32 cr0, cg0, cb0, cr1, cg1, cb1;
	wxUint16 col;
	wxUint8 r, g, b;
	wxUint16 a;
	float percent_r, percent_g, percent_b;

	cr0 = (color0 >> 12) & 0xF;
	cg0 = (color0 >> 8) & 0xF;
	cb0 = (color0 >> 4) & 0xF;
	cr1 = (color1 >> 12) & 0xF;
	cg1 = (color1 >> 8) & 0xF;
	cb1 = (color1 >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		percent_r = ((col >> 8) & 0xF) / 15.0f;
		percent_g = ((col >> 4) & 0xF) / 15.0f;
		percent_b = (col & 0xF) / 15.0f;
		r = min(15, (wxUint8)(percent_r * cr0 + cr1 + 0.0001f));
		g = min(15, (wxUint8)(percent_g * cg0 + cg1 + 0.0001f));
		b = min(15, (wxUint8)(percent_b * cb0 + cb1 + 0.0001f));
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_tex_add_col (wxUint16 *dst, int size, wxUint32 color)
{
	wxUint32 cr, cg, cb;
	wxUint16 col;
	wxUint8 a, r, g, b;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = (wxUint8)((col >> 12) & 0xF);
//		a = col & 0xF000;
		r = (wxUint8)(cr + ((col >> 8) & 0xF))&0xF;
		g = (wxUint8)(cg + ((col >> 4) & 0xF))&0xF;
		b = (wxUint8)(cb + (col & 0xF))&0xF;
		*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
	}
}

static void mod_col_mul_texa_add_tex (wxUint16 *dst, int size, wxUint32 color)
{
	wxUint32 cr, cg, cb;
	wxUint16 col;
	wxUint8 r, g, b;
	wxUint16 a;
	float factor;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		factor = (a >> 12) / 15.0f;
		r = (wxUint8)(cr*factor + ((col >> 8) & 0xF))&0xF;
		g = (wxUint8)(cg*factor + ((col >> 4) & 0xF))&0xF;
		b = (wxUint8)(cb*factor + (col & 0xF))&0xF;
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_tex_sub_col (wxUint16 *dst, int size, wxUint32 color)
{
	int cr, cg, cb;
	wxUint16 col;
	wxUint8 a, r, g, b;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = (wxUint8)(col & 0xF000);
		r = (wxUint8)max((((col >> 8) & 0xF) - cr), 0);
		g = (wxUint8)max((((col >> 4) & 0xF) - cg), 0);
		b = (wxUint8)max(((col & 0xF) - cb), 0);
		*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
	}
}

static void mod_tex_sub_col_mul_fac (wxUint16 *dst, int size, wxUint32 color, wxUint32 factor)
{
	float percent = factor / 255.0f;
	wxUint32 cr, cg, cb;
	wxUint16 col, a;
	float r, g, b;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = (wxUint8)((col >> 12) & 0xF);
		r = (float)((col >> 8) & 0xF);
		r = (r - cr) * percent;
		if (r > 15.0f) r = 15.0f;
		if (r < 0.0f) r = 0.0f;
		g = (float)((col >> 4) & 0xF);
		g = (g - cg) * percent;
		if (g > 15.0f) g = 15.0f;
		if (g < 0.0f) g = 0.0f;
		b = (float)(col & 0xF);
		b = (b - cb) * percent;
		if (b > 15.0f) b = 15.0f;
		if (b < 0.0f) b = 0.0f;

		*(dst++) = (a << 12) | ((wxUint16)r << 8) | ((wxUint16)g << 4) | (wxUint16)b;
	}
}

static void mod_col_inter_tex_using_col1 (wxUint16 *dst, int size, wxUint32 color0, wxUint32 color1)
{
	wxUint32 cr, cg, cb;
	wxUint16 col, a;
	wxUint8 r, g, b;

	float percent_r = ((color1 >> 12) & 0xF) / 15.0f;
	float percent_g = ((color1 >> 8) & 0xF) / 15.0f;
	float percent_b = ((color1 >> 4) & 0xF) / 15.0f;
	float percent_r_i = 1.0f - percent_r;
	float percent_g_i = 1.0f - percent_g;
	float percent_b_i = 1.0f - percent_b;

	cr = (color0 >> 12) & 0xF;
	cg = (color0 >> 8) & 0xF;
	cb = (color0 >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = (wxUint8)((col >> 12) & 0xF);
		r = (wxUint8)(percent_r * ((col >> 8) & 0xF) + percent_r_i * cr);
		g = (wxUint8)(percent_g * ((col >> 4) & 0xF) + percent_g_i * cg);
		b = (wxUint8)(percent_b * (col & 0xF) + percent_b_i * cb);
		*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
	}
}

static void mod_tex_inter_noise_using_col (wxUint16 *dst, int size, wxUint32 color)
{
	wxUint16 col, a;
	wxUint8 r, g, b, noise;

	float percent_r = ((color >> 12) & 0xF) / 15.0f;
	float percent_g = ((color >> 8) & 0xF) / 15.0f;
	float percent_b = ((color >> 4) & 0xF) / 15.0f;
	float percent_r_i = 1.0f - percent_r;
	float percent_g_i = 1.0f - percent_g;
	float percent_b_i = 1.0f - percent_b;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
        noise = rand()%16;
		r = (wxUint8)(percent_r_i * ((col >> 8) & 0xF) + percent_r * noise);
		g = (wxUint8)(percent_g_i * ((col >> 4) & 0xF) + percent_g * noise);
		b = (wxUint8)(percent_b_i * (col & 0xF) + percent_b * noise);
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_tex_inter_col_using_texa (wxUint16 *dst, int size, wxUint32 color)
{
	wxUint32 cr, cg, cb;
	wxUint16 col;
	wxUint8 r, g, b;
	wxUint16 a;
	float percent, percent_i;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		percent = (a >> 12) / 15.0f;
		percent_i = 1.0f - percent;
		r = (wxUint8)(percent * cr + percent_i * ((col & 0x0F00) >> 8));
		g = (wxUint8)(percent * cg + percent_i * ((col & 0x00F0) >> 4));
		b = (wxUint8)(percent * cb + percent_i * (col & 0x000F));
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_tex_mul_col (wxUint16 *dst, int size, wxUint32 color)
{
	float cr, cg, cb;
	wxUint16 col;
	wxUint8 r, g, b;
	wxUint16 a;

	cr = (float)((color >> 12) & 0xF)/16.0f;
	cg = (float)((color >> 8) & 0xF)/16.0f;
	cb = (float)((color >> 4) & 0xF)/16.0f;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		a = col & 0xF000;
		r = (wxUint8)(cr * ((col & 0x0F00) >> 8));
		g = (wxUint8)(cg * ((col & 0x00F0) >> 4));
		b = (wxUint8)(cb * (col & 0x000F));
		*(dst++) = a | (r << 8) | (g << 4) | b;
	}
}

static void mod_tex_scale_fac_add_col (wxUint16 *dst, int size, wxUint32 color, wxUint32 factor)
{
	float percent = factor / 255.0f;
	wxUint32 cr, cg, cb;
	wxUint16 col;
	float r, g, b;

	cr = (color >> 12) & 0xF;
	cg = (color >> 8) & 0xF;
	cb = (color >> 4) & 0xF;

	for (int i=0; i<size; i++)
	{
		col = *dst;
		r = cr + percent * (float)((col>>8)&0xF);
		g = cg + percent * (float)((col>>4)&0xF);
		b = cb + percent * (float)(col&0xF);
		*(dst++) = (col&0xF000) | ((wxUint8)r << 8) | ((wxUint8)g << 4) | (wxUint8)b;
	}
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.