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