rnd-20100313-1-src
[rocksndiamonds.git] / src / game_sp / Explosions.c
index b6b6ca802509e993d7385339c77ce5577c9ded63..0d2ec1a0bf1996b163f54cd94ff0946bae1ef8ae 100644 (file)
@@ -8,7 +8,7 @@ static void LetExplodeFieldSP(int tsi, int cx, int dh);
 static int subExplodeInfotron(int tsi, int cx);
 static int subExplodeZonk(int tsi, int cx);
 
-static char *VB_Name = "modExplosions";
+// static char *VB_Name = "modExplosions";
 // --- Option Explicit
 
 // ==========================================================================
@@ -19,7 +19,8 @@ int subAnimateExplosion(int si)
 {
   int subAnimateExplosion;
 
-  int ax, bx, bl, X, Y;
+  // int ax, bx, bl, X, Y;
+  int ax, bl, X, Y;
 
   if (LowByte(PlayField16[si]) != fiExplosion)
     return subAnimateExplosion;
@@ -29,6 +30,10 @@ int subAnimateExplosion(int si)
     return subAnimateExplosion;
 
   bl = HighByte(PlayField16[si]);
+#if 0
+  printf("::: subAnimateExplosion: %d [%d, %d] [%d]\n",
+        bl, PlayField16[si], si, FrameCounter);
+#endif
   if ((bl & 0x80) != 0) // infotron explosion!
     goto loc_g_28D0;
 
@@ -37,12 +42,28 @@ int subAnimateExplosion(int si)
   // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   X = GetStretchX(si);
   Y = GetStretchY(si);
-  StretchedSprites.BltEx(X, Y, aniExplosion[bl]);
+#if 1
+
+#if 1
+  GfxGraphic[GetX(si)][GetY(si)] = aniDefaultExplosion;
+#else
+  StretchedSprites.BltImg(X, Y, aniDefaultExplosion, bl);
+#endif
+
+#else
+  StretchedSprites.BltEx(X, Y, aniFramesExplosion[bl]);
+#endif
   // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   if (bl == 8)
   {
     PlayField16[si] = 0;
     ExplosionShake = 0; // nothing explodes
+
+#if 1
+    GfxGraphic[GetX(si)][GetY(si)] = aniSpace;
+#else
+    StretchedSprites.BltImg(X, Y, aniSpace, 0);
+#endif
   } // loc_ret_g_28CF:
 
   return subAnimateExplosion;
@@ -53,6 +74,15 @@ loc_g_28D0: // explosion produces infotron
   {
     PlayField16[si] = fiInfotron;
     MovLowByte(&ExplosionShake, 0); // nothing explodes
+
+#if 1
+    GfxGraphic[GetX(si)][GetY(si)] = aniInfotron;
+#else
+    X = GetStretchX(si);
+    Y = GetStretchY(si);
+    StretchedSprites.BltImg(X, Y, aniInfotron, 0);
+#endif
+
     return subAnimateExplosion;
   } // loc_g_28E3:
 
@@ -60,7 +90,17 @@ loc_g_28D0: // explosion produces infotron
   // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   X = GetStretchX(si);
   Y = GetStretchY(si);
+#if 1
+
+#if 1
+  GfxGraphic[GetX(si)][GetY(si)] = aniElectronExplosion;
+#else
+  StretchedSprites.BltImg(X, Y, aniElectronExplosion, bl - 0x80);
+#endif
+
+#else
   StretchedSprites.BltEx(X, Y, aniExplosionInfo + bl - 0x80);
+#endif
   // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
   return subAnimateExplosion;
@@ -73,7 +113,8 @@ loc_g_28D0: // explosion produces infotron
 
 void ExplodeFieldSP(int si)
 {
-  int ax, al, cx, dl, dh;
+  // int ax, al, cx, dl, dh;
+  int ax, cx, dl;
 
   ax = LowByte(PlayField16[si]);
   if (ax == fiHardWare)
@@ -81,7 +122,13 @@ void ExplodeFieldSP(int si)
 
   ExplosionShake = 1; // something explodes
   if (ax == fiMurphy)
+  {
+#if 1
+    printf("::: Explosions.c: ExplodeFieldSP(): killing murphy\n");
+#endif
+
     KillMurphyFlag = 1;
+  }
 
   if (ax == fiElectron)
   {
@@ -104,8 +151,14 @@ void ExplodeFieldSP(int si)
   LetExplodeFieldSP(si + FieldWidth, cx, dl);
   LetExplodeFieldSP(si + FieldWidth + 1, cx, dl);
 
-loc_g_2C3B:
+  GfxGraphic[GetX(si)][GetY(si)] = -1;         // restart for chain-explosions
+
+  // loc_g_2C3B:
+#if 1
+  subSoundFX(si, ax, actExploding);
+#else
   subSoundFXExplosion();
+#endif
 } // ExplodeFieldSP
 
 static void LetExplodeFieldSP(int tsi, int cx, int dh)
@@ -116,6 +169,10 @@ static void LetExplodeFieldSP(int tsi, int cx, int dh)
     return;
 
   al = LowByte(PlayField16[tsi]);
+#if 0
+  printf("::: LetExplodeFieldSP: got %d [%d, %d] [%d]\n",
+        al, PlayField16[tsi], tsi, FrameCounter);
+#endif
   switch (al)
   {
     case fiHardWare:
@@ -144,6 +201,11 @@ static void LetExplodeFieldSP(int tsi, int cx, int dh)
       break;
 
     case fiMurphy:
+#if 1
+      printf("::: Explosions.c: LetExplodeFieldSP(): killing murphy [%d]\n",
+            tsi);
+#endif
+
       KillMurphyFlag = 1;
       PlayField8[tsi] = dh;
       PlayField16[tsi] = cx;
@@ -153,6 +215,8 @@ static void LetExplodeFieldSP(int tsi, int cx, int dh)
       PlayField16[tsi] = cx;
       break;
   }
+
+  GfxGraphic[GetX(tsi)][GetY(tsi)] = -1;       // restart for chain-explosions
 }
 
 static int subExplodeZonk(int tsi, int cx)
@@ -264,7 +328,17 @@ int subClearFieldDueToExplosion(int si)
   // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   X = GetStretchX(si);
   Y = GetStretchY(si);
+#if 1
+
+#if 1
+  GfxGraphic[GetX(si)][GetY(si)] = aniSpace;
+#else
+  StretchedSprites.BltImg(X, Y, aniSpace, 0);
+#endif
+
+#else
   StretchedSprites.BltEx(X, Y, fiSpace);
+#endif
   // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
   return subClearFieldDueToExplosion;
@@ -287,7 +361,18 @@ int subRedDiskReleaseExplosion()
   // +++++++++++++++++++++++++++++++++++++++++
   X = GetStretchX(si);
   Y = GetStretchY(si);
+#if 1
+
+#if 0
+  // !!! causes flicker -- fix in Murphy.c !!!
+  GfxGraphic[GetX(si)][GetY(si)] = aniRedDisk;
+#else
+  StretchedSprites.BltImg(X, Y, aniRedDisk, 0);
+#endif
+
+#else
   StretchedSprites.BltEx(X, Y, fiRedDisk);
+#endif
   // +++++++++++++++++++++++++++++++++++++++++
   RedDiskReleasePhase = RedDiskReleasePhase + 1;
   if (RedDiskReleasePhase >= 0x28)
@@ -306,7 +391,7 @@ int subFollowUpExplosions()
 
   int ax, si;
 
-locloop_g_2919:
+  // locloop_g_2919:
   for (si = 0; si <= LevelMax; si++)
   {
     ax = ByteToInt(PlayField8[si]);