rnd-20100107-1-src
[rocksndiamonds.git] / src / game_sp / MainForm.c
index 5c3b85fda28de4470669981ae381b6fe7396c8c3..9ee82353ac76f8e22d6ce2e6d8c72eca30aa57ce 100644 (file)
@@ -674,16 +674,26 @@ void DrawFieldNoAnimated(int X, int Y);
 // --- Option Explicit
 // --- Option Compare Text
 
+#if 0
+
 long SetParent(long hWndChild, long hWndNewParent);
 long SetWindowLong(long hWnd, long nIndex, long dwNewLong);
 long GetWindowLong(long hWnd, long nIndex);
+#if 0
 long GetTempPath(long nBufferLength, char *lpBuffer);
+#endif
 long GetWindowText(long hWnd, char *lpString, long cch);
 
+#endif
+
+#if 0
+
 #define GWL_STYLE                      ((-16))
 #define WS_CHILD                       (0x40000000)
 #define WS_POPUP                       (0x80000000)
 
+#endif
+
 // [UNCOMMENTED] Dim StretchWidth2&
 
 char *MpxBmp;
@@ -1003,11 +1013,22 @@ static boolean InstanceStillRunning(char *TmpFile)
 
 #endif
 
+void DrawFrameIfNeeded()
+{
+  DrawFrame(0);
+
+  /* !!! CHECK THIS !!! */
+#if 1
+  if (! menBorder.Checked)
+    DrawFrame(1);
+#endif
+}
+
 void DisplayLevel()
 {
   int X, Y;
 
-#if 1
+#if 0
   printf("::: MainForm.c: DisplayLevel(): %d, %d, %d\n",
         Loaded, LevelLoaded, bPlaying);
 #endif
@@ -1018,20 +1039,25 @@ void DisplayLevel()
   if (! LevelLoaded)
     return;
 
+  ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
+  ClearRectangle(screenBitmap, 0, 0,
+                MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY);
+
 #if 1
   SetDisplayRegion();
 #endif
 
   DrawFrame(0);
 
-#if 0
+  /* !!! CHECK THIS !!! */
+#if 1
   if (! menBorder.Checked)
     DrawFrame(1);
 #endif
 
   if (bPlaying)
   {
-#if 1
+#if 0
     printf("::: MainForm.c: DisplayLevel(): [%ld, %ld, %ld, %ld] [%d, %d]...\n",
           DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
           FieldWidth, FieldHeight);
@@ -1369,7 +1395,10 @@ void Form_Load()
   PauseMode = 0;
   //  BaseWidth = 16
 
-  menBorder_Click();
+#if 1
+  if (0)
+    menBorder_Click();
+#endif
 
   Loaded = True;
 
@@ -1604,7 +1633,7 @@ static void Form_Resize()
   //  NW = ScaleWidth - 2 * Space: If NW < 0 Then NW = 0
   //  NH = ScaleHeight - 3 * Space - cmbLevel.Height: If NH < 0 Then NH = 0
   //  picViewPort.Move Space, Space, NW, NH
-  Tmp = (ShowPanel != 0 ?  ScaleHeight - Panel.Height :  ScaleHeight - Panel.Height);
+  Tmp = (ShowPanel != 0 ? ScaleHeight - Panel.Height : ScaleHeight);
   if (Tmp < 0)
     Tmp = 0;
 
@@ -2022,7 +2051,7 @@ static void UpdateDeltaT()
   if (! bPlaying)
     return;
 
-  DeltaT = (DemoFlag != 0 ?  DeltaTDemo :  DeltaTDemo);
+  DeltaT = (DemoFlag != 0 ? DeltaTDemo : DeltaTPlay);
   if (DeltaT < 0)
   {
     Stage.Blt();
@@ -2087,7 +2116,7 @@ static void menOpen_Click()
     */
 
     LFilt = LastOpenFilter;
-    cmDlg.FilterIndex = (0 < LFilt & LFilt < 5 ?  LFilt :  LFilt);
+    cmDlg.FilterIndex = (0 < LFilt & LFilt < 5 ? LFilt : 1);
     if (FileExists(CurPath))
       cmDlg.InitDir = WithSlash(StripDir(CurPath));
 
@@ -2164,7 +2193,7 @@ static void menPause_Click()
   static StdPicture OldPic;
   static char *OldText = 0;
 
-  PauseMode = (PauseMode != 0 ?  0 :  0);
+  PauseMode = (PauseMode != 0 ? 0 : 1);
   if (PauseMode != 0)
   {
     if (IS_NOTHING(&OldPic, sizeof(OldPic)))
@@ -2391,7 +2420,7 @@ static void menSoundFX_Click()
 {
   {
     menSoundFX.Checked = ! menSoundFX.Checked;
-    FXOnFlag = (menSoundFX.Checked ?  -1 :  -1);
+    FXOnFlag = (menSoundFX.Checked ? -1 : 0);
   }
 }
 
@@ -2462,12 +2491,15 @@ void menPlay_Click()
 #endif
 
 #if 1
+#endif
+
+#if 0
   printf("::: MainForm.c: menPlay_Click(): subFetchAndInitLevelB(): ...\n");
 #endif
 
   subFetchAndInitLevelB();
 
-#if 1
+#if 0
   printf("::: MainForm.c: menPlay_Click(): subFetchAndInitLevelB(): done\n");
 #endif
 
@@ -2509,7 +2541,9 @@ void menPlay_Click()
 
   // Trace "MainForm", "subFetchAndInitLevel returned"
 
+#if 0
   Stage.Blt();
+#endif
 
 #if 0
 
@@ -2520,23 +2554,60 @@ void menPlay_Click()
   // Trace "MainForm", "<-- menPlay_Click()"
 
 #endif
-
 }
 
+#if 1
+
+// static void menPlayDemo_Click()
+void menPlayDemo_Click()
+{
+  DemoFlag = 1;
+  RecordDemoFlag = 0;
+
 #if 0
+  lblStatus = "Demo Playback";
+#endif
 
-static void menPlayDemo_Click()
+  menPlay_Click();
+
+#if 1
+  return;      /* return after initialization phase */
+#endif
+
+#if 0
+  if (LevelStatus != 1)
+    lblStatus = "Demo Failed";
+#endif
+
+  DemoFlag = 0;
+}
+
+#else
+
+// static void menPlayDemo_Click()
+void menPlayDemo_Click()
 {
   DemoFlag = 1;
   RecordDemoFlag = 0;
+
+#if 0
   lblStatus = "Demo Playback";
+#endif
+
   menPlay_Click();
+
+#if 0
   if (LevelStatus != 1)
     lblStatus = "Demo Failed";
+#endif
 
   DemoFlag = 0;
 }
 
+#endif
+
+#if 0
+
 static void menRec_Click()
 {
   Trace("MainForm", "--> menRec_Click()");
@@ -2717,7 +2788,7 @@ static void PanelTim_Timer()
   Tmp = Panel.Height;
   if (PanelSeq < Panel.Height && -1 < PanelSeq)
   {
-    PanelSeq = (ShowPanel != 0 ?  PanelSeq + 2 :  PanelSeq + 2);
+    PanelSeq = (ShowPanel != 0 ? PanelSeq + 2 : PanelSeq - 2);
     Tmp = ScaleHeight - Tmp + PanelSeq;
     Panel.top = Tmp;
     picViewPort.Height = Tmp;
@@ -2725,8 +2796,8 @@ static void PanelTim_Timer()
   else
   {
     PanelTim.Enabled = False;
-    PanelSeq = (PanelSeq < 0 ?  0 :  0);
-    ShowPanel = (ShowPanel == 0 ?  1 :  1);
+    PanelSeq = (PanelSeq < 0 ? 0 : PanelSeq - );
+    ShowPanel = (ShowPanel == 0 ? 1 : 0);
     menPanel.Checked = (ShowPanel != 0);
   }
 }
@@ -2952,7 +3023,11 @@ static void picPane_Paint()
 
   Oldflag = NoDisplayFlag;
   NoDisplayFlag = False;
+
+#if 0
   Stage.Blt();
+#endif
+
   NoDisplayFlag = Oldflag;
 }
 
@@ -2964,13 +3039,13 @@ static void ReStretch(float NewStretch)
   long BW2, LW, LH, i;
 #endif
 
-#if 1
+#if 0
   printf("::: MainForm.c: ReStretch(): %d, %d\n", Loaded, LevelLoaded);
 #endif
 
   if (! Loaded)
   {
-#if 1
+#if 0
     printf("::: NewStretch == %f\n", NewStretch);
 #endif
 
@@ -3027,7 +3102,7 @@ static void ReStretch(float NewStretch)
 
     if (Loaded && LevelLoaded)
     {
-#if 1
+#if 0
       printf("::: MainForm.c: ReStretch(): ...\n");
 #endif
 
@@ -3038,13 +3113,15 @@ static void ReStretch(float NewStretch)
 
     subCalculateScreenScrollPos();
 
-#if 1
+#if 0
   printf("::: MainForm.c: ReStretch(): %d, %d\n", ScreenScrollXPos, ScreenScrollYPos);
 #endif
 
     ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
 
+#if 0
     Stage.Blt();
+#endif
 
     picPane_Paint();
   }
@@ -3054,9 +3131,13 @@ static void ReStretch(float NewStretch)
 #endif
 }
 
+#if 0
 static void SetScrollEdges()
+#else
+void SetScrollEdges()
+#endif
 {
-#if 1
+#if 0
   printf("::: MainForm.c: SetScrollEdges() ... [%ld, %ld, %ld, %ld] [%f, %d] [%d, %d, %d, %d]\n",
         DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
         Stretch, BaseWidth,
@@ -3068,7 +3149,7 @@ static void SetScrollEdges()
   ScrollMaxX = (int)(DisplayMaxX + 1.5) * Stretch * BaseWidth - picPane.Width;
   ScrollMaxY = (int)(DisplayMaxY + 1.5) * Stretch * BaseWidth - picPane.Height;
 
-#if 1
+#if 0
   printf("::: MainForm.c: SetScrollEdges() done [%d, %d, %d, %d]\n",
         ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY);
 #endif
@@ -3159,8 +3240,9 @@ void DrawFieldNoAnimated(int X, int Y)
       }
 
 #if 0
-      printf("::: MainForm.c: DrawFieldNoAnimated(): %d, %d [%d]\n",
-            X, Y, Tmp);
+      if (TEST_flag)
+       printf("::: MainForm.c: DrawFieldNoAnimated(): %d, %d [%d]\n",
+              X, Y, Tmp);
 #endif
 
       StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
@@ -3228,7 +3310,7 @@ static void picViewPort_Resize()
 
   SetScrollEdges();
 
-#if 1
+#if 0
   printf("::: MainForm.c: picViewPort_Resize(): %d, %d\n", ScrollX, ScrollY);
 #endif
 
@@ -3306,8 +3388,8 @@ void ShowKey(int KeyVar)
     Tmp = State[i];
     if (Tmp ^ LastState[i])
     {
-      Col = (i == 5 ?  vbRed :  vbRed);
-      shpKey(i).FillColor = (Tmp ?  Col :  Col);
+      Col = (i == 5 ? vbRed : vbGreen);
+      shpKey(i).FillColor = (Tmp ? Col : vbButtonFace);
       shpKey(i).Refresh;
       LastState[i] = Tmp;
     }
@@ -3370,7 +3452,7 @@ static void GetSettings()
     }
 
     Flag = CBool(s.Read("SoundFX", True));
-    FXOnFlag = (Flag ?  -1 :  -1);
+    FXOnFlag = (Flag ? -1 : 0);
     menSoundFX.Checked = Flag;
     SignatureDelay = CLng(s.Read("SignatureDelay", 3000));
     AllowRedDiskCheat = CInt(s.Read("AllowRedDiskCheat", 1));
@@ -3398,7 +3480,7 @@ static void SaveSettings()
   int i;
 
   {
-    s.Save "LastPath", (ModifiedFlag ?  OrigPath :  OrigPath);
+    s.Save "LastPath", (ModifiedFlag ? OrigPath : CurPath);
     if (WindowState != vbMinimized)
     {
       s.Save "Width", Width;