- /* ---------- at this stage, the cave data always has V6 format ---------- */
-
- /* fix wheel */
- for (i = 0; i < 2048; i++)
- if (src[i] == 40)
- break;
- for (i++; i < 2048; i++)
- if (src[i] == 40)
- src[i] = 147;
-
-#if 0
-
- /* fix acid */
- for (i = 64; i < 2048; i++)
- if (src[i] == 63) /* replace element above 'Xacid_s' ... */
- src[i - 64] = 101; /* ... with 'Xacid_1' */
-
-#else
-
-#if 1
- /* fix acid */
- for (i = 64; i < 2048; i++)
- if (src[i] == 63) /* replace element above 'Xacid_s' ... */
- src[i - 64] = 101; /* ... with 'Xacid_1' */
-
- /* fix acid with no base beneath it (see below for details (*)) */
- for (i = 64; i < 2048 - 1; i++)
- {
- if (file_version <= FILE_VERSION_EM_V2 &&
- src[i - 64] == 101 && src[i] != 63) /* acid without base */
- {
- if (src[i - 1] == 101 || /* remove acid over acid row */
- src[i + 1] == 101)
- src[i - 64] = 6; /* replace element above with 'Xblank' */
- else
- src[i - 64] = 255; /* replace element above with 'Xfake_acid_1' */
- }
- }
-
-#else
-
- /* fix acid */
- for (i = 64; i < 2048; i++)
- {
- if (src[i] == 63) /* 'Xacid_s' (acid pool, bottom middle) */
- {
- if (file_version <= FILE_VERSION_EM_V2 &&
- i < 2048 - 64 && src[i + 64] == 63)
- {
- int obj_left = remap_emerald[src[i - 1]];
- int obj_right = remap_emerald[src[i + 1]];
-
- if (obj_left == Xblank || obj_right == Xblank ||
- obj_left == Xplant || obj_right == Xplant)
- src[i - 64] = 6; /* replace element above with 'Xblank' */
- else
- src[i - 64] = 255; /* replace element above with 'Xfake_acid_1' */
- }
- else
- {
- src[i - 64] = 101; /* replace element above with 'Xacid_1' */
- }
- }
- }
-#endif
-#endif
-
- /* fix acid in eater 1 */
- for (i = 2051; i < 2057; i++)
- if (src[i] == 63)
- src[i - 3] = 101;
-
- /* fix acid in eater 2 */
- for (i = 2060; i < 2066; i++)
- if (src[i] == 63)
- src[i - 3] = 101;
-
- /* fix acid in eater 3 */
- for (i = 2069; i < 2075; i++)
- if (src[i] == 63)
- src[i - 3] = 101;
-
- /* fix acid in eater 4 */
- for (i = 2078; i < 2084; i++)
- if (src[i] == 63)
- src[i - 3] = 101;
-
- /* fix acid in eater 5 */
- for (i = 2115; i < 2121; i++)
- if (src[i] == 63)
- src[i - 3] = 101;
-
- /* fix acid in eater 6 */
- for (i = 2124; i < 2130; i++)
- if (src[i] == 63)
- src[i - 3] = 101;
-
- /* fix acid in eater 7 */
- for (i = 2133; i < 2139; i++)
- if (src[i] == 63)
- src[i - 3] = 101;
-
- /* fix acid in eater 8 */
- for (i = 2142; i < 2148; i++)
- if (src[i] == 63)
- src[i - 3] = 101;
-
- /* old style time */
- src[2094] = 0;
-
- /* player 1 pos */
- src[2096] &= 7;
- src[src[2096] << 8 | src[2097]] = 128;
-
- /* player 2 pos */
- src[2098] &= 7;
- src[src[2098] << 8 | src[2099]] = 128;
-
- /* amoeba speed */
- if ((src[2100] << 8 | src[2101]) > 9999)
- {
- src[2100] = 39;
- src[2101] = 15;
- }
-
- /* time wonderwall */
- if ((src[2102] << 8 | src[2103]) > 9999)
- {
- src[2102] = 39;
- src[2103] = 15;
- }
-
- /* time */
- if ((src[2110] << 8 | src[2111]) > 9999)
- {
- src[2110] = 39;
- src[2111] = 15;
- }
-
- /* wind direction */
- i = src[2149];
- i &= 15;
- i &= -i;
- src[2149] = i;
-
- /* time lenses */
- if ((src[2154] << 8 | src[2155]) > 9999)
- {
- src[2154] = 39;
- src[2155] = 15;
- }
-
- /* time magnify */
- if ((src[2156] << 8 | src[2157]) > 9999)
- {
- src[2156] = 39;
- src[2157] = 15;
- }
-
- /* ball object */
- src[2158] = 0;
- src[2159] = remap_v6[src[2159]];
-
- /* ball pause */
- if ((src[2160] << 8 | src[2161]) > 9999)
- {
- src[2160] = 39;
- src[2161] = 15;
- }
-
- /* ball data */
- src[2162] &= 129;
- if (src[2162] & 1)
- src[2163] = 0;
-
- /* android move pause */
- if ((src[2164] << 8 | src[2165]) > 9999)
- {
- src[2164] = 39;
- src[2165] = 15;
- }
-
- /* android clone pause */
- if ((src[2166] << 8 | src[2167]) > 9999)
- {
- src[2166] = 39;
- src[2167] = 15;
- }
-
- /* android data */
- src[2168] &= 31;
-
- /* size of v6 cave */
- length = 2172;
-
- if (options.debug)
- printf("::: EM level file version: %d\n", file_version);
-
- return file_version;
-}
-
-/* 2000-07-30T00:26:00Z
- *
- * Read emerald mine caves version 6
- *
- * v4 and v5 emerald mine caves are converted to v6 (which completely supports
- * older versions)
- *
- * converting to the internal format loses /significant/ information which can
- * break lots of caves.
- *
- * major incompatibilities:
- * - borderless caves behave completely differently, the player no longer
- * "warps" to the other side.
- * - a compile time option for spring can make it behave differently when it
- * rolls.
- * - a compile time option for rolling objects (stone, nut, spring, bomb) only
- * in eater.
- * - acid is always deadly even with no base beneath it (this breaks cave 0 in
- * downunder mine 16)
- * (*) fixed (see above):
- * - downunder mine 16, level 0, works again
- * - downunder mine 11, level 71, corrected (only cosmetically)
- *
- * so far all below have not broken any caves:
- *
- * - active wheel inside an eater will not function, eater explosions will not
- * change settings.
- * - initial collect objects (emerald, diamond, dynamite) don't exist.
- * - initial rolling objects will be moved manually and made into sitting
- * objects.
- * - drips always appear from dots.
- * - more than one thing can fall into acid at the same time.
- * - acid explodes when the player walks into it, rather than splashing.
- * - simultaneous explosions may be in a slightly different order.
- * - quicksand states have been reduced.
- * - acid base is effectively an indestructable wall now which can affect eater
- * explosions.
- * - android can clone forever with a clone pause of 0 (emeralds, diamonds,
- * nuts, stones, bombs, springs).
- *
- * 2001-03-12T02:46:55Z
- * - rolling stuff is now allowed in the cave, i didn't like making this
- * decision.
- * - if BAD_ROLL is not defined, initial rolling objects are moved by hand.
- * - initial collect objects break some cave in elvis mine 5.
- * - different timing for wonderwall break some cave in exception mine 2.
- * - i think i'm pretty locked into always using the bad roll. *sigh*
- * - rolling spring is now turned into regular spring. it appears the emc
- * editor only uses the force code for initially moving spring. i will
- * follow this in my editor.
- *
- * 2006-04-02
- * - introduced ALLOW_ROLLING_SPRING; if defined, do NOT turn rolling spring
- * into regular spring, because this breaks at least E.M.C. Mine 3, level 79
- * (see comment directly above)
- */
-
-static unsigned short remap_emerald[256] =
-{
- Xstone, Xstone, Xdiamond, Xdiamond,
- Xalien, Xalien, Xblank, Xblank,
- Xtank_n, Xtank_e, Xtank_s, Xtank_w,
- Xtank_gon, Xtank_goe, Xtank_gos, Xtank_gow,
-
- Xbomb, Xbomb, Xemerald, Xemerald,
- Xbug_n, Xbug_e, Xbug_s, Xbug_w,
- Xbug_gon, Xbug_goe, Xbug_gos, Xbug_gow,
- Xdrip_eat, Xdrip_eat, Xdrip_eat, Xdrip_eat,
-
- Xstone, Xbomb, Xdiamond, Xemerald,
- Xwonderwall, Xnut, Xnut, Xnut,
- Xwheel, Xeater_n, Xeater_s, Xeater_w,
- Xeater_e, Xsand_stone, Xblank, Xblank,
-
- Xblank, Xsand, Xsand, Xsand,
- Xsand_stone, Xsand_stone, Xsand_stone, Xsand,
- Xstone, Xgrow_ew, Xgrow_ns, Xdynamite_1,
- Xdynamite_2, Xdynamite_3, Xdynamite_4, Xacid_s,
-
-#ifdef ALLOW_ROLLING_SPRING
- Xexit_1, Xexit_2, Xexit_3, Xballoon,
- Xplant, Xspring, Xspring_fall, Xspring_w,
- Xspring_e, Xball_1, Xball_2, Xandroid,
- Xblank, Xandroid, Xandroid, Xandroid,
-#else
- Xexit_1, Xexit_2, Xexit_3, Xballoon,
- Xplant, Xspring, Xspring, Xspring,
- Xspring, Xball_1, Xball_2, Xandroid,
- Xblank, Xandroid, Xandroid, Xandroid,
-#endif
-
- Xandroid, Xandroid, Xandroid, Xandroid,
- Xandroid, Xblank, Xblank, Xblank,
- Xblank, Xblank, Xblank, Xblank,
- Xblank, Xblank, Xblank, Xblank,
-
-#ifdef BAD_ROLL
-
- Xblank, Xblank, Xblank, Xspring_force_w,
- Xspring_force_e, Xacid_1, Xacid_2, Xacid_3,
- Xacid_4, Xacid_5, Xacid_6, Xacid_7,
- Xacid_8, Xblank, Xblank, Xblank,
-
- Xblank, Xblank, Xnut_force_w, Xnut_force_e,
- Xsteel_1, Xblank, Xblank, Xbomb_force_w,
- Xbomb_force_e, Xstone_force_w, Xstone_force_e, Xblank,
- Xblank, Xblank, Xblank, Xblank,
-
-#else
-
- Xblank, Xblank, Xblank, Xspring,
- Xspring, Xacid_1, Xacid_2, Xacid_3,
- Xacid_4, Xacid_5, Xacid_6, Xacid_7,
- Xacid_8, Xblank, Xblank, Xblank,
-
- Xblank, Xblank, Xnut, Xnut,
- Xsteel_1, Xblank, Xblank, Xbomb,
- Xbomb, Xstone, Xstone, Xblank,
- Xblank, Xblank, Xblank, Xblank,
-
-#endif
-
- Xblank, Xround_wall_1, Xgrass, Xsteel_1,
- Xwall_1, Xkey_1, Xkey_2, Xkey_3,
- Xkey_4, Xdoor_1, Xdoor_2, Xdoor_3,
- Xdoor_4, Xdripper, Xfake_door_1, Xfake_door_2,
-
- Xfake_door_3, Xfake_door_4, Xwonderwall, Xwheel,
- Xsand, Xacid_nw, Xacid_ne, Xacid_sw,
- Xacid_se, Xfake_blank, Xamoeba_1, Xamoeba_2,
- Xamoeba_3, Xamoeba_4, Xexit, Xalpha_arrow_w,
-
- Xfake_grass, Xlenses, Xmagnify, Xfake_blank,
- Xfake_grass, Xswitch, Xswitch, Xblank,
- Xdecor_8, Xdecor_9, Xdecor_10, Xdecor_5,
- Xalpha_comma, Xalpha_quote, Xalpha_minus, Xdynamite,
-
- Xsteel_3, Xdecor_6, Xdecor_7, Xsteel_2,
- Xround_wall_2, Xdecor_2, Xdecor_4, Xdecor_3,
- Xwind_nesw, Xwind_e, Xwind_s, Xwind_w,
- Xwind_n, Xdirt, Xplant, Xkey_5,
-
- Xkey_6, Xkey_7, Xkey_8, Xdoor_5,
- Xdoor_6, Xdoor_7, Xdoor_8, Xbumper,
- Xalpha_a, Xalpha_b, Xalpha_c, Xalpha_d,
- Xalpha_e, Xalpha_f, Xalpha_g, Xalpha_h,