changed order of functions in EM engine source file
[rocksndiamonds.git] / src / game_em / synchro_3.c
index f094ceebc3684c42cbed64fe4d229c82acc52472..8ec410d34eb61f6b842ab19cece7c90e1c3b312e 100644 (file)
@@ -5,33 +5,21 @@
  * this should be spread over the frames for reduced cpu load.
  */
 
-#include "tile.h"
-#include "level.h"
-#include "sample.h"
+#include "main_em.h"
 
 
 void synchro_3(void)
 {
-  register unsigned int x;
-  register unsigned int y;
-  register unsigned int count;
-  register unsigned long random;
+  int x;
+  int y;
+  int count;
+  unsigned int random;
 
   /* update variables */
 
   if (lev.score > 9999)
     lev.score = 9999;
 
-#if 1
-  if (lev.time_initial == 0)
-    lev.time++;
-  else if (lev.time)
-    lev.time--;
-#else
-  if (lev.time)
-    lev.time--;
-#endif
-
   if (lev.android_move_cnt-- == 0)
     lev.android_move_cnt = lev.android_move_time;
   if (lev.android_clone_cnt-- == 0)
@@ -50,72 +38,68 @@ void synchro_3(void)
   if (lev.wonderwall_time && lev.wonderwall_state)
     lev.wonderwall_time--;
 
-  if (lev.time_initial > 0 &&
-      lev.time > 0 && lev.time <= 50 && lev.time % 5 == 0)
-    play_sound(-1, -1, SAMPLE_time);
-
   if (lev.wheel_cnt)
-    play_sound(-1, -1, SAMPLE_wheel);
+    play_element_sound(lev.wheel_x, lev.wheel_y, SOUND_wheel, Xwheel);
 
   /* grow amoeba */
 
-  random = Random;
+  random = RandomEM;
 
   for (count = lev.amoeba_time; count--;)
   {
     x = (random >> 10) % (WIDTH - 2);
     y = (random >> 20) % (HEIGHT - 2);
-    switch (Cave[y][x])
+    switch (Cave[x][y])
     {
       case Xblank:
-      case Yacid_splash_eB:
-      case Yacid_splash_wB:
+      case Xacid_splash_e:
+      case Xacid_splash_w:
       case Xgrass:
       case Xdirt:
       case Xsand:
       case Xplant:
       case Yplant:
-       if (tab_amoeba[Cave[y-1][x]] ||
-           tab_amoeba[Cave[y][x+1]] ||
-           tab_amoeba[Cave[y+1][x]] ||
-           tab_amoeba[Cave[y][x-1]])
-         Cave[y][x] = Xdrip_eat;
+       if (tab_amoeba[Cave[x][y-1]] ||
+           tab_amoeba[Cave[x+1][y]] ||
+           tab_amoeba[Cave[x][y+1]] ||
+           tab_amoeba[Cave[x-1][y]])
+         Cave[x][y] = Xdrip;
     }
 
     random = random * 129 + 1;
   }
 
-  Random = random;
+  RandomEM = random;
 
   /* handle explosions */
 
   for (y = 1; y < HEIGHT - 1; y++)
     for (x = 1; x < WIDTH - 1; x++)
     {
-      switch (Cave[y][x])
+      switch (Cave[x][y])
       {
         case Znormal:
-         Cave[y][x] = Xboom_1;
-         Cave[y-1][x] = tab_explode_normal[Cave[y-1][x]];
-         Cave[y][x-1] = tab_explode_normal[Cave[y][x-1]];
-         Cave[y][x+1] = tab_explode_normal[Cave[y][x+1]];
-         Cave[y+1][x] = tab_explode_normal[Cave[y+1][x]];
-         Cave[y-1][x-1] = tab_explode_normal[Cave[y-1][x-1]];
-         Cave[y-1][x+1] = tab_explode_normal[Cave[y-1][x+1]];
-         Cave[y+1][x-1] = tab_explode_normal[Cave[y+1][x-1]];
-         Cave[y+1][x+1] = tab_explode_normal[Cave[y+1][x+1]];
+         Cave[x][y] = Xboom_1;
+         Cave[x][y-1] = tab_explode_normal[Cave[x][y-1]];
+         Cave[x-1][y] = tab_explode_normal[Cave[x-1][y]];
+         Cave[x+1][y] = tab_explode_normal[Cave[x+1][y]];
+         Cave[x][y+1] = tab_explode_normal[Cave[x][y+1]];
+         Cave[x-1][y-1] = tab_explode_normal[Cave[x-1][y-1]];
+         Cave[x+1][y-1] = tab_explode_normal[Cave[x+1][y-1]];
+         Cave[x-1][y+1] = tab_explode_normal[Cave[x-1][y+1]];
+         Cave[x+1][y+1] = tab_explode_normal[Cave[x+1][y+1]];
          break;
 
         case Zdynamite:
-         Cave[y][x] = Xboom_1;
-         Cave[y-1][x] = tab_explode_dynamite[Cave[y-1][x]];
-         Cave[y][x-1] = tab_explode_dynamite[Cave[y][x-1]];
-         Cave[y][x+1] = tab_explode_dynamite[Cave[y][x+1]];
-         Cave[y+1][x] = tab_explode_dynamite[Cave[y+1][x]];
-         Cave[y-1][x-1] = tab_explode_dynamite[Cave[y-1][x-1]];
-         Cave[y-1][x+1] = tab_explode_dynamite[Cave[y-1][x+1]];
-         Cave[y+1][x-1] = tab_explode_dynamite[Cave[y+1][x-1]];
-         Cave[y+1][x+1] = tab_explode_dynamite[Cave[y+1][x+1]];
+         Cave[x][y] = Xboom_1;
+         Cave[x][y-1] = tab_explode_dynamite[Cave[x][y-1]];
+         Cave[x-1][y] = tab_explode_dynamite[Cave[x-1][y]];
+         Cave[x+1][y] = tab_explode_dynamite[Cave[x+1][y]];
+         Cave[x][y+1] = tab_explode_dynamite[Cave[x][y+1]];
+         Cave[x-1][y-1] = tab_explode_dynamite[Cave[x-1][y-1]];
+         Cave[x+1][y-1] = tab_explode_dynamite[Cave[x+1][y-1]];
+         Cave[x-1][y+1] = tab_explode_dynamite[Cave[x-1][y+1]];
+         Cave[x+1][y+1] = tab_explode_dynamite[Cave[x+1][y+1]];
          break;
       }
     }
@@ -124,5 +108,5 @@ void synchro_3(void)
 
   for (y = 0; y < HEIGHT; y++)
     for (x = 0; x < WIDTH; x++)
-      Next[y][x] = Cave[y][x];
+      Next[x][y] = Cave[x][y];
 }