//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code 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 3 of the License, or (at your option) any later version.

// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
// in the hope that it will be useful, but with permitted additional restrictions 
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
// distributed with this program. You should have received a copy of the 
// GNU General Public License along with permitted additional restrictions 
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection

/* $Header:   F:\projects\c&c\vcs\code\const.cpv   2.17   16 Oct 1995 16:52:24   JOE_BOSTIC  $ */
/***********************************************************************************************
 ***             C O N F I D E N T I A L  ---  W E S T W O O D   S T U D I O S               ***
 ***********************************************************************************************
 *                                                                                             *
 *                 Project Name : Command & Conquer                                            *
 *                                                                                             *
 *                    File Name : CONST.CPP                                                    *
 *                                                                                             *
 *                   Programmer : Joe L. Bostic                                                *
 *                                                                                             *
 *                   Start Date : September 20, 1993                                           *
 *                                                                                             *
 *                  Last Update : September 20, 1993   [JLB]                                   *
 *                                                                                             *
 *---------------------------------------------------------------------------------------------*
 * Functions:                                                                                  *
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#include "function.h"


char const * SourceName[SOURCE_COUNT] =
{
	"North",
	"East",
	"South",
	"West",
	"Shipping",
	"Beach",
	"Air",
	"Visible",
	"EnemyBase",
	"HomeBase",
	"Ocean",
};


/***************************************************************************
**	Relative coordinate offsets from the center of a cell for each
**	of the legal positions that an object in a cell may stop at. Only infantry
**	are allowed to stop at other than the center of the cell.
*/
COORDINATE const StoppingCoordAbs[5] = {
	0x00800080L,	// center
	0x00400040L,	// upper left
	0x004000C0L,	// upper right
	0x00C00040L,	// lower left
	0x00C000C0L		// lower right
};


/***************************************************************************
**	These are the various weapons and their characteristics.
**
**	bullet type				dmg,	rof,	range,	sound
*/
WeaponTypeClass const Weapons[WEAPON_COUNT] = {
	{BULLET_SNIPER,		125,	40,	0x0580,	VOC_SNIPER, ANIM_NONE},				//	WEAPON_RIFLE
	{BULLET_SPREADFIRE,	25,	50,	0x0400,	VOC_MINI,	ANIM_GUN_N},			//	WEAPON_CHAIN_GUN
	{BULLET_BULLET,		1,		7,		0x01C0,	VOC_RIFLE,	ANIM_NONE},				//	WEAPON_PISTOL
	{BULLET_BULLET,		15,	20,	0x0200,	VOC_MGUN2,	ANIM_NONE},				//	WEAPON_M16
	{BULLET_TOW,			30,	60,	0x0400,	VOC_BAZOOKA,ANIM_NONE},				//	WEAPON_DRAGON
	{BULLET_FLAME,			35,	50,	0x0200,	VOC_FLAMER1,ANIM_FLAME_N},			//	WEAPON_FLAMETHROWER
	{BULLET_FLAME,			50,	50,	0x0200,	VOC_FLAMER1,ANIM_FLAME_N},			//	WEAPON_FLAME_TONGUE
	{BULLET_CHEMSPRAY,	80,	70,	0x0200,	VOC_FLAMER1,ANIM_CHEM_N},			//	WEAPON_CHEMSPRAY
	{BULLET_GRENADE,		50,	60,	0x0340,	VOC_TOSS,	ANIM_NONE},				//	WEAPON_GRENADE
	{BULLET_APDS,			25,	60,	0x0400,	VOC_TANK2,	ANIM_MUZZLE_FLASH},	//	WEAPON_75MM
	{BULLET_APDS,			30,	50,	0x04C0,	VOC_TANK3,	ANIM_MUZZLE_FLASH},	//	WEAPON_105MM
	{BULLET_APDS,			40,	80,	0x04C0,	VOC_TANK4,	ANIM_MUZZLE_FLASH},	//	WEAPON_120MM
	{BULLET_APDS,			40,	60,	0x0600,	VOC_TANK4,	ANIM_MUZZLE_FLASH},	//	WEAPON_TURRET_GUN
	{BULLET_SSM,			75,	80,	0x0500,	VOC_ROCKET1,ANIM_NONE},				//	WEAPON_MAMMOTH_TUSK
	{BULLET_SSM2,			75,	80,	0x0600,	VOC_ROCKET1,ANIM_NONE},				//	WEAPON_MLRS
	{BULLET_HE,				150,	65,	0x0600,	VOC_TANK1,	ANIM_MUZZLE_FLASH},	//	WEAPON_155MM
	{BULLET_BULLET,		15,	30,	0x0400,	VOC_MGUN11,	ANIM_GUN_N},			//	WEAPON_M60MG
	{BULLET_SSM,			60,	35,	0x0780,	VOC_ROCKET2,ANIM_NONE},				//	WEAPON_TOMAHAWK
	{BULLET_SSM,			60,	40,	0x0680,	VOC_ROCKET2,ANIM_NONE},				//	WEAPON_TOW_TWO
	{BULLET_NAPALM,		100,	20,	0x0480,	VOC_NONE,	ANIM_NONE},				//	WEAPON_NAPALM
	{BULLET_LASER,			200,	90,	0x0780,	VOC_LASER,	ANIM_NONE},				//	WEAPON_OBELISK_LASER
	{BULLET_SAM,			50,	50,	0x0780,	VOC_ROCKET2,ANIM_NONE},				//	WEAPON_NIKE
	{BULLET_HONEST_JOHN,	100,	200,	0x0A00,	VOC_ROCKET1,ANIM_NONE},				//	WEAPON_HONEST_JOHN
	{BULLET_HEADBUTT,		100,	30,	0x0180,	VOC_DINOATK1,ANIM_NONE},				// WEAPON_STEG
	{BULLET_TREXBITE,		155,	30,	0x0180,	VOC_DINOATK1,ANIM_NONE},				// WEAPON_TREX
#ifdef PETROGLYPH_EXAMPLE_MOD
	{BULLET_NUKE_LOB,		150,	130,	0x0B00,	VOC_NUKE_LOB,	ANIM_MUZZLE_FLASH},	//	WEAPON_NUKE_LOB
#endif //PETROGLYPH_EXAMPLE_MOD
};


/***************************************************************************
**	These are the various warheads.
**
** spread factor, destroys walls, destroys wood, destroys Tiberium, {armor defense table}
**           -vs- {none, wood, aluminum, steel, concrete}
*/
WarheadTypeClass const Warheads[WARHEAD_COUNT] = {
	{  2,false,false,false,{0x100, 0x80, 0x90, 0x40, 0x40}},	//	WARHEAD_SA					Small arms -- good against infantry.
	{  6,true,true,true,{0xE0, 0xC0, 0x90, 0x40, 0x100}},		//	WARHEAD_HE					High explosive -- good against buildings & infantry.
	{  6,true,true,false,{0x40, 0xC0, 0xC0, 0x100, 0x80}},		//	WARHEAD_AP					Armor piercing -- good against armor.
	{  8,false,true,true,{0xE0, 0x100, 0xB0, 0x40, 0x80}},		//	WARHEAD_FIRE				Incendiary -- Good against flammables.
	{  4,false,false,false,{0x100, 0x100, 0x100, 0x100, 0x100}},//	WARHEAD_LASER				Light Amplification of Stimulated Emission by Radiation.
	{  7,true,true,true,{0x100, 0x100, 0xC0, 0xC0, 0xC0}},		//	WARHEAD_PB					Particle beam (neutron beam).
	{  4,false,false,false,{0x100, 0x20, 0x20, 0x10, 0x10}},	//	WARHEAD_FIST				Punching in hand-to-hand combat.
	{  4,false,false,false,{0x100, 0x20, 0x20, 0x10, 0x10}},	//	WARHEAD_FOOT				Kicking in hand-to-hand combat.
	{  4,false,false,false,{0x100, 0x08, 0x08, 0x08, 0x08}},	//	WARHEAD_HOLLOW_POINT		Sniper bullet type.
	{255,false,false,false,{0x100, 0x01, 0x01, 0x01, 0x01}},	//	WARHEAD_SPORE
	{  1, true,true,false,{0x100, 0xC0, 0x80, 0x20, 0x08}},		//	WARHEAD_HEADBUTT
	{  1, true,true,false,{0x100, 0xC0, 0x80, 0x20, 0x08}},		//	WARHEAD_FEEDME
};


/***************************************************************************
**	Converts pixel values (cell relative) into the appropriate lepton (sub cell)
**	value. This is used to convert pixel (screen) coordinates into the underlying
**	coordinate system.
*/
unsigned char const Pixel2Lepton[24] = {
	0x00,0x0B,0x15,0x20,0x2B,0x35,0x40,0x4B,
	0x55,0x60,0x6B,0x75,0x80,0x8B,0x95,0xA0,
	0xAB,0xB5,0xC0,0xCB,0xD5,0xE0,0xEB,0xF5
};


/***************************************************************************
**	This array is used to index a facing in order to retrieve a cell
**	offset that, when added to another cell, will achieve the adjacent cell
**	in the indexed direction.
*/
CELL const AdjacentCell[FACING_COUNT] = {
	-(MAP_CELL_W),				// North
	-(MAP_CELL_W-1),			// North East
	1,								// East
	MAP_CELL_W+1,				// South East
	MAP_CELL_W,					// South
	MAP_CELL_W-1,				// South West
	-1,							// West
	-(MAP_CELL_W+1)			// North West
};

COORDINATE const AdjacentCoord[FACING_COUNT] = {
	0xFF000000L,
	0xFF000100L,
	0x00000100L,
	0x01000100L,
	0x01000000L,
	0x0100FF00L,
	0x0000FF00L,
	0xFF00FF00L
};


/***************************************************************************
** This converts 0..255 facing values into either 8, 16, or 32 facing values.
**	Note: a simple shift won't suffice because 0..255 facing values should
**	be converted to the CLOSEST appropriate facing, NOT rounded down to the
**	nearest facing.
*/
unsigned char const Facing8[256] = {
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
	3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
	4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
	5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
	6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
	7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};

#ifdef NEVER
unsigned char const Facing16[256] = {
	0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,
	4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,
	6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,
	8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,
	10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,
	12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,
	14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,0,0,0,0,0,0
};
#endif

/*
**	This table incorporates a compensating factor for the distortion caused
**	by 3D-Studio when it tries to render 45% angles.
*/
unsigned char const Facing32[256] = {
	0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,
	3,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,
	8,8,8,9,9,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,
	13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,
	16,16,16,16,16,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,
	19,20,20,20,20,20,20,21,21,21,21,21,21,21,22,22,22,22,22,22,22,23,23,23,23,23,23,23,24,24,24,24,
	24,24,24,25,25,25,25,25,25,25,26,26,26,26,26,26,26,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,
	29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,0,0,0,0,0,0
};

#ifdef OBSOLETE
unsigned char const Facing32[256] = {
	0,0,0,0,
	1,1,1,1,1,1,1,1,
	2,2,2,2,2,2,2,2,
	3,3,3,3,3,3,3,3,
	4,4,4,4,4,4,4,4,
	5,5,5,5,5,5,5,5,
	6,6,6,6,6,6,6,6,
	7,7,7,7,7,7,7,7,
	8,8,8,8,8,8,8,8,
	9,9,9,9,9,9,9,9,
	10,10,10,10,10,10,10,10,
	11,11,11,11,11,11,11,11,
	12,12,12,12,12,12,12,12,
	13,13,13,13,13,13,13,13,
	14,14,14,14,14,14,14,14,
	15,15,15,15,15,15,15,15,
	16,16,16,16,16,16,16,16,
	17,17,17,17,17,17,17,17,
	18,18,18,18,18,18,18,18,
	19,19,19,19,19,19,19,19,
	20,20,20,20,20,20,20,20,
	21,21,21,21,21,21,21,21,
	22,22,22,22,22,22,22,22,
	23,23,23,23,23,23,23,23,
	24,24,24,24,24,24,24,24,
	25,25,25,25,25,25,25,25,
	26,26,26,26,26,26,26,26,
	27,27,27,27,27,27,27,27,
	28,28,28,28,28,28,28,28,
	29,29,29,29,29,29,29,29,
	30,30,30,30,30,30,30,30,
	31,31,31,31,31,31,31,31,
	0,0,0,0
};
#endif


/***************************************************************************
**	These are the movement costs (in ticks at fastest speed) to enter each
**	of the given terrain cells.
*/
#define	S1	0x00
#define	S2 0x40
#define	S3 0x70
#define	S4 0xA0
#define	S5 0xC0
#define	S6 0xFF
GroundType const Ground[LAND_COUNT] = {
//						Foot
//						|		Tracked
//						|		|		Harvester
//						|		|		|		Wheeled
//						|		|		|		|		Winged
//						|		|		|		|		|		Hover
//						|		|		|		|		|		|		float  build
	{66, 				{S3,	S3,	S3,	S4,	S6,	S5,	S1	}, true},	// LAND_CLEAR
	{68,				{S5,	S4,	S4,	S4,  	S6,	S5,	S1	}, true},	// LAND_ROAD
	{BLUE,			{S1,	S1,	S1,	S1,	S6,	S5,	S6	}, false},	// LAND_WATER
	{DKGREY,			{S1,	S1,	S1,	S1,	S6,	S1,	S1	}, false},	// LAND_ROCK
	{DKGREY,			{S1,	S1,	S1,	S1,	S6,	S1,	S1	}, false},	// LAND_WALL
	{143,				{S3,	S3,	S3,	S4,	S6,	S5,	S1	}, false},	// LAND_TIBERIUM
	{66,				{S3,	S3,	S3,	S4,	S6,	S5,	S1	}, false},	// LAND_BEACH
};


/***************************************************************************
**	These are the names of the theaters.
*/
TheaterDataType const Theaters[THEATER_COUNT] = {
	{"DESERT","DESERT","DES"},
	{"JUNGLE","JUNGLE","JUN"},
	{"TEMPERATE","TEMPERAT","TEM"},
	{"WINTER","WINTER","WIN"}
};


/***************************************************************************
** These are the remap tables that are used to convert the units/buildings
**	into the other color schemes.
*/
unsigned char const RemapGold[256] = {
	0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,										// 0..15
	16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,						// 16..31
	32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,						// 32..47
	48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,						// 48..63
	64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,						// 64..79
	80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,						// 80..95
	96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,		// 96..111
	112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,	// 112..127
	128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,	// 128..143
	144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,	// 144..159
	160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,	// 160..175
	176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,	// 176..191
	192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,	// 192..207
	208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,	// 208..223
	224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,	// 224..239
	240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255	// 240..255
};

unsigned char const RemapRed[256] = {
	0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,										// 0..15
	16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,						// 16..31
	32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,						// 32..47
	48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,						// 48..63
	64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,						// 64..79
	80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,						// 80..95
	96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,		// 96..111
	112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,	// 112..127
	128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,	// 128..143
	144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,	// 144..159
	160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,	// 160..175
	127,126,125,124,122,46,120,47,125,124,123,122,42,121,120,120,		// 176..191
	192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,	// 192..207
	208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,	// 208..223
	224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,	// 224..239
	240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255	// 240..255
};

unsigned char const RemapBlue[256] = {
	0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,										// 0..15
	16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,						// 16..31
	32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,						// 32..47
	48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,						// 48..63
	64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,						// 64..79
	80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,						// 80..95
	96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,		// 96..111
	112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,	// 112..127
	128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,	// 128..143
	144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,	// 144..159
	160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,	// 160..175
	2,119,118,135,136,138,112,12,118,135,136,137,138,139,114,112,		// 176..191
	192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,	// 192..207
	208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,	// 208..223
	224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,	// 224..239
	240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255	// 240..255
};

unsigned char const RemapOrange[256] = {
	0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,										// 0..15
	16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,						// 16..31
	32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,						// 32..47
	48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,						// 48..63
	64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,						// 64..79
	80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,						// 80..95
	96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,		// 96..111
	112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,	// 112..127
	128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,	// 128..143
	144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,	// 144..159
	160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,	// 160..175
	24,25,26,27,29,31,46,47,26,27,28,29,30,31,43,47,						// 176..191
	192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,	// 192..207
	208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,	// 208..223
	224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,	// 224..239
	240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255	// 240..255
};

unsigned char const RemapGreen[256] = {
	0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,										// 0..15
	16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,						// 16..31
	32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,						// 32..47
	48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,						// 48..63
	64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,						// 64..79
	80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,						// 80..95
	96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,		// 96..111
	112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,	// 112..127
	128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,	// 128..143
	144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,	// 144..159
	160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,	// 160..175
	5,165,166,167,159,142,140,199,166,167,157,3,159,143,142,141,		// 176..191
	192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,	// 192..207
	208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,	// 208..223
	224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,	// 224..239
	240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255	// 240..255
};

unsigned char const RemapLtBlue[256] = {
	0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,										// 0..15
	16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,						// 16..31
	32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,						// 32..47
	48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,						// 48..63
	64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,						// 64..79
	80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,						// 80..95
	96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,		// 96..111
	112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,	// 112..127
	128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,	// 128..143
	144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,	// 144..159
	160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,	// 160..175
	161,200,201,202,204,205,206,12,201,202,203,204,205,115,198,114,	// 176..191
	192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,	// 192..207
	208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,	// 208..223
	224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,	// 224..239
	240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255	// 240..255
};

unsigned char const RemapNone[256] = {
	0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,										// 0..15
	16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,						// 16..31
	32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,						// 32..47
	48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,						// 48..63
	64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,						// 64..79
	80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,						// 80..95
	96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,		// 96..111
	112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,	// 112..127
	128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,	// 128..143
	144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,	// 144..159
	160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,	// 160..175
	176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,	// 176..191
	192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,	// 192..207
	208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,	// 208..223
	224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,	// 224..239
	240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255	// 240..255
};