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>
59 #include "segment.h" //for Side_to_verts
97 // # include "3dfx_des.h"
99 //added on 9/30/98 by Matt Mueller for selectable automap modes
103 #include "../texmap/scanline.h" //for select_tmap -MM
106 #include "editor/editor.h"
107 #include "editor/kdefs.h"
118 void arch_init(void);
119 void arch_init_start(void);
121 //Current version number
123 ubyte Version_major = 1; //FULL VERSION
124 ubyte Version_minor = 2;
126 //static const char desc_id_checksum_str[] = DESC_ID_CHKSUM_TAG "0000"; // 4-byte checksum
127 char desc_id_exit_num = 0;
129 int Function_mode=FMODE_MENU; //game or editor?
130 int Screen_mode=-1; //game screen or editor screen?
132 //--unused-- grs_bitmap Inferno_bitmap_title;
134 int WVIDEO_running=0; //debugger can set to 1 if running
137 int __far descent_critical_error_handler( unsigned deverr, unsigned errcode, unsigned __far * devhdr );
140 void check_joystick_calibration(void);
142 void show_order_form(void);
144 //--------------------------------------------------------------------------
146 extern int piggy_low_memory;
149 int descent_critical_error = 0;
150 unsigned descent_critical_deverror = 0;
151 unsigned descent_critical_errcode = 0;
153 extern int Network_allow_socket_changes;
155 extern void vfx_set_palette_sub(ubyte *);
157 extern int VR_low_res;
161 //read help from a file & print to screen
162 void print_commandline_help()
168 ifile = cfopen("help.tex","rb");
170 ifile = cfopen("help.txb","rb");
172 Warning("Cannot load help text file.");
180 while ((end = cfgets(line,LINE_LEN,ifile))) {
183 decode_text_line (line);
185 // This is the only use of cfgets that needs the CR
189 continue; //don't show comments
199 // printf( " Diagnostic:\n\n");
200 // printf( " -emul %s\n", "Certain video cards need this option in order to run game");
201 // printf( " -ddemul %s\n", "If -emul doesn't work, use this option");
204 printf( " Editor Options:\n\n");
205 printf( " -autoload <file>%s\n", "Autoload a level in the editor");
206 printf( " -hoarddata %s\n","Make the hoard ham file from some files, then exit");
207 // printf( " -nobm %s\n","FIXME: Undocumented");
210 printf( " D2X Options:\n\n");
211 printf( " -noredundancy %s\n", "Do not send messages when picking up redundant items in multi");
212 printf( " -shortpackets %s\n", "Set shortpackets to default as on");
213 #ifdef OGL // currently only does anything on ogl build, so don't advertise othewise.
214 printf(" -renderstats %s\n", "Enable renderstats info by default");
216 printf( " -maxfps <n> %s\n", "Set maximum framerate (1-100)");
217 printf( " -notitles %s\n", "Do not show titlescreens on startup");
218 printf( " -hogdir <dir> %s\n", "set shared data directory to <dir>");
220 printf( " -nohogdir %s\n", "don't try to use shared data directory");
221 printf( " -userdir <dir> %s\n", "set user dir to <dir> instead of $HOME/.d2x");
223 printf( " -autoexec <file> %s\n", "autoexec file (execute console commands), defaults to autoexec.cfg");
224 printf( " -ini <file> %s\n", "option file (alternate to command line), defaults to d2x.ini");
225 printf( " -autodemo %s\n", "Start in demo mode");
226 printf( " -bigpig %s\n","FIXME: Undocumented");
227 printf( " -bspgen %s\n","FIXME: Undocumented");
228 // printf( " -cdproxy %s\n","FIXME: Undocumented");
230 printf( " -checktime %s\n","FIXME: Undocumented");
231 printf( " -showmeminfo %s\n","FIXME: Undocumented");
233 // printf( " -codereadonly %s\n","FIXME: Undocumented");
234 // printf( " -cyberimpact %s\n","FIXME: Undocumented");
235 printf( " -debug %s\n","Enable very verbose output");
236 // printf( " -debugmode %s\n","FIXME: Undocumented");
237 // printf( " -disallowgfx %s\n","FIXME: Undocumented");
238 // printf( " -disallowreboot %s\n","FIXME: Undocumented");
239 // printf( " -dynamicsockets %s\n","FIXME: Undocumented");
240 // printf( " -forcegfx %s\n","FIXME: Undocumented");
241 // printf( " -hw_3dacc %s\n","FIXME: Undocumented");
243 printf( " -invulnerability %s\n","Make yourself invulnerable");
245 printf( " -ipxnetwork <num> %s\n","Use IPX network number <num>");
246 printf( " -jasen %s\n","FIXME: Undocumented");
247 printf( " -joyslow %s\n","FIXME: Undocumented");
249 printf( " -kali %s\n","use Kali for networking");
251 // printf( " -logfile %s\n","FIXME: Undocumented");
252 printf( " -lowresmovies %s\n","Play low resolution movies if available (for slow machines)");
253 #if defined(EDITOR) || !defined(MACDATA)
254 printf( " -macdata %s\n","Read (and, for editor, write) mac data files (swap colors)");
256 // printf( " -memdbg %s\n","FIXME: Undocumented");
257 // printf( " -monodebug %s\n","FIXME: Undocumented");
258 printf( " -nocdrom %s\n","FIXME: Undocumented");
260 printf( " -nofade %s\n","Disable fades");
263 printf( " -nomatrixcheat %s\n","FIXME: Undocumented");
264 printf( " -norankings %s\n","Disable multiplayer ranking system");
265 printf( " -packets <num> %s\n","Specifies the number of packets per second\n");
266 // printf( " -showaddress %s\n","FIXME: Undocumented");
267 printf( " -socket %s\n","FIXME: Undocumented");
269 #if !defined(MACINTOSH) && !defined(WINDOWS)
270 printf( " -nomixer %s\n","Don't crank music volume");
272 // printf( " -nomodex %s\n","FIXME: Undocumented");
274 printf( " -nomovies %s\n","Don't play movies");
275 printf( " -noscreens %s\n","Skip briefing screens");
277 printf( " -noredbook %s\n","Disable redbook audio");
278 printf( " -norun %s\n","Bail out after initialization");
279 // printf( " -ordinaljoy %s\n","FIXME: Undocumented");
280 // printf( " -rtscts %s\n","Same as -ctsrts");
281 // printf( " -semiwin %s\n","Use non-fullscreen mode");
282 // printf( " -specialdevice %s\n","FIXME: Undocumented");
284 printf( " -stickmag %s\n","FIXME: Undocumented");
286 // printf( " -stopwatch %s\n","FIXME: Undocumented");
287 printf( " -subtitles %s\n","Turn on movie subtitles (English-only)");
288 // printf( " -sysram %s\n","FIXME: Undocumented");
289 printf( " -text <file> %s\n","Specify alternate .tex file");
290 // printf( " -tsengdebug1 %s\n","FIXME: Undocumented");
291 // printf( " -tsengdebug2 %s\n","FIXME: Undocumented");
292 // printf( " -tsengdebug3 %s\n","FIXME: Undocumented");
293 // printf( " -vidram %s\n","FIXME: Undocumented");
294 printf( " -tmap <t> %s\n","select texmapper to use (c,fp,i386,pent,ppro)");
296 printf( " -<X>x<Y> %s\n", "Change screen resolution. Options:");
297 printf( " 320x100;320x200;320x240;320x400;640x400;640x480;800x600;1024x768\n");
299 printf( " -<X>x<Y> %s\n", "Change screen resolution to <X> by <Y>");
301 printf(" -niceautomap %s\n", "Free cpu while doing automap");
302 printf( " -automap<X>x<Y> %s\n","Set automap resolution to <X> by <Y>");
303 printf( " -automap_gameres %s\n","Set automap to use the same resolution as in game");
304 // printf( " -menu<X>x<Y> %s\n","Set menu resolution to <X> by <Y>");
305 // printf( " -menu_gameres %s\n","Set menus to use the same resolution as in game");
306 printf(" -rearviewtime t %s\n", "time holding rearview key to use toggle mode (default 0.0625 seconds)");
309 printf( "D2X System Options:\n\n");
311 printf(" -ihaveabrokenmouse %s\n", "try to make mouse work if it is not currently");
312 printf( " -joy209 %s\n", "Use alternate port 209 for joystick");
314 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
315 printf( " -fullscreen %s\n", "Use fullscreen mode if available");
318 printf( " -gl_texmagfilt <f> %s\n","set GL_TEXTURE_MAG_FILTER (see readme.d1x)");
319 printf( " -gl_texminfilt <f> %s\n","set GL_TEXTURE_MIN_FILTER (see readme.d1x)");
320 printf(" -gl_mipmap %s\n", "set gl texture filters to \"standard\" (bilinear) mipmapping");
321 printf(" -gl_trilinear %s\n", "set gl texture filters to trilinear mipmapping");
322 printf( " -gl_simple %s\n","set gl texture filters to gl_nearest for \"original\" look. (default)");
323 printf(" -gl_anisotropy <f> %s\n", "set maximum degree of anisotropy to <f>");
324 printf( " -gl_alttexmerge %s\n","use new texmerge, usually uses less ram (default)");
325 printf( " -gl_stdtexmerge %s\n","use old texmerge, uses more ram, but _might_ be a bit faster");
326 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
327 printf( " -gl_voodoo %s\n","force fullscreen mode only");
329 printf( " -gl_16bittextures %s\n","attempt to use 16bit textures");
330 printf(" -gl_16bpp %s\n", "attempt to use 16bit screen mode");
331 printf( " -gl_reticle <r> %s\n","use OGL reticle 0=never 1=above 320x* 2=always");
332 printf( " -gl_intensity4_ok %s\n","FIXME: Undocumented");
333 printf( " -gl_luminance4_alpha4_ok %s\n","FIXME: Undocumented");
334 printf( " -gl_readpixels_ok %s\n","FIXME: Undocumented");
335 printf( " -gl_rgba2_ok %s\n","FIXME: Undocumented");
336 // printf( " -gl_test1 %s\n","FIXME: Undocumented");
337 printf( " -gl_test2 %s\n","FIXME: Undocumented");
338 printf( " -gl_vidmem %s\n","FIXME: Undocumented");
339 #ifdef OGL_RUNTIME_LOAD
340 printf( " -gl_library <l> %s\n","use alternate opengl library");
343 printf(" -gl_refresh <r> %s\n", "set refresh rate (in fullscreen mode)");
347 printf( " -nosdlvidmodecheck %s\n", "Some X servers don't like checking vidmode first, so just switch");
348 printf( " -hwsurface %s\n","FIXME: Undocumented");
351 printf(" -udp %s\n", "Specify options for udp/ip:");
352 printf(" @<shift> %s\n", " shift udp port base offset");
353 printf(" =<HOST_LIST> %s\n", " broadcast both local and to HOST_LIST");
354 printf(" +<HOST_LIST> %s\n", " broadcast only to HOST_LIST");
355 printf(" %s\n", " HOSTS can be any IP or hostname")
357 printf(" %s\n", " HOSTS can also be in the form of <address>:<shift>");
358 printf(" %s\n", " separate multiple HOSTS with a ,");
361 printf( " -serialdevice <s> %s\n", "Set serial/modem device to <s>");
362 printf( " -serialread <r> %s\n", "Set serial/modem to read from <r>");
364 printf( "\n Help:\n\n");
365 printf( " -help, -h, -?, ? %s\n", "View this help screen");
369 void do_joystick_init()
372 if (!FindArg( "-nojoystick" )) {
373 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_6);
375 if ( FindArg( "-joyslow" )) {
376 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_7);
377 joy_set_slow_reading(JOY_SLOW_READINGS);
379 if ( FindArg( "-joypolled" )) {
380 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_8);
381 joy_set_slow_reading(JOY_POLLED_READINGS);
383 if ( FindArg( "-joybios" )) {
384 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_9);
385 joy_set_slow_reading(JOY_BIOS_READINGS);
388 // Added from Descent v1.5 by John. Adapted by Samir.
390 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_10);
394 //set this to force game to run in low res
395 int disable_high_res=0;
397 void do_register_player(ubyte *title_pal)
399 strncpy( Players[Player_num].callsign, config_last_player.string, CALLSIGN_LEN );
400 if (strlen(Players[Player_num].callsign))
407 //now, before we bring up the register player menu, we need to
408 //do some stuff to make sure the palette is ok. First, we need to
409 //get our current palette into the 2d's array, so the remapping will
410 //work. Second, we need to remap the fonts. Third, we need to fill
411 //in part of the fade tables so the darkening of the menu edges works
414 memcpy(gr_palette,title_pal,sizeof(gr_palette));
416 remap_fonts_and_menus(1);
417 RegisterPlayer(); //get player's name
422 #define PROGNAME argv[0]
424 extern char Language[];
426 //can we do highres menus?
427 extern int MenuHiresAvailable;
429 int Inferno_verbose = 0;
431 //added on 11/18/98 by Victor Rachels to add -mission and -startgame
432 int start_net_immediately = 0;
433 //int start_with_mission = 0;
434 //char *start_with_mission_name;
435 //end this section addition
437 #define MENU_HIRES_MODE SM(640,480)
439 // DESCENT II by Parallax Software
442 //extern ubyte gr_current_pal[];
446 char Auto_file[128] = "";
449 int main(int argc, char *argv[])
452 ubyte title_pal[768];
455 CON_Init(); // Initialise the console
457 error_init(NULL, NULL);
458 PHYSFSX_init(argc, argv);
460 if (FindArg("-debug"))
461 cvar_setint( &con_threshold, CON_DEBUG );
462 else if (FindArg("-verbose"))
463 cvar_setint( &con_threshold, CON_VERBOSE );
465 if (! cfile_init("descent2.hog"))
466 if (! cfile_init("d2demo.hog"))
467 Warning("Could not find a valid hog file (descent2.hog or d2demo.hog)\nPossible locations are:\n"
472 "\tCurrent directory\n"
474 "Or use the -hogdir option to specify an alternate location.");
477 //print out the banner title
478 con_printf(CON_NORMAL, "\nDESCENT 2 %s v%d.%d",VERSION_TYPE,Version_major,Version_minor);
480 con_printf(CON_NORMAL, " %s", VERSION_NAME);
482 if (cfexist(MISSION_DIR "d2x.hog"))
483 con_printf(CON_NORMAL, " Vertigo Enhanced");
485 con_printf(CON_NORMAL, " %s %s\n", __DATE__,__TIME__);
486 con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
487 con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2. Copyright (c) 1999 Peter Hawkins\n");
488 con_printf(CON_NORMAL, " Copyright (c) 2002 Bradley Bell\n");
491 if (FindArg( "-?" ) || FindArg( "-help" ) || FindArg( "?" ) || FindArg( "-h" ) ) {
492 print_commandline_help();
493 set_exit_message("");
495 exit(0); /* mingw hangs on this return. dunno why */
500 con_printf(CON_NORMAL, "\n");
501 con_printf(CON_NORMAL, TXT_HELP, PROGNAME); //help message has %s for program name
502 con_printf(CON_NORMAL, "\n");
507 for (i = PHYSFS_getSearchPath(); *i != NULL; i++)
508 con_printf(CON_VERBOSE, "PHYSFS: [%s] is in the search path.\n", *i);
510 list = PHYSFS_getCdRomDirs();
511 for (i = list; *i != NULL; i++)
512 con_printf(CON_VERBOSE, "PHYSFS: cdrom dir [%s] is available.\n", *i);
513 PHYSFS_freeList(list);
515 list = PHYSFS_enumerateFiles("");
516 for (i = list; *i != NULL; i++)
517 con_printf(CON_DEBUG, "PHYSFS: * We've got [%s].\n", *i);
518 PHYSFS_freeList(list);
521 //(re)added Mar 30, 2003 Micah Lieske - Allow use of 22K sound samples again.
522 if(FindArg("-sound22k"))
524 digi_sample_rate = SAMPLE_RATE_22K;
527 if(FindArg("-sound11k"))
529 digi_sample_rate = SAMPLE_RATE_11K;
536 //con_printf(CON_VERBOSE, "\n%s...", "Checking for Descent 2 CD-ROM");
538 if ((t = FindArg("-rearviewtime")))
540 float f = atof(Args[t + 1]);
541 Rear_view_leave_time = f * f1_0;
543 con_printf(CON_VERBOSE, "Rear_view_leave_time=0x%x (%f sec)\n", Rear_view_leave_time, Rear_view_leave_time / (float)f1_0);
545 //added/edited 8/18/98 by Victor Rachels to set maximum fps <= 100
546 if ((t = FindArg( "-maxfps" ))) {
548 if (t > 0 && t <= MAX_FPS)
551 //end addition - Victor Rachels
553 #ifdef SUPPORTS_NICEFPS
554 if (FindArg("-nicefps"))
556 if (FindArg("-niceautomap"))
560 if (FindArg("-renderstats"))
563 if ( FindArg( "-autodemo" ))
567 if ( FindArg( "-noscreens" ) )
568 Skip_briefing_screens = 1;
571 if ((t=FindArg("-tmap"))){
572 select_tmap(Args[t+1]);
578 // if (init_graphics()) return 1;
581 if (gr_check_mode(SM(800, 600)) != 0)
583 con_printf(CON_NORMAL, "The editor will not be available, press any key to start game...\n" );
584 Function_mode = FMODE_MENU;
589 con_printf(CON_DEBUG,"WVIDEO_running = %d\n",WVIDEO_running);
593 if ((t = gr_init()) != 0) // doesn't do much
594 Error(TXT_CANT_INIT_GFX, t);
596 con_printf (CON_VERBOSE, "%s", TXT_VERBOSE_1);
599 if (!VR_offscreen_buffer) //if hasn't been initialied (by headset init)
600 set_display_mode(Default_display_mode); //..then set default display mode
603 int screen_width = 640;
604 int screen_height = 480;
606 FindResArg("", &screen_width, &screen_height);
608 // added 3/24/99 by Owen Evans for screen res changing
609 Game_screen_mode = SM(screen_width, screen_height);
611 set_display_mode(Game_screen_mode);
615 // added/edited on 12/14/98 by Matt Mueller - override res in d1x.ini with command line args
616 int i, argnum = INT_MAX, w, h;
617 // 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.
618 #define SMODE(V,VV,VG) if ((i=FindResArg(#V, &w, &h)) && (i < argnum)) { argnum = i; VV = SM(w, h); VG = 0; }
619 #define SMODE_GR(V,VG) if ((i=FindArg("-" #V "_gameres"))){if (i<argnum) VG=1;}
620 #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) );
621 // aren't #defines great? :)
622 // end addition/edit -MM
623 #define S_MODE(V,VV,VG) argnum = INT_MAX; SMODE(V, VV, VG); SMODE_GR(V, VG); SMODE_PRINT(V, VV, VG);
625 S_MODE(automap,automap_mode,automap_use_game_res);
626 // S_MODE(menu,menu_screen_mode,menu_use_game_res);
632 con_printf(CON_VERBOSE, "\n%s\n\n", TXT_INITIALIZING_GRAPHICS);
633 if (FindArg("-nofade"))
634 grd_fades_disabled=1;
636 //determine whether we're using high-res menus & movies
637 if (FindArg("-nohires") || FindArg("-nohighres") || (gr_check_mode(MENU_HIRES_MODE) != 0) || disable_high_res)
638 cvar_setint( &MovieHires, MenuHires = MenuHiresAvailable = 0 );
640 //NOTE LINK TO ABOVE!
641 MenuHires = MenuHiresAvailable = 1;
643 if (FindArg( "-lowresmovies" ))
644 cvar_setint( &MovieHires, 0 );
646 con_printf(CON_VERBOSE, "Going into graphics mode...\n");
647 gr_set_mode(MovieHires.intval?SM(640,480):SM(320,200));
649 // Load the palette stuff. Returns non-zero if error.
650 con_printf(CON_DEBUG, "Initializing palette system...\n" );
651 gr_use_palette_table(DEFAULT_PALETTE );
653 con_printf(CON_DEBUG, "Initializing font system...\n" );
654 gamefont_init(); // must load after palette data loaded.
656 con_printf( CON_DEBUG, "Initializing movie libraries...\n" );
657 init_movies(); //init movie libraries
659 if ( FindArg( "-notitles" ) )
660 songs_play_song( SONG_TITLE, 1);
664 con_printf( CON_DEBUG, "\nShowing loading screen..." );
665 show_loading_screen(title_pal); // title_pal is needed (see below)
667 CON_InitGFX(SWIDTH, SHEIGHT / 2);
669 con_printf( CON_DEBUG , "\nDoing bm_init..." );
671 if (!bm_init_use_tbl())
676 if (FindArg("-hoarddata") != 0)
683 //the bitmap loading code changes gr_palette, so restore it
684 memcpy(gr_palette,title_pal,sizeof(gr_palette));
686 if ( FindArg( "-norun" ) )
689 con_printf( CON_DEBUG, "\nInitializing 3d system..." );
692 con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
693 texmerge_init( 10 ); // 10 cache bitmaps
695 con_printf( CON_DEBUG, "\nRunning game...\n" );
696 set_screen_mode(SCREEN_MENU);
700 remap_fonts_and_menus(1);
702 if ((t = FindArg("-autoexec")))
703 cmd_appendf("exec %s", Args[t+1]);
704 else if (cfexist("autoexec.cfg"))
705 cmd_append("exec autoexec.cfg");
709 // If built with editor, option to auto-load a level and quit game
710 // to write certain data.
713 if ( (t = FindArg( "-autoload" )) ) {
715 strcpy(Auto_file, Args[t+1]);
721 strcpy(Players[0].callsign, "dummy");
724 if (!strlen(Players[0].callsign))
725 do_register_player(title_pal);
727 Game_mode = GM_GAME_OVER;
730 newdemo_start_playback("descent.dem");
731 if (Newdemo_state == ND_STATE_PLAYBACK )
732 Function_mode = FMODE_GAME;
735 //do this here because the demo code can do a longjmp when trying to
736 //autostart a demo from the main menu, never having gone into the game
739 remap_fonts_and_menus(1);
741 while (Function_mode != FMODE_EXIT)
745 switch( Function_mode ) {
747 set_screen_mode(SCREEN_MENU);
749 newdemo_start_playback(NULL); // Randomly pick a file
750 if (Newdemo_state != ND_STATE_PLAYBACK)
751 Error("No demo files were found for autodemo mode!");
755 strcpy((char *)&Level_names[0], Auto_file);
757 Function_mode = FMODE_EXIT;
762 check_joystick_calibration();
763 gr_palette_clear(); //I'm not sure why we need this, but we do
766 if ( Function_mode == FMODE_EDITOR ) {
768 SetPlayerFromCurseg();
769 load_palette(NULL,1,0);
776 keyd_editor_mode = 0;
781 if ( Function_mode == FMODE_MENU )
782 songs_play_song( SONG_TITLE, 1 );
786 keyd_editor_mode = 1;
789 _harderr( (void*)descent_critical_error_handler ); // Reinstall game error handler
791 if ( Function_mode == FMODE_GAME ) {
792 Game_mode = GM_EDITOR;
793 editor_reset_stuff_on_level();
799 Error("Invalid function mode %d",Function_mode);
805 if (!FindArg( "-notitles" ))
809 if ( FindArg( "-showmeminfo" ) )
810 show_mem_info = 1; // Make memory statistics show
813 return(0); //presumably successful exit
817 void check_joystick_calibration() {
818 int x1, y1, x2, y2, c;
821 if ( !Config_control_joystick.intval )
824 joy_get_pos( &x1, &y1 );
826 t1 = timer_get_fixed_seconds();
827 while( timer_get_fixed_seconds() < t1 + F1_0/100 )
830 joy_get_pos( &x2, &y2 );
832 // If joystick hasn't moved...
833 if ( (abs(x2-x1)<30) && (abs(y2-y1)<30) ) {
834 if ( (abs(x1)>30) || (abs(x2)>30) || (abs(y1)>30) || (abs(y2)>30) ) {
835 c = nm_messagebox( NULL, 2, TXT_CALIBRATE, TXT_SKIP, TXT_JOYSTICK_NOT_CEN );
847 // void network_abort_game();
848 // if(Network_status)
849 // network_abort_game();