rnd-20100216-1-src
[rocksndiamonds.git] / src / game_sp / BugsTerminals.c
index 330b6f7a356eb65baceb9709d32c5ff891e34bd1..17fc9a0fe459b5f726459ff14aba79f5d8c5a68a 100644 (file)
@@ -28,16 +28,35 @@ int subAnimateBugs(int si)
 
   // int ax, bx, cx, dx, di;
   // int ah, bh, ch, dh, al, bl, cl, dl;
-  int cx;
+  // int cx;
+#if 0
+  int graphic, sync_frame;
+#endif
   int bl;
 
   if (fiBug != LowByte(PlayField16[si]))
     return subAnimateBugs;
 
+#if 0
   if (0 != (TimerVar & 3))
     return subAnimateBugs;
+#endif
 
   bl = SgnHighByte(PlayField16[si]); // get and increment sequence#
+
+#if 1
+  if ((TimerVar & 3) == 0)
+  {
+    bl = bl + 1;
+    if (bl >= 0xE)
+    {
+      bl = subGetRandomNumber(); // generate new random number
+      bl = -((bl & 0x3F) + 0x20);
+    }
+
+    MovHighByte(&PlayField16[si], bl); // save sequence#
+  }
+#else
   bl = bl + 1;
   if (bl >= 0xE)
   {
@@ -46,9 +65,15 @@ int subAnimateBugs(int si)
   }
 
   MovHighByte(&PlayField16[si], bl); // save sequence#
+#endif
   if (bl < 0) // bug sleeps / is inactive
     return subAnimateBugs;
 
+#if 1
+  if ((TimerVar & 3) != 0)
+    goto markDisplay;
+#endif
+
   // now the bug is active! Beware Murphy!
   if ((ByteMask && PlayField16[si - FieldWidth - 1]) == fiMurphy)
     goto markPlaySound;
@@ -81,8 +106,45 @@ markPlaySound:
 
 markDisplay:
   // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-  cx = aniBug[bl];
+#if 1
+
+#if 1
+
+#if 0
+  graphic = (bl == 0  ? aniBugActivating :
+            bl == 12 ? aniBugDeactivating :
+            bl == 13 ? aniBug : aniBugActive);
+  sync_frame = (bl >= 1 && bl <= 11 ? (bl - 1) * 4 : 0) + (TimerVar & 3);
+#endif
+
+  // printf("::: %d [%d]\n", sync_frame, gfx.anim_random_frame);
+
+#if 0
+  /* a general random frame treatment would be needed for _all_ animations */
+  /* (DONE) */
+  if (isRandomAnimation_SP(graphic) &&
+      !isNextAnimationFrame_SP(graphic, sync_frame))
+    return subAnimateBugs;
+#endif
+
+#if 1
+
+  GfxGraphic[GetX(si)][GetY(si)] = (bl == 0  ? aniBugActivating :
+                                   bl == 12 ? aniBugDeactivating :
+                                   bl == 13 ? aniBug : aniBugActive);
+
+#else
+  subCopyAnimToScreen(si, graphic, sync_frame);
+#endif
+
+#else
+  subCopyFieldToScreen(si, aniFramesBug[bl]);
+#endif
+
+#else
+  cx = aniFramesBug[bl];
   StretchedSprites.BltEx(GetStretchX(si), GetStretchY(si), cx);
+#endif
   // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
   return subAnimateBugs;
@@ -160,7 +222,15 @@ int subAnimateTerminals(int si)
     GfxFrame[lx][ly] += getGraphicInfo_Delay(graphic);
 
 #if 1
+
+#if 1
+
+  GfxGraphic[GetX(si)][GetY(si)] = (bl < 8 ? aniTerminal : aniTerminalActive);
+
+#else
   subCopyAnimToScreen(si, graphic, GfxFrame[lx][ly]);
+#endif
+
 #else
   X = GetStretchX(si);
   Y = GetStretchY(si);
@@ -229,6 +299,9 @@ int subGetRandomNumber()
   int subGetRandomNumber;
 
   long Tmp, RSeed;
+#if 0
+  long Tst;
+#endif
 
   RSeed = (long)(0x7FFF & RandomSeed);
   if (0x8000 == (RandomSeed & 0x8000))
@@ -240,6 +313,15 @@ int subGetRandomNumber()
 #else
   Tmp = 0xFFFF & (((0x5E5 * RandomSeed) & 0xFFFF) + 0x31);
 #endif
+
+#if 0
+  Tst = 0xFFFF & (((0x5E5 * RSeed) & 0xFFFF) + 0x31);
+  printf("::: BugsTerminals.c: subGetRandomNumber(): %d [%ld] [%ld, %ld]\n",
+        RandomSeed, RSeed, Tmp, Tst);
+  if (Tmp != Tst)
+    printf("::: !!!!!!!!!!\n");
+#endif
+
   RandomSeed = 0x7FFF & Tmp;
   if ((Tmp & 0x8000) != 0)
     RandomSeed = RandomSeed | 0x8000;
@@ -258,5 +340,10 @@ int subGetRandomNumber()
         subGetRandomNumber);
 #endif
 
+#if 0
+  printf("::: BugsTerminals.c: subGetRandomNumber(): %d [%ld, %d]\n",
+        subGetRandomNumber, Tmp, RandomSeed);
+#endif
+
   return subGetRandomNumber;
 } // subGetRandomNumber