5 * my own version of the emerald mine engine
11 #define SPRING_ROLL /* spring rolling off round things continues to roll */
12 #define ACID_ROLL /* rolling objects go into acid rather than remove it */
14 #define USE_CHANGED_ACID_STUFF
16 #define RANDOM_RAW (seed = seed << 31 | seed >> 1)
17 #define RANDOM(x) (RANDOM_RAW & (x - 1))
19 static short **cave, **next, **boom;
20 static unsigned int seed;
23 static const byte is_blank[TILE_MAX] =
38 static const byte is_blank_or_acid[TILE_MAX] =
61 static const byte is_fake_acid[TILE_MAX] =
73 static const byte is_amoeba[TILE_MAX] =
87 static const byte is_android_walkable[TILE_MAX] =
103 static void Lboom_generic(int x, int y, int element, int element_middle)
105 boom[x-1][y-1] = element;
106 boom[x][y-1] = element;
107 boom[x+1][y-1] = element;
108 boom[x-1][y] = element;
109 boom[x][y] = element_middle;
110 boom[x+1][y] = element;
111 boom[x-1][y+1] = element;
112 boom[x][y+1] = element;
113 boom[x+1][y+1] = element;
116 static void Lboom_bug(int x, int y, int by_element)
118 next[x][y] = Znormal;
120 Lboom_generic(x, y, Xemerald, Xdiamond);
122 #if PLAY_ELEMENT_SOUND
123 play_element_sound(x, y, SOUND_boom, by_element);
127 static void Lboom_tank(int x, int y, int by_element)
129 next[x][y] = Znormal;
131 Lboom_generic(x, y, Xblank, Xblank);
133 #if PLAY_ELEMENT_SOUND
134 play_element_sound(x, y, SOUND_boom, by_element);
138 static void Lboom_eater(int x, int y, int by_element)
140 next[x][y] = Znormal;
142 boom[x-1][y-1] = lev.eater_array[lev.eater_pos][0];
143 boom[x][y-1] = lev.eater_array[lev.eater_pos][1];
144 boom[x+1][y-1] = lev.eater_array[lev.eater_pos][2];
145 boom[x-1][y] = lev.eater_array[lev.eater_pos][3];
146 boom[x][y] = lev.eater_array[lev.eater_pos][4];
147 boom[x+1][y] = lev.eater_array[lev.eater_pos][5];
148 boom[x-1][y+1] = lev.eater_array[lev.eater_pos][6];
149 boom[x][y+1] = lev.eater_array[lev.eater_pos][7];
150 boom[x+1][y+1] = lev.eater_array[lev.eater_pos][8];
152 lev.eater_pos = (lev.eater_pos + 1) & 7;
154 #if PLAY_ELEMENT_SOUND
155 play_element_sound(x, y, SOUND_boom, by_element);
159 static boolean player_killed(struct PLAYER *ply)
167 if (lev.killed_out_of_time && setup.time_limit)
170 switch (cave[x][y-1])
191 switch (cave[x+1][y])
212 switch (cave[x][y+1])
233 switch (cave[x-1][y])
278 static void kill_player(struct PLAYER *ply)
285 switch (cave[x][y-1])
295 cave[x][y-1] = Xboom_bug;
306 cave[x][y-1] = Xboom_bomb;
310 switch (cave[x+1][y])
320 cave[x+1][y] = Xboom_bug;
331 cave[x+1][y] = Xboom_bomb;
335 switch (cave[x][y+1])
345 cave[x][y+1] = Xboom_bug;
356 cave[x][y+1] = Xboom_bomb;
360 switch (cave[x-1][y])
370 cave[x-1][y] = Xboom_bug;
381 cave[x-1][y] = Xboom_bomb;
392 play_element_sound(x, y, SOUND_exit_leave, Xexit_1);
396 play_element_sound(x, y, SOUND_die, Zplayer);
402 #ifdef USE_CHANGED_ACID_STUFF
415 cave[x][y] = Xboom_1;
421 static boolean player_digfield(struct PLAYER *ply, int dx, int dy)
423 int anim = (dx < 0 ? 3 : dx > 0 ? 1 : dy < 0 ? 0 : dy > 0 ? 2 : 2);
428 boolean result = TRUE;
430 if (!dx && !dy) /* no direction specified */
433 if (dx && dy && ply->joy_snap) /* more than one direction specified */
436 if (ply->joy_snap == 0) /* player wants to move */
438 int element = cave[x][y];
442 /* fire is released */
446 cave[x][y] = Zplayer;
447 next[x][y] = Zplayer;
456 play_element_sound(x, y, SOUND_blank, Xblank);
457 ply->anim = PLY_walk_n + anim;
462 #ifdef USE_CHANGED_ACID_STUFF
471 if (cave[x+1][y-1] == Xblank)
472 cave[x+1][y-1] = Xsplash_e;
473 if (cave[x-1][y-1] == Xblank)
474 cave[x-1][y-1] = Xsplash_w;
475 play_element_sound(x, y, SOUND_acid, Xacid_1);
497 #ifndef USE_CHANGED_ACID_STUFF
507 ply->anim = PLY_walk_n + anim;
513 cave[x][y] = (dy ? (dy < 0 ? Ygrass_nB : Ygrass_sB) :
514 (dx > 0 ? Ygrass_eB : Ygrass_wB));
515 next[x][y] = Zplayer;
516 play_element_sound(x, y, SOUND_dirt, Xgrass);
517 ply->anim = PLY_walk_n + anim;
523 cave[x][y] = (dy ? (dy < 0 ? Ydirt_nB : Ydirt_sB) :
524 (dx > 0 ? Ydirt_eB : Ydirt_wB));
525 next[x][y] = Zplayer;
526 play_element_sound(x, y, SOUND_dirt, Xdirt);
527 ply->anim = PLY_walk_n + anim;
534 cave[x][y] = Ydiamond_blank;
535 next[x][y] = Zplayer;
536 play_element_sound(x, y, SOUND_collect, element);
537 lev.score += lev.diamond_score;
538 lev.gems_needed = lev.gems_needed < 3 ? 0 : lev.gems_needed - 3;
539 game.snapshot.collected_item = TRUE;
540 ply->anim = PLY_walk_n + anim;
547 cave[x][y] = Yemerald_blank;
548 next[x][y] = Zplayer;
549 play_element_sound(x, y, SOUND_collect, element);
550 lev.score += lev.emerald_score;
551 lev.gems_needed = lev.gems_needed < 1 ? 0 : lev.gems_needed - 1;
552 game.snapshot.collected_item = TRUE;
553 ply->anim = PLY_walk_n + anim;
559 cave[x][y] = Ydynamite_blank;
560 next[x][y] = Zplayer;
561 play_element_sound(x, y, SOUND_collect, element);
562 lev.score += lev.dynamite_score;
563 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
564 ply->anim = PLY_walk_n + anim;
571 cave[x][y] = Ykey_1_blank;
576 cave[x][y] = Ykey_2_blank;
581 cave[x][y] = Ykey_3_blank;
586 cave[x][y] = Ykey_4_blank;
591 cave[x][y] = Ykey_5_blank;
596 cave[x][y] = Ykey_6_blank;
601 cave[x][y] = Ykey_7_blank;
606 cave[x][y] = Ykey_8_blank;
611 next[x][y] = Zplayer;
612 play_element_sound(x, y, SOUND_collect, element);
613 lev.score += lev.key_score;
614 ply->anim = PLY_walk_n + anim;
620 cave[x][y] = Ylenses_blank;
621 next[x][y] = Zplayer;
622 play_element_sound(x, y, SOUND_collect, element);
623 lev.score += lev.lenses_score;
624 lev.lenses_cnt = lev.lenses_time;
625 ply->anim = PLY_walk_n + anim;
631 cave[x][y] = Ymagnify_blank;
632 next[x][y] = Zplayer;
633 play_element_sound(x, y, SOUND_collect, element);
634 lev.score += lev.magnify_score;
635 lev.magnify_cnt = lev.magnify_time;
636 ply->anim = PLY_walk_n + anim;
645 switch (cave[x+dx][y])
658 cave[x+dx][y] = dx > 0 ? Ystone_e : Ystone_w;
659 next[x+dx][y] = Xstone_pause;
670 if (cave[x+dx+1][y-1] == Xblank)
671 cave[x+dx+1][y-1] = Xsplash_e;
672 if (cave[x+dx-1][y-1] == Xblank)
673 cave[x+dx-1][y-1] = Xsplash_w;
674 play_element_sound(x, y, SOUND_acid, Xacid_1);
678 cave[x][y] = dx > 0 ? Ystone_eB : Ystone_wB;
679 next[x][y] = Zplayer;
680 play_element_sound(x, y, SOUND_roll, Xstone);
685 ply->anim = PLY_push_n + anim;
692 switch (cave[x+dx][y])
705 cave[x+dx][y] = dx > 0 ? Ybomb_e : Ybomb_w;
706 next[x+dx][y] = Xbomb_pause;
717 if (cave[x+dx+1][y-1] == Xblank)
718 cave[x+dx+1][y-1] = Xsplash_e;
719 if (cave[x+dx-1][y-1] == Xblank)
720 cave[x+dx-1][y-1] = Xsplash_w;
721 play_element_sound(x, y, SOUND_acid, Xacid_1);
725 cave[x][y] = dx > 0 ? Ybomb_eB : Ybomb_wB;
726 next[x][y] = Zplayer;
727 play_element_sound(x, y, SOUND_roll, Xbomb);
732 ply->anim = PLY_push_n + anim;
739 switch (cave[x+dx][y])
752 cave[x+dx][y] = dx > 0 ? Ynut_e : Ynut_w;
753 next[x+dx][y] = Xnut_pause;
764 if (cave[x+dx+1][y-1] == Xblank)
765 cave[x+dx+1][y-1] = Xsplash_e;
766 if (cave[x+dx-1][y-1] == Xblank)
767 cave[x+dx-1][y-1] = Xsplash_w;
768 play_element_sound(x, y, SOUND_acid, Xacid_1);
772 cave[x][y] = dx > 0 ? Ynut_eB : Ynut_wB;
773 next[x][y] = Zplayer;
774 play_element_sound(x, y, SOUND_roll, Xnut);
779 ply->anim = PLY_push_n + anim;
786 switch (cave[x+dx][y])
799 cave[x+dx][y] = dx > 0 ? Yspring_e : Yspring_w;
800 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
811 if (cave[x+dx+1][y-1] == Xblank)
812 cave[x+dx+1][y-1] = Xsplash_e;
813 if (cave[x+dx-1][y-1] == Xblank)
814 cave[x+dx-1][y-1] = Xsplash_w;
815 play_element_sound(x, y, SOUND_acid, Xacid_1);
819 cave[x][y] = dx > 0 ? Yspring_eB : Yspring_wB;
820 next[x][y] = Zplayer;
821 play_element_sound(x, y, SOUND_roll, Xspring);
827 cave[x][y] = dx > 0 ? Yspring_alien_eB : Yspring_alien_wB;
828 cave[x+dx][y] = dx > 0 ? Yspring_alien_e : Yspring_alien_w;
829 next[x][y] = Zplayer;
830 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
831 play_element_sound(x, y, SOUND_slurp, Xalien);
832 lev.score += lev.slurp_score;
837 ply->anim = PLY_push_n + anim;
844 case Xsand_stonein_1:
845 case Xsand_stonein_2:
846 case Xsand_stonein_3:
847 case Xsand_stonein_4:
851 ply->anim = PLY_push_n + anim;
855 switch (cave[x+dx][y+dy])
868 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yballoon_n : Yballoon_s) :
869 (dx > 0 ? Yballoon_e : Yballoon_w));
870 next[x+dx][y+dy] = Xballoon;
881 if (cave[x+dx+1][y+dy-1] == Xblank)
882 cave[x+dx+1][y+dy-1] = Xsplash_e;
883 if (cave[x+dx-1][y+dy-1] == Xblank)
884 cave[x+dx-1][y+dy-1] = Xsplash_w;
885 play_element_sound(x, y, SOUND_acid, Xacid_1);
889 cave[x][y] = (dy ? (dy < 0 ? Yballoon_nB : Yballoon_sB) :
890 (dx > 0 ? Yballoon_eB : Yballoon_wB));
891 next[x][y] = Zplayer;
892 play_element_sound(x, y, SOUND_push, Xballoon);
898 ply->anim = PLY_push_n + anim;
910 switch (cave[x+dx][y+dy])
923 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yandroid_n : Yandroid_s) :
924 (dx > 0 ? Yandroid_e : Yandroid_w));
925 next[x+dx][y+dy] = (dy ? (dy < 0 ? Xandroid_2_n : Xandroid_2_s) :
926 (dx > 0 ? Xandroid_2_e : Xandroid_2_w));
937 if (cave[x+dx+1][y+dy-1] == Xblank)
938 cave[x+dx+1][y+dy-1] = Xsplash_e;
939 if (cave[x+dx-1][y+dy-1] == Xblank)
940 cave[x+dx-1][y+dy-1] = Xsplash_w;
941 play_element_sound(x, y, SOUND_acid, Xacid_1);
945 cave[x][y] = (dy ? (dy < 0 ? Yandroid_nB : Yandroid_sB) :
946 (dx > 0 ? Yandroid_eB : Yandroid_wB));
947 next[x][y] = Zplayer;
948 play_element_sound(x, y, SOUND_push, Xandroid);
954 ply->anim = PLY_push_n + anim;
959 if (ply->keys & 0x01)
966 if (ply->keys & 0x02)
973 if (ply->keys & 0x04)
980 if (ply->keys & 0x08)
987 if (ply->keys & 0x10)
994 if (ply->keys & 0x20)
1001 if (ply->keys & 0x40)
1008 if (ply->keys & 0x80)
1015 if (!is_blank[cave[x+dx][y+dy]])
1018 if (!is_fake_acid[cave[x+dx][y+dy]])
1020 cave[x+dx][y+dy] = Zplayer;
1021 next[x+dx][y+dy] = Zplayer;
1024 play_element_sound(x, y, SOUND_door, element);
1025 ply->anim = PLY_walk_n + anim;
1031 play_element_sound(x, y, SOUND_press, element);
1032 lev.wheel_cnt = lev.wheel_time;
1038 lev.wind_direction = 0;
1042 lev.wind_direction = 1;
1046 lev.wind_direction = 2;
1050 lev.wind_direction = 3;
1054 lev.wind_direction = dy ? (dy < 0 ? 0 : 2) : (dx > 0 ? 1 : 3);
1059 play_element_sound(x, y, SOUND_press, element);
1060 lev.wind_cnt = lev.wind_time;
1064 play_element_sound(x, y, SOUND_press, element);
1069 play_element_sound(x, y, SOUND_press, element);
1070 lev.ball_cnt = lev.ball_time;
1071 lev.ball_state = !lev.ball_state;
1075 cave[x][y] = Yplant;
1076 next[x][y] = Xplant;
1077 play_element_sound(x, y, SOUND_blank, Xplant);
1078 ply->anim = PLY_walk_n + anim;
1089 game_em.level_solved = TRUE;
1091 ply->anim = PLY_walk_n + anim;
1098 if (ply->x == oldx && ply->y == oldy) /* no movement */
1101 else /* player wants to snap */
1103 int element = cave[x][y];
1107 /* fire is pressed */
1110 cave[x][y] = Ygrass_blank;
1111 next[x][y] = Xblank;
1112 play_element_sound(x, y, SOUND_dirt, element);
1113 ply->anim = PLY_shoot_n + anim;
1117 cave[x][y] = Ydirt_blank;
1118 next[x][y] = Xblank;
1119 play_element_sound(x, y, SOUND_dirt, element);
1120 ply->anim = PLY_shoot_n + anim;
1124 case Xdiamond_pause:
1125 cave[x][y] = Ydiamond_blank;
1126 next[x][y] = Xblank;
1127 play_element_sound(x, y, SOUND_collect, element);
1128 lev.score += lev.diamond_score;
1129 lev.gems_needed = lev.gems_needed < 3 ? 0 : lev.gems_needed - 3;
1130 game.snapshot.collected_item = TRUE;
1131 ply->anim = PLY_walk_n + anim;
1135 case Xemerald_pause:
1136 cave[x][y] = Yemerald_blank;
1137 next[x][y] = Xblank;
1138 play_element_sound(x, y, SOUND_collect, element);
1139 lev.score += lev.emerald_score;
1140 lev.gems_needed = lev.gems_needed < 1 ? 0 : lev.gems_needed - 1;
1141 game.snapshot.collected_item = TRUE;
1142 ply->anim = PLY_walk_n + anim;
1146 cave[x][y] = Ydynamite_blank;
1147 next[x][y] = Xblank;
1148 play_element_sound(x, y, SOUND_collect, element);
1149 lev.score += lev.dynamite_score;
1150 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
1151 ply->anim = PLY_walk_n + anim;
1156 cave[x][y] = Ykey_1_blank;
1161 cave[x][y] = Ykey_2_blank;
1166 cave[x][y] = Ykey_3_blank;
1171 cave[x][y] = Ykey_4_blank;
1176 cave[x][y] = Ykey_5_blank;
1181 cave[x][y] = Ykey_6_blank;
1186 cave[x][y] = Ykey_7_blank;
1191 cave[x][y] = Ykey_8_blank;
1196 next[x][y] = Xblank;
1197 play_element_sound(x, y, SOUND_collect, element);
1198 lev.score += lev.key_score;
1199 ply->anim = PLY_walk_n + anim;
1203 cave[x][y] = Ylenses_blank;
1204 next[x][y] = Xblank;
1205 play_element_sound(x, y, SOUND_collect, element);
1206 lev.score += lev.lenses_score;
1207 lev.lenses_cnt = lev.lenses_time;
1208 ply->anim = PLY_walk_n + anim;
1212 cave[x][y] = Ymagnify_blank;
1213 next[x][y] = Xblank;
1214 play_element_sound(x, y, SOUND_collect, element);
1215 lev.score += lev.magnify_score;
1216 lev.magnify_cnt = lev.magnify_time;
1217 ply->anim = PLY_walk_n + anim;
1228 static void check_player(struct PLAYER *ply)
1236 game_em.last_player_direction[ply->num] = MV_NONE;
1238 if (ply->joy_w) /* west */
1243 else if (ply->joy_e) /* east */
1249 if (ply->joy_n) /* north */
1254 else if (ply->joy_s) /* south */
1266 boolean players_visible_before_move;
1267 boolean players_visible_after_move;
1270 players_visible_before_move = checkIfAllPlayersFitToScreen();
1275 players_visible_after_move = checkIfAllPlayersFitToScreen();
1278 player is allowed to move only in the following cases:
1279 - it is not needed to display all players (not focussed to all players)
1280 - all players are (still or again) visible after the move
1281 - some players were already outside visible screen area before the move
1283 can_move = (game.centered_player_nr != -1 ||
1284 players_visible_after_move ||
1285 !players_visible_before_move);
1292 ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
1298 if (dx == 0 && dy == 0)
1304 if (++ply->dynamite_cnt == 5 && ply->dynamite)
1306 cave[x][y] = Xdynamite_1;
1307 play_element_sound(x, y, SOUND_dynamite, Xdynamite_1);
1313 ply->dynamite_cnt = 0;
1316 RandomEM += 7; /* be a bit more random if the player doesn't move */
1322 ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
1323 ply->dynamite_cnt = 0; /* reset dynamite timer if we move */
1324 ply->joy_spin = !ply->joy_spin;
1326 if (ply->joy_snap == 0) /* player wants to move */
1328 boolean moved = FALSE;
1330 if (ply->last_move_dir & MV_HORIZONTAL)
1332 if (!(moved = player_digfield(ply, 0, dy)))
1333 moved = player_digfield(ply, dx, 0);
1337 if (!(moved = player_digfield(ply, dx, 0)))
1338 moved = player_digfield(ply, 0, dy);
1344 ply->last_move_dir = (dx < 0 ? MV_LEFT : MV_RIGHT);
1345 else if (oldy != ply->y)
1346 ply->last_move_dir = (dy < 0 ? MV_UP : MV_DOWN);
1348 game_em.any_player_moving = TRUE;
1349 game_em.last_moving_player = ply->num;
1350 game_em.last_player_direction[ply->num] = ply->last_move_dir;
1353 else /* player wants to snap */
1355 game_em.any_player_snapping = player_digfield(ply, dx, dy);
1359 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
1361 int distance, distance_shortest = CAVE_WIDTH + CAVE_HEIGHT;
1364 /* default values if no players are alive anymore */
1368 for (i = 0; i < MAX_PLAYERS; i++)
1373 distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
1375 if (distance < distance_shortest)
1380 distance_shortest = distance;
1385 static void Lacid_1(int x, int y)
1387 next[x][y] = Xacid_2;
1390 static void Lacid_2(int x, int y)
1392 next[x][y] = Xacid_3;
1395 static void Lacid_3(int x, int y)
1397 next[x][y] = Xacid_4;
1400 static void Lacid_4(int x, int y)
1402 next[x][y] = Xacid_5;
1405 static void Lacid_5(int x, int y)
1407 next[x][y] = Xacid_6;
1410 static void Lacid_6(int x, int y)
1412 next[x][y] = Xacid_7;
1415 static void Lacid_7(int x, int y)
1417 next[x][y] = Xacid_8;
1420 static void Lacid_8(int x, int y)
1422 next[x][y] = Xacid_1;
1425 static void Lfake_acid_1(int x, int y)
1427 next[x][y] = Xfake_acid_2;
1430 static void Lfake_acid_2(int x, int y)
1432 next[x][y] = Xfake_acid_3;
1435 static void Lfake_acid_3(int x, int y)
1437 next[x][y] = Xfake_acid_4;
1440 static void Lfake_acid_4(int x, int y)
1442 next[x][y] = Xfake_acid_5;
1445 static void Lfake_acid_5(int x, int y)
1447 next[x][y] = Xfake_acid_6;
1450 static void Lfake_acid_6(int x, int y)
1452 next[x][y] = Xfake_acid_7;
1455 static void Lfake_acid_7(int x, int y)
1457 next[x][y] = Xfake_acid_8;
1460 static void Lfake_acid_8(int x, int y)
1462 next[x][y] = Xfake_acid_1;
1465 static void Landroid(int x, int y)
1469 if (lev.android_clone_cnt == 0)
1471 if (!is_blank[cave[x-1][y-1]] &&
1472 !is_blank[cave[x][y-1]] &&
1473 !is_blank[cave[x+1][y-1]] &&
1474 !is_blank[cave[x-1][y]] &&
1475 !is_blank[cave[x+1][y]] &&
1476 !is_blank[cave[x-1][y+1]] &&
1477 !is_blank[cave[x][y+1]] &&
1478 !is_blank[cave[x+1][y+1]])
1483 /* randomly find an object to clone */
1485 case 0: /* S,NE,W,NW,SE,E,SW,N */
1486 temp = lev.android_array[cave[x][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-1][y]]; if (temp != Xblank) break;
1489 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1490 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1491 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1492 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1493 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1496 case 1: /* NW,SE,N,S,NE,SW,E,W */
1497 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1498 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1499 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1500 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1501 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1502 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1503 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1504 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1507 case 2: /* SW,E,S,W,N,NW,SE,NE */
1508 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1509 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1510 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1511 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1512 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1513 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1514 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1515 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1518 case 3: /* N,SE,NE,E,W,S,NW,SW */
1519 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1520 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1521 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1522 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1523 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1524 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1525 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1526 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1529 case 4: /* SE,NW,E,NE,SW,W,N,S */
1530 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1531 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1532 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1533 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1534 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1535 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1536 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1537 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1540 case 5: /* NE,W,SE,SW,S,N,E,NW */
1541 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1542 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1543 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1544 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1545 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1546 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1547 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1548 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1551 case 6: /* E,N,SW,S,NW,NE,SE,W */
1552 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1553 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1554 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1555 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1556 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1557 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1558 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1559 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1562 case 7: /* W,SW,NW,N,E,SE,NE,S */
1563 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1564 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1565 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1566 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1567 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1568 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1569 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1570 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1574 next[x][y] = temp; /* the item we chose to clone */
1575 play_element_sound(x, y, SOUND_android_clone, temp);
1579 /* randomly find a direction to move */
1581 case 0: /* S,NE,W,NW,SE,E,SW,N */
1582 if (is_blank[cave[x][y+1]]) goto android_s;
1583 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1584 if (is_blank[cave[x-1][y]]) goto android_w;
1585 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1586 if (is_blank[cave[x+1][y+1]]) goto android_se;
1587 if (is_blank[cave[x+1][y]]) goto android_e;
1588 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1589 if (is_blank[cave[x][y-1]]) goto android_n;
1592 case 1: /* NW,SE,N,S,NE,SW,E,W */
1593 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1594 if (is_blank[cave[x+1][y+1]]) goto android_se;
1595 if (is_blank[cave[x][y-1]]) goto android_n;
1596 if (is_blank[cave[x][y+1]]) goto android_s;
1597 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1598 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1599 if (is_blank[cave[x+1][y]]) goto android_e;
1600 if (is_blank[cave[x-1][y]]) goto android_w;
1603 case 2: /* SW,E,S,W,N,NW,SE,NE */
1604 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1605 if (is_blank[cave[x+1][y]]) goto android_e;
1606 if (is_blank[cave[x][y+1]]) goto android_s;
1607 if (is_blank[cave[x-1][y]]) goto android_w;
1608 if (is_blank[cave[x][y-1]]) goto android_n;
1609 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1610 if (is_blank[cave[x+1][y+1]]) goto android_se;
1611 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1614 case 3: /* N,SE,NE,E,W,S,NW,SW */
1615 if (is_blank[cave[x][y-1]]) goto android_n;
1616 if (is_blank[cave[x+1][y+1]]) goto android_se;
1617 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1618 if (is_blank[cave[x+1][y]]) goto android_e;
1619 if (is_blank[cave[x-1][y]]) goto android_w;
1620 if (is_blank[cave[x][y+1]]) goto android_s;
1621 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1622 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1625 case 4: /* SE,NW,E,NE,SW,W,N,S */
1626 if (is_blank[cave[x+1][y+1]]) goto android_se;
1627 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1628 if (is_blank[cave[x+1][y]]) goto android_e;
1629 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1630 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1631 if (is_blank[cave[x-1][y]]) goto android_w;
1632 if (is_blank[cave[x][y-1]]) goto android_n;
1633 if (is_blank[cave[x][y+1]]) goto android_s;
1636 case 5: /* NE,W,SE,SW,S,N,E,NW */
1637 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1638 if (is_blank[cave[x-1][y]]) goto android_w;
1639 if (is_blank[cave[x+1][y+1]]) goto android_se;
1640 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1641 if (is_blank[cave[x][y+1]]) goto android_s;
1642 if (is_blank[cave[x][y-1]]) goto android_n;
1643 if (is_blank[cave[x+1][y]]) goto android_e;
1644 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1647 case 6: /* E,N,SW,S,NW,NE,SE,W */
1648 if (is_blank[cave[x+1][y]]) goto android_e;
1649 if (is_blank[cave[x][y-1]]) goto android_n;
1650 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1651 if (is_blank[cave[x][y+1]]) goto android_s;
1652 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1653 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1654 if (is_blank[cave[x+1][y+1]]) goto android_se;
1655 if (is_blank[cave[x-1][y]]) goto android_w;
1658 case 7: /* W,SW,NW,N,E,SE,NE,S */
1659 if (is_blank[cave[x-1][y]]) goto android_w;
1660 if (is_blank[cave[x-1][y+1]]) goto android_sw;
1661 if (is_blank[cave[x-1][y-1]]) goto android_nw;
1662 if (is_blank[cave[x][y-1]]) goto android_n;
1663 if (is_blank[cave[x+1][y]]) goto android_e;
1664 if (is_blank[cave[x+1][y+1]]) goto android_se;
1665 if (is_blank[cave[x+1][y-1]]) goto android_ne;
1666 if (is_blank[cave[x][y+1]]) goto android_s;
1672 if (lev.android_move_cnt == 0)
1674 if (cave[x-1][y-1] == Zplayer ||
1675 cave[x][y-1] == Zplayer ||
1676 cave[x+1][y-1] == Zplayer ||
1677 cave[x-1][y] == Zplayer ||
1678 cave[x+1][y] == Zplayer ||
1679 cave[x-1][y+1] == Zplayer ||
1680 cave[x][y+1] == Zplayer ||
1681 cave[x+1][y+1] == Zplayer)
1684 set_nearest_player_xy(x, y, &dx, &dy);
1686 next[x][y] = Xblank; /* assume we will move */
1687 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1693 /* attempt clockwise move first if direct path is blocked */
1695 case 0: /* north west */
1696 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1697 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1698 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1702 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1703 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1704 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1707 case 2: /* north east */
1708 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1709 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1710 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1714 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1715 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1716 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1719 case 4: /* nowhere */
1723 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1724 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1725 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1728 case 6: /* south west */
1729 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1730 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1731 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1735 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1736 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1737 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1740 case 8: /* south east */
1741 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1742 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1743 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1751 /* attempt counterclockwise move first if direct path is blocked */
1753 case 0: /* north west */
1754 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1755 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1756 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1760 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1761 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1762 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1765 case 2: /* north east */
1766 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1767 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1768 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1772 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1773 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1774 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1777 case 4: /* nowhere */
1781 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1782 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1783 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1786 case 6: /* south west */
1787 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1788 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1789 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1793 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1794 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1795 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1798 case 8: /* south east */
1799 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1800 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1801 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1808 next[x][y] = Xandroid;
1812 cave[x][y] = Yandroid_nB;
1813 cave[x][y-1] = Yandroid_n;
1814 next[x][y-1] = Xandroid;
1815 play_element_sound(x, y, SOUND_android_move, Xandroid);
1819 cave[x][y] = Yandroid_neB;
1820 cave[x+1][y-1] = Yandroid_ne;
1821 next[x+1][y-1] = Xandroid;
1822 play_element_sound(x, y, SOUND_android_move, Xandroid);
1826 cave[x][y] = Yandroid_eB;
1827 cave[x+1][y] = Yandroid_e;
1828 next[x+1][y] = Xandroid;
1829 play_element_sound(x, y, SOUND_android_move, Xandroid);
1833 cave[x][y] = Yandroid_seB;
1834 cave[x+1][y+1] = Yandroid_se;
1835 next[x+1][y+1] = Xandroid;
1836 play_element_sound(x, y, SOUND_android_move, Xandroid);
1840 cave[x][y] = Yandroid_sB;
1841 cave[x][y+1] = Yandroid_s;
1842 next[x][y+1] = Xandroid;
1843 play_element_sound(x, y, SOUND_android_move, Xandroid);
1847 cave[x][y] = Yandroid_swB;
1848 cave[x-1][y+1] = Yandroid_sw;
1849 next[x-1][y+1] = Xandroid;
1850 play_element_sound(x, y, SOUND_android_move, Xandroid);
1854 cave[x][y] = Yandroid_wB;
1855 cave[x-1][y] = Yandroid_w;
1856 next[x-1][y] = Xandroid;
1857 play_element_sound(x, y, SOUND_android_move, Xandroid);
1861 cave[x][y] = Yandroid_nwB;
1862 cave[x-1][y-1] = Yandroid_nw;
1863 next[x-1][y-1] = Xandroid;
1864 play_element_sound(x, y, SOUND_android_move, Xandroid);
1868 static void Landroid_1_n(int x, int y)
1870 switch (cave[x][y-1])
1883 cave[x][y] = Yandroid_nB;
1884 next[x][y] = Xblank;
1885 cave[x][y-1] = Yandroid_n;
1886 next[x][y-1] = Xandroid;
1887 play_element_sound(x, y, SOUND_android_move, Xandroid_1_n);
1898 cave[x][y] = Yandroid_nB;
1899 next[x][y] = Xblank;
1900 if (cave[x+1][y-2] == Xblank)
1901 cave[x+1][y-2] = Xsplash_e;
1902 if (cave[x-1][y-2] == Xblank)
1903 cave[x-1][y-2] = Xsplash_w;
1904 play_element_sound(x, y, SOUND_acid, Xacid_1);
1913 static void Landroid_2_n(int x, int y)
1915 switch (cave[x][y-1])
1928 cave[x][y] = Yandroid_nB;
1929 next[x][y] = Xblank;
1930 cave[x][y-1] = Yandroid_n;
1931 next[x][y-1] = Xandroid_1_n;
1932 play_element_sound(x, y, SOUND_android_move, Xandroid_2_n);
1943 cave[x][y] = Yandroid_nB;
1944 next[x][y] = Xblank;
1945 if (cave[x+1][y-2] == Xblank)
1946 cave[x+1][y-2] = Xsplash_e;
1947 if (cave[x-1][y-2] == Xblank)
1948 cave[x-1][y-2] = Xsplash_w;
1949 play_element_sound(x, y, SOUND_acid, Xacid_1);
1958 static void Landroid_1_e(int x, int y)
1960 switch (cave[x+1][y])
1973 cave[x][y] = Yandroid_eB;
1974 next[x][y] = Xblank;
1975 cave[x+1][y] = Yandroid_e;
1976 next[x+1][y] = Xandroid;
1977 play_element_sound(x, y, SOUND_android_move, Xandroid_1_e);
1988 cave[x][y] = Yandroid_eB;
1989 next[x][y] = Xblank;
1990 if (cave[x+2][y-1] == Xblank)
1991 cave[x+2][y-1] = Xsplash_e;
1992 if (cave[x][y-1] == Xblank)
1993 cave[x][y-1] = Xsplash_w;
1994 play_element_sound(x, y, SOUND_acid, Xacid_1);
2003 static void Landroid_2_e(int x, int y)
2005 switch (cave[x+1][y])
2018 cave[x][y] = Yandroid_eB;
2019 next[x][y] = Xblank;
2020 cave[x+1][y] = Yandroid_e;
2021 next[x+1][y] = Xandroid_1_e;
2022 play_element_sound(x, y, SOUND_android_move, Xandroid_2_e);
2033 cave[x][y] = Yandroid_eB;
2034 next[x][y] = Xblank;
2035 if (cave[x+2][y-1] == Xblank)
2036 cave[x+2][y-1] = Xsplash_e;
2037 if (cave[x][y-1] == Xblank)
2038 cave[x][y-1] = Xsplash_w;
2039 play_element_sound(x, y, SOUND_acid, Xacid_1);
2048 static void Landroid_1_s(int x, int y)
2050 switch (cave[x][y+1])
2063 cave[x][y] = Yandroid_sB;
2064 next[x][y] = Xblank;
2065 cave[x][y+1] = Yandroid_s;
2066 next[x][y+1] = Xandroid;
2067 play_element_sound(x, y, SOUND_android_move, Xandroid_1_s);
2078 cave[x][y] = Yandroid_sB;
2079 next[x][y] = Xblank;
2080 if (cave[x+1][y] == Xblank)
2081 cave[x+1][y] = Xsplash_e;
2082 if (cave[x-1][y] == Xblank)
2083 cave[x-1][y] = Xsplash_w;
2084 play_element_sound(x, y, SOUND_acid, Xacid_1);
2093 static void Landroid_2_s(int x, int y)
2095 switch (cave[x][y+1])
2108 cave[x][y] = Yandroid_sB;
2109 next[x][y] = Xblank;
2110 cave[x][y+1] = Yandroid_s;
2111 next[x][y+1] = Xandroid_1_s;
2112 play_element_sound(x, y, SOUND_android_move, Xandroid_2_s);
2123 cave[x][y] = Yandroid_sB;
2124 next[x][y] = Xblank;
2125 if (cave[x+1][y] == Xblank)
2126 cave[x+1][y] = Xsplash_e;
2127 if (cave[x-1][y] == Xblank)
2128 cave[x-1][y] = Xsplash_w;
2129 play_element_sound(x, y, SOUND_acid, Xacid_1);
2138 static void Landroid_1_w(int x, int y)
2140 switch (cave[x-1][y])
2153 cave[x][y] = Yandroid_wB;
2154 next[x][y] = Xblank;
2155 cave[x-1][y] = Yandroid_w;
2156 next[x-1][y] = Xandroid;
2157 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2168 cave[x][y] = Yandroid_wB;
2169 next[x][y] = Xblank;
2170 if (cave[x][y-1] == Xblank)
2171 cave[x][y-1] = Xsplash_e;
2172 if (cave[x-2][y-1] == Xblank)
2173 cave[x-2][y-1] = Xsplash_w;
2174 play_element_sound(x, y, SOUND_acid, Xacid_1);
2183 static void Landroid_2_w(int x, int y)
2185 switch (cave[x-1][y])
2198 cave[x][y] = Yandroid_wB;
2199 next[x][y] = Xblank;
2200 cave[x-1][y] = Yandroid_w;
2201 next[x-1][y] = Xandroid_1_w;
2202 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2213 cave[x][y] = Yandroid_wB;
2214 next[x][y] = Xblank;
2215 if (cave[x][y-1] == Xblank)
2216 cave[x][y-1] = Xsplash_e;
2217 if (cave[x-2][y-1] == Xblank)
2218 cave[x-2][y-1] = Xsplash_w;
2219 play_element_sound(x, y, SOUND_acid, Xacid_1);
2228 static void Leater_n(int x, int y)
2230 if (cave[x+1][y] == Xdiamond)
2232 cave[x+1][y] = Ydiamond_blank;
2233 next[x+1][y] = Xblank;
2234 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2238 if (cave[x][y+1] == Xdiamond)
2240 cave[x][y+1] = Ydiamond_blank;
2241 next[x][y+1] = Xblank;
2242 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2246 if (cave[x-1][y] == Xdiamond)
2248 cave[x-1][y] = Ydiamond_blank;
2249 next[x-1][y] = Xblank;
2250 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2254 if (cave[x][y-1] == Xdiamond)
2256 cave[x][y-1] = Ydiamond_blank;
2257 next[x][y-1] = Xblank;
2258 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2262 switch (cave[x][y-1])
2278 cave[x][y] = Yeater_nB;
2279 next[x][y] = Xblank;
2280 cave[x][y-1] = Yeater_n;
2281 next[x][y-1] = Xeater_n;
2292 cave[x][y] = Yeater_nB;
2293 next[x][y] = Xblank;
2294 if (cave[x+1][y-2] == Xblank)
2295 cave[x+1][y-2] = Xsplash_e;
2296 if (cave[x-1][y-2] == Xblank)
2297 cave[x-1][y-2] = Xsplash_w;
2298 play_element_sound(x, y, SOUND_acid, Xacid_1);
2302 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2303 play_element_sound(x, y, SOUND_eater, Xeater_n);
2308 static void Leater_e(int x, int y)
2310 if (cave[x][y+1] == Xdiamond)
2312 cave[x][y+1] = Ydiamond_blank;
2313 next[x][y+1] = Xblank;
2314 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2318 if (cave[x-1][y] == Xdiamond)
2320 cave[x-1][y] = Ydiamond_blank;
2321 next[x-1][y] = Xblank;
2322 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2326 if (cave[x][y-1] == Xdiamond)
2328 cave[x][y-1] = Ydiamond_blank;
2329 next[x][y-1] = Xblank;
2330 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2334 if (cave[x+1][y] == Xdiamond)
2336 cave[x+1][y] = Ydiamond_blank;
2337 next[x+1][y] = Xblank;
2338 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2342 switch (cave[x+1][y])
2358 cave[x][y] = Yeater_eB;
2359 next[x][y] = Xblank;
2360 cave[x+1][y] = Yeater_e;
2361 next[x+1][y] = Xeater_e;
2372 cave[x][y] = Yeater_eB;
2373 next[x][y] = Xblank;
2374 if (cave[x+2][y-1] == Xblank)
2375 cave[x+2][y-1] = Xsplash_e;
2376 if (cave[x][y-1] == Xblank)
2377 cave[x][y-1] = Xsplash_w;
2378 play_element_sound(x, y, SOUND_acid, Xacid_1);
2382 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2383 play_element_sound(x, y, SOUND_eater, Xeater_e);
2388 static void Leater_s(int x, int y)
2390 if (cave[x-1][y] == Xdiamond)
2392 cave[x-1][y] = Ydiamond_blank;
2393 next[x-1][y] = Xblank;
2394 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2398 if (cave[x][y-1] == Xdiamond)
2400 cave[x][y-1] = Ydiamond_blank;
2401 next[x][y-1] = Xblank;
2402 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2406 if (cave[x+1][y] == Xdiamond)
2408 cave[x+1][y] = Ydiamond_blank;
2409 next[x+1][y] = Xblank;
2410 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2414 if (cave[x][y+1] == Xdiamond)
2416 cave[x][y+1] = Ydiamond_blank;
2417 next[x][y+1] = Xblank;
2418 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2422 switch (cave[x][y+1])
2438 cave[x][y] = Yeater_sB;
2439 next[x][y] = Xblank;
2440 cave[x][y+1] = Yeater_s;
2441 next[x][y+1] = Xeater_s;
2452 cave[x][y] = Yeater_sB;
2453 next[x][y] = Xblank;
2454 if (cave[x+1][y] == Xblank)
2455 cave[x+1][y] = Xsplash_e;
2456 if (cave[x-1][y] == Xblank)
2457 cave[x-1][y] = Xsplash_w;
2458 play_element_sound(x, y, SOUND_acid, Xacid_1);
2462 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2463 play_element_sound(x, y, SOUND_eater, Xeater_s);
2468 static void Leater_w(int x, int y)
2470 if (cave[x][y-1] == Xdiamond)
2472 cave[x][y-1] = Ydiamond_blank;
2473 next[x][y-1] = Xblank;
2474 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2478 if (cave[x+1][y] == Xdiamond)
2480 cave[x+1][y] = Ydiamond_blank;
2481 next[x+1][y] = Xblank;
2482 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2486 if (cave[x][y+1] == Xdiamond)
2488 cave[x][y+1] = Ydiamond_blank;
2489 next[x][y+1] = Xblank;
2490 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2494 if (cave[x-1][y] == Xdiamond)
2496 cave[x-1][y] = Ydiamond_blank;
2497 next[x-1][y] = Xblank;
2498 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2502 switch (cave[x-1][y])
2518 cave[x][y] = Yeater_wB;
2519 next[x][y] = Xblank;
2520 cave[x-1][y] = Yeater_w;
2521 next[x-1][y] = Xeater_w;
2532 cave[x][y] = Yeater_wB;
2533 next[x][y] = Xblank;
2534 if (cave[x][y-1] == Xblank)
2535 cave[x][y-1] = Xsplash_e;
2536 if (cave[x-2][y-1] == Xblank)
2537 cave[x-2][y-1] = Xsplash_w;
2538 play_element_sound(x, y, SOUND_acid, Xacid_1);
2542 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2543 play_element_sound(x, y, SOUND_eater, Xeater_w);
2548 static void Lalien(int x, int y)
2559 set_nearest_player_xy(x, y, &dx, &dy);
2566 switch (cave[x][y-1])
2582 cave[x][y] = Yalien_nB;
2583 next[x][y] = Xblank;
2584 cave[x][y-1] = Yalien_n;
2585 next[x][y-1] = Xalien_pause;
2586 play_element_sound(x, y, SOUND_alien, Xalien);
2597 cave[x][y] = Yalien_nB;
2598 next[x][y] = Xblank;
2599 if (cave[x+1][y-2] == Xblank)
2600 cave[x+1][y-2] = Xsplash_e;
2601 if (cave[x-1][y-2] == Xblank)
2602 cave[x-1][y-2] = Xsplash_w;
2603 play_element_sound(x, y, SOUND_acid, Xacid_1);
2609 switch (cave[x][y+1])
2625 cave[x][y] = Yalien_sB;
2626 next[x][y] = Xblank;
2627 cave[x][y+1] = Yalien_s;
2628 next[x][y+1] = Xalien_pause;
2629 play_element_sound(x, y, SOUND_alien, Xalien);
2640 cave[x][y] = Yalien_sB;
2641 next[x][y] = Xblank;
2642 if (cave[x+1][y] == Xblank)
2643 cave[x+1][y] = Xsplash_e;
2644 if (cave[x-1][y] == Xblank)
2645 cave[x-1][y] = Xsplash_w;
2646 play_element_sound(x, y, SOUND_acid, Xacid_1);
2655 switch (cave[x+1][y])
2671 cave[x][y] = Yalien_eB;
2672 next[x][y] = Xblank;
2673 cave[x+1][y] = Yalien_e;
2674 next[x+1][y] = Xalien_pause;
2675 play_element_sound(x, y, SOUND_alien, Xalien);
2686 cave[x][y] = Yalien_eB;
2687 next[x][y] = Xblank;
2688 if (cave[x+2][y-1] == Xblank)
2689 cave[x+2][y-1] = Xsplash_e;
2690 if (cave[x][y-1] == Xblank)
2691 cave[x][y-1] = Xsplash_w;
2692 play_element_sound(x, y, SOUND_acid, Xacid_1);
2698 switch (cave[x-1][y])
2714 cave[x][y] = Yalien_wB;
2715 next[x][y] = Xblank;
2716 cave[x-1][y] = Yalien_w;
2717 next[x-1][y] = Xalien_pause;
2718 play_element_sound(x, y, SOUND_alien, Xalien);
2729 cave[x][y] = Yalien_wB;
2730 next[x][y] = Xblank;
2731 if (cave[x][y-1] == Xblank)
2732 cave[x][y-1] = Xsplash_e;
2733 if (cave[x-2][y-1] == Xblank)
2734 cave[x-2][y-1] = Xsplash_w;
2735 play_element_sound(x, y, SOUND_acid, Xacid_1);
2742 static void Lalien_pause(int x, int y)
2744 next[x][y] = Xalien;
2747 static void Lbug_n(int x, int y)
2749 switch (cave[x][y-1])
2765 cave[x][y] = Ybug_nB;
2766 next[x][y] = Xblank;
2767 cave[x][y-1] = Ybug_n;
2768 next[x][y-1] = Xbug_1_n;
2769 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2780 cave[x][y] = Ybug_nB;
2781 next[x][y] = Xblank;
2782 if (cave[x+1][y-2] == Xblank)
2783 cave[x+1][y-2] = Xsplash_e;
2784 if (cave[x-1][y-2] == Xblank)
2785 cave[x-1][y-2] = Xsplash_w;
2786 play_element_sound(x, y, SOUND_acid, Xacid_1);
2790 cave[x][y] = Ybug_n_w;
2791 next[x][y] = Xbug_2_w;
2792 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2797 static void Lbug_1_n(int x, int y)
2799 if (is_amoeba[cave[x][y-1]] ||
2800 is_amoeba[cave[x+1][y]] ||
2801 is_amoeba[cave[x][y+1]] ||
2802 is_amoeba[cave[x-1][y]])
2804 Lboom_bug(x, y, Xbug_1_n);
2809 switch (cave[x+1][y])
2833 cave[x][y] = Ybug_n_e;
2834 next[x][y] = Xbug_2_e;
2835 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2844 static void Lbug_2_n(int x, int y)
2846 if (is_amoeba[cave[x][y-1]] ||
2847 is_amoeba[cave[x+1][y]] ||
2848 is_amoeba[cave[x][y+1]] ||
2849 is_amoeba[cave[x-1][y]])
2851 Lboom_bug(x, y, Xbug_2_n);
2859 static void Lbug_e(int x, int y)
2861 switch (cave[x+1][y])
2877 cave[x][y] = Ybug_eB;
2878 next[x][y] = Xblank;
2879 cave[x+1][y] = Ybug_e;
2880 next[x+1][y] = Xbug_1_e;
2881 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2892 cave[x][y] = Ybug_eB;
2893 next[x][y] = Xblank;
2894 if (cave[x+2][y-1] == Xblank)
2895 cave[x+2][y-1] = Xsplash_e;
2896 if (cave[x][y-1] == Xblank)
2897 cave[x][y-1] = Xsplash_w;
2898 play_element_sound(x, y, SOUND_acid, Xacid_1);
2902 cave[x][y] = Ybug_e_n;
2903 next[x][y] = Xbug_2_n;
2904 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2909 static void Lbug_1_e(int x, int y)
2911 if (is_amoeba[cave[x][y-1]] ||
2912 is_amoeba[cave[x+1][y]] ||
2913 is_amoeba[cave[x][y+1]] ||
2914 is_amoeba[cave[x-1][y]])
2916 Lboom_bug(x, y, Xbug_1_e);
2921 switch (cave[x][y+1])
2945 cave[x][y] = Ybug_e_s;
2946 next[x][y] = Xbug_2_s;
2947 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2956 static void Lbug_2_e(int x, int y)
2958 if (is_amoeba[cave[x][y-1]] ||
2959 is_amoeba[cave[x+1][y]] ||
2960 is_amoeba[cave[x][y+1]] ||
2961 is_amoeba[cave[x-1][y]])
2963 Lboom_bug(x, y, Xbug_2_e);
2971 static void Lbug_s(int x, int y)
2973 switch (cave[x][y+1])
2989 cave[x][y] = Ybug_sB;
2990 next[x][y] = Xblank;
2991 cave[x][y+1] = Ybug_s;
2992 next[x][y+1] = Xbug_1_s;
2993 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3004 cave[x][y] = Ybug_sB;
3005 next[x][y] = Xblank;
3006 if (cave[x+1][y] == Xblank)
3007 cave[x+1][y] = Xsplash_e;
3008 if (cave[x-1][y] == Xblank)
3009 cave[x-1][y] = Xsplash_w;
3010 play_element_sound(x, y, SOUND_acid, Xacid_1);
3014 cave[x][y] = Ybug_s_e;
3015 next[x][y] = Xbug_2_e;
3016 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3021 static void Lbug_1_s(int x, int y)
3023 if (is_amoeba[cave[x][y-1]] ||
3024 is_amoeba[cave[x+1][y]] ||
3025 is_amoeba[cave[x][y+1]] ||
3026 is_amoeba[cave[x-1][y]])
3028 Lboom_bug(x, y, Xbug_1_s);
3033 switch (cave[x-1][y])
3057 cave[x][y] = Ybug_s_w;
3058 next[x][y] = Xbug_2_w;
3059 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3068 static void Lbug_2_s(int x, int y)
3070 if (is_amoeba[cave[x][y-1]] ||
3071 is_amoeba[cave[x+1][y]] ||
3072 is_amoeba[cave[x][y+1]] ||
3073 is_amoeba[cave[x-1][y]])
3075 Lboom_bug(x, y, Xbug_2_s);
3083 static void Lbug_w(int x, int y)
3085 switch (cave[x-1][y])
3101 cave[x][y] = Ybug_wB;
3102 next[x][y] = Xblank;
3103 cave[x-1][y] = Ybug_w;
3104 next[x-1][y] = Xbug_1_w;
3105 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3116 cave[x][y] = Ybug_wB;
3117 next[x][y] = Xblank;
3118 if (cave[x][y-1] == Xblank)
3119 cave[x][y-1] = Xsplash_e;
3120 if (cave[x-2][y-1] == Xblank)
3121 cave[x-2][y-1] = Xsplash_w;
3122 play_element_sound(x, y, SOUND_acid, Xacid_1);
3126 cave[x][y] = Ybug_w_s;
3127 next[x][y] = Xbug_2_s;
3128 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3133 static void Lbug_1_w(int x, int y)
3135 if (is_amoeba[cave[x][y-1]] ||
3136 is_amoeba[cave[x+1][y]] ||
3137 is_amoeba[cave[x][y+1]] ||
3138 is_amoeba[cave[x-1][y]])
3140 Lboom_bug(x, y, Xbug_1_w);
3145 switch (cave[x][y-1])
3169 cave[x][y] = Ybug_w_n;
3170 next[x][y] = Xbug_2_n;
3171 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3180 static void Lbug_2_w(int x, int y)
3182 if (is_amoeba[cave[x][y-1]] ||
3183 is_amoeba[cave[x+1][y]] ||
3184 is_amoeba[cave[x][y+1]] ||
3185 is_amoeba[cave[x-1][y]])
3187 Lboom_bug(x, y, Xbug_2_w);
3195 static void Ltank_n(int x, int y)
3197 switch (cave[x][y-1])
3213 cave[x][y] = Ytank_nB;
3214 next[x][y] = Xblank;
3215 cave[x][y-1] = Ytank_n;
3216 next[x][y-1] = Xtank_1_n;
3217 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3228 cave[x][y] = Ytank_nB;
3229 next[x][y] = Xblank;
3230 if (cave[x+1][y-2] == Xblank)
3231 cave[x+1][y-2] = Xsplash_e;
3232 if (cave[x-1][y-2] == Xblank)
3233 cave[x-1][y-2] = Xsplash_w;
3234 play_element_sound(x, y, SOUND_acid, Xacid_1);
3238 cave[x][y] = Ytank_n_e;
3239 next[x][y] = Xtank_2_e;
3240 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3245 static void Ltank_1_n(int x, int y)
3247 if (is_amoeba[cave[x][y-1]] ||
3248 is_amoeba[cave[x+1][y]] ||
3249 is_amoeba[cave[x][y+1]] ||
3250 is_amoeba[cave[x-1][y]])
3252 Lboom_tank(x, y, Xtank_1_n);
3257 switch (cave[x-1][y])
3281 cave[x][y] = Ytank_n_w;
3282 next[x][y] = Xtank_2_w;
3283 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3292 static void Ltank_2_n(int x, int y)
3294 if (is_amoeba[cave[x][y-1]] ||
3295 is_amoeba[cave[x+1][y]] ||
3296 is_amoeba[cave[x][y+1]] ||
3297 is_amoeba[cave[x-1][y]])
3299 Lboom_tank(x, y, Xtank_2_n);
3307 static void Ltank_e(int x, int y)
3309 switch (cave[x+1][y])
3325 cave[x][y] = Ytank_eB;
3326 next[x][y] = Xblank;
3327 cave[x+1][y] = Ytank_e;
3328 next[x+1][y] = Xtank_1_e;
3329 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3340 cave[x][y] = Ytank_eB;
3341 next[x][y] = Xblank;
3342 if (cave[x+2][y-1] == Xblank)
3343 cave[x+2][y-1] = Xsplash_e;
3344 if (cave[x][y-1] == Xblank)
3345 cave[x][y-1] = Xsplash_w;
3346 play_element_sound(x, y, SOUND_acid, Xacid_1);
3350 cave[x][y] = Ytank_e_s;
3351 next[x][y] = Xtank_2_s;
3352 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3357 static void Ltank_1_e(int x, int y)
3359 if (is_amoeba[cave[x][y-1]] ||
3360 is_amoeba[cave[x+1][y]] ||
3361 is_amoeba[cave[x][y+1]] ||
3362 is_amoeba[cave[x-1][y]])
3364 Lboom_tank(x, y, Xtank_1_e);
3369 switch (cave[x][y-1])
3393 cave[x][y] = Ytank_e_n;
3394 next[x][y] = Xtank_2_n;
3395 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3404 static void Ltank_2_e(int x, int y)
3406 if (is_amoeba[cave[x][y-1]] ||
3407 is_amoeba[cave[x+1][y]] ||
3408 is_amoeba[cave[x][y+1]] ||
3409 is_amoeba[cave[x-1][y]])
3411 Lboom_tank(x, y, Xtank_2_e);
3419 static void Ltank_s(int x, int y)
3421 switch (cave[x][y+1])
3437 cave[x][y] = Ytank_sB;
3438 next[x][y] = Xblank;
3439 cave[x][y+1] = Ytank_s;
3440 next[x][y+1] = Xtank_1_s;
3441 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3452 cave[x][y] = Ytank_sB;
3453 next[x][y] = Xblank;
3454 if (cave[x+1][y] == Xblank)
3455 cave[x+1][y] = Xsplash_e;
3456 if (cave[x-1][y] == Xblank)
3457 cave[x-1][y] = Xsplash_w;
3458 play_element_sound(x, y, SOUND_acid, Xacid_1);
3462 cave[x][y] = Ytank_s_w;
3463 next[x][y] = Xtank_2_w;
3464 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3469 static void Ltank_1_s(int x, int y)
3471 if (is_amoeba[cave[x][y-1]] ||
3472 is_amoeba[cave[x+1][y]] ||
3473 is_amoeba[cave[x][y+1]] ||
3474 is_amoeba[cave[x-1][y]])
3476 Lboom_tank(x, y, Xtank_1_s);
3481 switch (cave[x+1][y])
3505 cave[x][y] = Ytank_s_e;
3506 next[x][y] = Xtank_2_e;
3507 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3516 static void Ltank_2_s(int x, int y)
3518 if (is_amoeba[cave[x][y-1]] ||
3519 is_amoeba[cave[x+1][y]] ||
3520 is_amoeba[cave[x][y+1]] ||
3521 is_amoeba[cave[x-1][y]])
3523 Lboom_tank(x, y, Xtank_2_s);
3531 static void Ltank_w(int x, int y)
3533 switch (cave[x-1][y])
3549 cave[x][y] = Ytank_wB;
3550 next[x][y] = Xblank;
3551 cave[x-1][y] = Ytank_w;
3552 next[x-1][y] = Xtank_1_w;
3553 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3564 cave[x][y] = Ytank_wB;
3565 next[x][y] = Xblank;
3566 if (cave[x][y-1] == Xblank)
3567 cave[x][y-1] = Xsplash_e;
3568 if (cave[x-2][y-1] == Xblank)
3569 cave[x-2][y-1] = Xsplash_w;
3570 play_element_sound(x, y, SOUND_acid, Xacid_1);
3574 cave[x][y] = Ytank_w_n;
3575 next[x][y] = Xtank_2_n;
3576 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3581 static void Ltank_1_w(int x, int y)
3583 if (is_amoeba[cave[x][y-1]] ||
3584 is_amoeba[cave[x+1][y]] ||
3585 is_amoeba[cave[x][y+1]] ||
3586 is_amoeba[cave[x-1][y]])
3588 Lboom_tank(x, y, Xtank_1_w);
3593 switch (cave[x][y+1])
3617 cave[x][y] = Ytank_w_s;
3618 next[x][y] = Xtank_2_s;
3619 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3628 static void Ltank_2_w(int x, int y)
3630 if (is_amoeba[cave[x][y-1]] ||
3631 is_amoeba[cave[x+1][y]] ||
3632 is_amoeba[cave[x][y+1]] ||
3633 is_amoeba[cave[x-1][y]])
3635 Lboom_tank(x, y, Xtank_2_w);
3643 static void Lemerald(int x, int y)
3645 switch (cave[x][y+1])
3658 cave[x][y] = Yemerald_sB;
3659 next[x][y] = Xblank;
3660 cave[x][y+1] = Yemerald_s;
3661 next[x][y+1] = Xemerald_fall;
3672 cave[x][y] = Yemerald_sB;
3673 next[x][y] = Xblank;
3674 if (cave[x+1][y] == Xblank)
3675 cave[x+1][y] = Xsplash_e;
3676 if (cave[x-1][y] == Xblank)
3677 cave[x-1][y] = Xsplash_w;
3678 play_element_sound(x, y, SOUND_acid, Xacid_1);
3691 case Xemerald_pause:
3693 case Xdiamond_pause:
3737 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
3739 cave[x][y] = Yemerald_eB;
3740 next[x][y] = Xblank;
3741 cave[x+1][y] = Yemerald_e;
3742 next[x+1][y] = Xemerald_pause;
3743 if (cave[x][y+1] == Xbumper)
3744 cave[x][y+1] = Ybumper;
3748 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
3750 cave[x][y] = Yemerald_wB;
3751 next[x][y] = Xblank;
3752 cave[x-1][y] = Yemerald_w;
3753 next[x-1][y] = Xemerald_pause;
3754 if (cave[x][y+1] == Xbumper)
3755 cave[x][y+1] = Ybumper;
3761 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
3763 cave[x][y] = Yemerald_wB;
3764 next[x][y] = Xblank;
3765 cave[x-1][y] = Yemerald_w;
3766 next[x-1][y] = Xemerald_pause;
3767 if (cave[x][y+1] == Xbumper)
3768 cave[x][y+1] = Ybumper;
3772 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
3774 cave[x][y] = Yemerald_eB;
3775 next[x][y] = Xblank;
3776 cave[x+1][y] = Yemerald_e;
3777 next[x+1][y] = Xemerald_pause;
3778 if (cave[x][y+1] == Xbumper)
3779 cave[x][y+1] = Ybumper;
3785 if (++lev.shine_cnt > 50)
3787 lev.shine_cnt = RANDOM(8);
3788 cave[x][y] = Xemerald_shine;
3795 static void Lemerald_pause(int x, int y)
3797 switch (cave[x][y+1])
3810 cave[x][y] = Yemerald_sB;
3811 next[x][y] = Xblank;
3812 cave[x][y+1] = Yemerald_s;
3813 next[x][y+1] = Xemerald_fall;
3824 cave[x][y] = Yemerald_sB;
3825 next[x][y] = Xblank;
3826 if (cave[x+1][y] == Xblank)
3827 cave[x+1][y] = Xsplash_e;
3828 if (cave[x-1][y] == Xblank)
3829 cave[x-1][y] = Xsplash_w;
3830 play_element_sound(x, y, SOUND_acid, Xacid_1);
3834 cave[x][y] = Xemerald;
3835 next[x][y] = Xemerald;
3840 static void Lemerald_fall(int x, int y)
3842 switch (cave[x][y+1])
3856 cave[x][y] = Yemerald_sB;
3857 next[x][y] = Xblank;
3858 cave[x][y+1] = Yemerald_s;
3859 next[x][y+1] = Xemerald_fall;
3870 cave[x][y] = Yemerald_sB;
3871 next[x][y] = Xblank;
3872 if (cave[x+1][y] == Xblank)
3873 cave[x+1][y] = Xsplash_e;
3874 if (cave[x-1][y] == Xblank)
3875 cave[x-1][y] = Xsplash_w;
3876 play_element_sound(x, y, SOUND_acid, Xacid_1);
3880 if (lev.wonderwall_time)
3882 lev.wonderwall_state = 1;
3883 cave[x][y] = Yemerald_sB;
3884 next[x][y] = Xblank;
3885 if (is_blank[cave[x][y+2]])
3887 cave[x][y+2] = Ydiamond_s;
3888 next[x][y+2] = Xdiamond_fall;
3890 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
3895 cave[x][y] = Xemerald;
3896 next[x][y] = Xemerald;
3897 play_element_sound(x, y, SOUND_diamond, Xemerald);
3902 static void Ldiamond(int x, int y)
3904 switch (cave[x][y+1])
3917 cave[x][y] = Ydiamond_sB;
3918 next[x][y] = Xblank;
3919 cave[x][y+1] = Ydiamond_s;
3920 next[x][y+1] = Xdiamond_fall;
3931 cave[x][y] = Ydiamond_sB;
3932 next[x][y] = Xblank;
3933 if (cave[x+1][y] == Xblank)
3934 cave[x+1][y] = Xsplash_e;
3935 if (cave[x-1][y] == Xblank)
3936 cave[x-1][y] = Xsplash_w;
3937 play_element_sound(x, y, SOUND_acid, Xacid_1);
3950 case Xemerald_pause:
3952 case Xdiamond_pause:
3996 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
3998 cave[x][y] = Ydiamond_eB;
3999 next[x][y] = Xblank;
4000 cave[x+1][y] = Ydiamond_e;
4001 next[x+1][y] = Xdiamond_pause;
4002 if (cave[x][y+1] == Xbumper)
4003 cave[x][y+1] = Ybumper;
4007 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4009 cave[x][y] = Ydiamond_wB;
4010 next[x][y] = Xblank;
4011 cave[x-1][y] = Ydiamond_w;
4012 next[x-1][y] = Xdiamond_pause;
4013 if (cave[x][y+1] == Xbumper)
4014 cave[x][y+1] = Ybumper;
4020 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4022 cave[x][y] = Ydiamond_wB;
4023 next[x][y] = Xblank;
4024 cave[x-1][y] = Ydiamond_w;
4025 next[x-1][y] = Xdiamond_pause;
4026 if (cave[x][y+1] == Xbumper)
4027 cave[x][y+1] = Ybumper;
4031 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4033 cave[x][y] = Ydiamond_eB;
4034 next[x][y] = Xblank;
4035 cave[x+1][y] = Ydiamond_e;
4036 next[x+1][y] = Xdiamond_pause;
4037 if (cave[x][y+1] == Xbumper)
4038 cave[x][y+1] = Ybumper;
4044 if (++lev.shine_cnt > 50)
4046 lev.shine_cnt = RANDOM(8);
4047 cave[x][y] = Xdiamond_shine;
4054 static void Ldiamond_pause(int x, int y)
4056 switch (cave[x][y+1])
4069 cave[x][y] = Ydiamond_sB;
4070 next[x][y] = Xblank;
4071 cave[x][y+1] = Ydiamond_s;
4072 next[x][y+1] = Xdiamond_fall;
4083 cave[x][y] = Ydiamond_sB;
4084 next[x][y] = Xblank;
4085 if (cave[x+1][y] == Xblank)
4086 cave[x+1][y] = Xsplash_e;
4087 if (cave[x-1][y] == Xblank)
4088 cave[x-1][y] = Xsplash_w;
4089 play_element_sound(x, y, SOUND_acid, Xacid_1);
4093 cave[x][y] = Xdiamond;
4094 next[x][y] = Xdiamond;
4099 static void Ldiamond_fall(int x, int y)
4101 switch (cave[x][y+1])
4115 cave[x][y] = Ydiamond_sB;
4116 next[x][y] = Xblank;
4117 cave[x][y+1] = Ydiamond_s;
4118 next[x][y+1] = Xdiamond_fall;
4129 cave[x][y] = Ydiamond_sB;
4130 next[x][y] = Xblank;
4131 if (cave[x+1][y] == Xblank)
4132 cave[x+1][y] = Xsplash_e;
4133 if (cave[x-1][y] == Xblank)
4134 cave[x-1][y] = Xsplash_w;
4135 play_element_sound(x, y, SOUND_acid, Xacid_1);
4139 if (lev.wonderwall_time)
4141 lev.wonderwall_state = 1;
4142 cave[x][y] = Ydiamond_sB;
4143 next[x][y] = Xblank;
4144 if (is_blank[cave[x][y+2]])
4146 cave[x][y+2] = Ystone_s;
4147 next[x][y+2] = Xstone_fall;
4149 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4154 cave[x][y] = Xdiamond;
4155 next[x][y] = Xdiamond;
4156 play_element_sound(x, y, SOUND_diamond, Xdiamond);
4161 static void Lstone(int x, int y)
4163 switch (cave[x][y+1])
4178 cave[x][y] = Ystone_sB;
4179 next[x][y] = Xblank;
4180 cave[x][y+1] = Ystone_s;
4181 next[x][y+1] = Xstone_fall;
4192 cave[x][y] = Ystone_sB;
4193 next[x][y] = Xblank;
4194 if (cave[x+1][y] == Xblank)
4195 cave[x+1][y] = Xsplash_e;
4196 if (cave[x-1][y] == Xblank)
4197 cave[x-1][y] = Xsplash_w;
4198 play_element_sound(x, y, SOUND_acid, Xacid_1);
4202 cave[x][y] = Xsand_stonein_1;
4203 next[x][y] = Xsand_stonein_2;
4204 cave[x][y+1] = Xsand_sandstone_1;
4205 next[x][y+1] = Xsand_sandstone_2;
4218 case Xemerald_pause:
4220 case Xdiamond_pause:
4257 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4259 cave[x][y] = Ystone_eB;
4260 next[x][y] = Xblank;
4261 cave[x+1][y] = Ystone_e;
4262 next[x+1][y] = Xstone_pause;
4263 if (cave[x][y+1] == Xbumper)
4264 cave[x][y+1] = Ybumper;
4268 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4270 cave[x][y] = Ystone_wB;
4271 next[x][y] = Xblank;
4272 cave[x-1][y] = Ystone_w;
4273 next[x-1][y] = Xstone_pause;
4274 if (cave[x][y+1] == Xbumper)
4275 cave[x][y+1] = Ybumper;
4281 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4283 cave[x][y] = Ystone_wB;
4284 next[x][y] = Xblank;
4285 cave[x-1][y] = Ystone_w;
4286 next[x-1][y] = Xstone_pause;
4287 if (cave[x][y+1] == Xbumper)
4288 cave[x][y+1] = Ybumper;
4292 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4294 cave[x][y] = Ystone_eB;
4295 next[x][y] = Xblank;
4296 cave[x+1][y] = Ystone_e;
4297 next[x+1][y] = Xstone_pause;
4298 if (cave[x][y+1] == Xbumper)
4299 cave[x][y+1] = Ybumper;
4306 static void Lstone_pause(int x, int y)
4308 switch (cave[x][y+1])
4321 cave[x][y] = Ystone_sB;
4322 next[x][y] = Xblank;
4323 cave[x][y+1] = Ystone_s;
4324 next[x][y+1] = Xstone_fall;
4335 cave[x][y] = Ystone_sB;
4336 next[x][y] = Xblank;
4337 if (cave[x+1][y] == Xblank)
4338 cave[x+1][y] = Xsplash_e;
4339 if (cave[x-1][y] == Xblank)
4340 cave[x-1][y] = Xsplash_w;
4341 play_element_sound(x, y, SOUND_acid, Xacid_1);
4345 cave[x][y] = Xstone;
4346 next[x][y] = Xstone;
4351 static void Lstone_fall(int x, int y)
4353 switch (cave[x][y+1])
4367 cave[x][y] = Ystone_sB;
4368 next[x][y] = Xblank;
4369 cave[x][y+1] = Ystone_s;
4370 next[x][y+1] = Xstone_fall;
4381 cave[x][y] = Ystone_sB;
4382 next[x][y] = Xblank;
4383 if (cave[x+1][y] == Xblank)
4384 cave[x+1][y] = Xsplash_e;
4385 if (cave[x-1][y] == Xblank)
4386 cave[x-1][y] = Xsplash_w;
4387 play_element_sound(x, y, SOUND_acid, Xacid_1);
4394 cave[x][y] = Ystone_sB;
4395 cave[x][y+1] = Yeater_stone;
4396 Lboom_eater(x, y+1, Xstone_fall);
4397 score += lev.eater_score;
4402 cave[x][y] = Ystone_sB;
4403 cave[x][y+1] = Yalien_stone;
4404 Lboom_tank(x, y+1, Xstone_fall);
4405 score += lev.alien_score;
4416 cave[x][y] = Ystone_sB;
4417 cave[x][y+1] = Ybug_stone;
4418 Lboom_bug(x, y+1, Xstone_fall);
4419 score += lev.bug_score;
4430 cave[x][y] = Ystone_sB;
4431 cave[x][y+1] = Ytank_stone;
4432 Lboom_tank(x, y+1, Xstone_fall);
4433 score += lev.tank_score;
4437 case Xdiamond_pause:
4438 switch (cave[x][y+2])
4494 next[x][y] = Xstone;
4495 play_element_sound(x, y, SOUND_stone, Xstone);
4499 cave[x][y] = Ystone_sB;
4500 next[x][y] = Xblank;
4501 cave[x][y+1] = Ydiamond_stone;
4502 next[x][y+1] = Xstone_pause;
4503 play_element_sound(x, y, SOUND_squash, Xdiamond);
4508 cave[x][y+1] = Ybomb_blank;
4509 Lboom_tank(x, y+1, Xstone_fall);
4514 next[x][y] = Xstone;
4515 cave[x][y+1] = Ynut_stone;
4516 next[x][y+1] = Xemerald;
4517 play_element_sound(x, y, SOUND_crack, Xnut);
4518 score += lev.nut_score;
4524 switch (cave[x+1][y+1])
4539 cave[x][y+1] = Xspring_e;
4543 cave[x][y+1] = Xspring_w;
4549 switch (cave[x-1][y+1])
4564 cave[x][y+1] = Xspring_w;
4567 cave[x][y+1] = Xspring_e;
4572 next[x][y] = Xstone;
4576 if (lev.wonderwall_time)
4578 lev.wonderwall_state = 1;
4579 cave[x][y] = Ystone_sB;
4580 next[x][y] = Xblank;
4581 if (is_blank[cave[x][y+2]])
4583 cave[x][y+2] = Yemerald_s;
4584 next[x][y+2] = Xemerald_fall;
4586 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4591 cave[x][y] = Xstone;
4592 next[x][y] = Xstone;
4593 play_element_sound(x, y, SOUND_stone, Xstone);
4598 static void Lbomb(int x, int y)
4600 switch (cave[x][y+1])
4613 cave[x][y] = Ybomb_sB;
4614 next[x][y] = Xblank;
4615 cave[x][y+1] = Ybomb_s;
4616 next[x][y+1] = Xbomb_fall;
4627 cave[x][y] = Ybomb_sB;
4628 next[x][y] = Xblank;
4629 if (cave[x+1][y] == Xblank)
4630 cave[x+1][y] = Xsplash_e;
4631 if (cave[x-1][y] == Xblank)
4632 cave[x-1][y] = Xsplash_w;
4633 play_element_sound(x, y, SOUND_acid, Xacid_1);
4646 case Xemerald_pause:
4648 case Xdiamond_pause:
4683 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4685 cave[x][y] = Ybomb_eB;
4686 next[x][y] = Xblank;
4687 cave[x+1][y] = Ybomb_e;
4688 next[x+1][y] = Xbomb_pause;
4689 if (cave[x][y+1] == Xbumper)
4690 cave[x][y+1] = Ybumper;
4694 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4696 cave[x][y] = Ybomb_wB;
4697 next[x][y] = Xblank;
4698 cave[x-1][y] = Ybomb_w;
4699 next[x-1][y] = Xbomb_pause;
4700 if (cave[x][y+1] == Xbumper)
4701 cave[x][y+1] = Ybumper;
4707 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4709 cave[x][y] = Ybomb_wB;
4710 next[x][y] = Xblank;
4711 cave[x-1][y] = Ybomb_w;
4712 next[x-1][y] = Xbomb_pause;
4713 if (cave[x][y+1] == Xbumper)
4714 cave[x][y+1] = Ybumper;
4718 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4720 cave[x][y] = Ybomb_eB;
4721 next[x][y] = Xblank;
4722 cave[x+1][y] = Ybomb_e;
4723 next[x+1][y] = Xbomb_pause;
4724 if (cave[x][y+1] == Xbumper)
4725 cave[x][y+1] = Ybumper;
4732 static void Lbomb_pause(int x, int y)
4734 switch (cave[x][y+1])
4747 cave[x][y] = Ybomb_sB;
4748 next[x][y] = Xblank;
4749 cave[x][y+1] = Ybomb_s;
4750 next[x][y+1] = Xbomb_fall;
4761 cave[x][y] = Ybomb_sB;
4762 next[x][y] = Xblank;
4763 if (cave[x+1][y] == Xblank)
4764 cave[x+1][y] = Xsplash_e;
4765 if (cave[x-1][y] == Xblank)
4766 cave[x-1][y] = Xsplash_w;
4767 play_element_sound(x, y, SOUND_acid, Xacid_1);
4777 static void Lbomb_fall(int x, int y)
4779 switch (cave[x][y+1])
4792 cave[x][y] = Ybomb_sB;
4793 next[x][y] = Xblank;
4794 cave[x][y+1] = Ybomb_s;
4795 next[x][y+1] = Xbomb_fall;
4806 cave[x][y] = Ybomb_sB;
4807 next[x][y] = Xblank;
4808 if (cave[x+1][y] == Xblank)
4809 cave[x+1][y] = Xsplash_e;
4810 if (cave[x-1][y] == Xblank)
4811 cave[x-1][y] = Xsplash_w;
4812 play_element_sound(x, y, SOUND_acid, Xacid_1);
4816 cave[x][y] = Ybomb_blank;
4817 Lboom_tank(x, y, Xbomb_fall);
4822 static void Lnut(int x, int y)
4824 switch (cave[x][y+1])
4837 cave[x][y] = Ynut_sB;
4838 next[x][y] = Xblank;
4839 cave[x][y+1] = Ynut_s;
4840 next[x][y+1] = Xnut_fall;
4851 cave[x][y] = Ynut_sB;
4852 next[x][y] = Xblank;
4853 if (cave[x+1][y] == Xblank)
4854 cave[x+1][y] = Xsplash_e;
4855 if (cave[x-1][y] == Xblank)
4856 cave[x-1][y] = Xsplash_w;
4857 play_element_sound(x, y, SOUND_acid, Xacid_1);
4870 case Xemerald_pause:
4872 case Xdiamond_pause:
4907 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4909 cave[x][y] = Ynut_eB;
4910 next[x][y] = Xblank;
4911 cave[x+1][y] = Ynut_e;
4912 next[x+1][y] = Xnut_pause;
4913 if (cave[x][y+1] == Xbumper)
4914 cave[x][y+1] = Ybumper;
4918 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4920 cave[x][y] = Ynut_wB;
4921 next[x][y] = Xblank;
4922 cave[x-1][y] = Ynut_w;
4923 next[x-1][y] = Xnut_pause;
4924 if (cave[x][y+1] == Xbumper)
4925 cave[x][y+1] = Ybumper;
4931 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4933 cave[x][y] = Ynut_wB;
4934 next[x][y] = Xblank;
4935 cave[x-1][y] = Ynut_w;
4936 next[x-1][y] = Xnut_pause;
4937 if (cave[x][y+1] == Xbumper)
4938 cave[x][y+1] = Ybumper;
4942 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4944 cave[x][y] = Ynut_eB;
4945 next[x][y] = Xblank;
4946 cave[x+1][y] = Ynut_e;
4947 next[x+1][y] = Xnut_pause;
4948 if (cave[x][y+1] == Xbumper)
4949 cave[x][y+1] = Ybumper;
4956 static void Lnut_pause(int x, int y)
4958 switch (cave[x][y+1])
4971 cave[x][y] = Ynut_sB;
4972 next[x][y] = Xblank;
4973 cave[x][y+1] = Ynut_s;
4974 next[x][y+1] = Xnut_fall;
4985 cave[x][y] = Ynut_sB;
4986 next[x][y] = Xblank;
4987 if (cave[x+1][y] == Xblank)
4988 cave[x+1][y] = Xsplash_e;
4989 if (cave[x-1][y] == Xblank)
4990 cave[x-1][y] = Xsplash_w;
4991 play_element_sound(x, y, SOUND_acid, Xacid_1);
5001 static void Lnut_fall(int x, int y)
5003 switch (cave[x][y+1])
5017 cave[x][y] = Ynut_sB;
5018 next[x][y] = Xblank;
5019 cave[x][y+1] = Ynut_s;
5020 next[x][y+1] = Xnut_fall;
5031 cave[x][y] = Ynut_sB;
5032 next[x][y] = Xblank;
5033 if (cave[x+1][y] == Xblank)
5034 cave[x+1][y] = Xsplash_e;
5035 if (cave[x-1][y] == Xblank)
5036 cave[x-1][y] = Xsplash_w;
5037 play_element_sound(x, y, SOUND_acid, Xacid_1);
5043 play_element_sound(x, y, SOUND_nut, Xnut);
5048 static void Lspring(int x, int y)
5050 switch (cave[x][y+1])
5065 cave[x][y] = Yspring_sB;
5066 next[x][y] = Xblank;
5067 cave[x][y+1] = Yspring_s;
5068 next[x][y+1] = Xspring_fall;
5079 cave[x][y] = Yspring_sB;
5080 next[x][y] = Xblank;
5081 if (cave[x+1][y] == Xblank)
5082 cave[x+1][y] = Xsplash_e;
5083 if (cave[x-1][y] == Xblank)
5084 cave[x-1][y] = Xsplash_w;
5085 play_element_sound(x, y, SOUND_acid, Xacid_1);
5098 case Xemerald_pause:
5100 case Xdiamond_pause:
5135 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5137 cave[x][y] = Yspring_eB;
5138 next[x][y] = Xblank;
5139 cave[x+1][y] = Yspring_e;
5141 next[x+1][y] = Xspring_e;
5143 next[x+1][y] = Xspring_pause;
5145 if (cave[x][y+1] == Xbumper)
5146 cave[x][y+1] = Ybumper;
5150 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5152 cave[x][y] = Yspring_wB;
5153 next[x][y] = Xblank;
5154 cave[x-1][y] = Yspring_w;
5156 next[x-1][y] = Xspring_w;
5158 next[x-1][y] = Xspring_pause;
5160 if (cave[x][y+1] == Xbumper)
5161 cave[x][y+1] = Ybumper;
5167 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5169 cave[x][y] = Yspring_wB;
5170 next[x][y] = Xblank;
5171 cave[x-1][y] = Yspring_w;
5173 next[x-1][y] = Xspring_w;
5175 next[x-1][y] = Xspring_pause;
5177 if (cave[x][y+1] == Xbumper)
5178 cave[x][y+1] = Ybumper;
5182 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5184 cave[x][y] = Yspring_eB;
5185 next[x][y] = Xblank;
5186 cave[x+1][y] = Yspring_e;
5188 next[x+1][y] = Xspring_e;
5190 next[x+1][y] = Xspring_pause;
5192 if (cave[x][y+1] == Xbumper)
5193 cave[x][y+1] = Ybumper;
5200 static void Lspring_pause(int x, int y)
5202 switch (cave[x][y+1])
5215 cave[x][y] = Yspring_sB;
5216 next[x][y] = Xblank;
5217 cave[x][y+1] = Yspring_s;
5218 next[x][y+1] = Xspring_fall;
5229 cave[x][y] = Yspring_sB;
5230 next[x][y] = Xblank;
5231 if (cave[x+1][y] == Xblank)
5232 cave[x+1][y] = Xsplash_e;
5233 if (cave[x-1][y] == Xblank)
5234 cave[x-1][y] = Xsplash_w;
5235 play_element_sound(x, y, SOUND_acid, Xacid_1);
5239 cave[x][y] = Xspring;
5240 next[x][y] = Xspring;
5245 static void Lspring_e(int x, int y)
5247 switch (cave[x][y+1])
5260 cave[x][y] = Yspring_sB;
5261 next[x][y] = Xblank;
5262 cave[x][y+1] = Yspring_s;
5263 next[x][y+1] = Xspring_fall;
5274 cave[x][y] = Yspring_sB;
5275 next[x][y] = Xblank;
5276 if (cave[x+1][y] == Xblank)
5277 cave[x+1][y] = Xsplash_e;
5278 if (cave[x-1][y] == Xblank)
5279 cave[x-1][y] = Xsplash_w;
5280 play_element_sound(x, y, SOUND_acid, Xacid_1);
5284 cave[x][y+1] = Ybumper;
5287 switch (cave[x+1][y])
5304 cave[x][y] = Yspring_eB;
5305 next[x][y] = Xblank;
5306 cave[x+1][y] = Yspring_e;
5307 next[x+1][y] = Xspring_e;
5318 cave[x][y] = Yspring_eB;
5319 next[x][y] = Xblank;
5320 if (cave[x+2][y-1] == Xblank)
5321 cave[x+2][y-1] = Xsplash_e;
5322 if (cave[x][y-1] == Xblank)
5323 cave[x][y-1] = Xsplash_w;
5324 play_element_sound(x, y, SOUND_acid, Xacid_1);
5333 cave[x][y] = Yspring_alien_eB;
5334 next[x][y] = Xblank;
5335 cave[x+1][y] = Yspring_alien_e;
5336 next[x+1][y] = Xspring_e;
5337 play_element_sound(x, y, SOUND_slurp, Xalien);
5338 score += lev.slurp_score;
5343 cave[x+1][y] = Ybumper;
5344 next[x][y] = Xspring_w;
5345 play_element_sound(x, y, SOUND_spring, Xspring);
5349 cave[x][y] = Xspring;
5350 next[x][y] = Xspring;
5351 play_element_sound(x, y, SOUND_spring, Xspring);
5356 static void Lspring_w(int x, int y)
5358 switch (cave[x][y+1])
5371 cave[x][y] = Yspring_sB;
5372 next[x][y] = Xblank;
5373 cave[x][y+1] = Yspring_s;
5374 next[x][y+1] = Xspring_fall;
5385 cave[x][y] = Yspring_sB;
5386 next[x][y] = Xblank;
5387 if (cave[x+1][y] == Xblank)
5388 cave[x+1][y] = Xsplash_e;
5389 if (cave[x-1][y] == Xblank)
5390 cave[x-1][y] = Xsplash_w;
5391 play_element_sound(x, y, SOUND_acid, Xacid_1);
5395 cave[x][y+1] = Ybumper;
5398 switch (cave[x-1][y])
5415 cave[x][y] = Yspring_wB;
5416 next[x][y] = Xblank;
5417 cave[x-1][y] = Yspring_w;
5418 next[x-1][y] = Xspring_w;
5429 cave[x][y] = Yspring_wB;
5430 next[x][y] = Xblank;
5431 if (cave[x][y-1] == Xblank)
5432 cave[x][y-1] = Xsplash_e;
5433 if (cave[x-2][y-1] == Xblank)
5434 cave[x-2][y-1] = Xsplash_w;
5435 play_element_sound(x, y, SOUND_acid, Xacid_1);
5444 cave[x][y] = Yspring_alien_wB;
5445 next[x][y] = Xblank;
5446 cave[x-1][y] = Yspring_alien_w;
5447 next[x-1][y] = Xspring_w;
5448 play_element_sound(x, y, SOUND_slurp, Xalien);
5449 score += lev.slurp_score;
5454 cave[x-1][y] = Ybumper;
5455 next[x][y] = Xspring_e;
5456 play_element_sound(x, y, SOUND_spring, Xspring);
5460 cave[x][y] = Xspring;
5461 next[x][y] = Xspring;
5462 play_element_sound(x, y, SOUND_spring, Xspring);
5467 static void Lspring_fall(int x, int y)
5469 switch (cave[x][y+1])
5483 cave[x][y] = Yspring_sB;
5484 next[x][y] = Xblank;
5485 cave[x][y+1] = Yspring_s;
5486 next[x][y+1] = Xspring_fall;
5497 cave[x][y] = Yspring_sB;
5498 next[x][y] = Xblank;
5499 if (cave[x+1][y] == Xblank)
5500 cave[x+1][y] = Xsplash_e;
5501 if (cave[x-1][y] == Xblank)
5502 cave[x-1][y] = Xsplash_w;
5503 play_element_sound(x, y, SOUND_acid, Xacid_1);
5510 cave[x][y] = Yspring_sB;
5511 cave[x][y+1] = Yeater_spring;
5512 Lboom_eater(x, y+1, Xspring_fall);
5513 score += lev.eater_score;
5518 cave[x][y] = Yspring_sB;
5519 cave[x][y+1] = Yalien_spring;
5520 Lboom_tank(x, y+1, Xspring_fall);
5521 score += lev.alien_score;
5532 cave[x][y] = Yspring_sB;
5533 cave[x][y+1] = Ybug_spring;
5534 Lboom_bug(x, y+1, Xspring_fall);
5535 score += lev.bug_score;
5546 cave[x][y] = Yspring_sB;
5547 cave[x][y+1] = Ytank_spring;
5548 Lboom_tank(x, y+1, Xspring_fall);
5549 score += lev.tank_score;
5554 cave[x][y+1] = Ybomb_blank;
5555 Lboom_tank(x, y+1, Xspring_fall);
5559 cave[x][y] = Xspring;
5560 next[x][y] = Xspring;
5561 play_element_sound(x, y, SOUND_spring, Xspring);
5566 static void Lpush_emerald_e(int x, int y)
5568 switch (cave[x+1][y])
5578 cave[x][y] = Xemerald;
5579 next[x][y] = Xemerald;
5591 cave[x][y] = Yemerald_eB;
5592 next[x][y] = Xblank;
5593 if (cave[x+2][y-1] == Xblank)
5594 cave[x+2][y-1] = Xsplash_e;
5595 if (cave[x][y-1] == Xblank)
5596 cave[x][y-1] = Xsplash_w;
5597 play_element_sound(x, y, SOUND_acid, Xacid_1);
5602 cave[x][y] = Yemerald_eB;
5603 next[x][y] = Xblank;
5604 cave[x+1][y] = Yemerald_e;
5605 next[x+1][y] = Xemerald_pause;
5610 static void Lpush_emerald_w(int x, int y)
5612 switch (cave[x-1][y])
5622 cave[x][y] = Xemerald;
5623 next[x][y] = Xemerald;
5635 cave[x][y] = Yemerald_wB;
5636 next[x][y] = Xblank;
5637 if (cave[x][y-1] == Xblank)
5638 cave[x][y-1] = Xsplash_e;
5639 if (cave[x-2][y-1] == Xblank)
5640 cave[x-2][y-1] = Xsplash_w;
5641 play_element_sound(x, y, SOUND_acid, Xacid_1);
5646 cave[x][y] = Yemerald_wB;
5647 next[x][y] = Xblank;
5648 cave[x-1][y] = Yemerald_w;
5649 next[x-1][y] = Xemerald_pause;
5654 static void Lpush_diamond_e(int x, int y)
5656 switch (cave[x+1][y])
5666 cave[x][y] = Xdiamond;
5667 next[x][y] = Xdiamond;
5679 cave[x][y] = Ydiamond_eB;
5680 next[x][y] = Xblank;
5681 if (cave[x+2][y-1] == Xblank)
5682 cave[x+2][y-1] = Xsplash_e;
5683 if (cave[x][y-1] == Xblank)
5684 cave[x][y-1] = Xsplash_w;
5685 play_element_sound(x, y, SOUND_acid, Xacid_1);
5690 cave[x][y] = Ydiamond_eB;
5691 next[x][y] = Xblank;
5692 cave[x+1][y] = Ydiamond_e;
5693 next[x+1][y] = Xdiamond_pause;
5698 static void Lpush_diamond_w(int x, int y)
5700 switch (cave[x-1][y])
5710 cave[x][y] = Xdiamond;
5711 next[x][y] = Xdiamond;
5723 cave[x][y] = Ydiamond_wB;
5724 next[x][y] = Xblank;
5725 if (cave[x][y-1] == Xblank)
5726 cave[x][y-1] = Xsplash_e;
5727 if (cave[x-2][y-1] == Xblank)
5728 cave[x-2][y-1] = Xsplash_w;
5729 play_element_sound(x, y, SOUND_acid, Xacid_1);
5734 cave[x][y] = Ydiamond_wB;
5735 next[x][y] = Xblank;
5736 cave[x-1][y] = Ydiamond_w;
5737 next[x-1][y] = Xdiamond_pause;
5742 static void Lpush_stone_e(int x, int y)
5744 switch (cave[x+1][y])
5754 cave[x][y] = Xstone;
5755 next[x][y] = Xstone;
5767 cave[x][y] = Ystone_eB;
5768 next[x][y] = Xblank;
5769 if (cave[x+2][y-1] == Xblank)
5770 cave[x+2][y-1] = Xsplash_e;
5771 if (cave[x][y-1] == Xblank)
5772 cave[x][y-1] = Xsplash_w;
5773 play_element_sound(x, y, SOUND_acid, Xacid_1);
5778 cave[x][y] = Ystone_eB;
5779 next[x][y] = Xblank;
5780 cave[x+1][y] = Ystone_e;
5781 next[x+1][y] = Xstone_pause;
5786 static void Lpush_stone_w(int x, int y)
5788 switch (cave[x-1][y])
5798 cave[x][y] = Xstone;
5799 next[x][y] = Xstone;
5811 cave[x][y] = Ystone_wB;
5812 next[x][y] = Xblank;
5813 if (cave[x][y-1] == Xblank)
5814 cave[x][y-1] = Xsplash_e;
5815 if (cave[x-2][y-1] == Xblank)
5816 cave[x-2][y-1] = Xsplash_w;
5817 play_element_sound(x, y, SOUND_acid, Xacid_1);
5822 cave[x][y] = Ystone_wB;
5823 next[x][y] = Xblank;
5824 cave[x-1][y] = Ystone_w;
5825 next[x-1][y] = Xstone_pause;
5830 static void Lpush_bomb_e(int x, int y)
5832 switch (cave[x+1][y])
5855 cave[x][y] = Ybomb_eB;
5856 next[x][y] = Xblank;
5857 if (cave[x+2][y-1] == Xblank)
5858 cave[x+2][y-1] = Xsplash_e;
5859 if (cave[x][y-1] == Xblank)
5860 cave[x][y-1] = Xsplash_w;
5861 play_element_sound(x, y, SOUND_acid, Xacid_1);
5866 cave[x][y] = Ybomb_eB;
5867 next[x][y] = Xblank;
5868 cave[x+1][y] = Ybomb_e;
5869 next[x+1][y] = Xbomb_pause;
5874 static void Lpush_bomb_w(int x, int y)
5876 switch (cave[x-1][y])
5899 cave[x][y] = Ybomb_wB;
5900 next[x][y] = Xblank;
5901 if (cave[x][y-1] == Xblank)
5902 cave[x][y-1] = Xsplash_e;
5903 if (cave[x-2][y-1] == Xblank)
5904 cave[x-2][y-1] = Xsplash_w;
5905 play_element_sound(x, y, SOUND_acid, Xacid_1);
5910 cave[x][y] = Ybomb_wB;
5911 next[x][y] = Xblank;
5912 cave[x-1][y] = Ybomb_w;
5913 next[x-1][y] = Xbomb_pause;
5918 static void Lpush_nut_e(int x, int y)
5920 switch (cave[x+1][y])
5943 cave[x][y] = Ynut_eB;
5944 next[x][y] = Xblank;
5945 if (cave[x+2][y-1] == Xblank)
5946 cave[x+2][y-1] = Xsplash_e;
5947 if (cave[x][y-1] == Xblank)
5948 cave[x][y-1] = Xsplash_w;
5949 play_element_sound(x, y, SOUND_acid, Xacid_1);
5954 cave[x][y] = Ynut_eB;
5955 next[x][y] = Xblank;
5956 cave[x+1][y] = Ynut_e;
5957 next[x+1][y] = Xnut_pause;
5962 static void Lpush_nut_w(int x, int y)
5964 switch (cave[x-1][y])
5987 cave[x][y] = Ynut_wB;
5988 next[x][y] = Xblank;
5989 if (cave[x][y-1] == Xblank)
5990 cave[x][y-1] = Xsplash_e;
5991 if (cave[x-2][y-1] == Xblank)
5992 cave[x-2][y-1] = Xsplash_w;
5993 play_element_sound(x, y, SOUND_acid, Xacid_1);
5998 cave[x][y] = Ynut_wB;
5999 next[x][y] = Xblank;
6000 cave[x-1][y] = Ynut_w;
6001 next[x-1][y] = Xnut_pause;
6006 static void Lpush_spring_e(int x, int y)
6008 switch (cave[x+1][y])
6018 cave[x][y] = Xspring;
6019 next[x][y] = Xspring;
6031 cave[x][y] = Yspring_eB;
6032 next[x][y] = Xblank;
6033 if (cave[x+2][y-1] == Xblank)
6034 cave[x+2][y-1] = Xsplash_e;
6035 if (cave[x][y-1] == Xblank)
6036 cave[x][y-1] = Xsplash_w;
6037 play_element_sound(x, y, SOUND_acid, Xacid_1);
6042 cave[x][y] = Yspring_eB;
6043 next[x][y] = Xblank;
6044 cave[x+1][y] = Yspring_e;
6045 next[x+1][y] = Xspring_e;
6050 static void Lpush_spring_w(int x, int y)
6052 switch (cave[x-1][y])
6062 cave[x][y] = Xspring;
6063 next[x][y] = Xspring;
6075 cave[x][y] = Yspring_wB;
6076 next[x][y] = Xblank;
6077 if (cave[x][y-1] == Xblank)
6078 cave[x][y-1] = Xsplash_e;
6079 if (cave[x-2][y-1] == Xblank)
6080 cave[x-2][y-1] = Xsplash_w;
6081 play_element_sound(x, y, SOUND_acid, Xacid_1);
6086 cave[x][y] = Yspring_wB;
6087 next[x][y] = Xblank;
6088 cave[x-1][y] = Yspring_w;
6089 next[x-1][y] = Xspring_w;
6094 static void Ldynamite_1(int x, int y)
6096 play_element_sound(x, y, SOUND_tick, Xdynamite_1);
6097 next[x][y] = Xdynamite_2;
6100 static void Ldynamite_2(int x, int y)
6102 play_element_sound(x, y, SOUND_tick, Xdynamite_2);
6103 next[x][y] = Xdynamite_3;
6106 static void Ldynamite_3(int x, int y)
6108 play_element_sound(x, y, SOUND_tick, Xdynamite_3);
6109 next[x][y] = Xdynamite_4;
6112 static void Ldynamite_4(int x, int y)
6114 play_element_sound(x, y, SOUND_tick, Xdynamite_4);
6115 next[x][y] = Zdynamite;
6117 Lboom_generic(x, y, Xblank, Xblank);
6120 static void Lfake_door_1(int x, int y)
6122 if (lev.magnify_cnt)
6123 cave[x][y] = Xdoor_1;
6126 static void Lfake_door_2(int x, int y)
6128 if (lev.magnify_cnt)
6129 cave[x][y] = Xdoor_2;
6132 static void Lfake_door_3(int x, int y)
6134 if (lev.magnify_cnt)
6135 cave[x][y] = Xdoor_3;
6138 static void Lfake_door_4(int x, int y)
6140 if (lev.magnify_cnt)
6141 cave[x][y] = Xdoor_4;
6144 static void Lfake_door_5(int x, int y)
6146 if (lev.magnify_cnt)
6147 cave[x][y] = Xdoor_5;
6150 static void Lfake_door_6(int x, int y)
6152 if (lev.magnify_cnt)
6153 cave[x][y] = Xdoor_6;
6156 static void Lfake_door_7(int x, int y)
6158 if (lev.magnify_cnt)
6159 cave[x][y] = Xdoor_7;
6162 static void Lfake_door_8(int x, int y)
6164 if (lev.magnify_cnt)
6165 cave[x][y] = Xdoor_8;
6168 static void Lballoon(int x, int y)
6170 if (lev.wind_cnt == 0)
6173 switch (lev.wind_direction)
6176 switch (cave[x][y-1])
6189 cave[x][y] = Yballoon_nB;
6190 next[x][y] = Xblank;
6191 cave[x][y-1] = Yballoon_n;
6192 next[x][y-1] = Xballoon;
6203 cave[x][y] = Yballoon_nB;
6204 next[x][y] = Xblank;
6205 if (cave[x+1][y-2] == Xblank)
6206 cave[x+1][y-2] = Xsplash_e;
6207 if (cave[x-1][y-2] == Xblank)
6208 cave[x-1][y-2] = Xsplash_w;
6209 play_element_sound(x, y, SOUND_acid, Xacid_1);
6215 switch (cave[x+1][y])
6228 cave[x][y] = Yballoon_eB;
6229 next[x][y] = Xblank;
6230 cave[x+1][y] = Yballoon_e;
6231 next[x+1][y] = Xballoon;
6242 cave[x][y] = Yballoon_eB;
6243 next[x][y] = Xblank;
6244 if (cave[x+2][y-1] == Xblank)
6245 cave[x+2][y-1] = Xsplash_e;
6246 if (cave[x][y-1] == Xblank)
6247 cave[x][y-1] = Xsplash_w;
6248 play_element_sound(x, y, SOUND_acid, Xacid_1);
6254 switch (cave[x][y+1])
6267 cave[x][y] = Yballoon_sB;
6268 next[x][y] = Xblank;
6269 cave[x][y+1] = Yballoon_s;
6270 next[x][y+1] = Xballoon;
6281 cave[x][y] = Yballoon_sB;
6282 next[x][y] = Xblank;
6283 if (cave[x+1][y] == Xblank)
6284 cave[x+1][y] = Xsplash_e;
6285 if (cave[x-1][y] == Xblank)
6286 cave[x-1][y] = Xsplash_w;
6287 play_element_sound(x, y, SOUND_acid, Xacid_1);
6293 switch (cave[x-1][y])
6306 cave[x][y] = Yballoon_wB;
6307 next[x][y] = Xblank;
6308 cave[x-1][y] = Yballoon_w;
6309 next[x-1][y] = Xballoon;
6320 cave[x][y] = Yballoon_wB;
6321 next[x][y] = Xblank;
6322 if (cave[x][y-1] == Xblank)
6323 cave[x][y-1] = Xsplash_e;
6324 if (cave[x-2][y-1] == Xblank)
6325 cave[x-2][y-1] = Xsplash_w;
6326 play_element_sound(x, y, SOUND_acid, Xacid_1);
6333 static void Lball_common(int x, int y)
6335 play_element_sound(x, y, SOUND_ball, Xball_1);
6337 if (lev.ball_random)
6342 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6343 is_blank[cave[x-1][y-1]])
6345 cave[x-1][y-1] = Yball_blank;
6346 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6351 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6352 is_blank[cave[x][y-1]])
6354 cave[x][y-1] = Yball_blank;
6355 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6360 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6361 is_blank[cave[x+1][y-1]])
6363 cave[x+1][y-1] = Yball_blank;
6364 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6369 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6370 is_blank[cave[x-1][y]])
6372 cave[x-1][y] = Yball_blank;
6373 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6378 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6379 is_blank[cave[x+1][y]])
6381 cave[x+1][y] = Yball_blank;
6382 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6387 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6388 is_blank[cave[x-1][y+1]])
6390 cave[x-1][y+1] = Yball_blank;
6391 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6396 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6397 is_blank[cave[x][y+1]])
6399 cave[x][y+1] = Yball_blank;
6400 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6405 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6406 is_blank[cave[x+1][y+1]])
6408 cave[x+1][y+1] = Yball_blank;
6409 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6416 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6417 is_blank[cave[x-1][y-1]])
6419 cave[x-1][y-1] = Yball_blank;
6420 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6423 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6424 is_blank[cave[x][y-1]])
6426 cave[x][y-1] = Yball_blank;
6427 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6430 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6431 is_blank[cave[x+1][y-1]])
6433 cave[x+1][y-1] = Yball_blank;
6434 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6437 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6438 is_blank[cave[x-1][y]])
6440 cave[x-1][y] = Yball_blank;
6441 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6444 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6445 is_blank[cave[x+1][y]])
6447 cave[x+1][y] = Yball_blank;
6448 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6451 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6452 is_blank[cave[x-1][y+1]])
6454 cave[x-1][y+1] = Yball_blank;
6455 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6458 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6459 is_blank[cave[x][y+1]])
6461 cave[x][y+1] = Yball_blank;
6462 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6465 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6466 is_blank[cave[x+1][y+1]])
6468 cave[x+1][y+1] = Yball_blank;
6469 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6473 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
6476 static void Lball_1(int x, int y)
6478 if (lev.ball_state == 0)
6481 cave[x][y] = Yball_1;
6482 next[x][y] = Xball_2;
6489 static void Lball_2(int x, int y)
6491 if (lev.ball_state == 0)
6494 cave[x][y] = Yball_2;
6495 next[x][y] = Xball_1;
6502 static void Ldrip(int x, int y)
6504 next[x][y] = Xdrip_fall;
6507 static void Ldrip_fall(int x, int y)
6511 switch (cave[x][y+1])
6527 cave[x][y] = Ydrip_1_sB;
6528 next[x][y] = Xdrip_stretchB;
6529 cave[x][y+1] = Ydrip_1_s;
6530 next[x][y+1] = Xdrip_stretch;
6541 cave[x][y] = Ydrip_1_sB;
6542 next[x][y] = Xdrip_stretchB;
6543 if (cave[x+1][y] == Xblank)
6544 cave[x+1][y] = Xsplash_e;
6545 if (cave[x-1][y] == Xblank)
6546 cave[x-1][y] = Xsplash_w;
6547 play_element_sound(x, y, SOUND_acid, Xacid_1);
6553 case 0: temp = Xamoeba_1; break;
6554 case 1: temp = Xamoeba_2; break;
6555 case 2: temp = Xamoeba_3; break;
6556 case 3: temp = Xamoeba_4; break;
6557 case 4: temp = Xamoeba_5; break;
6558 case 5: temp = Xamoeba_6; break;
6559 case 6: temp = Xamoeba_7; break;
6560 case 7: temp = Xamoeba_8; break;
6565 play_element_sound(x, y, SOUND_drip, Xdrip_fall);
6570 static void Ldrip_stretch(int x, int y)
6572 cave[x][y] = Ydrip_2_s;
6573 next[x][y] = Xdrip_fall;
6576 static void Ldrip_stretchB(int x, int y)
6578 cave[x][y] = Ydrip_2_sB;
6579 next[x][y] = Xblank;
6582 static void Lwonderwall(int x, int y)
6584 if (lev.wonderwall_time && lev.wonderwall_state)
6586 cave[x][y] = Ywonderwall;
6587 play_element_sound(x, y, SOUND_wonder, Xwonderwall);
6591 static void Lwheel(int x, int y)
6593 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
6594 cave[x][y] = Ywheel;
6597 static void Lswitch(int x, int y)
6600 cave[x][y] = Yswitch;
6603 static void Lfake_blank(int x, int y)
6606 cave[x][y] = Yfake_blank;
6609 static void Lfake_grass(int x, int y)
6611 if (lev.magnify_cnt)
6612 cave[x][y] = Yfake_grass;
6615 static void Lfake_amoeba(int x, int y)
6618 cave[x][y] = Yfake_amoeba;
6621 static void Lsand_stone(int x, int y)
6623 switch (cave[x][y+1])
6636 cave[x][y] = Xsand_stonesand_quickout_1;
6637 next[x][y] = Xsand_stonesand_quickout_2;
6638 cave[x][y+1] = Xsand_stoneout_1;
6639 next[x][y+1] = Xsand_stoneout_2;
6650 cave[x][y] = Xsand_stonesand_quickout_1;
6651 next[x][y] = Xsand_stonesand_quickout_2;
6652 if (cave[x+1][y] == Xblank)
6653 cave[x+1][y] = Xsplash_e;
6654 if (cave[x-1][y] == Xblank)
6655 cave[x-1][y] = Xsplash_w;
6656 play_element_sound(x, y, SOUND_acid, Xacid_1);
6660 cave[x][y] = Xsand_stonesand_1;
6661 next[x][y] = Xsand_stonesand_2;
6662 cave[x][y+1] = Xsand_sandstone_1;
6663 next[x][y+1] = Xsand_sandstone_2;
6668 static void Lsand_stonein_1(int x, int y)
6670 next[x][y] = Xsand_stonein_2;
6673 static void Lsand_stonein_2(int x, int y)
6675 next[x][y] = Xsand_stonein_3;
6678 static void Lsand_stonein_3(int x, int y)
6680 next[x][y] = Xsand_stonein_4;
6683 static void Lsand_stonein_4(int x, int y)
6685 next[x][y] = Xblank;
6688 static void Lsand_sandstone_1(int x, int y)
6690 next[x][y] = Xsand_sandstone_2;
6693 static void Lsand_sandstone_2(int x, int y)
6695 next[x][y] = Xsand_sandstone_3;
6698 static void Lsand_sandstone_3(int x, int y)
6700 next[x][y] = Xsand_sandstone_4;
6703 static void Lsand_sandstone_4(int x, int y)
6705 next[x][y] = Xsand_stone;
6708 static void Lsand_stonesand_1(int x, int y)
6710 next[x][y] = Xsand_stonesand_2;
6713 static void Lsand_stonesand_2(int x, int y)
6715 next[x][y] = Xsand_stonesand_3;
6718 static void Lsand_stonesand_3(int x, int y)
6720 next[x][y] = Xsand_stonesand_4;
6723 static void Lsand_stonesand_4(int x, int y)
6728 static void Lsand_stoneout_1(int x, int y)
6730 next[x][y] = Xsand_stoneout_2;
6733 static void Lsand_stoneout_2(int x, int y)
6735 next[x][y] = Xstone_fall;
6738 static void Lsand_stonesand_quickout_1(int x, int y)
6740 next[x][y] = Xsand_stonesand_quickout_2;
6743 static void Lsand_stonesand_quickout_2(int x, int y)
6748 static void Lslide_ns(int x, int y)
6750 if (is_blank[cave[x][y-1]])
6752 cave[x][y-1] = Yslide_ns_blank;
6753 next[x][y-1] = Xslide_ns;
6754 play_element_sound(x, y, SOUND_slide, Xslide_ns);
6757 if (is_blank[cave[x][y+1]])
6759 cave[x][y+1] = Yslide_ns_blank;
6760 next[x][y+1] = Xslide_ns;
6761 play_element_sound(x, y, SOUND_slide, Xslide_ns);
6765 static void Lslide_ew(int x, int y)
6767 if (is_blank[cave[x+1][y]])
6769 cave[x+1][y] = Yslide_ew_blank;
6770 next[x+1][y] = Xslide_ew;
6771 play_element_sound(x, y, SOUND_slide, Xslide_ew);
6774 if (is_blank[cave[x-1][y]])
6776 cave[x-1][y] = Yslide_ew_blank;
6777 next[x-1][y] = Xslide_ew;
6778 play_element_sound(x, y, SOUND_slide, Xslide_ew);
6782 static void Lexit(int x, int y)
6784 if (lev.gems_needed > 0)
6787 switch (RANDOM(64) / 21)
6790 cave[x][y] = Xexit_1;
6791 next[x][y] = Xexit_2;
6795 cave[x][y] = Xexit_2;
6796 next[x][y] = Xexit_3;
6800 cave[x][y] = Xexit_3;
6801 next[x][y] = Xexit_1;
6805 play_element_sound(x, y, SOUND_exit_open, Xexit);
6808 static void Lexit_1(int x, int y)
6810 next[x][y] = Xexit_2;
6813 static void Lexit_2(int x, int y)
6815 next[x][y] = Xexit_3;
6818 static void Lexit_3(int x, int y)
6820 next[x][y] = Xexit_1;
6823 static void Lpause(int x, int y)
6825 next[x][y] = Xblank;
6828 static void Lamoeba(int x, int y)
6848 if (is_amoeba[cave[x][y-1]] ||
6849 is_amoeba[cave[x+1][y]] ||
6850 is_amoeba[cave[x][y+1]] ||
6851 is_amoeba[cave[x-1][y]])
6856 static void Lboom_one(int x, int y, boolean by_dynamite)
6913 cave[x][y] = Xboom_android;
6924 cave[x][y] = Xboom_bug;
6930 cave[x][y] = Xboom_bomb;
6934 cave[x][y] = Xboom_1;
6939 static void Lboom_nine(int x, int y, boolean by_dynamite)
6941 Lboom_one(x, y-1, by_dynamite);
6942 Lboom_one(x-1, y, by_dynamite);
6943 Lboom_one(x+1, y, by_dynamite);
6944 Lboom_one(x, y+1, by_dynamite);
6945 Lboom_one(x-1, y-1, by_dynamite);
6946 Lboom_one(x+1, y-1, by_dynamite);
6947 Lboom_one(x-1, y+1, by_dynamite);
6948 Lboom_one(x+1, y+1, by_dynamite);
6950 cave[x][y] = Xboom_1;
6953 static void Lexplode(int x, int y)
6958 Lboom_nine(x, y, FALSE);
6962 Lboom_nine(x, y, TRUE);
6967 static void Lboom_1(int x, int y)
6969 next[x][y] = Xboom_2;
6970 #if !PLAY_ELEMENT_SOUND
6971 if (x != lev.exit_x && y != lev.exit_y)
6972 play_sound(x, y, SOUND_boom);
6974 lev.exit_x = lev.exit_y = -1;
6978 static void Lboom_2(int x, int y)
6980 next[x][y] = boom[x][y];
6983 static void Lboom_android(int x, int y)
6985 #if PLAY_ELEMENT_SOUND
6986 play_element_sound(x, y, SOUND_boom, Xandroid);
6992 static void handle_tile(int x, int y)
6996 case Xacid_1: Lacid_1(x, y); break;
6997 case Xacid_2: Lacid_2(x, y); break;
6998 case Xacid_3: Lacid_3(x, y); break;
6999 case Xacid_4: Lacid_4(x, y); break;
7000 case Xacid_5: Lacid_5(x, y); break;
7001 case Xacid_6: Lacid_6(x, y); break;
7002 case Xacid_7: Lacid_7(x, y); break;
7003 case Xacid_8: Lacid_8(x, y); break;
7005 case Xfake_acid_1: Lfake_acid_1(x, y); break;
7006 case Xfake_acid_2: Lfake_acid_2(x, y); break;
7007 case Xfake_acid_3: Lfake_acid_3(x, y); break;
7008 case Xfake_acid_4: Lfake_acid_4(x, y); break;
7009 case Xfake_acid_5: Lfake_acid_5(x, y); break;
7010 case Xfake_acid_6: Lfake_acid_6(x, y); break;
7011 case Xfake_acid_7: Lfake_acid_7(x, y); break;
7012 case Xfake_acid_8: Lfake_acid_8(x, y); break;
7014 case Xandroid: Landroid(x, y); break;
7015 case Xandroid_1_n: Landroid_1_n(x, y); break;
7016 case Xandroid_2_n: Landroid_2_n(x, y); break;
7017 case Xandroid_1_e: Landroid_1_e(x, y); break;
7018 case Xandroid_2_e: Landroid_2_e(x, y); break;
7019 case Xandroid_1_s: Landroid_1_s(x, y); break;
7020 case Xandroid_2_s: Landroid_2_s(x, y); break;
7021 case Xandroid_1_w: Landroid_1_w(x, y); break;
7022 case Xandroid_2_w: Landroid_2_w(x, y); break;
7024 case Xeater_n: Leater_n(x, y); break;
7025 case Xeater_e: Leater_e(x, y); break;
7026 case Xeater_s: Leater_s(x, y); break;
7027 case Xeater_w: Leater_w(x, y); break;
7029 case Xalien: Lalien(x, y); break;
7030 case Xalien_pause: Lalien_pause(x, y); break;
7032 case Xbug_1_n: Lbug_1_n(x, y); break;
7033 case Xbug_2_n: Lbug_2_n(x, y); break;
7034 case Xbug_1_e: Lbug_1_e(x, y); break;
7035 case Xbug_2_e: Lbug_2_e(x, y); break;
7036 case Xbug_1_s: Lbug_1_s(x, y); break;
7037 case Xbug_2_s: Lbug_2_s(x, y); break;
7038 case Xbug_1_w: Lbug_1_w(x, y); break;
7039 case Xbug_2_w: Lbug_2_w(x, y); break;
7041 case Xtank_1_n: Ltank_1_n(x, y); break;
7042 case Xtank_2_n: Ltank_2_n(x, y); break;
7043 case Xtank_1_e: Ltank_1_e(x, y); break;
7044 case Xtank_2_e: Ltank_2_e(x, y); break;
7045 case Xtank_1_s: Ltank_1_s(x, y); break;
7046 case Xtank_2_s: Ltank_2_s(x, y); break;
7047 case Xtank_1_w: Ltank_1_w(x, y); break;
7048 case Xtank_2_w: Ltank_2_w(x, y); break;
7050 case Xemerald: Lemerald(x, y); break;
7051 case Xemerald_pause: Lemerald_pause(x, y); break;
7052 case Xemerald_fall: Lemerald_fall(x, y); break;
7054 case Xdiamond: Ldiamond(x, y); break;
7055 case Xdiamond_pause: Ldiamond_pause(x, y); break;
7056 case Xdiamond_fall: Ldiamond_fall(x, y); break;
7058 case Xstone: Lstone(x, y); break;
7059 case Xstone_pause: Lstone_pause(x, y); break;
7060 case Xstone_fall: Lstone_fall(x, y); break;
7062 case Xbomb: Lbomb(x, y); break;
7063 case Xbomb_pause: Lbomb_pause(x, y); break;
7064 case Xbomb_fall: Lbomb_fall(x, y); break;
7066 case Xnut: Lnut(x, y); break;
7067 case Xnut_pause: Lnut_pause(x, y); break;
7068 case Xnut_fall: Lnut_fall(x, y); break;
7070 case Xspring: Lspring(x, y); break;
7071 case Xspring_pause: Lspring_pause(x, y); break;
7072 case Xspring_e: Lspring_e(x, y); break;
7073 case Xspring_w: Lspring_w(x, y); break;
7074 case Xspring_fall: Lspring_fall(x, y); break;
7076 case Xpush_emerald_e: Lpush_emerald_e(x, y); break;
7077 case Xpush_emerald_w: Lpush_emerald_w(x, y); break;
7078 case Xpush_diamond_e: Lpush_diamond_e(x, y); break;
7079 case Xpush_diamond_w: Lpush_diamond_w(x, y); break;
7080 case Xpush_stone_e: Lpush_stone_e(x, y); break;
7081 case Xpush_stone_w: Lpush_stone_w(x, y); break;
7082 case Xpush_bomb_e: Lpush_bomb_e(x, y); break;
7083 case Xpush_bomb_w: Lpush_bomb_w(x, y); break;
7084 case Xpush_nut_e: Lpush_nut_e(x, y); break;
7085 case Xpush_nut_w: Lpush_nut_w(x, y); break;
7086 case Xpush_spring_e: Lpush_spring_e(x, y); break;
7087 case Xpush_spring_w: Lpush_spring_w(x, y); break;
7089 case Xdynamite_1: Ldynamite_1(x, y); break;
7090 case Xdynamite_2: Ldynamite_2(x, y); break;
7091 case Xdynamite_3: Ldynamite_3(x, y); break;
7092 case Xdynamite_4: Ldynamite_4(x, y); break;
7094 case Xfake_door_1: Lfake_door_1(x, y); break;
7095 case Xfake_door_2: Lfake_door_2(x, y); break;
7096 case Xfake_door_3: Lfake_door_3(x, y); break;
7097 case Xfake_door_4: Lfake_door_4(x, y); break;
7098 case Xfake_door_5: Lfake_door_5(x, y); break;
7099 case Xfake_door_6: Lfake_door_6(x, y); break;
7100 case Xfake_door_7: Lfake_door_7(x, y); break;
7101 case Xfake_door_8: Lfake_door_8(x, y); break;
7103 case Xballoon: Lballoon(x, y); break;
7105 case Xball_1: Lball_1(x, y); break;
7106 case Xball_2: Lball_2(x, y); break;
7108 case Xdrip: Ldrip(x, y); break;
7109 case Xdrip_fall: Ldrip_fall(x, y); break;
7110 case Xdrip_stretch: Ldrip_stretch(x, y); break;
7111 case Xdrip_stretchB: Ldrip_stretchB(x, y); break;
7113 case Xwonderwall: Lwonderwall(x, y); break;
7115 case Xwheel: Lwheel(x, y); break;
7117 case Xswitch: Lswitch(x, y); break;
7119 case Xfake_blank: Lfake_blank(x, y); break;
7120 case Xfake_grass: Lfake_grass(x, y); break;
7121 case Xfake_amoeba: Lfake_amoeba(x, y); break;
7123 case Xsand_stone: Lsand_stone(x, y); break;
7124 case Xsand_stonein_1: Lsand_stonein_1(x, y); break;
7125 case Xsand_stonein_2: Lsand_stonein_2(x, y); break;
7126 case Xsand_stonein_3: Lsand_stonein_3(x, y); break;
7127 case Xsand_stonein_4: Lsand_stonein_4(x, y); break;
7128 case Xsand_sandstone_1: Lsand_sandstone_1(x, y); break;
7129 case Xsand_sandstone_2: Lsand_sandstone_2(x, y); break;
7130 case Xsand_sandstone_3: Lsand_sandstone_3(x, y); break;
7131 case Xsand_sandstone_4: Lsand_sandstone_4(x, y); break;
7132 case Xsand_stonesand_1: Lsand_stonesand_1(x, y); break;
7133 case Xsand_stonesand_2: Lsand_stonesand_2(x, y); break;
7134 case Xsand_stonesand_3: Lsand_stonesand_3(x, y); break;
7135 case Xsand_stonesand_4: Lsand_stonesand_4(x, y); break;
7136 case Xsand_stoneout_1: Lsand_stoneout_1(x, y); break;
7137 case Xsand_stoneout_2: Lsand_stoneout_2(x, y); break;
7138 case Xsand_stonesand_quickout_1: Lsand_stonesand_quickout_1(x, y); break;
7139 case Xsand_stonesand_quickout_2: Lsand_stonesand_quickout_2(x, y); break;
7141 case Xslide_ns: Lslide_ns(x, y); break;
7142 case Xslide_ew: Lslide_ew(x, y); break;
7144 case Xexit: Lexit(x, y); break;
7145 case Xexit_1: Lexit_1(x, y); break;
7146 case Xexit_2: Lexit_2(x, y); break;
7147 case Xexit_3: Lexit_3(x, y); break;
7149 case Xpause: Lpause(x, y); break;
7151 case Xboom_bug: Lboom_bug(x, y, Xboom_bug); break;
7152 case Xboom_bomb: Lboom_tank(x, y, Xboom_bomb); break;
7153 case Xboom_android: Lboom_android(x, y); break;
7154 case Xboom_1: Lboom_1(x, y); break;
7155 case Xboom_2: Lboom_2(x, y); break;
7159 void logic_players(void)
7168 game_em.any_player_moving = FALSE;
7169 game_em.any_player_snapping = FALSE;
7171 /* must test for death and actually kill separately */
7172 for (i = 0; i < MAX_PLAYERS; i++)
7174 boolean ply_kill = player_killed(&ply[i]);
7176 if (ply[i].alive && ply_kill)
7177 kill_player(&ply[i]);
7180 for (i = 0; i < MAX_PLAYERS; i++)
7182 /* check for wrap-around movement */
7183 if (ply[i].x < lev.left ||
7184 ply[i].x > lev.right - 1)
7186 ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left);
7188 game.centered_player_nr_next = i;
7189 game.set_centered_player = TRUE;
7190 game.set_centered_player_fast = TRUE;
7193 ply[i].oldx = ply[i].x;
7194 ply[i].oldy = ply[i].y;
7195 ply[i].anim = PLY_still;
7198 start_check_nr = (RandomEM & 128 ? 0 : 1) * 2 + (RandomEM & 256 ? 0 : 1);
7200 for (i = 0; i < MAX_PLAYERS; i++)
7202 int check_nr = (start_check_nr + i) % MAX_PLAYERS;
7204 if (ply[check_nr].alive)
7205 check_player(&ply[check_nr]);
7208 for (i = 0; i < MAX_PLAYERS; i++)
7213 if (cave[ply[i].oldx][ply[i].oldy] == Zplayer)
7215 cave[ply[i].oldx][ply[i].oldy] = Xblank;
7216 next[ply[i].oldx][ply[i].oldy] = Xblank;
7219 if (cave[ply[i].x][ply[i].y] == Xblank)
7221 cave[ply[i].x][ply[i].y] = Zplayer;
7222 next[ply[i].x][ply[i].y] = Zplayer;
7227 void logic_objects(void)
7238 for (y = lev.top; y < lev.bottom; y++)
7239 for (x = lev.left; x < lev.right; x++)
7242 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
7243 lev.score += score; /* only add a score if someone is alive */
7245 game_em.game_over = TRUE;
7249 /* triple buffering */
7250 void *temp = lev.cave;
7251 lev.cave = lev.next;
7252 lev.next = lev.draw;
7256 void logic_globals(void)
7261 unsigned int random;
7267 /* update variables */
7269 if (lev.score > 9999)
7272 if (lev.android_move_cnt-- == 0)
7273 lev.android_move_cnt = lev.android_move_time;
7274 if (lev.android_clone_cnt-- == 0)
7275 lev.android_clone_cnt = lev.android_clone_time;
7277 if (lev.ball_cnt-- == 0)
7278 lev.ball_cnt = lev.ball_time;
7281 if (lev.magnify_cnt)
7287 if (lev.wonderwall_time && lev.wonderwall_state)
7288 lev.wonderwall_time--;
7291 play_element_sound(lev.wheel_x, lev.wheel_y, SOUND_wheel, Xwheel);
7297 for (count = lev.amoeba_time; count--;)
7299 x = lev.left - 1 + (random >> 10) % (CAVE_WIDTH + 2);
7300 y = lev.top - 1 + (random >> 20) % (CAVE_HEIGHT + 2);
7302 if (x >= lev.left && x < lev.right &&
7303 y >= lev.top && y < lev.bottom)
7306 random = random * 129 + 1;
7311 /* handle explosions */
7313 for (y = lev.top; y < lev.bottom; y++)
7314 for (x = lev.left; x < lev.right; x++)
7317 /* triple buffering */
7319 for (y = lev.top; y < lev.bottom; y++)
7320 for (x = lev.left; x < lev.right; x++)
7321 next[x][y] = cave[x][y];