Enable global structs for mine saving functions
[btb/d2x.git] / main / menu.c
1 /* $Id: menu.c,v 1.39 2004-12-01 12:48:13 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                         newmenu_item m;
437                         char text[10]="";
438                         int new_level_num;
439
440                         m.type=NM_TYPE_INPUT; m.text_len = 10; m.text = text;
441
442                         newmenu_do( NULL, "Enter level to load", 1, &m, NULL );
443
444                         new_level_num = atoi(m.text);
445
446                         if (new_level_num!=0 && new_level_num>=Last_secret_level && new_level_num<=Last_level)  {
447                                 gr_palette_fade_out( gr_palette, 32, 0 );
448                                 StartNewGame(new_level_num);
449                         }
450
451                         break;
452                 }
453 #endif //ifndef RELEASE
454
455
456 #ifdef NETWORK
457                 //case MENU_START_TCP_NETGAME:
458                 //case MENU_JOIN_TCP_NETGAME:
459                 case MENU_START_IPX_NETGAME:
460                 case MENU_JOIN_IPX_NETGAME:
461                 case MENU_START_UDP_NETGAME:
462                 case MENU_JOIN_UDP_NETGAME:
463                 case MENU_START_KALI_NETGAME:
464                 case MENU_JOIN_KALI_NETGAME:
465                 case MENU_START_MCAST4_NETGAME:
466                 case MENU_JOIN_MCAST4_NETGAME:
467 //                      load_mission(Builtin_mission_num);
468 #ifdef MACINTOSH
469                         Network_game_type = IPX_GAME;
470 #endif
471 //                      WIN(ipx_create_read_thread());
472                         switch (select & ~0x1) {
473                         case MENU_START_IPX_NETGAME: ipx_set_driver(IPX_DRIVER_IPX); break;
474                         case MENU_START_UDP_NETGAME: ipx_set_driver(IPX_DRIVER_UDP); break;
475                         case MENU_START_KALI_NETGAME: ipx_set_driver(IPX_DRIVER_KALI); break;
476                         case MENU_START_MCAST4_NETGAME: ipx_set_driver(IPX_DRIVER_MCAST4); break;
477                         default: Int3();
478                         }
479
480                         if ((select & 0x1) == 0) // MENU_START_*_NETGAME
481                                 network_start_game();
482                         else // MENU_JOIN_*_NETGAME
483                                 network_join_game();
484                         break;
485
486 #ifdef MACINTOSH
487                 case MENU_START_APPLETALK_NETGAME:
488 //                      load_mission(Builtin_mission_num);
489                         #ifdef MACINTOSH
490                         Network_game_type = APPLETALK_GAME;
491                         #endif
492                         network_start_game();
493                         break;
494
495                 case MENU_JOIN_APPLETALK_NETGAME:
496 //                      load_mission(Builtin_mission_num);
497                         #ifdef MACINTOSH
498                         Network_game_type = APPLETALK_GAME;
499                         #endif
500                         network_join_game();
501                         break;
502 #endif
503 #if 0
504                 case MENU_START_TCP_NETGAME:
505                 case MENU_JOIN_TCP_NETGAME:
506                         nm_messagebox (TXT_SORRY,1,TXT_OK,"Not available in shareware version!");
507                         // DoNewIPAddress();
508                         break;
509 #endif
510                 case MENU_START_SERIAL:
511                         com_main_menu();
512                         break;
513                 case MENU_MULTIPLAYER:
514                         do_multi_player_menu();
515                         break;
516 #endif //NETWORK
517                 case MENU_CONFIG:
518                         do_options_menu();
519                         break;
520                 case MENU_SHOW_CREDITS:
521                         gr_palette_fade_out( gr_palette,32,0);
522                         songs_stop_all();
523                         credits_show(NULL); 
524                         break;
525                 default:
526                         Error("Unknown option %d in do_option",select);
527                         break;
528         }
529
530 }
531
532 int do_difficulty_menu()
533 {
534         int s;
535         newmenu_item m[5];
536
537         m[0].type=NM_TYPE_MENU; m[0].text=MENU_DIFFICULTY_TEXT(0);
538         m[1].type=NM_TYPE_MENU; m[1].text=MENU_DIFFICULTY_TEXT(1);
539         m[2].type=NM_TYPE_MENU; m[2].text=MENU_DIFFICULTY_TEXT(2);
540         m[3].type=NM_TYPE_MENU; m[3].text=MENU_DIFFICULTY_TEXT(3);
541         m[4].type=NM_TYPE_MENU; m[4].text=MENU_DIFFICULTY_TEXT(4);
542
543         s = newmenu_do1( NULL, TXT_DIFFICULTY_LEVEL, NDL, m, NULL, Difficulty_level);
544
545         if (s > -1 )    {
546                 if (s != Difficulty_level)
547                 {       
548                         Player_default_difficulty = s;
549                         write_player_file();
550                 }
551                 Difficulty_level = s;
552                 mprintf((0, "%s %s %i\n", TXT_DIFFICULTY_LEVEL, TXT_SET_TO, Difficulty_level));
553                 return 1;
554         }
555         return 0;
556 }
557
558 int     Max_debris_objects, Max_objects_onscreen_detailed;
559 int     Max_linear_depth_objects;
560
561 sbyte   Object_complexity=2, Object_detail=2;
562 sbyte   Wall_detail=2, Wall_render_depth=2, Debris_amount=2, SoundChannels = 2;
563
564 sbyte   Render_depths[NUM_DETAIL_LEVELS-1] =                        { 6,  9, 12, 15, 50};
565 sbyte   Max_perspective_depths[NUM_DETAIL_LEVELS-1] =               { 1,  2,  3,  5,  8};
566 sbyte   Max_linear_depths[NUM_DETAIL_LEVELS-1] =                    { 3,  5,  7, 10, 50};
567 sbyte   Max_linear_depths_objects[NUM_DETAIL_LEVELS-1] =            { 1,  2,  3,  7, 20};
568 sbyte   Max_debris_objects_list[NUM_DETAIL_LEVELS-1] =              { 2,  4,  7, 10, 15};
569 sbyte   Max_objects_onscreen_detailed_list[NUM_DETAIL_LEVELS-1] =   { 2,  4,  7, 10, 15};
570 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
571 sbyte   Max_sound_channels[NUM_DETAIL_LEVELS-1] =                   { 2,  4,  8, 12, 16};
572
573 //      -----------------------------------------------------------------------------
574 //      Set detail level based stuff.
575 //      Note: Highest detail level (detail_level == NUM_DETAIL_LEVELS-1) is custom detail level.
576 void set_detail_level_parameters(int detail_level)
577 {
578         Assert((detail_level >= 0) && (detail_level < NUM_DETAIL_LEVELS));
579
580         if (detail_level < NUM_DETAIL_LEVELS-1) {
581                 Render_depth = Render_depths[detail_level];
582                 Max_perspective_depth = Max_perspective_depths[detail_level];
583                 Max_linear_depth = Max_linear_depths[detail_level];
584                 Max_linear_depth_objects = Max_linear_depths_objects[detail_level];
585
586                 Max_debris_objects = Max_debris_objects_list[detail_level];
587                 Max_objects_onscreen_detailed = Max_objects_onscreen_detailed_list[detail_level];
588
589                 Simple_model_threshhold_scale = Smts_list[detail_level];
590
591                 digi_set_max_channels( Max_sound_channels[ detail_level ] );
592
593                 //      Set custom menu defaults.
594                 Object_complexity = detail_level;
595                 Wall_render_depth = detail_level;
596                 Object_detail = detail_level;
597                 Wall_detail = detail_level;
598                 Debris_amount = detail_level;
599                 SoundChannels = detail_level;
600
601 #if defined(POLY_ACC)
602
603                 #ifdef MACINTOSH
604                         if (detail_level < 2)
605                         {
606                                 pa_set_filtering(0);
607                         }
608                         else if (detail_level < 4)
609                         {
610                                 pa_set_filtering(1);
611                         }
612                         else if (detail_level == 4)
613                         {
614                                 pa_set_filtering(2);
615                         }
616                 #else
617                         pa_filter_mode = detail_level;
618                 #endif
619 #endif
620
621         }
622 }
623
624 //      -----------------------------------------------------------------------------
625 void do_detail_level_menu(void)
626 {
627         int s;
628         newmenu_item m[8];
629
630         m[0].type=NM_TYPE_MENU; m[0].text=MENU_DETAIL_TEXT(0);
631         m[1].type=NM_TYPE_MENU; m[1].text=MENU_DETAIL_TEXT(1);
632         m[2].type=NM_TYPE_MENU; m[2].text=MENU_DETAIL_TEXT(2);
633         m[3].type=NM_TYPE_MENU; m[3].text=MENU_DETAIL_TEXT(3);
634         m[4].type=NM_TYPE_MENU; m[4].text=MENU_DETAIL_TEXT(4);
635         m[5].type=NM_TYPE_TEXT; m[5].text="";
636         m[6].type=NM_TYPE_MENU; m[6].text=MENU_DETAIL_TEXT(5);
637         m[7].type=NM_TYPE_CHECK; m[7].text="Show High Res movies"; m[7].value=MovieHires;
638
639         s = newmenu_do1( NULL, TXT_DETAIL_LEVEL , NDL+3, m, NULL, Detail_level);
640
641         if (s > -1 )    {
642                 switch (s)      {
643                         case 0:
644                         case 1:
645                         case 2:
646                         case 3:
647                         case 4:
648                                 Detail_level = s;
649                                 mprintf((0, "Detail level set to %i\n", Detail_level));
650                                 set_detail_level_parameters(Detail_level);
651                                 break;
652                         case 6:
653                                 Detail_level = 5;
654                                 do_detail_level_menu_custom();
655                                 break;
656                 }
657         }
658         MovieHires = m[7].value;
659 }
660
661 //      -----------------------------------------------------------------------------
662 void do_detail_level_menu_custom_menuset(int nitems, newmenu_item * items, int *last_key, int citem )
663 {
664         nitems = nitems;
665         *last_key = *last_key;
666         citem = citem;
667
668         Object_complexity = items[0].value;
669         Object_detail = items[1].value;
670         Wall_detail = items[2].value;
671         Wall_render_depth = items[3].value;
672         Debris_amount = items[4].value;
673         SoundChannels = items[5].value;
674 #if defined(POLY_ACC)
675         pa_filter_mode = items[6].value;
676 #endif
677
678 }
679
680 void set_custom_detail_vars(void)
681 {
682         Render_depth = Render_depths[Wall_render_depth];
683
684         Max_perspective_depth = Max_perspective_depths[Wall_detail];
685         Max_linear_depth = Max_linear_depths[Wall_detail];
686
687         Max_debris_objects = Max_debris_objects_list[Debris_amount];
688
689         Max_objects_onscreen_detailed = Max_objects_onscreen_detailed_list[Object_complexity];
690         Simple_model_threshhold_scale = Smts_list[Object_complexity];
691         Max_linear_depth_objects = Max_linear_depths_objects[Object_detail];
692
693         digi_set_max_channels( Max_sound_channels[ SoundChannels ] );
694         
695 }
696
697 #define DL_MAX  10
698
699 //      -----------------------------------------------------------------------------
700
701 void do_detail_level_menu_custom(void)
702 {
703         int     count;
704         int     s=0;
705         newmenu_item m[DL_MAX];
706         #if defined(POLY_ACC)
707         int filtering_id;
708         #endif
709
710         do {
711                 count = 0;
712                 m[count].type = NM_TYPE_SLIDER;
713                 m[count].text = TXT_OBJ_COMPLEXITY;
714                 m[count].value = Object_complexity;
715                 m[count].min_value = 0;
716                 m[count++].max_value = NDL-1;
717
718                 m[count].type = NM_TYPE_SLIDER;
719                 m[count].text = TXT_OBJ_DETAIL;
720                 m[count].value = Object_detail;
721                 m[count].min_value = 0;
722                 m[count++].max_value = NDL-1;
723
724                 m[count].type = NM_TYPE_SLIDER;
725                 m[count].text = TXT_WALL_DETAIL;
726                 m[count].value = Wall_detail;
727                 m[count].min_value = 0;
728                 m[count++].max_value = NDL-1;
729
730                 m[count].type = NM_TYPE_SLIDER;
731                 m[count].text = TXT_WALL_RENDER_DEPTH;
732                 m[count].value = Wall_render_depth;
733                 m[count].min_value = 0;
734                 m[count++].max_value = NDL-1;
735
736                 m[count].type = NM_TYPE_SLIDER;
737                 m[count].text= TXT_DEBRIS_AMOUNT;
738                 m[count].value = Debris_amount;
739                 m[count].min_value = 0;
740                 m[count++].max_value = NDL-1;
741
742                 m[count].type = NM_TYPE_SLIDER;
743                 m[count].text= TXT_SOUND_CHANNELS;
744                 m[count].value = SoundChannels;
745                 m[count].min_value = 0;
746                 m[count++].max_value = NDL-1;
747
748                 #if defined(POLY_ACC)
749                 MAC( if(PAEnabled){ )
750                         filtering_id = count;
751                         m[count].type = NM_TYPE_SLIDER;
752                         m[count].text= "FILTERING";
753                         m[count].value = pa_filter_mode;
754                         m[count].min_value = 0;
755                         #ifdef MACINTOSH
756                         m[count++].max_value = 2;
757                         #else
758                         m[count++].max_value = NDL-1;
759                         #endif
760                 MAC(})
761                 #endif
762
763                 m[count].type = NM_TYPE_TEXT;
764                 m[count++].text= TXT_LO_HI;
765
766                 Assert(count < DL_MAX);
767
768                 s = newmenu_do1( NULL, TXT_DETAIL_CUSTOM, count, m, do_detail_level_menu_custom_menuset, s);
769         } while (s > -1);
770
771         set_custom_detail_vars();
772
773         #if defined(MACINTOSH) && defined(POLY_ACC)
774         if ( PAEnabled )
775                 pa_set_filtering( m[filtering_id].value );
776         #endif
777 }
778
779 #ifndef MACINTOSH
780 int Default_display_mode=0;
781 int Current_display_mode=0;
782 #else
783 int Default_display_mode=1;
784 int Current_display_mode=1;
785 #endif
786
787 extern int MenuHiresAvailable;
788
789 typedef struct {
790         int     VGA_mode;
791         short   w,h;
792         short   render_method;
793         short   flags;
794 } dmi;
795
796 dmi display_mode_info[7] = {
797                 #ifdef WINDOWS
798                         {SM95_320x200x8X, 320, 200, VR_NONE, VRF_ALLOW_COCKPIT},
799                         {SM95_640x480x8, 640, 480, VR_NONE, VRF_COMPATIBLE_MENUS+VRF_ALLOW_COCKPIT},
800                         {SM95_640x400x8, 640, 400, VR_NONE, VRF_COMPATIBLE_MENUS }, 
801                         {SM95_800x600x8, 800, 600, VR_NONE, VRF_COMPATIBLE_MENUS },
802                         {SM95_1024x768x8, 1024, 768, VR_NONE, VRF_COMPATIBLE_MENUS }, 
803                 #else
804                         {SM(320,200),    320,   200, VR_NONE, VRF_ALLOW_COCKPIT+VRF_COMPATIBLE_MENUS}, 
805                         {SM(640,480),    640, 480, VR_NONE, VRF_COMPATIBLE_MENUS+VRF_ALLOW_COCKPIT},
806                         {SM(320,400),    320, 400, VR_NONE, VRF_USE_PAGING},
807                         {SM(640,400),    640, 400, VR_NONE, VRF_COMPATIBLE_MENUS}, 
808                         {SM(800,600),    800, 600, VR_NONE, VRF_COMPATIBLE_MENUS}, 
809                         {SM(1024,768),  1024,   768, VR_NONE, VRF_COMPATIBLE_MENUS},    
810                         {SM(1280,1024),1280,1024, VR_NONE, VRF_COMPATIBLE_MENUS}, 
811                 #endif
812 };
813  
814 WIN(extern int DD_Emulation);
815
816
817 void set_display_mode(int mode)
818 {
819         dmi *dmi;
820
821         if ((Current_display_mode == -1)||(VR_render_mode != VR_NONE))  //special VR mode
822                 return;                                                         //...don't change
823
824         #if !defined(MACINTOSH) && !defined(WINDOWS)
825         if (0) // (mode >= 5 && !FindArg("-superhires"))
826                 mode = 4;
827         #endif
828
829         if (!MenuHiresAvailable && (mode != 2))
830                 mode = 0;
831
832 #ifndef WINDOWS
833
834         if (gr_check_mode(display_mode_info[mode].VGA_mode) != 0)               //can't do mode
835                 #ifndef MACINTOSH
836                 mode = 0;
837                 #else
838                 mode = 1;
839                 #endif
840
841         Current_display_mode = mode;
842 #else
843         if (mode == 2) mode = 3;                                        // 320x400 -> 640x400.
844         Current_display_mode = mode;
845         if (mode >= 3) mode--;                                          // Match to Windows dmi.
846         if (DDCheckMode(display_mode_info[mode].VGA_mode)) {
847                 if (Platform_system == WINNT_PLATFORM || DD_Emulation) mode = 1;
848                 else mode = 0;
849                 Current_display_mode = mode;
850         }
851 #endif
852
853         dmi = &display_mode_info[mode];
854
855         if (Current_display_mode != -1) {
856
857                 game_init_render_buffers(dmi->VGA_mode,dmi->w,dmi->h,dmi->render_method,dmi->flags);
858                 Default_display_mode = Current_display_mode;
859         }
860
861         Screen_mode = -1;               //force screen reset
862 }
863
864 #ifdef MACINTOSH        // use Mac version of do_screen_res_menu
865
866 void do_screen_res_menu()
867 {
868         #define N_SCREENRES_ITEMS 6
869         
870         newmenu_item m[N_SCREENRES_ITEMS];
871         int citem, i, n_items, odisplay_mode, result;
872
873         if ((Current_display_mode == -1)||(VR_render_mode != VR_NONE))          //special VR mode
874         {                               
875                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
876                                 "You may not change screen\n"
877                                 "resolution when VR modes enabled.");
878                 return;
879         }
880
881         m[0].type=NM_TYPE_TEXT;  m[0].value=0; m[0].text="Modes w/ Cockpit:";
882         m[1].type=NM_TYPE_RADIO; m[1].value=0; m[1].group=0; m[1].text=" 640x480";
883         m[2].type=NM_TYPE_TEXT;  m[2].value=0; m[2].text="Modes w/o Cockpit:";
884         m[3].type=NM_TYPE_RADIO; m[3].value=0; m[3].group=0; m[3].text=" 800x600";
885 //      m[4].type=NM_TYPE_RADIO; m[4].value=0; m[4].group=0; m[4].text=" 1024x768";
886 //      m[5].type=NM_TYPE_RADIO; m[5].value=0; m[5].group=0; m[5].text=" 1280x1024";
887         n_items = 4;
888
889         odisplay_mode = VGA_current_mode;
890         citem = Current_display_mode;
891         if (Current_display_mode >= 2)
892                 citem--;
893
894         if (citem >= n_items)
895                 citem = n_items-1;
896
897         m[citem].value = 1;
898
899         newmenu_do1( NULL, "Select screen mode", n_items, m, NULL, citem);
900
901         for (i=0;i<n_items;i++)
902                 if (m[i].value)
903                         break;
904         if (i >= 3)
905                 i++;
906
907 #if 0 //def SHAREWARE
908         if (i > 1)
909                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
910                         "High resolution modes are\n"
911                         "only available in the\n"
912                         "Commercial version of Descent 2.");
913         return;
914 #else
915         result = vga_check_mode(display_mode_info[i].VGA_mode);
916         
917         if (result) {
918                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
919                                 "Cannot set requested\n"
920                                 "mode on this video card.");
921                 return;
922         }
923         
924         set_display_mode(i);
925         reset_cockpit();
926 #endif
927
928 }
929
930 #else   // PC version of do_screen_res_menu is below
931
932 void do_screen_res_menu()
933 {
934 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
935 #define N_SCREENRES_ITEMS 10
936         int fullscreenc;
937 #else
938         #define N_SCREENRES_ITEMS 9
939 #endif
940         newmenu_item m[N_SCREENRES_ITEMS];
941         int citem;
942         int i;
943         int n_items;
944
945         if ((Current_display_mode == -1)||(VR_render_mode != VR_NONE)) {                                //special VR mode
946                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
947                                 "You may not change screen\n"
948                                 "resolution when VR modes enabled.");
949                 return;
950         }
951
952         m[0].type=NM_TYPE_TEXT;  m[0].value=0;                            m[0].text="Modes w/ Cockpit:";
953         
954 #ifdef WINDOWS
955         if (Platform_system == WINNT_PLATFORM || DD_Emulation) {
956                 m[1].type=NM_TYPE_TEXT; m[1].value=0; m[1].text=" 320x200 N/A";
957         } else
958 #endif
959                 //NOTE LINK TO ABOVE IF
960                 m[1].type=NM_TYPE_RADIO; m[1].value=0; m[1].group=0; m[1].text=" 320x200";
961
962         m[2].type=NM_TYPE_RADIO; m[2].value=0; m[2].group=0; m[2].text=" 640x480";
963         m[3].type=NM_TYPE_TEXT;  m[3].value=0;                                    m[3].text="Modes w/o Cockpit:";
964 #ifdef WINDOWS
965         m[4].type=NM_TYPE_RADIO; m[4].value=0; m[4].group=0; m[4].text=" 640x400";
966         m[5].type=NM_TYPE_RADIO; m[5].value=0; m[5].group=0; m[5].text=" 800x600";
967 //      m[6].type=NM_TYPE_RADIO; m[6].value=0; m[6].group=0; m[6].text=" 1024x768";
968         n_items = 6;
969 #else
970         m[4].type=NM_TYPE_RADIO; m[4].value=0; m[4].group=0; m[4].text=" 320x400";
971         m[5].type=NM_TYPE_RADIO; m[5].value=0; m[5].group=0; m[5].text=" 640x400";
972         m[6].type=NM_TYPE_RADIO; m[6].value=0; m[6].group=0; m[6].text=" 800x600";
973         n_items = 7;
974         if (1) { //(FindArg("-superhires")) {
975                 m[7].type=NM_TYPE_RADIO; m[7].value=0; m[7].group=0; m[7].text=" 1024x768";
976                 m[8].type=NM_TYPE_RADIO; m[8].value=0; m[8].group=0; m[8].text=" 1280x1024";
977                 n_items += 2;
978         }
979 #endif
980
981 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
982         m[n_items].type = NM_TYPE_CHECK; m[n_items].text = "Fullscreen";
983         m[n_items].value = gr_check_fullscreen();
984         fullscreenc=n_items++;
985 #endif
986
987         citem = Current_display_mode+1;
988         
989 #ifdef WINDOWS
990         if (citem == 3) citem++;                                // if 320x400 in DOS, make it look like 640x400
991 #else
992         if (Current_display_mode >= 2)
993                 citem++;
994 #endif
995
996         if (citem >= n_items)
997                 citem = n_items-1;
998
999         m[citem].value = 1;
1000
1001         newmenu_do1( NULL, "Select screen mode", n_items, m, NULL, citem);
1002
1003 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1004         if (m[fullscreenc].value != gr_check_fullscreen()){
1005                 gr_toggle_fullscreen();
1006                 Game_screen_mode = -1;
1007         }
1008 #endif
1009
1010         for (i=0;i<n_items;i++)
1011                 if (m[i].value)
1012                         break;
1013
1014 #ifndef WINDOWS                                                                 // if i >= 4 keep it that way since we skip 320x400
1015         if (i >= 4)
1016                 i--;
1017 #endif
1018
1019         i--;
1020
1021 #ifndef WINDOWS
1022         if (((i != 0) && (i != 2) && !MenuHiresAvailable) || gr_check_mode(display_mode_info[i].VGA_mode)) {
1023                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
1024                                 "Cannot set requested\n"
1025                                 "mode on this video card.");
1026                 return;
1027         }
1028 #else
1029         if (i >= 3) 
1030                 result = DDCheckMode(display_mode_info[i-1].VGA_mode);
1031         else 
1032                 result = DDCheckMode(display_mode_info[i].VGA_mode);
1033
1034         if (result) {
1035                 nm_messagebox(TXT_SORRY, 1, TXT_OK, 
1036                                 "Mode not supported by your\n"
1037                                 "DirectDraw driver.\n", 
1038                                 "Using default mode for gameplay.\n");
1039                 return;
1040         }
1041
1042 #endif
1043 #ifdef SHAREWARE
1044                 if (i != 0)
1045                         nm_messagebox(TXT_SORRY, 1, TXT_OK, 
1046                                 "High resolution modes are\n"
1047                                 "only available in the\n"
1048                                 "Commercial version of Descent 2.");
1049                 return;
1050 #else
1051                 if (i != Current_display_mode)
1052                         set_display_mode(i);
1053 #endif
1054
1055 }
1056 #endif  // end of PC version of do_screen_res_menu()
1057
1058
1059
1060 void do_new_game_menu()
1061 {
1062         int new_level_num,player_highest_level;
1063
1064     if (!select_mission(0, "New Game\n\nSelect mission"))
1065         return;
1066     
1067         new_level_num = 1;
1068
1069         player_highest_level = get_highest_level();
1070
1071         if (player_highest_level > Last_level)
1072                 player_highest_level = Last_level;
1073
1074         if (player_highest_level > 1) {
1075                 newmenu_item m[4];
1076                 char info_text[80];
1077                 char num_text[10];
1078                 int choice;
1079                 int n_items;
1080
1081 try_again:
1082                 sprintf(info_text,"%s %d",TXT_START_ANY_LEVEL, player_highest_level);
1083
1084                 m[0].type=NM_TYPE_TEXT; m[0].text = info_text;
1085                 m[1].type=NM_TYPE_INPUT; m[1].text_len = 10; m[1].text = num_text;
1086                 n_items = 2;
1087
1088                 #ifdef WINDOWS
1089                 m[2].type = NM_TYPE_TEXT; m[2].text = "";
1090                 m[3].type = NM_TYPE_MENU; m[3].text = "          Ok";
1091                 n_items = 4;
1092                 #endif
1093
1094                 strcpy(num_text,"1");
1095
1096                 choice = newmenu_do( NULL, TXT_SELECT_START_LEV, n_items, m, NULL );
1097
1098                 if (choice==-1 || m[1].text[0]==0)
1099                         return;
1100
1101                 new_level_num = atoi(m[1].text);
1102
1103                 if (!(new_level_num>0 && new_level_num<=player_highest_level)) {
1104                         m[0].text = TXT_ENTER_TO_CONT;
1105                         nm_messagebox( NULL, 1, TXT_OK, TXT_INVALID_LEVEL); 
1106                         goto try_again;
1107                 }
1108         }
1109
1110         Difficulty_level = Player_default_difficulty;
1111
1112         if (!do_difficulty_menu())
1113                 return;
1114
1115         gr_palette_fade_out( gr_palette, 32, 0 );
1116         StartNewGame(new_level_num);
1117
1118 }
1119
1120 extern void GameLoop(int, int );
1121
1122 extern int Redbook_enabled;
1123
1124 void options_menuset(int nitems, newmenu_item * items, int *last_key, int citem )
1125 {
1126         if ( citem==5)
1127         {
1128                 gr_palette_set_gamma(items[5].value);
1129         }
1130
1131         nitems++;               //kill warning
1132         last_key++;             //kill warning
1133 }
1134
1135
1136 // added on 9/20/98 by Victor Rachels to attempt to add screen res change ingame
1137 // Changed on 3/24/99 by Owen Evans to make it work  =)
1138 void change_res_poll()
1139 {
1140 }
1141
1142 void change_res()
1143 {
1144         // edited 05/27/99 Matt Mueller - ingame fullscreen changing
1145         newmenu_item m[11];
1146         u_int32_t modes[11];
1147         int i = 0, mc = 0, num_presets = 0;
1148         char customres[16];
1149 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1150         int fullscreenc;
1151 #endif
1152         //end edit -MM
1153         u_int32_t screen_mode = 0;
1154         int screen_width = 0;
1155         int screen_height = 0;
1156         int vr_mode = VR_NONE;
1157         int screen_flags = 0;
1158
1159         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++;
1160         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++;
1161         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++;
1162         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++;
1163         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++;
1164         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++;
1165         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++;
1166
1167         num_presets = mc;
1168         for (i = 0; i < mc; i++)
1169                 if (m[mc].value)
1170                         break;
1171
1172         m[mc].type = NM_TYPE_RADIO; m[mc].text = "custom:"; m[mc].value = (i == mc); m[mc].group = 0; modes[mc] = 0; mc++;
1173         sprintf(customres, "%ix%i", SM_W(Game_screen_mode), SM_H(Game_screen_mode));
1174         m[mc].type = NM_TYPE_INPUT; m[mc].text = customres; m[mc].text_len = 11; modes[mc] = 0; mc++;
1175
1176         //m[mc].type = NM_TYPE_CHECK; m[mc].text = "No Doublebuffer"; m[mc].value = use_double_buffer;
1177
1178         // added 05/27/99 Matt Mueller - ingame fullscreen changing
1179 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1180         fullscreenc = mc; m[mc].type = NM_TYPE_CHECK; m[mc].text = "Fullscreen"; m[mc].value = gr_check_fullscreen(); mc++;
1181 #endif
1182         // end addition -MM
1183
1184
1185         i = newmenu_do1(NULL, "Screen Resolution", mc, m, &change_res_poll, 0);
1186
1187         // added 05/27/99 Matt Mueller - ingame fullscreen changing
1188 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1189         if (m[fullscreenc].value != gr_check_fullscreen())
1190         {
1191                 gr_toggle_fullscreen();
1192         Game_screen_mode = -1;
1193         }
1194 #endif
1195         // end addition -MM
1196
1197         for (i = 0; (m[i].value == 0) && (i < num_presets); i++);
1198
1199         for(i = 0; (m[i].value == 0) && (i < num_presets); i++);
1200
1201         if (modes[i]==0)
1202         {
1203                 char *h = strchr(customres, 'x');
1204                 if (!h)
1205                         return;
1206                 screen_mode = SM(atoi(customres), atoi(h+1));
1207         }
1208         else
1209         {
1210                 screen_mode = modes[i];
1211         }
1212
1213         screen_width = SM_W(screen_mode);
1214         screen_height = SM_H(screen_mode);
1215         if (screen_height <= 0 || screen_width <= 0)
1216                 return;
1217
1218         switch (screen_mode)
1219         {
1220         case SM(320, 200):
1221         case SM(640, 480):
1222                 screen_flags = VRF_ALLOW_COCKPIT + VRF_COMPATIBLE_MENUS;
1223                 break;
1224         default:
1225                 screen_flags = VRF_COMPATIBLE_MENUS;
1226                 break;
1227         }
1228
1229 #ifdef __MSDOS__
1230         if (FindArg("-nodoublebuffer"))
1231 #endif
1232         {
1233                 screen_flags &= ~VRF_USE_PAGING;
1234         }
1235
1236         // added 6/15/1999 by Owen Evans to eliminate unneccesary mode modification
1237         if (Game_screen_mode == screen_mode)
1238                 return;
1239         //gr_set_mode(Game_screen_mode);
1240         // end section - OE
1241
1242         //VR_offscreen_buffer = 0; // Disable VR (so that VR_Screen_mode doesnt mess us up
1243         Game_screen_mode = screen_mode;
1244         Game_window_w = screen_width;
1245         Game_window_h = screen_height;
1246         game_init_render_buffers(screen_mode, screen_width, screen_height, vr_mode, screen_flags);
1247 }
1248 //End changed section (OE)
1249
1250
1251 //added on 8/18/98 by Victor Rachels to add d1x options menu, maxfps setting
1252 //added/edited on 8/18/98 by Victor Rachels to set maxfps always on, max=80
1253 //added/edited on 9/7/98 by Victor Rachels to attempt dir browsing.  failed.
1254
1255 void d2x_options_menu_poll(int nitems, newmenu_item * menus, int * key, int citem)
1256 {
1257 }
1258
1259
1260 void d2x_options_menu()
1261 {
1262         newmenu_item m[14];
1263         int i=0;
1264         int opt = 0;
1265         int inputs, commands;
1266 #if 0
1267         int checks;
1268 #endif
1269
1270         char smaxfps[4];
1271 #if 0
1272         char shudmaxnumdisp[4];
1273         char thogdir[64];
1274         extern int gr_message_color_level;
1275
1276         sprintf(thogdir,AltHogDir);
1277 #endif
1278         sprintf(smaxfps,"%d",maxfps);
1279 #if 0
1280         sprintf(shudmaxnumdisp,"%d",HUD_max_num_disp);
1281
1282         m[opt].type = NM_TYPE_MENU;  m[opt].text = "Primary autoselect ordering...";   opt++;
1283         m[opt].type = NM_TYPE_MENU;  m[opt].text = "Secondary autoselect ordering..."; opt++;
1284 #endif
1285
1286 #ifdef D2X_KEYS
1287         //added on 2/4/99 by Victor Rachels for new key menu
1288         m[opt].type = NM_TYPE_MENU;  m[opt].text = "D2X Keys"; opt++;
1289         //end this section addition - VR
1290 #endif
1291
1292         // enabled 3/24/99 - Owen Evans
1293         m[opt].type = NM_TYPE_MENU; m[opt].text = "Change Screen Resolution"; opt++;
1294         // end enabled stuff - OE
1295
1296         commands=opt;
1297 #if 0
1298         //added on 2/2/99 by Victor Rachels for bans
1299 #ifdef NETWORK
1300         m[opt].type = NM_TYPE_MENU; m[opt].text = "Save bans now"; opt++;
1301 #endif
1302         //end this section addition - VR
1303 #endif // 0
1304
1305         m[opt].type = NM_TYPE_TEXT;  m[opt].text = "Maximum Framerate (1-80):";       opt++;
1306
1307
1308         inputs=opt;
1309         m[opt].type = NM_TYPE_INPUT; m[opt].text = smaxfps; m[opt].text_len=3;         opt++;
1310 #if 0
1311         m[opt].type = NM_TYPE_TEXT;  m[opt].text = "Mission Directory";                opt++;
1312         m[opt].type = NM_TYPE_INPUT; m[opt].text = thogdir; m[opt].text_len=64;        opt++;
1313         m[opt].type = NM_TYPE_TEXT;  m[opt].text = "Hud Messages lines (1-80):";       opt++;
1314         m[opt].type = NM_TYPE_INPUT; m[opt].text = shudmaxnumdisp; m[opt].text_len=3;  opt++;
1315         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++;
1316         checks=opt;
1317 #ifdef __MSDOS__
1318         m[opt].type = NM_TYPE_CHECK; m[opt].text = "Joy is sidewinder"; m[opt].value=Joy_is_Sidewinder;  opt++;
1319 #endif
1320 #ifdef SUPPORTS_NICEFPS
1321         m[opt].type = NM_TYPE_CHECK; m[opt].text = "Nice FPS (free cpu cycles)"; m[opt].value = use_nice_fps; opt++;
1322 #endif
1323 #endif // 0
1324
1325         for(;;)
1326         {
1327                 i=newmenu_do1( NULL, "D2X options", opt, m, &d2x_options_menu_poll, i);
1328
1329                 if(i>-1)
1330                 {
1331             if(i<commands)
1332                         {
1333                                 switch(i)
1334                                 {
1335 #if 0
1336                                 case 0: reorder_primary(); break;
1337                                 case 1: reorder_secondary(); break;
1338 #endif
1339 #ifdef D2X_KEYS
1340                                         //added on 2/4/99 by Victor Rachels for new key menu
1341                                 case 0: kconfig(4, "D2X Keys"); break;
1342                                         //end this section addition - VR
1343 #endif
1344                                         // enabled 3/24/99 - Owen Evans
1345                                 case 0: change_res(); break;
1346                                         // end enabled stuff - OE
1347                                 }
1348                         }
1349
1350 #if 0
1351             //added on 2/4/99 by Victor Rachels for bans
1352 #ifdef NETWORK
1353             if(i==commands+0)
1354                         {              
1355
1356                                 nm_messagebox(NULL,1,TXT_OK, "%i Bans saved",writebans());
1357
1358                         }
1359 #endif
1360             //end this section addition - VR
1361 #endif // 0
1362
1363             if(i == inputs+0)
1364                         {
1365                                 maxfps = atoi(smaxfps);
1366                 if(maxfps < 1 || maxfps>80)
1367                                 {
1368                                         nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid value for maximum framerate");
1369                                         maxfps = 80;
1370                                         i = (inputs+0);
1371                                 }
1372                         }
1373 #if 0
1374             else if(i==inputs+2)
1375                                 cfile_use_alternate_hogdir(thogdir);
1376                         else if(i==inputs+4)
1377                         {
1378                                 HUD_max_num_disp = atoi(shudmaxnumdisp);
1379                 if(HUD_max_num_disp < 1||HUD_max_num_disp>HUD_MAX_NUM)
1380                                 {
1381                                         nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid value for hud lines");
1382                                         HUD_max_num_disp=4;
1383                                         //                   i=(inputs+4);//???
1384                                 }
1385                         }
1386                         gr_message_color_level=m[inputs+5].value;
1387
1388                         sprintf(shudmaxnumdisp,"%d",HUD_max_num_disp);
1389 #endif // 0
1390                         sprintf(smaxfps,"%d",maxfps);
1391                         //           m[inputs+0].text=smaxfps;//redundant.. its not going anywhere
1392 #if 0
1393                         sprintf(thogdir,AltHogDir);
1394                         //           m[inputs+2].text=thogdir;//redundant
1395 #endif
1396                 }
1397                 else
1398                         break;
1399         }
1400
1401 #if 0
1402         write_player_file();
1403
1404 #ifdef __MSDOS__
1405         Joy_is_Sidewinder=m[(checks+0)].value;
1406 #endif
1407 #ifdef __linux__
1408         Joy_is_Sidewinder=0;
1409 #endif
1410 #ifdef SUPPORTS_NICEFPS
1411         use_nice_fps=m[(checks+0)].value;
1412 #else
1413         use_nice_fps=0;
1414 #endif
1415 #endif // 0
1416 }
1417
1418 //end edit - Victor Rachels
1419 //end addition - Victor Rachels
1420
1421
1422 void do_options_menu()
1423 {
1424         newmenu_item m[13];
1425         int i = 0;
1426
1427         do {
1428                 m[ 0].type = NM_TYPE_MENU;   m[ 0].text="Sound effects & music...";
1429                 m[ 1].type = NM_TYPE_TEXT;   m[ 1].text="";
1430                 #if defined(MACINTOSH) && defined(APPLE_DEMO)
1431                 m [2].type = NM_TYPE_TEXT;   m[ 2].text="";
1432                 #else
1433                 m[ 2].type = NM_TYPE_MENU;   m[ 2].text=TXT_CONTROLS_;
1434                 #endif
1435         #ifdef WINDOWS
1436                 m[ 3].type = NM_TYPE_MENU;   m[ 3].text="INVOKE JOYSTICK CONTROL PANEL";
1437         #else
1438                 m[ 3].type = NM_TYPE_MENU;   m[ 3].text=TXT_CAL_JOYSTICK;
1439         #endif
1440                 m[ 4].type = NM_TYPE_TEXT;   m[ 4].text="";
1441
1442 #if defined(POLY_ACC)
1443         #ifdef MACINTOSH
1444
1445                 if ( !PAEnabled )
1446                 {
1447                         m[5].type               = NM_TYPE_SLIDER;
1448                         m[5].text               = TXT_BRIGHTNESS;
1449                         m[5].value              = gr_palette_get_gamma();
1450                         m[5].min_value  = 0;
1451                         m[5].max_value  = 8; 
1452                 }
1453                 else
1454                 {
1455                         m[ 5].type = NM_TYPE_TEXT;   m[ 5].text="";
1456                 }
1457         
1458         #else
1459                 m[ 5].type = NM_TYPE_TEXT;   m[ 5].text="";
1460         #endif
1461 #else
1462                 m[5].type = NM_TYPE_SLIDER;
1463                 m[5].text = TXT_BRIGHTNESS;
1464                 m[5].value = gr_palette_get_gamma();
1465                 m[5].min_value = 0;
1466                 m[5].max_value = 16; // CCA too dim, was 8;
1467 #endif
1468
1469
1470 #ifdef PA_3DFX_VOODOO
1471                 m[ 6].type = NM_TYPE_TEXT;   m[ 6].text="";
1472 #else
1473                 m[ 6].type = NM_TYPE_MENU;   m[ 6].text=TXT_DETAIL_LEVELS;
1474 #endif
1475
1476 #if defined(POLY_ACC)
1477                 m[ 7].type = NM_TYPE_TEXT;   m[ 7].text="";
1478 #else
1479                 #ifdef MACINTOSH
1480                         if ( gConfigInfo.mChangeResolution && !PAEnabled )
1481                         {
1482                                 m[ 7].type = NM_TYPE_MENU;   m[ 7].text="Screen resolution...";
1483                         }
1484                         else    // for when we are on a mac and no resolution switching allowed
1485                         {
1486                                 m[ 7].type = NM_TYPE_TEXT;   m[ 7].text="";
1487                         }
1488                 #else   // for PC's
1489                         m[ 7].type = NM_TYPE_MENU;   m[ 7].text="Screen resolution...";
1490                 #endif  // end of #ifdef macintosh
1491
1492 #endif
1493
1494                 m[ 8].type = NM_TYPE_TEXT;   m[ 8].text="";
1495                 m[ 9].type = NM_TYPE_MENU;   m[ 9].text="Primary autoselect ordering...";
1496                 m[10].type = NM_TYPE_MENU;   m[10].text="Secondary autoselect ordering...";
1497                 m[11].type = NM_TYPE_MENU;   m[11].text="Toggles...";
1498
1499                 m[12].type = NM_TYPE_MENU;   m[12].text="D2X options...";
1500
1501                 i = newmenu_do1( NULL, TXT_OPTIONS, sizeof(m)/sizeof(*m), m, options_menuset, i );
1502                         
1503                 switch(i)       {
1504                         case  0: do_sound_menu();                       break;
1505                         case  2: joydefs_config();                      break;
1506                         case  3: joydefs_calibrate();           break;
1507                         case  6: do_detail_level_menu();        break;
1508                         case  7: do_screen_res_menu();          break;
1509                         case  9: ReorderPrimary();                      break;
1510                         case 10: ReorderSecondary();            break;
1511                         case 11: do_toggles_menu();                     break;
1512                         case 12: d2x_options_menu();        break;
1513                 }
1514
1515         } while( i>-1 );
1516
1517         write_player_file();
1518 }
1519
1520 extern int Redbook_playing;
1521 void set_redbook_volume(int volume);
1522
1523 WIN(extern int RBCDROM_State);
1524 WIN(static BOOL windigi_driver_off=FALSE);
1525
1526 void sound_menuset(int nitems, newmenu_item * items, int *last_key, int citem )
1527 {
1528         nitems=nitems;          
1529         *last_key = *last_key;
1530
1531         if ( Config_digi_volume != items[0].value )     {
1532                 Config_digi_volume = items[0].value;
1533
1534                 #ifdef WINDOWS
1535                         if (windigi_driver_off) {
1536                                 digi_midi_wait();
1537                                 digi_init_digi();
1538                                 Sleep(500);
1539                                 windigi_driver_off = FALSE;
1540                         }
1541                 #endif                  
1542                 
1543                 #ifndef MACINTOSH
1544                         digi_set_digi_volume( (Config_digi_volume*32768)/8 );
1545                 #else
1546                         digi_set_digi_volume( (Config_digi_volume*256)/8 );
1547                 #endif
1548                 digi_play_sample_once( SOUND_DROP_BOMB, F1_0 );
1549         }
1550
1551 #ifdef WINDOWS
1552         if (!wmidi_support_volchange()) {
1553                 if (!items[1].value && Config_midi_volume) {
1554                         Config_midi_volume = 0;
1555                         digi_set_midi_volume(0);
1556                         digi_play_midi_song( NULL, NULL, NULL, 0 );
1557                 }
1558                 else if (Config_midi_volume == 0 && items[1].value) {
1559                         digi_set_midi_volume(64);
1560                         Config_midi_volume = 4;
1561                 }
1562         }
1563         else     // LINK TO BELOW IF
1564 #endif
1565         if (Config_midi_volume != items[1].value )   {
1566                 Config_midi_volume = items[1].value;
1567                 #ifdef WINDOWS
1568                         if (!windigi_driver_off) {
1569                                 Sleep(200);
1570                                 digi_close_digi();
1571                                 Sleep(100);
1572                                 windigi_driver_off = TRUE;
1573                         }
1574                 #endif
1575                 #ifndef MACINTOSH
1576                         digi_set_midi_volume( (Config_midi_volume*128)/8 );
1577                 #else
1578                         digi_set_midi_volume( (Config_midi_volume*256)/8 );
1579                 #endif
1580         }
1581 #ifdef MACINTOSH
1582         if (Config_master_volume != items[3].value ) {
1583                 Config_master_volume = items[3].value;
1584                 digi_set_master_volume( Config_master_volume );
1585                 digi_play_sample_once( SOUND_DROP_BOMB, F1_0 );
1586         }
1587 #endif
1588
1589         // don't enable redbook for a non-apple demo version of the shareware demo
1590         #if !defined(SHAREWARE) || ( defined(SHAREWARE) && defined(APPLE_DEMO) )
1591
1592         if (Config_redbook_volume != items[2].value )   {
1593                 Config_redbook_volume = items[2].value;
1594                 set_redbook_volume(Config_redbook_volume);
1595         }
1596
1597         if (items[4].value != (Redbook_playing!=0)) {
1598
1599                 if (items[4].value && FindArg("-noredbook")) {
1600                         nm_messagebox (TXT_SORRY,1,TXT_OK,"Redbook audio has been disabled\non the command line");
1601                         items[4].value = 0;
1602                         items[4].redraw = 1;
1603                 }
1604                 else {
1605                         Redbook_enabled = items[4].value;
1606
1607                         mprintf((1, "Redbook_enabled = %d\n", Redbook_enabled));
1608
1609                         if (Function_mode == FMODE_MENU)
1610                                 songs_play_song(SONG_TITLE,1);
1611                         else if (Function_mode == FMODE_GAME)
1612                                 songs_play_level_song( Current_level_num );
1613                         else
1614                                 Int3();
1615
1616                         if (items[4].value && !Redbook_playing) {
1617                         #ifdef WINDOWS
1618                                 if (RBCDROM_State == -1) 
1619                                         nm_messagebox (TXT_SORRY,1,TXT_OK,"Cannot start CD Music.\nAnother application is\nusing the CD player.\n");
1620                                 else // link to next code line!
1621                         #endif
1622                                 nm_messagebox (TXT_SORRY,1,TXT_OK,"Cannot start CD Music.  Insert\nyour Descent II CD and try again");
1623                                 items[4].value = 0;
1624                                 items[4].redraw = 1;
1625                         }
1626
1627                         items[1].type = (Redbook_playing?NM_TYPE_TEXT:NM_TYPE_SLIDER);
1628                         items[1].redraw = 1;
1629                         items[2].type = (Redbook_playing?NM_TYPE_SLIDER:NM_TYPE_TEXT);
1630                         items[2].redraw = 1;
1631
1632                 }
1633         }
1634
1635         #endif
1636
1637         citem++;                //kill warning
1638 }
1639
1640 void do_sound_menu()
1641 {
1642    newmenu_item m[6];
1643         int i = 0;
1644
1645  #ifdef WINDOWS
1646         extern BOOL DIGIDriverInit;
1647         if (!DIGIDriverInit) windigi_driver_off = TRUE;
1648         else windigi_driver_off = FALSE;
1649  #endif
1650
1651         do {
1652                 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; 
1653                 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;
1654
1655         #ifdef WINDOWS
1656                 if (!wmidi_support_volchange() && !Redbook_playing) {
1657                         m[1].type = NM_TYPE_CHECK;
1658                         m[1].text = "MIDI MUSIC";
1659                         if (Config_midi_volume) m[1].value = 1;
1660                 }
1661         #endif
1662
1663                 #ifdef SHAREWARE
1664                         m[ 2].type = NM_TYPE_TEXT; m[ 2].text="";
1665                         m[ 3].type = NM_TYPE_TEXT; m[ 3].text="";
1666                         m[ 4].type = NM_TYPE_TEXT; m[ 4].text="";
1667                         #ifdef MACINTOSH
1668                                 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;
1669
1670                                 #ifdef APPLE_DEMO
1671                                         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;
1672                                         m[ 4].type = NM_TYPE_CHECK;  m[ 4].text="CD Music (Redbook) enabled"; m[4].value=(Redbook_playing!=0);
1673                                 #endif
1674
1675                         #endif
1676
1677                 #else           // ifdef SHAREWARE
1678                         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;
1679
1680                         #ifndef MACINTOSH
1681                                 m[ 3].type = NM_TYPE_TEXT; m[ 3].text="";
1682                         #else
1683                                 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; 
1684                         #endif
1685                 
1686                         m[ 4].type = NM_TYPE_CHECK;  m[ 4].text="CD Music (Redbook) enabled"; m[4].value=(Redbook_playing!=0);
1687                 #endif
1688         
1689                 m[ 5].type = NM_TYPE_CHECK;  m[ 5].text=TXT_REVERSE_STEREO; m[5].value=Config_channels_reversed; 
1690                                 
1691                 i = newmenu_do1( NULL, "Sound Effects & Music", sizeof(m)/sizeof(*m), m, sound_menuset, i );
1692
1693                 Redbook_enabled = m[4].value;
1694                 Config_channels_reversed = m[5].value;
1695
1696         } while( i>-1 );
1697
1698 #ifdef WINDOWS
1699         if (windigi_driver_off) {
1700                 digi_midi_wait();
1701                 Sleep(500);
1702                 digi_init_digi();
1703                 windigi_driver_off=FALSE;
1704         }
1705 #endif
1706
1707
1708         if ( Config_midi_volume < 1 )   {
1709                 #ifndef MACINTOSH
1710                         digi_play_midi_song( NULL, NULL, NULL, 0 );
1711                 #else
1712                         digi_play_midi_song(-1, 0);
1713                 #endif
1714         }
1715
1716 }
1717
1718
1719 extern int Automap_always_hires;
1720
1721 #define ADD_CHECK(n,txt,v)  do { m[n].type=NM_TYPE_CHECK; m[n].text=txt; m[n].value=v;} while (0)
1722
1723 void do_toggles_menu()
1724 {
1725 #ifndef MACINTOSH
1726 #if defined(POLY_ACC)
1727         #define N_TOGGLE_ITEMS 6        // get rid of automap hi-res.
1728 #else
1729         #define N_TOGGLE_ITEMS 7
1730 #endif
1731 #else
1732         #define N_TOGGLE_ITEMS 7
1733 #endif
1734         newmenu_item m[N_TOGGLE_ITEMS];
1735         int i = 0;
1736
1737         do {
1738                 #if defined(MACINTOSH) && defined(USE_ISP)
1739                         if (ISpEnabled())
1740                         {
1741                                 m[0].type = NM_TYPE_TEXT; m[0].text = "";
1742                         }
1743                         else
1744                         {
1745                                 ADD_CHECK(0, "Ship auto-leveling", Auto_leveling_on);
1746                         }
1747                 #else 
1748                         ADD_CHECK(0, "Ship auto-leveling", Auto_leveling_on);
1749                 #endif
1750                 ADD_CHECK(1, "Show reticle", Reticle_on);
1751                 ADD_CHECK(2, "Missile view", Missile_view_enabled);
1752                 ADD_CHECK(3, "Headlight on when picked up", Headlight_active_default );
1753                 ADD_CHECK(4, "Show guided missile in main display", Guided_in_big_window );
1754                 ADD_CHECK(5, "Escort robot hot keys",EscortHotKeys);
1755                 #ifdef MACINTOSH
1756                         if ( !PAEnabled ) {
1757                                 ADD_CHECK(6, "Pixel Double", Scanline_double);
1758                         }
1759                 #else
1760 #if !defined(POLY_ACC)
1761                         ADD_CHECK(6, "Always show HighRes Automap", min(MenuHiresAvailable,Automap_always_hires));
1762 #endif
1763                 #endif
1764                 //when adding more options, change N_TOGGLE_ITEMS above
1765
1766                 #ifdef MACINTOSH
1767                 if ( PAEnabled )                // when doing RAVE, no pixel doubling
1768                         i = newmenu_do1( NULL, "Toggles", N_TOGGLE_ITEMS-1, m, NULL, i );
1769                 else
1770                 #endif          // note link to if
1771                         i = newmenu_do1( NULL, "Toggles", N_TOGGLE_ITEMS, m, NULL, i );
1772                         
1773                 Auto_leveling_on                        = m[0].value;
1774                 Reticle_on                                      = m[1].value;
1775                 Missile_view_enabled            = m[2].value;
1776                 Headlight_active_default        = m[3].value;
1777                 Guided_in_big_window            = m[4].value;
1778                 EscortHotKeys                           = m[5].value;
1779
1780
1781                 #ifdef MACINTOSH
1782                         if ( !PAEnabled )
1783                                 Scanline_double = m[6].value;
1784                 #else
1785 #if !defined(POLY_ACC)
1786                         if (MenuHiresAvailable)
1787                                 Automap_always_hires = m[6].value;
1788                         else if (m[6].value)
1789                                 nm_messagebox(TXT_SORRY,1,"OK","High Resolution modes are\nnot available on this video card");
1790 #endif
1791                 #endif
1792
1793         } while( i>-1 );
1794
1795 }
1796
1797 #ifdef NETWORK
1798 void do_multi_player_menu()
1799 {
1800         int menu_choice[9];
1801         newmenu_item m[9];
1802         int choice = 0, num_options = 0;
1803         int old_game_mode;
1804
1805         do {
1806 //              WIN(ipx_destroy_read_thread());
1807
1808                 old_game_mode = Game_mode;
1809                 num_options = 0;
1810
1811 #ifdef NATIVE_IPX
1812                 ADD_ITEM(TXT_START_IPX_NET_GAME, MENU_START_IPX_NETGAME, -1);
1813                 ADD_ITEM(TXT_JOIN_IPX_NET_GAME, MENU_JOIN_IPX_NETGAME, -1);
1814 #endif //NATIVE_IPX
1815                 //ADD_ITEM(TXT_START_TCP_NET_GAME, MENU_START_TCP_NETGAME, -1);
1816                 //ADD_ITEM(TXT_JOIN_TCP_NET_GAME, MENU_JOIN_TCP_NETGAME, -1);
1817                 ADD_ITEM("Start UDP/IP Netgame", MENU_START_UDP_NETGAME, -1);
1818                 ADD_ITEM("Join UDP/IP Netgame\n", MENU_JOIN_UDP_NETGAME, -1);
1819                 ADD_ITEM("Start Multicast UDP/IP Netgame", MENU_START_MCAST4_NETGAME, -1);
1820                 ADD_ITEM("Join Multicast UDP/IP Netgame\n", MENU_JOIN_MCAST4_NETGAME, -1);
1821 #ifdef KALINIX
1822                 ADD_ITEM("Start Kali Netgame", MENU_START_KALI_NETGAME, -1);
1823                 ADD_ITEM("Join Kali Netgame\n", MENU_JOIN_KALI_NETGAME, -1);
1824 #endif // KALINIX
1825
1826 #ifdef MACINTOSH
1827                 ADD_ITEM("Start Appletalk Netgame", MENU_START_APPLETALK_NETGAME, -1 );
1828                 ADD_ITEM("Join Appletalk Netgame\n", MENU_JOIN_APPLETALK_NETGAME, -1 );
1829 #endif
1830
1831                 ADD_ITEM(TXT_MODEM_GAME, MENU_START_SERIAL, -1);
1832
1833                 choice = newmenu_do1( NULL, TXT_MULTIPLAYER, num_options, m, NULL, choice );
1834                 
1835                 if ( choice > -1 )      
1836                         do_option(menu_choice[choice]);
1837         
1838                 if (old_game_mode != Game_mode)
1839                         break;          // leave menu
1840
1841         } while( choice > -1 );
1842
1843 }
1844
1845 /*
1846  * ipx_set_driver was called do_network_init and located in main/inferno
1847  * before the change which allows the user to choose the network driver
1848  * from the game menu instead of having to supply command line args.
1849  */
1850 void ipx_set_driver(int ipx_driver)
1851 {
1852         ipx_close();
1853
1854         if (!FindArg("-nonetwork")) {
1855                 int ipx_error;
1856                 int socket = 0, t;
1857
1858                 con_printf(CON_VERBOSE, "\n%s ", TXT_INITIALIZING_NETWORK);
1859
1860                 if ((t = FindArg("-socket")))
1861                         socket = atoi(Args[t + 1]);
1862
1863                 arch_ipx_set_driver(ipx_driver);
1864
1865                 if ((ipx_error = ipx_init(IPX_DEFAULT_SOCKET + socket)) == IPX_INIT_OK) {
1866                         con_printf(CON_VERBOSE, "%s %d.\n", TXT_IPX_CHANNEL, socket );
1867                         Network_active = 1;
1868                 } else {
1869                         switch(ipx_error) {
1870                         case IPX_NOT_INSTALLED: con_printf(CON_VERBOSE, "%s\n", TXT_NO_NETWORK); break;
1871                         case IPX_SOCKET_TABLE_FULL: con_printf(CON_VERBOSE, "%s 0x%x.\n", TXT_SOCKET_ERROR, IPX_DEFAULT_SOCKET+socket); break;
1872                         case IPX_NO_LOW_DOS_MEM: con_printf(CON_VERBOSE, "%s\n", TXT_MEMORY_IPX ); break;
1873                         default: con_printf(CON_VERBOSE, "%s %d", TXT_ERROR_IPX, ipx_error );
1874                         }
1875                         con_printf(CON_VERBOSE, "%s\n",TXT_NETWORK_DISABLED);
1876                         Network_active = 0;             // Assume no network
1877                 }
1878                 ipx_read_user_file("descent.usr");
1879                 ipx_read_network_file("descent.net");
1880                 //@@if (FindArg("-dynamicsockets"))
1881                 //@@    Network_allow_socket_changes = 1;
1882                 //@@else
1883                 //@@    Network_allow_socket_changes = 0;
1884         } else {
1885                 con_printf(CON_VERBOSE, "%s\n", TXT_NETWORK_DISABLED);
1886                 Network_active = 0;             // Assume no network
1887         }
1888 }
1889
1890 void DoNewIPAddress ()
1891  {
1892   newmenu_item m[4];
1893   char IPText[30];
1894   int choice;
1895
1896   m[0].type=NM_TYPE_TEXT; m[0].text = "Enter an address or hostname:";
1897   m[1].type=NM_TYPE_INPUT; m[1].text_len = 50; m[1].text = IPText;
1898   IPText[0]=0;
1899
1900   choice = newmenu_do( NULL, "Join a TCPIP game", 2, m, NULL );
1901
1902   if (choice==-1 || m[1].text[0]==0)
1903    return;
1904
1905   nm_messagebox (TXT_SORRY,1,TXT_OK,"That address is not valid!");
1906  }
1907
1908 #endif // NETWORK