Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

include/util.h

Go to the documentation of this file.
00001 // util.h
00004 
00005 #ifndef UTIL_H
00006 #define UTIL_H
00007 
00008 //{{{
00016 struct coord
00017 {
00018     uchar x;
00019     uchar y;
00020 };
00021 TYPEDEF(struct coord coord)
00022 //}}}
00023 //{{{
00025 struct scoord
00026 {
00027     short x;
00028     short y;
00029 };
00030 TYPEDEF(struct scoord scoord)
00031 //}}}
00032 //{{{
00038 struct rect
00039 {
00040     struct coord topleft; 
00041     struct coord extent;  
00042 };
00043 TYPEDEF(struct rect rect)
00044 //}}}
00045 //{{{
00051 struct direction
00052 {
00053     schar x;
00054     schar y;
00055 };
00056 TYPEDEF(struct direction direction)
00057 //}}}
00058 //{{{
00065 struct range
00066 {
00067     uchar max;
00068     uchar min;
00069 };
00070 TYPEDEF(struct range range)
00071 //}}}
00072 //{{{
00077 struct lrange
00078 {
00079     sint max;
00080     sint min;
00081 };
00082 TYPEDEF(struct lrange lrange)
00083 //}}}
00084 //{{{
00085 // Cast constructors workaround
00086 #ifdef CASTCONSTRUCT
00087 #   define COORD(a,b) ((coord){(a),(b)})
00088 #   define RECT(a,b,c,d) ((rect){{a,b},{c,d}})
00089 #   define SRANGE(a,b) ((range){(a),(b)})
00090 #   define DIRECTION(a,b) ((direction){(a),(b)})
00091 #else
00092 #   define COORD(a,b) construct_coord(a, b)
00093 #   define RECT(a,b,c,d) construct_rect(a,b,c,d)
00094 #   define SRANGE(a,b) construct_range((a),(b))
00095 #   define DIRECTION(a,b) (construct_direction((a),(b)))
00096     struct coord construct_coord(uchar x, uchar y);
00097     struct rect construct_rect(uchar x, uchar y, uchar w, uchar h);
00098     struct direction construct_direction(schar x, schar y);
00099     struct range construct_range(uchar max, uchar min);
00100 #endif
00101 //}}}
00102 
00103 #ifdef SUPPORT_COLOR
00104 //{{{
00105 struct colorinfo
00106 {
00107     uchar dark;
00108     uchar lit;
00109 };
00110 TYPEDEF(struct colorinfo colorinfo)
00111 
00112 #define COLOR_BOLD 0x10
00113 #define BLACK    0
00114 #define RED      1
00115 #define GREEN    2
00116 #define YELLOW   3
00117 #define BLUE     4
00118 #define MAGENTA  5
00119 #define CYAN     6
00120 #define WHITE    7
00121 #define LBLACK   16
00122 #define LRED     17
00123 #define LGREEN   18
00124 #define LYELLOW  19
00125 #define LBLUE    20
00126 #define LMAGENTA 21
00127 #define LCYAN    22
00128 #define LWHITE   23
00129 //}}}
00130 #else
00131 TYPEDEF(void *colorinfo)
00132 #endif
00133 
00134 #include "filelink.h"
00135 
00136     // Better to pass as high and low bytes of one arg because most calls use
00137     // constant (precalculatable) values
00138 #define RANGE(a,b) xrandom( ((a)<<8)+(b) )
00139 
00140 #define distancesquare(x1, y1, x2, y2) ( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) )
00141 
00142 #ifndef IS_CALCULATOR
00143 #   ifdef min // Some platforms provide broken versions of this
00144 #       undef min
00145 #   endif
00146     int min(int a, int b);
00147 #   ifdef max
00148 #       undef max
00149 #   endif
00150     int max(int a, int b);
00151 #endif
00152 
00153 /* Helpers are provided by effect, but what really matters is calling
00154    convention. Thus, some aliases for equivalent calling conventions: */
00155 #define call_aifunc call_usefunc
00156 #define call_chatfunc call_throwhitfunc
00157 #define call_killfunc call_throwhitfunc
00158 
00159 /* drawstring.c */
00160 struct draw_string_info
00161 {
00162     int curX;
00163     int curRow;
00164 };
00165 TYPEDEF(struct draw_string_info draw_string_info)
00166 
00167 #ifndef DATA_FILE
00168 #ifdef DEBUG_ALLOCATOR
00169 int debug_verify_mem(void);
00170 int debug_verify_block(long *block);
00171 void *debug_malloc(size_t S);
00172 void debug_free(void *ptr);
00173 void *debug_calloc(size_t N, size_t S);
00174 void *debug_realloc(void *ptr, size_t S);
00175 #else // DEBUG_ALLOCATOR
00176 #   define debug_malloc  malloc_throw
00177 #   define debug_free    free
00178 #   define debug_calloc  calloc_throw
00179 #   define debug_realloc realloc_throw
00180 #endif // DEBUG_ALLOCATOR
00181 #endif // DATA_FILE
00182 
00183 #endif //UTIL_H
00184 

Generated on Thu May 20 13:12:09 2004 for CalcRogue by doxygen 1.3.6