1 /* 2000-08-20T09:41:18Z
3 * identify all emerald mine caves and turn them into v6 format.
4 * fixes illegal tiles, acid, wheel, limits times, cleans flags.
6 * these tables weed out bad tiles for older caves (eg. wheel on -> wheel off)
7 * and clean up v6 caves (acid, number limits) which should(!) be
8 * inconsequential, but no doubt it will break some caves.
16 static unsigned char remap_v6[256] =
18 /* filter crap for v6 */
20 0,0,2,2,4,4,118,118,8,9,10,11,12,13,14,15,
21 16,16,18,18,20,21,22,23,24,25,26,27,28,28,118,28,
22 0,16,2,18,36,37,37,37,40,41,42,43,44,45,128,128,
23 128,148,148,148,45,45,45,148,0,57,58,59,60,61,62,63,
24 64,65,66,67,68,69,69,69,69,73,74,75,118,75,75,75,
25 75,75,75,75,75,153,153,153,153,153,153,153,153,153,153,153,
26 153,153,153,99,100,68,68,68,68,68,68,68,68,118,118,118,
27 118,118,114,115,131,118,118,119,120,121,122,118,118,118,118,118,
28 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
29 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
30 160,161,162,163,164,165,165,118,168,169,170,171,172,173,174,175,
31 176,177,178,179,180,181,182,183,184,185,186,187,188,189,68,191,
32 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
33 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
34 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
35 240,241,242,243,244,245,153,153,153,153,153,153,153,153,153,153
38 static unsigned char remap_v5[256] =
40 /* filter crap for v5 */
42 0,0,2,2,4,4,118,118,8,9,10,11,12,13,14,15,
43 16,16,18,18,20,21,22,23,24,25,26,27,28,28,118,28,
44 0,16,2,18,36,37,37,37,147,41,42,43,44,45,128,128,
45 128,148,148,148,45,45,45,148,0,57,58,59,60,61,62,63,
46 64,65,66,67,68,153,153,153,153,153,153,153,153,153,153,153,
47 153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
48 153,153,153,153,153,68,68,68,68,68,68,68,68,118,118,118,
49 118,118,114,115,131,118,118,119,120,121,122,118,118,118,118,118,
50 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
51 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
52 160,153,153,153,153,153,153,118,168,169,170,171,172,173,174,175,
53 176,177,178,179,180,181,182,183,184,185,186,187,188,189,68,153,
54 153,153,153,153,153,153,153,153,200,201,202,203,204,205,206,207,
55 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
56 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
57 240,241,153,153,153,153,153,153,153,153,153,153,153,153,153,153
60 static unsigned char remap_v4[256] =
62 /* filter crap for v4 */
64 0,0,2,2,4,4,118,118,8,9,10,11,12,13,14,15,
65 16,16,18,18,20,21,22,23,24,25,26,27,28,28,118,28,
66 0,16,2,18,36,37,37,37,147,41,42,43,44,45,128,128,
67 128,148,148,148,45,45,45,148,0,153,153,59,60,61,62,63,
68 64,65,66,153,153,153,153,153,153,153,153,153,153,153,153,153,
69 153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
70 153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
71 153,118,114,115,131,118,118,119,120,121,122,118,118,118,118,118,
72 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
73 144,145,146,147,148,149,150,151,152,68,154,155,156,157,158,160,
74 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,175,
75 153,153,153,153,153,153,153,153,153,153,153,153,153,153,68,153,
76 153,153,153,153,153,153,153,153,200,201,202,203,204,205,206,207,
77 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
78 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
79 240,241,153,153,153,153,153,153,153,153,153,153,153,153,153,153
82 static unsigned char remap_v4eater[28] =
84 /* filter crap for v4 */
86 128,18,2,0,4,8,16,20,28,37,
87 41,45,130,129,131,132,133,134,135,136,
88 146,147,175,65,66,64,2,18
91 int cleanup_em_level(unsigned char *src, int length)
102 /* ---------- this cave has V6 file format ---------- */
103 file_version = FILE_VERSION_EM_V6;
105 for (i = 0; i < 2048; i++)
106 src[i] = remap_v6[src[i]];
107 for (i = 2048; i < 2084; i++)
108 src[i] = remap_v6[src[i]];
109 for (i = 2112; i < 2148; i++)
110 src[i] = remap_v6[src[i]];
112 else if (length >= 2110 &&
118 /* ---------- this cave has V5 file format ---------- */
119 file_version = FILE_VERSION_EM_V5;
121 for (i = 0; i < 2048; i++)
122 src[i] = remap_v5[src[i]];
123 for (i = 2048; i < 2084; i++)
124 src[i] = remap_v5[src[i]];
125 for (i = 2112; i < 2148; i++)
126 src[i] = src[i - 64];
128 else if (length >= 2106 &&
131 /* ---------- this cave has V4 file format ---------- */
132 file_version = FILE_VERSION_EM_V4;
134 for (i = 0; i < 2048; i++)
135 src[i] = remap_v4[src[i]];
136 for (i = 2048; i < 2084; i++)
137 src[i] = remap_v4eater[src[i] >= 28 ? 0 : src[i]];
138 for (i = 2112; i < 2148; i++) src[i] = src[i - 64];
140 else if (length >= 2106 &&
144 unsigned char j = 94;
146 /* ---------- this cave has V3 file format ---------- */
147 file_version = FILE_VERSION_EM_V3;
149 for (i = 0; i < 2106; i++)
150 src[i] = (src[i] ^ (j += 7)) - 0x11;
152 for (i = 0; i < 2048; i++)
153 src[i] = remap_v4[src[i]];
154 for (i = 2048; i < 2084; i++)
155 src[i] = remap_v4eater[src[i] >= 28 ? 0 : src[i]];
156 for (i = 2112; i < 2148; i++)
157 src[i] = src[i - 64];
161 /* ---------- this cave has unknown file format ---------- */
166 if (file_version < FILE_VERSION_EM_V6)
179 for (i = 2148; i < 2172; i++)
186 /* ---------- at this stage, the cave data always has V6 format ---------- */
189 for (i = 0; i < 2048; i++)
192 for (i++; i < 2048; i++)
197 for (i = 64; i < 2048; i++)
201 /* fix acid in eater 1 */
202 for (i = 2051; i < 2057; i++)
206 /* fix acid in eater 2 */
207 for (i = 2060; i < 2066; i++)
211 /* fix acid in eater 3 */
212 for (i = 2069; i < 2075; i++)
216 /* fix acid in eater 4 */
217 for (i = 2078; i < 2084; i++)
221 /* fix acid in eater 5 */
222 for (i = 2115; i < 2121; i++)
226 /* fix acid in eater 6 */
227 for (i = 2124; i < 2130; i++)
231 /* fix acid in eater 7 */
232 for (i = 2133; i < 2139; i++)
236 /* fix acid in eater 8 */
237 for (i = 2142; i < 2148; i++)
246 src[src[2096] << 8 | src[2097]] = 128;
250 src[src[2098] << 8 | src[2099]] = 128;
253 if ((src[2100] << 8 | src[2101]) > 9999)
259 /* time wonderwall */
260 if ((src[2102] << 8 | src[2103]) > 9999)
267 if ((src[2110] << 8 | src[2111]) > 9999)
280 if ((src[2154] << 8 | src[2155]) > 9999)
287 if ((src[2156] << 8 | src[2157]) > 9999)
295 src[2159] = remap_v6[src[2159]];
298 if ((src[2160] << 8 | src[2161]) > 9999)
309 /* android move pause */
310 if ((src[2164] << 8 | src[2165]) > 9999)
316 /* android clone pause */
317 if ((src[2166] << 8 | src[2167]) > 9999)
326 /* size of v6 cave */
332 /* 2000-07-30T00:26:00Z
334 * Read emerald mine caves version 6
336 * v4 and v5 emerald mine caves are converted to v6 (which completely supports
339 * converting to the internal format loses /significant/ information which can
340 * break lots of caves.
342 * major incompatibilities:
343 * - borderless caves behave completely differently, the player no longer
344 * "warps" to the other side.
345 * - a compile time option for spring can make it behave differently when it
347 * - a compile time option for rolling objects (stone, nut, spring, bomb) only
349 * - acid is always deadly even with no base beneath it.
351 * so far all below have not broken any caves:
353 * - active wheel inside an eater will not function, eater explosions will not
355 * - initial collect objects (emerald, diamond, dynamite) don't exist.
356 * - initial rolling objects will be moved manually and made into sitting
358 * - drips always appear from dots.
359 * - more than one thing can fall into acid at the same time.
360 * - acid explodes when the player walks into it, rather than splashing.
361 * - simultaneous explosions may be in a slightly different order.
362 * - quicksand states have been reduced.
363 * - acid base is effectively an indestructable wall now which can affect eater
365 * - android can clone forever with a clone pause of 0 (emeralds, diamonds,
366 * nuts, stones, bombs, springs).
368 * 2001-03-12T02:46:55Z
369 * - rolling stuff is now allowed in the cave, i didn't like making this
371 * - if BAD_ROLL is not defined, initial rolling objects are moved by hand.
372 * - initial collect objects break some cave in elvis mine 5.
373 * - different timing for wonderwall break some cave in exception mine 2.
374 * - i think i'm pretty locked into always using the bad roll. *sigh*
375 * - rolling spring is now turned into regular spring. it appears the emc
376 * editor only uses the force code for initially moving spring. i will
377 * follow this in my editor.
380 static unsigned short remap_emerald[256] =
382 Xstone, Xstone, Xdiamond, Xdiamond, Xalien, Xalien, Xblank, Xblank,
383 Xtank_n, Xtank_e, Xtank_s, Xtank_w, Xtank_gon, Xtank_goe, Xtank_gos, Xtank_gow,
384 Xbomb, Xbomb, Xemerald, Xemerald, Xbug_n, Xbug_e, Xbug_s, Xbug_w,
385 Xbug_gon, Xbug_goe, Xbug_gos, Xbug_gow, Xdrip_eat, Xdrip_eat, Xdrip_eat, Xdrip_eat,
386 Xstone, Xbomb, Xdiamond, Xemerald, Xwonderwall, Xnut, Xnut, Xnut,
387 Xwheel, Xeater_n, Xeater_s, Xeater_w, Xeater_e, Xsand_stone, Xblank, Xblank,
388 Xblank, Xsand, Xsand, Xsand, Xsand_stone, Xsand_stone, Xsand_stone, Xsand,
389 Xstone, Xgrow_ew, Xgrow_ns, Xdynamite_1, Xdynamite_2, Xdynamite_3, Xdynamite_4, Xacid_s,
390 Xexit_1, Xexit_2, Xexit_3, Xballoon, Xplant, Xspring, Xspring, Xspring,
391 Xspring, Xball_1, Xball_2, Xandroid, Xblank, Xandroid, Xandroid, Xandroid,
392 Xandroid, Xandroid, Xandroid, Xandroid, Xandroid, Xblank, Xblank, Xblank,
393 Xblank, Xblank, Xblank, Xblank, Xblank, Xblank, Xblank, Xblank,
397 Xblank, Xblank, Xblank, Xspring_force_w, Xspring_force_e, Xacid_1, Xacid_2, Xacid_3,
398 Xacid_4, Xacid_5, Xacid_6, Xacid_7, Xacid_8, Xblank, Xblank, Xblank,
399 Xblank, Xblank, Xnut_force_w, Xnut_force_e, Xsteel_1, Xblank, Xblank, Xbomb_force_w,
400 Xbomb_force_e, Xstone_force_w, Xstone_force_e, Xblank, Xblank, Xblank, Xblank, Xblank,
404 Xblank, Xblank, Xblank, Xspring, Xspring, Xacid_1, Xacid_2, Xacid_3,
405 Xacid_4, Xacid_5, Xacid_6, Xacid_7, Xacid_8, Xblank, Xblank, Xblank,
406 Xblank, Xblank, Xnut, Xnut, Xsteel_1, Xblank, Xblank, Xbomb,
407 Xbomb, Xstone, Xstone, Xblank, Xblank, Xblank, Xblank, Xblank,
411 Xblank, Xround_wall_1, Xgrass, Xsteel_1, Xwall_1, Xkey_1, Xkey_2, Xkey_3,
412 Xkey_4, Xdoor_1, Xdoor_2, Xdoor_3, Xdoor_4, Xdripper, Xfake_door_1, Xfake_door_2,
413 Xfake_door_3, Xfake_door_4, Xwonderwall, Xwheel, Xsand, Xacid_nw, Xacid_ne, Xacid_sw,
414 Xacid_se, Xfake_blank, Xamoeba_1, Xamoeba_2, Xamoeba_3, Xamoeba_4, Xexit, Xalpha_arrow_w,
415 Xfake_grass, Xlenses, Xmagnify, Xfake_blank, Xfake_grass, Xswitch, Xswitch, Xblank,
416 Xdecor_8, Xdecor_9, Xdecor_10, Xdecor_5, Xalpha_comma, Xalpha_quote, Xalpha_minus, Xdynamite,
417 Xsteel_3, Xdecor_6, Xdecor_7, Xsteel_2, Xround_wall_2, Xdecor_2, Xdecor_4, Xdecor_3,
418 Xwind_nesw, Xwind_e, Xwind_s, Xwind_w, Xwind_n, Xdirt, Xplant, Xkey_5,
419 Xkey_6, Xkey_7, Xkey_8, Xdoor_5, Xdoor_6, Xdoor_7, Xdoor_8, Xbumper,
420 Xalpha_a, Xalpha_b, Xalpha_c, Xalpha_d, Xalpha_e, Xalpha_f, Xalpha_g, Xalpha_h,
421 Xalpha_i, Xalpha_j, Xalpha_k, Xalpha_l, Xalpha_m, Xalpha_n, Xalpha_o, Xalpha_p,
422 Xalpha_q, Xalpha_r, Xalpha_s, Xalpha_t, Xalpha_u, Xalpha_v, Xalpha_w, Xalpha_x,
423 Xalpha_y, Xalpha_z, Xalpha_0, Xalpha_1, Xalpha_2, Xalpha_3, Xalpha_4, Xalpha_5,
424 Xalpha_6, Xalpha_7, Xalpha_8, Xalpha_9, Xalpha_perio, Xalpha_excla, Xalpha_colon, Xalpha_quest,
425 Xalpha_arrow_e, Xdecor_1, Xfake_door_5, Xfake_door_6, Xfake_door_7, Xfake_door_8, Xblank, Xblank,
426 Xblank, Xblank, Xblank, Xblank, Xblank, Xblank, Xblank, Xblank,
429 void convert_em_level(unsigned char *src, int file_version)
431 static int eater_offset[8] =
433 0x800, 0x809, 0x812, 0x81B, 0x840, 0x849, 0x852, 0x85B
435 unsigned int i, x, y, temp;
438 lev.time_seconds = src[0x83E] << 8 | src[0x83F];
439 if (lev.time_seconds > 9999)
440 lev.time_seconds = 9999;
442 temp = ((src[0x83E] << 8 | src[0x83F]) * 25 + 3) / 4;
443 if (temp == 0 || temp > 9999)
445 lev.time_initial = temp;
448 lev.required_initial = src[0x82F];
450 temp = src[0x830] << 8 | src[0x831];
451 ply1.x_initial = (temp & 63) + 1;
452 ply1.y_initial = (temp >> 6 & 31) + 1;
453 temp = src[0x832] << 8 | src[0x833];
454 ply2.x_initial = (temp & 63) + 1;
455 ply2.y_initial = (temp >> 6 & 31) + 1;
457 temp = (src[0x834] << 8 | src[0x835]) * 28;
460 lev.amoeba_time = temp;
462 lev.android_move_time = src[0x874] << 8 | src[0x875];
463 lev.android_clone_time = src[0x876] << 8 | src[0x877];
465 lev.ball_random = src[0x872] & 1 ? 1 : 0;
466 lev.ball_state_initial = src[0x872] & 128 ? 1 : 0;
467 lev.ball_time = src[0x870] << 8 | src[0x871];
469 lev.emerald_score = src[0x824];
470 lev.diamond_score = src[0x825];
471 lev.alien_score = src[0x826];
472 lev.tank_score = src[0x827];
473 lev.bug_score = src[0x828];
474 lev.eater_score = src[0x829];
475 lev.nut_score = src[0x82A];
476 lev.dynamite_score = src[0x82B];
477 lev.key_score = src[0x82C];
478 lev.exit_score = src[0x82D] * 8 / 5;
479 lev.lenses_score = src[0x867];
480 lev.magnify_score = src[0x868];
481 lev.slurp_score = src[0x869];
483 lev.lenses_time = src[0x86A] << 8 | src[0x86B];
484 lev.magnify_time = src[0x86C] << 8 | src[0x86D];
485 lev.wheel_time = src[0x838] << 8 | src[0x839];
487 lev.wind_cnt_initial = src[0x865] & 15 ? lev.wind_time : 0;
489 lev.wind_direction_initial = (temp & 8 ? 0 :
494 lev.wonderwall_time_initial = src[0x836] << 8 | src[0x837];
496 for (i = 0; i < 8; i++)
497 for (x = 0; x < 9; x++)
498 lev.eater_array[i][x] = remap_emerald[src[eater_offset[i] + x]];
500 temp = remap_emerald[src[0x86F]];
501 for (y = 0; y < 8; y++)
505 for (x = 0; x < 8; x++)
506 lev.ball_array[y][x] = temp;
510 lev.ball_array[y][1] = (src[0x873] & 1) ? temp : Xblank; /* north */
511 lev.ball_array[y][6] = (src[0x873] & 2) ? temp : Xblank; /* south */
512 lev.ball_array[y][3] = (src[0x873] & 4) ? temp : Xblank; /* west */
513 lev.ball_array[y][4] = (src[0x873] & 8) ? temp : Xblank; /* east */
514 lev.ball_array[y][7] = (src[0x873] & 16) ? temp : Xblank; /* southeast */
515 lev.ball_array[y][5] = (src[0x873] & 32) ? temp : Xblank; /* southwest */
516 lev.ball_array[y][2] = (src[0x873] & 64) ? temp : Xblank; /* northeast */
517 lev.ball_array[y][0] = (src[0x873] & 128)? temp : Xblank; /* northwest */
521 temp = src[0x878] << 8 | src[0x879];
525 lev.android_array[Xemerald] =
526 lev.android_array[Xemerald_pause] =
527 lev.android_array[Xemerald_fall] =
528 lev.android_array[Yemerald_sB] =
529 lev.android_array[Yemerald_eB] =
530 lev.android_array[Yemerald_wB] = Xemerald;
535 lev.android_array[Xdiamond] =
536 lev.android_array[Xdiamond_pause] =
537 lev.android_array[Xdiamond_fall] =
538 lev.android_array[Ydiamond_sB] =
539 lev.android_array[Ydiamond_eB] =
540 lev.android_array[Ydiamond_wB] = Xdiamond;
545 lev.android_array[Xstone] =
546 lev.android_array[Xstone_pause] =
547 lev.android_array[Xstone_fall] =
548 lev.android_array[Ystone_sB] =
549 lev.android_array[Ystone_eB] =
550 lev.android_array[Ystone_wB] = Xstone;
555 lev.android_array[Xbomb] =
556 lev.android_array[Xbomb_pause] =
557 lev.android_array[Xbomb_fall] =
558 lev.android_array[Ybomb_sB] =
559 lev.android_array[Ybomb_eB] =
560 lev.android_array[Ybomb_wB] = Xbomb;
565 lev.android_array[Xnut] =
566 lev.android_array[Xnut_pause] =
567 lev.android_array[Xnut_fall] =
568 lev.android_array[Ynut_sB] =
569 lev.android_array[Ynut_eB] =
570 lev.android_array[Ynut_wB] = Xnut;
575 lev.android_array[Xtank_n] =
576 lev.android_array[Xtank_gon] =
577 lev.android_array[Ytank_nB] =
578 lev.android_array[Ytank_n_e] =
579 lev.android_array[Ytank_n_w] = Xtank_n;
581 lev.android_array[Xtank_e] =
582 lev.android_array[Xtank_goe] =
583 lev.android_array[Ytank_eB] =
584 lev.android_array[Ytank_e_s] =
585 lev.android_array[Ytank_e_n] = Xtank_e;
587 lev.android_array[Xtank_s] =
588 lev.android_array[Xtank_gos] =
589 lev.android_array[Ytank_sB] =
590 lev.android_array[Ytank_s_w] =
591 lev.android_array[Ytank_s_e] = Xtank_s;
593 lev.android_array[Xtank_w] =
594 lev.android_array[Xtank_gow] =
595 lev.android_array[Ytank_wB] =
596 lev.android_array[Ytank_w_n] =
597 lev.android_array[Ytank_w_s] = Xtank_w;
602 lev.android_array[Xeater_n] = lev.android_array[Yeater_nB] = Xeater_n;
603 lev.android_array[Xeater_e] = lev.android_array[Yeater_eB] = Xeater_e;
604 lev.android_array[Xeater_s] = lev.android_array[Yeater_sB] = Xeater_s;
605 lev.android_array[Xeater_w] = lev.android_array[Yeater_wB] = Xeater_w;
610 lev.android_array[Xbug_n] =
611 lev.android_array[Xbug_gon] =
612 lev.android_array[Ybug_nB] =
613 lev.android_array[Ybug_n_e] =
614 lev.android_array[Ybug_n_w] = Xbug_gon;
616 lev.android_array[Xbug_e] =
617 lev.android_array[Xbug_goe] =
618 lev.android_array[Ybug_eB] =
619 lev.android_array[Ybug_e_s] =
620 lev.android_array[Ybug_e_n] = Xbug_goe;
622 lev.android_array[Xbug_s] =
623 lev.android_array[Xbug_gos] =
624 lev.android_array[Ybug_sB] =
625 lev.android_array[Ybug_s_w] =
626 lev.android_array[Ybug_s_e] = Xbug_gos;
628 lev.android_array[Xbug_w] =
629 lev.android_array[Xbug_gow] =
630 lev.android_array[Ybug_wB] =
631 lev.android_array[Ybug_w_n] =
632 lev.android_array[Ybug_w_s] = Xbug_gow;
637 lev.android_array[Xalien] = lev.android_array[Xalien_pause] =
638 lev.android_array[Yalien_nB] = lev.android_array[Yalien_eB] =
639 lev.android_array[Yalien_sB] = lev.android_array[Yalien_wB] = Xalien;
644 lev.android_array[Xspring] =
645 lev.android_array[Xspring_pause] =
646 lev.android_array[Xspring_e] =
647 lev.android_array[Yspring_eB] =
648 lev.android_array[Yspring_kill_eB] =
649 lev.android_array[Xspring_w] =
650 lev.android_array[Yspring_wB] =
651 lev.android_array[Yspring_kill_wB] =
652 lev.android_array[Xspring_fall] =
653 lev.android_array[Yspring_sB] = Xspring;
658 lev.android_array[Yballoon_nB] =
659 lev.android_array[Yballoon_eB] =
660 lev.android_array[Yballoon_sB] =
661 lev.android_array[Yballoon_wB] =
662 lev.android_array[Xballoon] = Xballoon;
667 lev.android_array[Xdripper] =
668 lev.android_array[XdripperB] =
669 lev.android_array[Xamoeba_1] =
670 lev.android_array[Xamoeba_2] =
671 lev.android_array[Xamoeba_3] =
672 lev.android_array[Xamoeba_4] =
673 lev.android_array[Xamoeba_5] =
674 lev.android_array[Xamoeba_6] =
675 lev.android_array[Xamoeba_7] =
676 lev.android_array[Xamoeba_8] = Xdrip_eat;
681 lev.android_array[Xdynamite] = Xdynamite;
684 for (temp = 1; temp < 2047; temp++)
688 case 0x24: /* wonderwall */
689 lev.wonderwall_state_initial = 1;
690 lev.wonderwall_time_initial = 9999;
693 case 0x28: /* wheel */
694 lev.wheel_x_initial = temp & 63;
695 lev.wheel_y_initial = temp >> 6;
696 lev.wheel_cnt_initial = lev.wheel_time;
700 case 0x63: /* spring roll left */
701 src[temp - 1] = 0x45;
705 case 0x64: /* spring roll right */
706 src[temp + 1] = 0x45;
710 case 0x72: /* nut roll left */
711 src[temp - 1] = 0x25;
715 case 0x73: /* nut roll right */
716 src[temp + 1] = 0x25;
720 case 0x77: /* bomb roll left */
721 src[temp - 1] = 0x10;
725 case 0x78: /* bomb roll right */
726 src[temp + 1] = 0x10;
730 case 0x79: /* stone roll left */
731 src[temp - 1] = 0x00;
735 case 0x7A: /* stone roll right */
736 src[temp + 1] = 0x00;
741 case 0xA3: /* fake blank */
742 lev.lenses_cnt_initial = 9999;
745 case 0xA4: /* fake grass */
746 lev.magnify_cnt_initial = 9999;
751 /* first fill the complete playfield with the default border element */
752 for (y = 0; y < HEIGHT; y++)
753 for (x = 0; x < WIDTH; x++)
754 native_em_level.cave[x][y] = ZBORDER;
756 /* then copy the real level contents from level file into the playfield */
758 for (y = 0; y < lev.height; y++)
759 for (x = 0; x < lev.width; x++)
760 native_em_level.cave[x + 1][y + 1] = remap_emerald[src[temp++]];
762 /* at last, set the two players at their positions in the playfield */
763 if (ply1.alive_initial)
764 native_em_level.cave[ply1.x_initial][ply1.y_initial] = Zplayer;
765 if (ply2.alive_initial)
766 native_em_level.cave[ply2.x_initial][ply2.y_initial] = Zplayer;
768 native_em_level.file_version = file_version;
771 void prepare_em_level(void)
775 /* reset all runtime variables to their initial values */
777 for (y = 0; y < HEIGHT; y++)
778 for (x = 0; x < WIDTH; x++)
779 Cave[y][x] = native_em_level.cave[x][y];
781 for (y = 0; y < HEIGHT; y++)
782 for (x = 0; x < WIDTH; x++)
783 Next[y][x] = Cave[y][x];
785 for (y = 0; y < HEIGHT; y++)
786 for (x = 0; x < WIDTH; x++)
787 Draw[y][x] = Cave[y][x];
789 lev.time_initial = (lev.time_seconds * 50 + 7) / 8;
790 lev.time = lev.time_initial;
792 lev.required = lev.required_initial;
795 lev.android_move_cnt = lev.android_move_time;
796 lev.android_clone_cnt = lev.android_clone_time;
799 lev.ball_state = lev.ball_state_initial;
800 lev.ball_cnt = lev.ball_time;
805 lev.lenses_cnt = lev.lenses_cnt_initial;
806 lev.magnify_cnt = lev.magnify_cnt_initial;
808 lev.wheel_cnt = lev.wheel_cnt_initial;
809 lev.wheel_x = lev.wheel_x_initial;
810 lev.wheel_y = lev.wheel_y_initial;
812 lev.wind_cnt = lev.wind_cnt_initial;
813 lev.wind_direction = lev.wind_direction_initial;
815 lev.wonderwall_state = lev.wonderwall_state_initial;
816 lev.wonderwall_time = lev.wonderwall_time_initial;
818 lev.home = lev.home_initial;
821 ply1.alive = ply1.alive_initial;
823 ply1.dynamite_cnt = 0;
826 ply1.oldx = ply1.x = ply1.x_initial;
827 ply1.oldy = ply1.y = ply1.y_initial;
828 ply1.joy_n = ply1.joy_e = ply1.joy_s = ply1.joy_w = ply1.joy_fire = 0;
829 ply1.joy_stick = ply1.joy_spin = 0;
832 ply2.alive = ply2.alive_initial;
834 ply2.dynamite_cnt = 0;
837 ply2.oldx = ply2.x = ply2.x_initial;
838 ply2.oldy = ply2.y = ply2.y_initial;
839 ply2.joy_n = ply2.joy_e = ply2.joy_s = ply2.joy_w = ply2.joy_fire = 0;
840 ply2.joy_stick = ply2.joy_spin = 0;