d8f7913ce534e5efba868acf402f11338ea0ba8e
[rocksndiamonds.git] / src / game_em / synchro_2.c
1 /* second part of synchro.
2  *
3  * game logic for monsters.
4  *
5  * one giant switch statement to process everything.
6  *
7  * this whole thing is a major bottleneck. the compiler must use registers.
8  * compilers suck.
9  */
10
11 #include "display.h"
12 #include "tile.h"
13 #include "level.h"
14 #include "sample.h"
15
16
17 #define RANDOM (random = random << 31 | random >> 1)
18
19 void synchro_2(void)
20 {
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;
26
27   unsigned int temp = 0;        /* initialized to make compilers happy */
28   unsigned int dx; /* only needed to find closest player */
29   unsigned int dy;
30   int element;
31
32  loop:
33
34   element = cave_cache[++x];
35
36   switch (element)
37   {
38     default:
39       goto loop;
40
41     /* --------------------------------------------------------------------- */
42
43 #ifdef BAD_ROLL
44     case Xstone_force_e:
45       switch (Cave[y][x+1])
46       {
47         case ZBORDER:
48         case Znormal:
49         case Zdynamite:
50         case Xboom_bug:
51         case Xboom_bomb:
52         case Xboom_android:
53         case Xboom_1:
54         case Zplayer:
55           Cave[y][x] = Xstone;
56           Next[y][x] = Xstone;
57           goto loop;
58
59         default:
60           Cave[y][x] = Ystone_eB;
61           Cave[y][x+1] = Ystone_e;
62           Next[y][x] = Xblank;
63           Next[y][x+1] = Xstone_pause;
64           goto loop;
65       }
66
67     case Xstone_force_w:
68       switch (Cave[y][x-1])
69       {
70         case ZBORDER:
71         case Znormal:
72         case Zdynamite:
73         case Xboom_bug:
74         case Xboom_bomb:
75         case Xboom_android:
76         case Xboom_1:
77         case Zplayer:
78           Cave[y][x] = Xstone;
79           Next[y][x] = Xstone;
80           goto loop;
81
82         default:
83           Cave[y][x] = Ystone_wB;
84           Cave[y][x-1] = Ystone_w;
85           Next[y][x] = Xblank;
86           Next[y][x-1] = Xstone_pause;
87           goto loop;
88       }
89
90     case Xnut_force_e:
91       switch (Cave[y][x+1])
92       {
93         case ZBORDER:
94         case Znormal:
95         case Zdynamite:
96         case Xboom_bug:
97         case Xboom_bomb:
98         case Xboom_android:
99         case Xboom_1:
100         case Zplayer:
101           Cave[y][x] = Xnut;
102           Next[y][x] = Xnut;
103           goto loop;
104
105         default:
106           Cave[y][x] = Ynut_eB;
107           Cave[y][x+1] = Ynut_e;
108           Next[y][x] = Xblank;
109           Next[y][x+1] = Xnut_pause;
110           goto loop;
111       }
112
113     case Xnut_force_w:
114       switch (Cave[y][x-1])
115       {
116         case ZBORDER:
117         case Znormal:
118         case Zdynamite:
119         case Xboom_bug:
120         case Xboom_bomb:
121         case Xboom_android:
122         case Xboom_1:
123         case Zplayer:
124           Cave[y][x] = Xnut;
125           Next[y][x] = Xnut;
126           goto loop;
127
128         default:
129           Cave[y][x] = Ynut_wB;
130           Cave[y][x-1] = Ynut_w;
131           Next[y][x] = Xblank;
132           Next[y][x-1] = Xnut_pause;
133           goto loop;
134         }
135
136     case Xspring_force_e:
137       switch (Cave[y][x+1])
138       {
139         case ZBORDER:
140         case Znormal:
141         case Zdynamite:
142         case Xboom_bug:
143         case Xboom_bomb:
144         case Xboom_android:
145         case Xboom_1:
146         case Zplayer:
147           Cave[y][x] = Xspring;
148           Next[y][x] = Xspring;
149           goto loop;
150
151         default:
152           Cave[y][x] = Yspring_eB;
153           Cave[y][x+1] = Yspring_e;
154           Next[y][x] = Xblank;
155
156 #ifdef BAD_SPRING
157           Next[y][x+1] = Xspring_e;
158 #else
159           Next[y][x+1] = Xspring_pause;
160 #endif
161
162           goto loop;
163       }
164
165     case Xspring_force_w:
166       switch (Cave[y][x-1])
167       {
168         case ZBORDER:
169         case Znormal:
170         case Zdynamite:
171         case Xboom_bug:
172         case Xboom_bomb:
173         case Xboom_android:
174         case Xboom_1:
175         case Zplayer:
176           Cave[y][x] = Xspring;
177           Next[y][x] = Xspring;
178           goto loop;
179
180         default:
181           Cave[y][x] = Yspring_wB;
182           Cave[y][x-1] = Yspring_w;
183           Next[y][x] = Xblank;
184
185 #ifdef BAD_SPRING
186           Next[y][x-1] = Xspring_w;
187 #else   
188           Next[y][x-1] = Xspring_pause;
189 #endif  
190           goto loop;
191         }
192
193     case Xemerald_force_e:
194       switch (Cave[y][x+1])
195       {
196         case ZBORDER:
197         case Znormal:
198         case Zdynamite:
199         case Xboom_bug:
200         case Xboom_bomb:
201         case Xboom_android:
202         case Xboom_1:
203         case Zplayer:
204           Cave[y][x] = Xemerald;
205           Next[y][x] = Xemerald;
206           goto loop;
207
208         default:
209           Cave[y][x] = Yemerald_eB;
210           Cave[y][x+1] = Yemerald_e;
211           Next[y][x] = Xblank;
212           Next[y][x+1] = Xemerald_pause;
213           goto loop;
214         }
215
216     case Xemerald_force_w:
217       switch (Cave[y][x-1])
218       {
219         case ZBORDER:
220         case Znormal:
221         case Zdynamite:
222         case Xboom_bug:
223         case Xboom_bomb:
224         case Xboom_android:
225         case Xboom_1:
226         case Zplayer:
227           Cave[y][x] = Xemerald;
228           Next[y][x] = Xemerald;
229           goto loop;
230
231         default:
232           Cave[y][x] = Yemerald_wB;
233           Cave[y][x-1] = Yemerald_w;
234           Next[y][x] = Xblank;
235           Next[y][x-1] = Xemerald_pause;
236           goto loop;
237         }
238
239     case Xdiamond_force_e:
240       switch (Cave[y][x+1])
241       {
242         case ZBORDER:
243         case Znormal:
244         case Zdynamite:
245         case Xboom_bug:
246         case Xboom_bomb:
247         case Xboom_android:
248         case Xboom_1:
249         case Zplayer:
250           Cave[y][x] = Xdiamond;
251           Next[y][x] = Xdiamond;
252           goto loop;
253
254         default:
255           Cave[y][x] = Ydiamond_eB;
256           Cave[y][x+1] = Ydiamond_e;
257           Next[y][x] = Xblank;
258           Next[y][x+1] = Xdiamond_pause;
259           goto loop;
260         }
261
262     case Xdiamond_force_w:
263       switch (Cave[y][x-1])
264       {
265         case ZBORDER:
266         case Znormal:
267         case Zdynamite:
268         case Xboom_bug:
269         case Xboom_bomb:
270         case Xboom_android:
271         case Xboom_1:
272         case Zplayer:
273           Cave[y][x] = Xdiamond;
274           Next[y][x] = Xdiamond;
275           goto loop;
276
277         default:
278           Cave[y][x] = Ydiamond_wB;
279           Cave[y][x-1] = Ydiamond_w;
280           Next[y][x] = Xblank;
281           Next[y][x-1] = Xdiamond_pause;
282           goto loop;
283         }
284
285     case Xbomb_force_e:
286       switch (Cave[y][x+1])
287       {
288         case ZBORDER:
289         case Znormal:
290         case Zdynamite:
291         case Xboom_bug:
292         case Xboom_bomb:
293         case Xboom_android:
294         case Xboom_1:
295         case Zplayer:
296           Cave[y][x] = Xbomb;
297           Next[y][x] = Xbomb;
298           goto loop;
299
300         default:
301           Cave[y][x] = Ybomb_eB;
302           Cave[y][x+1] = Ybomb_e;
303           Next[y][x] = Xblank;
304           Next[y][x+1] = Xbomb_pause;
305           goto loop;
306         }
307
308     case Xbomb_force_w:
309       switch (Cave[y][x-1])
310       {
311         case ZBORDER:
312         case Znormal:
313         case Zdynamite:
314         case Xboom_bug:
315         case Xboom_bomb:
316         case Xboom_android:
317         case Xboom_1:
318         case Zplayer:
319           Cave[y][x] = Xbomb;
320           Next[y][x] = Xbomb;
321           goto loop;
322
323         default:
324           Cave[y][x] = Ybomb_wB;
325           Cave[y][x-1] = Ybomb_w;
326           Next[y][x] = Xblank;
327           Next[y][x-1] = Xbomb_pause;
328           goto loop;
329         }
330 #endif  /* BAD_ROLL */
331
332     /* --------------------------------------------------------------------- */
333
334     case Xstone:
335       switch (Cave[y+1][x])
336       {
337         case Xacid_1:
338         case Xacid_2:
339         case Xacid_3:
340         case Xacid_4:
341         case Xacid_5:
342         case Xacid_6:
343         case Xacid_7:
344         case Xacid_8:
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;
350           Next[y][x] = Xblank;
351           play_sound(x, y, SAMPLE_acid);
352           goto loop;
353
354         case Xblank:
355         case Yacid_splash_eB:
356         case Yacid_splash_wB:
357         case Xplant:
358         case Yplant:
359           Cave[y][x] = Ystone_sB;
360           Cave[y+1][x] = Ystone_s;
361           Next[y][x] = Xblank;
362           Next[y+1][x] = Xstone_fall;
363           goto loop;
364
365         case Xsand:
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;
370           goto loop;
371
372         case Xspring:
373         case Xspring_pause:
374         case Xspring_e:
375         case Xspring_w:
376         case Xandroid:
377         case Xandroid_1_n:
378         case Xandroid_2_n:
379         case Xandroid_1_e:
380         case Xandroid_2_e:
381         case Xandroid_1_s:
382         case Xandroid_2_s:
383         case Xandroid_1_w:
384         case Xandroid_2_w:
385         case Xstone:
386         case Xstone_pause:
387         case Xemerald:
388         case Xemerald_pause:
389         case Xdiamond:
390         case Xdiamond_pause:
391         case Xbomb:
392         case Xbomb_pause:
393         case Xballoon:
394         case Xacid_ne:
395         case Xacid_nw:
396         case Xball_1:
397         case Xball_2:
398         case Xnut:
399         case Xnut_pause:
400         case Xgrow_ns:
401         case Xgrow_ew:
402         case Xkey_1:
403         case Xkey_2:
404         case Xkey_3:
405         case Xkey_4:
406         case Xkey_5:
407         case Xkey_6:
408         case Xkey_7:
409         case Xkey_8:
410         case Xbumper:
411         case Xswitch:
412         case Xlenses:
413         case Xmagnify:
414         case Xround_wall_1:
415         case Xround_wall_2:
416         case Xround_wall_3:
417         case Xround_wall_4:
418           if (RANDOM & 1)
419           {
420             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
421             {
422               Cave[y][x] = Ystone_eB;
423               Cave[y][x+1] = Ystone_e;
424               Next[y][x] = Xblank;
425               Next[y][x+1] = Xstone_pause;
426               goto loop;
427             }
428
429             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
430             {
431               Cave[y][x] = Ystone_wB;
432               Cave[y][x-1] = Ystone_w;
433               Next[y][x] = Xblank;
434               Next[y][x-1] = Xstone_pause;
435               goto loop;
436             }
437           }
438           else
439           {
440             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
441             {
442               Cave[y][x] = Ystone_wB;
443               Cave[y][x-1] = Ystone_w;
444               Next[y][x] = Xblank;
445               Next[y][x-1] = Xstone_pause;
446               goto loop;
447             }
448
449             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
450             {
451               Cave[y][x] = Ystone_eB;
452               Cave[y][x+1] = Ystone_e;
453               Next[y][x] = Xblank;
454               Next[y][x+1] = Xstone_pause;
455               goto loop;
456             }
457           }
458
459         default:
460           goto loop;
461       }
462
463     /* --------------------------------------------------------------------- */
464
465     case Xstone_pause:
466       switch (Cave[y+1][x])
467       {
468         case Xacid_1:
469         case Xacid_2:
470         case Xacid_3:
471         case Xacid_4:
472         case Xacid_5:
473         case Xacid_6:
474         case Xacid_7:
475         case Xacid_8:
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;
481           Next[y][x] = Xblank;
482           play_sound(x, y, SAMPLE_acid);
483           goto loop;
484
485         case Xblank:
486         case Yacid_splash_eB:
487         case Yacid_splash_wB:
488           Cave[y][x] = Ystone_sB;
489           Cave[y+1][x] = Ystone_s;
490           Next[y][x] = Xblank;
491           Next[y+1][x] = Xstone_fall;
492           goto loop;
493
494         default:
495           Cave[y][x] = Xstone;
496           Next[y][x] = Xstone;
497           goto loop;
498         }
499
500     /* --------------------------------------------------------------------- */
501
502     case Xstone_fall:
503       switch (Cave[y+1][x])
504       {
505         case Xacid_1:
506         case Xacid_2:
507         case Xacid_3:
508         case Xacid_4:
509         case Xacid_5:
510         case Xacid_6:
511         case Xacid_7:
512         case Xacid_8:
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;
518           Next[y][x] = Xblank;
519           play_sound(x, y, SAMPLE_acid);
520           goto loop;
521
522         case Xblank:
523         case Yacid_splash_eB:
524         case Yacid_splash_wB:
525         case Zplayer:
526           Cave[y][x] = Ystone_sB;
527           Cave[y+1][x] = Ystone_s;
528           Next[y][x] = Xblank;
529           Next[y+1][x] = Xstone_fall;
530           goto loop;
531
532         case Xnut:
533         case Xnut_pause:
534           Cave[y+1][x] = Yemerald_stone;
535           Next[y][x] = Xstone;
536           Next[y+1][x] = Xemerald;
537           play_sound(x, y, SAMPLE_crack);
538           score += lev.nut_score;
539           goto loop;
540
541         case Xbug_n:
542         case Xbug_e:
543         case Xbug_s:
544         case Xbug_w:
545         case Xbug_gon:
546         case Xbug_goe:
547         case Xbug_gos:
548         case Xbug_gow:
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;
561           score += lev.bug_score;
562           goto loop;
563
564         case Xtank_n:
565         case Xtank_e:
566         case Xtank_s:
567         case Xtank_w:
568         case Xtank_gon:
569         case Xtank_goe:
570         case Xtank_gos:
571         case Xtank_gow:
572           Cave[y][x] = Ystone_sB;
573           Cave[y+1][x] = Ytank_stone;
574           Next[y+1][x] = Znormal;
575           Boom[y][x-1] = Xblank;
576           Boom[y][x] = Xblank;
577           Boom[y][x+1] = Xblank;
578           Boom[y+1][x-1] = Xblank;
579           Boom[y+1][x] = Xblank;
580           Boom[y+1][x+1] = Xblank;
581           Boom[y+2][x-1] = Xblank;
582           Boom[y+2][x] = Xblank;
583           Boom[y+2][x+1] = Xblank;
584           score += lev.tank_score;
585           goto loop;
586
587         case Xspring:
588           if (RANDOM & 1)
589           {
590             switch (Cave[y+1][x+1])
591             {
592               case Xblank:
593               case Yacid_splash_eB:
594               case Yacid_splash_wB:
595               case Xalien:
596               case Xalien_pause:
597                 Cave[y+1][x] = Xspring_e;
598                 break;
599
600               default:
601                 Cave[y+1][x] = Xspring_w;
602                 break;
603             }
604           }
605           else
606           {
607             switch (Cave[y+1][x-1])
608             {
609               case Xblank:
610               case Yacid_splash_eB:
611               case Yacid_splash_wB:
612               case Xalien:
613               case Xalien_pause:
614                 Cave[y+1][x] = Xspring_w;
615                 break;
616               default:
617                 Cave[y+1][x] = Xspring_e;
618                 break;
619             }
620           }
621
622           Next[y][x] = Xstone;
623           goto loop;
624
625         case Xeater_n:
626         case Xeater_e:
627         case Xeater_s:
628         case Xeater_w:
629           Cave[y][x] = Ystone_sB;
630           Cave[y+1][x] = Yeater_stone;
631           Next[y+1][x] = Znormal;
632           Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
633           Boom[y][x] = lev.eater_array[lev.eater_pos][1];
634           Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
635           Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
636           Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
637           Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
638           Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
639           Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
640           Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
641           lev.eater_pos = (lev.eater_pos + 1) & 7;
642           score += lev.eater_score;
643           goto loop;
644
645         case Xalien:
646         case Xalien_pause:
647           Cave[y][x] = Ystone_sB;
648           Cave[y+1][x] = Yalien_stone;
649           Next[y+1][x] = Znormal;
650           Boom[y][x-1] = Xblank;
651           Boom[y][x] = Xblank;
652           Boom[y][x+1] = Xblank;
653           Boom[y+1][x-1] = Xblank;
654           Boom[y+1][x] = Xblank;
655           Boom[y+1][x+1] = Xblank;
656           Boom[y+2][x-1] = Xblank;
657           Boom[y+2][x] = Xblank;
658           Boom[y+2][x+1] = Xblank;
659           score += lev.alien_score;
660           goto loop;
661
662         case Xdiamond:
663         case Xdiamond_pause:
664           switch (Cave[y+2][x])
665           {
666             case Xblank:
667             case Yacid_splash_eB:
668             case Yacid_splash_wB:
669             case Zplayer:
670             case Xbug_n:
671             case Xbug_e:
672             case Xbug_s:
673             case Xbug_w:
674             case Xbug_gon:
675             case Xbug_goe:
676             case Xbug_gos:
677             case Xbug_gow:
678             case Xtank_n:
679             case Xtank_e:
680             case Xtank_s:
681             case Xtank_w:
682             case Xtank_gon:
683             case Xtank_goe:
684             case Xtank_gos:
685             case Xtank_gow:
686             case Xspring_fall:
687             case Xandroid:
688             case Xandroid_1_n:
689             case Xandroid_2_n:
690             case Xandroid_1_e:
691             case Xandroid_2_e:
692             case Xandroid_1_s:
693             case Xandroid_2_s:
694             case Xandroid_1_w:
695             case Xandroid_2_w:
696             case Xstone_fall:
697             case Xemerald_fall:
698             case Xdiamond_fall:
699             case Xbomb_fall:
700             case Xacid_s:
701             case Xacid_1:
702             case Xacid_2:
703             case Xacid_3:
704             case Xacid_4:
705             case Xacid_5:
706             case Xacid_6:
707             case Xacid_7:
708             case Xacid_8:
709             case Xnut_fall:
710             case Xplant:
711             case Yplant:
712               Next[y][x] = Xstone;
713               play_sound(x, y, SAMPLE_stone);
714               goto loop;
715           }
716
717           Cave[y][x] = Ystone_sB;
718           Cave[y+1][x] = Ydiamond_stone;
719           Next[y][x] = Xblank;
720           Next[y+1][x] = Xstone_pause;
721           play_sound(x, y, SAMPLE_squash);
722           goto loop;
723
724         case Xbomb:
725         case Xbomb_pause:
726           Cave[y+1][x] = Ybomb_eat;
727           Next[y+1][x] = Znormal;
728           Boom[y][x-1] = Xblank;
729           Boom[y][x] = Xblank;
730           Boom[y][x+1] = Xblank;
731           Boom[y+1][x-1] = Xblank;
732           Boom[y+1][x] = Xblank;
733           Boom[y+1][x+1] = Xblank;
734           Boom[y+2][x-1] = Xblank;
735           Boom[y+2][x] = Xblank;
736           Boom[y+2][x+1] = Xblank;
737           goto loop;
738
739         case Xwonderwall:
740           if (lev.wonderwall_time)
741           {
742             lev.wonderwall_state = 1;
743             Cave[y][x] = Ystone_sB;
744
745             if (tab_blank[Cave[y+2][x]])
746             {
747               Cave[y+2][x] = Yemerald_s;
748               Next[y+2][x] = Xemerald_fall;
749             }
750
751             Next[y][x] = Xblank;
752             play_element_sound(x, y, SAMPLE_wonderfall, Xstone);
753             goto loop;
754           }
755
756         default:
757           Cave[y][x] = Xstone;
758           Next[y][x] = Xstone;
759           play_sound(x, y, SAMPLE_stone);
760           goto loop;
761       }
762
763     /* --------------------------------------------------------------------- */
764
765     case Xnut:
766       switch (Cave[y+1][x])
767       {
768         case Xacid_1:
769         case Xacid_2:
770         case Xacid_3:
771         case Xacid_4:
772         case Xacid_5:
773         case Xacid_6:
774         case Xacid_7:
775         case Xacid_8:
776           Cave[y][x] = Ynut_sB;
777           if (Cave[y][x+1] == Xblank)
778             Cave[y][x+1] = Yacid_splash_eB;
779           if (Cave[y][x-1] == Xblank)
780             Cave[y][x-1] = Yacid_splash_wB;
781           Next[y][x] = Xblank;
782           play_sound(x, y, SAMPLE_acid);
783           goto loop;
784
785         case Xblank:
786         case Yacid_splash_eB:
787         case Yacid_splash_wB:
788           Cave[y][x] = Ynut_sB;
789           Cave[y+1][x] = Ynut_s;
790           Next[y][x] = Xblank;
791           Next[y+1][x] = Xnut_fall;
792           goto loop;
793
794         case Xspring:
795         case Xspring_pause:
796         case Xspring_e:
797         case Xspring_w:
798         case Xandroid:
799         case Xandroid_1_n:
800         case Xandroid_2_n:
801         case Xandroid_1_e:
802         case Xandroid_2_e:
803         case Xandroid_1_s:
804         case Xandroid_2_s:
805         case Xandroid_1_w:
806         case Xandroid_2_w:
807         case Xstone:
808         case Xstone_pause:
809         case Xemerald:
810         case Xemerald_pause:
811         case Xdiamond:
812         case Xdiamond_pause:
813         case Xbomb:
814         case Xbomb_pause:
815         case Xballoon:
816         case Xacid_ne:
817         case Xacid_nw:
818         case Xball_1:
819         case Xball_2:
820         case Xnut:
821         case Xnut_pause:
822         case Xgrow_ns:
823         case Xgrow_ew:
824         case Xkey_1:
825         case Xkey_2:
826         case Xkey_3:
827         case Xkey_4:
828         case Xkey_5:
829         case Xkey_6:
830         case Xkey_7:
831         case Xkey_8:
832         case Xbumper:
833         case Xswitch:
834         case Xround_wall_1:
835         case Xround_wall_2:
836         case Xround_wall_3:
837         case Xround_wall_4:
838           if (RANDOM & 1)
839           {
840             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
841             {
842               Cave[y][x] = Ynut_eB;
843               Cave[y][x+1] = Ynut_e;
844               Next[y][x] = Xblank;
845               Next[y][x+1] = Xnut_pause;
846               goto loop;
847             }
848
849             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
850             {
851               Cave[y][x] = Ynut_wB;
852               Cave[y][x-1] = Ynut_w;
853               Next[y][x] = Xblank;
854               Next[y][x-1] = Xnut_pause;
855               goto loop;
856             }
857           }
858           else
859           {
860             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
861             {
862               Cave[y][x] = Ynut_wB;
863               Cave[y][x-1] = Ynut_w;
864               Next[y][x] = Xblank;
865               Next[y][x-1] = Xnut_pause;
866               goto loop;
867             }
868
869             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
870             {
871               Cave[y][x] = Ynut_eB;
872               Cave[y][x+1] = Ynut_e;
873               Next[y][x] = Xblank;
874               Next[y][x+1] = Xnut_pause;
875               goto loop;
876             }
877           }
878
879         default:
880           goto loop;
881       }
882
883     /* --------------------------------------------------------------------- */
884
885
886     case Xnut_pause:
887       switch (Cave[y+1][x])
888       {
889         case Xacid_1:
890         case Xacid_2:
891         case Xacid_3:
892         case Xacid_4:
893         case Xacid_5:
894         case Xacid_6:
895         case Xacid_7:
896         case Xacid_8:
897           Cave[y][x] = Ynut_sB;
898           if (Cave[y][x+1] == Xblank)
899             Cave[y][x+1] = Yacid_splash_eB;
900           if (Cave[y][x-1] == Xblank)
901             Cave[y][x-1] = Yacid_splash_wB;
902           Next[y][x] = Xblank;
903           play_sound(x, y, SAMPLE_acid);
904           goto loop;
905
906         case Xblank:
907         case Yacid_splash_eB:
908         case Yacid_splash_wB:
909           Cave[y][x] = Ynut_sB;
910           Cave[y+1][x] = Ynut_s;
911           Next[y][x] = Xblank;
912           Next[y+1][x] = Xnut_fall;
913           goto loop;
914
915         default:
916           Cave[y][x] = Xnut;
917           Next[y][x] = Xnut;
918           goto loop;
919       }
920
921     /* --------------------------------------------------------------------- */
922
923     case Xnut_fall:
924       switch (Cave[y+1][x])
925       {
926         case Xacid_1:
927         case Xacid_2:
928         case Xacid_3:
929         case Xacid_4:
930         case Xacid_5:
931         case Xacid_6:
932         case Xacid_7:
933         case Xacid_8:
934           Cave[y][x] = Ynut_sB;
935           if (Cave[y][x+1] == Xblank)
936             Cave[y][x+1] = Yacid_splash_eB;
937           if (Cave[y][x-1] == Xblank)
938             Cave[y][x-1] = Yacid_splash_wB;
939           Next[y][x] = Xblank;
940           play_sound(x, y, SAMPLE_acid);
941           goto loop;
942
943         case Xblank:
944         case Yacid_splash_eB:
945         case Yacid_splash_wB:
946         case Zplayer:
947           Cave[y][x] = Ynut_sB;
948           Cave[y+1][x] = Ynut_s;
949           Next[y][x] = Xblank;
950           Next[y+1][x] = Xnut_fall;
951           goto loop;
952
953         default:
954           Cave[y][x] = Xnut;
955           Next[y][x] = Xnut;
956           play_sound(x, y, SAMPLE_nut);
957           goto loop;
958       }
959
960     /* --------------------------------------------------------------------- */
961
962     case Xbug_n:
963       if (tab_amoeba[Cave[y-1][x]] ||
964           tab_amoeba[Cave[y][x+1]] ||
965           tab_amoeba[Cave[y+1][x]] ||
966           tab_amoeba[Cave[y][x-1]])
967         goto bug_boom;
968
969       switch (Cave[y][x+1])
970       {
971         case Xblank:
972         case Yacid_splash_eB:
973         case Yacid_splash_wB:
974         case Xplant:
975         case Yplant:
976         case Xacid_1:
977         case Xacid_2:
978         case Xacid_3:
979         case Xacid_4:
980         case Xacid_5:
981         case Xacid_6:
982         case Xacid_7:
983         case Xacid_8:
984         case Zplayer:
985           Cave[y][x] = Ybug_n_e;
986           Next[y][x] = Xbug_goe;
987           play_sound(x, y, SAMPLE_bug);
988           goto loop;
989
990         default:
991           goto bug_gon;
992         }
993
994     case Xbug_gon:
995       if (tab_amoeba[Cave[y-1][x]] ||
996           tab_amoeba[Cave[y][x+1]] ||
997           tab_amoeba[Cave[y+1][x]] ||
998           tab_amoeba[Cave[y][x-1]])
999         goto bug_boom;
1000
1001     bug_gon:
1002
1003       switch (Cave[y-1][x])
1004       {
1005         case Xacid_1:
1006         case Xacid_2:
1007         case Xacid_3:
1008         case Xacid_4:
1009         case Xacid_5:
1010         case Xacid_6:
1011         case Xacid_7:
1012         case Xacid_8:
1013           Cave[y][x] = Ybug_nB;
1014           if (Cave[y-2][x+1] == Xblank)
1015             Cave[y-2][x+1] = Yacid_splash_eB;
1016           if (Cave[y-2][x-1] == Xblank)
1017             Cave[y-2][x-1] = Yacid_splash_wB;
1018           Next[y][x] = Xblank;
1019           play_sound(x, y, SAMPLE_acid);
1020           goto loop;
1021
1022         case Xblank:
1023         case Yacid_splash_eB:
1024         case Yacid_splash_wB:
1025         case Xplant:
1026         case Yplant:
1027         case Zplayer:
1028           Cave[y][x] = Ybug_nB;
1029           Cave[y-1][x] = Ybug_n;
1030           Next[y][x] = Xblank;
1031           Next[y-1][x] = Xbug_n;
1032           play_sound(x, y, SAMPLE_bug);
1033           goto loop;
1034
1035         default:
1036           Cave[y][x] = Ybug_n_w;
1037           Next[y][x] = Xbug_gow;
1038           play_sound(x, y, SAMPLE_bug);
1039           goto loop;
1040       }
1041
1042     /* --------------------------------------------------------------------- */
1043
1044     case Xbug_e:
1045       if (tab_amoeba[Cave[y-1][x]] ||
1046           tab_amoeba[Cave[y][x+1]] ||
1047           tab_amoeba[Cave[y+1][x]] ||
1048           tab_amoeba[Cave[y][x-1]])
1049         goto bug_boom;
1050
1051       switch (Cave[y+1][x])
1052       {
1053         case Xblank:
1054         case Yacid_splash_eB:
1055         case Yacid_splash_wB:
1056         case Xplant:
1057         case Yplant:
1058         case Xacid_1:
1059         case Xacid_2:
1060         case Xacid_3:
1061         case Xacid_4:
1062         case Xacid_5:
1063         case Xacid_6:
1064         case Xacid_7:
1065         case Xacid_8:
1066         case Zplayer:
1067           Cave[y][x] = Ybug_e_s;
1068           Next[y][x] = Xbug_gos;
1069           play_sound(x, y, SAMPLE_bug);
1070           goto loop;
1071
1072         default:
1073           goto bug_goe;
1074       }
1075
1076     case Xbug_goe:
1077       if (tab_amoeba[Cave[y-1][x]] ||
1078           tab_amoeba[Cave[y][x+1]] ||
1079           tab_amoeba[Cave[y+1][x]] ||
1080           tab_amoeba[Cave[y][x-1]])
1081         goto bug_boom;
1082
1083     bug_goe:
1084
1085       switch (Cave[y][x+1])
1086       {
1087         case Xacid_1:
1088         case Xacid_2:
1089         case Xacid_3:
1090         case Xacid_4:
1091         case Xacid_5:
1092         case Xacid_6:
1093         case Xacid_7:
1094         case Xacid_8:
1095           Cave[y][x] = Ybug_eB;
1096           if (Cave[y-1][x+2] == Xblank)
1097             Cave[y-1][x+2] = Yacid_splash_eB;
1098           if (Cave[y-1][x] == Xblank)
1099             Cave[y-1][x] = Yacid_splash_wB;
1100           Next[y][x] = Xblank;
1101           play_sound(x, y, SAMPLE_acid);
1102           goto loop;
1103
1104         case Xblank:
1105         case Yacid_splash_eB:
1106         case Yacid_splash_wB:
1107         case Xplant:
1108         case Yplant:
1109         case Zplayer:
1110           Cave[y][x] = Ybug_eB;
1111           Cave[y][x+1] = Ybug_e;
1112           Next[y][x] = Xblank;
1113           Next[y][x+1] = Xbug_e;
1114           play_sound(x, y, SAMPLE_bug);
1115           goto loop;
1116
1117         default:
1118           Cave[y][x] = Ybug_e_n;
1119           Next[y][x] = Xbug_gon;
1120           play_sound(x, y, SAMPLE_bug);
1121           goto loop;
1122       }
1123
1124     /* --------------------------------------------------------------------- */
1125
1126     case Xbug_s:
1127       if (tab_amoeba[Cave[y-1][x]] ||
1128           tab_amoeba[Cave[y][x+1]] ||
1129           tab_amoeba[Cave[y+1][x]] ||
1130           tab_amoeba[Cave[y][x-1]])
1131         goto bug_boom;
1132
1133       switch (Cave[y][x-1])
1134       {
1135         case Xblank:
1136         case Yacid_splash_eB:
1137         case Yacid_splash_wB:
1138         case Xplant:
1139         case Yplant:
1140         case Xacid_1:
1141         case Xacid_2:
1142         case Xacid_3:
1143         case Xacid_4:
1144         case Xacid_5:
1145         case Xacid_6:
1146         case Xacid_7:
1147         case Xacid_8:
1148         case Zplayer:
1149           Cave[y][x] = Ybug_s_w;
1150           Next[y][x] = Xbug_gow;
1151           play_sound(x, y, SAMPLE_bug);
1152           goto loop;
1153
1154         default:
1155           goto bug_gos;
1156       }
1157
1158     case Xbug_gos:
1159       if (tab_amoeba[Cave[y-1][x]] ||
1160           tab_amoeba[Cave[y][x+1]] ||
1161           tab_amoeba[Cave[y+1][x]] ||
1162           tab_amoeba[Cave[y][x-1]])
1163         goto bug_boom;
1164
1165     bug_gos:
1166
1167       switch (Cave[y+1][x])
1168       {
1169         case Xacid_1:
1170         case Xacid_2:
1171         case Xacid_3:
1172         case Xacid_4:
1173         case Xacid_5:
1174         case Xacid_6:
1175         case Xacid_7:
1176         case Xacid_8:
1177           Cave[y][x] = Ybug_sB;
1178           if (Cave[y][x+1] == Xblank)
1179             Cave[y][x+1] = Yacid_splash_eB;
1180           if (Cave[y][x-1] == Xblank)
1181             Cave[y][x-1] = Yacid_splash_wB;
1182           Next[y][x] = Xblank;
1183           play_sound(x, y, SAMPLE_acid);
1184           goto loop;
1185
1186         case Xblank:
1187         case Yacid_splash_eB:
1188         case Yacid_splash_wB:
1189         case Xplant:
1190         case Yplant:
1191         case Zplayer:
1192           Cave[y][x] = Ybug_sB;
1193           Cave[y+1][x] = Ybug_s;
1194           Next[y][x] = Xblank;
1195           Next[y+1][x] = Xbug_s;
1196           play_sound(x, y, SAMPLE_bug);
1197           goto loop;
1198
1199         default:
1200           Cave[y][x] = Ybug_s_e;
1201           Next[y][x] = Xbug_goe;
1202           play_sound(x, y, SAMPLE_bug);
1203           goto loop;
1204       }
1205
1206     /* --------------------------------------------------------------------- */
1207
1208     case Xbug_w:
1209       if (tab_amoeba[Cave[y-1][x]] ||
1210           tab_amoeba[Cave[y][x+1]] ||
1211           tab_amoeba[Cave[y+1][x]] ||
1212           tab_amoeba[Cave[y][x-1]])
1213         goto bug_boom;
1214
1215       switch (Cave[y-1][x])
1216       {
1217         case Xblank:
1218         case Yacid_splash_eB:
1219         case Yacid_splash_wB:
1220         case Xplant:
1221         case Yplant:
1222         case Xacid_1:
1223         case Xacid_2:
1224         case Xacid_3:
1225         case Xacid_4:
1226         case Xacid_5:
1227         case Xacid_6:
1228         case Xacid_7:
1229         case Xacid_8:
1230         case Zplayer:
1231           Cave[y][x] = Ybug_w_n;
1232           Next[y][x] = Xbug_gon;
1233           play_sound(x, y, SAMPLE_bug);
1234           goto loop;
1235
1236         default:
1237           goto bug_gow;
1238       }
1239
1240     case Xbug_gow:
1241       if (tab_amoeba[Cave[y-1][x]] ||
1242           tab_amoeba[Cave[y][x+1]] ||
1243           tab_amoeba[Cave[y+1][x]] ||
1244           tab_amoeba[Cave[y][x-1]])
1245         goto bug_boom;
1246
1247     bug_gow:
1248
1249       switch (Cave[y][x-1])
1250       {
1251         case Xacid_1:
1252         case Xacid_2:
1253         case Xacid_3:
1254         case Xacid_4:
1255         case Xacid_5:
1256         case Xacid_6:
1257         case Xacid_7:
1258         case Xacid_8:
1259           Cave[y][x] = Ybug_wB;
1260           if (Cave[y-1][x] == Xblank)
1261             Cave[y-1][x] = Yacid_splash_eB;
1262           if (Cave[y-1][x-2] == Xblank)
1263             Cave[y-1][x-2] = Yacid_splash_wB;
1264           Next[y][x] = Xblank;
1265           play_sound(x, y, SAMPLE_acid);
1266           goto loop;
1267
1268         case Xblank:
1269         case Yacid_splash_eB:
1270         case Yacid_splash_wB:
1271         case Xplant:
1272         case Yplant:
1273         case Zplayer:
1274           Cave[y][x] = Ybug_wB;
1275           Cave[y][x-1] = Ybug_w;
1276           Next[y][x] = Xblank;
1277           Next[y][x-1] = Xbug_w;
1278           play_sound(x, y, SAMPLE_bug);
1279           goto loop;
1280
1281         default:
1282           Cave[y][x] = Ybug_w_s;
1283           Next[y][x] = Xbug_gos;
1284           play_sound(x, y, SAMPLE_bug);
1285           goto loop;
1286       }
1287
1288     /* --------------------------------------------------------------------- */
1289
1290     case Xtank_n:
1291       if (tab_amoeba[Cave[y-1][x]] ||
1292           tab_amoeba[Cave[y][x+1]] ||
1293           tab_amoeba[Cave[y+1][x]] ||
1294           tab_amoeba[Cave[y][x-1]])
1295         goto tank_boom;
1296
1297       switch (Cave[y][x-1])
1298       {
1299         case Xblank:
1300         case Yacid_splash_eB:
1301         case Yacid_splash_wB:
1302         case Xplant:
1303         case Yplant:
1304         case Xacid_1:
1305         case Xacid_2:
1306         case Xacid_3:
1307         case Xacid_4:
1308         case Xacid_5:
1309         case Xacid_6:
1310         case Xacid_7:
1311         case Xacid_8:
1312         case Zplayer:
1313           Cave[y][x] = Ytank_n_w;
1314           Next[y][x] = Xtank_gow;
1315           play_sound(x, y, SAMPLE_tank);
1316           goto loop;
1317
1318         default:
1319           goto tank_gon;
1320       }
1321
1322     case Xtank_gon:
1323       if (tab_amoeba[Cave[y-1][x]] ||
1324           tab_amoeba[Cave[y][x+1]] ||
1325           tab_amoeba[Cave[y+1][x]] ||
1326           tab_amoeba[Cave[y][x-1]])
1327         goto tank_boom;
1328
1329     tank_gon:
1330
1331       switch (Cave[y-1][x])
1332       {
1333         case Xacid_1:
1334         case Xacid_2:
1335         case Xacid_3:
1336         case Xacid_4:
1337         case Xacid_5:
1338         case Xacid_6:
1339         case Xacid_7:
1340         case Xacid_8:
1341           Cave[y][x] = Ytank_nB;
1342           if (Cave[y-2][x+1] == Xblank)
1343             Cave[y-2][x+1] = Yacid_splash_eB;
1344           if (Cave[y-2][x-1] == Xblank)
1345             Cave[y-2][x-1] = Yacid_splash_wB;
1346           Next[y][x] = Xblank;
1347           play_sound(x, y, SAMPLE_acid);
1348           goto loop;
1349
1350         case Xblank:
1351         case Yacid_splash_eB:
1352         case Yacid_splash_wB:
1353         case Xplant:
1354         case Yplant:
1355         case Zplayer:
1356           Cave[y][x] = Ytank_nB;
1357           Cave[y-1][x] = Ytank_n;
1358           Next[y][x] = Xblank;
1359           Next[y-1][x] = Xtank_n;
1360           play_sound(x, y, SAMPLE_tank);
1361           goto loop;
1362
1363         default:
1364           Cave[y][x] = Ytank_n_e;
1365           Next[y][x] = Xtank_goe;
1366           play_sound(x, y, SAMPLE_tank);
1367           goto loop;
1368       }
1369
1370     /* --------------------------------------------------------------------- */
1371
1372     case Xtank_e:
1373       if (tab_amoeba[Cave[y-1][x]] ||
1374           tab_amoeba[Cave[y][x+1]] ||
1375           tab_amoeba[Cave[y+1][x]] ||
1376           tab_amoeba[Cave[y][x-1]])
1377         goto tank_boom;
1378
1379       switch (Cave[y-1][x])
1380       {
1381         case Xblank:
1382         case Yacid_splash_eB:
1383         case Yacid_splash_wB:
1384         case Xplant:
1385         case Yplant:
1386         case Xacid_1:
1387         case Xacid_2:
1388         case Xacid_3:
1389         case Xacid_4:
1390         case Xacid_5:
1391         case Xacid_6:
1392         case Xacid_7:
1393         case Xacid_8:
1394         case Zplayer:
1395           Cave[y][x] = Ytank_e_n;
1396           Next[y][x] = Xtank_gon;
1397           play_sound(x, y, SAMPLE_tank);
1398           goto loop;
1399
1400         default:
1401           goto tank_goe;
1402       }
1403
1404     case Xtank_goe:
1405       if (tab_amoeba[Cave[y-1][x]] ||
1406           tab_amoeba[Cave[y][x+1]] ||
1407           tab_amoeba[Cave[y+1][x]] ||
1408           tab_amoeba[Cave[y][x-1]])
1409         goto tank_boom;
1410
1411     tank_goe:
1412
1413       switch (Cave[y][x+1])
1414       {
1415         case Xacid_1:
1416         case Xacid_2:
1417         case Xacid_3:
1418         case Xacid_4:
1419         case Xacid_5:
1420         case Xacid_6:
1421         case Xacid_7:
1422         case Xacid_8:
1423           Cave[y][x] = Ytank_eB;
1424           if (Cave[y-1][x+2] == Xblank)
1425             Cave[y-1][x+2] = Yacid_splash_eB;
1426           if (Cave[y-1][x] == Xblank)
1427             Cave[y-1][x] = Yacid_splash_wB;
1428           Next[y][x] = Xblank;
1429           play_sound(x, y, SAMPLE_acid);
1430           goto loop;
1431
1432         case Xblank:
1433         case Yacid_splash_eB:
1434         case Yacid_splash_wB:
1435         case Xplant:
1436         case Yplant:
1437         case Zplayer:
1438           Cave[y][x] = Ytank_eB;
1439           Cave[y][x+1] = Ytank_e;
1440           Next[y][x] = Xblank;
1441           Next[y][x+1] = Xtank_e;
1442           play_sound(x, y, SAMPLE_tank);
1443           goto loop;
1444
1445         default:
1446           Cave[y][x] = Ytank_e_s;
1447           Next[y][x] = Xtank_gos;
1448           play_sound(x, y, SAMPLE_tank);
1449           goto loop;
1450       }
1451
1452     /* --------------------------------------------------------------------- */
1453
1454     case Xtank_s:
1455       if (tab_amoeba[Cave[y-1][x]] ||
1456           tab_amoeba[Cave[y][x+1]] ||
1457           tab_amoeba[Cave[y+1][x]] ||
1458           tab_amoeba[Cave[y][x-1]])
1459         goto tank_boom;
1460
1461       switch (Cave[y][x+1])
1462       {
1463         case Xblank:
1464         case Yacid_splash_eB:
1465         case Yacid_splash_wB:
1466         case Xplant:
1467         case Yplant:
1468         case Xacid_1:
1469         case Xacid_2:
1470         case Xacid_3:
1471         case Xacid_4:
1472         case Xacid_5:
1473         case Xacid_6:
1474         case Xacid_7:
1475         case Xacid_8:
1476         case Zplayer:
1477           Cave[y][x] = Ytank_s_e;
1478           Next[y][x] = Xtank_goe;
1479           play_sound(x, y, SAMPLE_tank);
1480           goto loop;
1481
1482         default:
1483           goto tank_gos;
1484       }
1485
1486     case Xtank_gos:
1487       if (tab_amoeba[Cave[y-1][x]] ||
1488           tab_amoeba[Cave[y][x+1]] ||
1489           tab_amoeba[Cave[y+1][x]] ||
1490           tab_amoeba[Cave[y][x-1]])
1491         goto tank_boom;
1492
1493     tank_gos:
1494
1495       switch (Cave[y+1][x])
1496       {
1497         case Xacid_1:
1498         case Xacid_2:
1499         case Xacid_3:
1500         case Xacid_4:
1501         case Xacid_5:
1502         case Xacid_6:
1503         case Xacid_7:
1504         case Xacid_8:
1505           Cave[y][x] = Ytank_sB;
1506           if (Cave[y][x+1] == Xblank)
1507             Cave[y][x+1] = Yacid_splash_eB;
1508           if (Cave[y][x-1] == Xblank)
1509             Cave[y][x-1] = Yacid_splash_wB;
1510           Next[y][x] = Xblank;
1511           play_sound(x, y, SAMPLE_acid);
1512           goto loop;
1513
1514         case Xblank:
1515         case Yacid_splash_eB:
1516         case Yacid_splash_wB:
1517         case Xplant:
1518         case Yplant:
1519         case Zplayer:
1520           Cave[y][x] = Ytank_sB;
1521           Cave[y+1][x] = Ytank_s;
1522           Next[y][x] = Xblank;
1523           Next[y+1][x] = Xtank_s;
1524           play_sound(x, y, SAMPLE_tank);
1525           goto loop;
1526
1527         default:
1528           Cave[y][x] = Ytank_s_w;
1529           Next[y][x] = Xtank_gow;
1530           play_sound(x, y, SAMPLE_tank);
1531           goto loop;
1532       }
1533
1534     /* --------------------------------------------------------------------- */
1535
1536     case Xtank_w:
1537       if (tab_amoeba[Cave[y-1][x]] ||
1538           tab_amoeba[Cave[y][x+1]] ||
1539           tab_amoeba[Cave[y+1][x]] ||
1540           tab_amoeba[Cave[y][x-1]])
1541         goto tank_boom;
1542
1543       switch (Cave[y+1][x])
1544       {
1545         case Xblank:
1546         case Yacid_splash_eB:
1547         case Yacid_splash_wB:
1548         case Xplant:
1549         case Yplant:
1550         case Xacid_1:
1551         case Xacid_2:
1552         case Xacid_3:
1553         case Xacid_4:
1554         case Xacid_5:
1555         case Xacid_6:
1556         case Xacid_7:
1557         case Xacid_8:
1558         case Zplayer:
1559           Cave[y][x] = Ytank_w_s;
1560           Next[y][x] = Xtank_gos;
1561           play_sound(x, y, SAMPLE_tank);
1562           goto loop;
1563
1564         default:
1565           goto tank_gow;
1566       }
1567
1568     case Xtank_gow:
1569       if (tab_amoeba[Cave[y-1][x]] ||
1570           tab_amoeba[Cave[y][x+1]] ||
1571           tab_amoeba[Cave[y+1][x]] ||
1572           tab_amoeba[Cave[y][x-1]])
1573         goto tank_boom;
1574
1575     tank_gow:
1576
1577       switch (Cave[y][x-1])
1578       {
1579         case Xacid_1:
1580         case Xacid_2:
1581         case Xacid_3:
1582         case Xacid_4:
1583         case Xacid_5:
1584         case Xacid_6:
1585         case Xacid_7:
1586         case Xacid_8:
1587           Cave[y][x] = Ytank_wB;
1588           if (Cave[y-1][x] == Xblank)
1589             Cave[y-1][x] = Yacid_splash_eB;
1590           if (Cave[y-1][x-2] == Xblank)
1591             Cave[y-1][x-2] = Yacid_splash_wB;
1592           Next[y][x] = Xblank;
1593           play_sound(x, y, SAMPLE_acid);
1594           goto loop;
1595
1596         case Xblank:
1597         case Yacid_splash_eB:
1598         case Yacid_splash_wB:
1599         case Xplant:
1600         case Yplant:
1601         case Zplayer:
1602           Cave[y][x] = Ytank_wB;
1603           Cave[y][x-1] = Ytank_w;
1604           Next[y][x] = Xblank;
1605           Next[y][x-1] = Xtank_w;
1606           play_sound(x, y, SAMPLE_tank);
1607           goto loop;
1608
1609         default:
1610           Cave[y][x] = Ytank_w_n;
1611           Next[y][x] = Xtank_gon;
1612           play_sound(x, y, SAMPLE_tank);
1613           goto loop;
1614       }
1615
1616     /* --------------------------------------------------------------------- */
1617
1618     case Xandroid:
1619
1620     android:
1621
1622       if (lev.android_clone_cnt == 0)
1623       {
1624         if (Cave[y-1][x-1] != Xblank &&
1625             Cave[y-1][x]   != Xblank &&
1626             Cave[y-1][x+1] != Xblank &&
1627             Cave[y][x-1]   != Xblank &&
1628             Cave[y][x+1]   != Xblank &&
1629             Cave[y+1][x-1] != Xblank &&
1630             Cave[y+1][x]   != Xblank &&
1631             Cave[y+1][x+1] != Xblank)
1632           goto android_move;
1633
1634         switch (RANDOM & 7)
1635         {
1636           /* randomly find an object to clone */
1637
1638           case 0: /* S,NE,W,NW,SE,E,SW,N */
1639             temp= lev.android_array[Cave[y+1][x]];   if (temp != Xblank) break;
1640             temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1641             temp= lev.android_array[Cave[y][x-1]];   if (temp != Xblank) break;
1642             temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1643             temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1644             temp= lev.android_array[Cave[y][x+1]];   if (temp != Xblank) break;
1645             temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1646             temp= lev.android_array[Cave[y-1][x]];   if (temp != Xblank) break;
1647             goto android_move;
1648
1649           case 1: /* NW,SE,N,S,NE,SW,E,W */
1650             temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1651             temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1652             temp= lev.android_array[Cave[y-1][x]];   if (temp != Xblank) break;
1653             temp= lev.android_array[Cave[y+1][x]];   if (temp != Xblank) break;
1654             temp= lev.android_array[Cave[y-1][x+1]]; 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][x-1]];   if (temp != Xblank) break;
1658             goto android_move;
1659
1660           case 2: /* SW,E,S,W,N,NW,SE,NE */
1661             temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1662             temp= lev.android_array[Cave[y][x+1]];   if (temp != Xblank) break;
1663             temp= lev.android_array[Cave[y+1][x]];   if (temp != Xblank) break;
1664             temp= lev.android_array[Cave[y][x-1]];   if (temp != Xblank) break;
1665             temp= lev.android_array[Cave[y-1][x]];   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+1]]; if (temp != Xblank) break;
1668             temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1669             goto android_move;
1670
1671           case 3: /* N,SE,NE,E,W,S,NW,SW */
1672             temp= lev.android_array[Cave[y-1][x]];   if (temp != Xblank) break;
1673             temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1674             temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1675             temp= lev.android_array[Cave[y][x+1]];   if (temp != Xblank) break;
1676             temp= lev.android_array[Cave[y][x-1]];   if (temp != Xblank) break;
1677             temp= lev.android_array[Cave[y+1][x]];   if (temp != Xblank) break;
1678             temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1679             temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1680             goto android_move;
1681
1682           case 4: /* SE,NW,E,NE,SW,W,N,S */
1683             temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1684             temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1685             temp= lev.android_array[Cave[y][x+1]];   if (temp != Xblank) break;
1686             temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1687             temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1688             temp= lev.android_array[Cave[y][x-1]];   if (temp != Xblank) break;
1689             temp= lev.android_array[Cave[y-1][x]];   if (temp != Xblank) break;
1690             temp= lev.android_array[Cave[y+1][x]];   if (temp != Xblank) break;
1691             goto android_move;
1692
1693           case 5: /* NE,W,SE,SW,S,N,E,NW */
1694             temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1695             temp= lev.android_array[Cave[y][x-1]];   if (temp != Xblank) break;
1696             temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1697             temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1698             temp= lev.android_array[Cave[y+1][x]];   if (temp != Xblank) break;
1699             temp= lev.android_array[Cave[y-1][x]];   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             goto android_move;
1703
1704           case 6: /* E,N,SW,S,NW,NE,SE,W */
1705             temp= lev.android_array[Cave[y][x+1]];   if (temp != Xblank) break;
1706             temp= lev.android_array[Cave[y-1][x]];   if (temp != Xblank) break;
1707             temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1708             temp= lev.android_array[Cave[y+1][x]];   if (temp != Xblank) break;
1709             temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1710             temp= lev.android_array[Cave[y-1][x+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][x-1]];   if (temp != Xblank) break;
1713             goto android_move;
1714
1715           case 7: /* W,SW,NW,N,E,SE,NE,S */
1716             temp= lev.android_array[Cave[y][x-1]];   if (temp != Xblank) break;
1717             temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1718             temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1719             temp= lev.android_array[Cave[y-1][x]];   if (temp != Xblank) break;
1720             temp= lev.android_array[Cave[y][x+1]];   if (temp != Xblank) break;
1721             temp= lev.android_array[Cave[y+1][x+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             goto android_move;
1725         }
1726
1727         Next[y][x] = temp; /* the item we chose to clone */
1728         play_sound(x, y, SAMPLE_android);
1729
1730         switch (RANDOM & 7)
1731         {
1732           /* randomly find a direction to move */
1733
1734           case 0: /* S,NE,W,NW,SE,E,SW,N */
1735             if (Cave[y+1][x] == Xblank)   goto android_s;
1736             if (Cave[y-1][x+1] == Xblank) goto android_ne;
1737             if (Cave[y][x-1] == Xblank)   goto android_w;
1738             if (Cave[y-1][x-1] == Xblank) goto android_nw;
1739             if (Cave[y+1][x+1] == Xblank) goto android_se;
1740             if (Cave[y][x+1] == Xblank)   goto android_e;
1741             if (Cave[y+1][x-1] == Xblank) goto android_sw;
1742             if (Cave[y-1][x] == Xblank)   goto android_n;
1743             goto android_move;
1744
1745           case 1: /* NW,SE,N,S,NE,SW,E,W */
1746             if (Cave[y-1][x-1] == Xblank) goto android_nw;
1747             if (Cave[y+1][x+1] == Xblank) goto android_se;
1748             if (Cave[y-1][x] == Xblank)   goto android_n;
1749             if (Cave[y+1][x] == Xblank)   goto android_s;
1750             if (Cave[y-1][x+1] == Xblank) goto android_ne;
1751             if (Cave[y+1][x-1] == Xblank) goto android_sw;
1752             if (Cave[y][x+1] == Xblank)   goto android_e;
1753             if (Cave[y][x-1] == Xblank)   goto android_w;
1754             goto android_move;
1755
1756           case 2: /* SW,E,S,W,N,NW,SE,NE */
1757             if (Cave[y+1][x-1] == Xblank) goto android_sw;
1758             if (Cave[y][x+1] == Xblank)   goto android_e;
1759             if (Cave[y+1][x] == Xblank)   goto android_s;
1760             if (Cave[y][x-1] == Xblank)   goto android_w;
1761             if (Cave[y-1][x] == Xblank)   goto android_n;
1762             if (Cave[y-1][x-1] == Xblank) goto android_nw;
1763             if (Cave[y+1][x+1] == Xblank) goto android_se;
1764             if (Cave[y-1][x+1] == Xblank) goto android_ne;
1765             goto android_move;
1766
1767           case 3: /* N,SE,NE,E,W,S,NW,SW */
1768             if (Cave[y-1][x] == Xblank)   goto android_n;
1769             if (Cave[y+1][x+1] == Xblank) goto android_se;
1770             if (Cave[y-1][x+1] == Xblank) goto android_ne;
1771             if (Cave[y][x+1] == Xblank)   goto android_e;
1772             if (Cave[y][x-1] == Xblank)   goto android_w;
1773             if (Cave[y+1][x] == Xblank)   goto android_s;
1774             if (Cave[y-1][x-1] == Xblank) goto android_nw;
1775             if (Cave[y+1][x-1] == Xblank) goto android_sw;
1776             goto android_move;
1777
1778           case 4: /* SE,NW,E,NE,SW,W,N,S */
1779             if (Cave[y+1][x+1] == Xblank) goto android_se;
1780             if (Cave[y-1][x-1] == Xblank) goto android_nw;
1781             if (Cave[y][x+1] == Xblank)   goto android_e;
1782             if (Cave[y-1][x+1] == Xblank) goto android_ne;
1783             if (Cave[y+1][x-1] == Xblank) goto android_sw;
1784             if (Cave[y][x-1] == Xblank)   goto android_w;
1785             if (Cave[y-1][x] == Xblank)   goto android_n;
1786             if (Cave[y+1][x] == Xblank)   goto android_s;
1787             goto android_move;
1788
1789           case 5: /* NE,W,SE,SW,S,N,E,NW */
1790             if (Cave[y-1][x+1] == Xblank) goto android_ne;
1791             if (Cave[y][x-1] == Xblank)   goto android_w;
1792             if (Cave[y+1][x+1] == Xblank) goto android_se;
1793             if (Cave[y+1][x-1] == Xblank) goto android_sw;
1794             if (Cave[y+1][x] == Xblank)   goto android_s;
1795             if (Cave[y-1][x] == Xblank)   goto android_n;
1796             if (Cave[y][x+1] == Xblank)   goto android_e;
1797             if (Cave[y-1][x-1] == Xblank) goto android_nw;
1798             goto android_move;
1799
1800           case 6: /* E,N,SW,S,NW,NE,SE,W */
1801             if (Cave[y][x+1] == Xblank)   goto android_e;
1802             if (Cave[y-1][x] == Xblank)   goto android_n;
1803             if (Cave[y+1][x-1] == Xblank) goto android_sw;
1804             if (Cave[y+1][x] == Xblank)   goto android_s;
1805             if (Cave[y-1][x-1] == Xblank) goto android_nw;
1806             if (Cave[y-1][x+1] == Xblank) goto android_ne;
1807             if (Cave[y+1][x+1] == Xblank) goto android_se;
1808             if (Cave[y][x-1] == Xblank)   goto android_w;
1809             goto android_move;
1810
1811           case 7: /* W,SW,NW,N,E,SE,NE,S */
1812             if (Cave[y][x-1] == Xblank)   goto android_w;
1813             if (Cave[y+1][x-1] == Xblank) goto android_sw;
1814             if (Cave[y-1][x-1] == Xblank) goto android_nw;
1815             if (Cave[y-1][x] == Xblank)   goto android_n;
1816             if (Cave[y][x+1] == Xblank)   goto android_e;
1817             if (Cave[y+1][x+1] == Xblank) goto android_se;
1818             if (Cave[y-1][x+1] == Xblank) goto android_ne;
1819             if (Cave[y+1][x] == Xblank)   goto android_s;
1820             goto android_move;
1821         }
1822       }
1823
1824     android_move:
1825       if (lev.android_move_cnt == 0)
1826       {
1827         if (Cave[y-1][x-1] == Zplayer ||
1828             Cave[y-1][x]   == Zplayer ||
1829             Cave[y-1][x+1] == Zplayer ||
1830             Cave[y][x-1]   == Zplayer ||
1831             Cave[y][x+1]   == Zplayer ||
1832             Cave[y+1][x-1] == Zplayer ||
1833             Cave[y+1][x]   == Zplayer ||
1834             Cave[y+1][x+1] == Zplayer)
1835           goto android_still;
1836
1837         if (ply1.alive && ply2.alive)
1838         {
1839           if ((ply1.x > x ? ply1.x - x : x - ply1.x) +
1840               (ply1.y > y ? ply1.y - y : y - ply1.y) <
1841               (ply2.x > x ? ply2.x - x : x - ply2.x) +
1842               (ply2.y > y ? ply2.y - y : y - ply2.y))
1843           {
1844             dx = ply1.x;
1845             dy = ply1.y;
1846           }
1847           else
1848           {
1849             dx = ply2.x;
1850             dy = ply2.y;
1851           }
1852         }
1853         else if (ply1.alive)
1854         {
1855           dx = ply1.x;
1856           dy = ply1.y;
1857         }
1858         else if (ply2.alive)
1859         {
1860           dx = ply2.x;
1861           dy = ply2.y;
1862         }
1863         else
1864         {
1865           dx = 0;
1866           dy = 0;
1867         }
1868
1869         Next[y][x] = Xblank; /* assume we will move */
1870         temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1871
1872         if (RANDOM & 1)
1873         {
1874           switch (temp)
1875           {
1876             /* attempt clockwise move first if direct path is blocked */
1877
1878             case 0: /* north west */
1879               if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1880               if (tab_android_move[Cave[y-1][x]])   goto android_n;
1881               if (tab_android_move[Cave[y][x-1]])   goto android_w;
1882               break;
1883
1884             case 1: /* north */
1885               if (tab_android_move[Cave[y-1][x]])   goto android_n;
1886               if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1887               if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1888               break;
1889
1890             case 2: /* north east */
1891               if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1892               if (tab_android_move[Cave[y][x+1]])   goto android_e;
1893               if (tab_android_move[Cave[y-1][x]])   goto android_n;
1894               break;
1895
1896             case 3: /* west */
1897               if (tab_android_move[Cave[y][x-1]])   goto android_w;
1898               if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1899               if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1900               break;
1901
1902             case 4: /* nowhere */
1903               break;
1904
1905             case 5: /* east */
1906               if (tab_android_move[Cave[y][x+1]])   goto android_e;
1907               if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1908               if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1909               break;
1910
1911             case 6: /* south west */
1912               if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1913               if (tab_android_move[Cave[y][x-1]])   goto android_w;
1914               if (tab_android_move[Cave[y+1][x]])   goto android_s;
1915               break;
1916
1917             case 7: /* south */
1918               if (tab_android_move[Cave[y+1][x]])   goto android_s;
1919               if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1920               if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1921               break;
1922
1923             case 8: /* south east */
1924               if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1925               if (tab_android_move[Cave[y+1][x]])   goto android_s;
1926               if (tab_android_move[Cave[y][x+1]])   goto android_e;
1927               break;
1928           }
1929         }
1930         else
1931         {
1932           switch (temp)
1933           {
1934             /* attempt counterclockwise move first if direct path is blocked */
1935
1936             case 0: /* north west */
1937               if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1938               if (tab_android_move[Cave[y][x-1]])   goto android_w;
1939               if (tab_android_move[Cave[y-1][x]])   goto android_n;
1940               break;
1941
1942             case 1: /* north */
1943               if (tab_android_move[Cave[y-1][x]])   goto android_n;
1944               if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1945               if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1946               break;
1947
1948             case 2: /* north east */
1949               if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1950               if (tab_android_move[Cave[y-1][x]])   goto android_n;
1951               if (tab_android_move[Cave[y][x+1]])   goto android_e;
1952               break;
1953
1954             case 3: /* west */
1955               if (tab_android_move[Cave[y][x-1]])   goto android_w;
1956               if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1957               if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1958               break;
1959
1960             case 4: /* nowhere */
1961               break;
1962
1963             case 5: /* east */
1964               if (tab_android_move[Cave[y][x+1]])   goto android_e;
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_se;
1967               break;
1968
1969             case 6: /* south west */
1970               if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1971               if (tab_android_move[Cave[y+1][x]])   goto android_s;
1972               if (tab_android_move[Cave[y][x-1]])   goto android_w;
1973               break;
1974
1975             case 7: /* south */
1976               if (tab_android_move[Cave[y+1][x]])   goto android_s;
1977               if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1978               if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1979               break;
1980
1981             case 8: /* south east */
1982               if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1983               if (tab_android_move[Cave[y][x+1]])   goto android_e;
1984               if (tab_android_move[Cave[y+1][x]])   goto android_s;
1985               break;
1986           }
1987         }
1988       }
1989
1990     android_still:
1991
1992       Next[y][x] = Xandroid;
1993       goto loop;
1994
1995     android_n:
1996
1997       Cave[y][x] = Yandroid_nB;
1998       Cave[y-1][x] = Yandroid_n;
1999       Next[y-1][x] = Xandroid;
2000       play_sound(x, y, SAMPLE_tank);
2001       goto loop;
2002
2003     android_ne:
2004
2005       Cave[y][x] = Yandroid_neB;
2006       Cave[y-1][x+1] = Yandroid_ne;
2007       Next[y-1][x+1] = Xandroid;
2008       play_sound(x, y, SAMPLE_tank);
2009       goto loop;
2010
2011     android_e:
2012
2013       Cave[y][x] = Yandroid_eB;
2014       Cave[y][x+1] = Yandroid_e;
2015       Next[y][x+1] = Xandroid;
2016       play_sound(x, y, SAMPLE_tank);
2017       goto loop;
2018
2019     android_se:
2020
2021       Cave[y][x] = Yandroid_seB;
2022       Cave[y+1][x+1] = Yandroid_se;
2023       Next[y+1][x+1] = Xandroid;
2024       play_sound(x, y, SAMPLE_tank);
2025       goto loop;
2026
2027     android_s:
2028
2029       Cave[y][x] = Yandroid_sB;
2030       Cave[y+1][x] = Yandroid_s;
2031       Next[y+1][x] = Xandroid;
2032       play_sound(x, y, SAMPLE_tank);
2033       goto loop;
2034
2035     android_sw:
2036
2037       Cave[y][x] = Yandroid_swB;
2038       Cave[y+1][x-1] = Yandroid_sw;
2039       Next[y+1][x-1] = Xandroid;
2040       play_sound(x, y, SAMPLE_tank);
2041       goto loop;
2042
2043     android_w:
2044
2045       Cave[y][x] = Yandroid_wB;
2046       Cave[y][x-1] = Yandroid_w;
2047       Next[y][x-1] = Xandroid;
2048       play_sound(x, y, SAMPLE_tank);
2049       goto loop;
2050
2051     android_nw:
2052
2053       Cave[y][x] = Yandroid_nwB;
2054       Cave[y-1][x-1] = Yandroid_nw;
2055       Next[y-1][x-1] = Xandroid;
2056       play_sound(x, y, SAMPLE_tank);
2057       goto loop;
2058
2059     /* --------------------------------------------------------------------- */
2060
2061     case Xandroid_1_n:
2062       switch (Cave[y-1][x])
2063       {
2064         case Xacid_1:
2065         case Xacid_2:
2066         case Xacid_3:
2067         case Xacid_4:
2068         case Xacid_5:
2069         case Xacid_6:
2070         case Xacid_7:
2071         case Xacid_8:
2072           Cave[y][x] = Yandroid_nB;
2073           if (Cave[y-2][x+1] == Xblank)
2074             Cave[y-2][x+1] = Yacid_splash_eB;
2075           if (Cave[y-2][x-1] == Xblank)
2076             Cave[y-2][x-1] = Yacid_splash_wB;
2077           Next[y][x] = Xblank;
2078           play_sound(x, y, SAMPLE_acid);
2079           goto loop;
2080
2081         case Xblank:
2082         case Yacid_splash_eB:
2083         case Yacid_splash_wB:
2084           Cave[y][x] = Yandroid_nB;
2085           Cave[y-1][x] = Yandroid_n;
2086           Next[y][x] = Xblank;
2087           Next[y-1][x] = Xandroid;
2088           play_sound(x, y, SAMPLE_tank);
2089           goto loop;
2090
2091         default:
2092           goto android;
2093       }
2094
2095     case Xandroid_2_n:
2096       switch (Cave[y-1][x])
2097       {
2098         case Xacid_1:
2099         case Xacid_2:
2100         case Xacid_3:
2101         case Xacid_4:
2102         case Xacid_5:
2103         case Xacid_6:
2104         case Xacid_7:
2105         case Xacid_8:
2106           Cave[y][x] = Yandroid_nB;
2107           if (Cave[y-2][x+1] == Xblank)
2108             Cave[y-2][x+1] = Yacid_splash_eB;
2109           if (Cave[y-2][x-1] == Xblank)
2110             Cave[y-2][x-1] = Yacid_splash_wB;
2111           Next[y][x] = Xblank;
2112           play_sound(x, y, SAMPLE_acid);
2113           goto loop;
2114
2115         case Xblank:
2116         case Yacid_splash_eB:
2117         case Yacid_splash_wB:
2118           Cave[y][x] = Yandroid_nB;
2119           Cave[y-1][x] = Yandroid_n;
2120           Next[y][x] = Xblank;
2121           Next[y-1][x] = Xandroid_1_n;
2122           play_sound(x, y, SAMPLE_tank);
2123           goto loop;
2124
2125         default:
2126           goto android;
2127       }
2128
2129     /* --------------------------------------------------------------------- */
2130
2131     case Xandroid_1_e:
2132       switch (Cave[y][x+1])
2133       {
2134         case Xacid_1:
2135         case Xacid_2:
2136         case Xacid_3:
2137         case Xacid_4:
2138         case Xacid_5:
2139         case Xacid_6:
2140         case Xacid_7:
2141         case Xacid_8:
2142           Cave[y][x] = Yandroid_eB;
2143           if (Cave[y-1][x+2] == Xblank)
2144             Cave[y-1][x+2] = Yacid_splash_eB;
2145           if (Cave[y-1][x] == Xblank)
2146             Cave[y-1][x] = Yacid_splash_wB;
2147           Next[y][x] = Xblank;
2148           play_sound(x, y, SAMPLE_acid);
2149           goto loop;
2150
2151         case Xblank:
2152         case Yacid_splash_eB:
2153         case Yacid_splash_wB:
2154           Cave[y][x] = Yandroid_eB;
2155           Cave[y][x+1] = Yandroid_e;
2156           Next[y][x] = Xblank;
2157           Next[y][x+1] = Xandroid;
2158           play_sound(x, y, SAMPLE_tank);
2159           goto loop;
2160
2161         default:
2162           goto android;
2163       }
2164
2165     case Xandroid_2_e:
2166       switch (Cave[y][x+1])
2167       {
2168         case Xacid_1:
2169         case Xacid_2:
2170         case Xacid_3:
2171         case Xacid_4:
2172         case Xacid_5:
2173         case Xacid_6:
2174         case Xacid_7:
2175         case Xacid_8:
2176           Cave[y][x] = Yandroid_eB;
2177           if (Cave[y-1][x+2] == Xblank)
2178             Cave[y-1][x+2] = Yacid_splash_eB;
2179           if (Cave[y-1][x] == Xblank)
2180             Cave[y-1][x] = Yacid_splash_wB;
2181           Next[y][x] = Xblank;
2182           play_sound(x, y, SAMPLE_acid);
2183           goto loop;
2184
2185         case Xblank:
2186         case Yacid_splash_eB:
2187         case Yacid_splash_wB:
2188           Cave[y][x] = Yandroid_eB;
2189           Cave[y][x+1] = Yandroid_e;
2190           Next[y][x] = Xblank;
2191           Next[y][x+1] = Xandroid_1_e;
2192           play_sound(x, y, SAMPLE_tank);
2193           goto loop;
2194
2195         default:
2196           goto android;
2197       }
2198
2199     /* --------------------------------------------------------------------- */
2200
2201     case Xandroid_1_s:
2202       switch (Cave[y+1][x])
2203       {
2204         case Xacid_1:
2205         case Xacid_2:
2206         case Xacid_3:
2207         case Xacid_4:
2208         case Xacid_5:
2209         case Xacid_6:
2210         case Xacid_7:
2211         case Xacid_8:
2212           Cave[y][x] = Yandroid_sB;
2213           if (Cave[y][x+1] == Xblank)
2214             Cave[y][x+1] = Yacid_splash_eB;
2215           if (Cave[y][x-1] == Xblank)
2216             Cave[y][x-1] = Yacid_splash_wB;
2217           Next[y][x] = Xblank;
2218           play_sound(x, y, SAMPLE_acid);
2219           goto loop;
2220
2221         case Xblank:
2222         case Yacid_splash_eB:
2223         case Yacid_splash_wB:
2224           Cave[y][x] = Yandroid_sB;
2225           Cave[y+1][x] = Yandroid_s;
2226           Next[y][x] = Xblank;
2227           Next[y+1][x] = Xandroid;
2228           play_sound(x, y, SAMPLE_tank);
2229           goto loop;
2230
2231         default:
2232           goto android;
2233       }
2234
2235     case Xandroid_2_s:
2236       switch (Cave[y+1][x])
2237       {
2238         case Xacid_1:
2239         case Xacid_2:
2240         case Xacid_3:
2241         case Xacid_4:
2242         case Xacid_5:
2243         case Xacid_6:
2244         case Xacid_7:
2245         case Xacid_8:
2246           Cave[y][x] = Yandroid_sB;
2247           if (Cave[y][x+1] == Xblank)
2248             Cave[y][x+1] = Yacid_splash_eB;
2249           if (Cave[y][x-1] == Xblank)
2250             Cave[y][x-1] = Yacid_splash_wB;
2251           Next[y][x] = Xblank;
2252           play_sound(x, y, SAMPLE_acid);
2253           goto loop;
2254
2255         case Xblank:
2256         case Yacid_splash_eB:
2257         case Yacid_splash_wB:
2258           Cave[y][x] = Yandroid_sB;
2259           Cave[y+1][x] = Yandroid_s;
2260           Next[y][x] = Xblank;
2261           Next[y+1][x] = Xandroid_1_s;
2262           play_sound(x, y, SAMPLE_tank);
2263           goto loop;
2264
2265         default:
2266           goto android;
2267       }
2268
2269     /* --------------------------------------------------------------------- */
2270
2271     case Xandroid_1_w:
2272       switch (Cave[y][x-1])
2273       {
2274         case Xacid_1:
2275         case Xacid_2:
2276         case Xacid_3:
2277         case Xacid_4:
2278         case Xacid_5:
2279         case Xacid_6:
2280         case Xacid_7:
2281         case Xacid_8:
2282           Cave[y][x] = Yandroid_wB;
2283           if (Cave[y-1][x] == Xblank)
2284             Cave[y-1][x] = Yacid_splash_eB;
2285           if (Cave[y-1][x-2] == Xblank)
2286             Cave[y-1][x-2] = Yacid_splash_wB;
2287           Next[y][x] = Xblank;
2288           play_sound(x, y, SAMPLE_acid);
2289           goto loop;
2290
2291         case Xblank:
2292         case Yacid_splash_eB:
2293         case Yacid_splash_wB:
2294           Cave[y][x] = Yandroid_wB;
2295           Cave[y][x-1] = Yandroid_w;
2296           Next[y][x] = Xblank;
2297           Next[y][x-1] = Xandroid;
2298           play_sound(x, y, SAMPLE_tank);
2299           goto loop;
2300
2301         default:
2302           goto android;
2303       }
2304
2305     case Xandroid_2_w:
2306       switch (Cave[y][x-1])
2307       {
2308         case Xacid_1:
2309         case Xacid_2:
2310         case Xacid_3:
2311         case Xacid_4:
2312         case Xacid_5:
2313         case Xacid_6:
2314         case Xacid_7:
2315         case Xacid_8:
2316           Cave[y][x] = Yandroid_wB;
2317           if (Cave[y-1][x] == Xblank)
2318             Cave[y-1][x] = Yacid_splash_eB;
2319           if (Cave[y-1][x-2] == Xblank)
2320             Cave[y-1][x-2] = Yacid_splash_wB;
2321           Next[y][x] = Xblank;
2322           play_sound(x, y, SAMPLE_acid);
2323           goto loop;
2324
2325         case Xblank:
2326         case Yacid_splash_eB:
2327         case Yacid_splash_wB:
2328           Cave[y][x] = Yandroid_wB;
2329           Cave[y][x-1] = Yandroid_w;
2330           Next[y][x] = Xblank;
2331           Next[y][x-1] = Xandroid_1_w;
2332           play_sound(x, y, SAMPLE_tank);
2333           goto loop;
2334
2335         default:
2336           goto android;
2337       }
2338
2339     /* --------------------------------------------------------------------- */
2340
2341     case Xspring:
2342       switch (Cave[y+1][x])
2343       {
2344         case Xacid_1:
2345         case Xacid_2:
2346         case Xacid_3:
2347         case Xacid_4:
2348         case Xacid_5:
2349         case Xacid_6:
2350         case Xacid_7:
2351         case Xacid_8:
2352           Cave[y][x] = Yspring_sB;
2353           if (Cave[y][x+1] == Xblank)
2354             Cave[y][x+1] = Yacid_splash_eB;
2355           if (Cave[y][x-1] == Xblank)
2356             Cave[y][x-1] = Yacid_splash_wB;
2357           Next[y][x] = Xblank;
2358           play_sound(x, y, SAMPLE_acid);
2359           goto loop;
2360
2361         case Xblank:
2362         case Yacid_splash_eB:
2363         case Yacid_splash_wB:
2364         case Xplant:
2365         case Yplant:
2366           Cave[y][x] = Yspring_sB;
2367           Cave[y+1][x] = Yspring_s;
2368           Next[y][x] = Xblank;
2369           Next[y+1][x] = Xspring_fall;
2370           goto loop;
2371
2372         case Xspring:
2373         case Xspring_pause:
2374         case Xspring_e:
2375         case Xspring_w:
2376         case Xandroid:
2377         case Xandroid_1_n:
2378         case Xandroid_2_n:
2379         case Xandroid_1_e:
2380         case Xandroid_2_e:
2381         case Xandroid_1_s:
2382         case Xandroid_2_s:
2383         case Xandroid_1_w:
2384         case Xandroid_2_w:
2385         case Xstone:
2386         case Xstone_pause:
2387         case Xemerald:
2388         case Xemerald_pause:
2389         case Xdiamond:
2390         case Xdiamond_pause:
2391         case Xbomb:
2392         case Xbomb_pause:
2393         case Xballoon:
2394         case Xacid_ne:
2395         case Xacid_nw:
2396         case Xball_1:
2397         case Xball_2:
2398         case Xnut:
2399         case Xnut_pause:
2400         case Xgrow_ns:
2401         case Xgrow_ew:
2402         case Xkey_1:
2403         case Xkey_2:
2404         case Xkey_3:
2405         case Xkey_4:
2406         case Xkey_5:
2407         case Xkey_6:
2408         case Xkey_7:
2409         case Xkey_8:
2410         case Xbumper:
2411         case Xswitch:
2412         case Xround_wall_1:
2413         case Xround_wall_2:
2414         case Xround_wall_3:
2415         case Xround_wall_4:
2416           if (RANDOM & 1)
2417           {
2418             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2419             {
2420               Cave[y][x] = Yspring_eB;
2421               Cave[y][x+1] = Yspring_e;
2422               if (Cave[y+1][x] == Xbumper)
2423                 Cave[y+1][x] = XbumperB;
2424               Next[y][x] = Xblank;
2425
2426 #ifdef BAD_SPRING
2427               Next[y][x+1] = Xspring_e;
2428 #else   
2429               Next[y][x+1] = Xspring_pause;
2430 #endif
2431
2432               goto loop;
2433             }
2434
2435             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2436             {
2437               Cave[y][x] = Yspring_wB;
2438               Cave[y][x-1] = Yspring_w;
2439               if (Cave[y+1][x] == Xbumper)
2440                 Cave[y+1][x] = XbumperB;
2441               Next[y][x] = Xblank;
2442
2443 #ifdef BAD_SPRING
2444               Next[y][x-1] = Xspring_w;
2445 #else
2446               Next[y][x-1] = Xspring_pause;
2447 #endif
2448
2449               goto loop;
2450             }
2451           }
2452           else
2453           {
2454             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2455             {
2456               Cave[y][x] = Yspring_wB;
2457               Cave[y][x-1] = Yspring_w;
2458               if (Cave[y+1][x] == Xbumper)
2459                 Cave[y+1][x] = XbumperB;
2460               Next[y][x] = Xblank;
2461
2462 #ifdef BAD_SPRING
2463               Next[y][x-1] = Xspring_w;
2464 #else
2465               Next[y][x-1] = Xspring_pause;
2466 #endif
2467
2468               goto loop;
2469             }
2470
2471             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2472             {
2473               Cave[y][x] = Yspring_eB;
2474               Cave[y][x+1] = Yspring_e;
2475               if (Cave[y+1][x] == Xbumper)
2476                 Cave[y+1][x] = XbumperB;
2477               Next[y][x] = Xblank;
2478
2479 #ifdef BAD_SPRING
2480               Next[y][x+1] = Xspring_e;
2481 #else
2482               Next[y][x+1] = Xspring_pause;
2483 #endif
2484
2485               goto loop;
2486             }
2487           }
2488
2489         default:
2490           goto loop;
2491       }
2492
2493     /* --------------------------------------------------------------------- */
2494
2495     case Xspring_pause:
2496       switch (Cave[y+1][x])
2497       {
2498         case Xacid_1:
2499         case Xacid_2:
2500         case Xacid_3:
2501         case Xacid_4:
2502         case Xacid_5:
2503         case Xacid_6:
2504         case Xacid_7:
2505         case Xacid_8:
2506           Cave[y][x] = Yspring_sB;
2507           if (Cave[y][x+1] == Xblank)
2508             Cave[y][x+1] = Yacid_splash_eB;
2509           if (Cave[y][x-1] == Xblank)
2510             Cave[y][x-1] = Yacid_splash_wB;
2511           Next[y][x] = Xblank;
2512           play_sound(x, y, SAMPLE_acid);
2513           goto loop;
2514
2515         case Xblank:
2516         case Yacid_splash_eB:
2517         case Yacid_splash_wB:
2518           Cave[y][x] = Yspring_sB;
2519           Cave[y+1][x] = Yspring_s;
2520           Next[y][x] = Xblank;
2521           Next[y+1][x] = Xspring_fall;
2522           goto loop;
2523
2524         default:
2525           Cave[y][x] = Xspring;
2526           Next[y][x] = Xspring;
2527           goto loop;
2528       }
2529
2530     /* --------------------------------------------------------------------- */
2531
2532     case Xspring_e:
2533       switch (Cave[y+1][x])
2534       {
2535         case Xacid_1:
2536         case Xacid_2:
2537         case Xacid_3:
2538         case Xacid_4:
2539         case Xacid_5:
2540         case Xacid_6:
2541         case Xacid_7:
2542         case Xacid_8:
2543           Cave[y][x] = Yspring_sB;
2544           if (Cave[y][x+1] == Xblank)
2545             Cave[y][x+1] = Yacid_splash_eB;
2546           if (Cave[y][x-1] == Xblank)
2547             Cave[y][x-1] = Yacid_splash_wB;
2548           Next[y][x] = Xblank;
2549           play_sound(x, y, SAMPLE_acid);
2550           goto loop;
2551
2552         case Xblank:
2553         case Yacid_splash_eB:
2554         case Yacid_splash_wB:
2555           Cave[y][x] = Yspring_sB;
2556           Cave[y+1][x] = Yspring_s;
2557           Next[y][x] = Xblank;
2558           Next[y+1][x] = Xspring_fall;
2559           goto loop;
2560
2561         case Xbumper:
2562           Cave[y+1][x] = XbumperB;
2563       }
2564
2565       switch (Cave[y][x+1])
2566       {
2567         case Xacid_1:
2568         case Xacid_2:
2569         case Xacid_3:
2570         case Xacid_4:
2571         case Xacid_5:
2572         case Xacid_6:
2573         case Xacid_7:
2574         case Xacid_8:
2575           Cave[y][x] = Yspring_eB;
2576           if (Cave[y-1][x+2] == Xblank)
2577             Cave[y-1][x+2] = Yacid_splash_eB;
2578           if (Cave[y-1][x] == Xblank)
2579             Cave[y-1][x] = Yacid_splash_wB;
2580           Next[y][x] = Xblank;
2581           play_sound(x, y, SAMPLE_acid);
2582           goto loop;
2583
2584         case Xblank:
2585         case Yacid_splash_eB:
2586         case Yacid_splash_wB:
2587         case Yalien_nB:
2588         case Yalien_eB:
2589         case Yalien_sB:
2590         case Yalien_wB:
2591           Cave[y][x] = Yspring_eB;
2592           Cave[y][x+1] = Yspring_e;
2593           Next[y][x] = Xblank;
2594           Next[y][x+1] = Xspring_e;
2595           goto loop;
2596
2597         case Xalien:
2598         case Xalien_pause:
2599         case Yalien_n:
2600         case Yalien_e:
2601         case Yalien_s:
2602         case Yalien_w:
2603           Cave[y][x] = Yspring_kill_eB;
2604           Cave[y][x+1] = Yspring_kill_e;
2605           Next[y][x] = Xblank;
2606           Next[y][x+1] = Xspring_e;
2607           play_sound(x, y, SAMPLE_slurp);
2608           score += lev.slurp_score;
2609           goto loop;
2610
2611         case Xbumper:
2612         case XbumperB:
2613           Cave[y][x+1] = XbumperB;
2614           Next[y][x] = Xspring_w;
2615           play_sound(x, y, SAMPLE_spring);
2616           goto loop;
2617
2618         default:
2619           Cave[y][x] = Xspring;
2620           Next[y][x] = Xspring;
2621           play_sound(x, y, SAMPLE_spring);
2622           goto loop;
2623       }
2624
2625     /* --------------------------------------------------------------------- */
2626
2627     case Xspring_w:
2628       switch (Cave[y+1][x])
2629       {
2630         case Xacid_1:
2631         case Xacid_2:
2632         case Xacid_3:
2633         case Xacid_4:
2634         case Xacid_5:
2635         case Xacid_6:
2636         case Xacid_7:
2637         case Xacid_8:
2638           Cave[y][x] = Yspring_sB;
2639           if (Cave[y][x+1] == Xblank)
2640             Cave[y][x+1] = Yacid_splash_eB;
2641           if (Cave[y][x-1] == Xblank)
2642             Cave[y][x-1] = Yacid_splash_wB;
2643           Next[y][x] = Xblank;
2644           play_sound(x, y, SAMPLE_acid);
2645           goto loop;
2646
2647         case Xblank:
2648         case Yacid_splash_eB:
2649         case Yacid_splash_wB:
2650           Cave[y][x] = Yspring_sB;
2651           Cave[y+1][x] = Yspring_s;
2652           Next[y][x] = Xblank;
2653           Next[y+1][x] = Xspring_fall;
2654           goto loop;
2655
2656         case Xbumper:
2657           Cave[y+1][x] = XbumperB;
2658       }
2659
2660       switch (Cave[y][x-1])
2661       {
2662         case Xacid_1:
2663         case Xacid_2:
2664         case Xacid_3:
2665         case Xacid_4:
2666         case Xacid_5:
2667         case Xacid_6:
2668         case Xacid_7:
2669         case Xacid_8:
2670           Cave[y][x] = Yspring_wB;
2671           if (Cave[y-1][x] == Xblank)
2672             Cave[y-1][x] = Yacid_splash_eB;
2673           if (Cave[y-1][x-2] == Xblank)
2674             Cave[y-1][x-2] = Yacid_splash_wB;
2675           Next[y][x] = Xblank;
2676           play_sound(x, y, SAMPLE_acid);
2677           goto loop;
2678
2679         case Xblank:
2680         case Yacid_splash_eB:
2681         case Yacid_splash_wB:
2682         case Yalien_nB:
2683         case Yalien_eB:
2684         case Yalien_sB:
2685         case Yalien_wB:
2686           Cave[y][x] = Yspring_wB;
2687           Cave[y][x-1] = Yspring_w;
2688           Next[y][x] = Xblank;
2689           Next[y][x-1] = Xspring_w;
2690           goto loop;
2691
2692         case Xalien:
2693         case Xalien_pause:
2694         case Yalien_n:
2695         case Yalien_e:
2696         case Yalien_s:
2697         case Yalien_w:
2698           Cave[y][x] = Yspring_kill_wB;
2699           Cave[y][x-1] = Yspring_kill_w;
2700           Next[y][x] = Xblank;
2701           Next[y][x-1] = Xspring_w;
2702           play_sound(x, y, SAMPLE_slurp);
2703           score += lev.slurp_score;
2704           goto loop;
2705
2706         case Xbumper:
2707         case XbumperB:
2708           Cave[y][x-1] = XbumperB;
2709           Next[y][x] = Xspring_e;
2710           play_sound(x, y, SAMPLE_spring);
2711           goto loop;
2712
2713         default:
2714           Cave[y][x] = Xspring;
2715           Next[y][x] = Xspring;
2716           play_sound(x, y, SAMPLE_spring);
2717           goto loop;
2718       }
2719
2720     /* --------------------------------------------------------------------- */
2721
2722     case Xspring_fall:
2723       switch (Cave[y+1][x])
2724       {
2725         case Xacid_1:
2726         case Xacid_2:
2727         case Xacid_3:
2728         case Xacid_4:
2729         case Xacid_5:
2730         case Xacid_6:
2731         case Xacid_7:
2732         case Xacid_8:
2733           Cave[y][x] = Yspring_sB;
2734           if (Cave[y][x+1] == Xblank)
2735             Cave[y][x+1] = Yacid_splash_eB;
2736           if (Cave[y][x-1] == Xblank)
2737             Cave[y][x-1] = Yacid_splash_wB;
2738           Next[y][x] = Xblank;
2739           play_sound(x, y, SAMPLE_acid);
2740           goto loop;
2741
2742         case Xblank:
2743         case Yacid_splash_eB:
2744         case Yacid_splash_wB:
2745         case Zplayer:
2746           Cave[y][x] = Yspring_sB;
2747           Cave[y+1][x] = Yspring_s;
2748           Next[y][x] = Xblank;
2749           Next[y+1][x] = Xspring_fall;
2750           goto loop;
2751
2752         case Xbomb:
2753         case Xbomb_pause:
2754           Cave[y+1][x] = Ybomb_eat;
2755           Next[y+1][x] = Znormal;
2756           Boom[y][x-1] = Xblank;
2757           Boom[y][x] = Xblank;
2758           Boom[y][x+1] = Xblank;
2759           Boom[y+1][x-1] = Xblank;
2760           Boom[y+1][x] = Xblank;
2761           Boom[y+1][x+1] = Xblank;
2762           Boom[y+2][x-1] = Xblank;
2763           Boom[y+2][x] = Xblank;
2764           Boom[y+2][x+1] = Xblank;
2765           goto loop;
2766
2767         case Xbug_n:
2768         case Xbug_e:
2769         case Xbug_s:
2770         case Xbug_w:
2771         case Xbug_gon:
2772         case Xbug_goe:
2773         case Xbug_gos:
2774         case Xbug_gow:
2775           Cave[y][x] = Yspring_sB;
2776           Cave[y+1][x] = Ybug_spring;
2777           Next[y+1][x] = Znormal;
2778           Boom[y][x-1] = Xemerald;
2779           Boom[y][x] = Xemerald;
2780           Boom[y][x+1] = Xemerald;
2781           Boom[y+1][x-1] = Xemerald;
2782           Boom[y+1][x] = Xdiamond;
2783           Boom[y+1][x+1] = Xemerald;
2784           Boom[y+2][x-1] = Xemerald;
2785           Boom[y+2][x] = Xemerald;
2786           Boom[y+2][x+1] = Xemerald;
2787           score += lev.bug_score;
2788           goto loop;
2789
2790         case Xtank_n:
2791         case Xtank_e:
2792         case Xtank_s:
2793         case Xtank_w:
2794         case Xtank_gon:
2795         case Xtank_goe:
2796         case Xtank_gos:
2797         case Xtank_gow:
2798           Cave[y][x] = Yspring_sB;
2799           Cave[y+1][x] = Ytank_spring;
2800           Next[y+1][x] = Znormal;
2801           Boom[y][x-1] = Xblank;
2802           Boom[y][x] = Xblank;
2803           Boom[y][x+1] = Xblank;
2804           Boom[y+1][x-1] = Xblank;
2805           Boom[y+1][x] = Xblank;
2806           Boom[y+1][x+1] = Xblank;
2807           Boom[y+2][x-1] = Xblank;
2808           Boom[y+2][x] = Xblank;
2809           Boom[y+2][x+1] = Xblank;
2810           score += lev.tank_score;
2811           goto loop;
2812
2813         case Xeater_n:
2814         case Xeater_e:
2815         case Xeater_s:
2816         case Xeater_w:
2817           Cave[y][x] = Yspring_sB;
2818           Cave[y+1][x] = Yeater_spring;
2819           Next[y+1][x] = Znormal;
2820           Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
2821           Boom[y][x] = lev.eater_array[lev.eater_pos][1];
2822           Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
2823           Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
2824           Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
2825           Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
2826           Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
2827           Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
2828           Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
2829           lev.eater_pos = (lev.eater_pos + 1) & 7;
2830           score += lev.eater_score;
2831           goto loop;
2832
2833         case Xalien:
2834         case Xalien_pause:
2835           Cave[y][x] = Yspring_sB;
2836           Cave[y+1][x] = Yalien_spring;
2837           Next[y+1][x] = Znormal;
2838           Boom[y][x-1] = Xblank;
2839           Boom[y][x] = Xblank;
2840           Boom[y][x+1] = Xblank;
2841           Boom[y+1][x-1] = Xblank;
2842           Boom[y+1][x] = Xblank;
2843           Boom[y+1][x+1] = Xblank;
2844           Boom[y+2][x-1] = Xblank;
2845           Boom[y+2][x] = Xblank;
2846           Boom[y+2][x+1] = Xblank;
2847           score += lev.alien_score;
2848           goto loop;
2849
2850         default:
2851           Cave[y][x] = Xspring;
2852           Next[y][x] = Xspring;
2853           play_sound(x, y, SAMPLE_spring);
2854           goto loop;
2855       }
2856
2857     /* --------------------------------------------------------------------- */
2858
2859     case Xeater_n:
2860       if (Cave[y][x+1] == Xdiamond)
2861       {
2862         Cave[y][x+1] = Ydiamond_eat;
2863         Next[y][x+1] = Xblank;
2864         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2865         goto loop;
2866       }
2867
2868       if (Cave[y+1][x] == Xdiamond)
2869       {
2870         Cave[y+1][x] = Ydiamond_eat;
2871         Next[y+1][x] = Xblank;
2872         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2873         goto loop;
2874       }
2875
2876       if (Cave[y][x-1] == Xdiamond)
2877       {
2878         Cave[y][x-1] = Ydiamond_eat;
2879         Next[y][x-1] = Xblank;
2880         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2881         goto loop;
2882       }
2883
2884       if (Cave[y-1][x] == Xdiamond)
2885       {
2886         Cave[y-1][x] = Ydiamond_eat;
2887         Next[y-1][x] = Xblank;
2888         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2889         goto loop;
2890       }
2891
2892       switch (Cave[y-1][x])
2893       {
2894         case Xacid_1:
2895         case Xacid_2:
2896         case Xacid_3:
2897         case Xacid_4:
2898         case Xacid_5:
2899         case Xacid_6:
2900         case Xacid_7:
2901         case Xacid_8:
2902           Cave[y][x] = Yeater_nB;
2903           if (Cave[y-2][x+1] == Xblank)
2904             Cave[y-2][x+1] = Yacid_splash_eB;
2905           if (Cave[y-2][x-1] == Xblank)
2906             Cave[y-2][x-1] = Yacid_splash_wB;
2907           Next[y][x] = Xblank;
2908           play_sound(x, y, SAMPLE_acid);
2909           goto loop;
2910
2911         case Xblank:
2912         case Yacid_splash_eB:
2913         case Yacid_splash_wB:
2914         case Xplant:
2915         case Yplant:
2916         case Zplayer:
2917           Cave[y][x] = Yeater_nB;
2918           Cave[y-1][x] = Yeater_n;
2919           Next[y][x] = Xblank;
2920           Next[y-1][x] = Xeater_n;
2921           goto loop;
2922
2923         default:
2924           Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
2925           play_sound(x, y, SAMPLE_eater);
2926           goto loop;
2927       }
2928
2929     /* --------------------------------------------------------------------- */
2930
2931     case Xeater_e:
2932       if (Cave[y+1][x] == Xdiamond)
2933       {
2934         Cave[y+1][x] = Ydiamond_eat;
2935         Next[y+1][x] = Xblank;
2936         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2937         goto loop;
2938       }
2939
2940       if (Cave[y][x-1] == Xdiamond)
2941       {
2942         Cave[y][x-1] = Ydiamond_eat;
2943         Next[y][x-1] = Xblank;
2944         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2945         goto loop;
2946       }
2947
2948       if (Cave[y-1][x] == Xdiamond)
2949       {
2950         Cave[y-1][x] = Ydiamond_eat;
2951         Next[y-1][x] = Xblank;
2952         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2953         goto loop;
2954       }
2955
2956       if (Cave[y][x+1] == Xdiamond)
2957       {
2958         Cave[y][x+1] = Ydiamond_eat;
2959         Next[y][x+1] = Xblank;
2960         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
2961         goto loop;
2962       }
2963
2964       switch (Cave[y][x+1])
2965       {
2966         case Xacid_1:
2967         case Xacid_2:
2968         case Xacid_3:
2969         case Xacid_4:
2970         case Xacid_5:
2971         case Xacid_6:
2972         case Xacid_7:
2973         case Xacid_8:
2974           Cave[y][x] = Yeater_eB;
2975           if (Cave[y-1][x+2] == Xblank)
2976             Cave[y-1][x+2] = Yacid_splash_eB;
2977           if (Cave[y-1][x] == Xblank)
2978             Cave[y-1][x] = Yacid_splash_wB;
2979           Next[y][x] = Xblank;
2980           play_sound(x, y, SAMPLE_acid);
2981           goto loop;
2982
2983         case Xblank:
2984         case Yacid_splash_eB:
2985         case Yacid_splash_wB:
2986         case Xplant:
2987         case Yplant:
2988         case Zplayer:
2989           Cave[y][x] = Yeater_eB;
2990           Cave[y][x+1] = Yeater_e;
2991           Next[y][x] = Xblank;
2992           Next[y][x+1] = Xeater_e;
2993           goto loop;
2994
2995         default:
2996           Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
2997           play_sound(x, y, SAMPLE_eater);
2998           goto loop;
2999       }
3000
3001     /* --------------------------------------------------------------------- */
3002
3003     case Xeater_s:
3004       if (Cave[y][x-1] == Xdiamond)
3005       {
3006         Cave[y][x-1] = Ydiamond_eat;
3007         Next[y][x-1] = Xblank;
3008         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
3009         goto loop;
3010       }
3011
3012       if (Cave[y-1][x] == Xdiamond)
3013       {
3014         Cave[y-1][x] = Ydiamond_eat;
3015         Next[y-1][x] = Xblank;
3016         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
3017         goto loop;
3018       }
3019
3020       if (Cave[y][x+1] == Xdiamond)
3021       {
3022         Cave[y][x+1] = Ydiamond_eat;
3023         Next[y][x+1] = Xblank;
3024         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
3025         goto loop;
3026       }
3027
3028       if (Cave[y+1][x] == Xdiamond)
3029       {
3030         Cave[y+1][x] = Ydiamond_eat;
3031         Next[y+1][x] = Xblank;
3032         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
3033         goto loop;
3034       }
3035
3036       switch (Cave[y+1][x])
3037       {
3038         case Xacid_1:
3039         case Xacid_2:
3040         case Xacid_3:
3041         case Xacid_4:
3042         case Xacid_5:
3043         case Xacid_6:
3044         case Xacid_7:
3045         case Xacid_8:
3046           Cave[y][x] = Yeater_sB;
3047           if (Cave[y][x+1] == Xblank)
3048             Cave[y][x+1] = Yacid_splash_eB;
3049           if (Cave[y][x-1] == Xblank)
3050             Cave[y][x-1] = Yacid_splash_wB;
3051           Next[y][x] = Xblank;
3052           play_sound(x, y, SAMPLE_acid);
3053           goto loop;
3054
3055         case Xblank:
3056         case Yacid_splash_eB:
3057         case Yacid_splash_wB:
3058         case Xplant:
3059         case Yplant:
3060         case Zplayer:
3061           Cave[y][x] = Yeater_sB;
3062           Cave[y+1][x] = Yeater_s;
3063           Next[y][x] = Xblank;
3064           Next[y+1][x] = Xeater_s;
3065           goto loop;
3066
3067         default:
3068           Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
3069           play_sound(x, y, SAMPLE_eater);
3070           goto loop;
3071       }
3072
3073     /* --------------------------------------------------------------------- */
3074
3075     case Xeater_w:
3076       if (Cave[y-1][x] == Xdiamond)
3077       {
3078         Cave[y-1][x] = Ydiamond_eat;
3079         Next[y-1][x] = Xblank;
3080         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
3081         goto loop;
3082       }
3083
3084       if (Cave[y][x+1] == Xdiamond)
3085       {
3086         Cave[y][x+1] = Ydiamond_eat;
3087         Next[y][x+1] = Xblank;
3088         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
3089         goto loop;
3090       }
3091
3092       if (Cave[y+1][x] == Xdiamond)
3093       {
3094         Cave[y+1][x] = Ydiamond_eat;
3095         Next[y+1][x] = Xblank;
3096         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
3097         goto loop;
3098       }
3099
3100       if (Cave[y][x-1] == Xdiamond)
3101       {
3102         Cave[y][x-1] = Ydiamond_eat;
3103         Next[y][x-1] = Xblank;
3104         play_element_sound(x, y, SAMPLE_eater, Xdiamond);
3105         goto loop;
3106       }
3107
3108       switch (Cave[y][x-1])
3109       {
3110         case Xacid_1:
3111         case Xacid_2:
3112         case Xacid_3:
3113         case Xacid_4:
3114         case Xacid_5:
3115         case Xacid_6:
3116         case Xacid_7:
3117         case Xacid_8:
3118           Cave[y][x] = Yeater_wB;
3119           if (Cave[y-1][x] == Xblank)
3120             Cave[y-1][x] = Yacid_splash_eB;
3121           if (Cave[y-1][x-2] == Xblank)
3122             Cave[y-1][x-2] = Yacid_splash_wB;
3123           Next[y][x] = Xblank;
3124           play_sound(x, y, SAMPLE_acid);
3125           goto loop;
3126
3127         case Xblank:
3128         case Yacid_splash_eB:
3129         case Yacid_splash_wB:
3130         case Xplant:
3131         case Yplant:
3132         case Zplayer:
3133           Cave[y][x] = Yeater_wB;
3134           Cave[y][x-1] = Yeater_w;
3135           Next[y][x] = Xblank;
3136           Next[y][x-1] = Xeater_w;
3137           goto loop;
3138
3139         default:
3140           Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3141           play_sound(x, y, SAMPLE_eater);
3142           goto loop;
3143       }
3144
3145     /* --------------------------------------------------------------------- */
3146
3147     case Xalien:
3148       if (lev.wheel_cnt)
3149       {
3150         dx = lev.wheel_x;
3151         dy = lev.wheel_y;
3152       }
3153       else if (ply1.alive && ply2.alive)
3154       {
3155         if ((ply1.x > x ? ply1.x - x : x - ply1.x) +
3156             (ply1.y > y ? ply1.y - y : y - ply1.y) <
3157             (ply2.x > x ? ply2.x - x : x - ply2.x) +
3158             (ply2.y > y ? ply2.y - y : y - ply2.y))
3159         {
3160           dx = ply1.x;
3161           dy = ply1.y;
3162         }
3163         else
3164         {
3165           dx = ply2.x;
3166           dy = ply2.y;
3167         }
3168       }
3169       else if (ply1.alive)
3170       {
3171         dx = ply1.x;
3172         dy = ply1.y;
3173       }
3174       else if (ply2.alive)
3175       {
3176         dx = ply2.x;
3177         dy = ply2.y;
3178       }
3179       else
3180       {
3181         dx = 0;
3182         dy = 0;
3183       }
3184
3185       if (RANDOM & 1)
3186       {
3187         if (y > dy)
3188         {
3189           switch (Cave[y-1][x])
3190           {
3191             case Xacid_1:
3192             case Xacid_2:
3193             case Xacid_3:
3194             case Xacid_4:
3195             case Xacid_5:
3196             case Xacid_6:
3197             case Xacid_7:
3198             case Xacid_8:
3199               Cave[y][x] = Yalien_nB;
3200               if (Cave[y-2][x+1] == Xblank)
3201                 Cave[y-2][x+1] = Yacid_splash_eB;
3202               if (Cave[y-2][x-1] == Xblank)
3203                 Cave[y-2][x-1] = Yacid_splash_wB;
3204               Next[y][x] = Xblank;
3205               play_sound(x, y, SAMPLE_acid);
3206               goto loop;
3207
3208             case Xblank:
3209             case Yacid_splash_eB:
3210             case Yacid_splash_wB:
3211             case Xplant:
3212             case Yplant:
3213             case Zplayer:
3214               Cave[y][x] = Yalien_nB;
3215               Cave[y-1][x] = Yalien_n;
3216               Next[y][x] = Xblank;
3217               Next[y-1][x] = Xalien_pause;
3218               play_sound(x, y, SAMPLE_alien);
3219               goto loop;
3220           }
3221         }
3222         else if (y < dy)
3223         {
3224           switch (Cave[y+1][x])
3225           {
3226             case Xacid_1:
3227             case Xacid_2:
3228             case Xacid_3:
3229             case Xacid_4:
3230             case Xacid_5:
3231             case Xacid_6:
3232             case Xacid_7:
3233             case Xacid_8:
3234               Cave[y][x] = Yalien_sB;
3235               Next[y][x] = Xblank;
3236               if (Cave[y][x+1] == Xblank)
3237                 Cave[y][x+1] = Yacid_splash_eB;
3238               if (Cave[y][x-1] == Xblank)
3239                 Cave[y][x-1] = Yacid_splash_wB;
3240               play_sound(x, y, SAMPLE_acid);
3241               goto loop;
3242
3243             case Xblank:
3244             case Yacid_splash_eB:
3245             case Yacid_splash_wB:
3246             case Xplant:
3247             case Yplant:
3248             case Zplayer:
3249               Cave[y][x] = Yalien_sB;
3250               Cave[y+1][x] = Yalien_s;
3251               Next[y][x] = Xblank;
3252               Next[y+1][x] = Xalien_pause;
3253               play_sound(x, y, SAMPLE_alien);
3254               goto loop;
3255           }
3256         }
3257       }
3258       else
3259       {
3260         if (x < dx)
3261         {
3262           switch (Cave[y][x+1])
3263           {
3264             case Xacid_1:
3265             case Xacid_2:
3266             case Xacid_3:
3267             case Xacid_4:
3268             case Xacid_5:
3269             case Xacid_6:
3270             case Xacid_7:
3271             case Xacid_8:
3272               Cave[y][x] = Yalien_eB;
3273               if (Cave[y-1][x+2] == Xblank)
3274                 Cave[y-1][x+2] = Yacid_splash_eB;
3275               if (Cave[y-1][x] == Xblank)
3276                 Cave[y-1][x] = Yacid_splash_wB;
3277               Next[y][x] = Xblank;
3278               play_sound(x, y, SAMPLE_acid);
3279               goto loop;
3280
3281             case Xblank:
3282             case Yacid_splash_eB:
3283             case Yacid_splash_wB:
3284             case Xplant:
3285             case Yplant:
3286             case Zplayer:
3287               Cave[y][x] = Yalien_eB;
3288               Cave[y][x+1] = Yalien_e;
3289               Next[y][x] = Xblank;
3290               Next[y][x+1] = Xalien_pause;
3291               play_sound(x, y, SAMPLE_alien);
3292               goto loop;
3293           }
3294         }
3295         else if (x > dx)
3296         {
3297           switch (Cave[y][x-1])
3298           {
3299             case Xacid_1:
3300             case Xacid_2:
3301             case Xacid_3:
3302             case Xacid_4:
3303             case Xacid_5:
3304             case Xacid_6:
3305             case Xacid_7:
3306             case Xacid_8:
3307               Cave[y][x] = Yalien_wB;
3308               if (Cave[y-1][x] == Xblank)
3309                 Cave[y-1][x] = Yacid_splash_eB;
3310               if (Cave[y-1][x-2] == Xblank)
3311                 Cave[y-1][x-2] = Yacid_splash_wB;
3312               Next[y][x] = Xblank;
3313               play_sound(x, y, SAMPLE_acid);
3314               goto loop;
3315
3316             case Xblank:
3317             case Yacid_splash_eB:
3318             case Yacid_splash_wB:
3319             case Xplant:
3320             case Yplant:
3321             case Zplayer:
3322               Cave[y][x] = Yalien_wB;
3323               Cave[y][x-1] = Yalien_w;
3324               Next[y][x] = Xblank;
3325               Next[y][x-1] = Xalien_pause;
3326               play_sound(x, y, SAMPLE_alien);
3327               goto loop;
3328           }
3329         }
3330       }
3331
3332       goto loop;
3333
3334     case Xalien_pause:
3335       Next[y][x] = Xalien;
3336       goto loop;
3337
3338     /* --------------------------------------------------------------------- */
3339
3340     case Xemerald:
3341       switch (Cave[y+1][x])
3342       {
3343         case Xacid_1:
3344         case Xacid_2:
3345         case Xacid_3:
3346         case Xacid_4:
3347         case Xacid_5:
3348         case Xacid_6:
3349         case Xacid_7:
3350         case Xacid_8:
3351           Cave[y][x] = Yemerald_sB;
3352           if (Cave[y][x+1] == Xblank)
3353             Cave[y][x+1] = Yacid_splash_eB;
3354           if (Cave[y][x-1] == Xblank)
3355             Cave[y][x-1] = Yacid_splash_wB;
3356           Next[y][x] = Xblank;
3357           play_sound(x, y, SAMPLE_acid);
3358           goto loop;
3359
3360         case Xblank:
3361         case Yacid_splash_eB:
3362         case Yacid_splash_wB:
3363           Cave[y][x] = Yemerald_sB;
3364           Cave[y+1][x] = Yemerald_s;
3365           Next[y][x] = Xblank;
3366           Next[y+1][x] = Xemerald_fall;
3367           goto loop;
3368
3369         case Xspring:
3370         case Xspring_pause:
3371         case Xspring_e:
3372         case Xspring_w:
3373         case Xandroid:
3374         case Xandroid_1_n:
3375         case Xandroid_2_n:
3376         case Xandroid_1_e:
3377         case Xandroid_2_e:
3378         case Xandroid_1_s:
3379         case Xandroid_2_s:
3380         case Xandroid_1_w:
3381         case Xandroid_2_w:
3382         case Xstone:
3383         case Xstone_pause:
3384         case Xemerald:
3385         case Xemerald_pause:
3386         case Xdiamond:
3387         case Xdiamond_pause:
3388         case Xbomb:
3389         case Xbomb_pause:
3390         case Xballoon:
3391         case Xacid_ne:
3392         case Xacid_nw:
3393         case Xball_1:
3394         case Xball_2:
3395         case Xnut:
3396         case Xnut_pause:
3397         case Xgrow_ns:
3398         case Xgrow_ew:
3399         case Xwonderwall:
3400         case Xkey_1:
3401         case Xkey_2:
3402         case Xkey_3:
3403         case Xkey_4:
3404         case Xkey_5:
3405         case Xkey_6:
3406         case Xkey_7:
3407         case Xkey_8:
3408         case Xbumper:
3409         case Xswitch:
3410         case Xsteel_1:
3411         case Xsteel_2:
3412         case Xsteel_3:
3413         case Xsteel_4:
3414         case Xwall_1:
3415         case Xwall_2:
3416         case Xwall_3:
3417         case Xwall_4:
3418         case Xround_wall_1:
3419         case Xround_wall_2:
3420         case Xround_wall_3:
3421         case Xround_wall_4:
3422           if (RANDOM & 1)
3423           {
3424             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3425             {
3426               Cave[y][x] = Yemerald_eB;
3427               Cave[y][x+1] = Yemerald_e;
3428               Next[y][x] = Xblank;
3429               Next[y][x+1] = Xemerald_pause;
3430               goto loop;
3431             }
3432
3433             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3434             {
3435               Cave[y][x] = Yemerald_wB;
3436               Cave[y][x-1] = Yemerald_w;
3437               Next[y][x] = Xblank;
3438               Next[y][x-1] = Xemerald_pause;
3439               goto loop;
3440             }
3441           }
3442           else
3443           {
3444             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3445             {
3446               Cave[y][x] = Yemerald_wB;
3447               Cave[y][x-1] = Yemerald_w;
3448               Next[y][x] = Xblank;
3449               Next[y][x-1] = Xemerald_pause;
3450               goto loop;
3451             }
3452
3453             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3454             {
3455               Cave[y][x] = Yemerald_eB;
3456               Cave[y][x+1] = Yemerald_e;
3457               Next[y][x] = Xblank;
3458               Next[y][x+1] = Xemerald_pause;
3459               goto loop;
3460             }
3461           }
3462
3463         default:
3464           if (++lev.shine_cnt > 50)
3465           {
3466             lev.shine_cnt = RANDOM & 7;
3467             Cave[y][x] = Xemerald_shine;
3468           }
3469
3470           goto loop;
3471       }
3472
3473     /* --------------------------------------------------------------------- */
3474
3475     case Xemerald_pause:
3476       switch (Cave[y+1][x])
3477       {
3478         case Xacid_1:
3479         case Xacid_2:
3480         case Xacid_3:
3481         case Xacid_4:
3482         case Xacid_5:
3483         case Xacid_6:
3484         case Xacid_7:
3485         case Xacid_8:
3486           Cave[y][x] = Yemerald_sB;
3487           if (Cave[y][x+1] == Xblank)
3488             Cave[y][x+1] = Yacid_splash_eB;
3489           if (Cave[y][x-1] == Xblank)
3490             Cave[y][x-1] = Yacid_splash_wB;
3491           Next[y][x] = Xblank;
3492           play_sound(x, y, SAMPLE_acid);
3493           goto loop;
3494
3495         case Xblank:
3496         case Yacid_splash_eB:
3497         case Yacid_splash_wB:
3498           Cave[y][x] = Yemerald_sB;
3499           Cave[y+1][x] = Yemerald_s;
3500           Next[y][x] = Xblank;
3501           Next[y+1][x] = Xemerald_fall;
3502           goto loop;
3503
3504         default:
3505           Cave[y][x] = Xemerald;
3506           Next[y][x] = Xemerald;
3507           goto loop;
3508       }
3509
3510     /* --------------------------------------------------------------------- */
3511
3512     case Xemerald_fall:
3513       switch (Cave[y+1][x])
3514       {
3515         case Xacid_1:
3516         case Xacid_2:
3517         case Xacid_3:
3518         case Xacid_4:
3519         case Xacid_5:
3520         case Xacid_6:
3521         case Xacid_7:
3522         case Xacid_8:
3523           Cave[y][x] = Yemerald_sB;
3524           if (Cave[y][x+1] == Xblank)
3525             Cave[y][x+1] = Yacid_splash_eB;
3526           if (Cave[y][x-1] == Xblank)
3527             Cave[y][x-1] = Yacid_splash_wB;
3528           Next[y][x] = Xblank;
3529           play_sound(x, y, SAMPLE_acid);
3530           goto loop;
3531
3532         case Xblank:
3533         case Yacid_splash_eB:
3534         case Yacid_splash_wB:
3535         case Zplayer:
3536           Cave[y][x] = Yemerald_sB;
3537           Cave[y+1][x] = Yemerald_s;
3538           Next[y][x] = Xblank;
3539           Next[y+1][x] = Xemerald_fall;
3540           goto loop;
3541
3542         case Xwonderwall:
3543           if (lev.wonderwall_time)
3544           {
3545             lev.wonderwall_state = 1;
3546             Cave[y][x] = Yemerald_sB;
3547             if (tab_blank[Cave[y+2][x]])
3548             {
3549               Cave[y+2][x] = Ydiamond_s;
3550               Next[y+2][x] = Xdiamond_fall;
3551             }
3552
3553             Next[y][x] = Xblank;
3554             play_element_sound(x, y, SAMPLE_wonderfall, Xemerald);
3555             goto loop;
3556           }
3557
3558         default:
3559           Cave[y][x] = Xemerald;
3560           Next[y][x] = Xemerald;
3561           play_element_sound(x, y, SAMPLE_diamond, Xemerald);
3562           goto loop;
3563       }
3564
3565     /* --------------------------------------------------------------------- */
3566
3567     case Xdiamond:
3568       switch (Cave[y+1][x])
3569       {
3570         case Xacid_1:
3571         case Xacid_2:
3572         case Xacid_3:
3573         case Xacid_4:
3574         case Xacid_5:
3575         case Xacid_6:
3576         case Xacid_7:
3577         case Xacid_8:
3578           Cave[y][x] = Ydiamond_sB;
3579           if (Cave[y][x+1] == Xblank)
3580             Cave[y][x+1] = Yacid_splash_eB;
3581           if (Cave[y][x-1] == Xblank)
3582             Cave[y][x-1] = Yacid_splash_wB;
3583           Next[y][x] = Xblank;
3584           play_sound(x, y, SAMPLE_acid);
3585           goto loop;
3586
3587         case Xblank:
3588         case Yacid_splash_eB:
3589         case Yacid_splash_wB:
3590           Cave[y][x] = Ydiamond_sB;
3591           Cave[y+1][x] = Ydiamond_s;
3592           Next[y][x] = Xblank;
3593           Next[y+1][x] = Xdiamond_fall;
3594           goto loop;
3595
3596         case Xspring:
3597         case Xspring_pause:
3598         case Xspring_e:
3599         case Xspring_w:
3600         case Xandroid:
3601         case Xandroid_1_n:
3602         case Xandroid_2_n:
3603         case Xandroid_1_e:
3604         case Xandroid_2_e:
3605         case Xandroid_1_s:
3606         case Xandroid_2_s:
3607         case Xandroid_1_w:
3608         case Xandroid_2_w:
3609         case Xstone:
3610         case Xstone_pause:
3611         case Xemerald:
3612         case Xemerald_pause:
3613         case Xdiamond:
3614         case Xdiamond_pause:
3615         case Xbomb:
3616         case Xbomb_pause:
3617         case Xballoon:
3618         case Xacid_ne:
3619         case Xacid_nw:
3620         case Xball_1:
3621         case Xball_2:
3622         case Xnut:
3623         case Xnut_pause:
3624         case Xgrow_ns:
3625         case Xgrow_ew:
3626         case Xwonderwall:
3627         case Xkey_1:
3628         case Xkey_2:
3629         case Xkey_3:
3630         case Xkey_4:
3631         case Xkey_5:
3632         case Xkey_6:
3633         case Xkey_7:
3634         case Xkey_8:
3635         case Xbumper:
3636         case Xswitch:
3637         case Xsteel_1:
3638         case Xsteel_2:
3639         case Xsteel_3:
3640         case Xsteel_4:
3641         case Xwall_1:
3642         case Xwall_2:
3643         case Xwall_3:
3644         case Xwall_4:
3645         case Xround_wall_1:
3646         case Xround_wall_2:
3647         case Xround_wall_3:
3648         case Xround_wall_4:
3649           if (RANDOM & 1)
3650           {
3651             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3652             {
3653               Cave[y][x] = Ydiamond_eB;
3654               Cave[y][x+1] = Ydiamond_e;
3655               Next[y][x] = Xblank;
3656               Next[y][x+1] = Xdiamond_pause;
3657               goto loop;
3658             }
3659
3660             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3661             {
3662               Cave[y][x] = Ydiamond_wB;
3663               Cave[y][x-1] = Ydiamond_w;
3664               Next[y][x] = Xblank;
3665               Next[y][x-1] = Xdiamond_pause;
3666               goto loop;
3667             }
3668           }
3669           else
3670           {
3671             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3672             {
3673               Cave[y][x] = Ydiamond_wB;
3674               Cave[y][x-1] = Ydiamond_w;
3675               Next[y][x] = Xblank;
3676               Next[y][x-1] = Xdiamond_pause;
3677               goto loop;
3678             }
3679
3680             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3681             {
3682               Cave[y][x] = Ydiamond_eB;
3683               Cave[y][x+1] = Ydiamond_e;
3684               Next[y][x] = Xblank;
3685               Next[y][x+1] = Xdiamond_pause;
3686               goto loop;
3687             }
3688           }
3689
3690         default:
3691           if (++lev.shine_cnt > 50)
3692           {
3693             lev.shine_cnt = RANDOM & 7;
3694             Cave[y][x] = Xdiamond_shine;
3695           }
3696
3697           goto loop;
3698       }
3699
3700     /* --------------------------------------------------------------------- */
3701
3702     case Xdiamond_pause:
3703       switch (Cave[y+1][x])
3704       {
3705         case Xacid_1:
3706         case Xacid_2:
3707         case Xacid_3:
3708         case Xacid_4:
3709         case Xacid_5:
3710         case Xacid_6:
3711         case Xacid_7:
3712         case Xacid_8:
3713           Cave[y][x] = Ydiamond_sB;
3714           if (Cave[y][x+1] == Xblank)
3715             Cave[y][x+1] = Yacid_splash_eB;
3716           if (Cave[y][x-1] == Xblank)
3717             Cave[y][x-1] = Yacid_splash_wB;
3718           Next[y][x] = Xblank;
3719           play_sound(x, y, SAMPLE_acid);
3720           goto loop;
3721
3722         case Xblank:
3723         case Yacid_splash_eB:
3724         case Yacid_splash_wB:
3725           Cave[y][x] = Ydiamond_sB;
3726           Cave[y+1][x] = Ydiamond_s;
3727           Next[y][x] = Xblank;
3728           Next[y+1][x] = Xdiamond_fall;
3729           goto loop;
3730
3731         default:
3732           Cave[y][x] = Xdiamond;
3733           Next[y][x] = Xdiamond;
3734           goto loop;
3735       }
3736
3737     /* --------------------------------------------------------------------- */
3738
3739     case Xdiamond_fall:
3740       switch (Cave[y+1][x])
3741       {
3742         case Xacid_1:
3743         case Xacid_2:
3744         case Xacid_3:
3745         case Xacid_4:
3746         case Xacid_5:
3747         case Xacid_6:
3748         case Xacid_7:
3749         case Xacid_8:
3750           Cave[y][x] = Ydiamond_sB;
3751           if (Cave[y][x+1] == Xblank)
3752             Cave[y][x+1] = Yacid_splash_eB;
3753           if (Cave[y][x-1] == Xblank)
3754             Cave[y][x-1] = Yacid_splash_wB;
3755           Next[y][x] = Xblank;
3756           play_sound(x, y, SAMPLE_acid);
3757           goto loop;
3758
3759         case Xblank:
3760         case Yacid_splash_eB:
3761         case Yacid_splash_wB:
3762         case Zplayer:
3763           Cave[y][x] = Ydiamond_sB;
3764           Cave[y+1][x] = Ydiamond_s;
3765           Next[y][x] = Xblank;
3766           Next[y+1][x] = Xdiamond_fall;
3767           goto loop;
3768
3769         case Xwonderwall:
3770           if (lev.wonderwall_time)
3771           {
3772             lev.wonderwall_state = 1;
3773             Cave[y][x] = Ydiamond_sB;
3774             if (tab_blank[Cave[y+2][x]])
3775             {
3776               Cave[y+2][x] = Ystone_s;
3777               Next[y+2][x] = Xstone_fall;
3778             }
3779
3780             Next[y][x] = Xblank;
3781             play_element_sound(x, y, SAMPLE_wonderfall, Xdiamond);
3782             goto loop;
3783           }
3784
3785         default:
3786           Cave[y][x] = Xdiamond;
3787           Next[y][x] = Xdiamond;
3788           play_element_sound(x, y, SAMPLE_diamond, Xdiamond);
3789           goto loop;
3790       }
3791
3792     /* --------------------------------------------------------------------- */
3793
3794     case Xdrip_fall:
3795       switch (Cave[y+1][x])
3796       {
3797         case Xacid_1:
3798         case Xacid_2:
3799         case Xacid_3:
3800         case Xacid_4:
3801         case Xacid_5:
3802         case Xacid_6:
3803         case Xacid_7:
3804         case Xacid_8:
3805           Cave[y][x] = Ydrip_s1B;
3806           if (Cave[y][x+1] == Xblank)
3807             Cave[y][x+1] = Yacid_splash_eB;
3808           if (Cave[y][x-1] == Xblank)
3809             Cave[y][x-1] = Yacid_splash_wB;
3810           Next[y][x] = Xdrip_stretchB;
3811           play_sound(x, y, SAMPLE_acid);
3812           goto loop;
3813
3814         case Xblank:
3815         case Yacid_splash_eB:
3816         case Yacid_splash_wB:
3817         case Xplant:
3818         case Yplant:
3819         case Zplayer:
3820           Cave[y][x] = Ydrip_s1B;
3821           Cave[y+1][x] = Ydrip_s1;
3822           Next[y][x] = Xdrip_stretchB;
3823           Next[y+1][x] = Xdrip_stretch;
3824           goto loop;
3825
3826         default:
3827           switch (RANDOM & 7)
3828           {
3829             case 0:
3830               temp = Xamoeba_1;
3831               break;
3832
3833             case 1:
3834               temp = Xamoeba_2;
3835               break;
3836
3837             case 2:
3838               temp = Xamoeba_3;
3839               break;
3840
3841             case 3:
3842               temp = Xamoeba_4;
3843               break;
3844
3845             case 4:
3846               temp = Xamoeba_5;
3847               break;
3848
3849             case 5:
3850               temp = Xamoeba_6;
3851               break;
3852
3853             case 6:
3854               temp = Xamoeba_7;
3855               break;
3856
3857             case 7:
3858               temp = Xamoeba_8;
3859               break;
3860           }
3861
3862           Cave[y][x] = temp;
3863           Next[y][x] = temp;
3864           play_sound(x, y, SAMPLE_drip);
3865           goto loop;
3866       }
3867
3868     /* --------------------------------------------------------------------- */
3869
3870     case Xdrip_stretch:
3871       Cave[y][x] = Ydrip_s2;
3872       Next[y][x] = Xdrip_fall;
3873       goto loop;
3874
3875     case Xdrip_stretchB:
3876       Cave[y][x] = Ydrip_s2B;
3877       Next[y][x] = Xblank;
3878       goto loop;
3879
3880     case Xdrip_eat:
3881       Next[y][x] = Xdrip_fall;
3882       goto loop;
3883
3884     /* --------------------------------------------------------------------- */
3885
3886     case Xbomb:
3887       switch (Cave[y+1][x])
3888       {
3889         case Xacid_1:
3890         case Xacid_2:
3891         case Xacid_3:
3892         case Xacid_4:
3893         case Xacid_5:
3894         case Xacid_6:
3895         case Xacid_7:
3896         case Xacid_8:
3897           Cave[y][x] = Ybomb_sB;
3898           if (Cave[y][x+1] == Xblank)
3899             Cave[y][x+1] = Yacid_splash_eB;
3900           if (Cave[y][x-1] == Xblank)
3901             Cave[y][x-1] = Yacid_splash_wB;
3902           Next[y][x] = Xblank;
3903           play_sound(x, y, SAMPLE_acid);
3904           goto loop;
3905
3906         case Xblank:
3907         case Yacid_splash_eB:
3908         case Yacid_splash_wB:
3909           Cave[y][x] = Ybomb_sB;
3910           Cave[y+1][x] = Ybomb_s;
3911           Next[y][x] = Xblank;
3912           Next[y+1][x] = Xbomb_fall;
3913           goto loop;
3914
3915         case Xspring:
3916         case Xspring_pause:
3917         case Xspring_e:
3918         case Xspring_w:
3919         case Xandroid:
3920         case Xandroid_1_n:
3921         case Xandroid_2_n:
3922         case Xandroid_1_e:
3923         case Xandroid_2_e:
3924         case Xandroid_1_s:
3925         case Xandroid_2_s:
3926         case Xandroid_1_w:
3927         case Xandroid_2_w:
3928         case Xstone:
3929         case Xstone_pause:
3930         case Xemerald:
3931         case Xemerald_pause:
3932         case Xdiamond:
3933         case Xdiamond_pause:
3934         case Xbomb:
3935         case Xbomb_pause:
3936         case Xballoon:
3937         case Xacid_ne:
3938         case Xacid_nw:
3939         case Xball_1:
3940         case Xball_2:
3941         case Xnut:
3942         case Xnut_pause:
3943         case Xgrow_ns:
3944         case Xgrow_ew:
3945         case Xkey_1:
3946         case Xkey_2:
3947         case Xkey_3:
3948         case Xkey_4:
3949         case Xkey_5:
3950         case Xkey_6:
3951         case Xkey_7:
3952         case Xkey_8:
3953         case Xbumper:
3954         case Xswitch:
3955         case Xround_wall_1:
3956         case Xround_wall_2:
3957         case Xround_wall_3:
3958         case Xround_wall_4:
3959           if (RANDOM & 1)
3960           {
3961             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3962             {
3963               Cave[y][x] = Ybomb_eB;
3964               Cave[y][x+1] = Ybomb_e;
3965               Next[y][x] = Xblank;
3966               Next[y][x+1] = Xbomb_pause;
3967               goto loop;
3968             }
3969
3970             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3971             {
3972               Cave[y][x] = Ybomb_wB;
3973               Cave[y][x-1] = Ybomb_w;
3974               Next[y][x] = Xblank;
3975               Next[y][x-1] = Xbomb_pause;
3976               goto loop;
3977             }
3978           }
3979           else
3980           {
3981             if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3982             {
3983               Cave[y][x] = Ybomb_wB;
3984               Cave[y][x-1] = Ybomb_w;
3985               Next[y][x] = Xblank;
3986               Next[y][x-1] = Xbomb_pause;
3987               goto loop;
3988             }
3989
3990             if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3991             {
3992               Cave[y][x] = Ybomb_eB;
3993               Cave[y][x+1] = Ybomb_e;
3994               Next[y][x] = Xblank;
3995               Next[y][x+1] = Xbomb_pause;
3996               goto loop;
3997             }
3998           }
3999
4000         default:
4001           goto loop;
4002       }
4003
4004     /* --------------------------------------------------------------------- */
4005
4006     case Xbomb_pause:
4007       switch (Cave[y+1][x])
4008       {
4009         case Xacid_1:
4010         case Xacid_2:
4011         case Xacid_3:
4012         case Xacid_4:
4013         case Xacid_5:
4014         case Xacid_6:
4015         case Xacid_7:
4016         case Xacid_8:
4017           Cave[y][x] = Ybomb_sB;
4018           if (Cave[y][x+1] == Xblank)
4019             Cave[y][x+1] = Yacid_splash_eB;
4020           if (Cave[y][x-1] == Xblank)
4021             Cave[y][x-1] = Yacid_splash_wB;
4022           Next[y][x] = Xblank;
4023           play_sound(x, y, SAMPLE_acid);
4024           goto loop;
4025
4026         case Xblank:
4027         case Yacid_splash_eB:
4028         case Yacid_splash_wB:
4029           Cave[y][x] = Ybomb_sB;
4030           Cave[y+1][x] = Ybomb_s;
4031           Next[y][x] = Xblank;
4032           Next[y+1][x] = Xbomb_fall;
4033           goto loop;
4034
4035         default:
4036           Cave[y][x] = Xbomb;
4037           Next[y][x] = Xbomb;
4038           goto loop;
4039       }
4040
4041     /* --------------------------------------------------------------------- */
4042
4043     case Xbomb_fall:
4044       switch (Cave[y+1][x])
4045       {
4046         case Xacid_1:
4047         case Xacid_2:
4048         case Xacid_3:
4049         case Xacid_4:
4050         case Xacid_5:
4051         case Xacid_6:
4052         case Xacid_7:
4053         case Xacid_8:
4054           Cave[y][x] = Ybomb_sB;
4055           if (Cave[y][x+1] == Xblank)
4056             Cave[y][x+1] = Yacid_splash_eB;
4057           if (Cave[y][x-1] == Xblank)
4058             Cave[y][x-1] = Yacid_splash_wB;
4059           Next[y][x] = Xblank;
4060           play_sound(x, y, SAMPLE_acid);
4061           goto loop;
4062
4063         case Xblank:
4064         case Yacid_splash_eB:
4065         case Yacid_splash_wB:
4066           Cave[y][x] = Ybomb_sB;
4067           Cave[y+1][x] = Ybomb_s;
4068           Next[y][x] = Xblank;
4069           Next[y+1][x] = Xbomb_fall;
4070           goto loop;
4071
4072         default:
4073           Cave[y][x] = Ybomb_eat;
4074           Next[y][x] = Znormal;
4075           Boom[y-1][x-1] = Xblank;
4076           Boom[y-1][x] = Xblank;
4077           Boom[y-1][x+1] = Xblank;
4078           Boom[y][x-1] = Xblank;
4079           Boom[y][x] = Xblank;
4080           Boom[y][x+1] = Xblank;
4081           Boom[y+1][x-1] = Xblank;
4082           Boom[y+1][x] = Xblank;
4083           Boom[y+1][x+1] = Xblank;
4084           goto loop;
4085       }
4086
4087     /* --------------------------------------------------------------------- */
4088
4089     case Xballoon:
4090       if (lev.wind_cnt == 0)
4091         goto loop;
4092
4093       switch (lev.wind_direction)
4094       {
4095         case 0: /* north */
4096           switch (Cave[y-1][x])
4097           {
4098             case Xacid_1:
4099             case Xacid_2:
4100             case Xacid_3:
4101             case Xacid_4:
4102             case Xacid_5:
4103             case Xacid_6:
4104             case Xacid_7:
4105             case Xacid_8:
4106               Cave[y][x] = Yballoon_nB;
4107               if (Cave[y-2][x+1] == Xblank)
4108                 Cave[y-2][x+1] = Yacid_splash_eB;
4109               if (Cave[y-2][x-1] == Xblank)
4110                 Cave[y-2][x-1] = Yacid_splash_wB;
4111               Next[y][x] = Xblank;
4112               play_sound(x, y, SAMPLE_acid);
4113               goto loop;
4114
4115             case Xblank:
4116             case Yacid_splash_eB:
4117             case Yacid_splash_wB:
4118               Cave[y][x] = Yballoon_nB;
4119               Cave[y-1][x] = Yballoon_n;
4120               Next[y][x] = Xblank;
4121               Next[y-1][x] = Xballoon;
4122               goto loop;
4123
4124             default:
4125               goto loop;
4126           }
4127
4128         case 1: /* east */
4129           switch (Cave[y][x+1])
4130           {
4131             case Xacid_1:
4132             case Xacid_2:
4133             case Xacid_3:
4134             case Xacid_4:
4135             case Xacid_5:
4136             case Xacid_6:
4137             case Xacid_7:
4138             case Xacid_8:
4139               Cave[y][x] = Yballoon_eB;
4140               if (Cave[y-1][x+2] == Xblank)
4141                 Cave[y-1][x+2] = Yacid_splash_eB;
4142               if (Cave[y-1][x] == Xblank)
4143                 Cave[y-1][x] = Yacid_splash_wB;
4144               Next[y][x] = Xblank;
4145               play_sound(x, y, SAMPLE_acid);
4146               goto loop;
4147
4148             case Xblank:
4149             case Yacid_splash_eB:
4150             case Yacid_splash_wB:
4151               Cave[y][x] = Yballoon_eB;
4152               Cave[y][x+1] = Yballoon_e;
4153               Next[y][x] = Xblank;
4154               Next[y][x+1] = Xballoon;
4155               goto loop;
4156
4157             default:
4158               goto loop;
4159           }
4160
4161         case 2: /* south */
4162           switch (Cave[y+1][x])
4163           {
4164             case Xacid_1:
4165             case Xacid_2:
4166             case Xacid_3:
4167             case Xacid_4:
4168             case Xacid_5:
4169             case Xacid_6:
4170             case Xacid_7:
4171             case Xacid_8:
4172               Cave[y][x] = Yballoon_sB;
4173               if (Cave[y][x+1] == Xblank)
4174                 Cave[y][x+1] = Yacid_splash_eB;
4175               if (Cave[y][x-1] == Xblank)
4176                 Cave[y][x-1] = Yacid_splash_wB;
4177               Next[y][x] = Xblank;
4178               play_sound(x, y, SAMPLE_acid);
4179               goto loop;
4180
4181             case Xblank:
4182             case Yacid_splash_eB:
4183             case Yacid_splash_wB:
4184               Cave[y][x] = Yballoon_sB;
4185               Cave[y+1][x] = Yballoon_s;
4186               Next[y][x] = Xblank;
4187               Next[y+1][x] = Xballoon;
4188               goto loop;
4189
4190             default:
4191               goto loop;
4192           }
4193
4194         case 3: /* west */
4195           switch (Cave[y][x-1])
4196           {
4197             case Xacid_1:
4198             case Xacid_2:
4199             case Xacid_3:
4200             case Xacid_4:
4201             case Xacid_5:
4202             case Xacid_6:
4203             case Xacid_7:
4204             case Xacid_8:
4205               Cave[y][x] = Yballoon_wB;
4206               if (Cave[y-1][x] == Xblank)
4207                 Cave[y-1][x] = Yacid_splash_eB;
4208               if (Cave[y-1][x-2] == Xblank)
4209                 Cave[y-1][x-2] = Yacid_splash_wB;
4210               Next[y][x] = Xblank;
4211               play_sound(x, y, SAMPLE_acid);
4212               goto loop;
4213
4214             case Xblank:
4215             case Yacid_splash_eB:
4216             case Yacid_splash_wB:
4217               Cave[y][x] = Yballoon_wB;
4218               Cave[y][x-1] = Yballoon_w;
4219               Next[y][x] = Xblank;
4220               Next[y][x-1] = Xballoon;
4221               goto loop;
4222
4223             default:
4224               goto loop;
4225           }
4226       }
4227
4228     /* --------------------------------------------------------------------- */
4229
4230     case Xacid_1:
4231       Next[y][x] = Xacid_2;
4232       goto loop;
4233
4234     case Xacid_2:
4235       Next[y][x] = Xacid_3;
4236       goto loop;
4237
4238     case Xacid_3:
4239       Next[y][x] = Xacid_4;
4240       goto loop;
4241
4242     case Xacid_4:
4243       Next[y][x] = Xacid_5;
4244       goto loop;
4245
4246     case Xacid_5:
4247       Next[y][x] = Xacid_6;
4248       goto loop;
4249
4250     case Xacid_6:
4251       Next[y][x] = Xacid_7;
4252       goto loop;
4253
4254     case Xacid_7:
4255       Next[y][x] = Xacid_8;
4256       goto loop;
4257
4258     case Xacid_8:
4259       Next[y][x] = Xacid_1;
4260       goto loop;
4261
4262     /* --------------------------------------------------------------------- */
4263
4264     case Xball_1:
4265       if (lev.ball_state == 0)
4266         goto loop;
4267
4268       Cave[y][x] = Xball_1B;
4269       Next[y][x] = Xball_2;
4270       if (lev.ball_cnt)
4271         goto loop;
4272
4273       goto ball_common;
4274
4275     case Xball_2:
4276       if (lev.ball_state == 0)
4277         goto loop;
4278
4279       Cave[y][x] = Xball_2B;
4280       Next[y][x] = Xball_1;
4281       if (lev.ball_cnt)
4282         goto loop;
4283
4284       goto ball_common;
4285
4286     ball_common:
4287
4288       play_element_sound(x, y, SAMPLE_ball, element);
4289       if (lev.ball_random)
4290       {
4291         switch (RANDOM & 7)
4292         {
4293           case 0:
4294             if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4295                 tab_blank[Cave[y-1][x-1]])
4296             {
4297               Cave[y-1][x-1] = Yball_eat;
4298               Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4299             }
4300             break;
4301
4302           case 1:
4303             if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4304                 tab_blank[Cave[y-1][x]])
4305             {
4306               Cave[y-1][x] = Yball_eat;
4307               Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4308             }
4309             break;
4310
4311           case 2:
4312             if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4313                 tab_blank[Cave[y-1][x+1]])
4314             {
4315               Cave[y-1][x+1] = Yball_eat;
4316               Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4317             }
4318             break;
4319
4320           case 3:
4321             if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4322                 tab_blank[Cave[y][x-1]])
4323             {
4324               Cave[y][x-1] = Yball_eat;
4325               Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4326             }
4327             break;
4328
4329           case 4:
4330             if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4331                 tab_blank[Cave[y][x+1]])
4332             {
4333               Cave[y][x+1] = Yball_eat;
4334               Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4335             }
4336             break;
4337
4338           case 5:
4339             if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4340                 tab_blank[Cave[y+1][x-1]])
4341             {
4342               Cave[y+1][x-1] = Yball_eat;
4343               Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4344             }
4345             break;
4346
4347           case 6:
4348             if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4349                 tab_blank[Cave[y+1][x]])
4350             {
4351               Cave[y+1][x] = Yball_eat;
4352               Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4353             }
4354             break;
4355
4356           case 7:
4357             if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4358                 tab_blank[Cave[y+1][x+1]])
4359             {
4360               Cave[y+1][x+1] = Yball_eat;
4361               Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4362             }
4363             break;
4364         }
4365       }
4366       else
4367       {
4368         if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4369             tab_blank[Cave[y-1][x-1]])
4370         {
4371           Cave[y-1][x-1] = Yball_eat;
4372           Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4373         }
4374
4375         if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4376             tab_blank[Cave[y-1][x]])
4377         {
4378           Cave[y-1][x] = Yball_eat;
4379           Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4380         }
4381
4382         if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4383             tab_blank[Cave[y-1][x+1]])
4384         {
4385           Cave[y-1][x+1] = Yball_eat;
4386           Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4387         }
4388
4389         if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4390             tab_blank[Cave[y][x-1]])
4391         {
4392           Cave[y][x-1] = Yball_eat;
4393           Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4394         }
4395
4396         if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4397             tab_blank[Cave[y][x+1]])
4398         {
4399           Cave[y][x+1] = Yball_eat;
4400           Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4401         }
4402
4403         if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4404             tab_blank[Cave[y+1][x-1]])
4405         {
4406           Cave[y+1][x-1] = Yball_eat;
4407           Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4408         }
4409
4410         if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4411             tab_blank[Cave[y+1][x]])
4412         {
4413           Cave[y+1][x] = Yball_eat;
4414           Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4415         }
4416
4417         if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4418             tab_blank[Cave[y+1][x+1]])
4419         {
4420           Cave[y+1][x+1] = Yball_eat;
4421           Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4422         }
4423       }
4424
4425       lev.ball_pos = (lev.ball_pos + 1) & 7;
4426       goto loop;
4427
4428     /* --------------------------------------------------------------------- */
4429
4430     case Xgrow_ns:
4431       if (tab_blank[Cave[y-1][x]])
4432       {
4433         Cave[y-1][x] = Ygrow_ns_eat;
4434         Next[y-1][x] = Xgrow_ns;
4435         play_sound(x, y, SAMPLE_grow);
4436       }
4437
4438       if (tab_blank[Cave[y+1][x]])
4439       {
4440         Cave[y+1][x] = Ygrow_ns_eat;
4441         Next[y+1][x] = Xgrow_ns;
4442         play_sound(x, y, SAMPLE_grow);
4443       }
4444
4445       goto loop;
4446
4447     case Xgrow_ew:
4448       if (tab_blank[Cave[y][x+1]])
4449       {
4450         Cave[y][x+1] = Ygrow_ew_eat;
4451         Next[y][x+1] = Xgrow_ew;
4452         play_sound(x, y, SAMPLE_grow);
4453       }
4454
4455       if (tab_blank[Cave[y][x-1]])
4456       {
4457         Cave[y][x-1] = Ygrow_ew_eat;
4458         Next[y][x-1] = Xgrow_ew;
4459         play_sound(x, y, SAMPLE_grow);
4460       }
4461
4462       goto loop;
4463
4464     /* --------------------------------------------------------------------- */
4465
4466     case Xwonderwall:
4467       if (lev.wonderwall_time && lev.wonderwall_state)
4468       {
4469         Cave[y][x] = XwonderwallB;
4470         play_sound(x, y, SAMPLE_wonder);
4471       }
4472
4473       goto loop;
4474
4475     /* --------------------------------------------------------------------- */
4476
4477     case Xexit:
4478       if (lev.required > 0)
4479         goto loop;
4480
4481       temp = RANDOM & 63;
4482       if (temp < 21)
4483       {
4484         Cave[y][x] = Xexit_1;
4485         Next[y][x] = Xexit_2;
4486       }
4487       else if (temp < 42)
4488       {
4489         Cave[y][x] = Xexit_2;
4490         Next[y][x] = Xexit_3;
4491       }
4492       else
4493       {
4494         Cave[y][x] = Xexit_3;
4495         Next[y][x] = Xexit_1;
4496       }
4497
4498       goto loop;
4499
4500     case Xexit_1:
4501       Next[y][x] = Xexit_2;
4502       goto loop;
4503
4504     case Xexit_2:
4505       Next[y][x] = Xexit_3;
4506       goto loop;
4507
4508     case Xexit_3:
4509       Next[y][x] = Xexit_1;
4510       goto loop;
4511
4512     /* --------------------------------------------------------------------- */
4513
4514     case Xdynamite_1:
4515       play_sound(x, y, SAMPLE_tick);
4516       Next[y][x] = Xdynamite_2;
4517       goto loop;
4518
4519     case Xdynamite_2:
4520       play_sound(x, y, SAMPLE_tick);
4521       Next[y][x] = Xdynamite_3;
4522       goto loop;
4523
4524     case Xdynamite_3:
4525       play_sound(x, y, SAMPLE_tick);
4526       Next[y][x] = Xdynamite_4;
4527       goto loop;
4528
4529     case Xdynamite_4:
4530       play_sound(x, y, SAMPLE_tick);
4531       Next[y][x] = Zdynamite;
4532       Boom[y-1][x-1] = Xblank;
4533       Boom[y-1][x] = Xblank;
4534       Boom[y-1][x+1] = Xblank;
4535       Boom[y][x-1] = Xblank;
4536       Boom[y][x] = Xblank;
4537       Boom[y][x+1] = Xblank;
4538       Boom[y+1][x-1] = Xblank;
4539       Boom[y+1][x] = Xblank;
4540       Boom[y+1][x+1] = Xblank;
4541       goto loop;
4542
4543     /* --------------------------------------------------------------------- */
4544
4545     case Xwheel:
4546       if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
4547         Cave[y][x] = XwheelB;
4548       goto loop;
4549
4550     /* --------------------------------------------------------------------- */
4551
4552     case Xswitch:
4553       if (lev.ball_state)
4554         Cave[y][x] = XswitchB;
4555       goto loop;
4556
4557     /* --------------------------------------------------------------------- */
4558
4559     case Xsand_stone:
4560       switch (Cave[y+1][x])
4561       {
4562         case Xacid_1:
4563         case Xacid_2:
4564         case Xacid_3:
4565         case Xacid_4:
4566         case Xacid_5:
4567         case Xacid_6:
4568         case Xacid_7:
4569         case Xacid_8:
4570           Cave[y][x] = Xsand_stonesand_3;
4571           if (Cave[y][x+1] == Xblank)
4572             Cave[y][x+1] = Yacid_splash_eB;
4573           if (Cave[y][x-1] == Xblank)
4574             Cave[y][x-1] = Yacid_splash_wB;
4575           Next[y][x] = Xsand_stonesand_4;
4576           play_sound(x, y, SAMPLE_acid);
4577           goto loop;
4578
4579         case Xblank:
4580         case Yacid_splash_eB:
4581         case Yacid_splash_wB:
4582           Cave[y][x] = Xsand_stonesand_3;
4583           Cave[y+1][x] = Xsand_stoneout_1;
4584           Next[y][x] = Xsand_stonesand_4;
4585           Next[y+1][x] = Xsand_stoneout_2;
4586           goto loop;
4587
4588         case Xsand:
4589           Cave[y][x] = Xsand_stonesand_1;
4590           Cave[y+1][x] = Xsand_sandstone_1;
4591           Next[y][x] = Xsand_stonesand_2;
4592           Next[y+1][x] = Xsand_sandstone_2;
4593           goto loop;
4594
4595         default:
4596           goto loop;
4597       }
4598
4599     case Xsand_stonein_1:
4600       Next[y][x] = Xsand_stonein_2;
4601       goto loop;
4602
4603     case Xsand_stonein_2:
4604       Next[y][x] = Xsand_stonein_3;
4605       goto loop;
4606
4607     case Xsand_stonein_3:
4608       Next[y][x] = Xsand_stonein_4;
4609       goto loop;
4610
4611     case Xsand_stonein_4:
4612       Next[y][x] = Xblank;
4613       goto loop;
4614
4615     case Xsand_stonesand_1:
4616       Next[y][x] = Xsand_stonesand_2;
4617       goto loop;
4618
4619     case Xsand_stonesand_2:
4620       Next[y][x] = Xsand_stonesand_3;
4621       goto loop;
4622
4623     case Xsand_stonesand_3:
4624       Next[y][x] = Xsand_stonesand_4;
4625       goto loop;
4626
4627     case Xsand_stonesand_4:
4628       Next[y][x] = Xsand;
4629       goto loop;
4630
4631     case Xsand_stoneout_1:
4632       Next[y][x] = Xsand_stoneout_2;
4633       goto loop;
4634
4635     case Xsand_stoneout_2:
4636       Next[y][x] = Xstone_fall;
4637       goto loop;
4638
4639     case Xsand_sandstone_1:
4640       Next[y][x] = Xsand_sandstone_2;
4641       goto loop;
4642
4643     case Xsand_sandstone_2:
4644       Next[y][x] = Xsand_sandstone_3;
4645       goto loop;
4646
4647     case Xsand_sandstone_3:
4648       Next[y][x] = Xsand_sandstone_4;
4649       goto loop;
4650
4651     case Xsand_sandstone_4:
4652       Next[y][x] = Xsand_stone;
4653       goto loop;
4654
4655     /* --------------------------------------------------------------------- */
4656
4657     case Xdripper:
4658       if (lev.lenses_cnt)
4659         Cave[y][x] = XdripperB;
4660       goto loop;
4661
4662     /* --------------------------------------------------------------------- */
4663
4664     case Xfake_blank:
4665       if (lev.lenses_cnt)
4666         Cave[y][x] = Xfake_blankB;
4667       goto loop;
4668
4669     /* --------------------------------------------------------------------- */
4670
4671     case Xfake_grass:
4672       if (lev.magnify_cnt)
4673         Cave[y][x] = Xfake_grassB;
4674       goto loop;
4675
4676     /* --------------------------------------------------------------------- */
4677
4678     case Xfake_door_1:
4679       if (lev.magnify_cnt)
4680         Cave[y][x] = Xdoor_1;
4681       goto loop;
4682
4683     case Xfake_door_2:
4684       if (lev.magnify_cnt)
4685         Cave[y][x] = Xdoor_2;
4686       goto loop;
4687
4688     case Xfake_door_3:
4689       if (lev.magnify_cnt)
4690         Cave[y][x] = Xdoor_3;
4691       goto loop;
4692
4693     case Xfake_door_4:
4694       if (lev.magnify_cnt)
4695         Cave[y][x] = Xdoor_4;
4696       goto loop;
4697
4698     case Xfake_door_5:
4699       if (lev.magnify_cnt)
4700         Cave[y][x] = Xdoor_5;
4701       goto loop;
4702
4703     case Xfake_door_6:
4704       if (lev.magnify_cnt)
4705         Cave[y][x] = Xdoor_6;
4706       goto loop;
4707
4708     case Xfake_door_7:
4709       if (lev.magnify_cnt)
4710         Cave[y][x] = Xdoor_7;
4711       goto loop;
4712
4713     case Xfake_door_8:
4714       if (lev.magnify_cnt)
4715         Cave[y][x] = Xdoor_8;
4716       goto loop;
4717
4718     /* --------------------------------------------------------------------- */
4719
4720     case Xboom_bug:
4721       bug_boom:
4722       Next[y][x] = Znormal;
4723       Boom[y-1][x-1] = Xemerald;
4724       Boom[y-1][x] = Xemerald;
4725       Boom[y-1][x+1] = Xemerald;
4726       Boom[y][x-1] = Xemerald;
4727       Boom[y][x] = Xdiamond;
4728       Boom[y][x+1] = Xemerald;
4729       Boom[y+1][x-1] = Xemerald;
4730       Boom[y+1][x] = Xemerald;
4731       Boom[y+1][x+1] = Xemerald;
4732       goto loop;
4733
4734     case Xboom_bomb:
4735
4736     tank_boom:
4737
4738       Next[y][x] = Znormal;
4739       Boom[y-1][x-1] = Xblank;
4740       Boom[y-1][x] = Xblank;
4741       Boom[y-1][x+1] = Xblank;
4742       Boom[y][x-1] = Xblank;
4743       Boom[y][x] = Xblank;
4744       Boom[y][x+1] = Xblank;
4745       Boom[y+1][x-1] = Xblank;
4746       Boom[y+1][x] = Xblank;
4747       Boom[y+1][x+1] = Xblank;
4748       goto loop;
4749
4750     case Xboom_android:
4751     case Xboom_1:
4752       Next[y][x] = Xboom_2;
4753       play_sound(x, y, SAMPLE_boom);
4754       goto loop;
4755
4756     case Xboom_2:
4757       Next[y][x] = Boom[y][x];
4758       goto loop;
4759
4760     /* --------------------------------------------------------------------- */
4761
4762     case ZBORDER:
4763       if (++y < HEIGHT - 1)
4764       {
4765         x = 0;
4766         cave_cache = Cave[y];
4767         goto loop;
4768       }
4769
4770       goto done;
4771   }
4772
4773 #undef RANDOM
4774 #undef PLAY
4775 #undef PLAY_FORCE
4776
4777  done:
4778
4779   if (ply1.alive || ply2.alive)
4780     lev.score += score; /* only get a score if someone is alive */
4781
4782   Random = random;
4783
4784   {
4785     void *temp = Cave;
4786
4787     /* triple buffering */
4788     Cave = Next;
4789     Next = Draw;
4790     Draw = temp;
4791   }
4792 }