efbc06ab394ab15b8b11364b61720f481461e885
[crow/jumpnbump.git] / menu.c
1 #include "globals.h"
2
3 #define NUM_MESSAGES 24
4
5 char *menu_background;
6
7 char menu_pal[768];
8 char menu_cur_pal[768];
9
10 char message[NUM_MESSAGES][70] = {
11         "Jump 'n Bump",
12         "by Brainchild Design in 1998.",
13         "Code by Mattias Brynervall.",
14         "Graphics by Martin Magnusson",
15         "and Andreas Brynervall.",
16         "Music by Anders Nilsson.",
17         "Visit our homepage at:",
18         "http://www.algonet.se/~mattiasb",
19         "Jump 'n Bump is e-mailware.",
20         "That means you're supposed to send us an e-mail!",
21         "Write for example where you're from",
22         "and what you thought about this game.",
23         "If you do that, you will greatly encourage us",
24         "to make more games for you!",
25         "Send your e-mail to: matbr656@student.liu.se",
26         "Oh, and by the way, there's a lot of secrets!",
27         "If you can't find them, you'd better ask us...",
28         "If you'd like to contact a specific member of BCD,",
29         "these are their e-mail addresses:",
30         "Andreas Brynervall: andreasb@acc.umu.se",
31         "Mattias Brynervall: matbr656@student.liu.se",
32         "Martin Magnusson: marma102@student.liu.se",
33         "Anders Nilsson: equel@swipnet.se",
34         " "
35 };
36
37
38 char menu(void)
39 {
40         int c1;
41         char esc_pressed;
42         char end_loop_flag, new_game_flag, fade_flag;
43         char mod_vol, mod_fade_direction;
44         int cur_message;
45         int fade_dir, fade_count, fade_tick;
46         char fade_pal[48];
47
48         if (menu_init() != 0)
49                 return 1;
50
51         mod_vol = 0;
52         mod_fade_direction = 1;
53         dj_ready_mod(MOD_MENU);
54         dj_set_mod_volume(mod_vol);
55         dj_set_sfx_volume(64);
56         dj_start_mod();
57         dj_set_nosound(0);
58
59         memset(fade_pal, 0, 48);
60         outportb(0x3c8, 240);
61         for (c1 = 0; c1 < 48; c1++)
62                 outportb(0x3c9, fade_pal[c1]);
63         fade_dir = 0;
64         fade_count = 0;
65         fade_tick = 0;
66         cur_message = NUM_MESSAGES - 1;
67
68         main_info.page_info[0].num_pobs = 0;
69         main_info.page_info[1].num_pobs = 0;
70         main_info.view_page = 0;
71         main_info.draw_page = 1;
72
73         esc_pressed = key_pressed(1);
74         end_loop_flag = new_game_flag = 0;
75
76         while (1) {
77
78                 dj_mix();
79
80                 if (key_pressed(1) == 1 && esc_pressed == 0) {
81                         end_loop_flag = 1;
82                         new_game_flag = 0;
83                         memset(menu_pal, 0, 768);
84                         mod_fade_direction = 0;
85                 } else if (key_pressed(1) == 0)
86                         esc_pressed = 0;
87
88                 if (main_info.mouse_enabled == 1)
89                         read_mouse();
90                 if (main_info.joy_enabled == 1)
91                         read_joy();
92                 for (c1 = 0; c1 < 4; c1++) {
93                         if (end_loop_flag == 1 && new_game_flag == 1) {
94                                 if ((player[c1].x >> 16) > (165 + c1 * 2)) {
95                                         if (player[c1].x_add < 0)
96                                                 player[c1].x_add += 16384;
97                                         else
98                                                 player[c1].x_add += 12288;
99                                         if (player[c1].x_add > 98304L)
100                                                 player[c1].x_add = 98304L;
101                                         player[c1].direction = 0;
102                                         if (player[c1].anim == 0) {
103                                                 player[c1].anim = 1;
104                                                 player[c1].frame = 0;
105                                                 player[c1].frame_tick = 0;
106                                                 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
107                                         }
108                                         player[c1].enabled = 1;
109                                 }
110                                 if ((c1 == 0 && key_pressed(KEY_PL1_JUMP) == 0) || (c1 == 1 && key_pressed(KEY_PL2_JUMP) == 0) || (c1 == 2 && joy.but1 == 0) || (c1 == 3 && ((main_info.num_mouse_buttons == 3 && mouse.but3 == 0) || (main_info.num_mouse_buttons == 2 && mouse.but1 == 0 && mouse.but2 == 0)))) {
111                                         if (player[c1].y_add < 0) {
112                                                 player[c1].y_add += 32768;
113                                                 if (player[c1].y_add > 0)
114                                                         player[c1].y_add = 0;
115                                         }
116                                 }
117                                 player[c1].y_add += 12288;
118                                 if (player[c1].y_add > 36864 && player[c1].anim != 3) {
119                                         player[c1].anim = 3;
120                                         player[c1].frame = 0;
121                                         player[c1].frame_tick = 0;
122                                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
123                                 }
124                                 player[c1].y += player[c1].y_add;
125                                 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
126                                         if ((player[c1].y >> 16) > (160 + c1 * 2)) {
127                                                 player[c1].y = (160L + c1 * 2) << 16;
128                                                 player[c1].y_add = 0;
129                                                 if (player[c1].anim != 0 && player[c1].anim != 1) {
130                                                         player[c1].anim = 0;
131                                                         player[c1].frame = 0;
132                                                         player[c1].frame_tick = 0;
133                                                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
134                                                 }
135                                         }
136                                 } else {
137                                         if ((player[c1].y >> 16) > (138 + c1 * 2)) {
138                                                 player[c1].y = (138L + c1 * 2) << 16;
139                                                 player[c1].y_add = 0;
140                                                 if (player[c1].anim != 0 && player[c1].anim != 1) {
141                                                         player[c1].anim = 0;
142                                                         player[c1].frame = 0;
143                                                         player[c1].frame_tick = 0;
144                                                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
145                                                 }
146                                                 if ((c1 == 0 && key_pressed(KEY_PL1_JUMP) == 0) || (c1 == 1 && key_pressed(KEY_PL2_JUMP) == 0) || (c1 == 2 && joy.but1 == 0) || (c1 == 3 && ((main_info.num_mouse_buttons == 3 && mouse.but3 == 0) || (main_info.num_mouse_buttons == 2 && mouse.but1 == 0 && mouse.but2 == 0))))
147                                                         player[c1].jump_ready = 1;
148                                         }
149                                 }
150                                 player[c1].x += player[c1].x_add;
151                                 if ((player[c1].y >> 16) > (138 + c1 * 2)) {
152                                         if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (190 + c1 * 2)) {
153                                                 player[c1].x = (165L + c1 * 2) << 16;
154                                                 player[c1].x_add = 0;
155                                         }
156                                         if ((player[c1].x >> 16) > (190 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
157                                                 player[c1].x = (208L + c1 * 2) << 16;
158                                                 player[c1].x_add = 0;
159                                         }
160                                 }
161                         } else {
162                                 if ((c1 == 0 && key_pressed(KEY_PL1_LEFT) == 1 && key_pressed(KEY_PL1_RIGHT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_LEFT) == 1 && key_pressed(KEY_PL2_RIGHT) == 1) || (c1 == 2 && joy.x < -512 && joy.x > 512) || (c1 == 3 && mouse.but1 == 1 && mouse.but2 == 1)) {
163                                         if (player[c1].direction == 1) {
164                                                 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
165                                                         if (player[c1].x_add > 0) {
166                                                                 player[c1].x_add -= 16384;
167                                                                 if ((player[c1].y >> 16) >= (160 + c1 * 2))
168                                                                         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);
169                                                         } else
170                                                                 player[c1].x_add -= 12288;
171                                                 }
172                                                 if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
173                                                         if (player[c1].x_add > 0) {
174                                                                 player[c1].x_add -= 16384;
175                                                                 if ((player[c1].y >> 16) >= (138 + c1 * 2))
176                                                                         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);
177                                                         } else
178                                                                 player[c1].x_add -= 12288;
179                                                 }
180                                                 if (player[c1].x_add < -98304L)
181                                                         player[c1].x_add = -98304L;
182                                                 player[c1].direction = 1;
183                                                 if (player[c1].anim == 0) {
184                                                         player[c1].anim = 1;
185                                                         player[c1].frame = 0;
186                                                         player[c1].frame_tick = 0;
187                                                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
188                                                 }
189                                         } else {
190                                                 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
191                                                         if (player[c1].x_add < 0) {
192                                                                 player[c1].x_add += 16384;
193                                                                 if ((player[c1].y >> 16) >= (160 + c1 * 2))
194                                                                         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);
195                                                         } else
196                                                                 player[c1].x_add += 12288;
197                                                 }
198                                                 if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
199                                                         if (player[c1].x_add < 0) {
200                                                                 player[c1].x_add += 16384;
201                                                                 if ((player[c1].y >> 16) >= (138 + c1 * 2))
202                                                                         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);
203                                                         } else
204                                                                 player[c1].x_add += 12288;
205                                                 }
206                                                 if (player[c1].x_add > 98304L)
207                                                         player[c1].x_add = 98304L;
208                                                 player[c1].direction = 0;
209                                                 if (player[c1].anim == 0) {
210                                                         player[c1].anim = 1;
211                                                         player[c1].frame = 0;
212                                                         player[c1].frame_tick = 0;
213                                                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
214                                                 }
215                                         }
216                                 } else if ((c1 == 0 && key_pressed(KEY_PL1_LEFT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_LEFT) == 1) || (c1 == 2 && joy.x < -512) || (c1 == 3 && mouse.but1 == 1)) {
217                                         if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
218                                                 if (player[c1].x_add > 0) {
219                                                         player[c1].x_add -= 16384;
220                                                         if ((player[c1].y >> 16) >= (160 + c1 * 2))
221                                                                 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);
222                                                 } else
223                                                         player[c1].x_add -= 12288;
224                                         }
225                                         if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
226                                                 if (player[c1].x_add > 0) {
227                                                         player[c1].x_add -= 16384;
228                                                         if ((player[c1].y >> 16) >= (138 + c1 * 2))
229                                                                 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);
230                                                 } else
231                                                         player[c1].x_add -= 12288;
232                                         }
233                                         if (player[c1].x_add < -98304L)
234                                                 player[c1].x_add = -98304L;
235                                         player[c1].direction = 1;
236                                         if (player[c1].anim == 0) {
237                                                 player[c1].anim = 1;
238                                                 player[c1].frame = 0;
239                                                 player[c1].frame_tick = 0;
240                                                 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
241                                         }
242                                 } else if ((c1 == 0 && key_pressed(KEY_PL1_RIGHT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_RIGHT) == 1) || (c1 == 2 && joy.x > 512) || (c1 == 3 && mouse.but2 == 1)) {
243                                         if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
244                                                 if (player[c1].x_add < 0) {
245                                                         player[c1].x_add += 16384;
246                                                         if ((player[c1].y >> 16) >= (160 + c1 * 2))
247                                                                 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);
248                                                 } else
249                                                         player[c1].x_add += 12288;
250                                         }
251                                         if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
252                                                 if (player[c1].x_add < 0) {
253                                                         player[c1].x_add += 16384;
254                                                         if ((player[c1].y >> 16) >= (138 + c1 * 2))
255                                                                 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);
256                                                 } else
257                                                         player[c1].x_add += 12288;
258                                         }
259                                         if (player[c1].x_add > 98304L)
260                                                 player[c1].x_add = 98304L;
261                                         player[c1].direction = 0;
262                                         if (player[c1].anim == 0) {
263                                                 player[c1].anim = 1;
264                                                 player[c1].frame = 0;
265                                                 player[c1].frame_tick = 0;
266                                                 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
267                                         }
268                                 } else {
269                                         if (((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) && (player[c1].y >> 16) >= (160 + c1 * 2)) {
270                                                 if (player[c1].x_add < 0) {
271                                                         player[c1].x_add += 16384;
272                                                         if (player[c1].x_add > 0)
273                                                                 player[c1].x_add = 0;
274                                                         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);
275                                                 } else if (player[c1].x_add > 0) {
276                                                         player[c1].x_add -= 16384;
277                                                         if (player[c1].x_add < 0)
278                                                                 player[c1].x_add = 0;
279                                                         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);
280                                                 }
281                                         }
282                                         if ((((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) && (player[c1].y >> 16) >= (138 + c1 * 2))) {
283                                                 if (player[c1].x_add < 0) {
284                                                         player[c1].x_add += 16384;
285                                                         if (player[c1].x_add > 0)
286                                                                 player[c1].x_add = 0;
287                                                         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);
288                                                 } else if (player[c1].x_add > 0) {
289                                                         player[c1].x_add -= 16384;
290                                                         if (player[c1].x_add < 0)
291                                                                 player[c1].x_add = 0;
292                                                         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);
293                                                 }
294                                         }
295                                         if (player[c1].anim == 1) {
296                                                 player[c1].anim = 0;
297                                                 player[c1].frame = 0;
298                                                 player[c1].frame_tick = 0;
299                                                 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
300                                         }
301                                 }
302                                 if (player[c1].jump_ready == 1 && ((c1 == 0 && key_pressed(KEY_PL1_JUMP) == 1) || (c1 == 1 && key_pressed(KEY_PL2_JUMP) == 1) || (c1 == 2 && joy.but1 == 1) || (c1 == 3 && ((main_info.num_mouse_buttons == 3 && mouse.but3 == 1) || (main_info.num_mouse_buttons == 2 && mouse.but1 == 1 && mouse.but2 == 1))))) {
303                                         if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
304                                                 if ((player[c1].y >> 16) >= (160 + c1 * 2)) {
305                                                         player[c1].y_add = -280000L;
306                                                         player[c1].anim = 2;
307                                                         player[c1].frame = 0;
308                                                         player[c1].frame_tick = 0;
309                                                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
310                                                         player[c1].jump_ready = 0;
311                                                         dj_play_sfx(SFX_JUMP, SFX_JUMP_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
312                                                 }
313                                         } else {
314                                                 if ((player[c1].y >> 16) >= (138 + c1 * 2)) {
315                                                         player[c1].y_add = -280000L;
316                                                         player[c1].anim = 2;
317                                                         player[c1].frame = 0;
318                                                         player[c1].frame_tick = 0;
319                                                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
320                                                         player[c1].jump_ready = 0;
321                                                         dj_play_sfx(SFX_JUMP, SFX_JUMP_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
322                                                 }
323                                         }
324                                 }
325                                 if ((c1 == 0 && key_pressed(KEY_PL1_JUMP) == 0) || (c1 == 1 && key_pressed(KEY_PL2_JUMP) == 0) || (c1 == 2 && joy.but1 == 0) || (c1 == 3 && ((main_info.num_mouse_buttons == 3 && mouse.but3 == 0) || (main_info.num_mouse_buttons == 2 && mouse.but1 == 0 && mouse.but2 == 0)))) {
326                                         if (player[c1].y_add < 0) {
327                                                 player[c1].y_add += 32768;
328                                                 if (player[c1].y_add > 0)
329                                                         player[c1].y_add = 0;
330                                         }
331                                 }
332                                 if ((c1 == 0 && key_pressed(KEY_PL1_JUMP) == 0) || (c1 == 1 && key_pressed(KEY_PL2_JUMP) == 0) || (c1 == 2 && joy.but1 == 0) || (c1 == 3 && ((main_info.num_mouse_buttons == 3 && mouse.but3 == 0) || (main_info.num_mouse_buttons == 2 && (mouse.but1 == 0 || mouse.but2 == 0)))))
333                                         player[c1].jump_ready = 1;
334                                 player[c1].y_add += 12288;
335                                 if (player[c1].y_add > 36864 && player[c1].anim != 3) {
336                                         player[c1].anim = 3;
337                                         player[c1].frame = 0;
338                                         player[c1].frame_tick = 0;
339                                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
340                                 }
341                                 player[c1].y += player[c1].y_add;
342                                 if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
343                                         if ((player[c1].y >> 16) > (160 + c1 * 2)) {
344                                                 player[c1].y = (160L + c1 * 2) << 16;
345                                                 player[c1].y_add = 0;
346                                                 if (player[c1].anim != 0 && player[c1].anim != 1) {
347                                                         player[c1].anim = 0;
348                                                         player[c1].frame = 0;
349                                                         player[c1].frame_tick = 0;
350                                                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
351                                                 }
352                                         }
353                                 } else {
354                                         if ((player[c1].y >> 16) > (138 + c1 * 2)) {
355                                                 player[c1].y = (138L + c1 * 2) << 16;
356                                                 player[c1].y_add = 0;
357                                                 if (player[c1].anim != 0 && player[c1].anim != 1) {
358                                                         player[c1].anim = 0;
359                                                         player[c1].frame = 0;
360                                                         player[c1].frame_tick = 0;
361                                                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
362                                                 }
363                                         }
364                                 }
365                                 player[c1].x += player[c1].x_add;
366                                 if ((player[c1].x >> 16) < 0) {
367                                         player[c1].x = 0;
368                                         player[c1].x_add = 0;
369                                 }
370                                 if ((player[c1].x >> 16) > 400) {
371                                         end_loop_flag = 1;
372                                         new_game_flag = 1;
373                                         memset(menu_pal, 0, 768);
374                                         mod_fade_direction = 0;
375                                 }
376                                 if ((player[c1].y >> 16) > (138 + c1 * 2)) {
377                                         if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (190 + c1 * 2)) {
378                                                 player[c1].x = (165L + c1 * 2) << 16;
379                                                 player[c1].x_add = 0;
380                                         }
381                                         if ((player[c1].x >> 16) > (190 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
382                                                 player[c1].x = (208L + c1 * 2) << 16;
383                                                 player[c1].x_add = 0;
384                                         }
385                                 }
386                         }
387                         player[c1].frame_tick++;
388                         if (player[c1].frame_tick >= player_anims[player[c1].anim].frame[player[c1].frame].ticks) {
389                                 player[c1].frame++;
390                                 if (player[c1].frame >= player_anims[player[c1].anim].num_frames)
391                                         player[c1].frame = player_anims[player[c1].anim].restart_frame;
392                                 player[c1].frame_tick = 0;
393                         }
394                         player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
395                 }
396
397                 dj_mix();
398
399                 main_info.page_info[main_info.draw_page].num_pobs = 0;
400
401                 for (c1 = 3; c1 >= 0; c1--)
402                         add_pob(main_info.draw_page, player[c1].x >> 16, player[c1].y >> 16, player[c1].image + c1 * 18, rabbit_gobs);
403
404                 update_objects();
405
406                 draw_pobs(main_info.draw_page);
407
408                 dj_mix();
409
410                 if (mod_fade_direction == 1) {
411                         if (mod_vol < 35) {
412                                 mod_vol++;
413                                 dj_set_mod_volume(mod_vol);
414                         }
415                 } else {
416                         if (mod_vol > 0) {
417                                 mod_vol--;
418                                 dj_set_mod_volume(mod_vol);
419                         }
420                 }
421
422                 fade_flag = 0;
423                 for (c1 = 0; c1 < 720; c1++) {
424                         if (menu_cur_pal[c1] < menu_pal[c1]) {
425                                 menu_cur_pal[c1]++;
426                                 fade_flag = 1;
427                         } else if (menu_cur_pal[c1] > menu_pal[c1]) {
428                                 menu_cur_pal[c1]--;
429                                 fade_flag = 2;
430                         }
431                 }
432                 if (fade_flag == 0 && end_loop_flag == 1) {
433                         menu_deinit();
434                         if (new_game_flag == 1)
435                                 return 0;
436                         else
437                                 return 1;
438                 }
439                 switch (fade_dir) {
440                 case 0:
441                         if (fade_count < 30) {
442                                 for (c1 = 0; c1 < 48; c1++) {
443                                         if (fade_pal[c1] > 0)
444                                                 fade_pal[c1]--;
445                                 }
446                                 fade_count++;
447                         } else {
448                                 outportw(0x3c4, 0x0f02);
449                                 memset((char *) (0xa0000 + 220 * 100 + __djgpp_conventional_base), 0, 2000);
450                                 memset((char *) (0xa0000 + 32768 + 220 * 100 + __djgpp_conventional_base), 0, 2000);
451                                 cur_message++;
452                                 if (cur_message >= NUM_MESSAGES)
453                                         cur_message -= NUM_MESSAGES;
454                                 put_text(0, 200, 220, message[cur_message], 2);
455                                 put_text(1, 200, 220, message[cur_message], 2);
456                                 fade_dir = 1;
457                                 fade_count = 0;
458                                 fade_tick = 0;
459                         }
460                         break;
461                 case 1:
462                         if (fade_count < 100) {
463                                 for (c1 = 0; c1 < 48; c1++) {
464                                         if (fade_pal[c1] < menu_pal[c1 + 720])
465                                                 fade_pal[c1]++;
466                                 }
467                                 fade_count++;
468                         } else {
469                                 fade_dir = 0;
470                                 fade_count = 0;
471                                 fade_tick = 0;
472                         }
473                         break;
474                 }
475
476                 for (c1 = 0; c1 < 48; c1++) {
477                         if (fade_pal[c1] > menu_pal[c1 + 720])
478                                 fade_pal[c1]--;
479                 }
480
481                 main_info.draw_page ^= 1;
482                 main_info.view_page ^= 1;
483
484                 outportw(0x3d4, (main_info.view_page << 23) + 0x0d);
485                 outportw(0x3d4, ((main_info.view_page << 15) & 0xff00) + 0x0c);
486
487                 while ((inportb(0x3da) & 8) == 0)
488                         dj_mix();
489                 while ((inportb(0x3da) & 8) == 8)
490                         dj_mix();
491
492                 if (fade_flag != 0) {
493                         outportb(0x3c8, 0);
494                         for (c1 = 0; c1 < 720; c1++)
495                                 outportb(0x3c9, menu_cur_pal[c1]);
496                 }
497
498                 outportb(0x3c8, 240);
499                 for (c1 = 0; c1 < 48; c1++)
500                         outportb(0x3c9, fade_pal[c1]);
501
502                 dj_mix();
503
504                 redraw_pob_backgrounds(main_info.draw_page);
505
506         }
507
508         menu_deinit();
509         return 0;
510
511 }
512
513
514 char menu_init(void)
515 {
516         FILE *handle;
517         int c1;
518
519         outportb(0x3c8, 0);
520         for (c1 = 0; c1 < 768; c1++)
521                 outportb(0x3c9, 0);
522
523         if ((handle = dat_open("menu.pcx", datfile_name, "rb")) == 0) {
524                 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
525                 return 1;
526         }
527         if (read_pcx(handle, background_pic, 102400, menu_pal) != 0) {
528                 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
529                 return 1;
530         }
531         fclose(handle);
532         if ((handle = dat_open("menumask.pcx", datfile_name, "rb")) == 0) {
533                 strcpy(main_info.error_str, "Error loading 'menumask.pcx', aborting...\n");
534                 return 1;
535         }
536         if (read_pcx(handle, mask_pic, 102400, 0) != 0) {
537                 strcpy(main_info.error_str, "Error loading 'menumask.pcx', aborting...\n");
538                 return 1;
539         }
540         fclose(handle);
541         memset(menu_cur_pal, 0, 768);
542
543         put_block(0, 0, 0, 400, 256, background_pic);
544         put_block(1, 0, 0, 400, 256, background_pic);
545
546         for (c1 = 0; c1 < 4; c1++) {
547                 player[c1].enabled = 0;
548                 player[c1].x = (long) rnd(150) << 16;
549                 player[c1].y = (160L + c1 * 2) << 16;
550                 player[c1].x_add = 0;
551                 player[c1].y_add = 0;
552                 player[c1].direction = rnd(2);
553                 player[c1].jump_ready = 1;
554                 player[c1].anim = 0;
555                 player[c1].frame = 0;
556                 player[c1].frame_tick = 0;
557                 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image;
558         }
559
560         for (c1 = 0; c1 < 300; c1++)
561                 objects[c1].used = 0;
562
563         main_info.page_info[0].num_pobs = 0;
564         main_info.page_info[1].num_pobs = 0;
565
566         return 0;
567
568 }
569
570
571 void menu_deinit(void)
572 {
573
574         dj_set_nosound(1);
575
576 }