rnd-20021129-2-src
authorHolger Schemel <info@artsoft.org>
Fri, 29 Nov 2002 18:53:38 +0000 (19:53 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:39:05 +0000 (10:39 +0200)
src/cartoons.c
src/conftime.h
src/libgame/toons.c
src/libgame/toons.h
src/tools.c

index 5b38eb77bd401dc943f53dbaa8b57ed8be4405f4..5db44a296a82cd0805a61ad4ff9542aeb3ffea53 100644 (file)
 #define DWARF_Y                72
 #define DWARF2_Y       186
 #define DWARF_FRAMES   8
-#define DWARF_FPS      10
+#define DWARF_DELAY    5
 #define DWARF_STEPSIZE 4
 #define JUMPER_XSIZE   48
 #define JUMPER_YSIZE   56
 #define JUMPER_X       2
 #define JUMPER_Y       125
 #define JUMPER_FRAMES  8
-#define JUMPER_FPS     10
+#define JUMPER_DELAY   5
 #define JUMPER_STEPSIZE        4
 #define CLOWN_XSIZE    80
 #define CLOWN_YSIZE    110
 #define CLOWN_X                327
 #define CLOWN_Y                10
 #define CLOWN_FRAMES   1
-#define CLOWN_FPS      10
+#define CLOWN_DELAY    5
 #define CLOWN_STEPSIZE 4
 #define BIRD_XSIZE     32
 #define BIRD_YSIZE     30
 #define BIRD2_X                2
 #define BIRD2_Y                37
 #define BIRD_FRAMES    8
-#define BIRD_FPS       20
+#define BIRD_DELAY     2
 #define BIRD_STEPSIZE  4
 
-#define GAMETOON_XSIZE         TILEX
-#define GAMETOON_YSIZE         TILEY
-#define GAMETOON_FRAMES_4      4
-#define GAMETOON_FRAMES_8      8
-#define GAMETOON_FPS           20
-#define GAMETOON_STEPSIZE      4
-
 struct ToonInfo toons[NUM_TOONS] =
 {
   {
-    PIX_TOONS,
+    IMG_MENU_TOONS,
     DWARF_XSIZE, DWARF_YSIZE,
     DWARF_X, DWARF_Y,
     DWARF_FRAMES,
-    DWARF_FPS,
+    DWARF_DELAY,
     DWARF_STEPSIZE,
     ANIM_LOOP,
     ANIMDIR_RIGHT,
     ANIMPOS_DOWN
   },
   {
-    PIX_TOONS,
+    IMG_MENU_TOONS,
     DWARF_XSIZE, DWARF_YSIZE,
     DWARF_X, DWARF2_Y,
     DWARF_FRAMES,
-    DWARF_FPS,
+    DWARF_DELAY,
     DWARF_STEPSIZE,
     ANIM_LOOP,
     ANIMDIR_LEFT,
     ANIMPOS_DOWN
   },
   {
-    PIX_TOONS,
+    IMG_MENU_TOONS,
     JUMPER_XSIZE, JUMPER_YSIZE,
     JUMPER_X, JUMPER_Y,
     JUMPER_FRAMES,
-    JUMPER_FPS,
+    JUMPER_DELAY,
     JUMPER_STEPSIZE,
     ANIM_LOOP,
     ANIMDIR_RIGHT,
     ANIMPOS_DOWN
   },
   {
-    PIX_TOONS,
+    IMG_MENU_TOONS,
     CLOWN_XSIZE, CLOWN_YSIZE,
     CLOWN_X, CLOWN_Y,
     CLOWN_FRAMES,
-    CLOWN_FPS,
+    CLOWN_DELAY,
     CLOWN_STEPSIZE,
     ANIM_LOOP,
     ANIMDIR_UP,
     ANIMPOS_ANY
   },
   {
-    PIX_TOONS,
+    IMG_MENU_TOONS,
     BIRD_XSIZE, BIRD_YSIZE,
     BIRD1_X, BIRD1_Y,
     BIRD_FRAMES,
-    BIRD_FPS,
+    BIRD_DELAY,
     BIRD_STEPSIZE,
     ANIM_PINGPONG,
     ANIMDIR_RIGHT,
     ANIMPOS_UPPER
   },
   {
-    PIX_TOONS,
+    IMG_MENU_TOONS,
     BIRD_XSIZE, BIRD_YSIZE,
     BIRD2_X, BIRD2_Y,
     BIRD_FRAMES,
-    BIRD_FPS,
+    BIRD_DELAY,
     BIRD_STEPSIZE,
     ANIM_PINGPONG,
     ANIMDIR_LEFT,
     ANIMPOS_UPPER
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_SPIELER1_LEFT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_SPIELER1_LEFT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_4,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_PLAYER1_LEFT_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_LEFT,
     ANIMPOS_DOWN
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_SPIELER1_RIGHT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_SPIELER1_RIGHT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_4,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_PLAYER1_RIGHT_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_RIGHT,
     ANIMPOS_DOWN
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_PINGUIN_LEFT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_PINGUIN_LEFT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_4,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_PENGUIN_LEFT_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_LEFT,
     ANIMPOS_DOWN
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_PINGUIN_RIGHT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_PINGUIN_RIGHT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_4,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_PENGUIN_RIGHT_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_RIGHT,
     ANIMPOS_DOWN
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_MOLE_LEFT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_MOLE_LEFT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_4,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_MOLE_LEFT_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_LEFT,
     ANIMPOS_DOWN
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_MOLE_RIGHT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_MOLE_RIGHT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_4,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_MOLE_RIGHT_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_RIGHT,
     ANIMPOS_DOWN
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_SCHWEIN_LEFT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_SCHWEIN_LEFT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_4,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_PIG_LEFT_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_LEFT,
     ANIMPOS_DOWN
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_SCHWEIN_RIGHT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_SCHWEIN_RIGHT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_4,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_PIG_RIGHT_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_RIGHT,
     ANIMPOS_DOWN
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_DRACHE_LEFT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_DRACHE_LEFT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_4,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_DRAGON_LEFT_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_LEFT,
     ANIMPOS_DOWN
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_DRACHE_RIGHT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_DRACHE_RIGHT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_4,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_DRAGON_RIGHT_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_RIGHT,
     ANIMPOS_DOWN
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_SONDE - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_SONDE - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_8,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_SATELLITE_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_LEFT,
     ANIMPOS_ANY
   },
   {
-    PIX_HEROES,
-    GAMETOON_XSIZE, GAMETOON_YSIZE,
-    ((GFX_SONDE - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-    ((GFX_SONDE - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
-    GAMETOON_FRAMES_8,
-    GAMETOON_FPS,
-    GAMETOON_STEPSIZE,
-    ANIM_LOOP,
+    IMG_SATELLITE_MOVING,
+    -1, -1,
+    -1, -1,
+    -1,
+    -1,
+    -1,
+    -1,
     ANIMDIR_RIGHT,
     ANIMPOS_ANY
   },
@@ -310,7 +291,45 @@ boolean ToonNeedsRedraw()
 
 void InitToons()
 {
-  InitToonScreen(pix, bitmap_db_door,
+  int i;
+
+  for (i=0; i<NUM_TOONS; i++)
+  {
+    int graphic = toons[i].graphic;
+
+    toons[i].bitmap = new_graphic_info[graphic].bitmap;
+
+    if (toons[i].src_x == -1 && toons[i].src_y == -1)
+    {
+      int anim_frames = new_graphic_info[graphic].anim_frames;
+      int anim_delay = new_graphic_info[graphic].anim_delay;
+      int anim_mode = new_graphic_info[graphic].anim_mode;
+      int start_frame = new_graphic_info[graphic].anim_start_frame;
+
+      toons[i].src_x = new_graphic_info[graphic].src_x;
+      toons[i].src_y = new_graphic_info[graphic].src_y;
+
+      toons[i].width = TILEX;
+      toons[i].height = TILEY;
+
+      toons[i].anim_frames = anim_frames;
+      toons[i].anim_delay = anim_delay;
+      toons[i].anim_mode = anim_mode;
+      toons[i].start_frame = start_frame;
+
+      toons[i].move_delay = 1;
+      toons[i].stepsize = TILEX / 8;
+    }
+    else
+    {
+      toons[i].anim_delay = 1;         /* no delay between frames */
+      toons[i].start_frame = 0;                /* always start with first */
+    }
+
+    toons[i].move_delay *= GAME_FRAME_DELAY;
+  }
+
+  InitToonScreen(bitmap_db_door,
                 BackToFront, PrepareBackbuffer, ToonNeedsRedraw,
                 toons, NUM_TOONS,
                 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
index 977d6ef38c5ed49c5bfab58042ed5dca981fea99..830305a941fae8dcc2923b8c7d8d7cd5196029bd 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-11-29 17:31]"
+#define COMPILE_DATE_STRING "[2002-11-29 19:51]"
index 5c95800cc72c5f53fa0d126221dbaf9e890ac3ae..84a21c2569d2ce89cb8ebc537eac39aec2d7d329 100644 (file)
 
 static struct ToonScreenInfo screen_info;
 
-void InitToonScreen(Bitmap **toon_bitmap_array,
-                   Bitmap *save_buffer,
+
+/* ========================================================================= */
+/* generic animation frame calculation                                       */
+/* ========================================================================= */
+
+int getAnimationFrame(int num_frames, int delay, int mode, int start_frame,
+                     int sync_frame)
+{
+  int frame = 0;
+
+  sync_frame += start_frame * delay;
+
+  if (mode & ANIM_LOOP)                        /* normal, looping animation */
+  {
+    frame = (sync_frame % (delay * num_frames)) / delay;
+  }
+  else if (mode & ANIM_LINEAR)         /* normal, non-looping animation */
+  {
+    frame = sync_frame / delay;
+
+    if (frame > num_frames - 1)
+      frame = num_frames - 1;
+  }
+  else if (mode & ANIM_PINGPONG)       /* use border frames once */
+  {
+    int max_anim_frames = 2 * num_frames - 2;
+
+    frame = (sync_frame % (delay * max_anim_frames)) / delay;
+    frame = (frame < num_frames ? frame : max_anim_frames - frame);
+  }
+  else if (mode & ANIM_PINGPONG2)      /* use border frames twice */
+  {
+    int max_anim_frames = 2 * num_frames;
+
+    frame = (sync_frame % (delay * max_anim_frames)) / delay;
+    frame = (frame < num_frames ? frame : max_anim_frames - frame - 1);
+  }
+
+  if (mode & ANIM_REVERSE)             /* use reverse animation direction */
+    frame = num_frames - frame - 1;
+
+  return frame;
+}
+
+
+/* ========================================================================= */
+/* toon animation functions                                                  */
+/* ========================================================================= */
+
+void InitToonScreen(Bitmap *save_buffer,
                    void (*update_function)(void),
                    void (*prepare_backbuffer_function)(void),
                    boolean (*redraw_needed_function)(void),
@@ -32,7 +80,6 @@ void InitToonScreen(Bitmap **toon_bitmap_array,
                    int startx, int starty,
                    int width, int height)
 {
-  screen_info.toon_bitmap_array = toon_bitmap_array;
   screen_info.save_buffer = save_buffer;
   screen_info.update_function = update_function;
   screen_info.prepare_backbuffer_function = prepare_backbuffer_function;
@@ -81,9 +128,10 @@ void DrawAnim(Bitmap *toon_bitmap, GC toon_clip_gc,
 
 boolean AnimateToon(int toon_nr, boolean restart)
 {
+  static unsigned long animation_frame_counter = 0;
   static int pos_x = 0, pos_y = 0;
   static int delta_x = 0, delta_y = 0;
-  static int frame = 0, frame_step = 1;
+  static int frame = 0;
   static boolean horiz_move, vert_move;
   static unsigned long anim_delay = 0;
   static unsigned long anim_delay_value = 0;
@@ -92,18 +140,19 @@ boolean AnimateToon(int toon_nr, boolean restart)
   static int cut_x,cut_y;
   static int src_x, src_y;
   static int dest_x, dest_y;
-
   struct ToonInfo *anim = &screen_info.toons[toon_nr];
-  int bitmap_nr = screen_info.toons[toon_nr].bitmap_nr;
-  Bitmap *anim_bitmap = screen_info.toon_bitmap_array[bitmap_nr];
+  Bitmap *anim_bitmap = screen_info.toons[toon_nr].bitmap;
   GC anim_clip_gc = anim_bitmap->stored_clip_gc;
 
   if (restart)
   {
     horiz_move = (anim->direction & (ANIMDIR_LEFT | ANIMDIR_RIGHT));
     vert_move = (anim->direction & (ANIMDIR_UP | ANIMDIR_DOWN));
-    anim_delay_value = 1000/anim->frames_per_second;
-    frame = 0;
+    anim_delay_value = anim->move_delay;
+
+    frame = getAnimationFrame(anim->anim_frames, anim->anim_delay,
+                             anim->anim_mode, anim->start_frame,
+                             animation_frame_counter++);
 
     if (horiz_move)
     {
@@ -189,7 +238,7 @@ boolean AnimateToon(int toon_nr, boolean restart)
   width  = anim->width;
   height = anim->height;
 
-  if (pos_x<0)
+  if (pos_x < 0)
   {
     dest_x = 0;
     width += pos_x;
@@ -198,7 +247,7 @@ boolean AnimateToon(int toon_nr, boolean restart)
   else if (pos_x > screen_info.width - anim->width)
     width -= (pos_x - (screen_info.width - anim->width));
 
-  if (pos_y<0)
+  if (pos_y < 0)
   {
     dest_y = 0;
     height += pos_y;
@@ -216,18 +265,10 @@ boolean AnimateToon(int toon_nr, boolean restart)
 
   pos_x += delta_x;
   pos_y += delta_y;
-  frame += frame_step;
 
-  if (frame<0 || frame>=anim->frames)
-  {
-    if (anim->mode == ANIM_PINGPONG)
-    {
-      frame_step *= -1;
-      frame = (frame<0 ? 1 : anim->frames-2);
-    }
-    else
-      frame = (frame<0 ? anim->frames-1 : 0);
-  }
+  frame = getAnimationFrame(anim->anim_frames, anim->anim_delay,
+                           anim->anim_mode, anim->start_frame,
+                           animation_frame_counter++);
 
   return FALSE;
 }
index cf267345df4cecd8b167cf09ef12ff21c799c57c..75f76864e8203ccef076017791a773ea5c98780f 100644 (file)
@@ -41,7 +41,6 @@
 
 struct ToonScreenInfo
 {
-  Bitmap **toon_bitmap_array;
   Bitmap *save_buffer;
   void (*update_function)(void);
   void (*prepare_backbuffer_function)(void);
@@ -56,18 +55,24 @@ struct ToonScreenInfo
 
 struct ToonInfo
 {
-  int bitmap_nr;
+  int graphic;
   int width, height;
   int src_x, src_y;
-  int frames;
-  int frames_per_second;
+  int anim_frames;
+  int move_delay;
   int stepsize;
-  int mode;
+  int anim_mode;
   int direction;
   int position;
+
+  int anim_delay;
+  int start_frame;
+  Bitmap *bitmap;      /* dynamically initialized */
 };
 
 
+int getAnimationFrame(int, int, int, int, int);
+
 void InitToonScreen();
 void InitAnimation(void);
 void StopAnimation(void);
index efb413e13c34a21a3ea589c93f8480c85e2954a8..8ed62a521b36a2fbc2fefd7ceeadf38f710e9ae1 100644 (file)
@@ -32,7 +32,6 @@
 #define NUM_TOOL_BUTTONS       7
 
 /* forward declaration for internal use */
-static int getGraphicAnimationPhase(int, int, int);
 static void UnmapToolButtons();
 static void HandleToolButtons(struct GadgetInfo *);
 
@@ -384,6 +383,39 @@ void ClearWindow()
   redraw_mask |= REDRAW_FIELD;
 }
 
+static int getGraphicAnimationPhase(int frames, int delay, int mode)
+{
+  int phase;
+
+  if (mode & ANIM_PINGPONG)
+  {
+    int max_anim_frames = 2 * frames - 2;
+
+    phase = (FrameCounter % (delay * max_anim_frames)) / delay;
+    phase = (phase < frames ? phase : max_anim_frames - phase);
+  }
+  else
+    phase = (FrameCounter % (delay * frames)) / delay;
+
+  if (mode & ANIM_REVERSE)
+    phase = -phase;
+
+  return phase;
+}
+
+inline int getGraphicAnimationFrame(int graphic, int sync_frame)
+{
+  /* animation synchronized with global frame counter, not move position */
+  if (new_graphic_info[graphic].anim_global_sync || sync_frame < 0)
+    sync_frame = FrameCounter;
+
+  return getAnimationFrame(new_graphic_info[graphic].anim_frames,
+                          new_graphic_info[graphic].anim_delay,
+                          new_graphic_info[graphic].anim_mode,
+                          new_graphic_info[graphic].anim_start_frame,
+                          sync_frame);
+}
+
 void MarkTileDirty(int x, int y)
 {
   int xx = redraw_x1 + x;
@@ -736,71 +768,6 @@ void DrawPlayer(struct PlayerInfo *player)
   MarkTileDirty(sx,sy);
 }
 
-static int getGraphicAnimationPhase(int frames, int delay, int mode)
-{
-  int phase;
-
-  if (mode & ANIM_PINGPONG)
-  {
-    int max_anim_frames = 2 * frames - 2;
-
-    phase = (FrameCounter % (delay * max_anim_frames)) / delay;
-    phase = (phase < frames ? phase : max_anim_frames - phase);
-  }
-  else
-    phase = (FrameCounter % (delay * frames)) / delay;
-
-  if (mode & ANIM_REVERSE)
-    phase = -phase;
-
-  return phase;
-}
-
-int getGraphicAnimationFrame(int graphic, int sync_frame)
-{
-  int num_frames = new_graphic_info[graphic].anim_frames;
-  int delay = new_graphic_info[graphic].anim_delay;
-  int mode = new_graphic_info[graphic].anim_mode;
-  int frame = 0;
-
-  /* animation synchronized with global frame counter, not move position */
-  if (new_graphic_info[graphic].anim_global_sync || sync_frame < 0)
-    sync_frame = FrameCounter;
-
-  sync_frame += new_graphic_info[graphic].anim_start_frame * delay;
-
-  if (mode & ANIM_LOOP)                        /* normal, looping animation */
-  {
-    frame = (sync_frame % (delay * num_frames)) / delay;
-  }
-  else if (mode & ANIM_LINEAR)         /* normal, non-looping animation */
-  {
-    frame = sync_frame / delay;
-
-    if (frame > num_frames - 1)
-      frame = num_frames - 1;
-  }
-  else if (mode & ANIM_PINGPONG)       /* use border frames once */
-  {
-    int max_anim_frames = 2 * num_frames - 2;
-
-    frame = (sync_frame % (delay * max_anim_frames)) / delay;
-    frame = (frame < num_frames ? frame : max_anim_frames - frame);
-  }
-  else if (mode & ANIM_PINGPONG2)      /* use border frames twice */
-  {
-    int max_anim_frames = 2 * num_frames;
-
-    frame = (sync_frame % (delay * max_anim_frames)) / delay;
-    frame = (frame < num_frames ? frame : max_anim_frames - frame - 1);
-  }
-
-  if (mode & ANIM_REVERSE)             /* use reverse animation direction */
-    frame = num_frames - frame - 1;
-
-  return frame;
-}
-
 void DrawGraphicAnimationExt(int x, int y, int graphic, int mask_mode)
 {
   if (IN_SCR_FIELD(x, y))