rnd-20111007-1-src
[rocksndiamonds.git] / src / game_em / synchro_2.c
index d8f7913ce534e5efba868acf402f11338ea0ba8e..c4b9a678b3e1e9dbf5ebb3302986d70c76736abf 100644 (file)
@@ -8,25 +8,48 @@
  * compilers suck.
  */
 
-#include "display.h"
-#include "tile.h"
-#include "level.h"
-#include "sample.h"
+#include "main_em.h"
 
 
 #define RANDOM (random = random << 31 | random >> 1)
 
+static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
+{
+  int distance, distance_shortest = EM_MAX_CAVE_WIDTH + EM_MAX_CAVE_HEIGHT;
+  int i;
+
+  /* default values if no players are alive anymore */
+  *dx = 0;
+  *dy = 0;
+
+  for (i = 0; i < MAX_PLAYERS; i++)
+  {
+    if (!ply[i].alive)
+      continue;
+
+    distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
+
+    if (distance < distance_shortest)
+    {
+      *dx = ply[i].x;
+      *dy = ply[i].y;
+
+      distance_shortest = distance;
+    }
+  }
+}
+
 void synchro_2(void)
 {
-  register unsigned int x = 0;
-  register unsigned int y = 1;
-  register unsigned long random = Random;
-  register unsigned short *cave_cache = Cave[y]; /* might be a win */
-  unsigned long score = 0;
-
-  unsigned int temp = 0;       /* initialized to make compilers happy */
-  unsigned int dx; /* only needed to find closest player */
-  unsigned int dy;
+  int x = 0;
+  int y = 1;
+  unsigned int random = RandomEM;
+  short *cave_cache = Cave[y]; /* might be a win */
+  int score = 0;
+
+  int temp = 0;                        /* initialized to make compilers happy */
+  int dx;                      /* only needed to find closest player */
+  int dy;
   int element;
 
  loop:
@@ -348,7 +371,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -356,6 +379,16 @@ void synchro_2(void)
        case Yacid_splash_wB:
        case Xplant:
        case Yplant:
+#if 1
+        case Xfake_acid_1:
+        case Xfake_acid_2:
+        case Xfake_acid_3:
+        case Xfake_acid_4:
+        case Xfake_acid_5:
+        case Xfake_acid_6:
+        case Xfake_acid_7:
+        case Xfake_acid_8:
+#endif
          Cave[y][x] = Ystone_sB;
          Cave[y+1][x] = Ystone_s;
          Next[y][x] = Xblank;
@@ -479,12 +512,22 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
        case Yacid_splash_eB:
        case Yacid_splash_wB:
+#if 1
+        case Xfake_acid_1:
+        case Xfake_acid_2:
+        case Xfake_acid_3:
+        case Xfake_acid_4:
+        case Xfake_acid_5:
+        case Xfake_acid_6:
+        case Xfake_acid_7:
+        case Xfake_acid_8:
+#endif
          Cave[y][x] = Ystone_sB;
          Cave[y+1][x] = Ystone_s;
          Next[y][x] = Xblank;
@@ -516,13 +559,23 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
        case Yacid_splash_eB:
        case Yacid_splash_wB:
        case Zplayer:
+#if 1
+        case Xfake_acid_1:
+        case Xfake_acid_2:
+        case Xfake_acid_3:
+        case Xfake_acid_4:
+        case Xfake_acid_5:
+        case Xfake_acid_6:
+        case Xfake_acid_7:
+        case Xfake_acid_8:
+#endif
          Cave[y][x] = Ystone_sB;
          Cave[y+1][x] = Ystone_s;
          Next[y][x] = Xblank;
@@ -534,7 +587,7 @@ void synchro_2(void)
          Cave[y+1][x] = Yemerald_stone;
          Next[y][x] = Xstone;
          Next[y+1][x] = Xemerald;
-         play_sound(x, y, SAMPLE_crack);
+         play_element_sound(x, y, SAMPLE_crack, Xnut);
          score += lev.nut_score;
          goto loop;
 
@@ -558,6 +611,9 @@ void synchro_2(void)
          Boom[y+2][x-1] = Xemerald;
          Boom[y+2][x] = Xemerald;
          Boom[y+2][x+1] = Xemerald;
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          score += lev.bug_score;
          goto loop;
 
@@ -581,6 +637,9 @@ void synchro_2(void)
          Boom[y+2][x-1] = Xblank;
          Boom[y+2][x] = Xblank;
          Boom[y+2][x+1] = Xblank;
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          score += lev.tank_score;
          goto loop;
 
@@ -638,6 +697,9 @@ void synchro_2(void)
          Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
          Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
          Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          lev.eater_pos = (lev.eater_pos + 1) & 7;
          score += lev.eater_score;
          goto loop;
@@ -656,6 +718,9 @@ void synchro_2(void)
          Boom[y+2][x-1] = Xblank;
          Boom[y+2][x] = Xblank;
          Boom[y+2][x+1] = Xblank;
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          score += lev.alien_score;
          goto loop;
 
@@ -710,7 +775,7 @@ void synchro_2(void)
            case Xplant:
            case Yplant:
              Next[y][x] = Xstone;
-             play_sound(x, y, SAMPLE_stone);
+             play_element_sound(x, y, SAMPLE_stone, Xstone);
              goto loop;
          }
 
@@ -718,7 +783,7 @@ void synchro_2(void)
          Cave[y+1][x] = Ydiamond_stone;
          Next[y][x] = Xblank;
          Next[y+1][x] = Xstone_pause;
-         play_sound(x, y, SAMPLE_squash);
+         play_element_sound(x, y, SAMPLE_squash, Xdiamond);
          goto loop;
 
        case Xbomb:
@@ -734,6 +799,9 @@ void synchro_2(void)
          Boom[y+2][x-1] = Xblank;
          Boom[y+2][x] = Xblank;
          Boom[y+2][x+1] = Xblank;
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          goto loop;
 
        case Xwonderwall:
@@ -749,14 +817,14 @@ void synchro_2(void)
            }
 
            Next[y][x] = Xblank;
-           play_element_sound(x, y, SAMPLE_wonderfall, Xstone);
+           play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
            goto loop;
          }
 
        default:
          Cave[y][x] = Xstone;
          Next[y][x] = Xstone;
-         play_sound(x, y, SAMPLE_stone);
+         play_element_sound(x, y, SAMPLE_stone, Xstone);
          goto loop;
       }
 
@@ -779,7 +847,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -900,7 +968,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -937,7 +1005,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -953,7 +1021,7 @@ void synchro_2(void)
        default:
          Cave[y][x] = Xnut;
          Next[y][x] = Xnut;
-         play_sound(x, y, SAMPLE_nut);
+         play_element_sound(x, y, SAMPLE_nut, Xnut);
          goto loop;
       }
 
@@ -984,7 +1052,7 @@ void synchro_2(void)
        case Zplayer:
          Cave[y][x] = Ybug_n_e;
          Next[y][x] = Xbug_goe;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
 
        default:
@@ -1016,7 +1084,7 @@ void synchro_2(void)
          if (Cave[y-2][x-1] == Xblank)
            Cave[y-2][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -1029,13 +1097,13 @@ void synchro_2(void)
          Cave[y-1][x] = Ybug_n;
          Next[y][x] = Xblank;
          Next[y-1][x] = Xbug_n;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
 
        default:
          Cave[y][x] = Ybug_n_w;
          Next[y][x] = Xbug_gow;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
       }
 
@@ -1066,7 +1134,7 @@ void synchro_2(void)
        case Zplayer:
          Cave[y][x] = Ybug_e_s;
          Next[y][x] = Xbug_gos;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
 
        default:
@@ -1098,7 +1166,7 @@ void synchro_2(void)
          if (Cave[y-1][x] == Xblank)
            Cave[y-1][x] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -1111,13 +1179,13 @@ void synchro_2(void)
          Cave[y][x+1] = Ybug_e;
          Next[y][x] = Xblank;
          Next[y][x+1] = Xbug_e;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
 
        default:
          Cave[y][x] = Ybug_e_n;
          Next[y][x] = Xbug_gon;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
       }
 
@@ -1148,7 +1216,7 @@ void synchro_2(void)
        case Zplayer:
          Cave[y][x] = Ybug_s_w;
          Next[y][x] = Xbug_gow;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
 
        default:
@@ -1180,7 +1248,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -1193,13 +1261,13 @@ void synchro_2(void)
          Cave[y+1][x] = Ybug_s;
          Next[y][x] = Xblank;
          Next[y+1][x] = Xbug_s;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
 
        default:
          Cave[y][x] = Ybug_s_e;
          Next[y][x] = Xbug_goe;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
       }
 
@@ -1230,7 +1298,7 @@ void synchro_2(void)
        case Zplayer:
          Cave[y][x] = Ybug_w_n;
          Next[y][x] = Xbug_gon;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
 
        default:
@@ -1262,7 +1330,7 @@ void synchro_2(void)
          if (Cave[y-1][x-2] == Xblank)
            Cave[y-1][x-2] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -1275,13 +1343,13 @@ void synchro_2(void)
          Cave[y][x-1] = Ybug_w;
          Next[y][x] = Xblank;
          Next[y][x-1] = Xbug_w;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
 
        default:
          Cave[y][x] = Ybug_w_s;
          Next[y][x] = Xbug_gos;
-         play_sound(x, y, SAMPLE_bug);
+         play_element_sound(x, y, SAMPLE_bug, element);
          goto loop;
       }
 
@@ -1312,7 +1380,7 @@ void synchro_2(void)
        case Zplayer:
          Cave[y][x] = Ytank_n_w;
          Next[y][x] = Xtank_gow;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
 
        default:
@@ -1344,7 +1412,7 @@ void synchro_2(void)
          if (Cave[y-2][x-1] == Xblank)
            Cave[y-2][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -1357,13 +1425,13 @@ void synchro_2(void)
          Cave[y-1][x] = Ytank_n;
          Next[y][x] = Xblank;
          Next[y-1][x] = Xtank_n;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
 
        default:
          Cave[y][x] = Ytank_n_e;
          Next[y][x] = Xtank_goe;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
       }
 
@@ -1394,7 +1462,7 @@ void synchro_2(void)
        case Zplayer:
          Cave[y][x] = Ytank_e_n;
          Next[y][x] = Xtank_gon;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
 
        default:
@@ -1426,7 +1494,7 @@ void synchro_2(void)
          if (Cave[y-1][x] == Xblank)
            Cave[y-1][x] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -1439,13 +1507,13 @@ void synchro_2(void)
          Cave[y][x+1] = Ytank_e;
          Next[y][x] = Xblank;
          Next[y][x+1] = Xtank_e;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
 
        default:
          Cave[y][x] = Ytank_e_s;
          Next[y][x] = Xtank_gos;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
       }
 
@@ -1476,7 +1544,7 @@ void synchro_2(void)
        case Zplayer:
          Cave[y][x] = Ytank_s_e;
          Next[y][x] = Xtank_goe;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
 
        default:
@@ -1508,7 +1576,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -1521,13 +1589,13 @@ void synchro_2(void)
          Cave[y+1][x] = Ytank_s;
          Next[y][x] = Xblank;
          Next[y+1][x] = Xtank_s;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
 
        default:
          Cave[y][x] = Ytank_s_w;
          Next[y][x] = Xtank_gow;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
       }
 
@@ -1558,7 +1626,7 @@ void synchro_2(void)
        case Zplayer:
          Cave[y][x] = Ytank_w_s;
          Next[y][x] = Xtank_gos;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
 
        default:
@@ -1590,7 +1658,7 @@ void synchro_2(void)
          if (Cave[y-1][x-2] == Xblank)
            Cave[y-1][x-2] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -1603,13 +1671,13 @@ void synchro_2(void)
          Cave[y][x-1] = Ytank_w;
          Next[y][x] = Xblank;
          Next[y][x-1] = Xtank_w;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
 
        default:
          Cave[y][x] = Ytank_w_n;
          Next[y][x] = Xtank_gon;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_tank, element);
          goto loop;
       }
 
@@ -1724,8 +1792,8 @@ void synchro_2(void)
            goto android_move;
        }
 
-       Next[y][x] = temp; /* the item we chose to clone */
-       play_sound(x, y, SAMPLE_android);
+       Next[y][x] = temp;      /* the item we chose to clone */
+       play_element_sound(x, y, SAMPLE_android_clone, temp);
 
        switch (RANDOM & 7)
        {
@@ -1834,6 +1902,12 @@ void synchro_2(void)
            Cave[y+1][x+1] == Zplayer)
          goto android_still;
 
+#if 1
+
+       set_nearest_player_xy(x, y, &dx, &dy);
+
+#else
+
        if (ply1.alive && ply2.alive)
        {
          if ((ply1.x > x ? ply1.x - x : x - ply1.x) +
@@ -1866,7 +1940,9 @@ void synchro_2(void)
          dy = 0;
        }
 
-       Next[y][x] = Xblank; /* assume we will move */
+#endif
+
+       Next[y][x] = Xblank;    /* assume we will move */
        temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
 
        if (RANDOM & 1)
@@ -1997,7 +2073,7 @@ void synchro_2(void)
       Cave[y][x] = Yandroid_nB;
       Cave[y-1][x] = Yandroid_n;
       Next[y-1][x] = Xandroid;
-      play_sound(x, y, SAMPLE_tank);
+      play_element_sound(x, y, SAMPLE_android_move, element);
       goto loop;
 
     android_ne:
@@ -2005,7 +2081,7 @@ void synchro_2(void)
       Cave[y][x] = Yandroid_neB;
       Cave[y-1][x+1] = Yandroid_ne;
       Next[y-1][x+1] = Xandroid;
-      play_sound(x, y, SAMPLE_tank);
+      play_element_sound(x, y, SAMPLE_android_move, element);
       goto loop;
 
     android_e:
@@ -2013,7 +2089,7 @@ void synchro_2(void)
       Cave[y][x] = Yandroid_eB;
       Cave[y][x+1] = Yandroid_e;
       Next[y][x+1] = Xandroid;
-      play_sound(x, y, SAMPLE_tank);
+      play_element_sound(x, y, SAMPLE_android_move, element);
       goto loop;
 
     android_se:
@@ -2021,7 +2097,7 @@ void synchro_2(void)
       Cave[y][x] = Yandroid_seB;
       Cave[y+1][x+1] = Yandroid_se;
       Next[y+1][x+1] = Xandroid;
-      play_sound(x, y, SAMPLE_tank);
+      play_element_sound(x, y, SAMPLE_android_move, element);
       goto loop;
 
     android_s:
@@ -2029,7 +2105,7 @@ void synchro_2(void)
       Cave[y][x] = Yandroid_sB;
       Cave[y+1][x] = Yandroid_s;
       Next[y+1][x] = Xandroid;
-      play_sound(x, y, SAMPLE_tank);
+      play_element_sound(x, y, SAMPLE_android_move, element);
       goto loop;
 
     android_sw:
@@ -2037,7 +2113,7 @@ void synchro_2(void)
       Cave[y][x] = Yandroid_swB;
       Cave[y+1][x-1] = Yandroid_sw;
       Next[y+1][x-1] = Xandroid;
-      play_sound(x, y, SAMPLE_tank);
+      play_element_sound(x, y, SAMPLE_android_move, element);
       goto loop;
 
     android_w:
@@ -2045,7 +2121,7 @@ void synchro_2(void)
       Cave[y][x] = Yandroid_wB;
       Cave[y][x-1] = Yandroid_w;
       Next[y][x-1] = Xandroid;
-      play_sound(x, y, SAMPLE_tank);
+      play_element_sound(x, y, SAMPLE_android_move, element);
       goto loop;
 
     android_nw:
@@ -2053,7 +2129,7 @@ void synchro_2(void)
       Cave[y][x] = Yandroid_nwB;
       Cave[y-1][x-1] = Yandroid_nw;
       Next[y-1][x-1] = Xandroid;
-      play_sound(x, y, SAMPLE_tank);
+      play_element_sound(x, y, SAMPLE_android_move, element);
       goto loop;
 
     /* --------------------------------------------------------------------- */
@@ -2075,7 +2151,7 @@ void synchro_2(void)
          if (Cave[y-2][x-1] == Xblank)
            Cave[y-2][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2085,7 +2161,7 @@ void synchro_2(void)
          Cave[y-1][x] = Yandroid_n;
          Next[y][x] = Xblank;
          Next[y-1][x] = Xandroid;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_android_move, element);
          goto loop;
 
        default:
@@ -2109,7 +2185,7 @@ void synchro_2(void)
          if (Cave[y-2][x-1] == Xblank)
            Cave[y-2][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2119,7 +2195,7 @@ void synchro_2(void)
          Cave[y-1][x] = Yandroid_n;
          Next[y][x] = Xblank;
          Next[y-1][x] = Xandroid_1_n;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_android_move, element);
          goto loop;
 
        default:
@@ -2145,7 +2221,7 @@ void synchro_2(void)
          if (Cave[y-1][x] == Xblank)
            Cave[y-1][x] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2155,7 +2231,7 @@ void synchro_2(void)
          Cave[y][x+1] = Yandroid_e;
          Next[y][x] = Xblank;
          Next[y][x+1] = Xandroid;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_android_move, element);
          goto loop;
 
        default:
@@ -2179,7 +2255,7 @@ void synchro_2(void)
          if (Cave[y-1][x] == Xblank)
            Cave[y-1][x] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2189,7 +2265,7 @@ void synchro_2(void)
          Cave[y][x+1] = Yandroid_e;
          Next[y][x] = Xblank;
          Next[y][x+1] = Xandroid_1_e;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_android_move, element);
          goto loop;
 
        default:
@@ -2215,7 +2291,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2225,7 +2301,7 @@ void synchro_2(void)
          Cave[y+1][x] = Yandroid_s;
          Next[y][x] = Xblank;
          Next[y+1][x] = Xandroid;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_android_move, element);
          goto loop;
 
        default:
@@ -2249,7 +2325,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2259,7 +2335,7 @@ void synchro_2(void)
          Cave[y+1][x] = Yandroid_s;
          Next[y][x] = Xblank;
          Next[y+1][x] = Xandroid_1_s;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_android_move, element);
          goto loop;
 
        default:
@@ -2285,7 +2361,7 @@ void synchro_2(void)
          if (Cave[y-1][x-2] == Xblank)
            Cave[y-1][x-2] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2295,7 +2371,7 @@ void synchro_2(void)
          Cave[y][x-1] = Yandroid_w;
          Next[y][x] = Xblank;
          Next[y][x-1] = Xandroid;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_android_move, element);
          goto loop;
 
        default:
@@ -2319,7 +2395,7 @@ void synchro_2(void)
          if (Cave[y-1][x-2] == Xblank)
            Cave[y-1][x-2] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2329,7 +2405,7 @@ void synchro_2(void)
          Cave[y][x-1] = Yandroid_w;
          Next[y][x] = Xblank;
          Next[y][x-1] = Xandroid_1_w;
-         play_sound(x, y, SAMPLE_tank);
+         play_element_sound(x, y, SAMPLE_android_move, element);
          goto loop;
 
        default:
@@ -2355,7 +2431,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2509,7 +2585,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2546,7 +2622,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2578,7 +2654,7 @@ void synchro_2(void)
          if (Cave[y-1][x] == Xblank)
            Cave[y-1][x] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2604,7 +2680,7 @@ void synchro_2(void)
          Cave[y][x+1] = Yspring_kill_e;
          Next[y][x] = Xblank;
          Next[y][x+1] = Xspring_e;
-         play_sound(x, y, SAMPLE_slurp);
+         play_element_sound(x, y, SAMPLE_slurp, Xalien);
          score += lev.slurp_score;
          goto loop;
 
@@ -2612,13 +2688,13 @@ void synchro_2(void)
        case XbumperB:
          Cave[y][x+1] = XbumperB;
          Next[y][x] = Xspring_w;
-         play_sound(x, y, SAMPLE_spring);
+         play_element_sound(x, y, SAMPLE_spring, Xspring);
          goto loop;
 
        default:
          Cave[y][x] = Xspring;
          Next[y][x] = Xspring;
-         play_sound(x, y, SAMPLE_spring);
+         play_element_sound(x, y, SAMPLE_spring, Xspring);
          goto loop;
       }
 
@@ -2641,7 +2717,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2673,7 +2749,7 @@ void synchro_2(void)
          if (Cave[y-1][x-2] == Xblank)
            Cave[y-1][x-2] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2699,7 +2775,7 @@ void synchro_2(void)
          Cave[y][x-1] = Yspring_kill_w;
          Next[y][x] = Xblank;
          Next[y][x-1] = Xspring_w;
-         play_sound(x, y, SAMPLE_slurp);
+         play_element_sound(x, y, SAMPLE_slurp, Xalien);
          score += lev.slurp_score;
          goto loop;
 
@@ -2707,13 +2783,13 @@ void synchro_2(void)
        case XbumperB:
          Cave[y][x-1] = XbumperB;
          Next[y][x] = Xspring_e;
-         play_sound(x, y, SAMPLE_spring);
+         play_element_sound(x, y, SAMPLE_spring, Xspring);
          goto loop;
 
        default:
          Cave[y][x] = Xspring;
          Next[y][x] = Xspring;
-         play_sound(x, y, SAMPLE_spring);
+         play_element_sound(x, y, SAMPLE_spring, Xspring);
          goto loop;
       }
 
@@ -2736,7 +2812,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2762,6 +2838,9 @@ void synchro_2(void)
          Boom[y+2][x-1] = Xblank;
          Boom[y+2][x] = Xblank;
          Boom[y+2][x+1] = Xblank;
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          goto loop;
 
        case Xbug_n:
@@ -2784,6 +2863,9 @@ void synchro_2(void)
          Boom[y+2][x-1] = Xemerald;
          Boom[y+2][x] = Xemerald;
          Boom[y+2][x+1] = Xemerald;
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          score += lev.bug_score;
          goto loop;
 
@@ -2807,6 +2889,9 @@ void synchro_2(void)
          Boom[y+2][x-1] = Xblank;
          Boom[y+2][x] = Xblank;
          Boom[y+2][x+1] = Xblank;
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          score += lev.tank_score;
          goto loop;
 
@@ -2826,6 +2911,9 @@ void synchro_2(void)
          Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
          Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
          Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          lev.eater_pos = (lev.eater_pos + 1) & 7;
          score += lev.eater_score;
          goto loop;
@@ -2844,13 +2932,16 @@ void synchro_2(void)
          Boom[y+2][x-1] = Xblank;
          Boom[y+2][x] = Xblank;
          Boom[y+2][x+1] = Xblank;
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          score += lev.alien_score;
          goto loop;
 
        default:
          Cave[y][x] = Xspring;
          Next[y][x] = Xspring;
-         play_sound(x, y, SAMPLE_spring);
+         play_element_sound(x, y, SAMPLE_spring, Xspring);
          goto loop;
       }
 
@@ -2861,7 +2952,7 @@ void synchro_2(void)
       {
        Cave[y][x+1] = Ydiamond_eat;
        Next[y][x+1] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -2869,7 +2960,7 @@ void synchro_2(void)
       {
        Cave[y+1][x] = Ydiamond_eat;
        Next[y+1][x] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -2877,7 +2968,7 @@ void synchro_2(void)
       {
        Cave[y][x-1] = Ydiamond_eat;
        Next[y][x-1] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -2885,7 +2976,7 @@ void synchro_2(void)
       {
        Cave[y-1][x] = Ydiamond_eat;
        Next[y-1][x] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -2905,7 +2996,7 @@ void synchro_2(void)
          if (Cave[y-2][x-1] == Xblank)
            Cave[y-2][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2922,7 +3013,7 @@ void synchro_2(void)
 
        default:
          Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
-         play_sound(x, y, SAMPLE_eater);
+         play_element_sound(x, y, SAMPLE_eater, element);
          goto loop;
       }
 
@@ -2933,7 +3024,7 @@ void synchro_2(void)
       {
        Cave[y+1][x] = Ydiamond_eat;
        Next[y+1][x] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -2941,7 +3032,7 @@ void synchro_2(void)
       {
        Cave[y][x-1] = Ydiamond_eat;
        Next[y][x-1] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -2949,7 +3040,7 @@ void synchro_2(void)
       {
        Cave[y-1][x] = Ydiamond_eat;
        Next[y-1][x] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -2957,7 +3048,7 @@ void synchro_2(void)
       {
        Cave[y][x+1] = Ydiamond_eat;
        Next[y][x+1] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -2977,7 +3068,7 @@ void synchro_2(void)
          if (Cave[y-1][x] == Xblank)
            Cave[y-1][x] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -2994,7 +3085,7 @@ void synchro_2(void)
 
        default:
          Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
-         play_sound(x, y, SAMPLE_eater);
+         play_element_sound(x, y, SAMPLE_eater, element);
          goto loop;
       }
 
@@ -3005,7 +3096,7 @@ void synchro_2(void)
       {
        Cave[y][x-1] = Ydiamond_eat;
        Next[y][x-1] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -3013,7 +3104,7 @@ void synchro_2(void)
       {
        Cave[y-1][x] = Ydiamond_eat;
        Next[y-1][x] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -3021,7 +3112,7 @@ void synchro_2(void)
       {
        Cave[y][x+1] = Ydiamond_eat;
        Next[y][x+1] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -3029,7 +3120,7 @@ void synchro_2(void)
       {
        Cave[y+1][x] = Ydiamond_eat;
        Next[y+1][x] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -3049,7 +3140,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -3066,7 +3157,7 @@ void synchro_2(void)
 
        default:
          Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
-         play_sound(x, y, SAMPLE_eater);
+         play_element_sound(x, y, SAMPLE_eater, element);
          goto loop;
       }
 
@@ -3077,7 +3168,7 @@ void synchro_2(void)
       {
        Cave[y-1][x] = Ydiamond_eat;
        Next[y-1][x] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -3085,7 +3176,7 @@ void synchro_2(void)
       {
        Cave[y][x+1] = Ydiamond_eat;
        Next[y][x+1] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -3093,7 +3184,7 @@ void synchro_2(void)
       {
        Cave[y+1][x] = Ydiamond_eat;
        Next[y+1][x] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -3101,7 +3192,7 @@ void synchro_2(void)
       {
        Cave[y][x-1] = Ydiamond_eat;
        Next[y][x-1] = Xblank;
-       play_element_sound(x, y, SAMPLE_eater, Xdiamond);
+       play_element_sound(x, y, SAMPLE_eater_eat, element);
        goto loop;
       }
 
@@ -3121,7 +3212,7 @@ void synchro_2(void)
          if (Cave[y-1][x-2] == Xblank)
            Cave[y-1][x-2] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -3138,13 +3229,28 @@ void synchro_2(void)
 
        default:
          Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
-         play_sound(x, y, SAMPLE_eater);
+         play_element_sound(x, y, SAMPLE_eater, element);
          goto loop;
       }
 
     /* --------------------------------------------------------------------- */
 
     case Xalien:
+
+#if 1
+
+      if (lev.wheel_cnt)
+      {
+       dx = lev.wheel_x;
+       dy = lev.wheel_y;
+      }
+      else
+      {
+       set_nearest_player_xy(x, y, &dx, &dy);
+      }
+
+#else
+
       if (lev.wheel_cnt)
       {
        dx = lev.wheel_x;
@@ -3182,6 +3288,8 @@ void synchro_2(void)
        dy = 0;
       }
 
+#endif
+
       if (RANDOM & 1)
       {
        if (y > dy)
@@ -3202,7 +3310,7 @@ void synchro_2(void)
              if (Cave[y-2][x-1] == Xblank)
                Cave[y-2][x-1] = Yacid_splash_wB;
              Next[y][x] = Xblank;
-             play_sound(x, y, SAMPLE_acid);
+             play_element_sound(x, y, SAMPLE_acid, Xacid_1);
              goto loop;
 
            case Xblank:
@@ -3215,7 +3323,7 @@ void synchro_2(void)
              Cave[y-1][x] = Yalien_n;
              Next[y][x] = Xblank;
              Next[y-1][x] = Xalien_pause;
-             play_sound(x, y, SAMPLE_alien);
+             play_element_sound(x, y, SAMPLE_alien, Xalien);
              goto loop;
          }
        }
@@ -3237,7 +3345,7 @@ void synchro_2(void)
                Cave[y][x+1] = Yacid_splash_eB;
              if (Cave[y][x-1] == Xblank)
                Cave[y][x-1] = Yacid_splash_wB;
-             play_sound(x, y, SAMPLE_acid);
+             play_element_sound(x, y, SAMPLE_acid, Xacid_1);
              goto loop;
 
            case Xblank:
@@ -3250,7 +3358,7 @@ void synchro_2(void)
              Cave[y+1][x] = Yalien_s;
              Next[y][x] = Xblank;
              Next[y+1][x] = Xalien_pause;
-             play_sound(x, y, SAMPLE_alien);
+             play_element_sound(x, y, SAMPLE_alien, Xalien);
              goto loop;
          }
        }
@@ -3275,7 +3383,7 @@ void synchro_2(void)
              if (Cave[y-1][x] == Xblank)
                Cave[y-1][x] = Yacid_splash_wB;
              Next[y][x] = Xblank;
-             play_sound(x, y, SAMPLE_acid);
+             play_element_sound(x, y, SAMPLE_acid, Xacid_1);
              goto loop;
 
            case Xblank:
@@ -3288,7 +3396,7 @@ void synchro_2(void)
              Cave[y][x+1] = Yalien_e;
              Next[y][x] = Xblank;
              Next[y][x+1] = Xalien_pause;
-             play_sound(x, y, SAMPLE_alien);
+             play_element_sound(x, y, SAMPLE_alien, Xalien);
              goto loop;
          }
        }
@@ -3310,7 +3418,7 @@ void synchro_2(void)
              if (Cave[y-1][x-2] == Xblank)
                Cave[y-1][x-2] = Yacid_splash_wB;
              Next[y][x] = Xblank;
-             play_sound(x, y, SAMPLE_acid);
+             play_element_sound(x, y, SAMPLE_acid, Xacid_1);
              goto loop;
 
            case Xblank:
@@ -3323,7 +3431,7 @@ void synchro_2(void)
              Cave[y][x-1] = Yalien_w;
              Next[y][x] = Xblank;
              Next[y][x-1] = Xalien_pause;
-             play_sound(x, y, SAMPLE_alien);
+             play_element_sound(x, y, SAMPLE_alien, Xalien);
              goto loop;
          }
        }
@@ -3354,7 +3462,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -3489,7 +3597,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -3526,7 +3634,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -3551,7 +3659,7 @@ void synchro_2(void)
            }
 
            Next[y][x] = Xblank;
-           play_element_sound(x, y, SAMPLE_wonderfall, Xemerald);
+           play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
            goto loop;
          }
 
@@ -3581,7 +3689,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -3716,7 +3824,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -3753,7 +3861,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -3778,7 +3886,7 @@ void synchro_2(void)
            }
 
            Next[y][x] = Xblank;
-           play_element_sound(x, y, SAMPLE_wonderfall, Xdiamond);
+           play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
            goto loop;
          }
 
@@ -3808,7 +3916,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xdrip_stretchB;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -3861,7 +3969,7 @@ void synchro_2(void)
 
          Cave[y][x] = temp;
          Next[y][x] = temp;
-         play_sound(x, y, SAMPLE_drip);
+         play_element_sound(x, y, SAMPLE_drip, Xdrip_fall);
          goto loop;
       }
 
@@ -3900,7 +4008,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -4020,7 +4128,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -4057,7 +4165,7 @@ void synchro_2(void)
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xblank;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
 
        case Xblank:
@@ -4081,6 +4189,9 @@ void synchro_2(void)
          Boom[y+1][x-1] = Xblank;
          Boom[y+1][x] = Xblank;
          Boom[y+1][x+1] = Xblank;
+#if PLAY_ELEMENT_SOUND
+         play_element_sound(x, y, SAMPLE_boom, element);
+#endif
          goto loop;
       }
 
@@ -4109,7 +4220,7 @@ void synchro_2(void)
              if (Cave[y-2][x-1] == Xblank)
                Cave[y-2][x-1] = Yacid_splash_wB;
              Next[y][x] = Xblank;
-             play_sound(x, y, SAMPLE_acid);
+             play_element_sound(x, y, SAMPLE_acid, Xacid_1);
              goto loop;
 
            case Xblank:
@@ -4142,7 +4253,7 @@ void synchro_2(void)
              if (Cave[y-1][x] == Xblank)
                Cave[y-1][x] = Yacid_splash_wB;
              Next[y][x] = Xblank;
-             play_sound(x, y, SAMPLE_acid);
+             play_element_sound(x, y, SAMPLE_acid, Xacid_1);
              goto loop;
 
            case Xblank:
@@ -4175,7 +4286,7 @@ void synchro_2(void)
              if (Cave[y][x-1] == Xblank)
                Cave[y][x-1] = Yacid_splash_wB;
              Next[y][x] = Xblank;
-             play_sound(x, y, SAMPLE_acid);
+             play_element_sound(x, y, SAMPLE_acid, Xacid_1);
              goto loop;
 
            case Xblank:
@@ -4208,7 +4319,7 @@ void synchro_2(void)
              if (Cave[y-1][x-2] == Xblank)
                Cave[y-1][x-2] = Yacid_splash_wB;
              Next[y][x] = Xblank;
-             play_sound(x, y, SAMPLE_acid);
+             play_element_sound(x, y, SAMPLE_acid, Xacid_1);
              goto loop;
 
            case Xblank:
@@ -4259,6 +4370,38 @@ void synchro_2(void)
       Next[y][x] = Xacid_1;
       goto loop;
 
+    case Xfake_acid_1:
+      Next[y][x] = Xfake_acid_2;
+      goto loop;
+
+    case Xfake_acid_2:
+      Next[y][x] = Xfake_acid_3;
+      goto loop;
+
+    case Xfake_acid_3:
+      Next[y][x] = Xfake_acid_4;
+      goto loop;
+
+    case Xfake_acid_4:
+      Next[y][x] = Xfake_acid_5;
+      goto loop;
+
+    case Xfake_acid_5:
+      Next[y][x] = Xfake_acid_6;
+      goto loop;
+
+    case Xfake_acid_6:
+      Next[y][x] = Xfake_acid_7;
+      goto loop;
+
+    case Xfake_acid_7:
+      Next[y][x] = Xfake_acid_8;
+      goto loop;
+
+    case Xfake_acid_8:
+      Next[y][x] = Xfake_acid_1;
+      goto loop;
+
     /* --------------------------------------------------------------------- */
 
     case Xball_1:
@@ -4422,7 +4565,11 @@ void synchro_2(void)
        }
       }
 
+#if 1
+      lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
+#else
       lev.ball_pos = (lev.ball_pos + 1) & 7;
+#endif
       goto loop;
 
     /* --------------------------------------------------------------------- */
@@ -4432,14 +4579,14 @@ void synchro_2(void)
       {
        Cave[y-1][x] = Ygrow_ns_eat;
        Next[y-1][x] = Xgrow_ns;
-       play_sound(x, y, SAMPLE_grow);
+       play_element_sound(x, y, SAMPLE_grow, Xgrow_ns);
       }
 
       if (tab_blank[Cave[y+1][x]])
       {
        Cave[y+1][x] = Ygrow_ns_eat;
        Next[y+1][x] = Xgrow_ns;
-       play_sound(x, y, SAMPLE_grow);
+       play_element_sound(x, y, SAMPLE_grow, Xgrow_ns);
       }
 
       goto loop;
@@ -4449,14 +4596,14 @@ void synchro_2(void)
       {
        Cave[y][x+1] = Ygrow_ew_eat;
        Next[y][x+1] = Xgrow_ew;
-       play_sound(x, y, SAMPLE_grow);
+       play_element_sound(x, y, SAMPLE_grow, Xgrow_ew);
       }
 
       if (tab_blank[Cave[y][x-1]])
       {
        Cave[y][x-1] = Ygrow_ew_eat;
        Next[y][x-1] = Xgrow_ew;
-       play_sound(x, y, SAMPLE_grow);
+       play_element_sound(x, y, SAMPLE_grow, Xgrow_ew);
       }
 
       goto loop;
@@ -4467,7 +4614,7 @@ void synchro_2(void)
       if (lev.wonderwall_time && lev.wonderwall_state)
       {
        Cave[y][x] = XwonderwallB;
-       play_sound(x, y, SAMPLE_wonder);
+       play_element_sound(x, y, SAMPLE_wonder, Xwonderwall);
       }
 
       goto loop;
@@ -4495,6 +4642,8 @@ void synchro_2(void)
        Next[y][x] = Xexit_1;
       }
 
+      play_element_sound(x, y, SAMPLE_exit_open, Xexit);
+
       goto loop;
 
     case Xexit_1:
@@ -4512,22 +4661,22 @@ void synchro_2(void)
     /* --------------------------------------------------------------------- */
 
     case Xdynamite_1:
-      play_sound(x, y, SAMPLE_tick);
+      play_element_sound(x, y, SAMPLE_tick, Xdynamite_1);
       Next[y][x] = Xdynamite_2;
       goto loop;
 
     case Xdynamite_2:
-      play_sound(x, y, SAMPLE_tick);
+      play_element_sound(x, y, SAMPLE_tick, Xdynamite_2);
       Next[y][x] = Xdynamite_3;
       goto loop;
 
     case Xdynamite_3:
-      play_sound(x, y, SAMPLE_tick);
+      play_element_sound(x, y, SAMPLE_tick, Xdynamite_3);
       Next[y][x] = Xdynamite_4;
       goto loop;
 
     case Xdynamite_4:
-      play_sound(x, y, SAMPLE_tick);
+      play_element_sound(x, y, SAMPLE_tick, Xdynamite_4);
       Next[y][x] = Zdynamite;
       Boom[y-1][x-1] = Xblank;
       Boom[y-1][x] = Xblank;
@@ -4567,23 +4716,42 @@ void synchro_2(void)
        case Xacid_6:
        case Xacid_7:
        case Xacid_8:
+#if 1
+         Cave[y][x] = Xsand_stonesand_quickout_1;
+         if (Cave[y][x+1] == Xblank)
+           Cave[y][x+1] = Yacid_splash_eB;
+         if (Cave[y][x-1] == Xblank)
+           Cave[y][x-1] = Yacid_splash_wB;
+         Next[y][x] = Xsand_stonesand_quickout_2;
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
+         goto loop;
+#else
          Cave[y][x] = Xsand_stonesand_3;
          if (Cave[y][x+1] == Xblank)
            Cave[y][x+1] = Yacid_splash_eB;
          if (Cave[y][x-1] == Xblank)
            Cave[y][x-1] = Yacid_splash_wB;
          Next[y][x] = Xsand_stonesand_4;
-         play_sound(x, y, SAMPLE_acid);
+         play_element_sound(x, y, SAMPLE_acid, Xacid_1);
          goto loop;
+#endif
 
        case Xblank:
        case Yacid_splash_eB:
        case Yacid_splash_wB:
+#if 1
+         Cave[y][x] = Xsand_stonesand_quickout_1;
+         Cave[y+1][x] = Xsand_stoneout_1;
+         Next[y][x] = Xsand_stonesand_quickout_2;
+         Next[y+1][x] = Xsand_stoneout_2;
+         goto loop;
+#else
          Cave[y][x] = Xsand_stonesand_3;
          Cave[y+1][x] = Xsand_stoneout_1;
          Next[y][x] = Xsand_stonesand_4;
          Next[y+1][x] = Xsand_stoneout_2;
          goto loop;
+#endif
 
        case Xsand:
          Cave[y][x] = Xsand_stonesand_1;
@@ -4628,6 +4796,16 @@ void synchro_2(void)
       Next[y][x] = Xsand;
       goto loop;
 
+#if 1
+    case Xsand_stonesand_quickout_1:
+      Next[y][x] = Xsand_stonesand_quickout_2;
+      goto loop;
+
+    case Xsand_stonesand_quickout_2:
+      Next[y][x] = Xsand;
+      goto loop;
+#endif
+
     case Xsand_stoneout_1:
       Next[y][x] = Xsand_stoneout_2;
       goto loop;
@@ -4729,6 +4907,9 @@ void synchro_2(void)
       Boom[y+1][x-1] = Xemerald;
       Boom[y+1][x] = Xemerald;
       Boom[y+1][x+1] = Xemerald;
+#if PLAY_ELEMENT_SOUND
+      play_element_sound(x, y, SAMPLE_boom, element);
+#endif
       goto loop;
 
     case Xboom_bomb:
@@ -4745,12 +4926,23 @@ void synchro_2(void)
       Boom[y+1][x-1] = Xblank;
       Boom[y+1][x] = Xblank;
       Boom[y+1][x+1] = Xblank;
+#if PLAY_ELEMENT_SOUND
+      play_element_sound(x, y, SAMPLE_boom, element);
+#endif
       goto loop;
 
     case Xboom_android:
+#if PLAY_ELEMENT_SOUND
+      play_element_sound(x, y, SAMPLE_boom, Xandroid);
+#endif
     case Xboom_1:
       Next[y][x] = Xboom_2;
-      play_sound(x, y, SAMPLE_boom);
+#if !PLAY_ELEMENT_SOUND
+      if (x != lev.exit_x && y != lev.exit_y)
+       play_sound(x, y, SAMPLE_boom);
+      else
+       lev.exit_x = lev.exit_y = -1;
+#endif
       goto loop;
 
     case Xboom_2:
@@ -4776,10 +4968,10 @@ void synchro_2(void)
 
  done:
 
-  if (ply1.alive || ply2.alive)
-    lev.score += score; /* only get a score if someone is alive */
+  if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
+    lev.score += score;                /* only add a score if someone is alive */
 
-  Random = random;
+  RandomEM = random;
 
   {
     void *temp = Cave;