major cleanup of preprocessor hell
[rocksndiamonds.git] / src / game_sp / MainForm.c
index d4c3545eec5ffa5f7a1a306b0ff3390d7a4758f8..b6d7952cc14d99a515a17ccfcd2d521156caf3ef 100644 (file)
@@ -17,10 +17,8 @@ void DrawFrameIfNeeded()
   DrawFrame(0);
 
   /* !!! CHECK THIS !!! */
-#if 1
   if (! menBorder)
     DrawFrame(1);
-#endif
 }
 
 void DisplayLevel()
@@ -31,12 +29,9 @@ void DisplayLevel()
     return;
 
   ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
-  ClearRectangle(screenBitmap, 0, 0,
-                MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY);
+  ClearRectangle(bitmap_db_field_sp, 0, 0, FXSIZE, FYSIZE);
 
-#if 1
   SetDisplayRegion();
-#endif
 
   DrawFrameIfNeeded();
 
@@ -74,21 +69,27 @@ static void DrawFrame(int Delta)
   RX = FieldWidth - Delta;
   BY = FieldHeight - Delta;
 
-  DrawImage(LX, tY, imgFrameCorner);
-  DrawImage(LX, BY, imgFrameCorner);
-  DrawImage(RX, tY, imgFrameCorner);
-  DrawImage(RX, BY, imgFrameCorner);
+  DrawImage(LX, tY, (Delta > 0 ? imgFrameCorner : aniSpace));
+  DrawImage(LX, BY, (Delta > 0 ? imgFrameCorner : aniSpace));
+  DrawImage(RX, tY, (Delta > 0 ? imgFrameCorner : aniSpace));
+  DrawImage(RX, BY, (Delta > 0 ? imgFrameCorner : aniSpace));
 
   for (i = LX + 1; i <= RX - 1; i++)
   {
-    DrawImage(i, tY, imgFrameHorizontal);
-    DrawImage(i, BY, imgFrameHorizontal);
+    DrawImage(i, tY, (Delta > 0 ? imgFrameHorizontal : aniSpace));
+    DrawImage(i, BY, (Delta > 0 ? imgFrameHorizontal : aniSpace));
   }
 
   for (i = tY + 1; i <= BY - 1; i++)
   {
-    DrawImage(LX, i, imgFrameVertical);
-    DrawImage(RX, i, imgFrameVertical);
+    DrawImage(LX, i, (Delta > 0 ? imgFrameVertical : aniSpace));
+    DrawImage(RX, i, (Delta > 0 ? imgFrameVertical : aniSpace));
+  }
+
+  if (Delta > 0)
+  {
+    // ...
+    // ClearRectangle(bitmap_db_field_sp, 
   }
 }
 
@@ -147,14 +148,6 @@ void menPlay_Click()
   ReStretch();
 
   subMainGameLoop_Init();
-
-#if 1
-  return;
-#endif
-
-  bPlaying = False;
-
-  subFetchAndInitLevel();
 }
 
 static void ReStretch()
@@ -177,10 +170,26 @@ static void ReStretch()
 
 void SetScrollEdges()
 {
-  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;
+  int border1_offset = (menBorder ? 1 : 2);
+  int border2_offset = (menBorder ? 0 : TILESIZE / 2);
+
+  /* scroll correction for border frame (1 tile) or border element (2 tiles) */
+  ScrollMinX = 0;
+  ScrollMinY = 0;
+  ScrollMaxX = (DisplayMaxX + border1_offset - SCR_FIELDX) * TILEX;
+  ScrollMaxY = (DisplayMaxY + border1_offset - SCR_FIELDY) * TILEY;
+
+  /* scroll correction for border element (half tile on left and right side) */
+  ScrollMinX += border2_offset;
+  ScrollMinY += border2_offset;
+  ScrollMaxX -= border2_offset;
+  ScrollMaxY -= border2_offset;
+
+  /* scroll correction for even number of visible tiles (half tile shifted) */
+  ScrollMinX -= game_sp.scroll_xoffset;
+  ScrollMaxX -= game_sp.scroll_xoffset;
+  ScrollMinY -= game_sp.scroll_yoffset;
+  ScrollMaxY -= game_sp.scroll_yoffset;
 }
 
 void DrawField(int X, int Y)
@@ -241,25 +250,7 @@ void DrawFieldNoAnimated(int X, int Y)
       break;
 
     default:
-#if 1
       DrawField(X, Y);
-#else
-      if (Tmp < fiFirst || Tmp > fiLast)
-       Tmp = fiSpace;
-
-      if (Tmp == fiRAM ||
-         Tmp == fiHardWare ||
-         Tmp == fiBug ||
-         Tmp == fiWallSpace)
-       Tmp = DisPlayField[tsi];
-
-      subCopyImageToScreen(tsi, fiGraphic[Tmp]);
-
-      if (Tmp != fiSpace &&
-         Tmp != fiSnikSnak &&
-         Tmp != fiElectron)
-       GfxGraphic[X][Y] = fiGraphic[Tmp];
-#endif
       break;
   }
 }