Fix crash if Num_walls=0
[btb/d2x.git] / main / menu.c
1 /* $Id: menu.c,v 1.40 2005-01-07 21:58:42 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Inferno main menu.
18  *
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include <conf.h>
23 #endif
24
25 #ifdef WINDOWS
26 #include "desw.h"
27 #endif
28
29 #include <stdio.h>
30 #include <string.h>
31
32 #include "pa_enabl.h"                   //$$POLY_ACC
33
34 #include "menu.h"
35 #include "inferno.h"
36 #include "game.h"
37 #include "gr.h"
38 #include "key.h"
39 #include "iff.h"
40 #include "u_mem.h"
41 #include "error.h"
42 #include "bm.h"
43 #include "screens.h"
44 #include "mono.h"
45 #include "joy.h"
46 #include "vecmat.h"
47 #include "effects.h"
48 #include "slew.h"
49 #include "gamemine.h"
50 #include "gamesave.h"
51 #include "palette.h"
52 #include "args.h"
53 #include "newdemo.h"
54 #include "timer.h"
55 #include "sounds.h"
56 #include "gameseq.h"
57 #include "text.h"
58 #include "gamefont.h"
59 #include "newmenu.h"
60 #ifdef NETWORK
61 #  include "network.h"
62 #  include "ipx.h"
63 #  include "multi.h"
64 #endif
65 #include "scores.h"
66 #include "joydefs.h"
67 #ifdef NETWORK
68 #include "modem.h"
69 #endif
70 #include "playsave.h"
71 #include "kconfig.h"
72 #include "titles.h"
73 #include "credits.h"
74 #include "texmap.h"
75 #include "polyobj.h"
76 #include "state.h"
77 #include "mission.h"
78 #include "songs.h"
79 #include "config.h"
80 #include "movie.h"
81 #include "gamepal.h"
82 #include "gauges.h"
83 #include "powerup.h"
84 #include "strutil.h"
85 #include "reorder.h"
86
87 #ifdef MACINTOSH
88         #include "resource.h"
89         #include "isp.h"
90         #include <Dialogs.h>
91 #endif
92
93 #ifdef EDITOR
94 #include "editor/editor.h"
95 #endif
96
97 #if defined(POLY_ACC)
98 #include "poly_acc.h"
99 #endif
100
101 //char *menu_difficulty_text[] = { "Trainee", "Rookie", "Fighter", "Hotshot", "Insane" };
102 //char *menu_detail_text[] = { "Lowest", "Low", "Medium", "High", "Highest", "", "Custom..." };
103
104 #define MENU_NEW_GAME                   0
105 #define MENU_GAME                       1 
106 #define MENU_EDITOR                     2
107 #define MENU_VIEW_SCORES                3
108 #define MENU_QUIT                       4
109 #define MENU_LOAD_GAME                  5
110 #define MENU_SAVE_GAME                  6
111 #define MENU_DEMO_PLAY                  8
112 #define MENU_LOAD_LEVEL                 9
113 #define MENU_START_IPX_NETGAME          10
114 #define MENU_JOIN_IPX_NETGAME           11
115 #define MENU_CONFIG                     13
116 #define MENU_REJOIN_NETGAME             14
117 #define MENU_DIFFICULTY                 15
118 #define MENU_START_SERIAL               18
119 #define MENU_HELP                       19
120 #define MENU_NEW_PLAYER                 20
121 #define MENU_MULTIPLAYER                21
122 #define MENU_STOP_MODEM                 22
123 #define MENU_SHOW_CREDITS               23
124 #define MENU_ORDER_INFO                 24
125 #define MENU_PLAY_SONG                  25
126 //#define MENU_START_TCP_NETGAME          26 // TCP/IP support was planned in Descent II,
127 //#define MENU_JOIN_TCP_NETGAME           27 // but never realized.
128 #define MENU_START_APPLETALK_NETGAME    28
129 #define MENU_JOIN_APPLETALK_NETGAME     29
130 #define MENU_START_UDP_NETGAME          30 // UDP/IP support copied from d1x
131 #define MENU_JOIN_UDP_NETGAME           31
132 #define MENU_START_KALI_NETGAME         32 // Kali support copied from d1x
133 #define MENU_JOIN_KALI_NETGAME          33
134 #define MENU_START_MCAST4_NETGAME       34 // UDP/IP over multicast networks
135 #define MENU_JOIN_MCAST4_NETGAME        35
136
137 //ADD_ITEM("Start netgame...", MENU_START_NETGAME, -1 );
138 //ADD_ITEM("Send net message...", MENU_SEND_NET_MESSAGE, -1 );
139
140 #define ADD_ITEM(t,value,key)  do { m[num_options].type=NM_TYPE_MENU; m[num_options].text=t; menu_choice[num_options]=value;num_options++; } while (0)
141
142 //unused - extern int last_joy_time;               //last time the joystick was used
143 #ifndef NDEBUG
144 extern int Speedtest_on;
145 #else
146 #define Speedtest_on 0
147 #endif
148
149 void do_sound_menu();
150 void do_toggles_menu();
151
152 ubyte do_auto_demo = 1;                 // Flag used to enable auto demo starting in main menu.
153 int Player_default_difficulty; // Last difficulty level chosen by the player
154 int Auto_leveling_on = 1;
155 int Guided_in_big_window = 0;
156 int Menu_draw_copyright = 0;
157 int EscortHotKeys=1;
158
159 // Function Prototypes added after LINTING
160 void do_option(int select);
161 void do_detail_level_menu_custom(void);
162 void do_new_game_menu(void);
163 #ifdef NETWORK
164 void do_multi_player_menu(void);
165 void ipx_set_driver(int ipx_driver);
166 #endif //NETWORK
167
168 //returns the number of demo files on the disk
169 int newdemo_count_demos();
170 extern ubyte Version_major,Version_minor;
171
172 // ------------------------------------------------------------------------
173 void autodemo_menu_check(int nitems, newmenu_item * items, int *last_key, int citem )
174 {
175         int curtime;
176
177         nitems = nitems;
178         items=items;
179         citem = citem;
180
181         //draw copyright message
182         if ( Menu_draw_copyright )              {
183                 int w,h,aw;
184
185                 Menu_draw_copyright = 0;
186                 WINDOS( dd_gr_set_current_canvas(NULL),
187                                         gr_set_current_canvas(NULL));
188                 gr_set_curfont(GAME_FONT);
189                 gr_set_fontcolor(BM_XRGB(6,6,6),-1);
190
191                 gr_get_string_size("V2.2", &w, &h, &aw );
192         
193                 WIN(DDGRLOCK(dd_grd_curcanv));
194                         gr_printf(0x8000,grd_curcanv->cv_bitmap.bm_h-GAME_FONT->ft_h-2,TXT_COPYRIGHT);
195                         #ifdef MACINTOSH        // print out fix level as well if it exists
196                                 if (Version_fix != 0)
197                                 {
198                                         gr_get_string_size("V2.2.2", &w, &h, &aw );
199                                         gr_printf(grd_curcanv->cv_bitmap.bm_w-w-2,
200                                                           grd_curcanv->cv_bitmap.bm_h-GAME_FONT->ft_h-2,
201                                                           "V%d.%d.%d",
202                                                           Version_major,Version_minor,Version_fix);
203                                 }
204                                 else
205                                 {
206                                         gr_printf(grd_curcanv->cv_bitmap.bm_w-w-2,
207                                                           grd_curcanv->cv_bitmap.bm_h-GAME_FONT->ft_h-2,
208                                                           "V%d.%d",
209                                                           Version_major,Version_minor);
210                                 }
211                         #else
212                                 gr_printf(grd_curcanv->cv_bitmap.bm_w-w-2,grd_curcanv->cv_bitmap.bm_h-GAME_FONT->ft_h-2,"V%d.%d",Version_major,Version_minor);
213                         #endif
214
215                 //say this is vertigo version
216                 if (cfexist(MISSION_DIR "d2x.hog")) {
217                         gr_set_curfont(MEDIUM2_FONT);
218                         gr_printf(MenuHires?495:248, MenuHires?88:37, "Vertigo");
219                 }
220
221                 WIN(DDGRUNLOCK(dd_grd_curcanv));
222         }
223         
224         // Don't allow them to hit ESC in the main menu.
225         if (*last_key==KEY_ESC) *last_key = 0;
226
227         if ( do_auto_demo )     {
228                 curtime = timer_get_approx_seconds();
229                 //if ( ((keyd_time_when_last_pressed+i2f(20)) < curtime) && ((last_joy_time+i2f(20)) < curtime) && (!Speedtest_on)  ) {
230                 #ifndef MACINTOSH               // for now only!!!!
231                 if ( ((keyd_time_when_last_pressed+i2f(25)) < curtime) && (!Speedtest_on)  ) {
232                 #else
233                 if ( (keyd_time_when_last_pressed+i2f(40)) < curtime ) {
234                 #endif
235                         int n_demos;
236
237                         n_demos = newdemo_count_demos();
238
239 try_again:;
240
241                         if ((d_rand() % (n_demos+1)) == 0)
242                         {
243                                 #ifndef SHAREWARE
244                                         #ifdef WINDOWS
245                                         mouse_set_mode(1);                              //re-enable centering mode
246                                         HideCursorW();
247                                         #endif
248 #ifdef OGL
249                                         Screen_mode = -1;
250 #endif
251                                         PlayMovie("intro.mve",0);
252                                         songs_play_song(SONG_TITLE,1);
253                                         *last_key = -3; //exit menu to force redraw even if not going to game mode. -3 tells menu system not to restore
254                                         set_screen_mode(SCREEN_MENU);
255                                         #ifdef WINDOWS
256                                         mouse_set_mode(0);                              //disenable centering mode
257                                         ShowCursorW();
258                                         #endif
259                                 #endif // end of ifndef shareware
260                         }
261                         else {
262                                 WIN(HideCursorW());
263                                 keyd_time_when_last_pressed = curtime;                  // Reset timer so that disk won't thrash if no demos.
264                                 newdemo_start_playback(NULL);           // Randomly pick a file
265                                 if (Newdemo_state == ND_STATE_PLAYBACK) {
266                                         Function_mode = FMODE_GAME;
267                                         *last_key = -3; //exit menu to get into game mode. -3 tells menu system not to restore
268                                 }
269                                 else
270                                         goto try_again; //keep trying until we get a demo that works
271                         }
272                 }
273         }
274 }
275
276 //static int First_time = 1;
277 static int main_menu_choice = 0;
278
279 //      -----------------------------------------------------------------------------
280 //      Create the main menu.
281 void create_main_menu(newmenu_item *m, int *menu_choice, int *callers_num_options)
282 {
283         int     num_options;
284
285         #ifndef DEMO_ONLY
286         num_options = 0;
287
288         set_screen_mode (SCREEN_MENU);
289
290         ADD_ITEM(TXT_NEW_GAME,MENU_NEW_GAME,KEY_N);
291
292         ADD_ITEM(TXT_LOAD_GAME,MENU_LOAD_GAME,KEY_L);
293
294 #ifdef NETWORK
295         ADD_ITEM(TXT_MULTIPLAYER_,MENU_MULTIPLAYER,-1);
296 #endif
297
298         ADD_ITEM(TXT_OPTIONS_, MENU_CONFIG, -1 );
299         ADD_ITEM(TXT_CHANGE_PILOTS,MENU_NEW_PLAYER,unused);
300         ADD_ITEM(TXT_VIEW_DEMO,MENU_DEMO_PLAY,0);
301         ADD_ITEM(TXT_VIEW_SCORES,MENU_VIEW_SCORES,KEY_V);
302         if (cfexist("orderd2.pcx")) /* SHAREWARE */
303                 ADD_ITEM(TXT_ORDERING_INFO,MENU_ORDER_INFO,-1);
304         ADD_ITEM(TXT_CREDITS,MENU_SHOW_CREDITS,-1);
305         #endif
306         ADD_ITEM(TXT_QUIT,MENU_QUIT,KEY_Q);
307
308         #ifndef RELEASE
309         if (!(Game_mode & GM_MULTI ))   {
310                 //m[num_options].type=NM_TYPE_TEXT;
311                 //m[num_options++].text=" Debug options:";
312
313                 ADD_ITEM("  Load level...",MENU_LOAD_LEVEL ,KEY_N);
314                 #ifdef EDITOR
315                 ADD_ITEM("  Editor", MENU_EDITOR, KEY_E);
316                 #endif
317         }
318
319         //ADD_ITEM( "  Play song", MENU_PLAY_SONG, -1 );
320         #endif
321
322         *callers_num_options = num_options;
323 }
324
325 //returns number of item chosen
326 int DoMenu() 
327 {
328         int menu_choice[25];
329         newmenu_item m[25];
330         int num_options = 0;
331
332         load_palette(MENU_PALETTE,0,1);         //get correct palette
333
334         if ( Players[Player_num].callsign[0]==0 )       {
335                 RegisterPlayer();
336                 return 0;
337         }
338         
339         if ((Game_mode & GM_SERIAL) || (Game_mode & GM_MODEM)) {
340                 do_option(MENU_START_SERIAL);
341                 return 0;
342         }
343
344         do {
345                 create_main_menu(m, menu_choice, &num_options); // may have to change, eg, maybe selected pilot and no save games.
346
347                 keyd_time_when_last_pressed = timer_get_fixed_seconds();                // .. 20 seconds from now!
348                 if (main_menu_choice < 0 )
349                         main_menu_choice = 0;
350                 Menu_draw_copyright = 1;
351                 main_menu_choice = newmenu_do2( "", NULL, num_options, m, autodemo_menu_check, main_menu_choice, Menu_pcx_name);
352                 if ( main_menu_choice > -1 ) do_option(menu_choice[main_menu_choice]);
353         } while( Function_mode==FMODE_MENU );
354
355 //      if (main_menu_choice != -2)
356 //              do_auto_demo = 0;               // No more auto demos
357         if ( Function_mode==FMODE_GAME )
358                 gr_palette_fade_out( gr_palette, 32, 0 );
359
360         return main_menu_choice;
361 }
362
363 extern void show_order_form(void);      // John didn't want this in inferno.h so I just externed it.
364
365 #ifdef WINDOWS
366 #undef TXT_SELECT_DEMO
367 #define TXT_SELECT_DEMO "Select Demo\n<Ctrl-D> or Right-click\nto delete"
368 #endif
369
370 //returns flag, true means quit menu
371 void do_option ( int select) 
372 {
373         switch (select) {
374                 case MENU_NEW_GAME:
375                         do_new_game_menu();
376                         break;
377                 case MENU_GAME:
378                         break;
379                 case MENU_DEMO_PLAY:
380                 {
381                         char demo_file[16];
382                         if (newmenu_get_filename(TXT_SELECT_DEMO, "dem", demo_file, 1))
383                                 newdemo_start_playback(demo_file);
384                         break;
385                 }
386                 case MENU_LOAD_GAME:
387                         state_restore_all(0, 0, NULL);
388                         break;
389                 #ifdef EDITOR
390                 case MENU_EDITOR:
391                         Function_mode = FMODE_EDITOR;
392                         init_cockpit();
393                         break;
394                 #endif
395                 case MENU_VIEW_SCORES:
396                         gr_palette_fade_out( gr_palette,32,0 );
397                         scores_view(-1);
398                         break;
399 #if 1 //def SHAREWARE
400                 case MENU_ORDER_INFO:
401                         show_order_form();
402                         break;
403 #endif
404                 case MENU_QUIT:
405                         #ifdef EDITOR
406                         if (! SafetyCheck()) break;
407                         #endif
408                         gr_palette_fade_out( gr_palette,32,0);
409                         Function_mode = FMODE_EXIT;
410                         break;
411                 case MENU_NEW_PLAYER:
412                         RegisterPlayer();               //1 == allow escape out of menu
413                         break;
414
415                 case MENU_HELP:
416                         do_show_help();
417                         break;
418
419 #ifndef RELEASE
420
421                 case MENU_PLAY_SONG:    {
422                                 int i;
423                                 char * m[MAX_NUM_SONGS];
424
425                                 for (i=0;i<Num_songs;i++) {
426                                         m[i] = Songs[i].filename;
427                                 }
428                                 i = newmenu_listbox( "Select Song", Num_songs, m, 1, NULL );
429
430                                 if ( i > -1 )   {
431                                         songs_play_song( i, 0 );
432                                 }
433                         }
434                         break;
435         case MENU_LOAD_LEVEL:
436                 if (Current_mission || select_mission(0, "Load Level\n\nSelect mission"))
437                 {
438                         newmenu_item m;
439                         char text[10]="";
440                         int new_level_num;
441
442                         m.type=NM_TYPE_INPUT; m.text_len = 10; m.text = text;
443
444                         newmenu_do( NULL, "Enter level to load", 1, &m, NULL );
445
446                         new_level_num = atoi(m.text);
447
448                         if (new_level_num!=0 && new_level_num>=Last_secret_level && new_level_num<=Last_level)  {
449                                 gr_palette_fade_out( gr_palette, 32, 0 );
450                                 StartNewGame(new_level_num);
451                         }
452                 }
453                 break;
454
455 #endif //ifndef RELEASE
456
457
458 #ifdef NETWORK
459                 //case MENU_START_TCP_NETGAME:
460                 //case MENU_JOIN_TCP_NETGAME:
461                 case MENU_START_IPX_NETGAME:
462                 case MENU_JOIN_IPX_NETGAME:
463                 case MENU_START_UDP_NETGAME:
464                 case MENU_JOIN_UDP_NETGAME:
465                 case MENU_START_KALI_NETGAME:
466                 case MENU_JOIN_KALI_NETGAME:
467                 case MENU_START_MCAST4_NETGAME:
468                 case MENU_JOIN_MCAST4_NETGAME:
469 //                      load_mission(Builtin_mission_num);
470 #ifdef MACINTOSH
471                         Network_game_type = IPX_GAME;
472 #endif
473 //                      WIN(ipx_create_read_thread());
474                         switch (select & ~0x1) {
475                         case MENU_START_IPX_NETGAME: ipx_set_driver(IPX_DRIVER_IPX); break;
476                         case MENU_START_UDP_NETGAME: ipx_set_driver(IPX_DRIVER_UDP); break;
477                         case MENU_START_KALI_NETGAME: ipx_set_driver(IPX_DRIVER_KALI); break;
478                         case MENU_START_MCAST4_NETGAME: ipx_set_driver(IPX_DRIVER_MCAST4); break;
479                         default: Int3();
480                         }
481
482                         if ((select & 0x1) == 0) // MENU_START_*_NETGAME
483                                 network_start_game();
484                         else // MENU_JOIN_*_NETGAME
485                                 network_join_game();
486                         break;
487
488 #ifdef MACINTOSH
489                 case MENU_START_APPLETALK_NETGAME:
490 //                      load_mission(Builtin_mission_num);
491                         #ifdef MACINTOSH
492                         Network_game_type = APPLETALK_GAME;
493                         #endif
494                         network_start_game();
495                         break;
496
497                 case MENU_JOIN_APPLETALK_NETGAME:
498 //                      load_mission(Builtin_mission_num);
499                         #ifdef MACINTOSH
500                         Network_game_type = APPLETALK_GAME;
501                         #endif
502                         network_join_game();
503                         break;
504 #endif
505 #if 0
506                 case MENU_START_TCP_NETGAME:
507                 case MENU_JOIN_TCP_NETGAME:
508                         nm_messagebox (TXT_SORRY,1,TXT_OK,"Not available in shareware version!");
509                         // DoNewIPAddress();
510                         break;
511 #endif
512                 case MENU_START_SERIAL:
513                         com_main_menu();
514                         break;
515                 case MENU_MULTIPLAYER:
516                         do_multi_player_menu();
517                         break;
518 #endif //NETWORK
519                 case MENU_CONFIG:
520                         do_options_menu();
521                         break;
522                 case MENU_SHOW_CREDITS:
523                         gr_palette_fade_out( gr_palette,32,0);
524                         songs_stop_all();
525                         credits_show(NULL); 
526                         break;
527                 default:
528                         Error("Unknown option %d in do_option",select);
529                         break;
530         }
531
532 }
533
534 int do_difficulty_menu()
535 {
536         int s;
537         newmenu_item m[5];
538
539         m[0].type=NM_TYPE_MENU; m[0].text=MENU_DIFFICULTY_TEXT(0);
540         m[1].type=NM_TYPE_MENU; m[1].text=MENU_DIFFICULTY_TEXT(1);
541         m[2].type=NM_TYPE_MENU; m[2].text=MENU_DIFFICULTY_TEXT(2);
542         m[3].type=NM_TYPE_MENU; m[3].text=MENU_DIFFICULTY_TEXT(3);
543         m[4].type=NM_TYPE_MENU; m[4].text=MENU_DIFFICULTY_TEXT(4);
544
545         s = newmenu_do1( NULL, TXT_DIFFICULTY_LEVEL, NDL, m, NULL, Difficulty_level);
546
547         if (s > -1 )    {
548                 if (s != Difficulty_level)
549                 {       
550                         Player_default_difficulty = s;
551                         write_player_file();
552                 }
553                 Difficulty_level = s;
554                 mprintf((0, "%s %s %i\n", TXT_DIFFICULTY_LEVEL, TXT_SET_TO, Difficulty_level));
555                 return 1;
556         }
557         return 0;
558 }
559
560 int     Max_debris_objects, Max_objects_onscreen_detailed;
561 int     Max_linear_depth_objects;
562
563 sbyte   Object_complexity=2, Object_detail=2;
564 sbyte   Wall_detail=2, Wall_render_depth=2, Debris_amount=2, SoundChannels = 2;
565
566 sbyte   Render_depths[NUM_DETAIL_LEVELS-1] =                        { 6,  9, 12, 15, 50};
567 sbyte   Max_perspective_depths[NUM_DETAIL_LEVELS-1] =               { 1,  2,  3,  5,  8};
568 sbyte   Max_linear_depths[NUM_DETAIL_LEVELS-1] =                    { 3,  5,  7, 10, 50};
569 sbyte   Max_linear_depths_objects[NUM_DETAIL_LEVELS-1] =            { 1,  2,  3,  7, 20};
570 sbyte   Max_debris_objects_list[NUM_DETAIL_LEVELS-1] =              { 2,  4,  7, 10, 15};
571 sbyte   Max_objects_onscreen_detailed_list[NUM_DETAIL_LEVELS-1] =   { 2,  4,  7, 10, 15};
572 sbyte   Smts_list[NUM_DETAIL_LEVELS-1] =                            { 2,  4,  8, 16, 50};   //      threshold for models to go to lower detail model, gets multiplied by obj->size
573 sbyte   Max_sound_channels[NUM_DETAIL_LEVELS-1] =                   { 2,  4,  8, 12, 16};
574
575 //      -----------------------------------------------------------------------------
576 //      Set detail level based stuff.
577 //      Note: Highest detail level (detail_level == NUM_DETAIL_LEVELS-1) is custom detail level.
578 void set_detail_level_parameters(int detail_level)
579 {
580         Assert((detail_level >= 0) && (detail_level < NUM_DETAIL_LEVELS));
581
582         if (detail_level < NUM_DETAIL_LEVELS-1) {
583                 Render_depth = Render_depths[detail_level];
584                 Max_perspective_depth = Max_perspective_depths[detail_level];
585                 Max_linear_depth = Max_linear_depths[detail_level];
586                 Max_linear_depth_objects = Max_linear_depths_objects[detail_level];
587
588                 Max_debris_objects = Max_debris_objects_list[detail_level];
589                 Max_objects_onscreen_detailed = Max_objects_onscreen_detailed_list[detail_level];
590
591                 Simple_model_threshhold_scale = Smts_list[detail_level];
592
593                 digi_set_max_channels( Max_sound_channels[ detail_level ] );
594
595                 //      Set custom menu defaults.
596                 Object_complexity = detail_level;
597                 Wall_render_depth = detail_level;
598                 Object_detail = detail_level;
599                 Wall_detail = detail_level;
600                 Debris_amount = detail_level;
601                 SoundChannels = detail_level;
602
603 #if defined(POLY_ACC)
604
605                 #ifdef MACINTOSH
606                         if (detail_level < 2)
607                         {
608                                 pa_set_filtering(0);
609                         }
610                         else if (detail_level < 4)
611                         {
612                                 pa_set_filtering(1);
613                         }
614                         else if (detail_level == 4)
615                         {
616                                 pa_set_filtering(2);
617                         }
618                 #else
619                         pa_filter_mode = detail_level;
620                 #endif
621 #endif
622
623         }
624 }
625
626 //      -----------------------------------------------------------------------------
627 void do_detail_level_menu(void)
628 {
629         int s;
630         newmenu_item m[8];
631
632         m[0].type=NM_TYPE_MENU; m[0].text=MENU_DETAIL_TEXT(0);
633         m[1].type=NM_TYPE_MENU; m[1].text=MENU_DETAIL_TEXT(1);
634         m[2].type=NM_TYPE_MENU; m[2].text=MENU_DETAIL_TEXT(2);
635         m[3].type=NM_TYPE_MENU; m[3].text=MENU_DETAIL_TEXT(3);
636         m[4].type=NM_TYPE_MENU; m[4].text=MENU_DETAIL_TEXT(4);
637         m[5].type=NM_TYPE_TEXT; m[5].text="";
638         m[6].type=NM_TYPE_MENU; m[6].text=MENU_DETAIL_TEXT(5);
639         m[7].type=NM_TYPE_CHECK; m[7].text="Show High Res movies"; m[7].value=MovieHires;
640
641         s = newmenu_do1( NULL, TXT_DETAIL_LEVEL , NDL+3, m, NULL, Detail_level);
642
643         if (s > -1 )    {
644                 switch (s)      {
645                         case 0:
646                         case 1:
647                         case 2:
648                         case 3:
649                         case 4:
650                                 Detail_level = s;
651                                 mprintf((0, "Detail level set to %i\n", Detail_level));
652                                 set_detail_level_parameters(Detail_level);
653                                 break;
654                         case 6:
655                                 Detail_level = 5;
656                                 do_detail_level_menu_custom();
657                                 break;
658                 }
659         }
660         MovieHires = m[7].value;
661 }
662
663 //      -----------------------------------------------------------------------------
664 void do_detail_level_menu_custom_menuset(int nitems, newmenu_item * items, int *last_key, int citem )
665 {
666         nitems = nitems;
667         *last_key = *last_key;
668         citem = citem;
669
670         Object_complexity = items[0].value;
671         Object_detail = items[1].value;
672         Wall_detail = items[2].value;
673         Wall_render_depth = items[3].value;
674         Debris_amount = items[4].value;
675         SoundChannels = items[5].value;
676 #if defined(POLY_ACC)
677         pa_filter_mode = items[6].value;
678 #endif
679
680 }
681
682 void set_custom_detail_vars(void)
683 {
684         Render_depth = Render_depths[Wall_render_depth];
685
686         Max_perspective_depth = Max_perspective_depths[Wall_detail];
687         Max_linear_depth = Max_linear_depths[Wall_detail];
688
689         Max_debris_objects = Max_debris_objects_list[Debris_amount];
690
691         Max_objects_onscreen_detailed = Max_objects_onscreen_detailed_list[Object_complexity];
692         Simple_model_threshhold_scale = Smts_list[Object_complexity];
693         Max_linear_depth_objects = Max_linear_depths_objects[Object_detail];
694
695         digi_set_max_channels( Max_sound_channels[ SoundChannels ] );
696         
697 }
698
699 #define DL_MAX  10
700
701 //      -----------------------------------------------------------------------------
702
703 void do_detail_level_menu_custom(void)
704 {
705         int     count;
706         int     s=0;
707         newmenu_item m[DL_MAX];
708         #if defined(POLY_ACC)
709         int filtering_id;
710         #endif
711
712         do {
713                 count = 0;
714                 m[count].type = NM_TYPE_SLIDER;
715                 m[count].text = TXT_OBJ_COMPLEXITY;
716                 m[count].value = Object_complexity;
717                 m[count].min_value = 0;
718                 m[count++].max_value = NDL-1;
719
720                 m[count].type = NM_TYPE_SLIDER;
721                 m[count].text = TXT_OBJ_DETAIL;
722                 m[count].value = Object_detail;
723                 m[count].min_value = 0;
724                 m[count++].max_value = NDL-1;
725
726                 m[count].type = NM_TYPE_SLIDER;
727                 m[count].text = TXT_WALL_DETAIL;
728                 m[count].value = Wall_detail;
729                 m[count].min_value = 0;
730                 m[count++].max_value = NDL-1;
731
732                 m[count].type = NM_TYPE_SLIDER;
733                 m[count].text = TXT_WALL_RENDER_DEPTH;
734                 m[count].value = Wall_render_depth;
735                 m[count].min_value = 0;
736                 m[count++].max_value = NDL-1;
737
738                 m[count].type = NM_TYPE_SLIDER;
739                 m[count].text= TXT_DEBRIS_AMOUNT;
740                 m[count].value = Debris_amount;
741                 m[count].min_value = 0;
742                 m[count++].max_value = NDL-1;
743
744                 m[count].type = NM_TYPE_SLIDER;
745                 m[count].text= TXT_SOUND_CHANNELS;
746                 m[count].value = SoundChannels;
747                 m[count].min_value = 0;
748                 m[count++].max_value = NDL-1;
749
750                 #if defined(POLY_ACC)
751                 MAC( if(PAEnabled){ )
752                         filtering_id = count;
753                         m[count].type = NM_TYPE_SLIDER;
754                         m[count].text= "FILTERING";
755                         m[count].value = pa_filter_mode;
756                         m[count].min_value = 0;
757                         #ifdef MACINTOSH
758                         m[count++].max_value = 2;
759                         #else
760                         m[count++].max_value = NDL-1;
761                         #endif
762                 MAC(})
763                 #endif
764
765                 m[count].type = NM_TYPE_TEXT;
766                 m[count++].text= TXT_LO_HI;
767
768                 Assert(count < DL_MAX);
769
770                 s = newmenu_do1( NULL, TXT_DETAIL_CUSTOM, count, m, do_detail_level_menu_custom_menuset, s);
771         } while (s > -1);
772
773         set_custom_detail_vars();
774
775         #if defined(MACINTOSH) && defined(POLY_ACC)
776         if ( PAEnabled )
777                 pa_set_filtering( m[filtering_id].value );
778         #endif
779 }
780
781 #ifndef MACINTOSH
782 int Default_display_mode=0;
783 int Current_display_mode=0;
784 #else
785 int Default_display_mode=1;
786 int Current_display_mode=1;
787 #endif
788
789 extern int MenuHiresAvailable;
790
791 typedef struct {
792         int     VGA_mode;
793         short   w,h;
794         short   render_method;
795         short   flags;
796 } dmi;
797
798 dmi display_mode_info[7] = {
799                 #ifdef WINDOWS
800                         {SM95_320x200x8X, 320, 200, VR_NONE, VRF_ALLOW_COCKPIT},
801                         {SM95_640x480x8, 640, 480, VR_NONE, VRF_COMPATIBLE_MENUS+VRF_ALLOW_COCKPIT},
802                         {SM95_640x400x8, 640, 400, VR_NONE, VRF_COMPATIBLE_MENUS }, 
803                         {SM95_800x600x8, 800, 600, VR_NONE, VRF_COMPATIBLE_MENUS },
804                         {SM95_1024x768x8, 1024, 768, VR_NONE, VRF_COMPATIBLE_MENUS }, 
805                 #else
806                         {SM(320,200),    320,   200, VR_NONE, VRF_ALLOW_COCKPIT+VRF_COMPATIBLE_MENUS}, 
807                         {SM(640,480),    640, 480, VR_NONE, VRF_COMPATIBLE_MENUS+VRF_ALLOW_COCKPIT},
808                         {SM(320,400),    320, 400, VR_NONE, VRF_USE_PAGING},
809                         {SM(640,400),    640, 400, VR_NONE, VRF_COMPATIBLE_MENUS}, 
810                         {SM(800,600),    800, 600, VR_NONE, VRF_COMPATIBLE_MENUS}, 
811                         {SM(1024,768),  1024,   768, VR_NONE, VRF_COMPATIBLE_MENUS},    
812                         {SM(1280,1024),1280,1024, VR_NONE, VRF_COMPATIBLE_MENUS}, 
813                 #endif
814 };
815  
816 WIN(extern int DD_Emulation);
817
818
819 void set_display_mode(int mode)
820 {
821         dmi *dmi;
822
823         if ((Current_display_mode == -1)||(VR_render_mode != VR_NONE))  //special VR mode
824                 return;                                                         //...don't change
825
826         #if !defined(MACINTOSH) && !defined(WINDOWS)
827         if (0) // (mode >= 5 && !FindArg("-superhires"))
828                 mode = 4;
829         #endif
830
831         if (!MenuHiresAvailable && (mode != 2))
832                 mode = 0;
833
834 #ifndef WINDOWS
835
836         if (gr_check_mode(display_mode_info[mode].VGA_mode) != 0)               //can't do mode
837                 #ifndef MACINTOSH
838                 mode = 0;
839                 #else
840                 mode = 1;
841                 #endif
842
843         Current_display_mode = mode;
844 #else
845         if (mode == 2) mode = 3;                                        // 320x400 -> 640x400.
846         Current_display_mode = mode;
847         if (mode >= 3) mode--;                                          // Match to Windows dmi.
848         if (DDCheckMode(display_mode_info[mode].VGA_mode)) {
849                 if (Platform_system == WINNT_PLATFORM || DD_Emulation) mode = 1;
850                 else mode = 0;
851                 Current_display_mode = mode;
852         }
853 #endif
854
855         dmi = &display_mode_info[mode];
856
857         if (Current_display_mode != -1) {
858
859                 game_init_render_buffers(dmi->VGA_mode,dmi->w,dmi->h,dmi->render_method,dmi->flags);
860                 Default_display_mode = Current_display_mode;
861         }
862
863         Screen_mode = -1;               //force screen reset
864 }
865
866 #ifdef MACINTOSH        // use Mac version of do_screen_res_menu
867
868 void do_screen_res_menu()
869 {
870         #define N_SCREENRES_ITEMS 6
871         
872         newmenu_item m[N_SCREENRES_ITEMS];
873         int citem, i, n_items, odisplay_mode, result;
874
875         if ((Current_display_mode == -1)||(VR_render_mode != VR_NONE))          //special VR mode
876         {                               
877                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
878                                 "You may not change screen\n"
879                                 "resolution when VR modes enabled.");
880                 return;
881         }
882
883         m[0].type=NM_TYPE_TEXT;  m[0].value=0; m[0].text="Modes w/ Cockpit:";
884         m[1].type=NM_TYPE_RADIO; m[1].value=0; m[1].group=0; m[1].text=" 640x480";
885         m[2].type=NM_TYPE_TEXT;  m[2].value=0; m[2].text="Modes w/o Cockpit:";
886         m[3].type=NM_TYPE_RADIO; m[3].value=0; m[3].group=0; m[3].text=" 800x600";
887 //      m[4].type=NM_TYPE_RADIO; m[4].value=0; m[4].group=0; m[4].text=" 1024x768";
888 //      m[5].type=NM_TYPE_RADIO; m[5].value=0; m[5].group=0; m[5].text=" 1280x1024";
889         n_items = 4;
890
891         odisplay_mode = VGA_current_mode;
892         citem = Current_display_mode;
893         if (Current_display_mode >= 2)
894                 citem--;
895
896         if (citem >= n_items)
897                 citem = n_items-1;
898
899         m[citem].value = 1;
900
901         newmenu_do1( NULL, "Select screen mode", n_items, m, NULL, citem);
902
903         for (i=0;i<n_items;i++)
904                 if (m[i].value)
905                         break;
906         if (i >= 3)
907                 i++;
908
909 #if 0 //def SHAREWARE
910         if (i > 1)
911                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
912                         "High resolution modes are\n"
913                         "only available in the\n"
914                         "Commercial version of Descent 2.");
915         return;
916 #else
917         result = vga_check_mode(display_mode_info[i].VGA_mode);
918         
919         if (result) {
920                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
921                                 "Cannot set requested\n"
922                                 "mode on this video card.");
923                 return;
924         }
925         
926         set_display_mode(i);
927         reset_cockpit();
928 #endif
929
930 }
931
932 #else   // PC version of do_screen_res_menu is below
933
934 void do_screen_res_menu()
935 {
936 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
937 #define N_SCREENRES_ITEMS 10
938         int fullscreenc;
939 #else
940         #define N_SCREENRES_ITEMS 9
941 #endif
942         newmenu_item m[N_SCREENRES_ITEMS];
943         int citem;
944         int i;
945         int n_items;
946
947         if ((Current_display_mode == -1)||(VR_render_mode != VR_NONE)) {                                //special VR mode
948                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
949                                 "You may not change screen\n"
950                                 "resolution when VR modes enabled.");
951                 return;
952         }
953
954         m[0].type=NM_TYPE_TEXT;  m[0].value=0;                            m[0].text="Modes w/ Cockpit:";
955         
956 #ifdef WINDOWS
957         if (Platform_system == WINNT_PLATFORM || DD_Emulation) {
958                 m[1].type=NM_TYPE_TEXT; m[1].value=0; m[1].text=" 320x200 N/A";
959         } else
960 #endif
961                 //NOTE LINK TO ABOVE IF
962                 m[1].type=NM_TYPE_RADIO; m[1].value=0; m[1].group=0; m[1].text=" 320x200";
963
964         m[2].type=NM_TYPE_RADIO; m[2].value=0; m[2].group=0; m[2].text=" 640x480";
965         m[3].type=NM_TYPE_TEXT;  m[3].value=0;                                    m[3].text="Modes w/o Cockpit:";
966 #ifdef WINDOWS
967         m[4].type=NM_TYPE_RADIO; m[4].value=0; m[4].group=0; m[4].text=" 640x400";
968         m[5].type=NM_TYPE_RADIO; m[5].value=0; m[5].group=0; m[5].text=" 800x600";
969 //      m[6].type=NM_TYPE_RADIO; m[6].value=0; m[6].group=0; m[6].text=" 1024x768";
970         n_items = 6;
971 #else
972         m[4].type=NM_TYPE_RADIO; m[4].value=0; m[4].group=0; m[4].text=" 320x400";
973         m[5].type=NM_TYPE_RADIO; m[5].value=0; m[5].group=0; m[5].text=" 640x400";
974         m[6].type=NM_TYPE_RADIO; m[6].value=0; m[6].group=0; m[6].text=" 800x600";
975         n_items = 7;
976         if (1) { //(FindArg("-superhires")) {
977                 m[7].type=NM_TYPE_RADIO; m[7].value=0; m[7].group=0; m[7].text=" 1024x768";
978                 m[8].type=NM_TYPE_RADIO; m[8].value=0; m[8].group=0; m[8].text=" 1280x1024";
979                 n_items += 2;
980         }
981 #endif
982
983 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
984         m[n_items].type = NM_TYPE_CHECK; m[n_items].text = "Fullscreen";
985         m[n_items].value = gr_check_fullscreen();
986         fullscreenc=n_items++;
987 #endif
988
989         citem = Current_display_mode+1;
990         
991 #ifdef WINDOWS
992         if (citem == 3) citem++;                                // if 320x400 in DOS, make it look like 640x400
993 #else
994         if (Current_display_mode >= 2)
995                 citem++;
996 #endif
997
998         if (citem >= n_items)
999                 citem = n_items-1;
1000
1001         m[citem].value = 1;
1002
1003         newmenu_do1( NULL, "Select screen mode", n_items, m, NULL, citem);
1004
1005 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1006         if (m[fullscreenc].value != gr_check_fullscreen()){
1007                 gr_toggle_fullscreen();
1008                 Game_screen_mode = -1;
1009         }
1010 #endif
1011
1012         for (i=0;i<n_items;i++)
1013                 if (m[i].value)
1014                         break;
1015
1016 #ifndef WINDOWS                                                                 // if i >= 4 keep it that way since we skip 320x400
1017         if (i >= 4)
1018                 i--;
1019 #endif
1020
1021         i--;
1022
1023 #ifndef WINDOWS
1024         if (((i != 0) && (i != 2) && !MenuHiresAvailable) || gr_check_mode(display_mode_info[i].VGA_mode)) {
1025                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
1026                                 "Cannot set requested\n"
1027                                 "mode on this video card.");
1028                 return;
1029         }
1030 #else
1031         if (i >= 3) 
1032                 result = DDCheckMode(display_mode_info[i-1].VGA_mode);
1033         else 
1034                 result = DDCheckMode(display_mode_info[i].VGA_mode);
1035
1036         if (result) {
1037                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
1038                                 "Mode not supported by your\n"
1039                                 "DirectDraw driver.\n", 
1040                                 "Using default mode for gameplay.\n");
1041                 return;
1042         }
1043
1044 #endif
1045 #ifdef SHAREWARE
1046                 if (i != 0)
1047                         nm_messagebox(TXT_SORRY, 1, TXT_OK, 
1048                                 "High resolution modes are\n"
1049                                 "only available in the\n"
1050                                 "Commercial version of Descent 2.");
1051                 return;
1052 #else
1053                 if (i != Current_display_mode)
1054                         set_display_mode(i);
1055 #endif
1056
1057 }
1058 #endif  // end of PC version of do_screen_res_menu()
1059
1060
1061
1062 void do_new_game_menu()
1063 {
1064         int new_level_num,player_highest_level;
1065
1066     if (!select_mission(0, "New Game\n\nSelect mission"))
1067         return;
1068     
1069         new_level_num = 1;
1070
1071         player_highest_level = get_highest_level();
1072
1073         if (player_highest_level > Last_level)
1074                 player_highest_level = Last_level;
1075
1076         if (player_highest_level > 1) {
1077                 newmenu_item m[4];
1078                 char info_text[80];
1079                 char num_text[10];
1080                 int choice;
1081                 int n_items;
1082
1083 try_again:
1084                 sprintf(info_text,"%s %d",TXT_START_ANY_LEVEL, player_highest_level);
1085
1086                 m[0].type=NM_TYPE_TEXT; m[0].text = info_text;
1087                 m[1].type=NM_TYPE_INPUT; m[1].text_len = 10; m[1].text = num_text;
1088                 n_items = 2;
1089
1090                 #ifdef WINDOWS
1091                 m[2].type = NM_TYPE_TEXT; m[2].text = "";
1092                 m[3].type = NM_TYPE_MENU; m[3].text = "          Ok";
1093                 n_items = 4;
1094                 #endif
1095
1096                 strcpy(num_text,"1");
1097
1098                 choice = newmenu_do( NULL, TXT_SELECT_START_LEV, n_items, m, NULL );
1099
1100                 if (choice==-1 || m[1].text[0]==0)
1101                         return;
1102
1103                 new_level_num = atoi(m[1].text);
1104
1105                 if (!(new_level_num>0 && new_level_num<=player_highest_level)) {
1106                         m[0].text = TXT_ENTER_TO_CONT;
1107                         nm_messagebox( NULL, 1, TXT_OK, TXT_INVALID_LEVEL); 
1108                         goto try_again;
1109                 }
1110         }
1111
1112         Difficulty_level = Player_default_difficulty;
1113
1114         if (!do_difficulty_menu())
1115                 return;
1116
1117         gr_palette_fade_out( gr_palette, 32, 0 );
1118         StartNewGame(new_level_num);
1119
1120 }
1121
1122 extern void GameLoop(int, int );
1123
1124 extern int Redbook_enabled;
1125
1126 void options_menuset(int nitems, newmenu_item * items, int *last_key, int citem )
1127 {
1128         if ( citem==5)
1129         {
1130                 gr_palette_set_gamma(items[5].value);
1131         }
1132
1133         nitems++;               //kill warning
1134         last_key++;             //kill warning
1135 }
1136
1137
1138 // added on 9/20/98 by Victor Rachels to attempt to add screen res change ingame
1139 // Changed on 3/24/99 by Owen Evans to make it work  =)
1140 void change_res_poll()
1141 {
1142 }
1143
1144 void change_res()
1145 {
1146         // edited 05/27/99 Matt Mueller - ingame fullscreen changing
1147         newmenu_item m[11];
1148         u_int32_t modes[11];
1149         int i = 0, mc = 0, num_presets = 0;
1150         char customres[16];
1151 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1152         int fullscreenc;
1153 #endif
1154         //end edit -MM
1155         u_int32_t screen_mode = 0;
1156         int screen_width = 0;
1157         int screen_height = 0;
1158         int vr_mode = VR_NONE;
1159         int screen_flags = 0;
1160
1161         m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200"; m[mc].value = (Game_screen_mode == SM(320, 200)); m[mc].group = 0; modes[mc] = SM(320, 200); mc++;
1162         m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480"; m[mc].value = (Game_screen_mode == SM(640, 480)); m[mc].group = 0; modes[mc] = SM(640, 480); mc++;
1163         m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x400"; m[mc].value = (Game_screen_mode == SM(320, 400)); m[mc].group = 0; modes[mc] = SM(320, 400); mc++;
1164         m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x400"; m[mc].value = (Game_screen_mode == SM(640, 400)); m[mc].group = 0; modes[mc] = SM(640, 400); mc++;
1165         m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600"; m[mc].value = (Game_screen_mode == SM(800, 600)); m[mc].group = 0; modes[mc] = SM(800, 600); mc++;
1166         m[mc].type = NM_TYPE_RADIO; m[mc].text = "1024x768"; m[mc].value = (Game_screen_mode == SM(1024, 768)); m[mc].group = 0; modes[mc] = SM(1024, 768); mc++;
1167         m[mc].type = NM_TYPE_RADIO; m[mc].text = "1280x1024"; m[mc].value = (Game_screen_mode == SM(1280, 1024)); m[mc].group = 0; modes[mc] = SM(1280, 1024); mc++;
1168
1169         num_presets = mc;
1170         for (i = 0; i < mc; i++)
1171                 if (m[mc].value)
1172                         break;
1173
1174         m[mc].type = NM_TYPE_RADIO; m[mc].text = "custom:"; m[mc].value = (i == mc); m[mc].group = 0; modes[mc] = 0; mc++;
1175         sprintf(customres, "%ix%i", SM_W(Game_screen_mode), SM_H(Game_screen_mode));
1176         m[mc].type = NM_TYPE_INPUT; m[mc].text = customres; m[mc].text_len = 11; modes[mc] = 0; mc++;
1177
1178         //m[mc].type = NM_TYPE_CHECK; m[mc].text = "No Doublebuffer"; m[mc].value = use_double_buffer;
1179
1180         // added 05/27/99 Matt Mueller - ingame fullscreen changing
1181 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1182         fullscreenc = mc; m[mc].type = NM_TYPE_CHECK; m[mc].text = "Fullscreen"; m[mc].value = gr_check_fullscreen(); mc++;
1183 #endif
1184         // end addition -MM
1185
1186
1187         i = newmenu_do1(NULL, "Screen Resolution", mc, m, &change_res_poll, 0);
1188
1189         // added 05/27/99 Matt Mueller - ingame fullscreen changing
1190 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1191         if (m[fullscreenc].value != gr_check_fullscreen())
1192         {
1193                 gr_toggle_fullscreen();
1194         Game_screen_mode = -1;
1195         }
1196 #endif
1197         // end addition -MM
1198
1199         for (i = 0; (m[i].value == 0) && (i < num_presets); i++);
1200
1201         for(i = 0; (m[i].value == 0) && (i < num_presets); i++);
1202
1203         if (modes[i]==0)
1204         {
1205                 char *h = strchr(customres, 'x');
1206                 if (!h)
1207                         return;
1208                 screen_mode = SM(atoi(customres), atoi(h+1));
1209         }
1210         else
1211         {
1212                 screen_mode = modes[i];
1213         }
1214
1215         screen_width = SM_W(screen_mode);
1216         screen_height = SM_H(screen_mode);
1217         if (screen_height <= 0 || screen_width <= 0)
1218                 return;
1219
1220         switch (screen_mode)
1221         {
1222         case SM(320, 200):
1223         case SM(640, 480):
1224                 screen_flags = VRF_ALLOW_COCKPIT + VRF_COMPATIBLE_MENUS;
1225                 break;
1226         default:
1227                 screen_flags = VRF_COMPATIBLE_MENUS;
1228                 break;
1229         }
1230
1231 #ifdef __MSDOS__
1232         if (FindArg("-nodoublebuffer"))
1233 #endif
1234         {
1235                 screen_flags &= ~VRF_USE_PAGING;
1236         }
1237
1238         // added 6/15/1999 by Owen Evans to eliminate unneccesary mode modification
1239         if (Game_screen_mode == screen_mode)
1240                 return;
1241         //gr_set_mode(Game_screen_mode);
1242         // end section - OE
1243
1244         //VR_offscreen_buffer = 0; // Disable VR (so that VR_Screen_mode doesnt mess us up
1245         Game_screen_mode = screen_mode;
1246         Game_window_w = screen_width;
1247         Game_window_h = screen_height;
1248         game_init_render_buffers(screen_mode, screen_width, screen_height, vr_mode, screen_flags);
1249 }
1250 //End changed section (OE)
1251
1252
1253 //added on 8/18/98 by Victor Rachels to add d1x options menu, maxfps setting
1254 //added/edited on 8/18/98 by Victor Rachels to set maxfps always on, max=80
1255 //added/edited on 9/7/98 by Victor Rachels to attempt dir browsing.  failed.
1256
1257 void d2x_options_menu_poll(int nitems, newmenu_item * menus, int * key, int citem)
1258 {
1259 }
1260
1261
1262 void d2x_options_menu()
1263 {
1264         newmenu_item m[14];
1265         int i=0;
1266         int opt = 0;
1267         int inputs, commands;
1268 #if 0
1269         int checks;
1270 #endif
1271
1272         char smaxfps[4];
1273 #if 0
1274         char shudmaxnumdisp[4];
1275         char thogdir[64];
1276         extern int gr_message_color_level;
1277
1278         sprintf(thogdir,AltHogDir);
1279 #endif
1280         sprintf(smaxfps,"%d",maxfps);
1281 #if 0
1282         sprintf(shudmaxnumdisp,"%d",HUD_max_num_disp);
1283
1284         m[opt].type = NM_TYPE_MENU;  m[opt].text = "Primary autoselect ordering...";   opt++;
1285         m[opt].type = NM_TYPE_MENU;  m[opt].text = "Secondary autoselect ordering..."; opt++;
1286 #endif
1287
1288 #ifdef D2X_KEYS
1289         //added on 2/4/99 by Victor Rachels for new key menu
1290         m[opt].type = NM_TYPE_MENU;  m[opt].text = "D2X Keys"; opt++;
1291         //end this section addition - VR
1292 #endif
1293
1294         // enabled 3/24/99 - Owen Evans
1295         m[opt].type = NM_TYPE_MENU; m[opt].text = "Change Screen Resolution"; opt++;
1296         // end enabled stuff - OE
1297
1298         commands=opt;
1299 #if 0
1300         //added on 2/2/99 by Victor Rachels for bans
1301 #ifdef NETWORK
1302         m[opt].type = NM_TYPE_MENU; m[opt].text = "Save bans now"; opt++;
1303 #endif
1304         //end this section addition - VR
1305 #endif // 0
1306
1307         m[opt].type = NM_TYPE_TEXT;  m[opt].text = "Maximum Framerate (1-80):";       opt++;
1308
1309
1310         inputs=opt;
1311         m[opt].type = NM_TYPE_INPUT; m[opt].text = smaxfps; m[opt].text_len=3;         opt++;
1312 #if 0
1313         m[opt].type = NM_TYPE_TEXT;  m[opt].text = "Mission Directory";                opt++;
1314         m[opt].type = NM_TYPE_INPUT; m[opt].text = thogdir; m[opt].text_len=64;        opt++;
1315         m[opt].type = NM_TYPE_TEXT;  m[opt].text = "Hud Messages lines (1-80):";       opt++;
1316         m[opt].type = NM_TYPE_INPUT; m[opt].text = shudmaxnumdisp; m[opt].text_len=3;  opt++;
1317         m[opt].type = NM_TYPE_SLIDER; m[opt].text = "Message colorization level"; m[opt].value=gr_message_color_level;m[opt].min_value=0;m[opt].max_value=3;  opt++;
1318         checks=opt;
1319 #ifdef __MSDOS__
1320         m[opt].type = NM_TYPE_CHECK; m[opt].text = "Joy is sidewinder"; m[opt].value=Joy_is_Sidewinder;  opt++;
1321 #endif
1322 #ifdef SUPPORTS_NICEFPS
1323         m[opt].type = NM_TYPE_CHECK; m[opt].text = "Nice FPS (free cpu cycles)"; m[opt].value = use_nice_fps; opt++;
1324 #endif
1325 #endif // 0
1326
1327         for(;;)
1328         {
1329                 i=newmenu_do1( NULL, "D2X options", opt, m, &d2x_options_menu_poll, i);
1330
1331                 if(i>-1)
1332                 {
1333             if(i<commands)
1334                         {
1335                                 switch(i)
1336                                 {
1337 #if 0
1338                                 case 0: reorder_primary(); break;
1339                                 case 1: reorder_secondary(); break;
1340 #endif
1341 #ifdef D2X_KEYS
1342                                         //added on 2/4/99 by Victor Rachels for new key menu
1343                                 case 0: kconfig(4, "D2X Keys"); break;
1344                                         //end this section addition - VR
1345 #endif
1346                                         // enabled 3/24/99 - Owen Evans
1347                                 case 0: change_res(); break;
1348                                         // end enabled stuff - OE
1349                                 }
1350                         }
1351
1352 #if 0
1353             //added on 2/4/99 by Victor Rachels for bans
1354 #ifdef NETWORK
1355             if(i==commands+0)
1356                         {              
1357
1358                                 nm_messagebox(NULL,1,TXT_OK, "%i Bans saved",writebans());
1359
1360                         }
1361 #endif
1362             //end this section addition - VR
1363 #endif // 0
1364
1365             if(i == inputs+0)
1366                         {
1367                                 maxfps = atoi(smaxfps);
1368                 if(maxfps < 1 || maxfps>80)
1369                                 {
1370                                         nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid value for maximum framerate");
1371                                         maxfps = 80;
1372                                         i = (inputs+0);
1373                                 }
1374                         }
1375 #if 0
1376             else if(i==inputs+2)
1377                                 cfile_use_alternate_hogdir(thogdir);
1378                         else if(i==inputs+4)
1379                         {
1380                                 HUD_max_num_disp = atoi(shudmaxnumdisp);
1381                 if(HUD_max_num_disp < 1||HUD_max_num_disp>HUD_MAX_NUM)
1382                                 {
1383                                         nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid value for hud lines");
1384                                         HUD_max_num_disp=4;
1385                                         //                   i=(inputs+4);//???
1386                                 }
1387                         }
1388                         gr_message_color_level=m[inputs+5].value;
1389
1390                         sprintf(shudmaxnumdisp,"%d",HUD_max_num_disp);
1391 #endif // 0
1392                         sprintf(smaxfps,"%d",maxfps);
1393                         //           m[inputs+0].text=smaxfps;//redundant.. its not going anywhere
1394 #if 0
1395                         sprintf(thogdir,AltHogDir);
1396                         //           m[inputs+2].text=thogdir;//redundant
1397 #endif
1398                 }
1399                 else
1400                         break;
1401         }
1402
1403 #if 0
1404         write_player_file();
1405
1406 #ifdef __MSDOS__
1407         Joy_is_Sidewinder=m[(checks+0)].value;
1408 #endif
1409 #ifdef __linux__
1410         Joy_is_Sidewinder=0;
1411 #endif
1412 #ifdef SUPPORTS_NICEFPS
1413         use_nice_fps=m[(checks+0)].value;
1414 #else
1415         use_nice_fps=0;
1416 #endif
1417 #endif // 0
1418 }
1419
1420 //end edit - Victor Rachels
1421 //end addition - Victor Rachels
1422
1423
1424 void do_options_menu()
1425 {
1426         newmenu_item m[13];
1427         int i = 0;
1428
1429         do {
1430                 m[ 0].type = NM_TYPE_MENU;   m[ 0].text="Sound effects & music...";
1431                 m[ 1].type = NM_TYPE_TEXT;   m[ 1].text="";
1432                 #if defined(MACINTOSH) && defined(APPLE_DEMO)
1433                 m [2].type = NM_TYPE_TEXT;   m[ 2].text="";
1434                 #else
1435                 m[ 2].type = NM_TYPE_MENU;   m[ 2].text=TXT_CONTROLS_;
1436                 #endif
1437         #ifdef WINDOWS
1438                 m[ 3].type = NM_TYPE_MENU;   m[ 3].text="INVOKE JOYSTICK CONTROL PANEL";
1439         #else
1440                 m[ 3].type = NM_TYPE_MENU;   m[ 3].text=TXT_CAL_JOYSTICK;
1441         #endif
1442                 m[ 4].type = NM_TYPE_TEXT;   m[ 4].text="";
1443
1444 #if defined(POLY_ACC)
1445         #ifdef MACINTOSH
1446
1447                 if ( !PAEnabled )
1448                 {
1449                         m[5].type               = NM_TYPE_SLIDER;
1450                         m[5].text               = TXT_BRIGHTNESS;
1451                         m[5].value              = gr_palette_get_gamma();
1452                         m[5].min_value  = 0;
1453                         m[5].max_value  = 8; 
1454                 }
1455                 else
1456                 {
1457                         m[ 5].type = NM_TYPE_TEXT;   m[ 5].text="";
1458                 }
1459         
1460         #else
1461                 m[ 5].type = NM_TYPE_TEXT;   m[ 5].text="";
1462         #endif
1463 #else
1464                 m[5].type = NM_TYPE_SLIDER;
1465                 m[5].text = TXT_BRIGHTNESS;
1466                 m[5].value = gr_palette_get_gamma();
1467                 m[5].min_value = 0;
1468                 m[5].max_value = 16; // CCA too dim, was 8;
1469 #endif
1470
1471
1472 #ifdef PA_3DFX_VOODOO
1473                 m[ 6].type = NM_TYPE_TEXT;   m[ 6].text="";
1474 #else
1475                 m[ 6].type = NM_TYPE_MENU;   m[ 6].text=TXT_DETAIL_LEVELS;
1476 #endif
1477
1478 #if defined(POLY_ACC)
1479                 m[ 7].type = NM_TYPE_TEXT;   m[ 7].text="";
1480 #else
1481                 #ifdef MACINTOSH
1482                         if ( gConfigInfo.mChangeResolution && !PAEnabled )
1483                         {
1484                                 m[ 7].type = NM_TYPE_MENU;   m[ 7].text="Screen resolution...";
1485                         }
1486                         else    // for when we are on a mac and no resolution switching allowed
1487                         {
1488                                 m[ 7].type = NM_TYPE_TEXT;   m[ 7].text="";
1489                         }
1490                 #else   // for PC's
1491                         m[ 7].type = NM_TYPE_MENU;   m[ 7].text="Screen resolution...";
1492                 #endif  // end of #ifdef macintosh
1493
1494 #endif
1495
1496                 m[ 8].type = NM_TYPE_TEXT;   m[ 8].text="";
1497                 m[ 9].type = NM_TYPE_MENU;   m[ 9].text="Primary autoselect ordering...";
1498                 m[10].type = NM_TYPE_MENU;   m[10].text="Secondary autoselect ordering...";
1499                 m[11].type = NM_TYPE_MENU;   m[11].text="Toggles...";
1500
1501                 m[12].type = NM_TYPE_MENU;   m[12].text="D2X options...";
1502
1503                 i = newmenu_do1( NULL, TXT_OPTIONS, sizeof(m)/sizeof(*m), m, options_menuset, i );
1504                         
1505                 switch(i)       {
1506                         case  0: do_sound_menu();                       break;
1507                         case  2: joydefs_config();                      break;
1508                         case  3: joydefs_calibrate();           break;
1509                         case  6: do_detail_level_menu();        break;
1510                         case  7: do_screen_res_menu();          break;
1511                         case  9: ReorderPrimary();                      break;
1512                         case 10: ReorderSecondary();            break;
1513                         case 11: do_toggles_menu();                     break;
1514                         case 12: d2x_options_menu();        break;
1515                 }
1516
1517         } while( i>-1 );
1518
1519         write_player_file();
1520 }
1521
1522 extern int Redbook_playing;
1523 void set_redbook_volume(int volume);
1524
1525 WIN(extern int RBCDROM_State);
1526 WIN(static BOOL windigi_driver_off=FALSE);
1527
1528 void sound_menuset(int nitems, newmenu_item * items, int *last_key, int citem )
1529 {
1530         nitems=nitems;          
1531         *last_key = *last_key;
1532
1533         if ( Config_digi_volume != items[0].value )     {
1534                 Config_digi_volume = items[0].value;
1535
1536                 #ifdef WINDOWS
1537                         if (windigi_driver_off) {
1538                                 digi_midi_wait();
1539                                 digi_init_digi();
1540                                 Sleep(500);
1541                                 windigi_driver_off = FALSE;
1542                         }
1543                 #endif                  
1544                 
1545                 #ifndef MACINTOSH
1546                         digi_set_digi_volume( (Config_digi_volume*32768)/8 );
1547                 #else
1548                         digi_set_digi_volume( (Config_digi_volume*256)/8 );
1549                 #endif
1550                 digi_play_sample_once( SOUND_DROP_BOMB, F1_0 );
1551         }
1552
1553 #ifdef WINDOWS
1554         if (!wmidi_support_volchange()) {
1555                 if (!items[1].value && Config_midi_volume) {
1556                         Config_midi_volume = 0;
1557                         digi_set_midi_volume(0);
1558                         digi_play_midi_song( NULL, NULL, NULL, 0 );
1559                 }
1560                 else if (Config_midi_volume == 0 && items[1].value) {
1561                         digi_set_midi_volume(64);
1562                         Config_midi_volume = 4;
1563                 }
1564         }
1565         else     // LINK TO BELOW IF
1566 #endif
1567         if (Config_midi_volume != items[1].value )   {
1568                 Config_midi_volume = items[1].value;
1569                 #ifdef WINDOWS
1570                         if (!windigi_driver_off) {
1571                                 Sleep(200);
1572                                 digi_close_digi();
1573                                 Sleep(100);
1574                                 windigi_driver_off = TRUE;
1575                         }
1576                 #endif
1577                 #ifndef MACINTOSH
1578                         digi_set_midi_volume( (Config_midi_volume*128)/8 );
1579                 #else
1580                         digi_set_midi_volume( (Config_midi_volume*256)/8 );
1581                 #endif
1582         }
1583 #ifdef MACINTOSH
1584         if (Config_master_volume != items[3].value ) {
1585                 Config_master_volume = items[3].value;
1586                 digi_set_master_volume( Config_master_volume );
1587                 digi_play_sample_once( SOUND_DROP_BOMB, F1_0 );
1588         }
1589 #endif
1590
1591         // don't enable redbook for a non-apple demo version of the shareware demo
1592         #if !defined(SHAREWARE) || ( defined(SHAREWARE) && defined(APPLE_DEMO) )
1593
1594         if (Config_redbook_volume != items[2].value )   {
1595                 Config_redbook_volume = items[2].value;
1596                 set_redbook_volume(Config_redbook_volume);
1597         }
1598
1599         if (items[4].value != (Redbook_playing!=0)) {
1600
1601                 if (items[4].value && FindArg("-noredbook")) {
1602                         nm_messagebox (TXT_SORRY,1,TXT_OK,"Redbook audio has been disabled\non the command line");
1603                         items[4].value = 0;
1604                         items[4].redraw = 1;
1605                 }
1606                 else {
1607                         Redbook_enabled = items[4].value;
1608
1609                         mprintf((1, "Redbook_enabled = %d\n", Redbook_enabled));
1610
1611                         if (Function_mode == FMODE_MENU)
1612                                 songs_play_song(SONG_TITLE,1);
1613                         else if (Function_mode == FMODE_GAME)
1614                                 songs_play_level_song( Current_level_num );
1615                         else
1616                                 Int3();
1617
1618                         if (items[4].value && !Redbook_playing) {
1619                         #ifdef WINDOWS
1620                                 if (RBCDROM_State == -1) 
1621                                         nm_messagebox (TXT_SORRY,1,TXT_OK,"Cannot start CD Music.\nAnother application is\nusing the CD player.\n");
1622                                 else // link to next code line!
1623                         #endif
1624                                 nm_messagebox (TXT_SORRY,1,TXT_OK,"Cannot start CD Music.  Insert\nyour Descent II CD and try again");
1625                                 items[4].value = 0;
1626                                 items[4].redraw = 1;
1627                         }
1628
1629                         items[1].type = (Redbook_playing?NM_TYPE_TEXT:NM_TYPE_SLIDER);
1630                         items[1].redraw = 1;
1631                         items[2].type = (Redbook_playing?NM_TYPE_SLIDER:NM_TYPE_TEXT);
1632                         items[2].redraw = 1;
1633
1634                 }
1635         }
1636
1637         #endif
1638
1639         citem++;                //kill warning
1640 }
1641
1642 void do_sound_menu()
1643 {
1644    newmenu_item m[6];
1645         int i = 0;
1646
1647  #ifdef WINDOWS
1648         extern BOOL DIGIDriverInit;
1649         if (!DIGIDriverInit) windigi_driver_off = TRUE;
1650         else windigi_driver_off = FALSE;
1651  #endif
1652
1653         do {
1654                 m[ 0].type = NM_TYPE_SLIDER; m[ 0].text=TXT_FX_VOLUME; m[0].value=Config_digi_volume;m[0].min_value=0; m[0].max_value=8; 
1655                 m[ 1].type = (Redbook_playing?NM_TYPE_TEXT:NM_TYPE_SLIDER); m[ 1].text="MIDI music volume"; m[1].value=Config_midi_volume;m[1].min_value=0; m[1].max_value=8;
1656
1657         #ifdef WINDOWS
1658                 if (!wmidi_support_volchange() && !Redbook_playing) {
1659                         m[1].type = NM_TYPE_CHECK;
1660                         m[1].text = "MIDI MUSIC";
1661                         if (Config_midi_volume) m[1].value = 1;
1662                 }
1663         #endif
1664
1665                 #ifdef SHAREWARE
1666                         m[ 2].type = NM_TYPE_TEXT; m[ 2].text="";
1667                         m[ 3].type = NM_TYPE_TEXT; m[ 3].text="";
1668                         m[ 4].type = NM_TYPE_TEXT; m[ 4].text="";
1669                         #ifdef MACINTOSH
1670                                 m[ 3].type = NM_TYPE_SLIDER; m[ 3].text="Sound Manager Volume"; m[3].value=Config_master_volume;m[3].min_value=0; m[3].max_value=8;
1671
1672                                 #ifdef APPLE_DEMO
1673                                         m[ 2].type = (Redbook_playing?NM_TYPE_SLIDER:NM_TYPE_TEXT); m[ 2].text="CD music volume"; m[2].value=Config_redbook_volume;m[2].min_value=0; m[2].max_value=8;
1674                                         m[ 4].type = NM_TYPE_CHECK;  m[ 4].text="CD Music (Redbook) enabled"; m[4].value=(Redbook_playing!=0);
1675                                 #endif
1676
1677                         #endif
1678
1679                 #else           // ifdef SHAREWARE
1680                         m[ 2].type = (Redbook_playing?NM_TYPE_SLIDER:NM_TYPE_TEXT); m[ 2].text="CD music volume"; m[2].value=Config_redbook_volume;m[2].min_value=0; m[2].max_value=8;
1681
1682                         #ifndef MACINTOSH
1683                                 m[ 3].type = NM_TYPE_TEXT; m[ 3].text="";
1684                         #else
1685                                 m[ 3].type = NM_TYPE_SLIDER; m[ 3].text="Sound Manager Volume"; m[3].value=Config_master_volume;m[3].min_value=0; m[3].max_value=8; 
1686                         #endif
1687                 
1688                         m[ 4].type = NM_TYPE_CHECK;  m[ 4].text="CD Music (Redbook) enabled"; m[4].value=(Redbook_playing!=0);
1689                 #endif
1690         
1691                 m[ 5].type = NM_TYPE_CHECK;  m[ 5].text=TXT_REVERSE_STEREO; m[5].value=Config_channels_reversed; 
1692                                 
1693                 i = newmenu_do1( NULL, "Sound Effects & Music", sizeof(m)/sizeof(*m), m, sound_menuset, i );
1694
1695                 Redbook_enabled = m[4].value;
1696                 Config_channels_reversed = m[5].value;
1697
1698         } while( i>-1 );
1699
1700 #ifdef WINDOWS
1701         if (windigi_driver_off) {
1702                 digi_midi_wait();
1703                 Sleep(500);
1704                 digi_init_digi();
1705                 windigi_driver_off=FALSE;
1706         }
1707 #endif
1708
1709
1710         if ( Config_midi_volume < 1 )   {
1711                 #ifndef MACINTOSH
1712                         digi_play_midi_song( NULL, NULL, NULL, 0 );
1713                 #else
1714                         digi_play_midi_song(-1, 0);
1715                 #endif
1716         }
1717
1718 }
1719
1720
1721 extern int Automap_always_hires;
1722
1723 #define ADD_CHECK(n,txt,v)  do { m[n].type=NM_TYPE_CHECK; m[n].text=txt; m[n].value=v;} while (0)
1724
1725 void do_toggles_menu()
1726 {
1727 #ifndef MACINTOSH
1728 #if defined(POLY_ACC)
1729         #define N_TOGGLE_ITEMS 6        // get rid of automap hi-res.
1730 #else
1731         #define N_TOGGLE_ITEMS 7
1732 #endif
1733 #else
1734         #define N_TOGGLE_ITEMS 7
1735 #endif
1736         newmenu_item m[N_TOGGLE_ITEMS];
1737         int i = 0;
1738
1739         do {
1740                 #if defined(MACINTOSH) && defined(USE_ISP)
1741                         if (ISpEnabled())
1742                         {
1743                                 m[0].type = NM_TYPE_TEXT; m[0].text = "";
1744                         }
1745                         else
1746                         {
1747                                 ADD_CHECK(0, "Ship auto-leveling", Auto_leveling_on);
1748                         }
1749                 #else 
1750                         ADD_CHECK(0, "Ship auto-leveling", Auto_leveling_on);
1751                 #endif
1752                 ADD_CHECK(1, "Show reticle", Reticle_on);
1753                 ADD_CHECK(2, "Missile view", Missile_view_enabled);
1754                 ADD_CHECK(3, "Headlight on when picked up", Headlight_active_default );
1755                 ADD_CHECK(4, "Show guided missile in main display", Guided_in_big_window );
1756                 ADD_CHECK(5, "Escort robot hot keys",EscortHotKeys);
1757                 #ifdef MACINTOSH
1758                         if ( !PAEnabled ) {
1759                                 ADD_CHECK(6, "Pixel Double", Scanline_double);
1760                         }
1761                 #else
1762 #if !defined(POLY_ACC)
1763                         ADD_CHECK(6, "Always show HighRes Automap", min(MenuHiresAvailable,Automap_always_hires));
1764 #endif
1765                 #endif
1766                 //when adding more options, change N_TOGGLE_ITEMS above
1767
1768                 #ifdef MACINTOSH
1769                 if ( PAEnabled )                // when doing RAVE, no pixel doubling
1770                         i = newmenu_do1( NULL, "Toggles", N_TOGGLE_ITEMS-1, m, NULL, i );
1771                 else
1772                 #endif          // note link to if
1773                         i = newmenu_do1( NULL, "Toggles", N_TOGGLE_ITEMS, m, NULL, i );
1774                         
1775                 Auto_leveling_on                        = m[0].value;
1776                 Reticle_on                                      = m[1].value;
1777                 Missile_view_enabled            = m[2].value;
1778                 Headlight_active_default        = m[3].value;
1779                 Guided_in_big_window            = m[4].value;
1780                 EscortHotKeys                           = m[5].value;
1781
1782
1783                 #ifdef MACINTOSH
1784                         if ( !PAEnabled )
1785                                 Scanline_double = m[6].value;
1786                 #else
1787 #if !defined(POLY_ACC)
1788                         if (MenuHiresAvailable)
1789                                 Automap_always_hires = m[6].value;
1790                         else if (m[6].value)
1791                                 nm_messagebox(TXT_SORRY,1,"OK","High Resolution modes are\nnot available on this video card");
1792 #endif
1793                 #endif
1794
1795         } while( i>-1 );
1796
1797 }
1798
1799 #ifdef NETWORK
1800 void do_multi_player_menu()
1801 {
1802         int menu_choice[9];
1803         newmenu_item m[9];
1804         int choice = 0, num_options = 0;
1805         int old_game_mode;
1806
1807         do {
1808 //              WIN(ipx_destroy_read_thread());
1809
1810                 old_game_mode = Game_mode;
1811                 num_options = 0;
1812
1813 #ifdef NATIVE_IPX
1814                 ADD_ITEM(TXT_START_IPX_NET_GAME, MENU_START_IPX_NETGAME, -1);
1815                 ADD_ITEM(TXT_JOIN_IPX_NET_GAME, MENU_JOIN_IPX_NETGAME, -1);
1816 #endif //NATIVE_IPX
1817                 //ADD_ITEM(TXT_START_TCP_NET_GAME, MENU_START_TCP_NETGAME, -1);
1818                 //ADD_ITEM(TXT_JOIN_TCP_NET_GAME, MENU_JOIN_TCP_NETGAME, -1);
1819                 ADD_ITEM("Start UDP/IP Netgame", MENU_START_UDP_NETGAME, -1);
1820                 ADD_ITEM("Join UDP/IP Netgame\n", MENU_JOIN_UDP_NETGAME, -1);
1821                 ADD_ITEM("Start Multicast UDP/IP Netgame", MENU_START_MCAST4_NETGAME, -1);
1822                 ADD_ITEM("Join Multicast UDP/IP Netgame\n", MENU_JOIN_MCAST4_NETGAME, -1);
1823 #ifdef KALINIX
1824                 ADD_ITEM("Start Kali Netgame", MENU_START_KALI_NETGAME, -1);
1825                 ADD_ITEM("Join Kali Netgame\n", MENU_JOIN_KALI_NETGAME, -1);
1826 #endif // KALINIX
1827
1828 #ifdef MACINTOSH
1829                 ADD_ITEM("Start Appletalk Netgame", MENU_START_APPLETALK_NETGAME, -1 );
1830                 ADD_ITEM("Join Appletalk Netgame\n", MENU_JOIN_APPLETALK_NETGAME, -1 );
1831 #endif
1832
1833                 ADD_ITEM(TXT_MODEM_GAME, MENU_START_SERIAL, -1);
1834
1835                 choice = newmenu_do1( NULL, TXT_MULTIPLAYER, num_options, m, NULL, choice );
1836                 
1837                 if ( choice > -1 )      
1838                         do_option(menu_choice[choice]);
1839         
1840                 if (old_game_mode != Game_mode)
1841                         break;          // leave menu
1842
1843         } while( choice > -1 );
1844
1845 }
1846
1847 /*
1848  * ipx_set_driver was called do_network_init and located in main/inferno
1849  * before the change which allows the user to choose the network driver
1850  * from the game menu instead of having to supply command line args.
1851  */
1852 void ipx_set_driver(int ipx_driver)
1853 {
1854         ipx_close();
1855
1856         if (!FindArg("-nonetwork")) {
1857                 int ipx_error;
1858                 int socket = 0, t;
1859
1860                 con_printf(CON_VERBOSE, "\n%s ", TXT_INITIALIZING_NETWORK);
1861
1862                 if ((t = FindArg("-socket")))
1863                         socket = atoi(Args[t + 1]);
1864
1865                 arch_ipx_set_driver(ipx_driver);
1866
1867                 if ((ipx_error = ipx_init(IPX_DEFAULT_SOCKET + socket)) == IPX_INIT_OK) {
1868                         con_printf(CON_VERBOSE, "%s %d.\n", TXT_IPX_CHANNEL, socket );
1869                         Network_active = 1;
1870                 } else {
1871                         switch(ipx_error) {
1872                         case IPX_NOT_INSTALLED: con_printf(CON_VERBOSE, "%s\n", TXT_NO_NETWORK); break;
1873                         case IPX_SOCKET_TABLE_FULL: con_printf(CON_VERBOSE, "%s 0x%x.\n", TXT_SOCKET_ERROR, IPX_DEFAULT_SOCKET+socket); break;
1874                         case IPX_NO_LOW_DOS_MEM: con_printf(CON_VERBOSE, "%s\n", TXT_MEMORY_IPX ); break;
1875                         default: con_printf(CON_VERBOSE, "%s %d", TXT_ERROR_IPX, ipx_error );
1876                         }
1877                         con_printf(CON_VERBOSE, "%s\n",TXT_NETWORK_DISABLED);
1878                         Network_active = 0;             // Assume no network
1879                 }
1880                 ipx_read_user_file("descent.usr");
1881                 ipx_read_network_file("descent.net");
1882                 //@@if (FindArg("-dynamicsockets"))
1883                 //@@    Network_allow_socket_changes = 1;
1884                 //@@else
1885                 //@@    Network_allow_socket_changes = 0;
1886         } else {
1887                 con_printf(CON_VERBOSE, "%s\n", TXT_NETWORK_DISABLED);
1888                 Network_active = 0;             // Assume no network
1889         }
1890 }
1891
1892 void DoNewIPAddress ()
1893  {
1894   newmenu_item m[4];
1895   char IPText[30];
1896   int choice;
1897
1898   m[0].type=NM_TYPE_TEXT; m[0].text = "Enter an address or hostname:";
1899   m[1].type=NM_TYPE_INPUT; m[1].text_len = 50; m[1].text = IPText;
1900   IPText[0]=0;
1901
1902   choice = newmenu_do( NULL, "Join a TCPIP game", 2, m, NULL );
1903
1904   if (choice==-1 || m[1].text[0]==0)
1905    return;
1906
1907   nm_messagebox (TXT_SORRY,1,TXT_OK,"That address is not valid!");
1908  }
1909
1910 #endif // NETWORK