1 /** @file types.h Types for liblegacy. 2 * 3 * @authors Copyright © 2012-2017 Jaakko Keränen <jaakko.keranen@iki.fi> 4 * 5 * @par License 6 * GPL: http://www.gnu.org/licenses/gpl.html 7 * 8 * <small>This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by the 10 * Free Software Foundation; either version 2 of the License, or (at your 11 * option) any later version. This program is distributed in the hope that it 12 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 14 * Public License for more details. You should have received a copy of the GNU 15 * General Public License along with this program; if not, write to the Free 16 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 17 * 02110-1301 USA</small> 18 */ 19 20 #ifndef LIBDENG_BASIC_TYPES_H 21 #define LIBDENG_BASIC_TYPES_H 22 23 // This header is ignored if read by Microsoft RC. 24 #ifndef RC_INVOKED 25 26 #include <de/liblegacy.h> 27 28 /// @addtogroup legacyData 29 /// @{ 30 31 enum { 32 VX = 0, 33 VY = 1, 34 VZ = 2 35 }; 36 37 #ifndef __cplusplus 38 # ifndef true 39 # define true 1 40 # endif 41 # ifndef false 42 # define false 0 43 # endif 44 #endif 45 46 /* 47 * Basic types. 48 */ 49 50 #if !defined(_MSC_VER) || _MSC_VER >= 1800 51 # include <stdint.h> // use C99 standard header (MSVC doesn't have C99) 52 #else 53 /* MSVC must define them ouselves. 54 ISO C9x Integer types - not all of them though, just what we need 55 If we need more the this, best of taking the header from MinGW for MSVC users */ 56 57 /* 7.18.1.1 Exact-width integer types */ 58 typedef signed char int8_t; 59 typedef unsigned char uint8_t; 60 typedef short int16_t; 61 typedef unsigned short uint16_t; 62 typedef int int32_t; 63 typedef unsigned uint32_t; 64 typedef long long int64_t; 65 typedef unsigned long long uint64_t; 66 67 /* 7.18.1.2 Minimum-width integer types */ 68 typedef signed char int_least8_t; 69 typedef unsigned char uint_least8_t; 70 typedef short int_least16_t; 71 typedef unsigned short uint_least16_t; 72 typedef int int_least32_t; 73 typedef unsigned uint_least32_t; 74 typedef long long int_least64_t; 75 typedef unsigned long long uint_least64_t; 76 77 /* 7.18.1.3 Fastest minimum-width integer types 78 * Not actually guaranteed to be fastest for all purposes 79 * Here we use the exact-width types for 8 and 16-bit ints. 80 */ 81 typedef char int_fast8_t; 82 typedef unsigned char uint_fast8_t; 83 typedef short int_fast16_t; 84 typedef unsigned short uint_fast16_t; 85 typedef int int_fast32_t; 86 typedef unsigned int uint_fast32_t; 87 typedef long long int_fast64_t; 88 typedef unsigned long long uint_fast64_t; 89 90 /* 7.18.1.5 Greatest-width integer types */ 91 typedef long long intmax_t; 92 typedef unsigned long long uintmax_t; 93 94 #endif 95 96 //#ifndef MACOSX 97 typedef unsigned int uint; 98 typedef unsigned short ushort; 99 //#endif 100 #ifdef UNIX 101 # include <sys/types.h> 102 #endif 103 104 typedef unsigned char byte; 105 typedef int32_t fixed_t; 106 typedef uint32_t angle_t; 107 typedef uint32_t ident_t; 108 109 typedef uint32_t fontid_t; 110 typedef uint32_t materialid_t; 111 typedef int patchid_t; 112 typedef int32_t spritenum_t; 113 typedef uint16_t nodeindex_t; 114 typedef uint16_t thid_t; 115 typedef double timespan_t; 116 117 /// All points in the map coordinate space should be defined using this type. 118 typedef double coord_t; 119 120 typedef int ddboolean_t; 121 #define dd_bool ddboolean_t // for convenience 122 123 // Angles. 124 #define ANGLE_45 0x20000000 125 #define ANGLE_90 0x40000000 126 #define ANGLE_180 0x80000000 127 #define ANGLE_MAX 0xffffffff 128 #define ANGLE_1 (ANGLE_45/45) 129 #define ANGLE_60 (ANGLE_180/3) 130 131 #define ANG45 0x20000000 132 #define ANG90 0x40000000 133 #define ANG180 0x80000000 134 #define ANG270 0xc0000000 135 136 #define FINEANGLES 8192 137 #define FINEMASK (FINEANGLES-1) 138 #define ANGLETOFINESHIFT 19 ///< Shifts 0x100000000 to 0x2000. 139 140 typedef enum slopetype_e { 141 ST_HORIZONTAL, 142 ST_VERTICAL, 143 ST_POSITIVE, 144 ST_NEGATIVE 145 } slopetype_t; 146 147 /// Bounding box coordinates. 148 enum { 149 BOXTOP = 0, 150 BOXBOTTOM = 1, 151 BOXLEFT = 2, 152 BOXRIGHT = 3, 153 BOXFLOOR = 4, 154 BOXCEILING = 5 155 }; 156 157 // Pointer-integer conversion (used for legacy code). 158 #ifdef __64BIT__ 159 typedef int64_t int_from_pointer_t; 160 #else 161 typedef int32_t int_from_pointer_t; 162 #endif 163 #define PTR2INT(x) ( (int_from_pointer_t) ((void *)(x)) ) 164 #define INT2PTR(type,x) ( (type *) ((int_from_pointer_t)(x)) ) 165 166 /* 167 * Limits. 168 */ 169 170 #define DDMAXCHAR ((char)0x7f) 171 #define DDMAXSHORT ((int16_t)0x7fff) 172 #define DDMAXUSHORT ((uint16_t)0xffff) 173 #define DDMAXINT ((int32_t)0x7fffffff) ///< Max positive 32-bit int 174 #define DDMAXLONG ((int32_t)0x7fffffff) 175 #define DDMAXFLOAT ((float)1E+37) 176 177 #define DDMINCHAR ((char)0x80) 178 #define DDMINSHORT ((int16_t)0x8000) 179 #define DDMININT ((int32_t)0x80000000) ///< Min negative 32-bit integer 180 #define DDMINLONG ((int32_t)0x80000000) 181 #define DDMINFLOAT ((float)-(1E+37)) 182 183 /// @} 184 185 #endif // RC_INVOKED 186 187 #endif // LIBDENG_BASIC_TYPES_H 188