1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
5 #include "Explosions.h"
7 static void LetExplodeFieldSP(int tsi, int cx, int dh);
8 static int subExplodeInfotron(int tsi, int cx);
9 static int subExplodeZonk(int tsi, int cx);
11 // static char *VB_Name = "modExplosions";
12 // --- Option Explicit
14 // ==========================================================================
17 // ==========================================================================
18 int subAnimateExplosion(int si)
20 int subAnimateExplosion;
22 // int ax, bx, bl, X, Y;
25 if (LowByte(PlayField16[si]) != fiExplosion)
26 return subAnimateExplosion;
30 return subAnimateExplosion;
32 bl = HighByte(PlayField16[si]);
34 printf("::: subAnimateExplosion: %d [%d, %d] [%d]\n",
35 bl, PlayField16[si], si, FrameCounter);
37 if ((bl & 0x80) != 0) // infotron explosion!
41 MovHighByte(&PlayField16[si], bl);
42 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
48 GfxGraphic[GetX(si)][GetY(si)] = aniDefaultExplosion;
50 StretchedSprites.BltImg(X, Y, aniDefaultExplosion, bl);
54 StretchedSprites.BltEx(X, Y, aniFramesExplosion[bl]);
56 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
60 ExplosionShake = 0; // nothing explodes
63 GfxGraphic[GetX(si)][GetY(si)] = aniSpace;
65 StretchedSprites.BltImg(X, Y, aniSpace, 0);
69 return subAnimateExplosion;
71 loc_g_28D0: // explosion produces infotron
75 PlayField16[si] = fiInfotron;
76 MovLowByte(&ExplosionShake, 0); // nothing explodes
79 GfxGraphic[GetX(si)][GetY(si)] = aniInfotron;
83 StretchedSprites.BltImg(X, Y, aniInfotron, 0);
86 return subAnimateExplosion;
89 MovHighByte(&PlayField16[si], bl);
90 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
96 GfxGraphic[GetX(si)][GetY(si)] = aniElectronExplosion;
98 StretchedSprites.BltImg(X, Y, aniElectronExplosion, bl - 0x80);
102 StretchedSprites.BltEx(X, Y, aniExplosionInfo + bl - 0x80);
104 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
106 return subAnimateExplosion;
107 } // subAnimateExplosion
109 // ==========================================================================
112 // ==========================================================================
114 void ExplodeFieldSP(int si)
116 // int ax, al, cx, dl, dh;
119 ax = LowByte(PlayField16[si]);
120 if (ax == fiHardWare)
123 ExplosionShake = 1; // something explodes
127 printf("::: Explosions.c: ExplodeFieldSP(): killing murphy\n");
133 if (ax == fiElectron)
135 cx = 0x801F; // produce infotrons
140 cx = 0x1F; // normal explosion
144 LetExplodeFieldSP(si - FieldWidth - 1, cx, dl);
145 LetExplodeFieldSP(si - FieldWidth, cx, dl);
146 LetExplodeFieldSP(si - FieldWidth + 1, cx, dl);
147 LetExplodeFieldSP(si - 1, cx, dl);
148 PlayField16[si] = cx;
149 LetExplodeFieldSP(si + 1, cx, dl);
150 LetExplodeFieldSP(si + FieldWidth - 1, cx, dl);
151 LetExplodeFieldSP(si + FieldWidth, cx, dl);
152 LetExplodeFieldSP(si + FieldWidth + 1, cx, dl);
154 GfxGraphic[GetX(si)][GetY(si)] = -1; // restart for chain-explosions
158 subSoundFX(si, ax, actExploding);
160 subSoundFXExplosion();
164 static void LetExplodeFieldSP(int tsi, int cx, int dh)
168 if (tsi < (-FieldWidth))
171 al = LowByte(PlayField16[tsi]);
173 printf("::: LetExplodeFieldSP: got %d [%d, %d] [%d]\n",
174 al, PlayField16[tsi], tsi, FrameCounter);
186 PlayField8[tsi] = dh;
187 PlayField16[tsi] = cx;
191 subExplodeZonk(tsi, cx);
195 subExplodeInfotron(tsi, cx);
199 PlayField8[tsi] = (-dh) & 0xFF;
200 PlayField16[tsi] = 0x801F;
205 printf("::: Explosions.c: LetExplodeFieldSP(): killing murphy [%d]\n",
210 PlayField8[tsi] = dh;
211 PlayField16[tsi] = cx;
215 PlayField16[tsi] = cx;
219 GfxGraphic[GetX(tsi)][GetY(tsi)] = -1; // restart for chain-explosions
222 static int subExplodeZonk(int tsi, int cx)
224 static int subExplodeZonk;
228 ah = HighByte(PlayField16[tsi]) & 0xF0;
229 PlayField16[tsi] = cx;
234 subClearFieldDueToExplosion(tsi - FieldWidth);
235 tsi = tsi + FieldWidth;
236 if (PlayField16[tsi] == 0x9999)
237 subClearFieldDueToExplosion(tsi);
242 subClearFieldDueToExplosion(tsi + 1);
243 subClearFieldDueToExplosion(tsi + FieldWidth);
247 subClearFieldDueToExplosion(tsi - 1);
248 subClearFieldDueToExplosion(tsi + FieldWidth);
252 subClearFieldDueToExplosion(tsi - 1);
256 subClearFieldDueToExplosion(tsi + 1);
259 case 0xFF000070: // !!! 0x70; this will never be reached! ...??
260 subClearFieldDueToExplosion(tsi + FieldWidth);
264 return subExplodeZonk;
267 static int subExplodeInfotron(int tsi, int cx)
269 static int subExplodeInfotron;
273 ah = HighByte(PlayField16[tsi]) & 0xF0;
274 PlayField16[tsi] = cx;
279 subClearFieldDueToExplosion(tsi - FieldWidth);
280 tsi = tsi + FieldWidth;
281 if (PlayField16[tsi] == 0x9999)
282 subClearFieldDueToExplosion(tsi);
287 subClearFieldDueToExplosion(tsi + 1);
288 tsi = tsi + FieldWidth; // differnt from zonk version
289 if (PlayField16[tsi] == 0x9999)
290 subClearFieldDueToExplosion(tsi);
295 subClearFieldDueToExplosion(tsi - 1);
296 tsi = tsi + FieldWidth; // differnt from zonk version
297 if (PlayField16[tsi] == 0x9999)
298 subClearFieldDueToExplosion(tsi);
303 subClearFieldDueToExplosion(tsi - 1);
307 subClearFieldDueToExplosion(tsi + 1);
310 case 0xFF000070: // !!! 0x70; this will never be reached! ...??
311 subClearFieldDueToExplosion(tsi + FieldWidth);
315 return subExplodeInfotron;
316 } // subExplodeInfotron
318 int subClearFieldDueToExplosion(int si)
320 int subClearFieldDueToExplosion;
324 if (LowByte(PlayField16[si]) == fiExplosion)
325 return subClearFieldDueToExplosion;
328 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
334 GfxGraphic[GetX(si)][GetY(si)] = aniSpace;
336 StretchedSprites.BltImg(X, Y, aniSpace, 0);
340 StretchedSprites.BltEx(X, Y, fiSpace);
342 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
344 return subClearFieldDueToExplosion;
345 } // subClearFieldDueToExplosion
347 int subRedDiskReleaseExplosion()
349 int subRedDiskReleaseExplosion;
353 al = RedDiskReleasePhase; // Red disk release phase
355 return subRedDiskReleaseExplosion;
357 si = RedDiskReleaseMurphyPos;
358 if (PlayField16[si] == 0) // Release red disk
359 PlayField16[si] = fiRedDisk;
361 // +++++++++++++++++++++++++++++++++++++++++
367 // !!! causes flicker -- fix in Murphy.c !!!
368 GfxGraphic[GetX(si)][GetY(si)] = aniRedDisk;
370 StretchedSprites.BltImg(X, Y, aniRedDisk, 0);
374 StretchedSprites.BltEx(X, Y, fiRedDisk);
376 // +++++++++++++++++++++++++++++++++++++++++
377 RedDiskReleasePhase = RedDiskReleasePhase + 1;
378 if (RedDiskReleasePhase >= 0x28)
380 // si = RedDiskReleaseMurphyPos ' Red disk was released here
381 ExplodeFieldSP(si); // Explode
382 RedDiskReleasePhase = 0;
385 return subRedDiskReleaseExplosion;
388 int subFollowUpExplosions()
390 int subFollowUpExplosions;
395 for (si = 0; si <= LevelMax; si++)
397 ax = ByteToInt(PlayField8[si]);
403 PlayField8[si] = ax & 0xFF;
406 PlayField16[si] = 0xFF18;
407 ExplodeFieldSP(si); // Explode
421 return subFollowUpExplosions;
422 } // subFollowUpExplosions