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