rnd-20091020-1-src
[rocksndiamonds.git] / src / game_sp / Murphy.c
index 1d3c74c102544040060d88964bc4e2d8f661c213..a2063fda6cea7ef3c506018950f57f8fee9e843b 100644 (file)
@@ -11,7 +11,17 @@ static boolean subMoveKillsMurphy(int si, int ax, int bl);
 
 // --- Option Explicit
 
+#if 1
+
+#define LocalStretch                   (2)
+#define MurphyZoomFactor               (ZoomFactor)
+
+#else
+
 #define LocalStretch                   (1)
+#define MurphyZoomFactor               (1)
+
+#endif
 
 // ==========================================================================
 //                              SUBROUTINE
@@ -39,7 +49,7 @@ int subAnimateMurphy(int *si)
   ax = PlayField16[*si];
   al = LowByte(ax);
 
-#if 1
+#if 0
   printf("::: Murphy.c: subAnimateMurphy(): %d [%d, %d] %d, %d [%d]\n",
         *si, *si % 60, *si / 60, ax, al, (al == fiMurphy));
 #endif
@@ -78,6 +88,10 @@ int subAnimateMurphy(int *si)
   if (bl != 0) // a key was pressed!
     goto locKeyPressed5FCF;
 
+#if 0
+  printf("::: Murphy.c: !!! %d [%d]\n", DemoKeyCode, GravityFlag);
+#endif
+
   RedDiskReleaseFlag = 1;
   if (ScratchGravity != 0) // gravity pulls & space below?'-> force Space up to down
   {
@@ -571,7 +585,7 @@ loc_g_62E2:
   // ==========================================================================
 
 loc_g_6312:
-  dx = (MurphyVarFaceLeft == 0 ?  aniMurphyEatUpRight :  aniMurphyEatUpRight);
+  dx = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft);
   PlayField16[*si - FieldWidth] = 0x103;
   PlayField16[*si] = 0x300;
   *si = *si - FieldWidth;
@@ -593,7 +607,7 @@ loc_g_6341:
   // ==========================================================================
 
 loc_g_6364:
-  dx = (MurphyVarFaceLeft == 0 ?  aniMurphyEatUpRight :  aniMurphyEatUpRight);
+  dx = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft);
   PlayField16[*si + FieldWidth] = 0x303;
   PlayField16[*si] = 0x300;
   *si = *si + FieldWidth;
@@ -628,7 +642,7 @@ loc_g_63C2:
 
 loc_g_63D3:
   subSoundFXBase();
-  dx = (MurphyVarFaceLeft == 0 ?  aniMurphyEatUpRight :  aniMurphyEatUpRight);
+  dx = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft);
   PlayField16[*si - FieldWidth] = 0x503;
   PlayField16[*si] = 0x300;
   *si = *si - FieldWidth;
@@ -676,7 +690,7 @@ loc_g_6448:
 
 loc_g_6459:
   subSoundFXBase();
-  dx = (MurphyVarFaceLeft == 0 ?  aniMurphyEatUpRight :  aniMurphyEatUpRight);
+  dx = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft);
   PlayField16[*si + FieldWidth] = 0x703;
   PlayField16[*si] = 0x300;
   *si = *si + FieldWidth;
@@ -808,7 +822,7 @@ loc_g_6599:
 
 loc_g_65C6:
   subSoundFXInfotron();
-  dx = (MurphyVarFaceLeft == 0 ?  aniMurphyEatUpRight :  aniMurphyEatUpRight);
+  dx = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft);
   PlayField16[*si - FieldWidth] = 0x903;
   PlayField16[*si] = 0x300;
   *si = *si - FieldWidth;
@@ -835,7 +849,7 @@ loc_g_65FE:
 
 loc_g_662A:
   subSoundFXInfotron();
-  dx = (MurphyVarFaceLeft == 0 ?  aniMurphyEatUpRight :  aniMurphyEatUpRight);
+  dx = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft);
   PlayField16[*si + FieldWidth] = 0xB03;
   PlayField16[*si] = 0x300;
   *si = *si + FieldWidth;
@@ -917,6 +931,15 @@ loc_g_6756:
   if (LowByte(InfotronsNeeded) != 0)
     return subAnimateMurphy;
 
+#if 1
+  if (!game_sp_info.LevelSolved)
+    printf("::: Murphy.c: !!!!!!!!!! LEVEL %d SOLVED !!!!!!!!!!\n",LevelNumber);
+#endif
+
+#if 1
+  game_sp_info.LevelSolved = TRUE;
+#endif
+
   subSoundFXExit();
   data_h_DemoDone = 1; // EP set level success bytes
   LevelStatus = 1; // set Level Status DONE
@@ -1121,7 +1144,7 @@ loc_StopSplit:
   // ==========================================================================
 
 loc_g_69A6:
-  dx = (MurphyVarFaceLeft == 0 ?  aniMurphyEatUpRight :  aniMurphyEatUpRight);
+  dx = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft);
   PlayField16[*si] = 0x1C03;
   PlayField16[*si - FieldWidth] = 0x300;
   goto loc_StopNoSplit;
@@ -1142,7 +1165,7 @@ loc_g_69CE:
   // ==========================================================================
 
 loc_g_69F7:
-  dx = (MurphyVarFaceLeft == 0 ?  aniMurphyEatUpRight :  aniMurphyEatUpRight);
+  dx = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft);
   PlayField16[*si] = 0x1E03;
   PlayField16[*si + FieldWidth] = 0x300;
   goto loc_StopNoSplit;
@@ -1164,8 +1187,14 @@ loc_g_6A1F:
   // We only correct Murphies x-location here, when the sequence starts.
   // Remember that this is not the real bug-fix, but we must live with
   // this existing bug and correct for the consequences of it.
+
+#if 1
+  if (0 == AllowEatRightRedDiskBug) // Murphy's screen x-position
+    MurphyScreenXPos = MurphyScreenXPos - 2 * MurphyZoomFactor;
+#else
   if (0 == AllowEatRightRedDiskBug) // Murphy's screen x-position
     MurphyScreenXPos = MurphyScreenXPos - 2;
+#endif
 
   SeqPos = -1;
   // FS: for me this means to blit the first animation frame twice
@@ -1390,10 +1419,51 @@ loc_g_6C8F:
   {
     // ++++++++++++++++++++++++++
     // Begin of normal movement
+#if 1
+    MurphyScreenXPos = MurphyScreenXPos + MurphyDX * MurphyZoomFactor;
+    MurphyScreenYPos = MurphyScreenYPos + MurphyDY * MurphyZoomFactor;
+#else
     MurphyScreenXPos = MurphyScreenXPos + MurphyDX;
     MurphyScreenYPos = MurphyScreenYPos + MurphyDY;
+#endif
+
+
+#if 0
+  printf("::: %04d [%03ld, %02d] ----------> %s [%d] [%d, %d] [%d, %d] [%d]\n",
+        TimerVar,
+        DemoOffset - DemoPointer, DemoKeyRepeatCounter,
+        (DemoKeyCode == keyNone        ? "(none)"              :
+         DemoKeyCode == keyLeft        ? "left"                :
+         DemoKeyCode == keyRight       ? "right"               :
+         DemoKeyCode == keyUp          ? "up"                  :
+         DemoKeyCode == keyDown        ? "down"                :
+         DemoKeyCode == keySpace       ? "space"               :
+         DemoKeyCode == keySpaceLeft   ? "space + left"        :
+         DemoKeyCode == keySpaceRight  ? "space + right"       :
+         DemoKeyCode == keySpaceUp     ? "space + up"          :
+         DemoKeyCode == keySpaceDown   ? "space + down"        : "(unknown)"),
+        DemoKeyCode,
+        MurphyScreenXPos, MurphyScreenYPos,
+        MurphyPosIndex % 60, MurphyPosIndex / 60,
+        ClearPos);
+#endif
+
+#if 0
+  Delay(500);
+#endif
+
+#if 1
+    if (!(ClearPos < 0)) // clear field that murphy is leaving
+      subCopyFieldToScreen(ClearPos, 0);
+#else
     if (! ClearPos < 0) // clear field that murphy is leaving
       subCopyFieldToScreen(ClearPos, 0);
+#endif
+
+#if 0
+    printf("::: ---------------> %d, %d [%d, %d]\n",
+          MurphyScreenXPos, MurphyScreenYPos, MurphyDX, MurphyDY);
+#endif
 
     if (dx2 == fiInfotron) // special case of infotron moving left or right
     {
@@ -1408,9 +1478,14 @@ loc_g_6C8F:
 
     X = GetStretchX(dxPos) + tDeltaX;
     Y = GetStretchY(dxPos) + tDeltaY;
-    Tmp = (SeqPos < 0 ?  0 :  0); // 9StepBugFix!(red disk move right)
+    Tmp = (SeqPos < 0 ? 0 : SeqPos); // 9StepBugFix!(red disk move right)
     StretchedSprites.BltEx(X, Y, dx[Tmp]);
+
+#if 1
+    if (!(dx2 < 0))
+#else
     if (! dx2 < 0)
+#endif
     {
       tPos = dxPos + dx2Step;
       X = GetStretchX(tPos);
@@ -1432,8 +1507,13 @@ loc_g_6C8F:
   {
     // ++++++++++++++++++++++++++++++++
     // Begin of split movement (port)
+#if 1
+    MurphyScreenXPos = MurphyScreenXPos + 2 * MurphyDX * MurphyZoomFactor;
+    MurphyScreenYPos = MurphyScreenYPos + 2 * MurphyDY * MurphyZoomFactor;
+#else
     MurphyScreenXPos = MurphyScreenXPos + 2 * MurphyDX;
     MurphyScreenYPos = MurphyScreenYPos + 2 * MurphyDY;
+#endif
     subCopyFieldToScreen(ClearPos, 0); // clear the field that murphy leaves
     tDeltaX = MurphyDX * LocalStretch * (SeqPos + 1);
     tDeltaY = MurphyDY * LocalStretch * (SeqPos + 1);
@@ -2253,6 +2333,34 @@ int subSpPortTest(int si)
 
   int i, cx, bx;
 
+#if 1
+  cx = LInfo.SpecialPortCount; // number of special ports
+
+  for (i = 0; i < cx; i++)
+  {
+#if 1
+    /* this assumes that PortLocation is stored as big endian */
+    bx = LInfo.SpecialPort[i].PortLocation;
+#else
+    /* this assumes that PortLocation is stored as little endian */
+    bx = HighByte(LInfo.SpecialPort[i].PortLocation);
+    MovHighByte(&bx, LowByte(LInfo.SpecialPort[i].PortLocation));
+#endif
+
+    if (bx / 2 == si)
+    {
+      GravityFlag = LInfo.SpecialPort[i].Gravity;
+      FreezeZonks = LInfo.SpecialPort[i].FreezeZonks;
+      SnikSnaksElectronsFrozen = LInfo.SpecialPort[i].FreezeEnemies;
+
+      // RandomTime = RandomTime Xor RandomSeed 'is RandomTime used at all? no!
+
+      break;
+    }
+  }
+
+#else
+
   cx = LInfo.SpecialPortCount; // number of special ports
   for (i = 1; i <= cx; i++)
   {
@@ -2267,9 +2375,9 @@ int subSpPortTest(int si)
         //        RandomTime = RandomTime Xor RandomSeed 'is RandomTime used at all? no!
         i = cx + 1;
       }
-
     }
   }
+#endif
 
   return subSpPortTest;
 } // subSpPortTest