-
Notifications
You must be signed in to change notification settings - Fork 10
/
wl_menu.cpp
4410 lines (3780 loc) · 107 KB
/
wl_menu.cpp
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
////////////////////////////////////////////////////////////////////
//
// WL_MENU.C
// by John Romero (C) 1992 Id Software, Inc.
//
////////////////////////////////////////////////////////////////////
#include <sys/stat.h>
#include <sys/types.h>
#ifdef _WIN32
#include <io.h>
#include <direct.h>
#else
#include <unistd.h>
#endif
#include "wl_def.h"
extern int lastgamemusicoffset;
extern int numEpisodesMissing;
//
// PRIVATE PROTOTYPES
//
#define STARTITEM newgame
// ENDSTRx constants are defined in foreign.h
char endStrings[9][80] = {
ENDSTR1,
ENDSTR2,
ENDSTR3,
ENDSTR4,
ENDSTR5,
ENDSTR6,
ENDSTR7,
ENDSTR8,
ENDSTR9
};
CP_itemtype MainMenu[] = {
{1, STR_NG, CP_NewGame},
{1, STR_SD, CP_Sound},
{1, STR_CL, CP_Control},
{1, STR_LG, CP_LoadGame},
{0, STR_SG, CP_SaveGame},
{1, STR_CV, CP_ChangeView},
{1, STR_VS, CP_ViewScores},
{1, STR_BD, 0},
{1, STR_QT, 0}
};
CP_itemtype SndMenu[] = {
{1, STR_NONE, 0},
{1, STR_PC, 0},
{1, STR_ALSB, 0},
{0, "", 0},
{0, "", 0},
{1, STR_NONE, 0},
{0, STR_DISNEY, 0},
{1, STR_SB, 0},
{0, "", 0},
{0, "", 0},
{1, STR_NONE, 0},
{1, STR_ALSB, 0}
};
enum { CTL_MOUSEENABLE, CTL_MOUSESENS, CTL_JOYENABLE, CTL_CUSTOMIZE, CTL_CUSTOMIZE2, CTL_ALWAYSRUN, CTL_CROSSHAIR }; // [FG] extended "Customize" menus, toggle always run
CP_itemtype CtlMenu[] = {
{0, STR_MOUSEEN, 0},
{0, STR_SENS, MouseSensitivity},
{0, STR_JOYEN, 0},
{1, "Customize Keyboard", CustomControls}, // [FG] extended "Customize" menus
{1, "Customize Mouse/JS", Custom2Controls}, // [FG] extended "Customize" menus
{1, "Always Run", 0}, // [FG] toggle always run
{1, "Crosshair", 0} // [FG] toggle crosshair
};
#ifndef SPEAR
CP_itemtype NewEmenu[] = {
{1, "Episode 1\n" "Escape from Wolfenstein", 0},
{0, "", 0},
{3, "Episode 2\n" "Operation: Eisenfaust", 0},
{0, "", 0},
{3, "Episode 3\n" "Die, Fuhrer, Die!", 0},
{0, "", 0},
{3, "Episode 4\n" "A Dark Secret", 0},
{0, "", 0},
{3, "Episode 5\n" "Trail of the Madman", 0},
{0, "", 0},
{3, "Episode 6\n" "Confrontation", 0}
};
#endif
CP_itemtype NewMenu[] = {
{1, STR_DADDY, 0},
{1, STR_HURTME, 0},
{1, STR_BRINGEM, 0},
{1, STR_DEATH, 0}
};
CP_itemtype LSMenu[] = {
{1, "", 0},
{1, "", 0},
{1, "", 0},
{1, "", 0},
{1, "", 0},
{1, "", 0},
{1, "", 0},
{1, "", 0},
{1, "", 0},
{1, "", 0}
};
CP_itemtype CusMenu[] = {
{1, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{1, "", 0}
};
// [FG] extended "Customize" menus
CP_itemtype Cus2Menu[] = {
{1, "", 0},
{0, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0}
};
// CP_iteminfo struct format: short x, y, amount, curpos, indent;
CP_iteminfo MainItems = { MENU_X, MENU_Y, lengthof(MainMenu), STARTITEM, 24 },
SndItems = { SM_X, SM_Y1, lengthof(SndMenu), 0, 52 },
LSItems = { LSM_X, LSM_Y, lengthof(LSMenu), 0, 24 },
CtlItems = { CTL_X, CTL_Y, lengthof(CtlMenu), -1, 56 },
CusItems = { 8, CST_Y + 13 * 2, lengthof(CusMenu), -1, 0},
Cus2Items = { 8, CST_Y + 13 * 2, lengthof(Cus2Menu), -1, 0}, // [FG] extended "Customize" menus
#ifndef SPEAR
NewEitems = { NE_X, NE_Y, lengthof(NewEmenu), 0, 88 },
#endif
NewItems = { NM_X, NM_Y, lengthof(NewMenu), 2, 24 };
int color_hlite[] = {
DEACTIVE,
HIGHLIGHT,
READHCOLOR,
0x67
};
int color_norml[] = {
DEACTIVE,
TEXTCOLOR,
READCOLOR,
0x6b
};
int EpisodeSelect[6] = { 1 };
static int SaveGamesAvail[10];
static int StartGame;
static int SoundStatus = 1;
static int pickquick;
static char SaveGameNames[10][32];
static char SaveName[13] = "savegam?.";
////////////////////////////////////////////////////////////////////
//
// INPUT MANAGER SCANCODE TABLES
//
////////////////////////////////////////////////////////////////////
#if 0
static const char *ScanNames[] = // Scan code names with single chars
{
"?", "?", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "+", "?", "?",
"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "|", "?", "A", "S",
"D", "F", "G", "H", "J", "K", "L", ";", "\"", "?", "?", "?", "Z", "X", "C", "V",
"B", "N", "M", ",", ".", "/", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
"?", "?", "?", "?", "?", "?", "?", "?", "\xf", "?", "-", "\x15", "5", "\x11", "+", "?",
"\x13", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?"
}; // DEBUG - consolidate these
static ScanCode ExtScanCodes[] = // Scan codes with >1 char names
{
1, 0xe, 0xf, 0x1d, 0x2a, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x57, 0x59, 0x46, 0x1c, 0x36,
0x37, 0x38, 0x47, 0x49, 0x4f, 0x51, 0x52, 0x53, 0x45, 0x48,
0x50, 0x4b, 0x4d, 0x00
};
static const char *ExtScanNames[] = // Names corresponding to ExtScanCodes
{
"Esc", "BkSp", "Tab", "Ctrl", "LShft", "Space", "CapsLk", "F1", "F2", "F3", "F4",
"F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "ScrlLk", "Enter", "RShft",
"PrtSc", "Alt", "Home", "PgUp", "End", "PgDn", "Ins", "Del", "NumLk", "Up",
"Down", "Left", "Right", ""
};
/*#pragma warning 737 9
static byte
*ScanNames[] = // Scan code names with single chars
{
"?","?","1","2","3","4","5","6","7","8","9","0","-","+","?","?",
"Q","W","E","R","T","Y","U","I","O","P","[","]","|","?","A","S",
"D","F","G","H","J","K","L",";","\"","?","?","?","Z","X","C","V",
"B","N","M",",",".","/","?","?","?","?","?","?","?","?","?","?",
"?","?","?","?","?","?","?","?","\xf","?","-","\x15","5","\x11","+","?",
"\x13","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?",
"?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?",
"?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?"
}; // DEBUG - consolidate these
static byte ExtScanCodes[] = // Scan codes with >1 char names
{
1,0xe,0xf,0x1d,0x2a,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,
0x3f,0x40,0x41,0x42,0x43,0x44,0x57,0x59,0x46,0x1c,0x36,
0x37,0x38,0x47,0x49,0x4f,0x51,0x52,0x53,0x45,0x48,
0x50,0x4b,0x4d,0x00
};
static byte *ExtScanNames[] = // Names corresponding to ExtScanCodes
{
"Esc","BkSp","Tab","Ctrl","LShft","Space","CapsLk","F1","F2","F3","F4",
"F5","F6","F7","F8","F9","F10","F11","F12","ScrlLk","Enter","RShft",
"PrtSc","Alt","Home","PgUp","End","PgDn","Ins","Del","NumLk","Up",
"Down","Left","Right",""
};*/
#else
static std::unordered_map<ScanCode, const char *> ScanNames;
void US_SetScanNames()
{
ScanNames[0] = "None";
ScanNames[sc_Enter] = "Enter";
ScanNames[SDLK_UP] = "Up";
ScanNames[SDLK_DOWN] = "Down";
ScanNames[SDLK_RIGHT] = "Right";
ScanNames[SDLK_LEFT] = "Left";
ScanNames[SDLK_INSERT] = "Ins";
ScanNames[SDLK_HOME] = "Home";
ScanNames[SDLK_END] = "End";
ScanNames[SDLK_PAGEUP] = "PgUp";
ScanNames[SDLK_PAGEDOWN] = "PgDn";
ScanNames[SDLK_F1] = "F1";
ScanNames[SDLK_F2] = "F2";
ScanNames[SDLK_F3] = "F3";
ScanNames[SDLK_F4] = "F4";
ScanNames[SDLK_F5] = "F5";
ScanNames[SDLK_F6] = "F6";
ScanNames[SDLK_F7] = "F7";
ScanNames[SDLK_F8] = "F8";
ScanNames[SDLK_F9] = "F9";
ScanNames[SDLK_F10] = "F10";
ScanNames[SDLK_F11] = "F11";
ScanNames[SDLK_F12] = "F12";
ScanNames[SDLK_F13] = "F13";
ScanNames[SDLK_F14] = "F14";
ScanNames[SDLK_F15] = "F15";
ScanNames[SDLK_F16] = "F16";
ScanNames[SDLK_F17] = "F17";
ScanNames[SDLK_F18] = "F18";
ScanNames[SDLK_F19] = "F19";
ScanNames[SDLK_NUMLOCKCLEAR] = "NumLk";
ScanNames[SDLK_CAPSLOCK] = "CapsLk";
ScanNames[SDLK_SCROLLLOCK] = "ScrlLk";
ScanNames[SDLK_RSHIFT] = "RShft";
ScanNames[SDLK_LSHIFT] = "Shift";
ScanNames[SDLK_RCTRL] = "RCtrl";
ScanNames[SDLK_LCTRL] = "LCtrl";
ScanNames[SDLK_RALT] = "RAlt";
ScanNames[SDLK_LALT] = "Alt";
ScanNames[SDLK_RGUI] = "RMeta";
ScanNames[SDLK_LGUI] = "LMeta";
ScanNames[SDLK_PRINTSCREEN] = "PrtSc";
ScanNames[sc_BackSpace] = "BkSp";
ScanNames[sc_Tab] = "Tab";
ScanNames[sc_Return] = "Return";
ScanNames[SDLK_PAUSE] = "Pause";
ScanNames[sc_Escape] = "Esc";
ScanNames[sc_Space] = "Space";
ScanNames[SDLK_EXCLAIM] = "!";
ScanNames[SDLK_QUOTEDBL] = "\"";
ScanNames[SDLK_HASH] = "#";
ScanNames[SDLK_DOLLAR] = "$";
ScanNames[SDLK_QUESTION] = "?";
ScanNames[SDLK_AMPERSAND] = "&";
ScanNames[SDLK_QUOTE] = "'";
ScanNames[SDLK_LEFTPAREN] = "(";
ScanNames[SDLK_RIGHTPAREN] = ")";
ScanNames[SDLK_ASTERISK] = "*";
ScanNames[SDLK_PLUS] = "+";
ScanNames[SDLK_COMMA] = ",";
ScanNames[SDLK_MINUS] = "-";
ScanNames[SDLK_PERIOD] = ".";
ScanNames[SDLK_SLASH] = "/";
ScanNames[SDLK_0] = "0";
ScanNames[SDLK_1] = "1";
ScanNames[SDLK_2] = "2";
ScanNames[SDLK_3] = "3";
ScanNames[SDLK_4] = "4";
ScanNames[SDLK_5] = "5";
ScanNames[SDLK_6] = "6";
ScanNames[SDLK_7] = "7";
ScanNames[SDLK_8] = "8";
ScanNames[SDLK_9] = "9";
ScanNames[SDLK_COLON] = ":";
ScanNames[SDLK_SEMICOLON] = ";";
ScanNames[SDLK_LESS] = "<";
ScanNames[SDLK_EQUALS] = "=";
ScanNames[SDLK_GREATER] = ">";
ScanNames[SDLK_AT] = "@";
ScanNames[SDLK_a] = "A";
ScanNames[SDLK_b] = "B";
ScanNames[SDLK_c] = "C";
ScanNames[SDLK_d] = "D";
ScanNames[SDLK_e] = "E";
ScanNames[SDLK_f] = "F";
ScanNames[SDLK_g] = "G";
ScanNames[SDLK_h] = "H";
ScanNames[SDLK_i] = "I";
ScanNames[SDLK_j] = "J";
ScanNames[SDLK_k] = "K";
ScanNames[SDLK_l] = "L";
ScanNames[SDLK_m] = "M";
ScanNames[SDLK_n] = "N";
ScanNames[SDLK_o] = "O";
ScanNames[SDLK_p] = "P";
ScanNames[SDLK_q] = "Q";
ScanNames[SDLK_r] = "R";
ScanNames[SDLK_s] = "S";
ScanNames[SDLK_t] = "T";
ScanNames[SDLK_u] = "U";
ScanNames[SDLK_v] = "V";
ScanNames[SDLK_w] = "W";
ScanNames[SDLK_x] = "X";
ScanNames[SDLK_y] = "Y";
ScanNames[SDLK_z] = "Z";
ScanNames[SDLK_LEFTBRACKET] = "[";
ScanNames[SDLK_BACKSLASH] = "\\";
ScanNames[SDLK_RIGHTBRACKET] = "]";
ScanNames[KEYD_MWHEELUP] = "MWUP";
ScanNames[KEYD_MWHEELDOWN] = "MWDN";
}
#endif
bool menuactive; // [FG] true if menu is active
////////////////////////////////////////////////////////////////////
//
// Wolfenstein Control Panel! Ta Da!
//
////////////////////////////////////////////////////////////////////
void
US_ControlPanel (ScanCode scancode)
{
int which;
if (ingame)
{
if (CP_CheckQuick (scancode))
return;
lastgamemusicoffset = StartCPMusic (MENUSONG);
}
else
StartCPMusic (MENUSONG);
SetupControlPanel ();
//
// F-KEYS FROM WITHIN GAME
//
switch (scancode)
{
case sc_F1:
BossKey ();
goto finishup;
case sc_F2:
CP_SaveGame (0);
goto finishup;
case sc_F3:
CP_LoadGame (0);
goto finishup;
case sc_F4:
CP_Sound (0);
goto finishup;
case sc_F5:
CP_ChangeView (0);
goto finishup;
case sc_F6:
CP_Control (0);
goto finishup;
finishup:
CleanupControlPanel ();
#ifdef SPEAR
UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
#endif
return;
}
#ifdef SPEAR
CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
#endif
DrawMainMenu ();
MenuFadeIn ();
StartGame = 0;
//
// MAIN MENU LOOP
//
do
{
which = HandleMenu (&MainItems, &MainMenu[0], NULL);
#ifdef SPEAR
#ifndef SPEARDEMO
IN_ProcessEvents();
//
// EASTER EGG FOR SPEAR OF DESTINY!
//
if (Keyboard[sc_I] && Keyboard[sc_D])
{
VW_FadeOut ();
StartCPMusic (XJAZNAZI_MUS);
UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
UnCacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
ClearMemory ();
CA_CacheGrChunk (IDGUYS1PIC);
VWB_DrawPic (0, 0, IDGUYS1PIC);
UNCACHEGRCHUNK (IDGUYS1PIC);
CA_CacheGrChunk (IDGUYS2PIC);
VWB_DrawPic (0, 80, IDGUYS2PIC);
UNCACHEGRCHUNK (IDGUYS2PIC);
VW_UpdateScreen ();
SDL_Color pal[256];
CA_CacheGrChunk (IDGUYSPALETTE);
VL_ConvertPalette(grsegs[IDGUYSPALETTE], pal, 256);
VL_FadeIn (0, 255, pal, 30);
UNCACHEGRCHUNK (IDGUYSPALETTE);
while (Keyboard[sc_I] || Keyboard[sc_D])
IN_WaitAndProcessEvents();
IN_ClearKeysDown ();
IN_Ack ();
VW_FadeOut ();
CacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
DrawMainMenu ();
StartCPMusic (MENUSONG);
MenuFadeIn ();
}
#endif
#endif
switch (which)
{
case viewscores:
if (MainMenu[viewscores].routine == NULL)
{
if (CP_EndGame (0))
StartGame = 1;
}
else
{
DrawMainMenu();
MenuFadeIn ();
}
break;
case backtodemo:
StartGame = 1;
if (!ingame)
StartCPMusic (INTROSONG);
VL_FadeOut (0, 255, 0, 0, 0, 10);
break;
case -1:
case quit:
CP_Quit (0);
break;
default:
if (!StartGame)
{
DrawMainMenu ();
MenuFadeIn ();
}
}
//
// "EXIT OPTIONS" OR "NEW GAME" EXITS
//
}
while (!StartGame);
//
// DEALLOCATE EVERYTHING
//
CleanupControlPanel ();
//
// CHANGE MAINMENU ITEM
//
if (startgame || loadedgame)
EnableEndGameMenuItem();
// RETURN/START GAME EXECUTION
#ifdef SPEAR
UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
#endif
}
void EnableEndGameMenuItem()
{
MainMenu[viewscores].routine = NULL;
strcpy (MainMenu[viewscores].string, STR_EG);
}
////////////////////////
//
// DRAW MAIN MENU SCREEN
//
void
DrawMainMenu (void)
{
ClearMScreen ();
VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
DrawStripes (10);
VWB_DrawPic (84, 0, C_OPTIONSPIC);
DrawWindow (MENU_X - 8, MENU_Y - 3, MENU_W, MENU_H, BKGDCOLOR);
//
// CHANGE "GAME" AND "DEMO"
//
if (ingame)
{
strcpy (&MainMenu[backtodemo].string[8], STR_GAME);
MainMenu[backtodemo].active = 2;
}
else
{
strcpy (&MainMenu[backtodemo].string[8], STR_DEMO);
MainMenu[backtodemo].active = 1;
}
DrawMenu (&MainItems, &MainMenu[0]);
VW_UpdateScreen ();
}
////////////////////////////////////////////////////////////////////
//
// BOSS KEY
//
////////////////////////////////////////////////////////////////////
void
BossKey (void)
{
const char *prompt[] = {"C:\\>", "C:\\>_"};
int i = 0;
int lastoffs = StopMusic();
int32_t lastBlinkTime = GetTimeCount();
// [FG] instant fade-in to cleared screen
VWB_Bar(0, 0, 320, 200, 0);
VL_FadeIn(0, 255, gamepal, 1);
fontnumber = 0;
SETFONTCOLOR(15, 0);
do
{
// [FG] clear screen
VWB_Bar (0, 0, 320, 200, 0);
// [FG] print DOS prompt line with blinking cursor
if ((int32_t)GetTimeCount() - lastBlinkTime > 20)
{
lastBlinkTime = GetTimeCount();
i ^= 1;
}
PrintX = PrintY = 0;
US_Print(prompt[i]);
VW_UpdateScreen();
TicDelay(20);
} while (!(IN_KeyDown(sc_Escape) || IN_KeyDown(sc_Control) || IN_KeyDown(sc_Alt)));
IN_ClearKeysDown ();
ContinueMusic(lastoffs);
}
////////////////////////////////////////////////////////////////////
//
// CHECK QUICK-KEYS & QUIT (WHILE IN A GAME)
//
////////////////////////////////////////////////////////////////////
int
CP_CheckQuick (ScanCode scancode)
{
switch (scancode)
{
//
// END GAME
//
case sc_F7:
CA_CacheGrChunk (STARTFONT + 1);
WindowH = 160;
if (Confirm (ENDGAMESTR))
{
playstate = ex_died;
killerobj = NULL;
pickquick = gamestate.lives = 0;
}
WindowH = 200;
fontnumber = 0;
MainMenu[savegame].active = 0;
return 1;
//
// QUICKSAVE
//
case sc_F8:
if (SaveGamesAvail[LSItems.curpos] && pickquick)
{
CA_CacheGrChunk (STARTFONT + 1);
fontnumber = 1;
Message (STR_SAVING "...");
CP_SaveGame (1);
fontnumber = 0;
}
else
{
#ifndef SPEAR
CA_CacheGrChunk (STARTFONT + 1);
CA_CacheGrChunk (C_CURSOR1PIC);
CA_CacheGrChunk (C_CURSOR2PIC);
CA_CacheGrChunk (C_DISKLOADING1PIC);
CA_CacheGrChunk (C_DISKLOADING2PIC);
CA_CacheGrChunk (C_SAVEGAMEPIC);
CA_CacheGrChunk (C_MOUSELBACKPIC);
#else
CacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
CA_CacheGrChunk (C_CURSOR1PIC);
#endif
VW_FadeOut ();
if(screenHeight % 200 != 0)
VL_ClearScreen(0);
lastgamemusicoffset = StartCPMusic (MENUSONG);
pickquick = CP_SaveGame (0);
SETFONTCOLOR (0, 15);
IN_ClearKeysDown ();
VW_FadeOut();
if(viewsize != 21)
DrawPlayScreen ();
if (!startgame && !loadedgame)
ContinueMusic (lastgamemusicoffset);
if (loadedgame)
playstate = ex_abort;
lasttimecount = GetTimeCount ();
#ifndef SPEAR
UNCACHEGRCHUNK (C_CURSOR1PIC);
UNCACHEGRCHUNK (C_CURSOR2PIC);
UNCACHEGRCHUNK (C_DISKLOADING1PIC);
UNCACHEGRCHUNK (C_DISKLOADING2PIC);
UNCACHEGRCHUNK (C_SAVEGAMEPIC);
UNCACHEGRCHUNK (C_MOUSELBACKPIC);
#else
UnCacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
#endif
}
return 1;
//
// QUICKLOAD
//
case sc_F9:
if (SaveGamesAvail[LSItems.curpos] && pickquick)
{
char string[100] = STR_LGC;
CA_CacheGrChunk (STARTFONT + 1);
fontnumber = 1;
strcat (string, SaveGameNames[LSItems.curpos]);
strcat (string, "\"?");
if (Confirm (string))
CP_LoadGame (1);
fontnumber = 0;
}
else
{
#ifndef SPEAR
CA_CacheGrChunk (STARTFONT + 1);
CA_CacheGrChunk (C_CURSOR1PIC);
CA_CacheGrChunk (C_CURSOR2PIC);
CA_CacheGrChunk (C_DISKLOADING1PIC);
CA_CacheGrChunk (C_DISKLOADING2PIC);
CA_CacheGrChunk (C_LOADGAMEPIC);
CA_CacheGrChunk (C_MOUSELBACKPIC);
#else
CA_CacheGrChunk (C_CURSOR1PIC);
CacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
#endif
VW_FadeOut ();
if(screenHeight % 200 != 0)
VL_ClearScreen(0);
lastgamemusicoffset = StartCPMusic (MENUSONG);
pickquick = CP_LoadGame (0); // loads lastgamemusicoffs
SETFONTCOLOR (0, 15);
IN_ClearKeysDown ();
VW_FadeOut();
if(viewsize != 21)
DrawPlayScreen ();
if (!startgame && !loadedgame)
ContinueMusic (lastgamemusicoffset);
if (loadedgame)
playstate = ex_abort;
lasttimecount = GetTimeCount ();
#ifndef SPEAR
UNCACHEGRCHUNK (C_CURSOR1PIC);
UNCACHEGRCHUNK (C_CURSOR2PIC);
UNCACHEGRCHUNK (C_DISKLOADING1PIC);
UNCACHEGRCHUNK (C_DISKLOADING2PIC);
UNCACHEGRCHUNK (C_LOADGAMEPIC);
UNCACHEGRCHUNK (C_MOUSELBACKPIC);
#else
UnCacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
#endif
}
return 1;
//
// QUIT
//
case sc_F10:
CA_CacheGrChunk (STARTFONT + 1);
WindowX = WindowY = 0;
WindowW = 320;
WindowH = 160;
if (Confirm (endStrings[US_RndT () & (0x7 + (US_RndT () & 1))]))
{
VW_UpdateScreen ();
SD_MusicOff ();
SD_StopSound ();
MenuFadeOut ();
Quit (NULL);
}
DrawPlayBorder ();
WindowH = 200;
fontnumber = 0;
return 1;
}
return 0;
}
////////////////////////////////////////////////////////////////////
//
// END THE CURRENT GAME
//
////////////////////////////////////////////////////////////////////
int
CP_EndGame (int)
{
int res;
res = Confirm (ENDGAMESTR);
DrawMainMenu();
if(!res) return 0;
pickquick = gamestate.lives = 0;
playstate = ex_died;
killerobj = NULL;
MainMenu[savegame].active = 0;
MainMenu[viewscores].routine = CP_ViewScores;
strcpy (MainMenu[viewscores].string, STR_VS);
return 1;
}
////////////////////////////////////////////////////////////////////
//
// VIEW THE HIGH SCORES
//
////////////////////////////////////////////////////////////////////
int
CP_ViewScores (int)
{
fontnumber = 0;
#ifdef SPEAR
UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
StartCPMusic (XAWARD_MUS);
#else
StartCPMusic (ROSTER_MUS);
#endif
DrawHighScores ();
VW_UpdateScreen ();
MenuFadeIn ();
fontnumber = 1;
IN_Ack ();
StartCPMusic (MENUSONG);
MenuFadeOut ();
#ifdef SPEAR
CacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
#endif
return 0;
}
////////////////////////////////////////////////////////////////////
//
// START A NEW GAME
//
////////////////////////////////////////////////////////////////////
int
CP_NewGame (int)
{
int which, episode;
#ifdef SPEAR
UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
#endif
#ifndef SPEAR
firstpart:
DrawNewEpisode ();
do
{
which = HandleMenu (&NewEitems, &NewEmenu[0], NULL);
switch (which)
{
case -1:
MenuFadeOut ();
return 0;
default:
if (!EpisodeSelect[which / 2])
{
SD_PlaySound (NOWAYSND);
Message ("Please select \"Read This!\"\n"
"from the Options menu to\n"
"find out how to order this\n" "episode from Apogee.");
IN_ClearKeysDown ();
IN_Ack ();
DrawNewEpisode ();
which = 0;
}
else
{
episode = which / 2;
which = 1;
}
break;
}
}
while (!which);
ShootSnd ();
//
// ALREADY IN A GAME?
//
if (ingame)
if (!Confirm (CURGAME))
{
MenuFadeOut ();
return 0;
}
MenuFadeOut ();
#else
episode = 0;
//
// ALREADY IN A GAME?
//
CacheLump (NEWGAME_LUMP_START, NEWGAME_LUMP_END);
DrawNewGame ();
if (ingame)
if (!Confirm (CURGAME))
{
MenuFadeOut ();
UnCacheLump (NEWGAME_LUMP_START, NEWGAME_LUMP_END);
CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
return 0;
}
#endif
DrawNewGame ();
which = HandleMenu (&NewItems, &NewMenu[0], DrawNewGameDiff);
if (which < 0)
{
MenuFadeOut ();
#ifndef SPEAR
goto firstpart;
#else
UnCacheLump (NEWGAME_LUMP_START, NEWGAME_LUMP_END);
CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
return 0;
#endif
}
ShootSnd ();
NewGame (which, episode);
StartGame = 1;
MenuFadeOut ();
pickquick = 0;
#ifdef SPEAR
UnCacheLump (NEWGAME_LUMP_START, NEWGAME_LUMP_END);
CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
#endif
return 0;
}
#ifndef SPEAR
/////////////////////
//
// DRAW NEW EPISODE MENU
//
void
DrawNewEpisode (void)
{
int i;
ClearMScreen ();
VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
DrawWindow (NE_X - 4, NE_Y - 4, NE_W + 8, NE_H + 8, BKGDCOLOR);
SETFONTCOLOR (READHCOLOR, BKGDCOLOR);