changed order of switch cases in EM engine source file
[rocksndiamonds.git] / src / game_em / convert.c
index 0b3f05aa04a5c96c8467b3b20f5f28a7028ca3ca..17f709853ebef7e9625058eeb1508e59ad963d7c 100644 (file)
@@ -536,7 +536,7 @@ static unsigned short remap_emerald[256] =
 
   Xblank,              Xsand,          Xsand,          Xsand,
   Xsand_stone,         Xsand_stone,    Xsand_stone,    Xsand,
-  Xstone,              Xslidewall_ew,  Xslidewall_ns,  Xdynamite_1,
+  Xstone,              Xslide_ew,      Xslide_ns,      Xdynamite_1,
   Xdynamite_2,         Xdynamite_3,    Xdynamite_4,    Xacid_s,
 
   Xexit_1,             Xexit_2,        Xexit_3,        Xballoon,
@@ -938,18 +938,34 @@ void prepare_em_level(void)
 
   /* reset all runtime variables to their initial values */
 
-  for (y = 0; y < CAVE_HEIGHT; y++)
-    for (x = 0; x < CAVE_WIDTH; x++)
-      lev.cave[x + CAVE_BUFFER_XOFFSET][y + CAVE_BUFFER_YOFFSET] =
-       native_em_level.cave[x][y];
+  game_init_cave_buffers();
+
+  lev.left = CAVE_BUFFER_XOFFSET;
+  lev.top  = CAVE_BUFFER_YOFFSET;
+  lev.right = lev.left + lev.width;
+  lev.bottom = lev.top + lev.height;
+
+  /* add linked cave buffer columns for wrap-around movement */
+  for (x = 0; x < lev.left; x++)
+  {
+    lev.cavecol[x] = lev.cavecol[lev.width + x];
+    lev.nextcol[x] = lev.nextcol[lev.width + x];
+    lev.drawcol[x] = lev.drawcol[lev.width + x];
+    lev.boomcol[x] = lev.boomcol[lev.width + x];
+
+    lev.cavecol[lev.right + x] = lev.cavecol[lev.left + x];
+    lev.nextcol[lev.right + x] = lev.nextcol[lev.left + x];
+    lev.drawcol[lev.right + x] = lev.drawcol[lev.left + x];
+    lev.boomcol[lev.right + x] = lev.boomcol[lev.left + x];
+  }
 
-  for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
-    for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
-      lev.next[x][y] = lev.cave[x][y];
+  for (x = 0; x < lev.width; x++)
+    for (y = 0; y < lev.height; y++)
+      lev.cave[lev.left + x][lev.top + y] = native_em_level.cave[x][y];
 
-  for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
-    for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
-      lev.draw[x][y] = lev.cave[x][y];
+  for (x = lev.left; x < lev.right; x++)
+    for (y = lev.top; y < lev.bottom; y++)
+      lev.next[x][y] = lev.draw[x][y] = lev.cave[x][y];
 
   lev.time_initial = lev.time_seconds;
   lev.time = lev.time_initial;
@@ -1022,9 +1038,9 @@ void prepare_em_level(void)
 
        native_em_level.cave[x][y] = Xblank;
 
-       lev.cave[x + CAVE_BUFFER_XOFFSET][y + CAVE_BUFFER_YOFFSET] = Xblank;
-       lev.next[x + CAVE_BUFFER_XOFFSET][y + CAVE_BUFFER_YOFFSET] = Xblank;
-       lev.draw[x + CAVE_BUFFER_XOFFSET][y + CAVE_BUFFER_YOFFSET] = Xblank;
+       lev.cave[lev.left + x][lev.top + y] = Xblank;
+       lev.next[lev.left + x][lev.top + y] = Xblank;
+       lev.draw[lev.left + x][lev.top + y] = Xblank;
       }
     }
   }
@@ -1037,8 +1053,8 @@ void prepare_em_level(void)
     ply[i].dynamite_cnt = 0;
     ply[i].keys = 0;
     ply[i].anim = 0;
-    ply[i].oldx = ply[i].x = ply[i].x_initial + CAVE_BUFFER_XOFFSET;
-    ply[i].oldy = ply[i].y = ply[i].y_initial + CAVE_BUFFER_YOFFSET;
+    ply[i].oldx = ply[i].x = ply[i].x_initial + lev.left;
+    ply[i].oldy = ply[i].y = ply[i].y_initial + lev.top;
     ply[i].last_move_dir = MV_NONE;
     ply[i].joy_n = ply[i].joy_e = ply[i].joy_s = ply[i].joy_w = 0;
     ply[i].joy_snap  = ply[i].joy_drop = 0;