1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
5 #include "MainGameLoop.h"
11 boolean AutoScrollFlag;
14 // ==========================================================================
17 // ==========================================================================
19 void subMainGameLoop_Init()
21 // This was a bug in the original Supaplex: sometimes red disks could not
22 // be released. This happened if Murphy was killed DURING a red disk release
23 // and the next try started.
25 RedDiskReleasePhase = 0; // (re-)enable red disk release
28 void subMainGameLoop_Main(byte action, boolean warp_mode)
30 // ---------------------------------------------------------------------------
31 // --------------------- START OF GAME-BUSY LOOP -----------------------------
32 // ---------------------------------------------------------------------------
34 subProcessKeyboardInput(action); // check keyboard, act on keys
36 // ---------------------------------------------------------------------------
39 subDoGameStuff(); // do all game stuff
42 // ---------------------------------------------------------------------------
44 subRedDiskReleaseExplosion(); // Red Disk release and explode
45 subFollowUpExplosions(); // every explosion may cause up to 8 following explosions
47 subCalculateScreenScrollPos(); // calculate screen start addrs
50 ScrollTowards(ScreenScrollXPos, ScreenScrollYPos);
52 TimerVar = TimerVar + 1;
55 if (ExitToMenuFlag == 1)
57 // happens when demo ends or when Murphy enters exit (to be checked)
60 goto locExitMainGameLoop;
64 if (ExitToMenuFlag == 1)
65 goto locExitMainGameLoop;
68 if (LeadOutCounter == 0) // no lead-out: game busy
71 // ---------------------------------------------------------------------------
72 // ---------------------- END OF GAME-BUSY LOOP ------------------------------
73 // ---------------------------------------------------------------------------
75 LeadOutCounter = LeadOutCounter - 1; // do more lead-out after quit
77 if (LeadOutCounter != 0) // lead-out not ready: more
80 // lead-out done: exit now
81 // ---------------------- END OF GAME-BUSY LOOP (including lead-out) ---------
88 printf("::: locExitMainGameLoop reached [%d]\n", LeadOutCounter);
89 printf("::: [KillMurphyFlag == %d]\n", KillMurphyFlag);
93 /* if the game is not won when reaching this point, then it is lost */
94 if (!game_sp.LevelSolved)
95 game_sp.GameOver = TRUE;
99 void subCalculateScreenScrollPos()
104 int jump_pos = TILEX / 2;
106 if (MurphyScreenXPos < -jump_pos)
108 MurphyScreenXPos = FieldWidth * TILEX + MurphyScreenXPos;
109 MurphyScreenYPos -= TILEY;
111 else if (MurphyScreenXPos >= FieldWidth * TILEX - jump_pos)
113 MurphyScreenXPos = MurphyScreenXPos - FieldWidth * TILEX;
114 MurphyScreenYPos += TILEY;
118 if (ExplosionShake != 0)
120 subGetRandomNumber();
122 // printf("::: ExplosionShake [%d]\n", FrameCounter);
130 ScreenScrollXPos = (MurphyScreenXPos + TILEX / 2) - ax;
131 ScreenScrollYPos = (MurphyScreenYPos + TILEY / 2) - ay;