renamed constant
[rocksndiamonds.git] / src / game_em / logic.c
index 73b2d94c21f98318f9de4633f5de9358218d3283..cd2028c9e97e56ccd905c4e5fc249379609be22d 100644 (file)
@@ -20,7 +20,7 @@ static short **cave, **next, **boom;
 static unsigned int seed;
 static int score;
 
-static const byte is_blank[TILE_MAX] =
+static const byte is_blank[GAME_TILE_MAX] =
 {
   [Xblank]             = 1,
   [Xsplash_e]          = 1,
@@ -35,7 +35,7 @@ static const byte is_blank[TILE_MAX] =
   [Xfake_acid_8]       = 1
 };
 
-static const byte is_blank_or_acid[TILE_MAX] =
+static const byte is_blank_or_acid[GAME_TILE_MAX] =
 {
   [Xblank]             = 1,
   [Xsplash_e]          = 1,
@@ -58,7 +58,7 @@ static const byte is_blank_or_acid[TILE_MAX] =
   [Xacid_8]            = 1
 };
 
-static const byte is_fake_acid[TILE_MAX] =
+static const byte is_fake_acid[GAME_TILE_MAX] =
 {
   [Xfake_acid_1]       = 1,
   [Xfake_acid_2]       = 1,
@@ -70,7 +70,7 @@ static const byte is_fake_acid[TILE_MAX] =
   [Xfake_acid_8]       = 1
 };
 
-static const byte is_amoeba[TILE_MAX] =
+static const byte is_amoeba[GAME_TILE_MAX] =
 {
   [Xfake_amoeba]       = 1,
   [Yfake_amoeba]       = 1,
@@ -84,7 +84,7 @@ static const byte is_amoeba[TILE_MAX] =
   [Xamoeba_8]          = 1
 };
 
-static const byte is_android_walkable[TILE_MAX] =
+static const byte is_android_walkable[GAME_TILE_MAX] =
 {
   [Xblank]             = 1,
   [Xsplash_e]          = 1,
@@ -113,31 +113,34 @@ static void Lboom_generic(int x, int y, int element, int element_middle)
   boom[x+1][y+1] = element;
 }
 
-static void Lboom_bug(int x, int y, int by_element)
+static void Lboom_bug(int x, int y)
 {
-  next[x][y] = Zbug;
+  if (game_em.use_old_explosions)
+    next[x][y] = Zbug;
 
   Lboom_generic(x, y, Xemerald, Xdiamond);
 
 #if PLAY_ELEMENT_SOUND
-  play_element_sound(x, y, SOUND_boom, by_element);
+  play_element_sound(x, y, SOUND_boom, Xbug_1_n);
 #endif
 }
 
-static void Lboom_tank(int x, int y, int by_element)
+static void Lboom_tank(int x, int y)
 {
-  next[x][y] = Ztank;
+  if (game_em.use_old_explosions)
+    next[x][y] = Ztank;
 
   Lboom_generic(x, y, Xblank, Xblank);
 
 #if PLAY_ELEMENT_SOUND
-  play_element_sound(x, y, SOUND_boom, by_element);
+  play_element_sound(x, y, SOUND_boom, Xtank_1_n);
 #endif
 }
 
-static void Lboom_eater(int x, int y, int by_element)
+static void Lboom_eater(int x, int y)
 {
-  next[x][y] = Zeater;
+  if (game_em.use_old_explosions)
+    next[x][y] = Zeater;
 
   boom[x-1][y-1] = lev.eater_array[lev.eater_pos][0];
   boom[x][y-1]   = lev.eater_array[lev.eater_pos][1];
@@ -152,10 +155,67 @@ static void Lboom_eater(int x, int y, int by_element)
   lev.eater_pos = (lev.eater_pos + 1) & 7;
 
 #if PLAY_ELEMENT_SOUND
-  play_element_sound(x, y, SOUND_boom, by_element);
+  play_element_sound(x, y, SOUND_boom, Xeater_n);
 #endif
 }
 
+static void Lboom_bug_old(int x, int y)
+{
+  if (!game_em.use_old_explosions)
+    return;
+
+  Lboom_bug(x, y);
+}
+
+static void Lboom_tank_old(int x, int y)
+{
+  if (!game_em.use_old_explosions)
+    return;
+
+  Lboom_tank(x, y);
+}
+
+static void Lboom_eater_old(int x, int y)
+{
+  if (!game_em.use_old_explosions)
+    return;
+
+  Lboom_eater(x, y);
+}
+
+static void Lboom_bug_new(int x, int y, boolean chain_explosion)
+{
+  if (game_em.use_old_explosions)
+    return;
+
+  if (chain_explosion)
+    cave[x][y] = Xchain;
+
+  Lboom_bug(x, y);
+}
+
+static void Lboom_tank_new(int x, int y, boolean chain_explosion)
+{
+  if (game_em.use_old_explosions)
+    return;
+
+  if (chain_explosion)
+    cave[x][y] = Xchain;
+
+  Lboom_tank(x, y);
+}
+
+static void Lboom_eater_new(int x, int y, boolean chain_explosion)
+{
+  if (game_em.use_old_explosions)
+    return;
+
+  if (chain_explosion)
+    cave[x][y] = Xchain;
+
+  Lboom_eater(x, y);
+}
+
 static boolean player_killed(struct PLAYER *ply)
 {
   int x = ply->x;
@@ -293,6 +353,7 @@ static void kill_player(struct PLAYER *ply)
     case Xbug_2_s:
     case Xbug_2_w:
       cave[x][y-1] = Xboom_bug;
+      Lboom_bug_new(x, y-1, TRUE);
       break;
 
     case Xtank_1_n:
@@ -303,7 +364,8 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x][y-1] = Xboom_bomb;
+      cave[x][y-1] = Xboom_tank;
+      Lboom_tank_new(x, y-1, TRUE);
       break;
   }
 
@@ -318,6 +380,7 @@ static void kill_player(struct PLAYER *ply)
     case Xbug_2_s:
     case Xbug_2_w:
       cave[x+1][y] = Xboom_bug;
+      Lboom_bug_new(x+1, y, TRUE);
       break;
 
     case Xtank_1_n:
@@ -328,7 +391,8 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x+1][y] = Xboom_bomb;
+      cave[x+1][y] = Xboom_tank;
+      Lboom_tank_new(x+1, y, TRUE);
       break;
   }
 
@@ -343,6 +407,7 @@ static void kill_player(struct PLAYER *ply)
     case Xbug_2_s:
     case Xbug_2_w:
       cave[x][y+1] = Xboom_bug;
+      Lboom_bug_new(x, y+1, TRUE);
       break;
 
     case Xtank_1_n:
@@ -353,7 +418,8 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x][y+1] = Xboom_bomb;
+      cave[x][y+1] = Xboom_tank;
+      Lboom_tank_new(x, y+1, TRUE);
       break;
   }
 
@@ -368,6 +434,7 @@ static void kill_player(struct PLAYER *ply)
     case Xbug_2_s:
     case Xbug_2_w:
       cave[x-1][y] = Xboom_bug;
+      Lboom_bug_new(x-1, y, TRUE);
       break;
 
     case Xtank_1_n:
@@ -378,7 +445,8 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x-1][y] = Xboom_bomb;
+      cave[x-1][y] = Xboom_tank;
+      Lboom_tank_new(x-1, y, TRUE);
       break;
   }
 
@@ -2802,7 +2870,8 @@ static void Lbug_1_n(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_1_n);
+    next[x][y] = Zboom;
+    Lboom_bug(x, y);
 
     return;
   }
@@ -2849,7 +2918,8 @@ static void Lbug_2_n(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_2_n);
+    next[x][y] = Zboom;
+    Lboom_bug(x, y);
 
     return;
   }
@@ -2914,7 +2984,8 @@ static void Lbug_1_e(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_1_e);
+    next[x][y] = Zboom;
+    Lboom_bug(x, y);
 
     return;
   }
@@ -2961,7 +3032,8 @@ static void Lbug_2_e(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_2_e);
+    next[x][y] = Zboom;
+    Lboom_bug(x, y);
 
     return;
   }
@@ -3026,7 +3098,8 @@ static void Lbug_1_s(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_1_s);
+    next[x][y] = Zboom;
+    Lboom_bug(x, y);
 
     return;
   }
@@ -3073,7 +3146,8 @@ static void Lbug_2_s(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_2_s);
+    next[x][y] = Zboom;
+    Lboom_bug(x, y);
 
     return;
   }
@@ -3138,7 +3212,8 @@ static void Lbug_1_w(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_1_w);
+    next[x][y] = Zboom;
+    Lboom_bug(x, y);
 
     return;
   }
@@ -3185,7 +3260,8 @@ static void Lbug_2_w(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_2_w);
+    next[x][y] = Zboom;
+    Lboom_bug(x, y);
 
     return;
   }
@@ -3250,7 +3326,8 @@ static void Ltank_1_n(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_1_n);
+    next[x][y] = Zboom;
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3297,7 +3374,8 @@ static void Ltank_2_n(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_2_n);
+    next[x][y] = Zboom;
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3362,7 +3440,8 @@ static void Ltank_1_e(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_1_e);
+    next[x][y] = Zboom;
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3409,7 +3488,8 @@ static void Ltank_2_e(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_2_e);
+    next[x][y] = Zboom;
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3474,7 +3554,8 @@ static void Ltank_1_s(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_1_s);
+    next[x][y] = Zboom;
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3521,7 +3602,8 @@ static void Ltank_2_s(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_2_s);
+    next[x][y] = Zboom;
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3586,7 +3668,8 @@ static void Ltank_1_w(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_1_w);
+    next[x][y] = Zboom;
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3633,7 +3716,8 @@ static void Ltank_2_w(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_2_w);
+    next[x][y] = Zboom;
+    Lboom_tank(x, y);
 
     return;
   }
@@ -4393,16 +4477,20 @@ static void Lstone_fall(int x, int y)
     case Xeater_s:
     case Xeater_w:
       cave[x][y] = Ystone_sB;
+      next[x][y] = Xblank;
       cave[x][y+1] = Yeater_stone;
-      Lboom_eater(x, y+1, Xstone_fall);
+      next[x][y+1] = Zeater;
+      Lboom_eater_old(x, y+1);
       score += lev.eater_score;
       return;
 
     case Xalien:
     case Xalien_pause:
       cave[x][y] = Ystone_sB;
+      next[x][y] = Xblank;
       cave[x][y+1] = Yalien_stone;
-      Lboom_tank(x, y+1, Xstone_fall);
+      next[x][y+1] = Ztank;
+      Lboom_tank_old(x, y+1);
       score += lev.alien_score;
       return;
 
@@ -4415,8 +4503,10 @@ static void Lstone_fall(int x, int y)
     case Xbug_2_s:
     case Xbug_2_w:
       cave[x][y] = Ystone_sB;
+      next[x][y] = Xblank;
       cave[x][y+1] = Ybug_stone;
-      Lboom_bug(x, y+1, Xstone_fall);
+      next[x][y+1] = Zbug;
+      Lboom_bug_old(x, y+1);
       score += lev.bug_score;
       return;
 
@@ -4429,8 +4519,10 @@ static void Lstone_fall(int x, int y)
     case Xtank_2_s:
     case Xtank_2_w:
       cave[x][y] = Ystone_sB;
+      next[x][y] = Xblank;
       cave[x][y+1] = Ytank_stone;
-      Lboom_tank(x, y+1, Xstone_fall);
+      next[x][y+1] = Ztank;
+      Lboom_tank_old(x, y+1);
       score += lev.tank_score;
       return;
 
@@ -4506,8 +4598,11 @@ static void Lstone_fall(int x, int y)
 
     case Xbomb:
     case Xbomb_pause:
+      cave[x][y] = Xstone;
+      next[x][y] = Xstone;
       cave[x][y+1] = Ybomb_blank;
-      Lboom_tank(x, y+1, Xstone_fall);
+      next[x][y+1] = Ztank;
+      Lboom_tank_old(x, y+1);
       return;
 
     case Xnut:
@@ -4815,7 +4910,8 @@ static void Lbomb_fall(int x, int y)
 
     default:
       cave[x][y] = Ybomb_blank;
-      Lboom_tank(x, y, Xbomb_fall);
+      next[x][y] = Ztank;
+      Lboom_tank_old(x, y);
       return;
   }
 }
@@ -5509,16 +5605,20 @@ static void Lspring_fall(int x, int y)
     case Xeater_s:
     case Xeater_w:
       cave[x][y] = Yspring_sB;
+      next[x][y] = Xblank;
       cave[x][y+1] = Yeater_spring;
-      Lboom_eater(x, y+1, Xspring_fall);
+      next[x][y+1] = Zeater;
+      Lboom_eater_old(x, y+1);
       score += lev.eater_score;
       return;
 
     case Xalien:
     case Xalien_pause:
       cave[x][y] = Yspring_sB;
+      next[x][y] = Xblank;
       cave[x][y+1] = Yalien_spring;
-      Lboom_tank(x, y+1, Xspring_fall);
+      next[x][y+1] = Ztank;
+      Lboom_tank_old(x, y+1);
       score += lev.alien_score;
       return;
 
@@ -5531,8 +5631,10 @@ static void Lspring_fall(int x, int y)
     case Xbug_2_s:
     case Xbug_2_w:
       cave[x][y] = Yspring_sB;
+      next[x][y] = Xblank;
       cave[x][y+1] = Ybug_spring;
-      Lboom_bug(x, y+1, Xspring_fall);
+      next[x][y+1] = Zbug;
+      Lboom_bug_old(x, y+1);
       score += lev.bug_score;
       return;
 
@@ -5545,15 +5647,20 @@ static void Lspring_fall(int x, int y)
     case Xtank_2_s:
     case Xtank_2_w:
       cave[x][y] = Yspring_sB;
+      next[x][y] = Xblank;
       cave[x][y+1] = Ytank_spring;
-      Lboom_tank(x, y+1, Xspring_fall);
+      next[x][y+1] = Ztank;
+      Lboom_tank_old(x, y+1);
       score += lev.tank_score;
       return;
 
     case Xbomb:
     case Xbomb_pause:
+      cave[x][y] = Xspring;
+      next[x][y] = Xspring;
       cave[x][y+1] = Ybomb_blank;
-      Lboom_tank(x, y+1, Xspring_fall);
+      next[x][y+1] = Ztank;
+      Lboom_tank_old(x, y+1);
       return;
 
     default:
@@ -5576,8 +5683,10 @@ static void Lpush_emerald_e(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5616,8 +5725,10 @@ static void Lpush_emerald_w(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5656,8 +5767,10 @@ static void Lpush_diamond_e(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5696,8 +5809,10 @@ static void Lpush_diamond_w(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5736,8 +5851,10 @@ static void Lpush_stone_e(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5776,8 +5893,10 @@ static void Lpush_stone_w(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5816,8 +5935,10 @@ static void Lpush_bomb_e(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5856,8 +5977,10 @@ static void Lpush_bomb_w(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5896,8 +6019,10 @@ static void Lpush_nut_e(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5936,8 +6061,10 @@ static void Lpush_nut_w(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5976,8 +6103,10 @@ static void Lpush_spring_e(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -6016,8 +6145,10 @@ static void Lpush_spring_w(int x, int y)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -6815,8 +6946,10 @@ static void Lboom_one(int x, int y, boolean by_dynamite)
     case Ztank:
     case Zeater:
     case Zdynamite:
+    case Zboom:
+    case Xchain:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xacid_1:
     case Xacid_2:
@@ -6877,12 +7010,14 @@ static void Lboom_one(int x, int y, boolean by_dynamite)
     case Xbug_2_s:
     case Xbug_2_w:
       cave[x][y] = Xboom_bug;
+      Lboom_bug_new(x, y, TRUE);
       return;
 
     case Xbomb:
     case Xbomb_pause:
     case Xbomb_fall:
-      cave[x][y] = Xboom_bomb;
+      cave[x][y] = Xboom_tank;
+      Lboom_tank_new(x, y, TRUE);
       return;
 
     default:
@@ -6910,20 +7045,27 @@ static void Lexplode(int x, int y)
   switch (cave[x][y])
   {
     case Zbug:
+      Lboom_bug_new(x, y, FALSE);
       Lboom_nine(x, y, FALSE);
       break;
 
     case Ztank:
+      Lboom_tank_new(x, y, FALSE);
       Lboom_nine(x, y, FALSE);
       break;
 
     case Zeater:
+      Lboom_eater_new(x, y, FALSE);
       Lboom_nine(x, y, FALSE);
       break;
 
     case Zdynamite:
       Lboom_nine(x, y, TRUE);
       break;
+
+    case Zboom:
+      Lboom_nine(x, y, FALSE);
+      break;
   }
 }
 
@@ -6952,6 +7094,11 @@ static void Lboom_android(int x, int y)
   Lboom_1(x, y);
 }
 
+static void Lchain(int x, int y)
+{
+  next[x][y] = Zboom;
+}
+
 static void handle_tile(int x, int y)
 {
   switch (cave[x][y])
@@ -7111,15 +7258,16 @@ static void handle_tile(int x, int y)
 
     case Xpause:               Lpause(x, y);                   break;
 
-    case Xboom_bug:            Lboom_bug(x, y, Xboom_bug);     break;
-    case Xboom_bomb:           Lboom_tank(x, y, Xboom_bomb);   break;
+    case Xchain:               Lchain(x, y);                   break;
+    case Xboom_bug:            Lboom_bug(x, y);                break;
+    case Xboom_tank:           Lboom_tank(x, y);               break;
     case Xboom_android:                Lboom_android(x, y);            break;
     case Xboom_1:              Lboom_1(x, y);                  break;
     case Xboom_2:              Lboom_2(x, y);                  break;
   }
 }
 
-void logic_players(void)
+static void logic_players(void)
 {
   int start_check_nr;
   int i;
@@ -7142,6 +7290,9 @@ void logic_players(void)
 
   for (i = 0; i < MAX_PLAYERS; i++)
   {
+    if (!ply[i].alive)
+      continue;
+
     /* check for wrap-around movement */
     if (ply[i].x < lev.left ||
        ply[i].x > lev.right - 1)
@@ -7188,7 +7339,7 @@ void logic_players(void)
   }
 }
 
-void logic_objects(void)
+static void logic_objects(void)
 {
   int x, y;
 
@@ -7217,7 +7368,7 @@ void logic_objects(void)
   lev.draw = temp;
 }
 
-void logic_globals(void)
+static void logic_globals(void)
 {
   int x;
   int y;
@@ -7284,3 +7435,17 @@ void logic_globals(void)
     for (x = lev.left; x < lev.right; x++)
       next[x][y] = cave[x][y];
 }
+
+void logic(void)
+{
+  if (frame == 0)
+  {
+    logic_players();
+    logic_objects();
+  }
+
+  if (frame == 1)
+  {
+    logic_globals();
+  }
+}