rnd-20021212-1-src
[rocksndiamonds.git] / src / game.c
index 0a98a0b4692f7a23a70d9277ced4ee5766300eae..06edf65091e2acd9dac24734fd34eb66e3d3b586 100644 (file)
@@ -971,7 +971,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)
@@ -998,7 +998,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);
@@ -2984,7 +2984,7 @@ void StartMoving(int x, int y)
        }
       }
       else if (element == EL_SP_ELECTRON)
-       DrawGraphicAnimation(x, y, IMG_SP_ELECTRON);
+       DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_ELECTRON);
       else if (element == EL_DRAGON)
       {
        int i;
@@ -3242,11 +3242,11 @@ void StartMoving(int x, int y)
               element == EL_SP_SNIKSNAK || element == EL_MOLE)
        DrawLevelField(x, y);
       else if (element == EL_BD_BUTTERFLY || element == EL_BD_FIREFLY)
-       DrawGraphicAnimation(x, y, el2img(element));
+       DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(element));
       else if (element == EL_SATELLITE)
-       DrawGraphicAnimation(x, y, IMG_SATELLITE);
+       DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SATELLITE);
       else if (element == EL_SP_ELECTRON)
-       DrawGraphicAnimation(x, y, IMG_SP_ELECTRON);
+       DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_ELECTRON);
 
       if (DONT_TOUCH(element))
        TestIfBadThingTouchesHero(x, y);
@@ -3388,8 +3388,14 @@ void ContinueMoving(int x, int y)
     if (!CAN_MOVE(element))
       MovDir[newx][newy] = 0;
 #else
+    /*
     if (CAN_FALL(element) && MovDir[newx][newy] == MV_DOWN)
       MovDir[newx][newy] = 0;
+    */
+
+    if (!CAN_MOVE(element) ||
+       (element == EL_SPRING && MovDir[newx][newy] == MV_DOWN))
+      MovDir[newx][newy] = 0;
 #endif
 
     DrawLevelField(x, y);
@@ -4015,7 +4021,7 @@ void SiebAktivieren(int x, int y, int type)
 {
   int graphic = (type == 1 ? IMG_MAGIC_WALL_FULL : IMG_BD_MAGIC_WALL_FULL);
 
-  DrawGraphicAnimation(x, y, graphic);
+  DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
 }
 
 void AusgangstuerPruefen(int x, int y)
@@ -4071,9 +4077,10 @@ void AusgangstuerOeffnen(int x, int y)
 
        DrawGraphic(SCREENX(x), SCREENY(y), IMG_EXIT_OPENING, frame);
       }
+    }
 
+    if (MovDelay[x][y])
       return;
-    }
   }
 
   Feld[x][y] = EL_EXIT_OPEN;
@@ -4100,9 +4107,10 @@ void OpenSwitchgate(int x, int y)
 
        DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_OPENING, frame);
       }
+    }
 
+    if (MovDelay[x][y])
       return;
-    }
   }
 
   Feld[x][y] = EL_SWITCHGATE_OPEN;
@@ -4129,9 +4137,10 @@ void CloseSwitchgate(int x, int y)
 
        DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_CLOSING, frame);
       }
+    }
 
+    if (MovDelay[x][y])
       return;
-    }
   }
 
   Feld[x][y] = EL_SWITCHGATE_CLOSED;
@@ -4158,9 +4167,10 @@ void OpenTimegate(int x, int y)
 
        DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_OPENING, frame);
       }
+    }
 
+    if (MovDelay[x][y])
       return;
-    }
   }
 
   Feld[x][y] = EL_TIMEGATE_OPEN;
@@ -4187,9 +4197,10 @@ void CloseTimegate(int x, int y)
 
        DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_CLOSING, frame);
       }
+    }
 
+    if (MovDelay[x][y])
       return;
-    }
   }
 
   Feld[x][y] = EL_TIMEGATE_CLOSED;
@@ -4221,7 +4232,7 @@ void EdelsteinFunkeln(int x, int y)
     return;
 
   if (Feld[x][y] == EL_BD_DIAMOND)
-    DrawGraphicAnimation(x, y, IMG_BD_DIAMOND);
+    DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_BD_DIAMOND);
   else
   {
     if (!MovDelay[x][y])       /* next animation frame */
@@ -4237,7 +4248,7 @@ void EdelsteinFunkeln(int x, int y)
 #if 0
       DrawGraphic(SCREENX(x), SCREENY(y), el2img(Feld[x][y]), 0);
 #else
-      DrawGraphicAnimation(x, y, el2img(Feld[x][y]));
+      DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(Feld[x][y]));
 #endif
 
       if (MovDelay[x][y])
@@ -4592,7 +4603,7 @@ static void DrawBeltAnimation(int x, int y, int element)
   {
     int graphic = el2img(element);
 
-    DrawGraphicAnimation(x, y, graphic);
+    DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
 
     if (!(FrameCounter % 2))
       PlaySoundLevel(x, y, SND_CONVEYOR_BELT_ACTIVE);
@@ -4745,7 +4756,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;
 
@@ -4880,9 +4891,18 @@ 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)))
     {
@@ -4890,14 +4910,28 @@ void GameActions()
 
 #if 1
       if (Feld[x][y] == EL_EMERALD &&
-         new_graphic_info[IMG_EMERALD].anim_frames > 1 &&
+         new_graphic_info[graphic].anim_frames > 1 &&
          !IS_MOVING(x, y))
-       DrawGraphicAnimation(x, y, IMG_EMERALD);
+       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))
@@ -4922,8 +4956,6 @@ void GameActions()
       RobotWheel(x, y);
     else if (element == EL_TIMEGATE_SWITCH_ACTIVE)
       TimegateWheel(x, y);
-    else if (element == EL_ACID)
-      DrawGraphicAnimation(x, y, IMG_ACID);
     else if (element == EL_ACID_SPLASH_LEFT ||
             element == EL_ACID_SPLASH_RIGHT)
       Blurb(x, y);
@@ -4937,10 +4969,6 @@ void GameActions()
       AusgangstuerPruefen_SP(x, y);
     else if (element == EL_EXIT_OPENING)
       AusgangstuerOeffnen(x, y);
-    else if (element == EL_EXIT_OPEN)
-      DrawGraphicAnimation(x, y, IMG_EXIT_OPEN);
-    else if (element == EL_SP_EXIT_OPEN)
-      DrawGraphicAnimation(x, y, IMG_SP_EXIT_OPEN);
     else if (element == EL_WALL_GROWING_ACTIVE)
       MauerWaechst(x, y);
     else if (element == EL_WALL_GROWING ||
@@ -4954,10 +4982,6 @@ void GameActions()
       CheckBuggyBase(x, y);
     else if (element == EL_TRAP || element == EL_TRAP_ACTIVE)
       CheckTrap(x, y);
-    else if (element == EL_SP_TERMINAL)
-      DrawGraphicAnimation(x, y, IMG_SP_TERMINAL);
-    else if (element == EL_SP_TERMINAL_ACTIVE)
-      DrawGraphicAnimation(x, y, IMG_SP_TERMINAL_ACTIVE);
     else if (IS_BELT_ACTIVE(element))
       DrawBeltAnimation(x, y, element);
     else if (element == EL_SWITCHGATE_OPENING)
@@ -4968,12 +4992,11 @@ void GameActions()
       OpenTimegate(x, y);
     else if (element == EL_TIMEGATE_CLOSING)
       CloseTimegate(x, y);
-    else if (element == EL_EXTRA_TIME)
-      DrawGraphicAnimation(x, y, IMG_EXTRA_TIME);
-    else if (element == EL_SHIELD_NORMAL)
-      DrawGraphicAnimation(x, y, IMG_SHIELD_NORMAL);
-    else if (element == EL_SHIELD_DEADLY)
-      DrawGraphicAnimation(x, y, IMG_SHIELD_DEADLY);
+
+#if 1
+    else if (new_graphic_info[graphic].anim_frames > 1)
+      DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
+#endif
 
     if (game.magic_wall_active)
     {
@@ -6841,7 +6864,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;