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