1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
5 #include "DoGameStuff.h"
8 static void CallAnimation(int si, byte bl);
9 static boolean IsToBeAnimated(int bl);
12 int AnimationPosTable[SP_MAX_PLAYFIELD_SIZE];
13 byte AnimationSubTable[SP_MAX_PLAYFIELD_SIZE];
15 int *AnimationPosTable;
16 byte *AnimationSubTable;
20 // ==========================================================================
23 // ==========================================================================
29 subAnimateMurphy(&MurphyPosIndex); // move Murphy in any direction
31 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
32 // Build a database of locations and subs-to-call of animatable fields only:
33 // Make a snapshot from the field before the animation cycle starts.
34 // first and last line are not animated.
36 cx = LevelMax - 2 * FieldWidth - 1;
40 bl = LowByte(PlayField16[si]);
41 if (((bl & 0xD) != 0) && (bl < 0x20)) // all animatables have 1's in &H0D' above &H1F? (&H1F=explosion!)
43 if (IsToBeAnimated(bl))
45 AnimationPosTable[dx] = si;
46 AnimationSubTable[dx] = bl;
47 dx = dx + 1; // count database entries
51 si = si + 1; // next field
54 while (0 < cx); // locloop_g_2282' until all lines scanned(not top- and bottom edge)
56 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
57 // Now use the database to animate all animatables the fastest way.
58 // All the other fields are not checked anymore: those have no database entry.
59 // The field from before animation is frozen in the database in order not to
60 // do follow-up animations in the same loop.
61 if (dx != 0) // any database entries?
64 for (cx = 0; cx <= dx; cx++)
66 CallAnimation(AnimationPosTable[cx], AnimationSubTable[cx]);
67 } // loop locloop_g_22B8 ' until all animatables done
70 // All animations are done now
71 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
72 if (KillMurphyFlag == 1 || MurphyMoveCounter == 0)
74 if (LeadOutCounter == 0 &&
75 !game_sp.LevelSolved &&
79 printf("::: DoGameStuff.c: killing murphy [%d] ...\n", KillMurphyFlag);
82 KillMurphyFlag = 0; // no more "kill Murphy"
83 ExplodeFieldSP(MurphyExplodePos); // Explode
84 LeadOutCounter = 0x40; // quit: start lead-out
87 printf("::: DoGameStuff.c: !!!!!!!!!! GAME OVER !!!!!!!!!!\n");
88 printf("::: [KillMurphyFlag == %d]\n", KillMurphyFlag);
91 /* give Murphy some more time (LeadOutCounter) to reach the exit */
96 static boolean IsToBeAnimated(int bl)
98 static boolean IsToBeAnimated;
110 IsToBeAnimated = True;
114 IsToBeAnimated = False;
118 return IsToBeAnimated;
121 static void CallAnimation(int si, byte bl)
130 subAnimateInfotrons(si);
134 subAnimateOrangeDisks(si);
138 subAnimateSnikSnaks(si);
142 subAnimateTerminals(si);
146 subAnimateElectrons(si);
154 subAnimateExplosion(si);
158 // Debug.Assert(False);