-
Notifications
You must be signed in to change notification settings - Fork 5
/
d_main.pas
2182 lines (1916 loc) · 56.4 KB
/
d_main.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//------------------------------------------------------------------------------
//
// FPCDoom - Port of Doom to Free Pascal Compiler
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 2004-2007 by Jim Valavanis
// Copyright (C) 2017-2022 by Jim Valavanis
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
//------------------------------------------------------------------------------
// E-Mail: [email protected]
// Site : https://sourceforge.net/projects/fpcdoom/
//------------------------------------------------------------------------------
{$I FPCDoom.inc}
unit d_main;
interface
uses
d_event,
doomdef;
//
// DESCRIPTION:
// DOOM main program (D_DoomMain) and game loop (D_DoomLoop),
// plus functions to determine game mode (shareware, registered),
// parse command line parameters, configure game parameters (turbo),
// and call the startup functions.
//
//-----------------------------------------------------------------------------
const
AppTitle = 'FPCDoom';
//==============================================================================
//
// D_ProcessEvents
//
//==============================================================================
procedure D_ProcessEvents;
//==============================================================================
//
// D_DoAdvanceDemo
//
//==============================================================================
procedure D_DoAdvanceDemo;
//==============================================================================
//
// D_AddFile
//
//==============================================================================
procedure D_AddFile(const fname: string);
//==============================================================================
//
// D_DoomMain()
// Not a globally visible function, just included for source reference,
// calls all startup code, parses command line options.
// If not overrided by user input, calls N_AdvanceDemo.
//
//==============================================================================
procedure D_DoomMain;
//==============================================================================
// D_PostEvent
//
// Called by IO functions when input is detected.
//
//==============================================================================
procedure D_PostEvent(ev: Pevent_t);
//==============================================================================
// D_PageTicker
//
// BASE LEVEL
//
//==============================================================================
procedure D_PageTicker;
//==============================================================================
//
// D_PageDrawer
//
//==============================================================================
procedure D_PageDrawer;
//==============================================================================
//
// D_AdvanceDemo
//
//==============================================================================
procedure D_AdvanceDemo;
//==============================================================================
//
// D_StartTitle
//
//==============================================================================
procedure D_StartTitle;
//==============================================================================
//
// D_IsPaused
//
//==============================================================================
function D_IsPaused: boolean;
//==============================================================================
//
// D_Display
//
//==============================================================================
procedure D_Display;
// wipegamestate can be set to -1 to force a wipe on the next draw
var
wipegamestate: integer = -1; // JVAL was gamestate_t = GS_DEMOSCREEN;
wipedisplay: boolean = false;
nomonsters: boolean; // checkparm of -nomonsters
fastparm: boolean; // checkparm of -fast
devparm: boolean; // started game with -devparm
singletics: boolean; // debug flag to cancel adaptiveness
autostart: boolean;
startskill: skill_t;
respawnparm: boolean; // checkparm of -respawn
startepisode: integer;
startmap: integer;
advancedemo: boolean;
basedefault: string; // default file
//==============================================================================
//
// D_Version
//
//==============================================================================
function D_Version: string;
//==============================================================================
//
// D_VersionBuilt
//
//==============================================================================
function D_VersionBuilt: string;
//==============================================================================
//
// D_ShutDown
//
//==============================================================================
procedure D_ShutDown;
var
set_videomodeneeded: boolean = false;
set_screenwidth: integer;
set_screenheight: integer;
implementation
uses
d_fpc,
deh_main,
doomstat,
d_english,
d_player,
d_net,
c_con,
c_cmds,
e_endoom,
f_finale,
f_wipe,
m_argv,
m_misc,
m_menu,
info,
info_rnd,
i_system,
i_video,
i_io,
g_game,
hu_stuff,
wi_stuff,
st_stuff,
am_map,
p_setup,
p_mobj_h,
r_draw,
r_main,
r_hires,
r_defs,
r_intrpl,
r_data,
r_lightmap,
registry,
sounds,
s_sound,
sc_actordef,
t_main,
v_video,
v_screenresolution,
w_wad,
w_pak,
z_memory;
//==============================================================================
//
// D_DoomLoop()
// Not a globally visible function,
// just included for source reference,
// called by D_DoomMain, never exits.
// Manages timing and IO,
// calls all ?_Responder, ?_Ticker, and ?_Drawer,
// calls I_GetTime, I_StartFrame, and I_StartTic
//
// D_PostEvent
// Called by the I/O functions when input is detected
//
//==============================================================================
procedure D_PostEvent(ev: Pevent_t);
begin
events[eventhead] := ev^;
inc(eventhead);
eventhead := eventhead and (MAXEVENTS - 1);
end;
//==============================================================================
//
// D_ProcessEvents
// Send all the events of the given timestamp down the responder chain
//
//==============================================================================
procedure D_ProcessEvents;
var
ev: Pevent_t;
begin
// IF STORE DEMO, DO NOT ACCEPT INPUT
if (gamemode = commercial) and (W_CheckNumForName('MAP01') < 0) then
exit;
if I_GameFinished then
exit;
while eventtail <> eventhead do
begin
ev := @events[eventtail];
if C_Responder(ev) then
// console ate the event
else if M_Responder(ev) then
// menu ate the event
else
G_Responder(ev);
if I_GameFinished then
begin
eventtail := eventhead;
exit;
end;
inc(eventtail);
eventtail := eventtail and (MAXEVENTS - 1);
end;
end;
//
// D_Display
// draw current display, possibly wiping it from the previous
//
var
viewactivestate: boolean = false;
menuactivestate: boolean = false;
viewfullscreen: boolean = false;
inhelpscreensstate: boolean = false;
borderdrawcount: integer;
nodrawers: boolean = false; // for comparative timing purposes
noblit: boolean = false; // for comparative timing purposes
norender: boolean = false; // for comparative timing purposes
//==============================================================================
//
// D_FinishUpdate
//
//==============================================================================
procedure D_FinishUpdate;
begin
if not noblit then
I_FinishUpdate; // page flip or blit buffer
end;
//==============================================================================
//
// D_RenderPlayerView
//
//==============================================================================
procedure D_RenderPlayerView(player: Pplayer_t);
begin
if norender then
begin
R_PlayerViewBlanc(aprox_black);
exit;
end;
if player <> nil then
R_RenderPlayerView(player)
end;
var
diskbusy: integer = -1;
//==============================================================================
//
// D_Display
//
//==============================================================================
procedure D_Display;
var
nowtime: integer;
tics: integer;
wipestart: integer;
y: integer;
done: boolean;
wipe: boolean;
redrawsbar: boolean;
redrawbkscn: boolean;
palette: PByteArray;
oldvideomode: videomode_t;
drawhu: boolean;
begin
if gamestate = GS_ENDOOM then
begin
E_Drawer;
D_FinishUpdate; // page flip or blit buffer
exit;
end;
HU_DoFPSStuff;
if nodrawers then
exit; // for comparative timing / profiling
redrawsbar := false;
redrawbkscn := false;
drawhu := false;
// change the view size if needed
if setsizeneeded then
begin
R_ExecuteSetViewSize;
oldgamestate := -1; // force background redraw
borderdrawcount := 3;
end;
// save the current screen if about to wipe
if Ord(gamestate) <> wipegamestate then
begin
wipe := true;
wipe_StartScreen;
end
else
wipe := false;
if (gamestate = GS_LEVEL) and (gametic <> 0) then
HU_Erase;
// do buffered drawing
case gamestate of
GS_LEVEL:
begin
if gametic <> 0 then
begin
if amstate = am_only then
AM_Drawer;
if wipe or ((viewheight <> SCREENHEIGHT) and viewfullscreen) then
redrawsbar := true;
if inhelpscreensstate and not inhelpscreens then
redrawsbar := true; // just put away the help screen
viewfullscreen := viewheight = SCREENHEIGHT;
if viewfullscreen then
ST_Drawer(stdo_no, redrawsbar)
else
ST_Drawer(stdo_full, redrawsbar);
end;
end;
GS_INTERMISSION:
WI_Drawer;
GS_FINALE:
F_Drawer;
GS_DEMOSCREEN:
D_PageDrawer;
end;
// draw the view directly
if gamestate = GS_LEVEL then
begin
if (amstate <> am_only) and (gametic <> 0) then
begin
D_RenderPlayerView(@players[displayplayer]);
if amstate = am_overlay then
AM_Drawer;
end;
if gametic <> 0 then
drawhu := true;
end
else if Ord(gamestate) <> oldgamestate then
begin
// clean up border stuff
palette := V_ReadPalette(PU_STATIC);
I_SetPalette(palette);
V_SetPalette(palette);
Z_ChangeTag(palette, PU_CACHE);
end;
// see if the border needs to be initially drawn
if gamestate = GS_LEVEL then
begin
if needsbackscreen or (oldgamestate <> Ord(GS_LEVEL)) then
begin
viewactivestate := false; // view was not active
R_FillBackScreen; // draw the pattern into the back screen
end;
// see if the border needs to be updated to the screen
if amstate <> am_only then
begin
if scaledviewwidth <> SCREENWIDTH then
begin
if menuactive or menuactivestate or not viewactivestate or C_IsConsoleActive then
borderdrawcount := 3;
if borderdrawcount > 0 then
begin
R_DrawViewBorder; // erase old menu stuff
redrawbkscn := true;
dec(borderdrawcount);
end;
end
else if R_FullStOn and (gametic <> 0) then
ST_Drawer(stdo_small, redrawsbar);
end;
end;
menuactivestate := menuactive;
viewactivestate := viewactive;
inhelpscreensstate := inhelpscreens;
oldgamestate := Ord(gamestate);
wipegamestate := Ord(gamestate);
// draw pause pic
if paused then
begin
if amstate = am_only then
y := 4
else
y := (viewwindowy * 200) div SCREENHEIGHT + 4;
V_DrawPatch((320 - 68) div 2, y, SCN_FG,
'M_PAUSE', true);
end;
if drawhu then
HU_Drawer;
if isdiskbusy then
begin
diskbusy := 4; // Display busy disk for a little...
isdiskbusy := false;
end;
if diskbusy > 0 then
begin
// Menus go directly to the screen
M_Drawer; // Menu is drawn even on top of everything
// Console goes directly to the screen
C_Drawer; // Console is drawn even on top of menus
// Draw disk busy patch
R_DrawDiskBusy; // Draw disk busy is draw on top of console
dec(diskbusy);
end
else if diskbusy = 0 then
begin
if not redrawbkscn then
begin
R_DrawViewBorder;
if drawhu then
HU_Drawer;
end;
M_Drawer;
C_Drawer;
dec(diskbusy);
end
else
begin
M_Drawer;
C_Drawer;
end;
NetUpdate; // send out any new accumulation
// normal update
if not wipe then
begin
D_FinishUpdate; // page flip or blit buffer
exit;
end;
// wipe update
wipe_EndScreen;
wipedisplay := true;
wipestart := I_GetTime - 1;
oldvideomode := videomode;
videomode := vm32bit;
repeat
repeat
I_Sleep(0);
nowtime := I_GetTime;
tics := nowtime - wipestart;
until tics <> 0;
wipestart := nowtime;
done := wipe_Ticker(tics);
M_Drawer; // Menu is drawn even on top of wipes
C_Drawer; // Console draw on top of wipes and menus
D_FinishUpdate; // page flip or blit buffer
HU_DoFPSStuff;
until done;
videomode := oldvideomode;
wipedisplay := false;
end;
//==============================================================================
//
// D_DoomLoop
//
//==============================================================================
procedure D_DoomLoop;
begin
if demorecording then
G_BeginRecording;
I_InitGraphics;
while true do
begin
// frame syncronous IO operations
I_StartFrame;
// process one or more tics
if singletics then
D_RunSingleTick // will run only one tick
else
D_RunMultipleTicks; // will run at least one tick
S_UpdateSounds(players[consoleplayer].mo);// move positional sounds
if set_videomodeneeded then
begin
set_videomodeneeded := false;
V_SetScreenResolution(set_screenwidth, set_screenheight);
end;
end;
end;
//
// DEMO LOOP
//
var
demosequence: integer;
pagetic: integer;
pagename: string;
//==============================================================================
//
// D_PageTicker
// Handles timing for warped projection
//
//==============================================================================
procedure D_PageTicker;
begin
dec(pagetic);
if pagetic < 0 then
D_AdvanceDemo;
end;
//==============================================================================
//
// D_PageDrawer
//
//==============================================================================
procedure D_PageDrawer;
begin
V_PageDrawer(pagename);
end;
//==============================================================================
//
// D_AdvanceDemo
// Called after each demo or intro demosequence finishes
//
//==============================================================================
procedure D_AdvanceDemo;
begin
if gamestate <> GS_ENDOOM then
advancedemo := true;
end;
//==============================================================================
// D_DoAdvanceDemo
//
// This cycles through the demo sequences.
// FIXME - version dependend demo numbers?
//
//==============================================================================
procedure D_DoAdvanceDemo;
begin
players[consoleplayer].playerstate := PST_LIVE; // not reborn
advancedemo := false;
usergame := false; // no save / end game here
paused := false;
gameaction := ga_nothing;
if gamemode = retail then
demosequence := (demosequence + 1) mod 7
else
demosequence := (demosequence + 1) mod 6;
case demosequence of
0:
begin
if gamemode = commercial then
pagetic := TICRATE * 11
else
pagetic := 170;
gamestate := GS_DEMOSCREEN;
pagename := 'TITLEPIC';
if gamemode = commercial then
S_StartMusic(Ord(mus_dm2ttl))
else
S_StartMusic(Ord(mus_intro));
end;
1:
begin
G_DeferedPlayDemo('1');
end;
2:
begin
pagetic := 200;
gamestate := GS_DEMOSCREEN;
pagename := 'CREDIT';
end;
3:
begin
G_DeferedPlayDemo('2');
end;
4:
begin
gamestate := GS_DEMOSCREEN;
if gamemode = commercial then
begin
pagetic := TICRATE * 11;
pagename := 'TITLEPIC';
S_StartMusic(Ord(mus_dm2ttl));
end
else
begin
pagetic := 200;
if gamemode = retail then
pagename := 'CREDIT'
else
pagename := 'HELP2';
end;
end;
5:
begin
G_DeferedPlayDemo('3');
end;
// THE DEFINITIVE DOOM Special Edition demo
6:
begin
G_DeferedPlayDemo('4');
end;
end;
end;
//==============================================================================
//
// D_StartTitle
//
//==============================================================================
procedure D_StartTitle;
begin
gameaction := ga_nothing;
demosequence := -1;
D_AdvanceDemo;
end;
var
wadfiles: TDStringList;
//==============================================================================
//
// D_AddFile
//
//==============================================================================
procedure D_AddFile(const fname: string);
begin
if fname <> '' then
if wadfiles.IndexOf(strupper(fname)) < 0 then
wadfiles.Add(strupper(fname));
end;
//
// IdentifyVersion
// Checks availability of IWAD files by name,
// to determine whether registered/commercial features
// should be executed (notably loading PWAD's).
//
const
PATH_SEPARATOR = ';';
const
NUMSTEAMAPPS = 3;
steamapps: array[0..NUMSTEAMAPPS - 1] of integer = (2280, 2290, 2300);
{$IFNDEF FPC}
const
HKEY_LOCAL_MACHINE = LongWord($80000002);
KEY_WOW64_64KEY = $100;
KEY_WOW64_32KEY = $200;
KEY_READ = 983065;
{$ENDIF}
//==============================================================================
//
// QuerySteamDirectory
//
//==============================================================================
function QuerySteamDirectory(const flags, dirid: integer): string;
var
reg: TRegistry;
begin
reg := TRegistry.Create(flags);
reg.RootKey := HKEY_LOCAL_MACHINE;
if reg.OpenKeyReadOnly('\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App ' + itoa(dirid)) then
result := reg.ReadString('InstallLocation')
else if reg.OpenKeyReadOnly('\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Steam App ' + itoa(dirid)) then
result := reg.ReadString('InstallLocation')
else
result := '';
reg.free;
end;
//==============================================================================
//
// FileInDoomPath
//
//==============================================================================
function FileInDoomPath(const fn: string): string;
var
doomwaddir: string;
doomwadpath: string;
paths: TDStringList;
i: integer;
tmp: string;
begin
if fexists(fn) then
begin
result := fn;
exit;
end;
doomwaddir := getenv('DOOMWADDIR');
doomwadpath := getenv('DOOMWADPATH');
paths := TDStringList.Create;
if doomwaddir <> '' then
paths.Add(doomwaddir);
if doomwadpath <> '' then
begin
tmp := '';
for i := 1 to length(doomwadpath) do
begin
if doomwadpath[i] = PATH_SEPARATOR then
begin
if tmp <> '' then
begin
paths.Add(tmp);
tmp := '';
end;
end
else
tmp := tmp + doomwadpath[i];
end;
if tmp <> '' then
paths.Add(tmp);
end;
for i := 0 to NUMSTEAMAPPS - 1 do
begin
tmp := QuerySteamDirectory(KEY_READ or KEY_WOW64_64KEY, steamapps[i]);
if tmp = '' then
tmp := QuerySteamDirectory(KEY_READ, steamapps[i]);
if tmp <> '' then
begin
if tmp[length(tmp)] <> '\' then
tmp := tmp + '\';
paths.Add(tmp);
paths.Add(tmp + 'base\');
paths.Add(tmp + 'base\wads');
end;
end;
result := fname(fn);
for i := 0 to paths.Count - 1 do
begin
tmp := paths.Strings[i];
if tmp[length(tmp)] <> '\' then
tmp := tmp + '\';
if fexists(tmp + result) then
begin
result := tmp + result;
paths.free;
exit;
end;
end;
result := fn;
paths.free;
end;
const
SYSWAD = 'FPCDoom.wad';
//==============================================================================
//
// D_AddSystemWAD
//
//==============================================================================
procedure D_AddSystemWAD;
var
fsyswad: string;
begin
fsyswad := FileInDoomPath(SYSWAD);
if fexists(fsyswad) then
D_AddFile(fsyswad)
else
I_Error('D_AddSystemWAD(): System WAD %s not found.'#13#10, [fsyswad]);
end;
var
doomcwad: string = ''; // Custom main WAD
//==============================================================================
//
// IdentifyVersion
//
//==============================================================================
procedure IdentifyVersion;
var
doom1wad: string;
doomwad: string;
doomuwad: string;
doom2wad: string;
doom2fwad: string;
plutoniawad: string;
tntwad: string;
doomwaddir: string;
p: integer;
begin
doomwaddir := getenv('DOOMWADDIR');
if doomwaddir = '' then
doomwaddir := '.';
// Commercial.
sprintf(doom2wad, '%s\doom2.wad', [doomwaddir]);
// Retail.
sprintf(doomuwad, '%s\doomu.wad', [doomwaddir]);
// Registered.
sprintf(doomwad, '%s\doom.wad', [doomwaddir]);
// Shareware.
sprintf(doom1wad, '%s\doom1.wad', [doomwaddir]);
// plutonia pack
sprintf(plutoniawad, '%s\plutonia.wad', [doomwaddir]);
// tnt pack
sprintf(tntwad, '%s\tnt.wad', [doomwaddir]);
// French stuff.
sprintf(doom2fwad, '%s\doom2f.wad', [doomwaddir]);
basedefault := 'FPCDoom.ini';
p := M_CheckParm('-mainwad');
if p = 0 then
p := M_CheckParm('-iwad');
if (p > 0) and (p < myargc - 1) then
begin
inc(p);
doomcwad := FileInDoomPath(myargv[p]);
if fexists(doomcwad) then
begin
printf(' External main wad in use: %s'#13#10, [doomcwad]);
gamemode := indetermined;
D_AddFile(doomcwad);
exit;
end
else
doomcwad := '';
end;
if M_CheckParm('-shdev') > 0 then
begin
gamemode := shareware;
devparm := true;
D_AddFile(DEVDATA + 'doom1.wad');
D_AddFile(DEVMAPS + 'data_se/texture1.lmp');
D_AddFile(DEVMAPS + 'data_se/pnames.lmp');
basedefault := DEVDATA + 'FPCDoom.ini';
exit;
end;
if M_CheckParm('-regdev') > 0 then
begin
gamemode := registered;
devparm := true;
D_AddFile(DEVDATA + 'doom.wad');
D_AddFile(DEVMAPS + 'data_se/texture1.lmp');
D_AddFile(DEVMAPS + 'data_se/texture2.lmp');
D_AddFile(DEVMAPS + 'data_se/pnames.lmp');
basedefault := DEVDATA + 'FPCDoom.ini';
exit;
end;
if M_CheckParm('-comdev') > 0 then
begin
gamemode := commercial;
devparm := true;
D_AddFile(DEVDATA + 'doom2.wad');
D_AddFile(DEVMAPS + 'cdata/texture1.lmp');
D_AddFile(DEVMAPS + 'cdata/pnames.lmp');
basedefault := DEVDATA + 'FPCDoom.ini';
exit;
end;
for p := 1 to 2 do
begin
if fexists(doom2fwad) then
begin
gamemode := commercial;
gamemission := doom2;
// C'est ridicule!
// Let's handle languages in config files, okay?
language := french;
printf('French version'#13#10);
D_AddFile(doom2fwad);
exit;
end;
if fexists(doom2wad) then
begin
gamemode := commercial;
gamemission := doom2;
D_AddFile(doom2wad);
exit;
end;
if fexists(plutoniawad) then
begin
gamemode := commercial;
gamemission := pack_plutonia;
D_AddFile(plutoniawad);
exit;
end;
if fexists(tntwad) then