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