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)
21 register unsigned int x = 0;
22 register unsigned int y = 1;
23 register unsigned long random = Random;
24 register unsigned short *cave_cache = Cave[y]; /* might be a win */
25 unsigned long score = 0;
27 unsigned int temp = 0; /* initialized to make compilers happy */
28 unsigned int dx; /* only needed to find closest player */
34 element = cave_cache[++x];
41 /* --------------------------------------------------------------------- */
60 Cave[y][x] = Ystone_eB;
61 Cave[y][x+1] = Ystone_e;
63 Next[y][x+1] = Xstone_pause;
83 Cave[y][x] = Ystone_wB;
84 Cave[y][x-1] = Ystone_w;
86 Next[y][x-1] = Xstone_pause;
106 Cave[y][x] = Ynut_eB;
107 Cave[y][x+1] = Ynut_e;
109 Next[y][x+1] = Xnut_pause;
114 switch (Cave[y][x-1])
129 Cave[y][x] = Ynut_wB;
130 Cave[y][x-1] = Ynut_w;
132 Next[y][x-1] = Xnut_pause;
136 case Xspring_force_e:
137 switch (Cave[y][x+1])
147 Cave[y][x] = Xspring;
148 Next[y][x] = Xspring;
152 Cave[y][x] = Yspring_eB;
153 Cave[y][x+1] = Yspring_e;
157 Next[y][x+1] = Xspring_e;
159 Next[y][x+1] = Xspring_pause;
165 case Xspring_force_w:
166 switch (Cave[y][x-1])
176 Cave[y][x] = Xspring;
177 Next[y][x] = Xspring;
181 Cave[y][x] = Yspring_wB;
182 Cave[y][x-1] = Yspring_w;
186 Next[y][x-1] = Xspring_w;
188 Next[y][x-1] = Xspring_pause;
193 case Xemerald_force_e:
194 switch (Cave[y][x+1])
204 Cave[y][x] = Xemerald;
205 Next[y][x] = Xemerald;
209 Cave[y][x] = Yemerald_eB;
210 Cave[y][x+1] = Yemerald_e;
212 Next[y][x+1] = Xemerald_pause;
216 case Xemerald_force_w:
217 switch (Cave[y][x-1])
227 Cave[y][x] = Xemerald;
228 Next[y][x] = Xemerald;
232 Cave[y][x] = Yemerald_wB;
233 Cave[y][x-1] = Yemerald_w;
235 Next[y][x-1] = Xemerald_pause;
239 case Xdiamond_force_e:
240 switch (Cave[y][x+1])
250 Cave[y][x] = Xdiamond;
251 Next[y][x] = Xdiamond;
255 Cave[y][x] = Ydiamond_eB;
256 Cave[y][x+1] = Ydiamond_e;
258 Next[y][x+1] = Xdiamond_pause;
262 case Xdiamond_force_w:
263 switch (Cave[y][x-1])
273 Cave[y][x] = Xdiamond;
274 Next[y][x] = Xdiamond;
278 Cave[y][x] = Ydiamond_wB;
279 Cave[y][x-1] = Ydiamond_w;
281 Next[y][x-1] = Xdiamond_pause;
286 switch (Cave[y][x+1])
301 Cave[y][x] = Ybomb_eB;
302 Cave[y][x+1] = Ybomb_e;
304 Next[y][x+1] = Xbomb_pause;
309 switch (Cave[y][x-1])
324 Cave[y][x] = Ybomb_wB;
325 Cave[y][x-1] = Ybomb_w;
327 Next[y][x-1] = Xbomb_pause;
330 #endif /* BAD_ROLL */
332 /* --------------------------------------------------------------------- */
335 switch (Cave[y+1][x])
345 Cave[y][x] = Ystone_sB;
346 if (Cave[y][x+1] == Xblank)
347 Cave[y][x+1] = Yacid_splash_eB;
348 if (Cave[y][x-1] == Xblank)
349 Cave[y][x-1] = Yacid_splash_wB;
351 play_sound(x, y, SAMPLE_acid);
355 case Yacid_splash_eB:
356 case Yacid_splash_wB:
359 Cave[y][x] = Ystone_sB;
360 Cave[y+1][x] = Ystone_s;
362 Next[y+1][x] = Xstone_fall;
366 Cave[y][x] = Xsand_stonein_1;
367 Cave[y+1][x] = Xsand_sandstone_1;
368 Next[y][x] = Xsand_stonein_2;
369 Next[y+1][x] = Xsand_sandstone_2;
420 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
422 Cave[y][x] = Ystone_eB;
423 Cave[y][x+1] = Ystone_e;
425 Next[y][x+1] = Xstone_pause;
429 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
431 Cave[y][x] = Ystone_wB;
432 Cave[y][x-1] = Ystone_w;
434 Next[y][x-1] = Xstone_pause;
440 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
442 Cave[y][x] = Ystone_wB;
443 Cave[y][x-1] = Ystone_w;
445 Next[y][x-1] = Xstone_pause;
449 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
451 Cave[y][x] = Ystone_eB;
452 Cave[y][x+1] = Ystone_e;
454 Next[y][x+1] = Xstone_pause;
463 /* --------------------------------------------------------------------- */
466 switch (Cave[y+1][x])
476 Cave[y][x] = Ystone_sB;
477 if (Cave[y][x+1] == Xblank)
478 Cave[y][x+1] = Yacid_splash_eB;
479 if (Cave[y][x-1] == Xblank)
480 Cave[y][x-1] = Yacid_splash_wB;
482 play_sound(x, y, SAMPLE_acid);
486 case Yacid_splash_eB:
487 case Yacid_splash_wB:
488 Cave[y][x] = Ystone_sB;
489 Cave[y+1][x] = Ystone_s;
491 Next[y+1][x] = Xstone_fall;
500 /* --------------------------------------------------------------------- */
503 switch (Cave[y+1][x])
513 Cave[y][x] = Ystone_sB;
514 if (Cave[y][x+1] == Xblank)
515 Cave[y][x+1] = Yacid_splash_eB;
516 if (Cave[y][x-1] == Xblank)
517 Cave[y][x-1] = Yacid_splash_wB;
519 play_sound(x, y, SAMPLE_acid);
523 case Yacid_splash_eB:
524 case Yacid_splash_wB:
526 Cave[y][x] = Ystone_sB;
527 Cave[y+1][x] = Ystone_s;
529 Next[y+1][x] = Xstone_fall;
534 Cave[y+1][x] = Yemerald_stone;
536 Next[y+1][x] = Xemerald;
537 play_element_sound(x, y, SAMPLE_crack, Xnut);
538 score += lev.nut_score;
549 Cave[y][x] = Ystone_sB;
550 Cave[y+1][x] = Ybug_stone;
551 Next[y+1][x] = Znormal;
552 Boom[y][x-1] = Xemerald;
553 Boom[y][x] = Xemerald;
554 Boom[y][x+1] = Xemerald;
555 Boom[y+1][x-1] = Xemerald;
556 Boom[y+1][x] = Xdiamond;
557 Boom[y+1][x+1] = Xemerald;
558 Boom[y+2][x-1] = Xemerald;
559 Boom[y+2][x] = Xemerald;
560 Boom[y+2][x+1] = Xemerald;
562 play_element_sound(x, y, SAMPLE_boom, element);
564 score += lev.bug_score;
575 Cave[y][x] = Ystone_sB;
576 Cave[y+1][x] = Ytank_stone;
577 Next[y+1][x] = Znormal;
578 Boom[y][x-1] = Xblank;
580 Boom[y][x+1] = Xblank;
581 Boom[y+1][x-1] = Xblank;
582 Boom[y+1][x] = Xblank;
583 Boom[y+1][x+1] = Xblank;
584 Boom[y+2][x-1] = Xblank;
585 Boom[y+2][x] = Xblank;
586 Boom[y+2][x+1] = Xblank;
588 play_element_sound(x, y, SAMPLE_boom, element);
590 score += lev.tank_score;
596 switch (Cave[y+1][x+1])
599 case Yacid_splash_eB:
600 case Yacid_splash_wB:
603 Cave[y+1][x] = Xspring_e;
607 Cave[y+1][x] = Xspring_w;
613 switch (Cave[y+1][x-1])
616 case Yacid_splash_eB:
617 case Yacid_splash_wB:
620 Cave[y+1][x] = Xspring_w;
623 Cave[y+1][x] = Xspring_e;
635 Cave[y][x] = Ystone_sB;
636 Cave[y+1][x] = Yeater_stone;
637 Next[y+1][x] = Znormal;
638 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
639 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
640 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
641 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
642 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
643 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
644 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
645 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
646 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
648 play_element_sound(x, y, SAMPLE_boom, element);
650 lev.eater_pos = (lev.eater_pos + 1) & 7;
651 score += lev.eater_score;
656 Cave[y][x] = Ystone_sB;
657 Cave[y+1][x] = Yalien_stone;
658 Next[y+1][x] = Znormal;
659 Boom[y][x-1] = Xblank;
661 Boom[y][x+1] = Xblank;
662 Boom[y+1][x-1] = Xblank;
663 Boom[y+1][x] = Xblank;
664 Boom[y+1][x+1] = Xblank;
665 Boom[y+2][x-1] = Xblank;
666 Boom[y+2][x] = Xblank;
667 Boom[y+2][x+1] = Xblank;
669 play_element_sound(x, y, SAMPLE_boom, element);
671 score += lev.alien_score;
676 switch (Cave[y+2][x])
679 case Yacid_splash_eB:
680 case Yacid_splash_wB:
725 play_element_sound(x, y, SAMPLE_stone, Xstone);
729 Cave[y][x] = Ystone_sB;
730 Cave[y+1][x] = Ydiamond_stone;
732 Next[y+1][x] = Xstone_pause;
733 play_element_sound(x, y, SAMPLE_squash, Xdiamond);
738 Cave[y+1][x] = Ybomb_eat;
739 Next[y+1][x] = Znormal;
740 Boom[y][x-1] = Xblank;
742 Boom[y][x+1] = Xblank;
743 Boom[y+1][x-1] = Xblank;
744 Boom[y+1][x] = Xblank;
745 Boom[y+1][x+1] = Xblank;
746 Boom[y+2][x-1] = Xblank;
747 Boom[y+2][x] = Xblank;
748 Boom[y+2][x+1] = Xblank;
750 play_element_sound(x, y, SAMPLE_boom, element);
755 if (lev.wonderwall_time)
757 lev.wonderwall_state = 1;
758 Cave[y][x] = Ystone_sB;
760 if (tab_blank[Cave[y+2][x]])
762 Cave[y+2][x] = Yemerald_s;
763 Next[y+2][x] = Xemerald_fall;
767 play_element_sound(x, y, SAMPLE_wonderfall, Xstone);
774 play_element_sound(x, y, SAMPLE_stone, Xstone);
778 /* --------------------------------------------------------------------- */
781 switch (Cave[y+1][x])
791 Cave[y][x] = Ynut_sB;
792 if (Cave[y][x+1] == Xblank)
793 Cave[y][x+1] = Yacid_splash_eB;
794 if (Cave[y][x-1] == Xblank)
795 Cave[y][x-1] = Yacid_splash_wB;
797 play_sound(x, y, SAMPLE_acid);
801 case Yacid_splash_eB:
802 case Yacid_splash_wB:
803 Cave[y][x] = Ynut_sB;
804 Cave[y+1][x] = Ynut_s;
806 Next[y+1][x] = Xnut_fall;
855 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
857 Cave[y][x] = Ynut_eB;
858 Cave[y][x+1] = Ynut_e;
860 Next[y][x+1] = Xnut_pause;
864 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
866 Cave[y][x] = Ynut_wB;
867 Cave[y][x-1] = Ynut_w;
869 Next[y][x-1] = Xnut_pause;
875 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
877 Cave[y][x] = Ynut_wB;
878 Cave[y][x-1] = Ynut_w;
880 Next[y][x-1] = Xnut_pause;
884 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
886 Cave[y][x] = Ynut_eB;
887 Cave[y][x+1] = Ynut_e;
889 Next[y][x+1] = Xnut_pause;
898 /* --------------------------------------------------------------------- */
902 switch (Cave[y+1][x])
912 Cave[y][x] = Ynut_sB;
913 if (Cave[y][x+1] == Xblank)
914 Cave[y][x+1] = Yacid_splash_eB;
915 if (Cave[y][x-1] == Xblank)
916 Cave[y][x-1] = Yacid_splash_wB;
918 play_sound(x, y, SAMPLE_acid);
922 case Yacid_splash_eB:
923 case Yacid_splash_wB:
924 Cave[y][x] = Ynut_sB;
925 Cave[y+1][x] = Ynut_s;
927 Next[y+1][x] = Xnut_fall;
936 /* --------------------------------------------------------------------- */
939 switch (Cave[y+1][x])
949 Cave[y][x] = Ynut_sB;
950 if (Cave[y][x+1] == Xblank)
951 Cave[y][x+1] = Yacid_splash_eB;
952 if (Cave[y][x-1] == Xblank)
953 Cave[y][x-1] = Yacid_splash_wB;
955 play_sound(x, y, SAMPLE_acid);
959 case Yacid_splash_eB:
960 case Yacid_splash_wB:
962 Cave[y][x] = Ynut_sB;
963 Cave[y+1][x] = Ynut_s;
965 Next[y+1][x] = Xnut_fall;
971 play_element_sound(x, y, SAMPLE_nut, Xnut);
975 /* --------------------------------------------------------------------- */
978 if (tab_amoeba[Cave[y-1][x]] ||
979 tab_amoeba[Cave[y][x+1]] ||
980 tab_amoeba[Cave[y+1][x]] ||
981 tab_amoeba[Cave[y][x-1]])
984 switch (Cave[y][x+1])
987 case Yacid_splash_eB:
988 case Yacid_splash_wB:
1000 Cave[y][x] = Ybug_n_e;
1001 Next[y][x] = Xbug_goe;
1002 play_sound(x, y, SAMPLE_bug);
1010 if (tab_amoeba[Cave[y-1][x]] ||
1011 tab_amoeba[Cave[y][x+1]] ||
1012 tab_amoeba[Cave[y+1][x]] ||
1013 tab_amoeba[Cave[y][x-1]])
1018 switch (Cave[y-1][x])
1028 Cave[y][x] = Ybug_nB;
1029 if (Cave[y-2][x+1] == Xblank)
1030 Cave[y-2][x+1] = Yacid_splash_eB;
1031 if (Cave[y-2][x-1] == Xblank)
1032 Cave[y-2][x-1] = Yacid_splash_wB;
1033 Next[y][x] = Xblank;
1034 play_sound(x, y, SAMPLE_acid);
1038 case Yacid_splash_eB:
1039 case Yacid_splash_wB:
1043 Cave[y][x] = Ybug_nB;
1044 Cave[y-1][x] = Ybug_n;
1045 Next[y][x] = Xblank;
1046 Next[y-1][x] = Xbug_n;
1047 play_sound(x, y, SAMPLE_bug);
1051 Cave[y][x] = Ybug_n_w;
1052 Next[y][x] = Xbug_gow;
1053 play_sound(x, y, SAMPLE_bug);
1057 /* --------------------------------------------------------------------- */
1060 if (tab_amoeba[Cave[y-1][x]] ||
1061 tab_amoeba[Cave[y][x+1]] ||
1062 tab_amoeba[Cave[y+1][x]] ||
1063 tab_amoeba[Cave[y][x-1]])
1066 switch (Cave[y+1][x])
1069 case Yacid_splash_eB:
1070 case Yacid_splash_wB:
1082 Cave[y][x] = Ybug_e_s;
1083 Next[y][x] = Xbug_gos;
1084 play_sound(x, y, SAMPLE_bug);
1092 if (tab_amoeba[Cave[y-1][x]] ||
1093 tab_amoeba[Cave[y][x+1]] ||
1094 tab_amoeba[Cave[y+1][x]] ||
1095 tab_amoeba[Cave[y][x-1]])
1100 switch (Cave[y][x+1])
1110 Cave[y][x] = Ybug_eB;
1111 if (Cave[y-1][x+2] == Xblank)
1112 Cave[y-1][x+2] = Yacid_splash_eB;
1113 if (Cave[y-1][x] == Xblank)
1114 Cave[y-1][x] = Yacid_splash_wB;
1115 Next[y][x] = Xblank;
1116 play_sound(x, y, SAMPLE_acid);
1120 case Yacid_splash_eB:
1121 case Yacid_splash_wB:
1125 Cave[y][x] = Ybug_eB;
1126 Cave[y][x+1] = Ybug_e;
1127 Next[y][x] = Xblank;
1128 Next[y][x+1] = Xbug_e;
1129 play_sound(x, y, SAMPLE_bug);
1133 Cave[y][x] = Ybug_e_n;
1134 Next[y][x] = Xbug_gon;
1135 play_sound(x, y, SAMPLE_bug);
1139 /* --------------------------------------------------------------------- */
1142 if (tab_amoeba[Cave[y-1][x]] ||
1143 tab_amoeba[Cave[y][x+1]] ||
1144 tab_amoeba[Cave[y+1][x]] ||
1145 tab_amoeba[Cave[y][x-1]])
1148 switch (Cave[y][x-1])
1151 case Yacid_splash_eB:
1152 case Yacid_splash_wB:
1164 Cave[y][x] = Ybug_s_w;
1165 Next[y][x] = Xbug_gow;
1166 play_sound(x, y, SAMPLE_bug);
1174 if (tab_amoeba[Cave[y-1][x]] ||
1175 tab_amoeba[Cave[y][x+1]] ||
1176 tab_amoeba[Cave[y+1][x]] ||
1177 tab_amoeba[Cave[y][x-1]])
1182 switch (Cave[y+1][x])
1192 Cave[y][x] = Ybug_sB;
1193 if (Cave[y][x+1] == Xblank)
1194 Cave[y][x+1] = Yacid_splash_eB;
1195 if (Cave[y][x-1] == Xblank)
1196 Cave[y][x-1] = Yacid_splash_wB;
1197 Next[y][x] = Xblank;
1198 play_sound(x, y, SAMPLE_acid);
1202 case Yacid_splash_eB:
1203 case Yacid_splash_wB:
1207 Cave[y][x] = Ybug_sB;
1208 Cave[y+1][x] = Ybug_s;
1209 Next[y][x] = Xblank;
1210 Next[y+1][x] = Xbug_s;
1211 play_sound(x, y, SAMPLE_bug);
1215 Cave[y][x] = Ybug_s_e;
1216 Next[y][x] = Xbug_goe;
1217 play_sound(x, y, SAMPLE_bug);
1221 /* --------------------------------------------------------------------- */
1224 if (tab_amoeba[Cave[y-1][x]] ||
1225 tab_amoeba[Cave[y][x+1]] ||
1226 tab_amoeba[Cave[y+1][x]] ||
1227 tab_amoeba[Cave[y][x-1]])
1230 switch (Cave[y-1][x])
1233 case Yacid_splash_eB:
1234 case Yacid_splash_wB:
1246 Cave[y][x] = Ybug_w_n;
1247 Next[y][x] = Xbug_gon;
1248 play_sound(x, y, SAMPLE_bug);
1256 if (tab_amoeba[Cave[y-1][x]] ||
1257 tab_amoeba[Cave[y][x+1]] ||
1258 tab_amoeba[Cave[y+1][x]] ||
1259 tab_amoeba[Cave[y][x-1]])
1264 switch (Cave[y][x-1])
1274 Cave[y][x] = Ybug_wB;
1275 if (Cave[y-1][x] == Xblank)
1276 Cave[y-1][x] = Yacid_splash_eB;
1277 if (Cave[y-1][x-2] == Xblank)
1278 Cave[y-1][x-2] = Yacid_splash_wB;
1279 Next[y][x] = Xblank;
1280 play_sound(x, y, SAMPLE_acid);
1284 case Yacid_splash_eB:
1285 case Yacid_splash_wB:
1289 Cave[y][x] = Ybug_wB;
1290 Cave[y][x-1] = Ybug_w;
1291 Next[y][x] = Xblank;
1292 Next[y][x-1] = Xbug_w;
1293 play_sound(x, y, SAMPLE_bug);
1297 Cave[y][x] = Ybug_w_s;
1298 Next[y][x] = Xbug_gos;
1299 play_sound(x, y, SAMPLE_bug);
1303 /* --------------------------------------------------------------------- */
1306 if (tab_amoeba[Cave[y-1][x]] ||
1307 tab_amoeba[Cave[y][x+1]] ||
1308 tab_amoeba[Cave[y+1][x]] ||
1309 tab_amoeba[Cave[y][x-1]])
1312 switch (Cave[y][x-1])
1315 case Yacid_splash_eB:
1316 case Yacid_splash_wB:
1328 Cave[y][x] = Ytank_n_w;
1329 Next[y][x] = Xtank_gow;
1330 play_sound(x, y, SAMPLE_tank);
1338 if (tab_amoeba[Cave[y-1][x]] ||
1339 tab_amoeba[Cave[y][x+1]] ||
1340 tab_amoeba[Cave[y+1][x]] ||
1341 tab_amoeba[Cave[y][x-1]])
1346 switch (Cave[y-1][x])
1356 Cave[y][x] = Ytank_nB;
1357 if (Cave[y-2][x+1] == Xblank)
1358 Cave[y-2][x+1] = Yacid_splash_eB;
1359 if (Cave[y-2][x-1] == Xblank)
1360 Cave[y-2][x-1] = Yacid_splash_wB;
1361 Next[y][x] = Xblank;
1362 play_sound(x, y, SAMPLE_acid);
1366 case Yacid_splash_eB:
1367 case Yacid_splash_wB:
1371 Cave[y][x] = Ytank_nB;
1372 Cave[y-1][x] = Ytank_n;
1373 Next[y][x] = Xblank;
1374 Next[y-1][x] = Xtank_n;
1375 play_sound(x, y, SAMPLE_tank);
1379 Cave[y][x] = Ytank_n_e;
1380 Next[y][x] = Xtank_goe;
1381 play_sound(x, y, SAMPLE_tank);
1385 /* --------------------------------------------------------------------- */
1388 if (tab_amoeba[Cave[y-1][x]] ||
1389 tab_amoeba[Cave[y][x+1]] ||
1390 tab_amoeba[Cave[y+1][x]] ||
1391 tab_amoeba[Cave[y][x-1]])
1394 switch (Cave[y-1][x])
1397 case Yacid_splash_eB:
1398 case Yacid_splash_wB:
1410 Cave[y][x] = Ytank_e_n;
1411 Next[y][x] = Xtank_gon;
1412 play_sound(x, y, SAMPLE_tank);
1420 if (tab_amoeba[Cave[y-1][x]] ||
1421 tab_amoeba[Cave[y][x+1]] ||
1422 tab_amoeba[Cave[y+1][x]] ||
1423 tab_amoeba[Cave[y][x-1]])
1428 switch (Cave[y][x+1])
1438 Cave[y][x] = Ytank_eB;
1439 if (Cave[y-1][x+2] == Xblank)
1440 Cave[y-1][x+2] = Yacid_splash_eB;
1441 if (Cave[y-1][x] == Xblank)
1442 Cave[y-1][x] = Yacid_splash_wB;
1443 Next[y][x] = Xblank;
1444 play_sound(x, y, SAMPLE_acid);
1448 case Yacid_splash_eB:
1449 case Yacid_splash_wB:
1453 Cave[y][x] = Ytank_eB;
1454 Cave[y][x+1] = Ytank_e;
1455 Next[y][x] = Xblank;
1456 Next[y][x+1] = Xtank_e;
1457 play_sound(x, y, SAMPLE_tank);
1461 Cave[y][x] = Ytank_e_s;
1462 Next[y][x] = Xtank_gos;
1463 play_sound(x, y, SAMPLE_tank);
1467 /* --------------------------------------------------------------------- */
1470 if (tab_amoeba[Cave[y-1][x]] ||
1471 tab_amoeba[Cave[y][x+1]] ||
1472 tab_amoeba[Cave[y+1][x]] ||
1473 tab_amoeba[Cave[y][x-1]])
1476 switch (Cave[y][x+1])
1479 case Yacid_splash_eB:
1480 case Yacid_splash_wB:
1492 Cave[y][x] = Ytank_s_e;
1493 Next[y][x] = Xtank_goe;
1494 play_sound(x, y, SAMPLE_tank);
1502 if (tab_amoeba[Cave[y-1][x]] ||
1503 tab_amoeba[Cave[y][x+1]] ||
1504 tab_amoeba[Cave[y+1][x]] ||
1505 tab_amoeba[Cave[y][x-1]])
1510 switch (Cave[y+1][x])
1520 Cave[y][x] = Ytank_sB;
1521 if (Cave[y][x+1] == Xblank)
1522 Cave[y][x+1] = Yacid_splash_eB;
1523 if (Cave[y][x-1] == Xblank)
1524 Cave[y][x-1] = Yacid_splash_wB;
1525 Next[y][x] = Xblank;
1526 play_sound(x, y, SAMPLE_acid);
1530 case Yacid_splash_eB:
1531 case Yacid_splash_wB:
1535 Cave[y][x] = Ytank_sB;
1536 Cave[y+1][x] = Ytank_s;
1537 Next[y][x] = Xblank;
1538 Next[y+1][x] = Xtank_s;
1539 play_sound(x, y, SAMPLE_tank);
1543 Cave[y][x] = Ytank_s_w;
1544 Next[y][x] = Xtank_gow;
1545 play_sound(x, y, SAMPLE_tank);
1549 /* --------------------------------------------------------------------- */
1552 if (tab_amoeba[Cave[y-1][x]] ||
1553 tab_amoeba[Cave[y][x+1]] ||
1554 tab_amoeba[Cave[y+1][x]] ||
1555 tab_amoeba[Cave[y][x-1]])
1558 switch (Cave[y+1][x])
1561 case Yacid_splash_eB:
1562 case Yacid_splash_wB:
1574 Cave[y][x] = Ytank_w_s;
1575 Next[y][x] = Xtank_gos;
1576 play_sound(x, y, SAMPLE_tank);
1584 if (tab_amoeba[Cave[y-1][x]] ||
1585 tab_amoeba[Cave[y][x+1]] ||
1586 tab_amoeba[Cave[y+1][x]] ||
1587 tab_amoeba[Cave[y][x-1]])
1592 switch (Cave[y][x-1])
1602 Cave[y][x] = Ytank_wB;
1603 if (Cave[y-1][x] == Xblank)
1604 Cave[y-1][x] = Yacid_splash_eB;
1605 if (Cave[y-1][x-2] == Xblank)
1606 Cave[y-1][x-2] = Yacid_splash_wB;
1607 Next[y][x] = Xblank;
1608 play_sound(x, y, SAMPLE_acid);
1612 case Yacid_splash_eB:
1613 case Yacid_splash_wB:
1617 Cave[y][x] = Ytank_wB;
1618 Cave[y][x-1] = Ytank_w;
1619 Next[y][x] = Xblank;
1620 Next[y][x-1] = Xtank_w;
1621 play_sound(x, y, SAMPLE_tank);
1625 Cave[y][x] = Ytank_w_n;
1626 Next[y][x] = Xtank_gon;
1627 play_sound(x, y, SAMPLE_tank);
1631 /* --------------------------------------------------------------------- */
1637 if (lev.android_clone_cnt == 0)
1639 if (Cave[y-1][x-1] != Xblank &&
1640 Cave[y-1][x] != Xblank &&
1641 Cave[y-1][x+1] != Xblank &&
1642 Cave[y][x-1] != Xblank &&
1643 Cave[y][x+1] != Xblank &&
1644 Cave[y+1][x-1] != Xblank &&
1645 Cave[y+1][x] != Xblank &&
1646 Cave[y+1][x+1] != Xblank)
1651 /* randomly find an object to clone */
1653 case 0: /* S,NE,W,NW,SE,E,SW,N */
1654 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1655 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1656 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1657 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1658 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1659 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1660 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1661 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1664 case 1: /* NW,SE,N,S,NE,SW,E,W */
1665 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1666 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1667 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1668 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1669 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1670 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1671 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1672 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1675 case 2: /* SW,E,S,W,N,NW,SE,NE */
1676 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1677 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1678 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1679 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1680 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1681 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1682 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1683 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1686 case 3: /* N,SE,NE,E,W,S,NW,SW */
1687 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1688 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1689 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1690 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1691 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1692 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1693 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1694 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1697 case 4: /* SE,NW,E,NE,SW,W,N,S */
1698 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1699 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1700 temp= lev.android_array[Cave[y][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+1][x-1]]; if (temp != Xblank) break;
1703 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1704 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1705 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1708 case 5: /* NE,W,SE,SW,S,N,E,NW */
1709 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1710 temp= lev.android_array[Cave[y][x-1]]; 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+1][x-1]]; if (temp != Xblank) break;
1713 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1714 temp= lev.android_array[Cave[y-1][x]]; 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;
1719 case 6: /* E,N,SW,S,NW,NE,SE,W */
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+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-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;
1727 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1730 case 7: /* W,SW,NW,N,E,SE,NE,S */
1731 temp= lev.android_array[Cave[y][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-1][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+1]]; 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]]; if (temp != Xblank) break;
1742 Next[y][x] = temp; /* the item we chose to clone */
1743 play_element_sound(x, y, SAMPLE_android, temp);
1747 /* randomly find a direction to move */
1749 case 0: /* S,NE,W,NW,SE,E,SW,N */
1750 if (Cave[y+1][x] == Xblank) goto android_s;
1751 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1752 if (Cave[y][x-1] == Xblank) goto android_w;
1753 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1754 if (Cave[y+1][x+1] == Xblank) goto android_se;
1755 if (Cave[y][x+1] == Xblank) goto android_e;
1756 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1757 if (Cave[y-1][x] == Xblank) goto android_n;
1760 case 1: /* NW,SE,N,S,NE,SW,E,W */
1761 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1762 if (Cave[y+1][x+1] == Xblank) goto android_se;
1763 if (Cave[y-1][x] == Xblank) goto android_n;
1764 if (Cave[y+1][x] == Xblank) goto android_s;
1765 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1766 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1767 if (Cave[y][x+1] == Xblank) goto android_e;
1768 if (Cave[y][x-1] == Xblank) goto android_w;
1771 case 2: /* SW,E,S,W,N,NW,SE,NE */
1772 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1773 if (Cave[y][x+1] == Xblank) goto android_e;
1774 if (Cave[y+1][x] == Xblank) goto android_s;
1775 if (Cave[y][x-1] == Xblank) goto android_w;
1776 if (Cave[y-1][x] == Xblank) goto android_n;
1777 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1778 if (Cave[y+1][x+1] == Xblank) goto android_se;
1779 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1782 case 3: /* N,SE,NE,E,W,S,NW,SW */
1783 if (Cave[y-1][x] == Xblank) goto android_n;
1784 if (Cave[y+1][x+1] == Xblank) goto android_se;
1785 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1786 if (Cave[y][x+1] == Xblank) goto android_e;
1787 if (Cave[y][x-1] == Xblank) goto android_w;
1788 if (Cave[y+1][x] == Xblank) goto android_s;
1789 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1790 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1793 case 4: /* SE,NW,E,NE,SW,W,N,S */
1794 if (Cave[y+1][x+1] == Xblank) goto android_se;
1795 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1796 if (Cave[y][x+1] == Xblank) goto android_e;
1797 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1798 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1799 if (Cave[y][x-1] == Xblank) goto android_w;
1800 if (Cave[y-1][x] == Xblank) goto android_n;
1801 if (Cave[y+1][x] == Xblank) goto android_s;
1804 case 5: /* NE,W,SE,SW,S,N,E,NW */
1805 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1806 if (Cave[y][x-1] == Xblank) goto android_w;
1807 if (Cave[y+1][x+1] == Xblank) goto android_se;
1808 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1809 if (Cave[y+1][x] == Xblank) goto android_s;
1810 if (Cave[y-1][x] == Xblank) goto android_n;
1811 if (Cave[y][x+1] == Xblank) goto android_e;
1812 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1815 case 6: /* E,N,SW,S,NW,NE,SE,W */
1816 if (Cave[y][x+1] == Xblank) goto android_e;
1817 if (Cave[y-1][x] == Xblank) goto android_n;
1818 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1819 if (Cave[y+1][x] == Xblank) goto android_s;
1820 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1821 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1822 if (Cave[y+1][x+1] == Xblank) goto android_se;
1823 if (Cave[y][x-1] == Xblank) goto android_w;
1826 case 7: /* W,SW,NW,N,E,SE,NE,S */
1827 if (Cave[y][x-1] == Xblank) goto android_w;
1828 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1829 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1830 if (Cave[y-1][x] == Xblank) goto android_n;
1831 if (Cave[y][x+1] == Xblank) goto android_e;
1832 if (Cave[y+1][x+1] == Xblank) goto android_se;
1833 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1834 if (Cave[y+1][x] == Xblank) goto android_s;
1840 if (lev.android_move_cnt == 0)
1842 if (Cave[y-1][x-1] == Zplayer ||
1843 Cave[y-1][x] == Zplayer ||
1844 Cave[y-1][x+1] == Zplayer ||
1845 Cave[y][x-1] == Zplayer ||
1846 Cave[y][x+1] == Zplayer ||
1847 Cave[y+1][x-1] == Zplayer ||
1848 Cave[y+1][x] == Zplayer ||
1849 Cave[y+1][x+1] == Zplayer)
1852 if (ply1.alive && ply2.alive)
1854 if ((ply1.x > x ? ply1.x - x : x - ply1.x) +
1855 (ply1.y > y ? ply1.y - y : y - ply1.y) <
1856 (ply2.x > x ? ply2.x - x : x - ply2.x) +
1857 (ply2.y > y ? ply2.y - y : y - ply2.y))
1868 else if (ply1.alive)
1873 else if (ply2.alive)
1884 Next[y][x] = Xblank; /* assume we will move */
1885 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1891 /* attempt clockwise move first if direct path is blocked */
1893 case 0: /* north west */
1894 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1895 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1896 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1900 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1901 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1902 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1905 case 2: /* north east */
1906 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1907 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1908 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1912 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1913 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1914 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1917 case 4: /* nowhere */
1921 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1922 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1923 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1926 case 6: /* south west */
1927 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1928 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1929 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1933 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1934 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1935 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1938 case 8: /* south east */
1939 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1940 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1941 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1949 /* attempt counterclockwise move first if direct path is blocked */
1951 case 0: /* north west */
1952 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1953 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1954 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1958 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1959 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1960 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1963 case 2: /* north east */
1964 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1965 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1966 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1970 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1971 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1972 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1975 case 4: /* nowhere */
1979 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1980 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1981 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1984 case 6: /* south west */
1985 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1986 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1987 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1991 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1992 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1993 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1996 case 8: /* south east */
1997 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1998 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1999 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2007 Next[y][x] = Xandroid;
2012 Cave[y][x] = Yandroid_nB;
2013 Cave[y-1][x] = Yandroid_n;
2014 Next[y-1][x] = Xandroid;
2015 play_sound(x, y, SAMPLE_tank);
2020 Cave[y][x] = Yandroid_neB;
2021 Cave[y-1][x+1] = Yandroid_ne;
2022 Next[y-1][x+1] = Xandroid;
2023 play_sound(x, y, SAMPLE_tank);
2028 Cave[y][x] = Yandroid_eB;
2029 Cave[y][x+1] = Yandroid_e;
2030 Next[y][x+1] = Xandroid;
2031 play_sound(x, y, SAMPLE_tank);
2036 Cave[y][x] = Yandroid_seB;
2037 Cave[y+1][x+1] = Yandroid_se;
2038 Next[y+1][x+1] = Xandroid;
2039 play_sound(x, y, SAMPLE_tank);
2044 Cave[y][x] = Yandroid_sB;
2045 Cave[y+1][x] = Yandroid_s;
2046 Next[y+1][x] = Xandroid;
2047 play_sound(x, y, SAMPLE_tank);
2052 Cave[y][x] = Yandroid_swB;
2053 Cave[y+1][x-1] = Yandroid_sw;
2054 Next[y+1][x-1] = Xandroid;
2055 play_sound(x, y, SAMPLE_tank);
2060 Cave[y][x] = Yandroid_wB;
2061 Cave[y][x-1] = Yandroid_w;
2062 Next[y][x-1] = Xandroid;
2063 play_sound(x, y, SAMPLE_tank);
2068 Cave[y][x] = Yandroid_nwB;
2069 Cave[y-1][x-1] = Yandroid_nw;
2070 Next[y-1][x-1] = Xandroid;
2071 play_sound(x, y, SAMPLE_tank);
2074 /* --------------------------------------------------------------------- */
2077 switch (Cave[y-1][x])
2087 Cave[y][x] = Yandroid_nB;
2088 if (Cave[y-2][x+1] == Xblank)
2089 Cave[y-2][x+1] = Yacid_splash_eB;
2090 if (Cave[y-2][x-1] == Xblank)
2091 Cave[y-2][x-1] = Yacid_splash_wB;
2092 Next[y][x] = Xblank;
2093 play_sound(x, y, SAMPLE_acid);
2097 case Yacid_splash_eB:
2098 case Yacid_splash_wB:
2099 Cave[y][x] = Yandroid_nB;
2100 Cave[y-1][x] = Yandroid_n;
2101 Next[y][x] = Xblank;
2102 Next[y-1][x] = Xandroid;
2103 play_sound(x, y, SAMPLE_tank);
2111 switch (Cave[y-1][x])
2121 Cave[y][x] = Yandroid_nB;
2122 if (Cave[y-2][x+1] == Xblank)
2123 Cave[y-2][x+1] = Yacid_splash_eB;
2124 if (Cave[y-2][x-1] == Xblank)
2125 Cave[y-2][x-1] = Yacid_splash_wB;
2126 Next[y][x] = Xblank;
2127 play_sound(x, y, SAMPLE_acid);
2131 case Yacid_splash_eB:
2132 case Yacid_splash_wB:
2133 Cave[y][x] = Yandroid_nB;
2134 Cave[y-1][x] = Yandroid_n;
2135 Next[y][x] = Xblank;
2136 Next[y-1][x] = Xandroid_1_n;
2137 play_sound(x, y, SAMPLE_tank);
2144 /* --------------------------------------------------------------------- */
2147 switch (Cave[y][x+1])
2157 Cave[y][x] = Yandroid_eB;
2158 if (Cave[y-1][x+2] == Xblank)
2159 Cave[y-1][x+2] = Yacid_splash_eB;
2160 if (Cave[y-1][x] == Xblank)
2161 Cave[y-1][x] = Yacid_splash_wB;
2162 Next[y][x] = Xblank;
2163 play_sound(x, y, SAMPLE_acid);
2167 case Yacid_splash_eB:
2168 case Yacid_splash_wB:
2169 Cave[y][x] = Yandroid_eB;
2170 Cave[y][x+1] = Yandroid_e;
2171 Next[y][x] = Xblank;
2172 Next[y][x+1] = Xandroid;
2173 play_sound(x, y, SAMPLE_tank);
2181 switch (Cave[y][x+1])
2191 Cave[y][x] = Yandroid_eB;
2192 if (Cave[y-1][x+2] == Xblank)
2193 Cave[y-1][x+2] = Yacid_splash_eB;
2194 if (Cave[y-1][x] == Xblank)
2195 Cave[y-1][x] = Yacid_splash_wB;
2196 Next[y][x] = Xblank;
2197 play_sound(x, y, SAMPLE_acid);
2201 case Yacid_splash_eB:
2202 case Yacid_splash_wB:
2203 Cave[y][x] = Yandroid_eB;
2204 Cave[y][x+1] = Yandroid_e;
2205 Next[y][x] = Xblank;
2206 Next[y][x+1] = Xandroid_1_e;
2207 play_sound(x, y, SAMPLE_tank);
2214 /* --------------------------------------------------------------------- */
2217 switch (Cave[y+1][x])
2227 Cave[y][x] = Yandroid_sB;
2228 if (Cave[y][x+1] == Xblank)
2229 Cave[y][x+1] = Yacid_splash_eB;
2230 if (Cave[y][x-1] == Xblank)
2231 Cave[y][x-1] = Yacid_splash_wB;
2232 Next[y][x] = Xblank;
2233 play_sound(x, y, SAMPLE_acid);
2237 case Yacid_splash_eB:
2238 case Yacid_splash_wB:
2239 Cave[y][x] = Yandroid_sB;
2240 Cave[y+1][x] = Yandroid_s;
2241 Next[y][x] = Xblank;
2242 Next[y+1][x] = Xandroid;
2243 play_sound(x, y, SAMPLE_tank);
2251 switch (Cave[y+1][x])
2261 Cave[y][x] = Yandroid_sB;
2262 if (Cave[y][x+1] == Xblank)
2263 Cave[y][x+1] = Yacid_splash_eB;
2264 if (Cave[y][x-1] == Xblank)
2265 Cave[y][x-1] = Yacid_splash_wB;
2266 Next[y][x] = Xblank;
2267 play_sound(x, y, SAMPLE_acid);
2271 case Yacid_splash_eB:
2272 case Yacid_splash_wB:
2273 Cave[y][x] = Yandroid_sB;
2274 Cave[y+1][x] = Yandroid_s;
2275 Next[y][x] = Xblank;
2276 Next[y+1][x] = Xandroid_1_s;
2277 play_sound(x, y, SAMPLE_tank);
2284 /* --------------------------------------------------------------------- */
2287 switch (Cave[y][x-1])
2297 Cave[y][x] = Yandroid_wB;
2298 if (Cave[y-1][x] == Xblank)
2299 Cave[y-1][x] = Yacid_splash_eB;
2300 if (Cave[y-1][x-2] == Xblank)
2301 Cave[y-1][x-2] = Yacid_splash_wB;
2302 Next[y][x] = Xblank;
2303 play_sound(x, y, SAMPLE_acid);
2307 case Yacid_splash_eB:
2308 case Yacid_splash_wB:
2309 Cave[y][x] = Yandroid_wB;
2310 Cave[y][x-1] = Yandroid_w;
2311 Next[y][x] = Xblank;
2312 Next[y][x-1] = Xandroid;
2313 play_sound(x, y, SAMPLE_tank);
2321 switch (Cave[y][x-1])
2331 Cave[y][x] = Yandroid_wB;
2332 if (Cave[y-1][x] == Xblank)
2333 Cave[y-1][x] = Yacid_splash_eB;
2334 if (Cave[y-1][x-2] == Xblank)
2335 Cave[y-1][x-2] = Yacid_splash_wB;
2336 Next[y][x] = Xblank;
2337 play_sound(x, y, SAMPLE_acid);
2341 case Yacid_splash_eB:
2342 case Yacid_splash_wB:
2343 Cave[y][x] = Yandroid_wB;
2344 Cave[y][x-1] = Yandroid_w;
2345 Next[y][x] = Xblank;
2346 Next[y][x-1] = Xandroid_1_w;
2347 play_sound(x, y, SAMPLE_tank);
2354 /* --------------------------------------------------------------------- */
2357 switch (Cave[y+1][x])
2367 Cave[y][x] = Yspring_sB;
2368 if (Cave[y][x+1] == Xblank)
2369 Cave[y][x+1] = Yacid_splash_eB;
2370 if (Cave[y][x-1] == Xblank)
2371 Cave[y][x-1] = Yacid_splash_wB;
2372 Next[y][x] = Xblank;
2373 play_sound(x, y, SAMPLE_acid);
2377 case Yacid_splash_eB:
2378 case Yacid_splash_wB:
2381 Cave[y][x] = Yspring_sB;
2382 Cave[y+1][x] = Yspring_s;
2383 Next[y][x] = Xblank;
2384 Next[y+1][x] = Xspring_fall;
2403 case Xemerald_pause:
2405 case Xdiamond_pause:
2433 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2435 Cave[y][x] = Yspring_eB;
2436 Cave[y][x+1] = Yspring_e;
2437 if (Cave[y+1][x] == Xbumper)
2438 Cave[y+1][x] = XbumperB;
2439 Next[y][x] = Xblank;
2442 Next[y][x+1] = Xspring_e;
2444 Next[y][x+1] = Xspring_pause;
2450 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2452 Cave[y][x] = Yspring_wB;
2453 Cave[y][x-1] = Yspring_w;
2454 if (Cave[y+1][x] == Xbumper)
2455 Cave[y+1][x] = XbumperB;
2456 Next[y][x] = Xblank;
2459 Next[y][x-1] = Xspring_w;
2461 Next[y][x-1] = Xspring_pause;
2469 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2471 Cave[y][x] = Yspring_wB;
2472 Cave[y][x-1] = Yspring_w;
2473 if (Cave[y+1][x] == Xbumper)
2474 Cave[y+1][x] = XbumperB;
2475 Next[y][x] = Xblank;
2478 Next[y][x-1] = Xspring_w;
2480 Next[y][x-1] = Xspring_pause;
2486 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2488 Cave[y][x] = Yspring_eB;
2489 Cave[y][x+1] = Yspring_e;
2490 if (Cave[y+1][x] == Xbumper)
2491 Cave[y+1][x] = XbumperB;
2492 Next[y][x] = Xblank;
2495 Next[y][x+1] = Xspring_e;
2497 Next[y][x+1] = Xspring_pause;
2508 /* --------------------------------------------------------------------- */
2511 switch (Cave[y+1][x])
2521 Cave[y][x] = Yspring_sB;
2522 if (Cave[y][x+1] == Xblank)
2523 Cave[y][x+1] = Yacid_splash_eB;
2524 if (Cave[y][x-1] == Xblank)
2525 Cave[y][x-1] = Yacid_splash_wB;
2526 Next[y][x] = Xblank;
2527 play_sound(x, y, SAMPLE_acid);
2531 case Yacid_splash_eB:
2532 case Yacid_splash_wB:
2533 Cave[y][x] = Yspring_sB;
2534 Cave[y+1][x] = Yspring_s;
2535 Next[y][x] = Xblank;
2536 Next[y+1][x] = Xspring_fall;
2540 Cave[y][x] = Xspring;
2541 Next[y][x] = Xspring;
2545 /* --------------------------------------------------------------------- */
2548 switch (Cave[y+1][x])
2558 Cave[y][x] = Yspring_sB;
2559 if (Cave[y][x+1] == Xblank)
2560 Cave[y][x+1] = Yacid_splash_eB;
2561 if (Cave[y][x-1] == Xblank)
2562 Cave[y][x-1] = Yacid_splash_wB;
2563 Next[y][x] = Xblank;
2564 play_sound(x, y, SAMPLE_acid);
2568 case Yacid_splash_eB:
2569 case Yacid_splash_wB:
2570 Cave[y][x] = Yspring_sB;
2571 Cave[y+1][x] = Yspring_s;
2572 Next[y][x] = Xblank;
2573 Next[y+1][x] = Xspring_fall;
2577 Cave[y+1][x] = XbumperB;
2580 switch (Cave[y][x+1])
2590 Cave[y][x] = Yspring_eB;
2591 if (Cave[y-1][x+2] == Xblank)
2592 Cave[y-1][x+2] = Yacid_splash_eB;
2593 if (Cave[y-1][x] == Xblank)
2594 Cave[y-1][x] = Yacid_splash_wB;
2595 Next[y][x] = Xblank;
2596 play_sound(x, y, SAMPLE_acid);
2600 case Yacid_splash_eB:
2601 case Yacid_splash_wB:
2606 Cave[y][x] = Yspring_eB;
2607 Cave[y][x+1] = Yspring_e;
2608 Next[y][x] = Xblank;
2609 Next[y][x+1] = Xspring_e;
2618 Cave[y][x] = Yspring_kill_eB;
2619 Cave[y][x+1] = Yspring_kill_e;
2620 Next[y][x] = Xblank;
2621 Next[y][x+1] = Xspring_e;
2622 play_element_sound(x, y, SAMPLE_slurp, Xalien);
2623 score += lev.slurp_score;
2628 Cave[y][x+1] = XbumperB;
2629 Next[y][x] = Xspring_w;
2630 play_element_sound(x, y, SAMPLE_spring, Xspring);
2634 Cave[y][x] = Xspring;
2635 Next[y][x] = Xspring;
2636 play_element_sound(x, y, SAMPLE_spring, Xspring);
2640 /* --------------------------------------------------------------------- */
2643 switch (Cave[y+1][x])
2653 Cave[y][x] = Yspring_sB;
2654 if (Cave[y][x+1] == Xblank)
2655 Cave[y][x+1] = Yacid_splash_eB;
2656 if (Cave[y][x-1] == Xblank)
2657 Cave[y][x-1] = Yacid_splash_wB;
2658 Next[y][x] = Xblank;
2659 play_sound(x, y, SAMPLE_acid);
2663 case Yacid_splash_eB:
2664 case Yacid_splash_wB:
2665 Cave[y][x] = Yspring_sB;
2666 Cave[y+1][x] = Yspring_s;
2667 Next[y][x] = Xblank;
2668 Next[y+1][x] = Xspring_fall;
2672 Cave[y+1][x] = XbumperB;
2675 switch (Cave[y][x-1])
2685 Cave[y][x] = Yspring_wB;
2686 if (Cave[y-1][x] == Xblank)
2687 Cave[y-1][x] = Yacid_splash_eB;
2688 if (Cave[y-1][x-2] == Xblank)
2689 Cave[y-1][x-2] = Yacid_splash_wB;
2690 Next[y][x] = Xblank;
2691 play_sound(x, y, SAMPLE_acid);
2695 case Yacid_splash_eB:
2696 case Yacid_splash_wB:
2701 Cave[y][x] = Yspring_wB;
2702 Cave[y][x-1] = Yspring_w;
2703 Next[y][x] = Xblank;
2704 Next[y][x-1] = Xspring_w;
2713 Cave[y][x] = Yspring_kill_wB;
2714 Cave[y][x-1] = Yspring_kill_w;
2715 Next[y][x] = Xblank;
2716 Next[y][x-1] = Xspring_w;
2717 play_element_sound(x, y, SAMPLE_slurp, Xalien);
2718 score += lev.slurp_score;
2723 Cave[y][x-1] = XbumperB;
2724 Next[y][x] = Xspring_e;
2725 play_element_sound(x, y, SAMPLE_spring, Xspring);
2729 Cave[y][x] = Xspring;
2730 Next[y][x] = Xspring;
2731 play_element_sound(x, y, SAMPLE_spring, Xspring);
2735 /* --------------------------------------------------------------------- */
2738 switch (Cave[y+1][x])
2748 Cave[y][x] = Yspring_sB;
2749 if (Cave[y][x+1] == Xblank)
2750 Cave[y][x+1] = Yacid_splash_eB;
2751 if (Cave[y][x-1] == Xblank)
2752 Cave[y][x-1] = Yacid_splash_wB;
2753 Next[y][x] = Xblank;
2754 play_sound(x, y, SAMPLE_acid);
2758 case Yacid_splash_eB:
2759 case Yacid_splash_wB:
2761 Cave[y][x] = Yspring_sB;
2762 Cave[y+1][x] = Yspring_s;
2763 Next[y][x] = Xblank;
2764 Next[y+1][x] = Xspring_fall;
2769 Cave[y+1][x] = Ybomb_eat;
2770 Next[y+1][x] = Znormal;
2771 Boom[y][x-1] = Xblank;
2772 Boom[y][x] = Xblank;
2773 Boom[y][x+1] = Xblank;
2774 Boom[y+1][x-1] = Xblank;
2775 Boom[y+1][x] = Xblank;
2776 Boom[y+1][x+1] = Xblank;
2777 Boom[y+2][x-1] = Xblank;
2778 Boom[y+2][x] = Xblank;
2779 Boom[y+2][x+1] = Xblank;
2781 play_element_sound(x, y, SAMPLE_boom, element);
2793 Cave[y][x] = Yspring_sB;
2794 Cave[y+1][x] = Ybug_spring;
2795 Next[y+1][x] = Znormal;
2796 Boom[y][x-1] = Xemerald;
2797 Boom[y][x] = Xemerald;
2798 Boom[y][x+1] = Xemerald;
2799 Boom[y+1][x-1] = Xemerald;
2800 Boom[y+1][x] = Xdiamond;
2801 Boom[y+1][x+1] = Xemerald;
2802 Boom[y+2][x-1] = Xemerald;
2803 Boom[y+2][x] = Xemerald;
2804 Boom[y+2][x+1] = Xemerald;
2806 play_element_sound(x, y, SAMPLE_boom, element);
2808 score += lev.bug_score;
2819 Cave[y][x] = Yspring_sB;
2820 Cave[y+1][x] = Ytank_spring;
2821 Next[y+1][x] = Znormal;
2822 Boom[y][x-1] = Xblank;
2823 Boom[y][x] = Xblank;
2824 Boom[y][x+1] = Xblank;
2825 Boom[y+1][x-1] = Xblank;
2826 Boom[y+1][x] = Xblank;
2827 Boom[y+1][x+1] = Xblank;
2828 Boom[y+2][x-1] = Xblank;
2829 Boom[y+2][x] = Xblank;
2830 Boom[y+2][x+1] = Xblank;
2832 play_element_sound(x, y, SAMPLE_boom, element);
2834 score += lev.tank_score;
2841 Cave[y][x] = Yspring_sB;
2842 Cave[y+1][x] = Yeater_spring;
2843 Next[y+1][x] = Znormal;
2844 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
2845 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
2846 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
2847 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
2848 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
2849 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
2850 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
2851 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
2852 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
2854 play_element_sound(x, y, SAMPLE_boom, element);
2856 lev.eater_pos = (lev.eater_pos + 1) & 7;
2857 score += lev.eater_score;
2862 Cave[y][x] = Yspring_sB;
2863 Cave[y+1][x] = Yalien_spring;
2864 Next[y+1][x] = Znormal;
2865 Boom[y][x-1] = Xblank;
2866 Boom[y][x] = Xblank;
2867 Boom[y][x+1] = Xblank;
2868 Boom[y+1][x-1] = Xblank;
2869 Boom[y+1][x] = Xblank;
2870 Boom[y+1][x+1] = Xblank;
2871 Boom[y+2][x-1] = Xblank;
2872 Boom[y+2][x] = Xblank;
2873 Boom[y+2][x+1] = Xblank;
2875 play_element_sound(x, y, SAMPLE_boom, element);
2877 score += lev.alien_score;
2881 Cave[y][x] = Xspring;
2882 Next[y][x] = Xspring;
2883 play_element_sound(x, y, SAMPLE_spring, Xspring);
2887 /* --------------------------------------------------------------------- */
2890 if (Cave[y][x+1] == Xdiamond)
2892 Cave[y][x+1] = Ydiamond_eat;
2893 Next[y][x+1] = Xblank;
2894 play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2898 if (Cave[y+1][x] == Xdiamond)
2900 Cave[y+1][x] = Ydiamond_eat;
2901 Next[y+1][x] = Xblank;
2902 play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2906 if (Cave[y][x-1] == Xdiamond)
2908 Cave[y][x-1] = Ydiamond_eat;
2909 Next[y][x-1] = Xblank;
2910 play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2914 if (Cave[y-1][x] == Xdiamond)
2916 Cave[y-1][x] = Ydiamond_eat;
2917 Next[y-1][x] = Xblank;
2918 play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2922 switch (Cave[y-1][x])
2932 Cave[y][x] = Yeater_nB;
2933 if (Cave[y-2][x+1] == Xblank)
2934 Cave[y-2][x+1] = Yacid_splash_eB;
2935 if (Cave[y-2][x-1] == Xblank)
2936 Cave[y-2][x-1] = Yacid_splash_wB;
2937 Next[y][x] = Xblank;
2938 play_sound(x, y, SAMPLE_acid);
2942 case Yacid_splash_eB:
2943 case Yacid_splash_wB:
2947 Cave[y][x] = Yeater_nB;
2948 Cave[y-1][x] = Yeater_n;
2949 Next[y][x] = Xblank;
2950 Next[y-1][x] = Xeater_n;
2954 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
2955 play_sound(x, y, SAMPLE_eater);
2959 /* --------------------------------------------------------------------- */
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, Xdiamond);
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, Xdiamond);
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, Xdiamond);
2986 if (Cave[y][x+1] == Xdiamond)
2988 Cave[y][x+1] = Ydiamond_eat;
2989 Next[y][x+1] = Xblank;
2990 play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2994 switch (Cave[y][x+1])
3004 Cave[y][x] = Yeater_eB;
3005 if (Cave[y-1][x+2] == Xblank)
3006 Cave[y-1][x+2] = Yacid_splash_eB;
3007 if (Cave[y-1][x] == Xblank)
3008 Cave[y-1][x] = Yacid_splash_wB;
3009 Next[y][x] = Xblank;
3010 play_sound(x, y, SAMPLE_acid);
3014 case Yacid_splash_eB:
3015 case Yacid_splash_wB:
3019 Cave[y][x] = Yeater_eB;
3020 Cave[y][x+1] = Yeater_e;
3021 Next[y][x] = Xblank;
3022 Next[y][x+1] = Xeater_e;
3026 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3027 play_sound(x, y, SAMPLE_eater);
3031 /* --------------------------------------------------------------------- */
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, Xdiamond);
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, Xdiamond);
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, Xdiamond);
3058 if (Cave[y+1][x] == Xdiamond)
3060 Cave[y+1][x] = Ydiamond_eat;
3061 Next[y+1][x] = Xblank;
3062 play_element_sound(x, y, SAMPLE_eater, Xdiamond);
3066 switch (Cave[y+1][x])
3076 Cave[y][x] = Yeater_sB;
3077 if (Cave[y][x+1] == Xblank)
3078 Cave[y][x+1] = Yacid_splash_eB;
3079 if (Cave[y][x-1] == Xblank)
3080 Cave[y][x-1] = Yacid_splash_wB;
3081 Next[y][x] = Xblank;
3082 play_sound(x, y, SAMPLE_acid);
3086 case Yacid_splash_eB:
3087 case Yacid_splash_wB:
3091 Cave[y][x] = Yeater_sB;
3092 Cave[y+1][x] = Yeater_s;
3093 Next[y][x] = Xblank;
3094 Next[y+1][x] = Xeater_s;
3098 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
3099 play_sound(x, y, SAMPLE_eater);
3103 /* --------------------------------------------------------------------- */
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, Xdiamond);
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, Xdiamond);
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, Xdiamond);
3130 if (Cave[y][x-1] == Xdiamond)
3132 Cave[y][x-1] = Ydiamond_eat;
3133 Next[y][x-1] = Xblank;
3134 play_element_sound(x, y, SAMPLE_eater, Xdiamond);
3138 switch (Cave[y][x-1])
3148 Cave[y][x] = Yeater_wB;
3149 if (Cave[y-1][x] == Xblank)
3150 Cave[y-1][x] = Yacid_splash_eB;
3151 if (Cave[y-1][x-2] == Xblank)
3152 Cave[y-1][x-2] = Yacid_splash_wB;
3153 Next[y][x] = Xblank;
3154 play_sound(x, y, SAMPLE_acid);
3158 case Yacid_splash_eB:
3159 case Yacid_splash_wB:
3163 Cave[y][x] = Yeater_wB;
3164 Cave[y][x-1] = Yeater_w;
3165 Next[y][x] = Xblank;
3166 Next[y][x-1] = Xeater_w;
3170 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3171 play_sound(x, y, SAMPLE_eater);
3175 /* --------------------------------------------------------------------- */
3183 else if (ply1.alive && ply2.alive)
3185 if ((ply1.x > x ? ply1.x - x : x - ply1.x) +
3186 (ply1.y > y ? ply1.y - y : y - ply1.y) <
3187 (ply2.x > x ? ply2.x - x : x - ply2.x) +
3188 (ply2.y > y ? ply2.y - y : y - ply2.y))
3199 else if (ply1.alive)
3204 else if (ply2.alive)
3219 switch (Cave[y-1][x])
3229 Cave[y][x] = Yalien_nB;
3230 if (Cave[y-2][x+1] == Xblank)
3231 Cave[y-2][x+1] = Yacid_splash_eB;
3232 if (Cave[y-2][x-1] == Xblank)
3233 Cave[y-2][x-1] = Yacid_splash_wB;
3234 Next[y][x] = Xblank;
3235 play_sound(x, y, SAMPLE_acid);
3239 case Yacid_splash_eB:
3240 case Yacid_splash_wB:
3244 Cave[y][x] = Yalien_nB;
3245 Cave[y-1][x] = Yalien_n;
3246 Next[y][x] = Xblank;
3247 Next[y-1][x] = Xalien_pause;
3248 play_element_sound(x, y, SAMPLE_alien, Xalien);
3254 switch (Cave[y+1][x])
3264 Cave[y][x] = Yalien_sB;
3265 Next[y][x] = Xblank;
3266 if (Cave[y][x+1] == Xblank)
3267 Cave[y][x+1] = Yacid_splash_eB;
3268 if (Cave[y][x-1] == Xblank)
3269 Cave[y][x-1] = Yacid_splash_wB;
3270 play_sound(x, y, SAMPLE_acid);
3274 case Yacid_splash_eB:
3275 case Yacid_splash_wB:
3279 Cave[y][x] = Yalien_sB;
3280 Cave[y+1][x] = Yalien_s;
3281 Next[y][x] = Xblank;
3282 Next[y+1][x] = Xalien_pause;
3283 play_element_sound(x, y, SAMPLE_alien, Xalien);
3292 switch (Cave[y][x+1])
3302 Cave[y][x] = Yalien_eB;
3303 if (Cave[y-1][x+2] == Xblank)
3304 Cave[y-1][x+2] = Yacid_splash_eB;
3305 if (Cave[y-1][x] == Xblank)
3306 Cave[y-1][x] = Yacid_splash_wB;
3307 Next[y][x] = Xblank;
3308 play_sound(x, y, SAMPLE_acid);
3312 case Yacid_splash_eB:
3313 case Yacid_splash_wB:
3317 Cave[y][x] = Yalien_eB;
3318 Cave[y][x+1] = Yalien_e;
3319 Next[y][x] = Xblank;
3320 Next[y][x+1] = Xalien_pause;
3321 play_element_sound(x, y, SAMPLE_alien, Xalien);
3327 switch (Cave[y][x-1])
3337 Cave[y][x] = Yalien_wB;
3338 if (Cave[y-1][x] == Xblank)
3339 Cave[y-1][x] = Yacid_splash_eB;
3340 if (Cave[y-1][x-2] == Xblank)
3341 Cave[y-1][x-2] = Yacid_splash_wB;
3342 Next[y][x] = Xblank;
3343 play_sound(x, y, SAMPLE_acid);
3347 case Yacid_splash_eB:
3348 case Yacid_splash_wB:
3352 Cave[y][x] = Yalien_wB;
3353 Cave[y][x-1] = Yalien_w;
3354 Next[y][x] = Xblank;
3355 Next[y][x-1] = Xalien_pause;
3356 play_element_sound(x, y, SAMPLE_alien, Xalien);
3365 Next[y][x] = Xalien;
3368 /* --------------------------------------------------------------------- */
3371 switch (Cave[y+1][x])
3381 Cave[y][x] = Yemerald_sB;
3382 if (Cave[y][x+1] == Xblank)
3383 Cave[y][x+1] = Yacid_splash_eB;
3384 if (Cave[y][x-1] == Xblank)
3385 Cave[y][x-1] = Yacid_splash_wB;
3386 Next[y][x] = Xblank;
3387 play_sound(x, y, SAMPLE_acid);
3391 case Yacid_splash_eB:
3392 case Yacid_splash_wB:
3393 Cave[y][x] = Yemerald_sB;
3394 Cave[y+1][x] = Yemerald_s;
3395 Next[y][x] = Xblank;
3396 Next[y+1][x] = Xemerald_fall;
3415 case Xemerald_pause:
3417 case Xdiamond_pause:
3454 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3456 Cave[y][x] = Yemerald_eB;
3457 Cave[y][x+1] = Yemerald_e;
3458 Next[y][x] = Xblank;
3459 Next[y][x+1] = Xemerald_pause;
3463 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3465 Cave[y][x] = Yemerald_wB;
3466 Cave[y][x-1] = Yemerald_w;
3467 Next[y][x] = Xblank;
3468 Next[y][x-1] = Xemerald_pause;
3474 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3476 Cave[y][x] = Yemerald_wB;
3477 Cave[y][x-1] = Yemerald_w;
3478 Next[y][x] = Xblank;
3479 Next[y][x-1] = Xemerald_pause;
3483 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3485 Cave[y][x] = Yemerald_eB;
3486 Cave[y][x+1] = Yemerald_e;
3487 Next[y][x] = Xblank;
3488 Next[y][x+1] = Xemerald_pause;
3494 if (++lev.shine_cnt > 50)
3496 lev.shine_cnt = RANDOM & 7;
3497 Cave[y][x] = Xemerald_shine;
3503 /* --------------------------------------------------------------------- */
3505 case Xemerald_pause:
3506 switch (Cave[y+1][x])
3516 Cave[y][x] = Yemerald_sB;
3517 if (Cave[y][x+1] == Xblank)
3518 Cave[y][x+1] = Yacid_splash_eB;
3519 if (Cave[y][x-1] == Xblank)
3520 Cave[y][x-1] = Yacid_splash_wB;
3521 Next[y][x] = Xblank;
3522 play_sound(x, y, SAMPLE_acid);
3526 case Yacid_splash_eB:
3527 case Yacid_splash_wB:
3528 Cave[y][x] = Yemerald_sB;
3529 Cave[y+1][x] = Yemerald_s;
3530 Next[y][x] = Xblank;
3531 Next[y+1][x] = Xemerald_fall;
3535 Cave[y][x] = Xemerald;
3536 Next[y][x] = Xemerald;
3540 /* --------------------------------------------------------------------- */
3543 switch (Cave[y+1][x])
3553 Cave[y][x] = Yemerald_sB;
3554 if (Cave[y][x+1] == Xblank)
3555 Cave[y][x+1] = Yacid_splash_eB;
3556 if (Cave[y][x-1] == Xblank)
3557 Cave[y][x-1] = Yacid_splash_wB;
3558 Next[y][x] = Xblank;
3559 play_sound(x, y, SAMPLE_acid);
3563 case Yacid_splash_eB:
3564 case Yacid_splash_wB:
3566 Cave[y][x] = Yemerald_sB;
3567 Cave[y+1][x] = Yemerald_s;
3568 Next[y][x] = Xblank;
3569 Next[y+1][x] = Xemerald_fall;
3573 if (lev.wonderwall_time)
3575 lev.wonderwall_state = 1;
3576 Cave[y][x] = Yemerald_sB;
3577 if (tab_blank[Cave[y+2][x]])
3579 Cave[y+2][x] = Ydiamond_s;
3580 Next[y+2][x] = Xdiamond_fall;
3583 Next[y][x] = Xblank;
3584 play_element_sound(x, y, SAMPLE_wonderfall, Xemerald);
3589 Cave[y][x] = Xemerald;
3590 Next[y][x] = Xemerald;
3591 play_element_sound(x, y, SAMPLE_diamond, Xemerald);
3595 /* --------------------------------------------------------------------- */
3598 switch (Cave[y+1][x])
3608 Cave[y][x] = Ydiamond_sB;
3609 if (Cave[y][x+1] == Xblank)
3610 Cave[y][x+1] = Yacid_splash_eB;
3611 if (Cave[y][x-1] == Xblank)
3612 Cave[y][x-1] = Yacid_splash_wB;
3613 Next[y][x] = Xblank;
3614 play_sound(x, y, SAMPLE_acid);
3618 case Yacid_splash_eB:
3619 case Yacid_splash_wB:
3620 Cave[y][x] = Ydiamond_sB;
3621 Cave[y+1][x] = Ydiamond_s;
3622 Next[y][x] = Xblank;
3623 Next[y+1][x] = Xdiamond_fall;
3642 case Xemerald_pause:
3644 case Xdiamond_pause:
3681 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3683 Cave[y][x] = Ydiamond_eB;
3684 Cave[y][x+1] = Ydiamond_e;
3685 Next[y][x] = Xblank;
3686 Next[y][x+1] = Xdiamond_pause;
3690 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3692 Cave[y][x] = Ydiamond_wB;
3693 Cave[y][x-1] = Ydiamond_w;
3694 Next[y][x] = Xblank;
3695 Next[y][x-1] = Xdiamond_pause;
3701 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3703 Cave[y][x] = Ydiamond_wB;
3704 Cave[y][x-1] = Ydiamond_w;
3705 Next[y][x] = Xblank;
3706 Next[y][x-1] = Xdiamond_pause;
3710 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3712 Cave[y][x] = Ydiamond_eB;
3713 Cave[y][x+1] = Ydiamond_e;
3714 Next[y][x] = Xblank;
3715 Next[y][x+1] = Xdiamond_pause;
3721 if (++lev.shine_cnt > 50)
3723 lev.shine_cnt = RANDOM & 7;
3724 Cave[y][x] = Xdiamond_shine;
3730 /* --------------------------------------------------------------------- */
3732 case Xdiamond_pause:
3733 switch (Cave[y+1][x])
3743 Cave[y][x] = Ydiamond_sB;
3744 if (Cave[y][x+1] == Xblank)
3745 Cave[y][x+1] = Yacid_splash_eB;
3746 if (Cave[y][x-1] == Xblank)
3747 Cave[y][x-1] = Yacid_splash_wB;
3748 Next[y][x] = Xblank;
3749 play_sound(x, y, SAMPLE_acid);
3753 case Yacid_splash_eB:
3754 case Yacid_splash_wB:
3755 Cave[y][x] = Ydiamond_sB;
3756 Cave[y+1][x] = Ydiamond_s;
3757 Next[y][x] = Xblank;
3758 Next[y+1][x] = Xdiamond_fall;
3762 Cave[y][x] = Xdiamond;
3763 Next[y][x] = Xdiamond;
3767 /* --------------------------------------------------------------------- */
3770 switch (Cave[y+1][x])
3780 Cave[y][x] = Ydiamond_sB;
3781 if (Cave[y][x+1] == Xblank)
3782 Cave[y][x+1] = Yacid_splash_eB;
3783 if (Cave[y][x-1] == Xblank)
3784 Cave[y][x-1] = Yacid_splash_wB;
3785 Next[y][x] = Xblank;
3786 play_sound(x, y, SAMPLE_acid);
3790 case Yacid_splash_eB:
3791 case Yacid_splash_wB:
3793 Cave[y][x] = Ydiamond_sB;
3794 Cave[y+1][x] = Ydiamond_s;
3795 Next[y][x] = Xblank;
3796 Next[y+1][x] = Xdiamond_fall;
3800 if (lev.wonderwall_time)
3802 lev.wonderwall_state = 1;
3803 Cave[y][x] = Ydiamond_sB;
3804 if (tab_blank[Cave[y+2][x]])
3806 Cave[y+2][x] = Ystone_s;
3807 Next[y+2][x] = Xstone_fall;
3810 Next[y][x] = Xblank;
3811 play_element_sound(x, y, SAMPLE_wonderfall, Xdiamond);
3816 Cave[y][x] = Xdiamond;
3817 Next[y][x] = Xdiamond;
3818 play_element_sound(x, y, SAMPLE_diamond, Xdiamond);
3822 /* --------------------------------------------------------------------- */
3825 switch (Cave[y+1][x])
3835 Cave[y][x] = Ydrip_s1B;
3836 if (Cave[y][x+1] == Xblank)
3837 Cave[y][x+1] = Yacid_splash_eB;
3838 if (Cave[y][x-1] == Xblank)
3839 Cave[y][x-1] = Yacid_splash_wB;
3840 Next[y][x] = Xdrip_stretchB;
3841 play_sound(x, y, SAMPLE_acid);
3845 case Yacid_splash_eB:
3846 case Yacid_splash_wB:
3850 Cave[y][x] = Ydrip_s1B;
3851 Cave[y+1][x] = Ydrip_s1;
3852 Next[y][x] = Xdrip_stretchB;
3853 Next[y+1][x] = Xdrip_stretch;
3894 play_element_sound(x, y, SAMPLE_drip, Xdrip_fall);
3898 /* --------------------------------------------------------------------- */
3901 Cave[y][x] = Ydrip_s2;
3902 Next[y][x] = Xdrip_fall;
3905 case Xdrip_stretchB:
3906 Cave[y][x] = Ydrip_s2B;
3907 Next[y][x] = Xblank;
3911 Next[y][x] = Xdrip_fall;
3914 /* --------------------------------------------------------------------- */
3917 switch (Cave[y+1][x])
3927 Cave[y][x] = Ybomb_sB;
3928 if (Cave[y][x+1] == Xblank)
3929 Cave[y][x+1] = Yacid_splash_eB;
3930 if (Cave[y][x-1] == Xblank)
3931 Cave[y][x-1] = Yacid_splash_wB;
3932 Next[y][x] = Xblank;
3933 play_sound(x, y, SAMPLE_acid);
3937 case Yacid_splash_eB:
3938 case Yacid_splash_wB:
3939 Cave[y][x] = Ybomb_sB;
3940 Cave[y+1][x] = Ybomb_s;
3941 Next[y][x] = Xblank;
3942 Next[y+1][x] = Xbomb_fall;
3961 case Xemerald_pause:
3963 case Xdiamond_pause:
3991 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3993 Cave[y][x] = Ybomb_eB;
3994 Cave[y][x+1] = Ybomb_e;
3995 Next[y][x] = Xblank;
3996 Next[y][x+1] = Xbomb_pause;
4000 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
4002 Cave[y][x] = Ybomb_wB;
4003 Cave[y][x-1] = Ybomb_w;
4004 Next[y][x] = Xblank;
4005 Next[y][x-1] = Xbomb_pause;
4011 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
4013 Cave[y][x] = Ybomb_wB;
4014 Cave[y][x-1] = Ybomb_w;
4015 Next[y][x] = Xblank;
4016 Next[y][x-1] = Xbomb_pause;
4020 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
4022 Cave[y][x] = Ybomb_eB;
4023 Cave[y][x+1] = Ybomb_e;
4024 Next[y][x] = Xblank;
4025 Next[y][x+1] = Xbomb_pause;
4034 /* --------------------------------------------------------------------- */
4037 switch (Cave[y+1][x])
4047 Cave[y][x] = Ybomb_sB;
4048 if (Cave[y][x+1] == Xblank)
4049 Cave[y][x+1] = Yacid_splash_eB;
4050 if (Cave[y][x-1] == Xblank)
4051 Cave[y][x-1] = Yacid_splash_wB;
4052 Next[y][x] = Xblank;
4053 play_sound(x, y, SAMPLE_acid);
4057 case Yacid_splash_eB:
4058 case Yacid_splash_wB:
4059 Cave[y][x] = Ybomb_sB;
4060 Cave[y+1][x] = Ybomb_s;
4061 Next[y][x] = Xblank;
4062 Next[y+1][x] = Xbomb_fall;
4071 /* --------------------------------------------------------------------- */
4074 switch (Cave[y+1][x])
4084 Cave[y][x] = Ybomb_sB;
4085 if (Cave[y][x+1] == Xblank)
4086 Cave[y][x+1] = Yacid_splash_eB;
4087 if (Cave[y][x-1] == Xblank)
4088 Cave[y][x-1] = Yacid_splash_wB;
4089 Next[y][x] = Xblank;
4090 play_sound(x, y, SAMPLE_acid);
4094 case Yacid_splash_eB:
4095 case Yacid_splash_wB:
4096 Cave[y][x] = Ybomb_sB;
4097 Cave[y+1][x] = Ybomb_s;
4098 Next[y][x] = Xblank;
4099 Next[y+1][x] = Xbomb_fall;
4103 Cave[y][x] = Ybomb_eat;
4104 Next[y][x] = Znormal;
4105 Boom[y-1][x-1] = Xblank;
4106 Boom[y-1][x] = Xblank;
4107 Boom[y-1][x+1] = Xblank;
4108 Boom[y][x-1] = Xblank;
4109 Boom[y][x] = Xblank;
4110 Boom[y][x+1] = Xblank;
4111 Boom[y+1][x-1] = Xblank;
4112 Boom[y+1][x] = Xblank;
4113 Boom[y+1][x+1] = Xblank;
4115 play_element_sound(x, y, SAMPLE_boom, element);
4120 /* --------------------------------------------------------------------- */
4123 if (lev.wind_cnt == 0)
4126 switch (lev.wind_direction)
4129 switch (Cave[y-1][x])
4139 Cave[y][x] = Yballoon_nB;
4140 if (Cave[y-2][x+1] == Xblank)
4141 Cave[y-2][x+1] = Yacid_splash_eB;
4142 if (Cave[y-2][x-1] == Xblank)
4143 Cave[y-2][x-1] = Yacid_splash_wB;
4144 Next[y][x] = Xblank;
4145 play_sound(x, y, SAMPLE_acid);
4149 case Yacid_splash_eB:
4150 case Yacid_splash_wB:
4151 Cave[y][x] = Yballoon_nB;
4152 Cave[y-1][x] = Yballoon_n;
4153 Next[y][x] = Xblank;
4154 Next[y-1][x] = Xballoon;
4162 switch (Cave[y][x+1])
4172 Cave[y][x] = Yballoon_eB;
4173 if (Cave[y-1][x+2] == Xblank)
4174 Cave[y-1][x+2] = Yacid_splash_eB;
4175 if (Cave[y-1][x] == Xblank)
4176 Cave[y-1][x] = Yacid_splash_wB;
4177 Next[y][x] = Xblank;
4178 play_sound(x, y, SAMPLE_acid);
4182 case Yacid_splash_eB:
4183 case Yacid_splash_wB:
4184 Cave[y][x] = Yballoon_eB;
4185 Cave[y][x+1] = Yballoon_e;
4186 Next[y][x] = Xblank;
4187 Next[y][x+1] = Xballoon;
4195 switch (Cave[y+1][x])
4205 Cave[y][x] = Yballoon_sB;
4206 if (Cave[y][x+1] == Xblank)
4207 Cave[y][x+1] = Yacid_splash_eB;
4208 if (Cave[y][x-1] == Xblank)
4209 Cave[y][x-1] = Yacid_splash_wB;
4210 Next[y][x] = Xblank;
4211 play_sound(x, y, SAMPLE_acid);
4215 case Yacid_splash_eB:
4216 case Yacid_splash_wB:
4217 Cave[y][x] = Yballoon_sB;
4218 Cave[y+1][x] = Yballoon_s;
4219 Next[y][x] = Xblank;
4220 Next[y+1][x] = Xballoon;
4228 switch (Cave[y][x-1])
4238 Cave[y][x] = Yballoon_wB;
4239 if (Cave[y-1][x] == Xblank)
4240 Cave[y-1][x] = Yacid_splash_eB;
4241 if (Cave[y-1][x-2] == Xblank)
4242 Cave[y-1][x-2] = Yacid_splash_wB;
4243 Next[y][x] = Xblank;
4244 play_sound(x, y, SAMPLE_acid);
4248 case Yacid_splash_eB:
4249 case Yacid_splash_wB:
4250 Cave[y][x] = Yballoon_wB;
4251 Cave[y][x-1] = Yballoon_w;
4252 Next[y][x] = Xblank;
4253 Next[y][x-1] = Xballoon;
4261 /* --------------------------------------------------------------------- */
4264 Next[y][x] = Xacid_2;
4268 Next[y][x] = Xacid_3;
4272 Next[y][x] = Xacid_4;
4276 Next[y][x] = Xacid_5;
4280 Next[y][x] = Xacid_6;
4284 Next[y][x] = Xacid_7;
4288 Next[y][x] = Xacid_8;
4292 Next[y][x] = Xacid_1;
4295 /* --------------------------------------------------------------------- */
4298 if (lev.ball_state == 0)
4301 Cave[y][x] = Xball_1B;
4302 Next[y][x] = Xball_2;
4309 if (lev.ball_state == 0)
4312 Cave[y][x] = Xball_2B;
4313 Next[y][x] = Xball_1;
4321 play_element_sound(x, y, SAMPLE_ball, element);
4322 if (lev.ball_random)
4327 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4328 tab_blank[Cave[y-1][x-1]])
4330 Cave[y-1][x-1] = Yball_eat;
4331 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4336 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4337 tab_blank[Cave[y-1][x]])
4339 Cave[y-1][x] = Yball_eat;
4340 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4345 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4346 tab_blank[Cave[y-1][x+1]])
4348 Cave[y-1][x+1] = Yball_eat;
4349 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4354 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4355 tab_blank[Cave[y][x-1]])
4357 Cave[y][x-1] = Yball_eat;
4358 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4363 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4364 tab_blank[Cave[y][x+1]])
4366 Cave[y][x+1] = Yball_eat;
4367 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4372 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4373 tab_blank[Cave[y+1][x-1]])
4375 Cave[y+1][x-1] = Yball_eat;
4376 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4381 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4382 tab_blank[Cave[y+1][x]])
4384 Cave[y+1][x] = Yball_eat;
4385 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4390 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4391 tab_blank[Cave[y+1][x+1]])
4393 Cave[y+1][x+1] = Yball_eat;
4394 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4401 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4402 tab_blank[Cave[y-1][x-1]])
4404 Cave[y-1][x-1] = Yball_eat;
4405 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4408 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4409 tab_blank[Cave[y-1][x]])
4411 Cave[y-1][x] = Yball_eat;
4412 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4415 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4416 tab_blank[Cave[y-1][x+1]])
4418 Cave[y-1][x+1] = Yball_eat;
4419 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4422 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4423 tab_blank[Cave[y][x-1]])
4425 Cave[y][x-1] = Yball_eat;
4426 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4429 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4430 tab_blank[Cave[y][x+1]])
4432 Cave[y][x+1] = Yball_eat;
4433 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4436 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4437 tab_blank[Cave[y+1][x-1]])
4439 Cave[y+1][x-1] = Yball_eat;
4440 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4443 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4444 tab_blank[Cave[y+1][x]])
4446 Cave[y+1][x] = Yball_eat;
4447 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4450 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4451 tab_blank[Cave[y+1][x+1]])
4453 Cave[y+1][x+1] = Yball_eat;
4454 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4458 lev.ball_pos = (lev.ball_pos + 1) & 7;
4461 /* --------------------------------------------------------------------- */
4464 if (tab_blank[Cave[y-1][x]])
4466 Cave[y-1][x] = Ygrow_ns_eat;
4467 Next[y-1][x] = Xgrow_ns;
4468 play_element_sound(x, y, SAMPLE_grow, Xgrow_ns);
4471 if (tab_blank[Cave[y+1][x]])
4473 Cave[y+1][x] = Ygrow_ns_eat;
4474 Next[y+1][x] = Xgrow_ns;
4475 play_element_sound(x, y, SAMPLE_grow, Xgrow_ns);
4481 if (tab_blank[Cave[y][x+1]])
4483 Cave[y][x+1] = Ygrow_ew_eat;
4484 Next[y][x+1] = Xgrow_ew;
4485 play_element_sound(x, y, SAMPLE_grow, Xgrow_ew);
4488 if (tab_blank[Cave[y][x-1]])
4490 Cave[y][x-1] = Ygrow_ew_eat;
4491 Next[y][x-1] = Xgrow_ew;
4492 play_element_sound(x, y, SAMPLE_grow, Xgrow_ew);
4497 /* --------------------------------------------------------------------- */
4500 if (lev.wonderwall_time && lev.wonderwall_state)
4502 Cave[y][x] = XwonderwallB;
4503 play_element_sound(x, y, SAMPLE_wonder, Xwonderwall);
4508 /* --------------------------------------------------------------------- */
4511 if (lev.required > 0)
4517 Cave[y][x] = Xexit_1;
4518 Next[y][x] = Xexit_2;
4522 Cave[y][x] = Xexit_2;
4523 Next[y][x] = Xexit_3;
4527 Cave[y][x] = Xexit_3;
4528 Next[y][x] = Xexit_1;
4534 Next[y][x] = Xexit_2;
4538 Next[y][x] = Xexit_3;
4542 Next[y][x] = Xexit_1;
4545 /* --------------------------------------------------------------------- */
4548 play_element_sound(x, y, SAMPLE_tick, Xdynamite_1);
4549 Next[y][x] = Xdynamite_2;
4553 play_element_sound(x, y, SAMPLE_tick, Xdynamite_2);
4554 Next[y][x] = Xdynamite_3;
4558 play_element_sound(x, y, SAMPLE_tick, Xdynamite_3);
4559 Next[y][x] = Xdynamite_4;
4563 play_element_sound(x, y, SAMPLE_tick, Xdynamite_4);
4564 Next[y][x] = Zdynamite;
4565 Boom[y-1][x-1] = Xblank;
4566 Boom[y-1][x] = Xblank;
4567 Boom[y-1][x+1] = Xblank;
4568 Boom[y][x-1] = Xblank;
4569 Boom[y][x] = Xblank;
4570 Boom[y][x+1] = Xblank;
4571 Boom[y+1][x-1] = Xblank;
4572 Boom[y+1][x] = Xblank;
4573 Boom[y+1][x+1] = Xblank;
4576 /* --------------------------------------------------------------------- */
4579 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
4580 Cave[y][x] = XwheelB;
4583 /* --------------------------------------------------------------------- */
4587 Cave[y][x] = XswitchB;
4590 /* --------------------------------------------------------------------- */
4593 switch (Cave[y+1][x])
4603 Cave[y][x] = Xsand_stonesand_3;
4604 if (Cave[y][x+1] == Xblank)
4605 Cave[y][x+1] = Yacid_splash_eB;
4606 if (Cave[y][x-1] == Xblank)
4607 Cave[y][x-1] = Yacid_splash_wB;
4608 Next[y][x] = Xsand_stonesand_4;
4609 play_sound(x, y, SAMPLE_acid);
4613 case Yacid_splash_eB:
4614 case Yacid_splash_wB:
4615 Cave[y][x] = Xsand_stonesand_3;
4616 Cave[y+1][x] = Xsand_stoneout_1;
4617 Next[y][x] = Xsand_stonesand_4;
4618 Next[y+1][x] = Xsand_stoneout_2;
4622 Cave[y][x] = Xsand_stonesand_1;
4623 Cave[y+1][x] = Xsand_sandstone_1;
4624 Next[y][x] = Xsand_stonesand_2;
4625 Next[y+1][x] = Xsand_sandstone_2;
4632 case Xsand_stonein_1:
4633 Next[y][x] = Xsand_stonein_2;
4636 case Xsand_stonein_2:
4637 Next[y][x] = Xsand_stonein_3;
4640 case Xsand_stonein_3:
4641 Next[y][x] = Xsand_stonein_4;
4644 case Xsand_stonein_4:
4645 Next[y][x] = Xblank;
4648 case Xsand_stonesand_1:
4649 Next[y][x] = Xsand_stonesand_2;
4652 case Xsand_stonesand_2:
4653 Next[y][x] = Xsand_stonesand_3;
4656 case Xsand_stonesand_3:
4657 Next[y][x] = Xsand_stonesand_4;
4660 case Xsand_stonesand_4:
4664 case Xsand_stoneout_1:
4665 Next[y][x] = Xsand_stoneout_2;
4668 case Xsand_stoneout_2:
4669 Next[y][x] = Xstone_fall;
4672 case Xsand_sandstone_1:
4673 Next[y][x] = Xsand_sandstone_2;
4676 case Xsand_sandstone_2:
4677 Next[y][x] = Xsand_sandstone_3;
4680 case Xsand_sandstone_3:
4681 Next[y][x] = Xsand_sandstone_4;
4684 case Xsand_sandstone_4:
4685 Next[y][x] = Xsand_stone;
4688 /* --------------------------------------------------------------------- */
4692 Cave[y][x] = XdripperB;
4695 /* --------------------------------------------------------------------- */
4699 Cave[y][x] = Xfake_blankB;
4702 /* --------------------------------------------------------------------- */
4705 if (lev.magnify_cnt)
4706 Cave[y][x] = Xfake_grassB;
4709 /* --------------------------------------------------------------------- */
4712 if (lev.magnify_cnt)
4713 Cave[y][x] = Xdoor_1;
4717 if (lev.magnify_cnt)
4718 Cave[y][x] = Xdoor_2;
4722 if (lev.magnify_cnt)
4723 Cave[y][x] = Xdoor_3;
4727 if (lev.magnify_cnt)
4728 Cave[y][x] = Xdoor_4;
4732 if (lev.magnify_cnt)
4733 Cave[y][x] = Xdoor_5;
4737 if (lev.magnify_cnt)
4738 Cave[y][x] = Xdoor_6;
4742 if (lev.magnify_cnt)
4743 Cave[y][x] = Xdoor_7;
4747 if (lev.magnify_cnt)
4748 Cave[y][x] = Xdoor_8;
4751 /* --------------------------------------------------------------------- */
4755 Next[y][x] = Znormal;
4756 Boom[y-1][x-1] = Xemerald;
4757 Boom[y-1][x] = Xemerald;
4758 Boom[y-1][x+1] = Xemerald;
4759 Boom[y][x-1] = Xemerald;
4760 Boom[y][x] = Xdiamond;
4761 Boom[y][x+1] = Xemerald;
4762 Boom[y+1][x-1] = Xemerald;
4763 Boom[y+1][x] = Xemerald;
4764 Boom[y+1][x+1] = Xemerald;
4766 play_element_sound(x, y, SAMPLE_boom, element);
4774 Next[y][x] = Znormal;
4775 Boom[y-1][x-1] = Xblank;
4776 Boom[y-1][x] = Xblank;
4777 Boom[y-1][x+1] = Xblank;
4778 Boom[y][x-1] = Xblank;
4779 Boom[y][x] = Xblank;
4780 Boom[y][x+1] = Xblank;
4781 Boom[y+1][x-1] = Xblank;
4782 Boom[y+1][x] = Xblank;
4783 Boom[y+1][x+1] = Xblank;
4785 play_element_sound(x, y, SAMPLE_boom, element);
4791 play_element_sound(x, y, SAMPLE_boom, Xandroid);
4794 Next[y][x] = Xboom_2;
4796 play_sound(x, y, SAMPLE_boom);
4801 Next[y][x] = Boom[y][x];
4804 /* --------------------------------------------------------------------- */
4807 if (++y < HEIGHT - 1)
4810 cave_cache = Cave[y];
4823 if (ply1.alive || ply2.alive)
4824 lev.score += score; /* only get a score if someone is alive */
4831 /* triple buffering */