3 * convert intermediate cave format to internal cave structure for
4 * use in logic(). initializes entire internal structure.
10 void prepare_em_level(void)
16 /* reset all runtime variables to their initial values */
18 game_init_cave_buffers();
20 lev.left = CAVE_BUFFER_XOFFSET;
21 lev.top = CAVE_BUFFER_YOFFSET;
22 lev.right = lev.left + lev.width;
23 lev.bottom = lev.top + lev.height;
25 /* add linked cave buffer columns for wrap-around movement */
26 for (x = 0; x < lev.left; x++)
28 lev.cavecol[x] = lev.cavecol[lev.width + x];
29 lev.nextcol[x] = lev.nextcol[lev.width + x];
30 lev.drawcol[x] = lev.drawcol[lev.width + x];
31 lev.boomcol[x] = lev.boomcol[lev.width + x];
33 lev.cavecol[lev.right + x] = lev.cavecol[lev.left + x];
34 lev.nextcol[lev.right + x] = lev.nextcol[lev.left + x];
35 lev.drawcol[lev.right + x] = lev.drawcol[lev.left + x];
36 lev.boomcol[lev.right + x] = lev.boomcol[lev.left + x];
39 for (x = 0; x < lev.width; x++)
40 for (y = 0; y < lev.height; y++)
41 lev.cave[lev.left + x][lev.top + y] = native_em_level.cave[x][y];
43 for (x = lev.left; x < lev.right; x++)
44 for (y = lev.top; y < lev.bottom; y++)
45 lev.next[x][y] = lev.draw[x][y] = lev.cave[x][y];
47 lev.time_initial = lev.time_seconds;
48 lev.time = lev.time_initial;
50 lev.required = lev.required_initial;
53 lev.android_move_cnt = lev.android_move_time;
54 lev.android_clone_cnt = lev.android_clone_time;
57 lev.ball_state = lev.ball_state_initial;
58 lev.ball_cnt = lev.ball_time;
63 lev.lenses_cnt = lev.lenses_cnt_initial;
64 lev.magnify_cnt = lev.magnify_cnt_initial;
66 lev.wheel_cnt = lev.wheel_cnt_initial;
67 lev.wheel_x = lev.wheel_x_initial;
68 lev.wheel_y = lev.wheel_y_initial;
70 lev.wind_direction = lev.wind_direction_initial;
71 lev.wind_cnt = lev.wind_cnt_initial;
73 lev.wonderwall_state = lev.wonderwall_state_initial;
74 lev.wonderwall_time = lev.wonderwall_time_initial;
76 lev.killed_out_of_time = FALSE;
78 /* determine number of players in this level */
81 for (i = 0; i < MAX_PLAYERS; i++)
84 ply[i].alive_initial = FALSE;
86 if (ply[i].x_initial != -1 && ply[i].y_initial != -1)
94 team_mode = getTeamMode_EM();
99 lev.home = lev.home_initial;
100 players_left = lev.home_initial;
102 for (i = 0; i < MAX_PLAYERS; i++)
108 ply[i].alive_initial = TRUE;
113 int x = ply[i].x_initial;
114 int y = ply[i].y_initial;
116 native_em_level.cave[x][y] = Xblank;
118 lev.cave[lev.left + x][lev.top + y] = Xblank;
119 lev.next[lev.left + x][lev.top + y] = Xblank;
120 lev.draw[lev.left + x][lev.top + y] = Xblank;
125 for (i = 0; i < MAX_PLAYERS; i++)
128 ply[i].alive = ply[i].alive_initial;
130 ply[i].dynamite_cnt = 0;
133 ply[i].oldx = ply[i].x = ply[i].x_initial + lev.left;
134 ply[i].oldy = ply[i].y = ply[i].y_initial + lev.top;
135 ply[i].last_move_dir = MV_NONE;
136 ply[i].joy_n = ply[i].joy_e = ply[i].joy_s = ply[i].joy_w = 0;
137 ply[i].joy_snap = ply[i].joy_drop = 0;
138 ply[i].joy_stick = ply[i].joy_spin = 0;
141 // the following engine variables are initialized to version-specific values
142 // in function InitGameEngine() (src/game.c):
144 // - game_em.use_single_button (default: TRUE)
145 // - game_em.use_snap_key_bug (default: FALSE)
147 game_em.level_solved = FALSE;
148 game_em.game_over = FALSE;
150 game_em.any_player_moving = FALSE;
151 game_em.any_player_snapping = FALSE;
153 game_em.last_moving_player = 0; /* default: first player */
155 for (i = 0; i < MAX_PLAYERS; i++)
156 game_em.last_player_direction[i] = MV_NONE;
158 lev.exit_x = lev.exit_y = -1; /* kludge for playing player exit sound */