1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
5 #include "DoGameStuff.h"
7 static void CallAnimation(int si, byte bl);
8 static boolean IsToBeAnimated(int bl);
10 // static char *VB_Name = "modDoGameStuff";
12 // --- Option Explicit
14 int *AnimationPosTable;
15 byte *AnimationSubTable;
17 // ==========================================================================
20 // ==========================================================================
28 subAnimateMurphy(&MurphyPosIndex); // move Murphy in any direction
30 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31 // Build a database of locations and subs-to-call of animatable fields only:
32 // Make a snapshot from the field before the animation cycle starts.
33 // first and last line are not animated.
35 cx = LevelMax - 2 * FieldWidth - 1;
39 bl = LowByte(PlayField16[si]);
40 if (((bl & 0xD) != 0) && (bl < 0x20)) // all animatables have 1's in &H0D' above &H1F? (&H1F=explosion!)
42 if (IsToBeAnimated(bl))
44 AnimationPosTable[dx] = si;
45 AnimationSubTable[dx] = bl;
46 dx = dx + 1; // count database entries
50 si = si + 1; // next field
53 while (0 < cx); // locloop_g_2282' until all lines scanned(not top- and bottom edge)
55 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56 // Now use the database to animate all animatables the fastest way.
57 // All the other fields are not checked anymore: those have no database entry.
58 // The field from before animation is frozen in the database in order not to
59 // do follow-up animations in the same loop.
60 if (dx != 0) // any database entries?
63 for (cx = 0; cx <= dx; cx++)
65 CallAnimation(AnimationPosTable[cx], AnimationSubTable[cx]);
66 } // loop locloop_g_22B8 ' until all animatables done
70 printf("::: DoGameStuff.c: KillMurphyFlag == %d [%d]\n",
71 KillMurphyFlag, MurphyMoveCounter);
74 // All animations are done now
75 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76 if (KillMurphyFlag == 1 || MurphyMoveCounter == 0)
79 if (LeadOutCounter == 0 &&
80 !game_sp_info.LevelSolved &&
81 !game_sp_info.GameOver)
83 if (LeadOutCounter == 0)
87 printf("::: DoGameStuff.c: killing murphy [%d] ...\n", KillMurphyFlag);
90 KillMurphyFlag = 0; // no more "kill Murphy"
91 ExplodeFieldSP(MurphyExplodePos); // Explode
92 LeadOutCounter = 0x40; // quit: start lead-out
97 printf("::: DoGameStuff.c: !!!!!!!!!! GAME OVER !!!!!!!!!!\n");
98 printf("::: [KillMurphyFlag == %d]\n", KillMurphyFlag);
102 /* give Murphy some more time (LeadOutCounter) to reach the exit */
104 game_sp_info.GameOver = TRUE;
112 printf("::: *** %d, %d, %d\n", KillMurphyFlag,
113 game_sp_info.LevelSolved, game_sp_info.GameOver);
117 if (KillMurphyFlag == 1 &&
118 !game_sp_info.LevelSolved &&
119 !game_sp_info.GameOver)
122 printf("::: DoGameStuff.c: !!!!!!!!!! GAME OVER !!!!!!!!!!\n");
125 game_sp_info.GameOver = TRUE;
133 return subDoGameStuff;
136 static boolean IsToBeAnimated(int bl)
138 static boolean IsToBeAnimated;
150 IsToBeAnimated = True;
154 IsToBeAnimated = False;
158 return IsToBeAnimated;
161 static void CallAnimation(int si, byte bl)
170 subAnimateInfotrons(si);
174 subAnimateOrangeDisks(si);
178 subAnimateSnikSnaks(si);
182 subAnimateTerminals(si);
186 subAnimateElectrons(si);
194 subAnimateExplosion(si);
198 // Debug.Assert(False);