added support for BD game engine to Makefile for Android
[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 STATE_AUTO
36 #undef STATE_AUTO
37 #endif
38
39 #ifdef STATE_ASK
40 #undef STATE_ASK
41 #endif
42
43 // values for boolean data type
44 #define TRUE                    1
45 #define FALSE                   0
46
47 // values for 3-state data type (for "yes/no/auto" or "yes/no/ask")
48 #define STATE_TRUE              1
49 #define STATE_FALSE             0
50 #define STATE_AUTO              -1
51 #define STATE_ASK               -1
52
53 #ifndef MIN
54 #define MIN(a, b)               ((a) < (b) ? (a) : (b))
55 #endif
56
57 #ifndef MAX
58 #define MAX(a, b)               ((a) > (b) ? (a) : (b))
59 #endif
60
61 #ifndef ABS
62 #define ABS(a)                  ((a) < 0 ? -(a) : (a))
63 #endif
64
65 #ifndef SIGN
66 #define SIGN(a)                 ((a) < 0 ? -1 : ((a) > 0 ? 1 : 0))
67 #endif
68
69 #ifndef ODD
70 #define ODD(a)                  (((a) & 1) == 1)
71 #endif
72
73 #ifndef EVEN
74 #define EVEN(a)                 (((a) & 1) == 0)
75 #endif
76
77 #define ARRAY_SIZE(array)       (sizeof(array) / sizeof(array[0]))
78
79 #if defined(__x86_64__)
80
81 #define PTR_TO_INT(p)           ((int) (long long) (p))
82 #define PTR_TO_UINT(p)          ((unsigned int) (unsigned long long) (p))
83
84 #define INT_TO_PTR(i)           ((void *) (long long) (i))
85 #define UINT_TO_PTR(u)          ((void *) (unsigned long long) (u))
86
87 #else
88
89 #define PTR_TO_INT(p)           ((int) (long) (p))
90 #define PTR_TO_UINT(p)          ((unsigned int) (unsigned long) (p))
91
92 #define INT_TO_PTR(i)           ((void *) (long) (i))
93 #define UINT_TO_PTR(u)          ((void *) (unsigned long) (u))
94
95 #endif
96
97 #define STRUCT_OFFSET(s, m)     (offsetof(s, m))
98
99
100 struct ListNode
101 {
102   char *key;
103   void *content;
104   struct ListNode *prev;
105   struct ListNode *next;
106 };
107 typedef struct ListNode ListNode;
108
109 struct DelayCounter
110 {
111   unsigned int value;
112   unsigned int count;
113 };
114 typedef struct DelayCounter DelayCounter;
115
116 #endif // TYPES_H