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