replaced function to draw graphic animation (MM engine)
[rocksndiamonds.git] / src / game_mm / mm_tools.c
index 5c67bbe42b4b7b7e503111c2d43e329830832c40..9f52eb735e5039bc60e157b0bd78d224b7909139 100644 (file)
@@ -17,9 +17,6 @@
 #include "mm_tools.h"
 
 
-/* forward declaration for internal use */
-static int getGraphicAnimationPhase_MM(int, int, int);
-
 void ClearWindow()
 {
   ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
@@ -29,49 +26,15 @@ void ClearWindow()
   redraw_mask |= REDRAW_FIELD;
 }
 
-static int getGraphicAnimationPhase_MM(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);
-}
-
-void DrawGraphicAnimationExt_MM(int x, int y, int graphic,
-                                int frames, int delay, int mode, int mask_mode)
+void DrawGraphicAnimation_MM(int x, int y, int graphic, int frame)
 {
-  int phase = getGraphicAnimationPhase_MM(frames, delay, mode);
-
-  if (!(FrameCounter % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
-  {
-    if (mask_mode == USE_MASKING)
-      DrawGraphicThruMask_MM(SCREENX(x), SCREENY(y), graphic + phase);
-    else
-      DrawGraphic_MM(SCREENX(x), SCREENY(y), graphic + phase);
-  }
-}
+  Bitmap *bitmap;
+  int src_x, src_y;
 
-void DrawGraphicAnimation_MM(int x, int y, int graphic,
-                         int frames, int delay, int mode)
-{
-  DrawGraphicAnimationExt_MM(x, y, graphic, frames, delay, mode, NO_MASKING);
-}
+  getGraphicSource(graphic, frame, &bitmap, &src_x, &src_y);
 
-void DrawGraphicAnimationThruMask_MM(int x, int y, int graphic,
-                                 int frames, int delay, int mode)
-{
-  DrawGraphicAnimationExt_MM(x, y, graphic, frames, delay, mode, USE_MASKING);
+  BlitBitmap(bitmap, drawto_field, src_x, src_y, TILEX, TILEY,
+            FX + x * TILEX, FY + y * TILEY);
 }
 
 void DrawGraphic_MM(int x, int y, int graphic)
@@ -271,7 +234,7 @@ void DrawScreenElementExt_MM(int x, int y, int dx, int dy, int element,
 
   if (element == EL_PACMAN)
   {
-    graphic += 4 * !phase2;
+    graphic = (phase2 ? IMG_MM_PACMAN_RIGHT : IMG_MM_PACMAN_EATING_RIGHT);
 
     if (dir == MV_UP)
       graphic += 1;
@@ -508,7 +471,8 @@ void DrawWallsAnimation_MM(int x, int y, int element, int phase, int bit_mask)
        frame = 0;
       }
 
-      getGraphicSource(graphic, frame, &bitmap, &src_x, &src_y);
+      getSizedGraphicSource(graphic, frame, MINI_TILESIZE, &bitmap,
+                           &src_x, &src_y);
 
       BlitBitmap(bitmap, drawto, src_x, src_y, MINI_TILEX, MINI_TILEY,
                 dst_x, dst_y);
@@ -722,8 +686,25 @@ int get_rotated_element(int element, int step)
   return base_element + (element_phase + step + num_elements) % num_elements;
 }
 
+static int map_element(int element)
+{
+  switch (element)
+  {
+    case EL_WALL_STEEL:                return EL_STEEL_WALL;
+    case EL_WALL_WOOD:         return EL_WOODEN_WALL;
+    case EL_WALL_ICE:          return EL_ICE_WALL;
+    case EL_WALL_AMOEBA:       return EL_AMOEBA_WALL;
+    case EL_DF_WALL_STEEL:     return EL_DF_STEEL_WALL;
+    case EL_DF_WALL_WOOD:      return EL_DF_WOODEN_WALL;
+
+    default:                   return element;
+  }
+}
+
 int el2gfx(int element)
 {
+  element = map_element(element);
+
   switch (element)
   {
     case EL_LIGHTBALL: