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