fixed single-step mode for wrap-around levels in EM engine
[rocksndiamonds.git] / src / game_em / logic.c
index 290066440bb70e75bcc3b48ad1f46bc702a5ee18..8b759630e93bc8524f02d7c7663af538b7134030 100644 (file)
@@ -12,6 +12,8 @@
 #define ACID_ROLL      /* rolling objects go into acid rather than remove it */
 #define ACID_PLAYER    /* player gets killed by acid, but without explosion */
 
+#define RANDOM_BUG     /* handle problem with old tapes using 64-bit random */
+
 #define RANDOM(x)      ((seed = seed << 31 | seed >> 1) % x)
 
 static short **cave, **next, **boom;
@@ -82,6 +84,21 @@ static const byte is_amoeba[GAME_TILE_MAX] =
   [Xamoeba_8]          = 1
 };
 
+static byte is_android_blank[GAME_TILE_MAX] =
+{
+  [Xblank]             = 1,
+  [Xsplash_e]          = 1,
+  [Xsplash_w]          = 1,
+  [Xfake_acid_1]       = 1,
+  [Xfake_acid_2]       = 1,
+  [Xfake_acid_3]       = 1,
+  [Xfake_acid_4]       = 1,
+  [Xfake_acid_5]       = 1,
+  [Xfake_acid_6]       = 1,
+  [Xfake_acid_7]       = 1,
+  [Xfake_acid_8]       = 1
+};
+
 static const byte is_android_walkable[GAME_TILE_MAX] =
 {
   [Xblank]             = 1,
@@ -150,7 +167,7 @@ static void Lboom_eater(int x, int y)
   boom[x][y+1]   = lev.eater_array[lev.eater_pos][7];
   boom[x+1][y+1] = lev.eater_array[lev.eater_pos][8];
 
-  lev.eater_pos = (lev.eater_pos + 1) % 8;
+  lev.eater_pos = (lev.eater_pos + 1) % lev.num_eater_arrays;
 
 #if PLAY_ELEMENT_SOUND
   play_element_sound(x, y, SOUND_boom, Xeater_n);
@@ -214,6 +231,31 @@ static void Lboom_eater_new(int x, int y, boolean chain_explosion)
   Lboom_eater(x, y);
 }
 
+static void Lboom_cave_new(int x, int y, int element)
+{
+  if (game_em.use_old_explosions)
+    return;
+
+  cave[x][y] = element;
+}
+
+static void Lboom_next_new(int x, int y, int element)
+{
+  if (game_em.use_old_explosions)
+    return;
+
+  next[x][y] = element;
+}
+
+static void Lpush_element_old(int x, int y, int element)
+{
+  if (!game_em.use_old_push_elements)
+    return;
+
+  cave[x][y] = element;
+  next[x][y] = element;
+}
+
 static boolean player_killed(struct PLAYER *ply)
 {
   int x = ply->x;
@@ -1537,14 +1579,14 @@ static void Landroid(int x, int y)
 
   if (lev.android_clone_cnt == 0)
   {
-    if (!is_blank[cave[x-1][y-1]] &&
-       !is_blank[cave[x][y-1]]   &&
-       !is_blank[cave[x+1][y-1]] &&
-       !is_blank[cave[x-1][y]]   &&
-       !is_blank[cave[x+1][y]]   &&
-       !is_blank[cave[x-1][y+1]] &&
-       !is_blank[cave[x][y+1]]   &&
-       !is_blank[cave[x+1][y+1]])
+    if (!is_android_blank[cave[x-1][y-1]] &&
+       !is_android_blank[cave[x][y-1]]   &&
+       !is_android_blank[cave[x+1][y-1]] &&
+       !is_android_blank[cave[x-1][y]]   &&
+       !is_android_blank[cave[x+1][y]]   &&
+       !is_android_blank[cave[x-1][y+1]] &&
+       !is_android_blank[cave[x][y+1]]   &&
+       !is_android_blank[cave[x+1][y+1]])
       goto android_move;
 
     switch (RANDOM(8))
@@ -1648,91 +1690,91 @@ static void Landroid(int x, int y)
       /* randomly find a direction to move */
 
       case 0: /* S,NE,W,NW,SE,E,SW,N */
-       if (is_blank[cave[x][y+1]])   goto android_s;
-       if (is_blank[cave[x+1][y-1]]) goto android_ne;
-       if (is_blank[cave[x-1][y]])   goto android_w;
-       if (is_blank[cave[x-1][y-1]]) goto android_nw;
-       if (is_blank[cave[x+1][y+1]]) goto android_se;
-       if (is_blank[cave[x+1][y]])   goto android_e;
-       if (is_blank[cave[x-1][y+1]]) goto android_sw;
-       if (is_blank[cave[x][y-1]])   goto android_n;
+       if (is_android_blank[cave[x][y+1]])   goto android_s;
+       if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+       if (is_android_blank[cave[x-1][y]])   goto android_w;
+       if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+       if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+       if (is_android_blank[cave[x+1][y]])   goto android_e;
+       if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+       if (is_android_blank[cave[x][y-1]])   goto android_n;
        goto android_move;
 
       case 1: /* NW,SE,N,S,NE,SW,E,W */
-       if (is_blank[cave[x-1][y-1]]) goto android_nw;
-       if (is_blank[cave[x+1][y+1]]) goto android_se;
-       if (is_blank[cave[x][y-1]])   goto android_n;
-       if (is_blank[cave[x][y+1]])   goto android_s;
-       if (is_blank[cave[x+1][y-1]]) goto android_ne;
-       if (is_blank[cave[x-1][y+1]]) goto android_sw;
-       if (is_blank[cave[x+1][y]])   goto android_e;
-       if (is_blank[cave[x-1][y]])   goto android_w;
+       if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+       if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+       if (is_android_blank[cave[x][y-1]])   goto android_n;
+       if (is_android_blank[cave[x][y+1]])   goto android_s;
+       if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+       if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+       if (is_android_blank[cave[x+1][y]])   goto android_e;
+       if (is_android_blank[cave[x-1][y]])   goto android_w;
        goto android_move;
 
       case 2: /* SW,E,S,W,N,NW,SE,NE */
-       if (is_blank[cave[x-1][y+1]]) goto android_sw;
-       if (is_blank[cave[x+1][y]])   goto android_e;
-       if (is_blank[cave[x][y+1]])   goto android_s;
-       if (is_blank[cave[x-1][y]])   goto android_w;
-       if (is_blank[cave[x][y-1]])   goto android_n;
-       if (is_blank[cave[x-1][y-1]]) goto android_nw;
-       if (is_blank[cave[x+1][y+1]]) goto android_se;
-       if (is_blank[cave[x+1][y-1]]) goto android_ne;
+       if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+       if (is_android_blank[cave[x+1][y]])   goto android_e;
+       if (is_android_blank[cave[x][y+1]])   goto android_s;
+       if (is_android_blank[cave[x-1][y]])   goto android_w;
+       if (is_android_blank[cave[x][y-1]])   goto android_n;
+       if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+       if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+       if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
        goto android_move;
 
       case 3: /* N,SE,NE,E,W,S,NW,SW */
-       if (is_blank[cave[x][y-1]])   goto android_n;
-       if (is_blank[cave[x+1][y+1]]) goto android_se;
-       if (is_blank[cave[x+1][y-1]]) goto android_ne;
-       if (is_blank[cave[x+1][y]])   goto android_e;
-       if (is_blank[cave[x-1][y]])   goto android_w;
-       if (is_blank[cave[x][y+1]])   goto android_s;
-       if (is_blank[cave[x-1][y-1]]) goto android_nw;
-       if (is_blank[cave[x-1][y+1]]) goto android_sw;
+       if (is_android_blank[cave[x][y-1]])   goto android_n;
+       if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+       if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+       if (is_android_blank[cave[x+1][y]])   goto android_e;
+       if (is_android_blank[cave[x-1][y]])   goto android_w;
+       if (is_android_blank[cave[x][y+1]])   goto android_s;
+       if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+       if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
        goto android_move;
 
       case 4: /* SE,NW,E,NE,SW,W,N,S */
-       if (is_blank[cave[x+1][y+1]]) goto android_se;
-       if (is_blank[cave[x-1][y-1]]) goto android_nw;
-       if (is_blank[cave[x+1][y]])   goto android_e;
-       if (is_blank[cave[x+1][y-1]]) goto android_ne;
-       if (is_blank[cave[x-1][y+1]]) goto android_sw;
-       if (is_blank[cave[x-1][y]])   goto android_w;
-       if (is_blank[cave[x][y-1]])   goto android_n;
-       if (is_blank[cave[x][y+1]])   goto android_s;
+       if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+       if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+       if (is_android_blank[cave[x+1][y]])   goto android_e;
+       if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+       if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+       if (is_android_blank[cave[x-1][y]])   goto android_w;
+       if (is_android_blank[cave[x][y-1]])   goto android_n;
+       if (is_android_blank[cave[x][y+1]])   goto android_s;
        goto android_move;
 
       case 5: /* NE,W,SE,SW,S,N,E,NW */
-       if (is_blank[cave[x+1][y-1]]) goto android_ne;
-       if (is_blank[cave[x-1][y]])   goto android_w;
-       if (is_blank[cave[x+1][y+1]]) goto android_se;
-       if (is_blank[cave[x-1][y+1]]) goto android_sw;
-       if (is_blank[cave[x][y+1]])   goto android_s;
-       if (is_blank[cave[x][y-1]])   goto android_n;
-       if (is_blank[cave[x+1][y]])   goto android_e;
-       if (is_blank[cave[x-1][y-1]]) goto android_nw;
+       if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+       if (is_android_blank[cave[x-1][y]])   goto android_w;
+       if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+       if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+       if (is_android_blank[cave[x][y+1]])   goto android_s;
+       if (is_android_blank[cave[x][y-1]])   goto android_n;
+       if (is_android_blank[cave[x+1][y]])   goto android_e;
+       if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
        goto android_move;
 
       case 6: /* E,N,SW,S,NW,NE,SE,W */
-       if (is_blank[cave[x+1][y]])   goto android_e;
-       if (is_blank[cave[x][y-1]])   goto android_n;
-       if (is_blank[cave[x-1][y+1]]) goto android_sw;
-       if (is_blank[cave[x][y+1]])   goto android_s;
-       if (is_blank[cave[x-1][y-1]]) goto android_nw;
-       if (is_blank[cave[x+1][y-1]]) goto android_ne;
-       if (is_blank[cave[x+1][y+1]]) goto android_se;
-       if (is_blank[cave[x-1][y]])   goto android_w;
+       if (is_android_blank[cave[x+1][y]])   goto android_e;
+       if (is_android_blank[cave[x][y-1]])   goto android_n;
+       if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+       if (is_android_blank[cave[x][y+1]])   goto android_s;
+       if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+       if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+       if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+       if (is_android_blank[cave[x-1][y]])   goto android_w;
        goto android_move;
 
       case 7: /* W,SW,NW,N,E,SE,NE,S */
-       if (is_blank[cave[x-1][y]])   goto android_w;
-       if (is_blank[cave[x-1][y+1]]) goto android_sw;
-       if (is_blank[cave[x-1][y-1]]) goto android_nw;
-       if (is_blank[cave[x][y-1]])   goto android_n;
-       if (is_blank[cave[x+1][y]])   goto android_e;
-       if (is_blank[cave[x+1][y+1]]) goto android_se;
-       if (is_blank[cave[x+1][y-1]]) goto android_ne;
-       if (is_blank[cave[x][y+1]])   goto android_s;
+       if (is_android_blank[cave[x-1][y]])   goto android_w;
+       if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+       if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+       if (is_android_blank[cave[x][y-1]])   goto android_n;
+       if (is_android_blank[cave[x+1][y]])   goto android_e;
+       if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+       if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+       if (is_android_blank[cave[x][y+1]])   goto android_s;
        goto android_move;
     }
   }
@@ -4477,7 +4519,7 @@ static void Lstone_fall(int x, int y)
     case Xeater_s:
     case Xeater_w:
       cave[x][y] = Ystone_sB;
-      next[x][y] = Xblank;
+      Lboom_next_new(x, y, Xblank);
       cave[x][y+1] = Yeater_stone;
       next[x][y+1] = Zeater;
       Lboom_eater_old(x, y+1);
@@ -4487,7 +4529,7 @@ static void Lstone_fall(int x, int y)
     case Xalien:
     case Xalien_pause:
       cave[x][y] = Ystone_sB;
-      next[x][y] = Xblank;
+      Lboom_next_new(x, y, Xblank);
       cave[x][y+1] = Yalien_stone;
       next[x][y+1] = Ztank;
       Lboom_tank_old(x, y+1);
@@ -4503,7 +4545,7 @@ 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;
+      Lboom_next_new(x, y, Xblank);
       cave[x][y+1] = Ybug_stone;
       next[x][y+1] = Zbug;
       Lboom_bug_old(x, y+1);
@@ -4519,7 +4561,7 @@ 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;
+      Lboom_next_new(x, y, Xblank);
       cave[x][y+1] = Ytank_stone;
       next[x][y+1] = Ztank;
       Lboom_tank_old(x, y+1);
@@ -4598,8 +4640,8 @@ static void Lstone_fall(int x, int y)
 
     case Xbomb:
     case Xbomb_pause:
-      cave[x][y] = Xstone;
-      next[x][y] = Xstone;
+      Lboom_cave_new(x, y, Xstone);
+      Lboom_next_new(x, y, Xstone);
       cave[x][y+1] = Ybomb_blank;
       next[x][y+1] = Ztank;
       Lboom_tank_old(x, y+1);
@@ -5678,6 +5720,9 @@ static void Lpush_emerald_e(int x, int y)
 
   switch (cave[x+1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -5689,6 +5734,7 @@ static void Lpush_emerald_e(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xemerald);
       return;
 
 #ifdef ACID_ROLL
@@ -5700,6 +5746,8 @@ static void Lpush_emerald_e(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x+2][y-1] == Xblank)
        cave[x+2][y-1] = Xsplash_e;
       if (cave[x][y-1] == Xblank)
@@ -5720,6 +5768,9 @@ static void Lpush_emerald_w(int x, int y)
 
   switch (cave[x-1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -5731,6 +5782,7 @@ static void Lpush_emerald_w(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xemerald);
       return;
 
 #ifdef ACID_ROLL
@@ -5742,6 +5794,8 @@ static void Lpush_emerald_w(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x][y-1] == Xblank)
        cave[x][y-1] = Xsplash_e;
       if (cave[x-2][y-1] == Xblank)
@@ -5762,6 +5816,9 @@ static void Lpush_diamond_e(int x, int y)
 
   switch (cave[x+1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -5773,6 +5830,7 @@ static void Lpush_diamond_e(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xdiamond);
       return;
 
 #ifdef ACID_ROLL
@@ -5784,6 +5842,8 @@ static void Lpush_diamond_e(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x+2][y-1] == Xblank)
        cave[x+2][y-1] = Xsplash_e;
       if (cave[x][y-1] == Xblank)
@@ -5804,6 +5864,9 @@ static void Lpush_diamond_w(int x, int y)
 
   switch (cave[x-1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -5815,6 +5878,7 @@ static void Lpush_diamond_w(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xdiamond);
       return;
 
 #ifdef ACID_ROLL
@@ -5826,6 +5890,8 @@ static void Lpush_diamond_w(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x][y-1] == Xblank)
        cave[x][y-1] = Xsplash_e;
       if (cave[x-2][y-1] == Xblank)
@@ -5846,6 +5912,9 @@ static void Lpush_stone_e(int x, int y)
 
   switch (cave[x+1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -5857,6 +5926,7 @@ static void Lpush_stone_e(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xstone);
       return;
 
 #ifdef ACID_ROLL
@@ -5868,6 +5938,8 @@ static void Lpush_stone_e(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x+2][y-1] == Xblank)
        cave[x+2][y-1] = Xsplash_e;
       if (cave[x][y-1] == Xblank)
@@ -5888,6 +5960,9 @@ static void Lpush_stone_w(int x, int y)
 
   switch (cave[x-1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -5899,6 +5974,7 @@ static void Lpush_stone_w(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xstone);
       return;
 
 #ifdef ACID_ROLL
@@ -5910,6 +5986,8 @@ static void Lpush_stone_w(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x][y-1] == Xblank)
        cave[x][y-1] = Xsplash_e;
       if (cave[x-2][y-1] == Xblank)
@@ -5930,6 +6008,9 @@ static void Lpush_bomb_e(int x, int y)
 
   switch (cave[x+1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -5941,6 +6022,7 @@ static void Lpush_bomb_e(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xbomb);
       return;
 
 #ifdef ACID_ROLL
@@ -5952,6 +6034,8 @@ static void Lpush_bomb_e(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x+2][y-1] == Xblank)
        cave[x+2][y-1] = Xsplash_e;
       if (cave[x][y-1] == Xblank)
@@ -5972,6 +6056,9 @@ static void Lpush_bomb_w(int x, int y)
 
   switch (cave[x-1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -5983,6 +6070,7 @@ static void Lpush_bomb_w(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xbomb);
       return;
 
 #ifdef ACID_ROLL
@@ -5994,6 +6082,8 @@ static void Lpush_bomb_w(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x][y-1] == Xblank)
        cave[x][y-1] = Xsplash_e;
       if (cave[x-2][y-1] == Xblank)
@@ -6014,6 +6104,9 @@ static void Lpush_nut_e(int x, int y)
 
   switch (cave[x+1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -6025,6 +6118,7 @@ static void Lpush_nut_e(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xnut);
       return;
 
 #ifdef ACID_ROLL
@@ -6036,6 +6130,8 @@ static void Lpush_nut_e(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x+2][y-1] == Xblank)
        cave[x+2][y-1] = Xsplash_e;
       if (cave[x][y-1] == Xblank)
@@ -6056,6 +6152,9 @@ static void Lpush_nut_w(int x, int y)
 
   switch (cave[x-1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -6067,6 +6166,7 @@ static void Lpush_nut_w(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xnut);
       return;
 
 #ifdef ACID_ROLL
@@ -6078,6 +6178,8 @@ static void Lpush_nut_w(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x][y-1] == Xblank)
        cave[x][y-1] = Xsplash_e;
       if (cave[x-2][y-1] == Xblank)
@@ -6098,6 +6200,9 @@ static void Lpush_spring_e(int x, int y)
 
   switch (cave[x+1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -6109,6 +6214,7 @@ static void Lpush_spring_e(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xspring);
       return;
 
 #ifdef ACID_ROLL
@@ -6120,6 +6226,8 @@ static void Lpush_spring_e(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x+2][y-1] == Xblank)
        cave[x+2][y-1] = Xsplash_e;
       if (cave[x][y-1] == Xblank)
@@ -6140,6 +6248,9 @@ static void Lpush_spring_w(int x, int y)
 
   switch (cave[x-1][y])
   {
+    case Zplayer:
+      if (!game_em.use_old_push_elements)
+       break;
     case Zborder:
     case Zbug:
     case Ztank:
@@ -6151,6 +6262,7 @@ static void Lpush_spring_w(int x, int y)
     case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
+      Lpush_element_old(x, y, Xspring);
       return;
 
 #ifdef ACID_ROLL
@@ -6162,6 +6274,8 @@ static void Lpush_spring_w(int x, int y)
     case Xacid_6:
     case Xacid_7:
     case Xacid_8:
+      if (game_em.use_old_push_into_acid)
+       break;
       if (cave[x][y-1] == Xblank)
        cave[x][y-1] = Xsplash_e;
       if (cave[x-2][y-1] == Xblank)
@@ -7267,27 +7381,28 @@ static void handle_tile(int x, int y)
   }
 }
 
-static void logic_players(void)
+boolean logic_check_wrap(void)
 {
-  int start_check_nr;
   int i;
 
-  cave = lev.cave;
-  next = lev.next;
-  boom = lev.boom;
-
-  game_em.any_player_moving = FALSE;
-  game_em.any_player_snapping = FALSE;
-
-  /* must test for death and actually kill separately */
   for (i = 0; i < MAX_PLAYERS; i++)
   {
-    boolean ply_kill = player_killed(&ply[i]);
+    if (!ply[i].alive)
+      continue;
 
-    if (ply[i].alive && ply_kill)
-      kill_player(&ply[i]);
+    /* check for wrap-around movement */
+    if (ply[i].x < lev.left ||
+       ply[i].x > lev.right - 1)
+      return TRUE;
   }
 
+  return FALSE;
+}
+
+void logic_move(void)
+{
+  int i;
+
   for (i = 0; i < MAX_PLAYERS; i++)
   {
     if (!ply[i].alive)
@@ -7299,6 +7414,9 @@ static void logic_players(void)
     {
       ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left);
 
+      if (!lev.infinite_true)
+       ply[i].y += (ply[i].x == lev.left ? 1 : -1);
+
       game.centered_player_nr_next = i;
       game.set_centered_player = TRUE;
       game.set_centered_player_wrap = TRUE;
@@ -7308,6 +7426,30 @@ static void logic_players(void)
     ply[i].prev_y = ply[i].y;
     ply[i].anim = PLY_still;
   }
+}
+
+static void logic_players(void)
+{
+  int start_check_nr;
+  int i;
+
+  cave = lev.cave;
+  next = lev.next;
+  boom = lev.boom;
+
+  game_em.any_player_moving = FALSE;
+  game_em.any_player_snapping = FALSE;
+
+  /* must test for death and actually kill separately */
+  for (i = 0; i < MAX_PLAYERS; i++)
+  {
+    boolean ply_kill = player_killed(&ply[i]);
+
+    if (ply[i].alive && ply_kill)
+      kill_player(&ply[i]);
+  }
+
+  logic_move();
 
   start_check_nr = ((game_em.random & 128 ? 0 : 1) * 2 +
                    (game_em.random & 256 ? 0 : 1));
@@ -7373,7 +7515,11 @@ static void logic_globals(void)
   int x;
   int y;
   int count;
-  unsigned int random;
+#ifdef RANDOM_BUG
+  uint64_t random;
+#else
+  uint32_t random;
+#endif
 
   cave = lev.cave;
   next = lev.next;
@@ -7419,6 +7565,11 @@ static void logic_globals(void)
       Lamoeba(x, y);
 
     random = random * 129 + 1;
+
+#ifdef RANDOM_BUG
+    if (!game_em.use_random_bug)
+      random = (uint32_t)random;
+#endif
   }
 
   game_em.random = random;
@@ -7436,6 +7587,14 @@ static void logic_globals(void)
       next[x][y] = cave[x][y];
 }
 
+void logic_init(void)
+{
+  int splash_is_blank = !game_em.use_old_android;
+
+  is_android_blank[Xsplash_e] = splash_is_blank;
+  is_android_blank[Xsplash_w] = splash_is_blank;
+}
+
 void logic(void)
 {
   if (frame == 0)