5 * my own version of the emerald mine engine
11 #define SPRING_ROLL /* spring rolling off round things continues to roll */
12 #define USE_CHANGED_ACID_STUFF
14 #define RANDOM_RAW (seed = seed << 31 | seed >> 1)
15 #define RANDOM(x) (RANDOM_RAW & (x - 1))
17 static short **cave, **next, **boom;
18 static unsigned int seed;
21 static const byte is_blank[TILE_MAX] =
36 static const byte is_blank_or_acid[TILE_MAX] =
59 static const byte is_fake_acid[TILE_MAX] =
71 static const byte is_amoeba[TILE_MAX] =
85 static const byte is_android_walkable[TILE_MAX] =
101 static void Lboom_generic(int x, int y, int element, int element_middle)
103 boom[x-1][y-1] = element;
104 boom[x][y-1] = element;
105 boom[x+1][y-1] = element;
106 boom[x-1][y] = element;
107 boom[x][y] = element_middle;
108 boom[x+1][y] = element;
109 boom[x-1][y+1] = element;
110 boom[x][y+1] = element;
111 boom[x+1][y+1] = element;
114 static void Lboom_bug(int x, int y, int by_element)
116 next[x][y] = Znormal;
118 Lboom_generic(x, y, Xemerald, Xdiamond);
120 #if PLAY_ELEMENT_SOUND
121 play_element_sound(x, y, SOUND_boom, by_element);
125 static void Lboom_tank(int x, int y, int by_element)
127 next[x][y] = Znormal;
129 Lboom_generic(x, y, Xblank, Xblank);
131 #if PLAY_ELEMENT_SOUND
132 play_element_sound(x, y, SOUND_boom, by_element);
136 static void Lboom_eater(int x, int y, int by_element)
138 next[x][y] = Znormal;
140 boom[x-1][y-1] = lev.eater_array[lev.eater_pos][0];
141 boom[x][y-1] = lev.eater_array[lev.eater_pos][1];
142 boom[x+1][y-1] = lev.eater_array[lev.eater_pos][2];
143 boom[x-1][y] = lev.eater_array[lev.eater_pos][3];
144 boom[x][y] = lev.eater_array[lev.eater_pos][4];
145 boom[x+1][y] = lev.eater_array[lev.eater_pos][5];
146 boom[x-1][y+1] = lev.eater_array[lev.eater_pos][6];
147 boom[x][y+1] = lev.eater_array[lev.eater_pos][7];
148 boom[x+1][y+1] = lev.eater_array[lev.eater_pos][8];
150 lev.eater_pos = (lev.eater_pos + 1) & 7;
152 #if PLAY_ELEMENT_SOUND
153 play_element_sound(x, y, SOUND_boom, by_element);
157 static boolean player_killed(struct PLAYER *ply)
165 if (lev.killed_out_of_time && setup.time_limit)
168 switch (cave[x][y-1])
189 switch (cave[x+1][y])
210 switch (cave[x][y+1])
231 switch (cave[x-1][y])
276 static void kill_player(struct PLAYER *ply)
283 switch (cave[x][y-1])
293 cave[x][y-1] = Xboom_bug;
304 cave[x][y-1] = Xboom_bomb;
308 switch (cave[x+1][y])
318 cave[x+1][y] = Xboom_bug;
329 cave[x+1][y] = Xboom_bomb;
333 switch (cave[x][y+1])
343 cave[x][y+1] = Xboom_bug;
354 cave[x][y+1] = Xboom_bomb;
358 switch (cave[x-1][y])
368 cave[x-1][y] = Xboom_bug;
379 cave[x-1][y] = Xboom_bomb;
390 play_element_sound(x, y, SOUND_exit_leave, Xexit_1);
394 play_element_sound(x, y, SOUND_die, Zplayer);
400 #ifdef USE_CHANGED_ACID_STUFF
413 cave[x][y] = Xboom_1;
419 static boolean player_digfield(struct PLAYER *ply, int dx, int dy)
421 int anim = (dx < 0 ? 3 : dx > 0 ? 1 : dy < 0 ? 0 : dy > 0 ? 2 : 2);
426 boolean result = TRUE;
428 if (!dx && !dy) /* no direction specified */
431 if (dx && dy && ply->joy_snap) /* more than one direction specified */
434 if (ply->joy_snap == 0) /* player wants to move */
436 int element = cave[x][y];
440 /* fire is released */
444 cave[x][y] = Zplayer;
445 next[x][y] = Zplayer;
454 play_element_sound(x, y, SOUND_blank, Xblank);
455 ply->anim = PLY_walk_n + anim;
460 #ifdef USE_CHANGED_ACID_STUFF
469 if (cave[x+1][y-1] == Xblank)
470 cave[x+1][y-1] = Xsplash_e;
471 if (cave[x-1][y-1] == Xblank)
472 cave[x-1][y-1] = Xsplash_w;
473 play_element_sound(x, y, SOUND_acid, Xacid_1);
495 #ifndef USE_CHANGED_ACID_STUFF
505 ply->anim = PLY_walk_n + anim;
511 cave[x][y] = (dy ? (dy < 0 ? Ygrass_nB : Ygrass_sB) :
512 (dx > 0 ? Ygrass_eB : Ygrass_wB));
513 next[x][y] = Zplayer;
514 play_element_sound(x, y, SOUND_dirt, Xgrass);
515 ply->anim = PLY_walk_n + anim;
521 cave[x][y] = (dy ? (dy < 0 ? Ydirt_nB : Ydirt_sB) :
522 (dx > 0 ? Ydirt_eB : Ydirt_wB));
523 next[x][y] = Zplayer;
524 play_element_sound(x, y, SOUND_dirt, Xdirt);
525 ply->anim = PLY_walk_n + anim;
532 cave[x][y] = Ydiamond_blank;
533 next[x][y] = Zplayer;
534 play_element_sound(x, y, SOUND_collect, element);
535 lev.score += lev.diamond_score;
536 lev.required = lev.required < 3 ? 0 : lev.required - 3;
537 game.snapshot.collected_item = TRUE;
538 ply->anim = PLY_walk_n + anim;
545 cave[x][y] = Yemerald_blank;
546 next[x][y] = Zplayer;
547 play_element_sound(x, y, SOUND_collect, element);
548 lev.score += lev.emerald_score;
549 lev.required = lev.required < 1 ? 0 : lev.required - 1;
550 game.snapshot.collected_item = TRUE;
551 ply->anim = PLY_walk_n + anim;
557 cave[x][y] = Ydynamite_blank;
558 next[x][y] = Zplayer;
559 play_element_sound(x, y, SOUND_collect, element);
560 lev.score += lev.dynamite_score;
561 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
562 ply->anim = PLY_walk_n + anim;
569 cave[x][y] = Ykey_1_blank;
574 cave[x][y] = Ykey_2_blank;
579 cave[x][y] = Ykey_3_blank;
584 cave[x][y] = Ykey_4_blank;
589 cave[x][y] = Ykey_5_blank;
594 cave[x][y] = Ykey_6_blank;
599 cave[x][y] = Ykey_7_blank;
604 cave[x][y] = Ykey_8_blank;
609 next[x][y] = Zplayer;
610 play_element_sound(x, y, SOUND_collect, element);
611 lev.score += lev.key_score;
612 ply->anim = PLY_walk_n + anim;
618 cave[x][y] = Ylenses_blank;
619 next[x][y] = Zplayer;
620 play_element_sound(x, y, SOUND_collect, element);
621 lev.score += lev.lenses_score;
622 lev.lenses_cnt = lev.lenses_time;
623 ply->anim = PLY_walk_n + anim;
629 cave[x][y] = Ymagnify_blank;
630 next[x][y] = Zplayer;
631 play_element_sound(x, y, SOUND_collect, element);
632 lev.score += lev.magnify_score;
633 lev.magnify_cnt = lev.magnify_time;
634 ply->anim = PLY_walk_n + anim;
643 switch (cave[x+dx][y])
656 cave[x+dx][y] = dx > 0 ? Ystone_e : Ystone_w;
657 next[x+dx][y] = Xstone_pause;
668 if (cave[x+dx+1][y-1] == Xblank)
669 cave[x+dx+1][y-1] = Xsplash_e;
670 if (cave[x+dx-1][y-1] == Xblank)
671 cave[x+dx-1][y-1] = Xsplash_w;
672 play_element_sound(x, y, SOUND_acid, Xacid_1);
676 cave[x][y] = dx > 0 ? Ystone_eB : Ystone_wB;
677 next[x][y] = Zplayer;
678 play_element_sound(x, y, SOUND_roll, Xstone);
683 ply->anim = PLY_push_n + anim;
690 switch (cave[x+dx][y])
703 cave[x+dx][y] = dx > 0 ? Ybomb_e : Ybomb_w;
704 next[x+dx][y] = Xbomb_pause;
715 if (cave[x+dx+1][y-1] == Xblank)
716 cave[x+dx+1][y-1] = Xsplash_e;
717 if (cave[x+dx-1][y-1] == Xblank)
718 cave[x+dx-1][y-1] = Xsplash_w;
719 play_element_sound(x, y, SOUND_acid, Xacid_1);
723 cave[x][y] = dx > 0 ? Ybomb_eB : Ybomb_wB;
724 next[x][y] = Zplayer;
725 play_element_sound(x, y, SOUND_roll, Xbomb);
730 ply->anim = PLY_push_n + anim;
737 switch (cave[x+dx][y])
750 cave[x+dx][y] = dx > 0 ? Ynut_e : Ynut_w;
751 next[x+dx][y] = Xnut_pause;
762 if (cave[x+dx+1][y-1] == Xblank)
763 cave[x+dx+1][y-1] = Xsplash_e;
764 if (cave[x+dx-1][y-1] == Xblank)
765 cave[x+dx-1][y-1] = Xsplash_w;
766 play_element_sound(x, y, SOUND_acid, Xacid_1);
770 cave[x][y] = dx > 0 ? Ynut_eB : Ynut_wB;
771 next[x][y] = Zplayer;
772 play_element_sound(x, y, SOUND_roll, Xnut);
777 ply->anim = PLY_push_n + anim;
784 switch (cave[x+dx][y])
797 cave[x+dx][y] = dx > 0 ? Yspring_e : Yspring_w;
798 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
809 if (cave[x+dx+1][y-1] == Xblank)
810 cave[x+dx+1][y-1] = Xsplash_e;
811 if (cave[x+dx-1][y-1] == Xblank)
812 cave[x+dx-1][y-1] = Xsplash_w;
813 play_element_sound(x, y, SOUND_acid, Xacid_1);
817 cave[x][y] = dx > 0 ? Yspring_eB : Yspring_wB;
818 next[x][y] = Zplayer;
819 play_element_sound(x, y, SOUND_roll, Xspring);
825 cave[x][y] = dx > 0 ? Yspring_alien_eB : Yspring_alien_wB;
826 cave[x+dx][y] = dx > 0 ? Yspring_alien_e : Yspring_alien_w;
827 next[x][y] = Zplayer;
828 next[x+dx][y] = dx > 0 ? Xspring_e : Xspring_w;
829 play_element_sound(x, y, SOUND_slurp, Xalien);
830 lev.score += lev.slurp_score;
835 ply->anim = PLY_push_n + anim;
842 case Xsand_stonein_1:
843 case Xsand_stonein_2:
844 case Xsand_stonein_3:
845 case Xsand_stonein_4:
849 ply->anim = PLY_push_n + anim;
853 switch (cave[x+dx][y+dy])
866 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yballoon_n : Yballoon_s) :
867 (dx > 0 ? Yballoon_e : Yballoon_w));
868 next[x+dx][y+dy] = Xballoon;
879 if (cave[x+dx+1][y+dy-1] == Xblank)
880 cave[x+dx+1][y+dy-1] = Xsplash_e;
881 if (cave[x+dx-1][y+dy-1] == Xblank)
882 cave[x+dx-1][y+dy-1] = Xsplash_w;
883 play_element_sound(x, y, SOUND_acid, Xacid_1);
887 cave[x][y] = (dy ? (dy < 0 ? Yballoon_nB : Yballoon_sB) :
888 (dx > 0 ? Yballoon_eB : Yballoon_wB));
889 next[x][y] = Zplayer;
890 play_element_sound(x, y, SOUND_push, Xballoon);
896 ply->anim = PLY_push_n + anim;
908 switch (cave[x+dx][y+dy])
921 cave[x+dx][y+dy] = (dy ? (dy < 0 ? Yandroid_n : Yandroid_s) :
922 (dx > 0 ? Yandroid_e : Yandroid_w));
923 next[x+dx][y+dy] = (dy ? (dy < 0 ? Xandroid_2_n : Xandroid_2_s) :
924 (dx > 0 ? Xandroid_2_e : Xandroid_2_w));
935 if (cave[x+dx+1][y+dy-1] == Xblank)
936 cave[x+dx+1][y+dy-1] = Xsplash_e;
937 if (cave[x+dx-1][y+dy-1] == Xblank)
938 cave[x+dx-1][y+dy-1] = Xsplash_w;
939 play_element_sound(x, y, SOUND_acid, Xacid_1);
943 cave[x][y] = (dy ? (dy < 0 ? Yandroid_nB : Yandroid_sB) :
944 (dx > 0 ? Yandroid_eB : Yandroid_wB));
945 next[x][y] = Zplayer;
946 play_element_sound(x, y, SOUND_push, Xandroid);
952 ply->anim = PLY_push_n + anim;
957 if (ply->keys & 0x01)
964 if (ply->keys & 0x02)
971 if (ply->keys & 0x04)
978 if (ply->keys & 0x08)
985 if (ply->keys & 0x10)
992 if (ply->keys & 0x20)
999 if (ply->keys & 0x40)
1006 if (ply->keys & 0x80)
1013 if (!is_blank[cave[x+dx][y+dy]])
1016 if (!is_fake_acid[cave[x+dx][y+dy]])
1018 cave[x+dx][y+dy] = Zplayer;
1019 next[x+dx][y+dy] = Zplayer;
1022 play_element_sound(x, y, SOUND_door, element);
1023 ply->anim = PLY_walk_n + anim;
1029 play_element_sound(x, y, SOUND_press, element);
1030 lev.wheel_cnt = lev.wheel_time;
1036 lev.wind_direction = 0;
1040 lev.wind_direction = 1;
1044 lev.wind_direction = 2;
1048 lev.wind_direction = 3;
1052 lev.wind_direction = dy ? (dy < 0 ? 0 : 2) : (dx > 0 ? 1 : 3);
1057 play_element_sound(x, y, SOUND_press, element);
1058 lev.wind_cnt = lev.wind_time;
1062 play_element_sound(x, y, SOUND_press, element);
1067 play_element_sound(x, y, SOUND_press, element);
1068 lev.ball_cnt = lev.ball_time;
1069 lev.ball_state = !lev.ball_state;
1073 cave[x][y] = Yplant;
1074 next[x][y] = Xplant;
1075 play_element_sound(x, y, SOUND_blank, Xplant);
1076 ply->anim = PLY_walk_n + anim;
1087 game_em.level_solved = TRUE;
1089 ply->anim = PLY_walk_n + anim;
1096 if (ply->x == oldx && ply->y == oldy) /* no movement */
1099 else /* player wants to snap */
1101 int element = cave[x][y];
1105 /* fire is pressed */
1108 cave[x][y] = Ygrass_blank;
1109 next[x][y] = Xblank;
1110 play_element_sound(x, y, SOUND_dirt, element);
1111 ply->anim = PLY_shoot_n + anim;
1115 cave[x][y] = Ydirt_blank;
1116 next[x][y] = Xblank;
1117 play_element_sound(x, y, SOUND_dirt, element);
1118 ply->anim = PLY_shoot_n + anim;
1122 case Xdiamond_pause:
1123 cave[x][y] = Ydiamond_blank;
1124 next[x][y] = Xblank;
1125 play_element_sound(x, y, SOUND_collect, element);
1126 lev.score += lev.diamond_score;
1127 lev.required = lev.required < 3 ? 0 : lev.required - 3;
1128 game.snapshot.collected_item = TRUE;
1129 ply->anim = PLY_walk_n + anim;
1133 case Xemerald_pause:
1134 cave[x][y] = Yemerald_blank;
1135 next[x][y] = Xblank;
1136 play_element_sound(x, y, SOUND_collect, element);
1137 lev.score += lev.emerald_score;
1138 lev.required = lev.required < 1 ? 0 : lev.required - 1;
1139 game.snapshot.collected_item = TRUE;
1140 ply->anim = PLY_walk_n + anim;
1144 cave[x][y] = Ydynamite_blank;
1145 next[x][y] = Xblank;
1146 play_element_sound(x, y, SOUND_collect, element);
1147 lev.score += lev.dynamite_score;
1148 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
1149 ply->anim = PLY_walk_n + anim;
1154 cave[x][y] = Ykey_1_blank;
1159 cave[x][y] = Ykey_2_blank;
1164 cave[x][y] = Ykey_3_blank;
1169 cave[x][y] = Ykey_4_blank;
1174 cave[x][y] = Ykey_5_blank;
1179 cave[x][y] = Ykey_6_blank;
1184 cave[x][y] = Ykey_7_blank;
1189 cave[x][y] = Ykey_8_blank;
1194 next[x][y] = Xblank;
1195 play_element_sound(x, y, SOUND_collect, element);
1196 lev.score += lev.key_score;
1197 ply->anim = PLY_walk_n + anim;
1201 cave[x][y] = Ylenses_blank;
1202 next[x][y] = Xblank;
1203 play_element_sound(x, y, SOUND_collect, element);
1204 lev.score += lev.lenses_score;
1205 lev.lenses_cnt = lev.lenses_time;
1206 ply->anim = PLY_walk_n + anim;
1210 cave[x][y] = Ymagnify_blank;
1211 next[x][y] = Xblank;
1212 play_element_sound(x, y, SOUND_collect, element);
1213 lev.score += lev.magnify_score;
1214 lev.magnify_cnt = lev.magnify_time;
1215 ply->anim = PLY_walk_n + anim;
1226 static void check_player(struct PLAYER *ply)
1234 game_em.last_player_direction[ply->num] = MV_NONE;
1236 if (ply->joy_w) /* west */
1241 else if (ply->joy_e) /* east */
1247 if (ply->joy_n) /* north */
1252 else if (ply->joy_s) /* south */
1264 boolean players_visible_before_move;
1265 boolean players_visible_after_move;
1268 players_visible_before_move = checkIfAllPlayersFitToScreen();
1273 players_visible_after_move = checkIfAllPlayersFitToScreen();
1276 player is allowed to move only in the following cases:
1277 - it is not needed to display all players (not focussed to all players)
1278 - all players are (still or again) visible after the move
1279 - some players were already outside visible screen area before the move
1281 can_move = (game.centered_player_nr != -1 ||
1282 players_visible_after_move ||
1283 !players_visible_before_move);
1290 ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
1296 if (dx == 0 && dy == 0)
1302 if (++ply->dynamite_cnt == 5 && ply->dynamite)
1304 cave[x][y] = Xdynamite_1;
1305 play_element_sound(x, y, SOUND_dynamite, Xdynamite_1);
1311 ply->dynamite_cnt = 0;
1314 RandomEM += 7; /* be a bit more random if the player doesn't move */
1320 ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
1321 ply->dynamite_cnt = 0; /* reset dynamite timer if we move */
1322 ply->joy_spin = !ply->joy_spin;
1324 if (ply->joy_snap == 0) /* player wants to move */
1326 boolean moved = FALSE;
1328 if (ply->last_move_dir & MV_HORIZONTAL)
1330 if (!(moved = player_digfield(ply, 0, dy)))
1331 moved = player_digfield(ply, dx, 0);
1335 if (!(moved = player_digfield(ply, dx, 0)))
1336 moved = player_digfield(ply, 0, dy);
1342 ply->last_move_dir = (dx < 0 ? MV_LEFT : MV_RIGHT);
1343 else if (oldy != ply->y)
1344 ply->last_move_dir = (dy < 0 ? MV_UP : MV_DOWN);
1346 game_em.any_player_moving = TRUE;
1347 game_em.last_moving_player = ply->num;
1348 game_em.last_player_direction[ply->num] = ply->last_move_dir;
1351 else /* player wants to snap */
1353 game_em.any_player_snapping = player_digfield(ply, dx, dy);
1357 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
1359 int distance, distance_shortest = CAVE_WIDTH + CAVE_HEIGHT;
1362 /* default values if no players are alive anymore */
1366 for (i = 0; i < MAX_PLAYERS; i++)
1371 distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
1373 if (distance < distance_shortest)
1378 distance_shortest = distance;
1383 static void Lacid_1(int x, int y)
1385 next[x][y] = Xacid_2;
1388 static void Lacid_2(int x, int y)
1390 next[x][y] = Xacid_3;
1393 static void Lacid_3(int x, int y)
1395 next[x][y] = Xacid_4;
1398 static void Lacid_4(int x, int y)
1400 next[x][y] = Xacid_5;
1403 static void Lacid_5(int x, int y)
1405 next[x][y] = Xacid_6;
1408 static void Lacid_6(int x, int y)
1410 next[x][y] = Xacid_7;
1413 static void Lacid_7(int x, int y)
1415 next[x][y] = Xacid_8;
1418 static void Lacid_8(int x, int y)
1420 next[x][y] = Xacid_1;
1423 static void Lfake_acid_1(int x, int y)
1425 next[x][y] = Xfake_acid_2;
1428 static void Lfake_acid_2(int x, int y)
1430 next[x][y] = Xfake_acid_3;
1433 static void Lfake_acid_3(int x, int y)
1435 next[x][y] = Xfake_acid_4;
1438 static void Lfake_acid_4(int x, int y)
1440 next[x][y] = Xfake_acid_5;
1443 static void Lfake_acid_5(int x, int y)
1445 next[x][y] = Xfake_acid_6;
1448 static void Lfake_acid_6(int x, int y)
1450 next[x][y] = Xfake_acid_7;
1453 static void Lfake_acid_7(int x, int y)
1455 next[x][y] = Xfake_acid_8;
1458 static void Lfake_acid_8(int x, int y)
1460 next[x][y] = Xfake_acid_1;
1463 static void Landroid(int x, int y)
1467 if (lev.android_clone_cnt == 0)
1469 if (cave[x-1][y-1] != Xblank &&
1470 cave[x][y-1] != Xblank &&
1471 cave[x+1][y-1] != Xblank &&
1472 cave[x-1][y] != Xblank &&
1473 cave[x+1][y] != Xblank &&
1474 cave[x-1][y+1] != Xblank &&
1475 cave[x][y+1] != Xblank &&
1476 cave[x+1][y+1] != Xblank)
1481 /* randomly find an object to clone */
1483 case 0: /* S,NE,W,NW,SE,E,SW,N */
1484 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1485 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1486 temp = lev.android_array[cave[x-1][y]]; 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+1]]; if (temp != Xblank) break;
1489 temp = lev.android_array[cave[x+1][y]]; 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][y-1]]; if (temp != Xblank) break;
1494 case 1: /* NW,SE,N,S,NE,SW,E,W */
1495 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1496 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1497 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1498 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1499 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1500 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1501 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1502 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1505 case 2: /* SW,E,S,W,N,NW,SE,NE */
1506 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1507 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1508 temp = lev.android_array[cave[x][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-1]]; if (temp != Xblank) break;
1512 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1513 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1516 case 3: /* N,SE,NE,E,W,S,NW,SW */
1517 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1518 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1519 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1520 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1521 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1522 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1523 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1524 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1527 case 4: /* SE,NW,E,NE,SW,W,N,S */
1528 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1529 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1530 temp = lev.android_array[cave[x+1][y]]; 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+1]]; if (temp != Xblank) break;
1533 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1534 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1535 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1538 case 5: /* NE,W,SE,SW,S,N,E,NW */
1539 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1540 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1541 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1542 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1543 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1544 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1545 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1546 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1549 case 6: /* E,N,SW,S,NW,NE,SE,W */
1550 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1551 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1552 temp = lev.android_array[cave[x-1][y+1]]; 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+1][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]]; if (temp != Xblank) break;
1560 case 7: /* W,SW,NW,N,E,SE,NE,S */
1561 temp = lev.android_array[cave[x-1][y]]; if (temp != Xblank) break;
1562 temp = lev.android_array[cave[x-1][y+1]]; if (temp != Xblank) break;
1563 temp = lev.android_array[cave[x-1][y-1]]; if (temp != Xblank) break;
1564 temp = lev.android_array[cave[x][y-1]]; if (temp != Xblank) break;
1565 temp = lev.android_array[cave[x+1][y]]; if (temp != Xblank) break;
1566 temp = lev.android_array[cave[x+1][y+1]]; if (temp != Xblank) break;
1567 temp = lev.android_array[cave[x+1][y-1]]; if (temp != Xblank) break;
1568 temp = lev.android_array[cave[x][y+1]]; if (temp != Xblank) break;
1572 next[x][y] = temp; /* the item we chose to clone */
1573 play_element_sound(x, y, SOUND_android_clone, temp);
1577 /* randomly find a direction to move */
1579 case 0: /* S,NE,W,NW,SE,E,SW,N */
1580 if (cave[x][y+1] == Xblank) goto android_s;
1581 if (cave[x+1][y-1] == Xblank) goto android_ne;
1582 if (cave[x-1][y] == Xblank) goto android_w;
1583 if (cave[x-1][y-1] == Xblank) goto android_nw;
1584 if (cave[x+1][y+1] == Xblank) goto android_se;
1585 if (cave[x+1][y] == Xblank) goto android_e;
1586 if (cave[x-1][y+1] == Xblank) goto android_sw;
1587 if (cave[x][y-1] == Xblank) goto android_n;
1590 case 1: /* NW,SE,N,S,NE,SW,E,W */
1591 if (cave[x-1][y-1] == Xblank) goto android_nw;
1592 if (cave[x+1][y+1] == Xblank) goto android_se;
1593 if (cave[x][y-1] == Xblank) goto android_n;
1594 if (cave[x][y+1] == Xblank) goto android_s;
1595 if (cave[x+1][y-1] == Xblank) goto android_ne;
1596 if (cave[x-1][y+1] == Xblank) goto android_sw;
1597 if (cave[x+1][y] == Xblank) goto android_e;
1598 if (cave[x-1][y] == Xblank) goto android_w;
1601 case 2: /* SW,E,S,W,N,NW,SE,NE */
1602 if (cave[x-1][y+1] == Xblank) goto android_sw;
1603 if (cave[x+1][y] == Xblank) goto android_e;
1604 if (cave[x][y+1] == Xblank) goto android_s;
1605 if (cave[x-1][y] == Xblank) goto android_w;
1606 if (cave[x][y-1] == Xblank) goto android_n;
1607 if (cave[x-1][y-1] == Xblank) goto android_nw;
1608 if (cave[x+1][y+1] == Xblank) goto android_se;
1609 if (cave[x+1][y-1] == Xblank) goto android_ne;
1612 case 3: /* N,SE,NE,E,W,S,NW,SW */
1613 if (cave[x][y-1] == Xblank) goto android_n;
1614 if (cave[x+1][y+1] == Xblank) goto android_se;
1615 if (cave[x+1][y-1] == Xblank) goto android_ne;
1616 if (cave[x+1][y] == Xblank) goto android_e;
1617 if (cave[x-1][y] == Xblank) goto android_w;
1618 if (cave[x][y+1] == Xblank) goto android_s;
1619 if (cave[x-1][y-1] == Xblank) goto android_nw;
1620 if (cave[x-1][y+1] == Xblank) goto android_sw;
1623 case 4: /* SE,NW,E,NE,SW,W,N,S */
1624 if (cave[x+1][y+1] == Xblank) goto android_se;
1625 if (cave[x-1][y-1] == Xblank) goto android_nw;
1626 if (cave[x+1][y] == Xblank) goto android_e;
1627 if (cave[x+1][y-1] == Xblank) goto android_ne;
1628 if (cave[x-1][y+1] == Xblank) goto android_sw;
1629 if (cave[x-1][y] == Xblank) goto android_w;
1630 if (cave[x][y-1] == Xblank) goto android_n;
1631 if (cave[x][y+1] == Xblank) goto android_s;
1634 case 5: /* NE,W,SE,SW,S,N,E,NW */
1635 if (cave[x+1][y-1] == Xblank) goto android_ne;
1636 if (cave[x-1][y] == Xblank) goto android_w;
1637 if (cave[x+1][y+1] == Xblank) goto android_se;
1638 if (cave[x-1][y+1] == Xblank) goto android_sw;
1639 if (cave[x][y+1] == Xblank) goto android_s;
1640 if (cave[x][y-1] == Xblank) goto android_n;
1641 if (cave[x+1][y] == Xblank) goto android_e;
1642 if (cave[x-1][y-1] == Xblank) goto android_nw;
1645 case 6: /* E,N,SW,S,NW,NE,SE,W */
1646 if (cave[x+1][y] == Xblank) goto android_e;
1647 if (cave[x][y-1] == Xblank) goto android_n;
1648 if (cave[x-1][y+1] == Xblank) goto android_sw;
1649 if (cave[x][y+1] == Xblank) goto android_s;
1650 if (cave[x-1][y-1] == Xblank) goto android_nw;
1651 if (cave[x+1][y-1] == Xblank) goto android_ne;
1652 if (cave[x+1][y+1] == Xblank) goto android_se;
1653 if (cave[x-1][y] == Xblank) goto android_w;
1656 case 7: /* W,SW,NW,N,E,SE,NE,S */
1657 if (cave[x-1][y] == Xblank) goto android_w;
1658 if (cave[x-1][y+1] == Xblank) goto android_sw;
1659 if (cave[x-1][y-1] == Xblank) goto android_nw;
1660 if (cave[x][y-1] == Xblank) goto android_n;
1661 if (cave[x+1][y] == Xblank) goto android_e;
1662 if (cave[x+1][y+1] == Xblank) goto android_se;
1663 if (cave[x+1][y-1] == Xblank) goto android_ne;
1664 if (cave[x][y+1] == Xblank) goto android_s;
1670 if (lev.android_move_cnt == 0)
1672 if (cave[x-1][y-1] == Zplayer ||
1673 cave[x][y-1] == Zplayer ||
1674 cave[x+1][y-1] == Zplayer ||
1675 cave[x-1][y] == Zplayer ||
1676 cave[x+1][y] == Zplayer ||
1677 cave[x-1][y+1] == Zplayer ||
1678 cave[x][y+1] == Zplayer ||
1679 cave[x+1][y+1] == Zplayer)
1682 set_nearest_player_xy(x, y, &dx, &dy);
1684 next[x][y] = Xblank; /* assume we will move */
1685 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1691 /* attempt clockwise move first if direct path is blocked */
1693 case 0: /* north west */
1694 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1695 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1696 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1700 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1701 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1702 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1705 case 2: /* north east */
1706 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1707 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1708 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1712 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1713 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1714 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1717 case 4: /* nowhere */
1721 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1722 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1723 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1726 case 6: /* south west */
1727 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1728 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1729 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1733 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1734 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1735 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1738 case 8: /* south east */
1739 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1740 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1741 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1749 /* attempt counterclockwise move first if direct path is blocked */
1751 case 0: /* north west */
1752 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1753 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1754 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1758 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1759 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1760 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1763 case 2: /* north east */
1764 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1765 if (is_android_walkable[cave[x][y-1]]) goto android_n;
1766 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1770 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1771 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1772 if (is_android_walkable[cave[x-1][y-1]]) goto android_nw;
1775 case 4: /* nowhere */
1779 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1780 if (is_android_walkable[cave[x+1][y-1]]) goto android_ne;
1781 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1784 case 6: /* south west */
1785 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1786 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1787 if (is_android_walkable[cave[x-1][y]]) goto android_w;
1791 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1792 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1793 if (is_android_walkable[cave[x-1][y+1]]) goto android_sw;
1796 case 8: /* south east */
1797 if (is_android_walkable[cave[x+1][y+1]]) goto android_se;
1798 if (is_android_walkable[cave[x+1][y]]) goto android_e;
1799 if (is_android_walkable[cave[x][y+1]]) goto android_s;
1806 next[x][y] = Xandroid;
1810 cave[x][y] = Yandroid_nB;
1811 cave[x][y-1] = Yandroid_n;
1812 next[x][y-1] = Xandroid;
1813 play_element_sound(x, y, SOUND_android_move, Xandroid);
1817 cave[x][y] = Yandroid_neB;
1818 cave[x+1][y-1] = Yandroid_ne;
1819 next[x+1][y-1] = Xandroid;
1820 play_element_sound(x, y, SOUND_android_move, Xandroid);
1824 cave[x][y] = Yandroid_eB;
1825 cave[x+1][y] = Yandroid_e;
1826 next[x+1][y] = Xandroid;
1827 play_element_sound(x, y, SOUND_android_move, Xandroid);
1831 cave[x][y] = Yandroid_seB;
1832 cave[x+1][y+1] = Yandroid_se;
1833 next[x+1][y+1] = Xandroid;
1834 play_element_sound(x, y, SOUND_android_move, Xandroid);
1838 cave[x][y] = Yandroid_sB;
1839 cave[x][y+1] = Yandroid_s;
1840 next[x][y+1] = Xandroid;
1841 play_element_sound(x, y, SOUND_android_move, Xandroid);
1845 cave[x][y] = Yandroid_swB;
1846 cave[x-1][y+1] = Yandroid_sw;
1847 next[x-1][y+1] = Xandroid;
1848 play_element_sound(x, y, SOUND_android_move, Xandroid);
1852 cave[x][y] = Yandroid_wB;
1853 cave[x-1][y] = Yandroid_w;
1854 next[x-1][y] = Xandroid;
1855 play_element_sound(x, y, SOUND_android_move, Xandroid);
1859 cave[x][y] = Yandroid_nwB;
1860 cave[x-1][y-1] = Yandroid_nw;
1861 next[x-1][y-1] = Xandroid;
1862 play_element_sound(x, y, SOUND_android_move, Xandroid);
1866 static void Landroid_1_n(int x, int y)
1868 switch (cave[x][y-1])
1881 cave[x][y] = Yandroid_nB;
1882 next[x][y] = Xblank;
1883 cave[x][y-1] = Yandroid_n;
1884 next[x][y-1] = Xandroid;
1885 play_element_sound(x, y, SOUND_android_move, Xandroid_1_n);
1896 cave[x][y] = Yandroid_nB;
1897 next[x][y] = Xblank;
1898 if (cave[x+1][y-2] == Xblank)
1899 cave[x+1][y-2] = Xsplash_e;
1900 if (cave[x-1][y-2] == Xblank)
1901 cave[x-1][y-2] = Xsplash_w;
1902 play_element_sound(x, y, SOUND_acid, Xacid_1);
1911 static void Landroid_2_n(int x, int y)
1913 switch (cave[x][y-1])
1926 cave[x][y] = Yandroid_nB;
1927 next[x][y] = Xblank;
1928 cave[x][y-1] = Yandroid_n;
1929 next[x][y-1] = Xandroid_1_n;
1930 play_element_sound(x, y, SOUND_android_move, Xandroid_2_n);
1941 cave[x][y] = Yandroid_nB;
1942 next[x][y] = Xblank;
1943 if (cave[x+1][y-2] == Xblank)
1944 cave[x+1][y-2] = Xsplash_e;
1945 if (cave[x-1][y-2] == Xblank)
1946 cave[x-1][y-2] = Xsplash_w;
1947 play_element_sound(x, y, SOUND_acid, Xacid_1);
1956 static void Landroid_1_e(int x, int y)
1958 switch (cave[x+1][y])
1971 cave[x][y] = Yandroid_eB;
1972 next[x][y] = Xblank;
1973 cave[x+1][y] = Yandroid_e;
1974 next[x+1][y] = Xandroid;
1975 play_element_sound(x, y, SOUND_android_move, Xandroid_1_e);
1986 cave[x][y] = Yandroid_eB;
1987 next[x][y] = Xblank;
1988 if (cave[x+2][y-1] == Xblank)
1989 cave[x+2][y-1] = Xsplash_e;
1990 if (cave[x][y-1] == Xblank)
1991 cave[x][y-1] = Xsplash_w;
1992 play_element_sound(x, y, SOUND_acid, Xacid_1);
2001 static void Landroid_2_e(int x, int y)
2003 switch (cave[x+1][y])
2016 cave[x][y] = Yandroid_eB;
2017 next[x][y] = Xblank;
2018 cave[x+1][y] = Yandroid_e;
2019 next[x+1][y] = Xandroid_1_e;
2020 play_element_sound(x, y, SOUND_android_move, Xandroid_2_e);
2031 cave[x][y] = Yandroid_eB;
2032 next[x][y] = Xblank;
2033 if (cave[x+2][y-1] == Xblank)
2034 cave[x+2][y-1] = Xsplash_e;
2035 if (cave[x][y-1] == Xblank)
2036 cave[x][y-1] = Xsplash_w;
2037 play_element_sound(x, y, SOUND_acid, Xacid_1);
2046 static void Landroid_1_s(int x, int y)
2048 switch (cave[x][y+1])
2061 cave[x][y] = Yandroid_sB;
2062 next[x][y] = Xblank;
2063 cave[x][y+1] = Yandroid_s;
2064 next[x][y+1] = Xandroid;
2065 play_element_sound(x, y, SOUND_android_move, Xandroid_1_s);
2076 cave[x][y] = Yandroid_sB;
2077 next[x][y] = Xblank;
2078 if (cave[x+1][y] == Xblank)
2079 cave[x+1][y] = Xsplash_e;
2080 if (cave[x-1][y] == Xblank)
2081 cave[x-1][y] = Xsplash_w;
2082 play_element_sound(x, y, SOUND_acid, Xacid_1);
2091 static void Landroid_2_s(int x, int y)
2093 switch (cave[x][y+1])
2106 cave[x][y] = Yandroid_sB;
2107 next[x][y] = Xblank;
2108 cave[x][y+1] = Yandroid_s;
2109 next[x][y+1] = Xandroid_1_s;
2110 play_element_sound(x, y, SOUND_android_move, Xandroid_2_s);
2121 cave[x][y] = Yandroid_sB;
2122 next[x][y] = Xblank;
2123 if (cave[x+1][y] == Xblank)
2124 cave[x+1][y] = Xsplash_e;
2125 if (cave[x-1][y] == Xblank)
2126 cave[x-1][y] = Xsplash_w;
2127 play_element_sound(x, y, SOUND_acid, Xacid_1);
2136 static void Landroid_1_w(int x, int y)
2138 switch (cave[x-1][y])
2151 cave[x][y] = Yandroid_wB;
2152 next[x][y] = Xblank;
2153 cave[x-1][y] = Yandroid_w;
2154 next[x-1][y] = Xandroid;
2155 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2166 cave[x][y] = Yandroid_wB;
2167 next[x][y] = Xblank;
2168 if (cave[x][y-1] == Xblank)
2169 cave[x][y-1] = Xsplash_e;
2170 if (cave[x-2][y-1] == Xblank)
2171 cave[x-2][y-1] = Xsplash_w;
2172 play_element_sound(x, y, SOUND_acid, Xacid_1);
2181 static void Landroid_2_w(int x, int y)
2183 switch (cave[x-1][y])
2196 cave[x][y] = Yandroid_wB;
2197 next[x][y] = Xblank;
2198 cave[x-1][y] = Yandroid_w;
2199 next[x-1][y] = Xandroid_1_w;
2200 play_element_sound(x, y, SOUND_android_move, Xandroid_1_w);
2211 cave[x][y] = Yandroid_wB;
2212 next[x][y] = Xblank;
2213 if (cave[x][y-1] == Xblank)
2214 cave[x][y-1] = Xsplash_e;
2215 if (cave[x-2][y-1] == Xblank)
2216 cave[x-2][y-1] = Xsplash_w;
2217 play_element_sound(x, y, SOUND_acid, Xacid_1);
2226 static void Leater_n(int x, int y)
2228 if (cave[x+1][y] == Xdiamond)
2230 cave[x+1][y] = Ydiamond_blank;
2231 next[x+1][y] = Xblank;
2232 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2236 if (cave[x][y+1] == Xdiamond)
2238 cave[x][y+1] = Ydiamond_blank;
2239 next[x][y+1] = Xblank;
2240 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2244 if (cave[x-1][y] == Xdiamond)
2246 cave[x-1][y] = Ydiamond_blank;
2247 next[x-1][y] = Xblank;
2248 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2252 if (cave[x][y-1] == Xdiamond)
2254 cave[x][y-1] = Ydiamond_blank;
2255 next[x][y-1] = Xblank;
2256 play_element_sound(x, y, SOUND_eater_eat, Xeater_n);
2260 switch (cave[x][y-1])
2276 cave[x][y] = Yeater_nB;
2277 next[x][y] = Xblank;
2278 cave[x][y-1] = Yeater_n;
2279 next[x][y-1] = Xeater_n;
2290 cave[x][y] = Yeater_nB;
2291 next[x][y] = Xblank;
2292 if (cave[x+1][y-2] == Xblank)
2293 cave[x+1][y-2] = Xsplash_e;
2294 if (cave[x-1][y-2] == Xblank)
2295 cave[x-1][y-2] = Xsplash_w;
2296 play_element_sound(x, y, SOUND_acid, Xacid_1);
2300 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2301 play_element_sound(x, y, SOUND_eater, Xeater_n);
2306 static void Leater_e(int x, int y)
2308 if (cave[x][y+1] == Xdiamond)
2310 cave[x][y+1] = Ydiamond_blank;
2311 next[x][y+1] = Xblank;
2312 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2316 if (cave[x-1][y] == Xdiamond)
2318 cave[x-1][y] = Ydiamond_blank;
2319 next[x-1][y] = Xblank;
2320 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2324 if (cave[x][y-1] == Xdiamond)
2326 cave[x][y-1] = Ydiamond_blank;
2327 next[x][y-1] = Xblank;
2328 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2332 if (cave[x+1][y] == Xdiamond)
2334 cave[x+1][y] = Ydiamond_blank;
2335 next[x+1][y] = Xblank;
2336 play_element_sound(x, y, SOUND_eater_eat, Xeater_e);
2340 switch (cave[x+1][y])
2356 cave[x][y] = Yeater_eB;
2357 next[x][y] = Xblank;
2358 cave[x+1][y] = Yeater_e;
2359 next[x+1][y] = Xeater_e;
2370 cave[x][y] = Yeater_eB;
2371 next[x][y] = Xblank;
2372 if (cave[x+2][y-1] == Xblank)
2373 cave[x+2][y-1] = Xsplash_e;
2374 if (cave[x][y-1] == Xblank)
2375 cave[x][y-1] = Xsplash_w;
2376 play_element_sound(x, y, SOUND_acid, Xacid_1);
2380 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2381 play_element_sound(x, y, SOUND_eater, Xeater_e);
2386 static void Leater_s(int x, int y)
2388 if (cave[x-1][y] == Xdiamond)
2390 cave[x-1][y] = Ydiamond_blank;
2391 next[x-1][y] = Xblank;
2392 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2396 if (cave[x][y-1] == Xdiamond)
2398 cave[x][y-1] = Ydiamond_blank;
2399 next[x][y-1] = Xblank;
2400 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2404 if (cave[x+1][y] == Xdiamond)
2406 cave[x+1][y] = Ydiamond_blank;
2407 next[x+1][y] = Xblank;
2408 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2412 if (cave[x][y+1] == Xdiamond)
2414 cave[x][y+1] = Ydiamond_blank;
2415 next[x][y+1] = Xblank;
2416 play_element_sound(x, y, SOUND_eater_eat, Xeater_s);
2420 switch (cave[x][y+1])
2436 cave[x][y] = Yeater_sB;
2437 next[x][y] = Xblank;
2438 cave[x][y+1] = Yeater_s;
2439 next[x][y+1] = Xeater_s;
2450 cave[x][y] = Yeater_sB;
2451 next[x][y] = Xblank;
2452 if (cave[x+1][y] == Xblank)
2453 cave[x+1][y] = Xsplash_e;
2454 if (cave[x-1][y] == Xblank)
2455 cave[x-1][y] = Xsplash_w;
2456 play_element_sound(x, y, SOUND_acid, Xacid_1);
2460 next[x][y] = RANDOM(2) ? Xeater_e : Xeater_w;
2461 play_element_sound(x, y, SOUND_eater, Xeater_s);
2466 static void Leater_w(int x, int y)
2468 if (cave[x][y-1] == Xdiamond)
2470 cave[x][y-1] = Ydiamond_blank;
2471 next[x][y-1] = Xblank;
2472 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2476 if (cave[x+1][y] == Xdiamond)
2478 cave[x+1][y] = Ydiamond_blank;
2479 next[x+1][y] = Xblank;
2480 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2484 if (cave[x][y+1] == Xdiamond)
2486 cave[x][y+1] = Ydiamond_blank;
2487 next[x][y+1] = Xblank;
2488 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2492 if (cave[x-1][y] == Xdiamond)
2494 cave[x-1][y] = Ydiamond_blank;
2495 next[x-1][y] = Xblank;
2496 play_element_sound(x, y, SOUND_eater_eat, Xeater_w);
2500 switch (cave[x-1][y])
2516 cave[x][y] = Yeater_wB;
2517 next[x][y] = Xblank;
2518 cave[x-1][y] = Yeater_w;
2519 next[x-1][y] = Xeater_w;
2530 cave[x][y] = Yeater_wB;
2531 next[x][y] = Xblank;
2532 if (cave[x][y-1] == Xblank)
2533 cave[x][y-1] = Xsplash_e;
2534 if (cave[x-2][y-1] == Xblank)
2535 cave[x-2][y-1] = Xsplash_w;
2536 play_element_sound(x, y, SOUND_acid, Xacid_1);
2540 next[x][y] = RANDOM(2) ? Xeater_n : Xeater_s;
2541 play_element_sound(x, y, SOUND_eater, Xeater_w);
2546 static void Lalien(int x, int y)
2557 set_nearest_player_xy(x, y, &dx, &dy);
2564 switch (cave[x][y-1])
2580 cave[x][y] = Yalien_nB;
2581 next[x][y] = Xblank;
2582 cave[x][y-1] = Yalien_n;
2583 next[x][y-1] = Xalien_pause;
2584 play_element_sound(x, y, SOUND_alien, Xalien);
2595 cave[x][y] = Yalien_nB;
2596 next[x][y] = Xblank;
2597 if (cave[x+1][y-2] == Xblank)
2598 cave[x+1][y-2] = Xsplash_e;
2599 if (cave[x-1][y-2] == Xblank)
2600 cave[x-1][y-2] = Xsplash_w;
2601 play_element_sound(x, y, SOUND_acid, Xacid_1);
2607 switch (cave[x][y+1])
2623 cave[x][y] = Yalien_sB;
2624 next[x][y] = Xblank;
2625 cave[x][y+1] = Yalien_s;
2626 next[x][y+1] = Xalien_pause;
2627 play_element_sound(x, y, SOUND_alien, Xalien);
2638 cave[x][y] = Yalien_sB;
2639 next[x][y] = Xblank;
2640 if (cave[x+1][y] == Xblank)
2641 cave[x+1][y] = Xsplash_e;
2642 if (cave[x-1][y] == Xblank)
2643 cave[x-1][y] = Xsplash_w;
2644 play_element_sound(x, y, SOUND_acid, Xacid_1);
2653 switch (cave[x+1][y])
2669 cave[x][y] = Yalien_eB;
2670 next[x][y] = Xblank;
2671 cave[x+1][y] = Yalien_e;
2672 next[x+1][y] = Xalien_pause;
2673 play_element_sound(x, y, SOUND_alien, Xalien);
2684 cave[x][y] = Yalien_eB;
2685 next[x][y] = Xblank;
2686 if (cave[x+2][y-1] == Xblank)
2687 cave[x+2][y-1] = Xsplash_e;
2688 if (cave[x][y-1] == Xblank)
2689 cave[x][y-1] = Xsplash_w;
2690 play_element_sound(x, y, SOUND_acid, Xacid_1);
2696 switch (cave[x-1][y])
2712 cave[x][y] = Yalien_wB;
2713 next[x][y] = Xblank;
2714 cave[x-1][y] = Yalien_w;
2715 next[x-1][y] = Xalien_pause;
2716 play_element_sound(x, y, SOUND_alien, Xalien);
2727 cave[x][y] = Yalien_wB;
2728 next[x][y] = Xblank;
2729 if (cave[x][y-1] == Xblank)
2730 cave[x][y-1] = Xsplash_e;
2731 if (cave[x-2][y-1] == Xblank)
2732 cave[x-2][y-1] = Xsplash_w;
2733 play_element_sound(x, y, SOUND_acid, Xacid_1);
2740 static void Lalien_pause(int x, int y)
2742 next[x][y] = Xalien;
2745 static void Lbug_n(int x, int y)
2747 switch (cave[x][y-1])
2763 cave[x][y] = Ybug_nB;
2764 next[x][y] = Xblank;
2765 cave[x][y-1] = Ybug_n;
2766 next[x][y-1] = Xbug_1_n;
2767 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2778 cave[x][y] = Ybug_nB;
2779 next[x][y] = Xblank;
2780 if (cave[x+1][y-2] == Xblank)
2781 cave[x+1][y-2] = Xsplash_e;
2782 if (cave[x-1][y-2] == Xblank)
2783 cave[x-1][y-2] = Xsplash_w;
2784 play_element_sound(x, y, SOUND_acid, Xacid_1);
2788 cave[x][y] = Ybug_n_w;
2789 next[x][y] = Xbug_2_w;
2790 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2795 static void Lbug_1_n(int x, int y)
2797 if (is_amoeba[cave[x][y-1]] ||
2798 is_amoeba[cave[x+1][y]] ||
2799 is_amoeba[cave[x][y+1]] ||
2800 is_amoeba[cave[x-1][y]])
2802 Lboom_bug(x, y, Xbug_1_n);
2807 switch (cave[x+1][y])
2831 cave[x][y] = Ybug_n_e;
2832 next[x][y] = Xbug_2_e;
2833 play_element_sound(x, y, SOUND_bug, Xbug_1_n);
2842 static void Lbug_2_n(int x, int y)
2844 if (is_amoeba[cave[x][y-1]] ||
2845 is_amoeba[cave[x+1][y]] ||
2846 is_amoeba[cave[x][y+1]] ||
2847 is_amoeba[cave[x-1][y]])
2849 Lboom_bug(x, y, Xbug_2_n);
2857 static void Lbug_e(int x, int y)
2859 switch (cave[x+1][y])
2875 cave[x][y] = Ybug_eB;
2876 next[x][y] = Xblank;
2877 cave[x+1][y] = Ybug_e;
2878 next[x+1][y] = Xbug_1_e;
2879 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2890 cave[x][y] = Ybug_eB;
2891 next[x][y] = Xblank;
2892 if (cave[x+2][y-1] == Xblank)
2893 cave[x+2][y-1] = Xsplash_e;
2894 if (cave[x][y-1] == Xblank)
2895 cave[x][y-1] = Xsplash_w;
2896 play_element_sound(x, y, SOUND_acid, Xacid_1);
2900 cave[x][y] = Ybug_e_n;
2901 next[x][y] = Xbug_2_n;
2902 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2907 static void Lbug_1_e(int x, int y)
2909 if (is_amoeba[cave[x][y-1]] ||
2910 is_amoeba[cave[x+1][y]] ||
2911 is_amoeba[cave[x][y+1]] ||
2912 is_amoeba[cave[x-1][y]])
2914 Lboom_bug(x, y, Xbug_1_e);
2919 switch (cave[x][y+1])
2943 cave[x][y] = Ybug_e_s;
2944 next[x][y] = Xbug_2_s;
2945 play_element_sound(x, y, SOUND_bug, Xbug_1_e);
2954 static void Lbug_2_e(int x, int y)
2956 if (is_amoeba[cave[x][y-1]] ||
2957 is_amoeba[cave[x+1][y]] ||
2958 is_amoeba[cave[x][y+1]] ||
2959 is_amoeba[cave[x-1][y]])
2961 Lboom_bug(x, y, Xbug_2_e);
2969 static void Lbug_s(int x, int y)
2971 switch (cave[x][y+1])
2987 cave[x][y] = Ybug_sB;
2988 next[x][y] = Xblank;
2989 cave[x][y+1] = Ybug_s;
2990 next[x][y+1] = Xbug_1_s;
2991 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3002 cave[x][y] = Ybug_sB;
3003 next[x][y] = Xblank;
3004 if (cave[x+1][y] == Xblank)
3005 cave[x+1][y] = Xsplash_e;
3006 if (cave[x-1][y] == Xblank)
3007 cave[x-1][y] = Xsplash_w;
3008 play_element_sound(x, y, SOUND_acid, Xacid_1);
3012 cave[x][y] = Ybug_s_e;
3013 next[x][y] = Xbug_2_e;
3014 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3019 static void Lbug_1_s(int x, int y)
3021 if (is_amoeba[cave[x][y-1]] ||
3022 is_amoeba[cave[x+1][y]] ||
3023 is_amoeba[cave[x][y+1]] ||
3024 is_amoeba[cave[x-1][y]])
3026 Lboom_bug(x, y, Xbug_1_s);
3031 switch (cave[x-1][y])
3055 cave[x][y] = Ybug_s_w;
3056 next[x][y] = Xbug_2_w;
3057 play_element_sound(x, y, SOUND_bug, Xbug_1_s);
3066 static void Lbug_2_s(int x, int y)
3068 if (is_amoeba[cave[x][y-1]] ||
3069 is_amoeba[cave[x+1][y]] ||
3070 is_amoeba[cave[x][y+1]] ||
3071 is_amoeba[cave[x-1][y]])
3073 Lboom_bug(x, y, Xbug_2_s);
3081 static void Lbug_w(int x, int y)
3083 switch (cave[x-1][y])
3099 cave[x][y] = Ybug_wB;
3100 next[x][y] = Xblank;
3101 cave[x-1][y] = Ybug_w;
3102 next[x-1][y] = Xbug_1_w;
3103 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3114 cave[x][y] = Ybug_wB;
3115 next[x][y] = Xblank;
3116 if (cave[x][y-1] == Xblank)
3117 cave[x][y-1] = Xsplash_e;
3118 if (cave[x-2][y-1] == Xblank)
3119 cave[x-2][y-1] = Xsplash_w;
3120 play_element_sound(x, y, SOUND_acid, Xacid_1);
3124 cave[x][y] = Ybug_w_s;
3125 next[x][y] = Xbug_2_s;
3126 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3131 static void Lbug_1_w(int x, int y)
3133 if (is_amoeba[cave[x][y-1]] ||
3134 is_amoeba[cave[x+1][y]] ||
3135 is_amoeba[cave[x][y+1]] ||
3136 is_amoeba[cave[x-1][y]])
3138 Lboom_bug(x, y, Xbug_1_w);
3143 switch (cave[x][y-1])
3167 cave[x][y] = Ybug_w_n;
3168 next[x][y] = Xbug_2_n;
3169 play_element_sound(x, y, SOUND_bug, Xbug_1_w);
3178 static void Lbug_2_w(int x, int y)
3180 if (is_amoeba[cave[x][y-1]] ||
3181 is_amoeba[cave[x+1][y]] ||
3182 is_amoeba[cave[x][y+1]] ||
3183 is_amoeba[cave[x-1][y]])
3185 Lboom_bug(x, y, Xbug_2_w);
3193 static void Ltank_n(int x, int y)
3195 switch (cave[x][y-1])
3211 cave[x][y] = Ytank_nB;
3212 next[x][y] = Xblank;
3213 cave[x][y-1] = Ytank_n;
3214 next[x][y-1] = Xtank_1_n;
3215 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3226 cave[x][y] = Ytank_nB;
3227 next[x][y] = Xblank;
3228 if (cave[x+1][y-2] == Xblank)
3229 cave[x+1][y-2] = Xsplash_e;
3230 if (cave[x-1][y-2] == Xblank)
3231 cave[x-1][y-2] = Xsplash_w;
3232 play_element_sound(x, y, SOUND_acid, Xacid_1);
3236 cave[x][y] = Ytank_n_e;
3237 next[x][y] = Xtank_2_e;
3238 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3243 static void Ltank_1_n(int x, int y)
3245 if (is_amoeba[cave[x][y-1]] ||
3246 is_amoeba[cave[x+1][y]] ||
3247 is_amoeba[cave[x][y+1]] ||
3248 is_amoeba[cave[x-1][y]])
3250 Lboom_tank(x, y, Xtank_1_n);
3255 switch (cave[x-1][y])
3279 cave[x][y] = Ytank_n_w;
3280 next[x][y] = Xtank_2_w;
3281 play_element_sound(x, y, SOUND_tank, Xtank_1_n);
3290 static void Ltank_2_n(int x, int y)
3292 if (is_amoeba[cave[x][y-1]] ||
3293 is_amoeba[cave[x+1][y]] ||
3294 is_amoeba[cave[x][y+1]] ||
3295 is_amoeba[cave[x-1][y]])
3297 Lboom_tank(x, y, Xtank_2_n);
3305 static void Ltank_e(int x, int y)
3307 switch (cave[x+1][y])
3323 cave[x][y] = Ytank_eB;
3324 next[x][y] = Xblank;
3325 cave[x+1][y] = Ytank_e;
3326 next[x+1][y] = Xtank_1_e;
3327 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3338 cave[x][y] = Ytank_eB;
3339 next[x][y] = Xblank;
3340 if (cave[x+2][y-1] == Xblank)
3341 cave[x+2][y-1] = Xsplash_e;
3342 if (cave[x][y-1] == Xblank)
3343 cave[x][y-1] = Xsplash_w;
3344 play_element_sound(x, y, SOUND_acid, Xacid_1);
3348 cave[x][y] = Ytank_e_s;
3349 next[x][y] = Xtank_2_s;
3350 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3355 static void Ltank_1_e(int x, int y)
3357 if (is_amoeba[cave[x][y-1]] ||
3358 is_amoeba[cave[x+1][y]] ||
3359 is_amoeba[cave[x][y+1]] ||
3360 is_amoeba[cave[x-1][y]])
3362 Lboom_tank(x, y, Xtank_1_e);
3367 switch (cave[x][y-1])
3391 cave[x][y] = Ytank_e_n;
3392 next[x][y] = Xtank_2_n;
3393 play_element_sound(x, y, SOUND_tank, Xtank_1_e);
3402 static void Ltank_2_e(int x, int y)
3404 if (is_amoeba[cave[x][y-1]] ||
3405 is_amoeba[cave[x+1][y]] ||
3406 is_amoeba[cave[x][y+1]] ||
3407 is_amoeba[cave[x-1][y]])
3409 Lboom_tank(x, y, Xtank_2_e);
3417 static void Ltank_s(int x, int y)
3419 switch (cave[x][y+1])
3435 cave[x][y] = Ytank_sB;
3436 next[x][y] = Xblank;
3437 cave[x][y+1] = Ytank_s;
3438 next[x][y+1] = Xtank_1_s;
3439 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3450 cave[x][y] = Ytank_sB;
3451 next[x][y] = Xblank;
3452 if (cave[x+1][y] == Xblank)
3453 cave[x+1][y] = Xsplash_e;
3454 if (cave[x-1][y] == Xblank)
3455 cave[x-1][y] = Xsplash_w;
3456 play_element_sound(x, y, SOUND_acid, Xacid_1);
3460 cave[x][y] = Ytank_s_w;
3461 next[x][y] = Xtank_2_w;
3462 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3467 static void Ltank_1_s(int x, int y)
3469 if (is_amoeba[cave[x][y-1]] ||
3470 is_amoeba[cave[x+1][y]] ||
3471 is_amoeba[cave[x][y+1]] ||
3472 is_amoeba[cave[x-1][y]])
3474 Lboom_tank(x, y, Xtank_1_s);
3479 switch (cave[x+1][y])
3503 cave[x][y] = Ytank_s_e;
3504 next[x][y] = Xtank_2_e;
3505 play_element_sound(x, y, SOUND_tank, Xtank_1_s);
3514 static void Ltank_2_s(int x, int y)
3516 if (is_amoeba[cave[x][y-1]] ||
3517 is_amoeba[cave[x+1][y]] ||
3518 is_amoeba[cave[x][y+1]] ||
3519 is_amoeba[cave[x-1][y]])
3521 Lboom_tank(x, y, Xtank_2_s);
3529 static void Ltank_w(int x, int y)
3531 switch (cave[x-1][y])
3547 cave[x][y] = Ytank_wB;
3548 next[x][y] = Xblank;
3549 cave[x-1][y] = Ytank_w;
3550 next[x-1][y] = Xtank_1_w;
3551 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3562 cave[x][y] = Ytank_wB;
3563 next[x][y] = Xblank;
3564 if (cave[x][y-1] == Xblank)
3565 cave[x][y-1] = Xsplash_e;
3566 if (cave[x-2][y-1] == Xblank)
3567 cave[x-2][y-1] = Xsplash_w;
3568 play_element_sound(x, y, SOUND_acid, Xacid_1);
3572 cave[x][y] = Ytank_w_n;
3573 next[x][y] = Xtank_2_n;
3574 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3579 static void Ltank_1_w(int x, int y)
3581 if (is_amoeba[cave[x][y-1]] ||
3582 is_amoeba[cave[x+1][y]] ||
3583 is_amoeba[cave[x][y+1]] ||
3584 is_amoeba[cave[x-1][y]])
3586 Lboom_tank(x, y, Xtank_1_w);
3591 switch (cave[x][y+1])
3615 cave[x][y] = Ytank_w_s;
3616 next[x][y] = Xtank_2_s;
3617 play_element_sound(x, y, SOUND_tank, Xtank_1_w);
3626 static void Ltank_2_w(int x, int y)
3628 if (is_amoeba[cave[x][y-1]] ||
3629 is_amoeba[cave[x+1][y]] ||
3630 is_amoeba[cave[x][y+1]] ||
3631 is_amoeba[cave[x-1][y]])
3633 Lboom_tank(x, y, Xtank_2_w);
3641 static void Lemerald(int x, int y)
3643 switch (cave[x][y+1])
3656 cave[x][y] = Yemerald_sB;
3657 next[x][y] = Xblank;
3658 cave[x][y+1] = Yemerald_s;
3659 next[x][y+1] = Xemerald_fall;
3670 cave[x][y] = Yemerald_sB;
3671 next[x][y] = Xblank;
3672 if (cave[x+1][y] == Xblank)
3673 cave[x+1][y] = Xsplash_e;
3674 if (cave[x-1][y] == Xblank)
3675 cave[x-1][y] = Xsplash_w;
3676 play_element_sound(x, y, SOUND_acid, Xacid_1);
3695 case Xemerald_pause:
3697 case Xdiamond_pause:
3734 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
3736 cave[x][y] = Yemerald_eB;
3737 next[x][y] = Xblank;
3738 cave[x+1][y] = Yemerald_e;
3739 next[x+1][y] = Xemerald_pause;
3743 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
3745 cave[x][y] = Yemerald_wB;
3746 next[x][y] = Xblank;
3747 cave[x-1][y] = Yemerald_w;
3748 next[x-1][y] = Xemerald_pause;
3754 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
3756 cave[x][y] = Yemerald_wB;
3757 next[x][y] = Xblank;
3758 cave[x-1][y] = Yemerald_w;
3759 next[x-1][y] = Xemerald_pause;
3763 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
3765 cave[x][y] = Yemerald_eB;
3766 next[x][y] = Xblank;
3767 cave[x+1][y] = Yemerald_e;
3768 next[x+1][y] = Xemerald_pause;
3774 if (++lev.shine_cnt > 50)
3776 lev.shine_cnt = RANDOM(8);
3777 cave[x][y] = Xemerald_shine;
3784 static void Lemerald_pause(int x, int y)
3786 switch (cave[x][y+1])
3799 cave[x][y] = Yemerald_sB;
3800 next[x][y] = Xblank;
3801 cave[x][y+1] = Yemerald_s;
3802 next[x][y+1] = Xemerald_fall;
3813 cave[x][y] = Yemerald_sB;
3814 next[x][y] = Xblank;
3815 if (cave[x+1][y] == Xblank)
3816 cave[x+1][y] = Xsplash_e;
3817 if (cave[x-1][y] == Xblank)
3818 cave[x-1][y] = Xsplash_w;
3819 play_element_sound(x, y, SOUND_acid, Xacid_1);
3823 cave[x][y] = Xemerald;
3824 next[x][y] = Xemerald;
3829 static void Lemerald_fall(int x, int y)
3831 switch (cave[x][y+1])
3845 cave[x][y] = Yemerald_sB;
3846 next[x][y] = Xblank;
3847 cave[x][y+1] = Yemerald_s;
3848 next[x][y+1] = Xemerald_fall;
3859 cave[x][y] = Yemerald_sB;
3860 next[x][y] = Xblank;
3861 if (cave[x+1][y] == Xblank)
3862 cave[x+1][y] = Xsplash_e;
3863 if (cave[x-1][y] == Xblank)
3864 cave[x-1][y] = Xsplash_w;
3865 play_element_sound(x, y, SOUND_acid, Xacid_1);
3869 if (lev.wonderwall_time)
3871 lev.wonderwall_state = 1;
3872 cave[x][y] = Yemerald_sB;
3873 if (is_blank[cave[x][y+2]])
3875 cave[x][y+2] = Ydiamond_s;
3876 next[x][y+2] = Xdiamond_fall;
3879 next[x][y] = Xblank;
3880 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
3885 cave[x][y] = Xemerald;
3886 next[x][y] = Xemerald;
3887 play_element_sound(x, y, SOUND_diamond, Xemerald);
3892 static void Ldiamond(int x, int y)
3894 switch (cave[x][y+1])
3907 cave[x][y] = Ydiamond_sB;
3908 next[x][y] = Xblank;
3909 cave[x][y+1] = Ydiamond_s;
3910 next[x][y+1] = Xdiamond_fall;
3921 cave[x][y] = Ydiamond_sB;
3922 next[x][y] = Xblank;
3923 if (cave[x+1][y] == Xblank)
3924 cave[x+1][y] = Xsplash_e;
3925 if (cave[x-1][y] == Xblank)
3926 cave[x-1][y] = Xsplash_w;
3927 play_element_sound(x, y, SOUND_acid, Xacid_1);
3946 case Xemerald_pause:
3948 case Xdiamond_pause:
3985 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
3987 cave[x][y] = Ydiamond_eB;
3988 next[x][y] = Xblank;
3989 cave[x+1][y] = Ydiamond_e;
3990 next[x+1][y] = Xdiamond_pause;
3994 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
3996 cave[x][y] = Ydiamond_wB;
3997 next[x][y] = Xblank;
3998 cave[x-1][y] = Ydiamond_w;
3999 next[x-1][y] = Xdiamond_pause;
4005 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4007 cave[x][y] = Ydiamond_wB;
4008 next[x][y] = Xblank;
4009 cave[x-1][y] = Ydiamond_w;
4010 next[x-1][y] = Xdiamond_pause;
4014 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4016 cave[x][y] = Ydiamond_eB;
4017 next[x][y] = Xblank;
4018 cave[x+1][y] = Ydiamond_e;
4019 next[x+1][y] = Xdiamond_pause;
4025 if (++lev.shine_cnt > 50)
4027 lev.shine_cnt = RANDOM(8);
4028 cave[x][y] = Xdiamond_shine;
4035 static void Ldiamond_pause(int x, int y)
4037 switch (cave[x][y+1])
4050 cave[x][y] = Ydiamond_sB;
4051 next[x][y] = Xblank;
4052 cave[x][y+1] = Ydiamond_s;
4053 next[x][y+1] = Xdiamond_fall;
4064 cave[x][y] = Ydiamond_sB;
4065 next[x][y] = Xblank;
4066 if (cave[x+1][y] == Xblank)
4067 cave[x+1][y] = Xsplash_e;
4068 if (cave[x-1][y] == Xblank)
4069 cave[x-1][y] = Xsplash_w;
4070 play_element_sound(x, y, SOUND_acid, Xacid_1);
4074 cave[x][y] = Xdiamond;
4075 next[x][y] = Xdiamond;
4080 static void Ldiamond_fall(int x, int y)
4082 switch (cave[x][y+1])
4096 cave[x][y] = Ydiamond_sB;
4097 next[x][y] = Xblank;
4098 cave[x][y+1] = Ydiamond_s;
4099 next[x][y+1] = Xdiamond_fall;
4110 cave[x][y] = Ydiamond_sB;
4111 next[x][y] = Xblank;
4112 if (cave[x+1][y] == Xblank)
4113 cave[x+1][y] = Xsplash_e;
4114 if (cave[x-1][y] == Xblank)
4115 cave[x-1][y] = Xsplash_w;
4116 play_element_sound(x, y, SOUND_acid, Xacid_1);
4120 if (lev.wonderwall_time)
4122 lev.wonderwall_state = 1;
4123 cave[x][y] = Ydiamond_sB;
4124 if (is_blank[cave[x][y+2]])
4126 cave[x][y+2] = Ystone_s;
4127 next[x][y+2] = Xstone_fall;
4130 next[x][y] = Xblank;
4131 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4136 cave[x][y] = Xdiamond;
4137 next[x][y] = Xdiamond;
4138 play_element_sound(x, y, SOUND_diamond, Xdiamond);
4143 static void Lstone(int x, int y)
4145 switch (cave[x][y+1])
4160 cave[x][y] = Ystone_sB;
4161 next[x][y] = Xblank;
4162 cave[x][y+1] = Ystone_s;
4163 next[x][y+1] = Xstone_fall;
4174 cave[x][y] = Ystone_sB;
4175 next[x][y] = Xblank;
4176 if (cave[x+1][y] == Xblank)
4177 cave[x+1][y] = Xsplash_e;
4178 if (cave[x-1][y] == Xblank)
4179 cave[x-1][y] = Xsplash_w;
4180 play_element_sound(x, y, SOUND_acid, Xacid_1);
4184 cave[x][y] = Xsand_stonein_1;
4185 next[x][y] = Xsand_stonein_2;
4186 cave[x][y+1] = Xsand_sandstone_1;
4187 next[x][y+1] = Xsand_sandstone_2;
4206 case Xemerald_pause:
4208 case Xdiamond_pause:
4238 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4240 cave[x][y] = Ystone_eB;
4241 next[x][y] = Xblank;
4242 cave[x+1][y] = Ystone_e;
4243 next[x+1][y] = Xstone_pause;
4247 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4249 cave[x][y] = Ystone_wB;
4250 next[x][y] = Xblank;
4251 cave[x-1][y] = Ystone_w;
4252 next[x-1][y] = Xstone_pause;
4258 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4260 cave[x][y] = Ystone_wB;
4261 next[x][y] = Xblank;
4262 cave[x-1][y] = Ystone_w;
4263 next[x-1][y] = Xstone_pause;
4267 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4269 cave[x][y] = Ystone_eB;
4270 next[x][y] = Xblank;
4271 cave[x+1][y] = Ystone_e;
4272 next[x+1][y] = Xstone_pause;
4279 static void Lstone_pause(int x, int y)
4281 switch (cave[x][y+1])
4294 cave[x][y] = Ystone_sB;
4295 next[x][y] = Xblank;
4296 cave[x][y+1] = Ystone_s;
4297 next[x][y+1] = Xstone_fall;
4308 cave[x][y] = Ystone_sB;
4309 next[x][y] = Xblank;
4310 if (cave[x+1][y] == Xblank)
4311 cave[x+1][y] = Xsplash_e;
4312 if (cave[x-1][y] == Xblank)
4313 cave[x-1][y] = Xsplash_w;
4314 play_element_sound(x, y, SOUND_acid, Xacid_1);
4318 cave[x][y] = Xstone;
4319 next[x][y] = Xstone;
4324 static void Lstone_fall(int x, int y)
4326 switch (cave[x][y+1])
4340 cave[x][y] = Ystone_sB;
4341 next[x][y] = Xblank;
4342 cave[x][y+1] = Ystone_s;
4343 next[x][y+1] = Xstone_fall;
4354 cave[x][y] = Ystone_sB;
4355 next[x][y] = Xblank;
4356 if (cave[x+1][y] == Xblank)
4357 cave[x+1][y] = Xsplash_e;
4358 if (cave[x-1][y] == Xblank)
4359 cave[x-1][y] = Xsplash_w;
4360 play_element_sound(x, y, SOUND_acid, Xacid_1);
4365 next[x][y] = Xstone;
4366 cave[x][y+1] = Ynut_stone;
4367 next[x][y+1] = Xemerald;
4368 play_element_sound(x, y, SOUND_crack, Xnut);
4369 score += lev.nut_score;
4380 cave[x][y] = Ystone_sB;
4381 cave[x][y+1] = Ybug_stone;
4382 Lboom_bug(x, y+1, Xstone_fall);
4383 score += lev.bug_score;
4394 cave[x][y] = Ystone_sB;
4395 cave[x][y+1] = Ytank_stone;
4396 Lboom_tank(x, y+1, Xstone_fall);
4397 score += lev.tank_score;
4403 switch (cave[x+1][y+1])
4418 cave[x][y+1] = Xspring_e;
4422 cave[x][y+1] = Xspring_w;
4428 switch (cave[x-1][y+1])
4443 cave[x][y+1] = Xspring_w;
4446 cave[x][y+1] = Xspring_e;
4451 next[x][y] = Xstone;
4458 cave[x][y] = Ystone_sB;
4459 cave[x][y+1] = Yeater_stone;
4460 Lboom_eater(x, y+1, Xstone_fall);
4461 score += lev.eater_score;
4466 cave[x][y] = Ystone_sB;
4467 cave[x][y+1] = Yalien_stone;
4468 Lboom_tank(x, y+1, Xstone_fall);
4469 score += lev.alien_score;
4473 case Xdiamond_pause:
4474 switch (cave[x][y+2])
4530 next[x][y] = Xstone;
4531 play_element_sound(x, y, SOUND_stone, Xstone);
4535 cave[x][y] = Ystone_sB;
4536 next[x][y] = Xblank;
4537 cave[x][y+1] = Ydiamond_stone;
4538 next[x][y+1] = Xstone_pause;
4539 play_element_sound(x, y, SOUND_squash, Xdiamond);
4544 cave[x][y+1] = Ybomb_blank;
4545 Lboom_tank(x, y+1, Xstone_fall);
4549 if (lev.wonderwall_time)
4551 lev.wonderwall_state = 1;
4552 cave[x][y] = Ystone_sB;
4554 if (is_blank[cave[x][y+2]])
4556 cave[x][y+2] = Yemerald_s;
4557 next[x][y+2] = Xemerald_fall;
4560 next[x][y] = Xblank;
4561 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
4566 cave[x][y] = Xstone;
4567 next[x][y] = Xstone;
4568 play_element_sound(x, y, SOUND_stone, Xstone);
4573 static void Lbomb(int x, int y)
4575 switch (cave[x][y+1])
4588 cave[x][y] = Ybomb_sB;
4589 next[x][y] = Xblank;
4590 cave[x][y+1] = Ybomb_s;
4591 next[x][y+1] = Xbomb_fall;
4602 cave[x][y] = Ybomb_sB;
4603 next[x][y] = Xblank;
4604 if (cave[x+1][y] == Xblank)
4605 cave[x+1][y] = Xsplash_e;
4606 if (cave[x-1][y] == Xblank)
4607 cave[x-1][y] = Xsplash_w;
4608 play_element_sound(x, y, SOUND_acid, Xacid_1);
4627 case Xemerald_pause:
4629 case Xdiamond_pause:
4657 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4659 cave[x][y] = Ybomb_eB;
4660 next[x][y] = Xblank;
4661 cave[x+1][y] = Ybomb_e;
4662 next[x+1][y] = Xbomb_pause;
4666 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4668 cave[x][y] = Ybomb_wB;
4669 next[x][y] = Xblank;
4670 cave[x-1][y] = Ybomb_w;
4671 next[x-1][y] = Xbomb_pause;
4677 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4679 cave[x][y] = Ybomb_wB;
4680 next[x][y] = Xblank;
4681 cave[x-1][y] = Ybomb_w;
4682 next[x-1][y] = Xbomb_pause;
4686 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4688 cave[x][y] = Ybomb_eB;
4689 next[x][y] = Xblank;
4690 cave[x+1][y] = Ybomb_e;
4691 next[x+1][y] = Xbomb_pause;
4698 static void Lbomb_pause(int x, int y)
4700 switch (cave[x][y+1])
4713 cave[x][y] = Ybomb_sB;
4714 next[x][y] = Xblank;
4715 cave[x][y+1] = Ybomb_s;
4716 next[x][y+1] = Xbomb_fall;
4727 cave[x][y] = Ybomb_sB;
4728 next[x][y] = Xblank;
4729 if (cave[x+1][y] == Xblank)
4730 cave[x+1][y] = Xsplash_e;
4731 if (cave[x-1][y] == Xblank)
4732 cave[x-1][y] = Xsplash_w;
4733 play_element_sound(x, y, SOUND_acid, Xacid_1);
4743 static void Lbomb_fall(int x, int y)
4745 switch (cave[x][y+1])
4758 cave[x][y] = Ybomb_sB;
4759 next[x][y] = Xblank;
4760 cave[x][y+1] = Ybomb_s;
4761 next[x][y+1] = Xbomb_fall;
4772 cave[x][y] = Ybomb_sB;
4773 next[x][y] = Xblank;
4774 if (cave[x+1][y] == Xblank)
4775 cave[x+1][y] = Xsplash_e;
4776 if (cave[x-1][y] == Xblank)
4777 cave[x-1][y] = Xsplash_w;
4778 play_element_sound(x, y, SOUND_acid, Xacid_1);
4782 cave[x][y] = Ybomb_blank;
4783 Lboom_tank(x, y, Xbomb_fall);
4788 static void Lnut(int x, int y)
4790 switch (cave[x][y+1])
4803 cave[x][y] = Ynut_sB;
4804 next[x][y] = Xblank;
4805 cave[x][y+1] = Ynut_s;
4806 next[x][y+1] = Xnut_fall;
4817 cave[x][y] = Ynut_sB;
4818 next[x][y] = Xblank;
4819 if (cave[x+1][y] == Xblank)
4820 cave[x+1][y] = Xsplash_e;
4821 if (cave[x-1][y] == Xblank)
4822 cave[x-1][y] = Xsplash_w;
4823 play_element_sound(x, y, SOUND_acid, Xacid_1);
4842 case Xemerald_pause:
4844 case Xdiamond_pause:
4872 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4874 cave[x][y] = Ynut_eB;
4875 next[x][y] = Xblank;
4876 cave[x+1][y] = Ynut_e;
4877 next[x+1][y] = Xnut_pause;
4881 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4883 cave[x][y] = Ynut_wB;
4884 next[x][y] = Xblank;
4885 cave[x-1][y] = Ynut_w;
4886 next[x-1][y] = Xnut_pause;
4892 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
4894 cave[x][y] = Ynut_wB;
4895 next[x][y] = Xblank;
4896 cave[x-1][y] = Ynut_w;
4897 next[x-1][y] = Xnut_pause;
4901 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
4903 cave[x][y] = Ynut_eB;
4904 next[x][y] = Xblank;
4905 cave[x+1][y] = Ynut_e;
4906 next[x+1][y] = Xnut_pause;
4913 static void Lnut_pause(int x, int y)
4915 switch (cave[x][y+1])
4928 cave[x][y] = Ynut_sB;
4929 next[x][y] = Xblank;
4930 cave[x][y+1] = Ynut_s;
4931 next[x][y+1] = Xnut_fall;
4942 cave[x][y] = Ynut_sB;
4943 next[x][y] = Xblank;
4944 if (cave[x+1][y] == Xblank)
4945 cave[x+1][y] = Xsplash_e;
4946 if (cave[x-1][y] == Xblank)
4947 cave[x-1][y] = Xsplash_w;
4948 play_element_sound(x, y, SOUND_acid, Xacid_1);
4958 static void Lnut_fall(int x, int y)
4960 switch (cave[x][y+1])
4974 cave[x][y] = Ynut_sB;
4975 next[x][y] = Xblank;
4976 cave[x][y+1] = Ynut_s;
4977 next[x][y+1] = Xnut_fall;
4988 cave[x][y] = Ynut_sB;
4989 next[x][y] = Xblank;
4990 if (cave[x+1][y] == Xblank)
4991 cave[x+1][y] = Xsplash_e;
4992 if (cave[x-1][y] == Xblank)
4993 cave[x-1][y] = Xsplash_w;
4994 play_element_sound(x, y, SOUND_acid, Xacid_1);
5000 play_element_sound(x, y, SOUND_nut, Xnut);
5005 static void Lspring(int x, int y)
5007 switch (cave[x][y+1])
5022 cave[x][y] = Yspring_sB;
5023 next[x][y] = Xblank;
5024 cave[x][y+1] = Yspring_s;
5025 next[x][y+1] = Xspring_fall;
5036 cave[x][y] = Yspring_sB;
5037 next[x][y] = Xblank;
5038 if (cave[x+1][y] == Xblank)
5039 cave[x+1][y] = Xsplash_e;
5040 if (cave[x-1][y] == Xblank)
5041 cave[x-1][y] = Xsplash_w;
5042 play_element_sound(x, y, SOUND_acid, Xacid_1);
5061 case Xemerald_pause:
5063 case Xdiamond_pause:
5091 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5093 cave[x][y] = Yspring_eB;
5094 next[x][y] = Xblank;
5095 cave[x+1][y] = Yspring_e;
5096 if (cave[x][y+1] == Xbumper)
5097 cave[x][y+1] = XbumperB;
5100 next[x+1][y] = Xspring_e;
5102 next[x+1][y] = Xspring_pause;
5107 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5109 cave[x][y] = Yspring_wB;
5110 next[x][y] = Xblank;
5111 cave[x-1][y] = Yspring_w;
5112 if (cave[x][y+1] == Xbumper)
5113 cave[x][y+1] = XbumperB;
5116 next[x-1][y] = Xspring_w;
5118 next[x-1][y] = Xspring_pause;
5125 if (is_blank[cave[x-1][y]] && is_blank_or_acid[cave[x-1][y+1]])
5127 cave[x][y] = Yspring_wB;
5128 next[x][y] = Xblank;
5129 cave[x-1][y] = Yspring_w;
5130 if (cave[x][y+1] == Xbumper)
5131 cave[x][y+1] = XbumperB;
5134 next[x-1][y] = Xspring_w;
5136 next[x-1][y] = Xspring_pause;
5141 if (is_blank[cave[x+1][y]] && is_blank_or_acid[cave[x+1][y+1]])
5143 cave[x][y] = Yspring_eB;
5144 next[x][y] = Xblank;
5145 cave[x+1][y] = Yspring_e;
5146 if (cave[x][y+1] == Xbumper)
5147 cave[x][y+1] = XbumperB;
5150 next[x+1][y] = Xspring_e;
5152 next[x+1][y] = Xspring_pause;
5160 static void Lspring_pause(int x, int y)
5162 switch (cave[x][y+1])
5175 cave[x][y] = Yspring_sB;
5176 next[x][y] = Xblank;
5177 cave[x][y+1] = Yspring_s;
5178 next[x][y+1] = Xspring_fall;
5189 cave[x][y] = Yspring_sB;
5190 next[x][y] = Xblank;
5191 if (cave[x+1][y] == Xblank)
5192 cave[x+1][y] = Xsplash_e;
5193 if (cave[x-1][y] == Xblank)
5194 cave[x-1][y] = Xsplash_w;
5195 play_element_sound(x, y, SOUND_acid, Xacid_1);
5199 cave[x][y] = Xspring;
5200 next[x][y] = Xspring;
5205 static void Lspring_e(int x, int y)
5207 switch (cave[x][y+1])
5220 cave[x][y] = Yspring_sB;
5221 next[x][y] = Xblank;
5222 cave[x][y+1] = Yspring_s;
5223 next[x][y+1] = Xspring_fall;
5234 cave[x][y] = Yspring_sB;
5235 next[x][y] = Xblank;
5236 if (cave[x+1][y] == Xblank)
5237 cave[x+1][y] = Xsplash_e;
5238 if (cave[x-1][y] == Xblank)
5239 cave[x-1][y] = Xsplash_w;
5240 play_element_sound(x, y, SOUND_acid, Xacid_1);
5244 cave[x][y+1] = XbumperB;
5247 switch (cave[x+1][y])
5264 cave[x][y] = Yspring_eB;
5265 next[x][y] = Xblank;
5266 cave[x+1][y] = Yspring_e;
5267 next[x+1][y] = Xspring_e;
5278 cave[x][y] = Yspring_eB;
5279 next[x][y] = Xblank;
5280 if (cave[x+2][y-1] == Xblank)
5281 cave[x+2][y-1] = Xsplash_e;
5282 if (cave[x][y-1] == Xblank)
5283 cave[x][y-1] = Xsplash_w;
5284 play_element_sound(x, y, SOUND_acid, Xacid_1);
5293 cave[x][y] = Yspring_alien_eB;
5294 next[x][y] = Xblank;
5295 cave[x+1][y] = Yspring_alien_e;
5296 next[x+1][y] = Xspring_e;
5297 play_element_sound(x, y, SOUND_slurp, Xalien);
5298 score += lev.slurp_score;
5303 cave[x+1][y] = XbumperB;
5304 next[x][y] = Xspring_w;
5305 play_element_sound(x, y, SOUND_spring, Xspring);
5309 cave[x][y] = Xspring;
5310 next[x][y] = Xspring;
5311 play_element_sound(x, y, SOUND_spring, Xspring);
5316 static void Lspring_w(int x, int y)
5318 switch (cave[x][y+1])
5331 cave[x][y] = Yspring_sB;
5332 next[x][y] = Xblank;
5333 cave[x][y+1] = Yspring_s;
5334 next[x][y+1] = Xspring_fall;
5345 cave[x][y] = Yspring_sB;
5346 next[x][y] = Xblank;
5347 if (cave[x+1][y] == Xblank)
5348 cave[x+1][y] = Xsplash_e;
5349 if (cave[x-1][y] == Xblank)
5350 cave[x-1][y] = Xsplash_w;
5351 play_element_sound(x, y, SOUND_acid, Xacid_1);
5355 cave[x][y+1] = XbumperB;
5358 switch (cave[x-1][y])
5375 cave[x][y] = Yspring_wB;
5376 next[x][y] = Xblank;
5377 cave[x-1][y] = Yspring_w;
5378 next[x-1][y] = Xspring_w;
5389 cave[x][y] = Yspring_wB;
5390 next[x][y] = Xblank;
5391 if (cave[x][y-1] == Xblank)
5392 cave[x][y-1] = Xsplash_e;
5393 if (cave[x-2][y-1] == Xblank)
5394 cave[x-2][y-1] = Xsplash_w;
5395 play_element_sound(x, y, SOUND_acid, Xacid_1);
5404 cave[x][y] = Yspring_alien_wB;
5405 next[x][y] = Xblank;
5406 cave[x-1][y] = Yspring_alien_w;
5407 next[x-1][y] = Xspring_w;
5408 play_element_sound(x, y, SOUND_slurp, Xalien);
5409 score += lev.slurp_score;
5414 cave[x-1][y] = XbumperB;
5415 next[x][y] = Xspring_e;
5416 play_element_sound(x, y, SOUND_spring, Xspring);
5420 cave[x][y] = Xspring;
5421 next[x][y] = Xspring;
5422 play_element_sound(x, y, SOUND_spring, Xspring);
5427 static void Lspring_fall(int x, int y)
5429 switch (cave[x][y+1])
5443 cave[x][y] = Yspring_sB;
5444 next[x][y] = Xblank;
5445 cave[x][y+1] = Yspring_s;
5446 next[x][y+1] = Xspring_fall;
5457 cave[x][y] = Yspring_sB;
5458 next[x][y] = Xblank;
5459 if (cave[x+1][y] == Xblank)
5460 cave[x+1][y] = Xsplash_e;
5461 if (cave[x-1][y] == Xblank)
5462 cave[x-1][y] = Xsplash_w;
5463 play_element_sound(x, y, SOUND_acid, Xacid_1);
5468 cave[x][y+1] = Ybomb_blank;
5469 Lboom_tank(x, y+1, Xspring_fall);
5480 cave[x][y] = Yspring_sB;
5481 cave[x][y+1] = Ybug_spring;
5482 Lboom_bug(x, y+1, Xspring_fall);
5483 score += lev.bug_score;
5494 cave[x][y] = Yspring_sB;
5495 cave[x][y+1] = Ytank_spring;
5496 Lboom_tank(x, y+1, Xspring_fall);
5497 score += lev.tank_score;
5504 cave[x][y] = Yspring_sB;
5505 cave[x][y+1] = Yeater_spring;
5506 Lboom_eater(x, y+1, Xspring_fall);
5507 score += lev.eater_score;
5512 cave[x][y] = Yspring_sB;
5513 cave[x][y+1] = Yalien_spring;
5514 Lboom_tank(x, y+1, Xspring_fall);
5515 score += lev.alien_score;
5519 cave[x][y] = Xspring;
5520 next[x][y] = Xspring;
5521 play_element_sound(x, y, SOUND_spring, Xspring);
5526 static void Lpush_emerald_e(int x, int y)
5528 switch (cave[x+1][y])
5538 cave[x][y] = Xemerald;
5539 next[x][y] = Xemerald;
5543 cave[x][y] = Yemerald_eB;
5544 next[x][y] = Xblank;
5545 cave[x+1][y] = Yemerald_e;
5546 next[x+1][y] = Xemerald_pause;
5551 static void Lpush_emerald_w(int x, int y)
5553 switch (cave[x-1][y])
5563 cave[x][y] = Xemerald;
5564 next[x][y] = Xemerald;
5568 cave[x][y] = Yemerald_wB;
5569 next[x][y] = Xblank;
5570 cave[x-1][y] = Yemerald_w;
5571 next[x-1][y] = Xemerald_pause;
5576 static void Lpush_diamond_e(int x, int y)
5578 switch (cave[x+1][y])
5588 cave[x][y] = Xdiamond;
5589 next[x][y] = Xdiamond;
5593 cave[x][y] = Ydiamond_eB;
5594 next[x][y] = Xblank;
5595 cave[x+1][y] = Ydiamond_e;
5596 next[x+1][y] = Xdiamond_pause;
5601 static void Lpush_diamond_w(int x, int y)
5603 switch (cave[x-1][y])
5613 cave[x][y] = Xdiamond;
5614 next[x][y] = Xdiamond;
5618 cave[x][y] = Ydiamond_wB;
5619 next[x][y] = Xblank;
5620 cave[x-1][y] = Ydiamond_w;
5621 next[x-1][y] = Xdiamond_pause;
5626 static void Lpush_stone_e(int x, int y)
5628 switch (cave[x+1][y])
5638 cave[x][y] = Xstone;
5639 next[x][y] = Xstone;
5643 cave[x][y] = Ystone_eB;
5644 next[x][y] = Xblank;
5645 cave[x+1][y] = Ystone_e;
5646 next[x+1][y] = Xstone_pause;
5651 static void Lpush_stone_w(int x, int y)
5653 switch (cave[x-1][y])
5663 cave[x][y] = Xstone;
5664 next[x][y] = Xstone;
5668 cave[x][y] = Ystone_wB;
5669 next[x][y] = Xblank;
5670 cave[x-1][y] = Ystone_w;
5671 next[x-1][y] = Xstone_pause;
5676 static void Lpush_bomb_e(int x, int y)
5678 switch (cave[x+1][y])
5693 cave[x][y] = Ybomb_eB;
5694 next[x][y] = Xblank;
5695 cave[x+1][y] = Ybomb_e;
5696 next[x+1][y] = Xbomb_pause;
5701 static void Lpush_bomb_w(int x, int y)
5703 switch (cave[x-1][y])
5718 cave[x][y] = Ybomb_wB;
5719 next[x][y] = Xblank;
5720 cave[x-1][y] = Ybomb_w;
5721 next[x-1][y] = Xbomb_pause;
5726 static void Lpush_nut_e(int x, int y)
5728 switch (cave[x+1][y])
5743 cave[x][y] = Ynut_eB;
5744 next[x][y] = Xblank;
5745 cave[x+1][y] = Ynut_e;
5746 next[x+1][y] = Xnut_pause;
5751 static void Lpush_nut_w(int x, int y)
5753 switch (cave[x-1][y])
5768 cave[x][y] = Ynut_wB;
5769 next[x][y] = Xblank;
5770 cave[x-1][y] = Ynut_w;
5771 next[x-1][y] = Xnut_pause;
5776 static void Lpush_spring_e(int x, int y)
5778 switch (cave[x+1][y])
5788 cave[x][y] = Xspring;
5789 next[x][y] = Xspring;
5793 cave[x][y] = Yspring_eB;
5794 next[x][y] = Xblank;
5795 cave[x+1][y] = Yspring_e;
5796 next[x+1][y] = Xspring_e;
5801 static void Lpush_spring_w(int x, int y)
5803 switch (cave[x-1][y])
5813 cave[x][y] = Xspring;
5814 next[x][y] = Xspring;
5818 cave[x][y] = Yspring_wB;
5819 next[x][y] = Xblank;
5820 cave[x-1][y] = Yspring_w;
5821 next[x-1][y] = Xspring_w;
5826 static void Ldynamite_1(int x, int y)
5828 play_element_sound(x, y, SOUND_tick, Xdynamite_1);
5829 next[x][y] = Xdynamite_2;
5832 static void Ldynamite_2(int x, int y)
5834 play_element_sound(x, y, SOUND_tick, Xdynamite_2);
5835 next[x][y] = Xdynamite_3;
5838 static void Ldynamite_3(int x, int y)
5840 play_element_sound(x, y, SOUND_tick, Xdynamite_3);
5841 next[x][y] = Xdynamite_4;
5844 static void Ldynamite_4(int x, int y)
5846 play_element_sound(x, y, SOUND_tick, Xdynamite_4);
5847 next[x][y] = Zdynamite;
5849 Lboom_generic(x, y, Xblank, Xblank);
5852 static void Lfake_door_1(int x, int y)
5854 if (lev.magnify_cnt)
5855 cave[x][y] = Xdoor_1;
5858 static void Lfake_door_2(int x, int y)
5860 if (lev.magnify_cnt)
5861 cave[x][y] = Xdoor_2;
5864 static void Lfake_door_3(int x, int y)
5866 if (lev.magnify_cnt)
5867 cave[x][y] = Xdoor_3;
5870 static void Lfake_door_4(int x, int y)
5872 if (lev.magnify_cnt)
5873 cave[x][y] = Xdoor_4;
5876 static void Lfake_door_5(int x, int y)
5878 if (lev.magnify_cnt)
5879 cave[x][y] = Xdoor_5;
5882 static void Lfake_door_6(int x, int y)
5884 if (lev.magnify_cnt)
5885 cave[x][y] = Xdoor_6;
5888 static void Lfake_door_7(int x, int y)
5890 if (lev.magnify_cnt)
5891 cave[x][y] = Xdoor_7;
5894 static void Lfake_door_8(int x, int y)
5896 if (lev.magnify_cnt)
5897 cave[x][y] = Xdoor_8;
5900 static void Lballoon(int x, int y)
5902 if (lev.wind_cnt == 0)
5905 switch (lev.wind_direction)
5908 switch (cave[x][y-1])
5921 cave[x][y] = Yballoon_nB;
5922 next[x][y] = Xblank;
5923 cave[x][y-1] = Yballoon_n;
5924 next[x][y-1] = Xballoon;
5935 cave[x][y] = Yballoon_nB;
5936 next[x][y] = Xblank;
5937 if (cave[x+1][y-2] == Xblank)
5938 cave[x+1][y-2] = Xsplash_e;
5939 if (cave[x-1][y-2] == Xblank)
5940 cave[x-1][y-2] = Xsplash_w;
5941 play_element_sound(x, y, SOUND_acid, Xacid_1);
5947 switch (cave[x+1][y])
5960 cave[x][y] = Yballoon_eB;
5961 next[x][y] = Xblank;
5962 cave[x+1][y] = Yballoon_e;
5963 next[x+1][y] = Xballoon;
5974 cave[x][y] = Yballoon_eB;
5975 next[x][y] = Xblank;
5976 if (cave[x+2][y-1] == Xblank)
5977 cave[x+2][y-1] = Xsplash_e;
5978 if (cave[x][y-1] == Xblank)
5979 cave[x][y-1] = Xsplash_w;
5980 play_element_sound(x, y, SOUND_acid, Xacid_1);
5986 switch (cave[x][y+1])
5999 cave[x][y] = Yballoon_sB;
6000 next[x][y] = Xblank;
6001 cave[x][y+1] = Yballoon_s;
6002 next[x][y+1] = Xballoon;
6013 cave[x][y] = Yballoon_sB;
6014 next[x][y] = Xblank;
6015 if (cave[x+1][y] == Xblank)
6016 cave[x+1][y] = Xsplash_e;
6017 if (cave[x-1][y] == Xblank)
6018 cave[x-1][y] = Xsplash_w;
6019 play_element_sound(x, y, SOUND_acid, Xacid_1);
6025 switch (cave[x-1][y])
6038 cave[x][y] = Yballoon_wB;
6039 next[x][y] = Xblank;
6040 cave[x-1][y] = Yballoon_w;
6041 next[x-1][y] = Xballoon;
6052 cave[x][y] = Yballoon_wB;
6053 next[x][y] = Xblank;
6054 if (cave[x][y-1] == Xblank)
6055 cave[x][y-1] = Xsplash_e;
6056 if (cave[x-2][y-1] == Xblank)
6057 cave[x-2][y-1] = Xsplash_w;
6058 play_element_sound(x, y, SOUND_acid, Xacid_1);
6065 static void Lball_common(int x, int y)
6067 play_element_sound(x, y, SOUND_ball, Xball_1);
6069 if (lev.ball_random)
6074 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6075 is_blank[cave[x-1][y-1]])
6077 cave[x-1][y-1] = Yball_blank;
6078 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6083 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6084 is_blank[cave[x][y-1]])
6086 cave[x][y-1] = Yball_blank;
6087 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6092 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6093 is_blank[cave[x+1][y-1]])
6095 cave[x+1][y-1] = Yball_blank;
6096 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6101 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6102 is_blank[cave[x-1][y]])
6104 cave[x-1][y] = Yball_blank;
6105 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6110 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6111 is_blank[cave[x+1][y]])
6113 cave[x+1][y] = Yball_blank;
6114 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6119 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6120 is_blank[cave[x-1][y+1]])
6122 cave[x-1][y+1] = Yball_blank;
6123 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6128 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6129 is_blank[cave[x][y+1]])
6131 cave[x][y+1] = Yball_blank;
6132 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6137 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6138 is_blank[cave[x+1][y+1]])
6140 cave[x+1][y+1] = Yball_blank;
6141 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6148 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
6149 is_blank[cave[x-1][y-1]])
6151 cave[x-1][y-1] = Yball_blank;
6152 next[x-1][y-1] = lev.ball_array[lev.ball_pos][0];
6155 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
6156 is_blank[cave[x][y-1]])
6158 cave[x][y-1] = Yball_blank;
6159 next[x][y-1] = lev.ball_array[lev.ball_pos][1];
6162 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
6163 is_blank[cave[x+1][y-1]])
6165 cave[x+1][y-1] = Yball_blank;
6166 next[x+1][y-1] = lev.ball_array[lev.ball_pos][2];
6169 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
6170 is_blank[cave[x-1][y]])
6172 cave[x-1][y] = Yball_blank;
6173 next[x-1][y] = lev.ball_array[lev.ball_pos][3];
6176 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
6177 is_blank[cave[x+1][y]])
6179 cave[x+1][y] = Yball_blank;
6180 next[x+1][y] = lev.ball_array[lev.ball_pos][4];
6183 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
6184 is_blank[cave[x-1][y+1]])
6186 cave[x-1][y+1] = Yball_blank;
6187 next[x-1][y+1] = lev.ball_array[lev.ball_pos][5];
6190 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
6191 is_blank[cave[x][y+1]])
6193 cave[x][y+1] = Yball_blank;
6194 next[x][y+1] = lev.ball_array[lev.ball_pos][6];
6197 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
6198 is_blank[cave[x+1][y+1]])
6200 cave[x+1][y+1] = Yball_blank;
6201 next[x+1][y+1] = lev.ball_array[lev.ball_pos][7];
6205 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
6208 static void Lball_1(int x, int y)
6210 if (lev.ball_state == 0)
6213 cave[x][y] = Yball_1;
6214 next[x][y] = Xball_2;
6221 static void Lball_2(int x, int y)
6223 if (lev.ball_state == 0)
6226 cave[x][y] = Yball_2;
6227 next[x][y] = Xball_1;
6234 static void Ldrip(int x, int y)
6236 next[x][y] = Xdrip_fall;
6239 static void Ldrip_fall(int x, int y)
6243 switch (cave[x][y+1])
6259 cave[x][y] = Ydrip_1_sB;
6260 next[x][y] = Xdrip_stretchB;
6261 cave[x][y+1] = Ydrip_1_s;
6262 next[x][y+1] = Xdrip_stretch;
6273 cave[x][y] = Ydrip_1_sB;
6274 next[x][y] = Xdrip_stretchB;
6275 if (cave[x+1][y] == Xblank)
6276 cave[x+1][y] = Xsplash_e;
6277 if (cave[x-1][y] == Xblank)
6278 cave[x-1][y] = Xsplash_w;
6279 play_element_sound(x, y, SOUND_acid, Xacid_1);
6285 case 0: temp = Xamoeba_1; break;
6286 case 1: temp = Xamoeba_2; break;
6287 case 2: temp = Xamoeba_3; break;
6288 case 3: temp = Xamoeba_4; break;
6289 case 4: temp = Xamoeba_5; break;
6290 case 5: temp = Xamoeba_6; break;
6291 case 6: temp = Xamoeba_7; break;
6292 case 7: temp = Xamoeba_8; break;
6297 play_element_sound(x, y, SOUND_drip, Xdrip_fall);
6302 static void Ldrip_stretch(int x, int y)
6304 cave[x][y] = Ydrip_2_s;
6305 next[x][y] = Xdrip_fall;
6308 static void Ldrip_stretchB(int x, int y)
6310 cave[x][y] = Ydrip_2_sB;
6311 next[x][y] = Xblank;
6314 static void Lwonderwall(int x, int y)
6316 if (lev.wonderwall_time && lev.wonderwall_state)
6318 cave[x][y] = XwonderwallB;
6319 play_element_sound(x, y, SOUND_wonder, Xwonderwall);
6323 static void Lwheel(int x, int y)
6325 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
6326 cave[x][y] = XwheelB;
6329 static void Lswitch(int x, int y)
6332 cave[x][y] = XswitchB;
6335 static void Lfake_blank(int x, int y)
6338 cave[x][y] = Xfake_blankB;
6341 static void Lfake_grass(int x, int y)
6343 if (lev.magnify_cnt)
6344 cave[x][y] = Xfake_grassB;
6347 static void Lfake_amoeba(int x, int y)
6350 cave[x][y] = Xfake_amoebaB;
6353 static void Lsand_stone(int x, int y)
6355 switch (cave[x][y+1])
6368 cave[x][y] = Xsand_stonesand_quickout_1;
6369 next[x][y] = Xsand_stonesand_quickout_2;
6370 cave[x][y+1] = Xsand_stoneout_1;
6371 next[x][y+1] = Xsand_stoneout_2;
6382 cave[x][y] = Xsand_stonesand_quickout_1;
6383 next[x][y] = Xsand_stonesand_quickout_2;
6384 if (cave[x+1][y] == Xblank)
6385 cave[x+1][y] = Xsplash_e;
6386 if (cave[x-1][y] == Xblank)
6387 cave[x-1][y] = Xsplash_w;
6388 play_element_sound(x, y, SOUND_acid, Xacid_1);
6392 cave[x][y] = Xsand_stonesand_1;
6393 next[x][y] = Xsand_stonesand_2;
6394 cave[x][y+1] = Xsand_sandstone_1;
6395 next[x][y+1] = Xsand_sandstone_2;
6400 static void Lsand_stonein_1(int x, int y)
6402 next[x][y] = Xsand_stonein_2;
6405 static void Lsand_stonein_2(int x, int y)
6407 next[x][y] = Xsand_stonein_3;
6410 static void Lsand_stonein_3(int x, int y)
6412 next[x][y] = Xsand_stonein_4;
6415 static void Lsand_stonein_4(int x, int y)
6417 next[x][y] = Xblank;
6420 static void Lsand_sandstone_1(int x, int y)
6422 next[x][y] = Xsand_sandstone_2;
6425 static void Lsand_sandstone_2(int x, int y)
6427 next[x][y] = Xsand_sandstone_3;
6430 static void Lsand_sandstone_3(int x, int y)
6432 next[x][y] = Xsand_sandstone_4;
6435 static void Lsand_sandstone_4(int x, int y)
6437 next[x][y] = Xsand_stone;
6440 static void Lsand_stonesand_1(int x, int y)
6442 next[x][y] = Xsand_stonesand_2;
6445 static void Lsand_stonesand_2(int x, int y)
6447 next[x][y] = Xsand_stonesand_3;
6450 static void Lsand_stonesand_3(int x, int y)
6452 next[x][y] = Xsand_stonesand_4;
6455 static void Lsand_stonesand_4(int x, int y)
6460 static void Lsand_stoneout_1(int x, int y)
6462 next[x][y] = Xsand_stoneout_2;
6465 static void Lsand_stoneout_2(int x, int y)
6467 next[x][y] = Xstone_fall;
6470 static void Lsand_stonesand_quickout_1(int x, int y)
6472 next[x][y] = Xsand_stonesand_quickout_2;
6475 static void Lsand_stonesand_quickout_2(int x, int y)
6480 static void Lslide_ns(int x, int y)
6482 if (is_blank[cave[x][y-1]])
6484 cave[x][y-1] = Yslide_ns_blank;
6485 next[x][y-1] = Xslide_ns;
6486 play_element_sound(x, y, SOUND_slide, Xslide_ns);
6489 if (is_blank[cave[x][y+1]])
6491 cave[x][y+1] = Yslide_ns_blank;
6492 next[x][y+1] = Xslide_ns;
6493 play_element_sound(x, y, SOUND_slide, Xslide_ns);
6497 static void Lslide_ew(int x, int y)
6499 if (is_blank[cave[x+1][y]])
6501 cave[x+1][y] = Yslide_ew_blank;
6502 next[x+1][y] = Xslide_ew;
6503 play_element_sound(x, y, SOUND_slide, Xslide_ew);
6506 if (is_blank[cave[x-1][y]])
6508 cave[x-1][y] = Yslide_ew_blank;
6509 next[x-1][y] = Xslide_ew;
6510 play_element_sound(x, y, SOUND_slide, Xslide_ew);
6514 static void Lexit(int x, int y)
6516 if (lev.required > 0)
6519 switch (RANDOM(64) / 21)
6522 cave[x][y] = Xexit_1;
6523 next[x][y] = Xexit_2;
6527 cave[x][y] = Xexit_2;
6528 next[x][y] = Xexit_3;
6532 cave[x][y] = Xexit_3;
6533 next[x][y] = Xexit_1;
6537 play_element_sound(x, y, SOUND_exit_open, Xexit);
6540 static void Lexit_1(int x, int y)
6542 next[x][y] = Xexit_2;
6545 static void Lexit_2(int x, int y)
6547 next[x][y] = Xexit_3;
6550 static void Lexit_3(int x, int y)
6552 next[x][y] = Xexit_1;
6555 static void Lpause(int x, int y)
6557 next[x][y] = Xblank;
6560 static void Lamoeba(int x, int y)
6580 if (is_amoeba[cave[x][y-1]] ||
6581 is_amoeba[cave[x+1][y]] ||
6582 is_amoeba[cave[x][y+1]] ||
6583 is_amoeba[cave[x-1][y]])
6588 static void Lboom_one(int x, int y, boolean by_dynamite)
6645 cave[x][y] = Xboom_android;
6656 cave[x][y] = Xboom_bug;
6662 cave[x][y] = Xboom_bomb;
6666 cave[x][y] = Xboom_1;
6671 static void Lboom_nine(int x, int y, boolean by_dynamite)
6673 Lboom_one(x, y-1, by_dynamite);
6674 Lboom_one(x-1, y, by_dynamite);
6675 Lboom_one(x+1, y, by_dynamite);
6676 Lboom_one(x, y+1, by_dynamite);
6677 Lboom_one(x-1, y-1, by_dynamite);
6678 Lboom_one(x+1, y-1, by_dynamite);
6679 Lboom_one(x-1, y+1, by_dynamite);
6680 Lboom_one(x+1, y+1, by_dynamite);
6682 cave[x][y] = Xboom_1;
6685 static void Lexplode(int x, int y)
6690 Lboom_nine(x, y, FALSE);
6694 Lboom_nine(x, y, TRUE);
6699 static void Lboom_1(int x, int y)
6701 next[x][y] = Xboom_2;
6702 #if !PLAY_ELEMENT_SOUND
6703 if (x != lev.exit_x && y != lev.exit_y)
6704 play_sound(x, y, SOUND_boom);
6706 lev.exit_x = lev.exit_y = -1;
6710 static void Lboom_2(int x, int y)
6712 next[x][y] = boom[x][y];
6715 static void Lboom_android(int x, int y)
6717 #if PLAY_ELEMENT_SOUND
6718 play_element_sound(x, y, SOUND_boom, Xandroid);
6724 static void handle_tile(int x, int y)
6728 case Xacid_1: Lacid_1(x, y); break;
6729 case Xacid_2: Lacid_2(x, y); break;
6730 case Xacid_3: Lacid_3(x, y); break;
6731 case Xacid_4: Lacid_4(x, y); break;
6732 case Xacid_5: Lacid_5(x, y); break;
6733 case Xacid_6: Lacid_6(x, y); break;
6734 case Xacid_7: Lacid_7(x, y); break;
6735 case Xacid_8: Lacid_8(x, y); break;
6737 case Xfake_acid_1: Lfake_acid_1(x, y); break;
6738 case Xfake_acid_2: Lfake_acid_2(x, y); break;
6739 case Xfake_acid_3: Lfake_acid_3(x, y); break;
6740 case Xfake_acid_4: Lfake_acid_4(x, y); break;
6741 case Xfake_acid_5: Lfake_acid_5(x, y); break;
6742 case Xfake_acid_6: Lfake_acid_6(x, y); break;
6743 case Xfake_acid_7: Lfake_acid_7(x, y); break;
6744 case Xfake_acid_8: Lfake_acid_8(x, y); break;
6746 case Xandroid: Landroid(x, y); break;
6747 case Xandroid_1_n: Landroid_1_n(x, y); break;
6748 case Xandroid_2_n: Landroid_2_n(x, y); break;
6749 case Xandroid_1_e: Landroid_1_e(x, y); break;
6750 case Xandroid_2_e: Landroid_2_e(x, y); break;
6751 case Xandroid_1_s: Landroid_1_s(x, y); break;
6752 case Xandroid_2_s: Landroid_2_s(x, y); break;
6753 case Xandroid_1_w: Landroid_1_w(x, y); break;
6754 case Xandroid_2_w: Landroid_2_w(x, y); break;
6756 case Xeater_n: Leater_n(x, y); break;
6757 case Xeater_e: Leater_e(x, y); break;
6758 case Xeater_s: Leater_s(x, y); break;
6759 case Xeater_w: Leater_w(x, y); break;
6761 case Xalien: Lalien(x, y); break;
6762 case Xalien_pause: Lalien_pause(x, y); break;
6764 case Xbug_1_n: Lbug_1_n(x, y); break;
6765 case Xbug_2_n: Lbug_2_n(x, y); break;
6766 case Xbug_1_e: Lbug_1_e(x, y); break;
6767 case Xbug_2_e: Lbug_2_e(x, y); break;
6768 case Xbug_1_s: Lbug_1_s(x, y); break;
6769 case Xbug_2_s: Lbug_2_s(x, y); break;
6770 case Xbug_1_w: Lbug_1_w(x, y); break;
6771 case Xbug_2_w: Lbug_2_w(x, y); break;
6773 case Xtank_1_n: Ltank_1_n(x, y); break;
6774 case Xtank_2_n: Ltank_2_n(x, y); break;
6775 case Xtank_1_e: Ltank_1_e(x, y); break;
6776 case Xtank_2_e: Ltank_2_e(x, y); break;
6777 case Xtank_1_s: Ltank_1_s(x, y); break;
6778 case Xtank_2_s: Ltank_2_s(x, y); break;
6779 case Xtank_1_w: Ltank_1_w(x, y); break;
6780 case Xtank_2_w: Ltank_2_w(x, y); break;
6782 case Xemerald: Lemerald(x, y); break;
6783 case Xemerald_pause: Lemerald_pause(x, y); break;
6784 case Xemerald_fall: Lemerald_fall(x, y); break;
6786 case Xdiamond: Ldiamond(x, y); break;
6787 case Xdiamond_pause: Ldiamond_pause(x, y); break;
6788 case Xdiamond_fall: Ldiamond_fall(x, y); break;
6790 case Xstone: Lstone(x, y); break;
6791 case Xstone_pause: Lstone_pause(x, y); break;
6792 case Xstone_fall: Lstone_fall(x, y); break;
6794 case Xbomb: Lbomb(x, y); break;
6795 case Xbomb_pause: Lbomb_pause(x, y); break;
6796 case Xbomb_fall: Lbomb_fall(x, y); break;
6798 case Xnut: Lnut(x, y); break;
6799 case Xnut_pause: Lnut_pause(x, y); break;
6800 case Xnut_fall: Lnut_fall(x, y); break;
6802 case Xspring: Lspring(x, y); break;
6803 case Xspring_pause: Lspring_pause(x, y); break;
6804 case Xspring_e: Lspring_e(x, y); break;
6805 case Xspring_w: Lspring_w(x, y); break;
6806 case Xspring_fall: Lspring_fall(x, y); break;
6808 case Xpush_emerald_e: Lpush_emerald_e(x, y); break;
6809 case Xpush_emerald_w: Lpush_emerald_w(x, y); break;
6810 case Xpush_diamond_e: Lpush_diamond_e(x, y); break;
6811 case Xpush_diamond_w: Lpush_diamond_w(x, y); break;
6812 case Xpush_stone_e: Lpush_stone_e(x, y); break;
6813 case Xpush_stone_w: Lpush_stone_w(x, y); break;
6814 case Xpush_bomb_e: Lpush_bomb_e(x, y); break;
6815 case Xpush_bomb_w: Lpush_bomb_w(x, y); break;
6816 case Xpush_nut_e: Lpush_nut_e(x, y); break;
6817 case Xpush_nut_w: Lpush_nut_w(x, y); break;
6818 case Xpush_spring_e: Lpush_spring_e(x, y); break;
6819 case Xpush_spring_w: Lpush_spring_w(x, y); break;
6821 case Xdynamite_1: Ldynamite_1(x, y); break;
6822 case Xdynamite_2: Ldynamite_2(x, y); break;
6823 case Xdynamite_3: Ldynamite_3(x, y); break;
6824 case Xdynamite_4: Ldynamite_4(x, y); break;
6826 case Xfake_door_1: Lfake_door_1(x, y); break;
6827 case Xfake_door_2: Lfake_door_2(x, y); break;
6828 case Xfake_door_3: Lfake_door_3(x, y); break;
6829 case Xfake_door_4: Lfake_door_4(x, y); break;
6830 case Xfake_door_5: Lfake_door_5(x, y); break;
6831 case Xfake_door_6: Lfake_door_6(x, y); break;
6832 case Xfake_door_7: Lfake_door_7(x, y); break;
6833 case Xfake_door_8: Lfake_door_8(x, y); break;
6835 case Xballoon: Lballoon(x, y); break;
6837 case Xball_1: Lball_1(x, y); break;
6838 case Xball_2: Lball_2(x, y); break;
6840 case Xdrip: Ldrip(x, y); break;
6841 case Xdrip_fall: Ldrip_fall(x, y); break;
6842 case Xdrip_stretch: Ldrip_stretch(x, y); break;
6843 case Xdrip_stretchB: Ldrip_stretchB(x, y); break;
6845 case Xwonderwall: Lwonderwall(x, y); break;
6847 case Xwheel: Lwheel(x, y); break;
6849 case Xswitch: Lswitch(x, y); break;
6851 case Xfake_blank: Lfake_blank(x, y); break;
6852 case Xfake_grass: Lfake_grass(x, y); break;
6853 case Xfake_amoeba: Lfake_amoeba(x, y); break;
6855 case Xsand_stone: Lsand_stone(x, y); break;
6856 case Xsand_stonein_1: Lsand_stonein_1(x, y); break;
6857 case Xsand_stonein_2: Lsand_stonein_2(x, y); break;
6858 case Xsand_stonein_3: Lsand_stonein_3(x, y); break;
6859 case Xsand_stonein_4: Lsand_stonein_4(x, y); break;
6860 case Xsand_sandstone_1: Lsand_sandstone_1(x, y); break;
6861 case Xsand_sandstone_2: Lsand_sandstone_2(x, y); break;
6862 case Xsand_sandstone_3: Lsand_sandstone_3(x, y); break;
6863 case Xsand_sandstone_4: Lsand_sandstone_4(x, y); break;
6864 case Xsand_stonesand_1: Lsand_stonesand_1(x, y); break;
6865 case Xsand_stonesand_2: Lsand_stonesand_2(x, y); break;
6866 case Xsand_stonesand_3: Lsand_stonesand_3(x, y); break;
6867 case Xsand_stonesand_4: Lsand_stonesand_4(x, y); break;
6868 case Xsand_stoneout_1: Lsand_stoneout_1(x, y); break;
6869 case Xsand_stoneout_2: Lsand_stoneout_2(x, y); break;
6870 case Xsand_stonesand_quickout_1: Lsand_stonesand_quickout_1(x, y); break;
6871 case Xsand_stonesand_quickout_2: Lsand_stonesand_quickout_2(x, y); break;
6873 case Xslide_ns: Lslide_ns(x, y); break;
6874 case Xslide_ew: Lslide_ew(x, y); break;
6876 case Xexit: Lexit(x, y); break;
6877 case Xexit_1: Lexit_1(x, y); break;
6878 case Xexit_2: Lexit_2(x, y); break;
6879 case Xexit_3: Lexit_3(x, y); break;
6881 case Xpause: Lpause(x, y); break;
6883 case Xboom_bug: Lboom_bug(x, y, Xboom_bug); break;
6884 case Xboom_bomb: Lboom_tank(x, y, Xboom_bomb); break;
6885 case Xboom_android: Lboom_android(x, y); break;
6886 case Xboom_1: Lboom_1(x, y); break;
6887 case Xboom_2: Lboom_2(x, y); break;
6891 void logic_players(void)
6900 game_em.any_player_moving = FALSE;
6901 game_em.any_player_snapping = FALSE;
6903 /* must test for death and actually kill separately */
6904 for (i = 0; i < MAX_PLAYERS; i++)
6906 boolean ply_kill = player_killed(&ply[i]);
6908 if (ply[i].alive && ply_kill)
6909 kill_player(&ply[i]);
6912 for (i = 0; i < MAX_PLAYERS; i++)
6914 /* check for wrap-around movement */
6915 if (ply[i].x < lev.left ||
6916 ply[i].x > lev.right - 1)
6918 ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left);
6920 game.centered_player_nr_next = i;
6921 game.set_centered_player = TRUE;
6922 game.set_centered_player_fast = TRUE;
6925 ply[i].oldx = ply[i].x;
6926 ply[i].oldy = ply[i].y;
6927 ply[i].anim = PLY_still;
6930 start_check_nr = (RandomEM & 128 ? 0 : 1) * 2 + (RandomEM & 256 ? 0 : 1);
6932 for (i = 0; i < MAX_PLAYERS; i++)
6934 int check_nr = (start_check_nr + i) % MAX_PLAYERS;
6936 if (ply[check_nr].alive)
6937 check_player(&ply[check_nr]);
6940 for (i = 0; i < MAX_PLAYERS; i++)
6945 if (cave[ply[i].oldx][ply[i].oldy] == Zplayer)
6947 cave[ply[i].oldx][ply[i].oldy] = Xblank;
6948 next[ply[i].oldx][ply[i].oldy] = Xblank;
6951 if (cave[ply[i].x][ply[i].y] == Xblank)
6953 cave[ply[i].x][ply[i].y] = Zplayer;
6954 next[ply[i].x][ply[i].y] = Zplayer;
6959 void logic_objects(void)
6970 for (y = lev.top; y < lev.bottom; y++)
6971 for (x = lev.left; x < lev.right; x++)
6974 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
6975 lev.score += score; /* only add a score if someone is alive */
6977 game_em.game_over = TRUE;
6981 /* triple buffering */
6982 void *temp = lev.cave;
6983 lev.cave = lev.next;
6984 lev.next = lev.draw;
6988 void logic_globals(void)
6993 unsigned int random;
6999 /* update variables */
7001 if (lev.score > 9999)
7004 if (lev.android_move_cnt-- == 0)
7005 lev.android_move_cnt = lev.android_move_time;
7006 if (lev.android_clone_cnt-- == 0)
7007 lev.android_clone_cnt = lev.android_clone_time;
7009 if (lev.ball_cnt-- == 0)
7010 lev.ball_cnt = lev.ball_time;
7013 if (lev.magnify_cnt)
7019 if (lev.wonderwall_time && lev.wonderwall_state)
7020 lev.wonderwall_time--;
7023 play_element_sound(lev.wheel_x, lev.wheel_y, SOUND_wheel, Xwheel);
7029 for (count = lev.amoeba_time; count--;)
7031 x = lev.left - 1 + (random >> 10) % (CAVE_WIDTH + 2);
7032 y = lev.top - 1 + (random >> 20) % (CAVE_HEIGHT + 2);
7034 if (x >= lev.left && x < lev.right &&
7035 y >= lev.top && y < lev.bottom)
7038 random = random * 129 + 1;
7043 /* handle explosions */
7045 for (y = lev.top; y < lev.bottom; y++)
7046 for (x = lev.left; x < lev.right; x++)
7049 /* triple buffering */
7051 for (y = lev.top; y < lev.bottom; y++)
7052 for (x = lev.left; x < lev.right; x++)
7053 next[x][y] = cave[x][y];