rnd-20100417-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 17 Apr 2010 08:51:38 +0000 (10:51 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:59:03 +0000 (10:59 +0200)
18 files changed:
src/conf_gfx.c
src/conf_var.c
src/conftime.h
src/files.c
src/game_sp/DDScrollBuffer.c
src/game_sp/DDScrollBuffer.h
src/game_sp/DDSpriteBuffer.c
src/game_sp/MainForm.c
src/game_sp/MainGameLoop.c
src/game_sp/export.h
src/game_sp/init.c
src/game_sp/main_sp.h
src/init.c
src/libgame/system.c
src/libgame/system.h
src/main.c
src/main.h
src/tools.c

index b51564903b5db4ee42c044959e952f1bb90d8248..f8a5ae3f1d4016deedc83088910823bf608bef89 100644 (file)
@@ -6408,14 +6408,26 @@ struct ConfigInfo image_config[] =
 
   { "viewport.window.width",                   "672"                   },
   { "viewport.window.height",                  "560"                   },
-  { "viewport.playfield.width",                        "17"                    },
-  { "viewport.playfield.height",               "17"                    },
+  { "viewport.playfield.x",                    "6"                     },
+  { "viewport.playfield.y",                    "6"                     },
+  { "viewport.playfield.width",                        "548"                   },
+  { "viewport.playfield.height",               "548"                   },
+  { "viewport.playfield.border_size",          "2"                     },
+  { "viewport.playfield.MAIN.x",               ARG_DEFAULT             },
+  { "viewport.playfield.MAIN.y",               ARG_DEFAULT             },
   { "viewport.playfield.MAIN.width",           ARG_DEFAULT             },
   { "viewport.playfield.MAIN.height",          ARG_DEFAULT             },
+  { "viewport.playfield.MAIN.border_size",     ARG_DEFAULT             },
+  { "viewport.playfield.PLAYING.x",            ARG_DEFAULT             },
+  { "viewport.playfield.PLAYING.y",            ARG_DEFAULT             },
   { "viewport.playfield.PLAYING.width",                ARG_DEFAULT             },
   { "viewport.playfield.PLAYING.height",       ARG_DEFAULT             },
+  { "viewport.playfield.PLAYING.border_size",  ARG_DEFAULT             },
+  { "viewport.playfield.EDITOR.x",             ARG_DEFAULT             },
+  { "viewport.playfield.EDITOR.y",             ARG_DEFAULT             },
   { "viewport.playfield.EDITOR.width",         ARG_DEFAULT             },
   { "viewport.playfield.EDITOR.height",                ARG_DEFAULT             },
+  { "viewport.playfield.EDITOR.border_size",   ARG_DEFAULT             },
   { "viewport.door_1.x",                       "566"                   },
   { "viewport.door_1.y",                       "60"                    },
   { "viewport.door_1.MAIN.x",                  ARG_DEFAULT             },
index 4593e424fe06449c878de11d07f29b593d446d80..e12f0015938b77fd769bb1a0c30248caab987ee6 100644 (file)
@@ -5100,6 +5100,14 @@ struct TokenIntPtrInfo image_config_vars[] =
     "viewport.window.height",
     &viewport.window.height
   },
+  {
+    "viewport.playfield.x",
+    &viewport.playfield[GFX_SPECIAL_ARG_DEFAULT].x
+  },
+  {
+    "viewport.playfield.y",
+    &viewport.playfield[GFX_SPECIAL_ARG_DEFAULT].y
+  },
   {
     "viewport.playfield.width",
     &viewport.playfield[GFX_SPECIAL_ARG_DEFAULT].width
@@ -5108,6 +5116,18 @@ struct TokenIntPtrInfo image_config_vars[] =
     "viewport.playfield.height",
     &viewport.playfield[GFX_SPECIAL_ARG_DEFAULT].height
   },
+  {
+    "viewport.playfield.border_size",
+    &viewport.playfield[GFX_SPECIAL_ARG_DEFAULT].border_size
+  },
+  {
+    "viewport.playfield.MAIN.x",
+    &viewport.playfield[GFX_SPECIAL_ARG_MAIN].x
+  },
+  {
+    "viewport.playfield.MAIN.y",
+    &viewport.playfield[GFX_SPECIAL_ARG_MAIN].y
+  },
   {
     "viewport.playfield.MAIN.width",
     &viewport.playfield[GFX_SPECIAL_ARG_MAIN].width
@@ -5116,6 +5136,18 @@ struct TokenIntPtrInfo image_config_vars[] =
     "viewport.playfield.MAIN.height",
     &viewport.playfield[GFX_SPECIAL_ARG_MAIN].height
   },
+  {
+    "viewport.playfield.MAIN.border_size",
+    &viewport.playfield[GFX_SPECIAL_ARG_MAIN].border_size
+  },
+  {
+    "viewport.playfield.PLAYING.x",
+    &viewport.playfield[GFX_SPECIAL_ARG_PLAYING].x
+  },
+  {
+    "viewport.playfield.PLAYING.y",
+    &viewport.playfield[GFX_SPECIAL_ARG_PLAYING].y
+  },
   {
     "viewport.playfield.PLAYING.width",
     &viewport.playfield[GFX_SPECIAL_ARG_PLAYING].width
@@ -5124,6 +5156,18 @@ struct TokenIntPtrInfo image_config_vars[] =
     "viewport.playfield.PLAYING.height",
     &viewport.playfield[GFX_SPECIAL_ARG_PLAYING].height
   },
+  {
+    "viewport.playfield.PLAYING.border_size",
+    &viewport.playfield[GFX_SPECIAL_ARG_PLAYING].border_size
+  },
+  {
+    "viewport.playfield.EDITOR.x",
+    &viewport.playfield[GFX_SPECIAL_ARG_EDITOR].x
+  },
+  {
+    "viewport.playfield.EDITOR.y",
+    &viewport.playfield[GFX_SPECIAL_ARG_EDITOR].y
+  },
   {
     "viewport.playfield.EDITOR.width",
     &viewport.playfield[GFX_SPECIAL_ARG_EDITOR].width
@@ -5132,6 +5176,10 @@ struct TokenIntPtrInfo image_config_vars[] =
     "viewport.playfield.EDITOR.height",
     &viewport.playfield[GFX_SPECIAL_ARG_EDITOR].height
   },
+  {
+    "viewport.playfield.EDITOR.border_size",
+    &viewport.playfield[GFX_SPECIAL_ARG_EDITOR].border_size
+  },
   {
     "viewport.door_1.x",
     &viewport.door_1[GFX_SPECIAL_ARG_DEFAULT].x
index d918a3cb47a61f120e70bf2adde6c9d47c6bde5d..aa3503a057bdeffbfb01377d2b4d09dbdd1975d7 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2010-04-16 11:49"
+#define COMPILE_DATE_STRING "2010-04-17 10:50"
index 9f92ad68cb84300f0e09883ac808a6803a4b153a..a1017dd2d04c59ed2da1764235c90462c095815f 100644 (file)
@@ -9957,31 +9957,44 @@ static void LoadMenuDesignSettingsFromFilename(char *filename)
   /* (eg, init "viewport.door_1.MAIN.xyz" from "viewport.door_1.xyz") */
   for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)
   {
-    char *token_1 = "viewport.playfield.width";
-    char *token_2 = "viewport.playfield.height";
-    char *token_3 = "viewport.door_1.x";
-    char *token_4 = "viewport.door_1.y";
-    char *token_5 = "viewport.door_2.x";
-    char *token_6 = "viewport.door_2.y";
+    char *token_1 = "viewport.playfield.x";
+    char *token_2 = "viewport.playfield.y";
+    char *token_3 = "viewport.playfield.width";
+    char *token_4 = "viewport.playfield.height";
+    char *token_5 = "viewport.playfield.border_size";
+    char *token_6 = "viewport.door_1.x";
+    char *token_7 = "viewport.door_1.y";
+    char *token_8 = "viewport.door_2.x";
+    char *token_9 = "viewport.door_2.y";
     char *value_1 = getHashEntry(setup_file_hash, token_1);
     char *value_2 = getHashEntry(setup_file_hash, token_2);
     char *value_3 = getHashEntry(setup_file_hash, token_3);
     char *value_4 = getHashEntry(setup_file_hash, token_4);
     char *value_5 = getHashEntry(setup_file_hash, token_5);
     char *value_6 = getHashEntry(setup_file_hash, token_6);
+    char *value_7 = getHashEntry(setup_file_hash, token_7);
+    char *value_8 = getHashEntry(setup_file_hash, token_8);
+    char *value_9 = getHashEntry(setup_file_hash, token_9);
 
     if (value_1 != NULL)
-      viewport.playfield[i].width = get_token_parameter_value(token_1,value_1);
+      viewport.playfield[i].x = get_token_parameter_value(token_1, value_1);
     if (value_2 != NULL)
-      viewport.playfield[i].height = get_token_parameter_value(token_2,value_2);
+      viewport.playfield[i].y = get_token_parameter_value(token_2, value_2);
     if (value_3 != NULL)
-      viewport.door_1[i].x = get_token_parameter_value(token_3, value_3);
+      viewport.playfield[i].width = get_token_parameter_value(token_3, value_3);
     if (value_4 != NULL)
-      viewport.door_1[i].y = get_token_parameter_value(token_4, value_4);
+      viewport.playfield[i].height = get_token_parameter_value(token_4,value_4);
     if (value_5 != NULL)
-      viewport.door_2[i].x = get_token_parameter_value(token_5, value_5);
+      viewport.playfield[i].border_size = get_token_parameter_value(token_5,
+                                                                   value_5);
     if (value_6 != NULL)
-      viewport.door_2[i].y = get_token_parameter_value(token_6, value_6);
+      viewport.door_1[i].x = get_token_parameter_value(token_6, value_6);
+    if (value_7 != NULL)
+      viewport.door_1[i].y = get_token_parameter_value(token_7, value_7);
+    if (value_8 != NULL)
+      viewport.door_2[i].x = get_token_parameter_value(token_8, value_8);
+    if (value_9 != NULL)
+      viewport.door_2[i].y = get_token_parameter_value(token_9, value_9);
   }
 
   /* special case: initialize with default values that may be overwritten */
index 48710acec62fece318298015fc374b6fdd14bdf5..70c4c5a6c4835affe4c189ed282d238a9bff69e3 100644 (file)
 long mScrollX, mScrollY;
 long mScrollX_last, mScrollY_last;
 
+#if 1
+long ScreenBuffer[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2];
+boolean redraw[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2];
+#else
 long ScreenBuffer[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
 boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
+#endif
 
 
 void RestorePlayfield()
@@ -45,7 +50,7 @@ static void ScrollPlayfield(int dx, int dy)
   int y2 = mScrollY_last / TILEY + (SCR_FIELDY - 1) + 2;
   int x, y;
 
-  BlitBitmap(screenBitmap, screenBitmap,
+  BlitBitmap(bitmap_db_field_sp, bitmap_db_field_sp,
              TILEX * (dx == -1),
              TILEY * (dy == -1),
              (MAX_BUF_XSIZE * TILEX) - TILEX * (dx != 0),
@@ -217,6 +222,13 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap)
   int py = 2 * TILEY + (mScrollY - mScrollY_last) % TILEY;
   int sx, sy, sxsize, sysize;
 
+#if 1
+  printf("::: %d, %d - %d, %d - %ld, %ld\n",
+        MurphyScreenXPos, MurphyScreenYPos,
+        ScreenScrollXPos, ScreenScrollYPos,
+        mScrollX, mScrollY);
+#endif
+
   int xsize = SXSIZE;
   int ysize = SYSIZE;
   int full_xsize = (FieldWidth  - (menBorder ? 0 : 1)) * TILEX;
@@ -227,13 +239,27 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap)
   sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0);
   sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0);
 
+#if 1
+  if (0 && !menBorder)
+  {
+    if (mScrollX < ScrollMinX + TILEX / 2)
+      px += ScrollMinX + TILEX / 2 - mScrollX;
+    else if (mScrollX > ScrollMaxX - TILEX / 2)
+      px -= mScrollX - (ScrollMaxX - TILEX / 2);
+    if (mScrollY < ScrollMinY + TILEY / 2)
+      py += ScrollMinY + TILEY / 2 - mScrollY;
+    else if (mScrollY > ScrollMaxY - TILEY / 2)
+      py -= mScrollY - (ScrollMaxY - TILEY / 2);
+  }
+#else
   if (!menBorder)
   {
     px += TILEX / 2;
     py += TILEY / 2;
   }
+#endif
 
-  BlitBitmap(screenBitmap, target_bitmap, px, py, sxsize, sysize, sx, sy);
+  BlitBitmap(bitmap_db_field_sp, target_bitmap, px, py, sxsize, sysize, sx, sy);
 }
 
 void BackToFront_SP(void)
@@ -261,7 +287,7 @@ void BackToFront_SP(void)
        int yy = (top  + y) % MAX_BUF_YSIZE;
 
        if (redraw[xx][yy])
-         BlitBitmap(screenBitmap, window,
+         BlitBitmap(bitmap_db_field_sp, window,
                     xx * TILEX, yy * TILEY, TILEX, TILEY,
                     SX + x * TILEX, SY + y * TILEY);
       }
index 78c6e563ad90aaf9549d05e85cb56eded2d8b1a2..e34ef21952c7eea8d280561cd40fb06f3fee08e6 100644 (file)
 extern long mScrollX, mScrollY;
 extern long mScrollX_last, mScrollY_last;
 
+#if 1
+extern boolean redraw[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2];
+#else
 extern boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
+#endif
 
 extern int TEST_flag;
 
index 863aac39f4a8e9f2516ea96f8082fc565e365058..4683d319d1829b2c4d646f2985e8362705ed2858 100644 (file)
@@ -24,7 +24,7 @@ static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY)
   if (pX < sx1 || pX > sx2 || pY < sy1 || pY > sy2)
     return;
 
-  BlitBitmap(bitmap, screenBitmap, SpriteX, SpriteY,
+  BlitBitmap(bitmap, bitmap_db_field_sp, SpriteX, SpriteY,
             TILEX, TILEY, sx, sy);
 }
 
index d4c3545eec5ffa5f7a1a306b0ff3390d7a4758f8..9f0b6cb573de48f98f20f2cb195ee858695b49b0 100644 (file)
@@ -31,8 +31,12 @@ void DisplayLevel()
     return;
 
   ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
-  ClearRectangle(screenBitmap, 0, 0,
+#if 1
+  ClearRectangle(bitmap_db_field_sp, 0, 0, FXSIZE, FYSIZE);
+#else
+  ClearRectangle(bitmap_db_field_sp, 0, 0,
                 MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY);
+#endif
 
 #if 1
   SetDisplayRegion();
@@ -177,10 +181,36 @@ static void ReStretch()
 
 void SetScrollEdges()
 {
+#if 1
+  int border_offset = (menBorder ? 1 : 2);
+
+  ScrollMinX = 0;
+  ScrollMinY = 0;
+  ScrollMaxX = (DisplayMaxX + border_offset) * BaseWidth - SXSIZE;
+  ScrollMaxY = (DisplayMaxY + border_offset) * BaseWidth - SYSIZE;
+
+#if 1
+  if (!menBorder)
+  {
+    ScrollMinX += TILEX / 2;
+    ScrollMinY += TILEY / 2;
+    ScrollMaxX -= TILEX / 2;
+    ScrollMaxY -= TILEY / 2;
+  }
+#endif
+
+#else
   ScrollMinX = (int)(DisplayMinX - 0.5) * BaseWidth;
   ScrollMinY = (int)(DisplayMinY - 0.5) * BaseWidth;
   ScrollMaxX = (int)(DisplayMaxX + 1.5) * BaseWidth - SXSIZE;
   ScrollMaxY = (int)(DisplayMaxY + 1.5) * BaseWidth - SYSIZE;
+#endif
+
+#if 1
+  printf("::: (%ld, %ld), (%ld, %ld) -> (%d, %d), (%d, %d)\n",
+        DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
+        ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY);
+#endif
 }
 
 void DrawField(int X, int Y)
index 145c0436798e2487ce1167314f72a9cc6d8972c4..2a6d25515b21287fff51ec4edb236d1f1f8e7525 100644 (file)
@@ -122,11 +122,17 @@ void subCalculateScreenScrollPos()
     // printf("::: ExplosionShake [%d]\n", FrameCounter);
   }
 
-  {
-    ax = SXSIZE / 2;
-    ay = SYSIZE / 2;
-  }
+#if 1
+  ax = (SCR_FIELDX / 2) * TILESIZE;
+  ay = (SCR_FIELDY / 2) * TILESIZE;
+
+  ScreenScrollXPos = MurphyScreenXPos - ax;
+  ScreenScrollYPos = MurphyScreenYPos - ay;
+#else
+  ax = SXSIZE / 2;
+  ay = SYSIZE / 2;
 
   ScreenScrollXPos = (MurphyScreenXPos + TILEX / 2) - ax;
   ScreenScrollYPos = (MurphyScreenYPos + TILEY / 2) - ay;
+#endif
 }
index ca5912b60d58aada1abb3511adda8b241a0f6cd6..b5c0d0bb27285ff509b307d131ac5973b41f4712 100644 (file)
@@ -184,6 +184,8 @@ extern struct EngineSnapshotInfo_SP engine_snapshot_sp;
 extern void sp_open_all();
 extern void sp_close_all();
 
+extern void InitGfxBuffers_SP();
+
 extern void InitGameEngine_SP();
 extern void GameActions_SP(byte *, boolean);
 
index 32a832c200e45ce21ed4f9050974c54dbfa37e26..a8e672769bc70bac22bb95f7ade02ee9a71af9de 100644 (file)
@@ -3,7 +3,7 @@
 #include "global.h"
 
 
-Bitmap *screenBitmap;
+Bitmap *bitmap_db_field_sp;
 
 struct EngineSnapshotInfo_SP engine_snapshot_sp;
 
@@ -11,14 +11,41 @@ void sp_open_all()
 {
   Form_Load();
 
-  screenBitmap = CreateBitmap(MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY,
-                              DEFAULT_DEPTH);
+#if 0
+  printf("::: open 1: %d, %d [%08x]\n", FXSIZE, FYSIZE, bitmap_db_field_sp);
+
+  /*
+  bitmap_db_field_sp = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
+  bitmap_db_field_sp = CreateBitmap(MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY,
+                             DEFAULT_DEPTH);
+  */
+
+  ReCreateBitmap(&bitmap_db_field_sp, FXSIZE, FYSIZE, DEFAULT_DEPTH);
+
+  printf("::: open 2: %d, %d [%08x]\n", FXSIZE, FYSIZE, bitmap_db_field_sp);
+#endif
 }
 
 void sp_close_all()
 {
 }
 
+void InitGfxBuffers_SP()
+{
+#if 1
+  printf("::: init 1: %d, %d [%08x]\n", FXSIZE, FYSIZE, bitmap_db_field_sp);
+
+  /*
+  ReCreateBitmap(&bitmap_db_field_sp, MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY,
+                DEFAULT_DEPTH);
+  */
+
+  ReCreateBitmap(&bitmap_db_field_sp, FXSIZE, FYSIZE, DEFAULT_DEPTH);
+
+  printf("::: init 2: %d, %d [%08x]\n", FXSIZE, FYSIZE, bitmap_db_field_sp);
+#endif
+}
+
 unsigned int InitEngineRandom_SP(long seed)
 {
   if (seed == NEW_RANDOMIZE)
index ff3035a483dd0c2a20ef6f8af10f7f09f1a7ad31..6e61508b44bdc93487cb51a5eb817d7d57c2c013 100644 (file)
 
 /* screen sizes and positions for SP engine */
 
-#define ORIG_TILEX             16
-#define ORIG_TILEY             16
+#define ORIG_TILESIZE          16
 
 #define ZOOM_FACTOR            2
 
-#define TILEX                  (ORIG_TILEX             * ZOOM_FACTOR)
-#define TILEY                  (ORIG_TILEY             * ZOOM_FACTOR)
+#define TILESIZE               (ORIG_TILESIZE * ZOOM_FACTOR)
+#define TILEX                  TILESIZE
+#define TILEY                  TILESIZE
 
 #define ORIG_SCR_MENUX         20
 #define ORIG_SCR_MENUY         12
 #define SCR_MENUX              17
 #define SCR_MENUY              12
+#if 1
+extern int                     SCR_FIELDX, SCR_FIELDY;
+#else
 #define SCR_FIELDX             17
 #define SCR_FIELDY             17
+#endif
 #define MAX_BUF_XSIZE          (2 + SCR_FIELDX + 2)
 #define MAX_BUF_YSIZE          (2 + SCR_FIELDY + 2)
 
 /* often used screen positions */
+#if 1
+extern int                     SX, SY;
+#else
 #define SX                     8
 #define SY                     8
+#endif
 #define SXSIZE                 (SCR_FIELDX * TILEX)
 #define SYSIZE                 (SCR_FIELDY * TILEY)
+#define FXSIZE                 (MAX_BUF_XSIZE * TILEX)
+#define FYSIZE                 (MAX_BUF_YSIZE * TILEY)
 
+#if 1
+extern int                     REAL_SX, REAL_SY;
+#else
 #define REAL_SX                        (SX - 2)
 #define REAL_SY                        (SY - 2)
+#endif
 #define FULL_SXSIZE            (2 + SXSIZE + 2)
 #define FULL_SYSIZE            (2 + SYSIZE + 2)
 
@@ -66,9 +80,7 @@
 
 extern struct LevelInfo_SP native_sp_level;
 
-extern Bitmap *screenBitmap;
-
-extern Bitmap *sp_objects;
+extern Bitmap *bitmap_db_field_sp;
 
 extern int GfxElementLast[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT];
 extern int GfxGraphicLast[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT];
index 89b4bc6a879ed15041830c7501d5c9da26d15feb..3d7b3065e534adf6c2d1d6446fc07b92efa23eb3 100644 (file)
@@ -5465,6 +5465,8 @@ void InitGfxBuffers()
   InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
   InitGfxWindowInfo(WIN_XSIZE, WIN_YSIZE);
   InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
+
+  InitGfxBuffers_SP();
 }
 
 void InitGfx()
index 8a5942da4af6ca6984b540c1ef99f4c8e1686ebf..bccb5fddddbc847b0208998eb783968cb86b9dd9 100644 (file)
@@ -512,6 +512,38 @@ boolean DrawingOnBackground(int x, int y)
          CheckDrawingArea(x, y, 1, 1, gfx.draw_background_mask));
 }
 
+static boolean ValidClippedRectangle(Bitmap *bitmap, int *x, int *y,
+                                    int *width, int *height)
+{
+  /* skip if rectangle completely outside bitmap */
+
+  if (*x + *width <= 0 ||
+      *y + *height <= 0 ||
+      *x >= bitmap->width ||
+      *y >= bitmap->height)
+    return FALSE;
+
+  /* clip if rectangle overlaps bitmap */
+
+  if (*x < 0)
+  {
+    *x = 0;
+    *width += *x;
+  }
+  else if (*x + *width > bitmap->width)
+    *width = bitmap->width - *x;
+
+  if (*y < 0)
+  {
+    *y = 0;
+    *height += *y;
+  }
+  else if (*y + *height > bitmap->height)
+    *height = bitmap->height - *y;
+
+  return TRUE;
+}
+
 void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap,
                int src_x, int src_y, int width, int height,
                int dst_x, int dst_y)
@@ -520,6 +552,10 @@ void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap,
     return;
 
 #if 1
+  if (!ValidClippedRectangle(src_bitmap, &src_x, &src_y, &width, &height) ||
+      !ValidClippedRectangle(dst_bitmap, &dst_x, &dst_y, &width, &height))
+    return;
+#else
   /* skip if rectangle starts outside bitmap */
   if (src_x >= src_bitmap->width ||
       src_y >= src_bitmap->height ||
@@ -599,6 +635,12 @@ void FadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height,
                   int fade_mode, int fade_delay, int post_delay,
                   void (*draw_border_function)(void))
 {
+#if 1
+  /* (use bitmap "backbuffer" -- "bitmap_cross" may be undefined) */
+  if (!ValidClippedRectangle(backbuffer, &x, &y, &width, &height))
+    return;
+#endif
+
 #if defined(TARGET_SDL)
   SDLFadeRectangle(bitmap_cross, x, y, width, height,
                   fade_mode, fade_delay, post_delay, draw_border_function);
@@ -615,6 +657,9 @@ void FillRectangle(Bitmap *bitmap, int x, int y, int width, int height,
     return;
 
 #if 1
+  if (!ValidClippedRectangle(bitmap, &x, &y, &width, &height))
+    return;
+#else
   /* skip if rectangle starts outside bitmap */
   if (x >= bitmap->width ||
       y >= bitmap->height)
index d35505b5a0183982f98c00f8724986ca091f186e..51017fec1808d696b9d78e07dd7dec04ad6d39b5 100644 (file)
@@ -1108,6 +1108,13 @@ struct Rect
   int width, height;
 };
 
+struct RectWithBorder
+{
+  int x, y;
+  int width, height;
+  int border_size;
+};
+
 struct MenuPosInfo
 {
   int x, y;
index aab51a3824fce88fde27434e27eb7497915e3a4b..b9e35e2b568e7c04b49d62aec00ffd980a8c94fc 100644 (file)
@@ -90,11 +90,17 @@ int                 scroll_x, scroll_y;
 
 int                    WIN_XSIZE = 672, WIN_YSIZE = 560;
 int                    SCR_FIELDX = 17, SCR_FIELDY = 17;
+int                    SX = 8, SY = 8;
+int                    REAL_SX = 6, REAL_SY = 6;
 int                    DX = 566, DY = 60;
 int                    VX = 566, VY = 400;
 int                    EX = 566, EY = 356;
 
+#if 1
+int                    FX, FY;
+#else
 int                    FX = SX, FY = SY;
+#endif
 int                    ScrollStepSize;
 int                    ScreenMovDir = MV_NONE, ScreenMovPos = 0;
 int                    ScreenGfxPos = 0;
index 4268c9018b494b39e759a60e340852237313637e..f71341b2b513ed5fea5f63777c653eabf7d8fd9d 100644 (file)
 #define MAX_INITIAL_INVENTORY_SIZE     8
 
 /* often used screen positions */
+#if 0
 #define SX                     8
 #define SY                     8
 #define REAL_SX                        (SX - 2)
 #define REAL_SY                        (SY - 2)
-#if 0
 #define DX                     566
 #define DY                     60
 #define VX                     DX
@@ -2259,10 +2259,10 @@ struct PreviewInfo
 
 struct ViewportInfo
 {
-  struct Rect window;
-  struct Rect playfield[NUM_SPECIAL_GFX_ARGS];
-  struct Rect door_1[NUM_SPECIAL_GFX_ARGS];
-  struct Rect door_2[NUM_SPECIAL_GFX_ARGS];
+  struct RectWithBorder window;
+  struct RectWithBorder playfield[NUM_SPECIAL_GFX_ARGS];
+  struct RectWithBorder door_1[NUM_SPECIAL_GFX_ARGS];
+  struct RectWithBorder door_2[NUM_SPECIAL_GFX_ARGS];
 };
 
 struct HiScore
@@ -2863,6 +2863,8 @@ extern int                        scroll_x, scroll_y;
 
 extern int                     WIN_XSIZE, WIN_YSIZE;
 extern int                     SCR_FIELDX, SCR_FIELDY;
+extern int                     SX, SY;
+extern int                     REAL_SX, REAL_SY;
 extern int                     DX, DY;
 extern int                     VX, VY;
 extern int                     EX, EY;
index 2ec7c9ee816cbb412912f2b96394c136e448f8b2..cb23bae615649c143a0e385aa126f6eb869a4f63 100644 (file)
@@ -8095,6 +8095,14 @@ void ChangeViewportPropertiesIfNeeded()
   int gfx_game_mode = (game_status == GAME_MODE_PLAYING ||
                       game_status == GAME_MODE_EDITOR ? game_status :
                       GAME_MODE_MAIN);
+  struct RectWithBorder *vp_playfield = &viewport.playfield[gfx_game_mode];
+  struct RectWithBorder *vp_door_1 = &viewport.door_1[gfx_game_mode];
+  struct RectWithBorder *vp_door_2 = &viewport.door_2[gfx_game_mode];
+  int border_size = vp_playfield->border_size;
+  int new_sx = vp_playfield->x + border_size;
+  int new_sy = vp_playfield->y + border_size;
+  int new_scr_fieldx = (vp_playfield->width  - 2 * border_size) / TILESIZE;
+  int new_scr_fieldy = (vp_playfield->height - 2 * border_size) / TILESIZE;
 
   if (viewport.window.width  != WIN_XSIZE ||
       viewport.window.height != WIN_YSIZE)
@@ -8113,20 +8121,28 @@ void ChangeViewportPropertiesIfNeeded()
 #endif
   }
 
-  if (viewport.playfield[gfx_game_mode].width  != SCR_FIELDX ||
-      viewport.playfield[gfx_game_mode].height != SCR_FIELDY ||
-      viewport.door_1[gfx_game_mode].x != *door_1_x ||
-      viewport.door_1[gfx_game_mode].y != *door_1_y ||
-      viewport.door_2[gfx_game_mode].x != *door_2_x ||
-      viewport.door_2[gfx_game_mode].y != *door_2_y)
-  {
-    SCR_FIELDX = viewport.playfield[gfx_game_mode].width;
-    SCR_FIELDY = viewport.playfield[gfx_game_mode].height;
-
-    *door_1_x = viewport.door_1[gfx_game_mode].x;
-    *door_1_y = viewport.door_1[gfx_game_mode].y;
-    *door_2_x = viewport.door_2[gfx_game_mode].x;
-    *door_2_y = viewport.door_2[gfx_game_mode].y;
+  if (new_scr_fieldx != SCR_FIELDX ||
+      new_scr_fieldy != SCR_FIELDY ||
+      new_sx != SX ||
+      new_sy != SY ||
+      vp_playfield->x != REAL_SX ||
+      vp_playfield->y != REAL_SY ||
+      vp_door_1->x != *door_1_x ||
+      vp_door_1->y != *door_1_y ||
+      vp_door_2->x != *door_2_x ||
+      vp_door_2->y != *door_2_y)
+  {
+    SCR_FIELDX = new_scr_fieldx;
+    SCR_FIELDY = new_scr_fieldy;
+    SX = new_sx;
+    SY = new_sy;
+    REAL_SX = vp_playfield->x;
+    REAL_SY = vp_playfield->y;
+
+    *door_1_x = vp_door_1->x;
+    *door_1_y = vp_door_1->y;
+    *door_2_x = vp_door_2->x;
+    *door_2_y = vp_door_2->y;
 
     InitGfxBuffers();