forked from KS-Presto/Wolf4SDL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wl_menu.cpp
4159 lines (3682 loc) · 76.3 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 "unistd_win.h"
#else
#include <unistd.h>
#endif
#include "wl_def.h"
#pragma hdrstop
extern int lastgamemusicoffset;
extern int numEpisodesMissing;
//
// PRIVATE PROTOTYPES
//
int CP_ReadThis(int);
#ifdef SPEAR
#define STARTITEM newgame
#else
#ifdef GOODTIMES
#define STARTITEM newgame
#else
#define STARTITEM readthis
#endif
#endif
// ENDSTRx constants are defined in foreign.h
char endStrings[9][80] = {
ENDSTR1,
ENDSTR2,
ENDSTR3,
ENDSTR4,
ENDSTR5,
ENDSTR6,
ENDSTR7,
ENDSTR8,
ENDSTR9
};
CP_itemtype MainMenu[] = {
#ifdef JAPAN
{1, "", CP_NewGame},
{1, "", CP_Sound},
{1, "", CP_Control},
{1, "", CP_LoadGame},
{0, "", CP_SaveGame},
{1, "", CP_ChangeView},
{2, "", CP_ReadThis},
{1, "", CP_ViewScores},
{1, "", 0},
{1, "", 0}
#else
{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},
#ifndef GOODTIMES
#ifndef SPEAR
#ifdef SPANISH
{2, "Ve esto!", CP_ReadThis},
#else
{2, "Read This!", CP_ReadThis},
#endif
#endif
#endif
{1, STR_VS, CP_ViewScores},
{1, STR_BD, 0},
{1, STR_QT, 0}
#endif
};
CP_itemtype SndMenu[] = {
#ifdef JAPAN
{1, "", 0},
{1, "", 0},
{1, "", 0},
{0, "", 0},
{0, "", 0},
{1, "", 0},
{1, "", 0},
{1, "", 0},
{0, "", 0},
{0, "", 0},
{1, "", 0},
{1, "", 0},
#else
{1, STR_NONE, 0},
{0, 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}
#endif
};
enum { CTL_MOUSEENABLE, CTL_MOUSESENS, CTL_JOYENABLE, CTL_CUSTOMIZE };
CP_itemtype CtlMenu[] = {
#ifdef JAPAN
{0, "", 0},
{0, "", MouseSensitivity},
{0, "", 0},
{1, "", CustomControls}
#else
{0, STR_MOUSEEN, 0},
{0, STR_SENS, MouseSensitivity},
{0, STR_JOYEN, 0},
{1, STR_CUSTOM, CustomControls}
#endif
};
#ifndef SPEAR
CP_itemtype NewEmenu[] = {
#ifdef JAPAN
#ifdef JAPDEMO
{1, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", 0},
#else
{1, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0}
#endif
#else
#ifdef SPANISH
{1, "Episodio 1\n" "Fuga desde Wolfenstein", 0},
{0, "", 0},
{3, "Episodio 2\n" "Operacion Eisenfaust", 0},
{0, "", 0},
{3, "Episodio 3\n" "Muere, Fuhrer, Muere!", 0},
{0, "", 0},
{3, "Episodio 4\n" "Un Negro Secreto", 0},
{0, "", 0},
{3, "Episodio 5\n" "Huellas del Loco", 0},
{0, "", 0},
{3, "Episodio 6\n" "Confrontacion", 0}
#else
{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
#endif
};
#endif
CP_itemtype NewMenu[] = {
#ifdef JAPAN
{1, "", 0},
{1, "", 0},
{1, "", 0},
{1, "", 0}
#else
{1, STR_DADDY, 0},
{1, STR_HURTME, 0},
{1, STR_BRINGEM, 0},
{1, STR_DEATH, 0}
#endif
};
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},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{0, "", 0},
{1, "", 0},
{0, "", 0},
{1, "", 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 },
#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",""
};*/
#endif
////////////////////////////////////////////////////////////////////
//
// 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:
#ifdef SPEAR
BossKey();
#else
#ifdef GOODTIMES
BossKey();
#else
HelpScreens();
#endif
#endif
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;
#ifndef JAPAN
strcpy(MainMenu[viewscores].string, STR_EG);
#endif
}
////////////////////////
//
// DRAW MAIN MENU SCREEN
//
void
DrawMainMenu(void)
{
#ifdef JAPAN
CA_CacheScreen(S_OPTIONSPIC);
#else
ClearMScreen();
VWB_DrawPic(112, 184, C_MOUSELBACKPIC);
DrawStripes(10);
VWB_DrawPic(84, 0, C_OPTIONSPIC);
#ifdef SPANISH
DrawWindow(MENU_X - 8, MENU_Y - 3, MENU_W + 8, MENU_H, BKGDCOLOR);
#else
DrawWindow(MENU_X - 8, MENU_Y - 3, MENU_W, MENU_H, BKGDCOLOR);
#endif
#endif
//
// CHANGE "GAME" AND "DEMO"
//
if (ingame)
{
#ifndef JAPAN
#ifdef SPANISH
strcpy(&MainMenu[backtodemo].string, STR_GAME);
#else
strcpy(&MainMenu[backtodemo].string[8], STR_GAME);
#endif
#else
CA_CacheGrChunk(C_MRETGAMEPIC);
VWB_DrawPic(12 * 8, 20 * 8, C_MRETGAMEPIC);
UNCACHEGRCHUNK(C_MRETGAMEPIC);
CA_CacheGrChunk(C_MENDGAMEPIC);
VWB_DrawPic(12 * 8, 18 * 8, C_MENDGAMEPIC);
UNCACHEGRCHUNK(C_MENDGAMEPIC);
#endif
MainMenu[backtodemo].active = 2;
}
else
{
#ifndef JAPAN
#ifdef SPANISH
strcpy(&MainMenu[backtodemo].string, STR_BD);
#else
strcpy(&MainMenu[backtodemo].string[8], STR_DEMO);
#endif
#else
CA_CacheGrChunk(C_MRETDEMOPIC);
VWB_DrawPic(12 * 8, 20 * 8, C_MRETDEMOPIC);
UNCACHEGRCHUNK(C_MRETDEMOPIC);
CA_CacheGrChunk(C_MSCORESPIC);
VWB_DrawPic(12 * 8, 18 * 8, C_MSCORESPIC);
UNCACHEGRCHUNK(C_MSCORESPIC);
#endif
MainMenu[backtodemo].active = 1;
}
DrawMenu(&MainItems, &MainMenu[0]);
VW_UpdateScreen();
}
#ifndef GOODTIMES
#ifndef SPEAR
////////////////////////////////////////////////////////////////////
//
// READ THIS!
//
////////////////////////////////////////////////////////////////////
int
CP_ReadThis(int)
{
StartCPMusic(CORNER_MUS);
HelpScreens();
StartCPMusic(MENUSONG);
return true;
}
#endif
#endif
#ifdef GOODTIMES
////////////////////////////////////////////////////////////////////
//
// BOSS KEY
//
////////////////////////////////////////////////////////////////////
void
BossKey(void)
{
#ifdef NOTYET
byte palette1[256][3];
SD_MusicOff();
/* _AX = 3;
geninterrupt(0x10); */
_asm
{
mov eax, 3 int 0x10}
puts("C>");
SetTextCursor(2, 0);
// while (!Keyboard[sc_Escape])
IN_Ack();
IN_ClearKeysDown();
SD_MusicOn();
VL_SetVGAPlaneMode();
for (int i = 0; i < 768; i++)
palette1[0][i] = 0;
VL_SetPalette(&palette1[0][0]);
LoadLatchMem();
#endif
}
#else
#ifdef SPEAR
void
BossKey(void)
{
#ifdef NOTYET
byte palette1[256][3];
SD_MusicOff();
/* _AX = 3;
geninterrupt(0x10); */
_asm
{
mov eax, 3 int 0x10}
puts("C>");
SetTextCursor(2, 0);
// while (!Keyboard[sc_Escape])
IN_Ack();
IN_ClearKeysDown();
SD_MusicOn();
VL_SetVGAPlaneMode();
for (int i = 0; i < 768; i++)
palette1[0][i] = 0;
VL_SetPalette(&palette1[0][0]);
LoadLatchMem();
#endif
}
#endif
#endif
////////////////////////////////////////////////////////////////////
//
// 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;
#ifdef JAPAN
if (GetYorN(7, 8, C_JAPQUITPIC))
#else
if (Confirm(ENDGAMESTR))
#endif
{
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;
#ifdef JAPAN
if (GetYorN(7, 8, C_QUITMSGPIC))
#else
#ifdef SPANISH
if (Confirm(ENDGAMESTR))
#else
if (Confirm(endStrings[US_RndT() & 0x7 + (US_RndT() & 1)]))
#endif
#endif
{
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;
#ifdef JAPAN
res = GetYorN(7, 8, C_JAPQUITPIC);
#else
res = Confirm(ENDGAMESTR);
#endif
DrawMainMenu();
if (!res) return 0;
pickquick = gamestate.lives = 0;
playstate = ex_died;
killerobj = NULL;
MainMenu[savegame].active = 0;
MainMenu[viewscores].routine = CP_ViewScores;
#ifndef JAPAN
strcpy(MainMenu[viewscores].string, STR_VS);
#endif
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)
#ifdef JAPAN
if (!GetYorN(7, 8, C_JAPNEWGAMEPIC))
#else
if (!Confirm(CURGAME))
#endif
{
MenuFadeOut();
return 0;
}
MenuFadeOut();