* behaviour.
*/
+/* changes for game engine integration in Rocks'n'Diamonds:
+ *
+ * added support for rolling spring (not mapped to pushed spring)
+ * - required for Elvis Mine 8, levels 3, 23, 48 and 73
+ */
+
#define GET_BE16(x) ((&x)[0] << 8 | (&x)[1])
-static const short map_emc[256] =
+static const short map_emc_raw[256] =
{
Cstone, Cstone, Cdiamond, Cdiamond, // 0
Calien, Calien, Cpause, Cpause, // 4
Cdynamite_2, Cdynamite_3, Cdynamite_4, Cacid_s, // 60
Cexit_1, Cexit_2, Cexit_3, Cballoon, // 64
- Cplant, Cspring, Cspring, Cpush_spring_w, // 68
- Cpush_spring_e, Cball_1, Cball_2, Candroid, // 72
+ Cplant, Cspring, Cspring, Cspring_w, // 68
+ Cspring_e, Cball_1, Cball_2, Candroid, // 72
Cpause, Candroid, Candroid, Candroid, // 76
Candroid, Candroid, Candroid, Candroid, // 80
Candroid, Cblank, Cblank, Cblank, // 84
Cwall_1, Cblank, Calpha_copyr, Cfake_acid_1 // 252
};
+static const short swap_emc[CAVE_TILE_MAX] =
+{
+ [Cdirt] = Cgrass,
+ [Cgrass] = Cdirt,
+
+ [Csteel_1] = Csteel_2,
+ [Csteel_2] = Csteel_1,
+
+ [Cwall_1] = Cwall_2,
+ [Cwall_2] = Cwall_1,
+
+ [Croundwall_1] = Croundwall_2,
+ [Croundwall_2] = Croundwall_1
+};
+
static struct
{
int bit_nr;
void convert_em_level(unsigned char *src, int file_version)
{
int i, x, y, temp;
+ short map_emc[256];
+
+ /* initialize element mapping */
+
+ for (i = 0; i < 256; i++)
+ map_emc[i] = map_emc_raw[i];
+
+ /* swap tiles for pre-EMC caves (older than V5/V6), if needed */
+
+ if (swapTiles_EM(file_version < FILE_VERSION_EM_V5))
+ for (i = 0; i < 256; i++)
+ if (swap_emc[map_emc[i]] != 0)
+ map_emc[i] = swap_emc[map_emc[i]];
/* common to all emc caves */
cav.time_seconds = MIN(GET_BE16(src[2110]), 9999);
cav.gems_needed = src[2095];
- cav.infinite = TRUE;
- cav.testmode = FALSE;
cav.teamwork = (src[2150] & 128) != 0;
/* scores */
cav.nut_score = src[2090];
cav.dynamite_score = src[2091];
cav.key_score = src[2092];
- cav.exit_score = src[2093] * 8 / 5;
+ cav.exit_score = src[2093];
cav.lenses_score = src[2151];
cav.magnify_score = src[2152];
for (x = 0; x < 9; x++)
cav.eater_array[i][x] = map_emc[src[eater_offset[i] + x]];
+ if (file_version < FILE_VERSION_EM_V6)
+ cav.num_eater_arrays = 4;
+
/* ball */
temp = map_emc[src[2159]];
/* filter for v6 */
0,0,2,2, 4,4,118,118, 8,9,10,11, 12,13,14,15, // 0
- 16,16,18,18, 20,21,22,23, 24,25,26,27, 28,28,118,28, // 16
+ 16,16,18,18, 20,21,22,23, 24,25,26,27, 28,28,128,28, // 16
0,16,2,18, 36,37,37,37, 40,41,42,43, 44,45,128,128, // 32
128,148,148,148, 45,45,45,148, 0,57,58,59, 60,61,62,63, // 48
/* filter for v5 */
0,0,2,2, 4,4,118,118, 8,9,10,11, 12,13,14,15, // 0
- 16,16,18,18, 20,21,22,23, 24,25,26,27, 28,28,118,28, // 16
+ 16,16,18,18, 20,21,22,23, 24,25,26,27, 28,28,128,28, // 16
0,16,2,18, 36,37,37,37, 147,41,42,43, 44,45,128,128, // 32
128,148,148,148, 45,45,45,148, 0,57,58,59, 60,61,62,63, // 48
64,65,66,67, 68,153,153,153, 153,153,153,153, 153,153,153,153, // 64
153,153,153,153, 153,153,153,153, 153,153,153,153, 153,153,153,153, // 80
153,153,153,153, 153,68,68,68, 68,68,68,68, 68,118,118,118, // 96
- 118,118,114,115, 131,118,118,119, 120,121,122,118, 118,118,118,118, // 112
+ 118,118,114,115, 131,62,118,119, 120,121,122,118, 118,118,118,118, // 112
128,129,130,131, 132,133,134,135, 136,137,138,139, 140,141,142,143, // 128
144,145,146,147, 148,149,150,151, 152,153,154,155, 156,157,158,159, // 144
/* filter for v4 */
0,0,2,2, 4,4,118,118, 8,9,10,11, 12,13,14,15, // 0
- 16,16,18,18, 20,21,22,23, 24,25,26,27, 28,28,118,28, // 16
+ 16,16,18,18, 20,21,22,23, 24,25,26,27, 28,28,128,28, // 16
0,16,2,18, 36,37,37,37, 147,41,42,43, 44,45,128,128, // 32
128,148,148,148, 45,45,45,148, 0,153,153,59, 60,61,62,63, // 48
64,65,66,153, 153,153,153,153, 153,153,153,153, 153,153,153,153, // 64
153,153,153,153, 153,153,153,153, 153,153,153,153, 153,153,153,153, // 80
153,153,153,153, 153,153,153,153, 153,153,153,153, 153,153,153,153, // 96
- 153,118,114,115, 131,118,118,119, 120,121,122,118, 118,118,118,118, // 112
+ 153,118,114,115, 179,62,118,119, 120,121,122,118, 118,118,118,118, // 112
128,180,189,179, 252,133,134,135, 136,137,138,139, 140,141,142,143, // 128
- 144,145,146,147, 148,149,150,151, 152,68,154,155, 156,157,158,160, // 144
+ 144,145,146,147, 148,149,150,151, 152,68,248,249, 250,251,158,160, // 144
160,160,160,160, 160,160,160,160, 160,160,160,160, 160,160,160,175, // 160
153,153,153,153, 153,153,153,153, 153,153,153,153, 153,153,68,153, // 176
240,241,153,153, 153,153,153,153, 153,153,153,153, 153,153,153,153 // 240
};
-static const unsigned char map_v4_eater[32] =
+static const unsigned char map_v4_eater[28] =
{
/* filter for v4 eater */
128,18,2,0, 4,8,16,20, 28,37,41,45, 189,180,179,252, // 0
- 133,134,135,136, 146,147,175,65, 66,64,2,18, 128,128,128,128 // 16
+ 133,134,135,136, 146,147,175,65, 66,64,2,18 // 16
};
static boolean filename_has_v1_format(char *filename)
for (i = 0; i < 2048; i++) /* cave */
src[i] = map_v4[src[i]];
for (i = 2048; i < 2084; i++) /* eaters */
- src[i] = map_v4_eater[src[i] % 32];
+ src[i] = map_v4_eater[src[i] < 28 ? src[i] : 0];
for (i = 2112; i < 2148; i++) /* eaters */
src[i] = src[i - 64];
/* if file has length of old-style level file, print (wrong) magic byte */
if (length < 2110)
- Error(ERR_WARN, "unknown magic byte 0x%02x at position 0x%04x",
- src[1983], 1983);
+ Warn("unknown magic byte 0x%02x at position 0x%04x", src[1983], 1983);
return FILE_VERSION_EM_UNKNOWN;
}
/* size of v6 cave */
length = 2172;
- if (options.debug)
- Error(ERR_DEBUG, "EM level file version: %d", file_version);
+ Debug("level:native:EM", "EM level file version: %d", file_version);
return file_version;
}