5 * my own version of the emerald mine engine
11 #define SPRING_ROLL /* spring rolling off round things continues to roll */
12 #define USE_CHANGED_ACID_STUFF
14 #define RANDOM_RAW (seed = seed << 31 | seed >> 1)
15 #define RANDOM(x) (RANDOM_RAW & (x - 1))
17 static short **cave, **next, **boom;
18 static unsigned int seed;
21 static void Lboom_generic(int x, int y, int element, int element_middle)
23 boom[x-1][y-1] = element;
24 boom[x][y-1] = element;
25 boom[x+1][y-1] = element;
26 boom[x-1][y] = element;
27 boom[x][y] = element_middle;
28 boom[x+1][y] = element;
29 boom[x-1][y+1] = element;
30 boom[x][y+1] = element;
31 boom[x+1][y+1] = element;
34 static void Lboom_bug(int x, int y, int by_element)
38 Lboom_generic(x, y, Xemerald, Xdiamond);
40 #if PLAY_ELEMENT_SOUND
41 play_element_sound(x, y, SOUND_boom, by_element);
45 static void Lboom_tank(int x, int y, int by_element)
49 Lboom_generic(x, y, Xblank, Xblank);
51 #if PLAY_ELEMENT_SOUND
52 play_element_sound(x, y, SOUND_boom, by_element);
56 static void Lboom_eater(int x, int y, int by_element)
60 boom[x-1][y-1] = lev.eater_array[lev.eater_pos][0];
61 boom[x][y-1] = lev.eater_array[lev.eater_pos][1];
62 boom[x+1][y-1] = lev.eater_array[lev.eater_pos][2];
63 boom[x-1][y] = lev.eater_array[lev.eater_pos][3];
64 boom[x][y] = lev.eater_array[lev.eater_pos][4];
65 boom[x+1][y] = lev.eater_array[lev.eater_pos][5];
66 boom[x-1][y+1] = lev.eater_array[lev.eater_pos][6];
67 boom[x][y+1] = lev.eater_array[lev.eater_pos][7];
68 boom[x+1][y+1] = lev.eater_array[lev.eater_pos][8];
70 lev.eater_pos = (lev.eater_pos + 1) & 7;
72 #if PLAY_ELEMENT_SOUND
73 play_element_sound(x, y, SOUND_boom, by_element);
77 static boolean player_killed(struct PLAYER *ply)
85 if (lev.killed_out_of_time && setup.time_limit)
109 switch (cave[x+1][y])
130 switch (cave[x][y+1])
151 switch (cave[x-1][y])
196 static void kill_player(struct PLAYER *ply)
203 switch (cave[x][y-1])
213 cave[x][y-1] = Xboom_bug;
224 cave[x][y-1] = Xboom_bomb;
228 switch (cave[x+1][y])
238 cave[x+1][y] = Xboom_bug;
249 cave[x+1][y] = Xboom_bomb;
253 switch (cave[x][y+1])
263 cave[x][y+1] = Xboom_bug;
274 cave[x][y+1] = Xboom_bomb;
278 switch (cave[x-1][y])
288 cave[x-1][y] = Xboom_bug;
299 cave[x-1][y] = Xboom_bomb;
310 play_element_sound(x, y, SOUND_exit_leave, Xexit_1);
314 play_element_sound(x, y, SOUND_die, Zplayer);
320 #ifdef USE_CHANGED_ACID_STUFF
333 cave[x][y] = Xboom_1;
339 static boolean player_digfield(struct PLAYER *ply, int dx, int dy)
341 int anim = (dx < 0 ? 3 : dx > 0 ? 1 : dy < 0 ? 0 : dy > 0 ? 2 : 2);
346 boolean result = TRUE;
348 if (!dx && !dy) /* no direction specified */
351 if (dx && dy && ply->joy_snap) /* more than one direction specified */
354 if (ply->joy_snap == 0) /* player wants to move */
356 int element = cave[x][y];
360 /* fire is released */
364 cave[x][y] = Zplayer;
365 next[x][y] = Zplayer;
374 play_element_sound(x, y, SOUND_blank, Xblank);
375 ply->anim = PLY_walk_n + anim;
380 #ifdef USE_CHANGED_ACID_STUFF
389 if (cave[x+1][y-1] == Xblank)
390 cave[x+1][y-1] = Xsplash_e;
391 if (cave[x-1][y-1] == Xblank)
392 cave[x-1][y-1] = Xsplash_w;
393 play_element_sound(x, y, SOUND_acid, Xacid_1);
415 #ifndef USE_CHANGED_ACID_STUFF
425 ply->anim = PLY_walk_n + anim;
431 cave[x][y] = (dy ? (dy < 0 ? Ygrass_nB : Ygrass_sB) :
432 (dx > 0 ? Ygrass_eB : Ygrass_wB));
433 next[x][y] = Zplayer;
434 play_element_sound(x, y, SOUND_dirt, Xgrass);
435 ply->anim = PLY_walk_n + anim;
441 cave[x][y] = (dy ? (dy < 0 ? Ydirt_nB : Ydirt_sB) :
442 (dx > 0 ? Ydirt_eB : Ydirt_wB));
443 next[x][y] = Zplayer;
444 play_element_sound(x, y, SOUND_dirt, Xdirt);
445 ply->anim = PLY_walk_n + anim;
452 cave[x][y] = Ydiamond_blank;
453 next[x][y] = Zplayer;
454 play_element_sound(x, y, SOUND_collect, element);
455 lev.score += lev.diamond_score;
456 lev.required = lev.required < 3 ? 0 : lev.required - 3;
457 game.snapshot.collected_item = TRUE;
458 ply->anim = PLY_walk_n + anim;
465 cave[x][y] = Yemerald_blank;
466 next[x][y] = Zplayer;
467 play_element_sound(x, y, SOUND_collect, element);
468 lev.score += lev.emerald_score;
469 lev.required = lev.required < 1 ? 0 : lev.required - 1;
470 game.snapshot.collected_item = TRUE;
471 ply->anim = PLY_walk_n + anim;
477 cave[x][y] = Ydynamite_blank;
478 next[x][y] = Zplayer;
479 play_element_sound(x, y, SOUND_collect, element);
480 lev.score += lev.dynamite_score;
481 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
482 ply->anim = PLY_walk_n + anim;
489 cave[x][y] = Ykey_1_blank;
494 cave[x][y] = Ykey_2_blank;
499 cave[x][y] = Ykey_3_blank;
504 cave[x][y] = Ykey_4_blank;
509 cave[x][y] = Ykey_5_blank;
514 cave[x][y] = Ykey_6_blank;
519 cave[x][y] = Ykey_7_blank;
524 cave[x][y] = Ykey_8_blank;
529 next[x][y] = Zplayer;
530 play_element_sound(x, y, SOUND_collect, element);
531 lev.score += lev.key_score;
532 ply->anim = PLY_walk_n + anim;
538 cave[x][y] = Ylenses_blank;
539 next[x][y] = Zplayer;
540 play_element_sound(x, y, SOUND_collect, element);
541 lev.score += lev.lenses_score;
542 lev.lenses_cnt = lev.lenses_time;
543 ply->anim = PLY_walk_n + anim;
549 cave[x][y] = Ymagnify_blank;
550 next[x][y] = Zplayer;
551 play_element_sound(x, y, SOUND_collect, element);
552 lev.score += lev.magnify_score;
553 lev.magnify_cnt = lev.magnify_time;
554 ply->anim = PLY_walk_n + anim;
563 switch (cave[x+dx][y])
576 cave[x+dx][y] = dx > 0 ? Ystone_e : Ystone_w;
577 next[x+dx][y] = Xstone_pause;
588 if (cave[x+dx+1][y-1] == Xblank)
589 cave[x+dx+1][y-1] = Xsplash_e;
590 if (cave[x+dx-1][y-1] == Xblank)
591 cave[x+dx-1][y-1] = Xsplash_w;
592 play_element_sound(x, y, SOUND_acid, Xacid_1);
596 cave[x][y] = dx > 0 ? Ystone_eB : Ystone_wB;
597 next[x][y] = Zplayer;
598 play_element_sound(x, y, SOUND_roll, Xstone);
603 ply->anim = PLY_push_n + anim;
610 switch (cave[x+dx][y])
623 cave[x+dx][y] = dx > 0 ? Ybomb_e : Ybomb_w;
624 next[x+dx][y] = Xbomb_pause;
635 if (cave[x+dx+1][y-1] == Xblank)
636 cave[x+dx+1][y-1] = Xsplash_e;
637 if (cave[x+dx-1][y-1] == Xblank)
638 cave[x+dx-1][y-1] = Xsplash_w;
639 play_element_sound(x, y, SOUND_acid, Xacid_1);
643 cave[x][y] = dx > 0 ? Ybomb_eB : Ybomb_wB;
644 next[x][y] = Zplayer;
645 play_element_sound(x, y, SOUND_roll, Xbomb);
650 ply->anim = PLY_push_n + anim;
657 switch (cave[x+dx][y])
670 cave[x+dx][y] = dx > 0 ? Ynut_e : Ynut_w;
671 next[x+dx][y] = Xnut_pause;
682 if (cave[x+dx+1][y-1] == Xblank)
683 cave[x+dx+1][y-1] = Xsplash_e;
684 if (cave[x+dx-1][y-1] == Xblank)
685 cave[x+dx-1][y-1] = Xsplash_w;
686 play_element_sound(x, y, SOUND_acid, Xacid_1);
690 cave[x][y] = dx > 0 ? Ynut_eB : Ynut_wB;
691 next[x][y] = Zplayer;
692 play_element_sound(x, y, SOUND_roll, Xnut);
697 ply->anim = PLY_push_n + anim;
704 switch (cave[x+dx][y])
717 cave[x+dx][y] = dx > 0 ? Yspring_e : Yspring_w;
718 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
729 if (cave[x+dx+1][y-1] == Xblank)
730 cave[x+dx+1][y-1] = Xsplash_e;
731 if (cave[x+dx-1][y-1] == Xblank)
732 cave[x+dx-1][y-1] = Xsplash_w;
733 play_element_sound(x, y, SOUND_acid, Xacid_1);
737 cave[x][y] = dx > 0 ? Yspring_eB : Yspring_wB;
738 next[x][y] = Zplayer;
739 play_element_sound(x, y, SOUND_roll, Xspring);
745 cave[x][y] = dx > 0 ? Yspring_alien_eB : Yspring_alien_wB;
746 cave[x+dx][y] = dx > 0 ? Yspring_alien_e : Yspring_alien_w;
747 next[x][y] = Zplayer;
748 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
749 play_element_sound(x, y, SOUND_slurp, Xalien);
750 lev.score += lev.slurp_score;
755 ply->anim = PLY_push_n + anim;
762 case Xsand_stonein_1:
763 case Xsand_stonein_2:
764 case Xsand_stonein_3:
765 case Xsand_stonein_4:
769 ply->anim = PLY_push_n + anim;
773 switch (cave[x+dx][y+dy])
786 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yballoon_n : Yballoon_s) :
787 (dx > 0 ? Yballoon_e : Yballoon_w));
788 next[x+dx][y+dy] = Xballoon;
799 if (cave[x+dx+1][y+dy-1] == Xblank)
800 cave[x+dx+1][y+dy-1] = Xsplash_e;
801 if (cave[x+dx-1][y+dy-1] == Xblank)
802 cave[x+dx-1][y+dy-1] = Xsplash_w;
803 play_element_sound(x, y, SOUND_acid, Xacid_1);
807 cave[x][y] = (dy ? (dy < 0 ? Yballoon_nB : Yballoon_sB) :
808 (dx > 0 ? Yballoon_eB : Yballoon_wB));
809 next[x][y] = Zplayer;
810 play_element_sound(x, y, SOUND_push, Xballoon);
816 ply->anim = PLY_push_n + anim;
828 switch (cave[x+dx][y+dy])
841 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yandroid_n : Yandroid_s) :
842 (dx > 0 ? Yandroid_e : Yandroid_w));
843 next[x+dx][y+dy] = (dy ? (dy < 0 ? Xandroid_2_n : Xandroid_2_s) :
844 (dx > 0 ? Xandroid_2_e : Xandroid_2_w));
855 if (cave[x+dx+1][y+dy-1] == Xblank)
856 cave[x+dx+1][y+dy-1] = Xsplash_e;
857 if (cave[x+dx-1][y+dy-1] == Xblank)
858 cave[x+dx-1][y+dy-1] = Xsplash_w;
859 play_element_sound(x, y, SOUND_acid, Xacid_1);
863 cave[x][y] = (dy ? (dy < 0 ? Yandroid_nB : Yandroid_sB) :
864 (dx > 0 ? Yandroid_eB : Yandroid_wB));
865 next[x][y] = Zplayer;
866 play_element_sound(x, y, SOUND_push, Xandroid);
872 ply->anim = PLY_push_n + anim;
877 if (ply->keys & 0x01)
884 if (ply->keys & 0x02)
891 if (ply->keys & 0x04)
898 if (ply->keys & 0x08)
905 if (ply->keys & 0x10)
912 if (ply->keys & 0x20)
919 if (ply->keys & 0x40)
926 if (ply->keys & 0x80)
933 if (!tab_blank[cave[x+dx][y+dy]])
936 if (!tab_fake_acid[cave[x+dx][y+dy]])
938 cave[x+dx][y+dy] = Zplayer;
939 next[x+dx][y+dy] = Zplayer;
942 play_element_sound(x, y, SOUND_door, element);
943 ply->anim = PLY_walk_n + anim;
949 play_element_sound(x, y, SOUND_press, element);
950 lev.wheel_cnt = lev.wheel_time;
956 lev.wind_direction = 0;
960 lev.wind_direction = 1;
964 lev.wind_direction = 2;
968 lev.wind_direction = 3;
972 lev.wind_direction = dy ? (dy < 0 ? 0 : 2) : (dx > 0 ? 1 : 3);
977 play_element_sound(x, y, SOUND_press, element);
978 lev.wind_cnt = lev.wind_time;
982 play_element_sound(x, y, SOUND_press, element);
987 play_element_sound(x, y, SOUND_press, element);
988 lev.ball_cnt = lev.ball_time;
989 lev.ball_state = !lev.ball_state;
995 play_element_sound(x, y, SOUND_blank, Xplant);
996 ply->anim = PLY_walk_n + anim;
1007 game_em.level_solved = TRUE;
1009 ply->anim = PLY_walk_n + anim;
1016 if (ply->x == oldx && ply->y == oldy) /* no movement */
1019 else /* player wants to snap */
1021 int element = cave[x][y];
1025 /* fire is pressed */
1028 cave[x][y] = Ygrass_blank;
1029 next[x][y] = Xblank;
1030 play_element_sound(x, y, SOUND_dirt, element);
1031 ply->anim = PLY_shoot_n + anim;
1035 cave[x][y] = Ydirt_blank;
1036 next[x][y] = Xblank;
1037 play_element_sound(x, y, SOUND_dirt, element);
1038 ply->anim = PLY_shoot_n + anim;
1042 case Xdiamond_pause:
1043 cave[x][y] = Ydiamond_blank;
1044 next[x][y] = Xblank;
1045 play_element_sound(x, y, SOUND_collect, element);
1046 lev.score += lev.diamond_score;
1047 lev.required = lev.required < 3 ? 0 : lev.required - 3;
1048 game.snapshot.collected_item = TRUE;
1049 ply->anim = PLY_walk_n + anim;
1053 case Xemerald_pause:
1054 cave[x][y] = Yemerald_blank;
1055 next[x][y] = Xblank;
1056 play_element_sound(x, y, SOUND_collect, element);
1057 lev.score += lev.emerald_score;
1058 lev.required = lev.required < 1 ? 0 : lev.required - 1;
1059 game.snapshot.collected_item = TRUE;
1060 ply->anim = PLY_walk_n + anim;
1064 cave[x][y] = Ydynamite_blank;
1065 next[x][y] = Xblank;
1066 play_element_sound(x, y, SOUND_collect, element);
1067 lev.score += lev.dynamite_score;
1068 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
1069 ply->anim = PLY_walk_n + anim;
1074 cave[x][y] = Ykey_1_blank;
1079 cave[x][y] = Ykey_2_blank;
1084 cave[x][y] = Ykey_3_blank;
1089 cave[x][y] = Ykey_4_blank;
1094 cave[x][y] = Ykey_5_blank;
1099 cave[x][y] = Ykey_6_blank;
1104 cave[x][y] = Ykey_7_blank;
1109 cave[x][y] = Ykey_8_blank;
1114 next[x][y] = Xblank;
1115 play_element_sound(x, y, SOUND_collect, element);
1116 lev.score += lev.key_score;
1117 ply->anim = PLY_walk_n + anim;
1121 cave[x][y] = Ylenses_blank;
1122 next[x][y] = Xblank;
1123 play_element_sound(x, y, SOUND_collect, element);
1124 lev.score += lev.lenses_score;
1125 lev.lenses_cnt = lev.lenses_time;
1126 ply->anim = PLY_walk_n + anim;
1130 cave[x][y] = Ymagnify_blank;
1131 next[x][y] = Xblank;
1132 play_element_sound(x, y, SOUND_collect, element);
1133 lev.score += lev.magnify_score;
1134 lev.magnify_cnt = lev.magnify_time;
1135 ply->anim = PLY_walk_n + anim;
1146 static void check_player(struct PLAYER *ply)
1154 game_em.last_player_direction[ply->num] = MV_NONE;
1156 if (ply->joy_w) /* west */
1161 else if (ply->joy_e) /* east */
1167 if (ply->joy_n) /* north */
1172 else if (ply->joy_s) /* south */
1184 boolean players_visible_before_move;
1185 boolean players_visible_after_move;
1188 players_visible_before_move = checkIfAllPlayersFitToScreen();
1193 players_visible_after_move = checkIfAllPlayersFitToScreen();
1196 player is allowed to move only in the following cases:
1197 - it is not needed to display all players (not focussed to all players)
1198 - all players are (still or again) visible after the move
1199 - some players were already outside visible screen area before the move
1201 can_move = (game.centered_player_nr != -1 ||
1202 players_visible_after_move ||
1203 !players_visible_before_move);
1210 ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
1216 if (dx == 0 && dy == 0)
1222 if (++ply->dynamite_cnt == 5 && ply->dynamite)
1224 cave[x][y] = Xdynamite_1;
1225 play_element_sound(x, y, SOUND_dynamite, Xdynamite_1);
1231 ply->dynamite_cnt = 0;
1234 RandomEM += 7; /* be a bit more random if the player doesn't move */
1240 ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
1241 ply->dynamite_cnt = 0; /* reset dynamite timer if we move */
1242 ply->joy_spin = !ply->joy_spin;
1244 if (ply->joy_snap == 0) /* player wants to move */
1246 boolean moved = FALSE;
1248 if (ply->last_move_dir & MV_HORIZONTAL)
1250 if (!(moved = player_digfield(ply, 0, dy)))
1251 moved = player_digfield(ply, dx, 0);
1255 if (!(moved = player_digfield(ply, dx, 0)))
1256 moved = player_digfield(ply, 0, dy);
1262 ply->last_move_dir = (dx < 0 ? MV_LEFT : MV_RIGHT);
1263 else if (oldy != ply->y)
1264 ply->last_move_dir = (dy < 0 ? MV_UP : MV_DOWN);
1266 game_em.any_player_moving = TRUE;
1267 game_em.last_moving_player = ply->num;
1268 game_em.last_player_direction[ply->num] = ply->last_move_dir;
1271 else /* player wants to snap */
1273 game_em.any_player_snapping = player_digfield(ply, dx, dy);
1277 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
1279 int distance, distance_shortest = CAVE_WIDTH + CAVE_HEIGHT;
1282 /* default values if no players are alive anymore */
1286 for (i = 0; i < MAX_PLAYERS; i++)
1291 distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
1293 if (distance < distance_shortest)
1298 distance_shortest = distance;
1303 static void Lacid_1(int x, int y)
1305 next[x][y] = Xacid_2;
1308 static void Lacid_2(int x, int y)
1310 next[x][y] = Xacid_3;
1313 static void Lacid_3(int x, int y)
1315 next[x][y] = Xacid_4;
1318 static void Lacid_4(int x, int y)
1320 next[x][y] = Xacid_5;
1323 static void Lacid_5(int x, int y)
1325 next[x][y] = Xacid_6;
1328 static void Lacid_6(int x, int y)
1330 next[x][y] = Xacid_7;
1333 static void Lacid_7(int x, int y)
1335 next[x][y] = Xacid_8;
1338 static void Lacid_8(int x, int y)
1340 next[x][y] = Xacid_1;
1343 static void Lfake_acid_1(int x, int y)
1345 next[x][y] = Xfake_acid_2;
1348 static void Lfake_acid_2(int x, int y)
1350 next[x][y] = Xfake_acid_3;
1353 static void Lfake_acid_3(int x, int y)
1355 next[x][y] = Xfake_acid_4;
1358 static void Lfake_acid_4(int x, int y)
1360 next[x][y] = Xfake_acid_5;
1363 static void Lfake_acid_5(int x, int y)
1365 next[x][y] = Xfake_acid_6;
1368 static void Lfake_acid_6(int x, int y)
1370 next[x][y] = Xfake_acid_7;
1373 static void Lfake_acid_7(int x, int y)
1375 next[x][y] = Xfake_acid_8;
1378 static void Lfake_acid_8(int x, int y)
1380 next[x][y] = Xfake_acid_1;
1383 static void Landroid(int x, int y)
1387 if (lev.android_clone_cnt == 0)
1389 if (cave[x-1][y-1] != Xblank &&
1390 cave[x][y-1] != Xblank &&
1391 cave[x+1][y-1] != Xblank &&
1392 cave[x-1][y] != Xblank &&
1393 cave[x+1][y] != Xblank &&
1394 cave[x-1][y+1] != Xblank &&
1395 cave[x][y+1] != Xblank &&
1396 cave[x+1][y+1] != Xblank)
1401 /* randomly find an object to clone */
1403 case 0: /* S,NE,W,NW,SE,E,SW,N */
1404 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1405 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1406 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1407 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1408 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1409 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1410 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1411 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1414 case 1: /* NW,SE,N,S,NE,SW,E,W */
1415 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1416 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1417 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1418 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1419 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1420 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1421 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1422 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1425 case 2: /* SW,E,S,W,N,NW,SE,NE */
1426 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1427 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1428 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1429 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1430 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1431 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1432 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1433 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1436 case 3: /* N,SE,NE,E,W,S,NW,SW */
1437 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1438 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1439 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1440 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1441 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1442 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1443 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1444 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1447 case 4: /* SE,NW,E,NE,SW,W,N,S */
1448 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1449 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1450 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1451 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1452 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1453 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1454 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1455 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1458 case 5: /* NE,W,SE,SW,S,N,E,NW */
1459 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1460 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1461 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1462 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1463 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1464 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1465 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1466 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1469 case 6: /* E,N,SW,S,NW,NE,SE,W */
1470 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1471 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1472 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1473 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1474 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1475 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1476 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1477 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1480 case 7: /* W,SW,NW,N,E,SE,NE,S */
1481 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1482 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1483 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1484 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1485 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1486 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1487 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1488 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1492 next[x][y] = temp; /* the item we chose to clone */
1493 play_element_sound(x, y, SOUND_android_clone, temp);
1497 /* randomly find a direction to move */
1499 case 0: /* S,NE,W,NW,SE,E,SW,N */
1500 if (cave[x][y+1] == Xblank) goto android_s;
1501 if (cave[x+1][y-1] == Xblank) goto android_ne;
1502 if (cave[x-1][y] == Xblank) goto android_w;
1503 if (cave[x-1][y-1] == Xblank) goto android_nw;
1504 if (cave[x+1][y+1] == Xblank) goto android_se;
1505 if (cave[x+1][y] == Xblank) goto android_e;
1506 if (cave[x-1][y+1] == Xblank) goto android_sw;
1507 if (cave[x][y-1] == Xblank) goto android_n;
1510 case 1: /* NW,SE,N,S,NE,SW,E,W */
1511 if (cave[x-1][y-1] == Xblank) goto android_nw;
1512 if (cave[x+1][y+1] == Xblank) goto android_se;
1513 if (cave[x][y-1] == Xblank) goto android_n;
1514 if (cave[x][y+1] == Xblank) goto android_s;
1515 if (cave[x+1][y-1] == Xblank) goto android_ne;
1516 if (cave[x-1][y+1] == Xblank) goto android_sw;
1517 if (cave[x+1][y] == Xblank) goto android_e;
1518 if (cave[x-1][y] == Xblank) goto android_w;
1521 case 2: /* SW,E,S,W,N,NW,SE,NE */
1522 if (cave[x-1][y+1] == Xblank) goto android_sw;
1523 if (cave[x+1][y] == Xblank) goto android_e;
1524 if (cave[x][y+1] == Xblank) goto android_s;
1525 if (cave[x-1][y] == Xblank) goto android_w;
1526 if (cave[x][y-1] == Xblank) goto android_n;
1527 if (cave[x-1][y-1] == Xblank) goto android_nw;
1528 if (cave[x+1][y+1] == Xblank) goto android_se;
1529 if (cave[x+1][y-1] == Xblank) goto android_ne;
1532 case 3: /* N,SE,NE,E,W,S,NW,SW */
1533 if (cave[x][y-1] == Xblank) goto android_n;
1534 if (cave[x+1][y+1] == Xblank) goto android_se;
1535 if (cave[x+1][y-1] == Xblank) goto android_ne;
1536 if (cave[x+1][y] == Xblank) goto android_e;
1537 if (cave[x-1][y] == Xblank) goto android_w;
1538 if (cave[x][y+1] == Xblank) goto android_s;
1539 if (cave[x-1][y-1] == Xblank) goto android_nw;
1540 if (cave[x-1][y+1] == Xblank) goto android_sw;
1543 case 4: /* SE,NW,E,NE,SW,W,N,S */
1544 if (cave[x+1][y+1] == Xblank) goto android_se;
1545 if (cave[x-1][y-1] == Xblank) goto android_nw;
1546 if (cave[x+1][y] == Xblank) goto android_e;
1547 if (cave[x+1][y-1] == Xblank) goto android_ne;
1548 if (cave[x-1][y+1] == Xblank) goto android_sw;
1549 if (cave[x-1][y] == Xblank) goto android_w;
1550 if (cave[x][y-1] == Xblank) goto android_n;
1551 if (cave[x][y+1] == Xblank) goto android_s;
1554 case 5: /* NE,W,SE,SW,S,N,E,NW */
1555 if (cave[x+1][y-1] == Xblank) goto android_ne;
1556 if (cave[x-1][y] == Xblank) goto android_w;
1557 if (cave[x+1][y+1] == Xblank) goto android_se;
1558 if (cave[x-1][y+1] == Xblank) goto android_sw;
1559 if (cave[x][y+1] == Xblank) goto android_s;
1560 if (cave[x][y-1] == Xblank) goto android_n;
1561 if (cave[x+1][y] == Xblank) goto android_e;
1562 if (cave[x-1][y-1] == Xblank) goto android_nw;
1565 case 6: /* E,N,SW,S,NW,NE,SE,W */
1566 if (cave[x+1][y] == Xblank) goto android_e;
1567 if (cave[x][y-1] == Xblank) goto android_n;
1568 if (cave[x-1][y+1] == Xblank) goto android_sw;
1569 if (cave[x][y+1] == Xblank) goto android_s;
1570 if (cave[x-1][y-1] == Xblank) goto android_nw;
1571 if (cave[x+1][y-1] == Xblank) goto android_ne;
1572 if (cave[x+1][y+1] == Xblank) goto android_se;
1573 if (cave[x-1][y] == Xblank) goto android_w;
1576 case 7: /* W,SW,NW,N,E,SE,NE,S */
1577 if (cave[x-1][y] == Xblank) goto android_w;
1578 if (cave[x-1][y+1] == Xblank) goto android_sw;
1579 if (cave[x-1][y-1] == Xblank) goto android_nw;
1580 if (cave[x][y-1] == Xblank) goto android_n;
1581 if (cave[x+1][y] == Xblank) goto android_e;
1582 if (cave[x+1][y+1] == Xblank) goto android_se;
1583 if (cave[x+1][y-1] == Xblank) goto android_ne;
1584 if (cave[x][y+1] == Xblank) goto android_s;
1590 if (lev.android_move_cnt == 0)
1592 if (cave[x-1][y-1] == Zplayer ||
1593 cave[x][y-1] == Zplayer ||
1594 cave[x+1][y-1] == Zplayer ||
1595 cave[x-1][y] == Zplayer ||
1596 cave[x+1][y] == Zplayer ||
1597 cave[x-1][y+1] == Zplayer ||
1598 cave[x][y+1] == Zplayer ||
1599 cave[x+1][y+1] == Zplayer)
1602 set_nearest_player_xy(x, y, &dx, &dy);
1604 next[x][y] = Xblank; /* assume we will move */
1605 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1611 /* attempt clockwise move first if direct path is blocked */
1613 case 0: /* north west */
1614 if (tab_android_move[cave[x-1][y-1]]) goto android_nw;
1615 if (tab_android_move[cave[x][y-1]]) goto android_n;
1616 if (tab_android_move[cave[x-1][y]]) goto android_w;
1620 if (tab_android_move[cave[x][y-1]]) goto android_n;
1621 if (tab_android_move[cave[x+1][y-1]]) goto android_ne;
1622 if (tab_android_move[cave[x-1][y-1]]) goto android_nw;
1625 case 2: /* north east */
1626 if (tab_android_move[cave[x+1][y-1]]) goto android_ne;
1627 if (tab_android_move[cave[x+1][y]]) goto android_e;
1628 if (tab_android_move[cave[x][y-1]]) goto android_n;
1632 if (tab_android_move[cave[x-1][y]]) goto android_w;
1633 if (tab_android_move[cave[x-1][y-1]]) goto android_nw;
1634 if (tab_android_move[cave[x-1][y+1]]) goto android_sw;
1637 case 4: /* nowhere */
1641 if (tab_android_move[cave[x+1][y]]) goto android_e;
1642 if (tab_android_move[cave[x+1][y+1]]) goto android_se;
1643 if (tab_android_move[cave[x+1][y-1]]) goto android_ne;
1646 case 6: /* south west */
1647 if (tab_android_move[cave[x-1][y+1]]) goto android_sw;
1648 if (tab_android_move[cave[x-1][y]]) goto android_w;
1649 if (tab_android_move[cave[x][y+1]]) goto android_s;
1653 if (tab_android_move[cave[x][y+1]]) goto android_s;
1654 if (tab_android_move[cave[x-1][y+1]]) goto android_sw;
1655 if (tab_android_move[cave[x+1][y+1]]) goto android_se;
1658 case 8: /* south east */
1659 if (tab_android_move[cave[x+1][y+1]]) goto android_se;
1660 if (tab_android_move[cave[x][y+1]]) goto android_s;
1661 if (tab_android_move[cave[x+1][y]]) goto android_e;
1669 /* attempt counterclockwise move first if direct path is blocked */
1671 case 0: /* north west */
1672 if (tab_android_move[cave[x-1][y-1]]) goto android_nw;
1673 if (tab_android_move[cave[x-1][y]]) goto android_w;
1674 if (tab_android_move[cave[x][y-1]]) goto android_n;
1678 if (tab_android_move[cave[x][y-1]]) goto android_n;
1679 if (tab_android_move[cave[x-1][y-1]]) goto android_nw;
1680 if (tab_android_move[cave[x+1][y-1]]) goto android_ne;
1683 case 2: /* north east */
1684 if (tab_android_move[cave[x+1][y-1]]) goto android_ne;
1685 if (tab_android_move[cave[x][y-1]]) goto android_n;
1686 if (tab_android_move[cave[x+1][y]]) goto android_e;
1690 if (tab_android_move[cave[x-1][y]]) goto android_w;
1691 if (tab_android_move[cave[x-1][y+1]]) goto android_sw;
1692 if (tab_android_move[cave[x-1][y-1]]) goto android_nw;
1695 case 4: /* nowhere */
1699 if (tab_android_move[cave[x+1][y]]) goto android_e;
1700 if (tab_android_move[cave[x+1][y-1]]) goto android_ne;
1701 if (tab_android_move[cave[x+1][y+1]]) goto android_se;
1704 case 6: /* south west */
1705 if (tab_android_move[cave[x-1][y+1]]) goto android_sw;
1706 if (tab_android_move[cave[x][y+1]]) goto android_s;
1707 if (tab_android_move[cave[x-1][y]]) goto android_w;
1711 if (tab_android_move[cave[x][y+1]]) goto android_s;
1712 if (tab_android_move[cave[x+1][y+1]]) goto android_se;
1713 if (tab_android_move[cave[x-1][y+1]]) goto android_sw;
1716 case 8: /* south east */
1717 if (tab_android_move[cave[x+1][y+1]]) goto android_se;
1718 if (tab_android_move[cave[x+1][y]]) goto android_e;
1719 if (tab_android_move[cave[x][y+1]]) goto android_s;
1726 next[x][y] = Xandroid;
1730 cave[x][y] = Yandroid_nB;
1731 cave[x][y-1] = Yandroid_n;
1732 next[x][y-1] = Xandroid;
1733 play_element_sound(x, y, SOUND_android_move, Xandroid);
1737 cave[x][y] = Yandroid_neB;
1738 cave[x+1][y-1] = Yandroid_ne;
1739 next[x+1][y-1] = Xandroid;
1740 play_element_sound(x, y, SOUND_android_move, Xandroid);
1744 cave[x][y] = Yandroid_eB;
1745 cave[x+1][y] = Yandroid_e;
1746 next[x+1][y] = Xandroid;
1747 play_element_sound(x, y, SOUND_android_move, Xandroid);
1751 cave[x][y] = Yandroid_seB;
1752 cave[x+1][y+1] = Yandroid_se;
1753 next[x+1][y+1] = Xandroid;
1754 play_element_sound(x, y, SOUND_android_move, Xandroid);
1758 cave[x][y] = Yandroid_sB;
1759 cave[x][y+1] = Yandroid_s;
1760 next[x][y+1] = Xandroid;
1761 play_element_sound(x, y, SOUND_android_move, Xandroid);
1765 cave[x][y] = Yandroid_swB;
1766 cave[x-1][y+1] = Yandroid_sw;
1767 next[x-1][y+1] = Xandroid;
1768 play_element_sound(x, y, SOUND_android_move, Xandroid);
1772 cave[x][y] = Yandroid_wB;
1773 cave[x-1][y] = Yandroid_w;
1774 next[x-1][y] = Xandroid;
1775 play_element_sound(x, y, SOUND_android_move, Xandroid);
1779 cave[x][y] = Yandroid_nwB;
1780 cave[x-1][y-1] = Yandroid_nw;
1781 next[x-1][y-1] = Xandroid;
1782 play_element_sound(x, y, SOUND_android_move, Xandroid);
1786 static void Landroid_1_n(int x, int y)
1788 switch (cave[x][y-1])
1801 cave[x][y] = Yandroid_nB;
1802 next[x][y] = Xblank;
1803 cave[x][y-1] = Yandroid_n;
1804 next[x][y-1] = Xandroid;
1805 play_element_sound(x, y, SOUND_android_move, Xandroid_1_n);
1816 cave[x][y] = Yandroid_nB;
1817 next[x][y] = Xblank;
1818 if (cave[x+1][y-2] == Xblank)
1819 cave[x+1][y-2] = Xsplash_e;
1820 if (cave[x-1][y-2] == Xblank)
1821 cave[x-1][y-2] = Xsplash_w;
1822 play_element_sound(x, y, SOUND_acid, Xacid_1);
1831 static void Landroid_2_n(int x, int y)
1833 switch (cave[x][y-1])
1846 cave[x][y] = Yandroid_nB;
1847 next[x][y] = Xblank;
1848 cave[x][y-1] = Yandroid_n;
1849 next[x][y-1] = Xandroid_1_n;
1850 play_element_sound(x, y, SOUND_android_move, Xandroid_2_n);
1861 cave[x][y] = Yandroid_nB;
1862 next[x][y] = Xblank;
1863 if (cave[x+1][y-2] == Xblank)
1864 cave[x+1][y-2] = Xsplash_e;
1865 if (cave[x-1][y-2] == Xblank)
1866 cave[x-1][y-2] = Xsplash_w;
1867 play_element_sound(x, y, SOUND_acid, Xacid_1);
1876 static void Landroid_1_e(int x, int y)
1878 switch (cave[x+1][y])
1891 cave[x][y] = Yandroid_eB;
1892 next[x][y] = Xblank;
1893 cave[x+1][y] = Yandroid_e;
1894 next[x+1][y] = Xandroid;
1895 play_element_sound(x, y, SOUND_android_move, Xandroid_1_e);
1906 cave[x][y] = Yandroid_eB;
1907 next[x][y] = Xblank;
1908 if (cave[x+2][y-1] == Xblank)
1909 cave[x+2][y-1] = Xsplash_e;
1910 if (cave[x][y-1] == Xblank)
1911 cave[x][y-1] = Xsplash_w;
1912 play_element_sound(x, y, SOUND_acid, Xacid_1);
1921 static void Landroid_2_e(int x, int y)
1923 switch (cave[x+1][y])
1936 cave[x][y] = Yandroid_eB;
1937 next[x][y] = Xblank;
1938 cave[x+1][y] = Yandroid_e;
1939 next[x+1][y] = Xandroid_1_e;
1940 play_element_sound(x, y, SOUND_android_move, Xandroid_2_e);
1951 cave[x][y] = Yandroid_eB;
1952 next[x][y] = Xblank;
1953 if (cave[x+2][y-1] == Xblank)
1954 cave[x+2][y-1] = Xsplash_e;
1955 if (cave[x][y-1] == Xblank)
1956 cave[x][y-1] = Xsplash_w;
1957 play_element_sound(x, y, SOUND_acid, Xacid_1);
1966 static void Landroid_1_s(int x, int y)
1968 switch (cave[x][y+1])
1981 cave[x][y] = Yandroid_sB;
1982 next[x][y] = Xblank;
1983 cave[x][y+1] = Yandroid_s;
1984 next[x][y+1] = Xandroid;
1985 play_element_sound(x, y, SOUND_android_move, Xandroid_1_s);
1996 cave[x][y] = Yandroid_sB;
1997 next[x][y] = Xblank;
1998 if (cave[x+1][y] == Xblank)
1999 cave[x+1][y] = Xsplash_e;
2000 if (cave[x-1][y] == Xblank)
2001 cave[x-1][y] = Xsplash_w;
2002 play_element_sound(x, y, SOUND_acid, Xacid_1);
2011 static void Landroid_2_s(int x, int y)
2013 switch (cave[x][y+1])
2026 cave[x][y] = Yandroid_sB;
2027 next[x][y] = Xblank;
2028 cave[x][y+1] = Yandroid_s;
2029 next[x][y+1] = Xandroid_1_s;
2030 play_element_sound(x, y, SOUND_android_move, Xandroid_2_s);
2041 cave[x][y] = Yandroid_sB;
2042 next[x][y] = Xblank;
2043 if (cave[x+1][y] == Xblank)
2044 cave[x+1][y] = Xsplash_e;
2045 if (cave[x-1][y] == Xblank)
2046 cave[x-1][y] = Xsplash_w;
2047 play_element_sound(x, y, SOUND_acid, Xacid_1);
2056 static void Landroid_1_w(int x, int y)
2058 switch (cave[x-1][y])
2071 cave[x][y] = Yandroid_wB;
2072 next[x][y] = Xblank;
2073 cave[x-1][y] = Yandroid_w;
2074 next[x-1][y] = Xandroid;
2075 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2086 cave[x][y] = Yandroid_wB;
2087 next[x][y] = Xblank;
2088 if (cave[x][y-1] == Xblank)
2089 cave[x][y-1] = Xsplash_e;
2090 if (cave[x-2][y-1] == Xblank)
2091 cave[x-2][y-1] = Xsplash_w;
2092 play_element_sound(x, y, SOUND_acid, Xacid_1);
2101 static void Landroid_2_w(int x, int y)
2103 switch (cave[x-1][y])
2116 cave[x][y] = Yandroid_wB;
2117 next[x][y] = Xblank;
2118 cave[x-1][y] = Yandroid_w;
2119 next[x-1][y] = Xandroid_1_w;
2120 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2131 cave[x][y] = Yandroid_wB;
2132 next[x][y] = Xblank;
2133 if (cave[x][y-1] == Xblank)
2134 cave[x][y-1] = Xsplash_e;
2135 if (cave[x-2][y-1] == Xblank)
2136 cave[x-2][y-1] = Xsplash_w;
2137 play_element_sound(x, y, SOUND_acid, Xacid_1);
2146 static void Leater_n(int x, int y)
2148 if (cave[x+1][y] == Xdiamond)
2150 cave[x+1][y] = Ydiamond_blank;
2151 next[x+1][y] = Xblank;
2152 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2156 if (cave[x][y+1] == Xdiamond)
2158 cave[x][y+1] = Ydiamond_blank;
2159 next[x][y+1] = Xblank;
2160 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2164 if (cave[x-1][y] == Xdiamond)
2166 cave[x-1][y] = Ydiamond_blank;
2167 next[x-1][y] = Xblank;
2168 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2172 if (cave[x][y-1] == Xdiamond)
2174 cave[x][y-1] = Ydiamond_blank;
2175 next[x][y-1] = Xblank;
2176 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2180 switch (cave[x][y-1])
2196 cave[x][y] = Yeater_nB;
2197 next[x][y] = Xblank;
2198 cave[x][y-1] = Yeater_n;
2199 next[x][y-1] = Xeater_n;
2210 cave[x][y] = Yeater_nB;
2211 next[x][y] = Xblank;
2212 if (cave[x+1][y-2] == Xblank)
2213 cave[x+1][y-2] = Xsplash_e;
2214 if (cave[x-1][y-2] == Xblank)
2215 cave[x-1][y-2] = Xsplash_w;
2216 play_element_sound(x, y, SOUND_acid, Xacid_1);
2220 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2221 play_element_sound(x, y, SOUND_eater, Xeater_n);
2226 static void Leater_e(int x, int y)
2228 if (cave[x][y+1] == Xdiamond)
2230 cave[x][y+1] = Ydiamond_blank;
2231 next[x][y+1] = Xblank;
2232 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2236 if (cave[x-1][y] == Xdiamond)
2238 cave[x-1][y] = Ydiamond_blank;
2239 next[x-1][y] = Xblank;
2240 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2244 if (cave[x][y-1] == Xdiamond)
2246 cave[x][y-1] = Ydiamond_blank;
2247 next[x][y-1] = Xblank;
2248 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2252 if (cave[x+1][y] == Xdiamond)
2254 cave[x+1][y] = Ydiamond_blank;
2255 next[x+1][y] = Xblank;
2256 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2260 switch (cave[x+1][y])
2276 cave[x][y] = Yeater_eB;
2277 next[x][y] = Xblank;
2278 cave[x+1][y] = Yeater_e;
2279 next[x+1][y] = Xeater_e;
2290 cave[x][y] = Yeater_eB;
2291 next[x][y] = Xblank;
2292 if (cave[x+2][y-1] == Xblank)
2293 cave[x+2][y-1] = Xsplash_e;
2294 if (cave[x][y-1] == Xblank)
2295 cave[x][y-1] = Xsplash_w;
2296 play_element_sound(x, y, SOUND_acid, Xacid_1);
2300 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2301 play_element_sound(x, y, SOUND_eater, Xeater_e);
2306 static void Leater_s(int x, int y)
2308 if (cave[x-1][y] == Xdiamond)
2310 cave[x-1][y] = Ydiamond_blank;
2311 next[x-1][y] = Xblank;
2312 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2316 if (cave[x][y-1] == Xdiamond)
2318 cave[x][y-1] = Ydiamond_blank;
2319 next[x][y-1] = Xblank;
2320 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2324 if (cave[x+1][y] == Xdiamond)
2326 cave[x+1][y] = Ydiamond_blank;
2327 next[x+1][y] = Xblank;
2328 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2332 if (cave[x][y+1] == Xdiamond)
2334 cave[x][y+1] = Ydiamond_blank;
2335 next[x][y+1] = Xblank;
2336 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2340 switch (cave[x][y+1])
2356 cave[x][y] = Yeater_sB;
2357 next[x][y] = Xblank;
2358 cave[x][y+1] = Yeater_s;
2359 next[x][y+1] = Xeater_s;
2370 cave[x][y] = Yeater_sB;
2371 next[x][y] = Xblank;
2372 if (cave[x+1][y] == Xblank)
2373 cave[x+1][y] = Xsplash_e;
2374 if (cave[x-1][y] == Xblank)
2375 cave[x-1][y] = Xsplash_w;
2376 play_element_sound(x, y, SOUND_acid, Xacid_1);
2380 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2381 play_element_sound(x, y, SOUND_eater, Xeater_s);
2386 static void Leater_w(int x, int y)
2388 if (cave[x][y-1] == Xdiamond)
2390 cave[x][y-1] = Ydiamond_blank;
2391 next[x][y-1] = Xblank;
2392 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2396 if (cave[x+1][y] == Xdiamond)
2398 cave[x+1][y] = Ydiamond_blank;
2399 next[x+1][y] = Xblank;
2400 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2404 if (cave[x][y+1] == Xdiamond)
2406 cave[x][y+1] = Ydiamond_blank;
2407 next[x][y+1] = Xblank;
2408 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2412 if (cave[x-1][y] == Xdiamond)
2414 cave[x-1][y] = Ydiamond_blank;
2415 next[x-1][y] = Xblank;
2416 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2420 switch (cave[x-1][y])
2436 cave[x][y] = Yeater_wB;
2437 next[x][y] = Xblank;
2438 cave[x-1][y] = Yeater_w;
2439 next[x-1][y] = Xeater_w;
2450 cave[x][y] = Yeater_wB;
2451 next[x][y] = Xblank;
2452 if (cave[x][y-1] == Xblank)
2453 cave[x][y-1] = Xsplash_e;
2454 if (cave[x-2][y-1] == Xblank)
2455 cave[x-2][y-1] = Xsplash_w;
2456 play_element_sound(x, y, SOUND_acid, Xacid_1);
2460 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2461 play_element_sound(x, y, SOUND_eater, Xeater_w);
2466 static void Lalien(int x, int y)
2477 set_nearest_player_xy(x, y, &dx, &dy);
2484 switch (cave[x][y-1])
2500 cave[x][y] = Yalien_nB;
2501 next[x][y] = Xblank;
2502 cave[x][y-1] = Yalien_n;
2503 next[x][y-1] = Xalien_pause;
2504 play_element_sound(x, y, SOUND_alien, Xalien);
2515 cave[x][y] = Yalien_nB;
2516 next[x][y] = Xblank;
2517 if (cave[x+1][y-2] == Xblank)
2518 cave[x+1][y-2] = Xsplash_e;
2519 if (cave[x-1][y-2] == Xblank)
2520 cave[x-1][y-2] = Xsplash_w;
2521 play_element_sound(x, y, SOUND_acid, Xacid_1);
2527 switch (cave[x][y+1])
2543 cave[x][y] = Yalien_sB;
2544 next[x][y] = Xblank;
2545 cave[x][y+1] = Yalien_s;
2546 next[x][y+1] = Xalien_pause;
2547 play_element_sound(x, y, SOUND_alien, Xalien);
2558 cave[x][y] = Yalien_sB;
2559 next[x][y] = Xblank;
2560 if (cave[x+1][y] == Xblank)
2561 cave[x+1][y] = Xsplash_e;
2562 if (cave[x-1][y] == Xblank)
2563 cave[x-1][y] = Xsplash_w;
2564 play_element_sound(x, y, SOUND_acid, Xacid_1);
2573 switch (cave[x+1][y])
2589 cave[x][y] = Yalien_eB;
2590 next[x][y] = Xblank;
2591 cave[x+1][y] = Yalien_e;
2592 next[x+1][y] = Xalien_pause;
2593 play_element_sound(x, y, SOUND_alien, Xalien);
2604 cave[x][y] = Yalien_eB;
2605 next[x][y] = Xblank;
2606 if (cave[x+2][y-1] == Xblank)
2607 cave[x+2][y-1] = Xsplash_e;
2608 if (cave[x][y-1] == Xblank)
2609 cave[x][y-1] = Xsplash_w;
2610 play_element_sound(x, y, SOUND_acid, Xacid_1);
2616 switch (cave[x-1][y])
2632 cave[x][y] = Yalien_wB;
2633 next[x][y] = Xblank;
2634 cave[x-1][y] = Yalien_w;
2635 next[x-1][y] = Xalien_pause;
2636 play_element_sound(x, y, SOUND_alien, Xalien);
2647 cave[x][y] = Yalien_wB;
2648 next[x][y] = Xblank;
2649 if (cave[x][y-1] == Xblank)
2650 cave[x][y-1] = Xsplash_e;
2651 if (cave[x-2][y-1] == Xblank)
2652 cave[x-2][y-1] = Xsplash_w;
2653 play_element_sound(x, y, SOUND_acid, Xacid_1);
2660 static void Lalien_pause(int x, int y)
2662 next[x][y] = Xalien;
2665 static void Lbug_n(int x, int y)
2667 switch (cave[x][y-1])
2683 cave[x][y] = Ybug_nB;
2684 next[x][y] = Xblank;
2685 cave[x][y-1] = Ybug_n;
2686 next[x][y-1] = Xbug_1_n;
2687 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2698 cave[x][y] = Ybug_nB;
2699 next[x][y] = Xblank;
2700 if (cave[x+1][y-2] == Xblank)
2701 cave[x+1][y-2] = Xsplash_e;
2702 if (cave[x-1][y-2] == Xblank)
2703 cave[x-1][y-2] = Xsplash_w;
2704 play_element_sound(x, y, SOUND_acid, Xacid_1);
2708 cave[x][y] = Ybug_n_w;
2709 next[x][y] = Xbug_2_w;
2710 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2715 static void Lbug_1_n(int x, int y)
2717 if (tab_amoeba[cave[x][y-1]] ||
2718 tab_amoeba[cave[x+1][y]] ||
2719 tab_amoeba[cave[x][y+1]] ||
2720 tab_amoeba[cave[x-1][y]])
2722 Lboom_bug(x, y, Xbug_1_n);
2727 switch (cave[x+1][y])
2751 cave[x][y] = Ybug_n_e;
2752 next[x][y] = Xbug_2_e;
2753 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2762 static void Lbug_2_n(int x, int y)
2764 if (tab_amoeba[cave[x][y-1]] ||
2765 tab_amoeba[cave[x+1][y]] ||
2766 tab_amoeba[cave[x][y+1]] ||
2767 tab_amoeba[cave[x-1][y]])
2769 Lboom_bug(x, y, Xbug_2_n);
2777 static void Lbug_e(int x, int y)
2779 switch (cave[x+1][y])
2795 cave[x][y] = Ybug_eB;
2796 next[x][y] = Xblank;
2797 cave[x+1][y] = Ybug_e;
2798 next[x+1][y] = Xbug_1_e;
2799 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2810 cave[x][y] = Ybug_eB;
2811 next[x][y] = Xblank;
2812 if (cave[x+2][y-1] == Xblank)
2813 cave[x+2][y-1] = Xsplash_e;
2814 if (cave[x][y-1] == Xblank)
2815 cave[x][y-1] = Xsplash_w;
2816 play_element_sound(x, y, SOUND_acid, Xacid_1);
2820 cave[x][y] = Ybug_e_n;
2821 next[x][y] = Xbug_2_n;
2822 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2827 static void Lbug_1_e(int x, int y)
2829 if (tab_amoeba[cave[x][y-1]] ||
2830 tab_amoeba[cave[x+1][y]] ||
2831 tab_amoeba[cave[x][y+1]] ||
2832 tab_amoeba[cave[x-1][y]])
2834 Lboom_bug(x, y, Xbug_1_e);
2839 switch (cave[x][y+1])
2863 cave[x][y] = Ybug_e_s;
2864 next[x][y] = Xbug_2_s;
2865 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2874 static void Lbug_2_e(int x, int y)
2876 if (tab_amoeba[cave[x][y-1]] ||
2877 tab_amoeba[cave[x+1][y]] ||
2878 tab_amoeba[cave[x][y+1]] ||
2879 tab_amoeba[cave[x-1][y]])
2881 Lboom_bug(x, y, Xbug_2_e);
2889 static void Lbug_s(int x, int y)
2891 switch (cave[x][y+1])
2907 cave[x][y] = Ybug_sB;
2908 next[x][y] = Xblank;
2909 cave[x][y+1] = Ybug_s;
2910 next[x][y+1] = Xbug_1_s;
2911 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
2922 cave[x][y] = Ybug_sB;
2923 next[x][y] = Xblank;
2924 if (cave[x+1][y] == Xblank)
2925 cave[x+1][y] = Xsplash_e;
2926 if (cave[x-1][y] == Xblank)
2927 cave[x-1][y] = Xsplash_w;
2928 play_element_sound(x, y, SOUND_acid, Xacid_1);
2932 cave[x][y] = Ybug_s_e;
2933 next[x][y] = Xbug_2_e;
2934 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
2939 static void Lbug_1_s(int x, int y)
2941 if (tab_amoeba[cave[x][y-1]] ||
2942 tab_amoeba[cave[x+1][y]] ||
2943 tab_amoeba[cave[x][y+1]] ||
2944 tab_amoeba[cave[x-1][y]])
2946 Lboom_bug(x, y, Xbug_1_s);
2951 switch (cave[x-1][y])
2975 cave[x][y] = Ybug_s_w;
2976 next[x][y] = Xbug_2_w;
2977 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
2986 static void Lbug_2_s(int x, int y)
2988 if (tab_amoeba[cave[x][y-1]] ||
2989 tab_amoeba[cave[x+1][y]] ||
2990 tab_amoeba[cave[x][y+1]] ||
2991 tab_amoeba[cave[x-1][y]])
2993 Lboom_bug(x, y, Xbug_2_s);
3001 static void Lbug_w(int x, int y)
3003 switch (cave[x-1][y])
3019 cave[x][y] = Ybug_wB;
3020 next[x][y] = Xblank;
3021 cave[x-1][y] = Ybug_w;
3022 next[x-1][y] = Xbug_1_w;
3023 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3034 cave[x][y] = Ybug_wB;
3035 next[x][y] = Xblank;
3036 if (cave[x][y-1] == Xblank)
3037 cave[x][y-1] = Xsplash_e;
3038 if (cave[x-2][y-1] == Xblank)
3039 cave[x-2][y-1] = Xsplash_w;
3040 play_element_sound(x, y, SOUND_acid, Xacid_1);
3044 cave[x][y] = Ybug_w_s;
3045 next[x][y] = Xbug_2_s;
3046 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3051 static void Lbug_1_w(int x, int y)
3053 if (tab_amoeba[cave[x][y-1]] ||
3054 tab_amoeba[cave[x+1][y]] ||
3055 tab_amoeba[cave[x][y+1]] ||
3056 tab_amoeba[cave[x-1][y]])
3058 Lboom_bug(x, y, Xbug_1_w);
3063 switch (cave[x][y-1])
3087 cave[x][y] = Ybug_w_n;
3088 next[x][y] = Xbug_2_n;
3089 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3098 static void Lbug_2_w(int x, int y)
3100 if (tab_amoeba[cave[x][y-1]] ||
3101 tab_amoeba[cave[x+1][y]] ||
3102 tab_amoeba[cave[x][y+1]] ||
3103 tab_amoeba[cave[x-1][y]])
3105 Lboom_bug(x, y, Xbug_2_w);
3113 static void Ltank_n(int x, int y)
3115 switch (cave[x][y-1])
3131 cave[x][y] = Ytank_nB;
3132 next[x][y] = Xblank;
3133 cave[x][y-1] = Ytank_n;
3134 next[x][y-1] = Xtank_1_n;
3135 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3146 cave[x][y] = Ytank_nB;
3147 next[x][y] = Xblank;
3148 if (cave[x+1][y-2] == Xblank)
3149 cave[x+1][y-2] = Xsplash_e;
3150 if (cave[x-1][y-2] == Xblank)
3151 cave[x-1][y-2] = Xsplash_w;
3152 play_element_sound(x, y, SOUND_acid, Xacid_1);
3156 cave[x][y] = Ytank_n_e;
3157 next[x][y] = Xtank_2_e;
3158 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3163 static void Ltank_1_n(int x, int y)
3165 if (tab_amoeba[cave[x][y-1]] ||
3166 tab_amoeba[cave[x+1][y]] ||
3167 tab_amoeba[cave[x][y+1]] ||
3168 tab_amoeba[cave[x-1][y]])
3170 Lboom_tank(x, y, Xtank_1_n);
3175 switch (cave[x-1][y])
3199 cave[x][y] = Ytank_n_w;
3200 next[x][y] = Xtank_2_w;
3201 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3210 static void Ltank_2_n(int x, int y)
3212 if (tab_amoeba[cave[x][y-1]] ||
3213 tab_amoeba[cave[x+1][y]] ||
3214 tab_amoeba[cave[x][y+1]] ||
3215 tab_amoeba[cave[x-1][y]])
3217 Lboom_tank(x, y, Xtank_2_n);
3225 static void Ltank_e(int x, int y)
3227 switch (cave[x+1][y])
3243 cave[x][y] = Ytank_eB;
3244 next[x][y] = Xblank;
3245 cave[x+1][y] = Ytank_e;
3246 next[x+1][y] = Xtank_1_e;
3247 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3258 cave[x][y] = Ytank_eB;
3259 next[x][y] = Xblank;
3260 if (cave[x+2][y-1] == Xblank)
3261 cave[x+2][y-1] = Xsplash_e;
3262 if (cave[x][y-1] == Xblank)
3263 cave[x][y-1] = Xsplash_w;
3264 play_element_sound(x, y, SOUND_acid, Xacid_1);
3268 cave[x][y] = Ytank_e_s;
3269 next[x][y] = Xtank_2_s;
3270 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3275 static void Ltank_1_e(int x, int y)
3277 if (tab_amoeba[cave[x][y-1]] ||
3278 tab_amoeba[cave[x+1][y]] ||
3279 tab_amoeba[cave[x][y+1]] ||
3280 tab_amoeba[cave[x-1][y]])
3282 Lboom_tank(x, y, Xtank_1_e);
3287 switch (cave[x][y-1])
3311 cave[x][y] = Ytank_e_n;
3312 next[x][y] = Xtank_2_n;
3313 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3322 static void Ltank_2_e(int x, int y)
3324 if (tab_amoeba[cave[x][y-1]] ||
3325 tab_amoeba[cave[x+1][y]] ||
3326 tab_amoeba[cave[x][y+1]] ||
3327 tab_amoeba[cave[x-1][y]])
3329 Lboom_tank(x, y, Xtank_2_e);
3337 static void Ltank_s(int x, int y)
3339 switch (cave[x][y+1])
3355 cave[x][y] = Ytank_sB;
3356 next[x][y] = Xblank;
3357 cave[x][y+1] = Ytank_s;
3358 next[x][y+1] = Xtank_1_s;
3359 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3370 cave[x][y] = Ytank_sB;
3371 next[x][y] = Xblank;
3372 if (cave[x+1][y] == Xblank)
3373 cave[x+1][y] = Xsplash_e;
3374 if (cave[x-1][y] == Xblank)
3375 cave[x-1][y] = Xsplash_w;
3376 play_element_sound(x, y, SOUND_acid, Xacid_1);
3380 cave[x][y] = Ytank_s_w;
3381 next[x][y] = Xtank_2_w;
3382 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3387 static void Ltank_1_s(int x, int y)
3389 if (tab_amoeba[cave[x][y-1]] ||
3390 tab_amoeba[cave[x+1][y]] ||
3391 tab_amoeba[cave[x][y+1]] ||
3392 tab_amoeba[cave[x-1][y]])
3394 Lboom_tank(x, y, Xtank_1_s);
3399 switch (cave[x+1][y])
3423 cave[x][y] = Ytank_s_e;
3424 next[x][y] = Xtank_2_e;
3425 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3434 static void Ltank_2_s(int x, int y)
3436 if (tab_amoeba[cave[x][y-1]] ||
3437 tab_amoeba[cave[x+1][y]] ||
3438 tab_amoeba[cave[x][y+1]] ||
3439 tab_amoeba[cave[x-1][y]])
3441 Lboom_tank(x, y, Xtank_2_s);
3449 static void Ltank_w(int x, int y)
3451 switch (cave[x-1][y])
3467 cave[x][y] = Ytank_wB;
3468 next[x][y] = Xblank;
3469 cave[x-1][y] = Ytank_w;
3470 next[x-1][y] = Xtank_1_w;
3471 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3482 cave[x][y] = Ytank_wB;
3483 next[x][y] = Xblank;
3484 if (cave[x][y-1] == Xblank)
3485 cave[x][y-1] = Xsplash_e;
3486 if (cave[x-2][y-1] == Xblank)
3487 cave[x-2][y-1] = Xsplash_w;
3488 play_element_sound(x, y, SOUND_acid, Xacid_1);
3492 cave[x][y] = Ytank_w_n;
3493 next[x][y] = Xtank_2_n;
3494 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3499 static void Ltank_1_w(int x, int y)
3501 if (tab_amoeba[cave[x][y-1]] ||
3502 tab_amoeba[cave[x+1][y]] ||
3503 tab_amoeba[cave[x][y+1]] ||
3504 tab_amoeba[cave[x-1][y]])
3506 Lboom_tank(x, y, Xtank_1_w);
3511 switch (cave[x][y+1])
3535 cave[x][y] = Ytank_w_s;
3536 next[x][y] = Xtank_2_s;
3537 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3546 static void Ltank_2_w(int x, int y)
3548 if (tab_amoeba[cave[x][y-1]] ||
3549 tab_amoeba[cave[x+1][y]] ||
3550 tab_amoeba[cave[x][y+1]] ||
3551 tab_amoeba[cave[x-1][y]])
3553 Lboom_tank(x, y, Xtank_2_w);
3561 static void Lemerald(int x, int y)
3563 switch (cave[x][y+1])
3576 cave[x][y] = Yemerald_sB;
3577 next[x][y] = Xblank;
3578 cave[x][y+1] = Yemerald_s;
3579 next[x][y+1] = Xemerald_fall;
3590 cave[x][y] = Yemerald_sB;
3591 next[x][y] = Xblank;
3592 if (cave[x+1][y] == Xblank)
3593 cave[x+1][y] = Xsplash_e;
3594 if (cave[x-1][y] == Xblank)
3595 cave[x-1][y] = Xsplash_w;
3596 play_element_sound(x, y, SOUND_acid, Xacid_1);
3615 case Xemerald_pause:
3617 case Xdiamond_pause:
3654 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
3656 cave[x][y] = Yemerald_eB;
3657 next[x][y] = Xblank;
3658 cave[x+1][y] = Yemerald_e;
3659 next[x+1][y] = Xemerald_pause;
3663 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
3665 cave[x][y] = Yemerald_wB;
3666 next[x][y] = Xblank;
3667 cave[x-1][y] = Yemerald_w;
3668 next[x-1][y] = Xemerald_pause;
3674 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
3676 cave[x][y] = Yemerald_wB;
3677 next[x][y] = Xblank;
3678 cave[x-1][y] = Yemerald_w;
3679 next[x-1][y] = Xemerald_pause;
3683 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
3685 cave[x][y] = Yemerald_eB;
3686 next[x][y] = Xblank;
3687 cave[x+1][y] = Yemerald_e;
3688 next[x+1][y] = Xemerald_pause;
3694 if (++lev.shine_cnt > 50)
3696 lev.shine_cnt = RANDOM(8);
3697 cave[x][y] = Xemerald_shine;
3704 static void Lemerald_pause(int x, int y)
3706 switch (cave[x][y+1])
3719 cave[x][y] = Yemerald_sB;
3720 next[x][y] = Xblank;
3721 cave[x][y+1] = Yemerald_s;
3722 next[x][y+1] = Xemerald_fall;
3733 cave[x][y] = Yemerald_sB;
3734 next[x][y] = Xblank;
3735 if (cave[x+1][y] == Xblank)
3736 cave[x+1][y] = Xsplash_e;
3737 if (cave[x-1][y] == Xblank)
3738 cave[x-1][y] = Xsplash_w;
3739 play_element_sound(x, y, SOUND_acid, Xacid_1);
3743 cave[x][y] = Xemerald;
3744 next[x][y] = Xemerald;
3749 static void Lemerald_fall(int x, int y)
3751 switch (cave[x][y+1])
3765 cave[x][y] = Yemerald_sB;
3766 next[x][y] = Xblank;
3767 cave[x][y+1] = Yemerald_s;
3768 next[x][y+1] = Xemerald_fall;
3779 cave[x][y] = Yemerald_sB;
3780 next[x][y] = Xblank;
3781 if (cave[x+1][y] == Xblank)
3782 cave[x+1][y] = Xsplash_e;
3783 if (cave[x-1][y] == Xblank)
3784 cave[x-1][y] = Xsplash_w;
3785 play_element_sound(x, y, SOUND_acid, Xacid_1);
3789 if (lev.wonderwall_time)
3791 lev.wonderwall_state = 1;
3792 cave[x][y] = Yemerald_sB;
3793 if (tab_blank[cave[x][y+2]])
3795 cave[x][y+2] = Ydiamond_s;
3796 next[x][y+2] = Xdiamond_fall;
3799 next[x][y] = Xblank;
3800 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
3805 cave[x][y] = Xemerald;
3806 next[x][y] = Xemerald;
3807 play_element_sound(x, y, SOUND_diamond, Xemerald);
3812 static void Ldiamond(int x, int y)
3814 switch (cave[x][y+1])
3827 cave[x][y] = Ydiamond_sB;
3828 next[x][y] = Xblank;
3829 cave[x][y+1] = Ydiamond_s;
3830 next[x][y+1] = Xdiamond_fall;
3841 cave[x][y] = Ydiamond_sB;
3842 next[x][y] = Xblank;
3843 if (cave[x+1][y] == Xblank)
3844 cave[x+1][y] = Xsplash_e;
3845 if (cave[x-1][y] == Xblank)
3846 cave[x-1][y] = Xsplash_w;
3847 play_element_sound(x, y, SOUND_acid, Xacid_1);
3866 case Xemerald_pause:
3868 case Xdiamond_pause:
3905 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
3907 cave[x][y] = Ydiamond_eB;
3908 next[x][y] = Xblank;
3909 cave[x+1][y] = Ydiamond_e;
3910 next[x+1][y] = Xdiamond_pause;
3914 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
3916 cave[x][y] = Ydiamond_wB;
3917 next[x][y] = Xblank;
3918 cave[x-1][y] = Ydiamond_w;
3919 next[x-1][y] = Xdiamond_pause;
3925 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
3927 cave[x][y] = Ydiamond_wB;
3928 next[x][y] = Xblank;
3929 cave[x-1][y] = Ydiamond_w;
3930 next[x-1][y] = Xdiamond_pause;
3934 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
3936 cave[x][y] = Ydiamond_eB;
3937 next[x][y] = Xblank;
3938 cave[x+1][y] = Ydiamond_e;
3939 next[x+1][y] = Xdiamond_pause;
3945 if (++lev.shine_cnt > 50)
3947 lev.shine_cnt = RANDOM(8);
3948 cave[x][y] = Xdiamond_shine;
3955 static void Ldiamond_pause(int x, int y)
3957 switch (cave[x][y+1])
3970 cave[x][y] = Ydiamond_sB;
3971 next[x][y] = Xblank;
3972 cave[x][y+1] = Ydiamond_s;
3973 next[x][y+1] = Xdiamond_fall;
3984 cave[x][y] = Ydiamond_sB;
3985 next[x][y] = Xblank;
3986 if (cave[x+1][y] == Xblank)
3987 cave[x+1][y] = Xsplash_e;
3988 if (cave[x-1][y] == Xblank)
3989 cave[x-1][y] = Xsplash_w;
3990 play_element_sound(x, y, SOUND_acid, Xacid_1);
3994 cave[x][y] = Xdiamond;
3995 next[x][y] = Xdiamond;
4000 static void Ldiamond_fall(int x, int y)
4002 switch (cave[x][y+1])
4016 cave[x][y] = Ydiamond_sB;
4017 next[x][y] = Xblank;
4018 cave[x][y+1] = Ydiamond_s;
4019 next[x][y+1] = Xdiamond_fall;
4030 cave[x][y] = Ydiamond_sB;
4031 next[x][y] = Xblank;
4032 if (cave[x+1][y] == Xblank)
4033 cave[x+1][y] = Xsplash_e;
4034 if (cave[x-1][y] == Xblank)
4035 cave[x-1][y] = Xsplash_w;
4036 play_element_sound(x, y, SOUND_acid, Xacid_1);
4040 if (lev.wonderwall_time)
4042 lev.wonderwall_state = 1;
4043 cave[x][y] = Ydiamond_sB;
4044 if (tab_blank[cave[x][y+2]])
4046 cave[x][y+2] = Ystone_s;
4047 next[x][y+2] = Xstone_fall;
4050 next[x][y] = Xblank;
4051 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4056 cave[x][y] = Xdiamond;
4057 next[x][y] = Xdiamond;
4058 play_element_sound(x, y, SOUND_diamond, Xdiamond);
4063 static void Lstone(int x, int y)
4065 switch (cave[x][y+1])
4080 cave[x][y] = Ystone_sB;
4081 next[x][y] = Xblank;
4082 cave[x][y+1] = Ystone_s;
4083 next[x][y+1] = Xstone_fall;
4094 cave[x][y] = Ystone_sB;
4095 next[x][y] = Xblank;
4096 if (cave[x+1][y] == Xblank)
4097 cave[x+1][y] = Xsplash_e;
4098 if (cave[x-1][y] == Xblank)
4099 cave[x-1][y] = Xsplash_w;
4100 play_element_sound(x, y, SOUND_acid, Xacid_1);
4104 cave[x][y] = Xsand_stonein_1;
4105 next[x][y] = Xsand_stonein_2;
4106 cave[x][y+1] = Xsand_sandstone_1;
4107 next[x][y+1] = Xsand_sandstone_2;
4126 case Xemerald_pause:
4128 case Xdiamond_pause:
4158 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
4160 cave[x][y] = Ystone_eB;
4161 next[x][y] = Xblank;
4162 cave[x+1][y] = Ystone_e;
4163 next[x+1][y] = Xstone_pause;
4167 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
4169 cave[x][y] = Ystone_wB;
4170 next[x][y] = Xblank;
4171 cave[x-1][y] = Ystone_w;
4172 next[x-1][y] = Xstone_pause;
4178 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
4180 cave[x][y] = Ystone_wB;
4181 next[x][y] = Xblank;
4182 cave[x-1][y] = Ystone_w;
4183 next[x-1][y] = Xstone_pause;
4187 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
4189 cave[x][y] = Ystone_eB;
4190 next[x][y] = Xblank;
4191 cave[x+1][y] = Ystone_e;
4192 next[x+1][y] = Xstone_pause;
4199 static void Lstone_pause(int x, int y)
4201 switch (cave[x][y+1])
4214 cave[x][y] = Ystone_sB;
4215 next[x][y] = Xblank;
4216 cave[x][y+1] = Ystone_s;
4217 next[x][y+1] = Xstone_fall;
4228 cave[x][y] = Ystone_sB;
4229 next[x][y] = Xblank;
4230 if (cave[x+1][y] == Xblank)
4231 cave[x+1][y] = Xsplash_e;
4232 if (cave[x-1][y] == Xblank)
4233 cave[x-1][y] = Xsplash_w;
4234 play_element_sound(x, y, SOUND_acid, Xacid_1);
4238 cave[x][y] = Xstone;
4239 next[x][y] = Xstone;
4244 static void Lstone_fall(int x, int y)
4246 switch (cave[x][y+1])
4260 cave[x][y] = Ystone_sB;
4261 next[x][y] = Xblank;
4262 cave[x][y+1] = Ystone_s;
4263 next[x][y+1] = Xstone_fall;
4274 cave[x][y] = Ystone_sB;
4275 next[x][y] = Xblank;
4276 if (cave[x+1][y] == Xblank)
4277 cave[x+1][y] = Xsplash_e;
4278 if (cave[x-1][y] == Xblank)
4279 cave[x-1][y] = Xsplash_w;
4280 play_element_sound(x, y, SOUND_acid, Xacid_1);
4285 next[x][y] = Xstone;
4286 cave[x][y+1] = Ynut_stone;
4287 next[x][y+1] = Xemerald;
4288 play_element_sound(x, y, SOUND_crack, Xnut);
4289 score += lev.nut_score;
4300 cave[x][y] = Ystone_sB;
4301 cave[x][y+1] = Ybug_stone;
4302 Lboom_bug(x, y+1, Xstone_fall);
4303 score += lev.bug_score;
4314 cave[x][y] = Ystone_sB;
4315 cave[x][y+1] = Ytank_stone;
4316 Lboom_tank(x, y+1, Xstone_fall);
4317 score += lev.tank_score;
4323 switch (cave[x+1][y+1])
4338 cave[x][y+1] = Xspring_e;
4342 cave[x][y+1] = Xspring_w;
4348 switch (cave[x-1][y+1])
4363 cave[x][y+1] = Xspring_w;
4366 cave[x][y+1] = Xspring_e;
4371 next[x][y] = Xstone;
4378 cave[x][y] = Ystone_sB;
4379 cave[x][y+1] = Yeater_stone;
4380 Lboom_eater(x, y+1, Xstone_fall);
4381 score += lev.eater_score;
4386 cave[x][y] = Ystone_sB;
4387 cave[x][y+1] = Yalien_stone;
4388 Lboom_tank(x, y+1, Xstone_fall);
4389 score += lev.alien_score;
4393 case Xdiamond_pause:
4394 switch (cave[x][y+2])
4450 next[x][y] = Xstone;
4451 play_element_sound(x, y, SOUND_stone, Xstone);
4455 cave[x][y] = Ystone_sB;
4456 next[x][y] = Xblank;
4457 cave[x][y+1] = Ydiamond_stone;
4458 next[x][y+1] = Xstone_pause;
4459 play_element_sound(x, y, SOUND_squash, Xdiamond);
4464 cave[x][y+1] = Ybomb_blank;
4465 Lboom_tank(x, y+1, Xstone_fall);
4469 if (lev.wonderwall_time)
4471 lev.wonderwall_state = 1;
4472 cave[x][y] = Ystone_sB;
4474 if (tab_blank[cave[x][y+2]])
4476 cave[x][y+2] = Yemerald_s;
4477 next[x][y+2] = Xemerald_fall;
4480 next[x][y] = Xblank;
4481 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4486 cave[x][y] = Xstone;
4487 next[x][y] = Xstone;
4488 play_element_sound(x, y, SOUND_stone, Xstone);
4493 static void Lbomb(int x, int y)
4495 switch (cave[x][y+1])
4508 cave[x][y] = Ybomb_sB;
4509 next[x][y] = Xblank;
4510 cave[x][y+1] = Ybomb_s;
4511 next[x][y+1] = Xbomb_fall;
4522 cave[x][y] = Ybomb_sB;
4523 next[x][y] = Xblank;
4524 if (cave[x+1][y] == Xblank)
4525 cave[x+1][y] = Xsplash_e;
4526 if (cave[x-1][y] == Xblank)
4527 cave[x-1][y] = Xsplash_w;
4528 play_element_sound(x, y, SOUND_acid, Xacid_1);
4547 case Xemerald_pause:
4549 case Xdiamond_pause:
4577 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
4579 cave[x][y] = Ybomb_eB;
4580 next[x][y] = Xblank;
4581 cave[x+1][y] = Ybomb_e;
4582 next[x+1][y] = Xbomb_pause;
4586 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
4588 cave[x][y] = Ybomb_wB;
4589 next[x][y] = Xblank;
4590 cave[x-1][y] = Ybomb_w;
4591 next[x-1][y] = Xbomb_pause;
4597 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
4599 cave[x][y] = Ybomb_wB;
4600 next[x][y] = Xblank;
4601 cave[x-1][y] = Ybomb_w;
4602 next[x-1][y] = Xbomb_pause;
4606 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
4608 cave[x][y] = Ybomb_eB;
4609 next[x][y] = Xblank;
4610 cave[x+1][y] = Ybomb_e;
4611 next[x+1][y] = Xbomb_pause;
4618 static void Lbomb_pause(int x, int y)
4620 switch (cave[x][y+1])
4633 cave[x][y] = Ybomb_sB;
4634 next[x][y] = Xblank;
4635 cave[x][y+1] = Ybomb_s;
4636 next[x][y+1] = Xbomb_fall;
4647 cave[x][y] = Ybomb_sB;
4648 next[x][y] = Xblank;
4649 if (cave[x+1][y] == Xblank)
4650 cave[x+1][y] = Xsplash_e;
4651 if (cave[x-1][y] == Xblank)
4652 cave[x-1][y] = Xsplash_w;
4653 play_element_sound(x, y, SOUND_acid, Xacid_1);
4663 static void Lbomb_fall(int x, int y)
4665 switch (cave[x][y+1])
4678 cave[x][y] = Ybomb_sB;
4679 next[x][y] = Xblank;
4680 cave[x][y+1] = Ybomb_s;
4681 next[x][y+1] = Xbomb_fall;
4692 cave[x][y] = Ybomb_sB;
4693 next[x][y] = Xblank;
4694 if (cave[x+1][y] == Xblank)
4695 cave[x+1][y] = Xsplash_e;
4696 if (cave[x-1][y] == Xblank)
4697 cave[x-1][y] = Xsplash_w;
4698 play_element_sound(x, y, SOUND_acid, Xacid_1);
4702 cave[x][y] = Ybomb_blank;
4703 Lboom_tank(x, y, Xbomb_fall);
4708 static void Lnut(int x, int y)
4710 switch (cave[x][y+1])
4723 cave[x][y] = Ynut_sB;
4724 next[x][y] = Xblank;
4725 cave[x][y+1] = Ynut_s;
4726 next[x][y+1] = Xnut_fall;
4737 cave[x][y] = Ynut_sB;
4738 next[x][y] = Xblank;
4739 if (cave[x+1][y] == Xblank)
4740 cave[x+1][y] = Xsplash_e;
4741 if (cave[x-1][y] == Xblank)
4742 cave[x-1][y] = Xsplash_w;
4743 play_element_sound(x, y, SOUND_acid, Xacid_1);
4762 case Xemerald_pause:
4764 case Xdiamond_pause:
4792 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
4794 cave[x][y] = Ynut_eB;
4795 next[x][y] = Xblank;
4796 cave[x+1][y] = Ynut_e;
4797 next[x+1][y] = Xnut_pause;
4801 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
4803 cave[x][y] = Ynut_wB;
4804 next[x][y] = Xblank;
4805 cave[x-1][y] = Ynut_w;
4806 next[x-1][y] = Xnut_pause;
4812 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
4814 cave[x][y] = Ynut_wB;
4815 next[x][y] = Xblank;
4816 cave[x-1][y] = Ynut_w;
4817 next[x-1][y] = Xnut_pause;
4821 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
4823 cave[x][y] = Ynut_eB;
4824 next[x][y] = Xblank;
4825 cave[x+1][y] = Ynut_e;
4826 next[x+1][y] = Xnut_pause;
4833 static void Lnut_pause(int x, int y)
4835 switch (cave[x][y+1])
4848 cave[x][y] = Ynut_sB;
4849 next[x][y] = Xblank;
4850 cave[x][y+1] = Ynut_s;
4851 next[x][y+1] = Xnut_fall;
4862 cave[x][y] = Ynut_sB;
4863 next[x][y] = Xblank;
4864 if (cave[x+1][y] == Xblank)
4865 cave[x+1][y] = Xsplash_e;
4866 if (cave[x-1][y] == Xblank)
4867 cave[x-1][y] = Xsplash_w;
4868 play_element_sound(x, y, SOUND_acid, Xacid_1);
4878 static void Lnut_fall(int x, int y)
4880 switch (cave[x][y+1])
4894 cave[x][y] = Ynut_sB;
4895 next[x][y] = Xblank;
4896 cave[x][y+1] = Ynut_s;
4897 next[x][y+1] = Xnut_fall;
4908 cave[x][y] = Ynut_sB;
4909 next[x][y] = Xblank;
4910 if (cave[x+1][y] == Xblank)
4911 cave[x+1][y] = Xsplash_e;
4912 if (cave[x-1][y] == Xblank)
4913 cave[x-1][y] = Xsplash_w;
4914 play_element_sound(x, y, SOUND_acid, Xacid_1);
4920 play_element_sound(x, y, SOUND_nut, Xnut);
4925 static void Lspring(int x, int y)
4927 switch (cave[x][y+1])
4942 cave[x][y] = Yspring_sB;
4943 next[x][y] = Xblank;
4944 cave[x][y+1] = Yspring_s;
4945 next[x][y+1] = Xspring_fall;
4956 cave[x][y] = Yspring_sB;
4957 next[x][y] = Xblank;
4958 if (cave[x+1][y] == Xblank)
4959 cave[x+1][y] = Xsplash_e;
4960 if (cave[x-1][y] == Xblank)
4961 cave[x-1][y] = Xsplash_w;
4962 play_element_sound(x, y, SOUND_acid, Xacid_1);
4981 case Xemerald_pause:
4983 case Xdiamond_pause:
5011 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
5013 cave[x][y] = Yspring_eB;
5014 next[x][y] = Xblank;
5015 cave[x+1][y] = Yspring_e;
5016 if (cave[x][y+1] == Xbumper)
5017 cave[x][y+1] = XbumperB;
5020 next[x+1][y] = Xspring_e;
5022 next[x+1][y] = Xspring_pause;
5027 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
5029 cave[x][y] = Yspring_wB;
5030 next[x][y] = Xblank;
5031 cave[x-1][y] = Yspring_w;
5032 if (cave[x][y+1] == Xbumper)
5033 cave[x][y+1] = XbumperB;
5036 next[x-1][y] = Xspring_w;
5038 next[x-1][y] = Xspring_pause;
5045 if (tab_blank[cave[x-1][y]] && tab_acid[cave[x-1][y+1]])
5047 cave[x][y] = Yspring_wB;
5048 next[x][y] = Xblank;
5049 cave[x-1][y] = Yspring_w;
5050 if (cave[x][y+1] == Xbumper)
5051 cave[x][y+1] = XbumperB;
5054 next[x-1][y] = Xspring_w;
5056 next[x-1][y] = Xspring_pause;
5061 if (tab_blank[cave[x+1][y]] && tab_acid[cave[x+1][y+1]])
5063 cave[x][y] = Yspring_eB;
5064 next[x][y] = Xblank;
5065 cave[x+1][y] = Yspring_e;
5066 if (cave[x][y+1] == Xbumper)
5067 cave[x][y+1] = XbumperB;
5070 next[x+1][y] = Xspring_e;
5072 next[x+1][y] = Xspring_pause;
5080 static void Lspring_pause(int x, int y)
5082 switch (cave[x][y+1])
5095 cave[x][y] = Yspring_sB;
5096 next[x][y] = Xblank;
5097 cave[x][y+1] = Yspring_s;
5098 next[x][y+1] = Xspring_fall;
5109 cave[x][y] = Yspring_sB;
5110 next[x][y] = Xblank;
5111 if (cave[x+1][y] == Xblank)
5112 cave[x+1][y] = Xsplash_e;
5113 if (cave[x-1][y] == Xblank)
5114 cave[x-1][y] = Xsplash_w;
5115 play_element_sound(x, y, SOUND_acid, Xacid_1);
5119 cave[x][y] = Xspring;
5120 next[x][y] = Xspring;
5125 static void Lspring_e(int x, int y)
5127 switch (cave[x][y+1])
5140 cave[x][y] = Yspring_sB;
5141 next[x][y] = Xblank;
5142 cave[x][y+1] = Yspring_s;
5143 next[x][y+1] = Xspring_fall;
5154 cave[x][y] = Yspring_sB;
5155 next[x][y] = Xblank;
5156 if (cave[x+1][y] == Xblank)
5157 cave[x+1][y] = Xsplash_e;
5158 if (cave[x-1][y] == Xblank)
5159 cave[x-1][y] = Xsplash_w;
5160 play_element_sound(x, y, SOUND_acid, Xacid_1);
5164 cave[x][y+1] = XbumperB;
5167 switch (cave[x+1][y])
5184 cave[x][y] = Yspring_eB;
5185 next[x][y] = Xblank;
5186 cave[x+1][y] = Yspring_e;
5187 next[x+1][y] = Xspring_e;
5198 cave[x][y] = Yspring_eB;
5199 next[x][y] = Xblank;
5200 if (cave[x+2][y-1] == Xblank)
5201 cave[x+2][y-1] = Xsplash_e;
5202 if (cave[x][y-1] == Xblank)
5203 cave[x][y-1] = Xsplash_w;
5204 play_element_sound(x, y, SOUND_acid, Xacid_1);
5213 cave[x][y] = Yspring_alien_eB;
5214 next[x][y] = Xblank;
5215 cave[x+1][y] = Yspring_alien_e;
5216 next[x+1][y] = Xspring_e;
5217 play_element_sound(x, y, SOUND_slurp, Xalien);
5218 score += lev.slurp_score;
5223 cave[x+1][y] = XbumperB;
5224 next[x][y] = Xspring_w;
5225 play_element_sound(x, y, SOUND_spring, Xspring);
5229 cave[x][y] = Xspring;
5230 next[x][y] = Xspring;
5231 play_element_sound(x, y, SOUND_spring, Xspring);
5236 static void Lspring_w(int x, int y)
5238 switch (cave[x][y+1])
5251 cave[x][y] = Yspring_sB;
5252 next[x][y] = Xblank;
5253 cave[x][y+1] = Yspring_s;
5254 next[x][y+1] = Xspring_fall;
5265 cave[x][y] = Yspring_sB;
5266 next[x][y] = Xblank;
5267 if (cave[x+1][y] == Xblank)
5268 cave[x+1][y] = Xsplash_e;
5269 if (cave[x-1][y] == Xblank)
5270 cave[x-1][y] = Xsplash_w;
5271 play_element_sound(x, y, SOUND_acid, Xacid_1);
5275 cave[x][y+1] = XbumperB;
5278 switch (cave[x-1][y])
5295 cave[x][y] = Yspring_wB;
5296 next[x][y] = Xblank;
5297 cave[x-1][y] = Yspring_w;
5298 next[x-1][y] = Xspring_w;
5309 cave[x][y] = Yspring_wB;
5310 next[x][y] = Xblank;
5311 if (cave[x][y-1] == Xblank)
5312 cave[x][y-1] = Xsplash_e;
5313 if (cave[x-2][y-1] == Xblank)
5314 cave[x-2][y-1] = Xsplash_w;
5315 play_element_sound(x, y, SOUND_acid, Xacid_1);
5324 cave[x][y] = Yspring_alien_wB;
5325 next[x][y] = Xblank;
5326 cave[x-1][y] = Yspring_alien_w;
5327 next[x-1][y] = Xspring_w;
5328 play_element_sound(x, y, SOUND_slurp, Xalien);
5329 score += lev.slurp_score;
5334 cave[x-1][y] = XbumperB;
5335 next[x][y] = Xspring_e;
5336 play_element_sound(x, y, SOUND_spring, Xspring);
5340 cave[x][y] = Xspring;
5341 next[x][y] = Xspring;
5342 play_element_sound(x, y, SOUND_spring, Xspring);
5347 static void Lspring_fall(int x, int y)
5349 switch (cave[x][y+1])
5363 cave[x][y] = Yspring_sB;
5364 next[x][y] = Xblank;
5365 cave[x][y+1] = Yspring_s;
5366 next[x][y+1] = Xspring_fall;
5377 cave[x][y] = Yspring_sB;
5378 next[x][y] = Xblank;
5379 if (cave[x+1][y] == Xblank)
5380 cave[x+1][y] = Xsplash_e;
5381 if (cave[x-1][y] == Xblank)
5382 cave[x-1][y] = Xsplash_w;
5383 play_element_sound(x, y, SOUND_acid, Xacid_1);
5388 cave[x][y+1] = Ybomb_blank;
5389 Lboom_tank(x, y+1, Xspring_fall);
5400 cave[x][y] = Yspring_sB;
5401 cave[x][y+1] = Ybug_spring;
5402 Lboom_bug(x, y+1, Xspring_fall);
5403 score += lev.bug_score;
5414 cave[x][y] = Yspring_sB;
5415 cave[x][y+1] = Ytank_spring;
5416 Lboom_tank(x, y+1, Xspring_fall);
5417 score += lev.tank_score;
5424 cave[x][y] = Yspring_sB;
5425 cave[x][y+1] = Yeater_spring;
5426 Lboom_eater(x, y+1, Xspring_fall);
5427 score += lev.eater_score;
5432 cave[x][y] = Yspring_sB;
5433 cave[x][y+1] = Yalien_spring;
5434 Lboom_tank(x, y+1, Xspring_fall);
5435 score += lev.alien_score;
5439 cave[x][y] = Xspring;
5440 next[x][y] = Xspring;
5441 play_element_sound(x, y, SOUND_spring, Xspring);
5446 static void Lpush_emerald_e(int x, int y)
5448 switch (cave[x+1][y])
5458 cave[x][y] = Xemerald;
5459 next[x][y] = Xemerald;
5463 cave[x][y] = Yemerald_eB;
5464 next[x][y] = Xblank;
5465 cave[x+1][y] = Yemerald_e;
5466 next[x+1][y] = Xemerald_pause;
5471 static void Lpush_emerald_w(int x, int y)
5473 switch (cave[x-1][y])
5483 cave[x][y] = Xemerald;
5484 next[x][y] = Xemerald;
5488 cave[x][y] = Yemerald_wB;
5489 next[x][y] = Xblank;
5490 cave[x-1][y] = Yemerald_w;
5491 next[x-1][y] = Xemerald_pause;
5496 static void Lpush_diamond_e(int x, int y)
5498 switch (cave[x+1][y])
5508 cave[x][y] = Xdiamond;
5509 next[x][y] = Xdiamond;
5513 cave[x][y] = Ydiamond_eB;
5514 next[x][y] = Xblank;
5515 cave[x+1][y] = Ydiamond_e;
5516 next[x+1][y] = Xdiamond_pause;
5521 static void Lpush_diamond_w(int x, int y)
5523 switch (cave[x-1][y])
5533 cave[x][y] = Xdiamond;
5534 next[x][y] = Xdiamond;
5538 cave[x][y] = Ydiamond_wB;
5539 next[x][y] = Xblank;
5540 cave[x-1][y] = Ydiamond_w;
5541 next[x-1][y] = Xdiamond_pause;
5546 static void Lpush_stone_e(int x, int y)
5548 switch (cave[x+1][y])
5558 cave[x][y] = Xstone;
5559 next[x][y] = Xstone;
5563 cave[x][y] = Ystone_eB;
5564 next[x][y] = Xblank;
5565 cave[x+1][y] = Ystone_e;
5566 next[x+1][y] = Xstone_pause;
5571 static void Lpush_stone_w(int x, int y)
5573 switch (cave[x-1][y])
5583 cave[x][y] = Xstone;
5584 next[x][y] = Xstone;
5588 cave[x][y] = Ystone_wB;
5589 next[x][y] = Xblank;
5590 cave[x-1][y] = Ystone_w;
5591 next[x-1][y] = Xstone_pause;
5596 static void Lpush_bomb_e(int x, int y)
5598 switch (cave[x+1][y])
5613 cave[x][y] = Ybomb_eB;
5614 next[x][y] = Xblank;
5615 cave[x+1][y] = Ybomb_e;
5616 next[x+1][y] = Xbomb_pause;
5621 static void Lpush_bomb_w(int x, int y)
5623 switch (cave[x-1][y])
5638 cave[x][y] = Ybomb_wB;
5639 next[x][y] = Xblank;
5640 cave[x-1][y] = Ybomb_w;
5641 next[x-1][y] = Xbomb_pause;
5646 static void Lpush_nut_e(int x, int y)
5648 switch (cave[x+1][y])
5663 cave[x][y] = Ynut_eB;
5664 next[x][y] = Xblank;
5665 cave[x+1][y] = Ynut_e;
5666 next[x+1][y] = Xnut_pause;
5671 static void Lpush_nut_w(int x, int y)
5673 switch (cave[x-1][y])
5688 cave[x][y] = Ynut_wB;
5689 next[x][y] = Xblank;
5690 cave[x-1][y] = Ynut_w;
5691 next[x-1][y] = Xnut_pause;
5696 static void Lpush_spring_e(int x, int y)
5698 switch (cave[x+1][y])
5708 cave[x][y] = Xspring;
5709 next[x][y] = Xspring;
5713 cave[x][y] = Yspring_eB;
5714 next[x][y] = Xblank;
5715 cave[x+1][y] = Yspring_e;
5716 next[x+1][y] = Xspring_e;
5721 static void Lpush_spring_w(int x, int y)
5723 switch (cave[x-1][y])
5733 cave[x][y] = Xspring;
5734 next[x][y] = Xspring;
5738 cave[x][y] = Yspring_wB;
5739 next[x][y] = Xblank;
5740 cave[x-1][y] = Yspring_w;
5741 next[x-1][y] = Xspring_w;
5746 static void Ldynamite_1(int x, int y)
5748 play_element_sound(x, y, SOUND_tick, Xdynamite_1);
5749 next[x][y] = Xdynamite_2;
5752 static void Ldynamite_2(int x, int y)
5754 play_element_sound(x, y, SOUND_tick, Xdynamite_2);
5755 next[x][y] = Xdynamite_3;
5758 static void Ldynamite_3(int x, int y)
5760 play_element_sound(x, y, SOUND_tick, Xdynamite_3);
5761 next[x][y] = Xdynamite_4;
5764 static void Ldynamite_4(int x, int y)
5766 play_element_sound(x, y, SOUND_tick, Xdynamite_4);
5767 next[x][y] = Zdynamite;
5769 Lboom_generic(x, y, Xblank, Xblank);
5772 static void Lfake_door_1(int x, int y)
5774 if (lev.magnify_cnt)
5775 cave[x][y] = Xdoor_1;
5778 static void Lfake_door_2(int x, int y)
5780 if (lev.magnify_cnt)
5781 cave[x][y] = Xdoor_2;
5784 static void Lfake_door_3(int x, int y)
5786 if (lev.magnify_cnt)
5787 cave[x][y] = Xdoor_3;
5790 static void Lfake_door_4(int x, int y)
5792 if (lev.magnify_cnt)
5793 cave[x][y] = Xdoor_4;
5796 static void Lfake_door_5(int x, int y)
5798 if (lev.magnify_cnt)
5799 cave[x][y] = Xdoor_5;
5802 static void Lfake_door_6(int x, int y)
5804 if (lev.magnify_cnt)
5805 cave[x][y] = Xdoor_6;
5808 static void Lfake_door_7(int x, int y)
5810 if (lev.magnify_cnt)
5811 cave[x][y] = Xdoor_7;
5814 static void Lfake_door_8(int x, int y)
5816 if (lev.magnify_cnt)
5817 cave[x][y] = Xdoor_8;
5820 static void Lballoon(int x, int y)
5822 if (lev.wind_cnt == 0)
5825 switch (lev.wind_direction)
5828 switch (cave[x][y-1])
5841 cave[x][y] = Yballoon_nB;
5842 next[x][y] = Xblank;
5843 cave[x][y-1] = Yballoon_n;
5844 next[x][y-1] = Xballoon;
5855 cave[x][y] = Yballoon_nB;
5856 next[x][y] = Xblank;
5857 if (cave[x+1][y-2] == Xblank)
5858 cave[x+1][y-2] = Xsplash_e;
5859 if (cave[x-1][y-2] == Xblank)
5860 cave[x-1][y-2] = Xsplash_w;
5861 play_element_sound(x, y, SOUND_acid, Xacid_1);
5867 switch (cave[x+1][y])
5880 cave[x][y] = Yballoon_eB;
5881 next[x][y] = Xblank;
5882 cave[x+1][y] = Yballoon_e;
5883 next[x+1][y] = Xballoon;
5894 cave[x][y] = Yballoon_eB;
5895 next[x][y] = Xblank;
5896 if (cave[x+2][y-1] == Xblank)
5897 cave[x+2][y-1] = Xsplash_e;
5898 if (cave[x][y-1] == Xblank)
5899 cave[x][y-1] = Xsplash_w;
5900 play_element_sound(x, y, SOUND_acid, Xacid_1);
5906 switch (cave[x][y+1])
5919 cave[x][y] = Yballoon_sB;
5920 next[x][y] = Xblank;
5921 cave[x][y+1] = Yballoon_s;
5922 next[x][y+1] = Xballoon;
5933 cave[x][y] = Yballoon_sB;
5934 next[x][y] = Xblank;
5935 if (cave[x+1][y] == Xblank)
5936 cave[x+1][y] = Xsplash_e;
5937 if (cave[x-1][y] == Xblank)
5938 cave[x-1][y] = Xsplash_w;
5939 play_element_sound(x, y, SOUND_acid, Xacid_1);
5945 switch (cave[x-1][y])
5958 cave[x][y] = Yballoon_wB;
5959 next[x][y] = Xblank;
5960 cave[x-1][y] = Yballoon_w;
5961 next[x-1][y] = Xballoon;
5972 cave[x][y] = Yballoon_wB;
5973 next[x][y] = Xblank;
5974 if (cave[x][y-1] == Xblank)
5975 cave[x][y-1] = Xsplash_e;
5976 if (cave[x-2][y-1] == Xblank)
5977 cave[x-2][y-1] = Xsplash_w;
5978 play_element_sound(x, y, SOUND_acid, Xacid_1);
5985 static void Lball_common(int x, int y)
5987 play_element_sound(x, y, SOUND_ball, Xball_1);
5989 if (lev.ball_random)
5994 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
5995 tab_blank[cave[x-1][y-1]])
5997 cave[x-1][y-1] = Yball_blank;
5998 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6003 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6004 tab_blank[cave[x][y-1]])
6006 cave[x][y-1] = Yball_blank;
6007 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6012 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6013 tab_blank[cave[x+1][y-1]])
6015 cave[x+1][y-1] = Yball_blank;
6016 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6021 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6022 tab_blank[cave[x-1][y]])
6024 cave[x-1][y] = Yball_blank;
6025 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6030 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6031 tab_blank[cave[x+1][y]])
6033 cave[x+1][y] = Yball_blank;
6034 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6039 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6040 tab_blank[cave[x-1][y+1]])
6042 cave[x-1][y+1] = Yball_blank;
6043 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6048 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6049 tab_blank[cave[x][y+1]])
6051 cave[x][y+1] = Yball_blank;
6052 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6057 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6058 tab_blank[cave[x+1][y+1]])
6060 cave[x+1][y+1] = Yball_blank;
6061 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6068 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6069 tab_blank[cave[x-1][y-1]])
6071 cave[x-1][y-1] = Yball_blank;
6072 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6075 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6076 tab_blank[cave[x][y-1]])
6078 cave[x][y-1] = Yball_blank;
6079 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6082 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6083 tab_blank[cave[x+1][y-1]])
6085 cave[x+1][y-1] = Yball_blank;
6086 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6089 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6090 tab_blank[cave[x-1][y]])
6092 cave[x-1][y] = Yball_blank;
6093 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6096 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6097 tab_blank[cave[x+1][y]])
6099 cave[x+1][y] = Yball_blank;
6100 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6103 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6104 tab_blank[cave[x-1][y+1]])
6106 cave[x-1][y+1] = Yball_blank;
6107 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6110 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6111 tab_blank[cave[x][y+1]])
6113 cave[x][y+1] = Yball_blank;
6114 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6117 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6118 tab_blank[cave[x+1][y+1]])
6120 cave[x+1][y+1] = Yball_blank;
6121 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6125 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
6128 static void Lball_1(int x, int y)
6130 if (lev.ball_state == 0)
6133 cave[x][y] = Yball_1;
6134 next[x][y] = Xball_2;
6141 static void Lball_2(int x, int y)
6143 if (lev.ball_state == 0)
6146 cave[x][y] = Yball_2;
6147 next[x][y] = Xball_1;
6154 static void Ldrip(int x, int y)
6156 next[x][y] = Xdrip_fall;
6159 static void Ldrip_fall(int x, int y)
6163 switch (cave[x][y+1])
6179 cave[x][y] = Ydrip_1_sB;
6180 next[x][y] = Xdrip_stretchB;
6181 cave[x][y+1] = Ydrip_1_s;
6182 next[x][y+1] = Xdrip_stretch;
6193 cave[x][y] = Ydrip_1_sB;
6194 next[x][y] = Xdrip_stretchB;
6195 if (cave[x+1][y] == Xblank)
6196 cave[x+1][y] = Xsplash_e;
6197 if (cave[x-1][y] == Xblank)
6198 cave[x-1][y] = Xsplash_w;
6199 play_element_sound(x, y, SOUND_acid, Xacid_1);
6205 case 0: temp = Xamoeba_1; break;
6206 case 1: temp = Xamoeba_2; break;
6207 case 2: temp = Xamoeba_3; break;
6208 case 3: temp = Xamoeba_4; break;
6209 case 4: temp = Xamoeba_5; break;
6210 case 5: temp = Xamoeba_6; break;
6211 case 6: temp = Xamoeba_7; break;
6212 case 7: temp = Xamoeba_8; break;
6217 play_element_sound(x, y, SOUND_drip, Xdrip_fall);
6222 static void Ldrip_stretch(int x, int y)
6224 cave[x][y] = Ydrip_2_s;
6225 next[x][y] = Xdrip_fall;
6228 static void Ldrip_stretchB(int x, int y)
6230 cave[x][y] = Ydrip_2_sB;
6231 next[x][y] = Xblank;
6234 static void Lwonderwall(int x, int y)
6236 if (lev.wonderwall_time && lev.wonderwall_state)
6238 cave[x][y] = XwonderwallB;
6239 play_element_sound(x, y, SOUND_wonder, Xwonderwall);
6243 static void Lwheel(int x, int y)
6245 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
6246 cave[x][y] = XwheelB;
6249 static void Lswitch(int x, int y)
6252 cave[x][y] = XswitchB;
6255 static void Lfake_blank(int x, int y)
6258 cave[x][y] = Xfake_blankB;
6261 static void Lfake_grass(int x, int y)
6263 if (lev.magnify_cnt)
6264 cave[x][y] = Xfake_grassB;
6267 static void Lfake_amoeba(int x, int y)
6270 cave[x][y] = Xfake_amoebaB;
6273 static void Lsand_stone(int x, int y)
6275 switch (cave[x][y+1])
6288 cave[x][y] = Xsand_stonesand_quickout_1;
6289 next[x][y] = Xsand_stonesand_quickout_2;
6290 cave[x][y+1] = Xsand_stoneout_1;
6291 next[x][y+1] = Xsand_stoneout_2;
6302 cave[x][y] = Xsand_stonesand_quickout_1;
6303 next[x][y] = Xsand_stonesand_quickout_2;
6304 if (cave[x+1][y] == Xblank)
6305 cave[x+1][y] = Xsplash_e;
6306 if (cave[x-1][y] == Xblank)
6307 cave[x-1][y] = Xsplash_w;
6308 play_element_sound(x, y, SOUND_acid, Xacid_1);
6312 cave[x][y] = Xsand_stonesand_1;
6313 next[x][y] = Xsand_stonesand_2;
6314 cave[x][y+1] = Xsand_sandstone_1;
6315 next[x][y+1] = Xsand_sandstone_2;
6320 static void Lsand_stonein_1(int x, int y)
6322 next[x][y] = Xsand_stonein_2;
6325 static void Lsand_stonein_2(int x, int y)
6327 next[x][y] = Xsand_stonein_3;
6330 static void Lsand_stonein_3(int x, int y)
6332 next[x][y] = Xsand_stonein_4;
6335 static void Lsand_stonein_4(int x, int y)
6337 next[x][y] = Xblank;
6340 static void Lsand_sandstone_1(int x, int y)
6342 next[x][y] = Xsand_sandstone_2;
6345 static void Lsand_sandstone_2(int x, int y)
6347 next[x][y] = Xsand_sandstone_3;
6350 static void Lsand_sandstone_3(int x, int y)
6352 next[x][y] = Xsand_sandstone_4;
6355 static void Lsand_sandstone_4(int x, int y)
6357 next[x][y] = Xsand_stone;
6360 static void Lsand_stonesand_1(int x, int y)
6362 next[x][y] = Xsand_stonesand_2;
6365 static void Lsand_stonesand_2(int x, int y)
6367 next[x][y] = Xsand_stonesand_3;
6370 static void Lsand_stonesand_3(int x, int y)
6372 next[x][y] = Xsand_stonesand_4;
6375 static void Lsand_stonesand_4(int x, int y)
6380 static void Lsand_stoneout_1(int x, int y)
6382 next[x][y] = Xsand_stoneout_2;
6385 static void Lsand_stoneout_2(int x, int y)
6387 next[x][y] = Xstone_fall;
6390 static void Lsand_stonesand_quickout_1(int x, int y)
6392 next[x][y] = Xsand_stonesand_quickout_2;
6395 static void Lsand_stonesand_quickout_2(int x, int y)
6400 static void Lslide_ns(int x, int y)
6402 if (tab_blank[cave[x][y-1]])
6404 cave[x][y-1] = Yslide_ns_blank;
6405 next[x][y-1] = Xslide_ns;
6406 play_element_sound(x, y, SOUND_slide, Xslide_ns);
6409 if (tab_blank[cave[x][y+1]])
6411 cave[x][y+1] = Yslide_ns_blank;
6412 next[x][y+1] = Xslide_ns;
6413 play_element_sound(x, y, SOUND_slide, Xslide_ns);
6417 static void Lslide_ew(int x, int y)
6419 if (tab_blank[cave[x+1][y]])
6421 cave[x+1][y] = Yslide_ew_blank;
6422 next[x+1][y] = Xslide_ew;
6423 play_element_sound(x, y, SOUND_slide, Xslide_ew);
6426 if (tab_blank[cave[x-1][y]])
6428 cave[x-1][y] = Yslide_ew_blank;
6429 next[x-1][y] = Xslide_ew;
6430 play_element_sound(x, y, SOUND_slide, Xslide_ew);
6434 static void Lexit(int x, int y)
6436 if (lev.required > 0)
6439 switch (RANDOM(64) / 21)
6442 cave[x][y] = Xexit_1;
6443 next[x][y] = Xexit_2;
6447 cave[x][y] = Xexit_2;
6448 next[x][y] = Xexit_3;
6452 cave[x][y] = Xexit_3;
6453 next[x][y] = Xexit_1;
6457 play_element_sound(x, y, SOUND_exit_open, Xexit);
6460 static void Lexit_1(int x, int y)
6462 next[x][y] = Xexit_2;
6465 static void Lexit_2(int x, int y)
6467 next[x][y] = Xexit_3;
6470 static void Lexit_3(int x, int y)
6472 next[x][y] = Xexit_1;
6475 static void Lpause(int x, int y)
6477 next[x][y] = Xblank;
6480 static void Lamoeba(int x, int y)
6500 if (tab_amoeba[cave[x][y-1]] ||
6501 tab_amoeba[cave[x+1][y]] ||
6502 tab_amoeba[cave[x][y+1]] ||
6503 tab_amoeba[cave[x-1][y]])
6508 static void Lexplode(int x, int y)
6513 cave[x][y] = Xboom_1;
6514 cave[x][y-1] = tab_explode_normal[cave[x][y-1]];
6515 cave[x-1][y] = tab_explode_normal[cave[x-1][y]];
6516 cave[x+1][y] = tab_explode_normal[cave[x+1][y]];
6517 cave[x][y+1] = tab_explode_normal[cave[x][y+1]];
6518 cave[x-1][y-1] = tab_explode_normal[cave[x-1][y-1]];
6519 cave[x+1][y-1] = tab_explode_normal[cave[x+1][y-1]];
6520 cave[x-1][y+1] = tab_explode_normal[cave[x-1][y+1]];
6521 cave[x+1][y+1] = tab_explode_normal[cave[x+1][y+1]];
6525 cave[x][y] = Xboom_1;
6526 cave[x][y-1] = tab_explode_dynamite[cave[x][y-1]];
6527 cave[x-1][y] = tab_explode_dynamite[cave[x-1][y]];
6528 cave[x+1][y] = tab_explode_dynamite[cave[x+1][y]];
6529 cave[x][y+1] = tab_explode_dynamite[cave[x][y+1]];
6530 cave[x-1][y-1] = tab_explode_dynamite[cave[x-1][y-1]];
6531 cave[x+1][y-1] = tab_explode_dynamite[cave[x+1][y-1]];
6532 cave[x-1][y+1] = tab_explode_dynamite[cave[x-1][y+1]];
6533 cave[x+1][y+1] = tab_explode_dynamite[cave[x+1][y+1]];
6538 static void Lboom_1(int x, int y)
6540 next[x][y] = Xboom_2;
6541 #if !PLAY_ELEMENT_SOUND
6542 if (x != lev.exit_x && y != lev.exit_y)
6543 play_sound(x, y, SOUND_boom);
6545 lev.exit_x = lev.exit_y = -1;
6549 static void Lboom_2(int x, int y)
6551 next[x][y] = boom[x][y];
6554 static void Lboom_android(int x, int y)
6556 #if PLAY_ELEMENT_SOUND
6557 play_element_sound(x, y, SOUND_boom, Xandroid);
6563 static void handle_tile(int x, int y)
6567 case Xacid_1: Lacid_1(x, y); break;
6568 case Xacid_2: Lacid_2(x, y); break;
6569 case Xacid_3: Lacid_3(x, y); break;
6570 case Xacid_4: Lacid_4(x, y); break;
6571 case Xacid_5: Lacid_5(x, y); break;
6572 case Xacid_6: Lacid_6(x, y); break;
6573 case Xacid_7: Lacid_7(x, y); break;
6574 case Xacid_8: Lacid_8(x, y); break;
6576 case Xfake_acid_1: Lfake_acid_1(x, y); break;
6577 case Xfake_acid_2: Lfake_acid_2(x, y); break;
6578 case Xfake_acid_3: Lfake_acid_3(x, y); break;
6579 case Xfake_acid_4: Lfake_acid_4(x, y); break;
6580 case Xfake_acid_5: Lfake_acid_5(x, y); break;
6581 case Xfake_acid_6: Lfake_acid_6(x, y); break;
6582 case Xfake_acid_7: Lfake_acid_7(x, y); break;
6583 case Xfake_acid_8: Lfake_acid_8(x, y); break;
6585 case Xandroid: Landroid(x, y); break;
6586 case Xandroid_1_n: Landroid_1_n(x, y); break;
6587 case Xandroid_2_n: Landroid_2_n(x, y); break;
6588 case Xandroid_1_e: Landroid_1_e(x, y); break;
6589 case Xandroid_2_e: Landroid_2_e(x, y); break;
6590 case Xandroid_1_s: Landroid_1_s(x, y); break;
6591 case Xandroid_2_s: Landroid_2_s(x, y); break;
6592 case Xandroid_1_w: Landroid_1_w(x, y); break;
6593 case Xandroid_2_w: Landroid_2_w(x, y); break;
6595 case Xeater_n: Leater_n(x, y); break;
6596 case Xeater_e: Leater_e(x, y); break;
6597 case Xeater_s: Leater_s(x, y); break;
6598 case Xeater_w: Leater_w(x, y); break;
6600 case Xalien: Lalien(x, y); break;
6601 case Xalien_pause: Lalien_pause(x, y); break;
6603 case Xbug_1_n: Lbug_1_n(x, y); break;
6604 case Xbug_2_n: Lbug_2_n(x, y); break;
6605 case Xbug_1_e: Lbug_1_e(x, y); break;
6606 case Xbug_2_e: Lbug_2_e(x, y); break;
6607 case Xbug_1_s: Lbug_1_s(x, y); break;
6608 case Xbug_2_s: Lbug_2_s(x, y); break;
6609 case Xbug_1_w: Lbug_1_w(x, y); break;
6610 case Xbug_2_w: Lbug_2_w(x, y); break;
6612 case Xtank_1_n: Ltank_1_n(x, y); break;
6613 case Xtank_2_n: Ltank_2_n(x, y); break;
6614 case Xtank_1_e: Ltank_1_e(x, y); break;
6615 case Xtank_2_e: Ltank_2_e(x, y); break;
6616 case Xtank_1_s: Ltank_1_s(x, y); break;
6617 case Xtank_2_s: Ltank_2_s(x, y); break;
6618 case Xtank_1_w: Ltank_1_w(x, y); break;
6619 case Xtank_2_w: Ltank_2_w(x, y); break;
6621 case Xemerald: Lemerald(x, y); break;
6622 case Xemerald_pause: Lemerald_pause(x, y); break;
6623 case Xemerald_fall: Lemerald_fall(x, y); break;
6625 case Xdiamond: Ldiamond(x, y); break;
6626 case Xdiamond_pause: Ldiamond_pause(x, y); break;
6627 case Xdiamond_fall: Ldiamond_fall(x, y); break;
6629 case Xstone: Lstone(x, y); break;
6630 case Xstone_pause: Lstone_pause(x, y); break;
6631 case Xstone_fall: Lstone_fall(x, y); break;
6633 case Xbomb: Lbomb(x, y); break;
6634 case Xbomb_pause: Lbomb_pause(x, y); break;
6635 case Xbomb_fall: Lbomb_fall(x, y); break;
6637 case Xnut: Lnut(x, y); break;
6638 case Xnut_pause: Lnut_pause(x, y); break;
6639 case Xnut_fall: Lnut_fall(x, y); break;
6641 case Xspring: Lspring(x, y); break;
6642 case Xspring_pause: Lspring_pause(x, y); break;
6643 case Xspring_e: Lspring_e(x, y); break;
6644 case Xspring_w: Lspring_w(x, y); break;
6645 case Xspring_fall: Lspring_fall(x, y); break;
6647 case Xpush_emerald_e: Lpush_emerald_e(x, y); break;
6648 case Xpush_emerald_w: Lpush_emerald_w(x, y); break;
6649 case Xpush_diamond_e: Lpush_diamond_e(x, y); break;
6650 case Xpush_diamond_w: Lpush_diamond_w(x, y); break;
6651 case Xpush_stone_e: Lpush_stone_e(x, y); break;
6652 case Xpush_stone_w: Lpush_stone_w(x, y); break;
6653 case Xpush_bomb_e: Lpush_bomb_e(x, y); break;
6654 case Xpush_bomb_w: Lpush_bomb_w(x, y); break;
6655 case Xpush_nut_e: Lpush_nut_e(x, y); break;
6656 case Xpush_nut_w: Lpush_nut_w(x, y); break;
6657 case Xpush_spring_e: Lpush_spring_e(x, y); break;
6658 case Xpush_spring_w: Lpush_spring_w(x, y); break;
6660 case Xdynamite_1: Ldynamite_1(x, y); break;
6661 case Xdynamite_2: Ldynamite_2(x, y); break;
6662 case Xdynamite_3: Ldynamite_3(x, y); break;
6663 case Xdynamite_4: Ldynamite_4(x, y); break;
6665 case Xfake_door_1: Lfake_door_1(x, y); break;
6666 case Xfake_door_2: Lfake_door_2(x, y); break;
6667 case Xfake_door_3: Lfake_door_3(x, y); break;
6668 case Xfake_door_4: Lfake_door_4(x, y); break;
6669 case Xfake_door_5: Lfake_door_5(x, y); break;
6670 case Xfake_door_6: Lfake_door_6(x, y); break;
6671 case Xfake_door_7: Lfake_door_7(x, y); break;
6672 case Xfake_door_8: Lfake_door_8(x, y); break;
6674 case Xballoon: Lballoon(x, y); break;
6676 case Xball_1: Lball_1(x, y); break;
6677 case Xball_2: Lball_2(x, y); break;
6679 case Xdrip: Ldrip(x, y); break;
6680 case Xdrip_fall: Ldrip_fall(x, y); break;
6681 case Xdrip_stretch: Ldrip_stretch(x, y); break;
6682 case Xdrip_stretchB: Ldrip_stretchB(x, y); break;
6684 case Xwonderwall: Lwonderwall(x, y); break;
6686 case Xwheel: Lwheel(x, y); break;
6688 case Xswitch: Lswitch(x, y); break;
6690 case Xfake_blank: Lfake_blank(x, y); break;
6691 case Xfake_grass: Lfake_grass(x, y); break;
6692 case Xfake_amoeba: Lfake_amoeba(x, y); break;
6694 case Xsand_stone: Lsand_stone(x, y); break;
6695 case Xsand_stonein_1: Lsand_stonein_1(x, y); break;
6696 case Xsand_stonein_2: Lsand_stonein_2(x, y); break;
6697 case Xsand_stonein_3: Lsand_stonein_3(x, y); break;
6698 case Xsand_stonein_4: Lsand_stonein_4(x, y); break;
6699 case Xsand_sandstone_1: Lsand_sandstone_1(x, y); break;
6700 case Xsand_sandstone_2: Lsand_sandstone_2(x, y); break;
6701 case Xsand_sandstone_3: Lsand_sandstone_3(x, y); break;
6702 case Xsand_sandstone_4: Lsand_sandstone_4(x, y); break;
6703 case Xsand_stonesand_1: Lsand_stonesand_1(x, y); break;
6704 case Xsand_stonesand_2: Lsand_stonesand_2(x, y); break;
6705 case Xsand_stonesand_3: Lsand_stonesand_3(x, y); break;
6706 case Xsand_stonesand_4: Lsand_stonesand_4(x, y); break;
6707 case Xsand_stoneout_1: Lsand_stoneout_1(x, y); break;
6708 case Xsand_stoneout_2: Lsand_stoneout_2(x, y); break;
6709 case Xsand_stonesand_quickout_1: Lsand_stonesand_quickout_1(x, y); break;
6710 case Xsand_stonesand_quickout_2: Lsand_stonesand_quickout_2(x, y); break;
6712 case Xslide_ns: Lslide_ns(x, y); break;
6713 case Xslide_ew: Lslide_ew(x, y); break;
6715 case Xexit: Lexit(x, y); break;
6716 case Xexit_1: Lexit_1(x, y); break;
6717 case Xexit_2: Lexit_2(x, y); break;
6718 case Xexit_3: Lexit_3(x, y); break;
6720 case Xpause: Lpause(x, y); break;
6722 case Xboom_bug: Lboom_bug(x, y, Xboom_bug); break;
6723 case Xboom_bomb: Lboom_tank(x, y, Xboom_bomb); break;
6724 case Xboom_android: Lboom_android(x, y); break;
6725 case Xboom_1: Lboom_1(x, y); break;
6726 case Xboom_2: Lboom_2(x, y); break;
6739 game_em.any_player_moving = FALSE;
6740 game_em.any_player_snapping = FALSE;
6742 /* must test for death and actually kill separately */
6743 for (i = 0; i < MAX_PLAYERS; i++)
6745 boolean ply_kill = player_killed(&ply[i]);
6747 if (ply[i].alive && ply_kill)
6748 kill_player(&ply[i]);
6751 for (i = 0; i < MAX_PLAYERS; i++)
6753 /* check for wrap-around movement */
6754 if (ply[i].x < lev.left ||
6755 ply[i].x > lev.right - 1)
6757 ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left);
6759 game.centered_player_nr_next = i;
6760 game.set_centered_player = TRUE;
6761 game.set_centered_player_fast = TRUE;
6764 ply[i].oldx = ply[i].x;
6765 ply[i].oldy = ply[i].y;
6766 ply[i].anim = PLY_still;
6769 start_check_nr = (RandomEM & 128 ? 0 : 1) * 2 + (RandomEM & 256 ? 0 : 1);
6771 for (i = 0; i < MAX_PLAYERS; i++)
6773 int check_nr = (start_check_nr + i) % MAX_PLAYERS;
6775 if (ply[check_nr].alive)
6776 check_player(&ply[check_nr]);
6779 for (i = 0; i < MAX_PLAYERS; i++)
6784 if (cave[ply[i].oldx][ply[i].oldy] == Zplayer)
6786 cave[ply[i].oldx][ply[i].oldy] = Xblank;
6787 next[ply[i].oldx][ply[i].oldy] = Xblank;
6790 if (cave[ply[i].x][ply[i].y] == Xblank)
6792 cave[ply[i].x][ply[i].y] = Zplayer;
6793 next[ply[i].x][ply[i].y] = Zplayer;
6809 for (y = lev.top; y < lev.bottom; y++)
6810 for (x = lev.left; x < lev.right; x++)
6813 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
6814 lev.score += score; /* only add a score if someone is alive */
6816 game_em.game_over = TRUE;
6820 /* triple buffering */
6821 void *temp = lev.cave;
6822 lev.cave = lev.next;
6823 lev.next = lev.draw;
6832 unsigned int random;
6838 /* update variables */
6840 if (lev.score > 9999)
6843 if (lev.android_move_cnt-- == 0)
6844 lev.android_move_cnt = lev.android_move_time;
6845 if (lev.android_clone_cnt-- == 0)
6846 lev.android_clone_cnt = lev.android_clone_time;
6848 if (lev.ball_cnt-- == 0)
6849 lev.ball_cnt = lev.ball_time;
6852 if (lev.magnify_cnt)
6858 if (lev.wonderwall_time && lev.wonderwall_state)
6859 lev.wonderwall_time--;
6862 play_element_sound(lev.wheel_x, lev.wheel_y, SOUND_wheel, Xwheel);
6868 for (count = lev.amoeba_time; count--;)
6870 x = lev.left - 1 + (random >> 10) % (CAVE_WIDTH + 2);
6871 y = lev.top - 1 + (random >> 20) % (CAVE_HEIGHT + 2);
6873 if (x >= lev.left && x < lev.right &&
6874 y >= lev.top && y < lev.bottom)
6877 random = random * 129 + 1;
6882 /* handle explosions */
6884 for (y = lev.top; y < lev.bottom; y++)
6885 for (x = lev.left; x < lev.right; x++)
6888 /* triple buffering */
6890 for (y = lev.top; y < lev.bottom; y++)
6891 for (x = lev.left; x < lev.right; x++)
6892 next[x][y] = cave[x][y];