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