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