dcf4f1df9e9fc2c3bbeaf888fccef8ef5b9be958
[rocksndiamonds.git] / src / main.h
1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back!               *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 Artsoft Entertainment                      *
5 *               Holger Schemel                             *
6 *               Detmolder Strasse 189                      *
7 *               33604 Bielefeld                            *
8 *               Germany                                    *
9 *               e-mail: info@artsoft.org                   *
10 *----------------------------------------------------------*
11 * main.h                                                   *
12 ***********************************************************/
13
14 #ifndef MAIN_H
15 #define MAIN_H
16
17 #include <time.h>
18 #include <sys/time.h>
19 #include <sys/types.h>
20 #include <sys/stat.h>
21 #include <errno.h>
22 #include <unistd.h>
23 #include <fcntl.h>
24
25 #include "libgame/libgame.h"
26 #include "game_em/game_em.h"
27
28 #include "conf_gfx.h"   /* include auto-generated data structure definitions */
29 #include "conf_snd.h"   /* include auto-generated data structure definitions */
30 #include "conf_mus.h"   /* include auto-generated data structure definitions */
31
32 #define IMG_UNDEFINED           (-1)
33 #define IMG_EMPTY               IMG_EMPTY_SPACE
34 #define IMG_SP_EMPTY            IMG_SP_EMPTY_SPACE
35 #define IMG_EXPLOSION           IMG_DEFAULT_EXPLODING
36 #define IMG_CHAR_START          IMG_CHAR_SPACE
37 #define IMG_CUSTOM_START        IMG_CUSTOM_1
38
39 #define SND_UNDEFINED           (-1)
40 #define MUS_UNDEFINED           (-1)
41
42 #define WIN_XSIZE               672
43 #define WIN_YSIZE               560
44
45 #define SCR_FIELDX              17
46 #define SCR_FIELDY              17
47 #define MAX_BUF_XSIZE           (SCR_FIELDX + 2)
48 #define MAX_BUF_YSIZE           (SCR_FIELDY + 2)
49 #define MIN_LEV_FIELDX          3
50 #define MIN_LEV_FIELDY          3
51 #define STD_LEV_FIELDX          64
52 #define STD_LEV_FIELDY          32
53 #define MAX_LEV_FIELDX          128
54 #define MAX_LEV_FIELDY          128
55
56 #define SCREENX(a)              ((a) - scroll_x)
57 #define SCREENY(a)              ((a) - scroll_y)
58 #define LEVELX(a)               ((a) + scroll_x)
59 #define LEVELY(a)               ((a) + scroll_y)
60 #define IN_VIS_FIELD(x,y) ((x)>=0 && (x)<SCR_FIELDX && (y)>=0 &&(y)<SCR_FIELDY)
61 #define IN_SCR_FIELD(x,y) ((x)>=BX1 && (x)<=BX2 && (y)>=BY1 &&(y)<=BY2)
62 #define IN_LEV_FIELD(x,y) ((x)>=0 && (x)<lev_fieldx && (y)>=0 &&(y)<lev_fieldy)
63
64 /* values for configurable properties (custom elem's only, else pre-defined) */
65 #define EP_DIGGABLE             0
66 #define EP_COLLECTIBLE_ONLY     1
67 #define EP_DONT_RUN_INTO        2
68 #define EP_DONT_COLLIDE_WITH    3
69 #define EP_DONT_TOUCH           4
70 #define EP_INDESTRUCTIBLE       5
71 #define EP_SLIPPERY             6
72 #define EP_CAN_CHANGE           7
73 #define EP_CAN_MOVE             8
74 #define EP_CAN_FALL             9
75 #define EP_CAN_SMASH_PLAYER     10
76 #define EP_CAN_SMASH_ENEMIES    11
77 #define EP_CAN_SMASH_EVERYTHING 12
78 #define EP_EXPLODES_BY_FIRE     13
79 #define EP_EXPLODES_SMASHED     14
80 #define EP_EXPLODES_IMPACT      15
81 #define EP_WALKABLE_OVER        16
82 #define EP_WALKABLE_INSIDE      17
83 #define EP_WALKABLE_UNDER       18
84 #define EP_PASSABLE_OVER        19
85 #define EP_PASSABLE_INSIDE      20
86 #define EP_PASSABLE_UNDER       21
87 #define EP_DROPPABLE            22
88 #define EP_EXPLODES_1X1_OLD     23
89 #define EP_PUSHABLE             24
90 #define EP_EXPLODES_CROSS_OLD   25
91 #define EP_PROTECTED            26
92 #define EP_CAN_MOVE_INTO_ACID   27
93 #define EP_THROWABLE            28
94 #define EP_CAN_EXPLODE          29
95 #define EP_GRAVITY_REACHABLE    30
96
97 /* values for pre-defined properties */
98 #define EP_PLAYER               32
99 #define EP_CAN_PASS_MAGIC_WALL  33
100 #define EP_SWITCHABLE           34
101 #define EP_BD_ELEMENT           35
102 #define EP_SP_ELEMENT           36
103 #define EP_SB_ELEMENT           37
104 #define EP_GEM                  38
105 #define EP_FOOD_DARK_YAMYAM     39
106 #define EP_FOOD_PENGUIN         40
107 #define EP_FOOD_PIG             41
108 #define EP_HISTORIC_WALL        42
109 #define EP_HISTORIC_SOLID       43
110 #define EP_CLASSIC_ENEMY        44
111 #define EP_BELT                 45
112 #define EP_BELT_ACTIVE          46
113 #define EP_BELT_SWITCH          47
114 #define EP_TUBE                 48
115 #define EP_KEYGATE              49
116 #define EP_AMOEBOID             50
117 #define EP_AMOEBALIVE           51
118 #define EP_HAS_CONTENT          52
119 #define EP_CAN_TURN_EACH_MOVE   53
120 #define EP_CAN_GROW             54
121 #define EP_ACTIVE_BOMB          55
122 #define EP_INACTIVE             56
123
124 /* values for special configurable properties (depending on level settings) */
125 #define EP_EM_SLIPPERY_WALL     57
126
127 /* values for special graphics properties (no effect on game engine) */
128 #define EP_GFX_CRUMBLED         58
129
130 /* values for derived properties (determined from properties above) */
131 #define EP_ACCESSIBLE_OVER      59
132 #define EP_ACCESSIBLE_INSIDE    60
133 #define EP_ACCESSIBLE_UNDER     61
134 #define EP_WALKABLE             62
135 #define EP_PASSABLE             63
136 #define EP_ACCESSIBLE           64
137 #define EP_COLLECTIBLE          65
138 #define EP_SNAPPABLE            66
139 #define EP_WALL                 67
140 #define EP_SOLID_FOR_PUSHING    68
141 #define EP_DRAGONFIRE_PROOF     69
142 #define EP_EXPLOSION_PROOF      70
143 #define EP_CAN_SMASH            71
144 #define EP_EXPLODES_3X3_OLD     72
145 #define EP_CAN_EXPLODE_BY_FIRE  73
146 #define EP_CAN_EXPLODE_SMASHED  74
147 #define EP_CAN_EXPLODE_IMPACT   75
148 #define EP_SP_PORT              76
149 #define EP_CAN_EXPLODE_BY_DRAGONFIRE    77
150 #define EP_CAN_EXPLODE_BY_EXPLOSION     78
151 #define EP_COULD_MOVE_INTO_ACID         79
152 #define EP_MAYBE_DONT_COLLIDE_WITH      80
153
154 /* values for internal purpose only (level editor) */
155 #define EP_WALK_TO_OBJECT       81
156 #define EP_DEADLY               82
157
158 #define NUM_ELEMENT_PROPERTIES  83
159
160 #define NUM_EP_BITFIELDS        ((NUM_ELEMENT_PROPERTIES + 31) / 32)
161 #define EP_BITFIELD_BASE        0
162
163 #define EP_BITMASK_DEFAULT      0
164
165 #define PROPERTY_BIT(p)         (1 << ((p) % 32))
166 #define PROPERTY_VAR(e,p)       (Properties[e][(p) / 32])
167 #define HAS_PROPERTY(e,p)       ((PROPERTY_VAR(e, p) & PROPERTY_BIT(p)) != 0)
168 #define SET_PROPERTY(e,p,v)     ((v) ?                                     \
169                                  (PROPERTY_VAR(e,p) |=  PROPERTY_BIT(p)) : \
170                                  (PROPERTY_VAR(e,p) &= ~PROPERTY_BIT(p)))
171
172
173 /* values for change events for custom elements (stored in level file) */
174 #define CE_DELAY                0
175 #define CE_TOUCHED_BY_PLAYER    1
176 #define CE_PRESSED_BY_PLAYER    2
177 #define CE_PUSHED_BY_PLAYER     3
178 #define CE_DROPPED_BY_PLAYER    4
179 #define CE_HITTING_SOMETHING    5
180 #define CE_IMPACT               6
181 #define CE_SMASHED              7
182 #define CE_OTHER_IS_TOUCHING    8
183 #define CE_OTHER_IS_CHANGING    9
184 #define CE_OTHER_IS_EXPLODING   10
185 #define CE_OTHER_GETS_TOUCHED   11
186 #define CE_OTHER_GETS_PRESSED   12
187 #define CE_OTHER_GETS_PUSHED    13
188 #define CE_OTHER_GETS_COLLECTED 14
189 #define CE_OTHER_GETS_DROPPED   15
190 #define CE_BY_PLAYER_OBSOLETE   16      /* obsolete; now CE_BY_DIRECT_ACTION */
191 #define CE_BY_COLLISION_OBSOLETE 17     /* obsolete; now CE_BY_DIRECT_ACTION */
192 #define CE_BY_OTHER_ACTION      18      /* activates other element events */
193 #define CE_BY_DIRECT_ACTION     19      /* activates direct element events */
194 #define CE_OTHER_GETS_DIGGED    20
195 #define CE_ENTERED_BY_PLAYER    21
196 #define CE_LEFT_BY_PLAYER       22
197 #define CE_OTHER_GETS_ENTERED   23
198 #define CE_OTHER_GETS_LEFT      24
199 #define CE_SWITCHED             25
200 #define CE_OTHER_IS_SWITCHING   26
201 #define CE_HIT_BY_SOMETHING     27
202 #define CE_OTHER_IS_HITTING     28
203 #define CE_OTHER_GETS_HIT       29
204 #define CE_BLOCKED              30
205
206 #define NUM_CHANGE_EVENTS       31
207
208 #define CE_BITMASK_DEFAULT      0
209
210 #define CH_EVENT_BIT(c)         (1 << (c))
211 #define CH_EVENT_VAR(e)         (element_info[e].change->events)
212 #define CH_ANY_EVENT_VAR(e)     (element_info[e].change_events)
213
214 #define HAS_CHANGE_EVENT(e,c)   (IS_CUSTOM_ELEMENT(e) &&                  \
215                                  (CH_EVENT_VAR(e) & CH_EVENT_BIT(c)) != 0)
216 #define HAS_ANY_CHANGE_EVENT(e,c) (IS_CUSTOM_ELEMENT(e) &&                \
217                                  (CH_ANY_EVENT_VAR(e) & CH_EVENT_BIT(c)) != 0)
218 #define SET_CHANGE_EVENT(e,c,v) (IS_CUSTOM_ELEMENT(e) ?                   \
219                                  ((v) ?                                   \
220                                   (CH_EVENT_VAR(e) |=  CH_EVENT_BIT(c)) : \
221                                   (CH_EVENT_VAR(e) &= ~CH_EVENT_BIT(c))) : 0)
222
223 /* values for change side for custom elements */
224 #define CH_SIDE_NONE            MV_NO_MOVING
225 #define CH_SIDE_LEFT            MV_LEFT
226 #define CH_SIDE_RIGHT           MV_RIGHT
227 #define CH_SIDE_TOP             MV_UP
228 #define CH_SIDE_BOTTOM          MV_DOWN
229 #define CH_SIDE_LEFT_RIGHT      MV_HORIZONTAL
230 #define CH_SIDE_TOP_BOTTOM      MV_VERTICAL
231 #define CH_SIDE_ANY             MV_ANY_DIRECTION
232
233 /* values for change player for custom elements */
234 #define CH_PLAYER_NONE          0
235 #define CH_PLAYER_1             (1 << 0)
236 #define CH_PLAYER_2             (1 << 1)
237 #define CH_PLAYER_3             (1 << 2)
238 #define CH_PLAYER_4             (1 << 3)
239 #define CH_PLAYER_ANY           (CH_PLAYER_1 | CH_PLAYER_2 | CH_PLAYER_3 | \
240                                  CH_PLAYER_4)
241
242 /* values for change page for custom elements */
243 #define CH_PAGE_ANY_FILE        (0xff)
244 #define CH_PAGE_ANY             (0xffffffff)
245
246 /* values for change power for custom elements */
247 #define CP_WHEN_EMPTY           0
248 #define CP_WHEN_DIGGABLE        1
249 #define CP_WHEN_DESTRUCTIBLE    2
250 #define CP_WHEN_COLLECTIBLE     3
251 #define CP_WHEN_REMOVABLE       4
252 #define CP_WHEN_WALKABLE        5
253
254 /* values for custom move patterns (bits 0 - 3: basic move directions) */
255 #define MV_BIT_TOWARDS_PLAYER   4
256 #define MV_BIT_AWAY_FROM_PLAYER 5
257 #define MV_BIT_ALONG_LEFT_SIDE  6
258 #define MV_BIT_ALONG_RIGHT_SIDE 7
259 #define MV_BIT_TURNING_LEFT     8
260 #define MV_BIT_TURNING_RIGHT    9
261 #define MV_BIT_WHEN_PUSHED      10
262 #define MV_BIT_MAZE_RUNNER      11
263 #define MV_BIT_MAZE_HUNTER      12
264 #define MV_BIT_WHEN_DROPPED     13
265 #define MV_BIT_TURNING_LEFT_RIGHT 14
266 #define MV_BIT_TURNING_RIGHT_LEFT 15
267 #define MV_BIT_TURNING_RANDOM   16
268
269 /* values for custom move patterns */
270 #define MV_HORIZONTAL           (MV_LEFT | MV_RIGHT)
271 #define MV_VERTICAL             (MV_UP   | MV_DOWN)
272 #define MV_ALL_DIRECTIONS       (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
273 #define MV_ANY_DIRECTION        (MV_ALL_DIRECTIONS)
274 #define MV_TOWARDS_PLAYER       (1 << MV_BIT_TOWARDS_PLAYER)
275 #define MV_AWAY_FROM_PLAYER     (1 << MV_BIT_AWAY_FROM_PLAYER)
276 #define MV_ALONG_LEFT_SIDE      (1 << MV_BIT_ALONG_LEFT_SIDE)
277 #define MV_ALONG_RIGHT_SIDE     (1 << MV_BIT_ALONG_RIGHT_SIDE)
278 #define MV_TURNING_LEFT         (1 << MV_BIT_TURNING_LEFT)
279 #define MV_TURNING_RIGHT        (1 << MV_BIT_TURNING_RIGHT)
280 #define MV_WHEN_PUSHED          (1 << MV_BIT_WHEN_PUSHED)
281 #define MV_MAZE_RUNNER          (1 << MV_BIT_MAZE_RUNNER)
282 #define MV_MAZE_HUNTER          (1 << MV_BIT_MAZE_HUNTER)
283 #define MV_MAZE_RUNNER_STYLE    (MV_MAZE_RUNNER | MV_MAZE_HUNTER)
284 #define MV_WHEN_DROPPED         (1 << MV_BIT_WHEN_DROPPED)
285 #define MV_TURNING_LEFT_RIGHT   (1 << MV_BIT_TURNING_LEFT_RIGHT)
286 #define MV_TURNING_RIGHT_LEFT   (1 << MV_BIT_TURNING_RIGHT_LEFT)
287 #define MV_TURNING_RANDOM       (1 << MV_BIT_TURNING_RANDOM)
288
289 /* values for initial move direction (bits 0 - 3: basic move directions) */
290 #define MV_START_BIT_PREVIOUS   4
291
292 /* values for initial move direction */
293 #define MV_START_AUTOMATIC      (MV_NO_MOVING)
294 #define MV_START_LEFT           (MV_LEFT)
295 #define MV_START_RIGHT          (MV_RIGHT)
296 #define MV_START_UP             (MV_UP)
297 #define MV_START_DOWN           (MV_DOWN)
298 #define MV_START_RANDOM         (MV_ALL_DIRECTIONS)
299 #define MV_START_PREVIOUS       (1 << MV_START_BIT_PREVIOUS)
300
301 /* values for elements left behind by custom elements */
302 #define LEAVE_TYPE_UNLIMITED    0
303 #define LEAVE_TYPE_LIMITED      1
304
305 /* values for slippery property for custom elements */
306 #define SLIPPERY_ANY_RANDOM     0
307 #define SLIPPERY_ANY_LEFT_RIGHT 1
308 #define SLIPPERY_ANY_RIGHT_LEFT 2
309 #define SLIPPERY_ONLY_LEFT      3
310 #define SLIPPERY_ONLY_RIGHT     4
311
312 /* values for explosion type for custom elements */
313 #define EXPLODES_3X3            0
314 #define EXPLODES_1X1            1
315 #define EXPLODES_CROSS          2
316
317 /* macros for configurable properties */
318 #define IS_DIGGABLE(e)          HAS_PROPERTY(e, EP_DIGGABLE)
319 #define IS_COLLECTIBLE_ONLY(e)  HAS_PROPERTY(e, EP_COLLECTIBLE_ONLY)
320 #define DONT_RUN_INTO(e)        HAS_PROPERTY(e, EP_DONT_RUN_INTO)
321 #define DONT_COLLIDE_WITH(e)    HAS_PROPERTY(e, EP_DONT_COLLIDE_WITH)
322 #define DONT_TOUCH(e)           HAS_PROPERTY(e, EP_DONT_TOUCH)
323 #define IS_INDESTRUCTIBLE(e)    HAS_PROPERTY(e, EP_INDESTRUCTIBLE)
324 #define IS_SLIPPERY(e)          HAS_PROPERTY(e, EP_SLIPPERY)
325 #define CAN_CHANGE(e)           HAS_PROPERTY(e, EP_CAN_CHANGE)
326 #define CAN_MOVE(e)             HAS_PROPERTY(e, EP_CAN_MOVE)
327 #define CAN_FALL(e)             HAS_PROPERTY(e, EP_CAN_FALL)
328 #define CAN_SMASH_PLAYER(e)     HAS_PROPERTY(e, EP_CAN_SMASH_PLAYER)
329 #define CAN_SMASH_ENEMIES(e)    HAS_PROPERTY(e, EP_CAN_SMASH_ENEMIES)
330 #define CAN_SMASH_EVERYTHING(e) HAS_PROPERTY(e, EP_CAN_SMASH_EVERYTHING)
331 #define EXPLODES_BY_FIRE(e)     HAS_PROPERTY(e, EP_EXPLODES_BY_FIRE)
332 #define EXPLODES_SMASHED(e)     HAS_PROPERTY(e, EP_EXPLODES_SMASHED)
333 #define EXPLODES_IMPACT(e)      HAS_PROPERTY(e, EP_EXPLODES_IMPACT)
334 #define IS_WALKABLE_OVER(e)     HAS_PROPERTY(e, EP_WALKABLE_OVER)
335 #define IS_WALKABLE_INSIDE(e)   HAS_PROPERTY(e, EP_WALKABLE_INSIDE)
336 #define IS_WALKABLE_UNDER(e)    HAS_PROPERTY(e, EP_WALKABLE_UNDER)
337 #define IS_PASSABLE_OVER(e)     HAS_PROPERTY(e, EP_PASSABLE_OVER)
338 #define IS_PASSABLE_INSIDE(e)   HAS_PROPERTY(e, EP_PASSABLE_INSIDE)
339 #define IS_PASSABLE_UNDER(e)    HAS_PROPERTY(e, EP_PASSABLE_UNDER)
340 #define IS_DROPPABLE(e)         HAS_PROPERTY(e, EP_DROPPABLE)
341 #define EXPLODES_1X1_OLD(e)     HAS_PROPERTY(e, EP_EXPLODES_1X1_OLD)
342 #define IS_PUSHABLE(e)          HAS_PROPERTY(e, EP_PUSHABLE)
343 #define EXPLODES_CROSS_OLD(e)   HAS_PROPERTY(e, EP_EXPLODES_CROSS_OLD)
344 #define IS_PROTECTED(e)         HAS_PROPERTY(e, EP_PROTECTED)
345 #define CAN_MOVE_INTO_ACID(e)   HAS_PROPERTY(e, EP_CAN_MOVE_INTO_ACID)
346 #define IS_THROWABLE(e)         HAS_PROPERTY(e, EP_THROWABLE)
347 #define CAN_EXPLODE(e)          HAS_PROPERTY(e, EP_CAN_EXPLODE)
348 #define IS_GRAVITY_REACHABLE(e) HAS_PROPERTY(e, EP_GRAVITY_REACHABLE)
349
350 /* macros for special configurable properties */
351 #define IS_EM_SLIPPERY_WALL(e)  HAS_PROPERTY(e, EP_EM_SLIPPERY_WALL)
352
353 /* macros for special graphics properties */
354 #define GFX_CRUMBLED(e)         HAS_PROPERTY(GFX_ELEMENT(e), EP_GFX_CRUMBLED)
355
356 /* macros for pre-defined properties */
357 #define ELEM_IS_PLAYER(e)       HAS_PROPERTY(e, EP_PLAYER)
358 #define CAN_PASS_MAGIC_WALL(e)  HAS_PROPERTY(e, EP_CAN_PASS_MAGIC_WALL)
359 #define IS_SWITCHABLE(e)        HAS_PROPERTY(e, EP_SWITCHABLE)
360 #define IS_BD_ELEMENT(e)        HAS_PROPERTY(e, EP_BD_ELEMENT)
361 #define IS_SP_ELEMENT(e)        HAS_PROPERTY(e, EP_SP_ELEMENT)
362 #define IS_SB_ELEMENT(e)        HAS_PROPERTY(e, EP_SB_ELEMENT)
363 #define IS_GEM(e)               HAS_PROPERTY(e, EP_GEM)
364 #define IS_FOOD_DARK_YAMYAM(e)  HAS_PROPERTY(e, EP_FOOD_DARK_YAMYAM)
365 #define IS_FOOD_PENGUIN(e)      HAS_PROPERTY(e, EP_FOOD_PENGUIN)
366 #define IS_FOOD_PIG(e)          HAS_PROPERTY(e, EP_FOOD_PIG)
367 #define IS_HISTORIC_WALL(e)     HAS_PROPERTY(e, EP_HISTORIC_WALL)
368 #define IS_HISTORIC_SOLID(e)    HAS_PROPERTY(e, EP_HISTORIC_SOLID)
369 #define IS_CLASSIC_ENEMY(e)     HAS_PROPERTY(e, EP_CLASSIC_ENEMY)
370 #define IS_BELT(e)              HAS_PROPERTY(e, EP_BELT)
371 #define IS_BELT_ACTIVE(e)       HAS_PROPERTY(e, EP_BELT_ACTIVE)
372 #define IS_BELT_SWITCH(e)       HAS_PROPERTY(e, EP_BELT_SWITCH)
373 #define IS_TUBE(e)              HAS_PROPERTY(e, EP_TUBE)
374 #define IS_KEYGATE(e)           HAS_PROPERTY(e, EP_KEYGATE)
375 #define IS_AMOEBOID(e)          HAS_PROPERTY(e, EP_AMOEBOID)
376 #define IS_AMOEBALIVE(e)        HAS_PROPERTY(e, EP_AMOEBALIVE)
377 #define HAS_CONTENT(e)          HAS_PROPERTY(e, EP_HAS_CONTENT)
378 #define CAN_TURN_EACH_MOVE(e)   HAS_PROPERTY(e, EP_CAN_TURN_EACH_MOVE)
379 #define CAN_GROW(e)             HAS_PROPERTY(e, EP_CAN_GROW)
380 #define IS_ACTIVE_BOMB(e)       HAS_PROPERTY(e, EP_ACTIVE_BOMB)
381 #define IS_INACTIVE(e)          HAS_PROPERTY(e, EP_INACTIVE)
382
383 /* macros for derived properties */
384 #define IS_ACCESSIBLE_OVER(e)   HAS_PROPERTY(e, EP_ACCESSIBLE_OVER)
385 #define IS_ACCESSIBLE_INSIDE(e) HAS_PROPERTY(e, EP_ACCESSIBLE_INSIDE)
386 #define IS_ACCESSIBLE_UNDER(e)  HAS_PROPERTY(e, EP_ACCESSIBLE_UNDER)
387 #define IS_WALKABLE(e)          HAS_PROPERTY(e, EP_WALKABLE)
388 #define IS_PASSABLE(e)          HAS_PROPERTY(e, EP_PASSABLE)
389 #define IS_ACCESSIBLE(e)        HAS_PROPERTY(e, EP_ACCESSIBLE)
390 #define IS_COLLECTIBLE(e)       HAS_PROPERTY(e, EP_COLLECTIBLE)
391 #define IS_SNAPPABLE(e)         HAS_PROPERTY(e, EP_SNAPPABLE)
392 #define IS_WALL(e)              HAS_PROPERTY(e, EP_WALL)
393 #define IS_SOLID_FOR_PUSHING(e) HAS_PROPERTY(e, EP_SOLID_FOR_PUSHING)
394 #define IS_DRAGONFIRE_PROOF(e)  HAS_PROPERTY(e, EP_DRAGONFIRE_PROOF)
395 #define IS_EXPLOSION_PROOF(e)   HAS_PROPERTY(e, EP_EXPLOSION_PROOF)
396 #define CAN_SMASH(e)            HAS_PROPERTY(e, EP_CAN_SMASH)
397 #define EXPLODES_3X3_OLD(e)     HAS_PROPERTY(e, EP_EXPLODES_3X3_OLD)
398 #define CAN_EXPLODE_BY_FIRE(e)  HAS_PROPERTY(e, EP_CAN_EXPLODE_BY_FIRE)
399 #define CAN_EXPLODE_SMASHED(e)  HAS_PROPERTY(e, EP_CAN_EXPLODE_SMASHED)
400 #define CAN_EXPLODE_IMPACT(e)   HAS_PROPERTY(e, EP_CAN_EXPLODE_IMPACT)
401 #define IS_SP_PORT(e)           HAS_PROPERTY(e, EP_SP_PORT)
402 #define CAN_EXPLODE_BY_DRAGONFIRE(e)    \
403                                 HAS_PROPERTY(e, EP_CAN_EXPLODE_BY_DRAGONFIRE)
404 #define CAN_EXPLODE_BY_EXPLOSION(e)     \
405                                 HAS_PROPERTY(e, EP_CAN_EXPLODE_BY_EXPLOSION)
406 #define COULD_MOVE_INTO_ACID(e) HAS_PROPERTY(e, EP_COULD_MOVE_INTO_ACID)
407 #define MAYBE_DONT_COLLIDE_WITH(e) HAS_PROPERTY(e, EP_MAYBE_DONT_COLLIDE_WITH)
408
409 /* special macros used in game engine */
410 #define IS_CUSTOM_ELEMENT(e)    ((e) >= EL_CUSTOM_START &&              \
411                                  (e) <= EL_CUSTOM_END)
412
413 #define IS_GROUP_ELEMENT(e)     ((e) >= EL_GROUP_START &&               \
414                                  (e) <= EL_GROUP_END)
415
416 #define IS_CLIPBOARD_ELEMENT(e) ((e) >= EL_INTERNAL_CLIPBOARD_START &&  \
417                                  (e) <= EL_INTERNAL_CLIPBOARD_END)
418
419 #define IS_INTERNAL_ELEMENT(e)  ((e) >= EL_INTERNAL_START &&            \
420                                  (e) <= EL_INTERNAL_END)
421
422 #define IS_ENVELOPE(e)          ((e) >= EL_ENVELOPE_1 &&                \
423                                  (e) <= EL_ENVELOPE_4)
424
425 #define IS_GATE(e)              ((e) >= EL_GATE_1 &&                    \
426                                  (e) <= EL_GATE_4)
427
428 #define IS_GATE_GRAY(e)         ((e) >= EL_GATE_1_GRAY &&               \
429                                  (e) <= EL_GATE_4_GRAY)
430
431 #define IS_EM_GATE(e)           ((e) >= EL_EM_GATE_1 &&                 \
432                                  (e) <= EL_EM_GATE_4)
433
434 #define IS_EM_GATE_GRAY(e)      ((e) >= EL_EM_GATE_1_GRAY &&            \
435                                  (e) <= EL_EM_GATE_4_GRAY)
436
437 #define GFX_ELEMENT(e)          (element_info[e].use_gfx_element ?      \
438                                  element_info[e].gfx_element : e)
439
440 /* !!! "use sound" deactivated due to problems with level "bug machine" !!! */
441 /* (solution: add separate "use sound of element" to level file and editor) */
442 #if 0
443 #define SND_ELEMENT(e)          GFX_ELEMENT(e)
444 #else
445 #define SND_ELEMENT(e)          (e)
446 #endif
447
448 #define IS_PLAYER(x, y)         (ELEM_IS_PLAYER(StorePlayer[x][y]))
449
450 #define IS_FREE(x, y)           (Feld[x][y] == EL_EMPTY && !IS_PLAYER(x, y))
451 #define IS_FREE_OR_PLAYER(x, y) (Feld[x][y] == EL_EMPTY)
452
453 #define IS_MOVING(x,y)          (MovPos[x][y] != 0)
454 #define IS_FALLING(x,y)         (MovPos[x][y] != 0 && MovDir[x][y] == MV_DOWN)
455 #define IS_BLOCKED(x,y)         (Feld[x][y] == EL_BLOCKED)
456
457 #define EL_CHANGED(e)           ((e) == EL_ROCK           ? EL_EMERALD :    \
458                                  (e) == EL_BD_ROCK        ? EL_BD_DIAMOND : \
459                                  (e) == EL_EMERALD        ? EL_DIAMOND :    \
460                                  (e) == EL_EMERALD_YELLOW ? EL_DIAMOND :    \
461                                  (e) == EL_EMERALD_RED    ? EL_DIAMOND :    \
462                                  (e) == EL_EMERALD_PURPLE ? EL_DIAMOND :    \
463                                  EL_ROCK)
464 #define EL_CHANGED2(e)          ((e) == EL_ROCK           ? EL_BD_DIAMOND : \
465                                  (e) == EL_BD_ROCK        ? EL_BD_DIAMOND : \
466                                  EL_BD_ROCK)
467 #define IS_DRAWABLE(e)          ((e) < EL_BLOCKED)
468 #define IS_NOT_DRAWABLE(e)      ((e) >= EL_BLOCKED)
469 #define TAPE_IS_EMPTY(x)        ((x).length == 0)
470 #define TAPE_IS_STOPPED(x)      (!(x).recording && !(x).playing)
471
472 #define PLAYERINFO(x,y)         (&stored_player[StorePlayer[x][y]-EL_PLAYER_1])
473 #define SHIELD_ON(p)            ((p)->shield_normal_time_left > 0)
474
475 #if 1
476
477 #define ENEMY_PROTECTED_FIELD(x,y)      (IS_PROTECTED(Feld[x][y]) ||       \
478                                          IS_PROTECTED(Back[x][y]))
479 #define EXPLOSION_PROTECTED_FIELD(x,y)  (IS_EXPLOSION_PROOF(Feld[x][y]))
480 #define PLAYER_ENEMY_PROTECTED(x,y)     (SHIELD_ON(PLAYERINFO(x, y)) ||    \
481                                          ENEMY_PROTECTED_FIELD(x, y))
482 #define PLAYER_EXPLOSION_PROTECTED(x,y) (SHIELD_ON(PLAYERINFO(x, y)) ||    \
483                                          EXPLOSION_PROTECTED_FIELD(x, y))
484
485 #else
486
487 #define PROTECTED_FIELD(x,y)    (IS_ACCESSIBLE_INSIDE(Feld[x][y]) &&    \
488                                  IS_INDESTRUCTIBLE(Feld[x][y]))
489 #define PLAYER_ENEMY_PROTECTED(x,y)     (SHIELD_ON(PLAYERINFO(x, y)) || \
490                                  PROTECTED_FIELD(x, y))
491 #define PLAYER_EXPLOSION_PROTECTED(x,y) (SHIELD_ON(PLAYERINFO(x, y)) || \
492                                  PROTECTED_FIELD(x, y))
493 #endif
494
495 #define PLAYER_SWITCHING(p,x,y) ((p)->is_switching &&                   \
496                                  (p)->switch_x == (x) && (p)->switch_y == (y))
497
498 #define PLAYER_NR_GFX(g,i)      ((g) + i * (IMG_PLAYER_2 - IMG_PLAYER_1))
499
500 #define ANIM_FRAMES(g)          (graphic_info[g].anim_frames)
501 #define ANIM_DELAY(g)           (graphic_info[g].anim_delay)
502 #define ANIM_MODE(g)            (graphic_info[g].anim_mode)
503
504 #define IS_ANIMATED(g)          (ANIM_FRAMES(g) > 1)
505 #define IS_NEW_DELAY(f, g)      ((f) % ANIM_DELAY(g) == 0)
506 #define IS_NEW_FRAME(f, g)      (IS_ANIMATED(g) && IS_NEW_DELAY(f, g))
507 #define IS_NEXT_FRAME(f, g)     (IS_NEW_FRAME(f, g) && (f) > 0)
508
509 #define IS_LOOP_SOUND(s)        (sound_info[s].loop)
510
511
512 /* fundamental game speed values */
513 #define ONE_SECOND_DELAY        1000    /* delay value for one second */
514 #define GAME_FRAME_DELAY        20      /* frame delay in milliseconds */
515 #define FFWD_FRAME_DELAY        10      /* 200% speed for fast forward */
516 #define FRAMES_PER_SECOND       (ONE_SECOND_DELAY / GAME_FRAME_DELAY)
517 #define MICROLEVEL_SCROLL_DELAY 50      /* delay for scrolling micro level */
518 #define MICROLEVEL_LABEL_DELAY  250     /* delay for micro level label */
519
520 /* boundaries of arrays etc. */
521 #define MAX_LEVEL_NAME_LEN      32
522 #define MAX_LEVEL_AUTHOR_LEN    32
523 #define MAX_ELEMENT_NAME_LEN    32
524 #define MAX_TAPELEN             (1000 * FRAMES_PER_SECOND) /* max.time x fps */
525 #define MAX_SCORE_ENTRIES       100
526 #define MAX_NUM_AMOEBA          100
527 #define MAX_INVENTORY_SIZE      1000
528 #define MAX_KEYS                4
529 #define NUM_BELTS               4
530 #define NUM_BELT_PARTS          3
531 #define MIN_ENVELOPE_XSIZE      1
532 #define MIN_ENVELOPE_YSIZE      1
533 #define MAX_ENVELOPE_XSIZE      30
534 #define MAX_ENVELOPE_YSIZE      20
535 #define MAX_ENVELOPE_TEXT_LEN   (MAX_ENVELOPE_XSIZE * MAX_ENVELOPE_YSIZE)
536 #define MIN_CHANGE_PAGES        1
537 #define MAX_CHANGE_PAGES        32
538 #define MIN_ELEMENTS_IN_GROUP   1
539 #define MAX_ELEMENTS_IN_GROUP   16
540
541 /* values for elements with content */
542 #define MIN_ELEMENT_CONTENTS    1
543 #define STD_ELEMENT_CONTENTS    4
544 #define MAX_ELEMENT_CONTENTS    8
545
546 #define LEVEL_SCORE_ELEMENTS    16      /* level elements with score */
547
548 /* often used screen positions */
549 #define SX                      8
550 #define SY                      8
551 #define REAL_SX                 (SX - 2)
552 #define REAL_SY                 (SY - 2)
553 #define DX                      566
554 #define DY                      60
555 #define VX                      DX
556 #define VY                      400
557 #define EX                      DX
558 #define EY                      (VY - 44)
559 #define TILEX                   32
560 #define TILEY                   32
561 #define MINI_TILEX              (TILEX / 2)
562 #define MINI_TILEY              (TILEY / 2)
563 #define MICRO_TILEX             (TILEX / 8)
564 #define MICRO_TILEY             (TILEY / 8)
565 #define MIDPOSX                 (SCR_FIELDX / 2)
566 #define MIDPOSY                 (SCR_FIELDY / 2)
567 #define SXSIZE                  (SCR_FIELDX * TILEX)
568 #define SYSIZE                  (SCR_FIELDY * TILEY)
569 #define FXSIZE                  ((SCR_FIELDX + 2) * TILEX)
570 #define FYSIZE                  ((SCR_FIELDY + 2) * TILEY)
571 #define DXSIZE                  100
572 #define DYSIZE                  280
573 #define VXSIZE                  DXSIZE
574 #define VYSIZE                  100
575 #define EXSIZE                  DXSIZE
576 #define EYSIZE                  (VYSIZE + 44)
577 #define FULL_SXSIZE             (2 + SXSIZE + 2)
578 #define FULL_SYSIZE             (2 + SYSIZE + 2)
579 #define MICROLEV_XSIZE          ((STD_LEV_FIELDX + 2) * MICRO_TILEX)
580 #define MICROLEV_YSIZE          ((STD_LEV_FIELDY + 2) * MICRO_TILEY)
581 #define MICROLEV_XPOS           (SX + (SXSIZE - MICROLEV_XSIZE) / 2)
582 #define MICROLEV_YPOS           (SX + 12 * TILEY - MICRO_TILEY)
583 #define MICROLABEL_YPOS         (MICROLEV_YPOS + MICROLEV_YSIZE + 7)
584
585
586 /* score for elements */
587 #define SC_EMERALD              0
588 #define SC_DIAMOND              1
589 #define SC_BUG                  2
590 #define SC_SPACESHIP            3
591 #define SC_YAMYAM               4
592 #define SC_ROBOT                5
593 #define SC_PACMAN               6
594 #define SC_NUT                  7
595 #define SC_DYNAMITE             8
596 #define SC_KEY                  9
597 #define SC_TIME_BONUS           10
598 #define SC_CRYSTAL              11
599 #define SC_PEARL                12
600 #define SC_SHIELD               13
601
602
603 /* "real" level file elements */
604 #define EL_UNDEFINED                    -1
605
606 #define EL_EMPTY_SPACE                  0
607 #define EL_EMPTY                        EL_EMPTY_SPACE
608 #define EL_SAND                         1
609 #define EL_WALL                         2
610 #define EL_WALL_SLIPPERY                3
611 #define EL_ROCK                         4
612 #define EL_KEY_OBSOLETE                 5       /* obsolete; now EL_KEY_1 */
613 #define EL_EMERALD                      6
614 #define EL_EXIT_CLOSED                  7
615 #define EL_PLAYER_OBSOLETE              8       /* obsolete; now EL_PLAYER_1 */
616 #define EL_BUG                          9
617 #define EL_SPACESHIP                    10
618 #define EL_YAMYAM                       11
619 #define EL_ROBOT                        12
620 #define EL_STEELWALL                    13
621 #define EL_DIAMOND                      14
622 #define EL_AMOEBA_DEAD                  15
623 #define EL_QUICKSAND_EMPTY              16
624 #define EL_QUICKSAND_FULL               17
625 #define EL_AMOEBA_DROP                  18
626 #define EL_BOMB                         19
627 #define EL_MAGIC_WALL                   20
628 #define EL_SPEED_PILL                   21
629 #define EL_ACID                         22
630 #define EL_AMOEBA_WET                   23
631 #define EL_AMOEBA_DRY                   24
632 #define EL_NUT                          25
633 #define EL_GAME_OF_LIFE                 26
634 #define EL_BIOMAZE                      27
635 #define EL_DYNAMITE_ACTIVE              28
636 #define EL_STONEBLOCK                   29
637 #define EL_ROBOT_WHEEL                  30
638 #define EL_ROBOT_WHEEL_ACTIVE           31
639 #define EL_KEY_1                        32
640 #define EL_KEY_2                        33
641 #define EL_KEY_3                        34
642 #define EL_KEY_4                        35
643 #define EL_GATE_1                       36
644 #define EL_GATE_2                       37
645 #define EL_GATE_3                       38
646 #define EL_GATE_4                       39
647 #define EL_GATE_1_GRAY                  40
648 #define EL_GATE_2_GRAY                  41
649 #define EL_GATE_3_GRAY                  42
650 #define EL_GATE_4_GRAY                  43
651 #define EL_DYNAMITE                     44
652 #define EL_PACMAN                       45
653 #define EL_INVISIBLE_WALL               46
654 #define EL_LAMP                         47
655 #define EL_LAMP_ACTIVE                  48
656 #define EL_WALL_EMERALD                 49
657 #define EL_WALL_DIAMOND                 50
658 #define EL_AMOEBA_FULL                  51
659 #define EL_BD_AMOEBA                    52
660 #define EL_TIME_ORB_FULL                53
661 #define EL_TIME_ORB_EMPTY               54
662 #define EL_EXPANDABLE_WALL              55
663 #define EL_BD_DIAMOND                   56
664 #define EL_EMERALD_YELLOW               57
665 #define EL_WALL_BD_DIAMOND              58
666 #define EL_WALL_EMERALD_YELLOW          59
667 #define EL_DARK_YAMYAM                  60
668 #define EL_BD_MAGIC_WALL                61
669 #define EL_INVISIBLE_STEELWALL          62
670 #define EL_SOKOBAN_FIELD_PLAYER         63
671 #define EL_DYNABOMB_INCREASE_NUMBER     64
672 #define EL_DYNABOMB_INCREASE_SIZE       65
673 #define EL_DYNABOMB_INCREASE_POWER      66
674 #define EL_SOKOBAN_OBJECT               67
675 #define EL_SOKOBAN_FIELD_EMPTY          68
676 #define EL_SOKOBAN_FIELD_FULL           69
677 #define EL_BD_BUTTERFLY_RIGHT           70
678 #define EL_BD_BUTTERFLY_UP              71
679 #define EL_BD_BUTTERFLY_LEFT            72
680 #define EL_BD_BUTTERFLY_DOWN            73
681 #define EL_BD_FIREFLY_RIGHT             74
682 #define EL_BD_FIREFLY_UP                75
683 #define EL_BD_FIREFLY_LEFT              76
684 #define EL_BD_FIREFLY_DOWN              77
685 #define EL_BD_BUTTERFLY_1               EL_BD_BUTTERFLY_DOWN
686 #define EL_BD_BUTTERFLY_2               EL_BD_BUTTERFLY_LEFT
687 #define EL_BD_BUTTERFLY_3               EL_BD_BUTTERFLY_UP
688 #define EL_BD_BUTTERFLY_4               EL_BD_BUTTERFLY_RIGHT
689 #define EL_BD_FIREFLY_1                 EL_BD_FIREFLY_LEFT
690 #define EL_BD_FIREFLY_2                 EL_BD_FIREFLY_DOWN
691 #define EL_BD_FIREFLY_3                 EL_BD_FIREFLY_RIGHT
692 #define EL_BD_FIREFLY_4                 EL_BD_FIREFLY_UP
693 #define EL_BD_BUTTERFLY                 78
694 #define EL_BD_FIREFLY                   79
695 #define EL_PLAYER_1                     80
696 #define EL_PLAYER_2                     81
697 #define EL_PLAYER_3                     82
698 #define EL_PLAYER_4                     83
699 #define EL_BUG_RIGHT                    84
700 #define EL_BUG_UP                       85
701 #define EL_BUG_LEFT                     86
702 #define EL_BUG_DOWN                     87
703 #define EL_SPACESHIP_RIGHT              88
704 #define EL_SPACESHIP_UP                 89
705 #define EL_SPACESHIP_LEFT               90
706 #define EL_SPACESHIP_DOWN               91
707 #define EL_PACMAN_RIGHT                 92
708 #define EL_PACMAN_UP                    93
709 #define EL_PACMAN_LEFT                  94
710 #define EL_PACMAN_DOWN                  95
711 #define EL_EMERALD_RED                  96
712 #define EL_EMERALD_PURPLE               97
713 #define EL_WALL_EMERALD_RED             98
714 #define EL_WALL_EMERALD_PURPLE          99
715 #define EL_ACID_POOL_TOPLEFT            100
716 #define EL_ACID_POOL_TOPRIGHT           101
717 #define EL_ACID_POOL_BOTTOMLEFT         102
718 #define EL_ACID_POOL_BOTTOM             103
719 #define EL_ACID_POOL_BOTTOMRIGHT        104
720 #define EL_BD_WALL                      105
721 #define EL_BD_ROCK                      106
722 #define EL_EXIT_OPEN                    107
723 #define EL_BLACK_ORB                    108
724 #define EL_AMOEBA_TO_DIAMOND            109
725 #define EL_MOLE                         110
726 #define EL_PENGUIN                      111
727 #define EL_SATELLITE                    112
728 #define EL_ARROW_LEFT                   113
729 #define EL_ARROW_RIGHT                  114
730 #define EL_ARROW_UP                     115
731 #define EL_ARROW_DOWN                   116
732 #define EL_PIG                          117
733 #define EL_DRAGON                       118
734
735 #define EL_EM_KEY_1_FILE_OBSOLETE       119     /* obsolete; now EL_EM_KEY_1 */
736
737 #define EL_CHAR_START                   120
738 #define EL_CHAR_ASCII0                  (EL_CHAR_START  - 32)
739 #define EL_CHAR_ASCII0_START            (EL_CHAR_ASCII0 + 32)
740
741 #include "conf_chr.h"   /* include auto-generated data structure definitions */
742
743 #define EL_CHAR_ASCII0_END              (EL_CHAR_ASCII0 + 111)
744 #define EL_CHAR_END                     (EL_CHAR_START  + 79)
745
746 #define EL_CHAR(c)                      (EL_CHAR_ASCII0 + MAP_FONT_ASCII(c))
747
748 #define EL_EXPANDABLE_WALL_HORIZONTAL   200
749 #define EL_EXPANDABLE_WALL_VERTICAL     201
750 #define EL_EXPANDABLE_WALL_ANY          202
751
752 #define EL_EM_GATE_1                    203
753 #define EL_EM_GATE_2                    204
754 #define EL_EM_GATE_3                    205
755 #define EL_EM_GATE_4                    206
756
757 #define EL_EM_KEY_2_FILE_OBSOLETE       207     /* obsolete; now EL_EM_KEY_2 */
758 #define EL_EM_KEY_3_FILE_OBSOLETE       208     /* obsolete; now EL_EM_KEY_3 */
759 #define EL_EM_KEY_4_FILE_OBSOLETE       209     /* obsolete; now EL_EM_KEY_4 */
760
761 #define EL_SP_START                     210
762 #define EL_SP_EMPTY_SPACE               (EL_SP_START + 0)
763 #define EL_SP_EMPTY                     EL_SP_EMPTY_SPACE
764 #define EL_SP_ZONK                      (EL_SP_START + 1)
765 #define EL_SP_BASE                      (EL_SP_START + 2)
766 #define EL_SP_MURPHY                    (EL_SP_START + 3)
767 #define EL_SP_INFOTRON                  (EL_SP_START + 4)
768 #define EL_SP_CHIP_SINGLE               (EL_SP_START + 5)
769 #define EL_SP_HARDWARE_GRAY             (EL_SP_START + 6)
770 #define EL_SP_EXIT_CLOSED               (EL_SP_START + 7)
771 #define EL_SP_DISK_ORANGE               (EL_SP_START + 8)
772 #define EL_SP_PORT_RIGHT                (EL_SP_START + 9)
773 #define EL_SP_PORT_DOWN                 (EL_SP_START + 10)
774 #define EL_SP_PORT_LEFT                 (EL_SP_START + 11)
775 #define EL_SP_PORT_UP                   (EL_SP_START + 12)
776 #define EL_SP_GRAVITY_PORT_RIGHT        (EL_SP_START + 13)
777 #define EL_SP_GRAVITY_PORT_DOWN         (EL_SP_START + 14)
778 #define EL_SP_GRAVITY_PORT_LEFT         (EL_SP_START + 15)
779 #define EL_SP_GRAVITY_PORT_UP           (EL_SP_START + 16)
780 #define EL_SP_SNIKSNAK                  (EL_SP_START + 17)
781 #define EL_SP_DISK_YELLOW               (EL_SP_START + 18)
782 #define EL_SP_TERMINAL                  (EL_SP_START + 19)
783 #define EL_SP_DISK_RED                  (EL_SP_START + 20)
784 #define EL_SP_PORT_VERTICAL             (EL_SP_START + 21)
785 #define EL_SP_PORT_HORIZONTAL           (EL_SP_START + 22)
786 #define EL_SP_PORT_ANY                  (EL_SP_START + 23)
787 #define EL_SP_ELECTRON                  (EL_SP_START + 24)
788 #define EL_SP_BUGGY_BASE                (EL_SP_START + 25)
789 #define EL_SP_CHIP_LEFT                 (EL_SP_START + 26)
790 #define EL_SP_CHIP_RIGHT                (EL_SP_START + 27)
791 #define EL_SP_HARDWARE_BASE_1           (EL_SP_START + 28)
792 #define EL_SP_HARDWARE_GREEN            (EL_SP_START + 29)
793 #define EL_SP_HARDWARE_BLUE             (EL_SP_START + 30)
794 #define EL_SP_HARDWARE_RED              (EL_SP_START + 31)
795 #define EL_SP_HARDWARE_YELLOW           (EL_SP_START + 32)
796 #define EL_SP_HARDWARE_BASE_2           (EL_SP_START + 33)
797 #define EL_SP_HARDWARE_BASE_3           (EL_SP_START + 34)
798 #define EL_SP_HARDWARE_BASE_4           (EL_SP_START + 35)
799 #define EL_SP_HARDWARE_BASE_5           (EL_SP_START + 36)
800 #define EL_SP_HARDWARE_BASE_6           (EL_SP_START + 37)
801 #define EL_SP_CHIP_TOP                  (EL_SP_START + 38)
802 #define EL_SP_CHIP_BOTTOM               (EL_SP_START + 39)
803 #define EL_SP_END                       (EL_SP_START + 39)
804
805 #define EL_EM_GATE_1_GRAY               250
806 #define EL_EM_GATE_2_GRAY               251
807 #define EL_EM_GATE_3_GRAY               252
808 #define EL_EM_GATE_4_GRAY               253
809
810 #define EL_UNUSED_254                   254
811 #define EL_UNUSED_255                   255
812
813 #define EL_PEARL                        256
814 #define EL_CRYSTAL                      257
815 #define EL_WALL_PEARL                   258
816 #define EL_WALL_CRYSTAL                 259
817 #define EL_DOOR_WHITE                   260
818 #define EL_DOOR_WHITE_GRAY              261
819 #define EL_KEY_WHITE                    262
820 #define EL_SHIELD_NORMAL                263
821 #define EL_EXTRA_TIME                   264
822 #define EL_SWITCHGATE_OPEN              265
823 #define EL_SWITCHGATE_CLOSED            266
824 #define EL_SWITCHGATE_SWITCH_UP         267
825 #define EL_SWITCHGATE_SWITCH_DOWN       268
826
827 #define EL_UNUSED_269                   269
828 #define EL_UNUSED_270                   270
829
830 #define EL_CONVEYOR_BELT_1_LEFT          271
831 #define EL_CONVEYOR_BELT_1_MIDDLE        272
832 #define EL_CONVEYOR_BELT_1_RIGHT         273
833 #define EL_CONVEYOR_BELT_1_SWITCH_LEFT   274
834 #define EL_CONVEYOR_BELT_1_SWITCH_MIDDLE 275
835 #define EL_CONVEYOR_BELT_1_SWITCH_RIGHT  276
836 #define EL_CONVEYOR_BELT_2_LEFT          277
837 #define EL_CONVEYOR_BELT_2_MIDDLE        278
838 #define EL_CONVEYOR_BELT_2_RIGHT         279
839 #define EL_CONVEYOR_BELT_2_SWITCH_LEFT   280
840 #define EL_CONVEYOR_BELT_2_SWITCH_MIDDLE 281
841 #define EL_CONVEYOR_BELT_2_SWITCH_RIGHT  282
842 #define EL_CONVEYOR_BELT_3_LEFT          283
843 #define EL_CONVEYOR_BELT_3_MIDDLE        284
844 #define EL_CONVEYOR_BELT_3_RIGHT         285
845 #define EL_CONVEYOR_BELT_3_SWITCH_LEFT   286
846 #define EL_CONVEYOR_BELT_3_SWITCH_MIDDLE 287
847 #define EL_CONVEYOR_BELT_3_SWITCH_RIGHT  288
848 #define EL_CONVEYOR_BELT_4_LEFT          289
849 #define EL_CONVEYOR_BELT_4_MIDDLE        290
850 #define EL_CONVEYOR_BELT_4_RIGHT         291
851 #define EL_CONVEYOR_BELT_4_SWITCH_LEFT   292
852 #define EL_CONVEYOR_BELT_4_SWITCH_MIDDLE 293
853 #define EL_CONVEYOR_BELT_4_SWITCH_RIGHT  294
854 #define EL_LANDMINE                     295
855 #define EL_ENVELOPE_OBSOLETE            296   /* obsolete; now EL_ENVELOPE_1 */
856 #define EL_LIGHT_SWITCH                 297
857 #define EL_LIGHT_SWITCH_ACTIVE          298
858 #define EL_SIGN_EXCLAMATION             299
859 #define EL_SIGN_RADIOACTIVITY           300
860 #define EL_SIGN_STOP                    301
861 #define EL_SIGN_WHEELCHAIR              302
862 #define EL_SIGN_PARKING                 303
863 #define EL_SIGN_ONEWAY                  304
864 #define EL_SIGN_HEART                   305
865 #define EL_SIGN_TRIANGLE                306
866 #define EL_SIGN_ROUND                   307
867 #define EL_SIGN_EXIT                    308
868 #define EL_SIGN_YINYANG                 309
869 #define EL_SIGN_OTHER                   310
870 #define EL_MOLE_LEFT                    311
871 #define EL_MOLE_RIGHT                   312
872 #define EL_MOLE_UP                      313
873 #define EL_MOLE_DOWN                    314
874 #define EL_STEELWALL_SLIPPERY           315
875 #define EL_INVISIBLE_SAND               316
876 #define EL_DX_UNKNOWN_15                317
877 #define EL_DX_UNKNOWN_42                318
878
879 #define EL_UNUSED_319                   319
880 #define EL_UNUSED_320                   320
881
882 #define EL_SHIELD_DEADLY                321
883 #define EL_TIMEGATE_OPEN                322
884 #define EL_TIMEGATE_CLOSED              323
885 #define EL_TIMEGATE_SWITCH_ACTIVE       324
886 #define EL_TIMEGATE_SWITCH              325
887
888 #define EL_BALLOON                      326
889 #define EL_BALLOON_SWITCH_LEFT          327
890 #define EL_BALLOON_SWITCH_RIGHT         328
891 #define EL_BALLOON_SWITCH_UP            329
892 #define EL_BALLOON_SWITCH_DOWN          330
893 #define EL_BALLOON_SWITCH_ANY           331
894
895 #define EL_EMC_STEELWALL_1              332
896 #define EL_EMC_STEELWALL_2              333
897 #define EL_EMC_STEELWALL_3              334
898 #define EL_EMC_STEELWALL_4              335
899 #define EL_EMC_WALL_1                   336
900 #define EL_EMC_WALL_2                   337
901 #define EL_EMC_WALL_3                   338
902 #define EL_EMC_WALL_4                   339
903 #define EL_EMC_WALL_5                   340
904 #define EL_EMC_WALL_6                   341
905 #define EL_EMC_WALL_7                   342
906 #define EL_EMC_WALL_8                   343
907
908 #define EL_TUBE_ANY                     344
909 #define EL_TUBE_VERTICAL                345
910 #define EL_TUBE_HORIZONTAL              346
911 #define EL_TUBE_VERTICAL_LEFT           347
912 #define EL_TUBE_VERTICAL_RIGHT          348
913 #define EL_TUBE_HORIZONTAL_UP           349
914 #define EL_TUBE_HORIZONTAL_DOWN         350
915 #define EL_TUBE_LEFT_UP                 351
916 #define EL_TUBE_LEFT_DOWN               352
917 #define EL_TUBE_RIGHT_UP                353
918 #define EL_TUBE_RIGHT_DOWN              354
919 #define EL_SPRING                       355
920 #define EL_TRAP                         356
921 #define EL_DX_SUPABOMB                  357
922
923 #define EL_UNUSED_358                   358
924 #define EL_UNUSED_359                   359
925
926 /* ---------- begin of custom elements section ----------------------------- */
927 #define EL_CUSTOM_START                 360
928
929 #include "conf_cus.h"   /* include auto-generated data structure definitions */
930
931 #define NUM_CUSTOM_ELEMENTS             256
932 #define EL_CUSTOM_END                   615
933 /* ---------- end of custom elements section ------------------------------- */
934
935 #define EL_EM_KEY_1                     616
936 #define EL_EM_KEY_2                     617
937 #define EL_EM_KEY_3                     618
938 #define EL_EM_KEY_4                     619
939 #define EL_ENVELOPE_1                   620
940 #define EL_ENVELOPE_2                   621
941 #define EL_ENVELOPE_3                   622
942 #define EL_ENVELOPE_4                   623
943
944 /* ---------- begin of group elements section ------------------------------ */
945 #define EL_GROUP_START                  624
946
947 #include "conf_grp.h"   /* include auto-generated data structure definitions */
948
949 #define NUM_GROUP_ELEMENTS              32
950 #define EL_GROUP_END                    655
951 /* ---------- end of custom elements section ------------------------------- */
952
953 #define EL_UNKNOWN                      656
954 #define EL_TRIGGER_ELEMENT              657
955 #define EL_TRIGGER_PLAYER               658
956
957 #define EL_SP_GRAVITY_ON_PORT_RIGHT     659
958 #define EL_SP_GRAVITY_ON_PORT_DOWN      660
959 #define EL_SP_GRAVITY_ON_PORT_LEFT      661
960 #define EL_SP_GRAVITY_ON_PORT_UP        662
961 #define EL_SP_GRAVITY_OFF_PORT_RIGHT    663
962 #define EL_SP_GRAVITY_OFF_PORT_DOWN     664
963 #define EL_SP_GRAVITY_OFF_PORT_LEFT     665
964 #define EL_SP_GRAVITY_OFF_PORT_UP       666
965
966 #if 1
967
968 #define NUM_FILE_ELEMENTS               667
969
970 /* the following EMC style elements are currently not implemented in R'n'D */
971 #define EL_BALLOON_SWITCH_NONE          EL_UNKNOWN
972 #define EL_EMC_LEVEL_BORDER             EL_UNKNOWN
973 #define EL_EMC_ANDROID                  EL_UNKNOWN
974 #define EL_EMC_ANDROID_RIGHT            EL_UNKNOWN
975 #define EL_EMC_ANDROID_UP               EL_UNKNOWN
976 #define EL_EMC_ANDROID_LEFT             EL_UNKNOWN
977 #define EL_EMC_ANDROID_DOWN             EL_UNKNOWN
978 #define EL_EMC_ANDROID_LEFT_UP          EL_UNKNOWN
979 #define EL_EMC_ANDROID_LEFT_DOWN        EL_UNKNOWN
980 #define EL_EMC_ANDROID_RIGHT_UP         EL_UNKNOWN
981 #define EL_EMC_ANDROID_RIGHT_DOWN       EL_UNKNOWN
982 #define EL_EMC_GRASS                    EL_UNKNOWN
983 #define EL_EMC_GENERATOR_BALL           EL_UNKNOWN
984 #define EL_EMC_GROW                     EL_UNKNOWN
985 #define EL_EMC_GATE_1                   EL_UNKNOWN
986 #define EL_EMC_GATE_2                   EL_UNKNOWN
987 #define EL_EMC_GATE_3                   EL_UNKNOWN
988 #define EL_EMC_GATE_4                   EL_UNKNOWN
989 #define EL_EMC_GATE_5                   EL_UNKNOWN
990 #define EL_EMC_GATE_6                   EL_UNKNOWN
991 #define EL_EMC_GATE_7                   EL_UNKNOWN
992 #define EL_EMC_GATE_8                   EL_UNKNOWN
993 #define EL_EMC_GATE_1_GRAY              EL_UNKNOWN
994 #define EL_EMC_GATE_2_GRAY              EL_UNKNOWN
995 #define EL_EMC_GATE_3_GRAY              EL_UNKNOWN
996 #define EL_EMC_GATE_4_GRAY              EL_UNKNOWN
997 #define EL_EMC_GATE_5_GRAY              EL_UNKNOWN
998 #define EL_EMC_GATE_6_GRAY              EL_UNKNOWN
999 #define EL_EMC_GATE_7_GRAY              EL_UNKNOWN
1000 #define EL_EMC_GATE_8_GRAY              EL_UNKNOWN
1001 #define EL_EMC_KEY_1                    EL_UNKNOWN
1002 #define EL_EMC_KEY_2                    EL_UNKNOWN
1003 #define EL_EMC_KEY_3                    EL_UNKNOWN
1004 #define EL_EMC_KEY_4                    EL_UNKNOWN
1005 #define EL_EMC_KEY_5                    EL_UNKNOWN
1006 #define EL_EMC_KEY_6                    EL_UNKNOWN
1007 #define EL_EMC_KEY_7                    EL_UNKNOWN
1008 #define EL_EMC_KEY_8                    EL_UNKNOWN
1009 #define EL_EMC_BUMPER                   EL_UNKNOWN
1010 #define EL_EMC_PLANT                    EL_UNKNOWN
1011 #define EL_EMC_LENSES                   EL_UNKNOWN
1012 #define EL_EMC_MAGNIFY                  EL_UNKNOWN
1013
1014 #else
1015
1016 /* the following EMC style elements are currently not implemented in R'n'D */
1017 #define EL_BALLOON_SWITCH_NONE          667
1018 #define EL_EMC_LEVEL_BORDER             668
1019 #define EL_EMC_ANDROID                  669
1020 #define EL_EMC_ANDROID_RIGHT            670
1021 #define EL_EMC_ANDROID_UP               671
1022 #define EL_EMC_ANDROID_LEFT             672
1023 #define EL_EMC_ANDROID_DOWN             673
1024 #define EL_EMC_ANDROID_LEFT_UP          674
1025 #define EL_EMC_ANDROID_LEFT_DOWN        675
1026 #define EL_EMC_ANDROID_RIGHT_UP         676
1027 #define EL_EMC_ANDROID_RIGHT_DOWN       677
1028 #define EL_EMC_GRASS                    678
1029 #define EL_EMC_GENERATOR_BALL           679
1030 #define EL_EMC_GROW                     680
1031 #define EL_EMC_GATE_1                   681
1032 #define EL_EMC_GATE_2                   682
1033 #define EL_EMC_GATE_3                   683
1034 #define EL_EMC_GATE_4                   684
1035 #define EL_EMC_GATE_5                   685
1036 #define EL_EMC_GATE_6                   686
1037 #define EL_EMC_GATE_7                   687
1038 #define EL_EMC_GATE_8                   688
1039 #define EL_EMC_GATE_1_GRAY              689
1040 #define EL_EMC_GATE_2_GRAY              690
1041 #define EL_EMC_GATE_3_GRAY              691
1042 #define EL_EMC_GATE_4_GRAY              692
1043 #define EL_EMC_GATE_5_GRAY              693
1044 #define EL_EMC_GATE_6_GRAY              694
1045 #define EL_EMC_GATE_7_GRAY              695
1046 #define EL_EMC_GATE_8_GRAY              696
1047 #define EL_EMC_KEY_1                    697
1048 #define EL_EMC_KEY_2                    698
1049 #define EL_EMC_KEY_3                    699
1050 #define EL_EMC_KEY_4                    700
1051 #define EL_EMC_KEY_5                    701
1052 #define EL_EMC_KEY_6                    702
1053 #define EL_EMC_KEY_7                    703
1054 #define EL_EMC_KEY_8                    704
1055 #define EL_EMC_BUMPER                   705
1056 #define EL_EMC_PLANT                    706
1057 #define EL_EMC_LENSES                   707
1058 #define EL_EMC_MAGNIFY                  708
1059
1060 #define NUM_FILE_ELEMENTS               709
1061
1062 #endif
1063
1064
1065 /* "real" (and therefore drawable) runtime elements */
1066 #define EL_FIRST_RUNTIME_REAL           NUM_FILE_ELEMENTS
1067
1068 #define EL_DYNABOMB_PLAYER_1_ACTIVE     (EL_FIRST_RUNTIME_REAL + 0)
1069 #define EL_DYNABOMB_PLAYER_2_ACTIVE     (EL_FIRST_RUNTIME_REAL + 1)
1070 #define EL_DYNABOMB_PLAYER_3_ACTIVE     (EL_FIRST_RUNTIME_REAL + 2)
1071 #define EL_DYNABOMB_PLAYER_4_ACTIVE     (EL_FIRST_RUNTIME_REAL + 3)
1072 #define EL_SP_DISK_RED_ACTIVE           (EL_FIRST_RUNTIME_REAL + 4)
1073 #define EL_SWITCHGATE_OPENING           (EL_FIRST_RUNTIME_REAL + 5)
1074 #define EL_SWITCHGATE_CLOSING           (EL_FIRST_RUNTIME_REAL + 6)
1075 #define EL_TIMEGATE_OPENING             (EL_FIRST_RUNTIME_REAL + 7)
1076 #define EL_TIMEGATE_CLOSING             (EL_FIRST_RUNTIME_REAL + 8)
1077 #define EL_PEARL_BREAKING               (EL_FIRST_RUNTIME_REAL + 9)
1078 #define EL_TRAP_ACTIVE                  (EL_FIRST_RUNTIME_REAL + 10)
1079 #define EL_INVISIBLE_STEELWALL_ACTIVE   (EL_FIRST_RUNTIME_REAL + 11)
1080 #define EL_INVISIBLE_WALL_ACTIVE        (EL_FIRST_RUNTIME_REAL + 12)
1081 #define EL_INVISIBLE_SAND_ACTIVE        (EL_FIRST_RUNTIME_REAL + 13)
1082 #define EL_CONVEYOR_BELT_1_LEFT_ACTIVE   (EL_FIRST_RUNTIME_REAL + 14)
1083 #define EL_CONVEYOR_BELT_1_MIDDLE_ACTIVE (EL_FIRST_RUNTIME_REAL + 15)
1084 #define EL_CONVEYOR_BELT_1_RIGHT_ACTIVE  (EL_FIRST_RUNTIME_REAL + 16)
1085 #define EL_CONVEYOR_BELT_2_LEFT_ACTIVE   (EL_FIRST_RUNTIME_REAL + 17)
1086 #define EL_CONVEYOR_BELT_2_MIDDLE_ACTIVE (EL_FIRST_RUNTIME_REAL + 18)
1087 #define EL_CONVEYOR_BELT_2_RIGHT_ACTIVE  (EL_FIRST_RUNTIME_REAL + 19)
1088 #define EL_CONVEYOR_BELT_3_LEFT_ACTIVE   (EL_FIRST_RUNTIME_REAL + 20)
1089 #define EL_CONVEYOR_BELT_3_MIDDLE_ACTIVE (EL_FIRST_RUNTIME_REAL + 21)
1090 #define EL_CONVEYOR_BELT_3_RIGHT_ACTIVE  (EL_FIRST_RUNTIME_REAL + 22)
1091 #define EL_CONVEYOR_BELT_4_LEFT_ACTIVE   (EL_FIRST_RUNTIME_REAL + 23)
1092 #define EL_CONVEYOR_BELT_4_MIDDLE_ACTIVE (EL_FIRST_RUNTIME_REAL + 24)
1093 #define EL_CONVEYOR_BELT_4_RIGHT_ACTIVE  (EL_FIRST_RUNTIME_REAL + 25)
1094 #define EL_EXIT_OPENING                 (EL_FIRST_RUNTIME_REAL + 26)
1095 #define EL_EXIT_CLOSING                 (EL_FIRST_RUNTIME_REAL + 27)
1096 #define EL_SP_EXIT_OPENING              (EL_FIRST_RUNTIME_REAL + 28)
1097 #define EL_SP_EXIT_CLOSING              (EL_FIRST_RUNTIME_REAL + 29)
1098 #define EL_SP_EXIT_OPEN                 (EL_FIRST_RUNTIME_REAL + 30)
1099 #define EL_SP_TERMINAL_ACTIVE           (EL_FIRST_RUNTIME_REAL + 31)
1100 #define EL_SP_BUGGY_BASE_ACTIVATING     (EL_FIRST_RUNTIME_REAL + 32)
1101 #define EL_SP_BUGGY_BASE_ACTIVE         (EL_FIRST_RUNTIME_REAL + 33)
1102 #define EL_SP_MURPHY_CLONE              (EL_FIRST_RUNTIME_REAL + 34)
1103 #define EL_AMOEBA_DROPPING              (EL_FIRST_RUNTIME_REAL + 35)
1104 #define EL_QUICKSAND_EMPTYING           (EL_FIRST_RUNTIME_REAL + 36)
1105 #define EL_MAGIC_WALL_ACTIVE            (EL_FIRST_RUNTIME_REAL + 37)
1106 #define EL_BD_MAGIC_WALL_ACTIVE         (EL_FIRST_RUNTIME_REAL + 38)
1107 #define EL_MAGIC_WALL_FULL              (EL_FIRST_RUNTIME_REAL + 39)
1108 #define EL_BD_MAGIC_WALL_FULL           (EL_FIRST_RUNTIME_REAL + 40)
1109 #define EL_MAGIC_WALL_EMPTYING          (EL_FIRST_RUNTIME_REAL + 41)
1110 #define EL_BD_MAGIC_WALL_EMPTYING       (EL_FIRST_RUNTIME_REAL + 42)
1111 #define EL_MAGIC_WALL_DEAD              (EL_FIRST_RUNTIME_REAL + 43)
1112 #define EL_BD_MAGIC_WALL_DEAD           (EL_FIRST_RUNTIME_REAL + 44)
1113
1114 /* "unreal" (and therefore not drawable) runtime elements */
1115 #define EL_FIRST_RUNTIME_UNREAL         (EL_FIRST_RUNTIME_REAL + 45)
1116
1117 #define EL_BLOCKED                      (EL_FIRST_RUNTIME_UNREAL + 0)
1118 #define EL_EXPLOSION                    (EL_FIRST_RUNTIME_UNREAL + 1)
1119 #define EL_NUT_BREAKING                 (EL_FIRST_RUNTIME_UNREAL + 2)
1120 #define EL_DIAMOND_BREAKING             (EL_FIRST_RUNTIME_UNREAL + 3)
1121 #define EL_ACID_SPLASH_LEFT             (EL_FIRST_RUNTIME_UNREAL + 4)
1122 #define EL_ACID_SPLASH_RIGHT            (EL_FIRST_RUNTIME_UNREAL + 5)
1123 #define EL_AMOEBA_GROWING               (EL_FIRST_RUNTIME_UNREAL + 6)
1124 #define EL_AMOEBA_SHRINKING             (EL_FIRST_RUNTIME_UNREAL + 7)
1125 #define EL_EXPANDABLE_WALL_GROWING      (EL_FIRST_RUNTIME_UNREAL + 8)
1126 #define EL_FLAMES                       (EL_FIRST_RUNTIME_UNREAL + 9)
1127 #define EL_PLAYER_IS_LEAVING            (EL_FIRST_RUNTIME_UNREAL + 10)
1128 #define EL_PLAYER_IS_EXPLODING_1        (EL_FIRST_RUNTIME_UNREAL + 11)
1129 #define EL_PLAYER_IS_EXPLODING_2        (EL_FIRST_RUNTIME_UNREAL + 12)
1130 #define EL_PLAYER_IS_EXPLODING_3        (EL_FIRST_RUNTIME_UNREAL + 13)
1131 #define EL_PLAYER_IS_EXPLODING_4        (EL_FIRST_RUNTIME_UNREAL + 14)
1132 #define EL_QUICKSAND_FILLING            (EL_FIRST_RUNTIME_UNREAL + 15)
1133 #define EL_MAGIC_WALL_FILLING           (EL_FIRST_RUNTIME_UNREAL + 16)
1134 #define EL_BD_MAGIC_WALL_FILLING        (EL_FIRST_RUNTIME_UNREAL + 17)
1135
1136 /* dummy elements (never used as game elements, only used as graphics) */
1137 #define EL_FIRST_DUMMY                  (EL_FIRST_RUNTIME_UNREAL + 18)
1138
1139 #define EL_STEELWALL_TOPLEFT                    (EL_FIRST_DUMMY + 0)
1140 #define EL_STEELWALL_TOPRIGHT                   (EL_FIRST_DUMMY + 1)
1141 #define EL_STEELWALL_BOTTOMLEFT                 (EL_FIRST_DUMMY + 2)
1142 #define EL_STEELWALL_BOTTOMRIGHT                (EL_FIRST_DUMMY + 3)
1143 #define EL_STEELWALL_HORIZONTAL                 (EL_FIRST_DUMMY + 4)
1144 #define EL_STEELWALL_VERTICAL                   (EL_FIRST_DUMMY + 5)
1145 #define EL_INVISIBLE_STEELWALL_TOPLEFT          (EL_FIRST_DUMMY + 6)
1146 #define EL_INVISIBLE_STEELWALL_TOPRIGHT         (EL_FIRST_DUMMY + 7)
1147 #define EL_INVISIBLE_STEELWALL_BOTTOMLEFT       (EL_FIRST_DUMMY + 8)
1148 #define EL_INVISIBLE_STEELWALL_BOTTOMRIGHT      (EL_FIRST_DUMMY + 9)
1149 #define EL_INVISIBLE_STEELWALL_HORIZONTAL       (EL_FIRST_DUMMY + 10)
1150 #define EL_INVISIBLE_STEELWALL_VERTICAL         (EL_FIRST_DUMMY + 11)
1151 #define EL_DYNABOMB                             (EL_FIRST_DUMMY + 12)
1152 #define EL_DYNABOMB_ACTIVE                      (EL_FIRST_DUMMY + 13)
1153 #define EL_DYNABOMB_PLAYER_1                    (EL_FIRST_DUMMY + 14)
1154 #define EL_DYNABOMB_PLAYER_2                    (EL_FIRST_DUMMY + 15)
1155 #define EL_DYNABOMB_PLAYER_3                    (EL_FIRST_DUMMY + 16)
1156 #define EL_DYNABOMB_PLAYER_4                    (EL_FIRST_DUMMY + 17)
1157 #define EL_SHIELD_NORMAL_ACTIVE                 (EL_FIRST_DUMMY + 18)
1158 #define EL_SHIELD_DEADLY_ACTIVE                 (EL_FIRST_DUMMY + 19)
1159 #define EL_AMOEBA                               (EL_FIRST_DUMMY + 20)
1160 #define EL_DEFAULT                              (EL_FIRST_DUMMY + 21)
1161 #define EL_BD_DEFAULT                           (EL_FIRST_DUMMY + 22)
1162 #define EL_SP_DEFAULT                           (EL_FIRST_DUMMY + 23)
1163 #define EL_SB_DEFAULT                           (EL_FIRST_DUMMY + 24)
1164
1165 /* internal elements (only used for internal purposes like copying) */
1166 #define EL_FIRST_INTERNAL                       (EL_FIRST_DUMMY + 25)
1167
1168 #define EL_INTERNAL_CLIPBOARD_CUSTOM            (EL_FIRST_INTERNAL + 0)
1169 #define EL_INTERNAL_CLIPBOARD_CHANGE            (EL_FIRST_INTERNAL + 1)
1170 #define EL_INTERNAL_CLIPBOARD_GROUP             (EL_FIRST_INTERNAL + 2)
1171 #define EL_INTERNAL_DUMMY                       (EL_FIRST_INTERNAL + 3)
1172
1173 #define EL_INTERNAL_CLIPBOARD_START             (EL_FIRST_INTERNAL + 0)
1174 #define EL_INTERNAL_CLIPBOARD_END               (EL_FIRST_INTERNAL + 2)
1175 #define EL_INTERNAL_START                       (EL_FIRST_INTERNAL + 0)
1176 #define EL_INTERNAL_END                         (EL_FIRST_INTERNAL + 3)
1177
1178 #define MAX_NUM_ELEMENTS                        (EL_FIRST_INTERNAL + 4)
1179
1180
1181 /* values for graphics/sounds action types */
1182 #define ACTION_DEFAULT                          0
1183 #define ACTION_WAITING                          1
1184 #define ACTION_FALLING                          2
1185 #define ACTION_MOVING                           3
1186 #define ACTION_DIGGING                          4
1187 #define ACTION_SNAPPING                         5
1188 #define ACTION_COLLECTING                       6
1189 #define ACTION_DROPPING                         7
1190 #define ACTION_PUSHING                          8
1191 #define ACTION_WALKING                          9
1192 #define ACTION_PASSING                          10
1193 #define ACTION_IMPACT                           11
1194 #define ACTION_BREAKING                         12
1195 #define ACTION_ACTIVATING                       13
1196 #define ACTION_DEACTIVATING                     14
1197 #define ACTION_OPENING                          15
1198 #define ACTION_CLOSING                          16
1199 #define ACTION_ATTACKING                        17
1200 #define ACTION_GROWING                          18
1201 #define ACTION_SHRINKING                        19
1202 #define ACTION_ACTIVE                           20
1203 #define ACTION_FILLING                          21
1204 #define ACTION_EMPTYING                         22
1205 #define ACTION_CHANGING                         23
1206 #define ACTION_EXPLODING                        24
1207 #define ACTION_BORING                           25
1208 #define ACTION_BORING_1                         26
1209 #define ACTION_BORING_2                         27
1210 #define ACTION_BORING_3                         28
1211 #define ACTION_BORING_4                         29
1212 #define ACTION_BORING_5                         30
1213 #define ACTION_BORING_6                         31
1214 #define ACTION_BORING_7                         32
1215 #define ACTION_BORING_8                         33
1216 #define ACTION_BORING_9                         34
1217 #define ACTION_BORING_10                        35
1218 #define ACTION_SLEEPING                         36
1219 #define ACTION_SLEEPING_1                       37
1220 #define ACTION_SLEEPING_2                       38
1221 #define ACTION_SLEEPING_3                       39
1222 #define ACTION_AWAKENING                        40
1223 #define ACTION_DYING                            41
1224 #define ACTION_TURNING                          42
1225 #define ACTION_TURNING_FROM_LEFT                43
1226 #define ACTION_TURNING_FROM_RIGHT               44
1227 #define ACTION_TURNING_FROM_UP                  45
1228 #define ACTION_TURNING_FROM_DOWN                46
1229 #define ACTION_OTHER                            47
1230
1231 #define NUM_ACTIONS                             48
1232
1233 #define ACTION_BORING_LAST                      ACTION_BORING_10
1234 #define ACTION_SLEEPING_LAST                    ACTION_SLEEPING_3
1235
1236
1237 /* values for special image configuration suffixes (must match game mode) */
1238 #define GFX_SPECIAL_ARG_DEFAULT                 0
1239 #define GFX_SPECIAL_ARG_MAIN                    1
1240 #define GFX_SPECIAL_ARG_LEVELS                  2
1241 #define GFX_SPECIAL_ARG_SCORES                  3
1242 #define GFX_SPECIAL_ARG_EDITOR                  4
1243 #define GFX_SPECIAL_ARG_INFO                    5
1244 #define GFX_SPECIAL_ARG_SETUP                   6
1245 #define GFX_SPECIAL_ARG_PLAYING                 7
1246 #define GFX_SPECIAL_ARG_DOOR                    8
1247 #define GFX_SPECIAL_ARG_PREVIEW                 9
1248 #define GFX_SPECIAL_ARG_CRUMBLED                10
1249
1250 #define NUM_SPECIAL_GFX_ARGS                    11
1251
1252
1253 /* values for image configuration suffixes */
1254 #define GFX_ARG_X                               0
1255 #define GFX_ARG_Y                               1
1256 #define GFX_ARG_XPOS                            2
1257 #define GFX_ARG_YPOS                            3
1258 #define GFX_ARG_WIDTH                           4
1259 #define GFX_ARG_HEIGHT                          5
1260 #define GFX_ARG_OFFSET                          6
1261 #define GFX_ARG_VERTICAL                        7
1262 #define GFX_ARG_XOFFSET                         8
1263 #define GFX_ARG_YOFFSET                         9
1264 #define GFX_ARG_FRAMES                          10
1265 #define GFX_ARG_FRAMES_PER_LINE                 11
1266 #define GFX_ARG_START_FRAME                     12
1267 #define GFX_ARG_DELAY                           13
1268 #define GFX_ARG_ANIM_MODE                       14
1269 #define GFX_ARG_GLOBAL_SYNC                     15
1270 #define GFX_ARG_CRUMBLED_LIKE                   16
1271 #define GFX_ARG_DIGGABLE_LIKE                   17
1272 #define GFX_ARG_BORDER_SIZE                     18
1273 #define GFX_ARG_STEP_OFFSET                     19
1274 #define GFX_ARG_STEP_DELAY                      20
1275 #define GFX_ARG_DIRECTION                       21
1276 #define GFX_ARG_POSITION                        22
1277 #define GFX_ARG_DRAW_XOFFSET                    23
1278 #define GFX_ARG_DRAW_YOFFSET                    24
1279 #define GFX_ARG_DRAW_MASKED                     25
1280 #define GFX_ARG_ANIM_DELAY_FIXED                26
1281 #define GFX_ARG_ANIM_DELAY_RANDOM               27
1282 #define GFX_ARG_POST_DELAY_FIXED                28
1283 #define GFX_ARG_POST_DELAY_RANDOM               29
1284 #define GFX_ARG_NAME                            30
1285 #define GFX_ARG_SCALE_UP                        31
1286
1287 #define NUM_GFX_ARGS                            32
1288
1289
1290 /* values for sound configuration suffixes */
1291 #define SND_ARG_MODE_LOOP                       0
1292
1293 #define NUM_SND_ARGS                            1
1294
1295
1296 /* values for music configuration suffixes */
1297 #define MUS_ARG_MODE_LOOP                       0
1298
1299 #define NUM_MUS_ARGS                            1
1300
1301
1302 /* values for font configuration */
1303 #define FONT_INITIAL_1                          0
1304 #define FONT_INITIAL_2                          1
1305 #define FONT_INITIAL_3                          2
1306 #define FONT_INITIAL_4                          3
1307 #define FONT_TITLE_1                            4
1308 #define FONT_TITLE_2                            5
1309 #define FONT_MENU_1                             6
1310 #define FONT_MENU_2                             7
1311 #define FONT_TEXT_1_ACTIVE                      8
1312 #define FONT_TEXT_2_ACTIVE                      9
1313 #define FONT_TEXT_3_ACTIVE                      10
1314 #define FONT_TEXT_4_ACTIVE                      11
1315 #define FONT_TEXT_1                             12
1316 #define FONT_TEXT_2                             13
1317 #define FONT_TEXT_3                             14
1318 #define FONT_TEXT_4                             15
1319 #define FONT_ENVELOPE_1                         16
1320 #define FONT_ENVELOPE_2                         17
1321 #define FONT_ENVELOPE_3                         18
1322 #define FONT_ENVELOPE_4                         19
1323 #define FONT_INPUT_1_ACTIVE                     20
1324 #define FONT_INPUT_2_ACTIVE                     21
1325 #define FONT_INPUT_1                            22
1326 #define FONT_INPUT_2                            23
1327 #define FONT_OPTION_OFF                         24
1328 #define FONT_OPTION_ON                          25
1329 #define FONT_VALUE_1                            26
1330 #define FONT_VALUE_2                            27
1331 #define FONT_VALUE_OLD                          28
1332 #define FONT_LEVEL_NUMBER                       29
1333 #define FONT_TAPE_RECORDER                      30
1334 #define FONT_GAME_INFO                          31
1335
1336 #define NUM_FONTS                               32
1337 #define NUM_INITIAL_FONTS                       4
1338
1339 /* values for game_status (must match special image configuration suffixes) */
1340 #define GAME_MODE_DEFAULT                       0
1341 #define GAME_MODE_MAIN                          1
1342 #define GAME_MODE_LEVELS                        2
1343 #define GAME_MODE_SCORES                        3
1344 #define GAME_MODE_EDITOR                        4
1345 #define GAME_MODE_INFO                          5
1346 #define GAME_MODE_SETUP                         6
1347 #define GAME_MODE_PLAYING                       7
1348 #define GAME_MODE_PSEUDO_DOOR                   8
1349 #define GAME_MODE_PSEUDO_PREVIEW                9
1350 #define GAME_MODE_PSEUDO_CRUMBLED               10
1351
1352 /* there are no special config file suffixes for these modes */
1353 #define GAME_MODE_PSEUDO_TYPENAME               11
1354 #define GAME_MODE_QUIT                          12
1355
1356 /* special definitions currently only used for custom artwork configuration */
1357 #define MUSIC_PREFIX_BACKGROUND                 0
1358 #define NUM_MUSIC_PREFIXES                      1
1359 #define MAX_LEVELS                              1000
1360
1361 /* definitions for demo animation lists */
1362 #define HELPANIM_LIST_NEXT                      -1
1363 #define HELPANIM_LIST_END                       -999
1364
1365
1366 /* program information and versioning definitions */
1367
1368 #define PROGRAM_VERSION_MAJOR   3
1369 #define PROGRAM_VERSION_MINOR   1
1370 #define PROGRAM_VERSION_PATCH   1
1371 #define PROGRAM_VERSION_BUILD   0
1372
1373 #define PROGRAM_TITLE_STRING    "Rocks'n'Diamonds"
1374 #define PROGRAM_AUTHOR_STRING   "Holger Schemel"
1375 #define PROGRAM_COPYRIGHT_STRING "Copyright Â©1995-2004 by Holger Schemel"
1376
1377 #define ICON_TITLE_STRING       PROGRAM_TITLE_STRING
1378 #define COOKIE_PREFIX           "ROCKSNDIAMONDS"
1379 #define FILENAME_PREFIX         "Rocks"
1380
1381 #if defined(PLATFORM_UNIX)
1382 #define USERDATA_DIRECTORY      ".rocksndiamonds"
1383 #elif defined(PLATFORM_WIN32)
1384 #define USERDATA_DIRECTORY      PROGRAM_TITLE_STRING
1385 #else
1386 #define USERDATA_DIRECTORY      "userdata"
1387 #endif
1388
1389 #define X11_ICON_FILENAME       "rocks_icon.xbm"
1390 #define X11_ICONMASK_FILENAME   "rocks_iconmask.xbm"
1391 #define MSDOS_POINTER_FILENAME  "mouse.pcx"
1392
1393 /* file version numbers for resource files (levels, tapes, score, setup, etc.)
1394 ** currently supported/known file version numbers:
1395 **      1.0 (old)
1396 **      1.2 (still in use)
1397 **      1.4 (still in use)
1398 **      2.0 (actual)
1399 */
1400 #define FILE_VERSION_1_0        VERSION_IDENT(1,0,0,0)
1401 #define FILE_VERSION_1_2        VERSION_IDENT(1,2,0,0)
1402 #define FILE_VERSION_1_4        VERSION_IDENT(1,4,0,0)
1403 #define FILE_VERSION_2_0        VERSION_IDENT(2,0,0,0)
1404
1405 /* file version does not change for every program version, but is changed
1406    when new features are introduced that are incompatible with older file
1407    versions, so that they can be treated accordingly */
1408 #define FILE_VERSION_ACTUAL     FILE_VERSION_2_0
1409
1410 #define GAME_VERSION_1_0        FILE_VERSION_1_0
1411 #define GAME_VERSION_1_2        FILE_VERSION_1_2
1412 #define GAME_VERSION_1_4        FILE_VERSION_1_4
1413 #define GAME_VERSION_2_0        FILE_VERSION_2_0
1414
1415 #define GAME_VERSION_ACTUAL     VERSION_IDENT(PROGRAM_VERSION_MAJOR, \
1416                                               PROGRAM_VERSION_MINOR, \
1417                                               PROGRAM_VERSION_PATCH, \
1418                                               PROGRAM_VERSION_BUILD)
1419
1420 /* values for game_emulation */
1421 #define EMU_NONE                0
1422 #define EMU_BOULDERDASH         1
1423 #define EMU_SOKOBAN             2
1424 #define EMU_SUPAPLEX            3
1425
1426 struct MenuInfo
1427 {
1428   int draw_xoffset_default;
1429   int draw_yoffset_default;
1430   int draw_xoffset[NUM_SPECIAL_GFX_ARGS];
1431   int draw_yoffset[NUM_SPECIAL_GFX_ARGS];
1432
1433   int scrollbar_xoffset;
1434
1435   int list_size_default;
1436   int list_size[NUM_SPECIAL_GFX_ARGS];
1437
1438   int sound[NUM_SPECIAL_GFX_ARGS];
1439   int music[NUM_SPECIAL_GFX_ARGS];
1440 };
1441
1442 struct DoorInfo
1443 {
1444   int step_offset;
1445   int step_delay;
1446   int anim_mode;
1447 };
1448
1449 struct HiScore
1450 {
1451   char Name[MAX_PLAYER_NAME_LEN + 1];
1452   int Score;
1453 };
1454
1455 struct PlayerInfo
1456 {
1457   boolean present;              /* player present in level playfield */
1458   boolean connected;            /* player connected (locally or via network) */
1459   boolean active;               /* player present and connected */
1460
1461   int index_nr;                 /* player number (0 to 3) */
1462   int index_bit;                /* player number bit (1 << 0 to 1 << 3) */
1463   int element_nr;               /* element (EL_PLAYER_1 to EL_PLAYER_4) */
1464   int client_nr;                /* network client identifier */
1465
1466   byte action;                  /* action from local input device */
1467   byte effective_action;        /* action acknowledged from network server
1468                                    or summarized over all configured input
1469                                    devices when in single player mode */
1470   byte programmed_action;       /* action forced by game itself (like moving
1471                                    through doors); overrides other actions */
1472
1473   int jx, jy, last_jx, last_jy;
1474   int MovDir, MovPos, GfxDir, GfxPos;
1475   int Frame, StepFrame;
1476
1477   int GfxAction;
1478
1479   boolean use_murphy_graphic;
1480
1481   boolean block_last_field;
1482   int block_delay;
1483
1484   boolean can_fall_into_acid;
1485
1486   boolean LevelSolved, GameOver;
1487
1488   int last_move_dir;
1489
1490   boolean is_waiting;
1491   boolean is_moving;
1492   boolean is_auto_moving;
1493   boolean is_digging;
1494   boolean is_snapping;
1495   boolean is_collecting;
1496   boolean is_pushing;
1497   boolean is_switching;
1498   boolean is_dropping;
1499
1500   boolean is_bored;
1501   boolean is_sleeping;
1502
1503   int frame_counter_bored;
1504   int frame_counter_sleeping;
1505
1506   int anim_delay_counter;
1507   int post_delay_counter;
1508
1509   int action_waiting, last_action_waiting;
1510   int special_action_bored;
1511   int special_action_sleeping;
1512
1513   int num_special_action_bored;
1514   int num_special_action_sleeping;
1515
1516   int switch_x, switch_y;
1517
1518   int show_envelope;
1519
1520 #if 1   /* USE_NEW_MOVE_DELAY */
1521   int move_delay;
1522   int move_delay_value;
1523 #else
1524   unsigned long move_delay;
1525   int move_delay_value;
1526 #endif
1527
1528   int move_delay_reset_counter;
1529
1530 #if 1   /* USE_NEW_PUSH_DELAY */
1531   int push_delay;
1532   int push_delay_value;
1533 #else
1534   unsigned long push_delay;
1535   unsigned long push_delay_value;
1536 #endif
1537
1538   unsigned long actual_frame_counter;
1539
1540   int drop_delay;
1541
1542   int step_counter;
1543
1544   int score;
1545   int gems_still_needed;
1546   int sokobanfields_still_needed;
1547   int lights_still_needed;
1548   int friends_still_needed;
1549   int key[4];
1550   int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
1551   int shield_normal_time_left;
1552   int shield_deadly_time_left;
1553
1554   int inventory_element[MAX_INVENTORY_SIZE];
1555   int inventory_infinite_element;
1556   int inventory_size;
1557 };
1558
1559 struct LevelSetInfo
1560 {
1561   int music[MAX_LEVELS];
1562 };
1563
1564 struct LevelFileInfo
1565 {
1566   int nr;
1567   int type;
1568   boolean packed;
1569   char *basename;
1570   char *filename;
1571 };
1572
1573 struct LevelInfo
1574 {
1575   struct LevelFileInfo file_info;
1576
1577   /* level stored in native format for the native game engines */
1578   struct LevelInfo_EM *native_em_level;
1579
1580   int game_engine_type;
1581
1582   int file_version;     /* file format version the level is stored with    */
1583   int game_version;     /* game release version the level was created with */
1584
1585   boolean encoding_16bit_field;         /* level contains 16-bit elements  */
1586   boolean encoding_16bit_yamyam;        /* yamyam contains 16-bit elements */
1587   boolean encoding_16bit_amoeba;        /* amoeba contains 16-bit elements */
1588
1589   int fieldx, fieldy;
1590
1591   int time;
1592   int gems_needed;
1593
1594   char name[MAX_LEVEL_NAME_LEN + 1];
1595   char author[MAX_LEVEL_AUTHOR_LEN + 1];
1596
1597   char envelope_text[4][MAX_ENVELOPE_TEXT_LEN + 1];
1598   int envelope_xsize[4], envelope_ysize[4];
1599
1600   int score[LEVEL_SCORE_ELEMENTS];
1601
1602   int yamyam_content[MAX_ELEMENT_CONTENTS][3][3];
1603   int num_yamyam_contents;
1604
1605   int amoeba_speed;
1606   int amoeba_content;
1607
1608   int time_magic_wall;
1609   int time_wheel;
1610   int time_light;
1611   int time_timegate;
1612
1613   int can_move_into_acid_bits;  /* bitfield to store property for elements */
1614   int dont_collide_with_bits;   /* bitfield to store property for elements */
1615
1616   boolean double_speed;
1617   boolean initial_gravity;
1618   boolean em_slippery_gems;     /* EM style "gems slip from wall" behaviour */
1619   boolean use_spring_bug;       /* for compatibility with old levels */
1620   boolean instant_relocation;   /* no visual delay when relocating player */
1621   boolean can_pass_to_walkable; /* player can pass to empty or walkable tile */
1622   boolean grow_into_diggable;   /* amoeba can grow into anything diggable */
1623
1624   boolean block_last_field;     /* player blocks previous field while moving */
1625   boolean sp_block_last_field;  /* player blocks previous field while moving */
1626   int block_delay;              /* delay for blocking previous field */
1627   int sp_block_delay;           /* delay for blocking previous field */
1628
1629   /* ('int' instead of 'boolean' because used as selectbox value in editor) */
1630   int use_step_counter;         /* count steps instead of seconds for level */
1631
1632   short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
1633
1634   boolean use_custom_template;  /* use custom properties from template file */
1635
1636   boolean no_valid_file;        /* set when level file missing or invalid */
1637
1638   boolean changed;              /* set when level was changed in the editor */
1639 };
1640
1641 struct TapeInfo
1642 {
1643   int file_version;     /* file format version the tape is stored with    */
1644   int game_version;     /* game release version the tape was created with */
1645   int engine_version;   /* game engine version the tape was recorded with */
1646
1647   char *level_identifier;
1648   int level_nr;
1649   unsigned long random_seed;
1650   unsigned long date;
1651   unsigned long counter;
1652   unsigned long length;
1653   unsigned long length_seconds;
1654   unsigned int delay_played;
1655   boolean pause_before_death;
1656   boolean recording, playing, pausing;
1657   boolean fast_forward;
1658   boolean warp_forward;
1659   boolean deactivate_display;
1660   boolean auto_play;
1661   boolean auto_play_level_solved;
1662   boolean quick_resume;
1663   boolean single_step;
1664   boolean changed;
1665   boolean player_participates[MAX_PLAYERS];
1666   int num_participating_players;
1667
1668   struct
1669   {
1670     byte action[MAX_PLAYERS];
1671     byte delay;
1672   } pos[MAX_TAPELEN];
1673
1674   boolean no_valid_file;        /* set when tape file missing or invalid */
1675 };
1676
1677 struct GameInfo
1678 {
1679   /* values for engine initialization */
1680   int default_push_delay_fixed;
1681   int default_push_delay_random;
1682
1683   /* constant within running game */
1684   int engine_version;
1685   int emulation;
1686   int initial_move_delay;
1687   int initial_move_delay_value;
1688   int initial_push_delay_value;
1689
1690   /* flags to handle bugs in and changes between different engine versions */
1691   /* (for the latest engine version, these flags should always be "FALSE") */
1692   boolean use_bug_change_when_pushing;
1693
1694   /* variable within running game */
1695   int yamyam_content_nr;
1696   boolean magic_wall_active;
1697   int magic_wall_time_left;
1698   int light_time_left;
1699   int timegate_time_left;
1700   int belt_dir[4];
1701   int belt_dir_nr[4];
1702   int switchgate_pos;
1703   int balloon_dir;
1704   boolean gravity;
1705   boolean explosions_delayed;
1706   boolean envelope_active;
1707
1708   /* values for player idle animation (no effect on engine) */
1709   int player_boring_delay_fixed;
1710   int player_boring_delay_random;
1711   int player_sleeping_delay_fixed;
1712   int player_sleeping_delay_random;
1713 };
1714
1715 struct GlobalInfo
1716 {
1717   char *autoplay_leveldir;
1718   int autoplay_level_nr;
1719
1720   char *convert_leveldir;
1721   int convert_level_nr;
1722
1723   int num_toons;
1724
1725   float frames_per_second;
1726   boolean fps_slowdown;
1727   int fps_slowdown_factor;
1728 };
1729
1730 struct ElementChangeInfo
1731 {
1732   boolean can_change;           /* use or ignore this change info */
1733
1734   unsigned long events;         /* change events */
1735
1736   int trigger_player;           /* player triggering change */
1737   int trigger_side;             /* side triggering change */
1738   int trigger_page;             /* page triggering change */
1739
1740   short target_element;         /* target element after change */
1741
1742   int delay_fixed;              /* added frame delay before changed (fixed) */
1743   int delay_random;             /* added frame delay before changed (random) */
1744   int delay_frames;             /* either 1 (frames) or 50 (seconds; 50 fps) */
1745
1746   short trigger_element;        /* element triggering change */
1747
1748   int target_content[3][3];     /* elements for extended change target */
1749   boolean use_target_content;   /* use extended change target */
1750   boolean only_if_complete;     /* only use complete target content */
1751   boolean use_random_replace;   /* use random value for replacing elements */
1752   int random_percentage;        /* random value for replacing elements */
1753   int replace_when;             /* type of elements that can be replaced */
1754
1755   boolean explode;              /* explode instead of change */
1756
1757   /* ---------- internal values used at runtime when playing ---------- */
1758
1759   /* functions that are called before, while and after the change of an
1760      element -- currently only used for non-custom elements */
1761   void (*pre_change_function)(int x, int y);
1762   void (*change_function)(int x, int y);
1763   void (*post_change_function)(int x, int y);
1764
1765   short actual_trigger_element; /* element that actually triggered change */
1766   int actual_trigger_player;    /* player which actually triggered change */
1767
1768   /* ---------- internal values used in level editor ---------- */
1769
1770   int direct_action;            /* change triggered by actions on element */
1771   int other_action;             /* change triggered by other element actions */
1772 };
1773
1774 struct ElementGroupInfo
1775 {
1776   int num_elements;                     /* number of elements in this group */
1777   short element[MAX_ELEMENTS_IN_GROUP]; /* list of elements in this group */
1778
1779   int choice_mode;              /* how to choose element from group */
1780
1781   /* ---------- internal values used at runtime when playing ---------- */
1782
1783   /* the following is the same as above, but with recursively resolved group
1784      elements (group elements may also contain further group elements!) */
1785   int num_elements_resolved;
1786   short element_resolved[NUM_FILE_ELEMENTS];
1787
1788   int choice_pos;               /* current element choice position */
1789 };
1790
1791 struct ElementNameInfo
1792 {
1793   /* ---------- token and description strings ---------- */
1794
1795   char *token_name;             /* element token used in config files */
1796   char *class_name;             /* element class used in config files */
1797   char *editor_description;     /* pre-defined description for level editor */
1798 };
1799
1800 struct ElementInfo
1801 {
1802   /* ---------- token and description strings ---------- */
1803
1804   char *token_name;             /* element token used in config files */
1805   char *class_name;             /* element class used in config files */
1806   char *editor_description;     /* pre-defined description for level editor */
1807   char *custom_description;     /* alternative description from config file */
1808   char description[MAX_ELEMENT_NAME_LEN + 1];   /* for custom/group elements */
1809
1810   /* ---------- graphic and sound definitions ---------- */
1811
1812   int graphic[NUM_ACTIONS];     /* default graphics for several actions */
1813   int direction_graphic[NUM_ACTIONS][NUM_DIRECTIONS];
1814                                 /* special graphics for left/right/up/down */
1815
1816   int crumbled[NUM_ACTIONS];    /* crumbled graphics for several actions */
1817   int direction_crumbled[NUM_ACTIONS][NUM_DIRECTIONS];
1818                                 /* crumbled graphics for left/right/up/down */
1819
1820   int special_graphic[NUM_SPECIAL_GFX_ARGS];
1821                                 /* special graphics for certain screens */
1822
1823   int sound[NUM_ACTIONS];       /* default sounds for several actions */
1824
1825   /* ---------- special element property values ---------- */
1826
1827   boolean use_gfx_element;      /* use custom graphic element */
1828   short gfx_element;            /* optional custom graphic element */
1829
1830   int access_direction;         /* accessible from which direction */
1831
1832   int collect_score;            /* score value for collecting */
1833   int collect_count;            /* count value for collecting */
1834
1835   int push_delay_fixed;         /* constant delay before pushing */
1836   int push_delay_random;        /* additional random delay before pushing */
1837   int drop_delay_fixed;         /* constant delay after dropping */
1838   int drop_delay_random;        /* additional random delay after dropping */
1839   int move_delay_fixed;         /* constant delay after moving */
1840   int move_delay_random;        /* additional random delay after moving */
1841
1842   int move_pattern;             /* direction movable element moves to */
1843   int move_direction_initial;   /* initial direction element moves to */
1844   int move_stepsize;            /* step size element moves with */
1845
1846   int move_enter_element;       /* element that can be entered (and removed) */
1847   int move_leave_element;       /* element that can be left behind */
1848   int move_leave_type;          /* change (limited) or leave (unlimited) */
1849
1850   int slippery_type;            /* how/where other elements slip away */
1851
1852   int content[3][3];            /* new elements after explosion */
1853
1854   int explosion_type;           /* type of explosion, like 3x3, 3+3 or 1x1 */
1855   int explosion_delay;          /* duration of explosion of this element */
1856   int ignition_delay;           /* delay for explosion by other explosion */
1857
1858   struct ElementChangeInfo *change_page; /* actual list of change pages */
1859   struct ElementChangeInfo *change;      /* pointer to current change page */
1860
1861   int num_change_pages;         /* actual number of change pages */
1862   int current_change_page;      /* currently edited change page */
1863
1864   struct ElementGroupInfo *group;       /* pointer to element group info */
1865
1866   /* ---------- internal values used at runtime when playing ---------- */
1867
1868   unsigned long change_events;  /* bitfield for combined change events */
1869
1870   int event_page_nr[NUM_CHANGE_EVENTS]; /* page number for each event */
1871   struct ElementChangeInfo *event_page[NUM_CHANGE_EVENTS]; /* page for event */
1872
1873   boolean in_group[NUM_GROUP_ELEMENTS];
1874
1875 #if 0
1876   boolean can_leave_element;    /* element can leave other element behind */
1877   boolean can_leave_element_last;
1878 #endif
1879
1880   /* ---------- internal values used in level editor ---------- */
1881
1882   int access_type;              /* walkable or passable */
1883   int access_layer;             /* accessible over/inside/under */
1884   int access_protected;         /* protection against deadly elements */
1885   int walk_to_action;           /* diggable/collectible/pushable */
1886   int smash_targets;            /* can smash player/enemies/everything */
1887   int deadliness;               /* deadly when running/colliding/touching */
1888
1889   boolean can_explode_by_fire;  /* element explodes by fire */
1890   boolean can_explode_smashed;  /* element explodes when smashed */
1891   boolean can_explode_impact;   /* element explodes on impact */
1892
1893   boolean modified_settings;    /* set for all modified custom elements */
1894 };
1895
1896 struct FontInfo
1897 {
1898   char *token_name;             /* font token used in config files */
1899
1900   int graphic;                  /* default graphic for this font */
1901   int special_graphic[NUM_SPECIAL_GFX_ARGS];
1902                                 /* special graphics for certain screens */
1903   int special_bitmap_id[NUM_SPECIAL_GFX_ARGS];
1904                                 /* internal bitmap ID for special graphics */
1905 };
1906
1907 struct GraphicInfo
1908 {
1909   Bitmap *bitmap;
1910   int src_x, src_y;             /* start position of animation frames */
1911   int width, height;            /* width/height of each animation frame */
1912   int offset_x, offset_y;       /* x/y offset to next animation frame */
1913   int anim_frames;
1914   int anim_frames_per_line;
1915   int anim_start_frame;
1916   int anim_delay;               /* important: delay of 1 means "no delay"! */
1917   int anim_mode;
1918   boolean anim_global_sync;
1919   int crumbled_like;            /* element for cloning crumble graphics */
1920   int diggable_like;            /* element for cloning digging graphics */
1921   int border_size;              /* border size for "crumbled" graphics */
1922   int scale_up_factor;          /* optional factor for scaling image up */
1923
1924   int anim_delay_fixed;         /* optional delay values for bored and   */
1925   int anim_delay_random;        /* sleeping player animations (animation */
1926   int post_delay_fixed;         /* intervall and following pause before  */
1927   int post_delay_random;        /* next intervall (bored animation only) */
1928
1929   int step_offset;              /* optional step offset of toon animations */
1930   int step_delay;               /* optional step delay of toon animations */
1931
1932   int draw_x, draw_y;           /* optional offset for drawing fonts chars */
1933
1934   int draw_masked;              /* optional setting for drawing envelope gfx */
1935
1936 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1937   Pixmap clip_mask;             /* single-graphic-only clip mask for X11 */
1938   GC clip_gc;                   /* single-graphic-only clip gc for X11 */
1939 #endif
1940 };
1941
1942 struct SoundInfo
1943 {
1944   boolean loop;
1945 };
1946
1947 struct MusicInfo
1948 {
1949   boolean loop;
1950 };
1951
1952 struct MusicPrefixInfo
1953 {
1954   char *prefix;
1955   boolean is_loop_music;
1956 };
1957
1958 struct MusicFileInfo
1959 {
1960   char *basename;
1961
1962   char *title_header;
1963   char *artist_header;
1964   char *album_header;
1965   char *year_header;
1966
1967   char *title;
1968   char *artist;
1969   char *album;
1970   char *year;
1971
1972   int music;
1973
1974   boolean is_sound;
1975
1976   struct MusicFileInfo *next;
1977 };
1978
1979 struct ElementActionInfo
1980 {
1981   char *suffix;
1982   int value;
1983   boolean is_loop_sound;
1984 };
1985
1986 struct ElementDirectionInfo
1987 {
1988   char *suffix;
1989   int value;
1990 };
1991
1992 struct SpecialSuffixInfo
1993 {
1994   char *suffix;
1995   int value;
1996 };
1997
1998 struct HelpAnimInfo
1999 {
2000   int element;
2001   int action;
2002   int direction;
2003
2004   int delay;
2005 };
2006
2007
2008 #if 0
2009 extern GC                       tile_clip_gc;
2010 extern Bitmap                  *pix[];
2011 #endif
2012 extern Bitmap                  *bitmap_db_field, *bitmap_db_door;
2013 extern Pixmap                   tile_clipmask[];
2014 extern DrawBuffer             *fieldbuffer;
2015 extern DrawBuffer             *drawto_field;
2016
2017 extern int                      game_status;
2018 extern boolean                  level_editor_test_game;
2019 extern boolean                  network_playing;
2020
2021 #if defined(TARGET_SDL)
2022 extern boolean                  network_server;
2023 extern SDL_Thread              *server_thread;
2024 #endif
2025
2026 extern int                      key_joystick_mapping;
2027
2028 extern boolean                  redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
2029 extern int                      redraw_x1, redraw_y1;
2030
2031 extern short                    Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2032 extern short                    MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2033 extern short                    MovDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2034 extern short                    MovDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2035 extern short                    ChangeDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2036 extern short                    ChangePage[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2037 extern short                    Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2038 extern short                    Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2039 extern short                    StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2040 extern short                    Back[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2041 extern boolean                  Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2042 extern boolean                  Pushed[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2043 extern unsigned long            Changed[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2044 extern unsigned long            ChangeEvent[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2045 extern short                    WasJustMoving[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2046 extern short                    WasJustFalling[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2047 extern short                    CheckCollision[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2048 extern short                    AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2049 extern short                    AmoebaCnt[MAX_NUM_AMOEBA];
2050 extern short                    AmoebaCnt2[MAX_NUM_AMOEBA];
2051 extern short                    ExplodeField[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2052 extern short                    ExplodePhase[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2053 extern short                    ExplodeDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2054 extern int                      RunnerVisit[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2055 extern int                      PlayerVisit[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2056
2057 extern unsigned long            Properties[MAX_NUM_ELEMENTS][NUM_EP_BITFIELDS];
2058
2059 extern int                      GfxFrame[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2060 extern int                      GfxRandom[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2061 extern int                      GfxElement[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2062 extern int                      GfxAction[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2063 extern int                      GfxDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
2064
2065 extern int                      lev_fieldx, lev_fieldy;
2066 extern int                      scroll_x, scroll_y;
2067
2068 extern int                      FX, FY;
2069 extern int                      ScrollStepSize;
2070 extern int                      ScreenMovDir, ScreenMovPos, ScreenGfxPos;
2071 extern int                      BorderElement;
2072 extern int                      GameFrameDelay;
2073 extern int                      FfwdFrameDelay;
2074 extern int                      BX1, BY1;
2075 extern int                      BX2, BY2;
2076 extern int                      SBX_Left, SBX_Right;
2077 extern int                      SBY_Upper, SBY_Lower;
2078 extern int                      ZX, ZY;
2079 extern int                      ExitX, ExitY;
2080 extern int                      AllPlayersGone;
2081
2082 extern int                      TimeFrames, TimePlayed, TimeLeft, TapeTime;
2083 extern boolean                  SiebAktiv;
2084 extern int                      SiebCount;
2085
2086 extern boolean                  network_player_action_received;
2087
2088 extern int                      graphics_action_mapping[];
2089
2090 extern struct LevelSetInfo      levelset;
2091 extern struct LevelInfo         level, level_template;
2092 extern struct PlayerInfo        stored_player[], *local_player;
2093 extern struct HiScore           highscore[];
2094 extern struct TapeInfo          tape;
2095 extern struct GameInfo          game;
2096 extern struct GlobalInfo        global;
2097 extern struct MenuInfo          menu;
2098 extern struct DoorInfo          door_1, door_2;
2099 extern struct ElementInfo       element_info[];
2100 extern struct ElementNameInfo   element_name_info[];
2101 extern struct ElementActionInfo element_action_info[];
2102 extern struct ElementDirectionInfo element_direction_info[];
2103 extern struct SpecialSuffixInfo special_suffix_info[];
2104 extern struct TokenIntPtrInfo   image_config_vars[];
2105 extern struct FontInfo          font_info[];
2106 extern struct MusicPrefixInfo   music_prefix_info[];
2107 extern struct GraphicInfo      *graphic_info;
2108 extern struct SoundInfo        *sound_info;
2109 extern struct MusicInfo        *music_info;
2110 extern struct MusicFileInfo    *music_file_info;
2111 extern struct HelpAnimInfo     *helpanim_info;
2112 extern SetupFileHash           *helptext_info;
2113 extern struct ConfigTypeInfo    image_config_suffix[];
2114 extern struct ConfigTypeInfo    sound_config_suffix[];
2115 extern struct ConfigTypeInfo    music_config_suffix[];
2116 extern struct ConfigInfo        image_config[];
2117 extern struct ConfigInfo        sound_config[];
2118 extern struct ConfigInfo        music_config[];
2119 extern struct ConfigInfo        helpanim_config[];
2120 extern struct ConfigInfo        helptext_config[];
2121
2122 #endif  /* MAIN_H */