5 * my own version of the emerald mine engine
11 #define SPRING_ROLL /* spring rolling off round things continues to roll */
12 #define ACID_ROLL /* rolling objects go into acid rather than remove it */
13 #define ACID_PLAYER /* player gets killed by acid, but without explosion */
15 #define RANDOM(x) ((seed = seed << 31 | seed >> 1) % x)
17 static short **cave, **next, **boom;
18 static unsigned int seed;
21 static const byte is_blank[GAME_TILE_MAX] =
36 static const byte is_blank_or_acid[GAME_TILE_MAX] =
59 static const byte is_fake_acid[GAME_TILE_MAX] =
71 static const byte is_amoeba[GAME_TILE_MAX] =
85 static const byte is_android_walkable[GAME_TILE_MAX] =
101 static void Lboom_generic(int x, int y, int element, int element_middle)
103 boom[x-1][y-1] = element;
104 boom[x][y-1] = element;
105 boom[x+1][y-1] = element;
106 boom[x-1][y] = element;
107 boom[x][y] = element_middle;
108 boom[x+1][y] = element;
109 boom[x-1][y+1] = element;
110 boom[x][y+1] = element;
111 boom[x+1][y+1] = element;
114 static void Lboom_bug(int x, int y)
116 if (game_em.use_old_explosions)
119 Lboom_generic(x, y, Xemerald, Xdiamond);
121 #if PLAY_ELEMENT_SOUND
122 play_element_sound(x, y, SOUND_boom, Xbug_1_n);
126 static void Lboom_tank(int x, int y)
128 if (game_em.use_old_explosions)
131 Lboom_generic(x, y, Xblank, Xblank);
133 #if PLAY_ELEMENT_SOUND
134 play_element_sound(x, y, SOUND_boom, Xtank_1_n);
138 static void Lboom_eater(int x, int y)
140 if (game_em.use_old_explosions)
143 boom[x-1][y-1] = lev.eater_array[lev.eater_pos][0];
144 boom[x][y-1] = lev.eater_array[lev.eater_pos][1];
145 boom[x+1][y-1] = lev.eater_array[lev.eater_pos][2];
146 boom[x-1][y] = lev.eater_array[lev.eater_pos][3];
147 boom[x][y] = lev.eater_array[lev.eater_pos][4];
148 boom[x+1][y] = lev.eater_array[lev.eater_pos][5];
149 boom[x-1][y+1] = lev.eater_array[lev.eater_pos][6];
150 boom[x][y+1] = lev.eater_array[lev.eater_pos][7];
151 boom[x+1][y+1] = lev.eater_array[lev.eater_pos][8];
153 lev.eater_pos = (lev.eater_pos + 1) % 8;
155 #if PLAY_ELEMENT_SOUND
156 play_element_sound(x, y, SOUND_boom, Xeater_n);
160 static void Lboom_bug_old(int x, int y)
162 if (!game_em.use_old_explosions)
168 static void Lboom_tank_old(int x, int y)
170 if (!game_em.use_old_explosions)
176 static void Lboom_eater_old(int x, int y)
178 if (!game_em.use_old_explosions)
184 static void Lboom_bug_new(int x, int y, boolean chain_explosion)
186 if (game_em.use_old_explosions)
195 static void Lboom_tank_new(int x, int y, boolean chain_explosion)
197 if (game_em.use_old_explosions)
206 static void Lboom_eater_new(int x, int y, boolean chain_explosion)
208 if (game_em.use_old_explosions)
217 static boolean player_killed(struct PLAYER *ply)
225 if (lev.killed_out_of_time && setup.time_limit)
228 switch (cave[x][y-1])
249 switch (cave[x+1][y])
270 switch (cave[x][y+1])
291 switch (cave[x-1][y])
336 static void kill_player(struct PLAYER *ply)
343 switch (cave[x][y-1])
353 cave[x][y-1] = Xboom_bug;
354 Lboom_bug_new(x, y-1, TRUE);
365 cave[x][y-1] = Xboom_tank;
366 Lboom_tank_new(x, y-1, TRUE);
370 switch (cave[x+1][y])
380 cave[x+1][y] = Xboom_bug;
381 Lboom_bug_new(x+1, y, TRUE);
392 cave[x+1][y] = Xboom_tank;
393 Lboom_tank_new(x+1, y, TRUE);
397 switch (cave[x][y+1])
407 cave[x][y+1] = Xboom_bug;
408 Lboom_bug_new(x, y+1, TRUE);
419 cave[x][y+1] = Xboom_tank;
420 Lboom_tank_new(x, y+1, TRUE);
424 switch (cave[x-1][y])
434 cave[x-1][y] = Xboom_bug;
435 Lboom_bug_new(x-1, y, TRUE);
446 cave[x-1][y] = Xboom_tank;
447 Lboom_tank_new(x-1, y, TRUE);
458 play_element_sound(x, y, SOUND_exit_leave, Xexit_1);
462 play_element_sound(x, y, SOUND_die, Zplayer);
481 cave[x][y] = Xboom_1;
487 static boolean player_digfield(struct PLAYER *ply, int dx, int dy)
489 int anim = (dx < 0 ? 3 : dx > 0 ? 1 : dy < 0 ? 0 : dy > 0 ? 2 : 2);
494 boolean result = TRUE;
496 if (!dx && !dy) /* no direction specified */
499 if (dx && dy && ply->joy_snap) /* more than one direction specified */
502 if (!ply->joy_snap) /* player wants to move */
504 int element = cave[x][y];
508 /* fire is released */
512 cave[x][y] = Zplayer;
513 next[x][y] = Zplayer;
524 play_element_sound(x, y, SOUND_blank, Xblank);
525 ply->anim = PLY_walk_n + anim;
539 if (cave[x+1][y-1] == Xblank)
540 cave[x+1][y-1] = Xsplash_e;
541 if (cave[x-1][y-1] == Xblank)
542 cave[x-1][y-1] = Xsplash_w;
543 play_element_sound(x, y, SOUND_acid, Xacid_1);
564 ply->anim = PLY_walk_n + anim;
570 cave[x][y] = (dy ? (dy < 0 ? Ygrass_nB : Ygrass_sB) :
571 (dx > 0 ? Ygrass_eB : Ygrass_wB));
572 next[x][y] = Zplayer;
573 play_element_sound(x, y, SOUND_dirt, Xgrass);
574 ply->anim = PLY_walk_n + anim;
580 cave[x][y] = (dy ? (dy < 0 ? Ydirt_nB : Ydirt_sB) :
581 (dx > 0 ? Ydirt_eB : Ydirt_wB));
582 next[x][y] = Zplayer;
583 play_element_sound(x, y, SOUND_dirt, Xdirt);
584 ply->anim = PLY_walk_n + anim;
591 cave[x][y] = Ydiamond_blank;
592 next[x][y] = Zplayer;
593 play_element_sound(x, y, SOUND_collect, element);
594 lev.score += lev.diamond_score;
595 lev.gems_needed = lev.gems_needed < 3 ? 0 : lev.gems_needed - 3;
596 game.snapshot.collected_item = TRUE;
597 ply->anim = PLY_walk_n + anim;
604 cave[x][y] = Yemerald_blank;
605 next[x][y] = Zplayer;
606 play_element_sound(x, y, SOUND_collect, element);
607 lev.score += lev.emerald_score;
608 lev.gems_needed = lev.gems_needed < 1 ? 0 : lev.gems_needed - 1;
609 game.snapshot.collected_item = TRUE;
610 ply->anim = PLY_walk_n + anim;
616 cave[x][y] = Ydynamite_blank;
617 next[x][y] = Zplayer;
618 play_element_sound(x, y, SOUND_collect, element);
619 lev.score += lev.dynamite_score;
620 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
621 ply->anim = PLY_walk_n + anim;
628 cave[x][y] = Ykey_1_blank;
633 cave[x][y] = Ykey_2_blank;
638 cave[x][y] = Ykey_3_blank;
643 cave[x][y] = Ykey_4_blank;
648 cave[x][y] = Ykey_5_blank;
653 cave[x][y] = Ykey_6_blank;
658 cave[x][y] = Ykey_7_blank;
663 cave[x][y] = Ykey_8_blank;
668 next[x][y] = Zplayer;
669 play_element_sound(x, y, SOUND_collect, element);
670 lev.score += lev.key_score;
671 ply->anim = PLY_walk_n + anim;
677 cave[x][y] = Ylenses_blank;
678 next[x][y] = Zplayer;
679 play_element_sound(x, y, SOUND_collect, element);
680 lev.score += lev.lenses_score;
681 lev.lenses_cnt = lev.lenses_time;
682 ply->anim = PLY_walk_n + anim;
688 cave[x][y] = Ymagnify_blank;
689 next[x][y] = Zplayer;
690 play_element_sound(x, y, SOUND_collect, element);
691 lev.score += lev.magnify_score;
692 lev.magnify_cnt = lev.magnify_time;
693 ply->anim = PLY_walk_n + anim;
702 switch (cave[x+dx][y])
715 cave[x+dx][y] = dx > 0 ? Ystone_e : Ystone_w;
716 next[x+dx][y] = Xstone_pause;
727 if (cave[x+dx+1][y-1] == Xblank)
728 cave[x+dx+1][y-1] = Xsplash_e;
729 if (cave[x+dx-1][y-1] == Xblank)
730 cave[x+dx-1][y-1] = Xsplash_w;
731 play_element_sound(x, y, SOUND_acid, Xacid_1);
735 cave[x][y] = dx > 0 ? Ystone_eB : Ystone_wB;
736 next[x][y] = Zplayer;
737 play_element_sound(x, y, SOUND_roll, Xstone);
742 ply->anim = PLY_push_n + anim;
749 switch (cave[x+dx][y])
762 cave[x+dx][y] = dx > 0 ? Ybomb_e : Ybomb_w;
763 next[x+dx][y] = Xbomb_pause;
774 if (cave[x+dx+1][y-1] == Xblank)
775 cave[x+dx+1][y-1] = Xsplash_e;
776 if (cave[x+dx-1][y-1] == Xblank)
777 cave[x+dx-1][y-1] = Xsplash_w;
778 play_element_sound(x, y, SOUND_acid, Xacid_1);
782 cave[x][y] = dx > 0 ? Ybomb_eB : Ybomb_wB;
783 next[x][y] = Zplayer;
784 play_element_sound(x, y, SOUND_roll, Xbomb);
789 ply->anim = PLY_push_n + anim;
796 switch (cave[x+dx][y])
809 cave[x+dx][y] = dx > 0 ? Ynut_e : Ynut_w;
810 next[x+dx][y] = Xnut_pause;
821 if (cave[x+dx+1][y-1] == Xblank)
822 cave[x+dx+1][y-1] = Xsplash_e;
823 if (cave[x+dx-1][y-1] == Xblank)
824 cave[x+dx-1][y-1] = Xsplash_w;
825 play_element_sound(x, y, SOUND_acid, Xacid_1);
829 cave[x][y] = dx > 0 ? Ynut_eB : Ynut_wB;
830 next[x][y] = Zplayer;
831 play_element_sound(x, y, SOUND_roll, Xnut);
836 ply->anim = PLY_push_n + anim;
843 switch (cave[x+dx][y])
856 cave[x+dx][y] = dx > 0 ? Yspring_e : Yspring_w;
857 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
868 if (cave[x+dx+1][y-1] == Xblank)
869 cave[x+dx+1][y-1] = Xsplash_e;
870 if (cave[x+dx-1][y-1] == Xblank)
871 cave[x+dx-1][y-1] = Xsplash_w;
872 play_element_sound(x, y, SOUND_acid, Xacid_1);
876 cave[x][y] = dx > 0 ? Yspring_eB : Yspring_wB;
877 next[x][y] = Zplayer;
878 play_element_sound(x, y, SOUND_roll, Xspring);
884 cave[x][y] = dx > 0 ? Yspring_alien_eB : Yspring_alien_wB;
885 cave[x+dx][y] = dx > 0 ? Yspring_alien_e : Yspring_alien_w;
886 next[x][y] = Zplayer;
887 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
888 play_element_sound(x, y, SOUND_slurp, Xalien);
889 lev.score += lev.slurp_score;
894 ply->anim = PLY_push_n + anim;
901 case Xsand_stonein_1:
902 case Xsand_stonein_2:
903 case Xsand_stonein_3:
904 case Xsand_stonein_4:
908 ply->anim = PLY_push_n + anim;
912 switch (cave[x+dx][y+dy])
925 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yballoon_n : Yballoon_s) :
926 (dx > 0 ? Yballoon_e : Yballoon_w));
927 next[x+dx][y+dy] = Xballoon;
938 if (cave[x+dx+1][y+dy-1] == Xblank)
939 cave[x+dx+1][y+dy-1] = Xsplash_e;
940 if (cave[x+dx-1][y+dy-1] == Xblank)
941 cave[x+dx-1][y+dy-1] = Xsplash_w;
942 play_element_sound(x, y, SOUND_acid, Xacid_1);
946 cave[x][y] = (dy ? (dy < 0 ? Yballoon_nB : Yballoon_sB) :
947 (dx > 0 ? Yballoon_eB : Yballoon_wB));
948 next[x][y] = Zplayer;
949 play_element_sound(x, y, SOUND_push, Xballoon);
955 ply->anim = PLY_push_n + anim;
967 switch (cave[x+dx][y+dy])
980 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yandroid_n : Yandroid_s) :
981 (dx > 0 ? Yandroid_e : Yandroid_w));
982 next[x+dx][y+dy] = (dy ? (dy < 0 ? Xandroid_2_n : Xandroid_2_s) :
983 (dx > 0 ? Xandroid_2_e : Xandroid_2_w));
994 if (cave[x+dx+1][y+dy-1] == Xblank)
995 cave[x+dx+1][y+dy-1] = Xsplash_e;
996 if (cave[x+dx-1][y+dy-1] == Xblank)
997 cave[x+dx-1][y+dy-1] = Xsplash_w;
998 play_element_sound(x, y, SOUND_acid, Xacid_1);
1002 cave[x][y] = (dy ? (dy < 0 ? Yandroid_nB : Yandroid_sB) :
1003 (dx > 0 ? Yandroid_eB : Yandroid_wB));
1004 next[x][y] = Zplayer;
1005 play_element_sound(x, y, SOUND_push, Xandroid);
1011 ply->anim = PLY_push_n + anim;
1016 if (ply->keys & 0x01)
1023 if (ply->keys & 0x02)
1030 if (ply->keys & 0x04)
1037 if (ply->keys & 0x08)
1044 if (ply->keys & 0x10)
1051 if (ply->keys & 0x20)
1058 if (ply->keys & 0x40)
1065 if (ply->keys & 0x80)
1072 if (!is_blank[cave[x+dx][y+dy]])
1075 if (!is_fake_acid[cave[x+dx][y+dy]])
1077 cave[x+dx][y+dy] = Zplayer;
1078 next[x+dx][y+dy] = Zplayer;
1081 play_element_sound(x, y, SOUND_door, element);
1082 ply->anim = PLY_walk_n + anim;
1088 play_element_sound(x, y, SOUND_press, element);
1089 lev.wheel_cnt = lev.wheel_time;
1095 lev.wind_direction = 0;
1099 lev.wind_direction = 1;
1103 lev.wind_direction = 2;
1107 lev.wind_direction = 3;
1111 lev.wind_direction = dy ? (dy < 0 ? 0 : 2) : (dx > 0 ? 1 : 3);
1116 play_element_sound(x, y, SOUND_press, element);
1117 lev.wind_cnt = lev.wind_time;
1121 play_element_sound(x, y, SOUND_press, element);
1126 play_element_sound(x, y, SOUND_press, element);
1127 lev.ball_cnt = lev.ball_time;
1128 lev.ball_active = !lev.ball_active;
1132 cave[x][y] = Yplant;
1133 next[x][y] = Xplant;
1134 play_element_sound(x, y, SOUND_blank, Xplant);
1135 ply->anim = PLY_walk_n + anim;
1146 game_em.level_solved = TRUE;
1148 ply->anim = PLY_walk_n + anim;
1155 if (ply->x == oldx && ply->y == oldy) /* no movement */
1158 else /* player wants to snap */
1160 int element = cave[x][y];
1164 /* fire is pressed */
1167 cave[x][y] = Ygrass_blank;
1168 next[x][y] = Xblank;
1169 play_element_sound(x, y, SOUND_dirt, element);
1170 ply->anim = PLY_shoot_n + anim;
1174 cave[x][y] = Ydirt_blank;
1175 next[x][y] = Xblank;
1176 play_element_sound(x, y, SOUND_dirt, element);
1177 ply->anim = PLY_shoot_n + anim;
1181 case Xdiamond_pause:
1182 cave[x][y] = Ydiamond_blank;
1183 next[x][y] = Xblank;
1184 play_element_sound(x, y, SOUND_collect, element);
1185 lev.score += lev.diamond_score;
1186 lev.gems_needed = lev.gems_needed < 3 ? 0 : lev.gems_needed - 3;
1187 game.snapshot.collected_item = TRUE;
1188 ply->anim = PLY_walk_n + anim;
1192 case Xemerald_pause:
1193 cave[x][y] = Yemerald_blank;
1194 next[x][y] = Xblank;
1195 play_element_sound(x, y, SOUND_collect, element);
1196 lev.score += lev.emerald_score;
1197 lev.gems_needed = lev.gems_needed < 1 ? 0 : lev.gems_needed - 1;
1198 game.snapshot.collected_item = TRUE;
1199 ply->anim = PLY_walk_n + anim;
1203 cave[x][y] = Ydynamite_blank;
1204 next[x][y] = Xblank;
1205 play_element_sound(x, y, SOUND_collect, element);
1206 lev.score += lev.dynamite_score;
1207 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
1208 ply->anim = PLY_walk_n + anim;
1213 cave[x][y] = Ykey_1_blank;
1218 cave[x][y] = Ykey_2_blank;
1223 cave[x][y] = Ykey_3_blank;
1228 cave[x][y] = Ykey_4_blank;
1233 cave[x][y] = Ykey_5_blank;
1238 cave[x][y] = Ykey_6_blank;
1243 cave[x][y] = Ykey_7_blank;
1248 cave[x][y] = Ykey_8_blank;
1253 next[x][y] = Xblank;
1254 play_element_sound(x, y, SOUND_collect, element);
1255 lev.score += lev.key_score;
1256 ply->anim = PLY_walk_n + anim;
1260 cave[x][y] = Ylenses_blank;
1261 next[x][y] = Xblank;
1262 play_element_sound(x, y, SOUND_collect, element);
1263 lev.score += lev.lenses_score;
1264 lev.lenses_cnt = lev.lenses_time;
1265 ply->anim = PLY_walk_n + anim;
1269 cave[x][y] = Ymagnify_blank;
1270 next[x][y] = Xblank;
1271 play_element_sound(x, y, SOUND_collect, element);
1272 lev.score += lev.magnify_score;
1273 lev.magnify_cnt = lev.magnify_time;
1274 ply->anim = PLY_walk_n + anim;
1285 static void check_player(struct PLAYER *ply)
1293 game_em.last_player_direction[ply->num] = MV_NONE;
1295 if (ply->joy_w) /* west */
1300 else if (ply->joy_e) /* east */
1306 if (ply->joy_n) /* north */
1311 else if (ply->joy_s) /* south */
1323 boolean players_visible_before_move;
1324 boolean players_visible_after_move;
1327 players_visible_before_move = checkIfAllPlayersFitToScreen();
1332 players_visible_after_move = checkIfAllPlayersFitToScreen();
1335 player is allowed to move only in the following cases:
1336 - it is not needed to display all players (not focussed to all players)
1337 - all players are (still or again) visible after the move
1338 - some players were already outside visible screen area before the move
1340 can_move = (game.centered_player_nr != -1 ||
1341 players_visible_after_move ||
1342 !players_visible_before_move);
1358 if (dx == 0 && dy == 0)
1360 ply->joy_stick = FALSE;
1364 if (++ply->dynamite_cnt == 5 && ply->dynamite)
1366 cave[x][y] = Xdynamite_1;
1367 play_element_sound(x, y, SOUND_dynamite, Xdynamite_1);
1373 ply->dynamite_cnt = 0;
1376 /* be a bit more random if the player doesn't move */
1377 game_em.random += 7;
1382 ply->joy_stick = TRUE;
1388 ply->dynamite_cnt = 0; /* reset dynamite timer if we move */
1390 if (!ply->joy_snap) /* player wants to move */
1392 boolean moved = FALSE;
1394 if (ply->last_move_dir & MV_HORIZONTAL)
1396 if (!(moved = player_digfield(ply, 0, dy)))
1397 moved = player_digfield(ply, dx, 0);
1401 if (!(moved = player_digfield(ply, dx, 0)))
1402 moved = player_digfield(ply, 0, dy);
1408 ply->last_move_dir = (dx < 0 ? MV_LEFT : MV_RIGHT);
1409 else if (oldy != ply->y)
1410 ply->last_move_dir = (dy < 0 ? MV_UP : MV_DOWN);
1412 game_em.any_player_moving = TRUE;
1413 game_em.last_moving_player = ply->num;
1414 game_em.last_player_direction[ply->num] = ply->last_move_dir;
1417 else /* player wants to snap */
1419 game_em.any_player_snapping = player_digfield(ply, dx, dy);
1423 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
1425 int distance, distance_shortest = CAVE_WIDTH + CAVE_HEIGHT;
1428 /* default values if no players are alive anymore */
1432 for (i = 0; i < MAX_PLAYERS; i++)
1437 distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
1439 if (distance < distance_shortest)
1444 distance_shortest = distance;
1449 static void Lacid_1(int x, int y)
1451 next[x][y] = Xacid_2;
1454 static void Lacid_2(int x, int y)
1456 next[x][y] = Xacid_3;
1459 static void Lacid_3(int x, int y)
1461 next[x][y] = Xacid_4;
1464 static void Lacid_4(int x, int y)
1466 next[x][y] = Xacid_5;
1469 static void Lacid_5(int x, int y)
1471 next[x][y] = Xacid_6;
1474 static void Lacid_6(int x, int y)
1476 next[x][y] = Xacid_7;
1479 static void Lacid_7(int x, int y)
1481 next[x][y] = Xacid_8;
1484 static void Lacid_8(int x, int y)
1486 next[x][y] = Xacid_1;
1489 static void Lfake_acid_1(int x, int y)
1491 next[x][y] = Xfake_acid_2;
1494 static void Lfake_acid_2(int x, int y)
1496 next[x][y] = Xfake_acid_3;
1499 static void Lfake_acid_3(int x, int y)
1501 next[x][y] = Xfake_acid_4;
1504 static void Lfake_acid_4(int x, int y)
1506 next[x][y] = Xfake_acid_5;
1509 static void Lfake_acid_5(int x, int y)
1511 next[x][y] = Xfake_acid_6;
1514 static void Lfake_acid_6(int x, int y)
1516 next[x][y] = Xfake_acid_7;
1519 static void Lfake_acid_7(int x, int y)
1521 next[x][y] = Xfake_acid_8;
1524 static void Lfake_acid_8(int x, int y)
1526 next[x][y] = Xfake_acid_1;
1529 static void Landroid(int x, int y)
1533 if (lev.android_clone_cnt == 0)
1535 if (!is_blank[cave[x-1][y-1]] &&
1536 !is_blank[cave[x][y-1]] &&
1537 !is_blank[cave[x+1][y-1]] &&
1538 !is_blank[cave[x-1][y]] &&
1539 !is_blank[cave[x+1][y]] &&
1540 !is_blank[cave[x-1][y+1]] &&
1541 !is_blank[cave[x][y+1]] &&
1542 !is_blank[cave[x+1][y+1]])
1547 /* randomly find an object to clone */
1549 case 0: /* S,NE,W,NW,SE,E,SW,N */
1550 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1551 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1552 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1553 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1554 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1555 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1556 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1557 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1560 case 1: /* NW,SE,N,S,NE,SW,E,W */
1561 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1562 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1563 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1564 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1565 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1566 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1567 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1568 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1571 case 2: /* SW,E,S,W,N,NW,SE,NE */
1572 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1573 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1574 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1575 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1576 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1577 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1578 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1579 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1582 case 3: /* N,SE,NE,E,W,S,NW,SW */
1583 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1584 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1585 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1586 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1587 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1588 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1589 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1590 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1593 case 4: /* SE,NW,E,NE,SW,W,N,S */
1594 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1595 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1596 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1597 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1598 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1599 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1600 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1601 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1604 case 5: /* NE,W,SE,SW,S,N,E,NW */
1605 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1606 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1607 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1608 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1609 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1610 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1611 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1612 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1615 case 6: /* E,N,SW,S,NW,NE,SE,W */
1616 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1617 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1618 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1619 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1620 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1621 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1622 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1623 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1626 case 7: /* W,SW,NW,N,E,SE,NE,S */
1627 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1628 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1629 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1630 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1631 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1632 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1633 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1634 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1638 next[x][y] = temp; /* the item we chose to clone */
1639 play_element_sound(x, y, SOUND_android_clone, temp);
1643 /* randomly find a direction to move */
1645 case 0: /* S,NE,W,NW,SE,E,SW,N */
1646 if (is_blank[cave[x][y+1]]) goto android_s;
1647 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1648 if (is_blank[cave[x-1][y]]) goto android_w;
1649 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1650 if (is_blank[cave[x+1][y+1]]) goto android_se;
1651 if (is_blank[cave[x+1][y]]) goto android_e;
1652 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1653 if (is_blank[cave[x][y-1]]) goto android_n;
1656 case 1: /* NW,SE,N,S,NE,SW,E,W */
1657 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1658 if (is_blank[cave[x+1][y+1]]) goto android_se;
1659 if (is_blank[cave[x][y-1]]) goto android_n;
1660 if (is_blank[cave[x][y+1]]) goto android_s;
1661 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1662 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1663 if (is_blank[cave[x+1][y]]) goto android_e;
1664 if (is_blank[cave[x-1][y]]) goto android_w;
1667 case 2: /* SW,E,S,W,N,NW,SE,NE */
1668 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1669 if (is_blank[cave[x+1][y]]) goto android_e;
1670 if (is_blank[cave[x][y+1]]) goto android_s;
1671 if (is_blank[cave[x-1][y]]) goto android_w;
1672 if (is_blank[cave[x][y-1]]) goto android_n;
1673 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1674 if (is_blank[cave[x+1][y+1]]) goto android_se;
1675 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1678 case 3: /* N,SE,NE,E,W,S,NW,SW */
1679 if (is_blank[cave[x][y-1]]) goto android_n;
1680 if (is_blank[cave[x+1][y+1]]) goto android_se;
1681 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1682 if (is_blank[cave[x+1][y]]) goto android_e;
1683 if (is_blank[cave[x-1][y]]) goto android_w;
1684 if (is_blank[cave[x][y+1]]) goto android_s;
1685 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1686 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1689 case 4: /* SE,NW,E,NE,SW,W,N,S */
1690 if (is_blank[cave[x+1][y+1]]) goto android_se;
1691 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1692 if (is_blank[cave[x+1][y]]) goto android_e;
1693 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1694 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1695 if (is_blank[cave[x-1][y]]) goto android_w;
1696 if (is_blank[cave[x][y-1]]) goto android_n;
1697 if (is_blank[cave[x][y+1]]) goto android_s;
1700 case 5: /* NE,W,SE,SW,S,N,E,NW */
1701 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1702 if (is_blank[cave[x-1][y]]) goto android_w;
1703 if (is_blank[cave[x+1][y+1]]) goto android_se;
1704 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1705 if (is_blank[cave[x][y+1]]) goto android_s;
1706 if (is_blank[cave[x][y-1]]) goto android_n;
1707 if (is_blank[cave[x+1][y]]) goto android_e;
1708 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1711 case 6: /* E,N,SW,S,NW,NE,SE,W */
1712 if (is_blank[cave[x+1][y]]) goto android_e;
1713 if (is_blank[cave[x][y-1]]) goto android_n;
1714 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1715 if (is_blank[cave[x][y+1]]) goto android_s;
1716 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1717 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1718 if (is_blank[cave[x+1][y+1]]) goto android_se;
1719 if (is_blank[cave[x-1][y]]) goto android_w;
1722 case 7: /* W,SW,NW,N,E,SE,NE,S */
1723 if (is_blank[cave[x-1][y]]) goto android_w;
1724 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1725 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1726 if (is_blank[cave[x][y-1]]) goto android_n;
1727 if (is_blank[cave[x+1][y]]) goto android_e;
1728 if (is_blank[cave[x+1][y+1]]) goto android_se;
1729 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1730 if (is_blank[cave[x][y+1]]) goto android_s;
1736 if (lev.android_move_cnt == 0)
1738 if (cave[x-1][y-1] == Zplayer ||
1739 cave[x][y-1] == Zplayer ||
1740 cave[x+1][y-1] == Zplayer ||
1741 cave[x-1][y] == Zplayer ||
1742 cave[x+1][y] == Zplayer ||
1743 cave[x-1][y+1] == Zplayer ||
1744 cave[x][y+1] == Zplayer ||
1745 cave[x+1][y+1] == Zplayer)
1748 set_nearest_player_xy(x, y, &dx, &dy);
1750 next[x][y] = Xblank; /* assume we will move */
1751 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1757 /* attempt clockwise move first if direct path is blocked */
1759 case 0: /* north west */
1760 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1761 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1762 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1766 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1767 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1768 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1771 case 2: /* north east */
1772 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1773 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1774 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1778 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1779 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1780 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1783 case 4: /* nowhere */
1787 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1788 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1789 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1792 case 6: /* south west */
1793 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1794 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1795 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1799 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1800 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1801 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1804 case 8: /* south east */
1805 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1806 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1807 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1815 /* attempt counterclockwise move first if direct path is blocked */
1817 case 0: /* north west */
1818 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1819 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1820 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1824 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1825 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1826 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1829 case 2: /* north east */
1830 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1831 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1832 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1836 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1837 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1838 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1841 case 4: /* nowhere */
1845 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1846 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1847 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1850 case 6: /* south west */
1851 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1852 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1853 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1857 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1858 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1859 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1862 case 8: /* south east */
1863 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1864 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1865 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1872 next[x][y] = Xandroid;
1876 cave[x][y] = Yandroid_nB;
1877 cave[x][y-1] = Yandroid_n;
1878 next[x][y-1] = Xandroid;
1879 play_element_sound(x, y, SOUND_android_move, Xandroid);
1883 cave[x][y] = Yandroid_neB;
1884 cave[x+1][y-1] = Yandroid_ne;
1885 next[x+1][y-1] = Xandroid;
1886 play_element_sound(x, y, SOUND_android_move, Xandroid);
1890 cave[x][y] = Yandroid_eB;
1891 cave[x+1][y] = Yandroid_e;
1892 next[x+1][y] = Xandroid;
1893 play_element_sound(x, y, SOUND_android_move, Xandroid);
1897 cave[x][y] = Yandroid_seB;
1898 cave[x+1][y+1] = Yandroid_se;
1899 next[x+1][y+1] = Xandroid;
1900 play_element_sound(x, y, SOUND_android_move, Xandroid);
1904 cave[x][y] = Yandroid_sB;
1905 cave[x][y+1] = Yandroid_s;
1906 next[x][y+1] = Xandroid;
1907 play_element_sound(x, y, SOUND_android_move, Xandroid);
1911 cave[x][y] = Yandroid_swB;
1912 cave[x-1][y+1] = Yandroid_sw;
1913 next[x-1][y+1] = Xandroid;
1914 play_element_sound(x, y, SOUND_android_move, Xandroid);
1918 cave[x][y] = Yandroid_wB;
1919 cave[x-1][y] = Yandroid_w;
1920 next[x-1][y] = Xandroid;
1921 play_element_sound(x, y, SOUND_android_move, Xandroid);
1925 cave[x][y] = Yandroid_nwB;
1926 cave[x-1][y-1] = Yandroid_nw;
1927 next[x-1][y-1] = Xandroid;
1928 play_element_sound(x, y, SOUND_android_move, Xandroid);
1932 static void Landroid_1_n(int x, int y)
1934 switch (cave[x][y-1])
1947 cave[x][y] = Yandroid_nB;
1948 next[x][y] = Xblank;
1949 cave[x][y-1] = Yandroid_n;
1950 next[x][y-1] = Xandroid;
1951 play_element_sound(x, y, SOUND_android_move, Xandroid_1_n);
1962 cave[x][y] = Yandroid_nB;
1963 next[x][y] = Xblank;
1964 if (cave[x+1][y-2] == Xblank)
1965 cave[x+1][y-2] = Xsplash_e;
1966 if (cave[x-1][y-2] == Xblank)
1967 cave[x-1][y-2] = Xsplash_w;
1968 play_element_sound(x, y, SOUND_acid, Xacid_1);
1977 static void Landroid_2_n(int x, int y)
1979 switch (cave[x][y-1])
1992 cave[x][y] = Yandroid_nB;
1993 next[x][y] = Xblank;
1994 cave[x][y-1] = Yandroid_n;
1995 next[x][y-1] = Xandroid_1_n;
1996 play_element_sound(x, y, SOUND_android_move, Xandroid_2_n);
2007 cave[x][y] = Yandroid_nB;
2008 next[x][y] = Xblank;
2009 if (cave[x+1][y-2] == Xblank)
2010 cave[x+1][y-2] = Xsplash_e;
2011 if (cave[x-1][y-2] == Xblank)
2012 cave[x-1][y-2] = Xsplash_w;
2013 play_element_sound(x, y, SOUND_acid, Xacid_1);
2022 static void Landroid_1_e(int x, int y)
2024 switch (cave[x+1][y])
2037 cave[x][y] = Yandroid_eB;
2038 next[x][y] = Xblank;
2039 cave[x+1][y] = Yandroid_e;
2040 next[x+1][y] = Xandroid;
2041 play_element_sound(x, y, SOUND_android_move, Xandroid_1_e);
2052 cave[x][y] = Yandroid_eB;
2053 next[x][y] = Xblank;
2054 if (cave[x+2][y-1] == Xblank)
2055 cave[x+2][y-1] = Xsplash_e;
2056 if (cave[x][y-1] == Xblank)
2057 cave[x][y-1] = Xsplash_w;
2058 play_element_sound(x, y, SOUND_acid, Xacid_1);
2067 static void Landroid_2_e(int x, int y)
2069 switch (cave[x+1][y])
2082 cave[x][y] = Yandroid_eB;
2083 next[x][y] = Xblank;
2084 cave[x+1][y] = Yandroid_e;
2085 next[x+1][y] = Xandroid_1_e;
2086 play_element_sound(x, y, SOUND_android_move, Xandroid_2_e);
2097 cave[x][y] = Yandroid_eB;
2098 next[x][y] = Xblank;
2099 if (cave[x+2][y-1] == Xblank)
2100 cave[x+2][y-1] = Xsplash_e;
2101 if (cave[x][y-1] == Xblank)
2102 cave[x][y-1] = Xsplash_w;
2103 play_element_sound(x, y, SOUND_acid, Xacid_1);
2112 static void Landroid_1_s(int x, int y)
2114 switch (cave[x][y+1])
2127 cave[x][y] = Yandroid_sB;
2128 next[x][y] = Xblank;
2129 cave[x][y+1] = Yandroid_s;
2130 next[x][y+1] = Xandroid;
2131 play_element_sound(x, y, SOUND_android_move, Xandroid_1_s);
2142 cave[x][y] = Yandroid_sB;
2143 next[x][y] = Xblank;
2144 if (cave[x+1][y] == Xblank)
2145 cave[x+1][y] = Xsplash_e;
2146 if (cave[x-1][y] == Xblank)
2147 cave[x-1][y] = Xsplash_w;
2148 play_element_sound(x, y, SOUND_acid, Xacid_1);
2157 static void Landroid_2_s(int x, int y)
2159 switch (cave[x][y+1])
2172 cave[x][y] = Yandroid_sB;
2173 next[x][y] = Xblank;
2174 cave[x][y+1] = Yandroid_s;
2175 next[x][y+1] = Xandroid_1_s;
2176 play_element_sound(x, y, SOUND_android_move, Xandroid_2_s);
2187 cave[x][y] = Yandroid_sB;
2188 next[x][y] = Xblank;
2189 if (cave[x+1][y] == Xblank)
2190 cave[x+1][y] = Xsplash_e;
2191 if (cave[x-1][y] == Xblank)
2192 cave[x-1][y] = Xsplash_w;
2193 play_element_sound(x, y, SOUND_acid, Xacid_1);
2202 static void Landroid_1_w(int x, int y)
2204 switch (cave[x-1][y])
2217 cave[x][y] = Yandroid_wB;
2218 next[x][y] = Xblank;
2219 cave[x-1][y] = Yandroid_w;
2220 next[x-1][y] = Xandroid;
2221 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2232 cave[x][y] = Yandroid_wB;
2233 next[x][y] = Xblank;
2234 if (cave[x][y-1] == Xblank)
2235 cave[x][y-1] = Xsplash_e;
2236 if (cave[x-2][y-1] == Xblank)
2237 cave[x-2][y-1] = Xsplash_w;
2238 play_element_sound(x, y, SOUND_acid, Xacid_1);
2247 static void Landroid_2_w(int x, int y)
2249 switch (cave[x-1][y])
2262 cave[x][y] = Yandroid_wB;
2263 next[x][y] = Xblank;
2264 cave[x-1][y] = Yandroid_w;
2265 next[x-1][y] = Xandroid_1_w;
2266 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2277 cave[x][y] = Yandroid_wB;
2278 next[x][y] = Xblank;
2279 if (cave[x][y-1] == Xblank)
2280 cave[x][y-1] = Xsplash_e;
2281 if (cave[x-2][y-1] == Xblank)
2282 cave[x-2][y-1] = Xsplash_w;
2283 play_element_sound(x, y, SOUND_acid, Xacid_1);
2292 static void Leater_n(int x, int y)
2294 if (cave[x+1][y] == Xdiamond)
2296 cave[x+1][y] = Ydiamond_blank;
2297 next[x+1][y] = Xblank;
2298 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2302 if (cave[x][y+1] == Xdiamond)
2304 cave[x][y+1] = Ydiamond_blank;
2305 next[x][y+1] = Xblank;
2306 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2310 if (cave[x-1][y] == Xdiamond)
2312 cave[x-1][y] = Ydiamond_blank;
2313 next[x-1][y] = Xblank;
2314 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2318 if (cave[x][y-1] == Xdiamond)
2320 cave[x][y-1] = Ydiamond_blank;
2321 next[x][y-1] = Xblank;
2322 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2326 switch (cave[x][y-1])
2342 cave[x][y] = Yeater_nB;
2343 next[x][y] = Xblank;
2344 cave[x][y-1] = Yeater_n;
2345 next[x][y-1] = Xeater_n;
2356 cave[x][y] = Yeater_nB;
2357 next[x][y] = Xblank;
2358 if (cave[x+1][y-2] == Xblank)
2359 cave[x+1][y-2] = Xsplash_e;
2360 if (cave[x-1][y-2] == Xblank)
2361 cave[x-1][y-2] = Xsplash_w;
2362 play_element_sound(x, y, SOUND_acid, Xacid_1);
2366 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2367 play_element_sound(x, y, SOUND_eater, Xeater_n);
2372 static void Leater_e(int x, int y)
2374 if (cave[x][y+1] == Xdiamond)
2376 cave[x][y+1] = Ydiamond_blank;
2377 next[x][y+1] = Xblank;
2378 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2382 if (cave[x-1][y] == Xdiamond)
2384 cave[x-1][y] = Ydiamond_blank;
2385 next[x-1][y] = Xblank;
2386 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2390 if (cave[x][y-1] == Xdiamond)
2392 cave[x][y-1] = Ydiamond_blank;
2393 next[x][y-1] = Xblank;
2394 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2398 if (cave[x+1][y] == Xdiamond)
2400 cave[x+1][y] = Ydiamond_blank;
2401 next[x+1][y] = Xblank;
2402 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2406 switch (cave[x+1][y])
2422 cave[x][y] = Yeater_eB;
2423 next[x][y] = Xblank;
2424 cave[x+1][y] = Yeater_e;
2425 next[x+1][y] = Xeater_e;
2436 cave[x][y] = Yeater_eB;
2437 next[x][y] = Xblank;
2438 if (cave[x+2][y-1] == Xblank)
2439 cave[x+2][y-1] = Xsplash_e;
2440 if (cave[x][y-1] == Xblank)
2441 cave[x][y-1] = Xsplash_w;
2442 play_element_sound(x, y, SOUND_acid, Xacid_1);
2446 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2447 play_element_sound(x, y, SOUND_eater, Xeater_e);
2452 static void Leater_s(int x, int y)
2454 if (cave[x-1][y] == Xdiamond)
2456 cave[x-1][y] = Ydiamond_blank;
2457 next[x-1][y] = Xblank;
2458 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2462 if (cave[x][y-1] == Xdiamond)
2464 cave[x][y-1] = Ydiamond_blank;
2465 next[x][y-1] = Xblank;
2466 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2470 if (cave[x+1][y] == Xdiamond)
2472 cave[x+1][y] = Ydiamond_blank;
2473 next[x+1][y] = Xblank;
2474 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2478 if (cave[x][y+1] == Xdiamond)
2480 cave[x][y+1] = Ydiamond_blank;
2481 next[x][y+1] = Xblank;
2482 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2486 switch (cave[x][y+1])
2502 cave[x][y] = Yeater_sB;
2503 next[x][y] = Xblank;
2504 cave[x][y+1] = Yeater_s;
2505 next[x][y+1] = Xeater_s;
2516 cave[x][y] = Yeater_sB;
2517 next[x][y] = Xblank;
2518 if (cave[x+1][y] == Xblank)
2519 cave[x+1][y] = Xsplash_e;
2520 if (cave[x-1][y] == Xblank)
2521 cave[x-1][y] = Xsplash_w;
2522 play_element_sound(x, y, SOUND_acid, Xacid_1);
2526 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2527 play_element_sound(x, y, SOUND_eater, Xeater_s);
2532 static void Leater_w(int x, int y)
2534 if (cave[x][y-1] == Xdiamond)
2536 cave[x][y-1] = Ydiamond_blank;
2537 next[x][y-1] = Xblank;
2538 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2542 if (cave[x+1][y] == Xdiamond)
2544 cave[x+1][y] = Ydiamond_blank;
2545 next[x+1][y] = Xblank;
2546 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2550 if (cave[x][y+1] == Xdiamond)
2552 cave[x][y+1] = Ydiamond_blank;
2553 next[x][y+1] = Xblank;
2554 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2558 if (cave[x-1][y] == Xdiamond)
2560 cave[x-1][y] = Ydiamond_blank;
2561 next[x-1][y] = Xblank;
2562 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2566 switch (cave[x-1][y])
2582 cave[x][y] = Yeater_wB;
2583 next[x][y] = Xblank;
2584 cave[x-1][y] = Yeater_w;
2585 next[x-1][y] = Xeater_w;
2596 cave[x][y] = Yeater_wB;
2597 next[x][y] = Xblank;
2598 if (cave[x][y-1] == Xblank)
2599 cave[x][y-1] = Xsplash_e;
2600 if (cave[x-2][y-1] == Xblank)
2601 cave[x-2][y-1] = Xsplash_w;
2602 play_element_sound(x, y, SOUND_acid, Xacid_1);
2606 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2607 play_element_sound(x, y, SOUND_eater, Xeater_w);
2612 static void Lalien(int x, int y)
2623 set_nearest_player_xy(x, y, &dx, &dy);
2630 switch (cave[x][y-1])
2646 cave[x][y] = Yalien_nB;
2647 next[x][y] = Xblank;
2648 cave[x][y-1] = Yalien_n;
2649 next[x][y-1] = Xalien_pause;
2650 play_element_sound(x, y, SOUND_alien, Xalien);
2661 cave[x][y] = Yalien_nB;
2662 next[x][y] = Xblank;
2663 if (cave[x+1][y-2] == Xblank)
2664 cave[x+1][y-2] = Xsplash_e;
2665 if (cave[x-1][y-2] == Xblank)
2666 cave[x-1][y-2] = Xsplash_w;
2667 play_element_sound(x, y, SOUND_acid, Xacid_1);
2673 switch (cave[x][y+1])
2689 cave[x][y] = Yalien_sB;
2690 next[x][y] = Xblank;
2691 cave[x][y+1] = Yalien_s;
2692 next[x][y+1] = Xalien_pause;
2693 play_element_sound(x, y, SOUND_alien, Xalien);
2704 cave[x][y] = Yalien_sB;
2705 next[x][y] = Xblank;
2706 if (cave[x+1][y] == Xblank)
2707 cave[x+1][y] = Xsplash_e;
2708 if (cave[x-1][y] == Xblank)
2709 cave[x-1][y] = Xsplash_w;
2710 play_element_sound(x, y, SOUND_acid, Xacid_1);
2719 switch (cave[x+1][y])
2735 cave[x][y] = Yalien_eB;
2736 next[x][y] = Xblank;
2737 cave[x+1][y] = Yalien_e;
2738 next[x+1][y] = Xalien_pause;
2739 play_element_sound(x, y, SOUND_alien, Xalien);
2750 cave[x][y] = Yalien_eB;
2751 next[x][y] = Xblank;
2752 if (cave[x+2][y-1] == Xblank)
2753 cave[x+2][y-1] = Xsplash_e;
2754 if (cave[x][y-1] == Xblank)
2755 cave[x][y-1] = Xsplash_w;
2756 play_element_sound(x, y, SOUND_acid, Xacid_1);
2762 switch (cave[x-1][y])
2778 cave[x][y] = Yalien_wB;
2779 next[x][y] = Xblank;
2780 cave[x-1][y] = Yalien_w;
2781 next[x-1][y] = Xalien_pause;
2782 play_element_sound(x, y, SOUND_alien, Xalien);
2793 cave[x][y] = Yalien_wB;
2794 next[x][y] = Xblank;
2795 if (cave[x][y-1] == Xblank)
2796 cave[x][y-1] = Xsplash_e;
2797 if (cave[x-2][y-1] == Xblank)
2798 cave[x-2][y-1] = Xsplash_w;
2799 play_element_sound(x, y, SOUND_acid, Xacid_1);
2806 static void Lalien_pause(int x, int y)
2808 next[x][y] = Xalien;
2811 static void Lbug_n(int x, int y)
2813 switch (cave[x][y-1])
2829 cave[x][y] = Ybug_nB;
2830 next[x][y] = Xblank;
2831 cave[x][y-1] = Ybug_n;
2832 next[x][y-1] = Xbug_1_n;
2833 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2844 cave[x][y] = Ybug_nB;
2845 next[x][y] = Xblank;
2846 if (cave[x+1][y-2] == Xblank)
2847 cave[x+1][y-2] = Xsplash_e;
2848 if (cave[x-1][y-2] == Xblank)
2849 cave[x-1][y-2] = Xsplash_w;
2850 play_element_sound(x, y, SOUND_acid, Xacid_1);
2854 cave[x][y] = Ybug_n_w;
2855 next[x][y] = Xbug_2_w;
2856 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2861 static void Lbug_1_n(int x, int y)
2863 if (is_amoeba[cave[x][y-1]] ||
2864 is_amoeba[cave[x+1][y]] ||
2865 is_amoeba[cave[x][y+1]] ||
2866 is_amoeba[cave[x-1][y]])
2874 switch (cave[x+1][y])
2898 cave[x][y] = Ybug_n_e;
2899 next[x][y] = Xbug_2_e;
2900 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2909 static void Lbug_2_n(int x, int y)
2911 if (is_amoeba[cave[x][y-1]] ||
2912 is_amoeba[cave[x+1][y]] ||
2913 is_amoeba[cave[x][y+1]] ||
2914 is_amoeba[cave[x-1][y]])
2925 static void Lbug_e(int x, int y)
2927 switch (cave[x+1][y])
2943 cave[x][y] = Ybug_eB;
2944 next[x][y] = Xblank;
2945 cave[x+1][y] = Ybug_e;
2946 next[x+1][y] = Xbug_1_e;
2947 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2958 cave[x][y] = Ybug_eB;
2959 next[x][y] = Xblank;
2960 if (cave[x+2][y-1] == Xblank)
2961 cave[x+2][y-1] = Xsplash_e;
2962 if (cave[x][y-1] == Xblank)
2963 cave[x][y-1] = Xsplash_w;
2964 play_element_sound(x, y, SOUND_acid, Xacid_1);
2968 cave[x][y] = Ybug_e_n;
2969 next[x][y] = Xbug_2_n;
2970 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2975 static void Lbug_1_e(int x, int y)
2977 if (is_amoeba[cave[x][y-1]] ||
2978 is_amoeba[cave[x+1][y]] ||
2979 is_amoeba[cave[x][y+1]] ||
2980 is_amoeba[cave[x-1][y]])
2988 switch (cave[x][y+1])
3012 cave[x][y] = Ybug_e_s;
3013 next[x][y] = Xbug_2_s;
3014 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
3023 static void Lbug_2_e(int x, int y)
3025 if (is_amoeba[cave[x][y-1]] ||
3026 is_amoeba[cave[x+1][y]] ||
3027 is_amoeba[cave[x][y+1]] ||
3028 is_amoeba[cave[x-1][y]])
3039 static void Lbug_s(int x, int y)
3041 switch (cave[x][y+1])
3057 cave[x][y] = Ybug_sB;
3058 next[x][y] = Xblank;
3059 cave[x][y+1] = Ybug_s;
3060 next[x][y+1] = Xbug_1_s;
3061 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3072 cave[x][y] = Ybug_sB;
3073 next[x][y] = Xblank;
3074 if (cave[x+1][y] == Xblank)
3075 cave[x+1][y] = Xsplash_e;
3076 if (cave[x-1][y] == Xblank)
3077 cave[x-1][y] = Xsplash_w;
3078 play_element_sound(x, y, SOUND_acid, Xacid_1);
3082 cave[x][y] = Ybug_s_e;
3083 next[x][y] = Xbug_2_e;
3084 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3089 static void Lbug_1_s(int x, int y)
3091 if (is_amoeba[cave[x][y-1]] ||
3092 is_amoeba[cave[x+1][y]] ||
3093 is_amoeba[cave[x][y+1]] ||
3094 is_amoeba[cave[x-1][y]])
3102 switch (cave[x-1][y])
3126 cave[x][y] = Ybug_s_w;
3127 next[x][y] = Xbug_2_w;
3128 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3137 static void Lbug_2_s(int x, int y)
3139 if (is_amoeba[cave[x][y-1]] ||
3140 is_amoeba[cave[x+1][y]] ||
3141 is_amoeba[cave[x][y+1]] ||
3142 is_amoeba[cave[x-1][y]])
3153 static void Lbug_w(int x, int y)
3155 switch (cave[x-1][y])
3171 cave[x][y] = Ybug_wB;
3172 next[x][y] = Xblank;
3173 cave[x-1][y] = Ybug_w;
3174 next[x-1][y] = Xbug_1_w;
3175 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3186 cave[x][y] = Ybug_wB;
3187 next[x][y] = Xblank;
3188 if (cave[x][y-1] == Xblank)
3189 cave[x][y-1] = Xsplash_e;
3190 if (cave[x-2][y-1] == Xblank)
3191 cave[x-2][y-1] = Xsplash_w;
3192 play_element_sound(x, y, SOUND_acid, Xacid_1);
3196 cave[x][y] = Ybug_w_s;
3197 next[x][y] = Xbug_2_s;
3198 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3203 static void Lbug_1_w(int x, int y)
3205 if (is_amoeba[cave[x][y-1]] ||
3206 is_amoeba[cave[x+1][y]] ||
3207 is_amoeba[cave[x][y+1]] ||
3208 is_amoeba[cave[x-1][y]])
3216 switch (cave[x][y-1])
3240 cave[x][y] = Ybug_w_n;
3241 next[x][y] = Xbug_2_n;
3242 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3251 static void Lbug_2_w(int x, int y)
3253 if (is_amoeba[cave[x][y-1]] ||
3254 is_amoeba[cave[x+1][y]] ||
3255 is_amoeba[cave[x][y+1]] ||
3256 is_amoeba[cave[x-1][y]])
3267 static void Ltank_n(int x, int y)
3269 switch (cave[x][y-1])
3285 cave[x][y] = Ytank_nB;
3286 next[x][y] = Xblank;
3287 cave[x][y-1] = Ytank_n;
3288 next[x][y-1] = Xtank_1_n;
3289 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3300 cave[x][y] = Ytank_nB;
3301 next[x][y] = Xblank;
3302 if (cave[x+1][y-2] == Xblank)
3303 cave[x+1][y-2] = Xsplash_e;
3304 if (cave[x-1][y-2] == Xblank)
3305 cave[x-1][y-2] = Xsplash_w;
3306 play_element_sound(x, y, SOUND_acid, Xacid_1);
3310 cave[x][y] = Ytank_n_e;
3311 next[x][y] = Xtank_2_e;
3312 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3317 static void Ltank_1_n(int x, int y)
3319 if (is_amoeba[cave[x][y-1]] ||
3320 is_amoeba[cave[x+1][y]] ||
3321 is_amoeba[cave[x][y+1]] ||
3322 is_amoeba[cave[x-1][y]])
3330 switch (cave[x-1][y])
3354 cave[x][y] = Ytank_n_w;
3355 next[x][y] = Xtank_2_w;
3356 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3365 static void Ltank_2_n(int x, int y)
3367 if (is_amoeba[cave[x][y-1]] ||
3368 is_amoeba[cave[x+1][y]] ||
3369 is_amoeba[cave[x][y+1]] ||
3370 is_amoeba[cave[x-1][y]])
3381 static void Ltank_e(int x, int y)
3383 switch (cave[x+1][y])
3399 cave[x][y] = Ytank_eB;
3400 next[x][y] = Xblank;
3401 cave[x+1][y] = Ytank_e;
3402 next[x+1][y] = Xtank_1_e;
3403 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3414 cave[x][y] = Ytank_eB;
3415 next[x][y] = Xblank;
3416 if (cave[x+2][y-1] == Xblank)
3417 cave[x+2][y-1] = Xsplash_e;
3418 if (cave[x][y-1] == Xblank)
3419 cave[x][y-1] = Xsplash_w;
3420 play_element_sound(x, y, SOUND_acid, Xacid_1);
3424 cave[x][y] = Ytank_e_s;
3425 next[x][y] = Xtank_2_s;
3426 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3431 static void Ltank_1_e(int x, int y)
3433 if (is_amoeba[cave[x][y-1]] ||
3434 is_amoeba[cave[x+1][y]] ||
3435 is_amoeba[cave[x][y+1]] ||
3436 is_amoeba[cave[x-1][y]])
3444 switch (cave[x][y-1])
3468 cave[x][y] = Ytank_e_n;
3469 next[x][y] = Xtank_2_n;
3470 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3479 static void Ltank_2_e(int x, int y)
3481 if (is_amoeba[cave[x][y-1]] ||
3482 is_amoeba[cave[x+1][y]] ||
3483 is_amoeba[cave[x][y+1]] ||
3484 is_amoeba[cave[x-1][y]])
3495 static void Ltank_s(int x, int y)
3497 switch (cave[x][y+1])
3513 cave[x][y] = Ytank_sB;
3514 next[x][y] = Xblank;
3515 cave[x][y+1] = Ytank_s;
3516 next[x][y+1] = Xtank_1_s;
3517 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3528 cave[x][y] = Ytank_sB;
3529 next[x][y] = Xblank;
3530 if (cave[x+1][y] == Xblank)
3531 cave[x+1][y] = Xsplash_e;
3532 if (cave[x-1][y] == Xblank)
3533 cave[x-1][y] = Xsplash_w;
3534 play_element_sound(x, y, SOUND_acid, Xacid_1);
3538 cave[x][y] = Ytank_s_w;
3539 next[x][y] = Xtank_2_w;
3540 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3545 static void Ltank_1_s(int x, int y)
3547 if (is_amoeba[cave[x][y-1]] ||
3548 is_amoeba[cave[x+1][y]] ||
3549 is_amoeba[cave[x][y+1]] ||
3550 is_amoeba[cave[x-1][y]])
3558 switch (cave[x+1][y])
3582 cave[x][y] = Ytank_s_e;
3583 next[x][y] = Xtank_2_e;
3584 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3593 static void Ltank_2_s(int x, int y)
3595 if (is_amoeba[cave[x][y-1]] ||
3596 is_amoeba[cave[x+1][y]] ||
3597 is_amoeba[cave[x][y+1]] ||
3598 is_amoeba[cave[x-1][y]])
3609 static void Ltank_w(int x, int y)
3611 switch (cave[x-1][y])
3627 cave[x][y] = Ytank_wB;
3628 next[x][y] = Xblank;
3629 cave[x-1][y] = Ytank_w;
3630 next[x-1][y] = Xtank_1_w;
3631 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3642 cave[x][y] = Ytank_wB;
3643 next[x][y] = Xblank;
3644 if (cave[x][y-1] == Xblank)
3645 cave[x][y-1] = Xsplash_e;
3646 if (cave[x-2][y-1] == Xblank)
3647 cave[x-2][y-1] = Xsplash_w;
3648 play_element_sound(x, y, SOUND_acid, Xacid_1);
3652 cave[x][y] = Ytank_w_n;
3653 next[x][y] = Xtank_2_n;
3654 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3659 static void Ltank_1_w(int x, int y)
3661 if (is_amoeba[cave[x][y-1]] ||
3662 is_amoeba[cave[x+1][y]] ||
3663 is_amoeba[cave[x][y+1]] ||
3664 is_amoeba[cave[x-1][y]])
3672 switch (cave[x][y+1])
3696 cave[x][y] = Ytank_w_s;
3697 next[x][y] = Xtank_2_s;
3698 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3707 static void Ltank_2_w(int x, int y)
3709 if (is_amoeba[cave[x][y-1]] ||
3710 is_amoeba[cave[x+1][y]] ||
3711 is_amoeba[cave[x][y+1]] ||
3712 is_amoeba[cave[x-1][y]])
3723 static void Lemerald(int x, int y)
3725 switch (cave[x][y+1])
3738 cave[x][y] = Yemerald_sB;
3739 next[x][y] = Xblank;
3740 cave[x][y+1] = Yemerald_s;
3741 next[x][y+1] = Xemerald_fall;
3752 cave[x][y] = Yemerald_sB;
3753 next[x][y] = Xblank;
3754 if (cave[x+1][y] == Xblank)
3755 cave[x+1][y] = Xsplash_e;
3756 if (cave[x-1][y] == Xblank)
3757 cave[x-1][y] = Xsplash_w;
3758 play_element_sound(x, y, SOUND_acid, Xacid_1);
3771 case Xemerald_pause:
3773 case Xdiamond_pause:
3817 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
3819 cave[x][y] = Yemerald_eB;
3820 next[x][y] = Xblank;
3821 cave[x+1][y] = Yemerald_e;
3822 next[x+1][y] = Xemerald_pause;
3823 if (cave[x][y+1] == Xbumper)
3824 cave[x][y+1] = Ybumper;
3828 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
3830 cave[x][y] = Yemerald_wB;
3831 next[x][y] = Xblank;
3832 cave[x-1][y] = Yemerald_w;
3833 next[x-1][y] = Xemerald_pause;
3834 if (cave[x][y+1] == Xbumper)
3835 cave[x][y+1] = Ybumper;
3841 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
3843 cave[x][y] = Yemerald_wB;
3844 next[x][y] = Xblank;
3845 cave[x-1][y] = Yemerald_w;
3846 next[x-1][y] = Xemerald_pause;
3847 if (cave[x][y+1] == Xbumper)
3848 cave[x][y+1] = Ybumper;
3852 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
3854 cave[x][y] = Yemerald_eB;
3855 next[x][y] = Xblank;
3856 cave[x+1][y] = Yemerald_e;
3857 next[x+1][y] = Xemerald_pause;
3858 if (cave[x][y+1] == Xbumper)
3859 cave[x][y+1] = Ybumper;
3865 if (++lev.shine_cnt > 50)
3867 lev.shine_cnt = RANDOM(8);
3868 cave[x][y] = Xemerald_shine;
3875 static void Lemerald_pause(int x, int y)
3877 switch (cave[x][y+1])
3890 cave[x][y] = Yemerald_sB;
3891 next[x][y] = Xblank;
3892 cave[x][y+1] = Yemerald_s;
3893 next[x][y+1] = Xemerald_fall;
3904 cave[x][y] = Yemerald_sB;
3905 next[x][y] = Xblank;
3906 if (cave[x+1][y] == Xblank)
3907 cave[x+1][y] = Xsplash_e;
3908 if (cave[x-1][y] == Xblank)
3909 cave[x-1][y] = Xsplash_w;
3910 play_element_sound(x, y, SOUND_acid, Xacid_1);
3914 cave[x][y] = Xemerald;
3915 next[x][y] = Xemerald;
3920 static void Lemerald_fall(int x, int y)
3922 switch (cave[x][y+1])
3936 cave[x][y] = Yemerald_sB;
3937 next[x][y] = Xblank;
3938 cave[x][y+1] = Yemerald_s;
3939 next[x][y+1] = Xemerald_fall;
3950 cave[x][y] = Yemerald_sB;
3951 next[x][y] = Xblank;
3952 if (cave[x+1][y] == Xblank)
3953 cave[x+1][y] = Xsplash_e;
3954 if (cave[x-1][y] == Xblank)
3955 cave[x-1][y] = Xsplash_w;
3956 play_element_sound(x, y, SOUND_acid, Xacid_1);
3960 if (lev.wonderwall_time > 0)
3962 lev.wonderwall_active = TRUE;
3963 cave[x][y] = Yemerald_sB;
3964 next[x][y] = Xblank;
3965 if (is_blank[cave[x][y+2]])
3967 cave[x][y+2] = Ydiamond_s;
3968 next[x][y+2] = Xdiamond_fall;
3970 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
3975 cave[x][y] = Xemerald;
3976 next[x][y] = Xemerald;
3977 play_element_sound(x, y, SOUND_diamond, Xemerald);
3982 static void Ldiamond(int x, int y)
3984 switch (cave[x][y+1])
3997 cave[x][y] = Ydiamond_sB;
3998 next[x][y] = Xblank;
3999 cave[x][y+1] = Ydiamond_s;
4000 next[x][y+1] = Xdiamond_fall;
4011 cave[x][y] = Ydiamond_sB;
4012 next[x][y] = Xblank;
4013 if (cave[x+1][y] == Xblank)
4014 cave[x+1][y] = Xsplash_e;
4015 if (cave[x-1][y] == Xblank)
4016 cave[x-1][y] = Xsplash_w;
4017 play_element_sound(x, y, SOUND_acid, Xacid_1);
4030 case Xemerald_pause:
4032 case Xdiamond_pause:
4076 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4078 cave[x][y] = Ydiamond_eB;
4079 next[x][y] = Xblank;
4080 cave[x+1][y] = Ydiamond_e;
4081 next[x+1][y] = Xdiamond_pause;
4082 if (cave[x][y+1] == Xbumper)
4083 cave[x][y+1] = Ybumper;
4087 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4089 cave[x][y] = Ydiamond_wB;
4090 next[x][y] = Xblank;
4091 cave[x-1][y] = Ydiamond_w;
4092 next[x-1][y] = Xdiamond_pause;
4093 if (cave[x][y+1] == Xbumper)
4094 cave[x][y+1] = Ybumper;
4100 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4102 cave[x][y] = Ydiamond_wB;
4103 next[x][y] = Xblank;
4104 cave[x-1][y] = Ydiamond_w;
4105 next[x-1][y] = Xdiamond_pause;
4106 if (cave[x][y+1] == Xbumper)
4107 cave[x][y+1] = Ybumper;
4111 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4113 cave[x][y] = Ydiamond_eB;
4114 next[x][y] = Xblank;
4115 cave[x+1][y] = Ydiamond_e;
4116 next[x+1][y] = Xdiamond_pause;
4117 if (cave[x][y+1] == Xbumper)
4118 cave[x][y+1] = Ybumper;
4124 if (++lev.shine_cnt > 50)
4126 lev.shine_cnt = RANDOM(8);
4127 cave[x][y] = Xdiamond_shine;
4134 static void Ldiamond_pause(int x, int y)
4136 switch (cave[x][y+1])
4149 cave[x][y] = Ydiamond_sB;
4150 next[x][y] = Xblank;
4151 cave[x][y+1] = Ydiamond_s;
4152 next[x][y+1] = Xdiamond_fall;
4163 cave[x][y] = Ydiamond_sB;
4164 next[x][y] = Xblank;
4165 if (cave[x+1][y] == Xblank)
4166 cave[x+1][y] = Xsplash_e;
4167 if (cave[x-1][y] == Xblank)
4168 cave[x-1][y] = Xsplash_w;
4169 play_element_sound(x, y, SOUND_acid, Xacid_1);
4173 cave[x][y] = Xdiamond;
4174 next[x][y] = Xdiamond;
4179 static void Ldiamond_fall(int x, int y)
4181 switch (cave[x][y+1])
4195 cave[x][y] = Ydiamond_sB;
4196 next[x][y] = Xblank;
4197 cave[x][y+1] = Ydiamond_s;
4198 next[x][y+1] = Xdiamond_fall;
4209 cave[x][y] = Ydiamond_sB;
4210 next[x][y] = Xblank;
4211 if (cave[x+1][y] == Xblank)
4212 cave[x+1][y] = Xsplash_e;
4213 if (cave[x-1][y] == Xblank)
4214 cave[x-1][y] = Xsplash_w;
4215 play_element_sound(x, y, SOUND_acid, Xacid_1);
4219 if (lev.wonderwall_time > 0)
4221 lev.wonderwall_active = TRUE;
4222 cave[x][y] = Ydiamond_sB;
4223 next[x][y] = Xblank;
4224 if (is_blank[cave[x][y+2]])
4226 cave[x][y+2] = Ystone_s;
4227 next[x][y+2] = Xstone_fall;
4229 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4234 cave[x][y] = Xdiamond;
4235 next[x][y] = Xdiamond;
4236 play_element_sound(x, y, SOUND_diamond, Xdiamond);
4241 static void Lstone(int x, int y)
4243 switch (cave[x][y+1])
4258 cave[x][y] = Ystone_sB;
4259 next[x][y] = Xblank;
4260 cave[x][y+1] = Ystone_s;
4261 next[x][y+1] = Xstone_fall;
4272 cave[x][y] = Ystone_sB;
4273 next[x][y] = Xblank;
4274 if (cave[x+1][y] == Xblank)
4275 cave[x+1][y] = Xsplash_e;
4276 if (cave[x-1][y] == Xblank)
4277 cave[x-1][y] = Xsplash_w;
4278 play_element_sound(x, y, SOUND_acid, Xacid_1);
4282 cave[x][y] = Xsand_stonein_1;
4283 next[x][y] = Xsand_stonein_2;
4284 cave[x][y+1] = Xsand_sandstone_1;
4285 next[x][y+1] = Xsand_sandstone_2;
4298 case Xemerald_pause:
4300 case Xdiamond_pause:
4337 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4339 cave[x][y] = Ystone_eB;
4340 next[x][y] = Xblank;
4341 cave[x+1][y] = Ystone_e;
4342 next[x+1][y] = Xstone_pause;
4343 if (cave[x][y+1] == Xbumper)
4344 cave[x][y+1] = Ybumper;
4348 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4350 cave[x][y] = Ystone_wB;
4351 next[x][y] = Xblank;
4352 cave[x-1][y] = Ystone_w;
4353 next[x-1][y] = Xstone_pause;
4354 if (cave[x][y+1] == Xbumper)
4355 cave[x][y+1] = Ybumper;
4361 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4363 cave[x][y] = Ystone_wB;
4364 next[x][y] = Xblank;
4365 cave[x-1][y] = Ystone_w;
4366 next[x-1][y] = Xstone_pause;
4367 if (cave[x][y+1] == Xbumper)
4368 cave[x][y+1] = Ybumper;
4372 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4374 cave[x][y] = Ystone_eB;
4375 next[x][y] = Xblank;
4376 cave[x+1][y] = Ystone_e;
4377 next[x+1][y] = Xstone_pause;
4378 if (cave[x][y+1] == Xbumper)
4379 cave[x][y+1] = Ybumper;
4386 static void Lstone_pause(int x, int y)
4388 switch (cave[x][y+1])
4401 cave[x][y] = Ystone_sB;
4402 next[x][y] = Xblank;
4403 cave[x][y+1] = Ystone_s;
4404 next[x][y+1] = Xstone_fall;
4415 cave[x][y] = Ystone_sB;
4416 next[x][y] = Xblank;
4417 if (cave[x+1][y] == Xblank)
4418 cave[x+1][y] = Xsplash_e;
4419 if (cave[x-1][y] == Xblank)
4420 cave[x-1][y] = Xsplash_w;
4421 play_element_sound(x, y, SOUND_acid, Xacid_1);
4425 cave[x][y] = Xstone;
4426 next[x][y] = Xstone;
4431 static void Lstone_fall(int x, int y)
4433 switch (cave[x][y+1])
4447 cave[x][y] = Ystone_sB;
4448 next[x][y] = Xblank;
4449 cave[x][y+1] = Ystone_s;
4450 next[x][y+1] = Xstone_fall;
4461 cave[x][y] = Ystone_sB;
4462 next[x][y] = Xblank;
4463 if (cave[x+1][y] == Xblank)
4464 cave[x+1][y] = Xsplash_e;
4465 if (cave[x-1][y] == Xblank)
4466 cave[x-1][y] = Xsplash_w;
4467 play_element_sound(x, y, SOUND_acid, Xacid_1);
4474 cave[x][y] = Ystone_sB;
4475 next[x][y] = Xblank;
4476 cave[x][y+1] = Yeater_stone;
4477 next[x][y+1] = Zeater;
4478 Lboom_eater_old(x, y+1);
4479 score += lev.eater_score;
4484 cave[x][y] = Ystone_sB;
4485 next[x][y] = Xblank;
4486 cave[x][y+1] = Yalien_stone;
4487 next[x][y+1] = Ztank;
4488 Lboom_tank_old(x, y+1);
4489 score += lev.alien_score;
4500 cave[x][y] = Ystone_sB;
4501 next[x][y] = Xblank;
4502 cave[x][y+1] = Ybug_stone;
4503 next[x][y+1] = Zbug;
4504 Lboom_bug_old(x, y+1);
4505 score += lev.bug_score;
4516 cave[x][y] = Ystone_sB;
4517 next[x][y] = Xblank;
4518 cave[x][y+1] = Ytank_stone;
4519 next[x][y+1] = Ztank;
4520 Lboom_tank_old(x, y+1);
4521 score += lev.tank_score;
4525 case Xdiamond_pause:
4526 switch (cave[x][y+2])
4582 next[x][y] = Xstone;
4583 play_element_sound(x, y, SOUND_stone, Xstone);
4587 cave[x][y] = Ystone_sB;
4588 next[x][y] = Xblank;
4589 cave[x][y+1] = Ydiamond_stone;
4590 next[x][y+1] = Xstone_pause;
4591 play_element_sound(x, y, SOUND_squash, Xdiamond);
4596 cave[x][y] = Xstone;
4597 next[x][y] = Xstone;
4598 cave[x][y+1] = Ybomb_blank;
4599 next[x][y+1] = Ztank;
4600 Lboom_tank_old(x, y+1);
4605 next[x][y] = Xstone;
4606 cave[x][y+1] = Ynut_stone;
4607 next[x][y+1] = Xemerald;
4608 play_element_sound(x, y, SOUND_crack, Xnut);
4609 score += lev.nut_score;
4615 switch (cave[x+1][y+1])
4630 cave[x][y+1] = Xspring_e;
4634 cave[x][y+1] = Xspring_w;
4640 switch (cave[x-1][y+1])
4655 cave[x][y+1] = Xspring_w;
4658 cave[x][y+1] = Xspring_e;
4663 next[x][y] = Xstone;
4667 if (lev.wonderwall_time > 0)
4669 lev.wonderwall_active = TRUE;
4670 cave[x][y] = Ystone_sB;
4671 next[x][y] = Xblank;
4672 if (is_blank[cave[x][y+2]])
4674 cave[x][y+2] = Yemerald_s;
4675 next[x][y+2] = Xemerald_fall;
4677 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4682 cave[x][y] = Xstone;
4683 next[x][y] = Xstone;
4684 play_element_sound(x, y, SOUND_stone, Xstone);
4689 static void Lbomb(int x, int y)
4691 switch (cave[x][y+1])
4704 cave[x][y] = Ybomb_sB;
4705 next[x][y] = Xblank;
4706 cave[x][y+1] = Ybomb_s;
4707 next[x][y+1] = Xbomb_fall;
4718 cave[x][y] = Ybomb_sB;
4719 next[x][y] = Xblank;
4720 if (cave[x+1][y] == Xblank)
4721 cave[x+1][y] = Xsplash_e;
4722 if (cave[x-1][y] == Xblank)
4723 cave[x-1][y] = Xsplash_w;
4724 play_element_sound(x, y, SOUND_acid, Xacid_1);
4737 case Xemerald_pause:
4739 case Xdiamond_pause:
4774 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4776 cave[x][y] = Ybomb_eB;
4777 next[x][y] = Xblank;
4778 cave[x+1][y] = Ybomb_e;
4779 next[x+1][y] = Xbomb_pause;
4780 if (cave[x][y+1] == Xbumper)
4781 cave[x][y+1] = Ybumper;
4785 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4787 cave[x][y] = Ybomb_wB;
4788 next[x][y] = Xblank;
4789 cave[x-1][y] = Ybomb_w;
4790 next[x-1][y] = Xbomb_pause;
4791 if (cave[x][y+1] == Xbumper)
4792 cave[x][y+1] = Ybumper;
4798 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4800 cave[x][y] = Ybomb_wB;
4801 next[x][y] = Xblank;
4802 cave[x-1][y] = Ybomb_w;
4803 next[x-1][y] = Xbomb_pause;
4804 if (cave[x][y+1] == Xbumper)
4805 cave[x][y+1] = Ybumper;
4809 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4811 cave[x][y] = Ybomb_eB;
4812 next[x][y] = Xblank;
4813 cave[x+1][y] = Ybomb_e;
4814 next[x+1][y] = Xbomb_pause;
4815 if (cave[x][y+1] == Xbumper)
4816 cave[x][y+1] = Ybumper;
4823 static void Lbomb_pause(int x, int y)
4825 switch (cave[x][y+1])
4838 cave[x][y] = Ybomb_sB;
4839 next[x][y] = Xblank;
4840 cave[x][y+1] = Ybomb_s;
4841 next[x][y+1] = Xbomb_fall;
4852 cave[x][y] = Ybomb_sB;
4853 next[x][y] = Xblank;
4854 if (cave[x+1][y] == Xblank)
4855 cave[x+1][y] = Xsplash_e;
4856 if (cave[x-1][y] == Xblank)
4857 cave[x-1][y] = Xsplash_w;
4858 play_element_sound(x, y, SOUND_acid, Xacid_1);
4868 static void Lbomb_fall(int x, int y)
4870 switch (cave[x][y+1])
4883 cave[x][y] = Ybomb_sB;
4884 next[x][y] = Xblank;
4885 cave[x][y+1] = Ybomb_s;
4886 next[x][y+1] = Xbomb_fall;
4897 cave[x][y] = Ybomb_sB;
4898 next[x][y] = Xblank;
4899 if (cave[x+1][y] == Xblank)
4900 cave[x+1][y] = Xsplash_e;
4901 if (cave[x-1][y] == Xblank)
4902 cave[x-1][y] = Xsplash_w;
4903 play_element_sound(x, y, SOUND_acid, Xacid_1);
4907 cave[x][y] = Ybomb_blank;
4909 Lboom_tank_old(x, y);
4914 static void Lnut(int x, int y)
4916 switch (cave[x][y+1])
4929 cave[x][y] = Ynut_sB;
4930 next[x][y] = Xblank;
4931 cave[x][y+1] = Ynut_s;
4932 next[x][y+1] = Xnut_fall;
4943 cave[x][y] = Ynut_sB;
4944 next[x][y] = Xblank;
4945 if (cave[x+1][y] == Xblank)
4946 cave[x+1][y] = Xsplash_e;
4947 if (cave[x-1][y] == Xblank)
4948 cave[x-1][y] = Xsplash_w;
4949 play_element_sound(x, y, SOUND_acid, Xacid_1);
4962 case Xemerald_pause:
4964 case Xdiamond_pause:
4999 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5001 cave[x][y] = Ynut_eB;
5002 next[x][y] = Xblank;
5003 cave[x+1][y] = Ynut_e;
5004 next[x+1][y] = Xnut_pause;
5005 if (cave[x][y+1] == Xbumper)
5006 cave[x][y+1] = Ybumper;
5010 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5012 cave[x][y] = Ynut_wB;
5013 next[x][y] = Xblank;
5014 cave[x-1][y] = Ynut_w;
5015 next[x-1][y] = Xnut_pause;
5016 if (cave[x][y+1] == Xbumper)
5017 cave[x][y+1] = Ybumper;
5023 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5025 cave[x][y] = Ynut_wB;
5026 next[x][y] = Xblank;
5027 cave[x-1][y] = Ynut_w;
5028 next[x-1][y] = Xnut_pause;
5029 if (cave[x][y+1] == Xbumper)
5030 cave[x][y+1] = Ybumper;
5034 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5036 cave[x][y] = Ynut_eB;
5037 next[x][y] = Xblank;
5038 cave[x+1][y] = Ynut_e;
5039 next[x+1][y] = Xnut_pause;
5040 if (cave[x][y+1] == Xbumper)
5041 cave[x][y+1] = Ybumper;
5048 static void Lnut_pause(int x, int y)
5050 switch (cave[x][y+1])
5063 cave[x][y] = Ynut_sB;
5064 next[x][y] = Xblank;
5065 cave[x][y+1] = Ynut_s;
5066 next[x][y+1] = Xnut_fall;
5077 cave[x][y] = Ynut_sB;
5078 next[x][y] = Xblank;
5079 if (cave[x+1][y] == Xblank)
5080 cave[x+1][y] = Xsplash_e;
5081 if (cave[x-1][y] == Xblank)
5082 cave[x-1][y] = Xsplash_w;
5083 play_element_sound(x, y, SOUND_acid, Xacid_1);
5093 static void Lnut_fall(int x, int y)
5095 switch (cave[x][y+1])
5109 cave[x][y] = Ynut_sB;
5110 next[x][y] = Xblank;
5111 cave[x][y+1] = Ynut_s;
5112 next[x][y+1] = Xnut_fall;
5123 cave[x][y] = Ynut_sB;
5124 next[x][y] = Xblank;
5125 if (cave[x+1][y] == Xblank)
5126 cave[x+1][y] = Xsplash_e;
5127 if (cave[x-1][y] == Xblank)
5128 cave[x-1][y] = Xsplash_w;
5129 play_element_sound(x, y, SOUND_acid, Xacid_1);
5135 play_element_sound(x, y, SOUND_nut, Xnut);
5140 static void Lspring(int x, int y)
5142 switch (cave[x][y+1])
5157 cave[x][y] = Yspring_sB;
5158 next[x][y] = Xblank;
5159 cave[x][y+1] = Yspring_s;
5160 next[x][y+1] = Xspring_fall;
5171 cave[x][y] = Yspring_sB;
5172 next[x][y] = Xblank;
5173 if (cave[x+1][y] == Xblank)
5174 cave[x+1][y] = Xsplash_e;
5175 if (cave[x-1][y] == Xblank)
5176 cave[x-1][y] = Xsplash_w;
5177 play_element_sound(x, y, SOUND_acid, Xacid_1);
5190 case Xemerald_pause:
5192 case Xdiamond_pause:
5227 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5229 cave[x][y] = Yspring_eB;
5230 next[x][y] = Xblank;
5231 cave[x+1][y] = Yspring_e;
5233 next[x+1][y] = Xspring_e;
5235 next[x+1][y] = Xspring_pause;
5237 if (cave[x][y+1] == Xbumper)
5238 cave[x][y+1] = Ybumper;
5242 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5244 cave[x][y] = Yspring_wB;
5245 next[x][y] = Xblank;
5246 cave[x-1][y] = Yspring_w;
5248 next[x-1][y] = Xspring_w;
5250 next[x-1][y] = Xspring_pause;
5252 if (cave[x][y+1] == Xbumper)
5253 cave[x][y+1] = Ybumper;
5259 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5261 cave[x][y] = Yspring_wB;
5262 next[x][y] = Xblank;
5263 cave[x-1][y] = Yspring_w;
5265 next[x-1][y] = Xspring_w;
5267 next[x-1][y] = Xspring_pause;
5269 if (cave[x][y+1] == Xbumper)
5270 cave[x][y+1] = Ybumper;
5274 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5276 cave[x][y] = Yspring_eB;
5277 next[x][y] = Xblank;
5278 cave[x+1][y] = Yspring_e;
5280 next[x+1][y] = Xspring_e;
5282 next[x+1][y] = Xspring_pause;
5284 if (cave[x][y+1] == Xbumper)
5285 cave[x][y+1] = Ybumper;
5292 static void Lspring_pause(int x, int y)
5294 switch (cave[x][y+1])
5307 cave[x][y] = Yspring_sB;
5308 next[x][y] = Xblank;
5309 cave[x][y+1] = Yspring_s;
5310 next[x][y+1] = Xspring_fall;
5321 cave[x][y] = Yspring_sB;
5322 next[x][y] = Xblank;
5323 if (cave[x+1][y] == Xblank)
5324 cave[x+1][y] = Xsplash_e;
5325 if (cave[x-1][y] == Xblank)
5326 cave[x-1][y] = Xsplash_w;
5327 play_element_sound(x, y, SOUND_acid, Xacid_1);
5331 cave[x][y] = Xspring;
5332 next[x][y] = Xspring;
5337 static void Lspring_e(int x, int y)
5339 switch (cave[x][y+1])
5352 cave[x][y] = Yspring_sB;
5353 next[x][y] = Xblank;
5354 cave[x][y+1] = Yspring_s;
5355 next[x][y+1] = Xspring_fall;
5366 cave[x][y] = Yspring_sB;
5367 next[x][y] = Xblank;
5368 if (cave[x+1][y] == Xblank)
5369 cave[x+1][y] = Xsplash_e;
5370 if (cave[x-1][y] == Xblank)
5371 cave[x-1][y] = Xsplash_w;
5372 play_element_sound(x, y, SOUND_acid, Xacid_1);
5376 cave[x][y+1] = Ybumper;
5379 switch (cave[x+1][y])
5396 cave[x][y] = Yspring_eB;
5397 next[x][y] = Xblank;
5398 cave[x+1][y] = Yspring_e;
5399 next[x+1][y] = Xspring_e;
5410 cave[x][y] = Yspring_eB;
5411 next[x][y] = Xblank;
5412 if (cave[x+2][y-1] == Xblank)
5413 cave[x+2][y-1] = Xsplash_e;
5414 if (cave[x][y-1] == Xblank)
5415 cave[x][y-1] = Xsplash_w;
5416 play_element_sound(x, y, SOUND_acid, Xacid_1);
5425 cave[x][y] = Yspring_alien_eB;
5426 next[x][y] = Xblank;
5427 cave[x+1][y] = Yspring_alien_e;
5428 next[x+1][y] = Xspring_e;
5429 play_element_sound(x, y, SOUND_slurp, Xalien);
5430 score += lev.slurp_score;
5435 cave[x+1][y] = Ybumper;
5436 next[x][y] = Xspring_w;
5437 play_element_sound(x, y, SOUND_spring, Xspring);
5441 cave[x][y] = Xspring;
5442 next[x][y] = Xspring;
5443 play_element_sound(x, y, SOUND_spring, Xspring);
5448 static void Lspring_w(int x, int y)
5450 switch (cave[x][y+1])
5463 cave[x][y] = Yspring_sB;
5464 next[x][y] = Xblank;
5465 cave[x][y+1] = Yspring_s;
5466 next[x][y+1] = Xspring_fall;
5477 cave[x][y] = Yspring_sB;
5478 next[x][y] = Xblank;
5479 if (cave[x+1][y] == Xblank)
5480 cave[x+1][y] = Xsplash_e;
5481 if (cave[x-1][y] == Xblank)
5482 cave[x-1][y] = Xsplash_w;
5483 play_element_sound(x, y, SOUND_acid, Xacid_1);
5487 cave[x][y+1] = Ybumper;
5490 switch (cave[x-1][y])
5507 cave[x][y] = Yspring_wB;
5508 next[x][y] = Xblank;
5509 cave[x-1][y] = Yspring_w;
5510 next[x-1][y] = Xspring_w;
5521 cave[x][y] = Yspring_wB;
5522 next[x][y] = Xblank;
5523 if (cave[x][y-1] == Xblank)
5524 cave[x][y-1] = Xsplash_e;
5525 if (cave[x-2][y-1] == Xblank)
5526 cave[x-2][y-1] = Xsplash_w;
5527 play_element_sound(x, y, SOUND_acid, Xacid_1);
5536 cave[x][y] = Yspring_alien_wB;
5537 next[x][y] = Xblank;
5538 cave[x-1][y] = Yspring_alien_w;
5539 next[x-1][y] = Xspring_w;
5540 play_element_sound(x, y, SOUND_slurp, Xalien);
5541 score += lev.slurp_score;
5546 cave[x-1][y] = Ybumper;
5547 next[x][y] = Xspring_e;
5548 play_element_sound(x, y, SOUND_spring, Xspring);
5552 cave[x][y] = Xspring;
5553 next[x][y] = Xspring;
5554 play_element_sound(x, y, SOUND_spring, Xspring);
5559 static void Lspring_fall(int x, int y)
5561 switch (cave[x][y+1])
5575 cave[x][y] = Yspring_sB;
5576 next[x][y] = Xblank;
5577 cave[x][y+1] = Yspring_s;
5578 next[x][y+1] = Xspring_fall;
5589 cave[x][y] = Yspring_sB;
5590 next[x][y] = Xblank;
5591 if (cave[x+1][y] == Xblank)
5592 cave[x+1][y] = Xsplash_e;
5593 if (cave[x-1][y] == Xblank)
5594 cave[x-1][y] = Xsplash_w;
5595 play_element_sound(x, y, SOUND_acid, Xacid_1);
5602 cave[x][y] = Yspring_sB;
5603 next[x][y] = Xblank;
5604 cave[x][y+1] = Yeater_spring;
5605 next[x][y+1] = Zeater;
5606 Lboom_eater_old(x, y+1);
5607 score += lev.eater_score;
5612 cave[x][y] = Yspring_sB;
5613 next[x][y] = Xblank;
5614 cave[x][y+1] = Yalien_spring;
5615 next[x][y+1] = Ztank;
5616 Lboom_tank_old(x, y+1);
5617 score += lev.alien_score;
5628 cave[x][y] = Yspring_sB;
5629 next[x][y] = Xblank;
5630 cave[x][y+1] = Ybug_spring;
5631 next[x][y+1] = Zbug;
5632 Lboom_bug_old(x, y+1);
5633 score += lev.bug_score;
5644 cave[x][y] = Yspring_sB;
5645 next[x][y] = Xblank;
5646 cave[x][y+1] = Ytank_spring;
5647 next[x][y+1] = Ztank;
5648 Lboom_tank_old(x, y+1);
5649 score += lev.tank_score;
5654 cave[x][y] = Xspring;
5655 next[x][y] = Xspring;
5656 cave[x][y+1] = Ybomb_blank;
5657 next[x][y+1] = Ztank;
5658 Lboom_tank_old(x, y+1);
5662 cave[x][y] = Xspring;
5663 next[x][y] = Xspring;
5664 play_element_sound(x, y, SOUND_spring, Xspring);
5669 static void Lpush_emerald_e(int x, int y)
5671 cave[x][y] = Yemerald_eB;
5672 next[x][y] = Xblank;
5674 switch (cave[x+1][y])
5698 if (cave[x+2][y-1] == Xblank)
5699 cave[x+2][y-1] = Xsplash_e;
5700 if (cave[x][y-1] == Xblank)
5701 cave[x][y-1] = Xsplash_w;
5702 play_element_sound(x, y, SOUND_acid, Xacid_1);
5707 cave[x+1][y] = Yemerald_e;
5708 next[x+1][y] = Xemerald_pause;
5711 static void Lpush_emerald_w(int x, int y)
5713 cave[x][y] = Yemerald_wB;
5714 next[x][y] = Xblank;
5716 switch (cave[x-1][y])
5740 if (cave[x][y-1] == Xblank)
5741 cave[x][y-1] = Xsplash_e;
5742 if (cave[x-2][y-1] == Xblank)
5743 cave[x-2][y-1] = Xsplash_w;
5744 play_element_sound(x, y, SOUND_acid, Xacid_1);
5749 cave[x-1][y] = Yemerald_w;
5750 next[x-1][y] = Xemerald_pause;
5753 static void Lpush_diamond_e(int x, int y)
5755 cave[x][y] = Ydiamond_eB;
5756 next[x][y] = Xblank;
5758 switch (cave[x+1][y])
5782 if (cave[x+2][y-1] == Xblank)
5783 cave[x+2][y-1] = Xsplash_e;
5784 if (cave[x][y-1] == Xblank)
5785 cave[x][y-1] = Xsplash_w;
5786 play_element_sound(x, y, SOUND_acid, Xacid_1);
5791 cave[x+1][y] = Ydiamond_e;
5792 next[x+1][y] = Xdiamond_pause;
5795 static void Lpush_diamond_w(int x, int y)
5797 cave[x][y] = Ydiamond_wB;
5798 next[x][y] = Xblank;
5800 switch (cave[x-1][y])
5824 if (cave[x][y-1] == Xblank)
5825 cave[x][y-1] = Xsplash_e;
5826 if (cave[x-2][y-1] == Xblank)
5827 cave[x-2][y-1] = Xsplash_w;
5828 play_element_sound(x, y, SOUND_acid, Xacid_1);
5833 cave[x-1][y] = Ydiamond_w;
5834 next[x-1][y] = Xdiamond_pause;
5837 static void Lpush_stone_e(int x, int y)
5839 cave[x][y] = Ystone_eB;
5840 next[x][y] = Xblank;
5842 switch (cave[x+1][y])
5866 if (cave[x+2][y-1] == Xblank)
5867 cave[x+2][y-1] = Xsplash_e;
5868 if (cave[x][y-1] == Xblank)
5869 cave[x][y-1] = Xsplash_w;
5870 play_element_sound(x, y, SOUND_acid, Xacid_1);
5875 cave[x+1][y] = Ystone_e;
5876 next[x+1][y] = Xstone_pause;
5879 static void Lpush_stone_w(int x, int y)
5881 cave[x][y] = Ystone_wB;
5882 next[x][y] = Xblank;
5884 switch (cave[x-1][y])
5908 if (cave[x][y-1] == Xblank)
5909 cave[x][y-1] = Xsplash_e;
5910 if (cave[x-2][y-1] == Xblank)
5911 cave[x-2][y-1] = Xsplash_w;
5912 play_element_sound(x, y, SOUND_acid, Xacid_1);
5917 cave[x-1][y] = Ystone_w;
5918 next[x-1][y] = Xstone_pause;
5921 static void Lpush_bomb_e(int x, int y)
5923 cave[x][y] = Ybomb_eB;
5924 next[x][y] = Xblank;
5926 switch (cave[x+1][y])
5950 if (cave[x+2][y-1] == Xblank)
5951 cave[x+2][y-1] = Xsplash_e;
5952 if (cave[x][y-1] == Xblank)
5953 cave[x][y-1] = Xsplash_w;
5954 play_element_sound(x, y, SOUND_acid, Xacid_1);
5959 cave[x+1][y] = Ybomb_e;
5960 next[x+1][y] = Xbomb_pause;
5963 static void Lpush_bomb_w(int x, int y)
5965 cave[x][y] = Ybomb_wB;
5966 next[x][y] = Xblank;
5968 switch (cave[x-1][y])
5992 if (cave[x][y-1] == Xblank)
5993 cave[x][y-1] = Xsplash_e;
5994 if (cave[x-2][y-1] == Xblank)
5995 cave[x-2][y-1] = Xsplash_w;
5996 play_element_sound(x, y, SOUND_acid, Xacid_1);
6001 cave[x-1][y] = Ybomb_w;
6002 next[x-1][y] = Xbomb_pause;
6005 static void Lpush_nut_e(int x, int y)
6007 cave[x][y] = Ynut_eB;
6008 next[x][y] = Xblank;
6010 switch (cave[x+1][y])
6034 if (cave[x+2][y-1] == Xblank)
6035 cave[x+2][y-1] = Xsplash_e;
6036 if (cave[x][y-1] == Xblank)
6037 cave[x][y-1] = Xsplash_w;
6038 play_element_sound(x, y, SOUND_acid, Xacid_1);
6043 cave[x+1][y] = Ynut_e;
6044 next[x+1][y] = Xnut_pause;
6047 static void Lpush_nut_w(int x, int y)
6049 cave[x][y] = Ynut_wB;
6050 next[x][y] = Xblank;
6052 switch (cave[x-1][y])
6076 if (cave[x][y-1] == Xblank)
6077 cave[x][y-1] = Xsplash_e;
6078 if (cave[x-2][y-1] == Xblank)
6079 cave[x-2][y-1] = Xsplash_w;
6080 play_element_sound(x, y, SOUND_acid, Xacid_1);
6085 cave[x-1][y] = Ynut_w;
6086 next[x-1][y] = Xnut_pause;
6089 static void Lpush_spring_e(int x, int y)
6091 cave[x][y] = Yspring_eB;
6092 next[x][y] = Xblank;
6094 switch (cave[x+1][y])
6118 if (cave[x+2][y-1] == Xblank)
6119 cave[x+2][y-1] = Xsplash_e;
6120 if (cave[x][y-1] == Xblank)
6121 cave[x][y-1] = Xsplash_w;
6122 play_element_sound(x, y, SOUND_acid, Xacid_1);
6127 cave[x+1][y] = Yspring_e;
6128 next[x+1][y] = Xspring_e;
6131 static void Lpush_spring_w(int x, int y)
6133 cave[x][y] = Yspring_wB;
6134 next[x][y] = Xblank;
6136 switch (cave[x-1][y])
6160 if (cave[x][y-1] == Xblank)
6161 cave[x][y-1] = Xsplash_e;
6162 if (cave[x-2][y-1] == Xblank)
6163 cave[x-2][y-1] = Xsplash_w;
6164 play_element_sound(x, y, SOUND_acid, Xacid_1);
6169 cave[x-1][y] = Yspring_w;
6170 next[x-1][y] = Xspring_w;
6173 static void Ldynamite_1(int x, int y)
6175 play_element_sound(x, y, SOUND_tick, Xdynamite_1);
6176 next[x][y] = Xdynamite_2;
6179 static void Ldynamite_2(int x, int y)
6181 play_element_sound(x, y, SOUND_tick, Xdynamite_2);
6182 next[x][y] = Xdynamite_3;
6185 static void Ldynamite_3(int x, int y)
6187 play_element_sound(x, y, SOUND_tick, Xdynamite_3);
6188 next[x][y] = Xdynamite_4;
6191 static void Ldynamite_4(int x, int y)
6193 play_element_sound(x, y, SOUND_tick, Xdynamite_4);
6194 next[x][y] = Zdynamite;
6196 Lboom_generic(x, y, Xblank, Xblank);
6199 static void Lfake_door_1(int x, int y)
6201 if (lev.magnify_cnt)
6202 cave[x][y] = Xdoor_1;
6205 static void Lfake_door_2(int x, int y)
6207 if (lev.magnify_cnt)
6208 cave[x][y] = Xdoor_2;
6211 static void Lfake_door_3(int x, int y)
6213 if (lev.magnify_cnt)
6214 cave[x][y] = Xdoor_3;
6217 static void Lfake_door_4(int x, int y)
6219 if (lev.magnify_cnt)
6220 cave[x][y] = Xdoor_4;
6223 static void Lfake_door_5(int x, int y)
6225 if (lev.magnify_cnt)
6226 cave[x][y] = Xdoor_5;
6229 static void Lfake_door_6(int x, int y)
6231 if (lev.magnify_cnt)
6232 cave[x][y] = Xdoor_6;
6235 static void Lfake_door_7(int x, int y)
6237 if (lev.magnify_cnt)
6238 cave[x][y] = Xdoor_7;
6241 static void Lfake_door_8(int x, int y)
6243 if (lev.magnify_cnt)
6244 cave[x][y] = Xdoor_8;
6247 static void Lballoon(int x, int y)
6249 if (lev.wind_cnt == 0)
6252 switch (lev.wind_direction)
6255 switch (cave[x][y-1])
6268 cave[x][y] = Yballoon_nB;
6269 next[x][y] = Xblank;
6270 cave[x][y-1] = Yballoon_n;
6271 next[x][y-1] = Xballoon;
6282 cave[x][y] = Yballoon_nB;
6283 next[x][y] = Xblank;
6284 if (cave[x+1][y-2] == Xblank)
6285 cave[x+1][y-2] = Xsplash_e;
6286 if (cave[x-1][y-2] == Xblank)
6287 cave[x-1][y-2] = Xsplash_w;
6288 play_element_sound(x, y, SOUND_acid, Xacid_1);
6294 switch (cave[x+1][y])
6307 cave[x][y] = Yballoon_eB;
6308 next[x][y] = Xblank;
6309 cave[x+1][y] = Yballoon_e;
6310 next[x+1][y] = Xballoon;
6321 cave[x][y] = Yballoon_eB;
6322 next[x][y] = Xblank;
6323 if (cave[x+2][y-1] == Xblank)
6324 cave[x+2][y-1] = Xsplash_e;
6325 if (cave[x][y-1] == Xblank)
6326 cave[x][y-1] = Xsplash_w;
6327 play_element_sound(x, y, SOUND_acid, Xacid_1);
6333 switch (cave[x][y+1])
6346 cave[x][y] = Yballoon_sB;
6347 next[x][y] = Xblank;
6348 cave[x][y+1] = Yballoon_s;
6349 next[x][y+1] = Xballoon;
6360 cave[x][y] = Yballoon_sB;
6361 next[x][y] = Xblank;
6362 if (cave[x+1][y] == Xblank)
6363 cave[x+1][y] = Xsplash_e;
6364 if (cave[x-1][y] == Xblank)
6365 cave[x-1][y] = Xsplash_w;
6366 play_element_sound(x, y, SOUND_acid, Xacid_1);
6372 switch (cave[x-1][y])
6385 cave[x][y] = Yballoon_wB;
6386 next[x][y] = Xblank;
6387 cave[x-1][y] = Yballoon_w;
6388 next[x-1][y] = Xballoon;
6399 cave[x][y] = Yballoon_wB;
6400 next[x][y] = Xblank;
6401 if (cave[x][y-1] == Xblank)
6402 cave[x][y-1] = Xsplash_e;
6403 if (cave[x-2][y-1] == Xblank)
6404 cave[x-2][y-1] = Xsplash_w;
6405 play_element_sound(x, y, SOUND_acid, Xacid_1);
6412 static void Lball_common(int x, int y)
6414 play_element_sound(x, y, SOUND_ball, Xball_1);
6416 if (lev.ball_random)
6421 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6422 is_blank[cave[x-1][y-1]])
6424 cave[x-1][y-1] = Yball_blank;
6425 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6430 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6431 is_blank[cave[x][y-1]])
6433 cave[x][y-1] = Yball_blank;
6434 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6439 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6440 is_blank[cave[x+1][y-1]])
6442 cave[x+1][y-1] = Yball_blank;
6443 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6448 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6449 is_blank[cave[x-1][y]])
6451 cave[x-1][y] = Yball_blank;
6452 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6457 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6458 is_blank[cave[x+1][y]])
6460 cave[x+1][y] = Yball_blank;
6461 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6466 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6467 is_blank[cave[x-1][y+1]])
6469 cave[x-1][y+1] = Yball_blank;
6470 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6475 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6476 is_blank[cave[x][y+1]])
6478 cave[x][y+1] = Yball_blank;
6479 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6484 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6485 is_blank[cave[x+1][y+1]])
6487 cave[x+1][y+1] = Yball_blank;
6488 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6495 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6496 is_blank[cave[x-1][y-1]])
6498 cave[x-1][y-1] = Yball_blank;
6499 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6502 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6503 is_blank[cave[x][y-1]])
6505 cave[x][y-1] = Yball_blank;
6506 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6509 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6510 is_blank[cave[x+1][y-1]])
6512 cave[x+1][y-1] = Yball_blank;
6513 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6516 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6517 is_blank[cave[x-1][y]])
6519 cave[x-1][y] = Yball_blank;
6520 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6523 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6524 is_blank[cave[x+1][y]])
6526 cave[x+1][y] = Yball_blank;
6527 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6530 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6531 is_blank[cave[x-1][y+1]])
6533 cave[x-1][y+1] = Yball_blank;
6534 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6537 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6538 is_blank[cave[x][y+1]])
6540 cave[x][y+1] = Yball_blank;
6541 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6544 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6545 is_blank[cave[x+1][y+1]])
6547 cave[x+1][y+1] = Yball_blank;
6548 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6552 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
6555 static void Lball_1(int x, int y)
6557 if (!lev.ball_active)
6560 cave[x][y] = Yball_1;
6561 next[x][y] = Xball_2;
6568 static void Lball_2(int x, int y)
6570 if (!lev.ball_active)
6573 cave[x][y] = Yball_2;
6574 next[x][y] = Xball_1;
6581 static void Ldrip(int x, int y)
6583 next[x][y] = Xdrip_fall;
6586 static void Ldrip_fall(int x, int y)
6590 switch (cave[x][y+1])
6606 cave[x][y] = Ydrip_1_sB;
6607 next[x][y] = Xdrip_stretchB;
6608 cave[x][y+1] = Ydrip_1_s;
6609 next[x][y+1] = Xdrip_stretch;
6620 cave[x][y] = Ydrip_1_sB;
6621 next[x][y] = Xdrip_stretchB;
6622 if (cave[x+1][y] == Xblank)
6623 cave[x+1][y] = Xsplash_e;
6624 if (cave[x-1][y] == Xblank)
6625 cave[x-1][y] = Xsplash_w;
6626 play_element_sound(x, y, SOUND_acid, Xacid_1);
6632 case 0: temp = Xamoeba_1; break;
6633 case 1: temp = Xamoeba_2; break;
6634 case 2: temp = Xamoeba_3; break;
6635 case 3: temp = Xamoeba_4; break;
6636 case 4: temp = Xamoeba_5; break;
6637 case 5: temp = Xamoeba_6; break;
6638 case 6: temp = Xamoeba_7; break;
6639 case 7: temp = Xamoeba_8; break;
6644 play_element_sound(x, y, SOUND_drip, Xdrip_fall);
6649 static void Ldrip_stretch(int x, int y)
6651 cave[x][y] = Ydrip_2_s;
6652 next[x][y] = Xdrip_fall;
6655 static void Ldrip_stretchB(int x, int y)
6657 cave[x][y] = Ydrip_2_sB;
6658 next[x][y] = Xblank;
6661 static void Lwonderwall(int x, int y)
6663 if (lev.wonderwall_time > 0 && lev.wonderwall_active)
6665 cave[x][y] = Ywonderwall;
6666 play_element_sound(x, y, SOUND_wonder, Xwonderwall);
6670 static void Lwheel(int x, int y)
6672 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
6673 cave[x][y] = Ywheel;
6676 static void Lswitch(int x, int y)
6678 if (lev.ball_active)
6679 cave[x][y] = Yswitch;
6682 static void Lfake_blank(int x, int y)
6685 cave[x][y] = Yfake_blank;
6688 static void Lfake_grass(int x, int y)
6690 if (lev.magnify_cnt)
6691 cave[x][y] = Yfake_grass;
6694 static void Lfake_amoeba(int x, int y)
6697 cave[x][y] = Yfake_amoeba;
6700 static void Lsand_stone(int x, int y)
6702 switch (cave[x][y+1])
6715 cave[x][y] = Xsand_stonesand_quickout_1;
6716 next[x][y] = Xsand_stonesand_quickout_2;
6717 cave[x][y+1] = Xsand_stoneout_1;
6718 next[x][y+1] = Xsand_stoneout_2;
6729 cave[x][y] = Xsand_stonesand_quickout_1;
6730 next[x][y] = Xsand_stonesand_quickout_2;
6731 if (cave[x+1][y] == Xblank)
6732 cave[x+1][y] = Xsplash_e;
6733 if (cave[x-1][y] == Xblank)
6734 cave[x-1][y] = Xsplash_w;
6735 play_element_sound(x, y, SOUND_acid, Xacid_1);
6739 cave[x][y] = Xsand_stonesand_1;
6740 next[x][y] = Xsand_stonesand_2;
6741 cave[x][y+1] = Xsand_sandstone_1;
6742 next[x][y+1] = Xsand_sandstone_2;
6747 static void Lsand_stonein_1(int x, int y)
6749 next[x][y] = Xsand_stonein_2;
6752 static void Lsand_stonein_2(int x, int y)
6754 next[x][y] = Xsand_stonein_3;
6757 static void Lsand_stonein_3(int x, int y)
6759 next[x][y] = Xsand_stonein_4;
6762 static void Lsand_stonein_4(int x, int y)
6764 next[x][y] = Xblank;
6767 static void Lsand_sandstone_1(int x, int y)
6769 next[x][y] = Xsand_sandstone_2;
6772 static void Lsand_sandstone_2(int x, int y)
6774 next[x][y] = Xsand_sandstone_3;
6777 static void Lsand_sandstone_3(int x, int y)
6779 next[x][y] = Xsand_sandstone_4;
6782 static void Lsand_sandstone_4(int x, int y)
6784 next[x][y] = Xsand_stone;
6787 static void Lsand_stonesand_1(int x, int y)
6789 next[x][y] = Xsand_stonesand_2;
6792 static void Lsand_stonesand_2(int x, int y)
6794 next[x][y] = Xsand_stonesand_3;
6797 static void Lsand_stonesand_3(int x, int y)
6799 next[x][y] = Xsand_stonesand_4;
6802 static void Lsand_stonesand_4(int x, int y)
6807 static void Lsand_stoneout_1(int x, int y)
6809 next[x][y] = Xsand_stoneout_2;
6812 static void Lsand_stoneout_2(int x, int y)
6814 next[x][y] = Xstone_fall;
6817 static void Lsand_stonesand_quickout_1(int x, int y)
6819 next[x][y] = Xsand_stonesand_quickout_2;
6822 static void Lsand_stonesand_quickout_2(int x, int y)
6827 static void Lslide_ns(int x, int y)
6829 if (is_blank[cave[x][y-1]])
6831 cave[x][y-1] = Yslide_ns_blank;
6832 next[x][y-1] = Xslide_ns;
6833 play_element_sound(x, y, SOUND_slide, Xslide_ns);
6836 if (is_blank[cave[x][y+1]])
6838 cave[x][y+1] = Yslide_ns_blank;
6839 next[x][y+1] = Xslide_ns;
6840 play_element_sound(x, y, SOUND_slide, Xslide_ns);
6844 static void Lslide_ew(int x, int y)
6846 if (is_blank[cave[x+1][y]])
6848 cave[x+1][y] = Yslide_ew_blank;
6849 next[x+1][y] = Xslide_ew;
6850 play_element_sound(x, y, SOUND_slide, Xslide_ew);
6853 if (is_blank[cave[x-1][y]])
6855 cave[x-1][y] = Yslide_ew_blank;
6856 next[x-1][y] = Xslide_ew;
6857 play_element_sound(x, y, SOUND_slide, Xslide_ew);
6861 static void Lexit(int x, int y)
6863 if (lev.gems_needed > 0)
6866 switch (RANDOM(64) / 21)
6869 cave[x][y] = Xexit_1;
6870 next[x][y] = Xexit_2;
6874 cave[x][y] = Xexit_2;
6875 next[x][y] = Xexit_3;
6879 cave[x][y] = Xexit_3;
6880 next[x][y] = Xexit_1;
6884 play_element_sound(x, y, SOUND_exit_open, Xexit);
6887 static void Lexit_1(int x, int y)
6889 next[x][y] = Xexit_2;
6892 static void Lexit_2(int x, int y)
6894 next[x][y] = Xexit_3;
6897 static void Lexit_3(int x, int y)
6899 next[x][y] = Xexit_1;
6902 static void Lpause(int x, int y)
6904 next[x][y] = Xblank;
6907 static void Lamoeba(int x, int y)
6927 if (is_amoeba[cave[x][y-1]] ||
6928 is_amoeba[cave[x+1][y]] ||
6929 is_amoeba[cave[x][y+1]] ||
6930 is_amoeba[cave[x-1][y]])
6935 static void Lboom_one(int x, int y, boolean by_dynamite)
6996 cave[x][y] = Xboom_android;
7007 cave[x][y] = Xboom_bug;
7008 Lboom_bug_new(x, y, TRUE);
7014 cave[x][y] = Xboom_tank;
7015 Lboom_tank_new(x, y, TRUE);
7019 cave[x][y] = Xboom_1;
7024 static void Lboom_nine(int x, int y, boolean by_dynamite)
7026 Lboom_one(x, y-1, by_dynamite);
7027 Lboom_one(x-1, y, by_dynamite);
7028 Lboom_one(x+1, y, by_dynamite);
7029 Lboom_one(x, y+1, by_dynamite);
7030 Lboom_one(x-1, y-1, by_dynamite);
7031 Lboom_one(x+1, y-1, by_dynamite);
7032 Lboom_one(x-1, y+1, by_dynamite);
7033 Lboom_one(x+1, y+1, by_dynamite);
7035 cave[x][y] = Xboom_1;
7038 static void Lexplode(int x, int y)
7043 Lboom_bug_new(x, y, FALSE);
7044 Lboom_nine(x, y, FALSE);
7048 Lboom_tank_new(x, y, FALSE);
7049 Lboom_nine(x, y, FALSE);
7053 Lboom_eater_new(x, y, FALSE);
7054 Lboom_nine(x, y, FALSE);
7058 Lboom_nine(x, y, TRUE);
7062 Lboom_nine(x, y, FALSE);
7067 static void Lboom_1(int x, int y)
7069 next[x][y] = Xboom_2;
7070 #if !PLAY_ELEMENT_SOUND
7071 if (x != lev.exit_x && y != lev.exit_y)
7072 play_sound(x, y, SOUND_boom);
7074 lev.exit_x = lev.exit_y = -1;
7078 static void Lboom_2(int x, int y)
7080 next[x][y] = boom[x][y];
7083 static void Lboom_android(int x, int y)
7085 #if PLAY_ELEMENT_SOUND
7086 play_element_sound(x, y, SOUND_boom, Xandroid);
7092 static void Lchain(int x, int y)
7097 static void handle_tile(int x, int y)
7101 case Xacid_1: Lacid_1(x, y); break;
7102 case Xacid_2: Lacid_2(x, y); break;
7103 case Xacid_3: Lacid_3(x, y); break;
7104 case Xacid_4: Lacid_4(x, y); break;
7105 case Xacid_5: Lacid_5(x, y); break;
7106 case Xacid_6: Lacid_6(x, y); break;
7107 case Xacid_7: Lacid_7(x, y); break;
7108 case Xacid_8: Lacid_8(x, y); break;
7110 case Xfake_acid_1: Lfake_acid_1(x, y); break;
7111 case Xfake_acid_2: Lfake_acid_2(x, y); break;
7112 case Xfake_acid_3: Lfake_acid_3(x, y); break;
7113 case Xfake_acid_4: Lfake_acid_4(x, y); break;
7114 case Xfake_acid_5: Lfake_acid_5(x, y); break;
7115 case Xfake_acid_6: Lfake_acid_6(x, y); break;
7116 case Xfake_acid_7: Lfake_acid_7(x, y); break;
7117 case Xfake_acid_8: Lfake_acid_8(x, y); break;
7119 case Xandroid: Landroid(x, y); break;
7120 case Xandroid_1_n: Landroid_1_n(x, y); break;
7121 case Xandroid_2_n: Landroid_2_n(x, y); break;
7122 case Xandroid_1_e: Landroid_1_e(x, y); break;
7123 case Xandroid_2_e: Landroid_2_e(x, y); break;
7124 case Xandroid_1_s: Landroid_1_s(x, y); break;
7125 case Xandroid_2_s: Landroid_2_s(x, y); break;
7126 case Xandroid_1_w: Landroid_1_w(x, y); break;
7127 case Xandroid_2_w: Landroid_2_w(x, y); break;
7129 case Xeater_n: Leater_n(x, y); break;
7130 case Xeater_e: Leater_e(x, y); break;
7131 case Xeater_s: Leater_s(x, y); break;
7132 case Xeater_w: Leater_w(x, y); break;
7134 case Xalien: Lalien(x, y); break;
7135 case Xalien_pause: Lalien_pause(x, y); break;
7137 case Xbug_1_n: Lbug_1_n(x, y); break;
7138 case Xbug_2_n: Lbug_2_n(x, y); break;
7139 case Xbug_1_e: Lbug_1_e(x, y); break;
7140 case Xbug_2_e: Lbug_2_e(x, y); break;
7141 case Xbug_1_s: Lbug_1_s(x, y); break;
7142 case Xbug_2_s: Lbug_2_s(x, y); break;
7143 case Xbug_1_w: Lbug_1_w(x, y); break;
7144 case Xbug_2_w: Lbug_2_w(x, y); break;
7146 case Xtank_1_n: Ltank_1_n(x, y); break;
7147 case Xtank_2_n: Ltank_2_n(x, y); break;
7148 case Xtank_1_e: Ltank_1_e(x, y); break;
7149 case Xtank_2_e: Ltank_2_e(x, y); break;
7150 case Xtank_1_s: Ltank_1_s(x, y); break;
7151 case Xtank_2_s: Ltank_2_s(x, y); break;
7152 case Xtank_1_w: Ltank_1_w(x, y); break;
7153 case Xtank_2_w: Ltank_2_w(x, y); break;
7155 case Xemerald: Lemerald(x, y); break;
7156 case Xemerald_pause: Lemerald_pause(x, y); break;
7157 case Xemerald_fall: Lemerald_fall(x, y); break;
7159 case Xdiamond: Ldiamond(x, y); break;
7160 case Xdiamond_pause: Ldiamond_pause(x, y); break;
7161 case Xdiamond_fall: Ldiamond_fall(x, y); break;
7163 case Xstone: Lstone(x, y); break;
7164 case Xstone_pause: Lstone_pause(x, y); break;
7165 case Xstone_fall: Lstone_fall(x, y); break;
7167 case Xbomb: Lbomb(x, y); break;
7168 case Xbomb_pause: Lbomb_pause(x, y); break;
7169 case Xbomb_fall: Lbomb_fall(x, y); break;
7171 case Xnut: Lnut(x, y); break;
7172 case Xnut_pause: Lnut_pause(x, y); break;
7173 case Xnut_fall: Lnut_fall(x, y); break;
7175 case Xspring: Lspring(x, y); break;
7176 case Xspring_pause: Lspring_pause(x, y); break;
7177 case Xspring_e: Lspring_e(x, y); break;
7178 case Xspring_w: Lspring_w(x, y); break;
7179 case Xspring_fall: Lspring_fall(x, y); break;
7181 case Xpush_emerald_e: Lpush_emerald_e(x, y); break;
7182 case Xpush_emerald_w: Lpush_emerald_w(x, y); break;
7183 case Xpush_diamond_e: Lpush_diamond_e(x, y); break;
7184 case Xpush_diamond_w: Lpush_diamond_w(x, y); break;
7185 case Xpush_stone_e: Lpush_stone_e(x, y); break;
7186 case Xpush_stone_w: Lpush_stone_w(x, y); break;
7187 case Xpush_bomb_e: Lpush_bomb_e(x, y); break;
7188 case Xpush_bomb_w: Lpush_bomb_w(x, y); break;
7189 case Xpush_nut_e: Lpush_nut_e(x, y); break;
7190 case Xpush_nut_w: Lpush_nut_w(x, y); break;
7191 case Xpush_spring_e: Lpush_spring_e(x, y); break;
7192 case Xpush_spring_w: Lpush_spring_w(x, y); break;
7194 case Xdynamite_1: Ldynamite_1(x, y); break;
7195 case Xdynamite_2: Ldynamite_2(x, y); break;
7196 case Xdynamite_3: Ldynamite_3(x, y); break;
7197 case Xdynamite_4: Ldynamite_4(x, y); break;
7199 case Xfake_door_1: Lfake_door_1(x, y); break;
7200 case Xfake_door_2: Lfake_door_2(x, y); break;
7201 case Xfake_door_3: Lfake_door_3(x, y); break;
7202 case Xfake_door_4: Lfake_door_4(x, y); break;
7203 case Xfake_door_5: Lfake_door_5(x, y); break;
7204 case Xfake_door_6: Lfake_door_6(x, y); break;
7205 case Xfake_door_7: Lfake_door_7(x, y); break;
7206 case Xfake_door_8: Lfake_door_8(x, y); break;
7208 case Xballoon: Lballoon(x, y); break;
7210 case Xball_1: Lball_1(x, y); break;
7211 case Xball_2: Lball_2(x, y); break;
7213 case Xdrip: Ldrip(x, y); break;
7214 case Xdrip_fall: Ldrip_fall(x, y); break;
7215 case Xdrip_stretch: Ldrip_stretch(x, y); break;
7216 case Xdrip_stretchB: Ldrip_stretchB(x, y); break;
7218 case Xwonderwall: Lwonderwall(x, y); break;
7220 case Xwheel: Lwheel(x, y); break;
7222 case Xswitch: Lswitch(x, y); break;
7224 case Xfake_blank: Lfake_blank(x, y); break;
7225 case Xfake_grass: Lfake_grass(x, y); break;
7226 case Xfake_amoeba: Lfake_amoeba(x, y); break;
7228 case Xsand_stone: Lsand_stone(x, y); break;
7229 case Xsand_stonein_1: Lsand_stonein_1(x, y); break;
7230 case Xsand_stonein_2: Lsand_stonein_2(x, y); break;
7231 case Xsand_stonein_3: Lsand_stonein_3(x, y); break;
7232 case Xsand_stonein_4: Lsand_stonein_4(x, y); break;
7233 case Xsand_sandstone_1: Lsand_sandstone_1(x, y); break;
7234 case Xsand_sandstone_2: Lsand_sandstone_2(x, y); break;
7235 case Xsand_sandstone_3: Lsand_sandstone_3(x, y); break;
7236 case Xsand_sandstone_4: Lsand_sandstone_4(x, y); break;
7237 case Xsand_stonesand_1: Lsand_stonesand_1(x, y); break;
7238 case Xsand_stonesand_2: Lsand_stonesand_2(x, y); break;
7239 case Xsand_stonesand_3: Lsand_stonesand_3(x, y); break;
7240 case Xsand_stonesand_4: Lsand_stonesand_4(x, y); break;
7241 case Xsand_stoneout_1: Lsand_stoneout_1(x, y); break;
7242 case Xsand_stoneout_2: Lsand_stoneout_2(x, y); break;
7243 case Xsand_stonesand_quickout_1: Lsand_stonesand_quickout_1(x, y); break;
7244 case Xsand_stonesand_quickout_2: Lsand_stonesand_quickout_2(x, y); break;
7246 case Xslide_ns: Lslide_ns(x, y); break;
7247 case Xslide_ew: Lslide_ew(x, y); break;
7249 case Xexit: Lexit(x, y); break;
7250 case Xexit_1: Lexit_1(x, y); break;
7251 case Xexit_2: Lexit_2(x, y); break;
7252 case Xexit_3: Lexit_3(x, y); break;
7254 case Xpause: Lpause(x, y); break;
7256 case Xchain: Lchain(x, y); break;
7257 case Xboom_bug: Lboom_bug(x, y); break;
7258 case Xboom_tank: Lboom_tank(x, y); break;
7259 case Xboom_android: Lboom_android(x, y); break;
7260 case Xboom_1: Lboom_1(x, y); break;
7261 case Xboom_2: Lboom_2(x, y); break;
7265 static void logic_players(void)
7274 game_em.any_player_moving = FALSE;
7275 game_em.any_player_snapping = FALSE;
7277 /* must test for death and actually kill separately */
7278 for (i = 0; i < MAX_PLAYERS; i++)
7280 boolean ply_kill = player_killed(&ply[i]);
7282 if (ply[i].alive && ply_kill)
7283 kill_player(&ply[i]);
7286 for (i = 0; i < MAX_PLAYERS; i++)
7291 /* check for wrap-around movement */
7292 if (ply[i].x < lev.left ||
7293 ply[i].x > lev.right - 1)
7295 ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left);
7297 game.centered_player_nr_next = i;
7298 game.set_centered_player = TRUE;
7299 game.set_centered_player_wrap = TRUE;
7302 ply[i].prev_x = ply[i].x;
7303 ply[i].prev_y = ply[i].y;
7304 ply[i].anim = PLY_still;
7307 start_check_nr = ((game_em.random & 128 ? 0 : 1) * 2 +
7308 (game_em.random & 256 ? 0 : 1));
7310 for (i = 0; i < MAX_PLAYERS; i++)
7312 int check_nr = (start_check_nr + i) % MAX_PLAYERS;
7314 if (ply[check_nr].alive)
7315 check_player(&ply[check_nr]);
7318 for (i = 0; i < MAX_PLAYERS; i++)
7323 if (cave[ply[i].prev_x][ply[i].prev_y] == Zplayer)
7325 cave[ply[i].prev_x][ply[i].prev_y] = Xblank;
7326 next[ply[i].prev_x][ply[i].prev_y] = Xblank;
7329 if (cave[ply[i].x][ply[i].y] == Xblank)
7331 cave[ply[i].x][ply[i].y] = Zplayer;
7332 next[ply[i].x][ply[i].y] = Zplayer;
7337 static void logic_objects(void)
7345 seed = game_em.random;
7348 for (y = lev.top; y < lev.bottom; y++)
7349 for (x = lev.left; x < lev.right; x++)
7352 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
7353 lev.score += score; /* only add a score if someone is alive */
7355 game_em.game_over = TRUE;
7357 game_em.random = seed;
7359 /* triple buffering */
7360 void *temp = lev.cave;
7361 lev.cave = lev.next;
7362 lev.next = lev.draw;
7366 static void logic_globals(void)
7371 unsigned int random;
7377 /* update variables */
7379 if (lev.score > 9999)
7382 if (lev.android_move_cnt-- == 0)
7383 lev.android_move_cnt = lev.android_move_time;
7384 if (lev.android_clone_cnt-- == 0)
7385 lev.android_clone_cnt = lev.android_clone_time;
7386 if (lev.ball_active)
7387 if (lev.ball_cnt-- == 0)
7388 lev.ball_cnt = lev.ball_time;
7391 if (lev.magnify_cnt)
7397 if (lev.wonderwall_time > 0 && lev.wonderwall_active)
7398 lev.wonderwall_time--;
7401 play_element_sound(lev.wheel_x, lev.wheel_y, SOUND_wheel, Xwheel);
7405 random = game_em.random;
7407 for (count = lev.amoeba_time; count--;)
7409 x = lev.left - 1 + (random >> 10) % (CAVE_WIDTH + 2);
7410 y = lev.top - 1 + (random >> 20) % (CAVE_HEIGHT + 2);
7412 if (x >= lev.left && x < lev.right &&
7413 y >= lev.top && y < lev.bottom)
7416 random = random * 129 + 1;
7419 game_em.random = random;
7421 /* handle explosions */
7423 for (y = lev.top; y < lev.bottom; y++)
7424 for (x = lev.left; x < lev.right; x++)
7427 /* triple buffering */
7429 for (y = lev.top; y < lev.bottom; y++)
7430 for (x = lev.left; x < lev.right; x++)
7431 next[x][y] = cave[x][y];