rnd-20021227-2-src
[rocksndiamonds.git] / src / game.c
index 502d60d7b50dd68b6132b81a6ae84a0eeed3f4a7..b135360d0d5722578f9c1315a02298caab80fc55 100644 (file)
 #define NUM_GAME_BUTTONS               6
 
 /* forward declaration for internal use */
+static void InitBeltMovement(void);
 static void CloseAllOpenTimegates(void);
 static void CheckGravityMovement(struct PlayerInfo *);
 static void KillHeroUnlessProtected(int, int);
@@ -229,21 +230,28 @@ void GetPlayerConfig()
   InitJoysticks();
 }
 
-static int getBeltNrFromElement(int element)
+static int getBeltNrFromBeltElement(int element)
 {
   return (element < EL_CONVEYOR_BELT2_LEFT ? 0 :
          element < EL_CONVEYOR_BELT3_LEFT ? 1 :
          element < EL_CONVEYOR_BELT4_LEFT ? 2 : 3);
 }
 
-static int getBeltNrFromSwitchElement(int element)
+static int getBeltNrFromBeltActiveElement(int element)
+{
+  return (element < EL_CONVEYOR_BELT2_LEFT_ACTIVE ? 0 :
+         element < EL_CONVEYOR_BELT3_LEFT_ACTIVE ? 1 :
+         element < EL_CONVEYOR_BELT4_LEFT_ACTIVE ? 2 : 3);
+}
+
+static int getBeltNrFromBeltSwitchElement(int element)
 {
   return (element < EL_CONVEYOR_BELT2_SWITCH_LEFT ? 0 :
          element < EL_CONVEYOR_BELT3_SWITCH_LEFT ? 1 :
          element < EL_CONVEYOR_BELT4_SWITCH_LEFT ? 2 : 3);
 }
 
-static int getBeltDirNrFromSwitchElement(int element)
+static int getBeltDirNrFromBeltSwitchElement(int element)
 {
   static int belt_base_element[4] =
   {
@@ -253,13 +261,13 @@ static int getBeltDirNrFromSwitchElement(int element)
     EL_CONVEYOR_BELT4_SWITCH_LEFT
   };
 
-  int belt_nr = getBeltNrFromSwitchElement(element);
+  int belt_nr = getBeltNrFromBeltSwitchElement(element);
   int belt_dir_nr = element - belt_base_element[belt_nr];
 
   return (belt_dir_nr % 3);
 }
 
-static int getBeltDirFromSwitchElement(int element)
+static int getBeltDirFromBeltSwitchElement(int element)
 {
   static int belt_move_dir[3] =
   {
@@ -268,7 +276,7 @@ static int getBeltDirFromSwitchElement(int element)
     MV_RIGHT
   };
 
-  int belt_dir_nr = getBeltDirNrFromSwitchElement(element);
+  int belt_dir_nr = getBeltDirNrFromBeltSwitchElement(element);
 
   return belt_move_dir[belt_dir_nr];
 }
@@ -285,11 +293,9 @@ static void InitField(int x, int y, boolean init_game)
          Feld[x][y] = EL_SP_MURPHY_CLONE;
          break;
        }
-      }
-      /* no break! */
-    case EL_PLAYER:
-      if (init_game)
+
        Feld[x][y] = EL_PLAYER1;
+      }
       /* no break! */
     case EL_PLAYER1:
     case EL_PLAYER2:
@@ -443,9 +449,9 @@ static void InitField(int x, int y, boolean init_game)
     case EL_CONVEYOR_BELT4_SWITCH_RIGHT:
       if (init_game)
       {
-       int belt_nr = getBeltNrFromSwitchElement(Feld[x][y]);
-       int belt_dir = getBeltDirFromSwitchElement(Feld[x][y]);
-       int belt_dir_nr = getBeltDirNrFromSwitchElement(Feld[x][y]);
+       int belt_nr = getBeltNrFromBeltSwitchElement(Feld[x][y]);
+       int belt_dir = getBeltDirFromBeltSwitchElement(Feld[x][y]);
+       int belt_dir_nr = getBeltDirNrFromBeltSwitchElement(Feld[x][y]);
 
        if (game.belt_dir_nr[belt_nr] == 3)     /* initial value */
        {
@@ -482,7 +488,7 @@ void DrawGameDoorValues()
     for (j=0; j<4; j++)
       if (stored_player[i].key[j])
        DrawMiniGraphicExt(drawto, DX_KEYS + j * MINI_TILEX, DY_KEYS,
-                          GFX_SCHLUESSEL1 + j);
+                          IMG_KEY1 + j);
 
   DrawText(DX + XX_EMERALDS, DY + YY_EMERALDS,
           int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW);
@@ -666,12 +672,14 @@ void InitGame()
 
   InitGameEngine();
 
+#if 0
 #if DEBUG
 #if USE_NEW_AMOEBA_CODE
   printf("Using new amoeba code.\n");
 #else
   printf("Using old amoeba code.\n");
 #endif
+#endif
 #endif
 
   /* don't play tapes over network */
@@ -731,8 +739,8 @@ void InitGame()
     player->last_jx = player->last_jy = 0;
     player->jx = player->jy = 0;
 
-    player->shield_passive_time_left = 0;
-    player->shield_active_time_left = 0;
+    player->shield_normal_time_left = 0;
+    player->shield_deadly_time_left = 0;
 
     DigField(player, 0, 0, 0, 0, DF_NO_PUSH);
     SnapField(player, 0, 0);
@@ -790,6 +798,7 @@ void InitGame()
       MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0;
       Store[x][y] = Store2[x][y] = StorePlayer[x][y] = 0;
       Frame[x][y] = 0;
+      GfxAction[x][y] = GFX_ACTION_DEFAULT;
       AmoebaNr[x][y] = 0;
       JustStopped[x][y] = 0;
       Stop[x][y] = FALSE;
@@ -812,6 +821,8 @@ void InitGame()
     }
   }
 
+  InitBeltMovement();
+
   game.emulation = (emulate_bd ? EMU_BOULDERDASH :
                    emulate_sb ? EMU_SOKOBAN :
                    emulate_sp ? EMU_SUPAPLEX : EMU_NONE);
@@ -963,7 +974,7 @@ void InitGame()
   redraw_mask |= REDRAW_FROM_BACKBUFFER;
 
   /* copy default game door content to main double buffer */
-  BlitBitmap(pix[PIX_DOOR], drawto,
+  BlitBitmap(new_graphic_info[IMG_MENU_DOOR].bitmap, drawto,
             DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
 
   if (level_nr < 100)
@@ -990,7 +1001,7 @@ void InitGame()
   MapTapeButtons();
 
   /* copy actual game door content to door double buffer for OpenDoor() */
-  BlitBitmap(drawto, pix[PIX_DB_DOOR],
+  BlitBitmap(drawto, bitmap_db_door,
             DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
 
   OpenDoor(DOOR_OPEN_ALL);
@@ -1146,6 +1157,9 @@ void GameWon()
   if (local_player->MovPos)
     return;
 
+  if (tape.playing && tape.auto_play)
+    tape.auto_play_level_solved = TRUE;
+
   local_player->LevelSolved = FALSE;
 
   PlaySoundStereo(SND_GAME_WINNING, SOUND_MAX_RIGHT);
@@ -1319,13 +1333,20 @@ int NewHiScore()
 
 void InitMovingField(int x, int y, int direction)
 {
+  int element = Feld[x][y];
   int newx = x + (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0);
   int newy = y + (direction == MV_UP   ? -1 : direction == MV_DOWN  ? +1 : 0);
 
   MovDir[x][y] = direction;
   MovDir[newx][newy] = direction;
+
   if (Feld[newx][newy] == EL_EMPTY)
     Feld[newx][newy] = EL_BLOCKED;
+
+  if (direction == MV_DOWN && CAN_FALL(element))
+    GfxAction[x][y] = GFX_ACTION_FALLING;
+  else
+    GfxAction[x][y] = GFX_ACTION_MOVING;
 }
 
 void Moving2Blocked(int x, int y, int *goes_to_x, int *goes_to_y)
@@ -1436,6 +1457,7 @@ void RemoveMovingField(int x, int y)
   Feld[newx][newy] = EL_EMPTY;
   MovPos[oldx][oldy] = MovDir[oldx][oldy] = MovDelay[oldx][oldy] = 0;
   MovPos[newx][newy] = MovDir[newx][newy] = MovDelay[newx][newy] = 0;
+  GfxAction[oldx][oldy] = GfxAction[newx][newy] = GFX_ACTION_DEFAULT;
 
   DrawLevelField(oldx, oldy);
   DrawLevelField(newx, newy);
@@ -1444,32 +1466,27 @@ void RemoveMovingField(int x, int y)
 void DrawDynamite(int x, int y)
 {
   int sx = SCREENX(x), sy = SCREENY(y);
-  int graphic = el2gfx(Feld[x][y]);
-  int phase;
+  int graphic = el2img(Feld[x][y]);
+  int frame;
 
   if (!IN_SCR_FIELD(sx, sy) || IS_PLAYER(x, y))
     return;
 
   if (Store[x][y])
-    DrawGraphic(sx, sy, el2gfx(Store[x][y]));
+    DrawGraphic(sx, sy, el2img(Store[x][y]), 0);
 
-  if (Feld[x][y] == EL_DYNAMITE_ACTIVE)
-  {
-    if ((phase = (96 - MovDelay[x][y]) / 12) > 6)
-      phase = 6;
-  }
-  else
-  {
-    if ((phase = ((96 - MovDelay[x][y]) / 6) % 8) > 3)
-      phase = 7 - phase;
-  }
+  frame = getGraphicAnimationFrame(graphic, 96 - MovDelay[x][y]);
+
+  /*
+  printf("-> %d: %d [%d]\n", graphic, frame, MovDelay[x][y]);
+  */
 
   if (game.emulation == EMU_SUPAPLEX)
-    DrawGraphic(sx, sy, GFX_SP_DISK_RED);
+    DrawGraphic(sx, sy, IMG_SP_DISK_RED, 0);
   else if (Store[x][y])
-    DrawGraphicThruMask(sx, sy, graphic + phase);
+    DrawGraphicThruMask(sx, sy, graphic, frame);
   else
-    DrawGraphic(sx, sy, graphic + phase);
+    DrawGraphic(sx, sy, graphic, frame);
 }
 
 void CheckDynamite(int x, int y)
@@ -1505,7 +1522,8 @@ void CheckDynamite(int x, int y)
 void Explode(int ex, int ey, int phase, int mode)
 {
   int x, y;
-  int num_phase = 9, delay = (game.emulation == EMU_SUPAPLEX ? 3 : 2);
+  int num_phase = 9;
+  int delay = (game.emulation == EMU_SUPAPLEX ? 3 : 2);
   int last_phase = num_phase * delay;
   int half_phase = (num_phase / 2) * delay;
   int first_phase_after_start = EX_PHASE_START + 1;
@@ -1545,7 +1563,7 @@ void Explode(int ex, int ey, int phase, int mode)
        RemoveMovingField(x, y);
       }
 
-      if (IS_MASSIVE(element) || element == EL_DRAGON_FIRE)
+      if (IS_MASSIVE(element) || element == EL_FLAMES)
        continue;
 
       if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y)))
@@ -1694,27 +1712,24 @@ void Explode(int ex, int ey, int phase, int mode)
     if (IS_PLAYER(x, y) && !PLAYERINFO(x,y)->present)
       StorePlayer[x][y] = 0;
   }
-  else if (!(phase % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+  else if (phase >= delay && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
   {
-    int graphic = GFX_EXPLOSION;
-
-    if (game.emulation == EMU_SUPAPLEX)
-      graphic = (Store[x][y] == EL_SP_INFOTRON ?
-                GFX_SP_EXPLODE_INFOTRON :
-                GFX_SP_EXPLODE_EMPTY);
+    int stored = Store[x][y];
+    int graphic = (game.emulation != EMU_SUPAPLEX ? IMG_EXPLOSION :
+                  stored == EL_SP_INFOTRON ? IMG_SP_EXPLOSION_INFOTRON :
+                  IMG_SP_EXPLOSION);
+    int frame = getGraphicAnimationFrame(graphic, phase - delay);
 
     if (phase == delay)
-      ErdreichAnbroeckeln(SCREENX(x), SCREENY(y));
-
-    graphic += (phase / delay - 1);
+      DrawCrumbledSand(SCREENX(x), SCREENY(y));
 
     if (IS_PFORTE(Store[x][y]))
     {
       DrawLevelElement(x, y, Store[x][y]);
-      DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic);
+      DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic, frame);
     }
     else
-      DrawGraphic(SCREENX(x), SCREENY(y), graphic);
+      DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame);
   }
 }
 
@@ -1734,7 +1749,7 @@ void DynaExplode(int ex, int ey)
 
   if (IS_ACTIVE_BOMB(Feld[ex][ey]))
   {
-    player = &stored_player[Feld[ex][ey] - EL_DYNABOMB_ACTIVE_1];
+    player = &stored_player[Feld[ex][ey] - EL_DYNABOMB_PLAYER1_ACTIVE];
     dynabomb_size = player->dynabomb_size;
     dynabomb_xl = player->dynabomb_xl;
     player->dynabombs_left++;
@@ -1798,10 +1813,10 @@ void Bang(int x, int y)
       RaiseScoreElement(element);
       Explode(x, y, EX_PHASE_START, EX_NORMAL);
       break;
-    case EL_DYNABOMB_ACTIVE_1:
-    case EL_DYNABOMB_ACTIVE_2:
-    case EL_DYNABOMB_ACTIVE_3:
-    case EL_DYNABOMB_ACTIVE_4:
+    case EL_DYNABOMB_PLAYER1_ACTIVE:
+    case EL_DYNABOMB_PLAYER2_ACTIVE:
+    case EL_DYNABOMB_PLAYER3_ACTIVE:
+    case EL_DYNABOMB_PLAYER4_ACTIVE:
     case EL_DYNABOMB_NR:
     case EL_DYNABOMB_SZ:
     case EL_DYNABOMB_XL:
@@ -1825,27 +1840,28 @@ void Blurb(int x, int y)
 {
   int element = Feld[x][y];
 
-  if (element != EL_ACID_SPLASHING_LEFT &&
-      element != EL_ACID_SPLASHING_RIGHT)      /* start */
+  if (element != EL_ACID_SPLASH_LEFT &&
+      element != EL_ACID_SPLASH_RIGHT) /* start */
   {
     PlaySoundLevel(x, y, SND_ACID_SPLASHING);
     if (IN_LEV_FIELD(x-1, y) && IS_FREE(x-1, y) &&
        (!IN_LEV_FIELD(x-1, y-1) ||
         !CAN_FALL(MovingOrBlocked2Element(x-1, y-1))))
     {
-      Feld[x-1][y] = EL_ACID_SPLASHING_LEFT;
+      Feld[x-1][y] = EL_ACID_SPLASH_LEFT;
     }
     if (IN_LEV_FIELD(x+1, y) && IS_FREE(x+1, y) &&
        (!IN_LEV_FIELD(x+1, y-1) ||
         !CAN_FALL(MovingOrBlocked2Element(x+1, y-1))))
     {
-      Feld[x+1][y] = EL_ACID_SPLASHING_RIGHT;
+      Feld[x+1][y] = EL_ACID_SPLASH_RIGHT;
     }
   }
   else                                                         /* go on */
   {
-    int graphic =
-      (element == EL_ACID_SPLASHING_LEFT ? GFX_BLURB_LEFT : GFX_BLURB_RIGHT);
+    int graphic = (element == EL_ACID_SPLASH_LEFT ?
+                  IMG_ACID_SPLASH_LEFT :
+                  IMG_ACID_SPLASH_RIGHT);
 
     if (!MovDelay[x][y])       /* initialize animation counter */
       MovDelay[x][y] = 9;
@@ -1854,7 +1870,11 @@ void Blurb(int x, int y)
     {
       MovDelay[x][y]--;
       if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-       DrawGraphic(SCREENX(x), SCREENY(y), graphic+4-MovDelay[x][y]/2);
+      {
+       int frame = getGraphicAnimationFrame(graphic, 8 - MovDelay[x][y]);
+
+        DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame);
+      }
 
       if (!MovDelay[x][y])
       {
@@ -1865,9 +1885,84 @@ void Blurb(int x, int y)
   }
 }
 
+static void InitBeltMovement()
+{
+  static int belt_base_element[4] =
+  {
+    EL_CONVEYOR_BELT1_LEFT,
+    EL_CONVEYOR_BELT2_LEFT,
+    EL_CONVEYOR_BELT3_LEFT,
+    EL_CONVEYOR_BELT4_LEFT
+  };
+  static int belt_base_active_element[4] =
+  {
+    EL_CONVEYOR_BELT1_LEFT_ACTIVE,
+    EL_CONVEYOR_BELT2_LEFT_ACTIVE,
+    EL_CONVEYOR_BELT3_LEFT_ACTIVE,
+    EL_CONVEYOR_BELT4_LEFT_ACTIVE
+  };
+
+  int x, y, i, j;
+
+  /* set frame order for belt animation graphic according to belt direction */
+  for (i=0; i<4; i++)
+  {
+    int belt_nr = i;
+
+    for (j=0; j<3; j++)
+    {
+      int element = belt_base_active_element[belt_nr] + j;
+      int graphic = el2img(element);
+
+      if (game.belt_dir[i] == MV_LEFT)
+       new_graphic_info[graphic].anim_mode &= ~ANIM_REVERSE;
+      else
+       new_graphic_info[graphic].anim_mode |=  ANIM_REVERSE;
+    }
+  }
+
+  for(y=0; y<lev_fieldy; y++)
+  {
+    for(x=0; x<lev_fieldx; x++)
+    {
+      int element = Feld[x][y];
+
+      for (i=0; i<4; i++)
+      {
+       if (IS_BELT(element) && game.belt_dir[i] != MV_NO_MOVING)
+       {
+         int e_belt_nr = getBeltNrFromBeltElement(element);
+         int belt_nr = i;
+
+         if (e_belt_nr == belt_nr)
+         {
+           int belt_part = Feld[x][y] - belt_base_element[belt_nr];
+
+           Feld[x][y] = belt_base_active_element[belt_nr] + belt_part;
+         }
+       }
+      }
+    }
+  }
+}
+
 static void ToggleBeltSwitch(int x, int y)
 {
   static int belt_base_element[4] =
+  {
+    EL_CONVEYOR_BELT1_LEFT,
+    EL_CONVEYOR_BELT2_LEFT,
+    EL_CONVEYOR_BELT3_LEFT,
+    EL_CONVEYOR_BELT4_LEFT
+  };
+  static int belt_base_active_element[4] =
+  {
+    EL_CONVEYOR_BELT1_LEFT_ACTIVE,
+    EL_CONVEYOR_BELT2_LEFT_ACTIVE,
+    EL_CONVEYOR_BELT3_LEFT_ACTIVE,
+    EL_CONVEYOR_BELT4_LEFT_ACTIVE
+  };
+  static int belt_base_switch_element[4] =
   {
     EL_CONVEYOR_BELT1_SWITCH_LEFT,
     EL_CONVEYOR_BELT2_SWITCH_LEFT,
@@ -1883,10 +1978,10 @@ static void ToggleBeltSwitch(int x, int y)
   };
 
   int element = Feld[x][y];
-  int belt_nr = getBeltNrFromSwitchElement(element);
+  int belt_nr = getBeltNrFromBeltSwitchElement(element);
   int belt_dir_nr = (game.belt_dir_nr[belt_nr] + 1) % 4;
   int belt_dir = belt_move_dir[belt_dir_nr];
-  int xx, yy;
+  int xx, yy, i;
 
   if (!IS_BELT_SWITCH(element))
     return;
@@ -1897,6 +1992,18 @@ static void ToggleBeltSwitch(int x, int y)
   if (belt_dir_nr == 3)
     belt_dir_nr = 1;
 
+  /* set frame order for belt animation graphic according to belt direction */
+  for (i=0; i<3; i++)
+  {
+    int element = belt_base_active_element[belt_nr] + i;
+    int graphic = el2img(element);
+
+    if (belt_dir == MV_LEFT)
+      new_graphic_info[graphic].anim_mode &= ~ANIM_REVERSE;
+    else
+      new_graphic_info[graphic].anim_mode |=  ANIM_REVERSE;
+  }
+
   for (yy=0; yy<lev_fieldy; yy++)
   {
     for (xx=0; xx<lev_fieldx; xx++)
@@ -1905,20 +2012,37 @@ static void ToggleBeltSwitch(int x, int y)
 
       if (IS_BELT_SWITCH(element))
       {
-       int e_belt_nr = getBeltNrFromSwitchElement(element);
+       int e_belt_nr = getBeltNrFromBeltSwitchElement(element);
+
+       if (e_belt_nr == belt_nr)
+       {
+         Feld[xx][yy] = belt_base_switch_element[belt_nr] + belt_dir_nr;
+         DrawLevelField(xx, yy);
+       }
+      }
+      else if (IS_BELT(element) && belt_dir != MV_NO_MOVING)
+      {
+       int e_belt_nr = getBeltNrFromBeltElement(element);
 
        if (e_belt_nr == belt_nr)
        {
-         Feld[xx][yy] = belt_base_element[belt_nr] + belt_dir_nr;
+         int belt_part = Feld[xx][yy] - belt_base_element[belt_nr];
+
+         Feld[xx][yy] = belt_base_active_element[belt_nr] + belt_part;
          DrawLevelField(xx, yy);
        }
       }
-      else if (belt_dir == MV_NO_MOVING && IS_BELT(element))
+      else if (IS_BELT_ACTIVE(element) && belt_dir == MV_NO_MOVING)
       {
-       int e_belt_nr = getBeltNrFromElement(element);
+       int e_belt_nr = getBeltNrFromBeltActiveElement(element);
 
        if (e_belt_nr == belt_nr)
-         DrawLevelField(xx, yy);    /* set belt to parking position */
+       {
+         int belt_part = Feld[xx][yy] - belt_base_active_element[belt_nr];
+
+         Feld[xx][yy] = belt_base_element[belt_nr] + belt_part;
+         DrawLevelField(xx, yy);
+       }
       }
     }
   }
@@ -1958,6 +2082,20 @@ static void ToggleSwitchgateSwitch(int x, int y)
   }
 }
 
+static int getInvisibleActiveFromInvisibleElement(int element)
+{
+  return (element == EL_INVISIBLE_STEELWALL ? EL_INVISIBLE_STEELWALL_ACTIVE :
+         element == EL_INVISIBLE_WALL      ? EL_INVISIBLE_WALL_ACTIVE :
+         EL_INVISIBLE_SAND_ACTIVE);
+}
+
+static int getInvisibleFromInvisibleActiveElement(int element)
+{
+  return (element == EL_INVISIBLE_STEELWALL_ACTIVE ? EL_INVISIBLE_STEELWALL :
+         element == EL_INVISIBLE_WALL_ACTIVE      ? EL_INVISIBLE_WALL :
+         EL_INVISIBLE_SAND);
+}
+
 static void RedrawAllLightSwitchesAndInvisibleElements()
 {
   int x, y;
@@ -1980,11 +2118,24 @@ static void RedrawAllLightSwitchesAndInvisibleElements()
        Feld[x][y] = EL_LIGHT_SWITCH;
        DrawLevelField(x, y);
       }
+      else if (element == EL_INVISIBLE_STEELWALL ||
+              element == EL_INVISIBLE_WALL ||
+              element == EL_INVISIBLE_SAND)
+      {
+       if (game.light_time_left > 0)
+         Feld[x][y] = getInvisibleActiveFromInvisibleElement(element);
+
+       DrawLevelField(x, y);
+      }
+      else if (element == EL_INVISIBLE_STEELWALL_ACTIVE ||
+              element == EL_INVISIBLE_WALL_ACTIVE ||
+              element == EL_INVISIBLE_SAND_ACTIVE)
+      {
+       if (game.light_time_left == 0)
+         Feld[x][y] = getInvisibleFromInvisibleActiveElement(element);
 
-      if (element == EL_INVISIBLE_STEELWALL ||
-         element == EL_INVISIBLE_WALL ||
-         element == EL_INVISIBLE_SAND)
        DrawLevelField(x, y);
+      }
     }
   }
 }
@@ -2094,8 +2245,8 @@ void Impact(int x, int y)
     {
       int xx, yy;
       int activated_magic_wall =
-       (smashed == EL_MAGIC_WALL ? EL_MAGIC_WALL_EMPTY :
-        EL_BD_MAGIC_WALL_EMPTY);
+       (smashed == EL_MAGIC_WALL ? EL_MAGIC_WALL_ACTIVE :
+        EL_BD_MAGIC_WALL_ACTIVE);
 
       /* activate magic wall / mill */
       for (yy=0; yy<lev_fieldy; yy++)
@@ -2158,7 +2309,7 @@ void Impact(int x, int y)
        }
        else if (smashed == EL_NUT)
        {
-         Feld[x][y+1] = EL_CRACKINGNUT;
+         Feld[x][y+1] = EL_NUT_CRACKING;
          PlaySoundLevel(x, y, SND_NUT_CRACKING);
          RaiseScoreElement(EL_NUT);
          return;
@@ -2195,12 +2346,12 @@ void Impact(int x, int y)
 
   /* play sound of magic wall / mill */
   if (!lastline &&
-      (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY ||
-       Feld[x][y+1] == EL_BD_MAGIC_WALL_EMPTY))
+      (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE ||
+       Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE))
   {
-    if (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY)
+    if (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE)
       PlaySoundLevel(x, y, SND_MAGIC_WALL_CHANGING);
-    else if (Feld[x][y+1] == EL_BD_MAGIC_WALL_EMPTY)
+    else if (Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE)
       PlaySoundLevel(x, y, SND_BD_MAGIC_WALL_CHANGING);
 
     return;
@@ -2242,18 +2393,18 @@ void TurnRound(int x, int y)
 
   int element = Feld[x][y];
   int old_move_dir = MovDir[x][y];
-  int left_dir = turn[old_move_dir].left;
+  int left_dir  = turn[old_move_dir].left;
   int right_dir = turn[old_move_dir].right;
-  int back_dir = turn[old_move_dir].back;
+  int back_dir  = turn[old_move_dir].back;
 
-  int left_dx = move_xy[left_dir].x, left_dy = move_xy[left_dir].y;
-  int right_dx = move_xy[right_dir].x, right_dy = move_xy[right_dir].y;
-  int move_dx = move_xy[old_move_dir].x, move_dy = move_xy[old_move_dir].y;
-  int back_dx = move_xy[back_dir].x, back_dy = move_xy[back_dir].y;
+  int left_dx  = move_xy[left_dir].x,     left_dy  = move_xy[left_dir].y;
+  int right_dx = move_xy[right_dir].x,    right_dy = move_xy[right_dir].y;
+  int move_dx  = move_xy[old_move_dir].x, move_dy  = move_xy[old_move_dir].y;
+  int back_dx  = move_xy[back_dir].x,     back_dy  = move_xy[back_dir].y;
 
-  int left_x = x+left_dx, left_y = y+left_dy;
-  int right_x = x+right_dx, right_y = y+right_dy;
-  int move_x = x+move_dx, move_y = y+move_dy;
+  int left_x  = x + left_dx,  left_y  = y + left_dy;
+  int right_x = x + right_dx, right_y = y + right_dy;
+  int move_x  = x + move_dx,  move_y  = y + move_dy;
 
   if (element == EL_BUG || element == EL_BD_BUTTERFLY)
   {
@@ -2497,17 +2648,18 @@ void TurnRound(int x, int y)
     MovDir[x][y] = game.balloon_dir;
     MovDelay[x][y] = 0;
   }
-  else if (element == EL_SPRING_MOVING)
+  else if (element == EL_SPRING)
   {
-    if (!IN_LEV_FIELD(move_x, move_y) || !IS_FREE(move_x, move_y) ||
-       (IN_LEV_FIELD(x, y+1) && IS_FREE(x, y+1)))
-    {
-      Feld[x][y] = EL_SPRING;
+    if ((MovDir[x][y] == MV_LEFT || MovDir[x][y] == MV_RIGHT) &&
+       (!IN_LEV_FIELD(move_x, move_y) || !IS_FREE(move_x, move_y) ||
+        (IN_LEV_FIELD(x, y + 1) && IS_FREE(x, y + 1))))
       MovDir[x][y] = MV_NO_MOVING;
-    }
+
     MovDelay[x][y] = 0;
   }
-  else if (element == EL_ROBOT || element == EL_SATELLITE || element == EL_PENGUIN)
+  else if (element == EL_ROBOT ||
+          element == EL_SATELLITE ||
+          element == EL_PENGUIN)
   {
     int attr_x = -1, attr_y = -1;
 
@@ -2655,12 +2807,16 @@ static boolean JustBeingPushed(int x, int y)
 
 void StartMoving(int x, int y)
 {
+  static boolean use_spring_bug = TRUE;
+  boolean started_moving = FALSE;      /* some elements can fall _and_ move */
   int element = Feld[x][y];
 
   if (Stop[x][y])
     return;
 
-  if (CAN_FALL(element) && y<lev_fieldy-1)
+  GfxAction[x][y] = GFX_ACTION_DEFAULT;
+
+  if (CAN_FALL(element) && y < lev_fieldy - 1)
   {
     if ((x>0 && IS_PLAYER(x-1, y)) || (x<lev_fieldx-1 && IS_PLAYER(x+1, y)))
       if (JustBeingPushed(x, y))
@@ -2671,6 +2827,8 @@ void StartMoving(int x, int y)
       if (IS_FREE(x, y+1))
       {
        InitMovingField(x, y, MV_DOWN);
+       started_moving = TRUE;
+
        Feld[x][y] = EL_QUICKSAND_EMPTYING;
        Store[x][y] = EL_ROCK;
        PlaySoundLevel(x, y, SND_QUICKSAND_EMPTYING);
@@ -2698,6 +2856,8 @@ void StartMoving(int x, int y)
             Feld[x][y+1] == EL_QUICKSAND_EMPTY)
     {
       InitMovingField(x, y, MV_DOWN);
+      started_moving = TRUE;
+
       Feld[x][y] = EL_QUICKSAND_FILLING;
       Store[x][y] = element;
       PlaySoundLevel(x, y, SND_QUICKSAND_FILLING);
@@ -2707,10 +2867,12 @@ void StartMoving(int x, int y)
       if (IS_FREE(x, y+1))
       {
        InitMovingField(x, y, MV_DOWN);
+       started_moving = TRUE;
+
        Feld[x][y] = EL_MAGIC_WALL_EMPTYING;
        Store[x][y] = EL_CHANGED(Store[x][y]);
       }
-      else if (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY)
+      else if (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE)
       {
        if (!MovDelay[x][y])
          MovDelay[x][y] = TILEY/4 + 1;
@@ -2722,7 +2884,7 @@ void StartMoving(int x, int y)
            return;
        }
 
-       Feld[x][y] = EL_MAGIC_WALL_EMPTY;
+       Feld[x][y] = EL_MAGIC_WALL_ACTIVE;
        Feld[x][y+1] = EL_MAGIC_WALL_FULL;
        Store[x][y+1] = EL_CHANGED(Store[x][y]);
        Store[x][y] = 0;
@@ -2733,10 +2895,12 @@ void StartMoving(int x, int y)
       if (IS_FREE(x, y+1))
       {
        InitMovingField(x, y, MV_DOWN);
+       started_moving = TRUE;
+
        Feld[x][y] = EL_BD_MAGIC_WALL_EMPTYING;
        Store[x][y] = EL_CHANGED2(Store[x][y]);
       }
-      else if (Feld[x][y+1] == EL_BD_MAGIC_WALL_EMPTY)
+      else if (Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE)
       {
        if (!MovDelay[x][y])
          MovDelay[x][y] = TILEY/4 + 1;
@@ -2748,26 +2912,31 @@ void StartMoving(int x, int y)
            return;
        }
 
-       Feld[x][y] = EL_BD_MAGIC_WALL_EMPTY;
+       Feld[x][y] = EL_BD_MAGIC_WALL_ACTIVE;
        Feld[x][y+1] = EL_BD_MAGIC_WALL_FULL;
        Store[x][y+1] = EL_CHANGED2(Store[x][y]);
        Store[x][y] = 0;
       }
     }
     else if (CAN_CHANGE(element) &&
-            (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY ||
-             Feld[x][y+1] == EL_BD_MAGIC_WALL_EMPTY))
+            (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE ||
+             Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE))
     {
       InitMovingField(x, y, MV_DOWN);
+      started_moving = TRUE;
+
       Feld[x][y] =
-       (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY ? EL_MAGIC_WALL_FILLING :
+       (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE ? EL_MAGIC_WALL_FILLING :
         EL_BD_MAGIC_WALL_FILLING);
       Store[x][y] = element;
     }
     else if (CAN_SMASH(element) && Feld[x][y+1] == EL_ACID)
     {
       Blurb(x, y);
+
       InitMovingField(x, y, MV_DOWN);
+      started_moving = TRUE;
+
       Store[x][y] = EL_ACID;
     }
     else if (CAN_SMASH(element) && Feld[x][y+1] == EL_BLOCKED &&
@@ -2775,9 +2944,18 @@ void StartMoving(int x, int y)
     {
       Impact(x, y);
     }
+    else if (IS_FREE(x, y+1) && element == EL_SPRING && use_spring_bug)
+    {
+      if (MovDir[x][y] == MV_NO_MOVING)
+      {
+       InitMovingField(x, y, MV_DOWN);
+       started_moving = TRUE;
+      }
+    }
     else if (IS_FREE(x, y+1))
     {
       InitMovingField(x, y, MV_DOWN);
+      started_moving = TRUE;
     }
     else if (element == EL_AMOEBA_DROP)
     {
@@ -2815,44 +2993,71 @@ void StartMoving(int x, int y)
          left = !(right = RND(2));
 
        InitMovingField(x, y, left ? MV_LEFT : MV_RIGHT);
+       started_moving = TRUE;
       }
     }
-    else if (IS_BELT(Feld[x][y+1]))
+    else if (IS_BELT_ACTIVE(Feld[x][y+1]))
     {
       boolean left_is_free  = (x>0 && IS_FREE(x-1, y));
       boolean right_is_free = (x<lev_fieldx-1 && IS_FREE(x+1, y));
-      int belt_nr = getBeltNrFromElement(Feld[x][y+1]);
+      int belt_nr = getBeltNrFromBeltActiveElement(Feld[x][y+1]);
       int belt_dir = game.belt_dir[belt_nr];
 
       if ((belt_dir == MV_LEFT  && left_is_free) ||
          (belt_dir == MV_RIGHT && right_is_free))
+      {
        InitMovingField(x, y, belt_dir);
+       started_moving = TRUE;
+
+       GfxAction[x][y] = GFX_ACTION_DEFAULT;
+      }
     }
   }
-  else if (CAN_MOVE(element))
+
+  /* not "else if" because of EL_SPRING */
+  if (CAN_MOVE(element) && !started_moving)
   {
     int newx, newy;
 
-    if ((element == EL_SATELLITE || element == EL_BALLOON ||
-        element == EL_SPRING_MOVING)
+    if ((element == EL_SATELLITE ||
+        element == EL_BALLOON ||
+        element == EL_SPRING)
        && JustBeingPushed(x, y))
       return;
 
+#if 0
+#if 0
+    if (element == EL_SPRING && MovDir[x][y] == MV_DOWN)
+      Feld[x][y + 1] = EL_EMPTY;       /* was set to EL_BLOCKED above */
+#else
+    if (element == EL_SPRING && MovDir[x][y] != MV_NO_MOVING)
+    {
+      Moving2Blocked(x, y, &newx, &newy);
+      if (Feld[newx][newy] == EL_BLOCKED)
+       Feld[newx][newy] = EL_EMPTY;    /* was set to EL_BLOCKED above */
+    }
+#endif
+#endif
+
     if (!MovDelay[x][y])       /* start new movement phase */
     {
       /* all objects that can change their move direction after each step */
       /* (MAMPFER, MAMPFER2 and PACMAN go straight until they hit a wall  */
 
-      if (element!=EL_YAMYAM && element!=EL_DARK_YAMYAM && element!=EL_PACMAN)
+      if (element != EL_YAMYAM &&
+         element != EL_DARK_YAMYAM &&
+         element != EL_PACMAN)
       {
+#if 0
+  if (element == EL_SPRING)
+    printf("1--> %d\n", MovDir[x][y]);
+#endif
        TurnRound(x, y);
-
+#if 0
+  if (element == EL_SPRING)
+    printf("2--> %d\n", MovDir[x][y]);
+#endif
        if (MovDelay[x][y] && (element == EL_BUG ||
-                              element == EL_SPACESHIP ||
-                              element == EL_SP_SNIKSNAK ||
-                              element == EL_SP_ELECTRON))
-         DrawNewLevelField(x, y);
-       else if (MovDelay[x][y] && (element == EL_BUG ||
                               element == EL_SPACESHIP ||
                               element == EL_SP_SNIKSNAK ||
                               element == EL_SP_ELECTRON ||
@@ -2868,13 +3073,13 @@ void StartMoving(int x, int y)
       if (element == EL_ROBOT ||
          element == EL_YAMYAM || element == EL_DARK_YAMYAM)
       {
-       int phase = MovDelay[x][y] % 8;
-
-       if (phase > 3)
-         phase = 7 - phase;
-
        if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-         DrawGraphic(SCREENX(x), SCREENY(y), el2gfx(element) + phase);
+       {
+         int graphic = el2img(element);
+         int frame = getGraphicAnimationFrame(graphic, MovDelay[x][y] % 8);
+
+         DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame);
+       }
 
        if (MovDelay[x][y] % 4 == 3)
        {
@@ -2885,23 +3090,24 @@ void StartMoving(int x, int y)
        }
       }
       else if (element == EL_SP_ELECTRON)
-       DrawGraphicAnimation(x, y, GFX2_SP_ELECTRON, 8, 2, ANIM_NORMAL);
+       DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_ELECTRON);
       else if (element == EL_DRAGON)
       {
        int i;
        int dir = MovDir[x][y];
        int dx = (dir == MV_LEFT ? -1 : dir == MV_RIGHT ? +1 : 0);
        int dy = (dir == MV_UP   ? -1 : dir == MV_DOWN  ? +1 : 0);
-       int graphic = (dir == MV_LEFT   ? GFX_FLAMMEN_LEFT :
-                      dir == MV_RIGHT  ? GFX_FLAMMEN_RIGHT :
-                      dir == MV_UP     ? GFX_FLAMMEN_UP :
-                      dir == MV_DOWN   ? GFX_FLAMMEN_DOWN : GFX_LEERRAUM);
-       int phase = FrameCounter % 2;
+       int graphic = (dir == MV_LEFT   ? IMG_FLAMES_LEFT1 :
+                      dir == MV_RIGHT  ? IMG_FLAMES_RIGHT1 :
+                      dir == MV_UP     ? IMG_FLAMES_UP1 :
+                      dir == MV_DOWN   ? IMG_FLAMES_DOWN1 : IMG_EMPTY);
+       int frame = getGraphicAnimationFrame(graphic, -1);
 
        for (i=1; i<=3; i++)
        {
          int xx = x + i*dx, yy = y + i*dy;
          int sx = SCREENX(xx), sy = SCREENY(yy);
+         int flame_graphic = graphic + (i - 1);
 
          if (!IN_LEV_FIELD(xx, yy) ||
              IS_SOLID(Feld[xx][yy]) || Feld[xx][yy] == EL_EXPLOSION)
@@ -2916,13 +3122,13 @@ void StartMoving(int x, int y)
            else
              RemoveMovingField(xx, yy);
 
-           Feld[xx][yy] = EL_DRAGON_FIRE;
+           Feld[xx][yy] = EL_FLAMES;
            if (IN_SCR_FIELD(sx, sy))
-             DrawGraphic(sx, sy, graphic + phase*3 + i-1);
+             DrawGraphic(sx, sy, flame_graphic, frame);
          }
          else
          {
-           if (Feld[xx][yy] == EL_DRAGON_FIRE)
+           if (Feld[xx][yy] == EL_FLAMES)
              Feld[xx][yy] = EL_EMPTY;
            DrawLevelField(xx, yy);
          }
@@ -2973,7 +3179,7 @@ void StartMoving(int x, int y)
 
        PlaySoundLevel(newx, newy, SND_PENGUIN_PASSING_EXIT);
        if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy)))
-         DrawGraphicThruMask(SCREENX(newx), SCREENY(newy), el2gfx(element));
+         DrawGraphicThruMask(SCREENX(newx),SCREENY(newy), el2img(element), 0);
 
        local_player->friends_still_needed--;
        if (!local_player->friends_still_needed &&
@@ -3044,7 +3250,7 @@ void StartMoving(int x, int y)
 
        if ((wanna_flame || IS_ENEMY(element1) || IS_ENEMY(element2)) &&
            element1 != EL_DRAGON && element2 != EL_DRAGON &&
-           element1 != EL_DRAGON_FIRE && element2 != EL_DRAGON_FIRE)
+           element1 != EL_FLAMES && element2 != EL_FLAMES)
        {
          if (IS_PLAYER(x, y))
            DrawPlayerField(x, y);
@@ -3054,11 +3260,11 @@ void StartMoving(int x, int y)
          PlaySoundLevel(x, y, SND_DRAGON_ATTACKING);
 
          MovDelay[x][y] = 50;
-         Feld[newx][newy] = EL_DRAGON_FIRE;
+         Feld[newx][newy] = EL_FLAMES;
          if (IN_LEV_FIELD(newx1, newy1) && Feld[newx1][newy1] == EL_EMPTY)
-           Feld[newx1][newy1] = EL_DRAGON_FIRE;
+           Feld[newx1][newy1] = EL_FLAMES;
          if (IN_LEV_FIELD(newx2, newy2) && Feld[newx2][newy2] == EL_EMPTY)
-           Feld[newx2][newy2] = EL_DRAGON_FIRE;
+           Feld[newx2][newy2] = EL_FLAMES;
          return;
        }
       }
@@ -3118,7 +3324,7 @@ void StartMoving(int x, int y)
       else     /* element == EL_PACMAN */
       {
        Feld[newx][newy] = EL_EMPTY;
-       DrawNewLevelField(newx, newy);
+       DrawLevelField(newx, newy);
        PlaySoundLevel(x, y, SND_PACMAN_EATING);
       }
     }
@@ -3137,36 +3343,16 @@ void StartMoving(int x, int y)
 
       if (element == EL_BUG || element == EL_SPACESHIP ||
          element == EL_SP_SNIKSNAK)
-#if 0
        DrawLevelField(x, y);
-#else
-       DrawNewLevelField(x, y);
-#endif
       else if (element == EL_BUG || element == EL_SPACESHIP ||
               element == EL_SP_SNIKSNAK || element == EL_MOLE)
-#if 1
        DrawLevelField(x, y);
-#else
-       DrawNewLevelField(x, y);
-#endif
       else if (element == EL_BD_BUTTERFLY || element == EL_BD_FIREFLY)
-#if 0
-       DrawGraphicAnimation(x, y, el2gfx(element), 2, 4, ANIM_NORMAL);
-#else
-       DrawNewGraphicAnimation(x, y, el2img(element));
-#endif
+       DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(element));
       else if (element == EL_SATELLITE)
-#if 0
-       DrawGraphicAnimation(x, y, GFX_SONDE_START, 8, 2, ANIM_NORMAL);
-#else
-       DrawNewGraphicAnimation(x, y, IMG_SATELLITE);
-#endif
+       DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SATELLITE);
       else if (element == EL_SP_ELECTRON)
-#if 0
-       DrawGraphicAnimation(x, y, GFX2_SP_ELECTRON, 8, 2, ANIM_NORMAL);
-#else
-       DrawNewGraphicAnimation(x, y, IMG_SP_ELECTRON);
-#endif
+       DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_ELECTRON);
 
       if (DONT_TOUCH(element))
        TestIfBadThingTouchesHero(x, y);
@@ -3191,7 +3377,7 @@ void ContinueMoving(int x, int y)
   int direction = MovDir[x][y];
   int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0);
   int dy = (direction == MV_UP   ? -1 : direction == MV_DOWN  ? +1 : 0);
-  int horiz_move = (dx!=0);
+  int horiz_move = (dx != 0);
   int newx = x + dx, newy = y + dy;
   int step = (horiz_move ? dx : dy) * TILEX / 8;
 
@@ -3206,10 +3392,10 @@ void ContinueMoving(int x, int y)
           element == EL_BD_MAGIC_WALL_EMPTYING)
     step /= 2;
   else if (CAN_FALL(element) && horiz_move &&
-          y < lev_fieldy-1 && IS_BELT(Feld[x][y+1]))
+          y < lev_fieldy-1 && IS_BELT_ACTIVE(Feld[x][y+1]))
     step /= 2;
-  else if (element == EL_SPRING_MOVING)
-    step*=2;
+  else if (element == EL_SPRING && horiz_move)
+    step *= 2;
 
 #if OLD_GAME_BEHAVIOUR
   else if (CAN_FALL(element) && horiz_move && !IS_SP_ELEMENT(element))
@@ -3245,7 +3431,7 @@ void ContinueMoving(int x, int y)
        yy = y + xy[i][1];
 
        if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_SAND)
-         DrawLevelField(xx, yy);       /* for "ErdreichAnbroeckeln()" */
+         DrawLevelField(xx, yy);       /* for "DrawCrumbledSand()" */
       }
     }
 
@@ -3301,21 +3487,25 @@ void ContinueMoving(int x, int y)
     MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0;
     MovDelay[newx][newy] = 0;
 
+    GfxAction[newx][newy] = GfxAction[x][y];   /* keep action one frame */
+    GfxAction[x][y] = GFX_ACTION_DEFAULT;
+
+#if 0
     if (!CAN_MOVE(element))
       MovDir[newx][newy] = 0;
+#else
+    /*
+    if (CAN_FALL(element) && MovDir[newx][newy] == MV_DOWN)
+      MovDir[newx][newy] = 0;
+    */
 
-    if (element == EL_BUG || element == EL_SPACESHIP ||
-       element == EL_SP_SNIKSNAK || element == EL_PACMAN ||
-       element == EL_SP_ELECTRON)
-    {
-      DrawNewLevelField(x, y);
-      DrawNewLevelField(newx, newy);
-    }
-    else
-    {
-      DrawLevelField(x, y);
-      DrawLevelField(newx, newy);
-    }
+    if (!CAN_MOVE(element) ||
+       (element == EL_SPRING && MovDir[newx][newy] == MV_DOWN))
+      MovDir[newx][newy] = 0;
+#endif
+
+    DrawLevelField(x, y);
+    DrawLevelField(newx, newy);
 
     Stop[newx][newy] = TRUE;
     JustStopped[newx][newy] = 3;
@@ -3335,12 +3525,16 @@ void ContinueMoving(int x, int y)
   }
   else                         /* still moving on */
   {
-    if (element == EL_BUG || element == EL_SPACESHIP ||
-       element == EL_SP_SNIKSNAK || element == EL_PACMAN ||
-       element == EL_SP_ELECTRON)
-      DrawNewLevelField(x, y);
-    else
-      DrawLevelField(x, y);
+#if 0
+    if (GfxAction[x][y] == GFX_ACTION_DEFAULT)
+    {
+      printf("reset GfxAction...\n");
+
+      GfxAction[x][y] = GFX_ACTION_MOVING;
+    }
+#endif
+
+    DrawLevelField(x, y);
   }
 }
 
@@ -3546,7 +3740,12 @@ void AmoebeWaechst(int x, int y)
   {
     MovDelay[x][y]--;
     if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-      DrawGraphic(SCREENX(x), SCREENY(y), GFX_AMOEBING + 3 - MovDelay[x][y]/2);
+    {
+      int frame = getGraphicAnimationFrame(IMG_AMOEBA_CREATING,
+                                          6 - MovDelay[x][y]);
+
+      DrawGraphic(SCREENX(x), SCREENY(y), IMG_AMOEBA_CREATING, frame);
+    }
 
     if (!MovDelay[x][y])
     {
@@ -3574,7 +3773,12 @@ void AmoebaDisappearing(int x, int y)
   {
     MovDelay[x][y]--;
     if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-      DrawGraphic(SCREENX(x), SCREENY(y), GFX_AMOEBING + MovDelay[x][y]/2);
+    {
+      int frame = getGraphicAnimationFrame(IMG_AMOEBA_SHRINKING,
+                                          6 - MovDelay[x][y]);
+
+      DrawGraphic(SCREENX(x), SCREENY(y), IMG_AMOEBA_SHRINKING, frame);
+    }
 
     if (!MovDelay[x][y])
     {
@@ -3817,15 +4021,21 @@ void RobotWheel(int x, int y)
     if (MovDelay[x][y])
     {
       if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-       DrawGraphic(SCREENX(x), SCREENY(y), GFX_ABLENK+MovDelay[x][y]%4);
-      if (!(MovDelay[x][y]%4))
-       PlaySoundLevel(x, y, SND_ROBOT_WHEEL_ACTIVE);
+      {
+       int frame = getGraphicAnimationFrame(IMG_ROBOT_WHEEL_ACTIVE, -1);
+
+       DrawGraphic(SCREENX(x), SCREENY(y), IMG_ROBOT_WHEEL_ACTIVE, frame);
+      }
+
+      PlaySoundLevel(x, y, SND_ROBOT_WHEEL_ACTIVE);
+
       return;
     }
   }
 
   Feld[x][y] = EL_ROBOT_WHEEL;
   DrawLevelField(x, y);
+
   if (ZX == x && ZY == y)
     ZX = ZY = -1;
 }
@@ -3841,28 +4051,26 @@ void TimegateWheel(int x, int y)
     if (MovDelay[x][y])
     {
       if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-       DrawGraphic(SCREENX(x), SCREENY(y),
-                   GFX_TIMEGATE_SWITCH + MovDelay[x][y]%4);
-      if (!(MovDelay[x][y]%4))
-       PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE);
+      {
+       int frame = getGraphicAnimationFrame(IMG_TIMEGATE_SWITCH_ACTIVE, -1);
+
+       DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_SWITCH_ACTIVE, frame);
+      }
+
+      PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE);
+
       return;
     }
   }
 
   Feld[x][y] = EL_TIMEGATE_SWITCH;
   DrawLevelField(x, y);
+
+  /* !!! THIS LOOKS WRONG !!! */
   if (ZX == x && ZY == y)
     ZX = ZY = -1;
 }
 
-void Blubber(int x, int y)
-{
-  if (y > 0 && IS_MOVING(x, y-1) && MovDir[x][y-1] == MV_DOWN)
-    DrawLevelField(x, y-1);
-  else
-    DrawGraphicAnimation(x, y, GFX_GEBLUBBER, 4, 10, ANIM_NORMAL);
-}
-
 void NussKnacken(int x, int y)
 {
   if (!MovDelay[x][y])         /* next animation frame */
@@ -3871,16 +4079,22 @@ void NussKnacken(int x, int y)
   if (MovDelay[x][y])          /* wait some time before next frame */
   {
     MovDelay[x][y]--;
-    if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-      DrawGraphic(SCREENX(x), SCREENY(y),
-                 GFX_CRACKINGNUT + 3 - MovDelay[x][y]/2);
-
-    if (!MovDelay[x][y])
+    if (MovDelay[x][y])
     {
-      Feld[x][y] = EL_EMERALD;
-      DrawLevelField(x, y);
+      if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+      {
+       int frame = getGraphicAnimationFrame(IMG_NUT_CRACKING,
+                                            6 - MovDelay[x][y]);
+
+       DrawGraphic(SCREENX(x), SCREENY(y), IMG_NUT_CRACKING, frame);
+      }
+
+      return;
     }
   }
+
+  Feld[x][y] = EL_EMERALD;
+  DrawLevelField(x, y);
 }
 
 void BreakingPearl(int x, int y)
@@ -3891,23 +4105,29 @@ void BreakingPearl(int x, int y)
   if (MovDelay[x][y])          /* wait some time before next frame */
   {
     MovDelay[x][y]--;
-    if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-      DrawGraphic(SCREENX(x), SCREENY(y),
-                 GFX_PEARL_BREAKING + 4 - MovDelay[x][y]/2);
-
-    if (!MovDelay[x][y])
+    if (MovDelay[x][y])
     {
-      Feld[x][y] = EL_EMPTY;
-      DrawLevelField(x, y);
+      if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+      {
+       int frame = getGraphicAnimationFrame(IMG_PEARL_BREAKING,
+                                            8 - MovDelay[x][y]);
+
+       DrawGraphic(SCREENX(x), SCREENY(y), IMG_PEARL_BREAKING, frame);
+      }
+
+      return;
     }
   }
+
+  Feld[x][y] = EL_EMPTY;
+  DrawLevelField(x, y);
 }
 
-void SiebAktivieren(int x, int y, int typ)
+void SiebAktivieren(int x, int y, int type)
 {
-  int graphic = (typ == 1 ? GFX_MAGIC_WALL_FULL : GFX_MAGIC_WALL_BD_FULL) + 3;
+  int graphic = (type == 1 ? IMG_MAGIC_WALL_FULL : IMG_BD_MAGIC_WALL_FULL);
 
-  DrawGraphicAnimation(x, y, graphic, 4, 4, ANIM_REVERSE);
+  DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
 }
 
 void AusgangstuerPruefen(int x, int y)
@@ -3945,28 +4165,32 @@ void AusgangstuerOeffnen(int x, int y)
   int delay = 6;
 
   if (!MovDelay[x][y])         /* next animation frame */
-    MovDelay[x][y] = 5*delay;
+    MovDelay[x][y] = 5 * delay;
 
   if (MovDelay[x][y])          /* wait some time before next frame */
   {
     int tuer;
 
     MovDelay[x][y]--;
-    tuer = MovDelay[x][y]/delay;
-    if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-      DrawGraphic(SCREENX(x), SCREENY(y), GFX_AUSGANG_AUF-tuer);
+    tuer = MovDelay[x][y] / delay;
 
-    if (!MovDelay[x][y])
+    if (!(MovDelay[x][y] % delay))
     {
-      Feld[x][y] = EL_EXIT_OPEN;
-      DrawLevelField(x, y);
+      if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+      {
+       int frame = getGraphicAnimationFrame(IMG_EXIT_OPENING,
+                                            29 - MovDelay[x][y]);
+
+       DrawGraphic(SCREENX(x), SCREENY(y), IMG_EXIT_OPENING, frame);
+      }
     }
+
+    if (MovDelay[x][y])
+      return;
   }
-}
 
-void AusgangstuerBlinken(int x, int y)
-{
-  DrawGraphicAnimation(x, y, GFX_AUSGANG_AUF, 4, 4, ANIM_PINGPONG);
+  Feld[x][y] = EL_EXIT_OPEN;
+  DrawLevelField(x, y);
 }
 
 void OpenSwitchgate(int x, int y)
@@ -3978,19 +4202,25 @@ void OpenSwitchgate(int x, int y)
 
   if (MovDelay[x][y])          /* wait some time before next frame */
   {
-    int phase;
-
     MovDelay[x][y]--;
-    phase = MovDelay[x][y] / delay;
-    if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-      DrawGraphic(SCREENX(x), SCREENY(y), GFX_SWITCHGATE_OPEN - phase);
 
-    if (!MovDelay[x][y])
+    if (!(MovDelay[x][y] % delay))
     {
-      Feld[x][y] = EL_SWITCHGATE_OPEN;
-      DrawLevelField(x, y);
+      if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+      {
+       int frame = getGraphicAnimationFrame(IMG_SWITCHGATE_OPENING,
+                                            29 - MovDelay[x][y]);
+
+       DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_OPENING, frame);
+      }
     }
+
+    if (MovDelay[x][y])
+      return;
   }
+
+  Feld[x][y] = EL_SWITCHGATE_OPEN;
+  DrawLevelField(x, y);
 }
 
 void CloseSwitchgate(int x, int y)
@@ -4002,19 +4232,25 @@ void CloseSwitchgate(int x, int y)
 
   if (MovDelay[x][y])          /* wait some time before next frame */
   {
-    int phase;
-
     MovDelay[x][y]--;
-    phase = MovDelay[x][y] / delay;
-    if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-      DrawGraphic(SCREENX(x), SCREENY(y), GFX_SWITCHGATE_CLOSED + phase);
 
-    if (!MovDelay[x][y])
+    if (!(MovDelay[x][y] % delay))
     {
-      Feld[x][y] = EL_SWITCHGATE_CLOSED;
-      DrawLevelField(x, y);
+      if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+      {
+       int frame = getGraphicAnimationFrame(IMG_SWITCHGATE_CLOSING,
+                                            29 - MovDelay[x][y]);
+
+       DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_CLOSING, frame);
+      }
     }
+
+    if (MovDelay[x][y])
+      return;
   }
+
+  Feld[x][y] = EL_SWITCHGATE_CLOSED;
+  DrawLevelField(x, y);
 }
 
 void OpenTimegate(int x, int y)
@@ -4026,19 +4262,25 @@ void OpenTimegate(int x, int y)
 
   if (MovDelay[x][y])          /* wait some time before next frame */
   {
-    int phase;
-
     MovDelay[x][y]--;
-    phase = MovDelay[x][y] / delay;
-    if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-      DrawGraphic(SCREENX(x), SCREENY(y), GFX_TIMEGATE_OPEN - phase);
 
-    if (!MovDelay[x][y])
+    if (!(MovDelay[x][y] % delay))
     {
-      Feld[x][y] = EL_TIMEGATE_OPEN;
-      DrawLevelField(x, y);
+      if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+      {
+       int frame = getGraphicAnimationFrame(IMG_TIMEGATE_OPENING,
+                                            29 - MovDelay[x][y]);
+
+       DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_OPENING, frame);
+      }
     }
+
+    if (MovDelay[x][y])
+      return;
   }
+
+  Feld[x][y] = EL_TIMEGATE_OPEN;
+  DrawLevelField(x, y);
 }
 
 void CloseTimegate(int x, int y)
@@ -4050,19 +4292,25 @@ void CloseTimegate(int x, int y)
 
   if (MovDelay[x][y])          /* wait some time before next frame */
   {
-    int phase;
-
     MovDelay[x][y]--;
-    phase = MovDelay[x][y] / delay;
-    if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-      DrawGraphic(SCREENX(x), SCREENY(y), GFX_TIMEGATE_CLOSED + phase);
 
-    if (!MovDelay[x][y])
+    if (!(MovDelay[x][y] % delay))
     {
-      Feld[x][y] = EL_TIMEGATE_CLOSED;
-      DrawLevelField(x, y);
+      if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+      {
+       int frame = getGraphicAnimationFrame(IMG_TIMEGATE_CLOSING,
+                                            29 - MovDelay[x][y]);
+
+       DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_CLOSING, frame);
+      }
     }
+
+    if (MovDelay[x][y])
+      return;
   }
+
+  Feld[x][y] = EL_TIMEGATE_CLOSED;
+  DrawLevelField(x, y);
 }
 
 static void CloseAllOpenTimegates()
@@ -4090,7 +4338,7 @@ void EdelsteinFunkeln(int x, int y)
     return;
 
   if (Feld[x][y] == EL_BD_DIAMOND)
-    DrawGraphicAnimation(x, y, GFX_EDELSTEIN_BD, 4, 4, ANIM_REVERSE);
+    DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_BD_DIAMOND);
   else
   {
     if (!MovDelay[x][y])       /* next animation frame */
@@ -4103,23 +4351,25 @@ void EdelsteinFunkeln(int x, int y)
       if (setup.direct_draw && MovDelay[x][y])
        SetDrawtoField(DRAW_BUFFERED);
 
-      DrawGraphic(SCREENX(x), SCREENY(y), el2gfx(Feld[x][y]));
+#if 0
+      DrawGraphic(SCREENX(x), SCREENY(y), el2img(Feld[x][y]), 0);
+#else
+      DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(Feld[x][y]));
+#endif
 
       if (MovDelay[x][y])
       {
-       int phase = (MovDelay[x][y]-1)/2;
+       int frame = getGraphicAnimationFrame(IMG_TWINKLE_WHITE,
+                                            10 - MovDelay[x][y]);
 
-       if (phase > 2)
-         phase = 4-phase;
-
-       DrawGraphicThruMask(SCREENX(x), SCREENY(y), GFX_FUNKELN_WEISS + phase);
+       DrawGraphicThruMask(SCREENX(x), SCREENY(y), IMG_TWINKLE_WHITE, frame);
 
        if (setup.direct_draw)
        {
          int dest_x, dest_y;
 
-         dest_x = FX + SCREENX(x)*TILEX;
-         dest_y = FY + SCREENY(y)*TILEY;
+         dest_x = FX + SCREENX(x) * TILEX;
+         dest_y = FY + SCREENY(y) * TILEY;
 
          BlitBitmap(drawto_field, window,
                     dest_x, dest_y, TILEX, TILEY, dest_x, dest_y);
@@ -4135,42 +4385,41 @@ void MauerWaechst(int x, int y)
   int delay = 6;
 
   if (!MovDelay[x][y])         /* next animation frame */
-    MovDelay[x][y] = 3*delay;
+    MovDelay[x][y] = 3 * delay;
 
   if (MovDelay[x][y])          /* wait some time before next frame */
   {
-    int phase;
-
     MovDelay[x][y]--;
-    phase = 2-MovDelay[x][y]/delay;
-    if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-      DrawGraphic(SCREENX(x), SCREENY(y),
-                 (MovDir[x][y] == MV_LEFT  ? GFX_MAUER_LEFT  :
-                  MovDir[x][y] == MV_RIGHT ? GFX_MAUER_RIGHT :
-                  MovDir[x][y] == MV_UP    ? GFX_MAUER_UP    :
-                                             GFX_MAUER_DOWN  ) + phase);
+
+    if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+    {
+      int graphic = el_dir2img(Feld[x][y], MovDir[x][y]);
+      int frame = getGraphicAnimationFrame(graphic, 17 - MovDelay[x][y]);
+
+      DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame);
+    }
 
     if (!MovDelay[x][y])
     {
       if (MovDir[x][y] == MV_LEFT)
       {
-       if (IN_LEV_FIELD(x-1, y) && IS_MAUER(Feld[x-1][y]))
-         DrawLevelField(x-1, y);
+       if (IN_LEV_FIELD(x - 1, y) && IS_MAUER(Feld[x - 1][y]))
+         DrawLevelField(x - 1, y);
       }
       else if (MovDir[x][y] == MV_RIGHT)
       {
-       if (IN_LEV_FIELD(x+1, y) && IS_MAUER(Feld[x+1][y]))
-         DrawLevelField(x+1, y);
+       if (IN_LEV_FIELD(x + 1, y) && IS_MAUER(Feld[x + 1][y]))
+         DrawLevelField(x + 1, y);
       }
       else if (MovDir[x][y] == MV_UP)
       {
-       if (IN_LEV_FIELD(x, y-1) && IS_MAUER(Feld[x][y-1]))
-         DrawLevelField(x, y-1);
+       if (IN_LEV_FIELD(x, y - 1) && IS_MAUER(Feld[x][y - 1]))
+         DrawLevelField(x, y - 1);
       }
       else
       {
-       if (IN_LEV_FIELD(x, y+1) && IS_MAUER(Feld[x][y+1]))
-         DrawLevelField(x, y+1);
+       if (IN_LEV_FIELD(x, y + 1) && IS_MAUER(Feld[x][y + 1]))
+         DrawLevelField(x, y + 1);
       }
 
       Feld[x][y] = Store[x][y];
@@ -4217,7 +4466,8 @@ void MauerAbleger(int ax, int ay)
       Store[ax][ay-1] = element;
       MovDir[ax][ay-1] = MV_UP;
       if (IN_SCR_FIELD(SCREENX(ax), SCREENY(ay-1)))
-       DrawGraphic(SCREENX(ax), SCREENY(ay-1), GFX_MAUER_UP);
+       DrawGraphic(SCREENX(ax), SCREENY(ay - 1),
+                   IMG_WALL_GROWING_ACTIVE_UP, 0);
       new_wall = TRUE;
     }
     if (unten_frei)
@@ -4226,7 +4476,8 @@ void MauerAbleger(int ax, int ay)
       Store[ax][ay+1] = element;
       MovDir[ax][ay+1] = MV_DOWN;
       if (IN_SCR_FIELD(SCREENX(ax), SCREENY(ay+1)))
-       DrawGraphic(SCREENX(ax), SCREENY(ay+1), GFX_MAUER_DOWN);
+       DrawGraphic(SCREENX(ax), SCREENY(ay + 1),
+                   IMG_WALL_GROWING_ACTIVE_DOWN, 0);
       new_wall = TRUE;
     }
   }
@@ -4240,7 +4491,8 @@ void MauerAbleger(int ax, int ay)
       Store[ax-1][ay] = element;
       MovDir[ax-1][ay] = MV_LEFT;
       if (IN_SCR_FIELD(SCREENX(ax-1), SCREENY(ay)))
-       DrawGraphic(SCREENX(ax-1), SCREENY(ay), GFX_MAUER_LEFT);
+       DrawGraphic(SCREENX(ax - 1), SCREENY(ay),
+                   IMG_WALL_GROWING_ACTIVE_LEFT, 0);
       new_wall = TRUE;
     }
 
@@ -4250,7 +4502,8 @@ void MauerAbleger(int ax, int ay)
       Store[ax+1][ay] = element;
       MovDir[ax+1][ay] = MV_RIGHT;
       if (IN_SCR_FIELD(SCREENX(ax+1), SCREENY(ay)))
-       DrawGraphic(SCREENX(ax+1), SCREENY(ay), GFX_MAUER_RIGHT);
+       DrawGraphic(SCREENX(ax + 1), SCREENY(ay),
+                   IMG_WALL_GROWING_ACTIVE_RIGHT, 0);
       new_wall = TRUE;
     }
   }
@@ -4296,7 +4549,7 @@ void CheckForDragon(int x, int y)
       int xx = x + j*xy[i][0], yy = y + j*xy[i][1];
 
       if (IN_LEV_FIELD(xx, yy) &&
-         (Feld[xx][yy] == EL_DRAGON_FIRE || Feld[xx][yy] == EL_DRAGON))
+         (Feld[xx][yy] == EL_FLAMES || Feld[xx][yy] == EL_DRAGON))
       {
        if (Feld[xx][yy] == EL_DRAGON)
          dragon_found = TRUE;
@@ -4314,7 +4567,7 @@ void CheckForDragon(int x, int y)
       {
        int xx = x + j*xy[i][0], yy = y + j*xy[i][1];
   
-       if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_DRAGON_FIRE)
+       if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_FLAMES)
        {
          Feld[xx][yy] = EL_EMPTY;
          DrawLevelField(xx, yy);
@@ -4339,7 +4592,7 @@ static void CheckBuggyBase(int x, int y)
     {
       MovDelay[x][y]--;
       if (MovDelay[x][y] < 5 && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-       DrawGraphic(SCREENX(x), SCREENY(y), GFX_SP_BUG_WARNING);
+        DrawGraphic(SCREENX(x), SCREENY(y), IMG_SP_BUGGY_BASE, 0);
       if (MovDelay[x][y])
        return;
 
@@ -4366,7 +4619,12 @@ static void CheckBuggyBase(int x, int y)
        };
 
        if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-         DrawGraphic(SCREENX(x),SCREENY(y), GFX_SP_BUG_ACTIVE + SimpleRND(4));
+       {
+         int graphic = IMG_SP_BUGGY_BASE_ACTIVE;
+         int frame = getGraphicAnimationFrame(graphic, SimpleRND(100));
+
+          DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame);
+       }
 
        for (i=0; i<4; i++)
        {
@@ -4374,7 +4632,7 @@ static void CheckBuggyBase(int x, int y)
 
          if (IS_PLAYER(xx, yy))
          {
-           PlaySoundLevel(x, y, SND_SP_BUGGY_BASE_ACTIVATING);
+           PlaySoundLevel(x, y, SND_SP_BUGGY_BASE_ACTIVE);
            break;
          }
        }
@@ -4423,15 +4681,13 @@ static void CheckTrap(int x, int y)
       {
        if (!(MovDelay[x][y] % delay))
        {
-         int phase = MovDelay[x][y]/delay;
-
-         if (phase >= num_frames/2)
-           phase = num_frames - phase;
-
          if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
          {
-           DrawGraphic(SCREENX(x),SCREENY(y), GFX_TRAP_INACTIVE + phase - 1);
-           ErdreichAnbroeckeln(SCREENX(x), SCREENY(y));
+           int graphic = IMG_TRAP_ACTIVE;
+           int frame = getGraphicAnimationFrame(graphic, 31 - MovDelay[x][y]);
+
+           DrawGraphic(SCREENX(x),SCREENY(y), graphic, frame);
+           DrawCrumbledSand(SCREENX(x), SCREENY(y));
          }
        }
 
@@ -4446,16 +4702,14 @@ static void CheckTrap(int x, int y)
 
 static void DrawBeltAnimation(int x, int y, int element)
 {
-  int belt_nr = getBeltNrFromElement(element);
+  int belt_nr = getBeltNrFromBeltActiveElement(element);
   int belt_dir = game.belt_dir[belt_nr];
 
   if (belt_dir != MV_NO_MOVING)
   {
-    int delay = 2;
-    int mode = (belt_dir == MV_LEFT ? ANIM_NORMAL : ANIM_REVERSE);
-    int graphic = el2gfx(element) + (belt_dir == MV_LEFT ? 0 : 7);
+    int graphic = el2img(element);
 
-    DrawGraphicAnimation(x, y, graphic, 8, delay, mode);
+    DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
 
     if (!(FrameCounter % 2))
       PlaySoundLevel(x, y, SND_CONVEYOR_BELT_ACTIVE);
@@ -4552,6 +4806,7 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action)
     */
 #endif 
 
+    /* if the player does not move for some time, reset animation to start */
     if (++player->frame_reset_delay > player->move_delay_value)
       player->Frame = 0;
   }
@@ -4607,7 +4862,7 @@ void GameActions()
   static unsigned long action_delay = 0;
   unsigned long action_delay_value;
   int sieb_x = 0, sieb_y = 0;
-  int i, x, y, element;
+  int i, x, y, element, graphic;
   byte *recorded_player_action;
   byte summarized_player_action = 0;
 
@@ -4711,8 +4966,6 @@ void GameActions()
 #endif
 #endif
 
-
-
   FrameCounter++;
   TimeFrames++;
 
@@ -4742,17 +4995,47 @@ void GameActions()
   for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
   {
     element = Feld[x][y];
+    graphic = el2img(element);
 
     if (IS_INACTIVE(element))
+    {
+
+#if 1
+      if (new_graphic_info[graphic].anim_frames > 1)
+       DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
+#endif
+
       continue;
+    }
 
     if (!IS_MOVING(x, y) && (CAN_FALL(element) || CAN_MOVE(element)))
     {
       StartMoving(x, y);
 
+#if 1
+      if (Feld[x][y] == EL_EMERALD &&
+         new_graphic_info[graphic].anim_frames > 1 &&
+         !IS_MOVING(x, y))
+       DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
+#endif
+
       if (IS_GEM(element) || element == EL_SP_INFOTRON)
        EdelsteinFunkeln(x, y);
     }
+
+#if 1
+    else if ((element == EL_ACID ||
+             element == EL_EXIT_OPEN ||
+             element == EL_SP_EXIT_OPEN ||
+             element == EL_SP_TERMINAL ||
+             element == EL_SP_TERMINAL_ACTIVE ||
+             element == EL_EXTRA_TIME ||
+             element == EL_SHIELD_NORMAL ||
+             element == EL_SHIELD_DEADLY) &&
+            new_graphic_info[graphic].anim_frames > 1)
+      DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
+#endif
+
     else if (IS_MOVING(x, y))
       ContinueMoving(x, y);
     else if (IS_ACTIVE_BOMB(element))
@@ -4777,12 +5060,10 @@ void GameActions()
       RobotWheel(x, y);
     else if (element == EL_TIMEGATE_SWITCH_ACTIVE)
       TimegateWheel(x, y);
-    else if (element == EL_ACID)
-      Blubber(x, y);
-    else if (element == EL_ACID_SPLASHING_LEFT ||
-            element == EL_ACID_SPLASHING_RIGHT)
+    else if (element == EL_ACID_SPLASH_LEFT ||
+            element == EL_ACID_SPLASH_RIGHT)
       Blurb(x, y);
-    else if (element == EL_CRACKINGNUT)
+    else if (element == EL_NUT_CRACKING)
       NussKnacken(x, y);
     else if (element == EL_PEARL_BREAKING)
       BreakingPearl(x, y);
@@ -4792,10 +5073,6 @@ void GameActions()
       AusgangstuerPruefen_SP(x, y);
     else if (element == EL_EXIT_OPENING)
       AusgangstuerOeffnen(x, y);
-    else if (element == EL_EXIT_OPEN)
-      AusgangstuerBlinken(x, y);
-    else if (element == EL_SP_EXIT_OPEN)
-      ;                /* !!! ADD SOME (OPTIONAL) ANIMATIONS HERE !!! */
     else if (element == EL_WALL_GROWING_ACTIVE)
       MauerWaechst(x, y);
     else if (element == EL_WALL_GROWING ||
@@ -4803,23 +5080,13 @@ void GameActions()
             element == EL_WALL_GROWING_Y ||
             element == EL_WALL_GROWING_XY)
       MauerAbleger(x, y);
-    else if (element == EL_DRAGON_FIRE)
+    else if (element == EL_FLAMES)
       CheckForDragon(x, y);
     else if (element == EL_SP_BUGGY_BASE || element == EL_SP_BUGGY_BASE_ACTIVE)
       CheckBuggyBase(x, y);
     else if (element == EL_TRAP || element == EL_TRAP_ACTIVE)
       CheckTrap(x, y);
-    else if (element == EL_SP_TERMINAL)
-      DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL, 7, 12, ANIM_NORMAL);
-    else if (element == EL_SP_TERMINAL_ACTIVE)
-    {
-      DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_NORMAL);
-#if 0
-      if (!(FrameCounter % 4))
-       PlaySoundLevel(x, y, SND_SP_TERMINAL_ACTIVE);
-#endif
-    }
-    else if (IS_BELT(element))
+    else if (IS_BELT_ACTIVE(element))
       DrawBeltAnimation(x, y, element);
     else if (element == EL_SWITCHGATE_OPENING)
       OpenSwitchgate(x, y);
@@ -4829,24 +5096,11 @@ void GameActions()
       OpenTimegate(x, y);
     else if (element == EL_TIMEGATE_CLOSING)
       CloseTimegate(x, y);
-    else if (element == EL_EXTRA_TIME)
-      DrawGraphicAnimation(x, y, GFX_EXTRA_TIME, 6, 4, ANIM_NORMAL);
-    else if (element == EL_SHIELD_NORMAL)
-    {
-      DrawGraphicAnimation(x, y, GFX_SHIELD_PASSIVE, 6, 4, ANIM_NORMAL);
-#if 0
-      if (!(FrameCounter % 4))
-       PlaySoundLevel(x, y, SND_SHIELD_PASSIVE_ACTIVATED);
-#endif
-    }
-    else if (element == EL_SHIELD_DEADLY)
-    {
-      DrawGraphicAnimation(x, y, GFX_SHIELD_ACTIVE, 6, 4, ANIM_NORMAL);
-#if 0
-      if (!(FrameCounter % 4))
-       PlaySoundLevel(x, y, SND_SHIELD_DEADLY_ACTIVE);
+
+#if 1
+    else if (new_graphic_info[graphic].anim_frames > 1)
+      DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
 #endif
-    }
 
     if (game.magic_wall_active)
     {
@@ -4854,14 +5108,14 @@ void GameActions()
       int jx = local_player->jx, jy = local_player->jy;
 
       if (element == EL_MAGIC_WALL_FULL ||
-         element == EL_MAGIC_WALL_EMPTY ||
+         element == EL_MAGIC_WALL_ACTIVE ||
          element == EL_MAGIC_WALL_EMPTYING)
       {
        SiebAktivieren(x, y, 1);
        sieb = TRUE;
       }
       else if (element == EL_BD_MAGIC_WALL_FULL ||
-              element == EL_BD_MAGIC_WALL_EMPTY ||
+              element == EL_BD_MAGIC_WALL_ACTIVE ||
               element == EL_BD_MAGIC_WALL_EMPTYING)
       {
        SiebAktivieren(x, y, 2);
@@ -4900,8 +5154,8 @@ void GameActions()
          (element == EL_EMPTY ||
           element == EL_SAND ||
           element == EL_QUICKSAND_EMPTY ||
-          element == EL_ACID_SPLASHING_LEFT ||
-          element == EL_ACID_SPLASHING_RIGHT))
+          element == EL_ACID_SPLASH_LEFT ||
+          element == EL_ACID_SPLASH_RIGHT))
       {
        if ((IN_LEV_FIELD(x, y-1) && Feld[x][y-1] == EL_AMOEBA_WET) ||
            (IN_LEV_FIELD(x-1, y) && Feld[x-1][y] == EL_AMOEBA_WET) ||
@@ -4943,7 +5197,7 @@ void GameActions()
       int element = Feld[sieb_x][sieb_y];
 
       if (element == EL_BD_MAGIC_WALL_FULL ||
-         element == EL_BD_MAGIC_WALL_EMPTY ||
+         element == EL_BD_MAGIC_WALL_ACTIVE ||
          element == EL_BD_MAGIC_WALL_EMPTYING)
        PlaySoundLevel(sieb_x, sieb_y, SND_BD_MAGIC_WALL_ACTIVE);
       else
@@ -4959,13 +5213,13 @@ void GameActions()
        {
          element = Feld[x][y];
 
-         if (element == EL_MAGIC_WALL_EMPTY ||
+         if (element == EL_MAGIC_WALL_ACTIVE ||
              element == EL_MAGIC_WALL_FULL)
          {
            Feld[x][y] = EL_MAGIC_WALL_DEAD;
            DrawLevelField(x, y);
          }
-         else if (element == EL_BD_MAGIC_WALL_EMPTY ||
+         else if (element == EL_BD_MAGIC_WALL_ACTIVE ||
                   element == EL_BD_MAGIC_WALL_FULL)
          {
            Feld[x][y] = EL_BD_MAGIC_WALL_DEAD;
@@ -4983,22 +5237,7 @@ void GameActions()
     game.light_time_left--;
 
     if (game.light_time_left == 0)
-    {
-      for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
-      {
-       element = Feld[x][y];
-
-       if (element == EL_LIGHT_SWITCH_ACTIVE)
-       {
-         Feld[x][y] = EL_LIGHT_SWITCH;
-         DrawLevelField(x, y);
-       }
-       else if (element == EL_INVISIBLE_STEELWALL ||
-                element == EL_INVISIBLE_WALL ||
-                element == EL_INVISIBLE_SAND)
-         DrawLevelField(x, y);
-      }
-    }
+      RedrawAllLightSwitchesAndInvisibleElements();
   }
 
   if (game.timegate_time_left > 0)
@@ -5015,9 +5254,9 @@ void GameActions()
 
     if (SHIELD_ON(player))
     {
-      if (player->shield_active_time_left)
+      if (player->shield_deadly_time_left)
        PlaySoundLevel(player->jx, player->jy, SND_SHIELD_DEADLY_ACTIVE);
-      else if (player->shield_passive_time_left)
+      else if (player->shield_normal_time_left)
        PlaySoundLevel(player->jx, player->jy, SND_SHIELD_NORMAL_ACTIVE);
     }
   }
@@ -5033,10 +5272,10 @@ void GameActions()
 
       if (SHIELD_ON(player))
       {
-       player->shield_passive_time_left--;
+       player->shield_normal_time_left--;
 
-       if (player->shield_active_time_left > 0)
-         player->shield_active_time_left--;
+       if (player->shield_deadly_time_left > 0)
+         player->shield_deadly_time_left--;
       }
     }
 
@@ -5140,6 +5379,7 @@ void ScrollLevel(int dx, int dy)
     for (y=BY1; y<=BY2; y++)
       DrawScreenField(x, y);
   }
+
   if (dy)
   {
     y = (dy == 1 ? BY1 : BY2);
@@ -5211,7 +5451,7 @@ boolean MoveFigureOneStep(struct PlayerInfo *player,
     if (element == EL_ACID && dx == 0 && dy == 1)
     {
       Blurb(jx, jy);
-      Feld[jx][jy] = EL_PLAYER;
+      Feld[jx][jy] = EL_PLAYER1;
       InitMovingField(jx, jy, MV_DOWN);
       Store[jx][jy] = EL_ACID;
       ContinueMoving(jx, jy);
@@ -5272,7 +5512,8 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy)
     int original_move_delay_value = player->move_delay_value;
 
 #if DEBUG
-    printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES.\n");
+    printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES. [%ld]\n",
+          tape.counter);
 #endif
 
     /* scroll remaining steps with finest movement resolution */
@@ -5376,7 +5617,11 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy)
   if (!(moved & MF_MOVING) && !player->Pushing)
     player->Frame = 0;
   else
+#if 0
     player->Frame = (player->Frame + 1) % 4;
+#else
+    player->Frame += 1 * 0;
+#endif
 
   if (moved & MF_MOVING)
   {
@@ -5385,7 +5630,7 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy)
     else if (old_jx == jx && old_jy != jy)
       player->MovDir = (old_jy < jy ? MV_DOWN : MV_UP);
 
-    DrawLevelField(jx, jy);    /* for "ErdreichAnbroeckeln()" */
+    DrawLevelField(jx, jy);    /* for "DrawCrumbledSand()" */
 
     player->last_move_dir = player->MovDir;
     player->is_moving = TRUE;
@@ -5421,6 +5666,8 @@ void ScrollFigure(struct PlayerInfo *player, int mode)
   {
     player->actual_frame_counter = FrameCounter;
     player->GfxPos = move_stepsize * (player->MovPos / move_stepsize);
+    if (player->Frame)
+      player->Frame += 1;
 
     if (Feld[last_jx][last_jy] == EL_EMPTY)
       Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING;
@@ -5433,6 +5680,7 @@ void ScrollFigure(struct PlayerInfo *player, int mode)
 
   player->MovPos += (player->MovPos > 0 ? -1 : 1) * move_stepsize;
   player->GfxPos = move_stepsize * (player->MovPos / move_stepsize);
+  player->Frame += 1;
 
   if (Feld[last_jx][last_jy] == EL_PLAYER_IS_LEAVING)
     Feld[last_jx][last_jy] = EL_EMPTY;
@@ -5555,7 +5803,7 @@ void TestIfGoodThingHitsBadThing(int good_x, int good_y, int good_move_dir)
     {
       struct PlayerInfo *player = PLAYERINFO(good_x, good_y);
 
-      if (player->shield_active_time_left > 0)
+      if (player->shield_deadly_time_left > 0)
        Bang(kill_x, kill_y);
       else if (!PLAYER_PROTECTED(good_x, good_y))
        KillHero(player);
@@ -5652,7 +5900,7 @@ void TestIfBadThingHitsGoodThing(int bad_x, int bad_y, int bad_move_dir)
        ;
 #endif
 
-      if (player->shield_active_time_left > 0)
+      if (player->shield_deadly_time_left > 0)
        Bang(bad_x, bad_y);
       else if (!PLAYER_PROTECTED(kill_x, kill_y))
        KillHero(player);
@@ -5737,8 +5985,8 @@ void KillHero(struct PlayerInfo *player)
     Feld[jx][jy] = EL_EMPTY;
 
   /* deactivate shield (else Bang()/Explode() would not work right) */
-  player->shield_passive_time_left = 0;
-  player->shield_active_time_left = 0;
+  player->shield_normal_time_left = 0;
+  player->shield_deadly_time_left = 0;
 
   Bang(jx, jy);
   BuryHero(player);
@@ -5847,6 +6095,7 @@ int DigField(struct PlayerInfo *player,
     case EL_EMPTY:
     case EL_SAND:
     case EL_INVISIBLE_SAND:
+    case EL_INVISIBLE_SAND_ACTIVE:
     case EL_TRAP:
     case EL_SP_BASE:
     case EL_SP_BUGGY_BASE:
@@ -5899,14 +6148,14 @@ int DigField(struct PlayerInfo *player,
 
     case EL_SHIELD_NORMAL:
       RemoveField(x, y);
-      player->shield_passive_time_left += 10;
+      player->shield_normal_time_left += 10;
       PlaySoundLevel(x, y, SND_SHIELD_NORMAL_COLLECTING);
       break;
 
     case EL_SHIELD_DEADLY:
       RemoveField(x, y);
-      player->shield_passive_time_left += 10;
-      player->shield_active_time_left += 10;
+      player->shield_normal_time_left += 10;
+      player->shield_deadly_time_left += 10;
       PlaySoundLevel(x, y, SND_SHIELD_DEADLY_COLLECTING);
       break;
 
@@ -5954,9 +6203,9 @@ int DigField(struct PlayerInfo *player,
       player->key[key_nr] = TRUE;
       RaiseScoreElement(element);
       DrawMiniGraphicExt(drawto, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS,
-                        GFX_SCHLUESSEL1 + key_nr);
+                        IMG_KEY1 + key_nr);
       DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS,
-                        GFX_SCHLUESSEL1 + key_nr);
+                        IMG_KEY1 + key_nr);
       PlaySoundLevel(x, y, SND_KEY_COLLECTING);
       break;
     }
@@ -5972,9 +6221,9 @@ int DigField(struct PlayerInfo *player,
       player->key[key_nr] = TRUE;
       RaiseScoreElement(element);
       DrawMiniGraphicExt(drawto, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS,
-                        GFX_SCHLUESSEL1 + key_nr);
+                        IMG_KEY1 + key_nr);
       DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS,
-                        GFX_SCHLUESSEL1 + key_nr);
+                        IMG_KEY1 + key_nr);
       PlaySoundLevel(x, y, SND_KEY_COLLECTING);
       break;
     }
@@ -6128,18 +6377,18 @@ int DigField(struct PlayerInfo *player,
       else
       {
        RemoveField(x, y);
-       Feld[x+dx][y+dy] = element;
+       Feld[x + dx][y + dy] = element;
       }
 
       if (element == EL_SPRING)
       {
-       Feld[x+dx][y+dy] = EL_SPRING_MOVING;
-       MovDir[x+dx][y+dy] = move_direction;
+       Feld[x + dx][y + dy] = EL_SPRING;
+       MovDir[x + dx][y + dy] = move_direction;
       }
 
       player->push_delay_value = (element == EL_SPRING ? 0 : 2 + RND(8));
 
-      DrawLevelField(x+dx, y+dy);
+      DrawLevelField(x + dx, y + dy);
       PlaySoundLevelElementAction(x, y, element, SND_ACTION_PUSHING);
       break;
 
@@ -6404,7 +6653,7 @@ int DigField(struct PlayerInfo *player,
       player->push_delay_value = (element == EL_BALLOON ? 0 : 2);
 
       DrawLevelField(x, y);
-      DrawLevelField(x+dx, y+dy);
+      DrawLevelField(x + dx, y + dy);
 
       if (IS_SB_ELEMENT(element) &&
          local_player->sokobanfields_still_needed == 0 &&
@@ -6495,20 +6744,21 @@ boolean PlaceBomb(struct PlayerInfo *player)
     if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy)))
     {
       if (game.emulation == EMU_SUPAPLEX)
-       DrawGraphic(SCREENX(jx), SCREENY(jy), GFX_SP_DISK_RED);
+       DrawGraphic(SCREENX(jx), SCREENY(jy), IMG_SP_DISK_RED, 0);
       else
-       DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNAMIT);
+       DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), IMG_DYNAMITE_ACTIVE, 0);
     }
 
     PlaySoundLevel(jx, jy, SND_DYNAMITE_DROPPING);
   }
   else
   {
-    Feld[jx][jy] = EL_DYNABOMB_ACTIVE_1 + (player->element_nr - EL_PLAYER1);
+    Feld[jx][jy] =
+      EL_DYNABOMB_PLAYER1_ACTIVE + (player->element_nr - EL_PLAYER1);
     MovDelay[jx][jy] = 96;
     player->dynabombs_left--;
     if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy)))
-      DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNABOMB);
+      DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), el2img(Feld[jx][jy]), 0);
 
     PlaySoundLevel(jx, jy, SND_DYNABOMB_DROPPING);
   }
@@ -6719,7 +6969,7 @@ void CreateGameButtons()
 
   for (i=0; i<NUM_GAME_BUTTONS; i++)
   {
-    Bitmap *gd_bitmap = pix[PIX_DOOR];
+    Bitmap *gd_bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
     struct GadgetInfo *gi;
     int button_type;
     boolean checked;
@@ -6779,6 +7029,14 @@ void CreateGameButtons()
   }
 }
 
+void FreeGameButtons()
+{
+  int i;
+
+  for (i=0; i<NUM_GAME_BUTTONS; i++)
+    FreeGadget(game_gadget[i]);
+}
+
 static void MapGameButtons()
 {
   int i;