X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_em%2Fconvert.c;h=9e253dad12e75f8755a7f16376d9e9b944e32096;hb=d8e3568accbc475855027f7199e55543dc4d1ddf;hp=3f86d332a3157c233d5127e621259ffd729a93b8;hpb=e6c0b4c0114691d197018f878e0150a3f5d8490e;p=rocksndiamonds.git diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 3f86d332..9e253dad 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -88,60 +88,64 @@ static unsigned char remap_v4eater[28] = 146,147,175,65,66,64,2,18 }; -boolean cleanup_em_level(unsigned char *src, int *length) +int cleanup_em_level(unsigned char *src, int length) { - unsigned int i; + int file_version = 0; + int i; - if (*length >= 2172 && + if (length >= 2172 && src[2106] == 255 && src[2107] == 54 && src[2108] == 48 && src[2109] == 48) { + /* ---------- this cave has V6 file format ---------- */ + file_version = FILE_VERSION_EM_V6; + for (i = 0; i < 2048; i++) src[i] = remap_v6[src[i]]; for (i = 2048; i < 2084; i++) src[i] = remap_v6[src[i]]; for (i = 2112; i < 2148; i++) src[i] = remap_v6[src[i]]; - - goto v6; } - - if (*length >= 2110 && - src[2106] == 255 && - src[2107] == 53 && - src[2108] == 48 && - src[2109] == 48) + else if (length >= 2110 && + src[2106] == 255 && + src[2107] == 53 && + src[2108] == 48 && + src[2109] == 48) { + /* ---------- this cave has V5 file format ---------- */ + file_version = FILE_VERSION_EM_V5; + for (i = 0; i < 2048; i++) src[i] = remap_v5[src[i]]; for (i = 2048; i < 2084; i++) src[i] = remap_v5[src[i]]; for (i = 2112; i < 2148; i++) src[i] = src[i - 64]; - - goto v5; } - - if (*length >= 2106 && - src[1983] == 116) + else if (length >= 2106 && + src[1983] == 116) { + /* ---------- this cave has V4 file format ---------- */ + file_version = FILE_VERSION_EM_V4; + for (i = 0; i < 2048; i++) src[i] = remap_v4[src[i]]; for (i = 2048; i < 2084; i++) src[i] = remap_v4eater[src[i] >= 28 ? 0 : src[i]]; for (i = 2112; i < 2148; i++) src[i] = src[i - 64]; - - goto v4; } - - if (*length >= 2106 && - src[0] == 241 && - src[1983] == 27) + else if (length >= 2106 && + src[0] == 241 && + src[1983] == 27) { unsigned char j = 94; + /* ---------- this cave has V3 file format ---------- */ + file_version = FILE_VERSION_EM_V3; + for (i = 0; i < 2106; i++) src[i] = (src[i] ^ (j += 7)) - 0x11; src[1] = 131; @@ -151,34 +155,35 @@ boolean cleanup_em_level(unsigned char *src, int *length) src[i] = remap_v4eater[src[i] >= 28 ? 0 : src[i]]; for (i = 2112; i < 2148; i++) src[i] = src[i - 64]; - - goto v3; } + else + { + /* ---------- this cave has unknown file format ---------- */ - return FALSE; /* unrecognized cave */ - - v3: - v4: - v5: - - /* id */ - src[2106] = 255; - src[2107] = 54; - src[2108] = 48; - src[2109] = 48; - - /* time */ - i = src[2094] * 10; - src[2110] = i >> 8; - src[2111] = i; - - for (i = 2148; i < 2172; i++) - src[i] = 0; + return 0; + } - /* ball data */ - src[2159] = 128; + if (file_version < FILE_VERSION_EM_V6) + { + /* id */ + src[2106] = 255; + src[2107] = 54; + src[2108] = 48; + src[2109] = 48; + + /* time */ + i = src[2094] * 10; + src[2110] = i >> 8; + src[2111] = i; + + for (i = 2148; i < 2172; i++) + src[i] = 0; + + /* ball data */ + src[2159] = 128; + } - v6: + /* ---------- at this stage, the cave data always has V6 format ---------- */ /* fix wheel */ for (i = 0; i < 2048; i++) @@ -319,9 +324,9 @@ boolean cleanup_em_level(unsigned char *src, int *length) src[2168] &= 31; /* size of v6 cave */ - *length = 2172; + length = 2172; - return TRUE; + return file_version; } /* 2000-07-30T00:26:00Z @@ -421,7 +426,7 @@ static unsigned short remap_emerald[256] = Xblank, Xblank, Xblank, Xblank, Xblank, Xblank, Xblank, Xblank, }; -void convert_em_level(unsigned char *src) +void convert_em_level(unsigned char *src, int file_version) { static int eater_offset[8] = { @@ -429,10 +434,17 @@ void convert_em_level(unsigned char *src) }; unsigned int i, x, y, temp; +#if 1 + lev.time_seconds = src[0x83E] << 8 | src[0x83F]; + if (lev.time_seconds > 9999) + lev.time_seconds = 9999; +#else temp = ((src[0x83E] << 8 | src[0x83F]) * 25 + 3) / 4; if (temp == 0 || temp > 9999) temp = 9999; lev.time_initial = temp; +#endif + lev.required_initial = src[0x82F]; temp = src[0x830] << 8 | src[0x831]; @@ -469,17 +481,9 @@ void convert_em_level(unsigned char *src) lev.slurp_score = src[0x869]; lev.lenses_time = src[0x86A] << 8 | src[0x86B]; - lev.lenses_cnt_initial = 0; - lev.magnify_time = src[0x86C] << 8 | src[0x86D]; - lev.magnify_cnt_initial = 0; - lev.wheel_time = src[0x838] << 8 | src[0x839]; - lev.wheel_cnt_initial = 0; - lev.wheel_x_initial = 1; - lev.wheel_y_initial = 1; - lev.wind_time = 9999; lev.wind_cnt_initial = src[0x865] & 15 ? lev.wind_time : 0; temp = src[0x865]; lev.wind_direction_initial = (temp & 8 ? 0 : @@ -487,7 +491,6 @@ void convert_em_level(unsigned char *src) temp & 2 ? 2 : temp & 4 ? 3 : 0); - lev.wonderwall_state_initial = 0; lev.wonderwall_time_initial = src[0x836] << 8 | src[0x837]; for (i = 0; i < 8; i++) @@ -515,9 +518,6 @@ void convert_em_level(unsigned char *src) } } - for (temp = 0; temp < TILE_MAX; temp++) - lev.android_array[temp] = Xblank; - temp = src[0x878] << 8 | src[0x879]; if (temp & 1) @@ -748,11 +748,6 @@ void convert_em_level(unsigned char *src) } } - lev.home_initial = 1; /* initial number of players in this level */ - - ply1.alive_initial = (lev.home_initial >= 1); - ply2.alive_initial = (lev.home_initial >= 2); - /* first fill the complete playfield with the default border element */ for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) @@ -769,6 +764,8 @@ void convert_em_level(unsigned char *src) native_em_level.cave[ply1.x_initial][ply1.y_initial] = Zplayer; if (ply2.alive_initial) native_em_level.cave[ply2.x_initial][ply2.y_initial] = Zplayer; + + native_em_level.file_version = file_version; } void prepare_em_level(void) @@ -789,7 +786,9 @@ void prepare_em_level(void) for (x = 0; x < WIDTH; x++) Draw[y][x] = Cave[y][x]; + lev.time_initial = (lev.time_seconds * 50 + 7) / 8; lev.time = lev.time_initial; + lev.required = lev.required_initial; lev.score = 0; @@ -826,7 +825,9 @@ void prepare_em_level(void) ply1.anim = 0; ply1.oldx = ply1.x = ply1.x_initial; ply1.oldy = ply1.y = ply1.y_initial; - ply1.joy_n = ply1.joy_e = ply1.joy_s = ply1.joy_w = ply1.joy_fire = 0; + ply1.last_move_dir = MV_NO_MOVING; + ply1.joy_n = ply1.joy_e = ply1.joy_s = ply1.joy_w = 0; + ply1.joy_snap = ply1.joy_drop = 0; ply1.joy_stick = ply1.joy_spin = 0; ply2.num = 1; @@ -837,6 +838,8 @@ void prepare_em_level(void) ply2.anim = 0; ply2.oldx = ply2.x = ply2.x_initial; ply2.oldy = ply2.y = ply2.y_initial; - ply2.joy_n = ply2.joy_e = ply2.joy_s = ply2.joy_w = ply2.joy_fire = 0; + ply2.last_move_dir = MV_NO_MOVING; + ply2.joy_n = ply2.joy_e = ply2.joy_s = ply2.joy_w = 0; + ply2.joy_snap = ply1.joy_drop = 0; ply2.joy_stick = ply2.joy_spin = 0; }