Subversion Repositories Kolibri OS

Rev

Rev 300 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 300 Rev 333
1
// Emacs style mode select   -*- C++ -*- 
1
// Emacs style mode select   -*- C++ -*- 
2
//-----------------------------------------------------------------------------
2
//-----------------------------------------------------------------------------
3
//
3
//
4
// $Id:$
4
// $Id:$
5
//
5
//
6
// Copyright (C) 1993-1996 by id Software, Inc.
6
// Copyright (C) 1993-1996 by id Software, Inc.
7
//
7
//
8
// This source is available for distribution and/or modification
8
// This source is available for distribution and/or modification
9
// only under the terms of the DOOM Source Code License as
9
// only under the terms of the DOOM Source Code License as
10
// published by id Software. All rights reserved.
10
// published by id Software. All rights reserved.
11
//
11
//
12
// The source is distributed in the hope that it will be useful,
12
// The source is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
14
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
15
// for more details.
15
// for more details.
16
//
16
//
17
// $Log:$
17
// $Log:$
18
//
18
//
19
// DESCRIPTION:
19
// DESCRIPTION:
20
//	DOOM main program (D_DoomMain) and game loop (D_DoomLoop),
20
//      DOOM main program (D_DoomMain) and game loop (D_DoomLoop),
21
//	plus functions to determine game mode (shareware, registered),
21
//      plus functions to determine game mode (shareware, registered),
22
//	parse command line parameters, configure game parameters (turbo),
22
//      parse command line parameters, configure game parameters (turbo),
23
//	and call the startup functions.
23
//      and call the startup functions.
24
//
24
//
25
//-----------------------------------------------------------------------------
25
//-----------------------------------------------------------------------------
26
 
26
 
27
 
27
 
28
static const char rcsid[] = "$Id: d_main.c,v 1.8 1997/02/03 22:45:09 b1 Exp $";
28
static const char rcsid[] = "$Id: d_main.c,v 1.8 1997/02/03 22:45:09 b1 Exp $";
29
 
29
 
30
#define	BGCOLOR		7
30
#define BGCOLOR         7
31
#define	FGCOLOR		8
31
#define FGCOLOR         8
32
 
32
 
33
 
-
 
34
#include 
-
 
35
#include 
-
 
36
 
-
 
37
extern int access(char *file, int mode);
-
 
38
 
33
 
39
#define R_OK	4
-
 
40
#if 0
-
 
41
static int access(char *file, int mode)
-
 
42
{
-
 
43
	FILE *test_fp;
-
 
44
 
-
 
45
	test_fp = fopen(file, "r");
-
 
46
	if ( test_fp != NULL ) {
-
 
47
		fclose(test_fp);
-
 
48
		return(0);
-
 
49
	}
-
 
50
	return(-1);
-
 
51
}
-
 
-
 
34
#define R_OK    4
-
 
35
 
52
#endif
36
#include 
53
 
37
#include 
54
 
38
 
55
#include "doomdef.h"
39
#include "doomdef.h"
56
#include "doomstat.h"
40
#include "doomstat.h"
57
 
41
 
58
#include "dstrings.h"
42
#include "dstrings.h"
59
#include "sounds.h"
43
#include "sounds.h"
60
 
-
 
61
 
44
 
62
#include "z_zone.h"
45
#include "z_zone.h"
63
#include "w_wad.h"
46
#include "w_wad.h"
64
#include "s_sound.h"
47
#include "s_sound.h"
65
#include "v_video.h"
48
#include "v_video.h"
66
 
49
 
67
#include "f_finale.h"
50
#include "f_finale.h"
68
#include "f_wipe.h"
51
#include "f_wipe.h"
69
 
52
 
70
#include "m_argv.h"
53
#include "m_argv.h"
71
#include "m_misc.h"
54
#include "m_misc.h"
72
#include "m_menu.h"
55
#include "m_menu.h"
73
 
56
 
74
#include "i_system.h"
57
#include "i_system.h"
75
#include "i_sound.h"
58
#include "i_sound.h"
76
#include "i_video.h"
59
#include "i_video.h"
77
 
60
 
78
#include "g_game.h"
61
#include "g_game.h"
79
 
62
 
80
#include "hu_stuff.h"
63
#include "hu_stuff.h"
81
#include "wi_stuff.h"
64
#include "wi_stuff.h"
82
#include "st_stuff.h"
65
#include "st_stuff.h"
83
#include "am_map.h"
66
#include "am_map.h"
84
 
67
 
85
#include "p_setup.h"
68
#include "p_setup.h"
86
#include "r_local.h"
69
#include "r_local.h"
87
 
70
 
-
 
71
 
88
 
72
 
-
 
73
#include "d_main.h"
-
 
74
//#include "kolibri.h"
-
 
75
 
-
 
76
 
89
#include "d_main.h"
77
extern int access(char *file, int mode);
90
 
78
 
91
//
79
//
92
// D-DoomLoop()
80
// D-DoomLoop()
93
// Not a globally visible function,
81
// Not a globally visible function,
94
//  just included for source reference,
82
//  just included for source reference,
95
//  called by D_DoomMain, never exits.
83
//  called by D_DoomMain, never exits.
96
// Manages timing and IO,
84
// Manages timing and IO,
97
//  calls all ?_Responder, ?_Ticker, and ?_Drawer,
85
//  calls all ?_Responder, ?_Ticker, and ?_Drawer,
98
//  calls I_GetTime, I_StartFrame, and I_StartTic
86
//  calls I_GetTime, I_StartFrame, and I_StartTic
99
//
87
//
100
void D_DoomLoop (void);
88
void D_DoomLoop (void);
101
 
89
 
102
 
90
 
103
char*	wadfiles[MAXWADFILES];
91
char*   wadfiles[MAXWADFILES];
104
 
92
 
105
 
93
 
106
boolean	devparm;	// started game with -devparm
94
boolean devparm;        // started game with -devparm
107
boolean nomonsters;	// checkparm of -nomonsters
95
boolean nomonsters;     // checkparm of -nomonsters
108
boolean respawnparm;	// checkparm of -respawn
96
boolean respawnparm;    // checkparm of -respawn
109
boolean fastparm;	// checkparm of -fast
97
boolean fastparm;       // checkparm of -fast
110
 
98
 
111
boolean  drone;
99
boolean  drone;
112
 
100
 
113
boolean		singletics = false; // debug flag to cancel adaptiveness
101
boolean         singletics = false; // debug flag to cancel adaptiveness
114
 
102
 
115
 
103
 
116
 
104
 
117
//extern int soundVolume;
105
//extern int soundVolume;
118
//extern  int	sfxVolume;
106
//extern  int   sfxVolume;
119
//extern  int	musicVolume;
107
//extern  int   musicVolume;
120
 
108
 
121
extern  boolean	inhelpscreens;
109
extern  boolean inhelpscreens;
122
 
110
 
123
skill_t		startskill;
111
skill_t         startskill;
124
int             startepisode;
112
int             startepisode;
125
int		startmap;
113
int             startmap;
126
boolean		autostart;
114
boolean         autostart;
127
 
115
 
128
FILE*		debugfile;
116
FILE*           debugfile;
129
 
117
 
130
boolean		advancedemo;
118
boolean         advancedemo;
131
 
119
 
132
 
120
 
133
 
121
 
134
 
122
 
135
char		wadfile[1024];		// primary wad file
123
char            wadfile[1024];          // primary wad file
136
char		mapdir[1024];           // directory of development maps
124
char            mapdir[1024];           // directory of development maps
137
char		basedefault[1024];      // default file
125
char            basedefault[1024];      // default file
138
 
126
 
139
 
127
 
140
void D_CheckNetGame (void);
128
void D_CheckNetGame (void);
141
void D_ProcessEvents (void);
129
void D_ProcessEvents (void);
142
void G_BuildTiccmd (ticcmd_t* cmd);
130
void G_BuildTiccmd (ticcmd_t* cmd);
143
void D_DoAdvanceDemo (void);
131
void D_DoAdvanceDemo (void);
144
 
132
 
145
 
133
 
146
//
134
//
147
// EVENT HANDLING
135
// EVENT HANDLING
148
//
136
//
149
// Events are asynchronous inputs generally generated by the game user.
137
// Events are asynchronous inputs generally generated by the game user.
150
// Events can be discarded if no responder claims them
138
// Events can be discarded if no responder claims them
151
//
139
//
152
event_t         events[MAXEVENTS];
140
event_t         events[MAXEVENTS];
153
int             eventhead;
141
int             eventhead;
154
int 		eventtail;
142
int             eventtail;
155
 
143
 
156
 
144
 
157
//
145
//
158
// D_PostEvent
146
// D_PostEvent
159
// Called by the I/O functions when input is detected
147
// Called by the I/O functions when input is detected
160
//
148
//
161
void D_PostEvent (event_t* ev)
149
void D_PostEvent (event_t* ev)
162
{
150
{
163
    events[eventhead] = *ev;
151
    events[eventhead] = *ev;
164
    eventhead = (++eventhead)&(MAXEVENTS-1);
152
    eventhead = (++eventhead)&(MAXEVENTS-1);
165
}
153
}
166
 
154
 
167
 
155
 
168
//
156
//
169
// D_ProcessEvents
157
// D_ProcessEvents
170
// Send all the events of the given timestamp down the responder chain
158
// Send all the events of the given timestamp down the responder chain
171
//
159
//
172
void D_ProcessEvents (void)
160
void D_ProcessEvents (void)
173
{
161
{
174
    event_t*	ev;
162
    event_t*    ev;
175
	
163
        
176
    // IF STORE DEMO, DO NOT ACCEPT INPUT
164
    // IF STORE DEMO, DO NOT ACCEPT INPUT
177
    if ( ( gamemode == commercial )
165
    if ( ( gamemode == commercial )
178
	 && (W_CheckNumForName("map01")<0) )
166
         && (W_CheckNumForName("map01")<0) )
179
      return;
167
      return;
180
	
168
        
181
    for ( ; eventtail != eventhead ; eventtail = (++eventtail)&(MAXEVENTS-1) )
169
    for ( ; eventtail != eventhead ; eventtail = (++eventtail)&(MAXEVENTS-1) )
182
    {
170
    {
183
	ev = &events[eventtail];
171
        ev = &events[eventtail];
184
	if (M_Responder (ev))
172
        if (M_Responder (ev))
185
	    continue;               // menu ate the event
173
            continue;               // menu ate the event
186
	G_Responder (ev);
174
        G_Responder (ev);
187
    }
175
    }
188
}
176
}
189
 
177
 
190
 
178
 
191
 
179
 
192
 
180
 
193
//
181
//
194
// D_Display
182
// D_Display
195
//  draw current display, possibly wiping it from the previous
183
//  draw current display, possibly wiping it from the previous
196
//
184
//
197
 
185
 
198
// wipegamestate can be set to -1 to force a wipe on the next draw
186
// wipegamestate can be set to -1 to force a wipe on the next draw
199
gamestate_t     wipegamestate = GS_DEMOSCREEN;
187
gamestate_t     wipegamestate = GS_DEMOSCREEN;
200
extern  boolean setsizeneeded;
188
extern  boolean setsizeneeded;
201
extern  int             showMessages;
189
extern  int             showMessages;
202
void R_ExecuteSetViewSize (void);
190
void R_ExecuteSetViewSize (void);
203
 
191
 
204
 
192
 
205
// #define XXX(n)	__libclog_printf("d_main.c: %u\n",n)
193
// #define XXX(n)       __libclog_printf("d_main.c: %u\n",n)
206
#define XXX(n)
194
#define XXX(n)
207
 
195
 
208
void D_Display (void)
196
void D_Display (void)
209
{
197
{
210
    static  boolean		viewactivestate = false;
198
    static  boolean             viewactivestate = false;
211
    static  boolean		menuactivestate = false;
199
    static  boolean             menuactivestate = false;
212
    static  boolean		inhelpscreensstate = false;
200
    static  boolean             inhelpscreensstate = false;
213
    static  boolean		fullscreen = false;
201
    static  boolean             fullscreen = false;
214
    static  gamestate_t		oldgamestate = -1;
202
    static  gamestate_t         oldgamestate = -1;
215
    static  int			borderdrawcount;
203
    static  int                 borderdrawcount;
216
    int				nowtime;
204
    int                         nowtime;
217
    int				tics;
205
    int                         tics;
218
    int				wipestart;
206
    int                         wipestart;
219
    int				y;
207
    int                         y;
220
    boolean			done;
208
    boolean                     done;
221
    boolean			wipe;
209
    boolean                     wipe;
222
    boolean			redrawsbar;
210
    boolean                     redrawsbar;
223
 
211
 
224
    if (nodrawers)
212
    if (nodrawers)
225
    {
213
    {
226
	XXX(0);
214
        XXX(0);
227
	return;                    // for comparative timing / profiling
215
        return;                    // for comparative timing / profiling
228
    }		
216
    }           
229
    redrawsbar = false;
217
    redrawsbar = false;
230
    
218
    
231
    // change the view size if needed
219
    // change the view size if needed
232
    if (setsizeneeded)
220
    if (setsizeneeded)
233
    {
221
    {
234
	XXX(1);
222
        XXX(1);
235
	R_ExecuteSetViewSize ();
223
        R_ExecuteSetViewSize ();
236
	XXX(2);
224
        XXX(2);
237
	oldgamestate = -1;                      // force background redraw
225
        oldgamestate = -1;                      // force background redraw
238
	borderdrawcount = 3;
226
        borderdrawcount = 3;
239
    }
227
    }
240
 
228
 
241
    // save the current screen if about to wipe
229
    // save the current screen if about to wipe
242
	XXX(3);
230
        XXX(3);
243
    if (gamestate != wipegamestate)
231
    if (gamestate != wipegamestate)
244
    {
232
    {
245
	wipe = true;
233
        wipe = true;
246
	XXX(4);
-
 
247
	wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
234
        wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
248
	XXX(5);
-
 
249
    }
235
    }
250
    else 
236
    else 
251
	wipe = false;
237
        wipe = false;
252
	XXX(6);
238
        XXX(6);
253
 
239
 
254
    if (gamestate == GS_LEVEL && gametic)
240
    if (gamestate == GS_LEVEL && gametic)
255
    {
241
    {
256
	XXX(7);
-
 
257
	HU_Erase();
242
        HU_Erase();
258
	XXX(8);
-
 
259
    }
243
    }
260
    // do buffered drawing
244
    // do buffered drawing
261
	XXX(9);
245
        XXX(9);
262
    switch (gamestate)
246
    switch (gamestate)
263
    {
247
    {
264
      case GS_LEVEL:
248
      case GS_LEVEL:
265
	XXX(10);
249
        XXX(10);
266
	if (!gametic)
250
        if (!gametic)
267
	    break;
251
            break;
268
	if (automapactive)
252
        if (automapactive)
269
	    AM_Drawer ();
253
            AM_Drawer ();
270
	if (wipe || (viewheight != 200 && fullscreen) )
254
        if (wipe || (viewheight != 200 && fullscreen) )
271
	    redrawsbar = true;
255
            redrawsbar = true;
272
	if (inhelpscreensstate && !inhelpscreens)
256
        if (inhelpscreensstate && !inhelpscreens)
273
	    redrawsbar = true;              // just put away the help screen
257
            redrawsbar = true;              // just put away the help screen
274
	ST_Drawer (viewheight == 200, redrawsbar );
258
        ST_Drawer (viewheight == 200, redrawsbar );
275
	fullscreen = viewheight == 200;
259
        fullscreen = viewheight == 200;
276
	break;
260
        break;
277
 
261
 
278
      case GS_INTERMISSION:
262
      case GS_INTERMISSION:
279
	XXX(11);
263
        XXX(11);
280
	WI_Drawer ();
264
        WI_Drawer ();
281
	break;
265
        break;
282
 
266
 
283
      case GS_FINALE:
267
      case GS_FINALE:
284
	XXX(12);
268
        XXX(12);
285
	F_Drawer ();
269
        F_Drawer ();
286
	break;
270
        break;
287
 
271
 
288
      case GS_DEMOSCREEN:
272
      case GS_DEMOSCREEN:
289
	XXX(13);
273
        XXX(13);
290
	D_PageDrawer ();
274
        D_PageDrawer ();
291
	XXX(14);
275
        XXX(14);
292
	break;
276
        break;
293
    }
277
    }
294
    
278
    
295
    // draw buffered stuff to screen
279
    // draw buffered stuff to screen
296
	XXX(15);
280
        XXX(15);
297
    I_UpdateNoBlit ();
281
    I_UpdateNoBlit ();
298
	XXX(16);
282
        XXX(16);
299
    
283
    
300
    // draw the view directly
284
    // draw the view directly
301
    if (gamestate == GS_LEVEL && !automapactive && gametic)
285
    if (gamestate == GS_LEVEL && !automapactive && gametic)
302
	R_RenderPlayerView (&players[displayplayer]);
286
        R_RenderPlayerView (&players[displayplayer]);
303
	XXX(17);
287
        XXX(17);
304
 
288
 
305
    if (gamestate == GS_LEVEL && gametic)
289
    if (gamestate == GS_LEVEL && gametic)
306
	HU_Drawer ();
290
        HU_Drawer ();
307
	XXX(18);
291
        XXX(18);
308
    
292
    
309
    // clean up border stuff
293
    // clean up border stuff
310
    if (gamestate != oldgamestate && gamestate != GS_LEVEL)
294
    if (gamestate != oldgamestate && gamestate != GS_LEVEL)
311
	I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE));
295
        I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE));
312
	XXX(19);
296
        XXX(19);
313
 
297
 
314
    // see if the border needs to be initially drawn
298
    // see if the border needs to be initially drawn
315
    if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL)
299
    if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL)
316
    {
300
    {
317
	XXX(20);
301
        XXX(20);
318
	viewactivestate = false;        // view was not active
302
        viewactivestate = false;        // view was not active
319
	R_FillBackScreen ();    // draw the pattern into the back screen
303
        R_FillBackScreen ();    // draw the pattern into the back screen
320
	XXX(21);
304
        XXX(21);
321
    }
305
    }
322
	XXX(22);
306
        XXX(22);
323
 
307
 
324
    // see if the border needs to be updated to the screen
308
    // see if the border needs to be updated to the screen
325
    if (gamestate == GS_LEVEL && !automapactive && scaledviewwidth != 320)
309
    if (gamestate == GS_LEVEL && !automapactive && scaledviewwidth != 320)
326
    {
310
    {
327
	XXX(23);
311
        XXX(23);
328
	if (menuactive || menuactivestate || !viewactivestate)
312
        if (menuactive || menuactivestate || !viewactivestate)
329
	    borderdrawcount = 3;
313
            borderdrawcount = 3;
330
	if (borderdrawcount)
314
        if (borderdrawcount)
331
	{
315
        {
332
	XXX(24);
316
        XXX(24);
333
	    R_DrawViewBorder ();    // erase old menu stuff
317
            R_DrawViewBorder ();    // erase old menu stuff
334
	XXX(25);
318
        XXX(25);
335
	    borderdrawcount--;
319
            borderdrawcount--;
336
	}
320
        }
337
 
321
 
338
    }
322
    }
339
	XXX(26);
323
        XXX(26);
340
 
324
 
341
    menuactivestate = menuactive;
325
    menuactivestate = menuactive;
342
    viewactivestate = viewactive;
326
    viewactivestate = viewactive;
343
    inhelpscreensstate = inhelpscreens;
327
    inhelpscreensstate = inhelpscreens;
344
    oldgamestate = wipegamestate = gamestate;
328
    oldgamestate = wipegamestate = gamestate;
345
    
329
    
346
    // draw pause pic
330
    // draw pause pic
347
    if (paused)
331
    if (paused)
348
    {
332
    {
349
	if (automapactive)
333
        if (automapactive)
350
	    y = 4;
334
            y = 4;
351
	else
335
        else
352
	    y = viewwindowy+4;
336
            y = viewwindowy+4;
353
	V_DrawPatchDirect(viewwindowx+(scaledviewwidth-68)/2,
337
        V_DrawPatchDirect(viewwindowx+(scaledviewwidth-68)/2,
354
			  y,0,W_CacheLumpName ("M_PAUSE", PU_CACHE));
338
                          y,0,W_CacheLumpName ("M_PAUSE", PU_CACHE));
355
    }
339
    }
356
 
340
 
357
 
341
 
358
    // menus go directly to the screen
342
    // menus go directly to the screen
359
	XXX(27);
343
        XXX(27);
360
    M_Drawer ();          // menu is drawn even on top of everything
344
    M_Drawer ();          // menu is drawn even on top of everything
361
	XXX(28);
345
        XXX(28);
362
    NetUpdate ();         // send out any new accumulation
346
    NetUpdate ();         // send out any new accumulation
363
	XXX(29);
347
        XXX(29);
364
 
348
 
365
 
349
 
366
    // normal update
350
    // normal update
367
    if (!wipe)
351
    if (!wipe)
368
    {
352
    {
369
	XXX(30);
353
        XXX(30);
370
	I_FinishUpdate ();              // page flip or blit buffer
354
        I_FinishUpdate ();              // page flip or blit buffer
371
	XXX(31);
355
        XXX(31);
372
	return;
356
        return;
373
    }
357
    }
374
	XXX(32);
358
        XXX(32);
375
    
359
    
376
    // wipe update
360
    // wipe update
377
    wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
361
    wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
378
	XXX(33);
362
        XXX(33);
379
 
363
 
380
    wipestart = I_GetTime () - 1;
364
    wipestart = I_GetTime () - 1;
381
 
365
 
382
	XXX(34);
366
        XXX(34);
383
    do
367
    do
384
    {
368
    {
385
	do
369
        do
386
	{
370
        {
387
	    nowtime = I_GetTime ();
371
            nowtime = I_GetTime ();
388
	    tics = nowtime - wipestart;
372
            tics = nowtime - wipestart;
389
	} while (!tics);
373
        } while (!tics);
390
	wipestart = nowtime;
374
        wipestart = nowtime;
391
	XXX(35);
375
        XXX(35);
392
	done = wipe_ScreenWipe(wipe_Melt
376
        done = wipe_ScreenWipe(wipe_Melt
393
			       , 0, 0, SCREENWIDTH, SCREENHEIGHT, tics);
377
                               , 0, 0, SCREENWIDTH, SCREENHEIGHT, tics);
394
	XXX(36);
378
        XXX(36);
395
	I_UpdateNoBlit ();
379
        I_UpdateNoBlit ();
396
	XXX(37);
380
        XXX(37);
397
	M_Drawer ();                            // menu is drawn even on top of wipes
381
        M_Drawer ();                            // menu is drawn even on top of wipes
398
	XXX(38);
382
        XXX(38);
399
	I_FinishUpdate ();                      // page flip or blit buffer
383
        I_FinishUpdate ();                      // page flip or blit buffer
400
	XXX(39);
384
        XXX(39);
401
    } while (!done);
385
    } while (!done);
402
	XXX(40);
386
        XXX(40);
403
}
387
}
404
 
388
 
405
//
389
//
406
//  D_DoomLoop
390
//  D_DoomLoop
407
//
391
//
408
extern  boolean         demorecording;
392
extern  boolean         demorecording;
409
 
393
 
410
void D_DoomLoop (void)
394
void D_DoomLoop (void)
411
{
395
{
412
    if (demorecording)
396
    if (demorecording)
413
	G_BeginRecording ();
397
        G_BeginRecording ();
414
		
398
                
415
    if (M_CheckParm ("-debugfile"))
399
    if (M_CheckParm ("-debugfile"))
416
    {
400
    {
417
	char    filename[20];
401
        char    filename[32];
418
	sprintf (filename,"debug%i.txt",consoleplayer);
402
        sprintf (filename,"debug%i.txt",consoleplayer);
419
//	__libclog_printf ("debug output to: %s\n",filename);
-
 
420
	debugfile = fopen (filename,"w");
403
        debugfile = fopen (filename,"w");
421
    }
404
    }
422
	
405
        
423
    I_InitGraphics ();
406
    I_InitGraphics ();
424
 
407
 
425
    while (1)
408
    while (1)
426
    {
409
    {
427
	// frame syncronous IO operations
410
        // frame syncronous IO operations
428
	XXX(100);
411
        XXX(100);
429
	I_StartFrame ();                
412
        I_StartFrame ();                
430
	XXX(101);
413
        XXX(101);
431
	
414
        
432
	// process one or more tics
415
        // process one or more tics
433
	if (singletics)
416
        if (singletics)
434
	{
417
        {
435
	XXX(201);
-
 
436
	    I_StartTic ();
418
          I_StartTic ();
437
	XXX(202);
419
 
438
	    D_ProcessEvents ();
420
          D_ProcessEvents ();
439
	XXX(203);
421
 
440
	    G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]);
422
          G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]);
441
	XXX(204);
423
                    
442
	    if (advancedemo)
424
          if (advancedemo)
-
 
425
          { 
443
		D_DoAdvanceDemo ();
426
             D_DoAdvanceDemo ();
444
	XXX(205);
427
          };  
445
	    M_Ticker ();
428
          M_Ticker ();
446
	XXX(206);
-
 
447
	    G_Ticker ();
429
          G_Ticker ();
448
	    gametic++;
430
          gametic++;
449
	    maketic++;
431
          maketic++;
450
	}
432
        }
451
	else
433
        else
452
	{
-
 
453
	XXX(102);
-
 
454
	    TryRunTics (); // will run at least one tic
434
          TryRunTics (); // will run at least one tic
455
	XXX(103);
-
 
456
	}
-
 
457
 
435
 
458
	S_UpdateSounds (players[consoleplayer].mo);// move positional sounds
436
        S_UpdateSounds (players[consoleplayer].mo);// move positional sounds
459
 
-
 
460
	// Update display, next frame, with current state.
-
 
461
	XXX(104);
437
 
462
	D_Display ();
438
        D_Display ();
463
	I_UpdateSound(); 	
439
//      I_UpdateSound();        
464
	XXX(105);
440
        XXX(105);
465
    }
441
    }
466
}
442
}
467
 
443
 
468
 
444
 
469
 
445
 
470
//
446
//
471
//  DEMO LOOP
447
//  DEMO LOOP
472
//
448
//
473
int             demosequence;
449
int             demosequence;
474
int             pagetic;
450
int             pagetic;
475
char                    *pagename;
451
char                    *pagename;
476
 
452
 
477
 
453
 
478
//
454
//
479
// D_PageTicker
455
// D_PageTicker
480
// Handles timing for warped projection
456
// Handles timing for warped projection
481
//
457
//
482
void D_PageTicker (void)
458
void D_PageTicker (void)
483
{
459
{
484
    if (--pagetic < 0)
460
   if (--pagetic < 0)
485
	D_AdvanceDemo ();
461
      D_AdvanceDemo ();
486
}
462
}
487
 
463
 
488
 
464
 
489
 
465
 
490
//
466
//
491
// D_PageDrawer
467
// D_PageDrawer
492
//
468
//
493
void D_PageDrawer (void)
469
void D_PageDrawer (void)
494
{
470
{
495
    V_DrawPatch (0,0, 0, W_CacheLumpName(pagename, PU_CACHE));
471
    V_DrawPatch (0,0, 0, W_CacheLumpName(pagename, PU_CACHE));
496
}
472
}
497
 
473
 
498
 
474
 
499
//
475
//
500
// D_AdvanceDemo
476
// D_AdvanceDemo
501
// Called after each demo or intro demosequence finishes
477
// Called after each demo or intro demosequence finishes
502
//
478
//
503
void D_AdvanceDemo (void)
479
void D_AdvanceDemo (void)
504
{
480
{
505
    advancedemo = true;
481
    advancedemo = true;
506
}
482
}
507
 
483
 
508
 
484
 
509
//
485
//
510
// This cycles through the demo sequences.
486
// This cycles through the demo sequences.
511
// FIXME - version dependend demo numbers?
487
// FIXME - version dependend demo numbers?
512
//
488
//
513
 void D_DoAdvanceDemo (void)
489
 void D_DoAdvanceDemo (void)
514
{
490
{
515
    players[consoleplayer].playerstate = PST_LIVE;  // not reborn
491
    players[consoleplayer].playerstate = PST_LIVE;  // not reborn
516
    advancedemo = false;
492
    advancedemo = false;
517
    usergame = false;               // no save / end game here
493
    usergame = false;               // no save / end game here
518
    paused = false;
494
    paused = false;
519
    gameaction = ga_nothing;
495
    gameaction = ga_nothing;
520
 
496
 
521
    if ( gamemode == retail )
497
    if ( gamemode == retail )
522
      demosequence = (demosequence+1)%7;
498
      demosequence = (demosequence+1)%7;
523
    else
499
    else
524
      demosequence = (demosequence+1)%6;
500
      demosequence = (demosequence+1)%6;
525
    
501
    
526
    switch (demosequence)
502
    switch (demosequence)
527
    {
503
    {
528
      case 0:
504
      case 0:
529
	if ( gamemode == commercial )
505
        if ( gamemode == commercial )
530
	    pagetic = 35 * 11;
506
            pagetic = 35 * 11;
531
	else
507
        else
532
	    pagetic = 170;
508
            pagetic = 170;
533
	gamestate = GS_DEMOSCREEN;
509
        gamestate = GS_DEMOSCREEN;
534
	pagename = "TITLEPIC";
510
        pagename = "TITLEPIC";
535
//	if ( gamemode == commercial )
511
//      if ( gamemode == commercial )
536
//	  S_StartMusic(mus_dm2ttl);
512
//        S_StartMusic(mus_dm2ttl);
537
//	else
513
//      else
538
//	  S_StartMusic (mus_intro);
514
//        S_StartMusic (mus_intro);
539
	break;
515
        break;
540
      case 1:
516
      case 1:
541
	G_DeferedPlayDemo ("demo1");
517
        G_DeferedPlayDemo ("demo1");
542
	break;
518
        break;
543
      case 2:
519
      case 2:
544
	pagetic = 200;
520
        pagetic = 200;
545
	gamestate = GS_DEMOSCREEN;
521
        gamestate = GS_DEMOSCREEN;
546
	pagename = "CREDIT";
522
        pagename = "CREDIT";
547
	break;
523
        break;
548
      case 3:
524
      case 3:
549
	G_DeferedPlayDemo ("demo2");
525
        G_DeferedPlayDemo ("demo2");
550
	break;
526
        break;
551
      case 4:
527
      case 4:
552
	gamestate = GS_DEMOSCREEN;
528
        gamestate = GS_DEMOSCREEN;
553
	if ( gamemode == commercial)
529
        if ( gamemode == commercial)
554
	{
530
        {
555
	    pagetic = 35 * 11;
531
            pagetic = 35 * 11;
556
	    pagename = "TITLEPIC";
532
            pagename = "TITLEPIC";
557
//	    S_StartMusic(mus_dm2ttl);
533
//          S_StartMusic(mus_dm2ttl);
558
	}
534
        }
559
	else
535
        else
560
	{
536
        {
561
	    pagetic = 200;
537
            pagetic = 200;
562
 
538
 
563
	    if ( gamemode == retail )
539
            if ( gamemode == retail )
564
	      pagename = "CREDIT";
540
              pagename = "CREDIT";
565
	    else
541
            else
566
	      pagename = "HELP2";
542
              pagename = "HELP2";
567
	}
543
        }
568
	break;
544
        break;
569
      case 5:
545
      case 5:
570
	G_DeferedPlayDemo ("demo3");
546
        G_DeferedPlayDemo ("demo3");
571
	break;
547
        break;
572
        // THE DEFINITIVE DOOM Special Edition demo
548
        // THE DEFINITIVE DOOM Special Edition demo
573
      case 6:
549
      case 6:
574
	G_DeferedPlayDemo ("demo4");
550
        G_DeferedPlayDemo ("demo4");
575
	break;
551
        break;
576
    }
552
    }
577
}
553
}
578
 
554
 
579
 
555
 
580
 
556
 
581
//
557
//
582
// D_StartTitle
558
// D_StartTitle
583
//
559
//
584
void D_StartTitle (void)
560
void D_StartTitle (void)
585
{
561
{
586
    gameaction = ga_nothing;
562
    gameaction = ga_nothing;
587
    demosequence = -1;
563
    demosequence = -1;
588
    D_AdvanceDemo ();
564
    D_AdvanceDemo ();
589
}
565
}
590
 
566
 
591
 
567
 
592
 
568
 
593
 
569
 
594
//      print title for every printed line
570
//      print title for every printed line
595
char            title[128];
571
char            title[128];
596
 
572
 
597
 
573
 
598
 
574
 
599
//
575
//
600
// D_AddFile
576
// D_AddFile
601
//
577
//
602
void D_AddFile (char *file)
578
void D_AddFile (char *file)
603
{
579
{
604
    int     numwadfiles;
580
    int     numwadfiles;
605
    char    *newfile;
581
    char    *newfile;
606
	
582
        
607
    for (numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++)
583
    for (numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++)
608
	;
584
        ;
609
 
585
 
610
    newfile = malloc (strlen(file)+1);
586
    newfile = malloc (strlen(file)+1);
611
    strcpy (newfile, file);
587
    strcpy (newfile, file);
612
	
588
        
613
    wadfiles[numwadfiles] = newfile;
589
    wadfiles[numwadfiles] = newfile;
614
}
590
}
615
 
591
 
616
//
592
//
617
// IdentifyVersion
593
// IdentifyVersion
618
// Checks availability of IWAD files by name,
594
// Checks availability of IWAD files by name,
619
// to determine whether registered/commercial features
595
// to determine whether registered/commercial features
620
// should be executed (notably loading PWAD's).
596
// should be executed (notably loading PWAD's).
621
//
597
//
622
void IdentifyVersion (void)
598
void IdentifyVersion (void)
623
{
599
{
624
 
600
 
625
    char*	doom1wad;
601
    char*       doom1wad;
626
    char*	doomwad;
602
    char*       doomwad;
627
    char*	doomuwad;
603
    char*       doomuwad;
628
    char*	doom2wad;
604
    char*       doom2wad;
629
 
605
 
630
    char*	doom2fwad;
606
    char*       doom2fwad;
631
    char*	plutoniawad;
607
    char*       plutoniawad;
632
    char*	tntwad;
608
    char*       tntwad;
633
 
609
 
634
    char *home;
610
    char *home;
635
    char *doomwaddir;
611
    char *doomwaddir;
636
//    doomwaddir = getenv("DOOMWADDIR");
612
//    doomwaddir = getenv("DOOMWADDIR");
637
//    if (!doomwaddir)
613
//    if (!doomwaddir)
638
	doomwaddir = ".";
614
    doomwaddir = ".";
639
 
615
 
640
    // Commercial.
616
    // Commercial.
641
    doom2wad = malloc(strlen(doomwaddir)+1+9+1);
617
    doom2wad = malloc(strlen(doomwaddir)+1+9+1);
642
    sprintf(doom2wad, "%s/doom2.wad", doomwaddir);
618
    sprintf(doom2wad, "%s/doom2.wad", doomwaddir);
643
 
-
 
644
    // Retail.
619
    // Retail.
645
    doomuwad = malloc(strlen(doomwaddir)+1+8+1);
620
    doomuwad = malloc(strlen(doomwaddir)+1+8+1);
646
    sprintf(doomuwad, "%s/doomu.wad", doomwaddir);
621
    sprintf(doomuwad, "%s/doomu.wad", doomwaddir);
647
    
622
    
648
    // Registered.
623
    // Registered.
649
    doomwad = malloc(strlen(doomwaddir)+1+8+1);
624
    doomwad = malloc(strlen(doomwaddir)+1+8+1);
650
    sprintf(doomwad, "%s/doom.wad", doomwaddir);
625
    sprintf(doomwad, "%s/doom.wad", doomwaddir);
651
    
626
    
652
    // Shareware.
627
    // Shareware.
653
    doom1wad = malloc(strlen(doomwaddir)+1+9+1);
628
    doom1wad = malloc(strlen(doomwaddir)+1+9+1);
654
    sprintf(doom1wad, "%s/doom1.wad", doomwaddir);
629
    sprintf(doom1wad, "%s/doom1.wad", doomwaddir);
655
 
630
 
656
     // Bug, dear Shawn.
631
     // Bug, dear Shawn.
657
    // Insufficient malloc, caused spurious realloc errors.
632
    // Insufficient malloc, caused spurious realloc errors.
658
    plutoniawad = malloc(strlen(doomwaddir)+1+/*9*/12+1);
633
    plutoniawad = malloc(strlen(doomwaddir)+1+/*9*/12+1);
659
    sprintf(plutoniawad, "%s/plutonia.wad", doomwaddir);
634
    sprintf(plutoniawad, "%splutonia.wad", doomwaddir);
660
 
635
 
661
    tntwad = malloc(strlen(doomwaddir)+1+9+1);
636
    tntwad = malloc(strlen(doomwaddir)+1+9+1);
662
    sprintf(tntwad, "%s/tnt.wad", doomwaddir);
637
    sprintf(tntwad, "%s/tnt.wad", doomwaddir);
663
 
-
 
664
 
638
 
665
    // French stuff.
639
    // French stuff.
666
    doom2fwad = malloc(strlen(doomwaddir)+1+10+1);
640
    doom2fwad = malloc(strlen(doomwaddir)+1+10+1);
667
    sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir);
641
    sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir);
668
 
642
 
669
//    home = getenv("HOME");
643
//    home = getenv("HOME");
670
//    if (!home)
644
//    if (!home)
671
      home = ".";
645
    home = ".";
672
    sprintf(basedefault, "%s/doomrc.txt", home);
646
    sprintf(basedefault, "%s/doomrc.txt", home);
673
 
647
 
674
    if (M_CheckParm ("-shdev"))
648
    if (M_CheckParm ("-shdev"))
675
    {
649
    {
676
	gamemode = shareware;
650
        gamemode = shareware;
677
	devparm = true;
651
        devparm = true;
678
	D_AddFile (DEVDATA"doom1.wad");
652
        D_AddFile (DEVDATA"doom1.wad");
679
	D_AddFile (DEVMAPS"data_se/texture1.lmp");
653
        D_AddFile (DEVMAPS"data_se/texture1.lmp");
680
	D_AddFile (DEVMAPS"data_se/pnames.lmp");
654
        D_AddFile (DEVMAPS"data_se/pnames.lmp");
681
	strcpy (basedefault,DEVDATA"default.cfg");
655
        strcpy (basedefault,DEVDATA"default.cfg");
682
	return;
656
        return;
683
    }
657
    }
684
 
658
 
685
    if (M_CheckParm ("-regdev"))
659
    if (M_CheckParm ("-regdev"))
686
    {
660
    {
687
	gamemode = registered;
661
        gamemode = registered;
688
	devparm = true;
662
        devparm = true;
689
	D_AddFile (DEVDATA"doom.wad");
663
        D_AddFile (DEVDATA"doom.wad");
690
	D_AddFile (DEVMAPS"data_se/texture1.lmp");
664
        D_AddFile (DEVMAPS"data_se/texture1.lmp");
691
	D_AddFile (DEVMAPS"data_se/texture2.lmp");
665
        D_AddFile (DEVMAPS"data_se/texture2.lmp");
692
	D_AddFile (DEVMAPS"data_se/pnames.lmp");
666
        D_AddFile (DEVMAPS"data_se/pnames.lmp");
693
	strcpy (basedefault,DEVDATA"default.cfg");
667
        strcpy (basedefault,DEVDATA"default.cfg");
694
	return;
668
        return;
695
    }
669
    }
696
 
670
 
697
    if (M_CheckParm ("-comdev"))
671
    if (M_CheckParm ("-comdev"))
698
    {
672
    {
699
	gamemode = commercial;
673
        gamemode = commercial;
700
	devparm = true;
674
        devparm = true;
701
	/* I don't bother
675
        /* I don't bother
702
	if(plutonia)
676
        if(plutonia)
703
	    D_AddFile (DEVDATA"plutonia.wad");
677
            D_AddFile (DEVDATA"plutonia.wad");
704
	else if(tnt)
678
        else if(tnt)
705
	    D_AddFile (DEVDATA"tnt.wad");
679
            D_AddFile (DEVDATA"tnt.wad");
706
	else*/
680
        else*/
707
	    D_AddFile (DEVDATA"doom2.wad");
681
            D_AddFile (DEVDATA"doom2.wad");
708
	    
682
            
709
	D_AddFile (DEVMAPS"cdata/texture1.lmp");
683
        D_AddFile (DEVMAPS"cdata/texture1.lmp");
710
	D_AddFile (DEVMAPS"cdata/pnames.lmp");
684
        D_AddFile (DEVMAPS"cdata/pnames.lmp");
711
	strcpy (basedefault,DEVDATA"default.cfg");
685
        strcpy (basedefault,DEVDATA"default.cfg");
712
	return;
686
        return;
713
    }
687
    }
714
 
688
 
715
    if ( !access (doom2fwad,R_OK) )
689
    if ( !access (doom2fwad,R_OK) )
716
    {
690
    {
717
	gamemode = commercial;
691
        gamemode = commercial;
718
	// C'est ridicule!
692
        // C'est ridicule!
719
	// Let's handle languages in config files, okay?
693
        // Let's handle languages in config files, okay?
720
	language = french;
694
        language = french;
721
//	__libclog_printf("French version\n");
-
 
722
	D_AddFile (doom2fwad);
695
        D_AddFile (doom2fwad);
723
	return;
696
        return;
724
    }
697
    }
725
 
698
 
726
    if ( !access (doom2wad,R_OK) )
699
    if ( !access (doom2wad,R_OK) )
727
    {
700
    {
728
	gamemode = commercial;
701
        gamemode = commercial;
729
	D_AddFile (doom2wad);
702
        D_AddFile (doom2wad);
730
	return;
703
        return;
731
    }
704
    }
732
 
705
 
733
    if ( !access (plutoniawad, R_OK ) )
706
    if ( !access (plutoniawad, R_OK ) )
734
    {
707
    {
735
      gamemode = commercial;
708
      gamemode = commercial;
736
      D_AddFile (plutoniawad);
709
      D_AddFile (plutoniawad);
737
      return;
710
      return;
738
    }
711
    }
739
 
712
 
740
    if ( !access ( tntwad, R_OK ) )
713
    if ( !access ( tntwad, R_OK ) )
741
    {
714
    {
742
      gamemode = commercial;
715
      gamemode = commercial;
743
      D_AddFile (tntwad);
716
      D_AddFile (tntwad);
744
      return;
717
      return;
745
    }
718
    }
746
 
719
 
747
    if ( !access (doomuwad,R_OK) )
720
    if ( !access (doomuwad,R_OK) )
748
    {
721
    {
749
      gamemode = retail;
722
      gamemode = retail;
750
      D_AddFile (doomuwad);
723
      D_AddFile (doomuwad);
751
      return;
724
      return;
752
    }
725
    }
753
 
726
 
754
    if ( !access (doomwad,R_OK) )
727
    if ( !access (doomwad,R_OK) )
755
    {
728
    {
756
      gamemode = registered;
729
      gamemode = registered;
757
      D_AddFile (doomwad);
730
      D_AddFile (doomwad);
758
      return;
731
      return;
759
    }
732
    }
760
 
733
 
761
    if ( !access (doom1wad,R_OK) )
734
    if ( !access (doom1wad,R_OK) )
762
    {
735
    {
763
      gamemode = shareware;
736
      gamemode = shareware;
764
      D_AddFile (doom1wad);
737
      D_AddFile (doom1wad);
765
      return;
738
      return;
766
    }
739
    }
767
 
740
 
768
 //   __libclog_printf("Game mode indeterminate.\n");
741
    printf("Game mode indeterminate.\n");
769
    gamemode = indetermined;
742
    gamemode = indetermined;
770
 
743
 
771
    // We don't abort. Let's see what the PWAD contains.
744
    // We don't abort. Let's see what the PWAD contains.
772
    //exit(1);
745
    //exit(1);
773
    //I_Error ("Game mode indeterminate\n");
746
    //I_Error ("Game mode indeterminate\n");
774
}
747
}
775
 
748
 
776
//
749
//
777
// Find a Response File
750
// Find a Response File
778
//
751
//
779
void FindResponseFile (void)
752
void FindResponseFile (void)
780
{
753
{
781
    int             i;
754
    int             i;
782
#define MAXARGVS        100
755
#define MAXARGVS        100
783
	
756
        
784
    for (i = 1;i < myargc;i++)
757
    for (i = 1;i < myargc;i++)
785
	if (myargv[i][0] == '@')
758
        if (myargv[i][0] == '@')
786
	{
759
        {
787
	    FILE *          handle;
760
            FILE *          handle;
788
	    int             size;
761
            int             size;
789
	    int             k;
762
            int             k;
790
	    int             index;
763
            int             index;
791
	    int             indexinfile;
764
            int             indexinfile;
792
	    char    *infile;
765
            char    *infile;
793
	    char    *file;
766
            char    *file;
794
	    char    *moreargs[20];
767
            char    *moreargs[20];
795
	    char    *firstargv;
768
            char    *firstargv;
796
			
769
                        
797
	    // READ THE RESPONSE FILE INTO MEMORY
770
            // READ THE RESPONSE FILE INTO MEMORY
798
	    handle = fopen (&myargv[i][1],"rb");
771
            handle = fopen (&myargv[i][1],"rb");
799
	    if (!handle)
772
            if (!handle)
800
	    {
773
            {
801
//		__libclog_printf ("\nNo such response file!");
774
//              __libclog_printf ("\nNo such response file!");
802
		exit(1);
775
                exit(1);
803
	    }
776
            }
804
//	    __libclog_printf("Found response file %s!\n",&myargv[i][1]);
777
//          __libclog_printf("Found response file %s!\n",&myargv[i][1]);
805
	    fseek (handle,0,SEEK_END);
778
//            fseek (handle,0,SEEK_END);
806
	    size = ftell(handle);
779
//            size = ftell(handle);
807
	    fseek (handle,0,SEEK_SET);
780
//            fseek (handle,0,SEEK_SET);
808
	    file = malloc (size);
781
//            file = malloc (size);
809
	    fread (file,size,1,handle);
782
//            fread (file,size,1,handle);
810
	    fclose (handle);
783
//            fclose (handle);
811
			
784
                        
812
	    // KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG
785
            // KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG
813
	    for (index = 0,k = i+1; k < myargc; k++)
786
            for (index = 0,k = i+1; k < myargc; k++)
814
		moreargs[index++] = myargv[k];
787
                moreargs[index++] = myargv[k];
815
			
788
                        
816
	    firstargv = myargv[0];
789
            firstargv = myargv[0];
817
	    myargv = malloc(sizeof(char *)*MAXARGVS);
790
            myargv = malloc(sizeof(char *)*MAXARGVS);
818
	    memset(myargv,0,sizeof(char *)*MAXARGVS);
791
            memset(myargv,0,sizeof(char *)*MAXARGVS);
819
	    myargv[0] = firstargv;
792
            myargv[0] = firstargv;
820
			
793
                        
821
	    infile = file;
794
            infile = file;
822
	    indexinfile = k = 0;
795
            indexinfile = k = 0;
823
	    indexinfile++;  // SKIP PAST ARGV[0] (KEEP IT)
796
            indexinfile++;  // SKIP PAST ARGV[0] (KEEP IT)
824
	    do
797
            do
825
	    {
798
            {
826
		myargv[indexinfile++] = infile+k;
799
                myargv[indexinfile++] = infile+k;
827
		while(k < size &&
800
                while(k < size &&
828
		      ((*(infile+k)>= ' '+1) && (*(infile+k)<='z')))
801
                      ((*(infile+k)>= ' '+1) && (*(infile+k)<='z')))
829
		    k++;
802
                    k++;
830
		*(infile+k) = 0;
803
                *(infile+k) = 0;
831
		while(k < size &&
804
                while(k < size &&
832
		      ((*(infile+k)<= ' ') || (*(infile+k)>'z')))
805
                      ((*(infile+k)<= ' ') || (*(infile+k)>'z')))
833
		    k++;
806
                    k++;
834
	    } while(k < size);
807
            } while(k < size);
835
			
808
                        
836
	    for (k = 0;k < index;k++)
809
            for (k = 0;k < index;k++)
837
		myargv[indexinfile++] = moreargs[k];
810
                myargv[indexinfile++] = moreargs[k];
838
	    myargc = indexinfile;
811
            myargc = indexinfile;
839
	
812
        
840
	    // DISPLAY ARGS
813
            // DISPLAY ARGS
841
//	    __libclog_printf("%d command-line args:\n",myargc);
814
//          __libclog_printf("%d command-line args:\n",myargc);
842
	    for (k=1;k
815
//            for (k=1;k
843
//		__libclog_printf("%s\n",myargv[k]);
816
//              __libclog_printf("%s\n",myargv[k]);
844
 
817
 
845
	    break;
818
            break;
846
	}
819
        }
847
}
820
}
848
 
821
 
849
 
822
 
850
//
823
//
851
// D_DoomMain
824
// D_DoomMain
852
//
825
//
853
void D_DoomMain (void)
826
void D_DoomMain (void)
854
{
827
{
855
    int             p;
828
    int             p;
856
    char                    file[256];
829
    char                    file[256];
857
 
830
 
858
    FindResponseFile ();
831
    FindResponseFile ();
859
	
832
 
860
    IdentifyVersion ();
833
    IdentifyVersion ();
861
 
-
 
862
 //   I_BeginSplash();
-
 
863
 
-
 
864
//    setbuf (stdout, NULL);
834
 
865
    modifiedgame = false;
835
    modifiedgame = false;
866
	
836
        
867
    nomonsters = M_CheckParm ("-nomonsters");
837
    nomonsters = M_CheckParm ("-nomonsters");
868
    respawnparm = M_CheckParm ("-respawn");
838
    respawnparm = M_CheckParm ("-respawn");
869
    fastparm = M_CheckParm ("-fast");
839
    fastparm = M_CheckParm ("-fast");
870
    devparm = M_CheckParm ("-devparm");
840
    devparm = M_CheckParm ("-devparm");
871
    if (M_CheckParm ("-altdeath"))
841
    if (M_CheckParm ("-altdeath"))
872
	deathmatch = 2;
842
        deathmatch = 2;
873
    else if (M_CheckParm ("-deathmatch"))
843
    else if (M_CheckParm ("-deathmatch"))
874
	deathmatch = 1;
844
        deathmatch = 1;
875
 
845
 
876
    switch ( gamemode )
846
    switch ( gamemode )
877
    {
847
    {
878
      case retail:
848
      case retail:
879
	sprintf (title,
849
        sprintf (title,
880
		 "                         "
850
                 "                         "
881
		 "The Ultimate DOOM Startup v%i.%i"
851
                 "The Ultimate DOOM Startup v%i.%i"
882
		 "                           ",
852
                 "                           ",
883
		 VERSION_NUM/100,VERSION_NUM%100);
853
                 VERSION_NUM/100,VERSION_NUM%100);
884
	break;
854
        break;
885
      case shareware:
855
      case shareware:
886
	sprintf (title,
856
        sprintf (title,
887
		 "                            "
857
                 "                            "
888
		 "DOOM Shareware Startup v%i.%i"
858
                 "DOOM Shareware Startup v%i.%i"
889
		 "                           ",
859
                 "                           ",
890
		 VERSION_NUM/100,VERSION_NUM%100);
860
                 VERSION_NUM/100,VERSION_NUM%100);
891
	break;
861
        break;
892
      case registered:
862
      case registered:
893
	sprintf (title,
863
        sprintf (title,
894
		 "                            "
864
                 "                            "
895
		 "DOOM Registered Startup v%i.%i"
865
                 "DOOM Registered Startup v%i.%i"
896
		 "                           ",
866
                 "                           ",
897
		 VERSION_NUM/100,VERSION_NUM%100);
867
                 VERSION_NUM/100,VERSION_NUM%100);
898
	break;
868
        break;
899
      case commercial:
869
      case commercial:
900
	sprintf (title,
870
        sprintf (title,
901
		 "                         "
871
                 "                         "
902
		 "DOOM 2: Hell on Earth v%i.%i"
872
                 "DOOM 2: Hell on Earth v%i.%i"
903
		 "                           ",
873
                 "                           ",
904
		 VERSION_NUM/100,VERSION_NUM%100);
874
                 VERSION_NUM/100,VERSION_NUM%100);
905
	break;
875
        break;
906
/*FIXME
876
/*FIXME
907
       case pack_plut:
877
       case pack_plut:
908
	sprintf (title,
878
        sprintf (title,
909
		 "                   "
879
                 "                   "
910
		 "DOOM 2: Plutonia Experiment v%i.%i"
880
                 "DOOM 2: Plutonia Experiment v%i.%i"
911
		 "                           ",
881
                 "                           ",
912
		 VERSION_NUM/100,VERSION_NUM%100);
882
                 VERSION_NUM/100,VERSION_NUM%100);
913
	break;
883
        break;
914
      case pack_tnt:
884
      case pack_tnt:
915
	sprintf (title,
885
        sprintf (title,
916
		 "                     "
886
                 "                     "
917
		 "DOOM 2: TNT - Evilution v%i.%i"
887
                 "DOOM 2: TNT - Evilution v%i.%i"
918
		 "                           ",
888
                 "                           ",
919
		 VERSION_NUM/100,VERSION_NUM%100);
889
                 VERSION_NUM/100,VERSION_NUM%100);
920
	break;
890
        break;
921
*/
891
*/
922
      default:
892
      default:
923
	sprintf (title,
893
        sprintf (title,
924
		 "                     "
894
                 "                     "
925
		 "Public DOOM - v%i.%i"
895
                 "Public DOOM - v%i.%i"
926
		 "                           ",
896
                 "                           ",
927
		 VERSION_NUM/100,VERSION_NUM%100);
897
                 VERSION_NUM/100,VERSION_NUM%100);
928
	break;
898
        break;
929
    }
899
    }
930
    
900
    
931
//    __libclog_printf ("%s\n",title);
901
//    __libclog_printf ("%s\n",title);
932
 
902
 
933
    if (devparm)
903
    if (devparm)
934
//	__libclog_printf(D_DEVSTR);
904
      printf(D_DEVSTR);
935
    
905
    
936
    // turbo option
906
    // turbo option
937
    if ( (p=M_CheckParm ("-turbo")) )
907
    if ( (p=M_CheckParm ("-turbo")) )
938
    {
908
    {
939
	int     scale = 200;
909
        int     scale = 200;
940
	extern int forwardmove[2];
910
        extern int forwardmove[2];
941
	extern int sidemove[2];
911
        extern int sidemove[2];
942
	
912
        
943
	if (p
913
        if (p
944
	    scale = atoi (myargv[p+1]);
914
            scale = atoi (myargv[p+1]);
945
	if (scale < 10)
915
        if (scale < 10)
946
	    scale = 10;
916
            scale = 10;
947
	if (scale > 400)
917
        if (scale > 400)
948
	    scale = 400;
918
            scale = 400;
949
//	__libclog_printf ("turbo scale: %i%%\n",scale);
919
        printf ("turbo scale: %i%%\n",scale);
950
	forwardmove[0] = forwardmove[0]*scale/100;
920
        forwardmove[0] = forwardmove[0]*scale/100;
951
	forwardmove[1] = forwardmove[1]*scale/100;
921
        forwardmove[1] = forwardmove[1]*scale/100;
952
	sidemove[0] = sidemove[0]*scale/100;
922
        sidemove[0] = sidemove[0]*scale/100;
953
	sidemove[1] = sidemove[1]*scale/100;
923
        sidemove[1] = sidemove[1]*scale/100;
954
    }
924
    }
955
    
925
    
956
    // add any files specified on the command line with -file wadfile
926
    // add any files specified on the command line with -file wadfile
957
    // to the wad list
927
    // to the wad list
958
    //
928
    //
959
    // convenience hack to allow -wart e m to add a wad file
929
    // convenience hack to allow -wart e m to add a wad file
960
    // prepend a tilde to the filename so wadfile will be reloadable
930
    // prepend a tilde to the filename so wadfile will be reloadable
961
    p = M_CheckParm ("-wart");
931
    p = M_CheckParm ("-wart");
962
    if (p)
932
    if (p)
963
    {
933
    {
964
	myargv[p][4] = 'p';     // big hack, change to -warp
934
        myargv[p][4] = 'p';     // big hack, change to -warp
965
 
935
 
966
	// Map name handling.
936
        // Map name handling.
967
	switch (gamemode )
937
        switch (gamemode )
968
	{
938
        {
969
	  case shareware:
939
          case shareware:
970
	  case retail:
940
          case retail:
971
	  case registered:
941
          case registered:
972
	    sprintf (file,"~"DEVMAPS"E%cM%c.wad",
942
            sprintf (file,"~"DEVMAPS"E%cM%c.wad",
973
		     myargv[p+1][0], myargv[p+2][0]);
943
                     myargv[p+1][0], myargv[p+2][0]);
974
//	    __libclog_printf("Warping to Episode %s, Map %s.\n",
-
 
975
//		   myargv[p+1],myargv[p+2]);
-
 
976
	    break;
944
            break;
977
	    
945
            
978
	  case commercial:
946
          case commercial:
979
	  default:
947
          default:
980
	    p = atoi (myargv[p+1]);
948
            p = atoi (myargv[p+1]);
981
	    if (p<10)
949
            if (p<10)
982
	      sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p);
950
              sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p);
983
	    else
951
            else
984
	      sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p);
952
              sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p);
985
	    break;
953
            break;
986
	}
954
        }
987
	D_AddFile (file);
955
        D_AddFile (file);
988
    }
956
    }
989
	
957
        
990
    p = M_CheckParm ("-file");
958
    p = M_CheckParm ("-file");
991
    if (p)
959
    if (p)
992
    {
960
    {
993
	// the parms after p are wadfile/lump names,
961
        // the parms after p are wadfile/lump names,
994
	// until end of parms or another - preceded parm
962
        // until end of parms or another - preceded parm
995
	modifiedgame = true;            // homebrew levels
963
        modifiedgame = true;            // homebrew levels
996
	while (++p != myargc && myargv[p][0] != '-')
964
        while (++p != myargc && myargv[p][0] != '-')
997
	    D_AddFile (myargv[p]);
965
            D_AddFile (myargv[p]);
998
    }
966
    }
999
 
967
 
1000
    p = M_CheckParm ("-playdemo");
968
    p = M_CheckParm ("-playdemo");
1001
 
969
 
1002
    if (!p)
970
    if (!p)
1003
	p = M_CheckParm ("-timedemo");
971
        p = M_CheckParm ("-timedemo");
1004
 
972
 
1005
    if (p && p < myargc-1)
973
    if (p && p < myargc-1)
1006
    {
974
    {
1007
	sprintf (file,"%s.lmp", myargv[p+1]);
975
        sprintf (file,"%s.lmp", myargv[p+1]);
1008
	D_AddFile (file);
976
        D_AddFile (file);
1009
	printf("Playing demo %s.lmp.\n",myargv[p+1]);
-
 
1010
    }
977
    }
1011
    
978
    
1012
    // get skill / episode / map from parms
979
    // get skill / episode / map from parms
1013
    startskill = sk_medium;
980
    startskill = sk_medium;
1014
    startepisode = 1;
981
    startepisode = 1;
1015
    startmap = 1;
982
    startmap = 1;
1016
    autostart = false;
983
    autostart = false;
1017
 
-
 
1018
		
984
                
1019
    p = M_CheckParm ("-skill");
985
    p = M_CheckParm ("-skill");
1020
    if (p && p < myargc-1)
986
    if (p && p < myargc-1)
1021
    {
987
    {
1022
	startskill = myargv[p+1][0]-'1';
988
        startskill = myargv[p+1][0]-'1';
1023
	autostart = true;
989
        autostart = true;
1024
    }
990
    }
1025
 
991
 
1026
    p = M_CheckParm ("-episode");
992
    p = M_CheckParm ("-episode");
1027
    if (p && p < myargc-1)
993
    if (p && p < myargc-1)
1028
    {
994
    {
1029
	startepisode = myargv[p+1][0]-'0';
995
        startepisode = myargv[p+1][0]-'0';
1030
	startmap = 1;
996
        startmap = 1;
1031
	autostart = true;
997
        autostart = true;
1032
    }
998
    }
1033
	
999
        
1034
    p = M_CheckParm ("-timer");
1000
    p = M_CheckParm ("-timer");
1035
    if (p && p < myargc-1 && deathmatch)
1001
    if (p && p < myargc-1 && deathmatch)
1036
    {
1002
    {
1037
	int     time;
1003
        int     time;
1038
	time = atoi(myargv[p+1]);
1004
        time = atoi(myargv[p+1]);
1039
    printf("Levels will end after %d minute",time);
-
 
1040
	if (time>1)
1005
        if (time>1)
1041
	    printf("s");
1006
            printf("s");
1042
	 printf(".\n");
1007
         printf(".\n");
1043
    }
1008
    }
1044
 
1009
 
1045
    p = M_CheckParm ("-avg");
1010
    p = M_CheckParm ("-avg");
1046
    if (p && p < myargc-1 && deathmatch)
1011
    if (p && p < myargc-1 && deathmatch)
1047
	printf("Austin Virtual Gaming: Levels will end after 20 minutes\n");
1012
      printf("Austin Virtual Gaming: Levels will end after 20 minutes\n");
1048
 
1013
 
1049
    p = M_CheckParm ("-warp");
1014
    p = M_CheckParm ("-warp");
1050
    if (p && p < myargc-1)
1015
    if (p && p < myargc-1)
1051
    {
1016
    {
1052
	if (gamemode == commercial)
1017
        if (gamemode == commercial)
1053
	    startmap = atoi (myargv[p+1]);
1018
            startmap = atoi (myargv[p+1]);
1054
	else
1019
        else
1055
	{
1020
        {
1056
	    startepisode = myargv[p+1][0]-'0';
1021
            startepisode = myargv[p+1][0]-'0';
1057
	    startmap = myargv[p+2][0]-'0';
1022
            startmap = myargv[p+2][0]-'0';
1058
	}
1023
        }
1059
	autostart = true;
1024
        autostart = true;
1060
    }
1025
    }
-
 
1026
 
1061
    
1027
 
1062
    // init subsystems
1028
    // init subsystems
1063
    printf ("V_Init: allocate screens.\n");
1029
    printf ("V_Init: allocate screens.\n\r");
1064
    V_Init ();
1030
    V_Init ();
1065
 
1031
 
1066
    printf ("M_LoadDefaults: Load system defaults.\n");
1032
    printf ("M_LoadDefaults: Load system defaults.\n\r");
1067
    M_LoadDefaults ();              // load before initing other systems
1033
    M_LoadDefaults ();              // load before initing other systems
1068
 
1034
 
1069
    printf ("Z_Init: Init zone memory allocation daemon. \n");
1035
    printf ("Z_Init: Init zone memory allocation daemon. \n\r");
1070
    Z_Init ();
-
 
1071
 
-
 
1072
    printf ("W_Init: Init WADfiles.\n");
1036
    Z_Init ();
1073
    W_InitMultipleFiles (wadfiles);
1037
 
1074
    printf("added\n");
1038
    printf ("W_Init: Init WADfiles.\n\r");
1075
    
1039
    W_InitMultipleFiles (wadfiles);
1076
 
1040
 
1077
    // Check for -file in shareware
1041
    // Check for -file in shareware
1078
    if (modifiedgame)
1042
    if (modifiedgame)
1079
    {
1043
    {
1080
	// These are the lumps that will be checked in IWAD,
1044
        // These are the lumps that will be checked in IWAD,
1081
	// if any one is not present, execution will be aborted.
1045
        // if any one is not present, execution will be aborted.
1082
	char name[23][8]=
1046
        char name[23][8]=
1083
	{
1047
        {
1084
	    "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9",
1048
            "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9",
1085
	    "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9",
1049
            "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9",
1086
	    "dphoof","bfgga0","heada1","cybra1","spida1d1"
1050
            "dphoof","bfgga0","heada1","cybra1","spida1d1"
1087
	};
1051
        };
1088
	int i;
1052
        int i;
1089
	
1053
        
1090
	if ( gamemode == shareware)
1054
        if ( gamemode == shareware)
1091
	    I_Error("\nYou cannot -file with the shareware "
1055
            I_Error("\n\rYou cannot -file with the shareware "
1092
		    "version. Register!");
1056
                    "version. Register!");
1093
 
1057
 
1094
	// Check for fake IWAD with right name,
1058
        // Check for fake IWAD with right name,
1095
	// but w/o all the lumps of the registered version. 
1059
        // but w/o all the lumps of the registered version. 
1096
	if (gamemode == registered)
1060
        if (gamemode == registered)
1097
	    for (i = 0;i < 23; i++)
1061
            for (i = 0;i < 23; i++)
1098
		if (W_CheckNumForName(name[i])<0)
1062
                if (W_CheckNumForName(name[i])<0)
1099
		    I_Error("\nThis is not the registered version.");
1063
                    I_Error("\n\rThis is not the registered version.");
1100
    }
1064
    }
1101
    
1065
    
1102
    // Iff additonal PWAD files are used, print modified banner
1066
    // Iff additonal PWAD files are used, print modified banner
1103
    if (modifiedgame)
1067
    if (modifiedgame)
1104
    {
1068
    {
1105
	  printf (
1069
//        //printf (
1106
	    "===========================================================================\n"
1070
//          "===========================================================================\n\r"
1107
	    "ATTENTION:  This version of DOOM has been modified.  If you would like to\n"
1071
//          "ATTENTION:  This version of DOOM has been modified.  If you would like to\n\r"
1108
	    "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n"
1072
//          "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n\r"
1109
	    "        You will not receive technical support for modified games.\n"
1073
//          "        You will not receive technical support for modified games.\n\r"
1110
	    "                      press enter to continue\n"
1074
//          "                      press enter to continue\n\r"
1111
	    "===========================================================================\n"
1075
//          "===========================================================================\n\r"
1112
	    );
1076
//          );
1113
//	  getchar ();
1077
//        getchar ();
1114
    }
1078
    }
1115
	
1079
        
1116
 
1080
 
1117
    // Check and print which version is executed.
1081
    // Check and print which version is executed.
1118
    switch ( gamemode )
1082
    switch ( gamemode )
1119
    {
1083
    {
1120
      case shareware:
1084
      case shareware:
1121
      case indetermined:
1085
      case indetermined:
1122
	  printf (
1086
//        //printf (
1123
	    "===========================================================================\n"
1087
//          "===========================================================================\n\r"
1124
	    "                                Shareware!\n"
1088
//          "                                Shareware!\n\r"
1125
	    "===========================================================================\n"
1089
//          "===========================================================================\n\r"
1126
	);
1090
//      );
1127
	break;
1091
        break;
1128
      case registered:
1092
      case registered:
1129
      case retail:
1093
      case retail:
1130
      case commercial:
1094
      case commercial:
1131
	  printf (
1095
//        //printf (
1132
	    "===========================================================================\n"
1096
//          "===========================================================================\n\r"
1133
	    "                 Commercial product - do not distribute!\n"
1097
//          "                 Commercial product - do not distribute!\n\r"
1134
	    "         Please report software piracy to the SPA: 1-800-388-PIR8\n"
1098
//          "         Please report software piracy to the SPA: 1-800-388-PIR8\n\r"
1135
	    "===========================================================================\n"
1099
//          "===========================================================================\n\r"
1136
	);
1100
//      );
1137
	break;
1101
        break;
1138
	
1102
        
1139
      default:
1103
      default:
1140
	// Ouch.
1104
        // Ouch.
1141
	break;
1105
        break;
1142
    }
1106
    }
1143
 
1107
 
1144
    printf ("M_Init: Init miscellaneous info.\n");
1108
    printf ("M_Init: Init miscellaneous info.\n\r");
1145
    M_Init ();
1109
    M_Init ();
1146
 
1110
 
1147
    printf ("R_Init: Init DOOM refresh daemon - ");
1111
    printf ("R_Init: Init DOOM refresh daemon - \n\r");
1148
    R_Init ();
1112
    R_Init ();
1149
 
1113
 
1150
    printf ("\nP_Init: Init Playloop state.\n");
1114
    printf ("\nP_Init: Init Playloop state.\n\r");
1151
    P_Init ();
1115
    P_Init ();
1152
 
1116
 
1153
    printf ("I_Init: Setting up machine state.\n");
1117
    printf ("I_Init: Setting up machine state.\n\r");
1154
    I_Init ();
1118
    I_Init ();
1155
 
1119
 
1156
    printf ("D_CheckNetGame: Checking network game status.\n");
1120
    printf ("D_CheckNetGame: Checking network game status.\n\r");
1157
    D_CheckNetGame ();
-
 
1158
 
-
 
1159
    printf ("S_Init: Setting up sound.\n");
1121
    D_CheckNetGame ();
1160
    S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ );
1122
 
1161
 
1123
//    printf ("S_Init: Setting up sound.\n\r");
1162
    printf ("HU_Init: Setting up heads up display.\n");
1124
//    S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ );
1163
    HU_Init ();
1125
 
1164
 
1126
    printf ("HU_Init: Setting up heads up display.\n\r");
1165
//    I_EndSplash();
1127
    HU_Init ();
1166
 
1128
 
1167
    printf ("ST_Init: Init status bar.\n");
1129
    printf ("ST_Init: Init status bar.\n\r");
1168
    ST_Init ();
1130
    ST_Init ();
1169
 
1131
 
1170
    // check for a driver that wants intermission stats
1132
    // check for a driver that wants intermission stats
1171
    p = M_CheckParm ("-statcopy");
1133
    p = M_CheckParm ("-statcopy");
1172
    if (p && p
1134
    if (p && p
1173
    {
1135
    {
1174
	// for statistics driver
1136
        // for statistics driver
1175
	extern  void*	statcopy;                            
1137
        extern  void*   statcopy;                            
1176
 
1138
 
1177
	statcopy = (void*)atoi(myargv[p+1]);
1139
        statcopy = (void*)atoi(myargv[p+1]);
1178
	printf ("External statistics registered.\n");
1140
        //printf ("External statistics registered.\n\r");
1179
    }
1141
    }
1180
    
1142
    
1181
    // start the apropriate game based on parms
1143
    // start the apropriate game based on parms
1182
    p = M_CheckParm ("-record");
1144
    p = M_CheckParm ("-record");
1183
 
1145
 
1184
    if (p && p < myargc-1)
1146
    if (p && p < myargc-1)
1185
    {
1147
    {
1186
	G_RecordDemo (myargv[p+1]);
1148
        G_RecordDemo (myargv[p+1]);
1187
	autostart = true;
1149
        autostart = true;
1188
    }
1150
    }
1189
	
1151
        
1190
    p = M_CheckParm ("-playdemo");
1152
    p = M_CheckParm ("-playdemo");
1191
    if (p && p < myargc-1)
1153
    if (p && p < myargc-1)
1192
    {
1154
    {
1193
	singledemo = true;              // quit after one demo
1155
        singledemo = true;              // quit after one demo
1194
	G_DeferedPlayDemo (myargv[p+1]);
1156
        G_DeferedPlayDemo (myargv[p+1]);
1195
	D_DoomLoop ();  // never returns
1157
        D_DoomLoop ();  // never returns
1196
    }
1158
    }
1197
	
1159
        
1198
    p = M_CheckParm ("-timedemo");
1160
    p = M_CheckParm ("-timedemo");
1199
    if (p && p < myargc-1)
1161
    if (p && p < myargc-1)
1200
    {
1162
    {
1201
	G_TimeDemo (myargv[p+1]);
1163
        G_TimeDemo (myargv[p+1]);
1202
	D_DoomLoop ();  // never returns
1164
        D_DoomLoop ();  // never returns
1203
    }
1165
    }
1204
	
1166
        
1205
    p = M_CheckParm ("-loadgame");
1167
    p = M_CheckParm ("-loadgame");
1206
    if (p && p < myargc-1)
1168
    if (p && p < myargc-1)
1207
    {
1169
    {
1208
	if (M_CheckParm("-cdrom"))
1170
        if (M_CheckParm("-cdrom"))
1209
	    sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
1171
            sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
1210
	else
1172
        else
1211
	    sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
1173
            sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
1212
	G_LoadGame (file);
1174
        G_LoadGame (file);
1213
    }
1175
    }
1214
	
1176
        
1215
 
1177
 
1216
    if ( gameaction != ga_loadgame )
1178
    if ( gameaction != ga_loadgame )
1217
    {
1179
    {
1218
	if (autostart || netgame)
1180
        if (autostart || netgame)
1219
	    G_InitNew (startskill, startepisode, startmap);
1181
            G_InitNew (startskill, startepisode, startmap);
1220
	else
1182
        else
1221
	    D_StartTitle ();                // start up intro loop
1183
            D_StartTitle ();                // start up intro loop
1222
 
1184
 
1223
    }
1185
    }
1224
 
1186
 
1225
    D_DoomLoop ();  // never returns
1187
    D_DoomLoop ();  // never returns
1226
}
1188
}
1227
>
1189
>
1228
>
1190
>
1229
>
1191
>
1230
>
1192
>
1231
//>
1193
//>
1232
>
1194
>