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