rnd-20021211-1-src
[rocksndiamonds.git] / src / init.c
index b10b8ec9fa1aff18f4b6caaa28dd2e2380c65fd8..f682a3fcec5abe21a75bf79885c08acf7cbdd42b 100644 (file)
 #include "cartoons.h"
 #include "config.h"
 
+#include "conf_e2g.c"  /* include auto-generated data structure definitions */
+
+
 static char *image_filename[NUM_PICTURES] =
 {
+#if 0
+  "RocksScreen.pcx",
+  "RocksDoor.pcx",
+  "RocksToons.pcx",
+  "RocksFontBig.pcx",
+  "RocksFontSmall.pcx",
+  "RocksFontMedium.pcx",
+  "RocksFontEM.pcx"
+#else
   "RocksScreen.pcx",
   "RocksElements.pcx",
   "RocksDoor.pcx",
@@ -40,8 +52,11 @@ static char *image_filename[NUM_PICTURES] =
   "RocksFontSmall.pcx",
   "RocksFontMedium.pcx",
   "RocksFontEM.pcx"
+#endif
 }; 
 
+static Bitmap *bitmap_font_initial = NULL;
+
 static void InitSetup(void);
 static void InitPlayerInfo(void);
 static void InitLevelInfo(void);
@@ -100,15 +115,17 @@ void OpenAll(void)
 
   InitEventFilter(FilterMouseMotionEvents);
 
-  InitGfx();
   InitElementProperties();     /* initializes IS_CHAR() for el2gfx() */
   InitElementInfo();
 
+  InitGfx();
+
   InitLevelInfo();
   InitLevelArtworkInfo();
-  InitGadgets();               /* needs to know number of level series */
+
   InitImages();                        /* needs to know current level directory */
   InitSound();                 /* needs to know current level directory */
+  InitGadgets();               /* needs images + number of level series */
 
   InitGfxBackground();
   InitToons();
@@ -176,14 +193,24 @@ void InitNetworkServer()
 #endif
 }
 
+static void ReinitializeGraphics()
+{
+  ReloadCustomImages();                /* load custom image files */
+
+  InitGraphicInfo();           /* initialize graphic info from config file */
+
+  InitFontInfo(bitmap_font_initial,
+              new_graphic_info[IMG_MENU_FONT_BIG].bitmap,
+              new_graphic_info[IMG_MENU_FONT_MEDIUM].bitmap,
+              new_graphic_info[IMG_MENU_FONT_SMALL].bitmap,
+              new_graphic_info[IMG_MENU_FONT_EM].bitmap);
+}
+
 static void InitImages()
 {
   InitImageList(image_config, image_config_suffix, NUM_IMAGE_FILES);
 
-  /* load custom images */
-  ReloadCustomImages();
-
-  InitGraphicInfo();
+  ReinitializeGraphics();
 }
 
 static void InitMixer()
@@ -211,6 +238,8 @@ static void InitTileClipmasks()
   unsigned long clip_gc_valuemask;
 
 #if defined(TARGET_X11_NATIVE)
+
+#if 0
   GC copy_clipmask_gc;
 
   static struct
@@ -264,13 +293,15 @@ static void InitTileClipmasks()
     { GFX2_SHIELD_ACTIVE, 3 },
     { -1, 0 }
   };
+#endif
+
 #endif /* TARGET_X11_NATIVE */
 #endif /* TARGET_X11 */
 
   int i;
 
   /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
-  for(i=0; i<NUM_TILES; i++)
+  for (i=0; i<NUM_TILES; i++)
     tile_clipmask[i] = None;
 
 #if defined(TARGET_X11)
@@ -284,7 +315,8 @@ static void InitTileClipmasks()
   tile_clip_gc = XCreateGC(display, window->drawable,
                           clip_gc_valuemask, &clip_gc_values);
 
-  for(i=0; i<NUM_BITMAPS; i++)
+#if 0
+  for (i=0; i<NUM_BITMAPS; i++)
   {
     if (pix[i]->clip_mask)
     {
@@ -295,9 +327,11 @@ static void InitTileClipmasks()
                                         clip_gc_valuemask, &clip_gc_values);
     }
   }
+#endif
 
 #if defined(TARGET_X11_NATIVE)
 
+#if 0
   /* create graphic context structures needed for clipping */
   clip_gc_values.graphics_exposures = False;
   clip_gc_valuemask = GCGraphicsExposures;
@@ -305,11 +339,11 @@ static void InitTileClipmasks()
                               clip_gc_valuemask, &clip_gc_values);
 
   /* create only those clipping Pixmaps we really need */
-  for(i=0; tile_needs_clipping[i].start>=0; i++)
+  for (i=0; tile_needs_clipping[i].start>=0; i++)
   {
     int j;
 
-    for(j=0; j<tile_needs_clipping[i].count; j++)
+    for (j=0; j<tile_needs_clipping[i].count; j++)
     {
       int tile = tile_needs_clipping[i].start + j;
       int graphic = tile;
@@ -329,6 +363,7 @@ static void InitTileClipmasks()
   }
 
   XFreeGC(display, copy_clipmask_gc);
+#endif
 
 #endif /* TARGET_X11_NATIVE */
 #endif /* TARGET_X11 */
@@ -339,7 +374,7 @@ void FreeTileClipmasks()
 #if defined(TARGET_X11)
   int i;
 
-  for(i=0; i<NUM_TILES; i++)
+  for (i=0; i<NUM_TILES; i++)
   {
     if (tile_clipmask[i] != None)
     {
@@ -352,7 +387,8 @@ void FreeTileClipmasks()
     XFreeGC(display, tile_clip_gc);
   tile_clip_gc = None;
 
-  for(i=0; i<NUM_BITMAPS; i++)
+#if 0
+  for (i=0; i<NUM_BITMAPS; i++)
   {
     if (pix[i] != NULL && pix[i]->stored_clip_gc)
     {
@@ -360,12 +396,16 @@ void FreeTileClipmasks()
       pix[i]->stored_clip_gc = None;
     }
   }
+#endif
+
 #endif /* TARGET_X11 */
 }
 
 void InitGfx()
 {
+#if 0
   int i;
+#endif
 
   /* initialize some global variables */
   global.frames_per_second = 0;
@@ -380,30 +420,42 @@ void InitGfx()
   InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
 
   /* create additional image buffers for double-buffering */
-  pix[PIX_DB_DOOR] = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
-  pix[PIX_DB_FIELD] = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
+  bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
+  bitmap_db_door  = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
 
+#if 0
   pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
 
   InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
+#else
+  bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
+
+  InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
+#endif
 
   DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
   DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
 
   DrawInitText("Loading graphics:", 120, FC_GREEN);
 
-  for(i=0; i<NUM_PICTURES; i++)
+#if 0
+  for (i=0; i<NUM_PICTURES; i++)
   {
+#if 0
     if (i != PIX_FONT_SMALL)
+#endif
     {
       DrawInitText(image_filename[i], 150, FC_YELLOW);
 
       pix[i] = LoadCustomImage(image_filename[i]);
     }
   }
+#endif
 
+#if 0
   InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
               pix[PIX_FONT_EM]);
+#endif
 
   InitTileClipmasks();
 }
@@ -413,15 +465,16 @@ void InitGfxBackground()
   int x, y;
 
   drawto = backbuffer;
-  fieldbuffer = pix[PIX_DB_FIELD];
+  fieldbuffer = bitmap_db_field;
   SetDrawtoField(DRAW_BACKBUFFER);
 
-  BlitBitmap(pix[PIX_BACK], backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
+  BlitBitmap(new_graphic_info[IMG_MENU_BACK].bitmap, backbuffer,
+            0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
   ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
-  ClearRectangle(pix[PIX_DB_DOOR], 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
+  ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
 
-  for(x=0; x<MAX_BUF_XSIZE; x++)
-    for(y=0; y<MAX_BUF_YSIZE; y++)
+  for (x=0; x<MAX_BUF_XSIZE; x++)
+    for (y=0; y<MAX_BUF_YSIZE; y++)
       redraw[x][y] = 0;
   redraw_tiles = 0;
   redraw_mask = REDRAW_ALL;
@@ -433,11 +486,21 @@ void ReloadCustomArtwork()
   static boolean last_override_level_graphics = FALSE;
   static boolean last_override_level_sounds = FALSE;
   static boolean last_override_level_music = FALSE;
-
   /* identifier for new artwork; default: artwork configured in setup */
   char *gfx_new_identifier = artwork.gfx_current->identifier;
   char *snd_new_identifier = artwork.snd_current->identifier;
   char *mus_new_identifier = artwork.mus_current->identifier;
+  boolean redraw_screen = FALSE;
+
+  if (leveldir_current_identifier == NULL)
+    leveldir_current_identifier = leveldir_current->identifier;
+
+#if 0
+  printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
+        leveldir_current->graphics_set);
+  printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
+        leveldir_current->identifier);
+#endif
 
 #if 0
   printf("graphics --> '%s' ('%s')\n",
@@ -489,31 +552,48 @@ void ReloadCustomArtwork()
   if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
       last_override_level_graphics != setup.override_level_graphics)
   {
+#if 0
+    printf("CHANGED GFX: '%s' -> '%s'\n",
+          artwork.gfx_current_identifier, gfx_new_identifier);
+#endif
+
+#if 0
     int i;
+#endif
 
     setLevelArtworkDir(artwork.gfx_first);
 
     ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
 
-    for(i=0; i<NUM_PICTURES; i++)
+#if 0
+    for (i=0; i<NUM_PICTURES; i++)
     {
       DrawInitText(image_filename[i], 150, FC_YELLOW);
       ReloadCustomImage(pix[i], image_filename[i]);
     }
+#endif
 
-    ReloadCustomImages();
-    InitGraphicInfo();
+    ReinitializeGraphics();
 
     FreeTileClipmasks();
     InitTileClipmasks();
+
+#if 0
     InitGfxBackground();
 
     /* force redraw of (open or closed) door graphics */
     SetDoorState(DOOR_OPEN_ALL);
     CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
+#endif
 
+#if 0
     artwork.gfx_current_identifier = gfx_new_identifier;
+#else
+    artwork.gfx_current_identifier = artwork.gfx_current->identifier;
+#endif
     last_override_level_graphics = setup.override_level_graphics;
+
+    redraw_screen = TRUE;
   }
 
   if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
@@ -526,6 +606,8 @@ void ReloadCustomArtwork()
 
     artwork.snd_current_identifier = snd_new_identifier;
     last_override_level_sounds = setup.override_level_sounds;
+
+    redraw_screen = TRUE;
   }
 
   if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
@@ -538,6 +620,17 @@ void ReloadCustomArtwork()
 
     artwork.mus_current_identifier = mus_new_identifier;
     last_override_level_music = setup.override_level_music;
+
+    redraw_screen = TRUE;
+  }
+
+  if (redraw_screen)
+  {
+    InitGfxBackground();
+
+    /* force redraw of (open or closed) door graphics */
+    SetDoorState(DOOR_OPEN_ALL);
+    CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
   }
 
 #if 0
@@ -556,8 +649,7 @@ void InitGadgets()
 
 void InitElementInfo()
 {
-  int i, j;
-
+#if 0
   static struct
   {
     int element;
@@ -575,7 +667,6 @@ void InitElementInfo()
     { EL_EXIT_OPENING,                 GFX_AUSGANG_ACT         },
     { EL_EXIT_OPEN,                    GFX_AUSGANG_AUF         },
     { EL_SP_EXIT_OPEN,                 GFX_SP_EXIT             },
-    { EL_PLAYER,                       GFX_SPIELFIGUR          },
     { EL_PLAYER1,                      GFX_SPIELER1            },
     { EL_PLAYER2,                      GFX_SPIELER2            },
     { EL_PLAYER3,                      GFX_SPIELER3            },
@@ -678,10 +769,10 @@ void InitElementInfo()
     { EL_BD_MAGIC_WALL_EMPTYING,       GFX_MAGIC_WALL_BD_EMPTY },
     { EL_BD_MAGIC_WALL_FULL,           GFX_MAGIC_WALL_BD_FULL  },
     { EL_BD_MAGIC_WALL_DEAD,           GFX_MAGIC_WALL_BD_DEAD  },
-    { EL_DYNABOMB_ACTIVE_1,            GFX_DYNABOMB            },
-    { EL_DYNABOMB_ACTIVE_2,            GFX_DYNABOMB            },
-    { EL_DYNABOMB_ACTIVE_3,            GFX_DYNABOMB            },
-    { EL_DYNABOMB_ACTIVE_4,            GFX_DYNABOMB            },
+    { EL_DYNABOMB_PLAYER1_ACTIVE,      GFX_DYNABOMB            },
+    { EL_DYNABOMB_PLAYER2_ACTIVE,      GFX_DYNABOMB            },
+    { EL_DYNABOMB_PLAYER3_ACTIVE,      GFX_DYNABOMB            },
+    { EL_DYNABOMB_PLAYER4_ACTIVE,      GFX_DYNABOMB            },
     { EL_DYNABOMB_NR,                  GFX_DYNABOMB_NR         },
     { EL_DYNABOMB_SZ,                  GFX_DYNABOMB_SZ         },
     { EL_DYNABOMB_XL,                  GFX_DYNABOMB_XL         },
@@ -920,21 +1011,37 @@ void InitElementInfo()
       -1,                      -1
     }
   };
+#endif
+
+  int i, act, dir;
 
-  /* always start with reliable default values */
-  for(i=0; i<MAX_ELEMENTS; i++)
+  /* set values to -1 to identify later as "uninitialized" values */
+  for (i=0; i<MAX_ELEMENTS; i++)
   {
-    for(j=0; j<NUM_GFX_ACTIONS_MAPPED; j++)
+    for (act=0; act<NUM_GFX_ACTIONS_MAPPED; act++)
     {
-      element_info[i].graphic[j] = GFX_LEERRAUM;
-      element_info[i].has_direction_graphic[j] = FALSE;
+      element_info[i].graphic[act] = -1;
+
+      for (dir=0; dir<NUM_MV_DIRECTIONS; dir++)
+       element_info[i].direction_graphic[act][dir] = -1;
     }
   }
 
+#if 0
   for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
     element_info[i].graphic[GFX_ACTION_DEFAULT] =
       GFX_CHAR_START + (i - EL_CHAR_START);
+#else
+  for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
+    element_info[i].graphic[GFX_ACTION_DEFAULT] =
+      IMG_CHAR_START + (i - EL_CHAR_START);
+#endif
+
+  for (i=EL_GENERIC_START; i<=EL_GENERIC_END; i++)
+    element_info[i].graphic[GFX_ACTION_DEFAULT] =
+      IMG_GENERIC_START + (i - EL_GENERIC_START);
 
+#if 0
   for (i=EL_SP_START; i<=EL_SP_END; i++)
   {
     int nr_element = i - EL_SP_START;
@@ -946,7 +1053,9 @@ void InitElementInfo()
     element_info[i].graphic[GFX_ACTION_DEFAULT] =
       GFX_START_ROCKSSP + nr_graphic;
   }
+#endif
 
+#if 0
   /* this overrides some of the above default settings (GFX_SP_ZONK etc.) */
   i = 0;
   while (element_to_graphic[i].element > -1)
@@ -976,15 +1085,87 @@ void InitElementInfo()
     element_info[element].has_direction_graphic[GFX_ACTION_DEFAULT] = TRUE;
     i++;
   }
+#else
+
+  i = 0;
+  while (element_to_graphic[i].element > -1)
+  {
+    int element   = element_to_graphic[i].element;
+    int direction = element_to_graphic[i].direction;
+    int action    = element_to_graphic[i].action;
+    int graphic   = element_to_graphic[i].graphic;
+
+    if (action > -1)
+      action = graphics_action_mapping[action];
+    else
+      action = GFX_ACTION_DEFAULT;
+
+    if (direction > -1)
+    {
+      direction = MV_DIR_BIT(direction);
+
+      element_info[element].direction_graphic[action][direction] = graphic;
+    }
+    else
+      element_info[element].graphic[action] = graphic;
+
+    i++;
+  }
+
+  /* now set all '-1' values to element specific default values */
+  for (i=0; i<MAX_ELEMENTS; i++)
+  {
+    int default_action_graphic = element_info[i].graphic[GFX_ACTION_DEFAULT];
+    int default_action_direction_graphic[NUM_MV_DIRECTIONS];
+
+    if (default_action_graphic == -1)
+      default_action_graphic = IMG_CHAR_QUESTION;
+
+    for (dir=0; dir<NUM_MV_DIRECTIONS; dir++)
+    {
+      default_action_direction_graphic[dir] =
+       element_info[i].direction_graphic[GFX_ACTION_DEFAULT][dir];
+
+      if (default_action_direction_graphic[dir] == -1)
+       default_action_direction_graphic[dir] = default_action_graphic;
+    }
+
+    for (act=0; act<NUM_GFX_ACTIONS_MAPPED; act++)
+    {
+      for (dir=0; dir<NUM_MV_DIRECTIONS; dir++)
+      {
+       int default_direction_graphic = element_info[i].graphic[act];
+
+       /* no graphic for current action -- use default direction graphic */
+       if (default_direction_graphic == -1)
+         default_direction_graphic = default_action_direction_graphic[dir];
+
+       if (element_info[i].direction_graphic[act][dir] == -1)
+         element_info[i].direction_graphic[act][dir] =
+           default_direction_graphic;
+      }
+
+      /* no graphic for this specific action -- use default action graphic */
+      if (element_info[i].graphic[act] == -1)
+       element_info[i].graphic[act] = default_action_graphic;
+    }
+  }
+
+#endif
 }
 
 static void InitGraphicInfo()
 {
+  static int gfx_action[NUM_IMAGE_FILES];
+  Bitmap *src_bitmap;
+  int src_x, src_y;
+  int last_frame;
   int i;
 
   image_files = getCurrentImageList();
 
-  for(i=0; i<MAX_GRAPHICS; i++)
+#if 0
+  for (i=0; i<MAX_GRAPHICS; i++)
   {
     /* always start with reliable default values */
     graphic_info[i].bitmap = NULL;
@@ -994,15 +1175,44 @@ static void InitGraphicInfo()
     getGraphicSource(i, &graphic_info[i].bitmap,
                     &graphic_info[i].src_x, &graphic_info[i].src_y);
   }
+#endif
+
+  /* set temporary graphics action field to default value */
+  for (i=0; i<NUM_IMAGE_FILES; i++)
+    gfx_action[i] = GFX_ACTION_DEFAULT;
+
+  /* set temporary graphics action field from element_to_graphic list */
+  i = 0;
+  while (element_to_graphic[i].element > -1)
+  {
+    int action    = element_to_graphic[i].action;
+    int graphic   = element_to_graphic[i].graphic;
+
+    if (action == -1)
+      action = GFX_ACTION_DEFAULT;
+
+    gfx_action[graphic] = action;
+
+    i++;
+  }
 
-  for(i=0; i<NUM_IMAGE_FILES; i++)
+  for (i=0; i<NUM_IMAGE_FILES; i++)
   {
     int *parameter = image_files[i].parameter;
 
-    /* always start with reliable default values */
     new_graphic_info[i].bitmap = getBitmapFromImageID(i);
+
     new_graphic_info[i].src_x = parameter[GFX_ARG_XPOS] * TILEX;
     new_graphic_info[i].src_y = parameter[GFX_ARG_YPOS] * TILEY;
+    new_graphic_info[i].offset_x = parameter[GFX_ARG_OFFSET];
+    new_graphic_info[i].offset_y = 0;
+
+    /* animation frames are ordered vertically instead of horizontally */
+    if (parameter[GFX_ARG_VERTICAL])
+    {
+      new_graphic_info[i].offset_x = 0;
+      new_graphic_info[i].offset_y = parameter[GFX_ARG_OFFSET];
+    }
 
     new_graphic_info[i].anim_frames = parameter[GFX_ARG_FRAMES];
 
@@ -1010,24 +1220,93 @@ static void InitGraphicInfo()
     if (new_graphic_info[i].anim_delay == 0)   /* delay must be at least 1 */
       new_graphic_info[i].anim_delay = 1;
 
-    /* basically, animation can be either normal or reverse direction */
-    if (parameter[GFX_ARG_REVERSE])
-      new_graphic_info[i].anim_mode = ANIM_REVERSE;
+    /* set mode for animation frame order */
+    if (parameter[GFX_ARG_MODE_LOOP])
+      new_graphic_info[i].anim_mode = ANIM_LOOP;
+    else if (parameter[GFX_ARG_MODE_LINEAR])
+      new_graphic_info[i].anim_mode = ANIM_LINEAR;
+    else if (parameter[GFX_ARG_MODE_PINGPONG])
+      new_graphic_info[i].anim_mode = ANIM_PINGPONG;
+    else if (parameter[GFX_ARG_MODE_PINGPONG2])
+      new_graphic_info[i].anim_mode = ANIM_PINGPONG2;
+    else if (parameter[GFX_ARG_FRAMES] > 1)
+      new_graphic_info[i].anim_mode = ANIM_LOOP;
     else
-      new_graphic_info[i].anim_mode = ANIM_NORMAL;
-
-    /* additionally, animation can be either pingpong or pingpong2 layout */
-    if (parameter[GFX_ARG_PINGPONG])
-      new_graphic_info[i].anim_mode |= ANIM_PINGPONG;
-    else if (parameter[GFX_ARG_PINGPONG2])
-      new_graphic_info[i].anim_mode |= ANIM_PINGPONG2;
+      new_graphic_info[i].anim_mode = ANIM_NONE;
+
+    /* set additional flag to play animation frames in reverse order */
+    if (parameter[GFX_ARG_MODE_REVERSE])
+      new_graphic_info[i].anim_mode |= ANIM_REVERSE;
+
+#if 1
+    /* set first frame of animation after determining animation mode */
+    new_graphic_info[i].anim_start_frame = parameter[GFX_ARG_START_FRAME];
+    if (new_graphic_info[i].anim_start_frame == -1)
+      new_graphic_info[i].anim_start_frame = 0;
+    else if (new_graphic_info[i].anim_mode & ANIM_REVERSE)
+      new_graphic_info[i].anim_start_frame =
+       new_graphic_info[i].anim_frames
+       - new_graphic_info[i].anim_start_frame - 1;
+#else
+    /* set first frame of animation after determining animation mode */
+    new_graphic_info[i].anim_start_frame = parameter[GFX_ARG_START_FRAME];
+    if (parameter[GFX_ARG_START_FRAME] == -1)  /* default: start with ... */
+    {
+      if (parameter[GFX_ARG_MODE_REVERSE])
+       new_graphic_info[i].anim_start_frame =
+         new_graphic_info[i].anim_frames - 1;          /* ... last frame */
+      else
+       new_graphic_info[i].anim_start_frame = 0;       /* ... first frame */
+    }
+#endif
 
+#if 1
+    /* animation synchronized with global frame counter, not move position */
+    new_graphic_info[i].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
+    if (parameter[GFX_ARG_GLOBAL_SYNC] == -1)
+      new_graphic_info[i].anim_global_sync =
+       (gfx_action[i] == GFX_ACTION_DEFAULT ? TRUE : FALSE);
+#else
     /* animation synchronized with global frame counter, not move position */
     new_graphic_info[i].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
+#endif
+
+    /* now check if the loaded image is large enough for the animation */
+    last_frame = new_graphic_info[i].anim_frames - 1;
+
+    getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
+    if (src_x + TILEX > src_bitmap->width ||
+       src_y + TILEY > src_bitmap->height)
+      Error(ERR_EXIT, "InitGraphicInfo: image bitmap '%s' too small for graphic object %d (normal size)", src_bitmap->source_filename, i);
+
+    getMiniGraphicSource(i, &src_bitmap, &src_x, &src_y);
+    if (src_x + MINI_TILEX > src_bitmap->width ||
+       src_y + MINI_TILEY > src_bitmap->height)
+      Error(ERR_EXIT, "InitGraphicInfo: image bitmap '%s' too small for graphic object %d ('mini' size)", src_bitmap->source_filename, i);
+
+    getMicroGraphicSource(i, &src_bitmap, &src_x, &src_y);
+    if (src_x + MICRO_TILEX > src_bitmap->width ||
+       src_y + MICRO_TILEY > src_bitmap->height)
+      Error(ERR_EXIT, "InitGraphicInfo: image bitmap '%s' too small for graphic object %d ('micro' size)", src_bitmap->source_filename, i);
+
+
+#if 0
+    {
+      int j;
+
+      if (i == IMG_EMERALD)
+      {
+       for (j=0; j<NUM_GFX_ARGS; j++)
+         printf("%s -> %d\n", image_config_suffix[j].token, parameter[j]);
+       printf("-> %d\n", new_graphic_info[i].anim_frames);
+       printf("\n");
+      }
+    }
+#endif
 
-    new_graphic_info[i].anim_vertical = parameter[GFX_ARG_VERTICAL];
   }
 
+
 #if 0
   printf("D> %d\n", image_files[GFX_BD_DIAMOND].parameter[GFX_ARG_NUM_FRAMES]);
   printf("W> %d\n", image_files[GFX_ROBOT_WHEEL].parameter[GFX_ARG_NUM_FRAMES]);
@@ -1587,7 +1866,7 @@ void InitElementProperties()
     EL_SP_SNIKSNAK,
     EL_SP_ELECTRON,
     EL_BALLOON,
-    EL_SPRING_MOVING
+    EL_SPRING
   };
   static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
 
@@ -1685,7 +1964,7 @@ void InitElementProperties()
     EL_EXIT_CLOSED,
     EL_EXIT_OPEN,
     EL_STEELWALL,
-    EL_PLAYER,
+    EL_PLAYER1,
     EL_BD_FIREFLY,
     EL_BD_FIREFLY_1,
     EL_BD_FIREFLY_2,
@@ -1708,7 +1987,7 @@ void InitElementProperties()
     EL_SOKOBAN_OBJECT,
     EL_SOKOBAN_FIELD_EMPTY,
     EL_SOKOBAN_FIELD_FULL,
-    EL_PLAYER,
+    EL_PLAYER1,
     EL_INVISIBLE_STEELWALL
   };
   static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
@@ -1865,10 +2144,10 @@ void InitElementProperties()
     EL_BOMB,
     EL_DYNAMITE_ACTIVE,
     EL_DYNAMITE,
-    EL_DYNABOMB_ACTIVE_1,
-    EL_DYNABOMB_ACTIVE_2,
-    EL_DYNABOMB_ACTIVE_3,
-    EL_DYNABOMB_ACTIVE_4,
+    EL_DYNABOMB_PLAYER1_ACTIVE,
+    EL_DYNABOMB_PLAYER2_ACTIVE,
+    EL_DYNABOMB_PLAYER3_ACTIVE,
+    EL_DYNABOMB_PLAYER4_ACTIVE,
     EL_DYNABOMB_NR,
     EL_DYNABOMB_SZ,
     EL_DYNABOMB_XL,
@@ -1921,7 +2200,6 @@ void InitElementProperties()
 
   static int ep_player[] =
   {
-    EL_PLAYER,
     EL_PLAYER1,
     EL_PLAYER2,
     EL_PLAYER3,
@@ -2056,10 +2334,10 @@ void InitElementProperties()
   static int ep_active_bomb[] =
   {
     EL_DYNAMITE_ACTIVE,
-    EL_DYNABOMB_ACTIVE_1,
-    EL_DYNABOMB_ACTIVE_2,
-    EL_DYNABOMB_ACTIVE_3,
-    EL_DYNABOMB_ACTIVE_4
+    EL_DYNABOMB_PLAYER1_ACTIVE,
+    EL_DYNABOMB_PLAYER2_ACTIVE,
+    EL_DYNABOMB_PLAYER3_ACTIVE,
+    EL_DYNABOMB_PLAYER4_ACTIVE
   };
   static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
 
@@ -2256,20 +2534,20 @@ void InitElementProperties()
   static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
   static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
 
-  for(i=0; i<MAX_ELEMENTS; i++)
+  for (i=0; i<MAX_ELEMENTS; i++)
   {
     Elementeigenschaften1[i] = 0;
     Elementeigenschaften2[i] = 0;
   }
 
-  for(i=0; i<num_properties1; i++)
-    for(j=0; j<*(ep1_num[i]); j++)
+  for (i=0; i<num_properties1; i++)
+    for (j=0; j<*(ep1_num[i]); j++)
       Elementeigenschaften1[(ep1_array[i])[j]] |= ep1_bit[i];
-  for(i=0; i<num_properties2; i++)
-    for(j=0; j<*(ep2_num[i]); j++)
+  for (i=0; i<num_properties2; i++)
+    for (j=0; j<*(ep2_num[i]); j++)
       Elementeigenschaften2[(ep2_array[i])[j]] |= ep2_bit[i];
 
-  for(i=EL_CHAR_START; i<=EL_CHAR_END; i++)
+  for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
     Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
 }
 
@@ -2328,7 +2606,9 @@ void Execute_Debug_Command(char *command)
 
 void CloseAllAndExit(int exit_value)
 {
+#if 0
   int i;
+#endif
 
   StopSounds();
   FreeAllSounds();
@@ -2338,8 +2618,13 @@ void CloseAllAndExit(int exit_value)
   FreeAllImages();
 
   FreeTileClipmasks();
-  for(i=0; i<NUM_BITMAPS; i++)
+#if 0
+  for (i=0; i<NUM_BITMAPS; i++)
     FreeBitmap(pix[i]);
+#endif
+
+  if (bitmap_font_initial)
+    FreeBitmap(bitmap_font_initial);
 
   CloseVideoDisplay();
   ClosePlatformDependantStuff();