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.
16 * inferno.c: Entry point of program (main procedure)
18 * After main initializes everything, most of the time is spent in the loop
19 * while (Function_mode != FMODE_EXIT)
20 * In this loop, the main menu is brought up first.
30 char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPORATION";
40 #include <sys/types.h>
64 // # include "3dfx_des.h"
65 #include "../texmap/scanline.h" //for select_tmap -MM
67 #include "editor/editor.h"
74 void arch_init_start(void);
76 //Current version number
78 ubyte Version_major = 1; //FULL VERSION
79 ubyte Version_minor = 2;
81 //static const char desc_id_checksum_str[] = DESC_ID_CHKSUM_TAG "0000"; // 4-byte checksum
82 char desc_id_exit_num = 0;
84 int Function_mode=FMODE_MENU; //game or editor?
85 int Screen_mode=-1; //game screen or editor screen?
87 //--unused-- grs_bitmap Inferno_bitmap_title;
89 int WVIDEO_running=0; //debugger can set to 1 if running
92 int __far descent_critical_error_handler( unsigned deverr, unsigned errcode, unsigned __far * devhdr );
95 void check_joystick_calibration(void);
97 //--------------------------------------------------------------------------
99 extern int piggy_low_memory;
102 int descent_critical_error = 0;
103 unsigned descent_critical_deverror = 0;
104 unsigned descent_critical_errcode = 0;
106 extern int Network_allow_socket_changes;
108 extern void vfx_set_palette_sub(ubyte *);
110 extern int VR_low_res;
114 //read help from a file & print to screen
115 void print_commandline_help()
121 ifile = cfopen("help.tex","rb");
123 ifile = cfopen("help.txb","rb");
125 Warning("Cannot load help text file.");
133 while ((end = cfgets(line,LINE_LEN,ifile))) {
136 decode_text_line (line);
138 // This is the only use of cfgets that needs the CR
142 continue; //don't show comments
152 // printf( " Diagnostic:\n\n");
153 // printf( " -emul %s\n", "Certain video cards need this option in order to run game");
154 // printf( " -ddemul %s\n", "If -emul doesn't work, use this option");
157 printf( " Editor Options:\n\n");
158 printf( " -autoload <file>%s\n", "Autoload a level in the editor");
159 printf( " -hoarddata %s\n","Make the hoard ham file from some files, then exit");
160 // printf( " -nobm %s\n","FIXME: Undocumented");
163 printf( " D2X Options:\n\n");
164 printf( " -noredundancy %s\n", "Do not send messages when picking up redundant items in multi");
165 printf( " -shortpackets %s\n", "Set shortpackets to default as on");
166 #ifdef OGL // currently only does anything on ogl build, so don't advertise othewise.
167 printf(" -renderstats %s\n", "Enable renderstats info by default");
169 printf( " -maxfps <n> %s\n", "Set maximum framerate (1-100)");
170 printf( " -notitles %s\n", "Do not show titlescreens on startup");
171 printf( " -hogdir <dir> %s\n", "set shared data directory to <dir>");
173 printf( " -nohogdir %s\n", "don't try to use shared data directory");
174 printf( " -userdir <dir> %s\n", "set user dir to <dir> instead of $HOME/.d2x");
176 printf( " -autoexec <file> %s\n", "autoexec file (execute console commands), defaults to autoexec.cfg");
177 printf( " -ini <file> %s\n", "option file (alternate to command line), defaults to d2x.ini");
178 printf( " -autodemo %s\n", "Start in demo mode");
179 printf( " -bigpig %s\n","FIXME: Undocumented");
180 printf( " -bspgen %s\n","FIXME: Undocumented");
181 // printf( " -cdproxy %s\n","FIXME: Undocumented");
183 printf( " -checktime %s\n","FIXME: Undocumented");
184 printf( " -showmeminfo %s\n","FIXME: Undocumented");
186 // printf( " -codereadonly %s\n","FIXME: Undocumented");
187 // printf( " -cyberimpact %s\n","FIXME: Undocumented");
188 printf( " -debug %s\n","Enable very verbose output");
189 // printf( " -debugmode %s\n","FIXME: Undocumented");
190 // printf( " -disallowgfx %s\n","FIXME: Undocumented");
191 // printf( " -disallowreboot %s\n","FIXME: Undocumented");
192 // printf( " -dynamicsockets %s\n","FIXME: Undocumented");
193 // printf( " -forcegfx %s\n","FIXME: Undocumented");
194 // printf( " -hw_3dacc %s\n","FIXME: Undocumented");
196 printf( " -invulnerability %s\n","Make yourself invulnerable");
198 printf( " -ipxnetwork <num> %s\n","Use IPX network number <num>");
199 printf( " -jasen %s\n","FIXME: Undocumented");
200 printf( " -joyslow %s\n","FIXME: Undocumented");
202 printf( " -kali %s\n","use Kali for networking");
204 // printf( " -logfile %s\n","FIXME: Undocumented");
205 printf( " -lowresmovies %s\n","Play low resolution movies if available (for slow machines)");
206 #if defined(EDITOR) || !defined(MACDATA)
207 printf( " -macdata %s\n","Read (and, for editor, write) mac data files (swap colors)");
209 // printf( " -memdbg %s\n","FIXME: Undocumented");
210 // printf( " -monodebug %s\n","FIXME: Undocumented");
211 printf( " -nocdrom %s\n","FIXME: Undocumented");
213 printf( " -nofade %s\n","Disable fades");
216 printf( " -nomatrixcheat %s\n","FIXME: Undocumented");
217 printf( " -norankings %s\n","Disable multiplayer ranking system");
218 printf( " -packets <num> %s\n","Specifies the number of packets per second\n");
219 // printf( " -showaddress %s\n","FIXME: Undocumented");
220 printf( " -socket %s\n","FIXME: Undocumented");
222 #if !defined(MACINTOSH) && !defined(WINDOWS)
223 printf( " -nomixer %s\n","Don't crank music volume");
225 // printf( " -nomodex %s\n","FIXME: Undocumented");
227 printf( " -nomovies %s\n","Don't play movies");
228 printf( " -noscreens %s\n","Skip briefing screens");
230 printf( " -noredbook %s\n","Disable redbook audio");
231 printf( " -norun %s\n","Bail out after initialization");
232 // printf( " -ordinaljoy %s\n","FIXME: Undocumented");
233 // printf( " -rtscts %s\n","Same as -ctsrts");
234 // printf( " -semiwin %s\n","Use non-fullscreen mode");
235 // printf( " -specialdevice %s\n","FIXME: Undocumented");
237 printf( " -stickmag %s\n","FIXME: Undocumented");
239 // printf( " -stopwatch %s\n","FIXME: Undocumented");
240 printf( " -subtitles %s\n","Turn on movie subtitles (English-only)");
241 // printf( " -sysram %s\n","FIXME: Undocumented");
242 printf( " -text <file> %s\n","Specify alternate .tex file");
243 // printf( " -tsengdebug1 %s\n","FIXME: Undocumented");
244 // printf( " -tsengdebug2 %s\n","FIXME: Undocumented");
245 // printf( " -tsengdebug3 %s\n","FIXME: Undocumented");
246 // printf( " -vidram %s\n","FIXME: Undocumented");
247 printf( " -tmap <t> %s\n","select texmapper to use (c,fp,i386,pent,ppro)");
249 printf( " -<X>x<Y> %s\n", "Change screen resolution. Options:");
250 printf( " 320x100;320x200;320x240;320x400;640x400;640x480;800x600;1024x768\n");
252 printf( " -<X>x<Y> %s\n", "Change screen resolution to <X> by <Y>");
254 printf(" -niceautomap %s\n", "Free cpu while doing automap");
255 printf( " -automap<X>x<Y> %s\n","Set automap resolution to <X> by <Y>");
256 printf( " -automap_gameres %s\n","Set automap to use the same resolution as in game");
257 // printf( " -menu<X>x<Y> %s\n","Set menu resolution to <X> by <Y>");
258 printf( " -menu_gameres %s\n","Set menus to use the same resolution as in game");
259 printf(" -rearviewtime t %s\n", "time holding rearview key to use toggle mode (default 0.0625 seconds)");
262 printf( "D2X System Options:\n\n");
264 printf(" -ihaveabrokenmouse %s\n", "try to make mouse work if it is not currently");
265 printf( " -joy209 %s\n", "Use alternate port 209 for joystick");
267 #ifdef VID_SUPPORTS_FULLSCREEN_TOGGLE
268 printf( " -fullscreen %s\n", "Use fullscreen mode if available");
271 printf( " -gl_texmagfilt <f> %s\n","set GL_TEXTURE_MAG_FILTER (see readme.d1x)");
272 printf( " -gl_texminfilt <f> %s\n","set GL_TEXTURE_MIN_FILTER (see readme.d1x)");
273 printf(" -gl_mipmap %s\n", "set gl texture filters to \"standard\" (bilinear) mipmapping");
274 printf(" -gl_trilinear %s\n", "set gl texture filters to trilinear mipmapping");
275 printf( " -gl_simple %s\n","set gl texture filters to gl_nearest for \"original\" look. (default)");
276 printf(" -gl_anisotropy <f> %s\n", "set maximum degree of anisotropy to <f>");
277 printf( " -gl_alttexmerge %s\n","use new texmerge, usually uses less ram (default)");
278 printf( " -gl_stdtexmerge %s\n","use old texmerge, uses more ram, but _might_ be a bit faster");
279 #ifdef VID_SUPPORTS_FULLSCREEN_TOGGLE
280 printf( " -gl_voodoo %s\n","force fullscreen mode only");
282 printf( " -gl_16bittextures %s\n","attempt to use 16bit textures");
283 printf(" -gl_16bpp %s\n", "attempt to use 16bit screen mode");
284 printf( " -gl_reticle <r> %s\n","use OGL reticle 0=never 1=above 320x* 2=always");
285 printf( " -gl_intensity4_ok %s\n","FIXME: Undocumented");
286 printf( " -gl_luminance4_alpha4_ok %s\n","FIXME: Undocumented");
287 printf( " -gl_readpixels_ok %s\n","FIXME: Undocumented");
288 printf( " -gl_rgba2_ok %s\n","FIXME: Undocumented");
289 // printf( " -gl_test1 %s\n","FIXME: Undocumented");
290 printf( " -gl_test2 %s\n","FIXME: Undocumented");
291 printf( " -gl_vidmem %s\n","FIXME: Undocumented");
292 #ifdef OGL_RUNTIME_LOAD
293 printf( " -gl_library <l> %s\n","use alternate opengl library");
296 printf(" -gl_refresh <r> %s\n", "set refresh rate (in fullscreen mode)");
300 printf( " -nosdlvidmodecheck %s\n", "Some X servers don't like checking vidmode first, so just switch");
301 printf( " -hwsurface %s\n","FIXME: Undocumented");
304 printf(" -udp %s\n", "Specify options for udp/ip:");
305 printf(" @<shift> %s\n", " shift udp port base offset");
306 printf(" =<HOST_LIST> %s\n", " broadcast both local and to HOST_LIST");
307 printf(" +<HOST_LIST> %s\n", " broadcast only to HOST_LIST");
308 printf(" %s\n", " HOSTS can be any IP or hostname")
310 printf(" %s\n", " HOSTS can also be in the form of <address>:<shift>");
311 printf(" %s\n", " separate multiple HOSTS with a ,");
314 printf( " -serialdevice <s> %s\n", "Set serial/modem device to <s>");
315 printf( " -serialread <r> %s\n", "Set serial/modem to read from <r>");
317 printf( "\n Help:\n\n");
318 printf( " -help, -h, -?, ? %s\n", "View this help screen");
322 void do_joystick_init()
325 if (!FindArg( "-nojoystick" )) {
326 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_6);
328 if ( FindArg( "-joyslow" )) {
329 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_7);
330 joy_set_slow_reading(JOY_SLOW_READINGS);
332 if ( FindArg( "-joypolled" )) {
333 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_8);
334 joy_set_slow_reading(JOY_POLLED_READINGS);
336 if ( FindArg( "-joybios" )) {
337 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_9);
338 joy_set_slow_reading(JOY_BIOS_READINGS);
341 // Added from Descent v1.5 by John. Adapted by Samir.
343 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_10);
347 //set this to force game to run in low res
348 int disable_high_res=0;
350 void do_register_player(ubyte *title_pal)
352 strncpy( Players[Player_num].callsign, config_last_player.string, CALLSIGN_LEN );
353 if (strlen(Players[Player_num].callsign))
360 //now, before we bring up the register player menu, we need to
361 //do some stuff to make sure the palette is ok. First, we need to
362 //get our current palette into the 2d's array, so the remapping will
363 //work. Second, we need to remap the fonts. Third, we need to fill
364 //in part of the fade tables so the darkening of the menu edges works
367 memcpy(gr_palette,title_pal,sizeof(gr_palette));
369 remap_fonts_and_menus(1);
370 RegisterPlayer(); //get player's name
375 #define PROGNAME argv[0]
377 extern char Language[];
379 //can we do highres menus?
380 extern int MenuHiresAvailable;
382 int Inferno_verbose = 0;
384 //added on 11/18/98 by Victor Rachels to add -mission and -startgame
385 int start_net_immediately = 0;
386 //int start_with_mission = 0;
387 //char *start_with_mission_name;
388 //end this section addition
390 #define MENU_HIRES_MODE SM(640,480)
392 // DESCENT II by Parallax Software
395 //extern ubyte gr_current_pal[];
399 char Auto_file[128] = "";
402 int main(int argc, char *argv[])
405 ubyte title_pal[768];
408 CON_Init(); // Initialise the console
410 error_init(NULL, NULL);
411 PHYSFSX_init(argc, argv);
413 if (FindArg("-debug"))
414 cvar_setint( &con_threshold, CON_DEBUG );
415 else if (FindArg("-verbose"))
416 cvar_setint( &con_threshold, CON_VERBOSE );
418 if (! cfile_init("descent2.hog"))
419 if (! cfile_init("d2demo.hog"))
420 Warning("Could not find a valid hog file (descent2.hog or d2demo.hog)\nPossible locations are:\n"
425 "\tCurrent directory\n"
427 "Or use the -hogdir option to specify an alternate location.");
430 //print out the banner title
431 con_printf(CON_NORMAL, "\nDESCENT 2 %s v%d.%d",VERSION_TYPE,Version_major,Version_minor);
433 con_printf(CON_NORMAL, " %s", VERSION_NAME);
435 if (cfexist(MISSION_DIR "d2x.hog"))
436 con_printf(CON_NORMAL, " Vertigo Enhanced");
438 con_printf(CON_NORMAL, " %s %s\n", __DATE__,__TIME__);
439 con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
440 con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2. Copyright (c) 1999 Peter Hawkins\n");
441 con_printf(CON_NORMAL, " Copyright (c) 2002 Bradley Bell\n");
444 if (FindArg( "-?" ) || FindArg( "-help" ) || FindArg( "?" ) || FindArg( "-h" ) ) {
445 print_commandline_help();
446 set_exit_message("");
448 exit(0); /* mingw hangs on this return. dunno why */
453 con_printf(CON_NORMAL, "\n");
454 con_printf(CON_NORMAL, TXT_HELP, PROGNAME); //help message has %s for program name
455 con_printf(CON_NORMAL, "\n");
460 for (i = PHYSFS_getSearchPath(); *i != NULL; i++)
461 con_printf(CON_VERBOSE, "PHYSFS: [%s] is in the search path.\n", *i);
463 list = PHYSFS_getCdRomDirs();
464 for (i = list; *i != NULL; i++)
465 con_printf(CON_VERBOSE, "PHYSFS: cdrom dir [%s] is available.\n", *i);
466 PHYSFS_freeList(list);
468 list = PHYSFS_enumerateFiles("");
469 for (i = list; *i != NULL; i++)
470 con_printf(CON_DEBUG, "PHYSFS: * We've got [%s].\n", *i);
471 PHYSFS_freeList(list);
474 //(re)added Mar 30, 2003 Micah Lieske - Allow use of 22K sound samples again.
475 if(FindArg("-sound22k"))
477 digi_sample_rate = SAMPLE_RATE_22K;
480 if(FindArg("-sound11k"))
482 digi_sample_rate = SAMPLE_RATE_11K;
489 //con_printf(CON_VERBOSE, "\n%s...", "Checking for Descent 2 CD-ROM");
491 if ((t = FindArg("-rearviewtime")))
493 float f = atof(Args[t + 1]);
494 Rear_view_leave_time = f * f1_0;
496 con_printf(CON_VERBOSE, "Rear_view_leave_time=0x%x (%f sec)\n", Rear_view_leave_time, Rear_view_leave_time / (float)f1_0);
498 //added/edited 8/18/98 by Victor Rachels to set maximum fps <= 100
499 if ((t = FindArg( "-maxfps" ))) {
501 if (t > 0 && t <= MAX_FPS)
504 //end addition - Victor Rachels
506 #ifdef SUPPORTS_NICEFPS
507 if (FindArg("-nicefps"))
509 if (FindArg("-niceautomap"))
513 if (FindArg("-renderstats"))
516 if ( FindArg( "-autodemo" ))
520 if ( FindArg( "-noscreens" ) )
521 Skip_briefing_screens = 1;
524 if ((t=FindArg("-tmap"))){
525 select_tmap(Args[t+1]);
535 if (vid_check_mode(SM(800, 600)) != 0) {
536 con_printf(CON_NORMAL, "The editor will not be available, press any key to start game...\n" );
537 Function_mode = FMODE_MENU;
542 con_printf(CON_DEBUG,"WVIDEO_running = %d\n",WVIDEO_running);
546 if ((t = gr_init()) != 0) // doesn't do much
547 Error(TXT_CANT_INIT_GFX, t);
549 con_printf (CON_VERBOSE, "%s", TXT_VERBOSE_1);
552 if (!VR_offscreen_buffer) //if hasn't been initialied (by headset init)
553 set_display_mode(Default_display_mode); //..then set default display mode
556 int screen_width = 0;
557 int screen_height = 0;
559 FindResArg("", &screen_width, &screen_height);
561 if (screen_width && screen_height)
562 set_display_mode(SM(screen_width, screen_height));
565 // added/edited on 12/14/98 by Matt Mueller - override res in d1x.ini with command line args
566 int i, argnum = INT_MAX, w, h;
567 // added on 9/30/98 by Matt Mueller for selectable automap modes - edited 11/21/99 whee, more fun with defines. - edited 03/31/02 to use new FindResArg.
568 #define SMODE(V,VV,VG) if ((i=FindResArg(#V, &w, &h)) && (i < argnum)) { argnum = i; VV = SM(w, h); VG = 0; }
569 #define SMODE_GR(V,VG) if ((i=FindArg("-" #V "_gameres"))){if (i<argnum) VG=1;}
570 #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) );
571 // aren't #defines great? :)
572 // end addition/edit -MM
573 #define S_MODE(V,VV,VG) argnum = INT_MAX; SMODE(V, VV, VG); SMODE_GR(V, VG); SMODE_PRINT(V, VV, VG);
575 S_MODE(automap,automap_mode,automap_use_game_res);
576 // S_MODE(menu,menu_screen_mode,menu_use_game_res);
577 cvar_registervariable(&menu_use_game_res);
578 if ((i = FindArg("-menu_gameres"))) { if (i < argnum) cvar_setint(&menu_use_game_res, 1); }
584 con_printf(CON_VERBOSE, "\n%s\n\n", TXT_INITIALIZING_GRAPHICS);
585 if (FindArg("-nofade"))
586 grd_fades_disabled=1;
588 //determine whether we're using high-res menus & movies
589 if (FindArg("-nohires") || FindArg("-nohighres") || (vid_check_mode(MENU_HIRES_MODE) != 0) || disable_high_res)
590 cvar_setint( &MovieHires, MenuHires = MenuHiresAvailable = 0 );
592 //NOTE LINK TO ABOVE!
593 MenuHires = MenuHiresAvailable = 1;
595 if (FindArg( "-lowresmovies" ))
596 cvar_setint( &MovieHires, 0 );
598 con_printf(CON_VERBOSE, "Going into graphics mode...\n");
599 vid_set_mode(MOVIE_SCREEN_MODE);
601 // Load the palette stuff. Returns non-zero if error.
602 con_printf(CON_DEBUG, "Initializing palette system...\n" );
603 gr_use_palette_table(DEFAULT_PALETTE );
605 con_printf(CON_DEBUG, "Initializing font system...\n" );
606 gamefont_init(); // must load after palette data loaded.
608 con_printf( CON_DEBUG, "Initializing movie libraries...\n" );
609 init_movies(); //init movie libraries
611 if ( FindArg( "-notitles" ) )
612 songs_play_song( SONG_TITLE, 1);
616 con_printf( CON_DEBUG, "\nShowing loading screen..." );
617 show_loading_screen(title_pal); // title_pal is needed (see below)
619 CON_InitGFX(SWIDTH, SHEIGHT / 2);
621 con_printf( CON_DEBUG , "\nDoing bm_init..." );
623 if (!bm_init_use_tbl())
628 if (FindArg("-hoarddata") != 0)
635 //the bitmap loading code changes gr_palette, so restore it
636 memcpy(gr_palette,title_pal,sizeof(gr_palette));
638 if ( FindArg( "-norun" ) )
641 con_printf( CON_DEBUG, "\nInitializing 3d system..." );
644 con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
645 texmerge_init( 10 ); // 10 cache bitmaps
647 con_printf( CON_DEBUG, "\nRunning game...\n" );
648 set_screen_mode(SCREEN_MENU);
652 remap_fonts_and_menus(1);
654 if ((t = FindArg("-autoexec")))
655 cmd_appendf("exec %s", Args[t+1]);
656 else if (cfexist("autoexec.cfg"))
657 cmd_append("exec autoexec.cfg");
661 // If built with editor, option to auto-load a level and quit game
662 // to write certain data.
665 if ( (t = FindArg( "-autoload" )) ) {
667 strcpy(Auto_file, Args[t+1]);
673 strcpy(Players[0].callsign, "dummy");
676 if (!strlen(Players[0].callsign))
677 do_register_player(title_pal);
679 Game_mode = GM_GAME_OVER;
682 newdemo_start_playback("descent.dem");
683 if (Newdemo_state == ND_STATE_PLAYBACK )
684 Function_mode = FMODE_GAME;
687 //do this here because the demo code can do a longjmp when trying to
688 //autostart a demo from the main menu, never having gone into the game
691 remap_fonts_and_menus(1);
693 while (Function_mode != FMODE_EXIT)
697 switch( Function_mode ) {
699 set_screen_mode(SCREEN_MENU);
701 newdemo_start_playback(NULL); // Randomly pick a file
702 if (Newdemo_state != ND_STATE_PLAYBACK)
703 Error("No demo files were found for autodemo mode!");
707 strcpy((char *)&Level_names[0], Auto_file);
709 Function_mode = FMODE_EXIT;
714 check_joystick_calibration();
715 gr_palette_clear(); //I'm not sure why we need this, but we do
718 if ( Function_mode == FMODE_EDITOR ) {
720 SetPlayerFromCurseg();
721 load_palette(NULL,1,0);
728 keyd_editor_mode = 0;
733 if ( Function_mode == FMODE_MENU )
734 songs_play_song( SONG_TITLE, 1 );
738 keyd_editor_mode = 1;
741 _harderr( (void*)descent_critical_error_handler ); // Reinstall game error handler
743 if ( Function_mode == FMODE_GAME ) {
744 Game_mode = GM_EDITOR;
745 editor_reset_stuff_on_level();
751 Error("Invalid function mode %d",Function_mode);
757 if (!FindArg( "-notitles" ))
761 if ( FindArg( "-showmeminfo" ) )
762 show_mem_info = 1; // Make memory statistics show
765 return(0); //presumably successful exit
769 void check_joystick_calibration() {
770 int x1, y1, x2, y2, c;
773 if ( !Config_control_joystick.intval )
776 joy_get_pos( &x1, &y1 );
778 t1 = timer_get_fixed_seconds();
779 while( timer_get_fixed_seconds() < t1 + F1_0/100 )
782 joy_get_pos( &x2, &y2 );
784 // If joystick hasn't moved...
785 if ( (abs(x2-x1)<30) && (abs(y2-y1)<30) ) {
786 if ( (abs(x1)>30) || (abs(x2)>30) || (abs(y1)>30) || (abs(y2)>30) ) {
787 c = nm_messagebox( NULL, 2, TXT_CALIBRATE, TXT_SKIP, TXT_JOYSTICK_NOT_CEN );
799 // void network_abort_game();
800 // if(Network_status)
801 // network_abort_game();