X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_em%2Fconvert.c;h=8a44053cabfa187cfe24cff148c6729a8b160d69;hb=b640b9d7647df4cbba0e530f6f4bcece384048e4;hp=3aa00be4d19cc842565791444b865d68dab69f4e;hpb=f772f882546ab982dc61074f298d6115c9909f32;p=rocksndiamonds.git diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 3aa00be4..8a44053c 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -8,11 +8,11 @@ * inconsequential, but no doubt it will break some caves. */ -#include "global.h" -#include "tile.h" -#include "level.h" +#include "main_em.h" +#define ALLOW_ROLLING_SPRING + static unsigned char remap_v6[256] = { /* filter crap for v6 */ @@ -22,7 +22,11 @@ static unsigned char remap_v6[256] = 0,16,2,18, 36,37,37,37, 40,41,42,43, 44,45,128,128, 128,148,148, 148,45,45,45, 148,0,57,58, 59,60,61,62,63, +#ifdef ALLOW_ROLLING_SPRING + 64,65,66,67, 68,69,69,71, 72,73,74,75, 118,75,75,75, +#else 64,65,66,67, 68,69,69,69, 69,73,74,75, 118,75,75,75, +#endif 75,75,75,75, 75,153,153,153, 153,153,153,153, 153,153,153,153, 153,153,153,99, 100,68,68,68, 68,68,68,68, 68,118,118,118, 118,118,114,115, 131,118,118,119, 120,121,122,118, 118,118,118,118, @@ -181,6 +185,7 @@ int cleanup_em_level(unsigned char *src, int length) for (i = 0; i < 2106; i++) src[i] = (src[i] ^ (j += 7)) - 0x11; + src[0] = 131; /* needed for Emerald Mine II levels */ src[1] = 131; for (i = 0; i < 2048; i++) src[i] = remap_v4[src[i]]; @@ -199,7 +204,7 @@ int cleanup_em_level(unsigned char *src, int length) { /* ---------- this cave has unknown file format ---------- */ -#if 1 +#if 0 printf("::: %d, %d\n", src[0], src[1983]); #endif @@ -441,6 +446,11 @@ int cleanup_em_level(unsigned char *src, int length) * - 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] = @@ -465,10 +475,17 @@ static unsigned short remap_emerald[256] = 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, @@ -547,6 +564,20 @@ static unsigned short remap_emerald[256] = #endif }; +static int get_em_element(unsigned short em_element_raw, int file_version) +{ + int em_element = remap_emerald[em_element_raw]; + + if (file_version <= FILE_VERSION_EM_V4) + { + /* versions up to V4 had no grass, but only sand/dirt */ + if (em_element == Xgrass) + em_element = Xdirt; + } + + return em_element; +} + void convert_em_level(unsigned char *src, int file_version) { static int eater_offset[8] = @@ -616,9 +647,10 @@ void convert_em_level(unsigned char *src, int file_version) for (i = 0; i < 8; i++) for (x = 0; x < 9; x++) - lev.eater_array[i][x] = remap_emerald[src[eater_offset[i] + x]]; + lev.eater_array[i][x] = + get_em_element(src[eater_offset[i] + x], file_version); - temp = remap_emerald[src[0x86F]]; + temp = get_em_element(src[0x86F], file_version); for (y = 0; y < 8; y++) { if (src[0x872] & 1) @@ -888,7 +920,8 @@ void convert_em_level(unsigned char *src, int file_version) temp = 0; for (y = 0; y < lev.height; y++) for (x = 0; x < lev.width; x++) - native_em_level.cave[x + 1][y + 1] = remap_emerald[src[temp++]]; + native_em_level.cave[x + 1][y + 1] = + get_em_element(src[temp++], file_version); /* at last, set the two players at their positions in the playfield */ /* (native EM[C] levels always have exactly two players in a level) */