Legendary Explorer Core Nightly
Core library for working with Mass Effect Trilogy / Legendary Edition files
Loading...
Searching...
No Matches
Common.h
Go to the documentation of this file.
1//===============================================================================
2// Copyright (c) 2017 Pawel Kolodziejski <aquadran at users.sourceforge.net>
3// Copyright (c) 2007-2014 Advanced Micro Devices, Inc. All rights reserved.
4// Copyright (c) 2004-2006 ATI Technologies Inc.
5//===============================================================================
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files(the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions :
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23// THE SOFTWARE.
24//
26
27#ifndef COMMON_H
28#define COMMON_H
29
30#include <string>
31
32typedef unsigned int CMP_DWORD;
33typedef unsigned short CMP_WORD;
34typedef unsigned char CMP_BYTE;
35typedef char CMP_CHAR;
36typedef float CMP_FLOAT;
37
38#define BLOCK_SIZE_4X4 16
39#define BLOCK_SIZE_4X4X4 64
40
41#define RGBA8888_CHANNEL_A 3
42#define RGBA8888_CHANNEL_R 2
43#define RGBA8888_CHANNEL_G 1
44#define RGBA8888_CHANNEL_B 0
45
46#define RGBA8888_OFFSET_A (RGBA8888_CHANNEL_A * 8)
47#define RGBA8888_OFFSET_R (RGBA8888_CHANNEL_R * 8)
48#define RGBA8888_OFFSET_G (RGBA8888_CHANNEL_G * 8)
49#define RGBA8888_OFFSET_B (RGBA8888_CHANNEL_B * 8)
50
51#define BYTE_MASK 0x00ff
52
53#define BYTE_MAXVAL 255
54#define BYTE_MAX_FLOAT 255.0f
55#define CONVERT_FLOAT_TO_BYTE(f) static_cast<CMP_BYTE>(((f) * BYTE_MAX_FLOAT) + 0.5)
56#define CONVERT_BYTE_TO_FLOAT(b) (b) / BYTE_MAX_FLOAT
57
58#ifndef max
59#define max(a,b) (((a) > (b)) ? (a) : (b))
60#endif
61
62#ifndef min
63#define min(a,b) (((a) < (b)) ? (a) : (b))
64#endif
65
66#if defined(WIN32) || defined(_WIN64)
67#define CMP_API __declspec(dllexport)
68#else
69#define CMP_API
70#endif
71
72#endif // !COMMON_H
unsigned char CMP_BYTE
An 8-bit integer format.
Definition: Common.h:34
unsigned int CMP_DWORD
A 32-bit integer format.
Definition: Common.h:32
char CMP_CHAR
An 8-bit char format.
Definition: Common.h:35
float CMP_FLOAT
A 32-bit float format.
Definition: Common.h:36
unsigned short CMP_WORD
A 16-bit integer format.
Definition: Common.h:33