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