rnd-20070822-1-src
[rocksndiamonds.git] / src / tools.c
index 63c29e6262030ae4f67591cc084c47970f711aeb..f593aeda20954a08accc0e65f332ecf1d8ce1be0 100644 (file)
@@ -241,8 +241,9 @@ void DrawMaskedBorder_ALL()
 
 void DrawMaskedBorder(int redraw_mask)
 {
-  /* do not draw masked screen borders when displaying title screens */
-  if (effectiveGameStatus() == GAME_MODE_TITLE)
+  /* never draw masked screen borders on borderless screens */
+  if (effectiveGameStatus() == GAME_MODE_LOADING ||
+      effectiveGameStatus() == GAME_MODE_TITLE)
     return;
 
   if (redraw_mask & REDRAW_ALL)
@@ -465,7 +466,7 @@ static void FadeExt(int fade_mask, int fade_mode, int fade_type)
   {
     if (fade_type_skip != FADE_TYPE_NONE)
     {
-#if 1
+#if 0
       printf("::: skipping %d ... [%d] (X)\n", fade_mode, fade_type_skip);
 #endif
 
@@ -477,16 +478,18 @@ static void FadeExt(int fade_mask, int fade_mode, int fade_type)
     }
 
     if (fading.fade_mode & FADE_TYPE_TRANSFORM)
+    {
       FadeCrossSaveBackbuffer();
 
-    return;
+      return;
+    }
   }
 
   redraw_mask |= fade_mask;
 
   if (fade_type == FADE_TYPE_SKIP)
   {
-#if 1
+#if 0
     printf("::: will skip %d ... [%d]\n", fade_mode, fade_type_skip);
 #endif
 
@@ -497,7 +500,7 @@ static void FadeExt(int fade_mask, int fade_mode, int fade_type)
 
   if (fade_type_skip != FADE_TYPE_NONE)
   {
-#if 1
+#if 0
     printf("::: skipping %d ... [%d]\n", fade_mode, fade_type_skip);
 #endif
 
@@ -528,7 +531,7 @@ static void FadeExt(int fade_mask, int fade_mode, int fade_type)
 
   /* !!! what abount fade_mask == REDRAW_FIELD | REDRAW_ALL ??? !!! */
 
-#if 1
+#if 0
   printf("::: NOW FADING %d ... [%d]\n", fade_mode, fade_type);
 #endif
 
@@ -6039,6 +6042,8 @@ void SetGfxAnimation_EM(int tile, int frame_em, int x, int y)
 
 void getGraphicSourceObjectExt_EM(int tile, int frame_em,
                                  Bitmap **src_bitmap, int *src_x, int *src_y,
+                                 Bitmap **crumbled_src_bitmap,
+                                 int *crumbled_src_x, int *crumbled_src_y,
                                  int x, int y)
 {
   int element         = object_mapping[tile].element_rnd;
@@ -6055,6 +6060,12 @@ void getGraphicSourceObjectExt_EM(int tile, int frame_em,
   int graphic = (direction == MV_NONE ?
                 el_act2img(effective_element, action) :
                 el_act_dir2img(effective_element, action, direction));
+  int crumbled = (direction == MV_NONE ?
+                 el_act2crm(effective_element, action) :
+                 el_act_dir2crm(effective_element, action, direction));
+  int base_graphic = el_act2img(effective_element, ACTION_DEFAULT);
+  int base_crumbled = el_act2crm(effective_element, ACTION_DEFAULT);
+  boolean has_crumbled_graphics = (base_crumbled != base_graphic);
   struct GraphicInfo *g = &graphic_info[graphic];
   int sync_frame;
 
@@ -6090,6 +6101,28 @@ void getGraphicSourceObjectExt_EM(int tile, int frame_em,
                                sync_frame);
 
   getGraphicSourceExt(graphic, frame, src_bitmap, src_x, src_y, FALSE);
+
+#if 0
+  if (x == 1 && y == 1 && frame == 0)
+    printf("--> %d, %d, %d\n", *crumbled_src_x, *crumbled_src_y, tile);
+#endif
+
+#if 0
+  getGraphicSource(crumbled, frame, crumbled_src_bitmap,
+                  crumbled_src_x, crumbled_src_y);
+#endif
+
+#if 0
+  *crumbled_src_bitmap = NULL;
+  *crumbled_src_x = 0;
+  *crumbled_src_y = 0;
+
+  if (has_crumbled_graphics && crumbled != IMG_EMPTY_SPACE)
+  {
+    getGraphicSource(crumbled, frame, crumbled_src_bitmap,
+                    crumbled_src_x, crumbled_src_y);
+  }
+#endif
 }
 
 void getGraphicSourcePlayerExt_EM(int player_nr, int anim, int frame_em,
@@ -6289,6 +6322,7 @@ void InitGraphicInfo_EM(void)
       boolean has_action_graphics = (graphic != base_graphic);
       boolean has_crumbled_graphics = (base_crumbled != base_graphic);
       struct GraphicInfo *g = &graphic_info[graphic];
+      struct GraphicInfo *g_crumbled = &graphic_info[crumbled];
       struct GraphicInfo_EM *g_em = &graphic_info_em_object[i][7 - j];
       Bitmap *src_bitmap;
       int src_x, src_y;
@@ -6441,17 +6475,43 @@ void InitGraphicInfo_EM(void)
 #endif
 
       /* if element can be crumbled, but certain action graphics are just empty
-        space (like snapping sand with the original R'n'D graphics), do not
+        space (like instantly snapping sand to empty space in 1 frame), do not
         treat these empty space graphics as crumbled graphics in EMC engine */
       if (has_crumbled_graphics && crumbled != IMG_EMPTY_SPACE)
       {
-       getGraphicSource(crumbled, frame, &src_bitmap, &src_x, &src_y);
+       int frame_crumbled = getAnimationFrame(g_crumbled->anim_frames,
+                                              g_crumbled->anim_delay,
+                                              g_crumbled->anim_mode,
+                                              g_crumbled->anim_start_frame,
+                                              sync_frame);
+
+       getGraphicSource(crumbled, frame_crumbled, &src_bitmap, &src_x, &src_y);
 
        g_em->has_crumbled_graphics = TRUE;
        g_em->crumbled_bitmap = src_bitmap;
        g_em->crumbled_src_x = src_x;
        g_em->crumbled_src_y = src_y;
        g_em->crumbled_border_size = graphic_info[crumbled].border_size;
+
+
+#if 0
+       if (g_em == &graphic_info_em_object[207][0])
+         printf("... %d, %d [%d, %d, %d, %d] [%d, %d, %d, %d, %d, %d => %d]\n",
+                graphic_info_em_object[207][0].crumbled_src_x,
+                graphic_info_em_object[207][0].crumbled_src_y,
+
+                crumbled, frame, src_x, src_y,
+
+                g->anim_frames,
+                g->anim_delay,
+                g->anim_mode,
+                g->anim_start_frame,
+                sync_frame,
+                gfx.anim_random_frame,
+                frame);
+#endif
+
+
       }
 
 #if 0