]> icculus.org git repositories - btb/d2x.git/blob - main/inferno.c
remove all the redundant Polygon Acceleration stuff: fix compiling errors (whoops)
[btb/d2x.git] / main / inferno.c
1 /* $Id: inferno.c,v 1.104 2005-07-30 08:16:13 chris 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.c: Entry point of program (main procedure)
18  *
19  * After main initializes everything, most of the time is spent in the loop
20  * while (Function_mode != FMODE_EXIT)
21  * In this loop, the main menu is brought up first.
22  *
23  * main() for Inferno
24  *
25  */
26
27 #ifdef HAVE_CONFIG_H
28 #include <conf.h>
29 #endif
30
31 char copyright[] = "DESCENT II  COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPORATION";
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <limits.h>
37
38 #ifdef __unix__
39 #include <unistd.h>
40 #include <sys/stat.h>
41 #include <sys/types.h>
42 #endif
43
44 #include <physfs.h>
45
46 #include "pstypes.h"
47 #include "strutil.h"
48 #include "console.h"
49 #include "gr.h"
50 #include "fix.h"
51 #include "vecmat.h"
52 #include "mono.h"
53 #include "key.h"
54 #include "timer.h"
55 #include "3d.h"
56 #include "bm.h"
57 #include "inferno.h"
58 #include "error.h"
59 #include "game.h"
60 #include "segment.h"            //for Side_to_verts
61 #include "u_mem.h"
62 #include "segpoint.h"
63 #include "screens.h"
64 #include "texmap.h"
65 #include "texmerge.h"
66 #include "menu.h"
67 #include "wall.h"
68 #include "polyobj.h"
69 #include "effects.h"
70 #include "digi.h"
71 #include "iff.h"
72 #include "pcx.h"
73 #include "palette.h"
74 #include "args.h"
75 #include "sounds.h"
76 #include "titles.h"
77 #include "player.h"
78 #include "text.h"
79 #include "newdemo.h"
80 #ifdef NETWORK
81 #include "network.h"
82 #include "modem.h"
83 #endif
84 #include "gamefont.h"
85 #include "kconfig.h"
86 #include "mouse.h"
87 #include "joy.h"
88 #include "newmenu.h"
89 #include "desc_id.h"
90 #include "config.h"
91 #include "joydefs.h"
92 #include "multi.h"
93 #include "songs.h"
94 #include "cfile.h"
95 #include "gameseq.h"
96 #include "gamepal.h"
97 #include "mission.h"
98 #include "movie.h"
99
100 // #  include "3dfx_des.h"
101
102 //added on 9/30/98 by Matt Mueller for selectable automap modes
103 #include "automap.h"
104 //end addition -MM
105
106 #include "../texmap/scanline.h" //for select_tmap -MM
107
108 #ifdef EDITOR
109 #include "editor/editor.h"
110 #include "editor/kdefs.h"
111 #include "ui.h"
112 #endif
113
114 #ifndef __MSDOS__
115 #include <SDL.h>
116 #endif
117
118 #include "vers_id.h"
119
120 void mem_init(void);
121 void arch_init(void);
122 void arch_init_start(void);
123
124 //Current version number
125
126 ubyte Version_major = 1;                //FULL VERSION
127 ubyte Version_minor = 2;
128
129 //static const char desc_id_checksum_str[] = DESC_ID_CHKSUM_TAG "0000"; // 4-byte checksum
130 char desc_id_exit_num = 0;
131
132 int Function_mode=FMODE_MENU;           //game or editor?
133 int Screen_mode=-1;                                     //game screen or editor screen?
134
135 //--unused-- grs_bitmap Inferno_bitmap_title;
136
137 int WVIDEO_running=0;           //debugger can set to 1 if running
138
139 //--unused-- int Cyberman_installed=0;                  // SWIFT device present
140 ubyte CybermouseActive=0;
141
142 #ifdef __WATCOMC__
143 int __far descent_critical_error_handler( unsigned deverr, unsigned errcode, unsigned __far * devhdr );
144 #endif
145
146 void check_joystick_calibration(void);
147
148 void show_order_form(void);
149
150 //--------------------------------------------------------------------------
151
152 extern int piggy_low_memory;
153
154
155 int descent_critical_error = 0;
156 unsigned descent_critical_deverror = 0;
157 unsigned descent_critical_errcode = 0;
158
159 extern int Network_allow_socket_changes;
160
161 extern void vfx_set_palette_sub(ubyte *);
162
163 extern int VR_low_res;
164
165 extern int Config_vr_type;
166 extern int Config_vr_resolution;
167 extern int Config_vr_tracking;
168
169 #define LINE_LEN        100
170
171 //read help from a file & print to screen
172 void print_commandline_help()
173 {
174         CFILE *ifile;
175         int have_binary=0;
176         char line[LINE_LEN];
177
178         ifile = cfopen("help.tex","rb");
179         if (!ifile) {
180                 ifile = cfopen("help.txb","rb");
181                 if (!ifile)
182                         Warning("Cannot load help text file.");
183                 have_binary = 1;
184         }
185
186         if (ifile)
187         {
188         char *end;
189         
190                 while ((end = cfgets(line,LINE_LEN,ifile))) {
191
192             // This is the only use of cfgets that needs the CR
193             *end++ = '\n';
194                         if (have_binary)
195                                 decode_text_line (line);
196
197                         if (line[0] == ';')
198                                 continue;               //don't show comments
199
200                         printf("%s",line);
201
202                 }
203
204                 cfclose(ifile);
205
206         }
207
208 //      printf( " Diagnostic:\n\n");
209 //      printf( "  -emul           %s\n", "Certain video cards need this option in order to run game");
210 //      printf( "  -ddemul         %s\n", "If -emul doesn't work, use this option");
211 //      printf( "\n");
212 #ifdef EDITOR
213         printf( " Editor Options:\n\n");
214         printf( "  -autoload <file>%s\n", "Autoload a level in the editor");
215         printf( "  -hoarddata      %s\n","Make the hoard ham file from some files, then exit");
216 //      printf( "  -nobm           %s\n","FIXME: Undocumented");
217         printf( "\n");
218 #endif
219         printf( " D2X Options:\n\n");
220         printf( "  -noredundancy   %s\n", "Do not send messages when picking up redundant items in multi");
221         printf( "  -shortpackets   %s\n", "Set shortpackets to default as on");
222 #ifdef OGL // currently only does anything on ogl build, so don't advertise othewise.
223         printf("  -renderstats    %s\n", "Enable renderstats info by default");
224 #endif
225         printf( "  -maxfps <n>     %s\n", "Set maximum framerate (1-100)");
226         printf( "  -notitles       %s\n", "Do not show titlescreens on startup");
227         printf( "  -hogdir <dir>   %s\n", "set shared data directory to <dir>");
228 #ifdef __unix__
229         printf( "  -nohogdir       %s\n", "don't try to use shared data directory");
230         printf( "  -userdir <dir>  %s\n", "set user dir to <dir> instead of $HOME/.d2x");
231 #endif
232         printf( "  -ini <file>     %s\n", "option file (alternate to command line), defaults to d2x.ini");
233         printf( "  -autodemo       %s\n", "Start in demo mode");
234         printf( "  -bigpig         %s\n","FIXME: Undocumented");
235         printf( "  -bspgen         %s\n","FIXME: Undocumented");
236 //      printf( "  -cdproxy        %s\n","FIXME: Undocumented");
237 #ifndef NDEBUG
238         printf( "  -checktime      %s\n","FIXME: Undocumented");
239         printf( "  -showmeminfo    %s\n","FIXME: Undocumented");
240 #endif
241 //      printf( "  -codereadonly   %s\n","FIXME: Undocumented");
242 //      printf( "  -cyberimpact    %s\n","FIXME: Undocumented");
243         printf( "  -debug          %s\n","Enable very verbose output");
244 //      printf( "  -debugmode      %s\n","FIXME: Undocumented");
245 //      printf( "  -disallowgfx    %s\n","FIXME: Undocumented");
246 //      printf( "  -disallowreboot %s\n","FIXME: Undocumented");
247 //      printf( "  -dynamicsockets %s\n","FIXME: Undocumented");
248 //      printf( "  -forcegfx       %s\n","FIXME: Undocumented");
249 #ifdef SDL_INPUT
250         printf( "  -grabmouse      %s\n","Keeps the mouse from wandering out of the window");
251 #endif
252 //      printf( "  -hw_3dacc       %s\n","FIXME: Undocumented");
253 #ifndef RELEASE
254         printf( "  -invulnerability %s\n","Make yourself invulnerable");
255 #endif
256         printf( "  -ipxnetwork <num> %s\n","Use IPX network number <num>");
257         printf( "  -jasen          %s\n","FIXME: Undocumented");
258         printf( "  -joyslow        %s\n","FIXME: Undocumented");
259 #ifdef NETWORK
260         printf( "  -kali           %s\n","use Kali for networking");
261 #endif
262 //      printf( "  -logfile        %s\n","FIXME: Undocumented");
263         printf( "  -lowresmovies   %s\n","Play low resolution movies if available (for slow machines)");
264 #if defined(EDITOR) || !defined(MACDATA)
265         printf( "  -macdata        %s\n","Read (and, for editor, write) mac data files (swap colors)");
266 #endif
267 //      printf( "  -memdbg         %s\n","FIXME: Undocumented");
268 //      printf( "  -monodebug      %s\n","FIXME: Undocumented");
269         printf( "  -nocdrom        %s\n","FIXME: Undocumented");
270 #ifdef __DJGPP__
271         printf( "  -nocyberman     %s\n","FIXME: Undocumented");
272 #endif
273 #ifndef NDEBUG
274         printf( "  -nofade         %s\n","Disable fades");
275 #endif
276 #ifdef NETWORK
277         printf( "  -nomatrixcheat  %s\n","FIXME: Undocumented");
278         printf( "  -norankings     %s\n","Disable multiplayer ranking system");
279         printf( "  -packets <num>  %s\n","Specifies the number of packets per second\n");
280 //      printf( "  -showaddress    %s\n","FIXME: Undocumented");
281         printf( "  -socket         %s\n","FIXME: Undocumented");
282 #endif
283 #if !defined(MACINTOSH) && !defined(WINDOWS)
284         printf( "  -nomixer        %s\n","Don't crank music volume");
285 //      printf( "  -superhires     %s\n","Allow higher-resolution modes");
286 #endif
287 //      printf( "  -nomodex        %s\n","FIXME: Undocumented");
288 #ifndef RELEASE
289         printf( "  -nomovies       %s\n","Don't play movies");
290         printf( "  -noscreens      %s\n","Skip briefing screens");
291 #endif
292 #if !defined(SHAREWARE) || ( defined(SHAREWARE) && defined(APPLE_DEMO) )
293         printf( "  -noredbook      %s\n","Disable redbook audio");
294 #endif
295         printf( "  -norun          %s\n","Bail out after initialization");
296 //      printf( "  -ordinaljoy     %s\n","FIXME: Undocumented");
297 //      printf( "  -rtscts         %s\n","Same as -ctsrts");
298 //      printf( "  -semiwin        %s\n","Use non-fullscreen mode");
299 //      printf( "  -specialdevice  %s\n","FIXME: Undocumented");
300 #ifdef TACTILE
301         printf( "  -stickmag       %s\n","FIXME: Undocumented");
302 #endif
303 //      printf( "  -stopwatch      %s\n","FIXME: Undocumented");
304         printf( "  -subtitles      %s\n","Turn on movie subtitles (English-only)");
305 //      printf( "  -sysram         %s\n","FIXME: Undocumented");
306         printf( "  -text <file>    %s\n","Specify alternate .tex file");
307 //      printf( "  -tsengdebug1    %s\n","FIXME: Undocumented");
308 //      printf( "  -tsengdebug2    %s\n","FIXME: Undocumented");
309 //      printf( "  -tsengdebug3    %s\n","FIXME: Undocumented");
310 //      printf( "  -vidram         %s\n","FIXME: Undocumented");
311         printf( "  -xcontrol       %s\n","FIXME: Undocumented");
312         printf( "  -xname          %s\n","FIXME: Undocumented");
313         printf( "  -xver           %s\n","FIXME: Undocumented");
314         printf( "  -tmap <t>       %s\n","select texmapper to use (c,fp,i386,pent,ppro)");
315 #ifdef __MSDOS__
316         printf( "  -<X>x<Y>        %s\n", "Change screen resolution. Options:");
317         printf( "                     320x100;320x200;320x240;320x400;640x400;640x480;800x600;1024x768\n");
318 #else
319         printf( "  -<X>x<Y>        %s\n", "Change screen resolution to <X> by <Y>");
320 #endif
321         printf("  -niceautomap    %s\n", "Free cpu while doing automap");
322         printf( "  -automap<X>x<Y> %s\n","Set automap resolution to <X> by <Y>");
323         printf( "  -automap_gameres %s\n","Set automap to use the same resolution as in game");
324 //      printf( "  -menu<X>x<Y>    %s\n","Set menu resolution to <X> by <Y>");
325 //      printf( "  -menu_gameres   %s\n","Set menus to use the same resolution as in game");
326         printf("  -rearviewtime t %s\n", "time holding rearview key to use toggle mode (default 0.0625 seconds)");
327         printf( "\n");
328
329         printf( "D2X System Options:\n\n");
330 #ifdef __MSDOS__
331         printf("  -ihaveabrokenmouse %s\n", "try to make mouse work if it is not currently");
332         printf( "  -joy209         %s\n", "Use alternate port 209 for joystick");
333 #endif
334 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
335         printf( "  -fullscreen     %s\n", "Use fullscreen mode if available");
336 #endif
337 #ifdef OGL
338         printf( "  -gl_texmagfilt <f> %s\n","set GL_TEXTURE_MAG_FILTER (see readme.d1x)");
339         printf( "  -gl_texminfilt <f> %s\n","set GL_TEXTURE_MIN_FILTER (see readme.d1x)");
340         printf("  -gl_mipmap      %s\n", "set gl texture filters to \"standard\" (bilinear) mipmapping");
341         printf("  -gl_trilinear   %s\n", "set gl texture filters to trilinear mipmapping");
342         printf( "  -gl_simple      %s\n","set gl texture filters to gl_nearest for \"original\" look. (default)");
343         printf("  -gl_anisotropy <f> %s\n", "set maximum degree of anisotropy to <f>");
344         printf( "  -gl_alttexmerge %s\n","use new texmerge, usually uses less ram (default)");
345         printf( "  -gl_stdtexmerge %s\n","use old texmerge, uses more ram, but _might_ be a bit faster");
346 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
347         printf( "  -gl_voodoo      %s\n","force fullscreen mode only");
348 #endif
349         printf( "  -gl_16bittextures %s\n","attempt to use 16bit textures");
350         printf("  -gl_16bpp       %s\n", "attempt to use 16bit screen mode");
351         printf( "  -gl_reticle <r> %s\n","use OGL reticle 0=never 1=above 320x* 2=always");
352         printf( "  -gl_intensity4_ok %s\n","FIXME: Undocumented");
353         printf( "  -gl_luminance4_alpha4_ok %s\n","FIXME: Undocumented");
354         printf( "  -gl_readpixels_ok %s\n","FIXME: Undocumented");
355         printf( "  -gl_rgba2_ok    %s\n","FIXME: Undocumented");
356 //      printf( "  -gl_test1       %s\n","FIXME: Undocumented");
357         printf( "  -gl_test2       %s\n","FIXME: Undocumented");
358         printf( "  -gl_vidmem      %s\n","FIXME: Undocumented");
359 #ifdef OGL_RUNTIME_LOAD
360         printf( "  -gl_library <l> %s\n","use alternate opengl library");
361 #endif
362 #ifdef WGL_VIDEO
363         printf("  -gl_refresh <r> %s\n", "set refresh rate (in fullscreen mode)");
364 #endif
365 #endif
366 #ifdef SDL_VIDEO
367         printf( "  -nosdlvidmodecheck %s\n", "Some X servers don't like checking vidmode first, so just switch");
368         printf( "  -hwsurface      %s\n","FIXME: Undocumented");
369 #endif
370 #ifdef NETWORK
371         printf("  -udp            %s\n", "Specify options for udp/ip:");
372         printf("    @<shift>      %s\n", "  shift udp port base offset");
373         printf("    =<HOST_LIST>  %s\n", "  broadcast both local and to HOST_LIST");
374         printf("    +<HOST_LIST>  %s\n", "  broadcast only to HOST_LIST");
375         printf("                  %s\n", "   HOSTS can be any IP or hostname")
376                 ;
377         printf("                  %s\n", "   HOSTS can also be in the form of <address>:<shift>");
378         printf("                  %s\n", "   separate multiple HOSTS with a ,");
379 #endif
380 #ifdef __unix__
381         printf( "  -serialdevice <s> %s\n", "Set serial/modem device to <s>");
382         printf( "  -serialread <r> %s\n", "Set serial/modem to read from <r>");
383 #endif
384         printf( "\n Help:\n\n");
385         printf( "  -help, -h, -?, ? %s\n", "View this help screen");
386         printf( "\n");
387 }
388
389 void do_joystick_init()
390 {
391
392         if (!FindArg( "-nojoystick" ))  {
393                 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_6);
394                 joy_init();
395                 if ( FindArg( "-joyslow" ))     {
396                         con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_7);
397                         joy_set_slow_reading(JOY_SLOW_READINGS);
398                 }
399                 if ( FindArg( "-joypolled" ))   {
400                         con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_8);
401                         joy_set_slow_reading(JOY_POLLED_READINGS);
402                 }
403                 if ( FindArg( "-joybios" ))     {
404                         con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_9);
405                         joy_set_slow_reading(JOY_BIOS_READINGS);
406                 }
407
408         //      Added from Descent v1.5 by John.  Adapted by Samir.
409         } else {
410                 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_10);
411         }
412 }
413
414 //set this to force game to run in low res
415 int disable_high_res=0;
416
417 void do_register_player(ubyte *title_pal)
418 {
419         Players[Player_num].callsign[0] = '\0';
420
421         if (!Auto_demo)         {
422
423                 key_flush();
424
425                 //now, before we bring up the register player menu, we need to
426                 //do some stuff to make sure the palette is ok.  First, we need to
427                 //get our current palette into the 2d's array, so the remapping will
428                 //work.  Second, we need to remap the fonts.  Third, we need to fill
429                 //in part of the fade tables so the darkening of the menu edges works
430
431                 memcpy(gr_palette,title_pal,sizeof(gr_palette));
432                 remap_fonts_and_menus(1);
433                 RegisterPlayer();               //get player's name
434         }
435
436 }
437
438 #define PROGNAME argv[0]
439
440 extern char Language[];
441
442 //can we do highres menus?
443 extern int MenuHiresAvailable;
444
445 int intro_played = 0;
446
447 int Inferno_verbose = 0;
448
449 //added on 11/18/98 by Victor Rachels to add -mission and -startgame
450 int start_net_immediately = 0;
451 //int start_with_mission = 0;
452 //char *start_with_mission_name;
453 //end this section addition
454
455 #define MENU_HIRES_MODE SM(640,480)
456
457 //      DESCENT II by Parallax Software
458 //              Descent Main
459
460 //extern ubyte gr_current_pal[];
461
462 #ifdef  EDITOR
463 int     Auto_exit = 0;
464 char    Auto_file[128] = "";
465 #endif
466
467 int main(int argc, char *argv[])
468 {
469         int i, t;
470         ubyte title_pal[768];
471
472         PHYSFS_init(argv[0]);
473         PHYSFS_permitSymbolicLinks(1);
474
475         con_init();  // Initialise the console
476         mem_init();
477
478         error_init(NULL, NULL);
479
480         PHYSFS_addToSearchPath(PHYSFS_getBaseDir(), 1);
481         InitArgs( argc,argv );
482
483         if ((t = FindArg("-userdir"))
484 #ifdef __unix__
485          || 1   // or if it's a unix platform
486 #endif
487          )
488         {
489                 // This stuff below seems overly complicated - brad
490
491                 char *path = Args[t+1];
492                 char fullPath[PATH_MAX + 5];
493
494 #ifdef __unix__
495                 if (!t)
496                         path = "~/.d2x";
497 #endif
498                 PHYSFS_removeFromSearchPath(PHYSFS_getBaseDir());
499                 
500                 if (path[0] == '~') // yes, this tilde can be put before non-unix paths.
501                 {
502                         const char *home = PHYSFS_getUserDir();
503                         
504                         strcpy(fullPath, home); // prepend home to the path
505                         path++;
506                         if (*path == *PHYSFS_getDirSeparator())
507                                 path++;
508                         strncat(fullPath, path, PATH_MAX + 5 - strlen(home));
509                 }
510                 else
511                         strncpy(fullPath, path, PATH_MAX + 5);
512                 
513                 PHYSFS_setWriteDir(fullPath);
514                 if (!PHYSFS_getWriteDir())  // need to make it
515                 {
516                         PHYSFS_mkdir(fullPath);
517                         PHYSFS_setWriteDir(fullPath);
518                 }
519                         
520                 PHYSFS_addToSearchPath(PHYSFS_getWriteDir(), 1);
521                 AppendArgs();
522         }
523
524         if (!PHYSFS_getWriteDir())
525         {
526                 PHYSFS_setWriteDir(PHYSFS_getBaseDir());
527                 if (!PHYSFS_getWriteDir())
528                         Error("can't set write dir\n");
529                 else
530                         PHYSFS_addToSearchPath(PHYSFS_getWriteDir(), 0);
531         }
532         
533         if (FindArg("-debug"))
534                 con_threshold.value = (float)2;
535         else if (FindArg("-verbose"))
536                 con_threshold.value = (float)1;
537
538         //tell cfile where hogdir is
539         if ((t=FindArg("-hogdir")))
540                 PHYSFS_addToSearchPath(Args[t + 1], 1);
541 #ifdef __unix__
542         else if (!FindArg("-nohogdir"))
543                 PHYSFS_addToSearchPath(SHAREPATH, 1);
544 #endif
545
546         if (! cfile_init("descent2.hog"))
547                 if (! cfile_init("d2demo.hog"))
548                         Warning("Could not find a valid hog file (descent2.hog or d2demo.hog)\nPossible locations are:\n"
549 #ifdef __unix__
550                               "\t$HOME/.d2x\n"
551                               "\t" SHAREPATH "\n"
552 #else
553                                   "\tCurrent directory\n"
554 #endif
555                                   "Or use the -hogdir option to specify an alternate location.");
556         load_text();
557
558         //print out the banner title
559         con_printf(CON_NORMAL, "\nDESCENT 2 %s v%d.%d",VERSION_TYPE,Version_major,Version_minor);
560         #ifdef VERSION_NAME
561         con_printf(CON_NORMAL, "  %s", VERSION_NAME);
562         #endif
563         if (cfexist(MISSION_DIR "d2x.hog"))
564                 con_printf(CON_NORMAL, "  Vertigo Enhanced");
565
566         con_printf(CON_NORMAL, "  %s %s\n", __DATE__,__TIME__);
567         con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
568         con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2. Copyright (c) 1999 Peter Hawkins\n");
569         con_printf(CON_NORMAL, "                                         Copyright (c) 2002 Bradley Bell\n");
570
571
572         if (FindArg( "-?" ) || FindArg( "-help" ) || FindArg( "?" ) || FindArg( "-h" ) ) {
573                 print_commandline_help();
574                 set_exit_message("");
575 #ifdef __MINGW32__
576                 exit(0);  /* mingw hangs on this return.  dunno why */
577 #endif
578                 return(0);
579         }
580
581         con_printf(CON_NORMAL, "\n");
582         con_printf(CON_NORMAL, TXT_HELP, PROGNAME);             //help message has %s for program name
583         con_printf(CON_NORMAL, "\n");
584
585         {
586                 char **i, **list;
587
588                 for (i = PHYSFS_getSearchPath(); *i != NULL; i++)
589                         con_printf(CON_VERBOSE, "PHYSFS: [%s] is in the search path.\n", *i);
590
591                 list = PHYSFS_getCdRomDirs();
592                 for (i = list; *i != NULL; i++)
593                         con_printf(CON_VERBOSE, "PHYSFS: cdrom dir [%s] is available.\n", *i);
594                 PHYSFS_freeList(list);
595
596                 list = PHYSFS_enumerateFiles("");
597                 for (i = list; *i != NULL; i++)
598                         con_printf(CON_DEBUG, "PHYSFS: * We've got [%s].\n", *i);
599                 PHYSFS_freeList(list);
600         }
601
602         //(re)added Mar 30, 2003 Micah Lieske - Allow use of 22K sound samples again.
603         if(FindArg("-sound22k"))
604         {
605                 digi_sample_rate = SAMPLE_RATE_22K;
606         }
607
608         if(FindArg("-sound11k"))
609         {
610                 digi_sample_rate = SAMPLE_RATE_11K;
611         }
612
613         arch_init_start();
614
615         arch_init();
616
617         //con_printf(CON_VERBOSE, "\n%s...", "Checking for Descent 2 CD-ROM");
618
619         if ((t = FindArg("-rearviewtime")))
620         {
621                 float f = atof(Args[t + 1]);
622                 Rear_view_leave_time = f * f1_0;
623         }
624         con_printf(CON_VERBOSE, "Rear_view_leave_time=0x%x (%f sec)\n", Rear_view_leave_time, Rear_view_leave_time / (float)f1_0);
625
626         //added/edited 8/18/98 by Victor Rachels to set maximum fps <= 100
627         if ((t = FindArg( "-maxfps" ))) {
628                 t=atoi(Args[t+1]);
629                 if (t > 0 && t <= MAX_FPS)
630                         maxfps=t;
631         }
632         //end addition - Victor Rachels
633
634 #ifdef SUPPORTS_NICEFPS
635         if (FindArg("-nicefps"))
636                 use_nice_fps = 1;
637         if (FindArg("-niceautomap"))
638                 nice_automap = 1;
639 #endif
640
641         if (FindArg("-renderstats"))
642                 gr_renderstats = 1;
643
644         if ( FindArg( "-autodemo" ))
645                 Auto_demo = 1;
646
647 #ifndef RELEASE
648         if ( FindArg( "-noscreens" ) )
649                 Skip_briefing_screens = 1;
650 #endif
651
652         if ((t=FindArg("-tmap"))){
653                 select_tmap(Args[t+1]);
654         }else
655                 select_tmap(NULL);
656
657         Lighting_on = 1;
658
659 //      if (init_graphics()) return 1;
660
661         #ifdef EDITOR
662         if (gr_check_mode(SM(800, 600)) != 0)
663         {
664                 con_printf(CON_NORMAL, "The editor will not be available, press any key to start game...\n" );
665                 Function_mode = FMODE_MENU;
666         }
667         #endif
668
669         if (!WVIDEO_running)
670                 con_printf(CON_DEBUG,"WVIDEO_running = %d\n",WVIDEO_running);
671
672         con_printf (CON_VERBOSE, "%s", TXT_VERBOSE_1);
673         ReadConfigFile();
674
675         do_joystick_init();
676
677         if (!VR_offscreen_buffer)       //if hasn't been initialied (by headset init)
678                 set_display_mode(0);            //..then set default display mode
679
680         {
681                 int screen_width = 640;
682                 int screen_height = 480;
683                 int vr_mode = VR_NONE;
684                 int screen_flags = VRF_USE_PAGING;
685
686                 if (FindResArg("", &screen_width, &screen_height))
687                 {
688                         /* stuff below mirrors values from display_mode_info in
689                          * menu.c which is used by set_display_mode. In fact,
690                          * set_display_mode should probably be rewritten to allow
691                          * arbitrary resolutions, and then we get rid of this
692                          * stuff here.
693                          */
694                         switch (SM(screen_width, screen_height))
695                         {
696                         case SM(320, 200):
697                         case SM(640, 480):
698                                 screen_flags = VRF_ALLOW_COCKPIT + VRF_COMPATIBLE_MENUS;
699                                 break;
700                         case SM(320, 400):
701                                 screen_flags = VRF_USE_PAGING;
702                                 break;
703                         case SM(640, 400):
704                         case SM(800, 600):
705                         case SM(1024, 768):
706                         case SM(1280, 1024):
707                                 screen_flags = VRF_COMPATIBLE_MENUS;
708                                 break;
709                         }
710
711                         con_printf(CON_VERBOSE, "Using %ix%i ...\n", screen_width, screen_height);
712                 }
713
714 // added ifdef on 9/30/98 by Matt Mueller to fix high res in linux
715 #ifdef __MSDOS__
716                 if (FindArg("-nodoublebuffer"))
717 #endif
718 // end addition -MM
719                 {
720                         con_printf(CON_VERBOSE, "Double-buffering disabled...\n");
721                         screen_flags &= ~VRF_USE_PAGING;
722                 }
723
724                 // added 3/24/99 by Owen Evans for screen res changing
725                 Game_screen_mode = SM(screen_width, screen_height);
726                 // end added -OE
727                 game_init_render_buffers(Game_screen_mode, screen_width, screen_height, vr_mode, screen_flags);
728
729         }
730         {
731 // added/edited on 12/14/98 by Matt Mueller - override res in d1x.ini with command line args
732                 int i, argnum = INT_MAX, w, h;
733 // added on 9/30/98 by Matt Mueller for selectable automap modes - edited 11/21/99 whee, more fun with defines. - edited 03/31/02 to use new FindResArg.
734 #define SMODE(V,VV,VG) if ((i=FindResArg(#V, &w, &h)) && (i < argnum)) { argnum = i; VV = SM(w, h); VG = 0; }
735 #define SMODE_GR(V,VG) if ((i=FindArg("-" #V "_gameres"))){if (i<argnum) VG=1;}
736 #define SMODE_PRINT(V,VV,VG) if (VG) con_printf(CON_VERBOSE, #V " using game resolution ...\n"); else con_printf(CON_VERBOSE, #V " using %ix%i ...\n",SM_W(VV),SM_H(VV) );
737 // aren't #defines great? :)
738 // end addition/edit -MM
739 #define S_MODE(V,VV,VG) argnum = INT_MAX; SMODE(V, VV, VG); SMODE_GR(V, VG); SMODE_PRINT(V, VV, VG);
740
741                 S_MODE(automap,automap_mode,automap_use_game_res);
742 //              S_MODE(menu,menu_screen_mode,menu_use_game_res);
743          }
744 //end addition -MM
745
746         i = FindArg( "-xcontrol" );
747         if ( i > 0 )    {
748                 kconfig_init_external_controls( strtol(Args[i+1], NULL, 0), strtol(Args[i+2], NULL, 0) );
749         }
750
751         con_printf(CON_VERBOSE, "\n%s\n\n", TXT_INITIALIZING_GRAPHICS);
752         if (FindArg("-nofade"))
753                 grd_fades_disabled=1;
754
755         //determine whether we're using high-res menus & movies
756         if (FindArg("-nohires") || FindArg("-nohighres") || (gr_check_mode(MENU_HIRES_MODE) != 0) || disable_high_res)
757                 MovieHires = MenuHires = MenuHiresAvailable = 0;
758         else
759                 //NOTE LINK TO ABOVE!
760                 MenuHires = MenuHiresAvailable = 1;
761
762         if (FindArg( "-lowresmovies" ))
763                 MovieHires = 0;
764
765         if ((t=gr_init())!=0)                           //doesn't do much
766                 Error(TXT_CANT_INIT_GFX,t);
767
768         // Load the palette stuff. Returns non-zero if error.
769         con_printf(CON_DEBUG, "Initializing palette system...\n" );
770         gr_use_palette_table(DEFAULT_PALETTE );
771
772         con_printf(CON_DEBUG, "Initializing font system...\n" );
773         gamefont_init();        // must load after palette data loaded.
774
775         con_printf( CON_DEBUG, "Initializing movie libraries...\n" );
776         init_movies();          //init movie libraries
777
778 #if 0
779         con_printf(CON_VERBOSE, "Going into graphics mode...\n");
780         gr_set_mode(MovieHires?SM(640,480):SM(320,200));
781 #endif
782
783         if ( FindArg( "-notitles" ) )
784                 songs_play_song( SONG_TITLE, 1);
785         else
786         {
787 #ifndef SHAREWARE
788                 int played=MOVIE_NOT_PLAYED;    //default is not played
789 #endif
790                 int song_playing = 0;
791
792                 #ifdef D2_OEM
793                 #define MOVIE_REQUIRED 0
794                 #else
795                 #define MOVIE_REQUIRED 1
796                 #endif
797
798                 {       //show bundler screens
799                         char filename[FILENAME_LEN];
800
801                         played=MOVIE_NOT_PLAYED;        //default is not played
802
803             played = PlayMovie("pre_i.mve",0);
804
805                         if (!played) {
806                 strcpy(filename,MenuHires?"pre_i1b.pcx":"pre_i1.pcx");
807
808                                 while (PHYSFS_exists(filename))
809                                 {
810                                         show_title_screen( filename, 1, 0 );
811                     filename[5]++;
812                                 }
813                         }
814                 }
815
816                 #ifndef SHAREWARE
817                         init_subtitles("intro.tex");
818                         played = PlayMovie("intro.mve",MOVIE_REQUIRED);
819                         close_subtitles();
820                 #endif
821
822                 if (played != MOVIE_NOT_PLAYED)
823                         intro_played = 1;
824                 else {                                          //didn't get intro movie, try titles
825
826                         played = PlayMovie("titles.mve",MOVIE_REQUIRED);
827
828                         if (played == MOVIE_NOT_PLAYED)
829                         {
830                                 char filename[FILENAME_LEN];
831
832                                 gr_set_mode(MenuHires?SM(640,480):SM(320,200));
833 #ifdef OGL
834                                 set_screen_mode(SCREEN_MENU);
835 #endif
836                                 con_printf( CON_DEBUG, "\nPlaying title song..." );
837                                 songs_play_song( SONG_TITLE, 1);
838                                 song_playing = 1;
839                                 con_printf( CON_DEBUG, "\nShowing logo screens..." );
840
841                                 strcpy(filename, MenuHires?"iplogo1b.pcx":"iplogo1.pcx"); // OEM
842                                 if (! cfexist(filename))
843                                         strcpy(filename, "iplogo1.pcx"); // SHAREWARE
844                                 if (! cfexist(filename))
845                                         strcpy(filename, "mplogo.pcx"); // MAC SHAREWARE
846                                 if (cfexist(filename))
847                                         show_title_screen(filename, 1, 1);
848
849                                 strcpy(filename, MenuHires?"logob.pcx":"logo.pcx"); // OEM
850                                 if (! cfexist(filename))
851                                         strcpy(filename, "logo.pcx"); // SHAREWARE
852                                 if (! cfexist(filename))
853                                         strcpy(filename, "plogo.pcx"); // MAC SHAREWARE
854                                 if (cfexist(filename))
855                                         show_title_screen(filename, 1, 1);
856                         }
857                 }
858
859                 {       //show bundler movie or screens
860
861                         char filename[FILENAME_LEN];
862                         PHYSFS_file *movie_handle;
863
864                         played=MOVIE_NOT_PLAYED;        //default is not played
865
866                         //check if OEM movie exists, so we don't stop the music if it doesn't
867                         movie_handle = PHYSFS_openRead("oem.mve");
868                         if (movie_handle)
869                         {
870                                 PHYSFS_close(movie_handle);
871                                 played = PlayMovie("oem.mve",0);
872                                 song_playing = 0;               //movie will kill sound
873                         }
874
875                         if (!played) {
876                                 strcpy(filename,MenuHires?"oem1b.pcx":"oem1.pcx");
877
878                                 while (PHYSFS_exists(filename))
879                                 {
880                                         show_title_screen( filename, 1, 0 );
881                                         filename[3]++;
882                                 }
883                         }
884                 }
885
886                 if (!song_playing)
887                         songs_play_song( SONG_TITLE, 1);
888                         
889         }
890
891         con_printf( CON_DEBUG, "\nShowing loading screen..." );
892         {
893                 //grs_bitmap title_bm;
894                 int pcx_error;
895                 char filename[14];
896
897                 strcpy(filename, MenuHires?"descentb.pcx":"descent.pcx");
898                 if (! cfexist(filename))
899                         strcpy(filename, MenuHires?"descntob.pcx":"descento.pcx"); // OEM
900                 if (! cfexist(filename))
901                         strcpy(filename, "descentd.pcx"); // SHAREWARE
902                 if (! cfexist(filename))
903                         strcpy(filename, "descentb.pcx"); // MAC SHAREWARE
904
905                 gr_set_mode(MenuHires?SM(640,480):SM(320,200));
906 #ifdef OGL
907                 set_screen_mode(SCREEN_MENU);
908 #endif
909
910                 FontHires = FontHiresAvailable && MenuHires;
911
912                 if ((pcx_error=pcx_read_fullscr( filename, title_pal ))==PCX_ERROR_NONE)        {
913                         //vfx_set_palette_sub( title_pal );
914                         gr_palette_clear();
915                         gr_palette_fade_in( title_pal, 32, 0 );
916                         gr_update();
917                 } else
918                         Error( "Couldn't load pcx file '%s', PCX load error: %s\n",filename, pcx_errormsg(pcx_error));
919         }
920
921         con_printf( CON_DEBUG , "\nDoing bm_init..." );
922         #ifdef EDITOR
923         if (!bm_init_use_tbl())
924         #endif
925                 bm_init();
926
927         #ifdef EDITOR
928         if (FindArg("-hoarddata") != 0) {
929                 #define MAX_BITMAPS_PER_BRUSH 30
930                 grs_bitmap * bm[MAX_BITMAPS_PER_BRUSH];
931                 grs_bitmap icon;
932                 int nframes;
933                 ubyte palette[256*3];
934                 PHYSFS_file *ofile;
935                 int iff_error,i;
936                 char *sounds[] = {"selforb.raw","selforb.r22",          //SOUND_YOU_GOT_ORB                     
937                                                                 "teamorb.raw","teamorb.r22",            //SOUND_FRIEND_GOT_ORB                  
938                                                                 "enemyorb.raw","enemyorb.r22",  //SOUND_OPPONENT_GOT_ORB        
939                                                                 "OPSCORE1.raw","OPSCORE1.r22"}; //SOUND_OPPONENT_HAS_SCORED
940
941                 ofile = PHYSFSX_openWriteBuffered("hoard.ham");
942
943            iff_error = iff_read_animbrush("orb.abm",bm,MAX_BITMAPS_PER_BRUSH,&nframes,palette);
944                 Assert(iff_error == IFF_NO_ERROR);
945                 PHYSFS_writeULE16(ofile, nframes);
946                 PHYSFS_writeULE16(ofile, bm[0]->bm_w);
947                 PHYSFS_writeULE16(ofile, bm[0]->bm_h);
948                 PHYSFS_write(ofile, palette, 3, 256);
949                 for (i=0;i<nframes;i++)
950                         PHYSFS_write(ofile, bm[i]->bm_data, bm[i]->bm_w*bm[i]->bm_h, 1);
951
952                 iff_error = iff_read_animbrush("orbgoal.abm",bm,MAX_BITMAPS_PER_BRUSH,&nframes,palette);
953                 Assert(iff_error == IFF_NO_ERROR);
954                 Assert(bm[0]->bm_w == 64 && bm[0]->bm_h == 64);
955                 PHYSFS_writeULE16(ofile, nframes);
956                 PHYSFS_write(ofile, palette, 3, 256);
957                 for (i=0;i<nframes;i++)
958                         PHYSFS_write(ofile, bm[i]->bm_data, bm[i]->bm_w*bm[i]->bm_h, 1);
959
960                 for (i=0;i<2;i++) {
961                         iff_error = iff_read_bitmap(i?"orbb.bbm":"orb.bbm",&icon,BM_LINEAR,palette);
962                         Assert(iff_error == IFF_NO_ERROR);
963                         PHYSFS_writeULE16(ofile, icon.bm_w);
964                         PHYSFS_writeULE16(ofile, icon.bm_h);
965                         PHYSFS_write(ofile, palette, 3, 256);
966                         PHYSFS_write(ofile, icon.bm_data, icon.bm_w*icon.bm_h, 1);
967                 }
968
969                 for (i=0;i<sizeof(sounds)/sizeof(*sounds);i++) {
970                         PHYSFS_file *ifile;
971                         int size;
972                         ubyte *buf;
973
974                         ifile = PHYSFS_openRead(sounds[i]);
975                         Assert(ifile != NULL);
976                         size = PHYSFS_fileLength(ifile);
977                         buf = d_malloc(size);
978                         PHYSFS_read(ifile, buf, size, 1);
979                         PHYSFS_writeULE32(ofile, size);
980                         PHYSFS_write(ofile, buf, size, 1);
981                         d_free(buf);
982                         PHYSFS_close(ifile);
983                 }
984
985                 PHYSFS_close(ofile);
986
987                 exit(1);
988         }
989         #endif
990
991         //the bitmap loading code changes gr_palette, so restore it
992         memcpy(gr_palette,title_pal,sizeof(gr_palette));
993
994         if ( FindArg( "-norun" ) )
995                 return(0);
996
997         con_printf( CON_DEBUG, "\nInitializing 3d system..." );
998         g3_init();
999
1000         con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
1001         texmerge_init( 10 );            // 10 cache bitmaps
1002
1003         con_printf( CON_DEBUG, "\nRunning game...\n" );
1004         set_screen_mode(SCREEN_MENU);
1005
1006         init_game();
1007
1008         //      If built with editor, option to auto-load a level and quit game
1009         //      to write certain data.
1010         #ifdef  EDITOR
1011         {       int t;
1012         if ( (t = FindArg( "-autoload" )) ) {
1013                 Auto_exit = 1;
1014                 strcpy(Auto_file, Args[t+1]);
1015         }
1016                 
1017         }
1018
1019         if (Auto_exit) {
1020                 strcpy(Players[0].callsign, "dummy");
1021         } else
1022         #endif
1023                 do_register_player(title_pal);
1024
1025         gr_palette_fade_out( title_pal, 32, 0 );
1026
1027         Game_mode = GM_GAME_OVER;
1028
1029         if (Auto_demo)  {
1030                 newdemo_start_playback("descent.dem");          
1031                 if (Newdemo_state == ND_STATE_PLAYBACK )
1032                         Function_mode = FMODE_GAME;
1033         }
1034
1035         //do this here because the demo code can do a longjmp when trying to
1036         //autostart a demo from the main menu, never having gone into the game
1037         setjmp(LeaveGame);
1038
1039         while (Function_mode != FMODE_EXIT)
1040         {
1041                 switch( Function_mode ) {
1042                 case FMODE_MENU:
1043                         set_screen_mode(SCREEN_MENU);
1044                         if ( Auto_demo )        {
1045                                 newdemo_start_playback(NULL);           // Randomly pick a file
1046                                 if (Newdemo_state != ND_STATE_PLAYBACK) 
1047                                         Error("No demo files were found for autodemo mode!");
1048                         } else {
1049                                 #ifdef EDITOR
1050                                 if (Auto_exit) {
1051                                         strcpy((char *)&Level_names[0], Auto_file);
1052                                         LoadLevel(1, 1);
1053                                         Function_mode = FMODE_EXIT;
1054                                         break;
1055                                 }
1056                                 #endif
1057
1058                                 check_joystick_calibration();
1059                                 gr_palette_clear();             //I'm not sure why we need this, but we do
1060                                 DoMenu();                                                                               
1061                                 #ifdef EDITOR
1062                                 if ( Function_mode == FMODE_EDITOR )    {
1063                                         create_new_mine();
1064                                         SetPlayerFromCurseg();
1065                                         load_palette(NULL,1,0);
1066                                 }
1067                                 #endif
1068                         }
1069                         break;
1070                 case FMODE_GAME:
1071                         #ifdef EDITOR
1072                                 keyd_editor_mode = 0;
1073                         #endif
1074
1075 #ifdef SDL_INPUT
1076                         /* keep the mouse from wandering in SDL */
1077                         if (FindArg("-grabmouse"))
1078                             SDL_WM_GrabInput(SDL_GRAB_ON);
1079 #endif
1080
1081                         game();
1082
1083 #ifdef SDL_INPUT
1084                         /* give control back to the WM */
1085                         if (FindArg("-grabmouse"))
1086                             SDL_WM_GrabInput(SDL_GRAB_OFF);
1087 #endif
1088
1089                         if ( Function_mode == FMODE_MENU )
1090                                 songs_play_song( SONG_TITLE, 1 );
1091                         break;
1092                 #ifdef EDITOR
1093                 case FMODE_EDITOR:
1094                         keyd_editor_mode = 1;
1095                         editor();
1096 #ifdef __WATCOMC__
1097                         _harderr( (void*)descent_critical_error_handler );              // Reinstall game error handler
1098 #endif
1099                         if ( Function_mode == FMODE_GAME ) {
1100                                 Game_mode = GM_EDITOR;
1101                                 editor_reset_stuff_on_level();
1102                                 N_players = 1;
1103                         }
1104                         break;
1105                 #endif
1106                 default:
1107                         Error("Invalid function mode %d",Function_mode);
1108                 }
1109         }
1110
1111         WriteConfigFile();
1112
1113         if (!FindArg( "-notitles" ))
1114                 show_order_form();
1115
1116         #ifndef NDEBUG
1117         if ( FindArg( "-showmeminfo" ) )
1118                 show_mem_info = 1;              // Make memory statistics show
1119         #endif
1120
1121         return(0);              //presumably successful exit
1122 }
1123
1124
1125 void check_joystick_calibration()       {
1126         int x1, y1, x2, y2, c;
1127         fix t1;
1128
1129         if ( (Config_control_type!=CONTROL_JOYSTICK) &&
1130                   (Config_control_type!=CONTROL_FLIGHTSTICK_PRO) &&
1131                   (Config_control_type!=CONTROL_THRUSTMASTER_FCS) &&
1132                   (Config_control_type!=CONTROL_GRAVIS_GAMEPAD)
1133                 ) return;
1134
1135         joy_get_pos( &x1, &y1 );
1136
1137         t1 = timer_get_fixed_seconds();
1138         while( timer_get_fixed_seconds() < t1 + F1_0/100 )
1139                 ;
1140
1141         joy_get_pos( &x2, &y2 );
1142
1143         // If joystick hasn't moved...
1144         if ( (abs(x2-x1)<30) &&  (abs(y2-y1)<30) )      {
1145                 if ( (abs(x1)>30) || (abs(x2)>30) ||  (abs(y1)>30) || (abs(y2)>30) )    {
1146                         c = nm_messagebox( NULL, 2, TXT_CALIBRATE, TXT_SKIP, TXT_JOYSTICK_NOT_CEN );
1147                         if ( c==0 )     {
1148                                 joydefs_calibrate();
1149                         }
1150                 }
1151         }
1152
1153 }
1154
1155 void show_order_form()
1156 {
1157 #ifndef EDITOR
1158
1159         int pcx_error;
1160         unsigned char title_pal[768];
1161         char    exit_screen[16];
1162
1163         gr_set_current_canvas( NULL );
1164         gr_palette_clear();
1165
1166         key_flush();
1167
1168         strcpy(exit_screen, MenuHires?"ordrd2ob.pcx":"ordrd2o.pcx"); // OEM
1169         if (! cfexist(exit_screen))
1170                 strcpy(exit_screen, MenuHires?"orderd2b.pcx":"orderd2.pcx"); // SHAREWARE, prefer mac if hires
1171         if (! cfexist(exit_screen))
1172                 strcpy(exit_screen, MenuHires?"orderd2.pcx":"orderd2b.pcx"); // SHAREWARE, have to rescale
1173         if (! cfexist(exit_screen))
1174                 strcpy(exit_screen, MenuHires?"warningb.pcx":"warning.pcx"); // D1
1175         if (! cfexist(exit_screen))
1176                 return; // D2 registered
1177
1178         if ((pcx_error=pcx_read_fullscr( exit_screen, title_pal ))==PCX_ERROR_NONE) {
1179                 //vfx_set_palette_sub( title_pal );
1180                 gr_palette_fade_in( title_pal, 32, 0 );
1181                 gr_update();
1182                 while (!key_inkey() && !mouse_button_state(0)) {} //key_getch();
1183                 gr_palette_fade_out( title_pal, 32, 0 );
1184         }
1185         else
1186                 Int3();         //can't load order screen
1187
1188         key_flush();
1189
1190 #endif
1191 }
1192
1193 void quit_request()
1194 {
1195 #ifdef NETWORK
1196 //      void network_abort_game();
1197 //      if(Network_status)
1198 //              network_abort_game();
1199 #endif
1200         exit(0);
1201 }