set the include directory
[AROS-Contrib.git] / Games / Doom / d_main.c
blob1f06b49f6951e6485f3ca342cebfbbafbd0cfa76
1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id$
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 //
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
15 // for more details.
17 // $Log$
18 // Revision 1.4 2001/05/04 00:20:56 falemagn
19 // removed the AROS specific defines that broke the yesterday's nightly building
21 // Revision 1.3 2001/04/05 20:40:25 stegerg
22 // No more need for a replacement getenv() function, as getenv
23 // is now available in c lib.
25 // Revision 1.2 2001/03/28 23:13:35 bernie
26 // use putchar() instead of printf() (this fixes a missing prototype warning).
28 // Revision 1.1 2000/02/29 18:21:04 stegerg
29 // Doom port based on ADoomPPC. Read README.AROS!
32 // DESCRIPTION:
33 // DOOM main program (D_DoomMain) and game loop (D_DoomLoop),
34 // plus functions to determine game mode (shareware, registered),
35 // parse command line parameters, configure game parameters (turbo),
36 // and call the startup functions.
38 //-----------------------------------------------------------------------------
41 static const char rcsid[] = "$Id$";
43 /*#ifdef AROS --- disabled now */
44 #if 0
45 extern int I_Exists(char *name);
46 /* extern char *I_GetEnv(char *name); */
47 extern void I_MakeDir(char *name);
49 #define access(name,mode) (!(I_Exists(name))) */
50 /* #define getenv(name) (I_GetEnv(name)) */
51 #define mkdir(name,b) (I_MakeDir(name))*/
53 #include <aros/debug.h>
54 #endif
56 #define BGCOLOR 7
57 #define FGCOLOR 8
60 #ifdef NORMALUNIX
61 #include <stdio.h>
62 #include <stdlib.h>
63 #include <unistd.h>
64 #include <sys/types.h>
65 #include <sys/stat.h>
66 #include <fcntl.h>
67 #endif
70 #include "doomdef.h"
71 #include "doomstat.h"
73 #include "dstrings.h"
74 #include "sounds.h"
77 #include "z_zone.h"
78 #include "w_wad.h"
79 #include "s_sound.h"
80 #include "v_video.h"
82 #include "f_finale.h"
83 #include "f_wipe.h"
85 #include "m_argv.h"
86 #include "m_misc.h"
87 #include "m_menu.h"
89 #include "i_system.h"
90 #include "i_sound.h"
91 #include "i_video.h"
93 #include "g_game.h"
95 #include "hu_stuff.h"
96 #include "wi_stuff.h"
97 #include "st_stuff.h"
98 #include "am_map.h"
100 #include "p_setup.h"
101 #include "r_local.h"
103 /* DeHacked Patch !!! */
104 #include "dehacked.h"
106 #include "d_main.h"
109 // D-DoomLoop()
110 // Not a globally visible function,
111 // just included for source reference,
112 // called by D_DoomMain, never exits.
113 // Manages timing and IO,
114 // calls all ?_Responder, ?_Ticker, and ?_Drawer,
115 // calls I_GetTime, I_StartFrame, and I_StartTic
117 void D_DoomLoop (void);
120 char* wadfiles[MAXWADFILES];
123 boolean devparm; // started game with -devparm
124 boolean nomonsters; // checkparm of -nomonsters
125 boolean respawnparm; // checkparm of -respawn
126 boolean fastparm; // checkparm of -fast
127 boolean rotatemap; // checkparm of -rotatemap
128 boolean maponhu; // checkparm of -maponhu
130 boolean drone;
132 boolean singletics = false; // debug flag to cancel adaptiveness
136 //extern int soundVolume;
137 //extern int sfxVolume;
138 //extern int musicVolume;
140 extern boolean inhelpscreens;
141 extern boolean maponhu;
143 skill_t startskill;
144 int startepisode;
145 int startmap;
146 boolean autostart;
148 FILE* debugfile;
150 boolean advancedemo;
155 char wadfile[1024]; // primary wad file
156 char mapdir[1024]; // directory of development maps
157 char basedefault[1024]; // default file
160 void D_CheckNetGame (void);
161 void D_ProcessEvents (void);
162 void G_BuildTiccmd (ticcmd_t* cmd);
163 void D_DoAdvanceDemo (void);
167 // EVENT HANDLING
169 // Events are asynchronous inputs generally generated by the game user.
170 // Events can be discarded if no responder claims them
172 event_t events[MAXEVENTS];
173 int eventhead;
174 int eventtail;
178 // D_PostEvent
179 // Called by the I/O functions when input is detected
181 void D_PostEvent (event_t* ev)
183 events[eventhead++] = *ev;
184 eventhead = (eventhead)&(MAXEVENTS-1);
189 // D_ProcessEvents
190 // Send all the events of the given timestamp down the responder chain
192 void D_ProcessEvents (void)
194 event_t* ev;
196 // IF STORE DEMO, DO NOT ACCEPT INPUT
197 if ( ( gamemode == commercial )
198 && (W_CheckNumForName("map01")<0) )
199 return;
201 for ( ; eventtail != eventhead ; eventtail++, eventtail = (eventtail)&(MAXEVENTS-1) )
203 ev = &events[eventtail];
204 if (M_Responder (ev))
205 continue; // menu ate the event
206 G_Responder (ev);
214 // D_Display
215 // draw current display, possibly wiping it from the previous
218 // wipegamestate can be set to -1 to force a wipe on the next draw
219 gamestate_t wipegamestate = GS_DEMOSCREEN;
220 extern boolean setsizeneeded;
221 extern int showMessages;
222 void R_ExecuteSetViewSize (void);
224 void D_Display (void)
226 static boolean maponhustate = false;
227 static boolean viewactivestate = false;
228 static boolean menuactivestate = false;
229 static boolean inhelpscreensstate = false;
230 static boolean fullscreen = false;
231 static gamestate_t oldgamestate = -1;
232 static int borderdrawcount;
233 int nowtime;
234 int tics;
235 int wipestart;
236 int y;
237 boolean done;
238 boolean wipe;
239 boolean redrawsbar;
241 if (nodrawers)
242 return; // for comparative timing / profiling
244 redrawsbar = false;
246 // change the view size if needed
247 if (setsizeneeded)
249 R_ExecuteSetViewSize ();
250 oldgamestate = -1; // force background redraw
251 borderdrawcount = 3;
254 // force redraw border if we changed maponhu type
255 if (maponhu > 0 && maponhustate == 0)
257 oldgamestate = -1; // force background redraw
258 borderdrawcount = 3;
261 // save the current screen if about to wipe
262 if (gamestate != wipegamestate)
264 wipe = true;
265 wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
267 else
268 wipe = false;
270 // start updating gfx in screens[0] here
271 I_StartUpdate ();
273 if (gamestate == GS_LEVEL && gametic)
274 HU_Erase();
276 // do buffered drawing
277 switch (gamestate)
279 case GS_LEVEL:
280 if (!gametic)
281 break;
282 /* Map On Headup Patch - CDE - 97'
283 if (automapactive)
284 AM_Drawer ();
286 if (wipe || (viewheight != SCREENHEIGHT && fullscreen) )
287 redrawsbar = true;
288 if (inhelpscreensstate && !inhelpscreens)
289 redrawsbar = true; // just put away the help screen
290 ST_Drawer (viewheight == SCREENHEIGHT, redrawsbar );
291 fullscreen = viewheight == SCREENHEIGHT;
292 break;
294 case GS_INTERMISSION:
295 WI_Drawer ();
296 break;
298 case GS_FINALE:
299 F_Drawer ();
300 break;
302 case GS_DEMOSCREEN:
303 D_PageDrawer ();
304 break;
307 // draw buffered stuff to screen
308 I_UpdateNoBlit ();
310 // draw the view directly
311 if (gamestate == GS_LEVEL && (!automapactive || maponhu) && gametic)
312 R_RenderPlayerView (&players[displayplayer]);
314 /* Map On HeadUp Patch - CDE 98' */
315 if (gamestate == GS_LEVEL && automapactive)
316 AM_Drawer ();
318 if (gamestate == GS_LEVEL && gametic)
319 HU_Drawer ();
321 // clean up border stuff
322 if (gamestate != oldgamestate && gamestate != GS_LEVEL)
323 I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE), 0);
325 // see if the border needs to be initially drawn
326 if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL)
328 viewactivestate = false; // view was not active
329 R_FillBackScreen (); // draw the pattern into the back screen
332 // see if the border needs to be updated to the screen
333 if (gamestate == GS_LEVEL && (maponhu || !automapactive) /* && scaledviewwidth != 320 */)
335 if (menuactive || menuactivestate || !viewactivestate)
336 borderdrawcount = 3;
337 if (borderdrawcount)
339 R_DrawViewBorder (); // erase old menu stuff
340 borderdrawcount--;
344 maponhustate = maponhu; // CDE'98
345 menuactivestate = menuactive;
346 viewactivestate = viewactive;
347 inhelpscreensstate = inhelpscreens;
348 oldgamestate = wipegamestate = gamestate;
350 // draw pause pic
351 if (paused)
353 if (automapactive)
354 y = 4;
355 else
356 y = viewwindowy+4;
357 V_DrawPatchDirect(viewwindowx+(scaledviewwidth-68)/2,
358 y,0,W_CacheLumpName ("M_PAUSE", PU_CACHE));
362 // menus go directly to the screen
363 M_Drawer (); // menu is drawn even on top of everything
364 NetUpdate (); // send out any new accumulation
367 // normal update
368 if (!wipe)
370 I_FinishUpdate (); // page flip or blit buffer
371 return;
374 // wipe update
375 wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
377 wipestart = I_GetTime () - 1;
383 nowtime = I_GetTime ();
384 tics = nowtime - wipestart;
385 } while (!tics);
386 wipestart = nowtime;
387 done = wipe_ScreenWipe(wipe_Melt
388 , 0, 0, SCREENWIDTH, SCREENHEIGHT, tics);
389 I_StartUpdate ();
390 I_UpdateNoBlit ();
391 M_Drawer (); // menu is drawn even on top of wipes
392 I_FinishUpdate (); // page flip or blit buffer
393 } while (!done);
399 // D_DoomLoop
401 extern boolean demorecording;
403 void D_DoomLoop (void)
405 if (demorecording)
406 G_BeginRecording ();
408 if (M_CheckParm ("-debugfile"))
410 char filename[20];
411 sprintf (filename,"debug%i.txt",consoleplayer);
412 printf ("debug output to: %s\n",filename);
413 debugfile = fopen (filename,"w");
415 I_InitGraphics ();
417 while (1)
419 // frame syncronous IO operations
420 I_StartFrame ();
422 // process one or more tics
423 if (singletics)
425 I_StartTic ();
426 D_ProcessEvents ();
427 G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]);
428 if (advancedemo)
429 D_DoAdvanceDemo ();
430 M_Ticker ();
431 G_Ticker ();
432 gametic++;
433 maketic++;
435 else
437 TryRunTics (); // will run at least one tic
440 S_UpdateSounds (players[consoleplayer].mo);// move positional sounds
442 // Update display, next frame, with current state.
443 D_Display ();
445 #if 0
446 #ifndef SNDSERV
447 // Sound mixing for the buffer is snychronous.
448 I_UpdateSound();
449 #endif
450 // Synchronous sound output is explicitly called.
451 #ifndef SNDINTR
452 // Update sound output.
453 I_SubmitSound();
454 #endif
455 #endif
462 // DEMO LOOP
464 int demosequence;
465 int pagetic;
466 char *pagename;
470 // D_PageTicker
471 // Handles timing for warped projection
473 void D_PageTicker (void)
475 if (--pagetic < 0)
476 D_AdvanceDemo ();
482 // D_PageDrawer
484 void D_PageDrawer (void)
486 V_DrawPatchInDirect (0,0, 0, W_CacheLumpName(pagename, PU_CACHE));
491 // D_AdvanceDemo
492 // Called after each demo or intro demosequence finishes
494 void D_AdvanceDemo (void)
496 advancedemo = true;
501 // This cycles through the demo sequences.
502 // FIXME - version dependend demo numbers?
504 void D_DoAdvanceDemo (void)
506 players[consoleplayer].playerstate = PST_LIVE; // not reborn
507 advancedemo = false;
508 usergame = false; // no save / end game here
509 paused = false;
510 gameaction = ga_nothing;
512 if ( gamemode == retail )
513 demosequence = (demosequence+1)%7;
514 else
515 demosequence = (demosequence+1)%6;
517 switch (demosequence)
519 case 0:
520 if ( gamemode == commercial )
521 pagetic = 35 * 11;
522 else
523 pagetic = 170;
524 gamestate = GS_DEMOSCREEN;
525 pagename = "TITLEPIC";
526 if ( gamemode == commercial )
527 S_StartMusic(mus_dm2ttl);
528 else
529 S_StartMusic (mus_intro);
530 break;
531 case 1:
532 G_DeferedPlayDemo ("demo1");
533 break;
534 case 2:
535 pagetic = 200;
536 gamestate = GS_DEMOSCREEN;
537 pagename = "CREDIT";
538 break;
539 case 3:
540 G_DeferedPlayDemo ("demo2");
541 break;
542 case 4:
543 gamestate = GS_DEMOSCREEN;
544 if ( gamemode == commercial)
546 pagetic = 35 * 11;
547 pagename = "TITLEPIC";
548 S_StartMusic(mus_dm2ttl);
550 else
552 pagetic = 200;
554 if ( gamemode == retail )
555 pagename = "CREDIT";
556 else
557 pagename = "HELP2";
559 break;
560 case 5:
561 G_DeferedPlayDemo ("demo3");
562 break;
563 // THE DEFINITIVE DOOM Special Edition demo
564 case 6:
565 G_DeferedPlayDemo ("demo4");
566 break;
573 // D_StartTitle
575 void D_StartTitle (void)
577 gameaction = ga_nothing;
578 demosequence = -1;
579 D_AdvanceDemo ();
585 // print title for every printed line
586 char title[128];
591 // D_AddFile
593 void D_AddFile (char *file)
595 int numwadfiles;
596 char *newfile;
598 for (numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++)
601 newfile = malloc (strlen(file)+1);
602 strcpy (newfile, file);
604 wadfiles[numwadfiles] = newfile;
607 #if defined DEBUGGING || defined AROS
608 #define DIRSTRING ""
609 #else
610 #define DIRSTRING "PROGDIR:"
611 #endif
614 // IdentifyVersion
615 // Checks availability of IWAD files by name,
616 // to determine whether registered/commercial features
617 // should be executed (notably loading PWAD's).
619 void IdentifyVersion (void)
621 int p;
623 char* doom1wad;
624 char* doomwad;
625 char* doomuwad;
626 char* doom2wad;
628 char* doom2fwad;
629 char* plutoniawad;
630 char* tntwad;
632 #ifdef NORMALUNIX
633 static char home[256];
634 static char doomwaddir[256];
636 if (getenv ("DOOMWADDIR") != NULL) {
637 strcpy (doomwaddir, getenv("DOOMWADDIR"));
638 if (doomwaddir[strlen(doomwaddir)-1] != '/' && doomwaddir[strlen(doomwaddir)-1] != ':')
639 strcat (doomwaddir, "/");
640 } else {
641 strcpy (doomwaddir, DIRSTRING);
642 p = M_CheckParm ("-waddir");
643 if (p) {
644 strcpy(doomwaddir, myargv[p+1]);
645 if (doomwaddir[strlen(doomwaddir)-1] != '/' && doomwaddir[strlen(doomwaddir)-1] != ':')
646 strcat (doomwaddir, "/");
650 // Commercial.
651 doom2wad = malloc(strlen(doomwaddir)+1+9+1);
652 sprintf(doom2wad, "%sdoom2.wad", doomwaddir);
654 // Retail.
655 doomuwad = malloc(strlen(doomwaddir)+1+8+1);
656 sprintf(doomuwad, "%sdoomu.wad", doomwaddir);
658 // Registered.
659 doomwad = malloc(strlen(doomwaddir)+1+8+1);
660 sprintf(doomwad, "%sdoom.wad", doomwaddir);
662 // Shareware.
663 doom1wad = malloc(strlen(doomwaddir)+1+9+1);
664 sprintf(doom1wad, "%sdoom1.wad", doomwaddir);
666 // Bug, dear Shawn.
667 // Insufficient malloc, caused spurious realloc errors.
668 plutoniawad = malloc(strlen(doomwaddir)+1+/*9*/12+1);
669 sprintf(plutoniawad, "%splutonia.wad", doomwaddir);
671 tntwad = malloc(strlen(doomwaddir)+1+9+1);
672 sprintf(tntwad, "%stnt.wad", doomwaddir);
675 // French stuff.
676 doom2fwad = malloc(strlen(doomwaddir)+1+10+1);
677 sprintf(doom2fwad, "%sdoom2f.wad", doomwaddir);
679 #if defined __SASC || defined AROS
680 if (getenv ("HOME") != NULL) {
681 strcpy (home, getenv("HOME"));
682 if (home[strlen(home)-1] != '/' && home[strlen(home)-1] != ':')
683 strcat (home, "/");
684 } else
685 home[0] = '\0';
686 #else
687 home = getenv("HOME");
688 if (!home)
689 I_Error("Please set $HOME to your home directory");
690 #endif
691 sprintf(basedefault, "%s.doomrc", home);
692 #endif
694 if (M_CheckParm ("-shdev"))
696 gamemode = shareware;
697 devparm = true;
698 D_AddFile (DEVDATA"doom1.wad");
699 D_AddFile (DEVMAPS"data_se/texture1.lmp");
700 D_AddFile (DEVMAPS"data_se/pnames.lmp");
701 strcpy (basedefault,DEVDATA"default.cfg");
702 return;
705 if (M_CheckParm ("-regdev"))
707 gamemode = registered;
708 devparm = true;
709 D_AddFile (DEVDATA"doom.wad");
710 D_AddFile (DEVMAPS"data_se/texture1.lmp");
711 D_AddFile (DEVMAPS"data_se/texture2.lmp");
712 D_AddFile (DEVMAPS"data_se/pnames.lmp");
713 strcpy (basedefault,DEVDATA"default.cfg");
714 return;
717 if (M_CheckParm ("-comdev"))
719 gamemode = commercial;
720 devparm = true;
721 /* I don't bother
722 if(plutonia)
723 D_AddFile (DEVDATA"plutonia.wad");
724 else if(tnt)
725 D_AddFile (DEVDATA"tnt.wad");
726 else*/
727 D_AddFile (DEVDATA"doom2.wad");
729 D_AddFile (DEVMAPS"cdata/texture1.lmp");
730 D_AddFile (DEVMAPS"cdata/pnames.lmp");
731 strcpy (basedefault,DEVDATA"default.cfg");
732 return;
735 if ( !access (doom2fwad,R_OK) )
737 gamemode = commercial;
738 // C'est ridicule!
739 // Let's handle languages in config files, okay?
740 language = french;
741 printf("French version\n");
742 D_AddFile (doom2fwad);
743 return;
746 if ( !access (doom2wad,R_OK) )
748 gamemode = commercial;
749 D_AddFile (doom2wad);
750 return;
753 if ( !access (plutoniawad, R_OK ) )
755 gamemode = commercial;
756 D_AddFile (plutoniawad);
757 return;
760 if ( !access ( tntwad, R_OK ) )
762 gamemode = commercial;
763 D_AddFile (tntwad);
764 return;
767 if ( !access (doomuwad,R_OK) )
769 gamemode = retail;
770 D_AddFile (doomuwad);
771 return;
774 if ( !access (doomwad,R_OK) )
776 gamemode = registered;
777 D_AddFile (doomwad);
778 return;
781 if ( !access (doom1wad,R_OK) )
783 gamemode = shareware;
784 D_AddFile (doom1wad);
785 return;
788 printf("Game mode indeterminate.\n");
789 gamemode = indetermined;
791 // We don't abort. Let's see what the PWAD contains.
792 //exit(1);
793 //I_Error ("Game mode indeterminate\n");
797 // Find a Response File
799 void FindResponseFile (void)
801 int i;
803 for (i = 1;i < myargc;i++)
804 if (myargv[i][0] == '@')
806 FILE * handle;
807 int size;
808 int k;
809 int index;
810 int indexinfile;
811 char *infile;
812 char *file;
813 char *moreargs[20];
814 char *firstargv;
816 // READ THE RESPONSE FILE INTO MEMORY
817 handle = fopen (&myargv[i][1],"rb");
818 if (!handle)
820 printf ("\nNo such response file!");
821 exit(1);
823 printf("Found response file %s!\n",&myargv[i][1]);
824 fseek (handle,0,SEEK_END);
825 size = ftell(handle);
826 fseek (handle,0,SEEK_SET);
827 file = malloc (size);
828 fread (file,size,1,handle);
829 fclose (handle);
831 // KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG
832 for (index = 0,k = i+1; k < myargc; k++)
833 moreargs[index++] = myargv[k];
835 firstargv = myargv[0];
836 myargv = malloc(sizeof(char *)*MAXARGVS);
837 memset(myargv,0,sizeof(char *)*MAXARGVS);
838 myargv[0] = firstargv;
840 infile = file;
841 indexinfile = k = 0;
842 indexinfile++; // SKIP PAST ARGV[0] (KEEP IT)
845 myargv[indexinfile++] = infile+k;
846 while(k < size &&
847 ((*(infile+k)>= ' '+1) && (*(infile+k)<='z')))
848 k++;
849 *(infile+k) = 0;
850 while(k < size &&
851 ((*(infile+k)<= ' ') || (*(infile+k)>'z')))
852 k++;
853 } while(k < size);
855 for (k = 0;k < index;k++)
856 myargv[indexinfile++] = moreargs[k];
857 myargc = indexinfile;
859 // DISPLAY ARGS
860 printf("%d command-line args:\n",myargc);
861 for (k=1;k<myargc;k++)
862 printf("%s\n",myargv[k]);
864 break;
870 // D_DoomMain
872 void D_DoomMain (void)
874 int p;
875 char file[256];
877 FindResponseFile ();
878 IdentifyVersion ();
879 #ifndef AROS
880 setbuf (stdout, NULL);
881 #endif
882 modifiedgame = false;
884 nomonsters = M_CheckParm ("-nomonsters");
885 respawnparm = M_CheckParm ("-respawn");
886 fastparm = M_CheckParm ("-fast");
887 rotatemap = M_CheckParm ("-rotatemap");
888 devparm = M_CheckParm ("-devparm");
889 maponhu = (M_CheckParm ("-maponhu") != 0);
891 if (M_CheckParm ("-altdeath"))
892 deathmatch = 2;
893 else if (M_CheckParm ("-deathmatch"))
894 deathmatch = 1;
896 switch ( gamemode )
898 case retail:
899 sprintf (title,
901 "The Ultimate DOOM Startup v%i.%i"
902 " ",
903 VERSION/100,VERSION%100);
904 break;
905 case shareware:
906 sprintf (title,
908 "DOOM Shareware Startup v%i.%i"
909 " ",
910 VERSION/100,VERSION%100);
911 break;
912 case registered:
913 sprintf (title,
915 "DOOM Registered Startup v%i.%i"
916 " ",
917 VERSION/100,VERSION%100);
918 break;
919 case commercial:
920 sprintf (title,
922 "DOOM 2: Hell on Earth v%i.%i"
923 " ",
924 VERSION/100,VERSION%100);
925 break;
926 /*FIXME
927 case pack_plut:
928 sprintf (title,
930 "DOOM 2: Plutonia Experiment v%i.%i"
931 " ",
932 VERSION/100,VERSION%100);
933 break;
934 case pack_tnt:
935 sprintf (title,
937 "DOOM 2: TNT - Evilution v%i.%i"
938 " ",
939 VERSION/100,VERSION%100);
940 break;
942 default:
943 sprintf (title,
945 "Public DOOM - v%i.%i"
946 " ",
947 VERSION/100,VERSION%100);
948 break;
951 printf ("%s\n",title);
953 if (devparm)
954 printf(D_DEVSTR);
956 if (M_CheckParm("-cdrom"))
958 printf(D_CDROM);
959 #ifdef __SASC
960 mkdir("c:\\doomdata");
961 #else
962 mkdir("c:\\doomdata",0);
963 #endif
964 strcpy (basedefault,"c:/doomdata/default.cfg");
967 // turbo option
968 if ( (p=M_CheckParm ("-turbo")) )
970 int scale = 200;
971 extern int forwardmove[2];
972 extern int sidemove[2];
974 if (p<myargc-1)
975 scale = atoi (myargv[p+1]);
976 if (scale < 10)
977 scale = 10;
978 if (scale > 400)
979 scale = 400;
980 printf ("turbo scale: %i%%\n",scale);
981 forwardmove[0] = forwardmove[0]*scale/100;
982 forwardmove[1] = forwardmove[1]*scale/100;
983 sidemove[0] = sidemove[0]*scale/100;
984 sidemove[1] = sidemove[1]*scale/100;
987 // add any files specified on the command line with -file wadfile
988 // to the wad list
990 // convenience hack to allow -wart e m to add a wad file
991 // prepend a tilde to the filename so wadfile will be reloadable
992 p = M_CheckParm ("-wart");
993 if (p)
995 myargv[p][4] = 'p'; // big hack, change to -warp
997 // Map name handling.
998 switch (gamemode )
1000 case shareware:
1001 case retail:
1002 case registered:
1003 sprintf (file,"~"DEVMAPS"E%cM%c.wad",
1004 myargv[p+1][0], myargv[p+2][0]);
1005 printf("Warping to Episode %s, Map %s.\n",
1006 myargv[p+1],myargv[p+2]);
1007 break;
1009 case commercial:
1010 default:
1011 p = atoi (myargv[p+1]);
1012 if (p<10)
1013 sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p);
1014 else
1015 sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p);
1016 break;
1018 D_AddFile (file);
1021 p = M_CheckParm ("-file");
1022 if (p)
1024 // the parms after p are wadfile/lump names,
1025 // until end of parms or another - preceded parm
1026 modifiedgame = true; // homebrew levels
1027 while (++p != myargc && myargv[p][0] != '-')
1028 D_AddFile (myargv[p]);
1031 /* DeHacked Patch !! */
1032 p = M_CheckParm ("-deh");
1033 if (p)
1035 // the parms after p are wadfile/lump names,
1036 // until end of parms or another - preceded parm
1037 //modifiedgame = true; // homebrew levels
1038 while (++p != myargc && myargv[p][0] != '-')
1039 DE_AddDeh(myargv[p]);
1042 p = M_CheckParm ("-playdemo");
1044 if (!p)
1045 p = M_CheckParm ("-timedemo");
1047 if (p && p < myargc-1)
1049 sprintf (file,"%s.lmp", myargv[p+1]);
1050 D_AddFile (file);
1051 printf("Playing demo %s.lmp.\n",myargv[p+1]);
1054 // get skill / episode / map from parms
1055 startskill = sk_medium;
1056 startepisode = 1;
1057 startmap = 1;
1058 autostart = false;
1061 p = M_CheckParm ("-skill");
1062 if (p && p < myargc-1)
1064 startskill = myargv[p+1][0]-'1';
1065 autostart = true;
1068 p = M_CheckParm ("-episode");
1069 if (p && p < myargc-1)
1071 startepisode = myargv[p+1][0]-'0';
1072 startmap = 1;
1073 autostart = true;
1076 p = M_CheckParm ("-timer");
1077 if (p && p < myargc-1 && deathmatch)
1079 int time;
1080 time = atoi(myargv[p+1]);
1081 printf("Levels will end after %d minute",time);
1082 if (time>1)
1083 putchar('s');
1084 printf(".\n");
1087 p = M_CheckParm ("-avg");
1088 if (p && p < myargc-1 && deathmatch)
1089 printf("Austin Virtual Gaming: Levels will end after 20 minutes\n");
1091 p = M_CheckParm ("-warp");
1092 if (p && p < myargc-1)
1094 if (gamemode == commercial)
1095 startmap = atoi (myargv[p+1]);
1096 else
1098 startepisode = myargv[p+1][0]-'0';
1099 startmap = myargv[p+2][0]-'0';
1101 autostart = true;
1104 // init subsystems
1105 printf ("V_Init: allocate screens.\n");
1106 V_Init ();
1108 printf ("M_LoadDefaults: Load system defaults.\n");
1109 M_LoadDefaults (); // load before initing other systems
1111 printf ("Z_Init: Init zone memory allocation daemon. \n");
1112 Z_Init ();
1114 printf ("W_Init: Init WADfiles.\n");
1115 W_InitMultipleFiles (wadfiles);
1118 // Check for -file in shareware
1119 if (modifiedgame)
1121 // These are the lumps that will be checked in IWAD,
1122 // if any one is not present, execution will be aborted.
1123 char name[23][8]=
1125 "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9",
1126 "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9",
1127 "dphoof","bfgga0","heada1","cybra1","spida1d1"
1129 int i;
1131 if ( gamemode == shareware)
1132 I_Error("\nYou cannot -file with the shareware "
1133 "version. Register!");
1135 // Check for fake IWAD with right name,
1136 // but w/o all the lumps of the registered version.
1137 if (gamemode == registered)
1138 for (i = 0;i < 23; i++)
1139 if (W_CheckNumForName(name[i])<0)
1140 I_Error("\nThis is not the registered version.");
1143 // Iff additonal PWAD files are used, print modified banner
1144 if (modifiedgame)
1146 /*m*/printf (
1147 "===========================================================================\n"
1148 "ATTENTION: This version of DOOM has been modified. If you would like to\n"
1149 "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n"
1150 " You will not receive technical support for modified games.\n"
1151 " press enter to continue\n"
1152 "===========================================================================\n"
1154 getchar ();
1158 // Check and print which version is executed.
1159 switch ( gamemode )
1161 case shareware:
1162 case indetermined:
1163 printf (
1164 "===========================================================================\n"
1165 " Shareware!\n"
1166 "===========================================================================\n"
1168 break;
1169 case registered:
1170 case retail:
1171 case commercial:
1172 printf (
1173 "===========================================================================\n"
1174 " Commercial product - do not distribute!\n"
1175 " Please report software piracy to the SPA: 1-800-388-PIR8\n"
1176 "===========================================================================\n"
1178 break;
1180 default:
1181 // Ouch.
1182 break;
1185 printf ("M_Init: Init miscellaneous info.\n");
1186 M_Init ();
1188 printf ("R_Init: Init DOOM refresh daemon - ");
1189 R_Init ();
1191 printf ("\nP_Init: Init Playloop state.\n");
1192 P_Init ();
1194 printf ("I_Init: Setting up machine state.\n");
1195 I_Init ();
1197 printf ("D_CheckNetGame: Checking network game status.\n");
1198 D_CheckNetGame ();
1200 printf ("S_Init: Setting up sound.\n");
1201 S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ );
1203 printf ("HU_Init: Setting up heads up display.\n");
1204 HU_Init ();
1206 printf ("ST_Init: Init status bar.\n");
1207 ST_Init ();
1209 // check for a driver that wants intermission stats
1210 p = M_CheckParm ("-statcopy");
1211 if (p && p<myargc-1)
1213 // for statistics driver
1214 extern void* statcopy;
1216 statcopy = (void*)atoi(myargv[p+1]);
1217 printf ("External statistics registered.\n");
1220 // start the apropriate game based on parms
1221 p = M_CheckParm ("-record");
1223 if (p && p < myargc-1)
1225 G_RecordDemo (myargv[p+1]);
1226 autostart = true;
1229 p = M_CheckParm ("-playdemo");
1230 if (p && p < myargc-1)
1232 singledemo = true; // quit after one demo
1233 G_DeferedPlayDemo (myargv[p+1]);
1234 D_DoomLoop (); // never returns
1237 p = M_CheckParm ("-timedemo");
1238 if (p && p < myargc-1)
1240 G_TimeDemo (myargv[p+1]);
1241 D_DoomLoop (); // never returns
1244 p = M_CheckParm ("-loadgame");
1245 if (p && p < myargc-1)
1247 if (M_CheckParm("-cdrom"))
1248 sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
1249 else
1250 sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
1251 G_LoadGame (file);
1255 if ( gameaction != ga_loadgame )
1257 if (autostart || netgame)
1258 G_InitNew (startskill, startepisode, startmap);
1259 else
1260 D_StartTitle (); // start up intro loop
1263 D_DoomLoop (); // never returns