3 * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/
5 * Copyright (C) 2001 tarzeau@space.ch
7 * Copyright (C) 2002 Florian Schulze - crow@icculus.org
9 * Portions of this code are from the MPEG software simulation group
10 * idct implementation. This code will be replaced with a new
11 * implementation soon.
13 * This file is part of Jump'n'Bump.
15 * Jump'n'Bump is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * Jump'n'Bump is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 char *menu_background;
35 char menu_cur_pal[768];
39 "by Brainchild Design in 1998.",
40 "Code by Mattias Brynervall.",
41 "Graphics by Martin Magnusson",
42 "and Andreas Brynervall.",
43 "Music by Anders Nilsson.",
44 "Linux port by Chuck Mason.",
45 "New SDL port by Florian Schulze.",
46 "http://www.icculus.org/jumpnbump/",
47 "Visit our homepage at:",
48 "http://www.algonet.se/~mattiasb",
49 "Jump 'n Bump is e-mailware.",
50 "That means you're supposed to send us an e-mail!",
51 "Write for example where you're from",
52 "and what you thought about this game.",
53 "If you do that, you will greatly encourage us",
54 "to make more games for you!",
55 "Send your e-mail to: matbr656@student.liu.se",
56 "Oh, and by the way, there's a lot of secrets!",
57 "If you can't find them, you'd better ask us...",
58 "If you'd like to contact a specific member of BCD,",
59 "these are their e-mail addresses:",
60 "Andreas Brynervall: andreasb@acc.umu.se",
61 "Mattias Brynervall: matbr656@student.liu.se",
62 "Martin Magnusson: marma102@student.liu.se",
63 "Anders Nilsson: equel@swipnet.se",
67 #define NUM_MESSAGES (sizeof(message)/sizeof(char *))
73 int end_loop_flag, new_game_flag, fade_flag;
74 int mod_vol = 0, mod_fade_direction = 0;
76 int fade_dir, fade_count, fade_tick;
83 mod_fade_direction = 1;
84 dj_ready_mod(MOD_MENU);
85 dj_set_mod_volume((char)mod_vol);
86 dj_set_sfx_volume(64);
90 memset(fade_pal, 0, 48);
91 setpalette(240, 16, fade_pal);
96 cur_message = NUM_MESSAGES - 1;
98 main_info.page_info[0].num_pobs = 0;
99 main_info.page_info[1].num_pobs = 0;
100 main_info.view_page = 0;
101 main_info.draw_page = 1;
103 esc_pressed = key_pressed(1);
104 end_loop_flag = new_game_flag = 0;
111 if (key_pressed(1) == 1 && esc_pressed == 0) {
114 memset(menu_pal, 0, 768);
115 mod_fade_direction = 0;
116 } else if (key_pressed(1) == 0)
119 update_player_actions();
120 for (c1 = 0; c1 < 4; c1++) {
121 if (end_loop_flag == 1 && new_game_flag == 1) {
122 if ((player[c1].x >> 16) > (165 + c1 * 2)) {
123 if (player[c1].x_add < 0)
124 player[c1].x_add += 16384;
126 player[c1].x_add += 12288;
127 if (player[c1].x_add > 98304L)
128 player[c1].x_add = 98304L;
129 player[c1].direction = 0;
130 if (player[c1].anim == 0) {
132 player[c1].frame = 0;
133 player[c1].frame_tick = 0;
134 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
136 player[c1].enabled = 1;
138 if (!player[c1].action_up) {
139 if (player[c1].y_add < 0) {
140 player[c1].y_add += 32768;
141 if (player[c1].y_add > 0)
142 player[c1].y_add = 0;
145 player[c1].y_add += 12288;
146 if (player[c1].y_add > 36864 && player[c1].anim != 3) {
148 player[c1].frame = 0;
149 player[c1].frame_tick = 0;
150 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
152 player[c1].y += player[c1].y_add;
153 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
154 if ((player[c1].y >> 16) > (160 + c1 * 2)) {
155 player[c1].y = (160L + c1 * 2) << 16;
156 player[c1].y_add = 0;
157 if (player[c1].anim != 0 && player[c1].anim != 1) {
159 player[c1].frame = 0;
160 player[c1].frame_tick = 0;
161 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
165 if ((player[c1].y >> 16) > (138 + c1 * 2)) {
166 player[c1].y = (138L + c1 * 2) << 16;
167 player[c1].y_add = 0;
168 if (player[c1].anim != 0 && player[c1].anim != 1) {
170 player[c1].frame = 0;
171 player[c1].frame_tick = 0;
172 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
174 if (!player[c1].action_up)
175 player[c1].jump_ready = 1;
178 player[c1].x += player[c1].x_add;
179 if ((player[c1].y >> 16) > (138 + c1 * 2)) {
180 if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (190 + c1 * 2)) {
181 player[c1].x = (165L + c1 * 2) << 16;
182 player[c1].x_add = 0;
184 if ((player[c1].x >> 16) > (190 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
185 player[c1].x = (208L + c1 * 2) << 16;
186 player[c1].x_add = 0;
190 if (player[c1].action_left && player[c1].action_right) {
191 if (player[c1].direction == 1) {
192 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
193 if (player[c1].x_add > 0) {
194 player[c1].x_add -= 16384;
195 if ((player[c1].y >> 16) >= (160 + c1 * 2))
196 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
198 player[c1].x_add -= 12288;
200 if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
201 if (player[c1].x_add > 0) {
202 player[c1].x_add -= 16384;
203 if ((player[c1].y >> 16) >= (138 + c1 * 2))
204 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
206 player[c1].x_add -= 12288;
208 if (player[c1].x_add < -98304L)
209 player[c1].x_add = -98304L;
210 player[c1].direction = 1;
211 if (player[c1].anim == 0) {
213 player[c1].frame = 0;
214 player[c1].frame_tick = 0;
215 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
218 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
219 if (player[c1].x_add < 0) {
220 player[c1].x_add += 16384;
221 if ((player[c1].y >> 16) >= (160 + c1 * 2))
222 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
224 player[c1].x_add += 12288;
226 if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
227 if (player[c1].x_add < 0) {
228 player[c1].x_add += 16384;
229 if ((player[c1].y >> 16) >= (138 + c1 * 2))
230 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
232 player[c1].x_add += 12288;
234 if (player[c1].x_add > 98304L)
235 player[c1].x_add = 98304L;
236 player[c1].direction = 0;
237 if (player[c1].anim == 0) {
239 player[c1].frame = 0;
240 player[c1].frame_tick = 0;
241 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
244 } else if (player[c1].action_left) {
245 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
246 if (player[c1].x_add > 0) {
247 player[c1].x_add -= 16384;
248 if ((player[c1].y >> 16) >= (160 + c1 * 2))
249 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
251 player[c1].x_add -= 12288;
253 if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
254 if (player[c1].x_add > 0) {
255 player[c1].x_add -= 16384;
256 if ((player[c1].y >> 16) >= (138 + c1 * 2))
257 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
259 player[c1].x_add -= 12288;
261 if (player[c1].x_add < -98304L)
262 player[c1].x_add = -98304L;
263 player[c1].direction = 1;
264 if (player[c1].anim == 0) {
266 player[c1].frame = 0;
267 player[c1].frame_tick = 0;
268 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
270 } else if (player[c1].action_right) {
271 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
272 if (player[c1].x_add < 0) {
273 player[c1].x_add += 16384;
274 if ((player[c1].y >> 16) >= (160 + c1 * 2))
275 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
277 player[c1].x_add += 12288;
279 if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
280 if (player[c1].x_add < 0) {
281 player[c1].x_add += 16384;
282 if ((player[c1].y >> 16) >= (138 + c1 * 2))
283 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
285 player[c1].x_add += 12288;
287 if (player[c1].x_add > 98304L)
288 player[c1].x_add = 98304L;
289 player[c1].direction = 0;
290 if (player[c1].anim == 0) {
292 player[c1].frame = 0;
293 player[c1].frame_tick = 0;
294 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
297 if (((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) && (player[c1].y >> 16) >= (160 + c1 * 2)) {
298 if (player[c1].x_add < 0) {
299 player[c1].x_add += 16384;
300 if (player[c1].x_add > 0)
301 player[c1].x_add = 0;
302 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
303 } else if (player[c1].x_add > 0) {
304 player[c1].x_add -= 16384;
305 if (player[c1].x_add < 0)
306 player[c1].x_add = 0;
307 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
310 if ((((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) && (player[c1].y >> 16) >= (138 + c1 * 2))) {
311 if (player[c1].x_add < 0) {
312 player[c1].x_add += 16384;
313 if (player[c1].x_add > 0)
314 player[c1].x_add = 0;
315 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
316 } else if (player[c1].x_add > 0) {
317 player[c1].x_add -= 16384;
318 if (player[c1].x_add < 0)
319 player[c1].x_add = 0;
320 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
323 if (player[c1].anim == 1) {
325 player[c1].frame = 0;
326 player[c1].frame_tick = 0;
327 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
330 if ((player[c1].jump_ready == 1) && player[c1].action_up) {
331 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
332 if ((player[c1].y >> 16) >= (160 + c1 * 2)) {
333 player[c1].y_add = -280000L;
335 player[c1].frame = 0;
336 player[c1].frame_tick = 0;
337 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
338 player[c1].jump_ready = 0;
339 dj_play_sfx(SFX_JUMP, (unsigned short)(SFX_JUMP_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
342 if ((player[c1].y >> 16) >= (138 + c1 * 2)) {
343 player[c1].y_add = -280000L;
345 player[c1].frame = 0;
346 player[c1].frame_tick = 0;
347 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
348 player[c1].jump_ready = 0;
349 dj_play_sfx(SFX_JUMP, (unsigned short)(SFX_JUMP_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
353 if (!player[c1].action_up) {
354 if (player[c1].y_add < 0) {
355 player[c1].y_add += 32768;
356 if (player[c1].y_add > 0)
357 player[c1].y_add = 0;
360 if (!player[c1].action_up)
361 player[c1].jump_ready = 1;
362 player[c1].y_add += 12288;
363 if (player[c1].y_add > 36864 && player[c1].anim != 3) {
365 player[c1].frame = 0;
366 player[c1].frame_tick = 0;
367 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
369 player[c1].y += player[c1].y_add;
370 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
371 if ((player[c1].y >> 16) > (160 + c1 * 2)) {
372 player[c1].y = (160L + c1 * 2) << 16;
373 player[c1].y_add = 0;
374 if (player[c1].anim != 0 && player[c1].anim != 1) {
376 player[c1].frame = 0;
377 player[c1].frame_tick = 0;
378 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
382 if ((player[c1].y >> 16) > (138 + c1 * 2)) {
383 player[c1].y = (138L + c1 * 2) << 16;
384 player[c1].y_add = 0;
385 if (player[c1].anim != 0 && player[c1].anim != 1) {
387 player[c1].frame = 0;
388 player[c1].frame_tick = 0;
389 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
393 player[c1].x += player[c1].x_add;
394 if ((player[c1].x >> 16) < 0) {
396 player[c1].x_add = 0;
398 if ((player[c1].x >> 16) > 400) {
401 memset(menu_pal, 0, 768);
402 mod_fade_direction = 0;
404 if ((player[c1].y >> 16) > (138 + c1 * 2)) {
405 if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (190 + c1 * 2)) {
406 player[c1].x = (165L + c1 * 2) << 16;
407 player[c1].x_add = 0;
409 if ((player[c1].x >> 16) > (190 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
410 player[c1].x = (208L + c1 * 2) << 16;
411 player[c1].x_add = 0;
415 player[c1].frame_tick++;
416 if (player[c1].frame_tick >= player_anims[player[c1].anim].frame[player[c1].frame].ticks) {
418 if (player[c1].frame >= player_anims[player[c1].anim].num_frames)
419 player[c1].frame = player_anims[player[c1].anim].restart_frame;
420 player[c1].frame_tick = 0;
422 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
427 main_info.page_info[main_info.draw_page].num_pobs = 0;
429 for (c1 = 3; c1 >= 0; c1--)
430 add_pob(main_info.draw_page, player[c1].x >> 16, player[c1].y >> 16, player[c1].image + c1 * 18, &rabbit_gobs);
435 draw_pobs(main_info.draw_page);
440 if (mod_fade_direction == 1) {
443 dj_set_mod_volume((char)mod_vol);
448 dj_set_mod_volume((char)mod_vol);
453 for (c1 = 0; c1 < 720; c1++) {
454 if (menu_cur_pal[c1] < menu_pal[c1]) {
457 } else if (menu_cur_pal[c1] > menu_pal[c1]) {
462 if (fade_flag == 0 && end_loop_flag == 1) {
464 if (new_game_flag == 1)
471 if (fade_count < 30) {
472 for (c1 = 0; c1 < 48; c1++) {
473 if (fade_pal[c1] > 0)
479 clear_lines(0, 220, 20, 0);
480 clear_lines(1, 220, 20, 0);
483 if (cur_message >= NUM_MESSAGES)
484 cur_message -= NUM_MESSAGES;
485 put_text(0, 200, 220, message[cur_message], 2);
486 put_text(1, 200, 220, message[cur_message], 2);
494 if (fade_count < 100) {
495 for (c1 = 0; c1 < 48; c1++) {
496 if (fade_pal[c1] < menu_pal[c1 + 720])
508 for (c1 = 0; c1 < 48; c1++) {
509 if (fade_pal[c1] > menu_pal[c1 + 720])
513 main_info.draw_page ^= 1;
514 main_info.view_page ^= 1;
516 flippage(main_info.view_page);
520 if (fade_flag != 0) {
521 setpalette(0, 240, menu_cur_pal);
524 setpalette(240, 16, fade_pal);
529 redraw_pob_backgrounds(main_info.draw_page);
545 fillpalette(0, 0, 0);
547 if ((handle = dat_open("menu.pcx", datfile_name, "rb")) == 0) {
548 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
551 if (read_pcx(handle, background_pic, 102400, menu_pal) != 0) {
552 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
556 if ((handle = dat_open("menumask.pcx", datfile_name, "rb")) == 0) {
557 strcpy(main_info.error_str, "Error loading 'menumask.pcx', aborting...\n");
560 if (read_pcx(handle, mask_pic, 102400, 0) != 0) {
561 strcpy(main_info.error_str, "Error loading 'menumask.pcx', aborting...\n");
565 memset(menu_cur_pal, 0, 768);
567 recalculate_gob(&rabbit_gobs, menu_pal);
568 recalculate_gob(&font_gobs, menu_pal);
569 recalculate_gob(&object_gobs, menu_pal);
570 register_background(background_pic, menu_pal);
571 register_mask(mask_pic);
573 for (c1 = 0; c1 < 4; c1++) {
574 player[c1].enabled = 0;
575 player[c1].x = (long) rnd(150) << 16;
576 player[c1].y = (160L + c1 * 2) << 16;
577 player[c1].x_add = 0;
578 player[c1].y_add = 0;
579 player[c1].direction = rnd(2);
580 player[c1].jump_ready = 1;
582 player[c1].frame = 0;
583 player[c1].frame_tick = 0;
584 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image;
587 for (c1 = 0; c1 < NUM_OBJECTS; c1++)
588 objects[c1].used = 0;
590 main_info.page_info[0].num_pobs = 0;
591 main_info.page_info[1].num_pobs = 0;
598 void menu_deinit(void)