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