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.
17 #define RANDOM (random = random << 31 | random >> 1)
19 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
21 int distance, distance_shortest = EM_MAX_CAVE_WIDTH + EM_MAX_CAVE_HEIGHT;
24 /* default values if no players are alive anymore */
28 for (i = 0; i < MAX_PLAYERS; i++)
33 distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
35 if (distance < distance_shortest)
40 distance_shortest = distance;
49 unsigned long random = RandomEM;
50 short *cave_cache = Cave[y]; /* might be a win */
53 int temp = 0; /* initialized to make compilers happy */
54 int dx; /* only needed to find closest player */
60 element = cave_cache[++x];
67 /* --------------------------------------------------------------------- */
86 Cave[y][x] = Ystone_eB;
87 Cave[y][x+1] = Ystone_e;
89 Next[y][x+1] = Xstone_pause;
109 Cave[y][x] = Ystone_wB;
110 Cave[y][x-1] = Ystone_w;
112 Next[y][x-1] = Xstone_pause;
117 switch (Cave[y][x+1])
132 Cave[y][x] = Ynut_eB;
133 Cave[y][x+1] = Ynut_e;
135 Next[y][x+1] = Xnut_pause;
140 switch (Cave[y][x-1])
155 Cave[y][x] = Ynut_wB;
156 Cave[y][x-1] = Ynut_w;
158 Next[y][x-1] = Xnut_pause;
162 case Xspring_force_e:
163 switch (Cave[y][x+1])
173 Cave[y][x] = Xspring;
174 Next[y][x] = Xspring;
178 Cave[y][x] = Yspring_eB;
179 Cave[y][x+1] = Yspring_e;
183 Next[y][x+1] = Xspring_e;
185 Next[y][x+1] = Xspring_pause;
191 case Xspring_force_w:
192 switch (Cave[y][x-1])
202 Cave[y][x] = Xspring;
203 Next[y][x] = Xspring;
207 Cave[y][x] = Yspring_wB;
208 Cave[y][x-1] = Yspring_w;
212 Next[y][x-1] = Xspring_w;
214 Next[y][x-1] = Xspring_pause;
219 case Xemerald_force_e:
220 switch (Cave[y][x+1])
230 Cave[y][x] = Xemerald;
231 Next[y][x] = Xemerald;
235 Cave[y][x] = Yemerald_eB;
236 Cave[y][x+1] = Yemerald_e;
238 Next[y][x+1] = Xemerald_pause;
242 case Xemerald_force_w:
243 switch (Cave[y][x-1])
253 Cave[y][x] = Xemerald;
254 Next[y][x] = Xemerald;
258 Cave[y][x] = Yemerald_wB;
259 Cave[y][x-1] = Yemerald_w;
261 Next[y][x-1] = Xemerald_pause;
265 case Xdiamond_force_e:
266 switch (Cave[y][x+1])
276 Cave[y][x] = Xdiamond;
277 Next[y][x] = Xdiamond;
281 Cave[y][x] = Ydiamond_eB;
282 Cave[y][x+1] = Ydiamond_e;
284 Next[y][x+1] = Xdiamond_pause;
288 case Xdiamond_force_w:
289 switch (Cave[y][x-1])
299 Cave[y][x] = Xdiamond;
300 Next[y][x] = Xdiamond;
304 Cave[y][x] = Ydiamond_wB;
305 Cave[y][x-1] = Ydiamond_w;
307 Next[y][x-1] = Xdiamond_pause;
312 switch (Cave[y][x+1])
327 Cave[y][x] = Ybomb_eB;
328 Cave[y][x+1] = Ybomb_e;
330 Next[y][x+1] = Xbomb_pause;
335 switch (Cave[y][x-1])
350 Cave[y][x] = Ybomb_wB;
351 Cave[y][x-1] = Ybomb_w;
353 Next[y][x-1] = Xbomb_pause;
356 #endif /* BAD_ROLL */
358 /* --------------------------------------------------------------------- */
361 switch (Cave[y+1][x])
371 Cave[y][x] = Ystone_sB;
372 if (Cave[y][x+1] == Xblank)
373 Cave[y][x+1] = Yacid_splash_eB;
374 if (Cave[y][x-1] == Xblank)
375 Cave[y][x-1] = Yacid_splash_wB;
377 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
381 case Yacid_splash_eB:
382 case Yacid_splash_wB:
395 Cave[y][x] = Ystone_sB;
396 Cave[y+1][x] = Ystone_s;
398 Next[y+1][x] = Xstone_fall;
402 Cave[y][x] = Xsand_stonein_1;
403 Cave[y+1][x] = Xsand_sandstone_1;
404 Next[y][x] = Xsand_stonein_2;
405 Next[y+1][x] = Xsand_sandstone_2;
456 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
458 Cave[y][x] = Ystone_eB;
459 Cave[y][x+1] = Ystone_e;
461 Next[y][x+1] = Xstone_pause;
465 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
467 Cave[y][x] = Ystone_wB;
468 Cave[y][x-1] = Ystone_w;
470 Next[y][x-1] = Xstone_pause;
476 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
478 Cave[y][x] = Ystone_wB;
479 Cave[y][x-1] = Ystone_w;
481 Next[y][x-1] = Xstone_pause;
485 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
487 Cave[y][x] = Ystone_eB;
488 Cave[y][x+1] = Ystone_e;
490 Next[y][x+1] = Xstone_pause;
499 /* --------------------------------------------------------------------- */
502 switch (Cave[y+1][x])
512 Cave[y][x] = Ystone_sB;
513 if (Cave[y][x+1] == Xblank)
514 Cave[y][x+1] = Yacid_splash_eB;
515 if (Cave[y][x-1] == Xblank)
516 Cave[y][x-1] = Yacid_splash_wB;
518 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
522 case Yacid_splash_eB:
523 case Yacid_splash_wB:
534 Cave[y][x] = Ystone_sB;
535 Cave[y+1][x] = Ystone_s;
537 Next[y+1][x] = Xstone_fall;
546 /* --------------------------------------------------------------------- */
549 switch (Cave[y+1][x])
559 Cave[y][x] = Ystone_sB;
560 if (Cave[y][x+1] == Xblank)
561 Cave[y][x+1] = Yacid_splash_eB;
562 if (Cave[y][x-1] == Xblank)
563 Cave[y][x-1] = Yacid_splash_wB;
565 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
569 case Yacid_splash_eB:
570 case Yacid_splash_wB:
582 Cave[y][x] = Ystone_sB;
583 Cave[y+1][x] = Ystone_s;
585 Next[y+1][x] = Xstone_fall;
590 Cave[y+1][x] = Yemerald_stone;
592 Next[y+1][x] = Xemerald;
593 play_element_sound(x, y, SAMPLE_crack, Xnut);
594 score += lev.nut_score;
605 Cave[y][x] = Ystone_sB;
606 Cave[y+1][x] = Ybug_stone;
607 Next[y+1][x] = Znormal;
608 Boom[y][x-1] = Xemerald;
609 Boom[y][x] = Xemerald;
610 Boom[y][x+1] = Xemerald;
611 Boom[y+1][x-1] = Xemerald;
612 Boom[y+1][x] = Xdiamond;
613 Boom[y+1][x+1] = Xemerald;
614 Boom[y+2][x-1] = Xemerald;
615 Boom[y+2][x] = Xemerald;
616 Boom[y+2][x+1] = Xemerald;
618 play_element_sound(x, y, SAMPLE_boom, element);
620 score += lev.bug_score;
631 Cave[y][x] = Ystone_sB;
632 Cave[y+1][x] = Ytank_stone;
633 Next[y+1][x] = Znormal;
634 Boom[y][x-1] = Xblank;
636 Boom[y][x+1] = Xblank;
637 Boom[y+1][x-1] = Xblank;
638 Boom[y+1][x] = Xblank;
639 Boom[y+1][x+1] = Xblank;
640 Boom[y+2][x-1] = Xblank;
641 Boom[y+2][x] = Xblank;
642 Boom[y+2][x+1] = Xblank;
644 play_element_sound(x, y, SAMPLE_boom, element);
646 score += lev.tank_score;
652 switch (Cave[y+1][x+1])
655 case Yacid_splash_eB:
656 case Yacid_splash_wB:
659 Cave[y+1][x] = Xspring_e;
663 Cave[y+1][x] = Xspring_w;
669 switch (Cave[y+1][x-1])
672 case Yacid_splash_eB:
673 case Yacid_splash_wB:
676 Cave[y+1][x] = Xspring_w;
679 Cave[y+1][x] = Xspring_e;
691 Cave[y][x] = Ystone_sB;
692 Cave[y+1][x] = Yeater_stone;
693 Next[y+1][x] = Znormal;
694 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
695 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
696 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
697 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
698 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
699 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
700 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
701 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
702 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
704 play_element_sound(x, y, SAMPLE_boom, element);
706 lev.eater_pos = (lev.eater_pos + 1) & 7;
707 score += lev.eater_score;
712 Cave[y][x] = Ystone_sB;
713 Cave[y+1][x] = Yalien_stone;
714 Next[y+1][x] = Znormal;
715 Boom[y][x-1] = Xblank;
717 Boom[y][x+1] = Xblank;
718 Boom[y+1][x-1] = Xblank;
719 Boom[y+1][x] = Xblank;
720 Boom[y+1][x+1] = Xblank;
721 Boom[y+2][x-1] = Xblank;
722 Boom[y+2][x] = Xblank;
723 Boom[y+2][x+1] = Xblank;
725 play_element_sound(x, y, SAMPLE_boom, element);
727 score += lev.alien_score;
732 switch (Cave[y+2][x])
735 case Yacid_splash_eB:
736 case Yacid_splash_wB:
781 play_element_sound(x, y, SAMPLE_stone, Xstone);
785 Cave[y][x] = Ystone_sB;
786 Cave[y+1][x] = Ydiamond_stone;
788 Next[y+1][x] = Xstone_pause;
789 play_element_sound(x, y, SAMPLE_squash, Xdiamond);
794 Cave[y+1][x] = Ybomb_eat;
795 Next[y+1][x] = Znormal;
796 Boom[y][x-1] = Xblank;
798 Boom[y][x+1] = Xblank;
799 Boom[y+1][x-1] = Xblank;
800 Boom[y+1][x] = Xblank;
801 Boom[y+1][x+1] = Xblank;
802 Boom[y+2][x-1] = Xblank;
803 Boom[y+2][x] = Xblank;
804 Boom[y+2][x+1] = Xblank;
806 play_element_sound(x, y, SAMPLE_boom, element);
811 if (lev.wonderwall_time)
813 lev.wonderwall_state = 1;
814 Cave[y][x] = Ystone_sB;
816 if (tab_blank[Cave[y+2][x]])
818 Cave[y+2][x] = Yemerald_s;
819 Next[y+2][x] = Xemerald_fall;
823 play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
830 play_element_sound(x, y, SAMPLE_stone, Xstone);
834 /* --------------------------------------------------------------------- */
837 switch (Cave[y+1][x])
847 Cave[y][x] = Ynut_sB;
848 if (Cave[y][x+1] == Xblank)
849 Cave[y][x+1] = Yacid_splash_eB;
850 if (Cave[y][x-1] == Xblank)
851 Cave[y][x-1] = Yacid_splash_wB;
853 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
857 case Yacid_splash_eB:
858 case Yacid_splash_wB:
859 Cave[y][x] = Ynut_sB;
860 Cave[y+1][x] = Ynut_s;
862 Next[y+1][x] = Xnut_fall;
911 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
913 Cave[y][x] = Ynut_eB;
914 Cave[y][x+1] = Ynut_e;
916 Next[y][x+1] = Xnut_pause;
920 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
922 Cave[y][x] = Ynut_wB;
923 Cave[y][x-1] = Ynut_w;
925 Next[y][x-1] = Xnut_pause;
931 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
933 Cave[y][x] = Ynut_wB;
934 Cave[y][x-1] = Ynut_w;
936 Next[y][x-1] = Xnut_pause;
940 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
942 Cave[y][x] = Ynut_eB;
943 Cave[y][x+1] = Ynut_e;
945 Next[y][x+1] = Xnut_pause;
954 /* --------------------------------------------------------------------- */
958 switch (Cave[y+1][x])
968 Cave[y][x] = Ynut_sB;
969 if (Cave[y][x+1] == Xblank)
970 Cave[y][x+1] = Yacid_splash_eB;
971 if (Cave[y][x-1] == Xblank)
972 Cave[y][x-1] = Yacid_splash_wB;
974 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
978 case Yacid_splash_eB:
979 case Yacid_splash_wB:
980 Cave[y][x] = Ynut_sB;
981 Cave[y+1][x] = Ynut_s;
983 Next[y+1][x] = Xnut_fall;
992 /* --------------------------------------------------------------------- */
995 switch (Cave[y+1][x])
1005 Cave[y][x] = Ynut_sB;
1006 if (Cave[y][x+1] == Xblank)
1007 Cave[y][x+1] = Yacid_splash_eB;
1008 if (Cave[y][x-1] == Xblank)
1009 Cave[y][x-1] = Yacid_splash_wB;
1010 Next[y][x] = Xblank;
1011 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1015 case Yacid_splash_eB:
1016 case Yacid_splash_wB:
1018 Cave[y][x] = Ynut_sB;
1019 Cave[y+1][x] = Ynut_s;
1020 Next[y][x] = Xblank;
1021 Next[y+1][x] = Xnut_fall;
1027 play_element_sound(x, y, SAMPLE_nut, Xnut);
1031 /* --------------------------------------------------------------------- */
1034 if (tab_amoeba[Cave[y-1][x]] ||
1035 tab_amoeba[Cave[y][x+1]] ||
1036 tab_amoeba[Cave[y+1][x]] ||
1037 tab_amoeba[Cave[y][x-1]])
1040 switch (Cave[y][x+1])
1043 case Yacid_splash_eB:
1044 case Yacid_splash_wB:
1056 Cave[y][x] = Ybug_n_e;
1057 Next[y][x] = Xbug_goe;
1058 play_element_sound(x, y, SAMPLE_bug, element);
1066 if (tab_amoeba[Cave[y-1][x]] ||
1067 tab_amoeba[Cave[y][x+1]] ||
1068 tab_amoeba[Cave[y+1][x]] ||
1069 tab_amoeba[Cave[y][x-1]])
1074 switch (Cave[y-1][x])
1084 Cave[y][x] = Ybug_nB;
1085 if (Cave[y-2][x+1] == Xblank)
1086 Cave[y-2][x+1] = Yacid_splash_eB;
1087 if (Cave[y-2][x-1] == Xblank)
1088 Cave[y-2][x-1] = Yacid_splash_wB;
1089 Next[y][x] = Xblank;
1090 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1094 case Yacid_splash_eB:
1095 case Yacid_splash_wB:
1099 Cave[y][x] = Ybug_nB;
1100 Cave[y-1][x] = Ybug_n;
1101 Next[y][x] = Xblank;
1102 Next[y-1][x] = Xbug_n;
1103 play_element_sound(x, y, SAMPLE_bug, element);
1107 Cave[y][x] = Ybug_n_w;
1108 Next[y][x] = Xbug_gow;
1109 play_element_sound(x, y, SAMPLE_bug, element);
1113 /* --------------------------------------------------------------------- */
1116 if (tab_amoeba[Cave[y-1][x]] ||
1117 tab_amoeba[Cave[y][x+1]] ||
1118 tab_amoeba[Cave[y+1][x]] ||
1119 tab_amoeba[Cave[y][x-1]])
1122 switch (Cave[y+1][x])
1125 case Yacid_splash_eB:
1126 case Yacid_splash_wB:
1138 Cave[y][x] = Ybug_e_s;
1139 Next[y][x] = Xbug_gos;
1140 play_element_sound(x, y, SAMPLE_bug, element);
1148 if (tab_amoeba[Cave[y-1][x]] ||
1149 tab_amoeba[Cave[y][x+1]] ||
1150 tab_amoeba[Cave[y+1][x]] ||
1151 tab_amoeba[Cave[y][x-1]])
1156 switch (Cave[y][x+1])
1166 Cave[y][x] = Ybug_eB;
1167 if (Cave[y-1][x+2] == Xblank)
1168 Cave[y-1][x+2] = Yacid_splash_eB;
1169 if (Cave[y-1][x] == Xblank)
1170 Cave[y-1][x] = Yacid_splash_wB;
1171 Next[y][x] = Xblank;
1172 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1176 case Yacid_splash_eB:
1177 case Yacid_splash_wB:
1181 Cave[y][x] = Ybug_eB;
1182 Cave[y][x+1] = Ybug_e;
1183 Next[y][x] = Xblank;
1184 Next[y][x+1] = Xbug_e;
1185 play_element_sound(x, y, SAMPLE_bug, element);
1189 Cave[y][x] = Ybug_e_n;
1190 Next[y][x] = Xbug_gon;
1191 play_element_sound(x, y, SAMPLE_bug, element);
1195 /* --------------------------------------------------------------------- */
1198 if (tab_amoeba[Cave[y-1][x]] ||
1199 tab_amoeba[Cave[y][x+1]] ||
1200 tab_amoeba[Cave[y+1][x]] ||
1201 tab_amoeba[Cave[y][x-1]])
1204 switch (Cave[y][x-1])
1207 case Yacid_splash_eB:
1208 case Yacid_splash_wB:
1220 Cave[y][x] = Ybug_s_w;
1221 Next[y][x] = Xbug_gow;
1222 play_element_sound(x, y, SAMPLE_bug, element);
1230 if (tab_amoeba[Cave[y-1][x]] ||
1231 tab_amoeba[Cave[y][x+1]] ||
1232 tab_amoeba[Cave[y+1][x]] ||
1233 tab_amoeba[Cave[y][x-1]])
1238 switch (Cave[y+1][x])
1248 Cave[y][x] = Ybug_sB;
1249 if (Cave[y][x+1] == Xblank)
1250 Cave[y][x+1] = Yacid_splash_eB;
1251 if (Cave[y][x-1] == Xblank)
1252 Cave[y][x-1] = Yacid_splash_wB;
1253 Next[y][x] = Xblank;
1254 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1258 case Yacid_splash_eB:
1259 case Yacid_splash_wB:
1263 Cave[y][x] = Ybug_sB;
1264 Cave[y+1][x] = Ybug_s;
1265 Next[y][x] = Xblank;
1266 Next[y+1][x] = Xbug_s;
1267 play_element_sound(x, y, SAMPLE_bug, element);
1271 Cave[y][x] = Ybug_s_e;
1272 Next[y][x] = Xbug_goe;
1273 play_element_sound(x, y, SAMPLE_bug, element);
1277 /* --------------------------------------------------------------------- */
1280 if (tab_amoeba[Cave[y-1][x]] ||
1281 tab_amoeba[Cave[y][x+1]] ||
1282 tab_amoeba[Cave[y+1][x]] ||
1283 tab_amoeba[Cave[y][x-1]])
1286 switch (Cave[y-1][x])
1289 case Yacid_splash_eB:
1290 case Yacid_splash_wB:
1302 Cave[y][x] = Ybug_w_n;
1303 Next[y][x] = Xbug_gon;
1304 play_element_sound(x, y, SAMPLE_bug, element);
1312 if (tab_amoeba[Cave[y-1][x]] ||
1313 tab_amoeba[Cave[y][x+1]] ||
1314 tab_amoeba[Cave[y+1][x]] ||
1315 tab_amoeba[Cave[y][x-1]])
1320 switch (Cave[y][x-1])
1330 Cave[y][x] = Ybug_wB;
1331 if (Cave[y-1][x] == Xblank)
1332 Cave[y-1][x] = Yacid_splash_eB;
1333 if (Cave[y-1][x-2] == Xblank)
1334 Cave[y-1][x-2] = Yacid_splash_wB;
1335 Next[y][x] = Xblank;
1336 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1340 case Yacid_splash_eB:
1341 case Yacid_splash_wB:
1345 Cave[y][x] = Ybug_wB;
1346 Cave[y][x-1] = Ybug_w;
1347 Next[y][x] = Xblank;
1348 Next[y][x-1] = Xbug_w;
1349 play_element_sound(x, y, SAMPLE_bug, element);
1353 Cave[y][x] = Ybug_w_s;
1354 Next[y][x] = Xbug_gos;
1355 play_element_sound(x, y, SAMPLE_bug, element);
1359 /* --------------------------------------------------------------------- */
1362 if (tab_amoeba[Cave[y-1][x]] ||
1363 tab_amoeba[Cave[y][x+1]] ||
1364 tab_amoeba[Cave[y+1][x]] ||
1365 tab_amoeba[Cave[y][x-1]])
1368 switch (Cave[y][x-1])
1371 case Yacid_splash_eB:
1372 case Yacid_splash_wB:
1384 Cave[y][x] = Ytank_n_w;
1385 Next[y][x] = Xtank_gow;
1386 play_element_sound(x, y, SAMPLE_tank, element);
1394 if (tab_amoeba[Cave[y-1][x]] ||
1395 tab_amoeba[Cave[y][x+1]] ||
1396 tab_amoeba[Cave[y+1][x]] ||
1397 tab_amoeba[Cave[y][x-1]])
1402 switch (Cave[y-1][x])
1412 Cave[y][x] = Ytank_nB;
1413 if (Cave[y-2][x+1] == Xblank)
1414 Cave[y-2][x+1] = Yacid_splash_eB;
1415 if (Cave[y-2][x-1] == Xblank)
1416 Cave[y-2][x-1] = Yacid_splash_wB;
1417 Next[y][x] = Xblank;
1418 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1422 case Yacid_splash_eB:
1423 case Yacid_splash_wB:
1427 Cave[y][x] = Ytank_nB;
1428 Cave[y-1][x] = Ytank_n;
1429 Next[y][x] = Xblank;
1430 Next[y-1][x] = Xtank_n;
1431 play_element_sound(x, y, SAMPLE_tank, element);
1435 Cave[y][x] = Ytank_n_e;
1436 Next[y][x] = Xtank_goe;
1437 play_element_sound(x, y, SAMPLE_tank, element);
1441 /* --------------------------------------------------------------------- */
1444 if (tab_amoeba[Cave[y-1][x]] ||
1445 tab_amoeba[Cave[y][x+1]] ||
1446 tab_amoeba[Cave[y+1][x]] ||
1447 tab_amoeba[Cave[y][x-1]])
1450 switch (Cave[y-1][x])
1453 case Yacid_splash_eB:
1454 case Yacid_splash_wB:
1466 Cave[y][x] = Ytank_e_n;
1467 Next[y][x] = Xtank_gon;
1468 play_element_sound(x, y, SAMPLE_tank, element);
1476 if (tab_amoeba[Cave[y-1][x]] ||
1477 tab_amoeba[Cave[y][x+1]] ||
1478 tab_amoeba[Cave[y+1][x]] ||
1479 tab_amoeba[Cave[y][x-1]])
1484 switch (Cave[y][x+1])
1494 Cave[y][x] = Ytank_eB;
1495 if (Cave[y-1][x+2] == Xblank)
1496 Cave[y-1][x+2] = Yacid_splash_eB;
1497 if (Cave[y-1][x] == Xblank)
1498 Cave[y-1][x] = Yacid_splash_wB;
1499 Next[y][x] = Xblank;
1500 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1504 case Yacid_splash_eB:
1505 case Yacid_splash_wB:
1509 Cave[y][x] = Ytank_eB;
1510 Cave[y][x+1] = Ytank_e;
1511 Next[y][x] = Xblank;
1512 Next[y][x+1] = Xtank_e;
1513 play_element_sound(x, y, SAMPLE_tank, element);
1517 Cave[y][x] = Ytank_e_s;
1518 Next[y][x] = Xtank_gos;
1519 play_element_sound(x, y, SAMPLE_tank, element);
1523 /* --------------------------------------------------------------------- */
1526 if (tab_amoeba[Cave[y-1][x]] ||
1527 tab_amoeba[Cave[y][x+1]] ||
1528 tab_amoeba[Cave[y+1][x]] ||
1529 tab_amoeba[Cave[y][x-1]])
1532 switch (Cave[y][x+1])
1535 case Yacid_splash_eB:
1536 case Yacid_splash_wB:
1548 Cave[y][x] = Ytank_s_e;
1549 Next[y][x] = Xtank_goe;
1550 play_element_sound(x, y, SAMPLE_tank, element);
1558 if (tab_amoeba[Cave[y-1][x]] ||
1559 tab_amoeba[Cave[y][x+1]] ||
1560 tab_amoeba[Cave[y+1][x]] ||
1561 tab_amoeba[Cave[y][x-1]])
1566 switch (Cave[y+1][x])
1576 Cave[y][x] = Ytank_sB;
1577 if (Cave[y][x+1] == Xblank)
1578 Cave[y][x+1] = Yacid_splash_eB;
1579 if (Cave[y][x-1] == Xblank)
1580 Cave[y][x-1] = Yacid_splash_wB;
1581 Next[y][x] = Xblank;
1582 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1586 case Yacid_splash_eB:
1587 case Yacid_splash_wB:
1591 Cave[y][x] = Ytank_sB;
1592 Cave[y+1][x] = Ytank_s;
1593 Next[y][x] = Xblank;
1594 Next[y+1][x] = Xtank_s;
1595 play_element_sound(x, y, SAMPLE_tank, element);
1599 Cave[y][x] = Ytank_s_w;
1600 Next[y][x] = Xtank_gow;
1601 play_element_sound(x, y, SAMPLE_tank, element);
1605 /* --------------------------------------------------------------------- */
1608 if (tab_amoeba[Cave[y-1][x]] ||
1609 tab_amoeba[Cave[y][x+1]] ||
1610 tab_amoeba[Cave[y+1][x]] ||
1611 tab_amoeba[Cave[y][x-1]])
1614 switch (Cave[y+1][x])
1617 case Yacid_splash_eB:
1618 case Yacid_splash_wB:
1630 Cave[y][x] = Ytank_w_s;
1631 Next[y][x] = Xtank_gos;
1632 play_element_sound(x, y, SAMPLE_tank, element);
1640 if (tab_amoeba[Cave[y-1][x]] ||
1641 tab_amoeba[Cave[y][x+1]] ||
1642 tab_amoeba[Cave[y+1][x]] ||
1643 tab_amoeba[Cave[y][x-1]])
1648 switch (Cave[y][x-1])
1658 Cave[y][x] = Ytank_wB;
1659 if (Cave[y-1][x] == Xblank)
1660 Cave[y-1][x] = Yacid_splash_eB;
1661 if (Cave[y-1][x-2] == Xblank)
1662 Cave[y-1][x-2] = Yacid_splash_wB;
1663 Next[y][x] = Xblank;
1664 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1668 case Yacid_splash_eB:
1669 case Yacid_splash_wB:
1673 Cave[y][x] = Ytank_wB;
1674 Cave[y][x-1] = Ytank_w;
1675 Next[y][x] = Xblank;
1676 Next[y][x-1] = Xtank_w;
1677 play_element_sound(x, y, SAMPLE_tank, element);
1681 Cave[y][x] = Ytank_w_n;
1682 Next[y][x] = Xtank_gon;
1683 play_element_sound(x, y, SAMPLE_tank, element);
1687 /* --------------------------------------------------------------------- */
1693 if (lev.android_clone_cnt == 0)
1695 if (Cave[y-1][x-1] != Xblank &&
1696 Cave[y-1][x] != Xblank &&
1697 Cave[y-1][x+1] != Xblank &&
1698 Cave[y][x-1] != Xblank &&
1699 Cave[y][x+1] != Xblank &&
1700 Cave[y+1][x-1] != Xblank &&
1701 Cave[y+1][x] != Xblank &&
1702 Cave[y+1][x+1] != Xblank)
1707 /* randomly find an object to clone */
1709 case 0: /* S,NE,W,NW,SE,E,SW,N */
1710 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1711 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1712 temp= lev.android_array[Cave[y][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+1][x+1]]; if (temp != Xblank) break;
1715 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1716 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1717 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1720 case 1: /* NW,SE,N,S,NE,SW,E,W */
1721 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1722 temp= lev.android_array[Cave[y+1][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]]; 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;
1727 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1728 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1731 case 2: /* SW,E,S,W,N,NW,SE,NE */
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+1][x]]; if (temp != Xblank) break;
1735 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1736 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1737 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1738 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1739 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1742 case 3: /* N,SE,NE,E,W,S,NW,SW */
1743 temp= lev.android_array[Cave[y-1][x]]; 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][x-1]]; if (temp != Xblank) break;
1748 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1749 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1750 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1753 case 4: /* SE,NW,E,NE,SW,W,N,S */
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][x+1]]; if (temp != Xblank) break;
1757 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1758 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1759 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1760 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1761 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1764 case 5: /* NE,W,SE,SW,S,N,E,NW */
1765 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1766 temp= lev.android_array[Cave[y][x-1]]; 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]]; if (temp != Xblank) break;
1770 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1771 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1772 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1775 case 6: /* E,N,SW,S,NW,NE,SE,W */
1776 temp= lev.android_array[Cave[y][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+1][x-1]]; if (temp != Xblank) break;
1779 temp= lev.android_array[Cave[y+1][x]]; 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+1]]; if (temp != Xblank) break;
1782 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1783 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1786 case 7: /* W,SW,NW,N,E,SE,NE,S */
1787 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1788 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1789 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1790 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1791 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1792 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1793 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1794 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1798 Next[y][x] = temp; /* the item we chose to clone */
1799 play_element_sound(x, y, SAMPLE_android_clone, temp);
1803 /* randomly find a direction to move */
1805 case 0: /* S,NE,W,NW,SE,E,SW,N */
1806 if (Cave[y+1][x] == Xblank) goto android_s;
1807 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1808 if (Cave[y][x-1] == Xblank) goto android_w;
1809 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1810 if (Cave[y+1][x+1] == Xblank) goto android_se;
1811 if (Cave[y][x+1] == Xblank) goto android_e;
1812 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1813 if (Cave[y-1][x] == Xblank) goto android_n;
1816 case 1: /* NW,SE,N,S,NE,SW,E,W */
1817 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1818 if (Cave[y+1][x+1] == Xblank) goto android_se;
1819 if (Cave[y-1][x] == Xblank) goto android_n;
1820 if (Cave[y+1][x] == Xblank) goto android_s;
1821 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1822 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1823 if (Cave[y][x+1] == Xblank) goto android_e;
1824 if (Cave[y][x-1] == Xblank) goto android_w;
1827 case 2: /* SW,E,S,W,N,NW,SE,NE */
1828 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1829 if (Cave[y][x+1] == Xblank) goto android_e;
1830 if (Cave[y+1][x] == Xblank) goto android_s;
1831 if (Cave[y][x-1] == Xblank) goto android_w;
1832 if (Cave[y-1][x] == Xblank) goto android_n;
1833 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1834 if (Cave[y+1][x+1] == Xblank) goto android_se;
1835 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1838 case 3: /* N,SE,NE,E,W,S,NW,SW */
1839 if (Cave[y-1][x] == Xblank) goto android_n;
1840 if (Cave[y+1][x+1] == Xblank) goto android_se;
1841 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1842 if (Cave[y][x+1] == Xblank) goto android_e;
1843 if (Cave[y][x-1] == Xblank) goto android_w;
1844 if (Cave[y+1][x] == Xblank) goto android_s;
1845 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1846 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1849 case 4: /* SE,NW,E,NE,SW,W,N,S */
1850 if (Cave[y+1][x+1] == Xblank) goto android_se;
1851 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1852 if (Cave[y][x+1] == Xblank) goto android_e;
1853 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1854 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1855 if (Cave[y][x-1] == Xblank) goto android_w;
1856 if (Cave[y-1][x] == Xblank) goto android_n;
1857 if (Cave[y+1][x] == Xblank) goto android_s;
1860 case 5: /* NE,W,SE,SW,S,N,E,NW */
1861 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1862 if (Cave[y][x-1] == Xblank) goto android_w;
1863 if (Cave[y+1][x+1] == Xblank) goto android_se;
1864 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1865 if (Cave[y+1][x] == Xblank) goto android_s;
1866 if (Cave[y-1][x] == Xblank) goto android_n;
1867 if (Cave[y][x+1] == Xblank) goto android_e;
1868 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1871 case 6: /* E,N,SW,S,NW,NE,SE,W */
1872 if (Cave[y][x+1] == Xblank) goto android_e;
1873 if (Cave[y-1][x] == Xblank) goto android_n;
1874 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1875 if (Cave[y+1][x] == Xblank) goto android_s;
1876 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1877 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1878 if (Cave[y+1][x+1] == Xblank) goto android_se;
1879 if (Cave[y][x-1] == Xblank) goto android_w;
1882 case 7: /* W,SW,NW,N,E,SE,NE,S */
1883 if (Cave[y][x-1] == Xblank) goto android_w;
1884 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1885 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1886 if (Cave[y-1][x] == Xblank) goto android_n;
1887 if (Cave[y][x+1] == Xblank) goto android_e;
1888 if (Cave[y+1][x+1] == Xblank) goto android_se;
1889 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1890 if (Cave[y+1][x] == Xblank) goto android_s;
1896 if (lev.android_move_cnt == 0)
1898 if (Cave[y-1][x-1] == Zplayer ||
1899 Cave[y-1][x] == Zplayer ||
1900 Cave[y-1][x+1] == Zplayer ||
1901 Cave[y][x-1] == Zplayer ||
1902 Cave[y][x+1] == Zplayer ||
1903 Cave[y+1][x-1] == Zplayer ||
1904 Cave[y+1][x] == Zplayer ||
1905 Cave[y+1][x+1] == Zplayer)
1910 set_nearest_player_xy(x, y, &dx, &dy);
1914 if (ply1.alive && ply2.alive)
1916 if ((ply1.x > x ? ply1.x - x : x - ply1.x) +
1917 (ply1.y > y ? ply1.y - y : y - ply1.y) <
1918 (ply2.x > x ? ply2.x - x : x - ply2.x) +
1919 (ply2.y > y ? ply2.y - y : y - ply2.y))
1930 else if (ply1.alive)
1935 else if (ply2.alive)
1948 Next[y][x] = Xblank; /* assume we will move */
1949 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1955 /* attempt clockwise move first if direct path is blocked */
1957 case 0: /* north west */
1958 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1959 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1960 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1964 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1965 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1966 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1969 case 2: /* north east */
1970 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1971 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1972 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1976 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1977 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1978 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1981 case 4: /* nowhere */
1985 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1986 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1987 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1990 case 6: /* south west */
1991 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1992 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1993 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1997 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1998 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1999 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2002 case 8: /* south east */
2003 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2004 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2005 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2013 /* attempt counterclockwise move first if direct path is blocked */
2015 case 0: /* north west */
2016 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2017 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2018 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2022 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2023 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2024 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2027 case 2: /* north east */
2028 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2029 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2030 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2034 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2035 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2036 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2039 case 4: /* nowhere */
2043 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2044 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2045 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2048 case 6: /* south west */
2049 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2050 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2051 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2055 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2056 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2057 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2060 case 8: /* south east */
2061 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2062 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2063 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2071 Next[y][x] = Xandroid;
2076 Cave[y][x] = Yandroid_nB;
2077 Cave[y-1][x] = Yandroid_n;
2078 Next[y-1][x] = Xandroid;
2079 play_element_sound(x, y, SAMPLE_android_move, element);
2084 Cave[y][x] = Yandroid_neB;
2085 Cave[y-1][x+1] = Yandroid_ne;
2086 Next[y-1][x+1] = Xandroid;
2087 play_element_sound(x, y, SAMPLE_android_move, element);
2092 Cave[y][x] = Yandroid_eB;
2093 Cave[y][x+1] = Yandroid_e;
2094 Next[y][x+1] = Xandroid;
2095 play_element_sound(x, y, SAMPLE_android_move, element);
2100 Cave[y][x] = Yandroid_seB;
2101 Cave[y+1][x+1] = Yandroid_se;
2102 Next[y+1][x+1] = Xandroid;
2103 play_element_sound(x, y, SAMPLE_android_move, element);
2108 Cave[y][x] = Yandroid_sB;
2109 Cave[y+1][x] = Yandroid_s;
2110 Next[y+1][x] = Xandroid;
2111 play_element_sound(x, y, SAMPLE_android_move, element);
2116 Cave[y][x] = Yandroid_swB;
2117 Cave[y+1][x-1] = Yandroid_sw;
2118 Next[y+1][x-1] = Xandroid;
2119 play_element_sound(x, y, SAMPLE_android_move, element);
2124 Cave[y][x] = Yandroid_wB;
2125 Cave[y][x-1] = Yandroid_w;
2126 Next[y][x-1] = Xandroid;
2127 play_element_sound(x, y, SAMPLE_android_move, element);
2132 Cave[y][x] = Yandroid_nwB;
2133 Cave[y-1][x-1] = Yandroid_nw;
2134 Next[y-1][x-1] = Xandroid;
2135 play_element_sound(x, y, SAMPLE_android_move, element);
2138 /* --------------------------------------------------------------------- */
2141 switch (Cave[y-1][x])
2151 Cave[y][x] = Yandroid_nB;
2152 if (Cave[y-2][x+1] == Xblank)
2153 Cave[y-2][x+1] = Yacid_splash_eB;
2154 if (Cave[y-2][x-1] == Xblank)
2155 Cave[y-2][x-1] = Yacid_splash_wB;
2156 Next[y][x] = Xblank;
2157 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2161 case Yacid_splash_eB:
2162 case Yacid_splash_wB:
2163 Cave[y][x] = Yandroid_nB;
2164 Cave[y-1][x] = Yandroid_n;
2165 Next[y][x] = Xblank;
2166 Next[y-1][x] = Xandroid;
2167 play_element_sound(x, y, SAMPLE_android_move, element);
2175 switch (Cave[y-1][x])
2185 Cave[y][x] = Yandroid_nB;
2186 if (Cave[y-2][x+1] == Xblank)
2187 Cave[y-2][x+1] = Yacid_splash_eB;
2188 if (Cave[y-2][x-1] == Xblank)
2189 Cave[y-2][x-1] = Yacid_splash_wB;
2190 Next[y][x] = Xblank;
2191 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2195 case Yacid_splash_eB:
2196 case Yacid_splash_wB:
2197 Cave[y][x] = Yandroid_nB;
2198 Cave[y-1][x] = Yandroid_n;
2199 Next[y][x] = Xblank;
2200 Next[y-1][x] = Xandroid_1_n;
2201 play_element_sound(x, y, SAMPLE_android_move, element);
2208 /* --------------------------------------------------------------------- */
2211 switch (Cave[y][x+1])
2221 Cave[y][x] = Yandroid_eB;
2222 if (Cave[y-1][x+2] == Xblank)
2223 Cave[y-1][x+2] = Yacid_splash_eB;
2224 if (Cave[y-1][x] == Xblank)
2225 Cave[y-1][x] = Yacid_splash_wB;
2226 Next[y][x] = Xblank;
2227 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2231 case Yacid_splash_eB:
2232 case Yacid_splash_wB:
2233 Cave[y][x] = Yandroid_eB;
2234 Cave[y][x+1] = Yandroid_e;
2235 Next[y][x] = Xblank;
2236 Next[y][x+1] = Xandroid;
2237 play_element_sound(x, y, SAMPLE_android_move, element);
2245 switch (Cave[y][x+1])
2255 Cave[y][x] = Yandroid_eB;
2256 if (Cave[y-1][x+2] == Xblank)
2257 Cave[y-1][x+2] = Yacid_splash_eB;
2258 if (Cave[y-1][x] == Xblank)
2259 Cave[y-1][x] = Yacid_splash_wB;
2260 Next[y][x] = Xblank;
2261 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2265 case Yacid_splash_eB:
2266 case Yacid_splash_wB:
2267 Cave[y][x] = Yandroid_eB;
2268 Cave[y][x+1] = Yandroid_e;
2269 Next[y][x] = Xblank;
2270 Next[y][x+1] = Xandroid_1_e;
2271 play_element_sound(x, y, SAMPLE_android_move, element);
2278 /* --------------------------------------------------------------------- */
2281 switch (Cave[y+1][x])
2291 Cave[y][x] = Yandroid_sB;
2292 if (Cave[y][x+1] == Xblank)
2293 Cave[y][x+1] = Yacid_splash_eB;
2294 if (Cave[y][x-1] == Xblank)
2295 Cave[y][x-1] = Yacid_splash_wB;
2296 Next[y][x] = Xblank;
2297 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2301 case Yacid_splash_eB:
2302 case Yacid_splash_wB:
2303 Cave[y][x] = Yandroid_sB;
2304 Cave[y+1][x] = Yandroid_s;
2305 Next[y][x] = Xblank;
2306 Next[y+1][x] = Xandroid;
2307 play_element_sound(x, y, SAMPLE_android_move, element);
2315 switch (Cave[y+1][x])
2325 Cave[y][x] = Yandroid_sB;
2326 if (Cave[y][x+1] == Xblank)
2327 Cave[y][x+1] = Yacid_splash_eB;
2328 if (Cave[y][x-1] == Xblank)
2329 Cave[y][x-1] = Yacid_splash_wB;
2330 Next[y][x] = Xblank;
2331 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2335 case Yacid_splash_eB:
2336 case Yacid_splash_wB:
2337 Cave[y][x] = Yandroid_sB;
2338 Cave[y+1][x] = Yandroid_s;
2339 Next[y][x] = Xblank;
2340 Next[y+1][x] = Xandroid_1_s;
2341 play_element_sound(x, y, SAMPLE_android_move, element);
2348 /* --------------------------------------------------------------------- */
2351 switch (Cave[y][x-1])
2361 Cave[y][x] = Yandroid_wB;
2362 if (Cave[y-1][x] == Xblank)
2363 Cave[y-1][x] = Yacid_splash_eB;
2364 if (Cave[y-1][x-2] == Xblank)
2365 Cave[y-1][x-2] = Yacid_splash_wB;
2366 Next[y][x] = Xblank;
2367 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2371 case Yacid_splash_eB:
2372 case Yacid_splash_wB:
2373 Cave[y][x] = Yandroid_wB;
2374 Cave[y][x-1] = Yandroid_w;
2375 Next[y][x] = Xblank;
2376 Next[y][x-1] = Xandroid;
2377 play_element_sound(x, y, SAMPLE_android_move, element);
2385 switch (Cave[y][x-1])
2395 Cave[y][x] = Yandroid_wB;
2396 if (Cave[y-1][x] == Xblank)
2397 Cave[y-1][x] = Yacid_splash_eB;
2398 if (Cave[y-1][x-2] == Xblank)
2399 Cave[y-1][x-2] = Yacid_splash_wB;
2400 Next[y][x] = Xblank;
2401 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2405 case Yacid_splash_eB:
2406 case Yacid_splash_wB:
2407 Cave[y][x] = Yandroid_wB;
2408 Cave[y][x-1] = Yandroid_w;
2409 Next[y][x] = Xblank;
2410 Next[y][x-1] = Xandroid_1_w;
2411 play_element_sound(x, y, SAMPLE_android_move, element);
2418 /* --------------------------------------------------------------------- */
2421 switch (Cave[y+1][x])
2431 Cave[y][x] = Yspring_sB;
2432 if (Cave[y][x+1] == Xblank)
2433 Cave[y][x+1] = Yacid_splash_eB;
2434 if (Cave[y][x-1] == Xblank)
2435 Cave[y][x-1] = Yacid_splash_wB;
2436 Next[y][x] = Xblank;
2437 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2441 case Yacid_splash_eB:
2442 case Yacid_splash_wB:
2445 Cave[y][x] = Yspring_sB;
2446 Cave[y+1][x] = Yspring_s;
2447 Next[y][x] = Xblank;
2448 Next[y+1][x] = Xspring_fall;
2467 case Xemerald_pause:
2469 case Xdiamond_pause:
2497 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2499 Cave[y][x] = Yspring_eB;
2500 Cave[y][x+1] = Yspring_e;
2501 if (Cave[y+1][x] == Xbumper)
2502 Cave[y+1][x] = XbumperB;
2503 Next[y][x] = Xblank;
2506 Next[y][x+1] = Xspring_e;
2508 Next[y][x+1] = Xspring_pause;
2514 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2516 Cave[y][x] = Yspring_wB;
2517 Cave[y][x-1] = Yspring_w;
2518 if (Cave[y+1][x] == Xbumper)
2519 Cave[y+1][x] = XbumperB;
2520 Next[y][x] = Xblank;
2523 Next[y][x-1] = Xspring_w;
2525 Next[y][x-1] = Xspring_pause;
2533 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2535 Cave[y][x] = Yspring_wB;
2536 Cave[y][x-1] = Yspring_w;
2537 if (Cave[y+1][x] == Xbumper)
2538 Cave[y+1][x] = XbumperB;
2539 Next[y][x] = Xblank;
2542 Next[y][x-1] = Xspring_w;
2544 Next[y][x-1] = Xspring_pause;
2550 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2552 Cave[y][x] = Yspring_eB;
2553 Cave[y][x+1] = Yspring_e;
2554 if (Cave[y+1][x] == Xbumper)
2555 Cave[y+1][x] = XbumperB;
2556 Next[y][x] = Xblank;
2559 Next[y][x+1] = Xspring_e;
2561 Next[y][x+1] = Xspring_pause;
2572 /* --------------------------------------------------------------------- */
2575 switch (Cave[y+1][x])
2585 Cave[y][x] = Yspring_sB;
2586 if (Cave[y][x+1] == Xblank)
2587 Cave[y][x+1] = Yacid_splash_eB;
2588 if (Cave[y][x-1] == Xblank)
2589 Cave[y][x-1] = Yacid_splash_wB;
2590 Next[y][x] = Xblank;
2591 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2595 case Yacid_splash_eB:
2596 case Yacid_splash_wB:
2597 Cave[y][x] = Yspring_sB;
2598 Cave[y+1][x] = Yspring_s;
2599 Next[y][x] = Xblank;
2600 Next[y+1][x] = Xspring_fall;
2604 Cave[y][x] = Xspring;
2605 Next[y][x] = Xspring;
2609 /* --------------------------------------------------------------------- */
2612 switch (Cave[y+1][x])
2622 Cave[y][x] = Yspring_sB;
2623 if (Cave[y][x+1] == Xblank)
2624 Cave[y][x+1] = Yacid_splash_eB;
2625 if (Cave[y][x-1] == Xblank)
2626 Cave[y][x-1] = Yacid_splash_wB;
2627 Next[y][x] = Xblank;
2628 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2632 case Yacid_splash_eB:
2633 case Yacid_splash_wB:
2634 Cave[y][x] = Yspring_sB;
2635 Cave[y+1][x] = Yspring_s;
2636 Next[y][x] = Xblank;
2637 Next[y+1][x] = Xspring_fall;
2641 Cave[y+1][x] = XbumperB;
2644 switch (Cave[y][x+1])
2654 Cave[y][x] = Yspring_eB;
2655 if (Cave[y-1][x+2] == Xblank)
2656 Cave[y-1][x+2] = Yacid_splash_eB;
2657 if (Cave[y-1][x] == Xblank)
2658 Cave[y-1][x] = Yacid_splash_wB;
2659 Next[y][x] = Xblank;
2660 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2664 case Yacid_splash_eB:
2665 case Yacid_splash_wB:
2670 Cave[y][x] = Yspring_eB;
2671 Cave[y][x+1] = Yspring_e;
2672 Next[y][x] = Xblank;
2673 Next[y][x+1] = Xspring_e;
2682 Cave[y][x] = Yspring_kill_eB;
2683 Cave[y][x+1] = Yspring_kill_e;
2684 Next[y][x] = Xblank;
2685 Next[y][x+1] = Xspring_e;
2686 play_element_sound(x, y, SAMPLE_slurp, Xalien);
2687 score += lev.slurp_score;
2692 Cave[y][x+1] = XbumperB;
2693 Next[y][x] = Xspring_w;
2694 play_element_sound(x, y, SAMPLE_spring, Xspring);
2698 Cave[y][x] = Xspring;
2699 Next[y][x] = Xspring;
2700 play_element_sound(x, y, SAMPLE_spring, Xspring);
2704 /* --------------------------------------------------------------------- */
2707 switch (Cave[y+1][x])
2717 Cave[y][x] = Yspring_sB;
2718 if (Cave[y][x+1] == Xblank)
2719 Cave[y][x+1] = Yacid_splash_eB;
2720 if (Cave[y][x-1] == Xblank)
2721 Cave[y][x-1] = Yacid_splash_wB;
2722 Next[y][x] = Xblank;
2723 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2727 case Yacid_splash_eB:
2728 case Yacid_splash_wB:
2729 Cave[y][x] = Yspring_sB;
2730 Cave[y+1][x] = Yspring_s;
2731 Next[y][x] = Xblank;
2732 Next[y+1][x] = Xspring_fall;
2736 Cave[y+1][x] = XbumperB;
2739 switch (Cave[y][x-1])
2749 Cave[y][x] = Yspring_wB;
2750 if (Cave[y-1][x] == Xblank)
2751 Cave[y-1][x] = Yacid_splash_eB;
2752 if (Cave[y-1][x-2] == Xblank)
2753 Cave[y-1][x-2] = Yacid_splash_wB;
2754 Next[y][x] = Xblank;
2755 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2759 case Yacid_splash_eB:
2760 case Yacid_splash_wB:
2765 Cave[y][x] = Yspring_wB;
2766 Cave[y][x-1] = Yspring_w;
2767 Next[y][x] = Xblank;
2768 Next[y][x-1] = Xspring_w;
2777 Cave[y][x] = Yspring_kill_wB;
2778 Cave[y][x-1] = Yspring_kill_w;
2779 Next[y][x] = Xblank;
2780 Next[y][x-1] = Xspring_w;
2781 play_element_sound(x, y, SAMPLE_slurp, Xalien);
2782 score += lev.slurp_score;
2787 Cave[y][x-1] = XbumperB;
2788 Next[y][x] = Xspring_e;
2789 play_element_sound(x, y, SAMPLE_spring, Xspring);
2793 Cave[y][x] = Xspring;
2794 Next[y][x] = Xspring;
2795 play_element_sound(x, y, SAMPLE_spring, Xspring);
2799 /* --------------------------------------------------------------------- */
2802 switch (Cave[y+1][x])
2812 Cave[y][x] = Yspring_sB;
2813 if (Cave[y][x+1] == Xblank)
2814 Cave[y][x+1] = Yacid_splash_eB;
2815 if (Cave[y][x-1] == Xblank)
2816 Cave[y][x-1] = Yacid_splash_wB;
2817 Next[y][x] = Xblank;
2818 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2822 case Yacid_splash_eB:
2823 case Yacid_splash_wB:
2825 Cave[y][x] = Yspring_sB;
2826 Cave[y+1][x] = Yspring_s;
2827 Next[y][x] = Xblank;
2828 Next[y+1][x] = Xspring_fall;
2833 Cave[y+1][x] = Ybomb_eat;
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;
2845 play_element_sound(x, y, SAMPLE_boom, element);
2857 Cave[y][x] = Yspring_sB;
2858 Cave[y+1][x] = Ybug_spring;
2859 Next[y+1][x] = Znormal;
2860 Boom[y][x-1] = Xemerald;
2861 Boom[y][x] = Xemerald;
2862 Boom[y][x+1] = Xemerald;
2863 Boom[y+1][x-1] = Xemerald;
2864 Boom[y+1][x] = Xdiamond;
2865 Boom[y+1][x+1] = Xemerald;
2866 Boom[y+2][x-1] = Xemerald;
2867 Boom[y+2][x] = Xemerald;
2868 Boom[y+2][x+1] = Xemerald;
2870 play_element_sound(x, y, SAMPLE_boom, element);
2872 score += lev.bug_score;
2883 Cave[y][x] = Yspring_sB;
2884 Cave[y+1][x] = Ytank_spring;
2885 Next[y+1][x] = Znormal;
2886 Boom[y][x-1] = Xblank;
2887 Boom[y][x] = Xblank;
2888 Boom[y][x+1] = Xblank;
2889 Boom[y+1][x-1] = Xblank;
2890 Boom[y+1][x] = Xblank;
2891 Boom[y+1][x+1] = Xblank;
2892 Boom[y+2][x-1] = Xblank;
2893 Boom[y+2][x] = Xblank;
2894 Boom[y+2][x+1] = Xblank;
2896 play_element_sound(x, y, SAMPLE_boom, element);
2898 score += lev.tank_score;
2905 Cave[y][x] = Yspring_sB;
2906 Cave[y+1][x] = Yeater_spring;
2907 Next[y+1][x] = Znormal;
2908 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
2909 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
2910 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
2911 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
2912 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
2913 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
2914 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
2915 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
2916 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
2918 play_element_sound(x, y, SAMPLE_boom, element);
2920 lev.eater_pos = (lev.eater_pos + 1) & 7;
2921 score += lev.eater_score;
2926 Cave[y][x] = Yspring_sB;
2927 Cave[y+1][x] = Yalien_spring;
2928 Next[y+1][x] = Znormal;
2929 Boom[y][x-1] = Xblank;
2930 Boom[y][x] = Xblank;
2931 Boom[y][x+1] = Xblank;
2932 Boom[y+1][x-1] = Xblank;
2933 Boom[y+1][x] = Xblank;
2934 Boom[y+1][x+1] = Xblank;
2935 Boom[y+2][x-1] = Xblank;
2936 Boom[y+2][x] = Xblank;
2937 Boom[y+2][x+1] = Xblank;
2939 play_element_sound(x, y, SAMPLE_boom, element);
2941 score += lev.alien_score;
2945 Cave[y][x] = Xspring;
2946 Next[y][x] = Xspring;
2947 play_element_sound(x, y, SAMPLE_spring, Xspring);
2951 /* --------------------------------------------------------------------- */
2954 if (Cave[y][x+1] == Xdiamond)
2956 Cave[y][x+1] = Ydiamond_eat;
2957 Next[y][x+1] = Xblank;
2958 play_element_sound(x, y, SAMPLE_eater_eat, element);
2962 if (Cave[y+1][x] == Xdiamond)
2964 Cave[y+1][x] = Ydiamond_eat;
2965 Next[y+1][x] = Xblank;
2966 play_element_sound(x, y, SAMPLE_eater_eat, element);
2970 if (Cave[y][x-1] == Xdiamond)
2972 Cave[y][x-1] = Ydiamond_eat;
2973 Next[y][x-1] = Xblank;
2974 play_element_sound(x, y, SAMPLE_eater_eat, element);
2978 if (Cave[y-1][x] == Xdiamond)
2980 Cave[y-1][x] = Ydiamond_eat;
2981 Next[y-1][x] = Xblank;
2982 play_element_sound(x, y, SAMPLE_eater_eat, element);
2986 switch (Cave[y-1][x])
2996 Cave[y][x] = Yeater_nB;
2997 if (Cave[y-2][x+1] == Xblank)
2998 Cave[y-2][x+1] = Yacid_splash_eB;
2999 if (Cave[y-2][x-1] == Xblank)
3000 Cave[y-2][x-1] = Yacid_splash_wB;
3001 Next[y][x] = Xblank;
3002 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3006 case Yacid_splash_eB:
3007 case Yacid_splash_wB:
3011 Cave[y][x] = Yeater_nB;
3012 Cave[y-1][x] = Yeater_n;
3013 Next[y][x] = Xblank;
3014 Next[y-1][x] = Xeater_n;
3018 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
3019 play_element_sound(x, y, SAMPLE_eater, element);
3023 /* --------------------------------------------------------------------- */
3026 if (Cave[y+1][x] == Xdiamond)
3028 Cave[y+1][x] = Ydiamond_eat;
3029 Next[y+1][x] = Xblank;
3030 play_element_sound(x, y, SAMPLE_eater_eat, element);
3034 if (Cave[y][x-1] == Xdiamond)
3036 Cave[y][x-1] = Ydiamond_eat;
3037 Next[y][x-1] = Xblank;
3038 play_element_sound(x, y, SAMPLE_eater_eat, element);
3042 if (Cave[y-1][x] == Xdiamond)
3044 Cave[y-1][x] = Ydiamond_eat;
3045 Next[y-1][x] = Xblank;
3046 play_element_sound(x, y, SAMPLE_eater_eat, element);
3050 if (Cave[y][x+1] == Xdiamond)
3052 Cave[y][x+1] = Ydiamond_eat;
3053 Next[y][x+1] = Xblank;
3054 play_element_sound(x, y, SAMPLE_eater_eat, element);
3058 switch (Cave[y][x+1])
3068 Cave[y][x] = Yeater_eB;
3069 if (Cave[y-1][x+2] == Xblank)
3070 Cave[y-1][x+2] = Yacid_splash_eB;
3071 if (Cave[y-1][x] == Xblank)
3072 Cave[y-1][x] = Yacid_splash_wB;
3073 Next[y][x] = Xblank;
3074 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3078 case Yacid_splash_eB:
3079 case Yacid_splash_wB:
3083 Cave[y][x] = Yeater_eB;
3084 Cave[y][x+1] = Yeater_e;
3085 Next[y][x] = Xblank;
3086 Next[y][x+1] = Xeater_e;
3090 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3091 play_element_sound(x, y, SAMPLE_eater, element);
3095 /* --------------------------------------------------------------------- */
3098 if (Cave[y][x-1] == Xdiamond)
3100 Cave[y][x-1] = Ydiamond_eat;
3101 Next[y][x-1] = Xblank;
3102 play_element_sound(x, y, SAMPLE_eater_eat, element);
3106 if (Cave[y-1][x] == Xdiamond)
3108 Cave[y-1][x] = Ydiamond_eat;
3109 Next[y-1][x] = Xblank;
3110 play_element_sound(x, y, SAMPLE_eater_eat, element);
3114 if (Cave[y][x+1] == Xdiamond)
3116 Cave[y][x+1] = Ydiamond_eat;
3117 Next[y][x+1] = Xblank;
3118 play_element_sound(x, y, SAMPLE_eater_eat, element);
3122 if (Cave[y+1][x] == Xdiamond)
3124 Cave[y+1][x] = Ydiamond_eat;
3125 Next[y+1][x] = Xblank;
3126 play_element_sound(x, y, SAMPLE_eater_eat, element);
3130 switch (Cave[y+1][x])
3140 Cave[y][x] = Yeater_sB;
3141 if (Cave[y][x+1] == Xblank)
3142 Cave[y][x+1] = Yacid_splash_eB;
3143 if (Cave[y][x-1] == Xblank)
3144 Cave[y][x-1] = Yacid_splash_wB;
3145 Next[y][x] = Xblank;
3146 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3150 case Yacid_splash_eB:
3151 case Yacid_splash_wB:
3155 Cave[y][x] = Yeater_sB;
3156 Cave[y+1][x] = Yeater_s;
3157 Next[y][x] = Xblank;
3158 Next[y+1][x] = Xeater_s;
3162 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
3163 play_element_sound(x, y, SAMPLE_eater, element);
3167 /* --------------------------------------------------------------------- */
3170 if (Cave[y-1][x] == Xdiamond)
3172 Cave[y-1][x] = Ydiamond_eat;
3173 Next[y-1][x] = Xblank;
3174 play_element_sound(x, y, SAMPLE_eater_eat, element);
3178 if (Cave[y][x+1] == Xdiamond)
3180 Cave[y][x+1] = Ydiamond_eat;
3181 Next[y][x+1] = Xblank;
3182 play_element_sound(x, y, SAMPLE_eater_eat, element);
3186 if (Cave[y+1][x] == Xdiamond)
3188 Cave[y+1][x] = Ydiamond_eat;
3189 Next[y+1][x] = Xblank;
3190 play_element_sound(x, y, SAMPLE_eater_eat, element);
3194 if (Cave[y][x-1] == Xdiamond)
3196 Cave[y][x-1] = Ydiamond_eat;
3197 Next[y][x-1] = Xblank;
3198 play_element_sound(x, y, SAMPLE_eater_eat, element);
3202 switch (Cave[y][x-1])
3212 Cave[y][x] = Yeater_wB;
3213 if (Cave[y-1][x] == Xblank)
3214 Cave[y-1][x] = Yacid_splash_eB;
3215 if (Cave[y-1][x-2] == Xblank)
3216 Cave[y-1][x-2] = Yacid_splash_wB;
3217 Next[y][x] = Xblank;
3218 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3222 case Yacid_splash_eB:
3223 case Yacid_splash_wB:
3227 Cave[y][x] = Yeater_wB;
3228 Cave[y][x-1] = Yeater_w;
3229 Next[y][x] = Xblank;
3230 Next[y][x-1] = Xeater_w;
3234 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3235 play_element_sound(x, y, SAMPLE_eater, element);
3239 /* --------------------------------------------------------------------- */
3252 set_nearest_player_xy(x, y, &dx, &dy);
3262 else if (ply1.alive && ply2.alive)
3264 if ((ply1.x > x ? ply1.x - x : x - ply1.x) +
3265 (ply1.y > y ? ply1.y - y : y - ply1.y) <
3266 (ply2.x > x ? ply2.x - x : x - ply2.x) +
3267 (ply2.y > y ? ply2.y - y : y - ply2.y))
3278 else if (ply1.alive)
3283 else if (ply2.alive)
3300 switch (Cave[y-1][x])
3310 Cave[y][x] = Yalien_nB;
3311 if (Cave[y-2][x+1] == Xblank)
3312 Cave[y-2][x+1] = Yacid_splash_eB;
3313 if (Cave[y-2][x-1] == Xblank)
3314 Cave[y-2][x-1] = Yacid_splash_wB;
3315 Next[y][x] = Xblank;
3316 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3320 case Yacid_splash_eB:
3321 case Yacid_splash_wB:
3325 Cave[y][x] = Yalien_nB;
3326 Cave[y-1][x] = Yalien_n;
3327 Next[y][x] = Xblank;
3328 Next[y-1][x] = Xalien_pause;
3329 play_element_sound(x, y, SAMPLE_alien, Xalien);
3335 switch (Cave[y+1][x])
3345 Cave[y][x] = Yalien_sB;
3346 Next[y][x] = Xblank;
3347 if (Cave[y][x+1] == Xblank)
3348 Cave[y][x+1] = Yacid_splash_eB;
3349 if (Cave[y][x-1] == Xblank)
3350 Cave[y][x-1] = Yacid_splash_wB;
3351 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3355 case Yacid_splash_eB:
3356 case Yacid_splash_wB:
3360 Cave[y][x] = Yalien_sB;
3361 Cave[y+1][x] = Yalien_s;
3362 Next[y][x] = Xblank;
3363 Next[y+1][x] = Xalien_pause;
3364 play_element_sound(x, y, SAMPLE_alien, Xalien);
3373 switch (Cave[y][x+1])
3383 Cave[y][x] = Yalien_eB;
3384 if (Cave[y-1][x+2] == Xblank)
3385 Cave[y-1][x+2] = Yacid_splash_eB;
3386 if (Cave[y-1][x] == Xblank)
3387 Cave[y-1][x] = Yacid_splash_wB;
3388 Next[y][x] = Xblank;
3389 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3393 case Yacid_splash_eB:
3394 case Yacid_splash_wB:
3398 Cave[y][x] = Yalien_eB;
3399 Cave[y][x+1] = Yalien_e;
3400 Next[y][x] = Xblank;
3401 Next[y][x+1] = Xalien_pause;
3402 play_element_sound(x, y, SAMPLE_alien, Xalien);
3408 switch (Cave[y][x-1])
3418 Cave[y][x] = Yalien_wB;
3419 if (Cave[y-1][x] == Xblank)
3420 Cave[y-1][x] = Yacid_splash_eB;
3421 if (Cave[y-1][x-2] == Xblank)
3422 Cave[y-1][x-2] = Yacid_splash_wB;
3423 Next[y][x] = Xblank;
3424 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3428 case Yacid_splash_eB:
3429 case Yacid_splash_wB:
3433 Cave[y][x] = Yalien_wB;
3434 Cave[y][x-1] = Yalien_w;
3435 Next[y][x] = Xblank;
3436 Next[y][x-1] = Xalien_pause;
3437 play_element_sound(x, y, SAMPLE_alien, Xalien);
3446 Next[y][x] = Xalien;
3449 /* --------------------------------------------------------------------- */
3452 switch (Cave[y+1][x])
3462 Cave[y][x] = Yemerald_sB;
3463 if (Cave[y][x+1] == Xblank)
3464 Cave[y][x+1] = Yacid_splash_eB;
3465 if (Cave[y][x-1] == Xblank)
3466 Cave[y][x-1] = Yacid_splash_wB;
3467 Next[y][x] = Xblank;
3468 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3472 case Yacid_splash_eB:
3473 case Yacid_splash_wB:
3474 Cave[y][x] = Yemerald_sB;
3475 Cave[y+1][x] = Yemerald_s;
3476 Next[y][x] = Xblank;
3477 Next[y+1][x] = Xemerald_fall;
3496 case Xemerald_pause:
3498 case Xdiamond_pause:
3535 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3537 Cave[y][x] = Yemerald_eB;
3538 Cave[y][x+1] = Yemerald_e;
3539 Next[y][x] = Xblank;
3540 Next[y][x+1] = Xemerald_pause;
3544 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3546 Cave[y][x] = Yemerald_wB;
3547 Cave[y][x-1] = Yemerald_w;
3548 Next[y][x] = Xblank;
3549 Next[y][x-1] = Xemerald_pause;
3555 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3557 Cave[y][x] = Yemerald_wB;
3558 Cave[y][x-1] = Yemerald_w;
3559 Next[y][x] = Xblank;
3560 Next[y][x-1] = Xemerald_pause;
3564 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3566 Cave[y][x] = Yemerald_eB;
3567 Cave[y][x+1] = Yemerald_e;
3568 Next[y][x] = Xblank;
3569 Next[y][x+1] = Xemerald_pause;
3575 if (++lev.shine_cnt > 50)
3577 lev.shine_cnt = RANDOM & 7;
3578 Cave[y][x] = Xemerald_shine;
3584 /* --------------------------------------------------------------------- */
3586 case Xemerald_pause:
3587 switch (Cave[y+1][x])
3597 Cave[y][x] = Yemerald_sB;
3598 if (Cave[y][x+1] == Xblank)
3599 Cave[y][x+1] = Yacid_splash_eB;
3600 if (Cave[y][x-1] == Xblank)
3601 Cave[y][x-1] = Yacid_splash_wB;
3602 Next[y][x] = Xblank;
3603 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3607 case Yacid_splash_eB:
3608 case Yacid_splash_wB:
3609 Cave[y][x] = Yemerald_sB;
3610 Cave[y+1][x] = Yemerald_s;
3611 Next[y][x] = Xblank;
3612 Next[y+1][x] = Xemerald_fall;
3616 Cave[y][x] = Xemerald;
3617 Next[y][x] = Xemerald;
3621 /* --------------------------------------------------------------------- */
3624 switch (Cave[y+1][x])
3634 Cave[y][x] = Yemerald_sB;
3635 if (Cave[y][x+1] == Xblank)
3636 Cave[y][x+1] = Yacid_splash_eB;
3637 if (Cave[y][x-1] == Xblank)
3638 Cave[y][x-1] = Yacid_splash_wB;
3639 Next[y][x] = Xblank;
3640 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3644 case Yacid_splash_eB:
3645 case Yacid_splash_wB:
3647 Cave[y][x] = Yemerald_sB;
3648 Cave[y+1][x] = Yemerald_s;
3649 Next[y][x] = Xblank;
3650 Next[y+1][x] = Xemerald_fall;
3654 if (lev.wonderwall_time)
3656 lev.wonderwall_state = 1;
3657 Cave[y][x] = Yemerald_sB;
3658 if (tab_blank[Cave[y+2][x]])
3660 Cave[y+2][x] = Ydiamond_s;
3661 Next[y+2][x] = Xdiamond_fall;
3664 Next[y][x] = Xblank;
3665 play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
3670 Cave[y][x] = Xemerald;
3671 Next[y][x] = Xemerald;
3672 play_element_sound(x, y, SAMPLE_diamond, Xemerald);
3676 /* --------------------------------------------------------------------- */
3679 switch (Cave[y+1][x])
3689 Cave[y][x] = Ydiamond_sB;
3690 if (Cave[y][x+1] == Xblank)
3691 Cave[y][x+1] = Yacid_splash_eB;
3692 if (Cave[y][x-1] == Xblank)
3693 Cave[y][x-1] = Yacid_splash_wB;
3694 Next[y][x] = Xblank;
3695 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3699 case Yacid_splash_eB:
3700 case Yacid_splash_wB:
3701 Cave[y][x] = Ydiamond_sB;
3702 Cave[y+1][x] = Ydiamond_s;
3703 Next[y][x] = Xblank;
3704 Next[y+1][x] = Xdiamond_fall;
3723 case Xemerald_pause:
3725 case Xdiamond_pause:
3762 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3764 Cave[y][x] = Ydiamond_eB;
3765 Cave[y][x+1] = Ydiamond_e;
3766 Next[y][x] = Xblank;
3767 Next[y][x+1] = Xdiamond_pause;
3771 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3773 Cave[y][x] = Ydiamond_wB;
3774 Cave[y][x-1] = Ydiamond_w;
3775 Next[y][x] = Xblank;
3776 Next[y][x-1] = Xdiamond_pause;
3782 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3784 Cave[y][x] = Ydiamond_wB;
3785 Cave[y][x-1] = Ydiamond_w;
3786 Next[y][x] = Xblank;
3787 Next[y][x-1] = Xdiamond_pause;
3791 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3793 Cave[y][x] = Ydiamond_eB;
3794 Cave[y][x+1] = Ydiamond_e;
3795 Next[y][x] = Xblank;
3796 Next[y][x+1] = Xdiamond_pause;
3802 if (++lev.shine_cnt > 50)
3804 lev.shine_cnt = RANDOM & 7;
3805 Cave[y][x] = Xdiamond_shine;
3811 /* --------------------------------------------------------------------- */
3813 case Xdiamond_pause:
3814 switch (Cave[y+1][x])
3824 Cave[y][x] = Ydiamond_sB;
3825 if (Cave[y][x+1] == Xblank)
3826 Cave[y][x+1] = Yacid_splash_eB;
3827 if (Cave[y][x-1] == Xblank)
3828 Cave[y][x-1] = Yacid_splash_wB;
3829 Next[y][x] = Xblank;
3830 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3834 case Yacid_splash_eB:
3835 case Yacid_splash_wB:
3836 Cave[y][x] = Ydiamond_sB;
3837 Cave[y+1][x] = Ydiamond_s;
3838 Next[y][x] = Xblank;
3839 Next[y+1][x] = Xdiamond_fall;
3843 Cave[y][x] = Xdiamond;
3844 Next[y][x] = Xdiamond;
3848 /* --------------------------------------------------------------------- */
3851 switch (Cave[y+1][x])
3861 Cave[y][x] = Ydiamond_sB;
3862 if (Cave[y][x+1] == Xblank)
3863 Cave[y][x+1] = Yacid_splash_eB;
3864 if (Cave[y][x-1] == Xblank)
3865 Cave[y][x-1] = Yacid_splash_wB;
3866 Next[y][x] = Xblank;
3867 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3871 case Yacid_splash_eB:
3872 case Yacid_splash_wB:
3874 Cave[y][x] = Ydiamond_sB;
3875 Cave[y+1][x] = Ydiamond_s;
3876 Next[y][x] = Xblank;
3877 Next[y+1][x] = Xdiamond_fall;
3881 if (lev.wonderwall_time)
3883 lev.wonderwall_state = 1;
3884 Cave[y][x] = Ydiamond_sB;
3885 if (tab_blank[Cave[y+2][x]])
3887 Cave[y+2][x] = Ystone_s;
3888 Next[y+2][x] = Xstone_fall;
3891 Next[y][x] = Xblank;
3892 play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
3897 Cave[y][x] = Xdiamond;
3898 Next[y][x] = Xdiamond;
3899 play_element_sound(x, y, SAMPLE_diamond, Xdiamond);
3903 /* --------------------------------------------------------------------- */
3906 switch (Cave[y+1][x])
3916 Cave[y][x] = Ydrip_s1B;
3917 if (Cave[y][x+1] == Xblank)
3918 Cave[y][x+1] = Yacid_splash_eB;
3919 if (Cave[y][x-1] == Xblank)
3920 Cave[y][x-1] = Yacid_splash_wB;
3921 Next[y][x] = Xdrip_stretchB;
3922 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3926 case Yacid_splash_eB:
3927 case Yacid_splash_wB:
3931 Cave[y][x] = Ydrip_s1B;
3932 Cave[y+1][x] = Ydrip_s1;
3933 Next[y][x] = Xdrip_stretchB;
3934 Next[y+1][x] = Xdrip_stretch;
3975 play_element_sound(x, y, SAMPLE_drip, Xdrip_fall);
3979 /* --------------------------------------------------------------------- */
3982 Cave[y][x] = Ydrip_s2;
3983 Next[y][x] = Xdrip_fall;
3986 case Xdrip_stretchB:
3987 Cave[y][x] = Ydrip_s2B;
3988 Next[y][x] = Xblank;
3992 Next[y][x] = Xdrip_fall;
3995 /* --------------------------------------------------------------------- */
3998 switch (Cave[y+1][x])
4008 Cave[y][x] = Ybomb_sB;
4009 if (Cave[y][x+1] == Xblank)
4010 Cave[y][x+1] = Yacid_splash_eB;
4011 if (Cave[y][x-1] == Xblank)
4012 Cave[y][x-1] = Yacid_splash_wB;
4013 Next[y][x] = Xblank;
4014 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4018 case Yacid_splash_eB:
4019 case Yacid_splash_wB:
4020 Cave[y][x] = Ybomb_sB;
4021 Cave[y+1][x] = Ybomb_s;
4022 Next[y][x] = Xblank;
4023 Next[y+1][x] = Xbomb_fall;
4042 case Xemerald_pause:
4044 case Xdiamond_pause:
4072 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
4074 Cave[y][x] = Ybomb_eB;
4075 Cave[y][x+1] = Ybomb_e;
4076 Next[y][x] = Xblank;
4077 Next[y][x+1] = Xbomb_pause;
4081 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
4083 Cave[y][x] = Ybomb_wB;
4084 Cave[y][x-1] = Ybomb_w;
4085 Next[y][x] = Xblank;
4086 Next[y][x-1] = Xbomb_pause;
4092 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
4094 Cave[y][x] = Ybomb_wB;
4095 Cave[y][x-1] = Ybomb_w;
4096 Next[y][x] = Xblank;
4097 Next[y][x-1] = Xbomb_pause;
4101 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
4103 Cave[y][x] = Ybomb_eB;
4104 Cave[y][x+1] = Ybomb_e;
4105 Next[y][x] = Xblank;
4106 Next[y][x+1] = Xbomb_pause;
4115 /* --------------------------------------------------------------------- */
4118 switch (Cave[y+1][x])
4128 Cave[y][x] = Ybomb_sB;
4129 if (Cave[y][x+1] == Xblank)
4130 Cave[y][x+1] = Yacid_splash_eB;
4131 if (Cave[y][x-1] == Xblank)
4132 Cave[y][x-1] = Yacid_splash_wB;
4133 Next[y][x] = Xblank;
4134 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4138 case Yacid_splash_eB:
4139 case Yacid_splash_wB:
4140 Cave[y][x] = Ybomb_sB;
4141 Cave[y+1][x] = Ybomb_s;
4142 Next[y][x] = Xblank;
4143 Next[y+1][x] = Xbomb_fall;
4152 /* --------------------------------------------------------------------- */
4155 switch (Cave[y+1][x])
4165 Cave[y][x] = Ybomb_sB;
4166 if (Cave[y][x+1] == Xblank)
4167 Cave[y][x+1] = Yacid_splash_eB;
4168 if (Cave[y][x-1] == Xblank)
4169 Cave[y][x-1] = Yacid_splash_wB;
4170 Next[y][x] = Xblank;
4171 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4175 case Yacid_splash_eB:
4176 case Yacid_splash_wB:
4177 Cave[y][x] = Ybomb_sB;
4178 Cave[y+1][x] = Ybomb_s;
4179 Next[y][x] = Xblank;
4180 Next[y+1][x] = Xbomb_fall;
4184 Cave[y][x] = Ybomb_eat;
4185 Next[y][x] = Znormal;
4186 Boom[y-1][x-1] = Xblank;
4187 Boom[y-1][x] = Xblank;
4188 Boom[y-1][x+1] = Xblank;
4189 Boom[y][x-1] = Xblank;
4190 Boom[y][x] = Xblank;
4191 Boom[y][x+1] = Xblank;
4192 Boom[y+1][x-1] = Xblank;
4193 Boom[y+1][x] = Xblank;
4194 Boom[y+1][x+1] = Xblank;
4196 play_element_sound(x, y, SAMPLE_boom, element);
4201 /* --------------------------------------------------------------------- */
4204 if (lev.wind_cnt == 0)
4207 switch (lev.wind_direction)
4210 switch (Cave[y-1][x])
4220 Cave[y][x] = Yballoon_nB;
4221 if (Cave[y-2][x+1] == Xblank)
4222 Cave[y-2][x+1] = Yacid_splash_eB;
4223 if (Cave[y-2][x-1] == Xblank)
4224 Cave[y-2][x-1] = Yacid_splash_wB;
4225 Next[y][x] = Xblank;
4226 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4230 case Yacid_splash_eB:
4231 case Yacid_splash_wB:
4232 Cave[y][x] = Yballoon_nB;
4233 Cave[y-1][x] = Yballoon_n;
4234 Next[y][x] = Xblank;
4235 Next[y-1][x] = Xballoon;
4243 switch (Cave[y][x+1])
4253 Cave[y][x] = Yballoon_eB;
4254 if (Cave[y-1][x+2] == Xblank)
4255 Cave[y-1][x+2] = Yacid_splash_eB;
4256 if (Cave[y-1][x] == Xblank)
4257 Cave[y-1][x] = Yacid_splash_wB;
4258 Next[y][x] = Xblank;
4259 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4263 case Yacid_splash_eB:
4264 case Yacid_splash_wB:
4265 Cave[y][x] = Yballoon_eB;
4266 Cave[y][x+1] = Yballoon_e;
4267 Next[y][x] = Xblank;
4268 Next[y][x+1] = Xballoon;
4276 switch (Cave[y+1][x])
4286 Cave[y][x] = Yballoon_sB;
4287 if (Cave[y][x+1] == Xblank)
4288 Cave[y][x+1] = Yacid_splash_eB;
4289 if (Cave[y][x-1] == Xblank)
4290 Cave[y][x-1] = Yacid_splash_wB;
4291 Next[y][x] = Xblank;
4292 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4296 case Yacid_splash_eB:
4297 case Yacid_splash_wB:
4298 Cave[y][x] = Yballoon_sB;
4299 Cave[y+1][x] = Yballoon_s;
4300 Next[y][x] = Xblank;
4301 Next[y+1][x] = Xballoon;
4309 switch (Cave[y][x-1])
4319 Cave[y][x] = Yballoon_wB;
4320 if (Cave[y-1][x] == Xblank)
4321 Cave[y-1][x] = Yacid_splash_eB;
4322 if (Cave[y-1][x-2] == Xblank)
4323 Cave[y-1][x-2] = Yacid_splash_wB;
4324 Next[y][x] = Xblank;
4325 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4329 case Yacid_splash_eB:
4330 case Yacid_splash_wB:
4331 Cave[y][x] = Yballoon_wB;
4332 Cave[y][x-1] = Yballoon_w;
4333 Next[y][x] = Xblank;
4334 Next[y][x-1] = Xballoon;
4342 /* --------------------------------------------------------------------- */
4345 Next[y][x] = Xacid_2;
4349 Next[y][x] = Xacid_3;
4353 Next[y][x] = Xacid_4;
4357 Next[y][x] = Xacid_5;
4361 Next[y][x] = Xacid_6;
4365 Next[y][x] = Xacid_7;
4369 Next[y][x] = Xacid_8;
4373 Next[y][x] = Xacid_1;
4377 Next[y][x] = Xfake_acid_2;
4381 Next[y][x] = Xfake_acid_3;
4385 Next[y][x] = Xfake_acid_4;
4389 Next[y][x] = Xfake_acid_5;
4393 Next[y][x] = Xfake_acid_6;
4397 Next[y][x] = Xfake_acid_7;
4401 Next[y][x] = Xfake_acid_8;
4405 Next[y][x] = Xfake_acid_1;
4408 /* --------------------------------------------------------------------- */
4411 if (lev.ball_state == 0)
4414 Cave[y][x] = Xball_1B;
4415 Next[y][x] = Xball_2;
4422 if (lev.ball_state == 0)
4425 Cave[y][x] = Xball_2B;
4426 Next[y][x] = Xball_1;
4434 play_element_sound(x, y, SAMPLE_ball, element);
4435 if (lev.ball_random)
4440 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4441 tab_blank[Cave[y-1][x-1]])
4443 Cave[y-1][x-1] = Yball_eat;
4444 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4449 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4450 tab_blank[Cave[y-1][x]])
4452 Cave[y-1][x] = Yball_eat;
4453 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4458 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4459 tab_blank[Cave[y-1][x+1]])
4461 Cave[y-1][x+1] = Yball_eat;
4462 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4467 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4468 tab_blank[Cave[y][x-1]])
4470 Cave[y][x-1] = Yball_eat;
4471 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4476 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4477 tab_blank[Cave[y][x+1]])
4479 Cave[y][x+1] = Yball_eat;
4480 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4485 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4486 tab_blank[Cave[y+1][x-1]])
4488 Cave[y+1][x-1] = Yball_eat;
4489 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4494 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4495 tab_blank[Cave[y+1][x]])
4497 Cave[y+1][x] = Yball_eat;
4498 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4503 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4504 tab_blank[Cave[y+1][x+1]])
4506 Cave[y+1][x+1] = Yball_eat;
4507 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4514 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4515 tab_blank[Cave[y-1][x-1]])
4517 Cave[y-1][x-1] = Yball_eat;
4518 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4521 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4522 tab_blank[Cave[y-1][x]])
4524 Cave[y-1][x] = Yball_eat;
4525 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4528 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4529 tab_blank[Cave[y-1][x+1]])
4531 Cave[y-1][x+1] = Yball_eat;
4532 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4535 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4536 tab_blank[Cave[y][x-1]])
4538 Cave[y][x-1] = Yball_eat;
4539 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4542 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4543 tab_blank[Cave[y][x+1]])
4545 Cave[y][x+1] = Yball_eat;
4546 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4549 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4550 tab_blank[Cave[y+1][x-1]])
4552 Cave[y+1][x-1] = Yball_eat;
4553 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4556 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4557 tab_blank[Cave[y+1][x]])
4559 Cave[y+1][x] = Yball_eat;
4560 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4563 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4564 tab_blank[Cave[y+1][x+1]])
4566 Cave[y+1][x+1] = Yball_eat;
4567 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4572 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
4574 lev.ball_pos = (lev.ball_pos + 1) & 7;
4578 /* --------------------------------------------------------------------- */
4581 if (tab_blank[Cave[y-1][x]])
4583 Cave[y-1][x] = Ygrow_ns_eat;
4584 Next[y-1][x] = Xgrow_ns;
4585 play_element_sound(x, y, SAMPLE_grow, Xgrow_ns);
4588 if (tab_blank[Cave[y+1][x]])
4590 Cave[y+1][x] = Ygrow_ns_eat;
4591 Next[y+1][x] = Xgrow_ns;
4592 play_element_sound(x, y, SAMPLE_grow, Xgrow_ns);
4598 if (tab_blank[Cave[y][x+1]])
4600 Cave[y][x+1] = Ygrow_ew_eat;
4601 Next[y][x+1] = Xgrow_ew;
4602 play_element_sound(x, y, SAMPLE_grow, Xgrow_ew);
4605 if (tab_blank[Cave[y][x-1]])
4607 Cave[y][x-1] = Ygrow_ew_eat;
4608 Next[y][x-1] = Xgrow_ew;
4609 play_element_sound(x, y, SAMPLE_grow, Xgrow_ew);
4614 /* --------------------------------------------------------------------- */
4617 if (lev.wonderwall_time && lev.wonderwall_state)
4619 Cave[y][x] = XwonderwallB;
4620 play_element_sound(x, y, SAMPLE_wonder, Xwonderwall);
4625 /* --------------------------------------------------------------------- */
4628 if (lev.required > 0)
4634 Cave[y][x] = Xexit_1;
4635 Next[y][x] = Xexit_2;
4639 Cave[y][x] = Xexit_2;
4640 Next[y][x] = Xexit_3;
4644 Cave[y][x] = Xexit_3;
4645 Next[y][x] = Xexit_1;
4648 play_element_sound(x, y, SAMPLE_exit_open, Xexit);
4653 Next[y][x] = Xexit_2;
4657 Next[y][x] = Xexit_3;
4661 Next[y][x] = Xexit_1;
4664 /* --------------------------------------------------------------------- */
4667 play_element_sound(x, y, SAMPLE_tick, Xdynamite_1);
4668 Next[y][x] = Xdynamite_2;
4672 play_element_sound(x, y, SAMPLE_tick, Xdynamite_2);
4673 Next[y][x] = Xdynamite_3;
4677 play_element_sound(x, y, SAMPLE_tick, Xdynamite_3);
4678 Next[y][x] = Xdynamite_4;
4682 play_element_sound(x, y, SAMPLE_tick, Xdynamite_4);
4683 Next[y][x] = Zdynamite;
4684 Boom[y-1][x-1] = Xblank;
4685 Boom[y-1][x] = Xblank;
4686 Boom[y-1][x+1] = Xblank;
4687 Boom[y][x-1] = Xblank;
4688 Boom[y][x] = Xblank;
4689 Boom[y][x+1] = Xblank;
4690 Boom[y+1][x-1] = Xblank;
4691 Boom[y+1][x] = Xblank;
4692 Boom[y+1][x+1] = Xblank;
4695 /* --------------------------------------------------------------------- */
4698 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
4699 Cave[y][x] = XwheelB;
4702 /* --------------------------------------------------------------------- */
4706 Cave[y][x] = XswitchB;
4709 /* --------------------------------------------------------------------- */
4712 switch (Cave[y+1][x])
4722 Cave[y][x] = Xsand_stonesand_3;
4723 if (Cave[y][x+1] == Xblank)
4724 Cave[y][x+1] = Yacid_splash_eB;
4725 if (Cave[y][x-1] == Xblank)
4726 Cave[y][x-1] = Yacid_splash_wB;
4727 Next[y][x] = Xsand_stonesand_4;
4728 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4732 case Yacid_splash_eB:
4733 case Yacid_splash_wB:
4734 Cave[y][x] = Xsand_stonesand_3;
4735 Cave[y+1][x] = Xsand_stoneout_1;
4736 Next[y][x] = Xsand_stonesand_4;
4737 Next[y+1][x] = Xsand_stoneout_2;
4741 Cave[y][x] = Xsand_stonesand_1;
4742 Cave[y+1][x] = Xsand_sandstone_1;
4743 Next[y][x] = Xsand_stonesand_2;
4744 Next[y+1][x] = Xsand_sandstone_2;
4751 case Xsand_stonein_1:
4752 Next[y][x] = Xsand_stonein_2;
4755 case Xsand_stonein_2:
4756 Next[y][x] = Xsand_stonein_3;
4759 case Xsand_stonein_3:
4760 Next[y][x] = Xsand_stonein_4;
4763 case Xsand_stonein_4:
4764 Next[y][x] = Xblank;
4767 case Xsand_stonesand_1:
4768 Next[y][x] = Xsand_stonesand_2;
4771 case Xsand_stonesand_2:
4772 Next[y][x] = Xsand_stonesand_3;
4775 case Xsand_stonesand_3:
4776 Next[y][x] = Xsand_stonesand_4;
4779 case Xsand_stonesand_4:
4783 case Xsand_stoneout_1:
4784 Next[y][x] = Xsand_stoneout_2;
4787 case Xsand_stoneout_2:
4788 Next[y][x] = Xstone_fall;
4791 case Xsand_sandstone_1:
4792 Next[y][x] = Xsand_sandstone_2;
4795 case Xsand_sandstone_2:
4796 Next[y][x] = Xsand_sandstone_3;
4799 case Xsand_sandstone_3:
4800 Next[y][x] = Xsand_sandstone_4;
4803 case Xsand_sandstone_4:
4804 Next[y][x] = Xsand_stone;
4807 /* --------------------------------------------------------------------- */
4811 Cave[y][x] = XdripperB;
4814 /* --------------------------------------------------------------------- */
4818 Cave[y][x] = Xfake_blankB;
4821 /* --------------------------------------------------------------------- */
4824 if (lev.magnify_cnt)
4825 Cave[y][x] = Xfake_grassB;
4828 /* --------------------------------------------------------------------- */
4831 if (lev.magnify_cnt)
4832 Cave[y][x] = Xdoor_1;
4836 if (lev.magnify_cnt)
4837 Cave[y][x] = Xdoor_2;
4841 if (lev.magnify_cnt)
4842 Cave[y][x] = Xdoor_3;
4846 if (lev.magnify_cnt)
4847 Cave[y][x] = Xdoor_4;
4851 if (lev.magnify_cnt)
4852 Cave[y][x] = Xdoor_5;
4856 if (lev.magnify_cnt)
4857 Cave[y][x] = Xdoor_6;
4861 if (lev.magnify_cnt)
4862 Cave[y][x] = Xdoor_7;
4866 if (lev.magnify_cnt)
4867 Cave[y][x] = Xdoor_8;
4870 /* --------------------------------------------------------------------- */
4874 Next[y][x] = Znormal;
4875 Boom[y-1][x-1] = Xemerald;
4876 Boom[y-1][x] = Xemerald;
4877 Boom[y-1][x+1] = Xemerald;
4878 Boom[y][x-1] = Xemerald;
4879 Boom[y][x] = Xdiamond;
4880 Boom[y][x+1] = Xemerald;
4881 Boom[y+1][x-1] = Xemerald;
4882 Boom[y+1][x] = Xemerald;
4883 Boom[y+1][x+1] = Xemerald;
4885 play_element_sound(x, y, SAMPLE_boom, element);
4893 Next[y][x] = Znormal;
4894 Boom[y-1][x-1] = Xblank;
4895 Boom[y-1][x] = Xblank;
4896 Boom[y-1][x+1] = Xblank;
4897 Boom[y][x-1] = Xblank;
4898 Boom[y][x] = Xblank;
4899 Boom[y][x+1] = Xblank;
4900 Boom[y+1][x-1] = Xblank;
4901 Boom[y+1][x] = Xblank;
4902 Boom[y+1][x+1] = Xblank;
4904 play_element_sound(x, y, SAMPLE_boom, element);
4910 play_element_sound(x, y, SAMPLE_boom, Xandroid);
4913 Next[y][x] = Xboom_2;
4915 play_sound(x, y, SAMPLE_boom);
4920 Next[y][x] = Boom[y][x];
4923 /* --------------------------------------------------------------------- */
4926 if (++y < HEIGHT - 1)
4929 cave_cache = Cave[y];
4942 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
4943 lev.score += score; /* only add a score if someone is alive */
4950 /* triple buffering */