added new, 3-state setup option to allow skipping levels (yes/no/ask)
[rocksndiamonds.git] / src / libgame / types.h
1 // ============================================================================
2 // Artsoft Retro-Game Library
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // types.h
10 // ============================================================================
11
12 #ifndef TYPES_H
13 #define TYPES_H
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <stdarg.h>
18 #include <string.h>
19 #include <sys/types.h>
20
21
22 #if !defined(PLATFORM_WINDOWS)
23 typedef int boolean;
24 typedef unsigned char byte;
25 #endif
26
27 #ifdef TRUE
28 #undef TRUE
29 #endif
30
31 #ifdef FALSE
32 #undef FALSE
33 #endif
34
35 #ifdef MODE_AUTO
36 #undef MODE_AUTO
37 #endif
38
39 #ifdef MODE_ASK
40 #undef MODE_ASK
41 #endif
42
43 #define TRUE                    1
44 #define FALSE                   0
45
46 #define MODE_AUTO               -1
47 #define MODE_ASK                -1
48
49 #ifndef MIN
50 #define MIN(a, b)               ((a) < (b) ? (a) : (b))
51 #endif
52
53 #ifndef MAX
54 #define MAX(a, b)               ((a) > (b) ? (a) : (b))
55 #endif
56
57 #ifndef ABS
58 #define ABS(a)                  ((a) < 0 ? -(a) : (a))
59 #endif
60
61 #ifndef SIGN
62 #define SIGN(a)                 ((a) < 0 ? -1 : ((a) > 0 ? 1 : 0))
63 #endif
64
65 #ifndef ODD
66 #define ODD(a)                  (((a) & 1) == 1)
67 #endif
68
69 #ifndef EVEN
70 #define EVEN(a)                 (((a) & 1) == 0)
71 #endif
72
73 #define ARRAY_SIZE(array)       (sizeof(array) / sizeof(array[0]))
74
75 #define PTR_TO_INT(p)           ((int) (long) (p))
76 #define PTR_TO_UINT(p)          ((unsigned int) (unsigned long) (p))
77
78 #define INT_TO_PTR(i)           ((void *) (long) (i))
79 #define UINT_TO_PTR(u)          ((void *) (unsigned long) (u))
80
81 #define STRUCT_OFFSET(s, m)     (offsetof(s, m))
82
83
84 struct ListNode
85 {
86   char *key;
87   void *content;
88   struct ListNode *prev;
89   struct ListNode *next;
90 };
91 typedef struct ListNode ListNode;
92
93 struct DelayCounter
94 {
95   unsigned int value;
96   unsigned int count;
97 };
98 typedef struct DelayCounter DelayCounter;
99
100 #endif // TYPES_H