added support for x/y/width/height parameters for border/background images
authorHolger Schemel <info@artsoft.org>
Tue, 31 Jan 2023 23:42:10 +0000 (00:42 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 31 Jan 2023 23:42:10 +0000 (00:42 +0100)
src/init.c
src/libgame/system.c
src/libgame/system.h
src/main.c
src/main.h
src/tools.c
src/tools.h

index f07be1d395e341c05e9b0dc7ac0c796e49cea4f5..bdcff36815e5f153b22f64ea5fc70687e79831de 100644 (file)
@@ -110,14 +110,14 @@ static int copy_properties[][5] =
 static int get_graphic_parameter_value(char *, char *, int);
 
 
-static Bitmap *getLoadingBackgroundBitmap(int graphic)
+static int getLoadingBackgroundImage(int graphic)
 {
-  return getBitmapFromGraphicOrDefault(graphic, INITIAL_IMG_BACKGROUND);
+  return getImageFromGraphicOrDefault(graphic, INITIAL_IMG_BACKGROUND);
 }
 
 static void SetLoadingWindowBackgroundImage(int graphic)
 {
-  SetWindowBackgroundBitmap(getLoadingBackgroundBitmap(graphic));
+  SetBackgroundImage(getLoadingBackgroundImage(graphic), REDRAW_ALL);
 }
 
 static void SetLoadingBackgroundImage(void)
@@ -5655,7 +5655,6 @@ void InitGfxBuffers(void)
   }
 
   ReCreateBitmap(&bitmap_db_field, FXSIZE, FYSIZE);
-  ReCreateBitmap(&bitmap_db_panel, DXSIZE, DYSIZE);
   ReCreateBitmap(&bitmap_db_door_1, 3 * DXSIZE, DYSIZE);
   ReCreateBitmap(&bitmap_db_door_2, 3 * VXSIZE, VYSIZE);
 
index b1d667c20d0c7cd2df6e2fbfd7029c50aba32c2b..1b2a41f46679848cd852454466cabcfd5252fdd2 100644 (file)
@@ -449,7 +449,8 @@ void SetDrawBackgroundMask(int draw_background_mask)
   gfx.draw_background_mask = draw_background_mask;
 }
 
-static void SetBackgroundBitmap(Bitmap *background_bitmap_tile, int mask)
+void SetBackgroundBitmap(Bitmap *background_bitmap_tile, int mask,
+                        int x, int y, int width, int height)
 {
   if (background_bitmap_tile != NULL)
     gfx.background_bitmap_mask |= mask;
@@ -460,40 +461,19 @@ static void SetBackgroundBitmap(Bitmap *background_bitmap_tile, int mask)
     return;
 
   if (mask == REDRAW_ALL)
-    BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap, 0, 0, 0, 0,
+    BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap,
+                   x, y, width, height,
                    0, 0, video.width, video.height);
   else if (mask == REDRAW_FIELD)
-    BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap, 0, 0, 0, 0,
+    BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap,
+                   x, y, width, height,
                    gfx.real_sx, gfx.real_sy, gfx.full_sxsize, gfx.full_sysize);
   else if (mask == REDRAW_DOOR_1)
-    BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap, 0, 0, 0, 0,
+    BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap,
+                   x, y, width, height,
                    gfx.dx, gfx.dy, gfx.dxsize, gfx.dysize);
 }
 
-void SetWindowBackgroundBitmap(Bitmap *background_bitmap_tile)
-{
-  // remove every mask before setting mask for window
-  // (!!! TO BE FIXED: The whole REDRAW_* system really sucks! !!!)
-  SetBackgroundBitmap(NULL, 0xffff);           // !!! FIX THIS !!!
-  SetBackgroundBitmap(background_bitmap_tile, REDRAW_ALL);
-}
-
-void SetMainBackgroundBitmap(Bitmap *background_bitmap_tile)
-{
-  // remove window area mask before setting mask for main area
-  // (!!! TO BE FIXED: The whole REDRAW_* system really sucks! !!!)
-  SetBackgroundBitmap(NULL, REDRAW_ALL);       // !!! FIX THIS !!!
-  SetBackgroundBitmap(background_bitmap_tile, REDRAW_FIELD);
-}
-
-void SetDoorBackgroundBitmap(Bitmap *background_bitmap_tile)
-{
-  // remove window area mask before setting mask for door area
-  // (!!! TO BE FIXED: The whole REDRAW_* system really sucks! !!!)
-  SetBackgroundBitmap(NULL, REDRAW_ALL);       // !!! FIX THIS !!!
-  SetBackgroundBitmap(background_bitmap_tile, REDRAW_DOOR_1);
-}
-
 
 // ============================================================================
 // video functions
index 524dbc586f755235b8eceb8ede0407d640dc4268..5c131b97477ac9d4eb687bb97c1ef2aa40282360 100644 (file)
@@ -1987,9 +1987,7 @@ boolean GetOverlayActive(void);
 void SetDrawDeactivationMask(int);
 int GetDrawDeactivationMask(void);
 void SetDrawBackgroundMask(int);
-void SetWindowBackgroundBitmap(Bitmap *);
-void SetMainBackgroundBitmap(Bitmap *);
-void SetDoorBackgroundBitmap(Bitmap *);
+void SetBackgroundBitmap(Bitmap *, int, int, int, int, int);
 void SetRedrawMaskFromArea(int, int, int, int);
 
 void LimitScreenUpdates(boolean);
index cf51e039414079e374806a48a7334e770507fcb0..d6bc2d26db15beb6dbd0ea0832675c2292da95bc 100644 (file)
@@ -21,7 +21,6 @@
 #include "config.h"
 
 Bitmap                *bitmap_db_field;
-Bitmap                *bitmap_db_panel;
 Bitmap                *bitmap_db_door_1;
 Bitmap                *bitmap_db_door_2;
 Bitmap                *bitmap_db_store_1;
index e111f027262d11f89b4864c911a132f254ca468e..238a0774785a98193e2b52d6cc808e4df636bb2a 100644 (file)
@@ -3762,7 +3762,6 @@ struct HelpAnimInfo
 
 
 extern Bitmap                 *bitmap_db_field;
-extern Bitmap                 *bitmap_db_panel;
 extern Bitmap                 *bitmap_db_door_1;
 extern Bitmap                 *bitmap_db_door_2;
 extern Bitmap                 *bitmap_db_store_1;
index d9e3652c2500d1598391fbbe4f09e0f69fe4e467..4ebf19bb15cc49e9e0a5f6a37937202d4ddc58dc 100644 (file)
@@ -1110,26 +1110,25 @@ static int getGlobalGameStatus(int status)
          status);
 }
 
-Bitmap *getBitmapFromGraphicOrDefault(int graphic, int default_graphic)
+int getImageFromGraphicOrDefault(int graphic, int default_graphic)
 {
   if (graphic == IMG_UNDEFINED)
-    return NULL;
+    return IMG_UNDEFINED;
 
   boolean redefined = getImageListEntryFromImageID(graphic)->redefined;
 
   return (graphic_info[graphic].bitmap != NULL || redefined ?
-         graphic_info[graphic].bitmap :
-         graphic_info[default_graphic].bitmap);
+         graphic : default_graphic);
 }
 
-static Bitmap *getBackgroundBitmap(int graphic)
+static int getBackgroundImage(int graphic)
 {
-  return getBitmapFromGraphicOrDefault(graphic, IMG_BACKGROUND);
+  return getImageFromGraphicOrDefault(graphic, IMG_BACKGROUND);
 }
 
-static Bitmap *getGlobalBorderBitmap(int graphic)
+static int getGlobalBorderImage(int graphic)
 {
-  return getBitmapFromGraphicOrDefault(graphic, IMG_GLOBAL_BORDER);
+  return getImageFromGraphicOrDefault(graphic, IMG_GLOBAL_BORDER);
 }
 
 Bitmap *getGlobalBorderBitmapFromStatus(int status_raw)
@@ -1141,51 +1140,66 @@ Bitmap *getGlobalBorderBitmapFromStatus(int status_raw)
      status == GAME_MODE_EDITOR  ? IMG_GLOBAL_BORDER_EDITOR :
      status == GAME_MODE_PLAYING ? IMG_GLOBAL_BORDER_PLAYING :
      IMG_GLOBAL_BORDER);
+  int graphic_final = getGlobalBorderImage(graphic);
 
-  return getGlobalBorderBitmap(graphic);
+  return graphic_info[graphic_final].bitmap;
+}
+
+void SetBackgroundImage(int graphic, int redraw_mask)
+{
+  struct GraphicInfo *g = &graphic_info[graphic];
+  struct GraphicInfo g_undefined = { 0 };
+
+  if (graphic == IMG_UNDEFINED)
+    g = &g_undefined;
+
+  // remove every mask before setting mask for window, and
+  // remove window area mask before setting mask for main or door area
+  int remove_mask = (redraw_mask == REDRAW_ALL ? 0xffff : REDRAW_ALL);
+
+  // (!!! TO BE FIXED: The whole REDRAW_* system really sucks! !!!)
+  SetBackgroundBitmap(NULL, remove_mask, 0, 0, 0, 0);  // !!! FIX THIS !!!
+  SetBackgroundBitmap(g->bitmap, redraw_mask,
+                     g->src_x, g->src_y,
+                     g->width, g->height);
 }
 
 void SetWindowBackgroundImageIfDefined(int graphic)
 {
   if (graphic_info[graphic].bitmap)
-    SetWindowBackgroundBitmap(graphic_info[graphic].bitmap);
+    SetBackgroundImage(graphic, REDRAW_ALL);
 }
 
 void SetMainBackgroundImageIfDefined(int graphic)
 {
   if (graphic_info[graphic].bitmap)
-    SetMainBackgroundBitmap(graphic_info[graphic].bitmap);
+    SetBackgroundImage(graphic, REDRAW_FIELD);
 }
 
 void SetDoorBackgroundImageIfDefined(int graphic)
 {
   if (graphic_info[graphic].bitmap)
-    SetDoorBackgroundBitmap(graphic_info[graphic].bitmap);
+    SetBackgroundImage(graphic, REDRAW_DOOR_1);
 }
 
 void SetWindowBackgroundImage(int graphic)
 {
-  SetWindowBackgroundBitmap(getBackgroundBitmap(graphic));
+  SetBackgroundImage(getBackgroundImage(graphic), REDRAW_ALL);
 }
 
 void SetMainBackgroundImage(int graphic)
 {
-  SetMainBackgroundBitmap(getBackgroundBitmap(graphic));
+  SetBackgroundImage(getBackgroundImage(graphic), REDRAW_FIELD);
 }
 
 void SetDoorBackgroundImage(int graphic)
 {
-  SetDoorBackgroundBitmap(getBackgroundBitmap(graphic));
+  SetBackgroundImage(getBackgroundImage(graphic), REDRAW_DOOR_1);
 }
 
 void SetPanelBackground(void)
 {
-  struct GraphicInfo *gfx = &graphic_info[IMG_BACKGROUND_PANEL];
-
-  BlitBitmapTiled(gfx->bitmap, bitmap_db_panel, gfx->src_x, gfx->src_y,
-                 gfx->width, gfx->height, 0, 0, DXSIZE, DYSIZE);
-
-  SetDoorBackgroundBitmap(bitmap_db_panel);
+  SetDoorBackgroundImage(IMG_BACKGROUND_PANEL);
 }
 
 void DrawBackground(int x, int y, int width, int height)
index 395e73b9cd04c71b26d61f31395418dae4a2f143..e0c4726d4c5e260b7d7cb08e5257425488b63ba8 100644 (file)
@@ -108,10 +108,12 @@ void FadeSetDisabled(void);
 void FadeSkipNextFadeIn(void);
 void FadeSkipNextFadeOut(void);
 
-Bitmap *getBitmapFromGraphicOrDefault(int, int);
+int getImageFromGraphicOrDefault(int, int);
 Bitmap *getGlobalBorderBitmapFromStatus(int);
 
 void ClearField(void);
+
+void SetBackgroundImage(int, int);
 void SetWindowBackgroundImageIfDefined(int);
 void SetMainBackgroundImageIfDefined(int);
 void SetDoorBackgroundImageIfDefined(int);