1 /* second part of synchro.
3 * game logic for monsters.
5 * one giant switch statement to process everything.
7 * this whole thing is a major bottleneck. the compiler must use registers.
14 #define SPRING_ROLL /* spring rolling off round things continues to roll */
16 #define RANDOM (random = random << 31 | random >> 1)
18 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
20 int distance, distance_shortest = EM_MAX_CAVE_WIDTH + EM_MAX_CAVE_HEIGHT;
23 /* default values if no players are alive anymore */
27 for (i = 0; i < MAX_PLAYERS; i++)
32 distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
34 if (distance < distance_shortest)
39 distance_shortest = distance;
48 unsigned int random = RandomEM;
49 short *cave_cache = Cave[y]; /* might be a win */
52 int temp = 0; /* initialized to make compilers happy */
53 int dx; /* only needed to find closest player */
59 element = cave_cache[++x];
66 /* --------------------------------------------------------------------- */
84 Cave[y][x] = Ystone_eB;
85 Cave[y][x+1] = Ystone_e;
87 Next[y][x+1] = Xstone_pause;
107 Cave[y][x] = Ystone_wB;
108 Cave[y][x-1] = Ystone_w;
110 Next[y][x-1] = Xstone_pause;
115 switch (Cave[y][x+1])
130 Cave[y][x] = Ynut_eB;
131 Cave[y][x+1] = Ynut_e;
133 Next[y][x+1] = Xnut_pause;
138 switch (Cave[y][x-1])
153 Cave[y][x] = Ynut_wB;
154 Cave[y][x-1] = Ynut_w;
156 Next[y][x-1] = Xnut_pause;
161 switch (Cave[y][x+1])
171 Cave[y][x] = Xspring;
172 Next[y][x] = Xspring;
176 Cave[y][x] = Yspring_eB;
177 Cave[y][x+1] = Yspring_e;
179 Next[y][x+1] = Xspring_e;
185 switch (Cave[y][x-1])
195 Cave[y][x] = Xspring;
196 Next[y][x] = Xspring;
200 Cave[y][x] = Yspring_wB;
201 Cave[y][x-1] = Yspring_w;
203 Next[y][x-1] = Xspring_w;
207 case Xpush_emerald_e:
208 switch (Cave[y][x+1])
218 Cave[y][x] = Xemerald;
219 Next[y][x] = Xemerald;
223 Cave[y][x] = Yemerald_eB;
224 Cave[y][x+1] = Yemerald_e;
226 Next[y][x+1] = Xemerald_pause;
230 case Xpush_emerald_w:
231 switch (Cave[y][x-1])
241 Cave[y][x] = Xemerald;
242 Next[y][x] = Xemerald;
246 Cave[y][x] = Yemerald_wB;
247 Cave[y][x-1] = Yemerald_w;
249 Next[y][x-1] = Xemerald_pause;
253 case Xpush_diamond_e:
254 switch (Cave[y][x+1])
264 Cave[y][x] = Xdiamond;
265 Next[y][x] = Xdiamond;
269 Cave[y][x] = Ydiamond_eB;
270 Cave[y][x+1] = Ydiamond_e;
272 Next[y][x+1] = Xdiamond_pause;
276 case Xpush_diamond_w:
277 switch (Cave[y][x-1])
287 Cave[y][x] = Xdiamond;
288 Next[y][x] = Xdiamond;
292 Cave[y][x] = Ydiamond_wB;
293 Cave[y][x-1] = Ydiamond_w;
295 Next[y][x-1] = Xdiamond_pause;
300 switch (Cave[y][x+1])
315 Cave[y][x] = Ybomb_eB;
316 Cave[y][x+1] = Ybomb_e;
318 Next[y][x+1] = Xbomb_pause;
323 switch (Cave[y][x-1])
338 Cave[y][x] = Ybomb_wB;
339 Cave[y][x-1] = Ybomb_w;
341 Next[y][x-1] = Xbomb_pause;
345 /* --------------------------------------------------------------------- */
348 switch (Cave[y+1][x])
358 Cave[y][x] = Ystone_sB;
359 if (Cave[y][x+1] == Xblank)
360 Cave[y][x+1] = Xacid_splash_e;
361 if (Cave[y][x-1] == Xblank)
362 Cave[y][x-1] = Xacid_splash_w;
364 play_element_sound(x, y, SOUND_acid, Xacid_1);
382 Cave[y][x] = Ystone_sB;
383 Cave[y+1][x] = Ystone_s;
385 Next[y+1][x] = Xstone_fall;
389 Cave[y][x] = Xsand_stonein_1;
390 Cave[y+1][x] = Xsand_sandstone_1;
391 Next[y][x] = Xsand_stonein_2;
392 Next[y+1][x] = Xsand_sandstone_2;
443 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
445 Cave[y][x] = Ystone_eB;
446 Cave[y][x+1] = Ystone_e;
448 Next[y][x+1] = Xstone_pause;
452 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
454 Cave[y][x] = Ystone_wB;
455 Cave[y][x-1] = Ystone_w;
457 Next[y][x-1] = Xstone_pause;
463 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
465 Cave[y][x] = Ystone_wB;
466 Cave[y][x-1] = Ystone_w;
468 Next[y][x-1] = Xstone_pause;
472 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
474 Cave[y][x] = Ystone_eB;
475 Cave[y][x+1] = Ystone_e;
477 Next[y][x+1] = Xstone_pause;
486 /* --------------------------------------------------------------------- */
489 switch (Cave[y+1][x])
499 Cave[y][x] = Ystone_sB;
500 if (Cave[y][x+1] == Xblank)
501 Cave[y][x+1] = Xacid_splash_e;
502 if (Cave[y][x-1] == Xblank)
503 Cave[y][x-1] = Xacid_splash_w;
505 play_element_sound(x, y, SOUND_acid, Xacid_1);
521 Cave[y][x] = Ystone_sB;
522 Cave[y+1][x] = Ystone_s;
524 Next[y+1][x] = Xstone_fall;
533 /* --------------------------------------------------------------------- */
536 switch (Cave[y+1][x])
546 Cave[y][x] = Ystone_sB;
547 if (Cave[y][x+1] == Xblank)
548 Cave[y][x+1] = Xacid_splash_e;
549 if (Cave[y][x-1] == Xblank)
550 Cave[y][x-1] = Xacid_splash_w;
552 play_element_sound(x, y, SOUND_acid, Xacid_1);
569 Cave[y][x] = Ystone_sB;
570 Cave[y+1][x] = Ystone_s;
572 Next[y+1][x] = Xstone_fall;
577 Cave[y+1][x] = Ynut_stone;
579 Next[y+1][x] = Xemerald;
580 play_element_sound(x, y, SOUND_crack, Xnut);
581 score += lev.nut_score;
592 Cave[y][x] = Ystone_sB;
593 Cave[y+1][x] = Ybug_stone;
594 Next[y+1][x] = Znormal;
595 Boom[y][x-1] = Xemerald;
596 Boom[y][x] = Xemerald;
597 Boom[y][x+1] = Xemerald;
598 Boom[y+1][x-1] = Xemerald;
599 Boom[y+1][x] = Xdiamond;
600 Boom[y+1][x+1] = Xemerald;
601 Boom[y+2][x-1] = Xemerald;
602 Boom[y+2][x] = Xemerald;
603 Boom[y+2][x+1] = Xemerald;
604 #if PLAY_ELEMENT_SOUND
605 play_element_sound(x, y, SOUND_boom, element);
607 score += lev.bug_score;
618 Cave[y][x] = Ystone_sB;
619 Cave[y+1][x] = Ytank_stone;
620 Next[y+1][x] = Znormal;
621 Boom[y][x-1] = Xblank;
623 Boom[y][x+1] = Xblank;
624 Boom[y+1][x-1] = Xblank;
625 Boom[y+1][x] = Xblank;
626 Boom[y+1][x+1] = Xblank;
627 Boom[y+2][x-1] = Xblank;
628 Boom[y+2][x] = Xblank;
629 Boom[y+2][x+1] = Xblank;
630 #if PLAY_ELEMENT_SOUND
631 play_element_sound(x, y, SOUND_boom, element);
633 score += lev.tank_score;
639 switch (Cave[y+1][x+1])
646 Cave[y+1][x] = Xspring_e;
650 Cave[y+1][x] = Xspring_w;
656 switch (Cave[y+1][x-1])
663 Cave[y+1][x] = Xspring_w;
666 Cave[y+1][x] = Xspring_e;
678 Cave[y][x] = Ystone_sB;
679 Cave[y+1][x] = Yeater_stone;
680 Next[y+1][x] = Znormal;
681 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
682 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
683 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
684 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
685 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
686 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
687 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
688 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
689 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
690 #if PLAY_ELEMENT_SOUND
691 play_element_sound(x, y, SOUND_boom, element);
693 lev.eater_pos = (lev.eater_pos + 1) & 7;
694 score += lev.eater_score;
699 Cave[y][x] = Ystone_sB;
700 Cave[y+1][x] = Yalien_stone;
701 Next[y+1][x] = Znormal;
702 Boom[y][x-1] = Xblank;
704 Boom[y][x+1] = Xblank;
705 Boom[y+1][x-1] = Xblank;
706 Boom[y+1][x] = Xblank;
707 Boom[y+1][x+1] = Xblank;
708 Boom[y+2][x-1] = Xblank;
709 Boom[y+2][x] = Xblank;
710 Boom[y+2][x+1] = Xblank;
711 #if PLAY_ELEMENT_SOUND
712 play_element_sound(x, y, SOUND_boom, element);
714 score += lev.alien_score;
719 switch (Cave[y+2][x])
768 play_element_sound(x, y, SOUND_stone, Xstone);
772 Cave[y][x] = Ystone_sB;
773 Cave[y+1][x] = Ydiamond_stone;
775 Next[y+1][x] = Xstone_pause;
776 play_element_sound(x, y, SOUND_squash, Xdiamond);
781 Cave[y+1][x] = Ybomb_blank;
782 Next[y+1][x] = Znormal;
783 Boom[y][x-1] = Xblank;
785 Boom[y][x+1] = Xblank;
786 Boom[y+1][x-1] = Xblank;
787 Boom[y+1][x] = Xblank;
788 Boom[y+1][x+1] = Xblank;
789 Boom[y+2][x-1] = Xblank;
790 Boom[y+2][x] = Xblank;
791 Boom[y+2][x+1] = Xblank;
792 #if PLAY_ELEMENT_SOUND
793 play_element_sound(x, y, SOUND_boom, element);
798 if (lev.wonderwall_time)
800 lev.wonderwall_state = 1;
801 Cave[y][x] = Ystone_sB;
803 if (tab_blank[Cave[y+2][x]])
805 Cave[y+2][x] = Yemerald_s;
806 Next[y+2][x] = Xemerald_fall;
810 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
817 play_element_sound(x, y, SOUND_stone, Xstone);
821 /* --------------------------------------------------------------------- */
824 switch (Cave[y+1][x])
834 Cave[y][x] = Ynut_sB;
835 if (Cave[y][x+1] == Xblank)
836 Cave[y][x+1] = Xacid_splash_e;
837 if (Cave[y][x-1] == Xblank)
838 Cave[y][x-1] = Xacid_splash_w;
840 play_element_sound(x, y, SOUND_acid, Xacid_1);
846 Cave[y][x] = Ynut_sB;
847 Cave[y+1][x] = Ynut_s;
849 Next[y+1][x] = Xnut_fall;
898 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
900 Cave[y][x] = Ynut_eB;
901 Cave[y][x+1] = Ynut_e;
903 Next[y][x+1] = Xnut_pause;
907 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
909 Cave[y][x] = Ynut_wB;
910 Cave[y][x-1] = Ynut_w;
912 Next[y][x-1] = Xnut_pause;
918 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
920 Cave[y][x] = Ynut_wB;
921 Cave[y][x-1] = Ynut_w;
923 Next[y][x-1] = Xnut_pause;
927 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
929 Cave[y][x] = Ynut_eB;
930 Cave[y][x+1] = Ynut_e;
932 Next[y][x+1] = Xnut_pause;
941 /* --------------------------------------------------------------------- */
945 switch (Cave[y+1][x])
955 Cave[y][x] = Ynut_sB;
956 if (Cave[y][x+1] == Xblank)
957 Cave[y][x+1] = Xacid_splash_e;
958 if (Cave[y][x-1] == Xblank)
959 Cave[y][x-1] = Xacid_splash_w;
961 play_element_sound(x, y, SOUND_acid, Xacid_1);
967 Cave[y][x] = Ynut_sB;
968 Cave[y+1][x] = Ynut_s;
970 Next[y+1][x] = Xnut_fall;
979 /* --------------------------------------------------------------------- */
982 switch (Cave[y+1][x])
992 Cave[y][x] = Ynut_sB;
993 if (Cave[y][x+1] == Xblank)
994 Cave[y][x+1] = Xacid_splash_e;
995 if (Cave[y][x-1] == Xblank)
996 Cave[y][x-1] = Xacid_splash_w;
998 play_element_sound(x, y, SOUND_acid, Xacid_1);
1002 case Xacid_splash_e:
1003 case Xacid_splash_w:
1005 Cave[y][x] = Ynut_sB;
1006 Cave[y+1][x] = Ynut_s;
1007 Next[y][x] = Xblank;
1008 Next[y+1][x] = Xnut_fall;
1014 play_element_sound(x, y, SOUND_nut, Xnut);
1018 /* --------------------------------------------------------------------- */
1021 if (tab_amoeba[Cave[y-1][x]] ||
1022 tab_amoeba[Cave[y][x+1]] ||
1023 tab_amoeba[Cave[y+1][x]] ||
1024 tab_amoeba[Cave[y][x-1]])
1027 switch (Cave[y][x+1])
1030 case Xacid_splash_e:
1031 case Xacid_splash_w:
1043 Cave[y][x] = Ybug_n_e;
1044 Next[y][x] = Xbug_2_e;
1045 play_element_sound(x, y, SOUND_bug, element);
1053 if (tab_amoeba[Cave[y-1][x]] ||
1054 tab_amoeba[Cave[y][x+1]] ||
1055 tab_amoeba[Cave[y+1][x]] ||
1056 tab_amoeba[Cave[y][x-1]])
1061 switch (Cave[y-1][x])
1071 Cave[y][x] = Ybug_nB;
1072 if (Cave[y-2][x+1] == Xblank)
1073 Cave[y-2][x+1] = Xacid_splash_e;
1074 if (Cave[y-2][x-1] == Xblank)
1075 Cave[y-2][x-1] = Xacid_splash_w;
1076 Next[y][x] = Xblank;
1077 play_element_sound(x, y, SOUND_acid, Xacid_1);
1081 case Xacid_splash_e:
1082 case Xacid_splash_w:
1086 Cave[y][x] = Ybug_nB;
1087 Cave[y-1][x] = Ybug_n;
1088 Next[y][x] = Xblank;
1089 Next[y-1][x] = Xbug_1_n;
1090 play_element_sound(x, y, SOUND_bug, element);
1094 Cave[y][x] = Ybug_n_w;
1095 Next[y][x] = Xbug_2_w;
1096 play_element_sound(x, y, SOUND_bug, element);
1100 /* --------------------------------------------------------------------- */
1103 if (tab_amoeba[Cave[y-1][x]] ||
1104 tab_amoeba[Cave[y][x+1]] ||
1105 tab_amoeba[Cave[y+1][x]] ||
1106 tab_amoeba[Cave[y][x-1]])
1109 switch (Cave[y+1][x])
1112 case Xacid_splash_e:
1113 case Xacid_splash_w:
1125 Cave[y][x] = Ybug_e_s;
1126 Next[y][x] = Xbug_2_s;
1127 play_element_sound(x, y, SOUND_bug, element);
1135 if (tab_amoeba[Cave[y-1][x]] ||
1136 tab_amoeba[Cave[y][x+1]] ||
1137 tab_amoeba[Cave[y+1][x]] ||
1138 tab_amoeba[Cave[y][x-1]])
1143 switch (Cave[y][x+1])
1153 Cave[y][x] = Ybug_eB;
1154 if (Cave[y-1][x+2] == Xblank)
1155 Cave[y-1][x+2] = Xacid_splash_e;
1156 if (Cave[y-1][x] == Xblank)
1157 Cave[y-1][x] = Xacid_splash_w;
1158 Next[y][x] = Xblank;
1159 play_element_sound(x, y, SOUND_acid, Xacid_1);
1163 case Xacid_splash_e:
1164 case Xacid_splash_w:
1168 Cave[y][x] = Ybug_eB;
1169 Cave[y][x+1] = Ybug_e;
1170 Next[y][x] = Xblank;
1171 Next[y][x+1] = Xbug_1_e;
1172 play_element_sound(x, y, SOUND_bug, element);
1176 Cave[y][x] = Ybug_e_n;
1177 Next[y][x] = Xbug_2_n;
1178 play_element_sound(x, y, SOUND_bug, element);
1182 /* --------------------------------------------------------------------- */
1185 if (tab_amoeba[Cave[y-1][x]] ||
1186 tab_amoeba[Cave[y][x+1]] ||
1187 tab_amoeba[Cave[y+1][x]] ||
1188 tab_amoeba[Cave[y][x-1]])
1191 switch (Cave[y][x-1])
1194 case Xacid_splash_e:
1195 case Xacid_splash_w:
1207 Cave[y][x] = Ybug_s_w;
1208 Next[y][x] = Xbug_2_w;
1209 play_element_sound(x, y, SOUND_bug, element);
1217 if (tab_amoeba[Cave[y-1][x]] ||
1218 tab_amoeba[Cave[y][x+1]] ||
1219 tab_amoeba[Cave[y+1][x]] ||
1220 tab_amoeba[Cave[y][x-1]])
1225 switch (Cave[y+1][x])
1235 Cave[y][x] = Ybug_sB;
1236 if (Cave[y][x+1] == Xblank)
1237 Cave[y][x+1] = Xacid_splash_e;
1238 if (Cave[y][x-1] == Xblank)
1239 Cave[y][x-1] = Xacid_splash_w;
1240 Next[y][x] = Xblank;
1241 play_element_sound(x, y, SOUND_acid, Xacid_1);
1245 case Xacid_splash_e:
1246 case Xacid_splash_w:
1250 Cave[y][x] = Ybug_sB;
1251 Cave[y+1][x] = Ybug_s;
1252 Next[y][x] = Xblank;
1253 Next[y+1][x] = Xbug_1_s;
1254 play_element_sound(x, y, SOUND_bug, element);
1258 Cave[y][x] = Ybug_s_e;
1259 Next[y][x] = Xbug_2_e;
1260 play_element_sound(x, y, SOUND_bug, element);
1264 /* --------------------------------------------------------------------- */
1267 if (tab_amoeba[Cave[y-1][x]] ||
1268 tab_amoeba[Cave[y][x+1]] ||
1269 tab_amoeba[Cave[y+1][x]] ||
1270 tab_amoeba[Cave[y][x-1]])
1273 switch (Cave[y-1][x])
1276 case Xacid_splash_e:
1277 case Xacid_splash_w:
1289 Cave[y][x] = Ybug_w_n;
1290 Next[y][x] = Xbug_2_n;
1291 play_element_sound(x, y, SOUND_bug, element);
1299 if (tab_amoeba[Cave[y-1][x]] ||
1300 tab_amoeba[Cave[y][x+1]] ||
1301 tab_amoeba[Cave[y+1][x]] ||
1302 tab_amoeba[Cave[y][x-1]])
1307 switch (Cave[y][x-1])
1317 Cave[y][x] = Ybug_wB;
1318 if (Cave[y-1][x] == Xblank)
1319 Cave[y-1][x] = Xacid_splash_e;
1320 if (Cave[y-1][x-2] == Xblank)
1321 Cave[y-1][x-2] = Xacid_splash_w;
1322 Next[y][x] = Xblank;
1323 play_element_sound(x, y, SOUND_acid, Xacid_1);
1327 case Xacid_splash_e:
1328 case Xacid_splash_w:
1332 Cave[y][x] = Ybug_wB;
1333 Cave[y][x-1] = Ybug_w;
1334 Next[y][x] = Xblank;
1335 Next[y][x-1] = Xbug_1_w;
1336 play_element_sound(x, y, SOUND_bug, element);
1340 Cave[y][x] = Ybug_w_s;
1341 Next[y][x] = Xbug_2_s;
1342 play_element_sound(x, y, SOUND_bug, element);
1346 /* --------------------------------------------------------------------- */
1349 if (tab_amoeba[Cave[y-1][x]] ||
1350 tab_amoeba[Cave[y][x+1]] ||
1351 tab_amoeba[Cave[y+1][x]] ||
1352 tab_amoeba[Cave[y][x-1]])
1355 switch (Cave[y][x-1])
1358 case Xacid_splash_e:
1359 case Xacid_splash_w:
1371 Cave[y][x] = Ytank_n_w;
1372 Next[y][x] = Xtank_2_w;
1373 play_element_sound(x, y, SOUND_tank, element);
1381 if (tab_amoeba[Cave[y-1][x]] ||
1382 tab_amoeba[Cave[y][x+1]] ||
1383 tab_amoeba[Cave[y+1][x]] ||
1384 tab_amoeba[Cave[y][x-1]])
1389 switch (Cave[y-1][x])
1399 Cave[y][x] = Ytank_nB;
1400 if (Cave[y-2][x+1] == Xblank)
1401 Cave[y-2][x+1] = Xacid_splash_e;
1402 if (Cave[y-2][x-1] == Xblank)
1403 Cave[y-2][x-1] = Xacid_splash_w;
1404 Next[y][x] = Xblank;
1405 play_element_sound(x, y, SOUND_acid, Xacid_1);
1409 case Xacid_splash_e:
1410 case Xacid_splash_w:
1414 Cave[y][x] = Ytank_nB;
1415 Cave[y-1][x] = Ytank_n;
1416 Next[y][x] = Xblank;
1417 Next[y-1][x] = Xtank_1_n;
1418 play_element_sound(x, y, SOUND_tank, element);
1422 Cave[y][x] = Ytank_n_e;
1423 Next[y][x] = Xtank_2_e;
1424 play_element_sound(x, y, SOUND_tank, element);
1428 /* --------------------------------------------------------------------- */
1431 if (tab_amoeba[Cave[y-1][x]] ||
1432 tab_amoeba[Cave[y][x+1]] ||
1433 tab_amoeba[Cave[y+1][x]] ||
1434 tab_amoeba[Cave[y][x-1]])
1437 switch (Cave[y-1][x])
1440 case Xacid_splash_e:
1441 case Xacid_splash_w:
1453 Cave[y][x] = Ytank_e_n;
1454 Next[y][x] = Xtank_2_n;
1455 play_element_sound(x, y, SOUND_tank, element);
1463 if (tab_amoeba[Cave[y-1][x]] ||
1464 tab_amoeba[Cave[y][x+1]] ||
1465 tab_amoeba[Cave[y+1][x]] ||
1466 tab_amoeba[Cave[y][x-1]])
1471 switch (Cave[y][x+1])
1481 Cave[y][x] = Ytank_eB;
1482 if (Cave[y-1][x+2] == Xblank)
1483 Cave[y-1][x+2] = Xacid_splash_e;
1484 if (Cave[y-1][x] == Xblank)
1485 Cave[y-1][x] = Xacid_splash_w;
1486 Next[y][x] = Xblank;
1487 play_element_sound(x, y, SOUND_acid, Xacid_1);
1491 case Xacid_splash_e:
1492 case Xacid_splash_w:
1496 Cave[y][x] = Ytank_eB;
1497 Cave[y][x+1] = Ytank_e;
1498 Next[y][x] = Xblank;
1499 Next[y][x+1] = Xtank_1_e;
1500 play_element_sound(x, y, SOUND_tank, element);
1504 Cave[y][x] = Ytank_e_s;
1505 Next[y][x] = Xtank_2_s;
1506 play_element_sound(x, y, SOUND_tank, element);
1510 /* --------------------------------------------------------------------- */
1513 if (tab_amoeba[Cave[y-1][x]] ||
1514 tab_amoeba[Cave[y][x+1]] ||
1515 tab_amoeba[Cave[y+1][x]] ||
1516 tab_amoeba[Cave[y][x-1]])
1519 switch (Cave[y][x+1])
1522 case Xacid_splash_e:
1523 case Xacid_splash_w:
1535 Cave[y][x] = Ytank_s_e;
1536 Next[y][x] = Xtank_2_e;
1537 play_element_sound(x, y, SOUND_tank, element);
1545 if (tab_amoeba[Cave[y-1][x]] ||
1546 tab_amoeba[Cave[y][x+1]] ||
1547 tab_amoeba[Cave[y+1][x]] ||
1548 tab_amoeba[Cave[y][x-1]])
1553 switch (Cave[y+1][x])
1563 Cave[y][x] = Ytank_sB;
1564 if (Cave[y][x+1] == Xblank)
1565 Cave[y][x+1] = Xacid_splash_e;
1566 if (Cave[y][x-1] == Xblank)
1567 Cave[y][x-1] = Xacid_splash_w;
1568 Next[y][x] = Xblank;
1569 play_element_sound(x, y, SOUND_acid, Xacid_1);
1573 case Xacid_splash_e:
1574 case Xacid_splash_w:
1578 Cave[y][x] = Ytank_sB;
1579 Cave[y+1][x] = Ytank_s;
1580 Next[y][x] = Xblank;
1581 Next[y+1][x] = Xtank_1_s;
1582 play_element_sound(x, y, SOUND_tank, element);
1586 Cave[y][x] = Ytank_s_w;
1587 Next[y][x] = Xtank_2_w;
1588 play_element_sound(x, y, SOUND_tank, element);
1592 /* --------------------------------------------------------------------- */
1595 if (tab_amoeba[Cave[y-1][x]] ||
1596 tab_amoeba[Cave[y][x+1]] ||
1597 tab_amoeba[Cave[y+1][x]] ||
1598 tab_amoeba[Cave[y][x-1]])
1601 switch (Cave[y+1][x])
1604 case Xacid_splash_e:
1605 case Xacid_splash_w:
1617 Cave[y][x] = Ytank_w_s;
1618 Next[y][x] = Xtank_2_s;
1619 play_element_sound(x, y, SOUND_tank, element);
1627 if (tab_amoeba[Cave[y-1][x]] ||
1628 tab_amoeba[Cave[y][x+1]] ||
1629 tab_amoeba[Cave[y+1][x]] ||
1630 tab_amoeba[Cave[y][x-1]])
1635 switch (Cave[y][x-1])
1645 Cave[y][x] = Ytank_wB;
1646 if (Cave[y-1][x] == Xblank)
1647 Cave[y-1][x] = Xacid_splash_e;
1648 if (Cave[y-1][x-2] == Xblank)
1649 Cave[y-1][x-2] = Xacid_splash_w;
1650 Next[y][x] = Xblank;
1651 play_element_sound(x, y, SOUND_acid, Xacid_1);
1655 case Xacid_splash_e:
1656 case Xacid_splash_w:
1660 Cave[y][x] = Ytank_wB;
1661 Cave[y][x-1] = Ytank_w;
1662 Next[y][x] = Xblank;
1663 Next[y][x-1] = Xtank_1_w;
1664 play_element_sound(x, y, SOUND_tank, element);
1668 Cave[y][x] = Ytank_w_n;
1669 Next[y][x] = Xtank_2_n;
1670 play_element_sound(x, y, SOUND_tank, element);
1674 /* --------------------------------------------------------------------- */
1680 if (lev.android_clone_cnt == 0)
1682 if (Cave[y-1][x-1] != Xblank &&
1683 Cave[y-1][x] != Xblank &&
1684 Cave[y-1][x+1] != Xblank &&
1685 Cave[y][x-1] != Xblank &&
1686 Cave[y][x+1] != Xblank &&
1687 Cave[y+1][x-1] != Xblank &&
1688 Cave[y+1][x] != Xblank &&
1689 Cave[y+1][x+1] != Xblank)
1694 /* randomly find an object to clone */
1696 case 0: /* S,NE,W,NW,SE,E,SW,N */
1697 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1698 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1699 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1700 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1701 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1702 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1703 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1704 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1707 case 1: /* NW,SE,N,S,NE,SW,E,W */
1708 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1709 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1710 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1711 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1712 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1713 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1714 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1715 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1718 case 2: /* SW,E,S,W,N,NW,SE,NE */
1719 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1720 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1721 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1722 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1723 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1724 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1725 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1726 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1729 case 3: /* N,SE,NE,E,W,S,NW,SW */
1730 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1731 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1732 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1733 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1734 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1735 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1736 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1737 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1740 case 4: /* SE,NW,E,NE,SW,W,N,S */
1741 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1742 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1743 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1744 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1745 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1746 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1747 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1748 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1751 case 5: /* NE,W,SE,SW,S,N,E,NW */
1752 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1753 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1754 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1755 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1756 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1757 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1758 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1759 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1762 case 6: /* E,N,SW,S,NW,NE,SE,W */
1763 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1764 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1765 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1766 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1767 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1768 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1769 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1770 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1773 case 7: /* W,SW,NW,N,E,SE,NE,S */
1774 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1775 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1776 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1777 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1778 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1779 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1780 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1781 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1785 Next[y][x] = temp; /* the item we chose to clone */
1786 play_element_sound(x, y, SOUND_android_clone, temp);
1790 /* randomly find a direction to move */
1792 case 0: /* S,NE,W,NW,SE,E,SW,N */
1793 if (Cave[y+1][x] == Xblank) goto android_s;
1794 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1795 if (Cave[y][x-1] == Xblank) goto android_w;
1796 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1797 if (Cave[y+1][x+1] == Xblank) goto android_se;
1798 if (Cave[y][x+1] == Xblank) goto android_e;
1799 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1800 if (Cave[y-1][x] == Xblank) goto android_n;
1803 case 1: /* NW,SE,N,S,NE,SW,E,W */
1804 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1805 if (Cave[y+1][x+1] == Xblank) goto android_se;
1806 if (Cave[y-1][x] == Xblank) goto android_n;
1807 if (Cave[y+1][x] == Xblank) goto android_s;
1808 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1809 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1810 if (Cave[y][x+1] == Xblank) goto android_e;
1811 if (Cave[y][x-1] == Xblank) goto android_w;
1814 case 2: /* SW,E,S,W,N,NW,SE,NE */
1815 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1816 if (Cave[y][x+1] == Xblank) goto android_e;
1817 if (Cave[y+1][x] == Xblank) goto android_s;
1818 if (Cave[y][x-1] == Xblank) goto android_w;
1819 if (Cave[y-1][x] == Xblank) goto android_n;
1820 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1821 if (Cave[y+1][x+1] == Xblank) goto android_se;
1822 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1825 case 3: /* N,SE,NE,E,W,S,NW,SW */
1826 if (Cave[y-1][x] == Xblank) goto android_n;
1827 if (Cave[y+1][x+1] == Xblank) goto android_se;
1828 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1829 if (Cave[y][x+1] == Xblank) goto android_e;
1830 if (Cave[y][x-1] == Xblank) goto android_w;
1831 if (Cave[y+1][x] == Xblank) goto android_s;
1832 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1833 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1836 case 4: /* SE,NW,E,NE,SW,W,N,S */
1837 if (Cave[y+1][x+1] == Xblank) goto android_se;
1838 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1839 if (Cave[y][x+1] == Xblank) goto android_e;
1840 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1841 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1842 if (Cave[y][x-1] == Xblank) goto android_w;
1843 if (Cave[y-1][x] == Xblank) goto android_n;
1844 if (Cave[y+1][x] == Xblank) goto android_s;
1847 case 5: /* NE,W,SE,SW,S,N,E,NW */
1848 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1849 if (Cave[y][x-1] == Xblank) goto android_w;
1850 if (Cave[y+1][x+1] == Xblank) goto android_se;
1851 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1852 if (Cave[y+1][x] == Xblank) goto android_s;
1853 if (Cave[y-1][x] == Xblank) goto android_n;
1854 if (Cave[y][x+1] == Xblank) goto android_e;
1855 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1858 case 6: /* E,N,SW,S,NW,NE,SE,W */
1859 if (Cave[y][x+1] == Xblank) goto android_e;
1860 if (Cave[y-1][x] == Xblank) goto android_n;
1861 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1862 if (Cave[y+1][x] == Xblank) goto android_s;
1863 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1864 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1865 if (Cave[y+1][x+1] == Xblank) goto android_se;
1866 if (Cave[y][x-1] == Xblank) goto android_w;
1869 case 7: /* W,SW,NW,N,E,SE,NE,S */
1870 if (Cave[y][x-1] == Xblank) goto android_w;
1871 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1872 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1873 if (Cave[y-1][x] == Xblank) goto android_n;
1874 if (Cave[y][x+1] == Xblank) goto android_e;
1875 if (Cave[y+1][x+1] == Xblank) goto android_se;
1876 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1877 if (Cave[y+1][x] == Xblank) goto android_s;
1883 if (lev.android_move_cnt == 0)
1885 if (Cave[y-1][x-1] == Zplayer ||
1886 Cave[y-1][x] == Zplayer ||
1887 Cave[y-1][x+1] == Zplayer ||
1888 Cave[y][x-1] == Zplayer ||
1889 Cave[y][x+1] == Zplayer ||
1890 Cave[y+1][x-1] == Zplayer ||
1891 Cave[y+1][x] == Zplayer ||
1892 Cave[y+1][x+1] == Zplayer)
1895 set_nearest_player_xy(x, y, &dx, &dy);
1897 Next[y][x] = Xblank; /* assume we will move */
1898 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1904 /* attempt clockwise move first if direct path is blocked */
1906 case 0: /* north west */
1907 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1908 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1909 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1913 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1914 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1915 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1918 case 2: /* north east */
1919 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1920 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1921 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1925 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1926 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1927 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1930 case 4: /* nowhere */
1934 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1935 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1936 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1939 case 6: /* south west */
1940 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1941 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1942 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1946 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1947 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1948 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1951 case 8: /* south east */
1952 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1953 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1954 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1962 /* attempt counterclockwise move first if direct path is blocked */
1964 case 0: /* north west */
1965 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1966 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1967 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1971 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1972 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1973 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1976 case 2: /* north east */
1977 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1978 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1979 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1983 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1984 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1985 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1988 case 4: /* nowhere */
1992 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1993 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1994 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1997 case 6: /* south west */
1998 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1999 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2000 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2004 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2005 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2006 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2009 case 8: /* south east */
2010 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2011 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2012 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2020 Next[y][x] = Xandroid;
2025 Cave[y][x] = Yandroid_nB;
2026 Cave[y-1][x] = Yandroid_n;
2027 Next[y-1][x] = Xandroid;
2028 play_element_sound(x, y, SOUND_android_move, element);
2033 Cave[y][x] = Yandroid_neB;
2034 Cave[y-1][x+1] = Yandroid_ne;
2035 Next[y-1][x+1] = Xandroid;
2036 play_element_sound(x, y, SOUND_android_move, element);
2041 Cave[y][x] = Yandroid_eB;
2042 Cave[y][x+1] = Yandroid_e;
2043 Next[y][x+1] = Xandroid;
2044 play_element_sound(x, y, SOUND_android_move, element);
2049 Cave[y][x] = Yandroid_seB;
2050 Cave[y+1][x+1] = Yandroid_se;
2051 Next[y+1][x+1] = Xandroid;
2052 play_element_sound(x, y, SOUND_android_move, element);
2057 Cave[y][x] = Yandroid_sB;
2058 Cave[y+1][x] = Yandroid_s;
2059 Next[y+1][x] = Xandroid;
2060 play_element_sound(x, y, SOUND_android_move, element);
2065 Cave[y][x] = Yandroid_swB;
2066 Cave[y+1][x-1] = Yandroid_sw;
2067 Next[y+1][x-1] = Xandroid;
2068 play_element_sound(x, y, SOUND_android_move, element);
2073 Cave[y][x] = Yandroid_wB;
2074 Cave[y][x-1] = Yandroid_w;
2075 Next[y][x-1] = Xandroid;
2076 play_element_sound(x, y, SOUND_android_move, element);
2081 Cave[y][x] = Yandroid_nwB;
2082 Cave[y-1][x-1] = Yandroid_nw;
2083 Next[y-1][x-1] = Xandroid;
2084 play_element_sound(x, y, SOUND_android_move, element);
2087 /* --------------------------------------------------------------------- */
2090 switch (Cave[y-1][x])
2100 Cave[y][x] = Yandroid_nB;
2101 if (Cave[y-2][x+1] == Xblank)
2102 Cave[y-2][x+1] = Xacid_splash_e;
2103 if (Cave[y-2][x-1] == Xblank)
2104 Cave[y-2][x-1] = Xacid_splash_w;
2105 Next[y][x] = Xblank;
2106 play_element_sound(x, y, SOUND_acid, Xacid_1);
2110 case Xacid_splash_e:
2111 case Xacid_splash_w:
2112 Cave[y][x] = Yandroid_nB;
2113 Cave[y-1][x] = Yandroid_n;
2114 Next[y][x] = Xblank;
2115 Next[y-1][x] = Xandroid;
2116 play_element_sound(x, y, SOUND_android_move, element);
2124 switch (Cave[y-1][x])
2134 Cave[y][x] = Yandroid_nB;
2135 if (Cave[y-2][x+1] == Xblank)
2136 Cave[y-2][x+1] = Xacid_splash_e;
2137 if (Cave[y-2][x-1] == Xblank)
2138 Cave[y-2][x-1] = Xacid_splash_w;
2139 Next[y][x] = Xblank;
2140 play_element_sound(x, y, SOUND_acid, Xacid_1);
2144 case Xacid_splash_e:
2145 case Xacid_splash_w:
2146 Cave[y][x] = Yandroid_nB;
2147 Cave[y-1][x] = Yandroid_n;
2148 Next[y][x] = Xblank;
2149 Next[y-1][x] = Xandroid_1_n;
2150 play_element_sound(x, y, SOUND_android_move, element);
2157 /* --------------------------------------------------------------------- */
2160 switch (Cave[y][x+1])
2170 Cave[y][x] = Yandroid_eB;
2171 if (Cave[y-1][x+2] == Xblank)
2172 Cave[y-1][x+2] = Xacid_splash_e;
2173 if (Cave[y-1][x] == Xblank)
2174 Cave[y-1][x] = Xacid_splash_w;
2175 Next[y][x] = Xblank;
2176 play_element_sound(x, y, SOUND_acid, Xacid_1);
2180 case Xacid_splash_e:
2181 case Xacid_splash_w:
2182 Cave[y][x] = Yandroid_eB;
2183 Cave[y][x+1] = Yandroid_e;
2184 Next[y][x] = Xblank;
2185 Next[y][x+1] = Xandroid;
2186 play_element_sound(x, y, SOUND_android_move, element);
2194 switch (Cave[y][x+1])
2204 Cave[y][x] = Yandroid_eB;
2205 if (Cave[y-1][x+2] == Xblank)
2206 Cave[y-1][x+2] = Xacid_splash_e;
2207 if (Cave[y-1][x] == Xblank)
2208 Cave[y-1][x] = Xacid_splash_w;
2209 Next[y][x] = Xblank;
2210 play_element_sound(x, y, SOUND_acid, Xacid_1);
2214 case Xacid_splash_e:
2215 case Xacid_splash_w:
2216 Cave[y][x] = Yandroid_eB;
2217 Cave[y][x+1] = Yandroid_e;
2218 Next[y][x] = Xblank;
2219 Next[y][x+1] = Xandroid_1_e;
2220 play_element_sound(x, y, SOUND_android_move, element);
2227 /* --------------------------------------------------------------------- */
2230 switch (Cave[y+1][x])
2240 Cave[y][x] = Yandroid_sB;
2241 if (Cave[y][x+1] == Xblank)
2242 Cave[y][x+1] = Xacid_splash_e;
2243 if (Cave[y][x-1] == Xblank)
2244 Cave[y][x-1] = Xacid_splash_w;
2245 Next[y][x] = Xblank;
2246 play_element_sound(x, y, SOUND_acid, Xacid_1);
2250 case Xacid_splash_e:
2251 case Xacid_splash_w:
2252 Cave[y][x] = Yandroid_sB;
2253 Cave[y+1][x] = Yandroid_s;
2254 Next[y][x] = Xblank;
2255 Next[y+1][x] = Xandroid;
2256 play_element_sound(x, y, SOUND_android_move, element);
2264 switch (Cave[y+1][x])
2274 Cave[y][x] = Yandroid_sB;
2275 if (Cave[y][x+1] == Xblank)
2276 Cave[y][x+1] = Xacid_splash_e;
2277 if (Cave[y][x-1] == Xblank)
2278 Cave[y][x-1] = Xacid_splash_w;
2279 Next[y][x] = Xblank;
2280 play_element_sound(x, y, SOUND_acid, Xacid_1);
2284 case Xacid_splash_e:
2285 case Xacid_splash_w:
2286 Cave[y][x] = Yandroid_sB;
2287 Cave[y+1][x] = Yandroid_s;
2288 Next[y][x] = Xblank;
2289 Next[y+1][x] = Xandroid_1_s;
2290 play_element_sound(x, y, SOUND_android_move, element);
2297 /* --------------------------------------------------------------------- */
2300 switch (Cave[y][x-1])
2310 Cave[y][x] = Yandroid_wB;
2311 if (Cave[y-1][x] == Xblank)
2312 Cave[y-1][x] = Xacid_splash_e;
2313 if (Cave[y-1][x-2] == Xblank)
2314 Cave[y-1][x-2] = Xacid_splash_w;
2315 Next[y][x] = Xblank;
2316 play_element_sound(x, y, SOUND_acid, Xacid_1);
2320 case Xacid_splash_e:
2321 case Xacid_splash_w:
2322 Cave[y][x] = Yandroid_wB;
2323 Cave[y][x-1] = Yandroid_w;
2324 Next[y][x] = Xblank;
2325 Next[y][x-1] = Xandroid;
2326 play_element_sound(x, y, SOUND_android_move, element);
2334 switch (Cave[y][x-1])
2344 Cave[y][x] = Yandroid_wB;
2345 if (Cave[y-1][x] == Xblank)
2346 Cave[y-1][x] = Xacid_splash_e;
2347 if (Cave[y-1][x-2] == Xblank)
2348 Cave[y-1][x-2] = Xacid_splash_w;
2349 Next[y][x] = Xblank;
2350 play_element_sound(x, y, SOUND_acid, Xacid_1);
2354 case Xacid_splash_e:
2355 case Xacid_splash_w:
2356 Cave[y][x] = Yandroid_wB;
2357 Cave[y][x-1] = Yandroid_w;
2358 Next[y][x] = Xblank;
2359 Next[y][x-1] = Xandroid_1_w;
2360 play_element_sound(x, y, SOUND_android_move, element);
2367 /* --------------------------------------------------------------------- */
2370 switch (Cave[y+1][x])
2380 Cave[y][x] = Yspring_sB;
2381 if (Cave[y][x+1] == Xblank)
2382 Cave[y][x+1] = Xacid_splash_e;
2383 if (Cave[y][x-1] == Xblank)
2384 Cave[y][x-1] = Xacid_splash_w;
2385 Next[y][x] = Xblank;
2386 play_element_sound(x, y, SOUND_acid, Xacid_1);
2390 case Xacid_splash_e:
2391 case Xacid_splash_w:
2394 Cave[y][x] = Yspring_sB;
2395 Cave[y+1][x] = Yspring_s;
2396 Next[y][x] = Xblank;
2397 Next[y+1][x] = Xspring_fall;
2416 case Xemerald_pause:
2418 case Xdiamond_pause:
2446 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2448 Cave[y][x] = Yspring_eB;
2449 Cave[y][x+1] = Yspring_e;
2450 if (Cave[y+1][x] == Xbumper)
2451 Cave[y+1][x] = XbumperB;
2452 Next[y][x] = Xblank;
2455 Next[y][x+1] = Xspring_e;
2457 Next[y][x+1] = Xspring_pause;
2463 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2465 Cave[y][x] = Yspring_wB;
2466 Cave[y][x-1] = Yspring_w;
2467 if (Cave[y+1][x] == Xbumper)
2468 Cave[y+1][x] = XbumperB;
2469 Next[y][x] = Xblank;
2472 Next[y][x-1] = Xspring_w;
2474 Next[y][x-1] = Xspring_pause;
2482 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2484 Cave[y][x] = Yspring_wB;
2485 Cave[y][x-1] = Yspring_w;
2486 if (Cave[y+1][x] == Xbumper)
2487 Cave[y+1][x] = XbumperB;
2488 Next[y][x] = Xblank;
2491 Next[y][x-1] = Xspring_w;
2493 Next[y][x-1] = Xspring_pause;
2499 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2501 Cave[y][x] = Yspring_eB;
2502 Cave[y][x+1] = Yspring_e;
2503 if (Cave[y+1][x] == Xbumper)
2504 Cave[y+1][x] = XbumperB;
2505 Next[y][x] = Xblank;
2508 Next[y][x+1] = Xspring_e;
2510 Next[y][x+1] = Xspring_pause;
2521 /* --------------------------------------------------------------------- */
2524 switch (Cave[y+1][x])
2534 Cave[y][x] = Yspring_sB;
2535 if (Cave[y][x+1] == Xblank)
2536 Cave[y][x+1] = Xacid_splash_e;
2537 if (Cave[y][x-1] == Xblank)
2538 Cave[y][x-1] = Xacid_splash_w;
2539 Next[y][x] = Xblank;
2540 play_element_sound(x, y, SOUND_acid, Xacid_1);
2544 case Xacid_splash_e:
2545 case Xacid_splash_w:
2546 Cave[y][x] = Yspring_sB;
2547 Cave[y+1][x] = Yspring_s;
2548 Next[y][x] = Xblank;
2549 Next[y+1][x] = Xspring_fall;
2553 Cave[y][x] = Xspring;
2554 Next[y][x] = Xspring;
2558 /* --------------------------------------------------------------------- */
2561 switch (Cave[y+1][x])
2571 Cave[y][x] = Yspring_sB;
2572 if (Cave[y][x+1] == Xblank)
2573 Cave[y][x+1] = Xacid_splash_e;
2574 if (Cave[y][x-1] == Xblank)
2575 Cave[y][x-1] = Xacid_splash_w;
2576 Next[y][x] = Xblank;
2577 play_element_sound(x, y, SOUND_acid, Xacid_1);
2581 case Xacid_splash_e:
2582 case Xacid_splash_w:
2583 Cave[y][x] = Yspring_sB;
2584 Cave[y+1][x] = Yspring_s;
2585 Next[y][x] = Xblank;
2586 Next[y+1][x] = Xspring_fall;
2590 Cave[y+1][x] = XbumperB;
2593 switch (Cave[y][x+1])
2603 Cave[y][x] = Yspring_eB;
2604 if (Cave[y-1][x+2] == Xblank)
2605 Cave[y-1][x+2] = Xacid_splash_e;
2606 if (Cave[y-1][x] == Xblank)
2607 Cave[y-1][x] = Xacid_splash_w;
2608 Next[y][x] = Xblank;
2609 play_element_sound(x, y, SOUND_acid, Xacid_1);
2613 case Xacid_splash_e:
2614 case Xacid_splash_w:
2619 Cave[y][x] = Yspring_eB;
2620 Cave[y][x+1] = Yspring_e;
2621 Next[y][x] = Xblank;
2622 Next[y][x+1] = Xspring_e;
2631 Cave[y][x] = Yspring_alien_eB;
2632 Cave[y][x+1] = Yspring_alien_e;
2633 Next[y][x] = Xblank;
2634 Next[y][x+1] = Xspring_e;
2635 play_element_sound(x, y, SOUND_slurp, Xalien);
2636 score += lev.slurp_score;
2641 Cave[y][x+1] = XbumperB;
2642 Next[y][x] = Xspring_w;
2643 play_element_sound(x, y, SOUND_spring, Xspring);
2647 Cave[y][x] = Xspring;
2648 Next[y][x] = Xspring;
2649 play_element_sound(x, y, SOUND_spring, Xspring);
2653 /* --------------------------------------------------------------------- */
2656 switch (Cave[y+1][x])
2666 Cave[y][x] = Yspring_sB;
2667 if (Cave[y][x+1] == Xblank)
2668 Cave[y][x+1] = Xacid_splash_e;
2669 if (Cave[y][x-1] == Xblank)
2670 Cave[y][x-1] = Xacid_splash_w;
2671 Next[y][x] = Xblank;
2672 play_element_sound(x, y, SOUND_acid, Xacid_1);
2676 case Xacid_splash_e:
2677 case Xacid_splash_w:
2678 Cave[y][x] = Yspring_sB;
2679 Cave[y+1][x] = Yspring_s;
2680 Next[y][x] = Xblank;
2681 Next[y+1][x] = Xspring_fall;
2685 Cave[y+1][x] = XbumperB;
2688 switch (Cave[y][x-1])
2698 Cave[y][x] = Yspring_wB;
2699 if (Cave[y-1][x] == Xblank)
2700 Cave[y-1][x] = Xacid_splash_e;
2701 if (Cave[y-1][x-2] == Xblank)
2702 Cave[y-1][x-2] = Xacid_splash_w;
2703 Next[y][x] = Xblank;
2704 play_element_sound(x, y, SOUND_acid, Xacid_1);
2708 case Xacid_splash_e:
2709 case Xacid_splash_w:
2714 Cave[y][x] = Yspring_wB;
2715 Cave[y][x-1] = Yspring_w;
2716 Next[y][x] = Xblank;
2717 Next[y][x-1] = Xspring_w;
2726 Cave[y][x] = Yspring_alien_wB;
2727 Cave[y][x-1] = Yspring_alien_w;
2728 Next[y][x] = Xblank;
2729 Next[y][x-1] = Xspring_w;
2730 play_element_sound(x, y, SOUND_slurp, Xalien);
2731 score += lev.slurp_score;
2736 Cave[y][x-1] = XbumperB;
2737 Next[y][x] = Xspring_e;
2738 play_element_sound(x, y, SOUND_spring, Xspring);
2742 Cave[y][x] = Xspring;
2743 Next[y][x] = Xspring;
2744 play_element_sound(x, y, SOUND_spring, Xspring);
2748 /* --------------------------------------------------------------------- */
2751 switch (Cave[y+1][x])
2761 Cave[y][x] = Yspring_sB;
2762 if (Cave[y][x+1] == Xblank)
2763 Cave[y][x+1] = Xacid_splash_e;
2764 if (Cave[y][x-1] == Xblank)
2765 Cave[y][x-1] = Xacid_splash_w;
2766 Next[y][x] = Xblank;
2767 play_element_sound(x, y, SOUND_acid, Xacid_1);
2771 case Xacid_splash_e:
2772 case Xacid_splash_w:
2774 Cave[y][x] = Yspring_sB;
2775 Cave[y+1][x] = Yspring_s;
2776 Next[y][x] = Xblank;
2777 Next[y+1][x] = Xspring_fall;
2782 Cave[y+1][x] = Ybomb_blank;
2783 Next[y+1][x] = Znormal;
2784 Boom[y][x-1] = Xblank;
2785 Boom[y][x] = Xblank;
2786 Boom[y][x+1] = Xblank;
2787 Boom[y+1][x-1] = Xblank;
2788 Boom[y+1][x] = Xblank;
2789 Boom[y+1][x+1] = Xblank;
2790 Boom[y+2][x-1] = Xblank;
2791 Boom[y+2][x] = Xblank;
2792 Boom[y+2][x+1] = Xblank;
2793 #if PLAY_ELEMENT_SOUND
2794 play_element_sound(x, y, SOUND_boom, element);
2806 Cave[y][x] = Yspring_sB;
2807 Cave[y+1][x] = Ybug_spring;
2808 Next[y+1][x] = Znormal;
2809 Boom[y][x-1] = Xemerald;
2810 Boom[y][x] = Xemerald;
2811 Boom[y][x+1] = Xemerald;
2812 Boom[y+1][x-1] = Xemerald;
2813 Boom[y+1][x] = Xdiamond;
2814 Boom[y+1][x+1] = Xemerald;
2815 Boom[y+2][x-1] = Xemerald;
2816 Boom[y+2][x] = Xemerald;
2817 Boom[y+2][x+1] = Xemerald;
2818 #if PLAY_ELEMENT_SOUND
2819 play_element_sound(x, y, SOUND_boom, element);
2821 score += lev.bug_score;
2832 Cave[y][x] = Yspring_sB;
2833 Cave[y+1][x] = Ytank_spring;
2834 Next[y+1][x] = Znormal;
2835 Boom[y][x-1] = Xblank;
2836 Boom[y][x] = Xblank;
2837 Boom[y][x+1] = Xblank;
2838 Boom[y+1][x-1] = Xblank;
2839 Boom[y+1][x] = Xblank;
2840 Boom[y+1][x+1] = Xblank;
2841 Boom[y+2][x-1] = Xblank;
2842 Boom[y+2][x] = Xblank;
2843 Boom[y+2][x+1] = Xblank;
2844 #if PLAY_ELEMENT_SOUND
2845 play_element_sound(x, y, SOUND_boom, element);
2847 score += lev.tank_score;
2854 Cave[y][x] = Yspring_sB;
2855 Cave[y+1][x] = Yeater_spring;
2856 Next[y+1][x] = Znormal;
2857 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
2858 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
2859 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
2860 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
2861 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
2862 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
2863 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
2864 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
2865 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
2866 #if PLAY_ELEMENT_SOUND
2867 play_element_sound(x, y, SOUND_boom, element);
2869 lev.eater_pos = (lev.eater_pos + 1) & 7;
2870 score += lev.eater_score;
2875 Cave[y][x] = Yspring_sB;
2876 Cave[y+1][x] = Yalien_spring;
2877 Next[y+1][x] = Znormal;
2878 Boom[y][x-1] = Xblank;
2879 Boom[y][x] = Xblank;
2880 Boom[y][x+1] = Xblank;
2881 Boom[y+1][x-1] = Xblank;
2882 Boom[y+1][x] = Xblank;
2883 Boom[y+1][x+1] = Xblank;
2884 Boom[y+2][x-1] = Xblank;
2885 Boom[y+2][x] = Xblank;
2886 Boom[y+2][x+1] = Xblank;
2887 #if PLAY_ELEMENT_SOUND
2888 play_element_sound(x, y, SOUND_boom, element);
2890 score += lev.alien_score;
2894 Cave[y][x] = Xspring;
2895 Next[y][x] = Xspring;
2896 play_element_sound(x, y, SOUND_spring, Xspring);
2900 /* --------------------------------------------------------------------- */
2903 if (Cave[y][x+1] == Xdiamond)
2905 Cave[y][x+1] = Ydiamond_blank;
2906 Next[y][x+1] = Xblank;
2907 play_element_sound(x, y, SOUND_eater_eat, element);
2911 if (Cave[y+1][x] == Xdiamond)
2913 Cave[y+1][x] = Ydiamond_blank;
2914 Next[y+1][x] = Xblank;
2915 play_element_sound(x, y, SOUND_eater_eat, element);
2919 if (Cave[y][x-1] == Xdiamond)
2921 Cave[y][x-1] = Ydiamond_blank;
2922 Next[y][x-1] = Xblank;
2923 play_element_sound(x, y, SOUND_eater_eat, element);
2927 if (Cave[y-1][x] == Xdiamond)
2929 Cave[y-1][x] = Ydiamond_blank;
2930 Next[y-1][x] = Xblank;
2931 play_element_sound(x, y, SOUND_eater_eat, element);
2935 switch (Cave[y-1][x])
2945 Cave[y][x] = Yeater_nB;
2946 if (Cave[y-2][x+1] == Xblank)
2947 Cave[y-2][x+1] = Xacid_splash_e;
2948 if (Cave[y-2][x-1] == Xblank)
2949 Cave[y-2][x-1] = Xacid_splash_w;
2950 Next[y][x] = Xblank;
2951 play_element_sound(x, y, SOUND_acid, Xacid_1);
2955 case Xacid_splash_e:
2956 case Xacid_splash_w:
2960 Cave[y][x] = Yeater_nB;
2961 Cave[y-1][x] = Yeater_n;
2962 Next[y][x] = Xblank;
2963 Next[y-1][x] = Xeater_n;
2967 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
2968 play_element_sound(x, y, SOUND_eater, element);
2972 /* --------------------------------------------------------------------- */
2975 if (Cave[y+1][x] == Xdiamond)
2977 Cave[y+1][x] = Ydiamond_blank;
2978 Next[y+1][x] = Xblank;
2979 play_element_sound(x, y, SOUND_eater_eat, element);
2983 if (Cave[y][x-1] == Xdiamond)
2985 Cave[y][x-1] = Ydiamond_blank;
2986 Next[y][x-1] = Xblank;
2987 play_element_sound(x, y, SOUND_eater_eat, element);
2991 if (Cave[y-1][x] == Xdiamond)
2993 Cave[y-1][x] = Ydiamond_blank;
2994 Next[y-1][x] = Xblank;
2995 play_element_sound(x, y, SOUND_eater_eat, element);
2999 if (Cave[y][x+1] == Xdiamond)
3001 Cave[y][x+1] = Ydiamond_blank;
3002 Next[y][x+1] = Xblank;
3003 play_element_sound(x, y, SOUND_eater_eat, element);
3007 switch (Cave[y][x+1])
3017 Cave[y][x] = Yeater_eB;
3018 if (Cave[y-1][x+2] == Xblank)
3019 Cave[y-1][x+2] = Xacid_splash_e;
3020 if (Cave[y-1][x] == Xblank)
3021 Cave[y-1][x] = Xacid_splash_w;
3022 Next[y][x] = Xblank;
3023 play_element_sound(x, y, SOUND_acid, Xacid_1);
3027 case Xacid_splash_e:
3028 case Xacid_splash_w:
3032 Cave[y][x] = Yeater_eB;
3033 Cave[y][x+1] = Yeater_e;
3034 Next[y][x] = Xblank;
3035 Next[y][x+1] = Xeater_e;
3039 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3040 play_element_sound(x, y, SOUND_eater, element);
3044 /* --------------------------------------------------------------------- */
3047 if (Cave[y][x-1] == Xdiamond)
3049 Cave[y][x-1] = Ydiamond_blank;
3050 Next[y][x-1] = Xblank;
3051 play_element_sound(x, y, SOUND_eater_eat, element);
3055 if (Cave[y-1][x] == Xdiamond)
3057 Cave[y-1][x] = Ydiamond_blank;
3058 Next[y-1][x] = Xblank;
3059 play_element_sound(x, y, SOUND_eater_eat, element);
3063 if (Cave[y][x+1] == Xdiamond)
3065 Cave[y][x+1] = Ydiamond_blank;
3066 Next[y][x+1] = Xblank;
3067 play_element_sound(x, y, SOUND_eater_eat, element);
3071 if (Cave[y+1][x] == Xdiamond)
3073 Cave[y+1][x] = Ydiamond_blank;
3074 Next[y+1][x] = Xblank;
3075 play_element_sound(x, y, SOUND_eater_eat, element);
3079 switch (Cave[y+1][x])
3089 Cave[y][x] = Yeater_sB;
3090 if (Cave[y][x+1] == Xblank)
3091 Cave[y][x+1] = Xacid_splash_e;
3092 if (Cave[y][x-1] == Xblank)
3093 Cave[y][x-1] = Xacid_splash_w;
3094 Next[y][x] = Xblank;
3095 play_element_sound(x, y, SOUND_acid, Xacid_1);
3099 case Xacid_splash_e:
3100 case Xacid_splash_w:
3104 Cave[y][x] = Yeater_sB;
3105 Cave[y+1][x] = Yeater_s;
3106 Next[y][x] = Xblank;
3107 Next[y+1][x] = Xeater_s;
3111 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
3112 play_element_sound(x, y, SOUND_eater, element);
3116 /* --------------------------------------------------------------------- */
3119 if (Cave[y-1][x] == Xdiamond)
3121 Cave[y-1][x] = Ydiamond_blank;
3122 Next[y-1][x] = Xblank;
3123 play_element_sound(x, y, SOUND_eater_eat, element);
3127 if (Cave[y][x+1] == Xdiamond)
3129 Cave[y][x+1] = Ydiamond_blank;
3130 Next[y][x+1] = Xblank;
3131 play_element_sound(x, y, SOUND_eater_eat, element);
3135 if (Cave[y+1][x] == Xdiamond)
3137 Cave[y+1][x] = Ydiamond_blank;
3138 Next[y+1][x] = Xblank;
3139 play_element_sound(x, y, SOUND_eater_eat, element);
3143 if (Cave[y][x-1] == Xdiamond)
3145 Cave[y][x-1] = Ydiamond_blank;
3146 Next[y][x-1] = Xblank;
3147 play_element_sound(x, y, SOUND_eater_eat, element);
3151 switch (Cave[y][x-1])
3161 Cave[y][x] = Yeater_wB;
3162 if (Cave[y-1][x] == Xblank)
3163 Cave[y-1][x] = Xacid_splash_e;
3164 if (Cave[y-1][x-2] == Xblank)
3165 Cave[y-1][x-2] = Xacid_splash_w;
3166 Next[y][x] = Xblank;
3167 play_element_sound(x, y, SOUND_acid, Xacid_1);
3171 case Xacid_splash_e:
3172 case Xacid_splash_w:
3176 Cave[y][x] = Yeater_wB;
3177 Cave[y][x-1] = Yeater_w;
3178 Next[y][x] = Xblank;
3179 Next[y][x-1] = Xeater_w;
3183 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3184 play_element_sound(x, y, SOUND_eater, element);
3188 /* --------------------------------------------------------------------- */
3199 set_nearest_player_xy(x, y, &dx, &dy);
3206 switch (Cave[y-1][x])
3216 Cave[y][x] = Yalien_nB;
3217 if (Cave[y-2][x+1] == Xblank)
3218 Cave[y-2][x+1] = Xacid_splash_e;
3219 if (Cave[y-2][x-1] == Xblank)
3220 Cave[y-2][x-1] = Xacid_splash_w;
3221 Next[y][x] = Xblank;
3222 play_element_sound(x, y, SOUND_acid, Xacid_1);
3226 case Xacid_splash_e:
3227 case Xacid_splash_w:
3231 Cave[y][x] = Yalien_nB;
3232 Cave[y-1][x] = Yalien_n;
3233 Next[y][x] = Xblank;
3234 Next[y-1][x] = Xalien_pause;
3235 play_element_sound(x, y, SOUND_alien, Xalien);
3241 switch (Cave[y+1][x])
3251 Cave[y][x] = Yalien_sB;
3252 Next[y][x] = Xblank;
3253 if (Cave[y][x+1] == Xblank)
3254 Cave[y][x+1] = Xacid_splash_e;
3255 if (Cave[y][x-1] == Xblank)
3256 Cave[y][x-1] = Xacid_splash_w;
3257 play_element_sound(x, y, SOUND_acid, Xacid_1);
3261 case Xacid_splash_e:
3262 case Xacid_splash_w:
3266 Cave[y][x] = Yalien_sB;
3267 Cave[y+1][x] = Yalien_s;
3268 Next[y][x] = Xblank;
3269 Next[y+1][x] = Xalien_pause;
3270 play_element_sound(x, y, SOUND_alien, Xalien);
3279 switch (Cave[y][x+1])
3289 Cave[y][x] = Yalien_eB;
3290 if (Cave[y-1][x+2] == Xblank)
3291 Cave[y-1][x+2] = Xacid_splash_e;
3292 if (Cave[y-1][x] == Xblank)
3293 Cave[y-1][x] = Xacid_splash_w;
3294 Next[y][x] = Xblank;
3295 play_element_sound(x, y, SOUND_acid, Xacid_1);
3299 case Xacid_splash_e:
3300 case Xacid_splash_w:
3304 Cave[y][x] = Yalien_eB;
3305 Cave[y][x+1] = Yalien_e;
3306 Next[y][x] = Xblank;
3307 Next[y][x+1] = Xalien_pause;
3308 play_element_sound(x, y, SOUND_alien, Xalien);
3314 switch (Cave[y][x-1])
3324 Cave[y][x] = Yalien_wB;
3325 if (Cave[y-1][x] == Xblank)
3326 Cave[y-1][x] = Xacid_splash_e;
3327 if (Cave[y-1][x-2] == Xblank)
3328 Cave[y-1][x-2] = Xacid_splash_w;
3329 Next[y][x] = Xblank;
3330 play_element_sound(x, y, SOUND_acid, Xacid_1);
3334 case Xacid_splash_e:
3335 case Xacid_splash_w:
3339 Cave[y][x] = Yalien_wB;
3340 Cave[y][x-1] = Yalien_w;
3341 Next[y][x] = Xblank;
3342 Next[y][x-1] = Xalien_pause;
3343 play_element_sound(x, y, SOUND_alien, Xalien);
3352 Next[y][x] = Xalien;
3355 /* --------------------------------------------------------------------- */
3358 switch (Cave[y+1][x])
3368 Cave[y][x] = Yemerald_sB;
3369 if (Cave[y][x+1] == Xblank)
3370 Cave[y][x+1] = Xacid_splash_e;
3371 if (Cave[y][x-1] == Xblank)
3372 Cave[y][x-1] = Xacid_splash_w;
3373 Next[y][x] = Xblank;
3374 play_element_sound(x, y, SOUND_acid, Xacid_1);
3378 case Xacid_splash_e:
3379 case Xacid_splash_w:
3380 Cave[y][x] = Yemerald_sB;
3381 Cave[y+1][x] = Yemerald_s;
3382 Next[y][x] = Xblank;
3383 Next[y+1][x] = Xemerald_fall;
3402 case Xemerald_pause:
3404 case Xdiamond_pause:
3441 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3443 Cave[y][x] = Yemerald_eB;
3444 Cave[y][x+1] = Yemerald_e;
3445 Next[y][x] = Xblank;
3446 Next[y][x+1] = Xemerald_pause;
3450 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3452 Cave[y][x] = Yemerald_wB;
3453 Cave[y][x-1] = Yemerald_w;
3454 Next[y][x] = Xblank;
3455 Next[y][x-1] = Xemerald_pause;
3461 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3463 Cave[y][x] = Yemerald_wB;
3464 Cave[y][x-1] = Yemerald_w;
3465 Next[y][x] = Xblank;
3466 Next[y][x-1] = Xemerald_pause;
3470 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3472 Cave[y][x] = Yemerald_eB;
3473 Cave[y][x+1] = Yemerald_e;
3474 Next[y][x] = Xblank;
3475 Next[y][x+1] = Xemerald_pause;
3481 if (++lev.shine_cnt > 50)
3483 lev.shine_cnt = RANDOM & 7;
3484 Cave[y][x] = Xemerald_shine;
3490 /* --------------------------------------------------------------------- */
3492 case Xemerald_pause:
3493 switch (Cave[y+1][x])
3503 Cave[y][x] = Yemerald_sB;
3504 if (Cave[y][x+1] == Xblank)
3505 Cave[y][x+1] = Xacid_splash_e;
3506 if (Cave[y][x-1] == Xblank)
3507 Cave[y][x-1] = Xacid_splash_w;
3508 Next[y][x] = Xblank;
3509 play_element_sound(x, y, SOUND_acid, Xacid_1);
3513 case Xacid_splash_e:
3514 case Xacid_splash_w:
3515 Cave[y][x] = Yemerald_sB;
3516 Cave[y+1][x] = Yemerald_s;
3517 Next[y][x] = Xblank;
3518 Next[y+1][x] = Xemerald_fall;
3522 Cave[y][x] = Xemerald;
3523 Next[y][x] = Xemerald;
3527 /* --------------------------------------------------------------------- */
3530 switch (Cave[y+1][x])
3540 Cave[y][x] = Yemerald_sB;
3541 if (Cave[y][x+1] == Xblank)
3542 Cave[y][x+1] = Xacid_splash_e;
3543 if (Cave[y][x-1] == Xblank)
3544 Cave[y][x-1] = Xacid_splash_w;
3545 Next[y][x] = Xblank;
3546 play_element_sound(x, y, SOUND_acid, Xacid_1);
3550 case Xacid_splash_e:
3551 case Xacid_splash_w:
3553 Cave[y][x] = Yemerald_sB;
3554 Cave[y+1][x] = Yemerald_s;
3555 Next[y][x] = Xblank;
3556 Next[y+1][x] = Xemerald_fall;
3560 if (lev.wonderwall_time)
3562 lev.wonderwall_state = 1;
3563 Cave[y][x] = Yemerald_sB;
3564 if (tab_blank[Cave[y+2][x]])
3566 Cave[y+2][x] = Ydiamond_s;
3567 Next[y+2][x] = Xdiamond_fall;
3570 Next[y][x] = Xblank;
3571 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
3576 Cave[y][x] = Xemerald;
3577 Next[y][x] = Xemerald;
3578 play_element_sound(x, y, SOUND_diamond, Xemerald);
3582 /* --------------------------------------------------------------------- */
3585 switch (Cave[y+1][x])
3595 Cave[y][x] = Ydiamond_sB;
3596 if (Cave[y][x+1] == Xblank)
3597 Cave[y][x+1] = Xacid_splash_e;
3598 if (Cave[y][x-1] == Xblank)
3599 Cave[y][x-1] = Xacid_splash_w;
3600 Next[y][x] = Xblank;
3601 play_element_sound(x, y, SOUND_acid, Xacid_1);
3605 case Xacid_splash_e:
3606 case Xacid_splash_w:
3607 Cave[y][x] = Ydiamond_sB;
3608 Cave[y+1][x] = Ydiamond_s;
3609 Next[y][x] = Xblank;
3610 Next[y+1][x] = Xdiamond_fall;
3629 case Xemerald_pause:
3631 case Xdiamond_pause:
3668 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3670 Cave[y][x] = Ydiamond_eB;
3671 Cave[y][x+1] = Ydiamond_e;
3672 Next[y][x] = Xblank;
3673 Next[y][x+1] = Xdiamond_pause;
3677 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3679 Cave[y][x] = Ydiamond_wB;
3680 Cave[y][x-1] = Ydiamond_w;
3681 Next[y][x] = Xblank;
3682 Next[y][x-1] = Xdiamond_pause;
3688 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3690 Cave[y][x] = Ydiamond_wB;
3691 Cave[y][x-1] = Ydiamond_w;
3692 Next[y][x] = Xblank;
3693 Next[y][x-1] = Xdiamond_pause;
3697 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3699 Cave[y][x] = Ydiamond_eB;
3700 Cave[y][x+1] = Ydiamond_e;
3701 Next[y][x] = Xblank;
3702 Next[y][x+1] = Xdiamond_pause;
3708 if (++lev.shine_cnt > 50)
3710 lev.shine_cnt = RANDOM & 7;
3711 Cave[y][x] = Xdiamond_shine;
3717 /* --------------------------------------------------------------------- */
3719 case Xdiamond_pause:
3720 switch (Cave[y+1][x])
3730 Cave[y][x] = Ydiamond_sB;
3731 if (Cave[y][x+1] == Xblank)
3732 Cave[y][x+1] = Xacid_splash_e;
3733 if (Cave[y][x-1] == Xblank)
3734 Cave[y][x-1] = Xacid_splash_w;
3735 Next[y][x] = Xblank;
3736 play_element_sound(x, y, SOUND_acid, Xacid_1);
3740 case Xacid_splash_e:
3741 case Xacid_splash_w:
3742 Cave[y][x] = Ydiamond_sB;
3743 Cave[y+1][x] = Ydiamond_s;
3744 Next[y][x] = Xblank;
3745 Next[y+1][x] = Xdiamond_fall;
3749 Cave[y][x] = Xdiamond;
3750 Next[y][x] = Xdiamond;
3754 /* --------------------------------------------------------------------- */
3757 switch (Cave[y+1][x])
3767 Cave[y][x] = Ydiamond_sB;
3768 if (Cave[y][x+1] == Xblank)
3769 Cave[y][x+1] = Xacid_splash_e;
3770 if (Cave[y][x-1] == Xblank)
3771 Cave[y][x-1] = Xacid_splash_w;
3772 Next[y][x] = Xblank;
3773 play_element_sound(x, y, SOUND_acid, Xacid_1);
3777 case Xacid_splash_e:
3778 case Xacid_splash_w:
3780 Cave[y][x] = Ydiamond_sB;
3781 Cave[y+1][x] = Ydiamond_s;
3782 Next[y][x] = Xblank;
3783 Next[y+1][x] = Xdiamond_fall;
3787 if (lev.wonderwall_time)
3789 lev.wonderwall_state = 1;
3790 Cave[y][x] = Ydiamond_sB;
3791 if (tab_blank[Cave[y+2][x]])
3793 Cave[y+2][x] = Ystone_s;
3794 Next[y+2][x] = Xstone_fall;
3797 Next[y][x] = Xblank;
3798 play_element_sound(x, y, SOUND_wonderfall, Xwonderwall);
3803 Cave[y][x] = Xdiamond;
3804 Next[y][x] = Xdiamond;
3805 play_element_sound(x, y, SOUND_diamond, Xdiamond);
3809 /* --------------------------------------------------------------------- */
3812 switch (Cave[y+1][x])
3822 Cave[y][x] = Ydrip_1_sB;
3823 if (Cave[y][x+1] == Xblank)
3824 Cave[y][x+1] = Xacid_splash_e;
3825 if (Cave[y][x-1] == Xblank)
3826 Cave[y][x-1] = Xacid_splash_w;
3827 Next[y][x] = Xdrip_stretchB;
3828 play_element_sound(x, y, SOUND_acid, Xacid_1);
3832 case Xacid_splash_e:
3833 case Xacid_splash_w:
3837 Cave[y][x] = Ydrip_1_sB;
3838 Cave[y+1][x] = Ydrip_1_s;
3839 Next[y][x] = Xdrip_stretchB;
3840 Next[y+1][x] = Xdrip_stretch;
3881 play_element_sound(x, y, SOUND_drip, Xdrip_fall);
3885 /* --------------------------------------------------------------------- */
3888 Cave[y][x] = Ydrip_2_s;
3889 Next[y][x] = Xdrip_fall;
3892 case Xdrip_stretchB:
3893 Cave[y][x] = Ydrip_2_sB;
3894 Next[y][x] = Xblank;
3898 Next[y][x] = Xdrip_fall;
3901 /* --------------------------------------------------------------------- */
3904 switch (Cave[y+1][x])
3914 Cave[y][x] = Ybomb_sB;
3915 if (Cave[y][x+1] == Xblank)
3916 Cave[y][x+1] = Xacid_splash_e;
3917 if (Cave[y][x-1] == Xblank)
3918 Cave[y][x-1] = Xacid_splash_w;
3919 Next[y][x] = Xblank;
3920 play_element_sound(x, y, SOUND_acid, Xacid_1);
3924 case Xacid_splash_e:
3925 case Xacid_splash_w:
3926 Cave[y][x] = Ybomb_sB;
3927 Cave[y+1][x] = Ybomb_s;
3928 Next[y][x] = Xblank;
3929 Next[y+1][x] = Xbomb_fall;
3948 case Xemerald_pause:
3950 case Xdiamond_pause:
3978 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3980 Cave[y][x] = Ybomb_eB;
3981 Cave[y][x+1] = Ybomb_e;
3982 Next[y][x] = Xblank;
3983 Next[y][x+1] = Xbomb_pause;
3987 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3989 Cave[y][x] = Ybomb_wB;
3990 Cave[y][x-1] = Ybomb_w;
3991 Next[y][x] = Xblank;
3992 Next[y][x-1] = Xbomb_pause;
3998 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
4000 Cave[y][x] = Ybomb_wB;
4001 Cave[y][x-1] = Ybomb_w;
4002 Next[y][x] = Xblank;
4003 Next[y][x-1] = Xbomb_pause;
4007 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
4009 Cave[y][x] = Ybomb_eB;
4010 Cave[y][x+1] = Ybomb_e;
4011 Next[y][x] = Xblank;
4012 Next[y][x+1] = Xbomb_pause;
4021 /* --------------------------------------------------------------------- */
4024 switch (Cave[y+1][x])
4034 Cave[y][x] = Ybomb_sB;
4035 if (Cave[y][x+1] == Xblank)
4036 Cave[y][x+1] = Xacid_splash_e;
4037 if (Cave[y][x-1] == Xblank)
4038 Cave[y][x-1] = Xacid_splash_w;
4039 Next[y][x] = Xblank;
4040 play_element_sound(x, y, SOUND_acid, Xacid_1);
4044 case Xacid_splash_e:
4045 case Xacid_splash_w:
4046 Cave[y][x] = Ybomb_sB;
4047 Cave[y+1][x] = Ybomb_s;
4048 Next[y][x] = Xblank;
4049 Next[y+1][x] = Xbomb_fall;
4058 /* --------------------------------------------------------------------- */
4061 switch (Cave[y+1][x])
4071 Cave[y][x] = Ybomb_sB;
4072 if (Cave[y][x+1] == Xblank)
4073 Cave[y][x+1] = Xacid_splash_e;
4074 if (Cave[y][x-1] == Xblank)
4075 Cave[y][x-1] = Xacid_splash_w;
4076 Next[y][x] = Xblank;
4077 play_element_sound(x, y, SOUND_acid, Xacid_1);
4081 case Xacid_splash_e:
4082 case Xacid_splash_w:
4083 Cave[y][x] = Ybomb_sB;
4084 Cave[y+1][x] = Ybomb_s;
4085 Next[y][x] = Xblank;
4086 Next[y+1][x] = Xbomb_fall;
4090 Cave[y][x] = Ybomb_blank;
4091 Next[y][x] = Znormal;
4092 Boom[y-1][x-1] = Xblank;
4093 Boom[y-1][x] = Xblank;
4094 Boom[y-1][x+1] = Xblank;
4095 Boom[y][x-1] = Xblank;
4096 Boom[y][x] = Xblank;
4097 Boom[y][x+1] = Xblank;
4098 Boom[y+1][x-1] = Xblank;
4099 Boom[y+1][x] = Xblank;
4100 Boom[y+1][x+1] = Xblank;
4101 #if PLAY_ELEMENT_SOUND
4102 play_element_sound(x, y, SOUND_boom, element);
4107 /* --------------------------------------------------------------------- */
4110 if (lev.wind_cnt == 0)
4113 switch (lev.wind_direction)
4116 switch (Cave[y-1][x])
4126 Cave[y][x] = Yballoon_nB;
4127 if (Cave[y-2][x+1] == Xblank)
4128 Cave[y-2][x+1] = Xacid_splash_e;
4129 if (Cave[y-2][x-1] == Xblank)
4130 Cave[y-2][x-1] = Xacid_splash_w;
4131 Next[y][x] = Xblank;
4132 play_element_sound(x, y, SOUND_acid, Xacid_1);
4136 case Xacid_splash_e:
4137 case Xacid_splash_w:
4138 Cave[y][x] = Yballoon_nB;
4139 Cave[y-1][x] = Yballoon_n;
4140 Next[y][x] = Xblank;
4141 Next[y-1][x] = Xballoon;
4149 switch (Cave[y][x+1])
4159 Cave[y][x] = Yballoon_eB;
4160 if (Cave[y-1][x+2] == Xblank)
4161 Cave[y-1][x+2] = Xacid_splash_e;
4162 if (Cave[y-1][x] == Xblank)
4163 Cave[y-1][x] = Xacid_splash_w;
4164 Next[y][x] = Xblank;
4165 play_element_sound(x, y, SOUND_acid, Xacid_1);
4169 case Xacid_splash_e:
4170 case Xacid_splash_w:
4171 Cave[y][x] = Yballoon_eB;
4172 Cave[y][x+1] = Yballoon_e;
4173 Next[y][x] = Xblank;
4174 Next[y][x+1] = Xballoon;
4182 switch (Cave[y+1][x])
4192 Cave[y][x] = Yballoon_sB;
4193 if (Cave[y][x+1] == Xblank)
4194 Cave[y][x+1] = Xacid_splash_e;
4195 if (Cave[y][x-1] == Xblank)
4196 Cave[y][x-1] = Xacid_splash_w;
4197 Next[y][x] = Xblank;
4198 play_element_sound(x, y, SOUND_acid, Xacid_1);
4202 case Xacid_splash_e:
4203 case Xacid_splash_w:
4204 Cave[y][x] = Yballoon_sB;
4205 Cave[y+1][x] = Yballoon_s;
4206 Next[y][x] = Xblank;
4207 Next[y+1][x] = Xballoon;
4215 switch (Cave[y][x-1])
4225 Cave[y][x] = Yballoon_wB;
4226 if (Cave[y-1][x] == Xblank)
4227 Cave[y-1][x] = Xacid_splash_e;
4228 if (Cave[y-1][x-2] == Xblank)
4229 Cave[y-1][x-2] = Xacid_splash_w;
4230 Next[y][x] = Xblank;
4231 play_element_sound(x, y, SOUND_acid, Xacid_1);
4235 case Xacid_splash_e:
4236 case Xacid_splash_w:
4237 Cave[y][x] = Yballoon_wB;
4238 Cave[y][x-1] = Yballoon_w;
4239 Next[y][x] = Xblank;
4240 Next[y][x-1] = Xballoon;
4248 /* --------------------------------------------------------------------- */
4251 Next[y][x] = Xacid_2;
4255 Next[y][x] = Xacid_3;
4259 Next[y][x] = Xacid_4;
4263 Next[y][x] = Xacid_5;
4267 Next[y][x] = Xacid_6;
4271 Next[y][x] = Xacid_7;
4275 Next[y][x] = Xacid_8;
4279 Next[y][x] = Xacid_1;
4283 Next[y][x] = Xfake_acid_2;
4287 Next[y][x] = Xfake_acid_3;
4291 Next[y][x] = Xfake_acid_4;
4295 Next[y][x] = Xfake_acid_5;
4299 Next[y][x] = Xfake_acid_6;
4303 Next[y][x] = Xfake_acid_7;
4307 Next[y][x] = Xfake_acid_8;
4311 Next[y][x] = Xfake_acid_1;
4314 /* --------------------------------------------------------------------- */
4317 if (lev.ball_state == 0)
4320 Cave[y][x] = Yball_1;
4321 Next[y][x] = Xball_2;
4328 if (lev.ball_state == 0)
4331 Cave[y][x] = Yball_2;
4332 Next[y][x] = Xball_1;
4340 play_element_sound(x, y, SOUND_ball, element);
4341 if (lev.ball_random)
4346 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4347 tab_blank[Cave[y-1][x-1]])
4349 Cave[y-1][x-1] = Yball_blank;
4350 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4355 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4356 tab_blank[Cave[y-1][x]])
4358 Cave[y-1][x] = Yball_blank;
4359 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4364 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4365 tab_blank[Cave[y-1][x+1]])
4367 Cave[y-1][x+1] = Yball_blank;
4368 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4373 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4374 tab_blank[Cave[y][x-1]])
4376 Cave[y][x-1] = Yball_blank;
4377 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4382 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4383 tab_blank[Cave[y][x+1]])
4385 Cave[y][x+1] = Yball_blank;
4386 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4391 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4392 tab_blank[Cave[y+1][x-1]])
4394 Cave[y+1][x-1] = Yball_blank;
4395 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4400 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4401 tab_blank[Cave[y+1][x]])
4403 Cave[y+1][x] = Yball_blank;
4404 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4409 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4410 tab_blank[Cave[y+1][x+1]])
4412 Cave[y+1][x+1] = Yball_blank;
4413 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4420 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4421 tab_blank[Cave[y-1][x-1]])
4423 Cave[y-1][x-1] = Yball_blank;
4424 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4427 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4428 tab_blank[Cave[y-1][x]])
4430 Cave[y-1][x] = Yball_blank;
4431 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4434 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4435 tab_blank[Cave[y-1][x+1]])
4437 Cave[y-1][x+1] = Yball_blank;
4438 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4441 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4442 tab_blank[Cave[y][x-1]])
4444 Cave[y][x-1] = Yball_blank;
4445 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4448 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4449 tab_blank[Cave[y][x+1]])
4451 Cave[y][x+1] = Yball_blank;
4452 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4455 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4456 tab_blank[Cave[y+1][x-1]])
4458 Cave[y+1][x-1] = Yball_blank;
4459 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4462 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4463 tab_blank[Cave[y+1][x]])
4465 Cave[y+1][x] = Yball_blank;
4466 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4469 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4470 tab_blank[Cave[y+1][x+1]])
4472 Cave[y+1][x+1] = Yball_blank;
4473 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4477 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
4481 /* --------------------------------------------------------------------- */
4484 if (tab_blank[Cave[y-1][x]])
4486 Cave[y-1][x] = Yslidewall_ns_blank;
4487 Next[y-1][x] = Xslidewall_ns;
4488 play_element_sound(x, y, SOUND_slidewall, Xslidewall_ns);
4491 if (tab_blank[Cave[y+1][x]])
4493 Cave[y+1][x] = Yslidewall_ns_blank;
4494 Next[y+1][x] = Xslidewall_ns;
4495 play_element_sound(x, y, SOUND_slidewall, Xslidewall_ns);
4501 if (tab_blank[Cave[y][x+1]])
4503 Cave[y][x+1] = Yslidewall_ew_blank;
4504 Next[y][x+1] = Xslidewall_ew;
4505 play_element_sound(x, y, SOUND_slidewall, Xslidewall_ew);
4508 if (tab_blank[Cave[y][x-1]])
4510 Cave[y][x-1] = Yslidewall_ew_blank;
4511 Next[y][x-1] = Xslidewall_ew;
4512 play_element_sound(x, y, SOUND_slidewall, Xslidewall_ew);
4517 /* --------------------------------------------------------------------- */
4520 if (lev.wonderwall_time && lev.wonderwall_state)
4522 Cave[y][x] = XwonderwallB;
4523 play_element_sound(x, y, SOUND_wonder, Xwonderwall);
4528 /* --------------------------------------------------------------------- */
4531 if (lev.required > 0)
4537 Cave[y][x] = Xexit_1;
4538 Next[y][x] = Xexit_2;
4542 Cave[y][x] = Xexit_2;
4543 Next[y][x] = Xexit_3;
4547 Cave[y][x] = Xexit_3;
4548 Next[y][x] = Xexit_1;
4551 play_element_sound(x, y, SOUND_exit_open, Xexit);
4556 Next[y][x] = Xexit_2;
4560 Next[y][x] = Xexit_3;
4564 Next[y][x] = Xexit_1;
4567 /* --------------------------------------------------------------------- */
4570 play_element_sound(x, y, SOUND_tick, Xdynamite_1);
4571 Next[y][x] = Xdynamite_2;
4575 play_element_sound(x, y, SOUND_tick, Xdynamite_2);
4576 Next[y][x] = Xdynamite_3;
4580 play_element_sound(x, y, SOUND_tick, Xdynamite_3);
4581 Next[y][x] = Xdynamite_4;
4585 play_element_sound(x, y, SOUND_tick, Xdynamite_4);
4586 Next[y][x] = Zdynamite;
4587 Boom[y-1][x-1] = Xblank;
4588 Boom[y-1][x] = Xblank;
4589 Boom[y-1][x+1] = Xblank;
4590 Boom[y][x-1] = Xblank;
4591 Boom[y][x] = Xblank;
4592 Boom[y][x+1] = Xblank;
4593 Boom[y+1][x-1] = Xblank;
4594 Boom[y+1][x] = Xblank;
4595 Boom[y+1][x+1] = Xblank;
4598 /* --------------------------------------------------------------------- */
4601 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
4602 Cave[y][x] = XwheelB;
4605 /* --------------------------------------------------------------------- */
4609 Cave[y][x] = XswitchB;
4612 /* --------------------------------------------------------------------- */
4615 switch (Cave[y+1][x])
4625 Cave[y][x] = Xsand_stonesand_quickout_1;
4626 if (Cave[y][x+1] == Xblank)
4627 Cave[y][x+1] = Xacid_splash_e;
4628 if (Cave[y][x-1] == Xblank)
4629 Cave[y][x-1] = Xacid_splash_w;
4630 Next[y][x] = Xsand_stonesand_quickout_2;
4631 play_element_sound(x, y, SOUND_acid, Xacid_1);
4635 case Xacid_splash_e:
4636 case Xacid_splash_w:
4637 Cave[y][x] = Xsand_stonesand_quickout_1;
4638 Cave[y+1][x] = Xsand_stoneout_1;
4639 Next[y][x] = Xsand_stonesand_quickout_2;
4640 Next[y+1][x] = Xsand_stoneout_2;
4644 Cave[y][x] = Xsand_stonesand_1;
4645 Cave[y+1][x] = Xsand_sandstone_1;
4646 Next[y][x] = Xsand_stonesand_2;
4647 Next[y+1][x] = Xsand_sandstone_2;
4654 case Xsand_stonein_1:
4655 Next[y][x] = Xsand_stonein_2;
4658 case Xsand_stonein_2:
4659 Next[y][x] = Xsand_stonein_3;
4662 case Xsand_stonein_3:
4663 Next[y][x] = Xsand_stonein_4;
4666 case Xsand_stonein_4:
4667 Next[y][x] = Xblank;
4670 case Xsand_stonesand_1:
4671 Next[y][x] = Xsand_stonesand_2;
4674 case Xsand_stonesand_2:
4675 Next[y][x] = Xsand_stonesand_3;
4678 case Xsand_stonesand_3:
4679 Next[y][x] = Xsand_stonesand_4;
4682 case Xsand_stonesand_4:
4687 case Xsand_stonesand_quickout_1:
4688 Next[y][x] = Xsand_stonesand_quickout_2;
4691 case Xsand_stonesand_quickout_2:
4696 case Xsand_stoneout_1:
4697 Next[y][x] = Xsand_stoneout_2;
4700 case Xsand_stoneout_2:
4701 Next[y][x] = Xstone_fall;
4704 case Xsand_sandstone_1:
4705 Next[y][x] = Xsand_sandstone_2;
4708 case Xsand_sandstone_2:
4709 Next[y][x] = Xsand_sandstone_3;
4712 case Xsand_sandstone_3:
4713 Next[y][x] = Xsand_sandstone_4;
4716 case Xsand_sandstone_4:
4717 Next[y][x] = Xsand_stone;
4720 /* --------------------------------------------------------------------- */
4724 Cave[y][x] = Xfake_amoebaB;
4727 /* --------------------------------------------------------------------- */
4731 Cave[y][x] = Xfake_blankB;
4734 /* --------------------------------------------------------------------- */
4737 if (lev.magnify_cnt)
4738 Cave[y][x] = Xfake_grassB;
4741 /* --------------------------------------------------------------------- */
4744 if (lev.magnify_cnt)
4745 Cave[y][x] = Xdoor_1;
4749 if (lev.magnify_cnt)
4750 Cave[y][x] = Xdoor_2;
4754 if (lev.magnify_cnt)
4755 Cave[y][x] = Xdoor_3;
4759 if (lev.magnify_cnt)
4760 Cave[y][x] = Xdoor_4;
4764 if (lev.magnify_cnt)
4765 Cave[y][x] = Xdoor_5;
4769 if (lev.magnify_cnt)
4770 Cave[y][x] = Xdoor_6;
4774 if (lev.magnify_cnt)
4775 Cave[y][x] = Xdoor_7;
4779 if (lev.magnify_cnt)
4780 Cave[y][x] = Xdoor_8;
4783 /* --------------------------------------------------------------------- */
4787 Next[y][x] = Znormal;
4788 Boom[y-1][x-1] = Xemerald;
4789 Boom[y-1][x] = Xemerald;
4790 Boom[y-1][x+1] = Xemerald;
4791 Boom[y][x-1] = Xemerald;
4792 Boom[y][x] = Xdiamond;
4793 Boom[y][x+1] = Xemerald;
4794 Boom[y+1][x-1] = Xemerald;
4795 Boom[y+1][x] = Xemerald;
4796 Boom[y+1][x+1] = Xemerald;
4797 #if PLAY_ELEMENT_SOUND
4798 play_element_sound(x, y, SOUND_boom, element);
4806 Next[y][x] = Znormal;
4807 Boom[y-1][x-1] = Xblank;
4808 Boom[y-1][x] = Xblank;
4809 Boom[y-1][x+1] = Xblank;
4810 Boom[y][x-1] = Xblank;
4811 Boom[y][x] = Xblank;
4812 Boom[y][x+1] = Xblank;
4813 Boom[y+1][x-1] = Xblank;
4814 Boom[y+1][x] = Xblank;
4815 Boom[y+1][x+1] = Xblank;
4816 #if PLAY_ELEMENT_SOUND
4817 play_element_sound(x, y, SOUND_boom, element);
4822 #if PLAY_ELEMENT_SOUND
4823 play_element_sound(x, y, SOUND_boom, Xandroid);
4826 Next[y][x] = Xboom_2;
4827 #if !PLAY_ELEMENT_SOUND
4828 if (x != lev.exit_x && y != lev.exit_y)
4829 play_sound(x, y, SOUND_boom);
4831 lev.exit_x = lev.exit_y = -1;
4836 Next[y][x] = Boom[y][x];
4839 /* --------------------------------------------------------------------- */
4842 if (++y < HEIGHT - 1)
4845 cave_cache = Cave[y];
4858 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
4859 lev.score += score; /* only add a score if someone is alive */
4861 game_em.game_over = TRUE;
4868 /* triple buffering */