+static unsigned int seed;
+static int score;
+
+static void Lboom_bug(int x, int y)
+{
+ Next[x][y] = Znormal;
+ Boom[x-1][y-1] = Xemerald;
+ Boom[x][y-1] = Xemerald;
+ Boom[x+1][y-1] = Xemerald;
+ Boom[x-1][y] = Xemerald;
+ Boom[x][y] = Xdiamond;
+ Boom[x+1][y] = Xemerald;
+ Boom[x-1][y+1] = Xemerald;
+ Boom[x][y+1] = Xemerald;
+ Boom[x+1][y+1] = Xemerald;
+
+#if PLAY_ELEMENT_SOUND
+ play_element_sound(x, y, SOUND_boom, element);
+#endif
+}
+
+static void Lboom_tank(int x, int y)
+{
+ Next[x][y] = Znormal;
+ Boom[x-1][y-1] = Xblank;
+ Boom[x][y-1] = Xblank;
+ Boom[x+1][y-1] = Xblank;
+ Boom[x-1][y] = Xblank;
+ Boom[x][y] = Xblank;
+ Boom[x+1][y] = Xblank;
+ Boom[x-1][y+1] = Xblank;
+ Boom[x][y+1] = Xblank;
+ Boom[x+1][y+1] = Xblank;
+#if PLAY_ELEMENT_SOUND
+ play_element_sound(x, y, SOUND_boom, element);
+#endif
+}
+
+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;
+ }
+ }
+}
+
+static void Lacid_1(int x, int y)
+{
+ Next[x][y] = Xacid_2;
+}
+
+static void Lacid_2(int x, int y)
+{
+ Next[x][y] = Xacid_3;
+}
+
+static void Lacid_3(int x, int y)
+{
+ Next[x][y] = Xacid_4;
+}
+
+static void Lacid_4(int x, int y)
+{
+ Next[x][y] = Xacid_5;
+}
+
+static void Lacid_5(int x, int y)
+{
+ Next[x][y] = Xacid_6;
+}
+
+static void Lacid_6(int x, int y)
+{
+ Next[x][y] = Xacid_7;
+}
+
+static void Lacid_7(int x, int y)
+{
+ Next[x][y] = Xacid_8;
+}
+
+static void Lacid_8(int x, int y)
+{
+ Next[x][y] = Xacid_1;
+}
+
+#ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
+static void Lfake_acid_1(int x, int y)
+{
+ Next[x][y] = Xfake_acid_2;
+}
+
+static void Lfake_acid_2(int x, int y)
+{
+ Next[x][y] = Xfake_acid_3;
+}
+
+static void Lfake_acid_3(int x, int y)
+{
+ Next[x][y] = Xfake_acid_4;
+}
+
+static void Lfake_acid_4(int x, int y)
+{
+ Next[x][y] = Xfake_acid_5;
+}
+
+static void Lfake_acid_5(int x, int y)
+{
+ Next[x][y] = Xfake_acid_6;
+}
+
+static void Lfake_acid_6(int x, int y)
+{
+ Next[x][y] = Xfake_acid_7;
+}
+
+static void Lfake_acid_7(int x, int y)
+{
+ Next[x][y] = Xfake_acid_8;
+}
+
+static void Lfake_acid_8(int x, int y)
+{
+ Next[x][y] = Xfake_acid_1;
+}
+#endif
+
+static void Landroid(int x, int y)
+{
+ int dx, dy, temp;
+
+ if (lev.android_clone_cnt == 0)
+ {
+ if (Cave[x-1][y-1] != Xblank &&
+ Cave[x][y-1] != Xblank &&
+ Cave[x+1][y-1] != Xblank &&
+ Cave[x-1][y] != Xblank &&
+ Cave[x+1][y] != Xblank &&
+ Cave[x-1][y+1] != Xblank &&
+ Cave[x][y+1] != Xblank &&
+ Cave[x+1][y+1] != Xblank)
+ goto android_move;
+
+ switch (RANDOM(8))
+ {
+ /* randomly find an object to clone */
+
+ case 0: /* S,NE,W,NW,SE,E,SW,N */
+ temp = lev.android_array[Cave[x][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y-1]]; if (temp != Xblank) break;
+ goto android_move;
+
+ case 1: /* NW,SE,N,S,NE,SW,E,W */
+ temp = lev.android_array[Cave[x-1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y]]; if (temp != Xblank) break;
+ goto android_move;
+
+ case 2: /* SW,E,S,W,N,NW,SE,NE */
+ temp = lev.android_array[Cave[x-1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y-1]]; if (temp != Xblank) break;
+ goto android_move;
+
+ case 3: /* N,SE,NE,E,W,S,NW,SW */
+ temp = lev.android_array[Cave[x][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y+1]]; if (temp != Xblank) break;
+ goto android_move;
+
+ case 4: /* SE,NW,E,NE,SW,W,N,S */
+ temp = lev.android_array[Cave[x+1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y+1]]; if (temp != Xblank) break;
+ goto android_move;
+
+ case 5: /* NE,W,SE,SW,S,N,E,NW */
+ temp = lev.android_array[Cave[x+1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y-1]]; if (temp != Xblank) break;
+ goto android_move;
+
+ case 6: /* E,N,SW,S,NW,NE,SE,W */
+ temp = lev.android_array[Cave[x+1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y]]; if (temp != Xblank) break;
+ goto android_move;
+
+ case 7: /* W,SW,NW,N,E,SE,NE,S */
+ temp = lev.android_array[Cave[x-1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x-1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y+1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x+1][y-1]]; if (temp != Xblank) break;
+ temp = lev.android_array[Cave[x][y+1]]; if (temp != Xblank) break;
+ goto android_move;
+ }
+
+ Next[x][y] = temp; /* the item we chose to clone */
+ play_element_sound(x, y, SOUND_android_clone, temp);
+
+ switch (RANDOM(8))
+ {
+ /* randomly find a direction to move */
+
+ case 0: /* S,NE,W,NW,SE,E,SW,N */
+ if (Cave[x][y+1] == Xblank) goto android_s;
+ if (Cave[x+1][y-1] == Xblank) goto android_ne;
+ if (Cave[x-1][y] == Xblank) goto android_w;
+ if (Cave[x-1][y-1] == Xblank) goto android_nw;
+ if (Cave[x+1][y+1] == Xblank) goto android_se;
+ if (Cave[x+1][y] == Xblank) goto android_e;
+ if (Cave[x-1][y+1] == Xblank) goto android_sw;
+ if (Cave[x][y-1] == Xblank) goto android_n;
+ goto android_move;
+
+ case 1: /* NW,SE,N,S,NE,SW,E,W */
+ if (Cave[x-1][y-1] == Xblank) goto android_nw;
+ if (Cave[x+1][y+1] == Xblank) goto android_se;
+ if (Cave[x][y-1] == Xblank) goto android_n;
+ if (Cave[x][y+1] == Xblank) goto android_s;
+ if (Cave[x+1][y-1] == Xblank) goto android_ne;
+ if (Cave[x-1][y+1] == Xblank) goto android_sw;
+ if (Cave[x+1][y] == Xblank) goto android_e;
+ if (Cave[x-1][y] == Xblank) goto android_w;
+ goto android_move;
+
+ case 2: /* SW,E,S,W,N,NW,SE,NE */
+ if (Cave[x-1][y+1] == Xblank) goto android_sw;
+ if (Cave[x+1][y] == Xblank) goto android_e;
+ if (Cave[x][y+1] == Xblank) goto android_s;
+ if (Cave[x-1][y] == Xblank) goto android_w;
+ if (Cave[x][y-1] == Xblank) goto android_n;
+ if (Cave[x-1][y-1] == Xblank) goto android_nw;
+ if (Cave[x+1][y+1] == Xblank) goto android_se;
+ if (Cave[x+1][y-1] == Xblank) goto android_ne;
+ goto android_move;
+
+ case 3: /* N,SE,NE,E,W,S,NW,SW */
+ if (Cave[x][y-1] == Xblank) goto android_n;
+ if (Cave[x+1][y+1] == Xblank) goto android_se;
+ if (Cave[x+1][y-1] == Xblank) goto android_ne;
+ if (Cave[x+1][y] == Xblank) goto android_e;
+ if (Cave[x-1][y] == Xblank) goto android_w;
+ if (Cave[x][y+1] == Xblank) goto android_s;
+ if (Cave[x-1][y-1] == Xblank) goto android_nw;
+ if (Cave[x-1][y+1] == Xblank) goto android_sw;
+ goto android_move;
+
+ case 4: /* SE,NW,E,NE,SW,W,N,S */
+ if (Cave[x+1][y+1] == Xblank) goto android_se;
+ if (Cave[x-1][y-1] == Xblank) goto android_nw;
+ if (Cave[x+1][y] == Xblank) goto android_e;
+ if (Cave[x+1][y-1] == Xblank) goto android_ne;
+ if (Cave[x-1][y+1] == Xblank) goto android_sw;
+ if (Cave[x-1][y] == Xblank) goto android_w;
+ if (Cave[x][y-1] == Xblank) goto android_n;
+ if (Cave[x][y+1] == Xblank) goto android_s;
+ goto android_move;
+
+ case 5: /* NE,W,SE,SW,S,N,E,NW */
+ if (Cave[x+1][y-1] == Xblank) goto android_ne;
+ if (Cave[x-1][y] == Xblank) goto android_w;
+ if (Cave[x+1][y+1] == Xblank) goto android_se;
+ if (Cave[x-1][y+1] == Xblank) goto android_sw;
+ if (Cave[x][y+1] == Xblank) goto android_s;
+ if (Cave[x][y-1] == Xblank) goto android_n;
+ if (Cave[x+1][y] == Xblank) goto android_e;
+ if (Cave[x-1][y-1] == Xblank) goto android_nw;
+ goto android_move;
+
+ case 6: /* E,N,SW,S,NW,NE,SE,W */
+ if (Cave[x+1][y] == Xblank) goto android_e;
+ if (Cave[x][y-1] == Xblank) goto android_n;
+ if (Cave[x-1][y+1] == Xblank) goto android_sw;
+ if (Cave[x][y+1] == Xblank) goto android_s;
+ if (Cave[x-1][y-1] == Xblank) goto android_nw;
+ if (Cave[x+1][y-1] == Xblank) goto android_ne;
+ if (Cave[x+1][y+1] == Xblank) goto android_se;
+ if (Cave[x-1][y] == Xblank) goto android_w;
+ goto android_move;
+
+ case 7: /* W,SW,NW,N,E,SE,NE,S */
+ if (Cave[x-1][y] == Xblank) goto android_w;
+ if (Cave[x-1][y+1] == Xblank) goto android_sw;
+ if (Cave[x-1][y-1] == Xblank) goto android_nw;
+ if (Cave[x][y-1] == Xblank) goto android_n;
+ if (Cave[x+1][y] == Xblank) goto android_e;
+ if (Cave[x+1][y+1] == Xblank) goto android_se;
+ if (Cave[x+1][y-1] == Xblank) goto android_ne;
+ if (Cave[x][y+1] == Xblank) goto android_s;
+ goto android_move;
+ }
+ }
+
+ android_move:
+ if (lev.android_move_cnt == 0)
+ {
+ if (Cave[x-1][y-1] == Zplayer ||
+ Cave[x][y-1] == Zplayer ||
+ Cave[x+1][y-1] == Zplayer ||
+ Cave[x-1][y] == Zplayer ||
+ Cave[x+1][y] == Zplayer ||
+ Cave[x-1][y+1] == Zplayer ||
+ Cave[x][y+1] == Zplayer ||
+ Cave[x+1][y+1] == Zplayer)
+ goto android_still;
+
+ set_nearest_player_xy(x, y, &dx, &dy);
+
+ Next[x][y] = Xblank; /* assume we will move */
+ temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
+
+ if (RANDOM(2))
+ {
+ switch (temp)
+ {
+ /* attempt clockwise move first if direct path is blocked */
+
+ case 0: /* north west */
+ if (tab_android_move[Cave[x-1][y-1]]) goto android_nw;
+ if (tab_android_move[Cave[x][y-1]]) goto android_n;
+ if (tab_android_move[Cave[x-1][y]]) goto android_w;
+ break;
+
+ case 1: /* north */
+ if (tab_android_move[Cave[x][y-1]]) goto android_n;
+ if (tab_android_move[Cave[x+1][y-1]]) goto android_ne;
+ if (tab_android_move[Cave[x-1][y-1]]) goto android_nw;
+ break;
+
+ case 2: /* north east */
+ if (tab_android_move[Cave[x+1][y-1]]) goto android_ne;
+ if (tab_android_move[Cave[x+1][y]]) goto android_e;
+ if (tab_android_move[Cave[x][y-1]]) goto android_n;
+ break;
+
+ case 3: /* west */
+ if (tab_android_move[Cave[x-1][y]]) goto android_w;
+ if (tab_android_move[Cave[x-1][y-1]]) goto android_nw;
+ if (tab_android_move[Cave[x-1][y+1]]) goto android_sw;
+ break;
+
+ case 4: /* nowhere */
+ break;
+
+ case 5: /* east */
+ if (tab_android_move[Cave[x+1][y]]) goto android_e;
+ if (tab_android_move[Cave[x+1][y+1]]) goto android_se;
+ if (tab_android_move[Cave[x+1][y-1]]) goto android_ne;
+ break;
+
+ case 6: /* south west */
+ if (tab_android_move[Cave[x-1][y+1]]) goto android_sw;
+ if (tab_android_move[Cave[x-1][y]]) goto android_w;
+ if (tab_android_move[Cave[x][y+1]]) goto android_s;
+ break;
+
+ case 7: /* south */
+ if (tab_android_move[Cave[x][y+1]]) goto android_s;
+ if (tab_android_move[Cave[x-1][y+1]]) goto android_sw;
+ if (tab_android_move[Cave[x+1][y+1]]) goto android_se;
+ break;
+
+ case 8: /* south east */
+ if (tab_android_move[Cave[x+1][y+1]]) goto android_se;
+ if (tab_android_move[Cave[x][y+1]]) goto android_s;
+ if (tab_android_move[Cave[x+1][y]]) goto android_e;
+ break;
+ }
+ }
+ else
+ {
+ switch (temp)
+ {
+ /* attempt counterclockwise move first if direct path is blocked */
+
+ case 0: /* north west */
+ if (tab_android_move[Cave[x-1][y-1]]) goto android_nw;
+ if (tab_android_move[Cave[x-1][y]]) goto android_w;
+ if (tab_android_move[Cave[x][y-1]]) goto android_n;
+ break;
+
+ case 1: /* north */
+ if (tab_android_move[Cave[x][y-1]]) goto android_n;
+ if (tab_android_move[Cave[x-1][y-1]]) goto android_nw;
+ if (tab_android_move[Cave[x+1][y-1]]) goto android_ne;
+ break;
+
+ case 2: /* north east */
+ if (tab_android_move[Cave[x+1][y-1]]) goto android_ne;
+ if (tab_android_move[Cave[x][y-1]]) goto android_n;
+ if (tab_android_move[Cave[x+1][y]]) goto android_e;
+ break;
+
+ case 3: /* west */
+ if (tab_android_move[Cave[x-1][y]]) goto android_w;
+ if (tab_android_move[Cave[x-1][y+1]]) goto android_sw;
+ if (tab_android_move[Cave[x-1][y-1]]) goto android_nw;
+ break;
+
+ case 4: /* nowhere */
+ break;
+
+ case 5: /* east */
+ if (tab_android_move[Cave[x+1][y]]) goto android_e;
+ if (tab_android_move[Cave[x+1][y-1]]) goto android_ne;
+ if (tab_android_move[Cave[x+1][y+1]]) goto android_se;
+ break;
+
+ case 6: /* south west */
+ if (tab_android_move[Cave[x-1][y+1]]) goto android_sw;
+ if (tab_android_move[Cave[x][y+1]]) goto android_s;
+ if (tab_android_move[Cave[x-1][y]]) goto android_w;
+ break;
+
+ case 7: /* south */
+ if (tab_android_move[Cave[x][y+1]]) goto android_s;
+ if (tab_android_move[Cave[x+1][y+1]]) goto android_se;
+ if (tab_android_move[Cave[x-1][y+1]]) goto android_sw;
+ break;
+
+ case 8: /* south east */
+ if (tab_android_move[Cave[x+1][y+1]]) goto android_se;
+ if (tab_android_move[Cave[x+1][y]]) goto android_e;
+ if (tab_android_move[Cave[x][y+1]]) goto android_s;
+ break;
+ }
+ }
+ }
+
+ android_still:
+ Next[x][y] = Xandroid;
+ return;
+
+ android_n:
+ Cave[x][y] = Yandroid_nB;
+ Cave[x][y-1] = Yandroid_n;
+ Next[x][y-1] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid);
+ return;
+
+ android_ne:
+ Cave[x][y] = Yandroid_neB;
+ Cave[x+1][y-1] = Yandroid_ne;
+ Next[x+1][y-1] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid);
+ return;
+
+ android_e:
+ Cave[x][y] = Yandroid_eB;
+ Cave[x+1][y] = Yandroid_e;
+ Next[x+1][y] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid);
+ return;
+
+ android_se:
+ Cave[x][y] = Yandroid_seB;
+ Cave[x+1][y+1] = Yandroid_se;
+ Next[x+1][y+1] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid);
+ return;
+
+ android_s:
+ Cave[x][y] = Yandroid_sB;
+ Cave[x][y+1] = Yandroid_s;
+ Next[x][y+1] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid);
+ return;
+
+ android_sw:
+ Cave[x][y] = Yandroid_swB;
+ Cave[x-1][y+1] = Yandroid_sw;
+ Next[x-1][y+1] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid);
+ return;
+
+ android_w:
+ Cave[x][y] = Yandroid_wB;
+ Cave[x-1][y] = Yandroid_w;
+ Next[x-1][y] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid);
+ return;
+
+ android_nw:
+ Cave[x][y] = Yandroid_nwB;
+ Cave[x-1][y-1] = Yandroid_nw;
+ Next[x-1][y-1] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid);
+ return;
+}
+
+static void Landroid_1_n(int x, int y)
+{
+ switch (Cave[x][y-1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yandroid_nB;
+ if (Cave[x+1][y-2] == Xblank)
+ Cave[x+1][y-2] = Xacid_splash_e;
+ if (Cave[x-1][y-2] == Xblank)
+ Cave[x-1][y-2] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Yandroid_nB;
+ Cave[x][y-1] = Yandroid_n;
+ Next[x][y] = Xblank;
+ Next[x][y-1] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid_1_n);
+ return;
+
+ default:
+ Landroid(x, y);
+ return;
+ }
+}
+
+static void Landroid_2_n(int x, int y)
+{
+ switch (Cave[x][y-1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yandroid_nB;
+ if (Cave[x+1][y-2] == Xblank)
+ Cave[x+1][y-2] = Xacid_splash_e;
+ if (Cave[x-1][y-2] == Xblank)
+ Cave[x-1][y-2] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Yandroid_nB;
+ Cave[x][y-1] = Yandroid_n;
+ Next[x][y] = Xblank;
+ Next[x][y-1] = Xandroid_1_n;
+ play_element_sound(x, y, SOUND_android_move, Xandroid_2_n);
+ return;
+
+ default:
+ Landroid(x, y);
+ return;
+ }
+}
+
+static void Landroid_1_e(int x, int y)
+{
+ switch (Cave[x+1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yandroid_eB;
+ if (Cave[x+2][y-1] == Xblank)
+ Cave[x+2][y-1] = Xacid_splash_e;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Yandroid_eB;
+ Cave[x+1][y] = Yandroid_e;
+ Next[x][y] = Xblank;
+ Next[x+1][y] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid_1_e);
+ return;
+
+ default:
+ Landroid(x, y);
+ return;
+ }
+}
+
+static void Landroid_2_e(int x, int y)
+{
+ switch (Cave[x+1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yandroid_eB;
+ if (Cave[x+2][y-1] == Xblank)
+ Cave[x+2][y-1] = Xacid_splash_e;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Yandroid_eB;
+ Cave[x+1][y] = Yandroid_e;
+ Next[x][y] = Xblank;
+ Next[x+1][y] = Xandroid_1_e;
+ play_element_sound(x, y, SOUND_android_move, Xandroid_2_e);
+ return;
+
+ default:
+ Landroid(x, y);
+ return;
+ }
+}
+
+static void Landroid_1_s(int x, int y)
+{
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yandroid_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Yandroid_sB;
+ Cave[x][y+1] = Yandroid_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid_1_s);
+ return;
+
+ default:
+ Landroid(x, y);
+ return;
+ }
+}
+
+static void Landroid_2_s(int x, int y)
+{
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yandroid_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Yandroid_sB;
+ Cave[x][y+1] = Yandroid_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xandroid_1_s;
+ play_element_sound(x, y, SOUND_android_move, Xandroid_2_s);
+ return;
+
+ default:
+ Landroid(x, y);
+ return;
+ }
+}
+
+static void Landroid_1_w(int x, int y)
+{
+ switch (Cave[x-1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yandroid_wB;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_e;
+ if (Cave[x-2][y-1] == Xblank)
+ Cave[x-2][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Yandroid_wB;
+ Cave[x-1][y] = Yandroid_w;
+ Next[x][y] = Xblank;
+ Next[x-1][y] = Xandroid;
+ play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
+ return;
+
+ default:
+ Landroid(x, y);
+ return;
+ }
+}
+
+static void Landroid_2_w(int x, int y)
+{
+ switch (Cave[x-1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yandroid_wB;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_e;
+ if (Cave[x-2][y-1] == Xblank)
+ Cave[x-2][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Yandroid_wB;
+ Cave[x-1][y] = Yandroid_w;
+ Next[x][y] = Xblank;
+ Next[x-1][y] = Xandroid_1_w;
+ play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
+ return;
+
+ default:
+ Landroid(x, y);
+ return;
+ }
+}
+
+static void Leater_n(int x, int y)
+{
+ if (Cave[x+1][y] == Xdiamond)
+ {
+ Cave[x+1][y] = Ydiamond_blank;
+ Next[x+1][y] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
+ return;
+ }
+
+ if (Cave[x][y+1] == Xdiamond)
+ {
+ Cave[x][y+1] = Ydiamond_blank;
+ Next[x][y+1] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
+ return;
+ }
+
+ if (Cave[x-1][y] == Xdiamond)
+ {
+ Cave[x-1][y] = Ydiamond_blank;
+ Next[x-1][y] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
+ return;
+ }
+
+ if (Cave[x][y-1] == Xdiamond)
+ {
+ Cave[x][y-1] = Ydiamond_blank;
+ Next[x][y-1] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
+ return;
+ }
+
+ switch (Cave[x][y-1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yeater_nB;
+ if (Cave[x+1][y-2] == Xblank)
+ Cave[x+1][y-2] = Xacid_splash_e;
+ if (Cave[x-1][y-2] == Xblank)
+ Cave[x-1][y-2] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Yeater_nB;
+ Cave[x][y-1] = Yeater_n;
+ Next[x][y] = Xblank;
+ Next[x][y-1] = Xeater_n;
+ return;
+
+ default:
+ Next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
+ play_element_sound(x, y, SOUND_eater, Xeater_n);
+ return;
+ }
+}
+
+static void Leater_e(int x, int y)
+{
+ if (Cave[x][y+1] == Xdiamond)
+ {
+ Cave[x][y+1] = Ydiamond_blank;
+ Next[x][y+1] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
+ return;
+ }
+
+ if (Cave[x-1][y] == Xdiamond)
+ {
+ Cave[x-1][y] = Ydiamond_blank;
+ Next[x-1][y] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
+ return;
+ }
+
+ if (Cave[x][y-1] == Xdiamond)
+ {
+ Cave[x][y-1] = Ydiamond_blank;
+ Next[x][y-1] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
+ return;
+ }
+
+ if (Cave[x+1][y] == Xdiamond)
+ {
+ Cave[x+1][y] = Ydiamond_blank;
+ Next[x+1][y] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
+ return;
+ }
+
+ switch (Cave[x+1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yeater_eB;
+ if (Cave[x+2][y-1] == Xblank)
+ Cave[x+2][y-1] = Xacid_splash_e;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Yeater_eB;
+ Cave[x+1][y] = Yeater_e;
+ Next[x][y] = Xblank;
+ Next[x+1][y] = Xeater_e;
+ return;
+
+ default:
+ Next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
+ play_element_sound(x, y, SOUND_eater, Xeater_e);
+ return;
+ }
+}
+
+static void Leater_s(int x, int y)
+{
+ if (Cave[x-1][y] == Xdiamond)
+ {
+ Cave[x-1][y] = Ydiamond_blank;
+ Next[x-1][y] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
+ return;
+ }
+
+ if (Cave[x][y-1] == Xdiamond)
+ {
+ Cave[x][y-1] = Ydiamond_blank;
+ Next[x][y-1] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
+ return;
+ }
+
+ if (Cave[x+1][y] == Xdiamond)
+ {
+ Cave[x+1][y] = Ydiamond_blank;
+ Next[x+1][y] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
+ return;
+ }
+
+ if (Cave[x][y+1] == Xdiamond)
+ {
+ Cave[x][y+1] = Ydiamond_blank;
+ Next[x][y+1] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
+ return;
+ }
+
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yeater_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Yeater_sB;
+ Cave[x][y+1] = Yeater_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xeater_s;
+ return;
+
+ default:
+ Next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
+ play_element_sound(x, y, SOUND_eater, Xeater_s);
+ return;
+ }
+}
+
+static void Leater_w(int x, int y)
+{
+ if (Cave[x][y-1] == Xdiamond)
+ {
+ Cave[x][y-1] = Ydiamond_blank;
+ Next[x][y-1] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
+ return;
+ }
+
+ if (Cave[x+1][y] == Xdiamond)
+ {
+ Cave[x+1][y] = Ydiamond_blank;
+ Next[x+1][y] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
+ return;
+ }
+
+ if (Cave[x][y+1] == Xdiamond)
+ {
+ Cave[x][y+1] = Ydiamond_blank;
+ Next[x][y+1] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
+ return;
+ }
+
+ if (Cave[x-1][y] == Xdiamond)
+ {
+ Cave[x-1][y] = Ydiamond_blank;
+ Next[x-1][y] = Xblank;
+ play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
+ return;
+ }
+
+ switch (Cave[x-1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yeater_wB;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_e;
+ if (Cave[x-2][y-1] == Xblank)
+ Cave[x-2][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Yeater_wB;
+ Cave[x-1][y] = Yeater_w;
+ Next[x][y] = Xblank;
+ Next[x-1][y] = Xeater_w;
+ return;
+
+ default:
+ Next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
+ play_element_sound(x, y, SOUND_eater, Xeater_w);
+ return;
+ }
+}
+
+static void Lalien(int x, int y)
+{
+ int dx, dy;
+
+ if (lev.wheel_cnt)
+ {
+ dx = lev.wheel_x;
+ dy = lev.wheel_y;
+ }
+ else
+ {
+ set_nearest_player_xy(x, y, &dx, &dy);
+ }
+
+ if (RANDOM(2))
+ {
+ if (y > dy)
+ {
+ switch (Cave[x][y-1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yalien_nB;
+ if (Cave[x+1][y-2] == Xblank)
+ Cave[x+1][y-2] = Xacid_splash_e;
+ if (Cave[x-1][y-2] == Xblank)
+ Cave[x-1][y-2] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Yalien_nB;
+ Cave[x][y-1] = Yalien_n;
+ Next[x][y] = Xblank;
+ Next[x][y-1] = Xalien_pause;
+ play_element_sound(x, y, SOUND_alien, Xalien);
+ return;
+ }
+ }
+ else if (y < dy)
+ {
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yalien_sB;
+ Next[x][y] = Xblank;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Yalien_sB;
+ Cave[x][y+1] = Yalien_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xalien_pause;
+ play_element_sound(x, y, SOUND_alien, Xalien);
+ return;
+ }
+ }
+ }
+ else
+ {
+ if (x < dx)
+ {
+ switch (Cave[x+1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yalien_eB;
+ if (Cave[x+2][y-1] == Xblank)
+ Cave[x+2][y-1] = Xacid_splash_e;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Yalien_eB;
+ Cave[x+1][y] = Yalien_e;
+ Next[x][y] = Xblank;
+ Next[x+1][y] = Xalien_pause;
+ play_element_sound(x, y, SOUND_alien, Xalien);
+ return;
+ }
+ }
+ else if (x > dx)
+ {
+ switch (Cave[x-1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yalien_wB;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_e;
+ if (Cave[x-2][y-1] == Xblank)
+ Cave[x-2][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Yalien_wB;
+ Cave[x-1][y] = Yalien_w;
+ Next[x][y] = Xblank;
+ Next[x-1][y] = Xalien_pause;
+ play_element_sound(x, y, SOUND_alien, Xalien);
+ return;
+ }
+ }
+ }
+}
+
+static void Lalien_pause(int x, int y)
+{
+ Next[x][y] = Xalien;
+}
+
+static void Lbug_n(int x, int y)
+{
+ switch (Cave[x][y-1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ybug_nB;
+ if (Cave[x+1][y-2] == Xblank)
+ Cave[x+1][y-2] = Xacid_splash_e;
+ if (Cave[x-1][y-2] == Xblank)
+ Cave[x-1][y-2] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Ybug_nB;
+ Cave[x][y-1] = Ybug_n;
+ Next[x][y] = Xblank;
+ Next[x][y-1] = Xbug_1_n;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_n);
+ return;
+
+ default:
+ Cave[x][y] = Ybug_n_w;
+ Next[x][y] = Xbug_2_w;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_n);
+ return;
+ }
+}
+
+static void Lbug_1_n(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_bug(x, y);
+
+ return;
+ }
+
+ switch (Cave[x+1][y])
+ {
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ case Zplayer:
+ Cave[x][y] = Ybug_n_e;
+ Next[x][y] = Xbug_2_e;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_n);
+ return;
+
+ default:
+ Lbug_n(x, y);
+ return;
+ }
+}
+
+static void Lbug_2_n(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_bug(x, y);
+
+ return;
+ }
+
+ Lbug_n(x, y);
+}
+
+static void Lbug_e(int x, int y)
+{
+ switch (Cave[x+1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ybug_eB;
+ if (Cave[x+2][y-1] == Xblank)
+ Cave[x+2][y-1] = Xacid_splash_e;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Ybug_eB;
+ Cave[x+1][y] = Ybug_e;
+ Next[x][y] = Xblank;
+ Next[x+1][y] = Xbug_1_e;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_e);
+ return;
+
+ default:
+ Cave[x][y] = Ybug_e_n;
+ Next[x][y] = Xbug_2_n;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_e);
+ return;
+ }
+}
+
+static void Lbug_1_e(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_bug(x, y);
+
+ return;
+ }
+
+ switch (Cave[x][y+1])
+ {
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ case Zplayer:
+ Cave[x][y] = Ybug_e_s;
+ Next[x][y] = Xbug_2_s;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_e);
+ return;
+
+ default:
+ Lbug_e(x, y);
+ return;
+ }
+}
+
+static void Lbug_2_e(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_bug(x, y);
+
+ return;
+ }
+
+ Lbug_e(x, y);
+}
+
+static void Lbug_s(int x, int y)
+{
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ybug_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Ybug_sB;
+ Cave[x][y+1] = Ybug_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xbug_1_s;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_s);
+ return;
+
+ default:
+ Cave[x][y] = Ybug_s_e;
+ Next[x][y] = Xbug_2_e;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_s);
+ return;
+ }
+}
+
+static void Lbug_1_s(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_bug(x, y);
+
+ return;
+ }
+
+ switch (Cave[x-1][y])
+ {
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ case Zplayer:
+ Cave[x][y] = Ybug_s_w;
+ Next[x][y] = Xbug_2_w;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_s);
+ return;
+
+ default:
+ Lbug_s(x, y);
+ return;
+ }
+}
+
+static void Lbug_2_s(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_bug(x, y);
+
+ return;
+ }
+
+ Lbug_s(x, y);
+}
+
+static void Lbug_w(int x, int y)
+{
+ switch (Cave[x-1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ybug_wB;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_e;
+ if (Cave[x-2][y-1] == Xblank)
+ Cave[x-2][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Ybug_wB;
+ Cave[x-1][y] = Ybug_w;
+ Next[x][y] = Xblank;
+ Next[x-1][y] = Xbug_1_w;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_w);
+ return;
+
+ default:
+ Cave[x][y] = Ybug_w_s;
+ Next[x][y] = Xbug_2_s;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_w);
+ return;
+ }
+}
+
+static void Lbug_1_w(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_bug(x, y);
+
+ return;
+ }
+
+ switch (Cave[x][y-1])
+ {
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ case Zplayer:
+ Cave[x][y] = Ybug_w_n;
+ Next[x][y] = Xbug_2_n;
+ play_element_sound(x, y, SOUND_bug, Xbug_1_w);
+ return;
+
+ default:
+ Lbug_w(x, y);
+ return;
+ }
+}
+
+static void Lbug_2_w(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_bug(x, y);
+
+ return;
+ }
+
+ Lbug_w(x, y);
+}
+
+static void Ltank_n(int x, int y)
+{
+ switch (Cave[x][y-1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ytank_nB;
+ if (Cave[x+1][y-2] == Xblank)
+ Cave[x+1][y-2] = Xacid_splash_e;
+ if (Cave[x-1][y-2] == Xblank)
+ Cave[x-1][y-2] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Ytank_nB;
+ Cave[x][y-1] = Ytank_n;
+ Next[x][y] = Xblank;
+ Next[x][y-1] = Xtank_1_n;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_n);
+ return;
+
+ default:
+ Cave[x][y] = Ytank_n_e;
+ Next[x][y] = Xtank_2_e;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_n);
+ return;
+ }
+}
+
+static void Ltank_1_n(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_tank(x, y);
+
+ return;
+ }
+
+ switch (Cave[x-1][y])
+ {
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ case Zplayer:
+ Cave[x][y] = Ytank_n_w;
+ Next[x][y] = Xtank_2_w;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_n);
+ return;
+
+ default:
+ Ltank_n(x, y);
+ return;
+ }
+}
+
+static void Ltank_2_n(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_tank(x, y);
+
+ return;
+ }
+
+ Ltank_n(x, y);
+}
+
+static void Ltank_e(int x, int y)
+{
+ switch (Cave[x+1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ytank_eB;
+ if (Cave[x+2][y-1] == Xblank)
+ Cave[x+2][y-1] = Xacid_splash_e;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Ytank_eB;
+ Cave[x+1][y] = Ytank_e;
+ Next[x][y] = Xblank;
+ Next[x+1][y] = Xtank_1_e;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_e);
+ return;
+
+ default:
+ Cave[x][y] = Ytank_e_s;
+ Next[x][y] = Xtank_2_s;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_e);
+ return;
+ }
+}
+
+static void Ltank_1_e(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_tank(x, y);
+
+ return;
+ }
+
+ switch (Cave[x][y-1])
+ {
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ case Zplayer:
+ Cave[x][y] = Ytank_e_n;
+ Next[x][y] = Xtank_2_n;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_e);
+ return;
+
+ default:
+ Ltank_e(x, y);
+ return;
+ }
+}
+
+static void Ltank_2_e(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_tank(x, y);
+
+ return;
+ }
+
+ Ltank_e(x, y);
+}
+
+static void Ltank_s(int x, int y)
+{
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ytank_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Ytank_sB;
+ Cave[x][y+1] = Ytank_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xtank_1_s;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_s);
+ return;
+
+ default:
+ Cave[x][y] = Ytank_s_w;
+ Next[x][y] = Xtank_2_w;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_s);
+ return;
+ }
+}
+
+static void Ltank_1_s(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_tank(x, y);
+
+ return;
+ }
+
+ switch (Cave[x+1][y])
+ {
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ case Zplayer:
+ Cave[x][y] = Ytank_s_e;
+ Next[x][y] = Xtank_2_e;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_s);
+ return;
+
+ default:
+ Ltank_s(x, y);
+ return;
+ }
+}
+
+static void Ltank_2_s(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_tank(x, y);
+
+ return;
+ }
+
+ Ltank_s(x, y);
+}
+
+static void Ltank_w(int x, int y)
+{
+ switch (Cave[x-1][y])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ytank_wB;
+ if (Cave[x][y-1] == Xblank)
+ Cave[x][y-1] = Xacid_splash_e;
+ if (Cave[x-2][y-1] == Xblank)
+ Cave[x-2][y-1] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Zplayer:
+ Cave[x][y] = Ytank_wB;
+ Cave[x-1][y] = Ytank_w;
+ Next[x][y] = Xblank;
+ Next[x-1][y] = Xtank_1_w;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_w);
+ return;
+
+ default:
+ Cave[x][y] = Ytank_w_n;
+ Next[x][y] = Xtank_2_n;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_w);
+ return;
+ }
+}
+
+static void Ltank_1_w(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_tank(x, y);
+
+ return;
+ }
+
+ switch (Cave[x][y+1])
+ {
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Xplant:
+ case Yplant:
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ case Zplayer:
+ Cave[x][y] = Ytank_w_s;
+ Next[x][y] = Xtank_2_s;
+ play_element_sound(x, y, SOUND_tank, Xtank_1_w);
+ return;
+
+ default:
+ Ltank_w(x, y);
+ return;
+ }
+}
+
+static void Ltank_2_w(int x, int y)
+{
+ if (tab_amoeba[Cave[x][y-1]] ||
+ tab_amoeba[Cave[x+1][y]] ||
+ tab_amoeba[Cave[x][y+1]] ||
+ tab_amoeba[Cave[x-1][y]])
+ {
+ Lboom_tank(x, y);
+
+ return;
+ }
+
+ Ltank_w(x, y);
+}
+
+static void Lemerald(int x, int y)
+{
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yemerald_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Yemerald_sB;
+ Cave[x][y+1] = Yemerald_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xemerald_fall;
+ return;
+
+ case Xspring:
+ case Xspring_pause:
+ case Xspring_e:
+ case Xspring_w:
+ case Xandroid:
+ case Xandroid_1_n:
+ case Xandroid_2_n:
+ case Xandroid_1_e:
+ case Xandroid_2_e:
+ case Xandroid_1_s:
+ case Xandroid_2_s:
+ case Xandroid_1_w:
+ case Xandroid_2_w:
+ case Xstone:
+ case Xstone_pause:
+ case Xemerald:
+ case Xemerald_pause:
+ case Xdiamond:
+ case Xdiamond_pause:
+ case Xbomb:
+ case Xbomb_pause:
+ case Xballoon:
+ case Xacid_ne:
+ case Xacid_nw:
+ case Xball_1:
+ case Xball_2:
+ case Xnut:
+ case Xnut_pause:
+ case Xslidewall_ns:
+ case Xslidewall_ew:
+ case Xwonderwall:
+ case Xkey_1:
+ case Xkey_2:
+ case Xkey_3:
+ case Xkey_4:
+ case Xkey_5:
+ case Xkey_6:
+ case Xkey_7:
+ case Xkey_8:
+ case Xbumper:
+ case Xswitch:
+ case Xsteel_1:
+ case Xsteel_2:
+ case Xsteel_3:
+ case Xsteel_4:
+ case Xwall_1:
+ case Xwall_2:
+ case Xwall_3:
+ case Xwall_4:
+ case Xroundwall_1:
+ case Xroundwall_2:
+ case Xroundwall_3:
+ case Xroundwall_4:
+ if (RANDOM(2))
+ {
+ if (tab_blank[Cave[x+1][y]] && tab_acid[Cave[x+1][y+1]])
+ {
+ Cave[x][y] = Yemerald_eB;
+ Cave[x+1][y] = Yemerald_e;
+ Next[x][y] = Xblank;
+ Next[x+1][y] = Xemerald_pause;
+ return;
+ }
+
+ if (tab_blank[Cave[x-1][y]] && tab_acid[Cave[x-1][y+1]])
+ {
+ Cave[x][y] = Yemerald_wB;
+ Cave[x-1][y] = Yemerald_w;
+ Next[x][y] = Xblank;
+ Next[x-1][y] = Xemerald_pause;
+ return;
+ }
+ }
+ else
+ {
+ if (tab_blank[Cave[x-1][y]] && tab_acid[Cave[x-1][y+1]])
+ {
+ Cave[x][y] = Yemerald_wB;
+ Cave[x-1][y] = Yemerald_w;
+ Next[x][y] = Xblank;
+ Next[x-1][y] = Xemerald_pause;
+ return;
+ }
+
+ if (tab_blank[Cave[x+1][y]] && tab_acid[Cave[x+1][y+1]])
+ {
+ Cave[x][y] = Yemerald_eB;
+ Cave[x+1][y] = Yemerald_e;
+ Next[x][y] = Xblank;
+ Next[x+1][y] = Xemerald_pause;
+ return;
+ }
+ }
+
+ default:
+ if (++lev.shine_cnt > 50)
+ {
+ lev.shine_cnt = RANDOM(8);
+ Cave[x][y] = Xemerald_shine;
+ }
+
+ return;
+ }
+}
+
+static void Lemerald_pause(int x, int y)
+{
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yemerald_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Yemerald_sB;
+ Cave[x][y+1] = Yemerald_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xemerald_fall;
+ return;
+
+ default:
+ Cave[x][y] = Xemerald;
+ Next[x][y] = Xemerald;
+ return;
+ }
+}
+
+static void Lemerald_fall(int x, int y)
+{
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Yemerald_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Zplayer:
+ Cave[x][y] = Yemerald_sB;
+ Cave[x][y+1] = Yemerald_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xemerald_fall;
+ return;
+
+ case Xwonderwall:
+ if (lev.wonderwall_time)
+ {
+ lev.wonderwall_state = 1;
+ Cave[x][y] = Yemerald_sB;
+ if (tab_blank[Cave[x][y+2]])
+ {
+ Cave[x][y+2] = Ydiamond_s;
+ Next[x][y+2] = Xdiamond_fall;
+ }
+
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
+ return;
+ }
+
+ default:
+ Cave[x][y] = Xemerald;
+ Next[x][y] = Xemerald;
+ play_element_sound(x, y, SOUND_diamond, Xemerald);
+ return;
+ }
+}
+
+static void Ldiamond(int x, int y)
+{
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ydiamond_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Ydiamond_sB;
+ Cave[x][y+1] = Ydiamond_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xdiamond_fall;
+ return;
+
+ case Xspring:
+ case Xspring_pause:
+ case Xspring_e:
+ case Xspring_w:
+ case Xandroid:
+ case Xandroid_1_n:
+ case Xandroid_2_n:
+ case Xandroid_1_e:
+ case Xandroid_2_e:
+ case Xandroid_1_s:
+ case Xandroid_2_s:
+ case Xandroid_1_w:
+ case Xandroid_2_w:
+ case Xstone:
+ case Xstone_pause:
+ case Xemerald:
+ case Xemerald_pause:
+ case Xdiamond:
+ case Xdiamond_pause:
+ case Xbomb:
+ case Xbomb_pause:
+ case Xballoon:
+ case Xacid_ne:
+ case Xacid_nw:
+ case Xball_1:
+ case Xball_2:
+ case Xnut:
+ case Xnut_pause:
+ case Xslidewall_ns:
+ case Xslidewall_ew:
+ case Xwonderwall:
+ case Xkey_1:
+ case Xkey_2:
+ case Xkey_3:
+ case Xkey_4:
+ case Xkey_5:
+ case Xkey_6:
+ case Xkey_7:
+ case Xkey_8:
+ case Xbumper:
+ case Xswitch:
+ case Xsteel_1:
+ case Xsteel_2:
+ case Xsteel_3:
+ case Xsteel_4:
+ case Xwall_1:
+ case Xwall_2:
+ case Xwall_3:
+ case Xwall_4:
+ case Xroundwall_1:
+ case Xroundwall_2:
+ case Xroundwall_3:
+ case Xroundwall_4:
+ if (RANDOM(2))
+ {
+ if (tab_blank[Cave[x+1][y]] && tab_acid[Cave[x+1][y+1]])
+ {
+ Cave[x][y] = Ydiamond_eB;
+ Cave[x+1][y] = Ydiamond_e;
+ Next[x][y] = Xblank;
+ Next[x+1][y] = Xdiamond_pause;
+ return;
+ }
+
+ if (tab_blank[Cave[x-1][y]] && tab_acid[Cave[x-1][y+1]])
+ {
+ Cave[x][y] = Ydiamond_wB;
+ Cave[x-1][y] = Ydiamond_w;
+ Next[x][y] = Xblank;
+ Next[x-1][y] = Xdiamond_pause;
+ return;
+ }
+ }
+ else
+ {
+ if (tab_blank[Cave[x-1][y]] && tab_acid[Cave[x-1][y+1]])
+ {
+ Cave[x][y] = Ydiamond_wB;
+ Cave[x-1][y] = Ydiamond_w;
+ Next[x][y] = Xblank;
+ Next[x-1][y] = Xdiamond_pause;
+ return;
+ }
+
+ if (tab_blank[Cave[x+1][y]] && tab_acid[Cave[x+1][y+1]])
+ {
+ Cave[x][y] = Ydiamond_eB;
+ Cave[x+1][y] = Ydiamond_e;
+ Next[x][y] = Xblank;
+ Next[x+1][y] = Xdiamond_pause;
+ return;
+ }
+ }
+
+ default:
+ if (++lev.shine_cnt > 50)
+ {
+ lev.shine_cnt = RANDOM(8);
+ Cave[x][y] = Xdiamond_shine;
+ }
+
+ return;
+ }
+}
+
+static void Ldiamond_pause(int x, int y)
+{
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ydiamond_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ Cave[x][y] = Ydiamond_sB;
+ Cave[x][y+1] = Ydiamond_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xdiamond_fall;
+ return;
+
+ default:
+ Cave[x][y] = Xdiamond;
+ Next[x][y] = Xdiamond;
+ return;
+ }
+}
+
+static void Ldiamond_fall(int x, int y)
+{
+ switch (Cave[x][y+1])
+ {
+ case Xacid_1:
+ case Xacid_2:
+ case Xacid_3:
+ case Xacid_4:
+ case Xacid_5:
+ case Xacid_6:
+ case Xacid_7:
+ case Xacid_8:
+ Cave[x][y] = Ydiamond_sB;
+ if (Cave[x+1][y] == Xblank)
+ Cave[x+1][y] = Xacid_splash_e;
+ if (Cave[x-1][y] == Xblank)
+ Cave[x-1][y] = Xacid_splash_w;
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_acid, Xacid_1);
+ return;
+
+ case Xblank:
+ case Xacid_splash_e:
+ case Xacid_splash_w:
+ case Zplayer:
+ Cave[x][y] = Ydiamond_sB;
+ Cave[x][y+1] = Ydiamond_s;
+ Next[x][y] = Xblank;
+ Next[x][y+1] = Xdiamond_fall;
+ return;
+
+ case Xwonderwall:
+ if (lev.wonderwall_time)
+ {
+ lev.wonderwall_state = 1;
+ Cave[x][y] = Ydiamond_sB;
+ if (tab_blank[Cave[x][y+2]])
+ {
+ Cave[x][y+2] = Ystone_s;
+ Next[x][y+2] = Xstone_fall;
+ }
+
+ Next[x][y] = Xblank;
+ play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
+ return;
+ }
+
+ default:
+ Cave[x][y] = Xdiamond;
+ Next[x][y] = Xdiamond;
+ play_element_sound(x, y, SOUND_diamond, Xdiamond);
+ return;
+ }
+}
+
+static void Lstone(int x, int y)