improved readability of some condition checks in EM engine
[rocksndiamonds.git] / src / game_em / synchro_2.c
index 96a72fbc3ad40dc2235b06946b5408984b5a5115..687747350d4a4f750192c92245743fba8dbc5ccd 100644 (file)
 
 #define SPRING_ROLL    /* spring rolling off round things continues to roll */
 
-#define RANDOM (random_em = random_em << 31 | random_em >> 1)
+#define RANDOM_RAW     (seed = seed << 31 | seed >> 1)
+#define RANDOM(x)      (RANDOM_RAW & (x - 1))
 
-static unsigned int random_em;
+static unsigned int seed;
 static int score;
 
 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
@@ -95,7 +96,7 @@ static void Landroid(int x, int y)
        Cave[y+1][x+1] != Xblank)
       goto android_move;
 
-    switch (RANDOM & 7)
+    switch (RANDOM(8))
     {
       /* randomly find an object to clone */
 
@@ -191,7 +192,7 @@ static void Landroid(int x, int y)
     Next[y][x] = temp; /* the item we chose to clone */
     play_element_sound(x, y, SOUND_android_clone, temp);
 
-    switch (RANDOM & 7)
+    switch (RANDOM(8))
     {
       /* randomly find a direction to move */
 
@@ -303,7 +304,7 @@ static void Landroid(int x, int y)
     Next[y][x] = Xblank;       /* assume we will move */
     temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
 
-    if (RANDOM & 1)
+    if (RANDOM(2))
     {
       switch (temp)
       {
@@ -844,7 +845,7 @@ static void Leater_n(int x, int y)
       return;
 
     default:
-      Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
+      Next[y][x] = RANDOM(2) ? Xeater_e : Xeater_w;
       play_element_sound(x, y, SOUND_eater, Xeater_n);
       return;
   }
@@ -916,7 +917,7 @@ static void Leater_e(int x, int y)
       return;
 
     default:
-      Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
+      Next[y][x] = RANDOM(2) ? Xeater_n : Xeater_s;
       play_element_sound(x, y, SOUND_eater, Xeater_e);
       return;
   }
@@ -988,7 +989,7 @@ static void Leater_s(int x, int y)
       return;
 
     default:
-      Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
+      Next[y][x] = RANDOM(2) ? Xeater_e : Xeater_w;
       play_element_sound(x, y, SOUND_eater, Xeater_s);
       return;
   }
@@ -1060,7 +1061,7 @@ static void Leater_w(int x, int y)
       return;
 
     default:
-      Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
+      Next[y][x] = RANDOM(2) ? Xeater_n : Xeater_s;
       play_element_sound(x, y, SOUND_eater, Xeater_w);
       return;
   }
@@ -1080,7 +1081,7 @@ static void Lalien(int x, int y)
     set_nearest_player_xy(x, y, &dx, &dy);
   }
 
-  if (RANDOM & 1)
+  if (RANDOM(2))
   {
     if (y > dy)
     {
@@ -2084,7 +2085,7 @@ static void Lemerald(int x, int y)
     case Xroundwall_2:
     case Xroundwall_3:
     case Xroundwall_4:
-      if (RANDOM & 1)
+      if (RANDOM(2))
       {
        if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
        {
@@ -2128,7 +2129,7 @@ static void Lemerald(int x, int y)
     default:
       if (++lev.shine_cnt > 50)
       {
-       lev.shine_cnt = RANDOM & 7;
+       lev.shine_cnt = RANDOM(8);
        Cave[y][x] = Xemerald_shine;
       }
 
@@ -2311,7 +2312,7 @@ static void Ldiamond(int x, int y)
     case Xroundwall_2:
     case Xroundwall_3:
     case Xroundwall_4:
-      if (RANDOM & 1)
+      if (RANDOM(2))
       {
        if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
        {
@@ -2355,7 +2356,7 @@ static void Ldiamond(int x, int y)
     default:
       if (++lev.shine_cnt > 50)
       {
-       lev.shine_cnt = RANDOM & 7;
+       lev.shine_cnt = RANDOM(8);
        Cave[y][x] = Xdiamond_shine;
       }
 
@@ -2481,7 +2482,7 @@ static void Lstone(int x, int y)
     case Xacid_splash_w:
     case Xplant:
     case Yplant:
-#if 1
+#ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
     case Xfake_acid_1:
     case Xfake_acid_2:
     case Xfake_acid_3:
@@ -2550,7 +2551,7 @@ static void Lstone(int x, int y)
     case Xroundwall_2:
     case Xroundwall_3:
     case Xroundwall_4:
-      if (RANDOM & 1)
+      if (RANDOM(2))
       {
        if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
        {
@@ -2617,7 +2618,7 @@ static void Lstone_pause(int x, int y)
     case Xblank:
     case Xacid_splash_e:
     case Xacid_splash_w:
-#if 1
+#ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
     case Xfake_acid_1:
     case Xfake_acid_2:
     case Xfake_acid_3:
@@ -2665,7 +2666,7 @@ static void Lstone_fall(int x, int y)
     case Xacid_splash_e:
     case Xacid_splash_w:
     case Zplayer:
-#if 1
+#ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
     case Xfake_acid_1:
     case Xfake_acid_2:
     case Xfake_acid_3:
@@ -2743,7 +2744,7 @@ static void Lstone_fall(int x, int y)
       return;
 
     case Xspring:
-      if (RANDOM & 1)
+      if (RANDOM(2))
       {
        switch (Cave[y+1][x+1])
        {
@@ -3002,7 +3003,7 @@ static void Lbomb(int x, int y)
     case Xroundwall_2:
     case Xroundwall_3:
     case Xroundwall_4:
-      if (RANDOM & 1)
+      if (RANDOM(2))
       {
        if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
        {
@@ -3205,7 +3206,7 @@ static void Lnut(int x, int y)
     case Xroundwall_2:
     case Xroundwall_3:
     case Xroundwall_4:
-      if (RANDOM & 1)
+      if (RANDOM(2))
       {
        if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
        {
@@ -3400,7 +3401,7 @@ static void Lspring(int x, int y)
     case Xroundwall_2:
     case Xroundwall_3:
     case Xroundwall_4:
-      if (RANDOM & 1)
+      if (RANDOM(2))
       {
        if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
        {
@@ -4289,7 +4290,7 @@ static void Lball_common(int x, int y)
 
   if (lev.ball_random)
   {
-    switch (RANDOM & 7)
+    switch (RANDOM(8))
     {
       case 0:
        if (lev.ball_array[lev.ball_pos][0] != Xblank &&
@@ -4493,39 +4494,16 @@ static void Ldrip_fall(int x, int y)
       return;
 
     default:
-      switch (RANDOM & 7)
+      switch (RANDOM(8))
       {
-       case 0:
-         temp = Xamoeba_1;
-         break;
-
-       case 1:
-         temp = Xamoeba_2;
-         break;
-
-       case 2:
-         temp = Xamoeba_3;
-         break;
-
-       case 3:
-         temp = Xamoeba_4;
-         break;
-
-       case 4:
-         temp = Xamoeba_5;
-         break;
-
-       case 5:
-         temp = Xamoeba_6;
-         break;
-
-       case 6:
-         temp = Xamoeba_7;
-         break;
-
-       case 7:
-         temp = Xamoeba_8;
-         break;
+       case 0: temp = Xamoeba_1; break;
+       case 1: temp = Xamoeba_2; break;
+       case 2: temp = Xamoeba_3; break;
+       case 3: temp = Xamoeba_4; break;
+       case 4: temp = Xamoeba_5; break;
+       case 5: temp = Xamoeba_6; break;
+       case 6: temp = Xamoeba_7; break;
+       case 7: temp = Xamoeba_8; break;
       }
 
       Cave[y][x] = temp;
@@ -4635,7 +4613,7 @@ static void Lsand_stonesand_4(int x, int y)
   Next[y][x] = Xsand;
 }
 
-#if 1
+#ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
 static void Lsand_stonesand_quickout_1(int x, int y)
 {
   Next[y][x] = Xsand_stonesand_quickout_2;
@@ -4716,22 +4694,22 @@ static void Lexit(int x, int y)
   if (lev.required > 0)
     return;
 
-  int temp = RANDOM & 63;
-
-  if (temp < 21)
-  {
-    Cave[y][x] = Xexit_1;
-    Next[y][x] = Xexit_2;
-  }
-  else if (temp < 42)
-  {
-    Cave[y][x] = Xexit_2;
-    Next[y][x] = Xexit_3;
-  }
-  else
+  switch (RANDOM(64) / 21)
   {
-    Cave[y][x] = Xexit_3;
-    Next[y][x] = Xexit_1;
+    case 0:
+      Cave[y][x] = Xexit_1;
+      Next[y][x] = Xexit_2;
+      break;
+
+    case 1:
+      Cave[y][x] = Xexit_2;
+      Next[y][x] = Xexit_3;
+      break;
+
+    default:
+      Cave[y][x] = Xexit_3;
+      Next[y][x] = Xexit_1;
+      break;
   }
 
   play_element_sound(x, y, SOUND_exit_open, Xexit);
@@ -4792,6 +4770,7 @@ static void Lacid_8(int x, int y)
   Next[y][x] = Xacid_1;
 }
 
+#ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
 static void Lfake_acid_1(int x, int y)
 {
   Next[y][x] = Xfake_acid_2;
@@ -4831,6 +4810,7 @@ static void Lfake_acid_8(int x, int y)
 {
   Next[y][x] = Xfake_acid_1;
 }
+#endif
 
 static void Lpause(int x, int y)
 {
@@ -4980,7 +4960,7 @@ void synchro_2(void)
   short *cave_cache = Cave[y]; /* might be a win */
   int element;
 
-  random_em = RandomEM;
+  seed = RandomEM;
   score = 0;
 
  loop:
@@ -4989,658 +4969,170 @@ void synchro_2(void)
 
   switch (element)
   {
-    default:
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xpush_stone_e:
-      Lpush_stone_e(x, y);
-      goto loop;
-
-    case Xpush_stone_w:
-      Lpush_stone_w(x, y);
-      goto loop;
-
-    case Xpush_nut_e:
-      Lpush_nut_e(x, y);
-      goto loop;
-
-    case Xpush_nut_w:
-      Lpush_nut_w(x, y);
-      goto loop;
-
-    case Xpush_spring_e:
-      Lpush_spring_e(x, y);
-      goto loop;
-
-    case Xpush_spring_w:
-      Lpush_spring_w(x, y);
-      goto loop;
-
-    case Xpush_emerald_e:
-      Lpush_emerald_e(x, y);
-      goto loop;
-
-    case Xpush_emerald_w:
-      Lpush_emerald_w(x, y);
-      goto loop;
-
-    case Xpush_diamond_e:
-      Lpush_diamond_e(x, y);
-      goto loop;
-
-    case Xpush_diamond_w:
-      Lpush_diamond_w(x, y);
-      goto loop;
-
-    case Xpush_bomb_e:
-      Lpush_bomb_e(x, y);
-      goto loop;
-
-    case Xpush_bomb_w:
-      Lpush_bomb_w(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xstone:
-      Lstone(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xstone_pause:
-      Lstone_pause(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xstone_fall:
-      Lstone_fall(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xnut:
-      Lnut(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xnut_pause:
-      Lnut_pause(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xnut_fall:
-      Lnut_fall(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xbug_1_n:
-      Lbug_1_n(x, y);
-      goto loop;
-
-    case Xbug_2_n:
-      Lbug_2_n(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xbug_1_e:
-      Lbug_1_e(x, y);
-      goto loop;
-
-    case Xbug_2_e:
-      Lbug_2_e(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xbug_1_s:
-      Lbug_1_s(x, y);
-      goto loop;
-
-    case Xbug_2_s:
-      Lbug_2_s(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xbug_1_w:
-      Lbug_1_w(x, y);
-      goto loop;
-
-    case Xbug_2_w:
-      Lbug_2_w(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xtank_1_n:
-      Ltank_1_n(x, y);
-      goto loop;
-
-    case Xtank_2_n:
-      Ltank_2_n(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xtank_1_e:
-      Ltank_1_e(x, y);
-      goto loop;
-
-    case Xtank_2_e:
-      Ltank_2_e(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xtank_1_s:
-      Ltank_1_s(x, y);
-      goto loop;
-
-    case Xtank_2_s:
-      Ltank_2_s(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xtank_1_w:
-      Ltank_1_w(x, y);
-      goto loop;
-
-    case Xtank_2_w:
-      Ltank_2_w(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xandroid:
-      Landroid(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xandroid_1_n:
-      Landroid_1_n(x, y);
-      goto loop;
-
-    case Xandroid_2_n:
-      Landroid_2_n(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xandroid_1_e:
-      Landroid_1_e(x, y);
-      goto loop;
-
-    case Xandroid_2_e:
-      Landroid_2_e(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xandroid_1_s:
-      Landroid_1_s(x, y);
-      goto loop;
-
-    case Xandroid_2_s:
-      Landroid_2_s(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xandroid_1_w:
-      Landroid_1_w(x, y);
-      goto loop;
-
-    case Xandroid_2_w:
-      Landroid_2_w(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xspring:
-      Lspring(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xspring_pause:
-      Lspring_pause(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xspring_e:
-      Lspring_e(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xspring_w:
-      Lspring_w(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xspring_fall:
-      Lspring_fall(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xeater_n:
-      Leater_n(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xeater_e:
-      Leater_e(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xeater_s:
-      Leater_s(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xeater_w:
-      Leater_w(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xalien:
-      Lalien(x, y);
-      goto loop;
-
-    case Xalien_pause:
-      Lalien_pause(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xemerald:
-      Lemerald(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xemerald_pause:
-      Lemerald_pause(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xemerald_fall:
-      Lemerald_fall(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xdiamond:
-      Ldiamond(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xdiamond_pause:
-      Ldiamond_pause(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xdiamond_fall:
-      Ldiamond_fall(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xdrip_fall:
-      Ldrip_fall(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xdrip_stretch:
-      Ldrip_stretch(x, y);
-      goto loop;
-
-    case Xdrip_stretchB:
-      Ldrip_stretchB(x, y);
-      goto loop;
-
-    case Xdrip:
-      Ldrip(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xbomb:
-      Lbomb(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xbomb_pause:
-      Lbomb_pause(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xbomb_fall:
-      Lbomb_fall(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xballoon:
-      Lballoon(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xacid_1:
-      Lacid_1(x, y);
-      goto loop;
-
-    case Xacid_2:
-      Lacid_2(x, y);
-      goto loop;
-
-    case Xacid_3:
-      Lacid_3(x, y);
-      goto loop;
-
-    case Xacid_4:
-      Lacid_4(x, y);
-      goto loop;
-
-    case Xacid_5:
-      Lacid_5(x, y);
-      goto loop;
-
-    case Xacid_6:
-      Lacid_6(x, y);
-      goto loop;
-
-    case Xacid_7:
-      Lacid_7(x, y);
-      goto loop;
-
-    case Xacid_8:
-      Lacid_8(x, y);
-      goto loop;
-
-    case Xfake_acid_1:
-      Lfake_acid_1(x, y);
-      goto loop;
-
-    case Xfake_acid_2:
-      Lfake_acid_2(x, y);
-      goto loop;
-
-    case Xfake_acid_3:
-      Lfake_acid_3(x, y);
-      goto loop;
-
-    case Xfake_acid_4:
-      Lfake_acid_4(x, y);
-      goto loop;
-
-    case Xfake_acid_5:
-      Lfake_acid_5(x, y);
-      goto loop;
-
-    case Xfake_acid_6:
-      Lfake_acid_6(x, y);
-      goto loop;
-
-    case Xfake_acid_7:
-      Lfake_acid_7(x, y);
-      goto loop;
-
-    case Xfake_acid_8:
-      Lfake_acid_8(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xball_1:
-      Lball_1(x, y);
-      goto loop;
-
-    case Xball_2:
-      Lball_2(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xslidewall_ns:
-      Lslidewall_ns(x, y);
-      goto loop;
-
-    case Xslidewall_ew:
-      Lslidewall_ew(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xwonderwall:
-      Lwonderwall(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xexit:
-      Lexit(x, y);
-      goto loop;
-
-    case Xexit_1:
-      Lexit_1(x, y);
-      goto loop;
-
-    case Xexit_2:
-      Lexit_2(x, y);
-      goto loop;
-
-    case Xexit_3:
-      Lexit_3(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xpause:
-      Lpause(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xdynamite_1:
-      Ldynamite_1(x, y);
-      goto loop;
-
-    case Xdynamite_2:
-      Ldynamite_2(x, y);
-      goto loop;
-
-    case Xdynamite_3:
-      Ldynamite_3(x, y);
-      goto loop;
-
-    case Xdynamite_4:
-      Ldynamite_4(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xwheel:
-      Lwheel(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xswitch:
-      Lswitch(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xsand_stone:
-      Lsand_stone(x, y);
-      goto loop;
-
-    case Xsand_stonein_1:
-      Lsand_stonein_1(x, y);
-      goto loop;
-
-    case Xsand_stonein_2:
-      Lsand_stonein_2(x, y);
-      goto loop;
-
-    case Xsand_stonein_3:
-      Lsand_stonein_3(x, y);
-      goto loop;
-
-    case Xsand_stonein_4:
-      Lsand_stonein_4(x, y);
-      goto loop;
-
-    case Xsand_stonesand_1:
-      Lsand_stonesand_1(x, y);
-      goto loop;
-
-    case Xsand_stonesand_2:
-      Lsand_stonesand_2(x, y);
-      goto loop;
-
-    case Xsand_stonesand_3:
-      Lsand_stonesand_3(x, y);
-      goto loop;
-
-    case Xsand_stonesand_4:
-      Lsand_stonesand_4(x, y);
-      goto loop;
-
-#if 1
-    case Xsand_stonesand_quickout_1:
-      Lsand_stonesand_quickout_1(x, y);
-      goto loop;
-
-    case Xsand_stonesand_quickout_2:
-      Lsand_stonesand_quickout_2(x, y);
-      goto loop;
+    case Xacid_1:              Lacid_1(x, y);                  goto loop;
+    case Xacid_2:              Lacid_2(x, y);                  goto loop;
+    case Xacid_3:              Lacid_3(x, y);                  goto loop;
+    case Xacid_4:              Lacid_4(x, y);                  goto loop;
+    case Xacid_5:              Lacid_5(x, y);                  goto loop;
+    case Xacid_6:              Lacid_6(x, y);                  goto loop;
+    case Xacid_7:              Lacid_7(x, y);                  goto loop;
+    case Xacid_8:              Lacid_8(x, y);                  goto loop;
+
+#ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
+    case Xfake_acid_1:         Lfake_acid_1(x, y);             goto loop;
+    case Xfake_acid_2:         Lfake_acid_2(x, y);             goto loop;
+    case Xfake_acid_3:         Lfake_acid_3(x, y);             goto loop;
+    case Xfake_acid_4:         Lfake_acid_4(x, y);             goto loop;
+    case Xfake_acid_5:         Lfake_acid_5(x, y);             goto loop;
+    case Xfake_acid_6:         Lfake_acid_6(x, y);             goto loop;
+    case Xfake_acid_7:         Lfake_acid_7(x, y);             goto loop;
+    case Xfake_acid_8:         Lfake_acid_8(x, y);             goto loop;
 #endif
 
-    case Xsand_stoneout_1:
-      Lsand_stoneout_1(x, y);
-      goto loop;
-
-    case Xsand_stoneout_2:
-      Lsand_stoneout_2(x, y);
-      goto loop;
-
-    case Xsand_sandstone_1:
-      Lsand_sandstone_1(x, y);
-      goto loop;
-
-    case Xsand_sandstone_2:
-      Lsand_sandstone_2(x, y);
-      goto loop;
-
-    case Xsand_sandstone_3:
-      Lsand_sandstone_3(x, y);
-      goto loop;
-
-    case Xsand_sandstone_4:
-      Lsand_sandstone_4(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xfake_amoeba:
-      Lfake_amoeba(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xfake_blank:
-      Lfake_blank(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xfake_grass:
-      Lfake_grass(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xfake_door_1:
-      Lfake_door_1(x, y);
-      goto loop;
-
-    case Xfake_door_2:
-      Lfake_door_2(x, y);
-      goto loop;
-
-    case Xfake_door_3:
-      Lfake_door_3(x, y);
-      goto loop;
-
-    case Xfake_door_4:
-      Lfake_door_4(x, y);
-      goto loop;
-
-    case Xfake_door_5:
-      Lfake_door_5(x, y);
-      goto loop;
-
-    case Xfake_door_6:
-      Lfake_door_6(x, y);
-      goto loop;
-
-    case Xfake_door_7:
-      Lfake_door_7(x, y);
-      goto loop;
-
-    case Xfake_door_8:
-      Lfake_door_8(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
-
-    case Xboom_bug:
-      Lboom_bug(x, y);
-      goto loop;
+    case Xandroid:             Landroid(x, y);                 goto loop;
+    case Xandroid_1_n:         Landroid_1_n(x, y);             goto loop;
+    case Xandroid_2_n:         Landroid_2_n(x, y);             goto loop;
+    case Xandroid_1_e:         Landroid_1_e(x, y);             goto loop;
+    case Xandroid_2_e:         Landroid_2_e(x, y);             goto loop;
+    case Xandroid_1_s:         Landroid_1_s(x, y);             goto loop;
+    case Xandroid_2_s:         Landroid_2_s(x, y);             goto loop;
+    case Xandroid_1_w:         Landroid_1_w(x, y);             goto loop;
+    case Xandroid_2_w:         Landroid_2_w(x, y);             goto loop;
+
+    case Xeater_n:             Leater_n(x, y);                 goto loop;
+    case Xeater_e:             Leater_e(x, y);                 goto loop;
+    case Xeater_s:             Leater_s(x, y);                 goto loop;
+    case Xeater_w:             Leater_w(x, y);                 goto loop;
+
+    case Xalien:               Lalien(x, y);                   goto loop;
+    case Xalien_pause:         Lalien_pause(x, y);             goto loop;
+
+    case Xbug_1_n:             Lbug_1_n(x, y);                 goto loop;
+    case Xbug_2_n:             Lbug_2_n(x, y);                 goto loop;
+    case Xbug_1_e:             Lbug_1_e(x, y);                 goto loop;
+    case Xbug_2_e:             Lbug_2_e(x, y);                 goto loop;
+    case Xbug_1_s:             Lbug_1_s(x, y);                 goto loop;
+    case Xbug_2_s:             Lbug_2_s(x, y);                 goto loop;
+    case Xbug_1_w:             Lbug_1_w(x, y);                 goto loop;
+    case Xbug_2_w:             Lbug_2_w(x, y);                 goto loop;
+
+    case Xtank_1_n:            Ltank_1_n(x, y);                goto loop;
+    case Xtank_2_n:            Ltank_2_n(x, y);                goto loop;
+    case Xtank_1_e:            Ltank_1_e(x, y);                goto loop;
+    case Xtank_2_e:            Ltank_2_e(x, y);                goto loop;
+    case Xtank_1_s:            Ltank_1_s(x, y);                goto loop;
+    case Xtank_2_s:            Ltank_2_s(x, y);                goto loop;
+    case Xtank_1_w:            Ltank_1_w(x, y);                goto loop;
+    case Xtank_2_w:            Ltank_2_w(x, y);                goto loop;
+
+    case Xemerald:             Lemerald(x, y);                 goto loop;
+    case Xemerald_pause:       Lemerald_pause(x, y);           goto loop;
+    case Xemerald_fall:                Lemerald_fall(x, y);            goto loop;
+
+    case Xdiamond:             Ldiamond(x, y);                 goto loop;
+    case Xdiamond_pause:       Ldiamond_pause(x, y);           goto loop;
+    case Xdiamond_fall:                Ldiamond_fall(x, y);            goto loop;
+
+    case Xstone:               Lstone(x, y);                   goto loop;
+    case Xstone_pause:         Lstone_pause(x, y);             goto loop;
+    case Xstone_fall:          Lstone_fall(x, y);              goto loop;
+
+    case Xbomb:                        Lbomb(x, y);                    goto loop;
+    case Xbomb_pause:          Lbomb_pause(x, y);              goto loop;
+    case Xbomb_fall:           Lbomb_fall(x, y);               goto loop;
+
+    case Xnut:                 Lnut(x, y);                     goto loop;
+    case Xnut_pause:           Lnut_pause(x, y);               goto loop;
+    case Xnut_fall:            Lnut_fall(x, y);                goto loop;
+
+    case Xspring:              Lspring(x, y);                  goto loop;
+    case Xspring_pause:                Lspring_pause(x, y);            goto loop;
+    case Xspring_e:            Lspring_e(x, y);                goto loop;
+    case Xspring_w:            Lspring_w(x, y);                goto loop;
+    case Xspring_fall:         Lspring_fall(x, y);             goto loop;
+
+    case Xpush_emerald_e:      Lpush_emerald_e(x, y);          goto loop;
+    case Xpush_emerald_w:      Lpush_emerald_w(x, y);          goto loop;
+    case Xpush_diamond_e:      Lpush_diamond_e(x, y);          goto loop;
+    case Xpush_diamond_w:      Lpush_diamond_w(x, y);          goto loop;
+    case Xpush_stone_e:                Lpush_stone_e(x, y);            goto loop;
+    case Xpush_stone_w:                Lpush_stone_w(x, y);            goto loop;
+    case Xpush_bomb_e:         Lpush_bomb_e(x, y);             goto loop;
+    case Xpush_bomb_w:         Lpush_bomb_w(x, y);             goto loop;
+    case Xpush_nut_e:          Lpush_nut_e(x, y);              goto loop;
+    case Xpush_nut_w:          Lpush_nut_w(x, y);              goto loop;
+    case Xpush_spring_e:       Lpush_spring_e(x, y);           goto loop;
+    case Xpush_spring_w:       Lpush_spring_w(x, y);           goto loop;
+
+    case Xdynamite_1:          Ldynamite_1(x, y);              goto loop;
+    case Xdynamite_2:          Ldynamite_2(x, y);              goto loop;
+    case Xdynamite_3:          Ldynamite_3(x, y);              goto loop;
+    case Xdynamite_4:          Ldynamite_4(x, y);              goto loop;
+
+    case Xfake_door_1:         Lfake_door_1(x, y);             goto loop;
+    case Xfake_door_2:         Lfake_door_2(x, y);             goto loop;
+    case Xfake_door_3:         Lfake_door_3(x, y);             goto loop;
+    case Xfake_door_4:         Lfake_door_4(x, y);             goto loop;
+    case Xfake_door_5:         Lfake_door_5(x, y);             goto loop;
+    case Xfake_door_6:         Lfake_door_6(x, y);             goto loop;
+    case Xfake_door_7:         Lfake_door_7(x, y);             goto loop;
+    case Xfake_door_8:         Lfake_door_8(x, y);             goto loop;
+
+    case Xballoon:             Lballoon(x, y);                 goto loop;
+
+    case Xball_1:              Lball_1(x, y);                  goto loop;
+    case Xball_2:              Lball_2(x, y);                  goto loop;
+
+    case Xdrip:                        Ldrip(x, y);                    goto loop;
+    case Xdrip_fall:           Ldrip_fall(x, y);               goto loop;
+    case Xdrip_stretch:                Ldrip_stretch(x, y);            goto loop;
+    case Xdrip_stretchB:       Ldrip_stretchB(x, y);           goto loop;
+
+    case Xwonderwall:          Lwonderwall(x, y);              goto loop;
+
+    case Xwheel:               Lwheel(x, y);                   goto loop;
+
+    case Xswitch:              Lswitch(x, y);                  goto loop;
+
+    case Xfake_blank:          Lfake_blank(x, y);              goto loop;
+    case Xfake_grass:          Lfake_grass(x, y);              goto loop;
+    case Xfake_amoeba:         Lfake_amoeba(x, y);             goto loop;
+
+    case Xsand_stone:          Lsand_stone(x, y);              goto loop;
+    case Xsand_stonein_1:      Lsand_stonein_1(x, y);          goto loop;
+    case Xsand_stonein_2:      Lsand_stonein_2(x, y);          goto loop;
+    case Xsand_stonein_3:      Lsand_stonein_3(x, y);          goto loop;
+    case Xsand_stonein_4:      Lsand_stonein_4(x, y);          goto loop;
+    case Xsand_sandstone_1:    Lsand_sandstone_1(x, y);        goto loop;
+    case Xsand_sandstone_2:    Lsand_sandstone_2(x, y);        goto loop;
+    case Xsand_sandstone_3:    Lsand_sandstone_3(x, y);        goto loop;
+    case Xsand_sandstone_4:    Lsand_sandstone_4(x, y);        goto loop;
+    case Xsand_stonesand_1:    Lsand_stonesand_1(x, y);        goto loop;
+    case Xsand_stonesand_2:    Lsand_stonesand_2(x, y);        goto loop;
+    case Xsand_stonesand_3:    Lsand_stonesand_3(x, y);        goto loop;
+    case Xsand_stonesand_4:    Lsand_stonesand_4(x, y);        goto loop;
+    case Xsand_stoneout_1:     Lsand_stoneout_1(x, y);         goto loop;
+    case Xsand_stoneout_2:     Lsand_stoneout_2(x, y);         goto loop;
+#ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
+    case Xsand_stonesand_quickout_1:Lsand_stonesand_quickout_1(x, y);goto loop;
+    case Xsand_stonesand_quickout_2:Lsand_stonesand_quickout_2(x, y);goto loop;
+#endif
 
-    case Xboom_bomb:
-      Lboom_tank(x, y);
-      goto loop;
+    case Xslidewall_ns:                Lslidewall_ns(x, y);            goto loop;
+    case Xslidewall_ew:                Lslidewall_ew(x, y);            goto loop;
 
-    case Xboom_android:
-      Lboom_android(x, y);
-      goto loop;
+    case Xexit:                        Lexit(x, y);                    goto loop;
+    case Xexit_1:              Lexit_1(x, y);                  goto loop;
+    case Xexit_2:              Lexit_2(x, y);                  goto loop;
+    case Xexit_3:              Lexit_3(x, y);                  goto loop;
 
-    case Xboom_1:
-      Lboom_1(x, y);
-      goto loop;
+    case Xpause:               Lpause(x, y);                   goto loop;
 
-    case Xboom_2:
-      Lboom_2(x, y);
-      goto loop;
-
-    /* --------------------------------------------------------------------- */
+    case Xboom_bug:            Lboom_bug(x, y);                goto loop;
+    case Xboom_bomb:           Lboom_tank(x, y);               goto loop;
+    case Xboom_android:                Lboom_android(x, y);            goto loop;
+    case Xboom_1:              Lboom_1(x, y);                  goto loop;
+    case Xboom_2:              Lboom_2(x, y);                  goto loop;
 
     case Zborder:
       if (++y < HEIGHT - 1)
@@ -5651,11 +5143,10 @@ void synchro_2(void)
       }
 
       goto done;
-  }
 
-#undef RANDOM
-#undef PLAY
-#undef PLAY_FORCE
+    default:
+      goto loop;
+  }
 
  done:
 
@@ -5664,7 +5155,7 @@ void synchro_2(void)
   else
     game_em.game_over = TRUE;
 
-  RandomEM = random_em;
+  RandomEM = seed;
 
   {
     void *temp = Cave;