1 /* cstypes.h 2 3 Copyright (C) 1991-2001 and beyond by Bo Lindbergh 4 and the "Aleph One" developers. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 This license is contained in the file "COPYING", 17 which is included with this source code; it is available online at 18 http://www.gnu.org/licenses/gpl.html 19 20 */ 21 22 #ifndef _CSERIES_TYPES_ 23 #define _CSERIES_TYPES_ 24 25 #include <limits.h> 26 #ifdef HAVE_CONFIG_H // pick up HAVE_OPENGL 27 #include "config.h" 28 #endif 29 30 // IR note: consts in headers are slow and eat TOC space. 31 //const int NONE = -1; 32 enum { 33 NONE = -1, 34 UNONE = 65535 35 }; 36 37 // Integer types with specific bit size 38 #include <SDL_types.h> 39 #include <time.h> // for time_t 40 typedef Uint8 uint8; 41 typedef Sint8 int8; 42 typedef Uint16 uint16; 43 typedef Sint16 int16; 44 typedef Uint32 uint32; 45 typedef Sint32 int32; 46 typedef time_t TimeType; 47 48 // Minimum and maximum values for these types 49 #ifndef INT16_MAX 50 #define INT16_MAX 32767 51 #endif 52 #ifndef UINT16_MAX 53 #define UINT16_MAX 65535 54 #endif 55 #ifndef INT16_MIN 56 #define INT16_MIN (-INT16_MAX-1) 57 #endif 58 #ifndef INT32_MAX 59 #define INT32_MAX 2147483647 60 #endif 61 #ifndef INT32_MIN 62 #define INT32_MIN (-INT32_MAX-1) 63 #endif 64 65 // Fixed point (16.16) type 66 // LP: changed to _fixed to get around MSVC namespace conflict 67 typedef int32 _fixed; 68 69 #define FIXED_FRACTIONAL_BITS 16 70 #define INTEGER_TO_FIXED(i) ((_fixed)(i)<<FIXED_FRACTIONAL_BITS) 71 #define FIXED_INTEGERAL_PART(f) ((f)>>FIXED_FRACTIONAL_BITS) 72 73 #define FIXED_ONE (1L<<FIXED_FRACTIONAL_BITS) 74 #define FIXED_ONE_HALF (1L<<(FIXED_FRACTIONAL_BITS-1)) 75 76 // Binary powers 77 const int MEG = 0x100000; 78 const int KILO = 0x400L; 79 80 // Construct four-character-code 81 #define FOUR_CHARS_TO_INT(a,b,c,d) (((uint32)(a) << 24) | ((uint32)(b) << 16) | ((uint32)(c) << 8) | (uint32)(d)) 82 83 // Hmmm, this should be removed one day... 84 typedef uint8 byte; 85 86 // Make it compile on systems without OpenGL 87 #ifndef HAVE_OPENGL 88 #define GLfloat float 89 #endif 90 91 #endif 92