rnd-20020921-5-src
[rocksndiamonds.git] / src / init.c
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 * init.c                                                   *
12 ***********************************************************/
13
14 #include "libgame/libgame.h"
15
16 #include "init.h"
17 #include "events.h"
18 #include "screens.h"
19 #include "editor.h"
20 #include "game.h"
21 #include "tape.h"
22 #include "tools.h"
23 #include "files.h"
24 #include "network.h"
25 #include "netserv.h"
26 #include "cartoons.h"
27 #include "config.h"
28
29 static char *image_filename[NUM_PICTURES] =
30 {
31   "RocksScreen.pcx",
32   "RocksElements.pcx",
33   "RocksDoor.pcx",
34   "RocksHeroes.pcx",
35   "RocksToons.pcx",
36   "RocksSP.pcx",
37   "RocksDC.pcx",
38   "RocksMore.pcx",
39   "RocksFontBig.pcx",
40   "RocksFontSmall.pcx",
41   "RocksFontMedium.pcx",
42   "RocksFontEM.pcx"
43 }; 
44
45 static void InitSetup(void);
46 static void InitPlayerInfo(void);
47 static void InitLevelInfo(void);
48 static void InitArtworkInfo(void);
49 static void InitLevelArtworkInfo(void);
50 static void InitNetworkServer(void);
51 static void InitImages(void);
52 static void InitMixer(void);
53 static void InitSound(void);
54 static void InitGfx(void);
55 static void InitGfxBackground(void);
56 static void InitGadgets(void);
57 static void InitElementProperties(void);
58 static void InitElementInfo(void);
59 static void InitGraphicInfo(void);
60 static void InitSoundInfo();
61 static void Execute_Debug_Command(char *);
62
63 void OpenAll(void)
64 {
65   if (options.debug_command)
66   {
67     Execute_Debug_Command(options.debug_command);
68
69     exit(0);
70   }
71
72   if (options.serveronly)
73   {
74 #if defined(PLATFORM_UNIX)
75     NetworkServer(options.server_port, options.serveronly);
76 #else
77     Error(ERR_WARN, "networking only supported in Unix version");
78 #endif
79     exit(0);    /* never reached */
80   }
81
82   InitProgramInfo(UNIX_USERDATA_DIRECTORY,
83                   PROGRAM_TITLE_STRING, getWindowTitleString(),
84                   ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME,
85                   MSDOS_POINTER_FILENAME,
86                   COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
87
88   InitSetup();
89   InitPlayerInfo();
90   InitArtworkInfo();            /* needed before loading gfx, sound & music */
91
92   InitCounter();
93   InitMixer();
94   InitJoysticks();
95   InitRND(NEW_RANDOMIZE);
96
97   InitVideoDisplay();
98   InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
99                   setup.fullscreen);
100
101   InitEventFilter(FilterMouseMotionEvents);
102
103   InitGfx();
104   InitElementProperties();      /* initializes IS_CHAR() for el2gfx() */
105   InitElementInfo();
106
107   InitLevelInfo();
108   InitLevelArtworkInfo();
109   InitGadgets();                /* needs to know number of level series */
110   InitImages();                 /* needs to know current level directory */
111   InitSound();                  /* needs to know current level directory */
112
113   InitGfxBackground();
114   InitToons();
115
116   DrawMainMenu();
117
118   InitNetworkServer();
119 }
120
121 void InitSetup()
122 {
123   LoadSetup();                                  /* global setup info */
124 }
125
126 void InitPlayerInfo()
127 {
128   int i;
129
130   /* choose default local player */
131   local_player = &stored_player[0];
132
133   for (i=0; i<MAX_PLAYERS; i++)
134     stored_player[i].connected = FALSE;
135
136   local_player->connected = TRUE;
137 }
138
139 void InitLevelInfo()
140 {
141   LoadLevelInfo();                              /* global level info */
142   LoadLevelSetup_LastSeries();                  /* last played series info */
143   LoadLevelSetup_SeriesInfo();                  /* last played level info */
144 }
145
146 void InitArtworkInfo()
147 {
148   LoadArtworkInfo();
149 }
150
151 void InitLevelArtworkInfo()
152 {
153   LoadLevelArtworkInfo();
154 }
155
156 void InitNetworkServer()
157 {
158 #if defined(PLATFORM_UNIX)
159   int nr_wanted;
160 #endif
161
162   if (!options.network)
163     return;
164
165 #if defined(PLATFORM_UNIX)
166   nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
167
168   if (!ConnectToServer(options.server_host, options.server_port))
169     Error(ERR_EXIT, "cannot connect to network game server");
170
171   SendToServer_PlayerName(setup.player_name);
172   SendToServer_ProtocolVersion();
173
174   if (nr_wanted)
175     SendToServer_NrWanted(nr_wanted);
176 #endif
177 }
178
179 static void InitImages()
180 {
181   InitImageList(image_config, image_config_suffix, NUM_IMAGE_FILES);
182
183   /* load custom images */
184   ReloadCustomImages();
185
186   InitGraphicInfo();
187 }
188
189 static void InitMixer()
190 {
191   OpenAudio();
192
193   InitSoundList(sound_config, sound_config_suffix, NUM_SOUND_FILES);
194
195   StartMixer();
196 }
197
198 static void InitSound()
199 {
200   /* load custom sounds and music */
201   InitReloadSounds(artwork.snd_current->identifier);
202   InitReloadMusic(artwork.mus_current->identifier);
203
204   InitSoundInfo();
205 }
206
207 static void InitTileClipmasks()
208 {
209 #if defined(TARGET_X11)
210   XGCValues clip_gc_values;
211   unsigned long clip_gc_valuemask;
212
213 #if defined(TARGET_X11_NATIVE)
214   GC copy_clipmask_gc;
215
216   static struct
217   {
218     int start;
219     int count;
220   }
221   tile_needs_clipping[] =
222   {
223     { GFX_SPIELER1_UP, 4 },
224     { GFX_SPIELER1_DOWN, 4 },
225     { GFX_SPIELER1_LEFT, 4 },
226     { GFX_SPIELER1_RIGHT, 4 },
227     { GFX_SPIELER1_PUSH_LEFT, 4 },
228     { GFX_SPIELER1_PUSH_RIGHT, 4 },
229     { GFX_SPIELER2_UP, 4 },
230     { GFX_SPIELER2_DOWN, 4 },
231     { GFX_SPIELER2_LEFT, 4 },
232     { GFX_SPIELER2_RIGHT, 4 },
233     { GFX_SPIELER2_PUSH_LEFT, 4 },
234     { GFX_SPIELER2_PUSH_RIGHT, 4 },
235     { GFX_SPIELER3_UP, 4 },
236     { GFX_SPIELER3_DOWN, 4 },
237     { GFX_SPIELER3_LEFT, 4 },
238     { GFX_SPIELER3_RIGHT, 4 },
239     { GFX_SPIELER3_PUSH_LEFT, 4 },
240     { GFX_SPIELER3_PUSH_RIGHT, 4 },
241     { GFX_SPIELER4_UP, 4 },
242     { GFX_SPIELER4_DOWN, 4 },
243     { GFX_SPIELER4_LEFT, 4 },
244     { GFX_SPIELER4_RIGHT, 4 },
245     { GFX_SPIELER4_PUSH_LEFT, 4 },
246     { GFX_SPIELER4_PUSH_RIGHT, 4 },
247     { GFX_SP_MURPHY, 1 },
248     { GFX_MURPHY_GO_LEFT, 3 },
249     { GFX_MURPHY_GO_RIGHT, 3 },
250     { GFX_MURPHY_SNAP_UP, 1 },
251     { GFX_MURPHY_SNAP_DOWN, 1 },
252     { GFX_MURPHY_SNAP_RIGHT, 1 },
253     { GFX_MURPHY_SNAP_LEFT, 1 },
254     { GFX_MURPHY_PUSH_RIGHT, 1 },
255     { GFX_MURPHY_PUSH_LEFT, 1 },
256     { GFX_GEBLUBBER, 4 },
257     { GFX_DYNAMIT, 7 },
258     { GFX_DYNABOMB, 4 },
259     { GFX_EXPLOSION, 8 },
260     { GFX_SOKOBAN_OBJEKT, 1 },
261     { GFX_FUNKELN_BLAU, 3 },
262     { GFX_FUNKELN_WEISS, 3 },
263     { GFX2_SHIELD_PASSIVE, 3 },
264     { GFX2_SHIELD_ACTIVE, 3 },
265     { -1, 0 }
266   };
267 #endif /* TARGET_X11_NATIVE */
268 #endif /* TARGET_X11 */
269
270   int i;
271
272   /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
273   for(i=0; i<NUM_TILES; i++)
274     tile_clipmask[i] = None;
275
276 #if defined(TARGET_X11)
277   /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
278      often very slow when preparing a masked XCopyArea() for big Pixmaps.
279      To prevent this, create small (tile-sized) mask Pixmaps which will then
280      be set much faster with XSetClipOrigin() and speed things up a lot. */
281
282   clip_gc_values.graphics_exposures = False;
283   clip_gc_valuemask = GCGraphicsExposures;
284   tile_clip_gc = XCreateGC(display, window->drawable,
285                            clip_gc_valuemask, &clip_gc_values);
286
287   for(i=0; i<NUM_BITMAPS; i++)
288   {
289     if (pix[i]->clip_mask)
290     {
291       clip_gc_values.graphics_exposures = False;
292       clip_gc_values.clip_mask = pix[i]->clip_mask;
293       clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
294       pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
295                                          clip_gc_valuemask, &clip_gc_values);
296     }
297   }
298
299 #if defined(TARGET_X11_NATIVE)
300
301   /* create graphic context structures needed for clipping */
302   clip_gc_values.graphics_exposures = False;
303   clip_gc_valuemask = GCGraphicsExposures;
304   copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
305                                clip_gc_valuemask, &clip_gc_values);
306
307   /* create only those clipping Pixmaps we really need */
308   for(i=0; tile_needs_clipping[i].start>=0; i++)
309   {
310     int j;
311
312     for(j=0; j<tile_needs_clipping[i].count; j++)
313     {
314       int tile = tile_needs_clipping[i].start + j;
315       int graphic = tile;
316       int src_x, src_y;
317       Bitmap *src_bitmap;
318       Pixmap src_pixmap;
319
320       getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
321       src_pixmap = src_bitmap->clip_mask;
322
323       tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
324                                           TILEX, TILEY, 1);
325
326       XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
327                 src_x, src_y, TILEX, TILEY, 0, 0);
328     }
329   }
330
331   XFreeGC(display, copy_clipmask_gc);
332
333 #endif /* TARGET_X11_NATIVE */
334 #endif /* TARGET_X11 */
335 }
336
337 void FreeTileClipmasks()
338 {
339 #if defined(TARGET_X11)
340   int i;
341
342   for(i=0; i<NUM_TILES; i++)
343   {
344     if (tile_clipmask[i] != None)
345     {
346       XFreePixmap(display, tile_clipmask[i]);
347       tile_clipmask[i] = None;
348     }
349   }
350
351   if (tile_clip_gc)
352     XFreeGC(display, tile_clip_gc);
353   tile_clip_gc = None;
354
355   for(i=0; i<NUM_BITMAPS; i++)
356   {
357     if (pix[i] != NULL && pix[i]->stored_clip_gc)
358     {
359       XFreeGC(display, pix[i]->stored_clip_gc);
360       pix[i]->stored_clip_gc = None;
361     }
362   }
363 #endif /* TARGET_X11 */
364 }
365
366 void InitGfx()
367 {
368   int i;
369
370   /* initialize some global variables */
371   global.frames_per_second = 0;
372   global.fps_slowdown = FALSE;
373   global.fps_slowdown_factor = 1;
374
375   /* initialize screen properties */
376   InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
377                    REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
378   InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
379   InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
380   InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
381
382   /* create additional image buffers for double-buffering */
383   pix[PIX_DB_DOOR] = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
384   pix[PIX_DB_FIELD] = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
385
386   pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
387
388   InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
389
390   DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
391   DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
392
393   DrawInitText("Loading graphics:", 120, FC_GREEN);
394
395   for(i=0; i<NUM_PICTURES; i++)
396   {
397     if (i != PIX_FONT_SMALL)
398     {
399       DrawInitText(image_filename[i], 150, FC_YELLOW);
400
401       pix[i] = LoadCustomImage(image_filename[i]);
402     }
403   }
404
405   InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
406                pix[PIX_FONT_EM]);
407
408   InitTileClipmasks();
409 }
410
411 void InitGfxBackground()
412 {
413   int x, y;
414
415   drawto = backbuffer;
416   fieldbuffer = pix[PIX_DB_FIELD];
417   SetDrawtoField(DRAW_BACKBUFFER);
418
419   BlitBitmap(pix[PIX_BACK], backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
420   ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
421   ClearRectangle(pix[PIX_DB_DOOR], 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
422
423   for(x=0; x<MAX_BUF_XSIZE; x++)
424     for(y=0; y<MAX_BUF_YSIZE; y++)
425       redraw[x][y] = 0;
426   redraw_tiles = 0;
427   redraw_mask = REDRAW_ALL;
428 }
429
430 void ReloadCustomArtwork()
431 {
432   static char *leveldir_current_identifier = NULL;
433   static boolean last_override_level_graphics = FALSE;
434   static boolean last_override_level_sounds = FALSE;
435   static boolean last_override_level_music = FALSE;
436
437   /* identifier for new artwork; default: artwork configured in setup */
438   char *gfx_new_identifier = artwork.gfx_current->identifier;
439   char *snd_new_identifier = artwork.snd_current->identifier;
440   char *mus_new_identifier = artwork.mus_current->identifier;
441
442 #if 0
443   printf("graphics --> '%s' ('%s')\n",
444          artwork.gfx_current_identifier, artwork.gfx_current->filename);
445   printf("sounds   --> '%s' ('%s')\n",
446          artwork.snd_current_identifier, artwork.snd_current->filename);
447   printf("music    --> '%s' ('%s')\n",
448          artwork.mus_current_identifier, artwork.mus_current->filename);
449 #endif
450
451   /* leveldir_current may be invalid (level group, parent link) */
452   if (!validLevelSeries(leveldir_current))
453     return;
454
455 #if 0
456   printf("--> '%s'\n", artwork.gfx_current_identifier);
457 #endif
458
459   /* when a new level series was selected, check if there was a change
460      in custom artwork stored in level series directory */
461   if (leveldir_current_identifier != leveldir_current->identifier)
462   {
463     char *identifier_old = leveldir_current_identifier;
464     char *identifier_new = leveldir_current->identifier;
465
466     if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
467         getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
468       gfx_new_identifier = identifier_new;
469     if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
470         getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
471       snd_new_identifier = identifier_new;
472     if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
473         getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
474       mus_new_identifier = identifier_new;
475
476     leveldir_current_identifier = leveldir_current->identifier;
477   }
478
479   /* custom level artwork configured in level series configuration file
480      always overrides custom level artwork stored in level series directory
481      and (level independant) custom artwork configured in setup menue */
482   if (leveldir_current->graphics_set != NULL)
483     gfx_new_identifier = leveldir_current->graphics_set;
484   if (leveldir_current->sounds_set != NULL)
485     snd_new_identifier = leveldir_current->sounds_set;
486   if (leveldir_current->music_set != NULL)
487     mus_new_identifier = leveldir_current->music_set;
488
489   if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
490       last_override_level_graphics != setup.override_level_graphics)
491   {
492     int i;
493
494     setLevelArtworkDir(artwork.gfx_first);
495
496     ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
497
498     for(i=0; i<NUM_PICTURES; i++)
499     {
500       DrawInitText(image_filename[i], 150, FC_YELLOW);
501       ReloadCustomImage(pix[i], image_filename[i]);
502     }
503
504     ReloadCustomImages();
505     InitGraphicInfo();
506
507     FreeTileClipmasks();
508     InitTileClipmasks();
509     InitGfxBackground();
510
511     /* force redraw of (open or closed) door graphics */
512     SetDoorState(DOOR_OPEN_ALL);
513     CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
514
515     artwork.gfx_current_identifier = gfx_new_identifier;
516     last_override_level_graphics = setup.override_level_graphics;
517   }
518
519   if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
520       last_override_level_sounds != setup.override_level_sounds)
521   {
522     /* set artwork path to send it to the sound server process */
523     setLevelArtworkDir(artwork.snd_first);
524
525     InitReloadSounds(snd_new_identifier);
526
527     artwork.snd_current_identifier = snd_new_identifier;
528     last_override_level_sounds = setup.override_level_sounds;
529   }
530
531   if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
532       last_override_level_music != setup.override_level_music)
533   {
534     /* set artwork path to send it to the sound server process */
535     setLevelArtworkDir(artwork.mus_first);
536
537     InitReloadMusic(mus_new_identifier);
538
539     artwork.mus_current_identifier = mus_new_identifier;
540     last_override_level_music = setup.override_level_music;
541   }
542
543 #if 0
544   printf("<-- '%s'\n", artwork.gfx_current_identifier);
545 #endif
546 }
547
548 void InitGadgets()
549 {
550   CreateLevelEditorGadgets();
551   CreateGameButtons();
552   CreateTapeButtons();
553   CreateToolButtons();
554   CreateScreenGadgets();
555 }
556
557 void InitElementInfo()
558 {
559   int i, j;
560
561   static struct
562   {
563     int element;
564     int graphic;
565   }
566   element_to_graphic[] =
567   {
568     { EL_EMPTY,                         GFX_LEERRAUM            },
569     { EL_SAND,                          GFX_ERDREICH            },
570     { EL_WALL,                          GFX_MAUERWERK           },
571     { EL_WALL_CRUMBLED,                 GFX_FELSBODEN           },
572     { EL_ROCK,                          GFX_FELSBROCKEN         },
573     { EL_EMERALD,                       GFX_EDELSTEIN           },
574     { EL_EXIT_CLOSED,                   GFX_AUSGANG_ZU          },
575     { EL_EXIT_OPENING,                  GFX_AUSGANG_ACT         },
576     { EL_EXIT_OPEN,                     GFX_AUSGANG_AUF         },
577     { EL_SP_EXIT_OPEN,                  GFX_SP_EXIT             },
578     { EL_PLAYER,                        GFX_SPIELFIGUR          },
579     { EL_PLAYER1,                       GFX_SPIELER1            },
580     { EL_PLAYER2,                       GFX_SPIELER2            },
581     { EL_PLAYER3,                       GFX_SPIELER3            },
582     { EL_PLAYER4,                       GFX_SPIELER4            },
583     { EL_BUG,                           GFX_KAEFER              },
584     { EL_BUG_RIGHT,                     GFX_KAEFER_RIGHT        },
585     { EL_BUG_UP,                        GFX_KAEFER_UP           },
586     { EL_BUG_LEFT,                      GFX_KAEFER_LEFT         },
587     { EL_BUG_DOWN,                      GFX_KAEFER_DOWN         },
588     { EL_SPACESHIP,                     GFX_FLIEGER             },
589     { EL_SPACESHIP_RIGHT,               GFX_FLIEGER_RIGHT       },
590     { EL_SPACESHIP_UP,                  GFX_FLIEGER_UP          },
591     { EL_SPACESHIP_LEFT,                GFX_FLIEGER_LEFT        },
592     { EL_SPACESHIP_DOWN,                GFX_FLIEGER_DOWN        },
593     { EL_BD_BUTTERFLY,                  GFX_BUTTERFLY           },
594     { EL_BD_BUTTERFLY_RIGHT,            GFX_BUTTERFLY_RIGHT     },
595     { EL_BD_BUTTERFLY_UP,               GFX_BUTTERFLY_UP        },
596     { EL_BD_BUTTERFLY_LEFT,             GFX_BUTTERFLY_LEFT      },
597     { EL_BD_BUTTERFLY_DOWN,             GFX_BUTTERFLY_DOWN      },
598     { EL_BD_FIREFLY,                    GFX_FIREFLY             },
599     { EL_BD_FIREFLY_RIGHT,              GFX_FIREFLY_RIGHT       },
600     { EL_BD_FIREFLY_UP,                 GFX_FIREFLY_UP          },
601     { EL_BD_FIREFLY_LEFT,               GFX_FIREFLY_LEFT        },
602     { EL_BD_FIREFLY_DOWN,               GFX_FIREFLY_DOWN        },
603     { EL_YAMYAM,                        GFX_MAMPFER             },
604     { EL_ROBOT,                         GFX_ROBOT               },
605     { EL_STEELWALL,                     GFX_BETON               },
606     { EL_DIAMOND,                       GFX_DIAMANT             },
607     { EL_QUICKSAND_EMPTY,               GFX_MORAST_LEER         },
608     { EL_QUICKSAND_FULL,                GFX_MORAST_VOLL         },
609     { EL_QUICKSAND_EMPTYING,            GFX_MORAST_LEER         },
610     { EL_AMOEBA_DROP,                   GFX_TROPFEN             },
611     { EL_BOMB,                          GFX_BOMBE               },
612     { EL_MAGIC_WALL,                    GFX_MAGIC_WALL_OFF      },
613     { EL_MAGIC_WALL_ACTIVE,             GFX_MAGIC_WALL_EMPTY    },
614     { EL_MAGIC_WALL_EMPTYING,           GFX_MAGIC_WALL_EMPTY    },
615     { EL_MAGIC_WALL_FULL,               GFX_MAGIC_WALL_FULL     },
616     { EL_MAGIC_WALL_DEAD,               GFX_MAGIC_WALL_DEAD     },
617     { EL_ACID,                          GFX_SALZSAEURE          },
618     { EL_AMOEBA_DEAD,                   GFX_AMOEBE_TOT          },
619     { EL_AMOEBA_WET,                    GFX_AMOEBE_NASS         },
620     { EL_AMOEBA_DRY,                    GFX_AMOEBE_NORM         },
621     { EL_AMOEBA_FULL,                   GFX_AMOEBE_VOLL         },
622     { EL_BD_AMOEBA,                     GFX_AMOEBE_BD           },
623     { EL_AMOEBA_TO_DIAMOND,             GFX_AMOEBA2DIAM         },
624     { EL_AMOEBA_DRIPPING,               GFX_AMOEBE_NASS         },
625     { EL_NUT,                           GFX_KOKOSNUSS           },
626     { EL_GAMEOFLIFE,                    GFX_LIFE                },
627     { EL_BIOMAZE,                       GFX_LIFE_ASYNC          },
628     { EL_DYNAMITE_ACTIVE,               GFX_DYNAMIT             },
629     { EL_STONEBLOCK,                    GFX_BADEWANNE           },
630     { EL_ACIDPOOL_TOPLEFT,              GFX_BADEWANNE1          },
631     { EL_ACIDPOOL_TOPRIGHT,             GFX_BADEWANNE2          },
632     { EL_ACIDPOOL_BOTTOMLEFT,           GFX_BADEWANNE3          },
633     { EL_ACIDPOOL_BOTTOM,               GFX_BADEWANNE4          },
634     { EL_ACIDPOOL_BOTTOMRIGHT,          GFX_BADEWANNE5          },
635     { EL_ROBOT_WHEEL,                   GFX_ABLENK_AUS          },
636     { EL_ROBOT_WHEEL_ACTIVE,            GFX_ABLENK_EIN          },
637     { EL_KEY1,                          GFX_SCHLUESSEL1         },
638     { EL_KEY2,                          GFX_SCHLUESSEL2         },
639     { EL_KEY3,                          GFX_SCHLUESSEL3         },
640     { EL_KEY4,                          GFX_SCHLUESSEL4         },
641     { EL_GATE1,                         GFX_PFORTE1             },
642     { EL_GATE2,                         GFX_PFORTE2             },
643     { EL_GATE3,                         GFX_PFORTE3             },
644     { EL_GATE4,                         GFX_PFORTE4             },
645     { EL_GATE1_GRAY,                    GFX_PFORTE1X            },
646     { EL_GATE2_GRAY,                    GFX_PFORTE2X            },
647     { EL_GATE3_GRAY,                    GFX_PFORTE3X            },
648     { EL_GATE4_GRAY,                    GFX_PFORTE4X            },
649     { EL_DYNAMITE,                      GFX_DYNAMIT_AUS         },
650     { EL_PACMAN,                        GFX_PACMAN              },
651     { EL_PACMAN_RIGHT,                  GFX_PACMAN_RIGHT        },
652     { EL_PACMAN_UP,                     GFX_PACMAN_UP           },
653     { EL_PACMAN_LEFT,                   GFX_PACMAN_LEFT         },
654     { EL_PACMAN_DOWN,                   GFX_PACMAN_DOWN         },
655     { EL_INVISIBLE_WALL,                GFX_UNSICHTBAR          },
656     { EL_INVISIBLE_WALL_ACTIVE,         GFX_UNSICHTBAR_ON       },
657     { EL_WALL_EMERALD,                  GFX_ERZ_EDEL            },
658     { EL_WALL_DIAMOND,                  GFX_ERZ_DIAM            },
659     { EL_LAMP,                          GFX_BIRNE_AUS           },
660     { EL_LAMP_ACTIVE,                   GFX_BIRNE_EIN           },
661     { EL_TIME_ORB_FULL,                 GFX_ZEIT_VOLL           },
662     { EL_TIME_ORB_EMPTY,                GFX_ZEIT_LEER           },
663     { EL_WALL_GROWING,                  GFX_MAUER_LEBT          },
664     { EL_WALL_GROWING_X,                GFX_MAUER_X             },
665     { EL_WALL_GROWING_Y,                GFX_MAUER_Y             },
666     { EL_WALL_GROWING_XY,               GFX_MAUER_XY            },
667     { EL_BD_DIAMOND,                    GFX_EDELSTEIN_BD        },
668     { EL_EMERALD_YELLOW,                GFX_EDELSTEIN_GELB      },
669     { EL_EMERALD_RED,                   GFX_EDELSTEIN_ROT       },
670     { EL_EMERALD_PURPLE,                GFX_EDELSTEIN_LILA      },
671     { EL_WALL_BD_DIAMOND,               GFX_ERZ_EDEL_BD         },
672     { EL_WALL_EMERALD_YELLOW,           GFX_ERZ_EDEL_GELB       },
673     { EL_WALL_EMERALD_RED,              GFX_ERZ_EDEL_ROT        },
674     { EL_WALL_EMERALD_PURPLE,           GFX_ERZ_EDEL_LILA       },
675     { EL_DARK_YAMYAM,                   GFX_MAMPFER2            },
676     { EL_BD_MAGIC_WALL,                 GFX_MAGIC_WALL_BD_OFF   },
677     { EL_BD_MAGIC_WALL_ACTIVE,          GFX_MAGIC_WALL_BD_EMPTY },
678     { EL_BD_MAGIC_WALL_EMPTYING,        GFX_MAGIC_WALL_BD_EMPTY },
679     { EL_BD_MAGIC_WALL_FULL,            GFX_MAGIC_WALL_BD_FULL  },
680     { EL_BD_MAGIC_WALL_DEAD,            GFX_MAGIC_WALL_BD_DEAD  },
681     { EL_DYNABOMB_ACTIVE_1,             GFX_DYNABOMB            },
682     { EL_DYNABOMB_ACTIVE_2,             GFX_DYNABOMB            },
683     { EL_DYNABOMB_ACTIVE_3,             GFX_DYNABOMB            },
684     { EL_DYNABOMB_ACTIVE_4,             GFX_DYNABOMB            },
685     { EL_DYNABOMB_NR,                   GFX_DYNABOMB_NR         },
686     { EL_DYNABOMB_SZ,                   GFX_DYNABOMB_SZ         },
687     { EL_DYNABOMB_XL,                   GFX_DYNABOMB_XL         },
688     { EL_SOKOBAN_OBJECT,                GFX_SOKOBAN_OBJEKT      },
689     { EL_SOKOBAN_FIELD_EMPTY,           GFX_SOKOBAN_FELD_LEER   },
690     { EL_SOKOBAN_FIELD_FULL,            GFX_SOKOBAN_FELD_VOLL   },
691     { EL_MOLE,                          GFX_MOLE                },
692     { EL_PENGUIN,                       GFX_PINGUIN             },
693     { EL_PIG,                           GFX_SCHWEIN             },
694     { EL_DRAGON,                        GFX_DRACHE              },
695     { EL_SATELLITE,                     GFX_SONDE               },
696     { EL_ARROW_BLUE_LEFT,               GFX_PFEIL_LEFT          },
697     { EL_ARROW_BLUE_RIGHT,              GFX_PFEIL_RIGHT         },
698     { EL_ARROW_BLUE_UP,                 GFX_PFEIL_UP            },
699     { EL_ARROW_BLUE_DOWN,               GFX_PFEIL_DOWN          },
700     { EL_SPEED_PILL,                    GFX_SPEED_PILL          },
701     { EL_SP_TERMINAL_ACTIVE,            GFX_SP_TERMINAL         },
702     { EL_SP_BUGGY_BASE_ACTIVE,          GFX_SP_BUG_ACTIVE       },
703     { EL_SP_ZONK,                       GFX_SP_ZONK             },
704     { EL_INVISIBLE_STEELWALL,           GFX_INVISIBLE_STEEL     },
705     { EL_INVISIBLE_STEELWALL_ACTIVE,    GFX_INVISIBLE_STEEL_ON  },
706     { EL_BLACK_ORB,                     GFX_BLACK_ORB           },
707     { EL_EM_GATE1,                      GFX_EM_GATE_1           },
708     { EL_EM_GATE2,                      GFX_EM_GATE_2           },
709     { EL_EM_GATE3,                      GFX_EM_GATE_3           },
710     { EL_EM_GATE4,                      GFX_EM_GATE_4           },
711     { EL_EM_GATE1_GRAY,                 GFX_EM_GATE_1X          },
712     { EL_EM_GATE2_GRAY,                 GFX_EM_GATE_2X          },
713     { EL_EM_GATE3_GRAY,                 GFX_EM_GATE_3X          },
714     { EL_EM_GATE4_GRAY,                 GFX_EM_GATE_4X          },
715     { EL_EM_KEY1_FILE,                  GFX_EM_KEY_1            },
716     { EL_EM_KEY2_FILE,                  GFX_EM_KEY_2            },
717     { EL_EM_KEY3_FILE,                  GFX_EM_KEY_3            },
718     { EL_EM_KEY4_FILE,                  GFX_EM_KEY_4            },
719     { EL_EM_KEY1,                       GFX_EM_KEY_1            },
720     { EL_EM_KEY2,                       GFX_EM_KEY_2            },
721     { EL_EM_KEY3,                       GFX_EM_KEY_3            },
722     { EL_EM_KEY4,                       GFX_EM_KEY_4            },
723     { EL_PEARL,                         GFX_PEARL               },
724     { EL_CRYSTAL,                       GFX_CRYSTAL             },
725     { EL_WALL_PEARL,                    GFX_WALL_PEARL          },
726     { EL_WALL_CRYSTAL,                  GFX_WALL_CRYSTAL        },
727     { EL_DOOR_WHITE,                    GFX_DOOR_WHITE          },
728     { EL_DOOR_WHITE_GRAY,               GFX_DOOR_WHITE_GRAY     },
729     { EL_KEY_WHITE,                     GFX_KEY_WHITE           },
730     { EL_SHIELD_NORMAL,                 GFX_SHIELD_PASSIVE      },
731     { EL_SHIELD_DEADLY,                 GFX_SHIELD_ACTIVE       },
732     { EL_EXTRA_TIME,                    GFX_EXTRA_TIME          },
733     { EL_SWITCHGATE_OPEN,               GFX_SWITCHGATE_OPEN     },
734     { EL_SWITCHGATE_CLOSED,             GFX_SWITCHGATE_CLOSED   },
735     { EL_SWITCHGATE_SWITCH_UP,          GFX_SWITCHGATE_SWITCH_1 },
736     { EL_SWITCHGATE_SWITCH_DOWN,        GFX_SWITCHGATE_SWITCH_2 },
737     { EL_CONVEYOR_BELT1_LEFT,           GFX_BELT1_LEFT          },
738     { EL_CONVEYOR_BELT1_MIDDLE,         GFX_BELT1_MIDDLE        },
739     { EL_CONVEYOR_BELT1_RIGHT,          GFX_BELT1_RIGHT         },
740     { EL_CONVEYOR_BELT1_LEFT_ACTIVE,    GFX_BELT1_LEFT          },
741     { EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,  GFX_BELT1_MIDDLE        },
742     { EL_CONVEYOR_BELT1_RIGHT_ACTIVE,   GFX_BELT1_RIGHT         },
743     { EL_CONVEYOR_BELT1_SWITCH_LEFT,    GFX_BELT1_SWITCH_LEFT   },
744     { EL_CONVEYOR_BELT1_SWITCH_MIDDLE,  GFX_BELT1_SWITCH_MIDDLE },
745     { EL_CONVEYOR_BELT1_SWITCH_RIGHT,   GFX_BELT1_SWITCH_RIGHT  },
746     { EL_CONVEYOR_BELT2_LEFT,           GFX_BELT2_LEFT          },
747     { EL_CONVEYOR_BELT2_MIDDLE,         GFX_BELT2_MIDDLE        },
748     { EL_CONVEYOR_BELT2_RIGHT,          GFX_BELT2_RIGHT         },
749     { EL_CONVEYOR_BELT2_LEFT_ACTIVE,    GFX_BELT2_LEFT          },
750     { EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,  GFX_BELT2_MIDDLE        },
751     { EL_CONVEYOR_BELT2_RIGHT_ACTIVE,   GFX_BELT2_RIGHT         },
752     { EL_CONVEYOR_BELT2_SWITCH_LEFT,    GFX_BELT2_SWITCH_LEFT   },
753     { EL_CONVEYOR_BELT2_SWITCH_MIDDLE,  GFX_BELT2_SWITCH_MIDDLE },
754     { EL_CONVEYOR_BELT2_SWITCH_RIGHT,   GFX_BELT2_SWITCH_RIGHT  },
755     { EL_CONVEYOR_BELT3_LEFT,           GFX_BELT3_LEFT          },
756     { EL_CONVEYOR_BELT3_MIDDLE,         GFX_BELT3_MIDDLE        },
757     { EL_CONVEYOR_BELT3_RIGHT,          GFX_BELT3_RIGHT         },
758     { EL_CONVEYOR_BELT3_LEFT_ACTIVE,    GFX_BELT3_LEFT          },
759     { EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,  GFX_BELT3_MIDDLE        },
760     { EL_CONVEYOR_BELT3_RIGHT_ACTIVE,   GFX_BELT3_RIGHT         },
761     { EL_CONVEYOR_BELT3_SWITCH_LEFT,    GFX_BELT3_SWITCH_LEFT   },
762     { EL_CONVEYOR_BELT3_SWITCH_MIDDLE,  GFX_BELT3_SWITCH_MIDDLE },
763     { EL_CONVEYOR_BELT3_SWITCH_RIGHT,   GFX_BELT3_SWITCH_RIGHT  },
764     { EL_CONVEYOR_BELT4_LEFT,           GFX_BELT4_LEFT          },
765     { EL_CONVEYOR_BELT4_MIDDLE,         GFX_BELT4_MIDDLE        },
766     { EL_CONVEYOR_BELT4_RIGHT,          GFX_BELT4_RIGHT         },
767     { EL_CONVEYOR_BELT4_LEFT_ACTIVE,    GFX_BELT4_LEFT          },
768     { EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,  GFX_BELT4_MIDDLE        },
769     { EL_CONVEYOR_BELT4_RIGHT_ACTIVE,   GFX_BELT4_RIGHT         },
770     { EL_CONVEYOR_BELT4_SWITCH_LEFT,    GFX_BELT4_SWITCH_LEFT   },
771     { EL_CONVEYOR_BELT4_SWITCH_MIDDLE,  GFX_BELT4_SWITCH_MIDDLE },
772     { EL_CONVEYOR_BELT4_SWITCH_RIGHT,   GFX_BELT4_SWITCH_RIGHT  },
773     { EL_LANDMINE,                      GFX_LANDMINE            },
774     { EL_ENVELOPE,                      GFX_ENVELOPE            },
775     { EL_LIGHT_SWITCH,                  GFX_LIGHT_SWITCH_OFF    },
776     { EL_LIGHT_SWITCH_ACTIVE,           GFX_LIGHT_SWITCH_ON     },
777     { EL_SIGN_EXCLAMATION,              GFX_SIGN_EXCLAMATION    },
778     { EL_SIGN_RADIOACTIVITY,            GFX_SIGN_RADIOACTIVITY  },
779     { EL_SIGN_STOP,                     GFX_SIGN_STOP           },
780     { EL_SIGN_WHEELCHAIR,               GFX_SIGN_WHEELCHAIR     },
781     { EL_SIGN_PARKING,                  GFX_SIGN_PARKING        },
782     { EL_SIGN_ONEWAY,                   GFX_SIGN_ONEWAY         },
783     { EL_SIGN_HEART,                    GFX_SIGN_HEART          },
784     { EL_SIGN_TRIANGLE,                 GFX_SIGN_TRIANGLE       },
785     { EL_SIGN_ROUND,                    GFX_SIGN_ROUND          },
786     { EL_SIGN_EXIT,                     GFX_SIGN_EXIT           },
787     { EL_SIGN_YINYANG,                  GFX_SIGN_YINYANG        },
788     { EL_SIGN_OTHER,                    GFX_SIGN_OTHER          },
789     { EL_MOLE_LEFT,                     GFX_MOLE_LEFT           },
790     { EL_MOLE_RIGHT,                    GFX_MOLE_RIGHT          },
791     { EL_MOLE_UP,                       GFX_MOLE_UP             },
792     { EL_MOLE_DOWN,                     GFX_MOLE_DOWN           },
793     { EL_STEELWALL_SLANTED,             GFX_STEEL_SLANTED       },
794     { EL_INVISIBLE_SAND,                GFX_SAND_INVISIBLE      },
795     { EL_INVISIBLE_SAND_ACTIVE,         GFX_SAND_INVISIBLE_ON   },
796     { EL_DX_UNKNOWN_15,                 GFX_DX_UNKNOWN_15       },
797     { EL_DX_UNKNOWN_42,                 GFX_DX_UNKNOWN_42       },
798     { EL_TIMEGATE_OPEN,                 GFX_TIMEGATE_OPEN       },
799     { EL_TIMEGATE_CLOSED,               GFX_TIMEGATE_CLOSED     },
800     { EL_TIMEGATE_SWITCH_ACTIVE,        GFX_TIMEGATE_SWITCH     },
801     { EL_TIMEGATE_SWITCH,               GFX_TIMEGATE_SWITCH     },
802     { EL_BALLOON,                       GFX_BALLOON             },
803     { EL_BALLOON_SEND_LEFT,             GFX_BALLOON_SEND_LEFT   },
804     { EL_BALLOON_SEND_RIGHT,            GFX_BALLOON_SEND_RIGHT  },
805     { EL_BALLOON_SEND_UP,               GFX_BALLOON_SEND_UP     },
806     { EL_BALLOON_SEND_DOWN,             GFX_BALLOON_SEND_DOWN   },
807     { EL_BALLOON_SEND_ANY_DIRECTION,    GFX_BALLOON_SEND_ANY    },
808     { EL_EMC_STEELWALL1,                GFX_EMC_STEEL_WALL_1    },
809     { EL_EMC_STEELWALL2,                GFX_EMC_STEEL_WALL_2    },
810     { EL_EMC_STEELWALL3,                GFX_EMC_STEEL_WALL_3    },
811     { EL_EMC_STEELWALL4,                GFX_EMC_STEEL_WALL_4    },
812     { EL_EMC_WALL_PILLAR_UPPER,         GFX_EMC_WALL_1          },
813     { EL_EMC_WALL_PILLAR_MIDDLE,        GFX_EMC_WALL_2          },
814     { EL_EMC_WALL_PILLAR_LOWER,         GFX_EMC_WALL_3          },
815     { EL_EMC_WALL4,                     GFX_EMC_WALL_4          },
816     { EL_EMC_WALL5,                     GFX_EMC_WALL_5          },
817     { EL_EMC_WALL6,                     GFX_EMC_WALL_6          },
818     { EL_EMC_WALL7,                     GFX_EMC_WALL_7          },
819     { EL_EMC_WALL8,                     GFX_EMC_WALL_8          },
820     { EL_TUBE_ALL,                      GFX_TUBE_CROSS          },
821     { EL_TUBE_VERTICAL,                 GFX_TUBE_VERTICAL       },
822     { EL_TUBE_HORIZONTAL,               GFX_TUBE_HORIZONTAL     },
823     { EL_TUBE_VERTICAL_LEFT,            GFX_TUBE_VERT_LEFT      },
824     { EL_TUBE_VERTICAL_RIGHT,           GFX_TUBE_VERT_RIGHT     },
825     { EL_TUBE_HORIZONTAL_UP,            GFX_TUBE_HORIZ_UP       },
826     { EL_TUBE_HORIZONTAL_DOWN,          GFX_TUBE_HORIZ_DOWN     },
827     { EL_TUBE_LEFT_UP,                  GFX_TUBE_LEFT_UP        },
828     { EL_TUBE_LEFT_DOWN,                GFX_TUBE_LEFT_DOWN      },
829     { EL_TUBE_RIGHT_UP,                 GFX_TUBE_RIGHT_UP       },
830     { EL_TUBE_RIGHT_DOWN,               GFX_TUBE_RIGHT_DOWN     },
831     { EL_SPRING,                        GFX_SPRING              },
832     { EL_SPRING_MOVING,                 GFX_SPRING              },
833     { EL_TRAP,                          GFX_TRAP_INACTIVE       },
834     { EL_TRAP_ACTIVE,                   GFX_TRAP_ACTIVE         },
835     { EL_BD_WALL,                       GFX_BD_WALL             },
836     { EL_BD_ROCK,                       GFX_BD_ROCK             },
837     { EL_DX_SUPABOMB,                   GFX_DX_SUPABOMB         },
838     { EL_SP_MURPHY_CLONE,               GFX_SP_MURPHY_CLONE     },
839     { -1,                               -1                      }
840   };
841
842   static struct
843   {
844     int element;
845     int graphic_left;
846     int graphic_right;
847     int graphic_up;
848     int graphic_down;
849   }
850   element_to_direction_graphic[] =
851   {
852     {
853       EL_PLAYER1,
854       IMG_PLAYER1_LEFT,         IMG_PLAYER1_RIGHT,
855       IMG_PLAYER1_UP,           IMG_PLAYER1_DOWN
856     },
857     {
858       EL_PLAYER2,
859       IMG_PLAYER2_LEFT,         IMG_PLAYER2_RIGHT,
860       IMG_PLAYER2_UP,           IMG_PLAYER2_DOWN
861     },
862     {
863       EL_PLAYER3,
864       IMG_PLAYER3_LEFT,         IMG_PLAYER3_RIGHT,
865       IMG_PLAYER3_UP,           IMG_PLAYER3_DOWN
866     },
867     {
868       EL_PLAYER4,
869       IMG_PLAYER4_LEFT,         IMG_PLAYER4_RIGHT,
870       IMG_PLAYER4_UP,           IMG_PLAYER4_DOWN
871     },
872     {
873       EL_SP_MURPHY,
874       IMG_SP_MURPHY_LEFT,       IMG_SP_MURPHY_RIGHT,
875       IMG_SP_MURPHY_UP,         IMG_SP_MURPHY_DOWN
876     },
877     {
878       EL_SP_SNIKSNAK,
879       IMG_SP_SNIKSNAK_LEFT,     IMG_SP_SNIKSNAK_RIGHT,
880       IMG_SP_SNIKSNAK_UP,       IMG_SP_SNIKSNAK_DOWN
881     },
882     {
883       EL_BUG,
884       IMG_BUG_LEFT,             IMG_BUG_RIGHT,
885       IMG_BUG_UP,               IMG_BUG_DOWN
886     },
887     {
888       EL_SPACESHIP,
889       IMG_SPACESHIP_LEFT,       IMG_SPACESHIP_RIGHT,
890       IMG_SPACESHIP_UP,         IMG_SPACESHIP_DOWN
891     },
892     {
893       EL_PACMAN,
894       IMG_PACMAN_LEFT,          IMG_PACMAN_RIGHT,
895       IMG_PACMAN_UP,            IMG_PACMAN_DOWN
896     },
897     {
898       EL_MOLE,
899       IMG_MOLE_LEFT,            IMG_MOLE_RIGHT,
900       IMG_MOLE_UP,              IMG_MOLE_DOWN
901     },
902     {
903       EL_PENGUIN,
904       IMG_PENGUIN_LEFT,         IMG_PENGUIN_RIGHT,
905       IMG_PENGUIN_UP,           IMG_PENGUIN_DOWN
906     },
907     {
908       EL_PIG,
909       IMG_PIG_LEFT,             IMG_PIG_RIGHT,
910       IMG_PIG_UP,               IMG_PIG_DOWN
911     },
912     {
913       EL_DRAGON,
914       IMG_DRAGON_LEFT,          IMG_DRAGON_RIGHT,
915       IMG_DRAGON_UP,            IMG_DRAGON_DOWN
916     },
917     {
918       -1,
919       -1,                       -1,
920       -1,                       -1
921     }
922   };
923
924   /* always start with reliable default values */
925   for(i=0; i<MAX_ELEMENTS; i++)
926   {
927     for(j=0; j<NUM_GFX_ACTIONS_MAPPED; j++)
928     {
929       element_info[i].graphic[j] = GFX_LEERRAUM;
930       element_info[i].has_direction_graphic[j] = FALSE;
931     }
932   }
933
934   for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
935     element_info[i].graphic[GFX_ACTION_DEFAULT] =
936       GFX_CHAR_START + (i - EL_CHAR_START);
937
938   for (i=EL_SP_START; i<=EL_SP_END; i++)
939   {
940     int nr_element = i - EL_SP_START;
941     int gfx_per_line = 8;
942     int nr_graphic =
943       (nr_element / gfx_per_line) * SP_PER_LINE +
944       (nr_element % gfx_per_line);
945
946     element_info[i].graphic[GFX_ACTION_DEFAULT] =
947       GFX_START_ROCKSSP + nr_graphic;
948   }
949
950   /* this overrides some of the above default settings (GFX_SP_ZONK etc.) */
951   i = 0;
952   while (element_to_graphic[i].element > -1)
953   {
954     int element = element_to_graphic[i].element;
955     int graphic = element_to_graphic[i].graphic;
956
957     element_info[element].graphic[GFX_ACTION_DEFAULT] = graphic;
958     i++;
959   }
960
961   /* this initializes special graphics for left/right/up/down directions */
962   i = 0;
963   while (element_to_direction_graphic[i].element > -1)
964   {
965     int element = element_to_direction_graphic[i].element;
966
967     element_info[element].direction_graphic[GFX_ACTION_DEFAULT][MV_BIT_LEFT] =
968       element_to_direction_graphic[i].graphic_left;
969     element_info[element].direction_graphic[GFX_ACTION_DEFAULT][MV_BIT_RIGHT] =
970       element_to_direction_graphic[i].graphic_right;
971     element_info[element].direction_graphic[GFX_ACTION_DEFAULT][MV_BIT_UP] =
972       element_to_direction_graphic[i].graphic_up;
973     element_info[element].direction_graphic[GFX_ACTION_DEFAULT][MV_BIT_DOWN] =
974       element_to_direction_graphic[i].graphic_down;
975
976     element_info[element].has_direction_graphic[GFX_ACTION_DEFAULT] = TRUE;
977     i++;
978   }
979 }
980
981 static void InitGraphicInfo()
982 {
983   int i;
984
985   image_files = getCurrentImageList();
986
987   for(i=0; i<MAX_GRAPHICS; i++)
988   {
989     /* always start with reliable default values */
990     graphic_info[i].bitmap = NULL;
991     graphic_info[i].src_x = 0;
992     graphic_info[i].src_y = 0;
993
994     getGraphicSource(i, &graphic_info[i].bitmap,
995                      &graphic_info[i].src_x, &graphic_info[i].src_y);
996   }
997
998   for(i=0; i<NUM_IMAGE_FILES; i++)
999   {
1000     int *parameter = image_files[i].parameter;
1001
1002     /* always start with reliable default values */
1003     new_graphic_info[i].bitmap = getBitmapFromImageID(i);
1004     new_graphic_info[i].src_x = parameter[GFX_ARG_XPOS] * TILEX;
1005     new_graphic_info[i].src_y = parameter[GFX_ARG_YPOS] * TILEY;
1006
1007     new_graphic_info[i].anim_frames = parameter[GFX_ARG_FRAMES];
1008
1009     new_graphic_info[i].anim_delay = parameter[GFX_ARG_DELAY];
1010     if (new_graphic_info[i].anim_delay == 0)    /* delay must be at least 1 */
1011       new_graphic_info[i].anim_delay = 1;
1012
1013     /* basically, animation can be either normal or reverse direction */
1014     if (parameter[GFX_ARG_REVERSE])
1015       new_graphic_info[i].anim_mode = ANIM_REVERSE;
1016     else
1017       new_graphic_info[i].anim_mode = ANIM_NORMAL;
1018
1019     /* additionally, animation can be either pingpong or pingpong2 layout */
1020     if (parameter[GFX_ARG_PINGPONG])
1021       new_graphic_info[i].anim_mode |= ANIM_PINGPONG;
1022     else if (parameter[GFX_ARG_PINGPONG2])
1023       new_graphic_info[i].anim_mode |= ANIM_PINGPONG2;
1024
1025     /* animation synchronized with global frame counter, not move position */
1026     new_graphic_info[i].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
1027
1028     new_graphic_info[i].anim_vertical = parameter[GFX_ARG_VERTICAL];
1029   }
1030
1031 #if 0
1032   printf("D> %d\n", image_files[GFX_BD_DIAMOND].parameter[GFX_ARG_NUM_FRAMES]);
1033   printf("W> %d\n", image_files[GFX_ROBOT_WHEEL].parameter[GFX_ARG_NUM_FRAMES]);
1034
1035   graphic_info[GFX_ABLENK].bitmap = getBitmapFromImageID(GFX_ROBOT_WHEEL);
1036   graphic_info[GFX_ABLENK].src_x = 0;
1037   graphic_info[GFX_ABLENK].src_y = 0;
1038
1039   graphic_info[GFX_ABLENK + 1].bitmap = getBitmapFromImageID(GFX_ROBOT_WHEEL);
1040   graphic_info[GFX_ABLENK + 2].bitmap = getBitmapFromImageID(GFX_ROBOT_WHEEL);
1041   graphic_info[GFX_ABLENK + 3].bitmap = getBitmapFromImageID(GFX_ROBOT_WHEEL);
1042   graphic_info[GFX_ABLENK + 1].src_x = 1 * TILEX;
1043   graphic_info[GFX_ABLENK + 2].src_x = 2 * TILEX;
1044   graphic_info[GFX_ABLENK + 3].src_x = 3 * TILEX;
1045   graphic_info[GFX_ABLENK + 1].src_y = 0;
1046   graphic_info[GFX_ABLENK + 2].src_y = 0;
1047   graphic_info[GFX_ABLENK + 3].src_y = 0;
1048 #endif
1049 }
1050
1051 static void InitSoundInfo()
1052 {
1053   sound_files = getCurrentSoundList();
1054
1055   /* initialize sound effect lookup table for element actions */
1056   InitGameSound();
1057 }
1058
1059 void InitElementProperties()
1060 {
1061   int i, j;
1062
1063   static int ep_amoebalive[] =
1064   {
1065     EL_AMOEBA_WET,
1066     EL_AMOEBA_DRY,
1067     EL_AMOEBA_FULL,
1068     EL_BD_AMOEBA
1069   };
1070   static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1071
1072   static int ep_amoeboid[] =
1073   {
1074     EL_AMOEBA_DEAD,
1075     EL_AMOEBA_WET,
1076     EL_AMOEBA_DRY,
1077     EL_AMOEBA_FULL,
1078     EL_BD_AMOEBA
1079   };
1080   static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1081
1082   static int ep_schluessel[] =
1083   {
1084     EL_KEY1,
1085     EL_KEY2,
1086     EL_KEY3,
1087     EL_KEY4,
1088     EL_EM_KEY1,
1089     EL_EM_KEY2,
1090     EL_EM_KEY3,
1091     EL_EM_KEY4
1092   };
1093   static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1094
1095   static int ep_pforte[] =
1096   {
1097     EL_GATE1,
1098     EL_GATE2,
1099     EL_GATE3,
1100     EL_GATE4,
1101     EL_GATE1_GRAY,
1102     EL_GATE2_GRAY,
1103     EL_GATE3_GRAY,
1104     EL_GATE4_GRAY,
1105     EL_EM_GATE1,
1106     EL_EM_GATE2,
1107     EL_EM_GATE3,
1108     EL_EM_GATE4,
1109     EL_EM_GATE1_GRAY,
1110     EL_EM_GATE2_GRAY,
1111     EL_EM_GATE3_GRAY,
1112     EL_EM_GATE4_GRAY,
1113     EL_SWITCHGATE_OPEN,
1114     EL_SWITCHGATE_OPENING,
1115     EL_SWITCHGATE_CLOSED,
1116     EL_SWITCHGATE_CLOSING,
1117     EL_TIMEGATE_OPEN,
1118     EL_TIMEGATE_OPENING,
1119     EL_TIMEGATE_CLOSED,
1120     EL_TIMEGATE_CLOSING,
1121     EL_TUBE_ALL,
1122     EL_TUBE_VERTICAL,
1123     EL_TUBE_HORIZONTAL,
1124     EL_TUBE_VERTICAL_LEFT,
1125     EL_TUBE_VERTICAL_RIGHT,
1126     EL_TUBE_HORIZONTAL_UP,
1127     EL_TUBE_HORIZONTAL_DOWN,
1128     EL_TUBE_LEFT_UP,
1129     EL_TUBE_LEFT_DOWN,
1130     EL_TUBE_RIGHT_UP,
1131     EL_TUBE_RIGHT_DOWN
1132   };
1133   static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1134
1135   static int ep_solid[] =
1136   {
1137     EL_STEELWALL,
1138     EL_WALL,
1139     EL_WALL_GROWING,
1140     EL_WALL_GROWING_X,
1141     EL_WALL_GROWING_Y,
1142     EL_WALL_GROWING_XY,
1143     EL_BD_WALL,
1144     EL_WALL_CRUMBLED,
1145     EL_EXIT_CLOSED,
1146     EL_EXIT_OPENING,
1147     EL_EXIT_OPEN,
1148     EL_AMOEBA_DEAD,
1149     EL_AMOEBA_WET,
1150     EL_AMOEBA_DRY,
1151     EL_AMOEBA_FULL,
1152     EL_BD_AMOEBA,
1153     EL_QUICKSAND_FULL,
1154     EL_QUICKSAND_EMPTY,
1155     EL_QUICKSAND_FILLING,
1156     EL_QUICKSAND_EMPTYING,
1157     EL_MAGIC_WALL,
1158     EL_MAGIC_WALL_ACTIVE,
1159     EL_MAGIC_WALL_EMPTYING,
1160     EL_MAGIC_WALL_FILLING,
1161     EL_MAGIC_WALL_FULL,
1162     EL_MAGIC_WALL_DEAD,
1163     EL_BD_MAGIC_WALL,
1164     EL_BD_MAGIC_WALL_ACTIVE,
1165     EL_BD_MAGIC_WALL_EMPTYING,
1166     EL_BD_MAGIC_WALL_FULL,
1167     EL_BD_MAGIC_WALL_FILLING,
1168     EL_BD_MAGIC_WALL_DEAD,
1169     EL_GAMEOFLIFE,
1170     EL_BIOMAZE,
1171     EL_ACIDPOOL_TOPLEFT,
1172     EL_ACIDPOOL_TOPRIGHT,
1173     EL_ACIDPOOL_BOTTOMLEFT,
1174     EL_ACIDPOOL_BOTTOM,
1175     EL_ACIDPOOL_BOTTOMRIGHT,
1176     EL_SP_CHIP_SINGLE,
1177     EL_SP_CHIP_LEFT,
1178     EL_SP_CHIP_RIGHT,
1179     EL_SP_CHIP_UPPER,
1180     EL_SP_CHIP_LOWER,
1181     EL_SP_HARD_GRAY,
1182     EL_SP_HARD_GREEN,
1183     EL_SP_HARD_BLUE,
1184     EL_SP_HARD_RED,
1185     EL_SP_HARD_YELLOW,
1186     EL_SP_HARD_BASE1,
1187     EL_SP_HARD_BASE2,
1188     EL_SP_HARD_BASE3,
1189     EL_SP_HARD_BASE4,
1190     EL_SP_HARD_BASE5,
1191     EL_SP_HARD_BASE6,
1192     EL_SP_TERMINAL,
1193     EL_SP_TERMINAL_ACTIVE,
1194     EL_SP_EXIT_CLOSED,
1195     EL_SP_EXIT_OPEN,
1196     EL_INVISIBLE_STEELWALL,
1197     EL_INVISIBLE_STEELWALL_ACTIVE,
1198     EL_INVISIBLE_WALL,
1199     EL_INVISIBLE_WALL_ACTIVE,
1200     EL_CONVEYOR_BELT1_SWITCH_LEFT,
1201     EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1202     EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1203     EL_CONVEYOR_BELT2_SWITCH_LEFT,
1204     EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1205     EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1206     EL_CONVEYOR_BELT3_SWITCH_LEFT,
1207     EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1208     EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1209     EL_CONVEYOR_BELT4_SWITCH_LEFT,
1210     EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1211     EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1212     EL_SWITCHGATE_SWITCH_UP,
1213     EL_SWITCHGATE_SWITCH_DOWN,
1214     EL_LIGHT_SWITCH,
1215     EL_LIGHT_SWITCH_ACTIVE,
1216     EL_TIMEGATE_SWITCH,
1217     EL_TIMEGATE_SWITCH_ACTIVE,
1218     EL_SIGN_EXCLAMATION,
1219     EL_SIGN_RADIOACTIVITY,
1220     EL_SIGN_STOP,
1221     EL_SIGN_WHEELCHAIR,
1222     EL_SIGN_PARKING,
1223     EL_SIGN_ONEWAY,
1224     EL_SIGN_HEART,
1225     EL_SIGN_TRIANGLE,
1226     EL_SIGN_ROUND,
1227     EL_SIGN_EXIT,
1228     EL_SIGN_YINYANG,
1229     EL_SIGN_OTHER,
1230     EL_STEELWALL_SLANTED,
1231     EL_EMC_STEELWALL1,
1232     EL_EMC_STEELWALL2,
1233     EL_EMC_STEELWALL3,
1234     EL_EMC_STEELWALL4,
1235     EL_EMC_WALL_PILLAR_UPPER,
1236     EL_EMC_WALL_PILLAR_MIDDLE,
1237     EL_EMC_WALL_PILLAR_LOWER,
1238     EL_EMC_WALL4,
1239     EL_EMC_WALL5,
1240     EL_EMC_WALL6,
1241     EL_EMC_WALL7,
1242     EL_EMC_WALL8,
1243     EL_CRYSTAL,
1244     EL_WALL_PEARL,
1245     EL_WALL_CRYSTAL,
1246     EL_GATE1,
1247     EL_GATE2,
1248     EL_GATE3,
1249     EL_GATE4,
1250     EL_GATE1_GRAY,
1251     EL_GATE2_GRAY,
1252     EL_GATE3_GRAY,
1253     EL_GATE4_GRAY,
1254     EL_EM_GATE1,
1255     EL_EM_GATE2,
1256     EL_EM_GATE3,
1257     EL_EM_GATE4,
1258     EL_EM_GATE1_GRAY,
1259     EL_EM_GATE2_GRAY,
1260     EL_EM_GATE3_GRAY,
1261     EL_EM_GATE4_GRAY,
1262     EL_SWITCHGATE_OPEN,
1263     EL_SWITCHGATE_OPENING,
1264     EL_SWITCHGATE_CLOSED,
1265     EL_SWITCHGATE_CLOSING,
1266     EL_TIMEGATE_OPEN,
1267     EL_TIMEGATE_OPENING,
1268     EL_TIMEGATE_CLOSED,
1269     EL_TIMEGATE_CLOSING,
1270     EL_TUBE_ALL,
1271     EL_TUBE_VERTICAL,
1272     EL_TUBE_HORIZONTAL,
1273     EL_TUBE_VERTICAL_LEFT,
1274     EL_TUBE_VERTICAL_RIGHT,
1275     EL_TUBE_HORIZONTAL_UP,
1276     EL_TUBE_HORIZONTAL_DOWN,
1277     EL_TUBE_LEFT_UP,
1278     EL_TUBE_LEFT_DOWN,
1279     EL_TUBE_RIGHT_UP,
1280     EL_TUBE_RIGHT_DOWN
1281   };
1282   static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1283
1284   static int ep_massive[] =
1285   {
1286     EL_STEELWALL,
1287     EL_ACID,
1288     EL_ACIDPOOL_TOPLEFT,
1289     EL_ACIDPOOL_TOPRIGHT,
1290     EL_ACIDPOOL_BOTTOMLEFT,
1291     EL_ACIDPOOL_BOTTOM,
1292     EL_ACIDPOOL_BOTTOMRIGHT,
1293     EL_SP_HARD_GRAY,
1294     EL_SP_HARD_GREEN,
1295     EL_SP_HARD_BLUE,
1296     EL_SP_HARD_RED,
1297     EL_SP_HARD_YELLOW,
1298     EL_SP_HARD_BASE1,
1299     EL_SP_HARD_BASE2,
1300     EL_SP_HARD_BASE3,
1301     EL_SP_HARD_BASE4,
1302     EL_SP_HARD_BASE5,
1303     EL_SP_HARD_BASE6,
1304     EL_INVISIBLE_STEELWALL,
1305     EL_INVISIBLE_STEELWALL_ACTIVE,
1306     EL_CONVEYOR_BELT1_SWITCH_LEFT,
1307     EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1308     EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1309     EL_CONVEYOR_BELT2_SWITCH_LEFT,
1310     EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1311     EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1312     EL_CONVEYOR_BELT3_SWITCH_LEFT,
1313     EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1314     EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1315     EL_CONVEYOR_BELT4_SWITCH_LEFT,
1316     EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1317     EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1318     EL_LIGHT_SWITCH,
1319     EL_LIGHT_SWITCH_ACTIVE,
1320     EL_SIGN_EXCLAMATION,
1321     EL_SIGN_RADIOACTIVITY,
1322     EL_SIGN_STOP,
1323     EL_SIGN_WHEELCHAIR,
1324     EL_SIGN_PARKING,
1325     EL_SIGN_ONEWAY,
1326     EL_SIGN_HEART,
1327     EL_SIGN_TRIANGLE,
1328     EL_SIGN_ROUND,
1329     EL_SIGN_EXIT,
1330     EL_SIGN_YINYANG,
1331     EL_SIGN_OTHER,
1332     EL_STEELWALL_SLANTED,
1333     EL_EMC_STEELWALL1,
1334     EL_EMC_STEELWALL2,
1335     EL_EMC_STEELWALL3,
1336     EL_EMC_STEELWALL4,
1337     EL_CRYSTAL,
1338     EL_GATE1,
1339     EL_GATE2,
1340     EL_GATE3,
1341     EL_GATE4,
1342     EL_GATE1_GRAY,
1343     EL_GATE2_GRAY,
1344     EL_GATE3_GRAY,
1345     EL_GATE4_GRAY,
1346     EL_EM_GATE1,
1347     EL_EM_GATE2,
1348     EL_EM_GATE3,
1349     EL_EM_GATE4,
1350     EL_EM_GATE1_GRAY,
1351     EL_EM_GATE2_GRAY,
1352     EL_EM_GATE3_GRAY,
1353     EL_EM_GATE4_GRAY,
1354     EL_SWITCHGATE_OPEN,
1355     EL_SWITCHGATE_OPENING,
1356     EL_SWITCHGATE_CLOSED,
1357     EL_SWITCHGATE_CLOSING,
1358     EL_TIMEGATE_OPEN,
1359     EL_TIMEGATE_OPENING,
1360     EL_TIMEGATE_CLOSED,
1361     EL_TIMEGATE_CLOSING,
1362     EL_TUBE_ALL,
1363     EL_TUBE_VERTICAL,
1364     EL_TUBE_HORIZONTAL,
1365     EL_TUBE_VERTICAL_LEFT,
1366     EL_TUBE_VERTICAL_RIGHT,
1367     EL_TUBE_HORIZONTAL_UP,
1368     EL_TUBE_HORIZONTAL_DOWN,
1369     EL_TUBE_LEFT_UP,
1370     EL_TUBE_LEFT_DOWN,
1371     EL_TUBE_RIGHT_UP,
1372     EL_TUBE_RIGHT_DOWN
1373   };
1374   static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1375
1376   static int ep_slippery[] =
1377   {
1378     EL_WALL_CRUMBLED,
1379     EL_BD_WALL,
1380     EL_ROCK,
1381     EL_BD_ROCK,
1382     EL_EMERALD,
1383     EL_BD_DIAMOND,
1384     EL_EMERALD_YELLOW,
1385     EL_EMERALD_RED,
1386     EL_EMERALD_PURPLE,
1387     EL_DIAMOND,
1388     EL_BOMB,
1389     EL_NUT,
1390     EL_ROBOT_WHEEL_ACTIVE,
1391     EL_ROBOT_WHEEL,
1392     EL_TIME_ORB_FULL,
1393     EL_TIME_ORB_EMPTY,
1394     EL_LAMP_ACTIVE,
1395     EL_LAMP,
1396     EL_ACIDPOOL_TOPLEFT,
1397     EL_ACIDPOOL_TOPRIGHT,
1398     EL_SATELLITE,
1399     EL_SP_ZONK,
1400     EL_SP_INFOTRON,
1401     EL_SP_CHIP_SINGLE,
1402     EL_SP_CHIP_LEFT,
1403     EL_SP_CHIP_RIGHT,
1404     EL_SP_CHIP_UPPER,
1405     EL_SP_CHIP_LOWER,
1406     EL_SPEED_PILL,
1407     EL_STEELWALL_SLANTED,
1408     EL_PEARL,
1409     EL_CRYSTAL
1410   };
1411   static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1412
1413   static int ep_enemy[] =
1414   {
1415     EL_BUG,
1416     EL_SPACESHIP,
1417     EL_BD_BUTTERFLY,
1418     EL_BD_FIREFLY,
1419     EL_YAMYAM,
1420     EL_DARK_YAMYAM,
1421     EL_ROBOT,
1422     EL_PACMAN,
1423     EL_SP_SNIKSNAK,
1424     EL_SP_ELECTRON
1425   };
1426   static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1427
1428   static int ep_mauer[] =
1429   {
1430     EL_STEELWALL,
1431     EL_GATE1,
1432     EL_GATE2,
1433     EL_GATE3,
1434     EL_GATE4,
1435     EL_GATE1_GRAY,
1436     EL_GATE2_GRAY,
1437     EL_GATE3_GRAY,
1438     EL_GATE4_GRAY,
1439     EL_EM_GATE1,
1440     EL_EM_GATE2,
1441     EL_EM_GATE3,
1442     EL_EM_GATE4,
1443     EL_EM_GATE1_GRAY,
1444     EL_EM_GATE2_GRAY,
1445     EL_EM_GATE3_GRAY,
1446     EL_EM_GATE4_GRAY,
1447     EL_EXIT_CLOSED,
1448     EL_EXIT_OPENING,
1449     EL_EXIT_OPEN,
1450     EL_WALL,
1451     EL_WALL_CRUMBLED,
1452     EL_WALL_GROWING,
1453     EL_WALL_GROWING_X,
1454     EL_WALL_GROWING_Y,
1455     EL_WALL_GROWING_XY,
1456     EL_WALL_GROWING_ACTIVE,
1457     EL_BD_WALL,
1458     EL_SP_CHIP_SINGLE,
1459     EL_SP_CHIP_LEFT,
1460     EL_SP_CHIP_RIGHT,
1461     EL_SP_CHIP_UPPER,
1462     EL_SP_CHIP_LOWER,
1463     EL_SP_HARD_GRAY,
1464     EL_SP_HARD_GREEN,
1465     EL_SP_HARD_BLUE,
1466     EL_SP_HARD_RED,
1467     EL_SP_HARD_YELLOW,
1468     EL_SP_HARD_BASE1,
1469     EL_SP_HARD_BASE2,
1470     EL_SP_HARD_BASE3,
1471     EL_SP_HARD_BASE4,
1472     EL_SP_HARD_BASE5,
1473     EL_SP_HARD_BASE6,
1474     EL_SP_TERMINAL,
1475     EL_SP_TERMINAL_ACTIVE,
1476     EL_SP_EXIT_CLOSED,
1477     EL_SP_EXIT_OPEN,
1478     EL_INVISIBLE_STEELWALL,
1479     EL_INVISIBLE_STEELWALL_ACTIVE,
1480     EL_INVISIBLE_WALL,
1481     EL_INVISIBLE_WALL_ACTIVE,
1482     EL_STEELWALL_SLANTED,
1483     EL_EMC_STEELWALL1,
1484     EL_EMC_STEELWALL2,
1485     EL_EMC_STEELWALL3,
1486     EL_EMC_STEELWALL4,
1487     EL_EMC_WALL_PILLAR_UPPER,
1488     EL_EMC_WALL_PILLAR_MIDDLE,
1489     EL_EMC_WALL_PILLAR_LOWER,
1490     EL_EMC_WALL4,
1491     EL_EMC_WALL5,
1492     EL_EMC_WALL6,
1493     EL_EMC_WALL7,
1494     EL_EMC_WALL8
1495   };
1496   static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1497
1498   static int ep_can_fall[] =
1499   {
1500     EL_ROCK,
1501     EL_BD_ROCK,
1502     EL_EMERALD,
1503     EL_BD_DIAMOND,
1504     EL_EMERALD_YELLOW,
1505     EL_EMERALD_RED,
1506     EL_EMERALD_PURPLE,
1507     EL_DIAMOND,
1508     EL_BOMB,
1509     EL_NUT,
1510     EL_AMOEBA_DROP,
1511     EL_QUICKSAND_FULL,
1512     EL_MAGIC_WALL_FULL,
1513     EL_BD_MAGIC_WALL_FULL,
1514     EL_TIME_ORB_FULL,
1515     EL_TIME_ORB_EMPTY,
1516     EL_SP_ZONK,
1517     EL_SP_INFOTRON,
1518     EL_SP_DISK_ORANGE,
1519     EL_PEARL,
1520     EL_CRYSTAL,
1521     EL_SPRING,
1522     EL_DX_SUPABOMB
1523   };
1524   static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1525
1526   static int ep_can_smash[] =
1527   {
1528     EL_ROCK,
1529     EL_BD_ROCK,
1530     EL_EMERALD,
1531     EL_BD_DIAMOND,
1532     EL_EMERALD_YELLOW,
1533     EL_EMERALD_RED,
1534     EL_EMERALD_PURPLE,
1535     EL_DIAMOND,
1536     EL_KEY1,
1537     EL_KEY2,
1538     EL_KEY3,
1539     EL_KEY4,
1540     EL_EM_KEY1,
1541     EL_EM_KEY2,
1542     EL_EM_KEY3,
1543     EL_EM_KEY4,
1544     EL_BOMB,
1545     EL_NUT,
1546     EL_AMOEBA_DROP,
1547     EL_TIME_ORB_FULL,
1548     EL_TIME_ORB_EMPTY,
1549     EL_SP_ZONK,
1550     EL_SP_INFOTRON,
1551     EL_SP_DISK_ORANGE,
1552     EL_PEARL,
1553     EL_CRYSTAL,
1554     EL_SPRING,
1555     EL_DX_SUPABOMB
1556   };
1557   static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1558
1559   static int ep_can_change[] =
1560   {
1561     EL_ROCK,
1562     EL_BD_ROCK,
1563     EL_EMERALD,
1564     EL_BD_DIAMOND,
1565     EL_EMERALD_YELLOW,
1566     EL_EMERALD_RED,
1567     EL_EMERALD_PURPLE,
1568     EL_DIAMOND
1569   };
1570   static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1571
1572   static int ep_can_move[] =
1573   {
1574     EL_BUG,
1575     EL_SPACESHIP,
1576     EL_BD_BUTTERFLY,
1577     EL_BD_FIREFLY,
1578     EL_YAMYAM,
1579     EL_DARK_YAMYAM,
1580     EL_ROBOT,
1581     EL_PACMAN,
1582     EL_MOLE,
1583     EL_PENGUIN,
1584     EL_PIG,
1585     EL_DRAGON,
1586     EL_SATELLITE,
1587     EL_SP_SNIKSNAK,
1588     EL_SP_ELECTRON,
1589     EL_BALLOON,
1590     EL_SPRING_MOVING
1591   };
1592   static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1593
1594   static int ep_could_move[] =
1595   {
1596     EL_BUG_RIGHT,
1597     EL_BUG_UP,
1598     EL_BUG_LEFT,
1599     EL_BUG_DOWN,
1600     EL_SPACESHIP_RIGHT,
1601     EL_SPACESHIP_UP,
1602     EL_SPACESHIP_LEFT,
1603     EL_SPACESHIP_DOWN,
1604     EL_BD_BUTTERFLY_RIGHT,
1605     EL_BD_BUTTERFLY_UP,
1606     EL_BD_BUTTERFLY_LEFT,
1607     EL_BD_BUTTERFLY_DOWN,
1608     EL_BD_FIREFLY_RIGHT,
1609     EL_BD_FIREFLY_UP,
1610     EL_BD_FIREFLY_LEFT,
1611     EL_BD_FIREFLY_DOWN,
1612     EL_PACMAN_RIGHT,
1613     EL_PACMAN_UP,
1614     EL_PACMAN_LEFT,
1615     EL_PACMAN_DOWN
1616   };
1617   static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1618
1619   static int ep_dont_touch[] =
1620   {
1621     EL_BUG,
1622     EL_SPACESHIP,
1623     EL_BD_BUTTERFLY,
1624     EL_BD_FIREFLY
1625   };
1626   static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1627
1628   static int ep_dont_go_to[] =
1629   {
1630     EL_BUG,
1631     EL_SPACESHIP,
1632     EL_BD_BUTTERFLY,
1633     EL_BD_FIREFLY,
1634     EL_YAMYAM,
1635     EL_DARK_YAMYAM,
1636     EL_ROBOT,
1637     EL_PACMAN,
1638     EL_AMOEBA_DROP,
1639     EL_ACID,
1640     EL_SP_SNIKSNAK,
1641     EL_SP_ELECTRON,
1642     EL_SP_BUGGY_BASE_ACTIVE,
1643     EL_TRAP_ACTIVE,
1644     EL_LANDMINE
1645   };
1646   static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1647
1648   static int ep_mampf2[] =
1649   {
1650     EL_SAND,
1651     EL_BUG,
1652     EL_SPACESHIP,
1653     EL_BD_BUTTERFLY,
1654     EL_BD_FIREFLY,
1655     EL_YAMYAM,
1656     EL_ROBOT,
1657     EL_PACMAN,
1658     EL_AMOEBA_DROP,
1659     EL_AMOEBA_DEAD,
1660     EL_AMOEBA_WET,
1661     EL_AMOEBA_DRY,
1662     EL_AMOEBA_FULL,
1663     EL_BD_AMOEBA,
1664     EL_EMERALD,
1665     EL_BD_DIAMOND,
1666     EL_EMERALD_YELLOW,
1667     EL_EMERALD_RED,
1668     EL_EMERALD_PURPLE,
1669     EL_DIAMOND,
1670     EL_PEARL,
1671     EL_CRYSTAL
1672   };
1673   static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1674
1675   static int ep_bd_element[] =
1676   {
1677     EL_EMPTY,
1678     EL_SAND,
1679     EL_WALL_CRUMBLED,
1680     EL_BD_WALL,
1681     EL_ROCK,
1682     EL_BD_ROCK,
1683     EL_BD_DIAMOND,
1684     EL_BD_MAGIC_WALL,
1685     EL_EXIT_CLOSED,
1686     EL_EXIT_OPEN,
1687     EL_STEELWALL,
1688     EL_PLAYER,
1689     EL_BD_FIREFLY,
1690     EL_BD_FIREFLY_1,
1691     EL_BD_FIREFLY_2,
1692     EL_BD_FIREFLY_3,
1693     EL_BD_FIREFLY_4,
1694     EL_BD_BUTTERFLY,
1695     EL_BD_BUTTERFLY_1,
1696     EL_BD_BUTTERFLY_2,
1697     EL_BD_BUTTERFLY_3,
1698     EL_BD_BUTTERFLY_4,
1699     EL_BD_AMOEBA,
1700     EL_CHAR_QUESTION
1701   };
1702   static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1703
1704   static int ep_sb_element[] =
1705   {
1706     EL_EMPTY,
1707     EL_STEELWALL,
1708     EL_SOKOBAN_OBJECT,
1709     EL_SOKOBAN_FIELD_EMPTY,
1710     EL_SOKOBAN_FIELD_FULL,
1711     EL_PLAYER,
1712     EL_INVISIBLE_STEELWALL
1713   };
1714   static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1715
1716   static int ep_gem[] =
1717   {
1718     EL_EMERALD,
1719     EL_BD_DIAMOND,
1720     EL_EMERALD_YELLOW,
1721     EL_EMERALD_RED,
1722     EL_EMERALD_PURPLE,
1723     EL_DIAMOND
1724   };
1725   static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1726
1727   static int ep_inactive[] =
1728   {
1729     EL_EMPTY,
1730     EL_SAND,
1731     EL_WALL,
1732     EL_BD_WALL,
1733     EL_WALL_CRUMBLED,
1734     EL_STEELWALL,
1735     EL_AMOEBA_DEAD,
1736     EL_QUICKSAND_EMPTY,
1737     EL_STONEBLOCK,
1738     EL_ROBOT_WHEEL,
1739     EL_KEY1,
1740     EL_KEY2,
1741     EL_KEY3,
1742     EL_KEY4,
1743     EL_EM_KEY1,
1744     EL_EM_KEY2,
1745     EL_EM_KEY3,
1746     EL_EM_KEY4,
1747     EL_GATE1,
1748     EL_GATE2,
1749     EL_GATE3,
1750     EL_GATE4,
1751     EL_GATE1_GRAY,
1752     EL_GATE2_GRAY,
1753     EL_GATE3_GRAY,
1754     EL_GATE4_GRAY,
1755     EL_EM_GATE1,
1756     EL_EM_GATE2,
1757     EL_EM_GATE3,
1758     EL_EM_GATE4,
1759     EL_EM_GATE1_GRAY,
1760     EL_EM_GATE2_GRAY,
1761     EL_EM_GATE3_GRAY,
1762     EL_EM_GATE4_GRAY,
1763     EL_DYNAMITE,
1764     EL_INVISIBLE_STEELWALL,
1765     EL_INVISIBLE_WALL,
1766     EL_INVISIBLE_SAND,
1767     EL_LAMP,
1768     EL_LAMP_ACTIVE,
1769     EL_WALL_EMERALD,
1770     EL_WALL_DIAMOND,
1771     EL_WALL_BD_DIAMOND,
1772     EL_WALL_EMERALD_YELLOW,
1773     EL_DYNABOMB_NR,
1774     EL_DYNABOMB_SZ,
1775     EL_DYNABOMB_XL,
1776     EL_SOKOBAN_OBJECT,
1777     EL_SOKOBAN_FIELD_EMPTY,
1778     EL_SOKOBAN_FIELD_FULL,
1779     EL_WALL_EMERALD_RED,
1780     EL_WALL_EMERALD_PURPLE,
1781     EL_ACIDPOOL_TOPLEFT,
1782     EL_ACIDPOOL_TOPRIGHT,
1783     EL_ACIDPOOL_BOTTOMLEFT,
1784     EL_ACIDPOOL_BOTTOM,
1785     EL_ACIDPOOL_BOTTOMRIGHT,
1786     EL_MAGIC_WALL,
1787     EL_MAGIC_WALL_DEAD,
1788     EL_BD_MAGIC_WALL,
1789     EL_BD_MAGIC_WALL_DEAD,
1790     EL_AMOEBA_TO_DIAMOND,
1791     EL_BLOCKED,
1792     EL_SP_EMPTY,
1793     EL_SP_BASE,
1794     EL_SP_PORT1_RIGHT,
1795     EL_SP_PORT1_DOWN,
1796     EL_SP_PORT1_LEFT,
1797     EL_SP_PORT1_UP,
1798     EL_SP_PORT2_RIGHT,
1799     EL_SP_PORT2_DOWN,
1800     EL_SP_PORT2_LEFT,
1801     EL_SP_PORT2_UP,
1802     EL_SP_PORT_X,
1803     EL_SP_PORT_Y,
1804     EL_SP_PORT_XY,
1805     EL_SP_DISK_RED,
1806     EL_SP_DISK_YELLOW,
1807     EL_SP_CHIP_SINGLE,
1808     EL_SP_CHIP_LEFT,
1809     EL_SP_CHIP_RIGHT,
1810     EL_SP_CHIP_UPPER,
1811     EL_SP_CHIP_LOWER,
1812     EL_SP_HARD_GRAY,
1813     EL_SP_HARD_GREEN,
1814     EL_SP_HARD_BLUE,
1815     EL_SP_HARD_RED,
1816     EL_SP_HARD_YELLOW,
1817     EL_SP_HARD_BASE1,
1818     EL_SP_HARD_BASE2,
1819     EL_SP_HARD_BASE3,
1820     EL_SP_HARD_BASE4,
1821     EL_SP_HARD_BASE5,
1822     EL_SP_HARD_BASE6,
1823     EL_CONVEYOR_BELT1_SWITCH_LEFT,
1824     EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1825     EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1826     EL_CONVEYOR_BELT2_SWITCH_LEFT,
1827     EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1828     EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1829     EL_CONVEYOR_BELT3_SWITCH_LEFT,
1830     EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1831     EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1832     EL_CONVEYOR_BELT4_SWITCH_LEFT,
1833     EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1834     EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1835     EL_SIGN_EXCLAMATION,
1836     EL_SIGN_RADIOACTIVITY,
1837     EL_SIGN_STOP,
1838     EL_SIGN_WHEELCHAIR,
1839     EL_SIGN_PARKING,
1840     EL_SIGN_ONEWAY,
1841     EL_SIGN_HEART,
1842     EL_SIGN_TRIANGLE,
1843     EL_SIGN_ROUND,
1844     EL_SIGN_EXIT,
1845     EL_SIGN_YINYANG,
1846     EL_SIGN_OTHER,
1847     EL_STEELWALL_SLANTED,
1848     EL_EMC_STEELWALL1,
1849     EL_EMC_STEELWALL2,
1850     EL_EMC_STEELWALL3,
1851     EL_EMC_STEELWALL4,
1852     EL_EMC_WALL_PILLAR_UPPER,
1853     EL_EMC_WALL_PILLAR_MIDDLE,
1854     EL_EMC_WALL_PILLAR_LOWER,
1855     EL_EMC_WALL4,
1856     EL_EMC_WALL5,
1857     EL_EMC_WALL6,
1858     EL_EMC_WALL7,
1859     EL_EMC_WALL8
1860   };
1861   static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1862
1863   static int ep_explosive[] =
1864   {
1865     EL_BOMB,
1866     EL_DYNAMITE_ACTIVE,
1867     EL_DYNAMITE,
1868     EL_DYNABOMB_ACTIVE_1,
1869     EL_DYNABOMB_ACTIVE_2,
1870     EL_DYNABOMB_ACTIVE_3,
1871     EL_DYNABOMB_ACTIVE_4,
1872     EL_DYNABOMB_NR,
1873     EL_DYNABOMB_SZ,
1874     EL_DYNABOMB_XL,
1875     EL_BUG,
1876     EL_MOLE,
1877     EL_PENGUIN,
1878     EL_PIG,
1879     EL_DRAGON,
1880     EL_SATELLITE,
1881     EL_SP_DISK_RED,
1882     EL_SP_DISK_ORANGE,
1883     EL_SP_DISK_YELLOW,
1884     EL_SP_SNIKSNAK,
1885     EL_SP_ELECTRON,
1886     EL_DX_SUPABOMB
1887   };
1888   static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1889
1890   static int ep_mampf3[] =
1891   {
1892     EL_EMERALD,
1893     EL_BD_DIAMOND,
1894     EL_EMERALD_YELLOW,
1895     EL_EMERALD_RED,
1896     EL_EMERALD_PURPLE,
1897     EL_DIAMOND,
1898     EL_PEARL,
1899     EL_CRYSTAL
1900   };
1901   static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1902
1903   static int ep_pushable[] =
1904   {
1905     EL_ROCK,
1906     EL_BD_ROCK,
1907     EL_BOMB,
1908     EL_NUT,
1909     EL_TIME_ORB_EMPTY,
1910     EL_SOKOBAN_FIELD_FULL,
1911     EL_SOKOBAN_OBJECT,
1912     EL_SATELLITE,
1913     EL_SP_ZONK,
1914     EL_SP_DISK_ORANGE,
1915     EL_SP_DISK_YELLOW,
1916     EL_BALLOON,
1917     EL_SPRING,
1918     EL_DX_SUPABOMB
1919   };
1920   static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1921
1922   static int ep_player[] =
1923   {
1924     EL_PLAYER,
1925     EL_PLAYER1,
1926     EL_PLAYER2,
1927     EL_PLAYER3,
1928     EL_PLAYER4
1929   };
1930   static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1931
1932   static int ep_has_content[] =
1933   {
1934     EL_YAMYAM,
1935     EL_AMOEBA_WET,
1936     EL_AMOEBA_DRY,
1937     EL_AMOEBA_FULL,
1938     EL_BD_AMOEBA
1939   };
1940   static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1941
1942   static int ep_eatable[] =
1943   {
1944     EL_SAND,
1945     EL_SP_BASE,
1946     EL_SP_BUGGY_BASE,
1947     EL_TRAP,
1948     EL_INVISIBLE_SAND,
1949     EL_INVISIBLE_SAND_ACTIVE
1950   };
1951   static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
1952
1953   static int ep_sp_element[] =
1954   {
1955     EL_SP_EMPTY,
1956     EL_SP_ZONK,
1957     EL_SP_BASE,
1958     EL_SP_MURPHY,
1959     EL_SP_INFOTRON,
1960     EL_SP_CHIP_SINGLE,
1961     EL_SP_HARD_GRAY,
1962     EL_SP_EXIT_CLOSED,
1963     EL_SP_EXIT_OPEN,
1964     EL_SP_DISK_ORANGE,
1965     EL_SP_PORT1_RIGHT,
1966     EL_SP_PORT1_DOWN,
1967     EL_SP_PORT1_LEFT,
1968     EL_SP_PORT1_UP,
1969     EL_SP_PORT2_RIGHT,
1970     EL_SP_PORT2_DOWN,
1971     EL_SP_PORT2_LEFT,
1972     EL_SP_PORT2_UP,
1973     EL_SP_SNIKSNAK,
1974     EL_SP_DISK_YELLOW,
1975     EL_SP_TERMINAL,
1976     EL_SP_DISK_RED,
1977     EL_SP_PORT_Y,
1978     EL_SP_PORT_X,
1979     EL_SP_PORT_XY,
1980     EL_SP_ELECTRON,
1981     EL_SP_BUGGY_BASE,
1982     EL_SP_CHIP_LEFT,
1983     EL_SP_CHIP_RIGHT,
1984     EL_SP_HARD_BASE1,
1985     EL_SP_HARD_GREEN,
1986     EL_SP_HARD_BLUE,
1987     EL_SP_HARD_RED,
1988     EL_SP_HARD_YELLOW,
1989     EL_SP_HARD_BASE2,
1990     EL_SP_HARD_BASE3,
1991     EL_SP_HARD_BASE4,
1992     EL_SP_HARD_BASE5,
1993     EL_SP_HARD_BASE6,
1994     EL_SP_CHIP_UPPER,
1995     EL_SP_CHIP_LOWER,
1996     /* additional elements that appeared in newer Supaplex levels */
1997     EL_INVISIBLE_WALL,
1998     /* more than one murphy in a level results in an inactive clone */
1999     EL_SP_MURPHY_CLONE
2000   };
2001   static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2002
2003   static int ep_quick_gate[] =
2004   {
2005     EL_EM_GATE1,
2006     EL_EM_GATE2,
2007     EL_EM_GATE3,
2008     EL_EM_GATE4,
2009     EL_EM_GATE1_GRAY,
2010     EL_EM_GATE2_GRAY,
2011     EL_EM_GATE3_GRAY,
2012     EL_EM_GATE4_GRAY,
2013     EL_SP_PORT1_LEFT,
2014     EL_SP_PORT2_LEFT,
2015     EL_SP_PORT1_RIGHT,
2016     EL_SP_PORT2_RIGHT,
2017     EL_SP_PORT1_UP,
2018     EL_SP_PORT2_UP,
2019     EL_SP_PORT1_DOWN,
2020     EL_SP_PORT2_DOWN,
2021     EL_SP_PORT_X,
2022     EL_SP_PORT_Y,
2023     EL_SP_PORT_XY,
2024     EL_SWITCHGATE_OPEN,
2025     EL_TIMEGATE_OPEN
2026   };
2027   static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2028
2029   static int ep_over_player[] =
2030   {
2031     EL_SP_PORT1_LEFT,
2032     EL_SP_PORT2_LEFT,
2033     EL_SP_PORT1_RIGHT,
2034     EL_SP_PORT2_RIGHT,
2035     EL_SP_PORT1_UP,
2036     EL_SP_PORT2_UP,
2037     EL_SP_PORT1_DOWN,
2038     EL_SP_PORT2_DOWN,
2039     EL_SP_PORT_X,
2040     EL_SP_PORT_Y,
2041     EL_SP_PORT_XY,
2042     EL_TUBE_ALL,
2043     EL_TUBE_VERTICAL,
2044     EL_TUBE_HORIZONTAL,
2045     EL_TUBE_VERTICAL_LEFT,
2046     EL_TUBE_VERTICAL_RIGHT,
2047     EL_TUBE_HORIZONTAL_UP,
2048     EL_TUBE_HORIZONTAL_DOWN,
2049     EL_TUBE_LEFT_UP,
2050     EL_TUBE_LEFT_DOWN,
2051     EL_TUBE_RIGHT_UP,
2052     EL_TUBE_RIGHT_DOWN
2053   };
2054   static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2055
2056   static int ep_active_bomb[] =
2057   {
2058     EL_DYNAMITE_ACTIVE,
2059     EL_DYNABOMB_ACTIVE_1,
2060     EL_DYNABOMB_ACTIVE_2,
2061     EL_DYNABOMB_ACTIVE_3,
2062     EL_DYNABOMB_ACTIVE_4
2063   };
2064   static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2065
2066   static int ep_belt[] =
2067   {
2068     EL_CONVEYOR_BELT1_LEFT,
2069     EL_CONVEYOR_BELT1_MIDDLE,
2070     EL_CONVEYOR_BELT1_RIGHT,
2071     EL_CONVEYOR_BELT2_LEFT,
2072     EL_CONVEYOR_BELT2_MIDDLE,
2073     EL_CONVEYOR_BELT2_RIGHT,
2074     EL_CONVEYOR_BELT3_LEFT,
2075     EL_CONVEYOR_BELT3_MIDDLE,
2076     EL_CONVEYOR_BELT3_RIGHT,
2077     EL_CONVEYOR_BELT4_LEFT,
2078     EL_CONVEYOR_BELT4_MIDDLE,
2079     EL_CONVEYOR_BELT4_RIGHT,
2080   };
2081   static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2082
2083   static int ep_belt_active[] =
2084   {
2085     EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2086     EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2087     EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2088     EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2089     EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2090     EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2091     EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2092     EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2093     EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2094     EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2095     EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2096     EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2097   };
2098   static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2099
2100   static int ep_belt_switch[] =
2101   {
2102     EL_CONVEYOR_BELT1_SWITCH_LEFT,
2103     EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2104     EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2105     EL_CONVEYOR_BELT2_SWITCH_LEFT,
2106     EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2107     EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2108     EL_CONVEYOR_BELT3_SWITCH_LEFT,
2109     EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2110     EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2111     EL_CONVEYOR_BELT4_SWITCH_LEFT,
2112     EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2113     EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2114   };
2115   static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2116
2117   static int ep_tube[] =
2118   {
2119     EL_TUBE_ALL,
2120     EL_TUBE_VERTICAL,
2121     EL_TUBE_HORIZONTAL,
2122     EL_TUBE_VERTICAL_LEFT,
2123     EL_TUBE_VERTICAL_RIGHT,
2124     EL_TUBE_HORIZONTAL_UP,
2125     EL_TUBE_HORIZONTAL_DOWN,
2126     EL_TUBE_LEFT_UP,
2127     EL_TUBE_LEFT_DOWN,
2128     EL_TUBE_RIGHT_UP,
2129     EL_TUBE_RIGHT_DOWN
2130   };
2131   static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2132
2133   static long ep1_bit[] =
2134   {
2135     EP_BIT_AMOEBALIVE,
2136     EP_BIT_AMOEBOID,
2137     EP_BIT_SCHLUESSEL,
2138     EP_BIT_PFORTE,
2139     EP_BIT_SOLID,
2140     EP_BIT_MASSIVE,
2141     EP_BIT_SLIPPERY,
2142     EP_BIT_ENEMY,
2143     EP_BIT_MAUER,
2144     EP_BIT_CAN_FALL,
2145     EP_BIT_CAN_SMASH,
2146     EP_BIT_CAN_CHANGE,
2147     EP_BIT_CAN_MOVE,
2148     EP_BIT_COULD_MOVE,
2149     EP_BIT_DONT_TOUCH,
2150     EP_BIT_DONT_GO_TO,
2151     EP_BIT_MAMPF2,
2152     EP_BIT_BD_ELEMENT,
2153     EP_BIT_SB_ELEMENT,
2154     EP_BIT_GEM,
2155     EP_BIT_INACTIVE,
2156     EP_BIT_EXPLOSIVE,
2157     EP_BIT_MAMPF3,
2158     EP_BIT_PUSHABLE,
2159     EP_BIT_PLAYER,
2160     EP_BIT_HAS_CONTENT,
2161     EP_BIT_EATABLE,
2162     EP_BIT_SP_ELEMENT,
2163     EP_BIT_QUICK_GATE,
2164     EP_BIT_OVER_PLAYER,
2165     EP_BIT_ACTIVE_BOMB
2166   };
2167   static long ep2_bit[] =
2168   {
2169     EP_BIT_BELT,
2170     EP_BIT_BELT_ACTIVE,
2171     EP_BIT_BELT_SWITCH,
2172     EP_BIT_TUBE
2173   };
2174   static int *ep1_array[] =
2175   {
2176     ep_amoebalive,
2177     ep_amoeboid,
2178     ep_schluessel,
2179     ep_pforte,
2180     ep_solid,
2181     ep_massive,
2182     ep_slippery,
2183     ep_enemy,
2184     ep_mauer,
2185     ep_can_fall,
2186     ep_can_smash,
2187     ep_can_change,
2188     ep_can_move,
2189     ep_could_move,
2190     ep_dont_touch,
2191     ep_dont_go_to,
2192     ep_mampf2,
2193     ep_bd_element,
2194     ep_sb_element,
2195     ep_gem,
2196     ep_inactive,
2197     ep_explosive,
2198     ep_mampf3,
2199     ep_pushable,
2200     ep_player,
2201     ep_has_content,
2202     ep_eatable,
2203     ep_sp_element,
2204     ep_quick_gate,
2205     ep_over_player,
2206     ep_active_bomb
2207   };
2208   static int *ep2_array[] =
2209   {
2210     ep_belt,
2211     ep_belt_active,
2212     ep_belt_switch,
2213     ep_tube
2214   };
2215   static int *ep1_num[] =
2216   {
2217     &ep_amoebalive_num,
2218     &ep_amoeboid_num,
2219     &ep_schluessel_num,
2220     &ep_pforte_num,
2221     &ep_solid_num,
2222     &ep_massive_num,
2223     &ep_slippery_num,
2224     &ep_enemy_num,
2225     &ep_mauer_num,
2226     &ep_can_fall_num,
2227     &ep_can_smash_num,
2228     &ep_can_change_num,
2229     &ep_can_move_num,
2230     &ep_could_move_num,
2231     &ep_dont_touch_num,
2232     &ep_dont_go_to_num,
2233     &ep_mampf2_num,
2234     &ep_bd_element_num,
2235     &ep_sb_element_num,
2236     &ep_gem_num,
2237     &ep_inactive_num,
2238     &ep_explosive_num,
2239     &ep_mampf3_num,
2240     &ep_pushable_num,
2241     &ep_player_num,
2242     &ep_has_content_num,
2243     &ep_eatable_num,
2244     &ep_sp_element_num,
2245     &ep_quick_gate_num,
2246     &ep_over_player_num,
2247     &ep_active_bomb_num
2248   };
2249   static int *ep2_num[] =
2250   {
2251     &ep_belt_num,
2252     &ep_belt_active_num,
2253     &ep_belt_switch_num,
2254     &ep_tube_num
2255   };
2256   static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2257   static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2258
2259   for(i=0; i<MAX_ELEMENTS; i++)
2260   {
2261     Elementeigenschaften1[i] = 0;
2262     Elementeigenschaften2[i] = 0;
2263   }
2264
2265   for(i=0; i<num_properties1; i++)
2266     for(j=0; j<*(ep1_num[i]); j++)
2267       Elementeigenschaften1[(ep1_array[i])[j]] |= ep1_bit[i];
2268   for(i=0; i<num_properties2; i++)
2269     for(j=0; j<*(ep2_num[i]); j++)
2270       Elementeigenschaften2[(ep2_array[i])[j]] |= ep2_bit[i];
2271
2272   for(i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2273     Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2274 }
2275
2276 void Execute_Debug_Command(char *command)
2277 {
2278   if (strcmp(command, "create graphicsinfo.conf") == 0)
2279   {
2280     int i;
2281
2282     printf("# You can configure additional/alternative image files here.\n");
2283     printf("# (The images below are default and therefore commented out.)\n");
2284     printf("\n");
2285     printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2286     printf("\n");
2287     printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2288     printf("\n");
2289
2290     for (i=0; image_config[i].token != NULL; i++)
2291       printf("# %s\n",
2292              getFormattedSetupEntry(image_config[i].token,
2293                                     image_config[i].value));
2294   }
2295   else if (strcmp(command, "create soundsinfo.conf") == 0)
2296   {
2297     int i;
2298
2299     printf("# You can configure additional/alternative sound files here.\n");
2300     printf("# (The sounds below are default and therefore commented out.)\n");
2301     printf("\n");
2302     printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2303     printf("\n");
2304     printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2305     printf("\n");
2306
2307     for (i=0; sound_config[i].token != NULL; i++)
2308       printf("# %s\n",
2309              getFormattedSetupEntry(sound_config[i].token,
2310                                     sound_config[i].value));
2311   }
2312   else if (strcmp(command, "create musicinfo.conf") == 0)
2313   {
2314     printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2315     printf("\n");
2316     printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2317     printf("\n");
2318     printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2319   }
2320   else if (strcmp(command, "help") == 0)
2321   {
2322     printf("The following commands are recognized:\n");
2323     printf("   \"create graphicsinfo.conf\"\n");
2324     printf("   \"create soundsinfo.conf\"\n");
2325     printf("   \"create musicinfo.conf\"\n");
2326   }
2327 }
2328
2329 void CloseAllAndExit(int exit_value)
2330 {
2331   int i;
2332
2333   StopSounds();
2334   FreeAllSounds();
2335   FreeAllMusic();
2336   CloseAudio();         /* called after freeing sounds (needed for SDL) */
2337
2338   FreeAllImages();
2339
2340   FreeTileClipmasks();
2341   for(i=0; i<NUM_BITMAPS; i++)
2342     FreeBitmap(pix[i]);
2343
2344   CloseVideoDisplay();
2345   ClosePlatformDependantStuff();
2346
2347   exit(exit_value);
2348 }