rnd-20020331-1-src
[rocksndiamonds.git] / src / tools.c
index e1ec84bd480dd9a172ed29da0b54275b99d73613..fe5c9f690cc89031b9db3b3f4998170e6cca3191 100644 (file)
 * tools.c                                                  *
 ***********************************************************/
 
-#include <stdarg.h>
-
-#if defined(PLATFORM_FREEBSD)
-#include <machine/joystick.h>
-#endif
-
 #include "libgame/libgame.h"
 
 #include "tools.h"
 #include "game.h"
 #include "events.h"
-#include "joystick.h"
 #include "cartoons.h"
 #include "network.h"
 #include "tape.h"
@@ -82,6 +75,51 @@ void SetDrawtoField(int mode)
   }
 }
 
+void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height)
+{
+  if (game_status == PLAYING)
+  {
+    if (force_redraw)
+    {
+      x = gfx.sx - TILEX;
+      y = gfx.sy - TILEY;
+      width = gfx.sxsize + 2 * TILEX;
+      height = gfx.sysize + 2 * TILEY;
+    }
+
+    if (force_redraw || setup.direct_draw)
+    {
+      int xx, yy;
+      int x1 = (x - SX) / TILEX, y1 = (y - SY) / TILEY;
+      int x2 = (x - SX + width) / TILEX, y2 = (y - SY + height) / TILEY;
+
+      if (setup.direct_draw)
+       SetDrawtoField(DRAW_BACKBUFFER);
+
+      for(xx=BX1; xx<=BX2; xx++)
+       for(yy=BY1; yy<=BY2; yy++)
+         if (xx >= x1 && xx <= x2 && yy >= y1 && yy <= y2)
+           DrawScreenField(xx, yy);
+      DrawAllPlayers();
+
+      if (setup.direct_draw)
+       SetDrawtoField(DRAW_DIRECT);
+    }
+
+    if (setup.soft_scrolling)
+    {
+      int fx = FX, fy = FY;
+
+      fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
+      fy += (ScreenMovDir & (MV_UP|MV_DOWN)    ? ScreenGfxPos : 0);
+
+      BlitBitmap(fieldbuffer, backbuffer, fx,fy, SXSIZE,SYSIZE, SX,SY);
+    }
+  }
+
+  BlitBitmap(drawto, window, x, y, width, height, x, y);
+}
+
 void BackToFront()
 {
   int x,y;
@@ -96,7 +134,7 @@ void BackToFront()
   if (redraw_mask & REDRAW_FIELD)
     redraw_mask &= ~REDRAW_TILES;
 
-  if (!redraw_mask)
+  if (redraw_mask == REDRAW_NONE)
     return;
 
   if (global.fps_slowdown && game_status == PLAYING)
@@ -257,7 +295,7 @@ void BackToFront()
     for(y=0; y<MAX_BUF_YSIZE; y++)
       redraw[x][y] = 0;
   redraw_tiles = 0;
-  redraw_mask = 0;
+  redraw_mask = REDRAW_NONE;
 }
 
 void FadeToFront()
@@ -434,7 +472,10 @@ void DrawPlayer(struct PlayerInfo *player)
     if (Store[last_jx][last_jy] && IS_DRAWABLE(last_element))
     {
       DrawLevelElement(last_jx, last_jy, Store[last_jx][last_jy]);
-      DrawLevelFieldThruMask(last_jx, last_jy);
+      if (last_element == EL_DYNAMITE_ACTIVE)
+       DrawDynamite(last_jx, last_jy);
+      else
+       DrawLevelFieldThruMask(last_jx, last_jy);
     }
     else if (last_element == EL_DYNAMITE_ACTIVE)
       DrawDynamite(last_jx, last_jy);
@@ -467,6 +508,8 @@ void DrawPlayer(struct PlayerInfo *player)
     DrawLevelElement(jx, jy, Store[jx][jy]);
   else if (!IS_ACTIVE_BOMB(element))
     DrawLevelField(jx, jy);
+  else
+    DrawLevelElement(jx, jy, EL_LEERRAUM);
 
   /* draw player himself */
 
@@ -1107,7 +1150,9 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element,
   else if ((element == EL_FELSBROCKEN ||
            element == EL_SP_ZONK ||
            element == EL_BD_ROCK ||
-           IS_GEM(element)) && !cut_mode)
+           element == EL_SP_INFOTRON ||
+           IS_GEM(element))
+          && !cut_mode)
   {
     if (uy >= lev_fieldy-1 || !IS_BELT(Feld[ux][uy+1]))
     {
@@ -2275,13 +2320,6 @@ static struct
   }
 };
 
-#if 0
-static void DoNotDisplayInfoText(void *ptr)
-{
-  return;
-}
-#endif
-
 void CreateToolButtons()
 {
   int i;
@@ -2328,11 +2366,6 @@ void CreateToolButtons()
                      GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
                      GDI_DECORATION_SHIFTING, 1, 1,
                      GDI_EVENT_MASK, event_mask,
-
-#if 0
-                     GDI_CALLBACK_INFO, DoNotDisplayInfoText,
-#endif
-
                      GDI_CALLBACK_ACTION, HandleToolButtons,
                      GDI_END);
 
@@ -2356,6 +2389,22 @@ static void HandleToolButtons(struct GadgetInfo *gi)
   request_gadget_id = gi->custom_id;
 }
 
+int get_next_element(int element)
+{
+  switch(element)
+  {
+    case EL_QUICKSAND_FILLING:         return EL_MORAST_VOLL;
+    case EL_QUICKSAND_EMPTYING:                return EL_MORAST_LEER;
+    case EL_MAGIC_WALL_FILLING:                return EL_MAGIC_WALL_FULL;
+    case EL_MAGIC_WALL_EMPTYING:       return EL_MAGIC_WALL_EMPTY;
+    case EL_MAGIC_WALL_BD_FILLING:     return EL_MAGIC_WALL_BD_FULL;
+    case EL_MAGIC_WALL_BD_EMPTYING:    return EL_MAGIC_WALL_BD_EMPTY;
+    case EL_AMOEBA_DRIPPING:           return EL_AMOEBE_NASS;
+
+    default:                           return element;
+  }
+}
+
 int el2gfx(int element)
 {
   switch(element)