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
136 //--unused-- int Cyberman_installed=0; // SWIFT device present
137 ubyte CybermouseActive=0;
140 int __far descent_critical_error_handler( unsigned deverr, unsigned errcode, unsigned __far * devhdr );
143 void check_joystick_calibration(void);
145 void show_order_form(void);
147 //--------------------------------------------------------------------------
149 extern int piggy_low_memory;
152 int descent_critical_error = 0;
153 unsigned descent_critical_deverror = 0;
154 unsigned descent_critical_errcode = 0;
156 extern int Network_allow_socket_changes;
158 extern void vfx_set_palette_sub(ubyte *);
160 extern int VR_low_res;
164 //read help from a file & print to screen
165 void print_commandline_help()
171 ifile = cfopen("help.tex","rb");
173 ifile = cfopen("help.txb","rb");
175 Warning("Cannot load help text file.");
183 while ((end = cfgets(line,LINE_LEN,ifile))) {
186 decode_text_line (line);
188 // This is the only use of cfgets that needs the CR
192 continue; //don't show comments
202 // printf( " Diagnostic:\n\n");
203 // printf( " -emul %s\n", "Certain video cards need this option in order to run game");
204 // printf( " -ddemul %s\n", "If -emul doesn't work, use this option");
207 printf( " Editor Options:\n\n");
208 printf( " -autoload <file>%s\n", "Autoload a level in the editor");
209 printf( " -hoarddata %s\n","Make the hoard ham file from some files, then exit");
210 // printf( " -nobm %s\n","FIXME: Undocumented");
213 printf( " D2X Options:\n\n");
214 printf( " -noredundancy %s\n", "Do not send messages when picking up redundant items in multi");
215 printf( " -shortpackets %s\n", "Set shortpackets to default as on");
216 #ifdef OGL // currently only does anything on ogl build, so don't advertise othewise.
217 printf(" -renderstats %s\n", "Enable renderstats info by default");
219 printf( " -maxfps <n> %s\n", "Set maximum framerate (1-100)");
220 printf( " -notitles %s\n", "Do not show titlescreens on startup");
221 printf( " -hogdir <dir> %s\n", "set shared data directory to <dir>");
223 printf( " -nohogdir %s\n", "don't try to use shared data directory");
224 printf( " -userdir <dir> %s\n", "set user dir to <dir> instead of $HOME/.d2x");
226 printf( " -autoexec <file> %s\n", "autoexec file (execute console commands), defaults to autoexec.cfg");
227 printf( " -ini <file> %s\n", "option file (alternate to command line), defaults to d2x.ini");
228 printf( " -autodemo %s\n", "Start in demo mode");
229 printf( " -bigpig %s\n","FIXME: Undocumented");
230 printf( " -bspgen %s\n","FIXME: Undocumented");
231 // printf( " -cdproxy %s\n","FIXME: Undocumented");
233 printf( " -checktime %s\n","FIXME: Undocumented");
234 printf( " -showmeminfo %s\n","FIXME: Undocumented");
236 // printf( " -codereadonly %s\n","FIXME: Undocumented");
237 // printf( " -cyberimpact %s\n","FIXME: Undocumented");
238 printf( " -debug %s\n","Enable very verbose output");
239 // printf( " -debugmode %s\n","FIXME: Undocumented");
240 // printf( " -disallowgfx %s\n","FIXME: Undocumented");
241 // printf( " -disallowreboot %s\n","FIXME: Undocumented");
242 // printf( " -dynamicsockets %s\n","FIXME: Undocumented");
243 // printf( " -forcegfx %s\n","FIXME: Undocumented");
244 // printf( " -hw_3dacc %s\n","FIXME: Undocumented");
246 printf( " -invulnerability %s\n","Make yourself invulnerable");
248 printf( " -ipxnetwork <num> %s\n","Use IPX network number <num>");
249 printf( " -jasen %s\n","FIXME: Undocumented");
250 printf( " -joyslow %s\n","FIXME: Undocumented");
252 printf( " -kali %s\n","use Kali for networking");
254 // printf( " -logfile %s\n","FIXME: Undocumented");
255 printf( " -lowresmovies %s\n","Play low resolution movies if available (for slow machines)");
256 #if defined(EDITOR) || !defined(MACDATA)
257 printf( " -macdata %s\n","Read (and, for editor, write) mac data files (swap colors)");
259 // printf( " -memdbg %s\n","FIXME: Undocumented");
260 // printf( " -monodebug %s\n","FIXME: Undocumented");
261 printf( " -nocdrom %s\n","FIXME: Undocumented");
263 printf( " -nocyberman %s\n","FIXME: Undocumented");
266 printf( " -nofade %s\n","Disable fades");
269 printf( " -nomatrixcheat %s\n","FIXME: Undocumented");
270 printf( " -norankings %s\n","Disable multiplayer ranking system");
271 printf( " -packets <num> %s\n","Specifies the number of packets per second\n");
272 // printf( " -showaddress %s\n","FIXME: Undocumented");
273 printf( " -socket %s\n","FIXME: Undocumented");
275 #if !defined(MACINTOSH) && !defined(WINDOWS)
276 printf( " -nomixer %s\n","Don't crank music volume");
277 // printf( " -superhires %s\n","Allow higher-resolution modes");
279 // printf( " -nomodex %s\n","FIXME: Undocumented");
281 printf( " -nomovies %s\n","Don't play movies");
282 printf( " -noscreens %s\n","Skip briefing screens");
284 printf( " -noredbook %s\n","Disable redbook audio");
285 printf( " -norun %s\n","Bail out after initialization");
286 // printf( " -ordinaljoy %s\n","FIXME: Undocumented");
287 // printf( " -rtscts %s\n","Same as -ctsrts");
288 // printf( " -semiwin %s\n","Use non-fullscreen mode");
289 // printf( " -specialdevice %s\n","FIXME: Undocumented");
291 printf( " -stickmag %s\n","FIXME: Undocumented");
293 // printf( " -stopwatch %s\n","FIXME: Undocumented");
294 printf( " -subtitles %s\n","Turn on movie subtitles (English-only)");
295 // printf( " -sysram %s\n","FIXME: Undocumented");
296 printf( " -text <file> %s\n","Specify alternate .tex file");
297 // printf( " -tsengdebug1 %s\n","FIXME: Undocumented");
298 // printf( " -tsengdebug2 %s\n","FIXME: Undocumented");
299 // printf( " -tsengdebug3 %s\n","FIXME: Undocumented");
300 // printf( " -vidram %s\n","FIXME: Undocumented");
301 printf( " -xcontrol %s\n","FIXME: Undocumented");
302 printf( " -xname %s\n","FIXME: Undocumented");
303 printf( " -xver %s\n","FIXME: Undocumented");
304 printf( " -tmap <t> %s\n","select texmapper to use (c,fp,i386,pent,ppro)");
306 printf( " -<X>x<Y> %s\n", "Change screen resolution. Options:");
307 printf( " 320x100;320x200;320x240;320x400;640x400;640x480;800x600;1024x768\n");
309 printf( " -<X>x<Y> %s\n", "Change screen resolution to <X> by <Y>");
311 printf(" -niceautomap %s\n", "Free cpu while doing automap");
312 printf( " -automap<X>x<Y> %s\n","Set automap resolution to <X> by <Y>");
313 printf( " -automap_gameres %s\n","Set automap to use the same resolution as in game");
314 // printf( " -menu<X>x<Y> %s\n","Set menu resolution to <X> by <Y>");
315 // printf( " -menu_gameres %s\n","Set menus to use the same resolution as in game");
316 printf(" -rearviewtime t %s\n", "time holding rearview key to use toggle mode (default 0.0625 seconds)");
319 printf( "D2X System Options:\n\n");
321 printf(" -ihaveabrokenmouse %s\n", "try to make mouse work if it is not currently");
322 printf( " -joy209 %s\n", "Use alternate port 209 for joystick");
324 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
325 printf( " -fullscreen %s\n", "Use fullscreen mode if available");
328 printf( " -gl_texmagfilt <f> %s\n","set GL_TEXTURE_MAG_FILTER (see readme.d1x)");
329 printf( " -gl_texminfilt <f> %s\n","set GL_TEXTURE_MIN_FILTER (see readme.d1x)");
330 printf(" -gl_mipmap %s\n", "set gl texture filters to \"standard\" (bilinear) mipmapping");
331 printf(" -gl_trilinear %s\n", "set gl texture filters to trilinear mipmapping");
332 printf( " -gl_simple %s\n","set gl texture filters to gl_nearest for \"original\" look. (default)");
333 printf(" -gl_anisotropy <f> %s\n", "set maximum degree of anisotropy to <f>");
334 printf( " -gl_alttexmerge %s\n","use new texmerge, usually uses less ram (default)");
335 printf( " -gl_stdtexmerge %s\n","use old texmerge, uses more ram, but _might_ be a bit faster");
336 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
337 printf( " -gl_voodoo %s\n","force fullscreen mode only");
339 printf( " -gl_16bittextures %s\n","attempt to use 16bit textures");
340 printf(" -gl_16bpp %s\n", "attempt to use 16bit screen mode");
341 printf( " -gl_reticle <r> %s\n","use OGL reticle 0=never 1=above 320x* 2=always");
342 printf( " -gl_intensity4_ok %s\n","FIXME: Undocumented");
343 printf( " -gl_luminance4_alpha4_ok %s\n","FIXME: Undocumented");
344 printf( " -gl_readpixels_ok %s\n","FIXME: Undocumented");
345 printf( " -gl_rgba2_ok %s\n","FIXME: Undocumented");
346 // printf( " -gl_test1 %s\n","FIXME: Undocumented");
347 printf( " -gl_test2 %s\n","FIXME: Undocumented");
348 printf( " -gl_vidmem %s\n","FIXME: Undocumented");
349 #ifdef OGL_RUNTIME_LOAD
350 printf( " -gl_library <l> %s\n","use alternate opengl library");
353 printf(" -gl_refresh <r> %s\n", "set refresh rate (in fullscreen mode)");
357 printf( " -nosdlvidmodecheck %s\n", "Some X servers don't like checking vidmode first, so just switch");
358 printf( " -hwsurface %s\n","FIXME: Undocumented");
361 printf(" -udp %s\n", "Specify options for udp/ip:");
362 printf(" @<shift> %s\n", " shift udp port base offset");
363 printf(" =<HOST_LIST> %s\n", " broadcast both local and to HOST_LIST");
364 printf(" +<HOST_LIST> %s\n", " broadcast only to HOST_LIST");
365 printf(" %s\n", " HOSTS can be any IP or hostname")
367 printf(" %s\n", " HOSTS can also be in the form of <address>:<shift>");
368 printf(" %s\n", " separate multiple HOSTS with a ,");
371 printf( " -serialdevice <s> %s\n", "Set serial/modem device to <s>");
372 printf( " -serialread <r> %s\n", "Set serial/modem to read from <r>");
374 printf( "\n Help:\n\n");
375 printf( " -help, -h, -?, ? %s\n", "View this help screen");
379 void do_joystick_init()
382 if (!FindArg( "-nojoystick" )) {
383 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_6);
385 if ( FindArg( "-joyslow" )) {
386 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_7);
387 joy_set_slow_reading(JOY_SLOW_READINGS);
389 if ( FindArg( "-joypolled" )) {
390 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_8);
391 joy_set_slow_reading(JOY_POLLED_READINGS);
393 if ( FindArg( "-joybios" )) {
394 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_9);
395 joy_set_slow_reading(JOY_BIOS_READINGS);
398 // Added from Descent v1.5 by John. Adapted by Samir.
400 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_10);
404 //set this to force game to run in low res
405 int disable_high_res=0;
407 void do_register_player(ubyte *title_pal)
409 strncpy( Players[Player_num].callsign, config_last_player.string, CALLSIGN_LEN );
410 if (strlen(Players[Player_num].callsign))
417 //now, before we bring up the register player menu, we need to
418 //do some stuff to make sure the palette is ok. First, we need to
419 //get our current palette into the 2d's array, so the remapping will
420 //work. Second, we need to remap the fonts. Third, we need to fill
421 //in part of the fade tables so the darkening of the menu edges works
424 memcpy(gr_palette,title_pal,sizeof(gr_palette));
426 remap_fonts_and_menus(1);
427 RegisterPlayer(); //get player's name
432 #define PROGNAME argv[0]
434 extern char Language[];
436 //can we do highres menus?
437 extern int MenuHiresAvailable;
439 int Inferno_verbose = 0;
441 //added on 11/18/98 by Victor Rachels to add -mission and -startgame
442 int start_net_immediately = 0;
443 //int start_with_mission = 0;
444 //char *start_with_mission_name;
445 //end this section addition
447 #define MENU_HIRES_MODE SM(640,480)
449 // DESCENT II by Parallax Software
452 //extern ubyte gr_current_pal[];
456 char Auto_file[128] = "";
459 int main(int argc, char *argv[])
462 ubyte title_pal[768];
465 CON_Init(); // Initialise the console
467 error_init(NULL, NULL);
468 PHYSFSX_init(argc, argv);
470 if (FindArg("-debug"))
471 cvar_setint( &con_threshold, CON_DEBUG );
472 else if (FindArg("-verbose"))
473 cvar_setint( &con_threshold, CON_VERBOSE );
475 if (! cfile_init("descent2.hog"))
476 if (! cfile_init("d2demo.hog"))
477 Warning("Could not find a valid hog file (descent2.hog or d2demo.hog)\nPossible locations are:\n"
482 "\tCurrent directory\n"
484 "Or use the -hogdir option to specify an alternate location.");
487 //print out the banner title
488 con_printf(CON_NORMAL, "\nDESCENT 2 %s v%d.%d",VERSION_TYPE,Version_major,Version_minor);
490 con_printf(CON_NORMAL, " %s", VERSION_NAME);
492 if (cfexist(MISSION_DIR "d2x.hog"))
493 con_printf(CON_NORMAL, " Vertigo Enhanced");
495 con_printf(CON_NORMAL, " %s %s\n", __DATE__,__TIME__);
496 con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
497 con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2. Copyright (c) 1999 Peter Hawkins\n");
498 con_printf(CON_NORMAL, " Copyright (c) 2002 Bradley Bell\n");
501 if (FindArg( "-?" ) || FindArg( "-help" ) || FindArg( "?" ) || FindArg( "-h" ) ) {
502 print_commandline_help();
503 set_exit_message("");
505 exit(0); /* mingw hangs on this return. dunno why */
510 con_printf(CON_NORMAL, "\n");
511 con_printf(CON_NORMAL, TXT_HELP, PROGNAME); //help message has %s for program name
512 con_printf(CON_NORMAL, "\n");
517 for (i = PHYSFS_getSearchPath(); *i != NULL; i++)
518 con_printf(CON_VERBOSE, "PHYSFS: [%s] is in the search path.\n", *i);
520 list = PHYSFS_getCdRomDirs();
521 for (i = list; *i != NULL; i++)
522 con_printf(CON_VERBOSE, "PHYSFS: cdrom dir [%s] is available.\n", *i);
523 PHYSFS_freeList(list);
525 list = PHYSFS_enumerateFiles("");
526 for (i = list; *i != NULL; i++)
527 con_printf(CON_DEBUG, "PHYSFS: * We've got [%s].\n", *i);
528 PHYSFS_freeList(list);
531 //(re)added Mar 30, 2003 Micah Lieske - Allow use of 22K sound samples again.
532 if(FindArg("-sound22k"))
534 digi_sample_rate = SAMPLE_RATE_22K;
537 if(FindArg("-sound11k"))
539 digi_sample_rate = SAMPLE_RATE_11K;
546 //con_printf(CON_VERBOSE, "\n%s...", "Checking for Descent 2 CD-ROM");
548 if ((t = FindArg("-rearviewtime")))
550 float f = atof(Args[t + 1]);
551 Rear_view_leave_time = f * f1_0;
553 con_printf(CON_VERBOSE, "Rear_view_leave_time=0x%x (%f sec)\n", Rear_view_leave_time, Rear_view_leave_time / (float)f1_0);
555 //added/edited 8/18/98 by Victor Rachels to set maximum fps <= 100
556 if ((t = FindArg( "-maxfps" ))) {
558 if (t > 0 && t <= MAX_FPS)
561 //end addition - Victor Rachels
563 #ifdef SUPPORTS_NICEFPS
564 if (FindArg("-nicefps"))
566 if (FindArg("-niceautomap"))
570 if (FindArg("-renderstats"))
573 if ( FindArg( "-autodemo" ))
577 if ( FindArg( "-noscreens" ) )
578 Skip_briefing_screens = 1;
581 if ((t=FindArg("-tmap"))){
582 select_tmap(Args[t+1]);
588 // if (init_graphics()) return 1;
591 if (gr_check_mode(SM(800, 600)) != 0)
593 con_printf(CON_NORMAL, "The editor will not be available, press any key to start game...\n" );
594 Function_mode = FMODE_MENU;
599 con_printf(CON_DEBUG,"WVIDEO_running = %d\n",WVIDEO_running);
603 con_printf (CON_VERBOSE, "%s", TXT_VERBOSE_1);
606 if (!VR_offscreen_buffer) //if hasn't been initialied (by headset init)
607 set_display_mode(Default_display_mode); //..then set default display mode
610 int screen_width = 640;
611 int screen_height = 480;
613 FindResArg("", &screen_width, &screen_height);
615 // added 3/24/99 by Owen Evans for screen res changing
616 Game_screen_mode = SM(screen_width, screen_height);
618 set_display_mode(Game_screen_mode);
622 // added/edited on 12/14/98 by Matt Mueller - override res in d1x.ini with command line args
623 int i, argnum = INT_MAX, w, h;
624 // 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.
625 #define SMODE(V,VV,VG) if ((i=FindResArg(#V, &w, &h)) && (i < argnum)) { argnum = i; VV = SM(w, h); VG = 0; }
626 #define SMODE_GR(V,VG) if ((i=FindArg("-" #V "_gameres"))){if (i<argnum) VG=1;}
627 #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) );
628 // aren't #defines great? :)
629 // end addition/edit -MM
630 #define S_MODE(V,VV,VG) argnum = INT_MAX; SMODE(V, VV, VG); SMODE_GR(V, VG); SMODE_PRINT(V, VV, VG);
632 S_MODE(automap,automap_mode,automap_use_game_res);
633 // S_MODE(menu,menu_screen_mode,menu_use_game_res);
637 i = FindArg( "-xcontrol" );
639 kconfig_init_external_controls( strtol(Args[i+1], NULL, 0), strtol(Args[i+2], NULL, 0) );
642 con_printf(CON_VERBOSE, "\n%s\n\n", TXT_INITIALIZING_GRAPHICS);
643 if (FindArg("-nofade"))
644 grd_fades_disabled=1;
646 //determine whether we're using high-res menus & movies
647 if (FindArg("-nohires") || FindArg("-nohighres") || (gr_check_mode(MENU_HIRES_MODE) != 0) || disable_high_res)
648 cvar_setint( &MovieHires, MenuHires = MenuHiresAvailable = 0 );
650 //NOTE LINK TO ABOVE!
651 MenuHires = MenuHiresAvailable = 1;
653 if (FindArg( "-lowresmovies" ))
654 cvar_setint( &MovieHires, 0 );
656 if ((t=gr_init())!=0) //doesn't do much
657 Error(TXT_CANT_INIT_GFX,t);
659 con_printf(CON_VERBOSE, "Going into graphics mode...\n");
660 gr_set_mode(MovieHires.intval?SM(640,480):SM(320,200));
662 // Load the palette stuff. Returns non-zero if error.
663 con_printf(CON_DEBUG, "Initializing palette system...\n" );
664 gr_use_palette_table(DEFAULT_PALETTE );
666 con_printf(CON_DEBUG, "Initializing font system...\n" );
667 gamefont_init(); // must load after palette data loaded.
669 con_printf( CON_DEBUG, "Initializing movie libraries...\n" );
670 init_movies(); //init movie libraries
672 if ( FindArg( "-notitles" ) )
673 songs_play_song( SONG_TITLE, 1);
677 con_printf( CON_DEBUG, "\nShowing loading screen..." );
678 show_loading_screen(title_pal); // title_pal is needed (see below)
680 CON_InitGFX(SWIDTH, SHEIGHT / 2);
682 con_printf( CON_DEBUG , "\nDoing bm_init..." );
684 if (!bm_init_use_tbl())
689 if (FindArg("-hoarddata") != 0)
696 //the bitmap loading code changes gr_palette, so restore it
697 memcpy(gr_palette,title_pal,sizeof(gr_palette));
699 if ( FindArg( "-norun" ) )
702 con_printf( CON_DEBUG, "\nInitializing 3d system..." );
705 con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
706 texmerge_init( 10 ); // 10 cache bitmaps
708 con_printf( CON_DEBUG, "\nRunning game...\n" );
709 set_screen_mode(SCREEN_MENU);
713 remap_fonts_and_menus(1);
715 if ((t = FindArg("-autoexec")))
716 cmd_appendf("exec %s", Args[t+1]);
717 else if (cfexist("autoexec.cfg"))
718 cmd_append("exec autoexec.cfg");
722 // If built with editor, option to auto-load a level and quit game
723 // to write certain data.
726 if ( (t = FindArg( "-autoload" )) ) {
728 strcpy(Auto_file, Args[t+1]);
734 strcpy(Players[0].callsign, "dummy");
737 if (!strlen(Players[0].callsign))
738 do_register_player(title_pal);
740 Game_mode = GM_GAME_OVER;
743 newdemo_start_playback("descent.dem");
744 if (Newdemo_state == ND_STATE_PLAYBACK )
745 Function_mode = FMODE_GAME;
748 //do this here because the demo code can do a longjmp when trying to
749 //autostart a demo from the main menu, never having gone into the game
752 remap_fonts_and_menus(1);
754 while (Function_mode != FMODE_EXIT)
758 switch( Function_mode ) {
760 set_screen_mode(SCREEN_MENU);
762 newdemo_start_playback(NULL); // Randomly pick a file
763 if (Newdemo_state != ND_STATE_PLAYBACK)
764 Error("No demo files were found for autodemo mode!");
768 strcpy((char *)&Level_names[0], Auto_file);
770 Function_mode = FMODE_EXIT;
775 check_joystick_calibration();
776 gr_palette_clear(); //I'm not sure why we need this, but we do
779 if ( Function_mode == FMODE_EDITOR ) {
781 SetPlayerFromCurseg();
782 load_palette(NULL,1,0);
789 keyd_editor_mode = 0;
794 if ( Function_mode == FMODE_MENU )
795 songs_play_song( SONG_TITLE, 1 );
799 keyd_editor_mode = 1;
802 _harderr( (void*)descent_critical_error_handler ); // Reinstall game error handler
804 if ( Function_mode == FMODE_GAME ) {
805 Game_mode = GM_EDITOR;
806 editor_reset_stuff_on_level();
812 Error("Invalid function mode %d",Function_mode);
818 if (!FindArg( "-notitles" ))
822 if ( FindArg( "-showmeminfo" ) )
823 show_mem_info = 1; // Make memory statistics show
826 return(0); //presumably successful exit
830 void check_joystick_calibration() {
831 int x1, y1, x2, y2, c;
834 if ( !Config_control_joystick.intval )
837 joy_get_pos( &x1, &y1 );
839 t1 = timer_get_fixed_seconds();
840 while( timer_get_fixed_seconds() < t1 + F1_0/100 )
843 joy_get_pos( &x2, &y2 );
845 // If joystick hasn't moved...
846 if ( (abs(x2-x1)<30) && (abs(y2-y1)<30) ) {
847 if ( (abs(x1)>30) || (abs(x2)>30) || (abs(y1)>30) || (abs(y2)>30) ) {
848 c = nm_messagebox( NULL, 2, TXT_CALIBRATE, TXT_SKIP, TXT_JOYSTICK_NOT_CEN );
860 // void network_abort_game();
861 // if(Network_status)
862 // network_abort_game();