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