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
157 subSoundFXExplosion();
160 static void LetExplodeFieldSP(int tsi, int cx, int dh)
164 if (tsi < (-FieldWidth))
167 al = LowByte(PlayField16[tsi]);
169 printf("::: LetExplodeFieldSP: got %d [%d, %d] [%d]\n",
170 al, PlayField16[tsi], tsi, FrameCounter);
182 PlayField8[tsi] = dh;
183 PlayField16[tsi] = cx;
187 subExplodeZonk(tsi, cx);
191 subExplodeInfotron(tsi, cx);
195 PlayField8[tsi] = (-dh) & 0xFF;
196 PlayField16[tsi] = 0x801F;
201 printf("::: Explosions.c: LetExplodeFieldSP(): killing murphy [%d]\n",
206 PlayField8[tsi] = dh;
207 PlayField16[tsi] = cx;
211 PlayField16[tsi] = cx;
215 GfxGraphic[GetX(tsi)][GetY(tsi)] = -1; // restart for chain-explosions
218 static int subExplodeZonk(int tsi, int cx)
220 static int subExplodeZonk;
224 ah = HighByte(PlayField16[tsi]) & 0xF0;
225 PlayField16[tsi] = cx;
230 subClearFieldDueToExplosion(tsi - FieldWidth);
231 tsi = tsi + FieldWidth;
232 if (PlayField16[tsi] == 0x9999)
233 subClearFieldDueToExplosion(tsi);
238 subClearFieldDueToExplosion(tsi + 1);
239 subClearFieldDueToExplosion(tsi + FieldWidth);
243 subClearFieldDueToExplosion(tsi - 1);
244 subClearFieldDueToExplosion(tsi + FieldWidth);
248 subClearFieldDueToExplosion(tsi - 1);
252 subClearFieldDueToExplosion(tsi + 1);
255 case 0xFF000070: // !!! 0x70; this will never be reached! ...??
256 subClearFieldDueToExplosion(tsi + FieldWidth);
260 return subExplodeZonk;
263 static int subExplodeInfotron(int tsi, int cx)
265 static int subExplodeInfotron;
269 ah = HighByte(PlayField16[tsi]) & 0xF0;
270 PlayField16[tsi] = cx;
275 subClearFieldDueToExplosion(tsi - FieldWidth);
276 tsi = tsi + FieldWidth;
277 if (PlayField16[tsi] == 0x9999)
278 subClearFieldDueToExplosion(tsi);
283 subClearFieldDueToExplosion(tsi + 1);
284 tsi = tsi + FieldWidth; // differnt from zonk version
285 if (PlayField16[tsi] == 0x9999)
286 subClearFieldDueToExplosion(tsi);
291 subClearFieldDueToExplosion(tsi - 1);
292 tsi = tsi + FieldWidth; // differnt from zonk version
293 if (PlayField16[tsi] == 0x9999)
294 subClearFieldDueToExplosion(tsi);
299 subClearFieldDueToExplosion(tsi - 1);
303 subClearFieldDueToExplosion(tsi + 1);
306 case 0xFF000070: // !!! 0x70; this will never be reached! ...??
307 subClearFieldDueToExplosion(tsi + FieldWidth);
311 return subExplodeInfotron;
312 } // subExplodeInfotron
314 int subClearFieldDueToExplosion(int si)
316 int subClearFieldDueToExplosion;
320 if (LowByte(PlayField16[si]) == fiExplosion)
321 return subClearFieldDueToExplosion;
324 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
330 GfxGraphic[GetX(si)][GetY(si)] = aniSpace;
332 StretchedSprites.BltImg(X, Y, aniSpace, 0);
336 StretchedSprites.BltEx(X, Y, fiSpace);
338 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
340 return subClearFieldDueToExplosion;
341 } // subClearFieldDueToExplosion
343 int subRedDiskReleaseExplosion()
345 int subRedDiskReleaseExplosion;
349 al = RedDiskReleasePhase; // Red disk release phase
351 return subRedDiskReleaseExplosion;
353 si = RedDiskReleaseMurphyPos;
354 if (PlayField16[si] == 0) // Release red disk
355 PlayField16[si] = fiRedDisk;
357 // +++++++++++++++++++++++++++++++++++++++++
363 // !!! causes flicker -- fix in Murphy.c !!!
364 GfxGraphic[GetX(si)][GetY(si)] = aniRedDisk;
366 StretchedSprites.BltImg(X, Y, aniRedDisk, 0);
370 StretchedSprites.BltEx(X, Y, fiRedDisk);
372 // +++++++++++++++++++++++++++++++++++++++++
373 RedDiskReleasePhase = RedDiskReleasePhase + 1;
374 if (RedDiskReleasePhase >= 0x28)
376 // si = RedDiskReleaseMurphyPos ' Red disk was released here
377 ExplodeFieldSP(si); // Explode
378 RedDiskReleasePhase = 0;
381 return subRedDiskReleaseExplosion;
384 int subFollowUpExplosions()
386 int subFollowUpExplosions;
391 for (si = 0; si <= LevelMax; si++)
393 ax = ByteToInt(PlayField8[si]);
399 PlayField8[si] = ax & 0xFF;
402 PlayField16[si] = 0xFF18;
403 ExplodeFieldSP(si); // Explode
417 return subFollowUpExplosions;
418 } // subFollowUpExplosions