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