blob: cdbc70aad12b03df7fc7a0aabd7cd3e561520766 [file] [log] [blame]
<
Franklin Wei3f59fc82019-07-07 22:00:20 -04001////////////////////////////////////////////////////////////////////
2//
3// WL_MENU.C
4// by John Romero (C) 1992 Id Software, Inc.
5//
6////////////////////////////////////////////////////////////////////
7
8#include "wl_def.h"
9#pragma hdrstop
10
11extern int lastgamemusicoffset;
12extern int numEpisodesMissing;
13
14//
15// PRIVATE PROTOTYPES
16//
17int CP_ReadThis (int);
18
19#ifdef SPEAR
20#define STARTITEM newgame
21
22#else
23#ifdef GOODTIMES
24#define STARTITEM newgame
25
26#else
27#define STARTITEM readthis
28#endif
29#endif
30
31// ENDSTRx constants are defined in foreign.h
32char endStrings[9][80] = {
33 ENDSTR1,
34 ENDSTR2,
35 ENDSTR3,
36 ENDSTR4,
37 ENDSTR5,
38 ENDSTR6,
39 ENDSTR7,
40 ENDSTR8,
41 ENDSTR9
42};
43
44CP_itemtype MainMenu[] = {
45#ifdef JAPAN
46 {1, "", CP_NewGame},
47 {1, "", CP_Sound},
48 {1, "", CP_Control},
49 {1, "", CP_LoadGame},
50 {0, "", CP_SaveGame},
51 {1, "", CP_ChangeView},
52 {2, "", CP_ReadThis},
53 {1, "", CP_ViewScores},
54 {1, "", 0},
55 {1, "", 0}
56#else
57
58 {1, STR_NG, CP_NewGame},
59 {1, STR_SD, CP_Sound},
60 {1, STR_CL, CP_Control},
61 {1, STR_LG, CP_LoadGame},
62 {0, STR_SG, CP_SaveGame},
63 {1, STR_CV, CP_ChangeView},
64
65#ifndef GOODTIMES
66#ifndef SPEAR
67
68#ifdef SPANISH
69 {2, "Ve esto!", CP_ReadThis},
70#else
71 {2, "Read This!", CP_ReadThis},
72#endif
73
74#endif
75#endif
76
77 {1, STR_VS, CP_ViewScores},
78 {1, STR_BD, 0},
79 {1, STR_QT, 0}
80#endif
81};
82
83CP_itemtype SndMenu[] = {
84#ifdef JAPAN
85 {1, "", 0},
86 {1, "", 0},
87 {1, "", 0},
88 {0, "", 0},
89 {0, "", 0},
90 {1, "", 0},
91 {1, "", 0},
92 {1, "", 0},
93 {0, "", 0},
94 {0, "", 0},
95 {1, "", 0},
96 {1, "", 0},
97#else
98 {1, STR_NONE, 0},
99 {0, STR_PC, 0},
100 {1, STR_ALSB, 0},
101 {0, "", 0},
102 {0, "", 0},
103 {1, STR_NONE, 0},
104 {0, STR_DISNEY, 0},
105 {1, STR_SB, 0},
106 {0, "", 0},
107 {0, "", 0},
108 {1, STR_NONE, 0},
109 {1, STR_ALSB, 0}
110#endif
111};
112
113enum { CTL_MOUSEENABLE, CTL_MOUSESENS, CTL_JOYENABLE, CTL_CUSTOMIZE };
114
115CP_itemtype CtlMenu[] = {
116#ifdef JAPAN
117 {0, "", 0},
118 {0, "", MouseSensitivity},
119 {0, "", 0},
120 {1, "", CustomControls}
121#else
122 {0, STR_MOUSEEN, 0},
123 {0, STR_SENS, MouseSensitivity},
124 {0, STR_JOYEN, 0},
125 {1, STR_CUSTOM, CustomControls}
126#endif
127};
128
129#ifndef SPEAR
130CP_itemtype NewEmenu[] = {
131#ifdef JAPAN
132#ifdef JAPDEMO
133 {1, "", 0},
134 {0, "", 0},
135 {0, "", 0},
136 {0, "", 0},
137 {0, "", 0},
138 {0, "", 0},
139 {0, "", 0},
140 {0, "", 0},
141 {0, "", 0},
142 {0, "", 0},
143 {0, "", 0},
144 {0, "", 0},
145#else
146 {1, "", 0},
147 {0, "", 0},
148 {1, "", 0},
149 {0, "", 0},
150 {1, "", 0},
151 {0, "", 0},
152 {1, "", 0},
153 {0, "", 0},
154 {1, "", 0},
155 {0, "", 0},
156 {1, "", 0},
157 {0, "", 0}
158#endif
159#else
160#ifdef SPANISH
161 {1, "Episodio 1\n" "Fuga desde Wolfenstein", 0},
162 {0, "", 0},
163 {3, "Episodio 2\n" "Operacion Eisenfaust", 0},
164 {0, "", 0},
165 {3, "Episodio 3\n" "Muere, Fuhrer, Muere!", 0},
166 {0, "", 0},
167 {3, "Episodio 4\n" "Un Negro Secreto", 0},
168 {0, "", 0},
169 {3, "Episodio 5\n" "Huellas del Loco", 0},
170 {0, "", 0},
171 {3, "Episodio 6\n" "Confrontacion", 0}
172#else
173 {1, "Episode 1\n" "Escape from Wolfenstein", 0},
174 {0, "", 0},
175 {3, "Episode 2\n" "Operation: Eisenfaust", 0},
176 {0, "", 0},
177 {3, "Episode 3\n" "Die, Fuhrer, Die!", 0},
178 {0, "", 0},
179 {3, "Episode 4\n" "A Dark Secret", 0},
180 {0, "", 0},
181 {3, "Episode 5\n" "Trail of the Madman", 0},
182 {0, "", 0},
183 {3, "Episode 6\n" "Confrontation", 0}
184#endif
185#endif
186};
187#endif
188
189
190CP_itemtype NewMenu[] = {
191#ifdef JAPAN
192 {1, "", 0},
193 {1, "", 0},
194 {1, "", 0},
195 {1, "", 0}
196#else
197 {1, STR_DADDY, 0},
198 {1, STR_HURTME, 0},
199 {1, STR_BRINGEM, 0},
200 {1, STR_DEATH, 0}
201#endif
202};
203
204CP_itemtype LSMenu[] = {
205 {1, "", 0},
206 {1, "", 0},
207 {1, "", 0},
208 {1, "", 0},
209 {1, "", 0},
210 {1, "", 0},
211 {1, "", 0},
212 {1, "", 0},
213 {1, "", 0},
214 {1, "", 0}
215};
216
217CP_itemtype CusMenu[] = {
218 {1, "", 0},
219 {0, "", 0},
220 {0, "", 0},
221 {1, "", 0},
222 {0, "", 0},
223 {0, "", 0},
224 {1, "", 0},
225 {0, "", 0},
226 {1, "", 0}
227};
228
229// CP_iteminfo struct format: short x, y, amount, curpos, indent;
230CP_iteminfo MainItems = { MENU_X, MENU_Y, lengthof(MainMenu), STARTITEM, 24 },
231 SndItems = { SM_X, SM_Y1, lengthof(SndMenu), 0, 52 },
232 LSItems = { LSM_X, LSM_Y, lengthof(LSMenu), 0, 24 },
233 CtlItems = { CTL_X, CTL_Y, lengthof(CtlMenu), -1, 56 },
234 CusItems = { 8, CST_Y + 13 * 2, lengthof(CusMenu), -1, 0},
235#ifndef SPEAR
236 NewEitems = { NE_X, NE_Y, lengthof(NewEmenu), 0, 88 },
237#endif
238 NewItems = { NM_X, NM_Y, lengthof(NewMenu), 2, 24 };
239
240int color_hlite[] = {
241 DEACTIVE,
242 HIGHLIGHT,
243 READHCOLOR,
244 0x67
245};
246
247int color_norml[] = {
248 DEACTIVE,
249 TEXTCOLOR,
250 READCOLOR,
251 0x6b
252};
253
254int EpisodeSelect[6] = { 1 };
255
256
257static int SaveGamesAvail[10];
258static int StartGame;
259static int SoundStatus = 1;
260static int pickquick;
261static char SaveGameNames[10][32];
262static char SaveName[13] = "savegam?.";
263
264
265////////////////////////////////////////////////////////////////////
266//
267// INPUT MANAGER SCANCODE TABLES
268//
269////////////////////////////////////////////////////////////////////
270
271#if 0
272static const char *ScanNames[] = // Scan code names with single chars
273{
274 "?", "?", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "+", "?", "?",
275 "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "|", "?", "A", "S",
276 "D", "F", "G", "H", "J", "K", "L", ";", "\"", "?", "?", "?", "Z", "X", "C", "V",
277 "B", "N", "M", ",", ".", "/", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
278 "?", "?", "?", "?", "?", "?", "?", "?", "\xf", "?", "-", "\x15", "5", "\x11", "+", "?",
279 "\x13", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
280 "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
281 "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?"
282}; // DEBUG - consolidate these
283static ScanCode ExtScanCodes[] = // Scan codes with >1 char names
284{
285 1, 0xe, 0xf, 0x1d, 0x2a, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
286 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x57, 0x59, 0x46, 0x1c, 0x36,
287 0x37, 0x38, 0x47, 0x49, 0x4f, 0x51, 0x52, 0x53, 0x45, 0x48,
288 0x50, 0x4b, 0x4d, 0x00
289};
290static const char *ExtScanNames[] = // Names corresponding to ExtScanCodes
291{
292 "Esc", "BkSp", "Tab", "Ctrl", "LShft", "Space", "CapsLk", "F1", "F2", "F3", "F4",
293 "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "ScrlLk", "Enter", "RShft",
294 "PrtSc", "Alt", "Home", "PgUp", "End", "PgDn", "Ins", "Del", "NumLk", "Up",
295 "Down", "Left", "Right", ""
296};
297
298/*#pragma warning 737 9
299static byte
300 *ScanNames[] = // Scan code names with single chars
301 {
302 "?","?","1","2","3","4","5","6","7","8","9","0","-","+","?","?",
303 "Q","W","E","R","T","Y","U","I","O","P","[","]","|","?","A","S",
304 "D","F","G","H","J","K","L",";","\"","?","?","?","Z","X","C","V",
305 "B","N","M",",",".","/","?","?","?","?","?","?","?","?","?","?",
306 "?","?","?","?","?","?","?","?","\xf","?","-","\x15","5","\x11","+","?",
307 "\x13","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?",
308 "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?",
309 "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?"
310 }; // DEBUG - consolidate these
311static byte ExtScanCodes[] = // Scan codes with >1 char names
312 {
313 1,0xe,0xf,0x1d,0x2a,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,
314 0x3f,0x40,0x41,0x42,0x43,0x44,0x57,0x59,0x46,0x1c,0x36,
315 0x37,0x38,0x47,0x49,0x4f,0x51,0x52,0x53,0x45,0x48,
316 0x50,0x4b,0x4d,0x00
317 };
318static byte *ExtScanNames[] = // Names corresponding to ExtScanCodes
319 {
320 "Esc","BkSp","Tab","Ctrl","LShft","Space","CapsLk","F1","F2","F3","F4",
321 "F5","F6","F7","F8","F9","F10","F11","F12","ScrlLk","Enter","RShft",
322 "PrtSc","Alt","Home","PgUp","End","PgDn","Ins","Del","NumLk","Up",
323 "Down","Left","Right",""
324 };*/
325
326#else
327static const char* const ScanNames[SDLK_LAST] =
328 {
329 "?","?","?","?","?","?","?","?", // 0
330 "BkSp","Tab","?","?","?","Return","?","?", // 8
331 "?","?","?","Pause","?","?","?","?", // 16
332 "?","?","?","Esc","?","?","?","?", // 24
333 "Space","!","\"","#","$","?","&","'", // 32
334 "(",")","*","+",",","-",".","/", // 40
335 "0","1","2","3","4","5","6","7", // 48
336 "8","9",":",";","<","=",">","?", // 56
337 "@","A","B","C","D","E","F","G", // 64
338 "H","I","J","K","L","M","N","O", // 72
339 "P","Q","R","S","T","U","V","W", // 80
340 "X","Y","Z","[","\\","]","^","_", // 88
341 "`","a","b","c","d","e","f","h", // 96
342 "h","i","j","k","l","m","n","o", // 104
343 "p","q","r","s","t","u","v","w", // 112
344 "x","y","z","{","|","}","~","?", // 120
345 "?","?","?","?","?","?","?","?", // 128
346 "?","?","?","?","?","?","?","?", // 136
347 "?","?","?","?","?","?","?","?", // 144
348 "?","?","?","?","?","?","?","?", // 152
349 "?","?","?","?","?","?","?","?", // 160
350 "?","?","?","?","?","?","?","?", // 168
351 "?","?","?","?","?","?","?","?", // 176
352 "?","?","?","?","?","?","?","?", // 184
353 "?","?","?","?","?","?","?","?", // 192
354 "?","?","?","?","?","?","?","?", // 200
355 "?","?","?","?","?","?","?","?", // 208
356 "?","?","?","?","?","?","?","?", // 216
357 "?","?","?","?","?","?","?","?", // 224
358 "?","?","?","?","?","?","?","?", // 232
359 "?","?","?","?","?","?","?","?", // 240
360 "?","?","?","?","?","?","?","?", // 248
361 "?","?","?","?","?","?","?","?", // 256
362 "?","?","?","?","?","?","?","Enter", // 264
363 "?","Up","Down","Right","Left","Ins","Home","End", // 272
364 "PgUp","PgDn","F1","F2","F3","F4","F5","F6", // 280
365 "F7","F8","F9","F10","F11","F12","?","?", // 288
366 "?","?","?","?","NumLk","CapsLk","ScrlLk","RShft", // 296
367 "Shift","RCtrl","Ctrl","RAlt","Alt","?","?","?", // 304
368 "?","?","?","?","PrtSc","?","?","?", // 312
369 "?","?" // 320
370 };
371
372#endif
373
374////////////////////////////////////////////////////////////////////
375//
376// Wolfenstein Control Panel! Ta Da!
377//
378////////////////////////////////////////////////////////////////////
379void
380US_ControlPanel (ScanCode scancode)
381{
382 int which;
383
384#ifdef _arch_dreamcast
385 DC_StatusClearLCD();
386#endif
387
388 if (ingame)
389 {
390 if (CP_CheckQuick (scancode))
391 return;
392 lastgamemusicoffset = StartCPMusic (MENUSONG);
393 }
394 else
395 StartCPMusic (MENUSONG);
396 SetupControlPanel ();
397
398 //
399 // F-KEYS FROM WITHIN GAME
400 //
401 switch (scancode)
402 {
403 case sc_F1:
404#ifdef SPEAR
405 BossKey ();
406#else
407#ifdef GOODTIMES
408 BossKey ();
409#else
410 HelpScreens ();
411#endif
412#endif
413 goto finishup;
414
415 case sc_F2:
416 CP_SaveGame (0);
417 goto finishup;
418
419 case sc_F3:
420 CP_LoadGame (0);
421 goto finishup;
422
423 case sc_F4:
424 CP_Sound (0);
425 goto finishup;
426
427 case sc_F5:
428 CP_ChangeView (0);
429 goto finishup;
430
431 case sc_F6:
432 CP_Control (0);
433 goto finishup;
434
435 finishup:
436 CleanupControlPanel ();
437#ifdef SPEAR
438 UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
439#endif
440 return;
441 }
442
443#ifdef SPEAR
444 CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
445#endif
446
447 DrawMainMenu ();
448 MenuFadeIn ();
449 StartGame = 0;
450
451 //
452 // MAIN MENU LOOP
453 //
454 do
455 {
456 which = HandleMenu (&MainItems, &MainMenu[0], NULL);
457
458#ifdef SPEAR
459#ifndef SPEARDEMO
460 IN_ProcessEvents();
461
462 //
463 // EASTER EGG FOR SPEAR OF DESTINY!
464 //
465 if (Keyboard[sc_I] && Keyboard[sc_D])
466 {
467 VW_FadeOut ();
468 StartCPMusic (XJAZNAZI_MUS);
469 UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
470 UnCacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
471 ClearMemory ();
472
473
474 CA_CacheGrChunk (IDGUYS1PIC);
475 VWB_DrawPic (0, 0, IDGUYS1PIC);
476 UNCACHEGRCHUNK (IDGUYS1PIC);
477
478 CA_CacheGrChunk (IDGUYS2PIC);
479 VWB_DrawPic (0, 80, IDGUYS2PIC);
480 UNCACHEGRCHUNK (IDGUYS2PIC);
481
482 VW_UpdateScreen ();
483
484 SDL_Color pal[256];
485 CA_CacheGrChunk (IDGUYSPALETTE);
486 VL_ConvertPalette(grsegs[IDGUYSPALETTE], pal, 256);
487 VL_FadeIn (0, 255, pal, 30);
488 UNCACHEGRCHUNK (IDGUYSPALETTE);
489
490 while (Keyboard[sc_I] || Keyboard[sc_D])
491 IN_WaitAndProcessEvents();
492 IN_ClearKeysDown ();
493 IN_Ack ();
494
495 VW_FadeOut ();
496
497 CacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
498 CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
499 DrawMainMenu ();
500 StartCPMusic (MENUSONG);
501 MenuFadeIn ();
502 }
503#endif
504#endif
505
506 switch (which)
507 {
508 case viewscores:
509 if (MainMenu[viewscores].routine == NULL)
510 {
511 if (CP_EndGame (0))
512 StartGame = 1;
513 }
514 else
515 {
516 DrawMainMenu();
517 MenuFadeIn ();
518 }
519 break;
520
521 case backtodemo:
522 StartGame = 1;
523 if (!ingame)
524 StartCPMusic (INTROSONG);
525 VL_FadeOut (0, 255, 0, 0, 0, 10);
526 break;
527
528 case -1:
529 case quit:
530 CP_Quit (0);
531 break;
532
533 default:
534 if (!StartGame)
535 {
536 DrawMainMenu ();
537 MenuFadeIn ();
538 }
539 }
540
541 //
542 // "EXIT OPTIONS" OR "NEW GAME" EXITS
543 //
544 }
545 while (!StartGame);
546
547 //
548 // DEALLOCATE EVERYTHING
549 //
550 CleanupControlPanel ();
551
552 //
553 // CHANGE MAINMENU ITEM
554 //
555 if (startgame || loadedgame)
556 EnableEndGameMenuItem();
557
558 // RETURN/START GAME EXECUTION
559
560#ifdef SPEAR
561 UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
562#endif
563}
564
565void EnableEndGameMenuItem()
566{
567 MainMenu[viewscores].routine = NULL;
568#ifndef JAPAN
569 strcpy (MainMenu[viewscores].string, STR_EG);
570#endif
571}
572
573////////////////////////
574//
575// DRAW MAIN MENU SCREEN
576//
577void
578DrawMainMenu (void)
579{
580#ifdef JAPAN
581 CA_CacheScreen (S_OPTIONSPIC);
582#else
583 ClearMScreen ();
584
585 VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
586 DrawStripes (10);
587 VWB_DrawPic (84, 0, C_OPTIONSPIC);
588
589#ifdef SPANISH
590 DrawWindow (MENU_X - 8, MENU_Y - 3, MENU_W + 8, MENU_H, BKGDCOLOR);
591#else
592 DrawWindow (MENU_X - 8, MENU_Y - 3, MENU_W, MENU_H, BKGDCOLOR);
593#endif
594#endif
595
596 //
597 // CHANGE "GAME" AND "DEMO"
598 //
599 if (ingame)
600 {
601#ifndef JAPAN
602
603#ifdef SPANISH
604 strcpy (&MainMenu[backtodemo].string, STR_GAME);
605#else
606 strcpy (&MainMenu[backtodemo].string[8], STR_GAME);
607#endif
608
609#else
610 CA_CacheGrChunk (C_MRETGAMEPIC);
611 VWB_DrawPic (12 * 8, 20 * 8, C_MRETGAMEPIC);
612 UNCACHEGRCHUNK (C_MRETGAMEPIC);
613 CA_CacheGrChunk (C_MENDGAMEPIC);
614 VWB_DrawPic (12 * 8, 18 * 8, C_MENDGAMEPIC);
615 UNCACHEGRCHUNK (C_MENDGAMEPIC);
616#endif
617 MainMenu[backtodemo].active = 2;
618 }
619 else
620 {
621#ifndef JAPAN
622#ifdef SPANISH
623 strcpy (&MainMenu[backtodemo].string, STR_BD);
624#else
625 strcpy (&MainMenu[backtodemo].string[8], STR_DEMO);
626#endif
627#else
628 CA_CacheGrChunk (C_MRETDEMOPIC);
629 VWB_DrawPic (12 * 8, 20 * 8, C_MRETDEMOPIC);
630 UNCACHEGRCHUNK (C_MRETDEMOPIC);
631 CA_CacheGrChunk (C_MSCORESPIC);
632 VWB_DrawPic (12 * 8, 18 * 8, C_MSCORESPIC);
633 UNCACHEGRCHUNK (C_MSCORESPIC);
634#endif
635 MainMenu[backtodemo].active = 1;
636 }
637
638 DrawMenu (&MainItems, &MainMenu[0]);
639 VW_UpdateScreen ();
640}
641
642#ifndef GOODTIMES
643#ifndef SPEAR
644////////////////////////////////////////////////////////////////////
645//
646// READ THIS!
647//
648////////////////////////////////////////////////////////////////////
649int
650CP_ReadThis (int)
651{
652 StartCPMusic (CORNER_MUS);
653 HelpScreens ();
654 StartCPMusic (MENUSONG);
655 return true;
656}
657#endif
658#endif
659
660
661#ifdef GOODTIMES
662////////////////////////////////////////////////////////////////////
663//
664// BOSS KEY
665//
666////////////////////////////////////////////////////////////////////
667void
668BossKey (void)
669{
670#ifdef NOTYET
671 byte palette1[256][3];
672 SD_MusicOff ();
673/* _AX = 3;
674 geninterrupt(0x10); */
675 _asm
676 {
677 mov eax, 3 int 0x10}
678 puts ("C>");
679 SetTextCursor (2, 0);
680// while (!Keyboard[sc_Escape])
681 IN_Ack ();
682 IN_ClearKeysDown ();
683
684 SD_MusicOn ();
685 VL_SetVGAPlaneMode ();
686 for (int i = 0; i < 768; i++)
687 palette1[0][i] = 0;
688
689 VL_SetPalette (&palette1[0][0]);
690 LoadLatchMem ();
691#endif
692}
693#else
694#ifdef SPEAR
695void
696BossKey (void)
697{
698#ifdef NOTYET
699 byte palette1[256][3];
700 SD_MusicOff ();
701/* _AX = 3;
702 geninterrupt(0x10); */
703 _asm
704 {
705 mov eax, 3 int 0x10}
706 puts ("C>");
707 SetTextCursor (2, 0);
708// while (!Keyboard[sc_Escape])
709 IN_Ack ();
710 IN_ClearKeysDown ();
711
712 SD_MusicOn ();
713 VL_SetVGAPlaneMode ();
714 for (int i = 0; i < 768; i++)
715 palette1[0][i] = 0;
716
717 VL_SetPalette (&palette1[0][0]);
718 LoadLatchMem ();
719#endif
720}
721#endif
722#endif
723
724
725////////////////////////////////////////////////////////////////////
726//
727// CHECK QUICK-KEYS & QUIT (WHILE IN A GAME)
728//
729////////////////////////////////////////////////////////////////////
730int
731CP_CheckQuick (ScanCode scancode)
732{
733 switch (scancode)
734 {
735 //
736 // END GAME
737 //
738 case sc_F7:
739 CA_CacheGrChunk (STARTFONT + 1);
740
741 WindowH = 160;
742#ifdef JAPAN
743 if (GetYorN (7, 8, C_JAPQUITPIC))
744#else
745 if (Confirm (ENDGAMESTR))
746#endif
747 {
748 playstate = ex_died;
749 killerobj = NULL;
750 pickquick = gamestate.lives = 0;
751 }
752
753 WindowH = 200;
754 fontnumber = 0;
755 MainMenu[savegame].active = 0;
756 return 1;
757
758 //
759 // QUICKSAVE
760 //
761 case sc_F8:
762 if (SaveGamesAvail[LSItems.curpos] && pickquick)
763 {
764 CA_CacheGrChunk (STARTFONT + 1);
765 fontnumber = 1;
766 Message (STR_SAVING "...");
767 CP_SaveGame (1);
768 fontnumber = 0;
769 }
770 else
771 {
772#ifndef SPEAR
773 CA_CacheGrChunk (STARTFONT + 1);
774 CA_CacheGrChunk (C_CURSOR1PIC);
775 CA_CacheGrChunk (C_CURSOR2PIC);
776 CA_CacheGrChunk (C_DISKLOADING1PIC);
777 CA_CacheGrChunk (C_DISKLOADING2PIC);
778 CA_CacheGrChunk (C_SAVEGAMEPIC);
779 CA_CacheGrChunk (C_MOUSELBACKPIC);
780#else
781 CacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
782 CA_CacheGrChunk (C_CURSOR1PIC);
783#endif
784
785 VW_FadeOut ();
786 if(screenHeight % 200 != 0)
787 VL_ClearScreen(0);
788
789 lastgamemusicoffset = StartCPMusic (MENUSONG);
790 pickquick = CP_SaveGame (0);
791
792 SETFONTCOLOR (0, 15);
793 IN_ClearKeysDown ();
794 VW_FadeOut();
795 if(viewsize != 21)
796 DrawPlayScreen ();
797
798 if (!startgame && !loadedgame)
799 ContinueMusic (lastgamemusicoffset);
800
801 if (loadedgame)
802 playstate = ex_abort;
803 lasttimecount = GetTimeCount ();
804
805 if (MousePresent && IN_IsInputGrabbed())
806 IN_CenterMouse(); // Clear accumulated mouse movement
807
808#ifndef SPEAR
809 UNCACHEGRCHUNK (C_CURSOR1PIC);
810 UNCACHEGRCHUNK (C_CURSOR2PIC);
811 UNCACHEGRCHUNK (C_DISKLOADING1PIC);
812 UNCACHEGRCHUNK (C_DISKLOADING2PIC);
813 UNCACHEGRCHUNK (C_SAVEGAMEPIC);
814 UNCACHEGRCHUNK (C_MOUSELBACKPIC);
815#else
816 UnCacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
817#endif
818 }
819 return 1;
820
821 //
822 // QUICKLOAD
823 //
824 case sc_F9:
825 if (SaveGamesAvail[LSItems.curpos] && pickquick)
826 {
827 char string[100] = STR_LGC;
828
829
830 CA_CacheGrChunk (STARTFONT + 1);
831 fontnumber = 1;
832
833 strcat (string, SaveGameNames[LSItems.curpos]);
834 strcat (string, "\"?");
835
836 if (Confirm (string))
837 CP_LoadGame (1);
838
839 fontnumber = 0;
840 }
841 else
842 {
843#ifndef SPEAR
844 CA_CacheGrChunk (STARTFONT + 1);
845 CA_CacheGrChunk (C_CURSOR1PIC);
846 CA_CacheGrChunk (C_CURSOR2PIC);
847 CA_CacheGrChunk (C_DISKLOADING1PIC);
848 CA_CacheGrChunk (C_DISKLOADING2PIC);
849 CA_CacheGrChunk (C_LOADGAMEPIC);
850 CA_CacheGrChunk (C_MOUSELBACKPIC);
851#else
852 CA_CacheGrChunk (C_CURSOR1PIC);
853 CacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
854#endif
855
856 VW_FadeOut ();
857 if(screenHeight % 200 != 0)
858 VL_ClearScreen(0);
859
860 lastgamemusicoffset = StartCPMusic (MENUSONG);
861 pickquick = CP_LoadGame (0); // loads lastgamemusicoffs
862
863 SETFONTCOLOR (0, 15);
864 IN_ClearKeysDown ();
865 VW_FadeOut();
866 if(viewsize != 21)
867 DrawPlayScreen ();
868
869 if (!startgame && !loadedgame)
870 ContinueMusic (lastgamemusicoffset);
871
872 if (loadedgame)
873 playstate = ex_abort;
874
875 lasttimecount = GetTimeCount ();
876
877 if (MousePresent && IN_IsInputGrabbed())
878 IN_CenterMouse(); // Clear accumulated mouse movement
879
880#ifndef SPEAR
881 UNCACHEGRCHUNK (C_CURSOR1PIC);
882 UNCACHEGRCHUNK (C_CURSOR2PIC);
883 UNCACHEGRCHUNK (C_DISKLOADING1PIC);
884 UNCACHEGRCHUNK (C_DISKLOADING2PIC);
885 UNCACHEGRCHUNK (C_LOADGAMEPIC);
886 UNCACHEGRCHUNK (C_MOUSELBACKPIC);
887#else
888 UnCacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
889#endif
890 }
891 return 1;
892
893 //
894 // QUIT
895 //
896 case sc_F10:
897 CA_CacheGrChunk (STARTFONT + 1);
898
899 WindowX = WindowY = 0;
900 WindowW = 320;
901 WindowH = 160;
902#ifdef JAPAN
903 if (GetYorN (7, 8, C_QUITMSGPIC))
904#else
905#ifdef SPANISH
906 if (Confirm (ENDGAMESTR))
907#else
908 if (Confirm (endStrings[US_RndT () & 0x7 + (US_RndT () & 1)]))
909#endif
910#endif
911 {
912 VW_UpdateScreen ();
913 SD_MusicOff ();
914 SD_StopSound ();
915 MenuFadeOut ();
916
917 Quit (NULL);
918 }
919
920 DrawPlayBorder ();
921 WindowH = 200;
922 fontnumber = 0;
923 return 1;
924 }
925
926 return 0;
927}
928
929
930////////////////////////////////////////////////////////////////////
931//
932// END THE CURRENT GAME
933//
934////////////////////////////////////////////////////////////////////
935int
936CP_EndGame (int a)
937{
938 int res;
939#ifdef JAPAN
940 res = GetYorN (7, 8, C_JAPQUITPIC);
941#else
942 res = Confirm (ENDGAMESTR);
943#endif
944 DrawMainMenu();
945 if(!res) return 0;
946
947 pickquick = gamestate.lives = 0;
948 playstate = ex_died;
949 killerobj = NULL;
950
951 MainMenu[savegame].active = 0;
952 MainMenu[viewscores].routine = CP_ViewScores;
953#ifndef JAPAN
954 strcpy (MainMenu[viewscores].string, STR_VS);
955#endif
956
957 return 1;
958}
959
960
961////////////////////////////////////////////////////////////////////
962//
963// VIEW THE HIGH SCORES
964//
965////////////////////////////////////////////////////////////////////
966int
967CP_ViewScores (int a)
968{
969 fontnumber = 0;
970
971#ifdef SPEAR
972 UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
973 StartCPMusic (XAWARD_MUS);
974#else
975 StartCPMusic (ROSTER_MUS);
976#endif
977
978 DrawHighScores ();
979 VW_UpdateScreen ();
980 MenuFadeIn ();
981 fontnumber = 1;
982
983 IN_Ack ();
984
985 StartCPMusic (MENUSONG);
986 MenuFadeOut ();
987
988#ifdef SPEAR
989 CacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
990 CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
991#endif
992 return 0;
993}
994
995
996////////////////////////////////////////////////////////////////////
997//
998// START A NEW GAME
999//
1000////////////////////////////////////////////////////////////////////
1001int
1002CP_NewGame (int a)
1003{
1004 int which, episode;
1005
1006#ifdef SPEAR
1007 UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1008#endif
1009
1010
1011#ifndef SPEAR
1012 firstpart:
1013
1014 DrawNewEpisode ();
1015 do
1016 {
1017 which = HandleMenu (&NewEitems, &NewEmenu[0], NULL);
1018 switch (which)
1019 {
1020 case -1:
1021 MenuFadeOut ();
1022 return 0;
1023
1024 default:
1025 if (!EpisodeSelect[which / 2])
1026 {
1027 SD_PlaySound (NOWAYSND);
1028 Message ("Please select \"Read This!\"\n"
1029 "from the Options menu to\n"
1030 "find out how to order this\n" "episode from Apogee.");
1031 IN_ClearKeysDown ();
1032 IN_Ack ();
1033 DrawNewEpisode ();
1034 which = 0;
1035 }
1036 else
1037 {
1038 episode = which / 2;
1039 which = 1;
1040 }
1041 break;
1042 }
1043
1044 }
1045 while (!which);
1046
1047 ShootSnd ();
1048
1049 //
1050 // ALREADY IN A GAME?
1051 //
1052 if (ingame)
1053#ifdef JAPAN
1054 if (!GetYorN (7, 8, C_JAPNEWGAMEPIC))
1055#else
1056 if (!Confirm (CURGAME))
1057#endif
1058 {
1059 MenuFadeOut ();
1060 return 0;
1061 }
1062
1063 MenuFadeOut ();
1064
1065#else
1066 episode = 0;
1067
1068 //
1069 // ALREADY IN A GAME?
1070 //
1071 CacheLump (NEWGAME_LUMP_START, NEWGAME_LUMP_END);
1072 DrawNewGame ();
1073 if (ingame)
1074 if (!Confirm (CURGAME))
1075 {
1076 MenuFadeOut ();
1077 UnCacheLump (NEWGAME_LUMP_START, NEWGAME_LUMP_END);
1078 CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1079 return 0;
1080 }
1081
1082#endif
1083
1084 DrawNewGame ();
1085 which = HandleMenu (&NewItems, &NewMenu[0], DrawNewGameDiff);
1086 if (which < 0)
1087 {
1088 MenuFadeOut ();
1089#ifndef SPEAR
1090 goto firstpart;
1091#else
1092 UnCacheLump (NEWGAME_LUMP_START, NEWGAME_LUMP_END);
1093 CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1094 return 0;
1095#endif
1096 }
1097
1098 ShootSnd ();
1099 NewGame (which, episode);
1100 StartGame = 1;
1101 MenuFadeOut ();
1102
1103 //
1104 // CHANGE "READ THIS!" TO NORMAL COLOR
1105 //
1106#ifndef SPEAR
1107#ifndef GOODTIMES
1108 MainMenu[readthis].active = 1;
1109#endif
1110#endif
1111
1112 pickquick = 0;
1113
1114#ifdef SPEAR
1115 UnCacheLump (NEWGAME_LUMP_START, NEWGAME_LUMP_END);
1116 CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1117#endif
1118
1119 return 0;
1120}
1121
1122
1123#ifndef SPEAR
1124/////////////////////
1125//
1126// DRAW NEW EPISODE MENU
1127//
1128void
1129DrawNewEpisode (void)
1130{
1131 int i;
1132
1133#ifdef JAPAN
1134 CA_CacheScreen (S_EPISODEPIC);
1135#else
1136 ClearMScreen ();
1137 VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
1138
1139 DrawWindow (NE_X - 4, NE_Y - 4, NE_W + 8, NE_H + 8, BKGDCOLOR);
1140 SETFONTCOLOR (READHCOLOR, BKGDCOLOR);
1141 PrintY = 2;
1142 WindowX = 0;
1143#ifdef SPANISH
1144 US_CPrint ("Cual episodio jugar?");
1145#else
1146 US_CPrint ("Which episode to play?");
1147#endif
1148#endif
1149
1150 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
1151 DrawMenu (&NewEitems, &NewEmenu[0]);
1152
1153 for (i = 0; i < 6; i++)
1154 VWB_DrawPic (NE_X + 32, NE_Y + i * 26, C_EPISODE1PIC + i);
1155
1156 VW_UpdateScreen ();
1157 MenuFadeIn ();
1158 WaitKeyUp ();
1159}
1160#endif
1161
1162/////////////////////
1163//
1164// DRAW NEW GAME MENU
1165//
1166void
1167DrawNewGame (void)
1168{
1169#ifdef JAPAN
1170 CA_CacheScreen (S_SKILLPIC);
1171#else
1172 ClearMScreen ();
1173 VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
1174
1175 SETFONTCOLOR (READHCOLOR, BKGDCOLOR);
1176 PrintX = NM_X + 20;
1177 PrintY = NM_Y - 32;
1178
1179#ifndef SPEAR
1180#ifdef SPANISH
1181 US_Print ("Eres macho?");
1182#else
1183 US_Print ("How tough are you?");
1184#endif
1185#else
1186 VWB_DrawPic (PrintX, PrintY, C_HOWTOUGHPIC);
1187#endif
1188
1189 DrawWindow (NM_X - 5, NM_Y - 10, NM_W, NM_H, BKGDCOLOR);
1190#endif
1191
1192 DrawMenu (&NewItems, &NewMenu[0]);
1193 DrawNewGameDiff (NewItems.curpos);
1194 VW_UpdateScreen ();
1195 MenuFadeIn ();
1196 WaitKeyUp ();
1197}
1198
1199
1200////////////////////////
1201//
1202// DRAW NEW GAME GRAPHIC
1203//
1204void
1205DrawNewGameDiff (int w)
1206{
1207 VWB_DrawPic (NM_X + 185, NM_Y + 7, w + C_BABYMODEPIC);
1208}
1209
1210
1211////////////////////////////////////////////////////////////////////
1212//
1213// HANDLE SOUND MENU
1214//
1215////////////////////////////////////////////////////////////////////
1216int
1217CP_Sound (int a)
1218{
1219 int which;
1220
1221
1222#ifdef SPEAR
1223 UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1224 CacheLump (SOUND_LUMP_START, SOUND_LUMP_END);
1225#endif
1226
1227 DrawSoundMenu ();
1228 MenuFadeIn ();
1229 WaitKeyUp ();
1230
1231 do
1232 {
1233 which = HandleMenu (&SndItems, &SndMenu[0], NULL);
1234 //
1235 // HANDLE MENU CHOICES
1236 //
1237 switch (which)
1238 {
1239 //
1240 // SOUND EFFECTS
1241 //
1242 case 0:
1243 if (SoundMode != sdm_Off)
1244 {
1245 SD_WaitSoundDone ();
1246 SD_SetSoundMode (sdm_Off);
1247 DrawSoundMenu ();
1248 }
1249 break;
1250 case 1:
1251 if (SoundMode != sdm_PC)
1252 {
1253 SD_WaitSoundDone ();
1254 SD_SetSoundMode (sdm_PC);
1255 CA_LoadAllSounds ();
1256 DrawSoundMenu ();
1257 ShootSnd ();
1258 }
1259 break;
1260 case 2:
1261 if (SoundMode != sdm_AdLib)
1262 {
1263 SD_WaitSoundDone ();
1264 SD_SetSoundMode (sdm_AdLib);
1265 CA_LoadAllSounds ();
1266 DrawSoundMenu ();
1267 ShootSnd ();
1268 }
1269 break;
1270
1271 //
1272 // DIGITIZED SOUND
1273 //
1274 case 5:
1275 if (DigiMode != sds_Off)
1276 {
1277 SD_SetDigiDevice (sds_Off);
1278 DrawSoundMenu ();
1279 }
1280 break;
1281 case 6:
1282/* if (DigiMode != sds_SoundSource)
1283 {
1284 SD_SetDigiDevice (sds_SoundSource);
1285 DrawSoundMenu ();
1286 ShootSnd ();
1287 }*/
1288 break;
1289 case 7:
1290 if (DigiMode != sds_SoundBlaster)
1291 {
1292 SD_SetDigiDevice (sds_SoundBlaster);
1293 DrawSoundMenu ();
1294 ShootSnd ();
1295 }
1296 break;
1297
1298 //
1299 // MUSIC
1300 //
1301 case 10:
1302 if (MusicMode != smm_Off)
1303 {
1304 SD_SetMusicMode (smm_Off);
1305 DrawSoundMenu ();
1306 ShootSnd ();
1307 }
1308 break;
1309 case 11:
1310 if (MusicMode != smm_AdLib)
1311 {
1312 SD_SetMusicMode (smm_AdLib);
1313 DrawSoundMenu ();
1314 ShootSnd ();
1315 StartCPMusic (MENUSONG);
1316 }
1317 break;
1318 }
1319 }
1320 while (which >= 0);
1321
1322 MenuFadeOut ();
1323
1324#ifdef SPEAR
1325 UnCacheLump (SOUND_LUMP_START, SOUND_LUMP_END);
1326 CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1327#endif
1328 return 0;
1329}
1330
1331
1332//////////////////////
1333//
1334// DRAW THE SOUND MENU
1335//
1336void
1337DrawSoundMenu (void)
1338{
1339 int i, on;
1340
1341
1342#ifdef JAPAN
1343 CA_CacheScreen (S_SOUNDPIC);
1344#else
1345 //
1346 // DRAW SOUND MENU
1347 //
1348 ClearMScreen ();
1349 VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
1350
1351 DrawWindow (SM_X - 8, SM_Y1 - 3, SM_W, SM_H1, BKGDCOLOR);
1352 DrawWindow (SM_X - 8, SM_Y2 - 3, SM_W, SM_H2, BKGDCOLOR);
1353 DrawWindow (SM_X - 8, SM_Y3 - 3, SM_W, SM_H3, BKGDCOLOR);
1354#endif
1355
1356 //
1357 // IF NO ADLIB, NON-CHOOSENESS!
1358 //
1359 if (!AdLibPresent && !SoundBlasterPresent)
1360 {
1361 SndMenu[2].active = SndMenu[10].active = SndMenu[11].active = 0;
1362 }
1363
1364 if (!SoundBlasterPresent)
1365 SndMenu[7].active = 0;
1366
1367 if (!SoundBlasterPresent)
1368 SndMenu[5].active = 0;
1369
1370 DrawMenu (&SndItems, &SndMenu[0]);
1371#ifndef JAPAN
1372 VWB_DrawPic (100, SM_Y1 - 20, C_FXTITLEPIC);
1373 VWB_DrawPic (100, SM_Y2 - 20, C_DIGITITLEPIC);
1374 VWB_DrawPic (100, SM_Y3 - 20, C_MUSICTITLEPIC);
1375#endif
1376
1377 for (i = 0; i < SndItems.amount; i++)
1378#ifdef JAPAN
1379 if (i != 3 && i != 4 && i != 8 && i != 9)
1380#else
1381 if (SndMenu[i].string[0])
1382#endif
1383 {
1384 //
1385 // DRAW SELECTED/NOT SELECTED GRAPHIC BUTTONS
1386 //
1387 on = 0;
1388 switch (i)
1389 {
1390 //
1391 // SOUND EFFECTS
1392 //
1393 case 0:
1394 if (SoundMode == sdm_Off)
1395 on = 1;
1396 break;
1397 case 1:
1398 if (SoundMode == sdm_PC)
1399 on = 1;
1400 break;
1401 case 2:
1402 if (SoundMode == sdm_AdLib)
1403 on = 1;
1404 break;
1405
1406 //
1407 // DIGITIZED SOUND
1408 //
1409 case 5:
1410 if (DigiMode == sds_Off)
1411 on = 1;
1412 break;
1413 case 6:
1414// if (DigiMode == sds_SoundSource)
1415// on = 1;
1416 break;
1417 case 7:
1418 if (DigiMode == sds_SoundBlaster)
1419 on = 1;
1420 break;
1421
1422 //
1423 // MUSIC
1424 //
1425 case 10:
1426 if (MusicMode == smm_Off)
1427 on = 1;
1428 break;
1429 case 11:
1430 if (MusicMode == smm_AdLib)
1431 on = 1;
1432 break;
1433 }
1434
1435 if (on)
1436 VWB_DrawPic (SM_X + 24, SM_Y1 + i * 13 + 2, C_SELECTEDPIC);
1437 else
1438 VWB_DrawPic (SM_X + 24, SM_Y1 + i * 13 + 2, C_NOTSELECTEDPIC);
1439 }
1440
1441 DrawMenuGun (&SndItems);
1442 VW_UpdateScreen ();
1443}
1444
1445
1446//
1447// DRAW LOAD/SAVE IN PROGRESS
1448//
1449void
1450DrawLSAction (int which)
1451{
1452#define LSA_X 96
1453#define LSA_Y 80
1454#define LSA_W 130
1455#define LSA_H 42
1456
1457 DrawWindow (LSA_X, LSA_Y, LSA_W, LSA_H, TEXTCOLOR);
1458 DrawOutline (LSA_X, LSA_Y, LSA_W, LSA_H, 0, HIGHLIGHT);
1459 VWB_DrawPic (LSA_X + 8, LSA_Y + 5, C_DISKLOADING1PIC);
1460
1461 fontnumber = 1;
1462 SETFONTCOLOR (0, TEXTCOLOR);
1463 PrintX = LSA_X + 46;
1464 PrintY = LSA_Y + 13;
1465
1466 if (!which)
1467 US_Print (STR_LOADING "...");
1468 else
1469 US_Print (STR_SAVING "...");
1470
1471 VW_UpdateScreen ();
1472}
1473
1474
1475////////////////////////////////////////////////////////////////////
1476//
1477// LOAD SAVED GAMES
1478//
1479////////////////////////////////////////////////////////////////////
1480int
1481CP_LoadGame (int quick)
1482{
1483 FILE *file;
1484 int which, exit = 0;
1485 char name[13];
1486 char loadpath[300];
1487
1488 strcpy (name, SaveName);
1489
1490 //
1491 // QUICKLOAD?
1492 //
1493 if (quick)
1494 {
1495 which = LSItems.curpos;
1496
1497 if (SaveGamesAvail[which])
1498 {
1499 name[7] = which + '0';
1500
1501#ifdef _arch_dreamcast
1502 DC_LoadFromVMU(name);
1503#endif
1504
1505 if(configdir[0])
1506 snprintf(loadpath, sizeof(loadpath), "%s/%s", configdir, name);
1507 else
1508 strcpy(loadpath, name);
1509
1510 file = fopen (loadpath, "rb");
1511 fseek (file, 32, SEEK_SET);
1512 loadedgame = true;
1513 LoadTheGame (file, 0, 0);
1514 loadedgame = false;
1515 fclose (file);
1516
1517 DrawFace ();
1518 DrawHealth ();
1519 DrawLives ();
1520 DrawLevel ();
1521 DrawAmmo ();
1522 DrawKeys ();
1523 DrawWeapon ();
1524 DrawScore ();
1525 ContinueMusic (lastgamemusicoffset);
1526 return 1;
1527 }
1528 }
1529
1530
1531#ifdef SPEAR
1532 UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1533 CacheLump (LOADSAVE_LUMP_START, LOADSAVE_LUMP_END);
1534#endif
1535
1536 DrawLoadSaveScreen (0);
1537
1538 do
1539 {
1540 which = HandleMenu (&LSItems, &LSMenu[0], TrackWhichGame);
1541 if (which >= 0 && SaveGamesAvail[which])
1542 {
1543 ShootSnd ();
1544 name[7] = which + '0';
1545
1546#ifdef _arch_dreamcast
1547 DC_LoadFromVMU(name);
1548#endif
1549
1550 if(configdir[0])
1551 snprintf(loadpath, sizeof(loadpath), "%s/%s", configdir, name);
1552 else
1553 strcpy(loadpath, name);
1554
1555 file = fopen (loadpath, "rb");
1556 fseek (file, 32, SEEK_SET);
1557
1558 DrawLSAction (0);
1559 loadedgame = true;
1560
1561 LoadTheGame (file, LSA_X + 8, LSA_Y + 5);
1562 fclose (file);
1563
1564 StartGame = 1;
1565 ShootSnd ();
1566 //
1567 // CHANGE "READ THIS!" TO NORMAL COLOR
1568 //
1569
1570#ifndef SPEAR
1571#ifndef GOODTIMES
1572 MainMenu[readthis].active = 1;
1573#endif
1574#endif
1575
1576 exit = 1;
1577 break;
1578 }
1579
1580 }
1581 while (which >= 0);
1582
1583 MenuFadeOut ();
1584
1585#ifdef SPEAR
1586 UnCacheLump (LOADSAVE_LUMP_START, LOADSAVE_LUMP_END);
1587 CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1588#endif
1589
1590 return exit;
1591}
1592
1593
1594///////////////////////////////////
1595//
1596// HIGHLIGHT CURRENT SELECTED ENTRY
1597//
1598void
1599TrackWhichGame (int w)
1600{
1601 static int lastgameon = 0;
1602
1603 PrintLSEntry (lastgameon, TEXTCOLOR);
1604 PrintLSEntry (w, HIGHLIGHT);
1605
1606 lastgameon = w;
1607}
1608
1609
1610////////////////////////////
1611//
1612// DRAW THE LOAD/SAVE SCREEN
1613//
1614void
1615DrawLoadSaveScreen (int loadsave)
1616{
1617#define DISKX 100
1618#define DISKY 0
1619
1620 int i;
1621
1622
1623 ClearMScreen ();
1624 fontnumber = 1;
1625 VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
1626 DrawWindow (LSM_X - 10, LSM_Y - 5, LSM_W, LSM_H, BKGDCOLOR);
1627 DrawStripes (10);
1628
1629 if (!loadsave)
1630 VWB_DrawPic (60, 0, C_LOADGAMEPIC);
1631 else
1632 VWB_DrawPic (60, 0, C_SAVEGAMEPIC);
1633
1634 for (i = 0; i < 10; i++)
1635 PrintLSEntry (i, TEXTCOLOR);
1636
1637 DrawMenu (&LSItems, &LSMenu[0]);
1638 VW_UpdateScreen ();
1639 MenuFadeIn ();
1640 WaitKeyUp ();
1641}
1642
1643
1644///////////////////////////////////////////
1645//
1646// PRINT LOAD/SAVE GAME ENTRY W/BOX OUTLINE
1647//
1648void
1649PrintLSEntry (int w, int color)
1650{
1651 SETFONTCOLOR (color, BKGDCOLOR);
1652 DrawOutline (LSM_X + LSItems.indent, LSM_Y + w * 13, LSM_W - LSItems.indent - 15, 11, color,
1653 color);
1654 PrintX = LSM_X + LSItems.indent + 2;
1655 PrintY = LSM_Y + w * 13 + 1;
1656 fontnumber = 0;
1657
1658 if (SaveGamesAvail[w])
1659 US_Print (SaveGameNames[w]);
1660 else
1661 US_Print (" - " STR_EMPTY " -");
1662
1663 fontnumber = 1;
1664}
1665
1666
1667////////////////////////////////////////////////////////////////////
1668//
1669// SAVE CURRENT GAME
1670//
1671////////////////////////////////////////////////////////////////////
1672int
1673CP_SaveGame (int quick)
1674{
1675 int which, exit = 0;
1676 FILE *file;
1677 char name[13];
1678 char savepath[300];
1679 char input[32];
1680
1681 strcpy (name, SaveName);
1682
1683 //
1684 // QUICKSAVE?
1685 //
1686 if (quick)
1687 {
1688 which = LSItems.curpos;
1689
1690 if (SaveGamesAvail[which])
1691 {
1692 name[7] = which + '0';
1693
1694 if(configdir[0])
1695 snprintf(savepath, sizeof(savepath), "%s/%s", configdir, name);
1696 else
1697 strcpy(savepath, name);
1698
1699 unlink (savepath);
1700 file = fopen (savepath, "wb");
1701
1702 strcpy (input, &SaveGameNames[which][0]);
1703
1704 fwrite (input, 1, 32, file);
1705 fseek (file, 32, SEEK_SET);
1706 SaveTheGame (file, 0, 0);
1707 fclose (file);
1708
1709#ifdef _arch_dreamcast
1710 DC_SaveToVMU(name, input);
1711#endif
1712
1713 return 1;
1714 }
1715 }
1716
1717
1718#ifdef SPEAR
1719 UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1720 CacheLump (LOADSAVE_LUMP_START, LOADSAVE_LUMP_END);
1721#endif
1722
1723 DrawLoadSaveScreen (1);
1724
1725 do
1726 {
1727 which = HandleMenu (&LSItems, &LSMenu[0], TrackWhichGame);
1728 if (which >= 0)
1729 {
1730 //
1731 // OVERWRITE EXISTING SAVEGAME?
1732 //
1733 if (SaveGamesAvail[which])
1734 {
1735#ifdef JAPAN
1736 if (!GetYorN (7, 8, C_JAPSAVEOVERPIC))
1737#else
1738 if (!Confirm (GAMESVD))
1739#endif
1740 {
1741 DrawLoadSaveScreen (1);
1742 continue;
1743 }
1744 else
1745 {
1746 DrawLoadSaveScreen (1);
1747 PrintLSEntry (which, HIGHLIGHT);
1748 VW_UpdateScreen ();
1749 }
1750 }
1751
1752 ShootSnd ();
1753
1754 strcpy (input, &SaveGameNames[which][0]);
1755 name[7] = which + '0';
1756
1757 fontnumber = 0;
1758 if (!SaveGamesAvail[which])
1759 VWB_Bar (LSM_X + LSItems.indent + 1, LSM_Y + which * 13 + 1,
1760 LSM_W - LSItems.indent - 16, 10, BKGDCOLOR);
1761 VW_UpdateScreen ();
1762
1763 if (US_LineInput
1764 (LSM_X + LSItems.indent + 2, LSM_Y + which * 13 + 1, input, input, true, 31,
1765 LSM_W - LSItems.indent - 30))
1766 {
1767 SaveGamesAvail[which] = 1;
1768 strcpy (&SaveGameNames[which][0], input);
1769
1770 if(configdir[0])
1771 snprintf(savepath, sizeof(savepath), "%s/%s", configdir, name);
1772 else
1773 strcpy(savepath, name);
1774
1775 unlink (savepath);
1776 file = fopen (savepath, "wb");
1777 fwrite (input, 32, 1, file);
1778 fseek (file, 32, SEEK_SET);
1779
1780 DrawLSAction (1);
1781 SaveTheGame (file, LSA_X + 8, LSA_Y + 5);
1782
1783 fclose (file);
1784
1785#ifdef _arch_dreamcast
1786 DC_SaveToVMU(name, input);
1787#endif
1788
1789 ShootSnd ();
1790 exit = 1;
1791 }
1792 else
1793 {
1794 VWB_Bar (LSM_X + LSItems.indent + 1, LSM_Y + which * 13 + 1,
1795 LSM_W - LSItems.indent - 16, 10, BKGDCOLOR);
1796 PrintLSEntry (which, HIGHLIGHT);
1797 VW_UpdateScreen ();
1798 SD_PlaySound (ESCPRESSEDSND);
1799 continue;
1800 }
1801
1802 fontnumber = 1;
1803 break;
1804 }
1805
1806 }
1807 while (which >= 0);
1808
1809 MenuFadeOut ();
1810
1811#ifdef SPEAR
1812 UnCacheLump (LOADSAVE_LUMP_START, LOADSAVE_LUMP_END);
1813 CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1814#endif
1815
1816 return exit;
1817}
1818
1819////////////////////////////////////////////////////////////////////
1820//
1821// DEFINE CONTROLS
1822//
1823////////////////////////////////////////////////////////////////////
1824int
1825CP_Control (int a)
1826{
1827 int which;
1828
1829#ifdef SPEAR
1830 UnCacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1831 CacheLump (CONTROL_LUMP_START, CONTROL_LUMP_END);
1832#endif
1833
1834 DrawCtlScreen ();
1835 MenuFadeIn ();
1836 WaitKeyUp ();
1837
1838 do
1839 {
1840 which = HandleMenu (&CtlItems, CtlMenu, NULL);
1841 switch (which)
1842 {
1843 case CTL_MOUSEENABLE:
1844 mouseenabled ^= 1;
1845 if(IN_IsInputGrabbed())
1846 IN_CenterMouse();
1847 DrawCtlScreen ();
1848 CusItems.curpos = -1;
1849 ShootSnd ();
1850 break;
1851
1852 case CTL_JOYENABLE:
1853 joystickenabled ^= 1;
1854 DrawCtlScreen ();
1855 CusItems.curpos = -1;
1856 ShootSnd ();
1857 break;
1858
1859 case CTL_MOUSESENS:
1860 case CTL_CUSTOMIZE:
1861 DrawCtlScreen ();
1862 MenuFadeIn ();
1863 WaitKeyUp ();
1864 break;
1865 }
1866 }
1867 while (which >= 0);
1868
1869 MenuFadeOut ();
1870
1871#ifdef SPEAR
1872 UnCacheLump (CONTROL_LUMP_START, CONTROL_LUMP_END);
1873 CacheLump (OPTIONS_LUMP_START, OPTIONS_LUMP_END);
1874#endif
1875 return 0;
1876}
1877
1878
1879////////////////////////////////
1880//
1881// DRAW MOUSE SENSITIVITY SCREEN
1882//
1883void
1884DrawMouseSens (void)
1885{
1886#ifdef JAPAN
1887 CA_CacheScreen (S_MOUSESENSPIC);
1888#else
1889 ClearMScreen ();
1890 VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
1891#ifdef SPANISH
1892 DrawWindow (10, 80, 300, 43, BKGDCOLOR);
1893#else
1894 DrawWindow (10, 80, 300, 30, BKGDCOLOR);
1895#endif
1896
1897 WindowX = 0;
1898 WindowW = 320;
1899 PrintY = 82;
1900 SETFONTCOLOR (READCOLOR, BKGDCOLOR);
1901 US_CPrint (STR_MOUSEADJ);
1902
1903 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
1904#ifdef SPANISH
1905 PrintX = 14;
1906 PrintY = 95 + 13;
1907 US_Print (STR_SLOW);
1908 PrintX = 252;
1909 US_Print (STR_FAST);
1910#else
1911 PrintX = 14;
1912 PrintY = 95;
1913 US_Print (STR_SLOW);
1914 PrintX = 269;
1915 US_Print (STR_FAST);
1916#endif
1917#endif
1918
1919 VWB_Bar (60, 97, 200, 10, TEXTCOLOR);
1920 DrawOutline (60, 97, 200, 10, 0, HIGHLIGHT);
1921 DrawOutline (60 + 20 * mouseadjustment, 97, 20, 10, 0, READCOLOR);
1922 VWB_Bar (61 + 20 * mouseadjustment, 98, 19, 9, READHCOLOR);
1923
1924 VW_UpdateScreen ();
1925 MenuFadeIn ();
1926}
1927
1928
1929///////////////////////////
1930//
1931// ADJUST MOUSE SENSITIVITY
1932//
1933int
1934MouseSensitivity (int a)
1935{
1936 ControlInfo ci;
1937 int exit = 0, oldMA;
1938
1939
1940 oldMA = mouseadjustment;
1941 DrawMouseSens ();
1942 do
1943 {
1944 SDL_Delay(5);
1945 ReadAnyControl (&ci);
1946 switch (ci.dir)
1947 {
1948 case dir_North:
1949 case dir_West:
1950 if (mouseadjustment)
1951 {
1952 mouseadjustment--;
1953 VWB_Bar (60, 97, 200, 10, TEXTCOLOR);
1954 DrawOutline (60, 97, 200, 10, 0, HIGHLIGHT);
1955 DrawOutline (60 + 20 * mouseadjustment, 97, 20, 10, 0, READCOLOR);
1956 VWB_Bar (61 + 20 * mouseadjustment, 98, 19, 9, READHCOLOR);
1957 VW_UpdateScreen ();
1958 SD_PlaySound (MOVEGUN1SND);
1959 TicDelay(20);
1960 }
1961 break;
1962
1963 case dir_South:
1964 case dir_East:
1965 if (mouseadjustment < 9)
1966 {
1967 mouseadjustment++;
1968 VWB_Bar (60, 97, 200, 10, TEXTCOLOR);
1969 DrawOutline (60, 97, 200, 10, 0, HIGHLIGHT);
1970 DrawOutline (60 + 20 * mouseadjustment, 97, 20, 10, 0, READCOLOR);
1971 VWB_Bar (61 + 20 * mouseadjustment, 98, 19, 9, READHCOLOR);
1972 VW_UpdateScreen ();
1973 SD_PlaySound (MOVEGUN1SND);
1974 TicDelay(20);
1975 }
1976 break;
1977 }
1978
1979 if (ci.button0 || Keyboard[sc_Space] || Keyboard[sc_Enter])
1980 exit = 1;
1981 else if (ci.button1 || Keyboard[sc_Escape])
1982 exit = 2;
1983
1984 }
1985 while (!exit);
1986
1987 if (exit == 2)
1988 {
1989 mouseadjustment = oldMA;
1990 SD_PlaySound (ESCPRESSEDSND);
1991 }
1992 else
1993 SD_PlaySound (SHOOTSND);
1994
1995 WaitKeyUp ();
1996 MenuFadeOut ();
1997
1998 return 0;
1999}
2000
2001
2002///////////////////////////
2003//
2004// DRAW CONTROL MENU SCREEN
2005//
2006void
2007DrawCtlScreen (void)
2008{
2009 int i, x, y;
2010
2011#ifdef JAPAN
2012 CA_CacheScreen (S_CONTROLPIC);
2013#else
2014 ClearMScreen ();
2015 DrawStripes (10);
2016 VWB_DrawPic (80, 0, C_CONTROLPIC);
2017 VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
2018 DrawWindow (CTL_X - 8, CTL_Y - 5, CTL_W, CTL_H, BKGDCOLOR);
2019#endif
2020 WindowX = 0;
2021 WindowW = 320;
2022 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
2023
2024 if (IN_JoyPresent())
2025 CtlMenu[CTL_JOYENABLE].active = 1;
2026
2027 if (MousePresent)
2028 {
2029 CtlMenu[CTL_MOUSESENS].active = CtlMenu[CTL_MOUSEENABLE].active = 1;
2030 }
2031
2032 CtlMenu[CTL_MOUSESENS].active = mouseenabled;
2033
2034
2035 DrawMenu (&CtlItems, CtlMenu);
2036
2037
2038 x = CTL_X + CtlItems.indent - 24;
2039 y = CTL_Y + 3;
2040 if (mouseenabled)
2041 VWB_DrawPic (x, y, C_SELECTEDPIC);
2042 else
2043 VWB_DrawPic (x, y, C_NOTSELECTEDPIC);
2044
2045 y = CTL_Y + 29;
2046 if (joystickenabled)
2047 VWB_DrawPic (x, y, C_SELECTEDPIC);
2048 else
2049 VWB_DrawPic (x, y, C_NOTSELECTEDPIC);
2050
2051 //
2052 // PICK FIRST AVAILABLE SPOT
2053 //
2054 if (CtlItems.curpos < 0 || !CtlMenu[CtlItems.curpos].active)
2055 {
2056 for (i = 0; i < CtlItems.amount; i++)
2057 {
2058 if (CtlMenu[i].active)
2059 {
2060 CtlItems.curpos = i;
2061 break;
2062 }
2063 }
2064 }
2065
2066 DrawMenuGun (&CtlItems);
2067 VW_UpdateScreen ();
2068}
2069
2070
2071////////////////////////////////////////////////////////////////////
2072//
2073// CUSTOMIZE CONTROLS
2074//
2075////////////////////////////////////////////////////////////////////
2076enum
2077{ FIRE, STRAFE, RUN, OPEN };
2078char mbarray[4][3] = { "b0", "b1", "b2", "b3" };
2079int8_t order[4] = { RUN, OPEN, FIRE, STRAFE };
2080
2081
2082int
2083CustomControls (int a)
2084{
2085 int which;
2086
2087 DrawCustomScreen ();
2088 do
2089 {
2090 which = HandleMenu (&CusItems, &CusMenu[0], FixupCustom);
2091 switch (which)
2092 {
2093 case 0:
2094 DefineMouseBtns ();
2095 DrawCustMouse (1);
2096 break;
2097 case 3:
2098 DefineJoyBtns ();
2099 DrawCustJoy (0);
2100 break;
2101 case 6:
2102 DefineKeyBtns ();
2103 DrawCustKeybd (0);
2104 break;
2105 case 8:
2106 DefineKeyMove ();
2107 DrawCustKeys (0);
2108 }
2109 }
2110 while (which >= 0);
2111
2112 MenuFadeOut ();
2113
2114 return 0;
2115}
2116
2117
2118////////////////////////
2119//
2120// DEFINE THE MOUSE BUTTONS
2121//
2122void
2123DefineMouseBtns (void)
2124{
2125 CustomCtrls mouseallowed = { 0, 1, 1, 1 };
2126 EnterCtrlData (2, &mouseallowed, DrawCustMouse, PrintCustMouse, MOUSE);
2127}
2128
2129
2130////////////////////////
2131//
2132// DEFINE THE JOYSTICK BUTTONS
2133//
2134void
2135DefineJoyBtns (void)
2136{
2137 CustomCtrls joyallowed = { 1, 1, 1, 1 };
2138 EnterCtrlData (5, &joyallowed, DrawCustJoy, PrintCustJoy, JOYSTICK);
2139}
2140
2141
2142////////////////////////
2143//
2144// DEFINE THE KEYBOARD BUTTONS
2145//
2146void
2147DefineKeyBtns (void)
2148{
2149 CustomCtrls keyallowed = { 1, 1, 1, 1 };
2150 EnterCtrlData (8, &keyallowed, DrawCustKeybd, PrintCustKeybd, KEYBOARDBTNS);
2151}
2152
2153
2154////////////////////////
2155//
2156// DEFINE THE KEYBOARD BUTTONS
2157//
2158void
2159DefineKeyMove (void)
2160{
2161 CustomCtrls keyallowed = { 1, 1, 1, 1 };
2162 EnterCtrlData (10, &keyallowed, DrawCustKeys, PrintCustKeys, KEYBOARDMOVE);
2163}
2164
2165
2166////////////////////////
2167//
2168// ENTER CONTROL DATA FOR ANY TYPE OF CONTROL
2169//
2170enum
2171{ FWRD, RIGHT, BKWD, LEFT };
2172int moveorder[4] = { LEFT, RIGHT, FWRD, BKWD };
2173
2174void
2175EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*PrintRtn) (int),
2176 int type)
2177{
2178 int j, exit, tick, redraw, which, x, picked, lastFlashTime;
2179 ControlInfo ci;
2180
2181
2182 ShootSnd ();
2183 PrintY = CST_Y + 13 * index;
2184 IN_ClearKeysDown ();
2185 exit = 0;
2186 redraw = 1;
2187 //
2188 // FIND FIRST SPOT IN ALLOWED ARRAY
2189 //
2190 for (j = 0; j < 4; j++)
2191 if (cust->allowed[j])
2192 {
2193 which = j;
2194 break;
2195 }
2196
2197 do
2198 {
2199 if (redraw)
2200 {
2201 x = CST_START + CST_SPC * which;
2202 DrawWindow (5, PrintY - 1, 310, 13, BKGDCOLOR);
2203
2204 DrawRtn (1);
2205 DrawWindow (x - 2, PrintY, CST_SPC, 11, TEXTCOLOR);
2206 DrawOutline (x - 2, PrintY, CST_SPC, 11, 0, HIGHLIGHT);
2207 SETFONTCOLOR (0, TEXTCOLOR);
2208 PrintRtn (which);
2209 PrintX = x;
2210 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
2211 VW_UpdateScreen ();
2212 WaitKeyUp ();
2213 redraw = 0;
2214 }
2215
2216 SDL_Delay(5);
2217 ReadAnyControl (&ci);
2218
2219 if (type == MOUSE || type == JOYSTICK)
2220 if (IN_KeyDown (sc_Enter) || IN_KeyDown (sc_Control) || IN_KeyDown (sc_Alt))
2221 {
2222 IN_ClearKeysDown ();
2223 ci.button0 = ci.button1 = false;
2224 }
2225
2226 //
2227 // CHANGE BUTTON VALUE?
2228 //
2229 if ((type != KEYBOARDBTNS && type != KEYBOARDMOVE) && (ci.button0 | ci.button1 | ci.button2 | ci.button3) ||
2230 ((type == KEYBOARDBTNS || type == KEYBOARDMOVE) && LastScan == sc_Enter))
2231 {
2232 lastFlashTime = GetTimeCount();
2233 tick = picked = 0;
2234 SETFONTCOLOR (0, TEXTCOLOR);
2235
2236 if (type == KEYBOARDBTNS || type == KEYBOARDMOVE)
2237 IN_ClearKeysDown ();
2238
2239 while(1)
2240 {
2241 int button, result = 0;
2242
2243 //
2244 // FLASH CURSOR
2245 //
2246 if (GetTimeCount() - lastFlashTime > 10)
2247 {
2248 switch (tick)
2249 {
2250 case 0:
2251 VWB_Bar (x, PrintY + 1, CST_SPC - 2, 10, TEXTCOLOR);
2252 break;
2253 case 1:
2254 PrintX = x;
2255 US_Print ("?");
2256 SD_PlaySound (HITWALLSND);
2257 }
2258 tick ^= 1;
2259 lastFlashTime = GetTimeCount();
2260 VW_UpdateScreen ();
2261 }
2262 else SDL_Delay(5);
2263
2264 //
2265 // WHICH TYPE OF INPUT DO WE PROCESS?
2266 //
2267 switch (type)
2268 {
2269 case MOUSE:
2270 button = IN_MouseButtons();
2271 switch (button)
2272 {
2273 case 1:
2274 result = 1;
2275 break;
2276 case 2:
2277 result = 2;
2278 break;
2279 case 4:
2280 result = 3;
2281 break;
2282 }
2283
2284 if (result)
2285 {
2286 for (int z = 0; z < 4; z++)
2287 if (order[which] == buttonmouse[z])
2288 {
2289 buttonmouse[z] = bt_nobutton;
2290 break;
2291 }
2292
2293 buttonmouse[result - 1] = order[which];
2294 picked = 1;
2295 SD_PlaySound (SHOOTDOORSND);
2296 }
2297 break;
2298
2299 case JOYSTICK:
2300 if (ci.button0)
2301 result = 1;
2302 else if (ci.button1)
2303 result = 2;
2304 else if (ci.button2)
2305 result = 3;
2306 else if (ci.button3)
2307 result = 4;
2308
2309 if (result)
2310 {
2311 for (int z = 0; z < 4; z++)
2312 {
2313 if (order[which] == buttonjoy[z])
2314 {
2315 buttonjoy[z] = bt_nobutton;
2316 break;
2317 }
2318 }
2319
2320 buttonjoy[result - 1] = order[which];
2321 picked = 1;
2322 SD_PlaySound (SHOOTDOORSND);
2323 }
2324 break;
2325
2326 case KEYBOARDBTNS:
2327 if (LastScan && LastScan != sc_Escape)
2328 {
2329 buttonscan[order[which]] = LastScan;
2330 picked = 1;
2331 ShootSnd ();
2332 IN_ClearKeysDown ();
2333 }
2334 break;
2335
2336 case KEYBOARDMOVE:
2337 if (LastScan && LastScan != sc_Escape)
2338 {
2339 dirscan[moveorder[which]] = LastScan;
2340 picked = 1;
2341 ShootSnd ();
2342 IN_ClearKeysDown ();
2343 }
2344 break;
2345 }
2346
2347 //
2348 // EXIT INPUT?
2349 //
2350 if (IN_KeyDown (sc_Escape) || type != JOYSTICK && ci.button1)
2351 {
2352 picked = 1;
2353 SD_PlaySound (ESCPRESSEDSND);
2354 }
2355
2356 if(picked) break;
2357
2358 ReadAnyControl (&ci);
2359 }
2360
2361 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
2362 redraw = 1;
2363 WaitKeyUp ();
2364 continue;
2365 }
2366
2367 if (ci.button1 || IN_KeyDown (sc_Escape))
2368 exit = 1;
2369
2370 //
2371 // MOVE TO ANOTHER SPOT?
2372 //
2373 switch (ci.dir)
2374 {
2375 case dir_West:
2376 do
2377 {
2378 which--;
2379 if (which < 0)
2380 which = 3;
2381 }
2382 while (!cust->allowed[which]);
2383 redraw = 1;
2384 SD_PlaySound (MOVEGUN1SND);
2385 while (ReadAnyControl (&ci), ci.dir != dir_None) SDL_Delay(5);
2386 IN_ClearKeysDown ();
2387 break;
2388
2389 case dir_East:
2390 do
2391 {
2392 which++;
2393 if (which > 3)
2394 which = 0;
2395 }
2396 while (!cust->allowed[which]);
2397 redraw = 1;
2398 SD_PlaySound (MOVEGUN1SND);
2399 while (ReadAnyControl (&ci), ci.dir != dir_None) SDL_Delay(5);
2400 IN_ClearKeysDown ();
2401 break;
2402 case dir_North:
2403 case dir_South:
2404 exit = 1;
2405 }
2406 }
2407 while (!exit);
2408
2409 SD_PlaySound (ESCPRESSEDSND);
2410 WaitKeyUp ();
2411 DrawWindow (5, PrintY - 1, 310, 13, BKGDCOLOR);
2412}
2413
2414
2415////////////////////////
2416//
2417// FIXUP GUN CURSOR OVERDRAW SHIT
2418//
2419void
2420FixupCustom (int w)
2421{
2422 static int lastwhich = -1;
2423 int y = CST_Y + 26 + w * 13;
2424
2425
2426 VWB_Hlin (7, 32, y - 1, DEACTIVE);
2427 VWB_Hlin (7, 32, y + 12, BORD2COLOR);
2428#ifndef SPEAR
2429 VWB_Hlin (7, 32, y - 2, BORDCOLOR);
2430 VWB_Hlin (7, 32, y + 13, BORDCOLOR);
2431#else
2432 VWB_Hlin (7, 32, y - 2, BORD2COLOR);
2433 VWB_Hlin (7, 32, y + 13, BORD2COLOR);
2434#endif
2435
2436 switch (w)
2437 {
2438 case 0:
2439 DrawCustMouse (1);
2440 break;
2441 case 3:
2442 DrawCustJoy (1);
2443 break;
2444 case 6:
2445 DrawCustKeybd (1);
2446 break;
2447 case 8:
2448 DrawCustKeys (1);
2449 }
2450
2451
2452 if (lastwhich >= 0)
2453 {
2454 y = CST_Y + 26 + lastwhich * 13;
2455 VWB_Hlin (7, 32, y - 1, DEACTIVE);
2456 VWB_Hlin (7, 32, y + 12, BORD2COLOR);
2457#ifndef SPEAR
2458 VWB_Hlin (7, 32, y - 2, BORDCOLOR);
2459 VWB_Hlin (7, 32, y + 13, BORDCOLOR);
2460#else
2461 VWB_Hlin (7, 32, y - 2, BORD2COLOR);
2462 VWB_Hlin (7, 32, y + 13, BORD2COLOR);
2463#endif
2464
2465 if (lastwhich != w)
2466 switch (lastwhich)
2467 {
2468 case 0:
2469 DrawCustMouse (0);
2470 break;
2471 case 3:
2472 DrawCustJoy (0);
2473 break;
2474 case 6:
2475 DrawCustKeybd (0);
2476 break;
2477 case 8:
2478 DrawCustKeys (0);
2479 }
2480 }
2481
2482 lastwhich = w;
2483}
2484
2485
2486////////////////////////
2487//
2488// DRAW CUSTOMIZE SCREEN
2489//
2490void
2491DrawCustomScreen (void)
2492{
2493 int i;
2494
2495
2496#ifdef JAPAN
2497 CA_CacheScreen (S_CUSTOMPIC);
2498 fontnumber = 1;
2499
2500 PrintX = CST_START;
2501 PrintY = CST_Y + 26;
2502 DrawCustMouse (0);
2503
2504 PrintX = CST_START;
2505 US_Print ("\n\n\n");
2506 DrawCustJoy (0);
2507
2508 PrintX = CST_START;
2509 US_Print ("\n\n\n");
2510 DrawCustKeybd (0);
2511
2512 PrintX = CST_START;
2513 US_Print ("\n\n\n");
2514 DrawCustKeys (0);
2515#else
2516 ClearMScreen ();
2517 WindowX = 0;
2518 WindowW = 320;
2519 VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
2520 DrawStripes (10);
2521 VWB_DrawPic (80, 0, C_CUSTOMIZEPIC);
2522
2523 //
2524 // MOUSE
2525 //
2526 SETFONTCOLOR (READCOLOR, BKGDCOLOR);
2527 WindowX = 0;
2528 WindowW = 320;
2529
2530#ifndef SPEAR
2531 PrintY = CST_Y;
2532 US_CPrint ("Mouse\n");
2533#else
2534 PrintY = CST_Y + 13;
2535 VWB_DrawPic (128, 48, C_MOUSEPIC);
2536#endif
2537
2538 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
2539#ifdef SPANISH
2540 PrintX = CST_START - 16;
2541 US_Print (STR_CRUN);
2542 PrintX = CST_START - 16 + CST_SPC * 1;
2543 US_Print (STR_COPEN);
2544 PrintX = CST_START - 16 + CST_SPC * 2;
2545 US_Print (STR_CFIRE);
2546 PrintX = CST_START - 16 + CST_SPC * 3;
2547 US_Print (STR_CSTRAFE "\n");
2548#else
2549 PrintX = CST_START;
2550 US_Print (STR_CRUN);
2551 PrintX = CST_START + CST_SPC * 1;
2552 US_Print (STR_COPEN);
2553 PrintX = CST_START + CST_SPC * 2;
2554 US_Print (STR_CFIRE);
2555 PrintX = CST_START + CST_SPC * 3;
2556 US_Print (STR_CSTRAFE "\n");
2557#endif
2558
2559 DrawWindow (5, PrintY - 1, 310, 13, BKGDCOLOR);
2560 DrawCustMouse (0);
2561 US_Print ("\n");
2562
2563
2564 //
2565 // JOYSTICK/PAD
2566 //
2567#ifndef SPEAR
2568 SETFONTCOLOR (READCOLOR, BKGDCOLOR);
2569 US_CPrint ("Joystick/Gravis GamePad\n");
2570#else
2571 PrintY += 13;
2572 VWB_DrawPic (40, 88, C_JOYSTICKPIC);
2573#endif
2574
2575#ifdef SPEAR
2576 VWB_DrawPic (112, 120, C_KEYBOARDPIC);
2577#endif
2578
2579 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
2580#ifdef SPANISH
2581 PrintX = CST_START - 16;
2582 US_Print (STR_CRUN);
2583 PrintX = CST_START - 16 + CST_SPC * 1;
2584 US_Print (STR_COPEN);
2585 PrintX = CST_START - 16 + CST_SPC * 2;
2586 US_Print (STR_CFIRE);
2587 PrintX = CST_START - 16 + CST_SPC * 3;
2588 US_Print (STR_CSTRAFE "\n");
2589#else
2590 PrintX = CST_START;
2591 US_Print (STR_CRUN);
2592 PrintX = CST_START + CST_SPC * 1;
2593 US_Print (STR_COPEN);
2594 PrintX = CST_START + CST_SPC * 2;
2595 US_Print (STR_CFIRE);
2596 PrintX = CST_START + CST_SPC * 3;
2597 US_Print (STR_CSTRAFE "\n");
2598#endif
2599 DrawWindow (5, PrintY - 1, 310, 13, BKGDCOLOR);
2600 DrawCustJoy (0);
2601 US_Print ("\n");
2602
2603
2604 //
2605 // KEYBOARD
2606 //
2607#ifndef SPEAR
2608 SETFONTCOLOR (READCOLOR, BKGDCOLOR);
2609 US_CPrint ("Keyboard\n");
2610#else
2611 PrintY += 13;
2612#endif
2613 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
2614#ifdef SPANISH
2615 PrintX = CST_START - 16;
2616 US_Print (STR_CRUN);
2617 PrintX = CST_START - 16 + CST_SPC * 1;
2618 US_Print (STR_COPEN);
2619 PrintX = CST_START - 16 + CST_SPC * 2;
2620 US_Print (STR_CFIRE);
2621 PrintX = CST_START - 16 + CST_SPC * 3;
2622 US_Print (STR_CSTRAFE "\n");
2623#else
2624 PrintX = CST_START;
2625 US_Print (STR_CRUN);
2626 PrintX = CST_START + CST_SPC * 1;
2627 US_Print (STR_COPEN);
2628 PrintX = CST_START + CST_SPC * 2;
2629 US_Print (STR_CFIRE);
2630 PrintX = CST_START + CST_SPC * 3;
2631 US_Print (STR_CSTRAFE "\n");
2632#endif
2633 DrawWindow (5, PrintY - 1, 310, 13, BKGDCOLOR);
2634 DrawCustKeybd (0);
2635 US_Print ("\n");
2636
2637
2638 //
2639 // KEYBOARD MOVE KEYS
2640 //
2641 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
2642#ifdef SPANISH
2643 PrintX = 4;
2644 US_Print (STR_LEFT);
2645 US_Print ("/");
2646 US_Print (STR_RIGHT);
2647 US_Print ("/");
2648 US_Print (STR_FRWD);
2649 US_Print ("/");
2650 US_Print (STR_BKWD "\n");
2651#else
2652 PrintX = CST_START;
2653 US_Print (STR_LEFT);
2654 PrintX = CST_START + CST_SPC * 1;
2655 US_Print (STR_RIGHT);
2656 PrintX = CST_START + CST_SPC * 2;
2657 US_Print (STR_FRWD);
2658 PrintX = CST_START + CST_SPC * 3;
2659 US_Print (STR_BKWD "\n");
2660#endif
2661 DrawWindow (5, PrintY - 1, 310, 13, BKGDCOLOR);
2662 DrawCustKeys (0);
2663#endif
2664 //
2665 // PICK STARTING POINT IN MENU
2666 //
2667 if (CusItems.curpos < 0)
2668 for (i = 0; i < CusItems.amount; i++)
2669 if (CusMenu[i].active)
2670 {
2671 CusItems.curpos = i;
2672 break;
2673 }
2674
2675
2676 VW_UpdateScreen ();
2677 MenuFadeIn ();
2678}
2679
2680
2681void
2682PrintCustMouse (int i)
2683{
2684 int j;
2685
2686 for (j = 0; j < 4; j++)
2687 if (order[i] == buttonmouse[j])
2688 {
2689 PrintX = CST_START + CST_SPC * i;
2690 US_Print (mbarray[j]);
2691 break;
2692 }
2693}
2694
2695void
2696DrawCustMouse (int hilight)
2697{
2698 int i, color;
2699
2700
2701 color = TEXTCOLOR;
2702 if (hilight)
2703 color = HIGHLIGHT;
2704 SETFONTCOLOR (color, BKGDCOLOR);
2705
2706 if (!mouseenabled)
2707 {
2708 SETFONTCOLOR (DEACTIVE, BKGDCOLOR);
2709 CusMenu[0].active = 0;
2710 }
2711 else
2712 CusMenu[0].active = 1;
2713
2714 PrintY = CST_Y + 13 * 2;
2715 for (i = 0; i < 4; i++)
2716 PrintCustMouse (i);
2717}
2718
2719void
2720PrintCustJoy (int i)
2721{
2722 for (int j = 0; j < 4; j++)
2723 {
2724 if (order[i] == buttonjoy[j])
2725 {
2726 PrintX = CST_START + CST_SPC * i;
2727 US_Print (mbarray[j]);
2728 break;
2729 }
2730 }
2731}
2732
2733void
2734DrawCustJoy (int hilight)
2735{
2736 int i, color;
2737
2738 color = TEXTCOLOR;
2739 if (hilight)
2740 color = HIGHLIGHT;
2741 SETFONTCOLOR (color, BKGDCOLOR);
2742
2743 if (!joystickenabled)
2744 {
2745 SETFONTCOLOR (DEACTIVE, BKGDCOLOR);
2746 CusMenu[3].active = 0;
2747 }
2748 else
2749 CusMenu[3].active = 1;
2750
2751 PrintY = CST_Y + 13 * 5;
2752 for (i = 0; i < 4; i++)
2753 PrintCustJoy (i);
2754}
2755
2756
2757void
2758PrintCustKeybd (int i)
2759{
2760 PrintX = CST_START + CST_SPC * i;
2761 US_Print ((const char *) IN_GetScanName (buttonscan[order[i]]));
2762}
2763
2764void
2765DrawCustKeybd (int hilight)
2766{
2767 int i, color;
2768
2769
2770 color = TEXTCOLOR;
2771 if (hilight)
2772 color = HIGHLIGHT;
2773 SETFONTCOLOR (color, BKGDCOLOR);
2774
2775 PrintY = CST_Y + 13 * 8;
2776 for (i = 0; i < 4; i++)
2777 PrintCustKeybd (i);
2778}
2779
2780void
2781PrintCustKeys (int i)
2782{
2783 PrintX = CST_START + CST_SPC * i;
2784 US_Print ((const char *) IN_GetScanName (dirscan[moveorder[i]]));
2785}
2786
2787void
2788DrawCustKeys (int hilight)
2789{
2790 int i, color;
2791
2792
2793 color = TEXTCOLOR;
2794 if (hilight)
2795 color = HIGHLIGHT;
2796 SETFONTCOLOR (color, BKGDCOLOR);
2797
2798 PrintY = CST_Y + 13 * 10;
2799 for (i = 0; i < 4; i++)
2800 PrintCustKeys (i);
2801}
2802
2803
2804////////////////////////////////////////////////////////////////////
2805//
2806// CHANGE SCREEN VIEWING SIZE
2807//
2808////////////////////////////////////////////////////////////////////
2809int
2810CP_ChangeView (int a)
2811{
2812 int exit = 0, oldview, newview;
2813 ControlInfo ci;
2814
2815 WindowX = WindowY = 0;
2816 WindowW = 320;
2817 WindowH = 200;
2818 newview = oldview = viewsize;
2819 DrawChangeView (oldview);
2820 MenuFadeIn ();
2821
2822 do
2823 {
2824 CheckPause ();
2825 SDL_Delay(5);
2826 ReadAnyControl (&ci);
2827 switch (ci.dir)
2828 {
2829 case dir_South:
2830 case dir_West:
2831 newview--;
2832 if (newview < 4)
2833 newview = 4;
2834 if(newview >= 19) DrawChangeView(newview);
2835 else ShowViewSize (newview);
2836 VW_UpdateScreen ();
2837 SD_PlaySound (HITWALLSND);
2838 TicDelay (10);
2839 break;
2840
2841 case dir_North:
2842 case dir_East:
2843 newview++;
2844 if (newview >= 21)
2845 {
2846 newview = 21;
2847 DrawChangeView(newview);
2848 }
2849 else ShowViewSize (newview);
2850 VW_UpdateScreen ();
2851 SD_PlaySound (HITWALLSND);
2852 TicDelay (10);
2853 break;
2854 }
2855
2856 if (ci.button0 || Keyboard[sc_Enter])
2857 exit = 1;
2858 else if (ci.button1 || Keyboard[sc_Escape])
2859 {
2860 SD_PlaySound (ESCPRESSEDSND);
2861 MenuFadeOut ();
2862 if(screenHeight % 200 != 0)
2863 VL_ClearScreen(0);
2864 return 0;
2865 }
2866 }
2867 while (!exit);
2868
2869 if (oldview != newview)
2870 {
2871 SD_PlaySound (SHOOTSND);
2872 Message (STR_THINK "...");
2873 NewViewSize (newview);
2874 }
2875
2876 ShootSnd ();
2877 MenuFadeOut ();
2878 if(screenHeight % 200 != 0)
2879 VL_ClearScreen(0);
2880
2881 return 0;