summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/wolf3d/wl_menu.c
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2019-07-07 22:00:20 -0400
committerFranklin Wei <git@fwei.tk>2019-07-09 11:20:55 -0400
commit3f59fc8b771625aca9c3aefe03cf1038d8461963 (patch)
treee0623a323613baa0b0993411b38bcaed144b27ed /apps/plugins/sdl/progs/wolf3d/wl_menu.c
parent439a0d1d91fa040d261fc39b87278bc9f5391dcc (diff)
downloadrockbox-3f59fc8b771625aca9c3aefe03cf1038d8461963.tar.gz
rockbox-3f59fc8b771625aca9c3aefe03cf1038d8461963.zip
Wolfenstein 3-D!
This is a port of Wolf4SDL, which is derived from the original id software source release. The port runs on top of the SDL plugin runtime and is loaded as an overlay. Licensing of the game code is not an issue, as discussed below (essentially, the Debian project treats Wolf4SDL as GPLv2, with an email from John Carmack backing it up): http://forums.rockbox.org/index.php?topic=52872 Included is a copy of MAME's Yamaha OPL sound chip emulator (fmopl_gpl.c). This file was not part of the original Wolf4SDL source (which includes a non-GPL'd version), but was rather rebased from from a later MAME source which had been relicensed to GPLv2. Change-Id: I64c2ba035e0be7e2f49252f40640641416613439
Diffstat (limited to 'apps/plugins/sdl/progs/wolf3d/wl_menu.c')
-rw-r--r--apps/plugins/sdl/progs/wolf3d/wl_menu.c4160
1 files changed, 4160 insertions, 0 deletions
diff --git a/apps/plugins/sdl/progs/wolf3d/wl_menu.c b/apps/plugins/sdl/progs/wolf3d/wl_menu.c
new file mode 100644
index 0000000000..3913fab33d
--- /dev/null
+++ b/apps/plugins/sdl/progs/wolf3d/wl_menu.c
@@ -0,0 +1,4160 @@
1////////////////////////////////////////////////////////////////////
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;
2882}
2883
2884
2885/////////////////////////////
2886//
2887// DRAW THE CHANGEVIEW SCREEN
2888//
2889void
2890DrawChangeView (int view)
2891{
2892 int rescaledHeight = screenHeight / scaleFactor;
2893 if(view != 21) VWB_Bar (0, rescaledHeight - 40, 320, 40, bordercol);
2894
2895#ifdef JAPAN
2896 CA_CacheScreen (S_CHANGEPIC);
2897
2898 ShowViewSize (view);
2899#else
2900 ShowViewSize (view);
2901
2902 PrintY = (screenHeight / scaleFactor) - 39;
2903 WindowX = 0;
2904 WindowY = 320; // TODO: Check this!
2905 SETFONTCOLOR (HIGHLIGHT, BKGDCOLOR);
2906
2907 US_CPrint (STR_SIZE1 "\n");
2908 US_CPrint (STR_SIZE2 "\n");
2909 US_CPrint (STR_SIZE3);
2910#endif
2911 VW_UpdateScreen ();
2912}
2913
2914
2915////////////////////////////////////////////////////////////////////
2916//
2917// QUIT THIS INFERNAL GAME!
2918//
2919////////////////////////////////////////////////////////////////////
2920int
2921CP_Quit (int a)
2922{
2923#ifdef JAPAN
2924 if (GetYorN (7, 11, C_QUITMSGPIC))
2925#else
2926
2927#ifdef SPANISH
2928 if (Confirm (ENDGAMESTR))
2929#else
2930 if (Confirm (endStrings[US_RndT () & 0x7 + (US_RndT () & 1)]))
2931#endif
2932
2933#endif
2934 {
2935 VW_UpdateScreen ();
2936 SD_MusicOff ();
2937 SD_StopSound ();
2938 MenuFadeOut ();
2939 Quit (NULL);
2940 }
2941
2942 DrawMainMenu ();
2943 return 0;
2944}
2945
2946
2947////////////////////////////////////////////////////////////////////
2948//
2949// HANDLE INTRO SCREEN (SYSTEM CONFIG)
2950//
2951////////////////////////////////////////////////////////////////////
2952void
2953IntroScreen (void)
2954{
2955#ifdef SPEAR
2956
2957#define MAINCOLOR 0x4f
2958#define EMSCOLOR 0x4f
2959#define XMSCOLOR 0x4f
2960
2961#else
2962
2963#define MAINCOLOR 0x6c
2964#define EMSCOLOR 0x6c // 0x4f
2965#define XMSCOLOR 0x6c // 0x7f
2966
2967#endif
2968#define FILLCOLOR 14
2969
2970// long memory;
2971// long emshere,xmshere;
2972 int i;
2973/* int ems[10]={100,200,300,400,500,600,700,800,900,1000},
2974 xms[10]={100,200,300,400,500,600,700,800,900,1000};
2975 int main[10]={32,64,96,128,160,192,224,256,288,320};*/
2976
2977
2978 //
2979 // DRAW MAIN MEMORY
2980 //
2981#ifdef ABCAUS
2982 memory = (1023l + mminfo.nearheap + mminfo.farheap) / 1024l;
2983 for (i = 0; i < 10; i++)
2984 if (memory >= main[i])
2985 VWB_Bar (49, 163 - 8 * i, 6, 5, MAINCOLOR - i);
2986
2987 //
2988 // DRAW EMS MEMORY
2989 //
2990 if (EMSPresent)
2991 {
2992 emshere = 4l * EMSPagesAvail;
2993 for (i = 0; i < 10; i++)
2994 if (emshere >= ems[i])
2995 VWB_Bar (89, 163 - 8 * i, 6, 5, EMSCOLOR - i);
2996 }
2997
2998 //
2999 // DRAW XMS MEMORY
3000 //
3001 if (XMSPresent)
3002 {
3003 xmshere = 4l * XMSPagesAvail;
3004 for (i = 0; i < 10; i++)
3005 if (xmshere >= xms[i])
3006 VWB_Bar (129, 163 - 8 * i, 6, 5, XMSCOLOR - i);
3007 }
3008#else
3009 for (i = 0; i < 10; i++)
3010 VWB_Bar (49, 163 - 8 * i, 6, 5, MAINCOLOR - i);
3011 for (i = 0; i < 10; i++)
3012 VWB_Bar (89, 163 - 8 * i, 6, 5, EMSCOLOR - i);
3013 for (i = 0; i < 10; i++)
3014 VWB_Bar (129, 163 - 8 * i, 6, 5, XMSCOLOR - i);
3015#endif
3016
3017
3018 //
3019 // FILL BOXES
3020 //
3021 if (MousePresent)
3022 VWB_Bar (164, 82, 12, 2, FILLCOLOR);
3023
3024 if (IN_JoyPresent())
3025 VWB_Bar (164, 105, 12, 2, FILLCOLOR);
3026
3027 if (AdLibPresent && !SoundBlasterPresent)
3028 VWB_Bar (164, 128, 12, 2, FILLCOLOR);
3029
3030 if (SoundBlasterPresent)
3031 VWB_Bar (164, 151, 12, 2, FILLCOLOR);
3032
3033// if (SoundSourcePresent)
3034// VWB_Bar (164, 174, 12, 2, FILLCOLOR);
3035}
3036
3037
3038////////////////////////////////////////////////////////////////////
3039////////////////////////////////////////////////////////////////////
3040//
3041// SUPPORT ROUTINES
3042//
3043////////////////////////////////////////////////////////////////////
3044////////////////////////////////////////////////////////////////////
3045
3046////////////////////////////////////////////////////////////////////
3047//
3048// Clear Menu screens to dark red
3049//
3050////////////////////////////////////////////////////////////////////
3051void
3052ClearMScreen (void)
3053{
3054#ifndef SPEAR
3055 VWB_Bar (0, 0, 320, 200, BORDCOLOR);
3056#else
3057 VWB_DrawPic (0, 0, C_BACKDROPPIC);
3058#endif
3059}
3060
3061
3062////////////////////////////////////////////////////////////////////
3063//
3064// Un/Cache a LUMP of graphics
3065//
3066////////////////////////////////////////////////////////////////////
3067void
3068CacheLump (int lumpstart, int lumpend)
3069{
3070 int i;
3071
3072 for (i = lumpstart; i <= lumpend; i++)
3073 CA_CacheGrChunk (i);
3074}
3075
3076
3077void
3078UnCacheLump (int lumpstart, int lumpend)
3079{
3080 int i;
3081
3082 for (i = lumpstart; i <= lumpend; i++)
3083 if (grsegs[i])
3084 UNCACHEGRCHUNK (i);
3085}
3086
3087
3088////////////////////////////////////////////////////////////////////
3089//
3090// Draw a window for a menu
3091//
3092////////////////////////////////////////////////////////////////////
3093void
3094DrawWindow (int x, int y, int w, int h, int wcolor)
3095{
3096 VWB_Bar (x, y, w, h, wcolor);
3097 DrawOutline (x, y, w, h, BORD2COLOR, DEACTIVE);
3098}
3099
3100
3101void
3102DrawOutline (int x, int y, int w, int h, int color1, int color2)
3103{
3104 VWB_Hlin (x, x + w, y, color2);
3105 VWB_Vlin (y, y + h, x, color2);
3106 VWB_Hlin (x, x + w, y + h, color1);
3107 VWB_Vlin (y, y + h, x + w, color1);
3108}
3109
3110
3111////////////////////////////////////////////////////////////////////
3112//
3113// Setup Control Panel stuff - graphics, etc.
3114//
3115////////////////////////////////////////////////////////////////////
3116void
3117SetupControlPanel (void)
3118{
3119 //
3120 // CACHE GRAPHICS & SOUNDS
3121 //
3122 CA_CacheGrChunk (STARTFONT + 1);
3123#ifndef SPEAR
3124 CacheLump (CONTROLS_LUMP_START, CONTROLS_LUMP_END);
3125#else
3126 CacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
3127#endif
3128
3129 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
3130 fontnumber = 1;
3131 WindowH = 200;
3132 if(screenHeight % 200 != 0)
3133 VL_ClearScreen(0);
3134
3135 if (!ingame)
3136 CA_LoadAllSounds ();
3137 else
3138 MainMenu[savegame].active = 1;
3139
3140 //
3141 // CENTER MOUSE
3142 //
3143 if(IN_IsInputGrabbed())
3144 IN_CenterMouse();
3145}
3146
3147////////////////////////////////////////////////////////////////////
3148//
3149// SEE WHICH SAVE GAME FILES ARE AVAILABLE & READ STRING IN
3150//
3151////////////////////////////////////////////////////////////////////
3152void SetupSaveGames()
3153{
3154 char name[13];
3155 char savepath[300];
3156
3157 strcpy(name, SaveName);
3158 for(int i = 0; i < 10; i++)
3159 {
3160 name[7] = '0' + i;
3161#ifdef _arch_dreamcast
3162 // Try to unpack file
3163 if(DC_LoadFromVMU(name))
3164 {
3165#endif
3166 if(configdir[0])
3167 snprintf(savepath, sizeof(savepath), "%s/%s", configdir, name);
3168 else
3169 strcpy(savepath, name);
3170
3171 const int handle = open(savepath, O_RDONLY | O_BINARY);
3172 if(handle >= 0)
3173 {
3174 char temp[32];
3175
3176 SaveGamesAvail[i] = 1;
3177 read(handle, temp, 32);
3178 close(handle);
3179 strcpy(&SaveGameNames[i][0], temp);
3180 }
3181#ifdef _arch_dreamcast
3182 // Remove unpacked version of file
3183 fs_unlink(name);
3184 }
3185#endif
3186 }
3187}
3188
3189////////////////////////////////////////////////////////////////////
3190//
3191// Clean up all the Control Panel stuff
3192//
3193////////////////////////////////////////////////////////////////////
3194void
3195CleanupControlPanel (void)
3196{
3197#ifndef SPEAR
3198 UnCacheLump (CONTROLS_LUMP_START, CONTROLS_LUMP_END);
3199#else
3200 UnCacheLump (BACKDROP_LUMP_START, BACKDROP_LUMP_END);
3201#endif
3202
3203 fontnumber = 0;
3204}
3205
3206
3207////////////////////////////////////////////////////////////////////
3208//
3209// Handle moving gun around a menu
3210//
3211////////////////////////////////////////////////////////////////////
3212int
3213HandleMenu (CP_iteminfo * item_i, CP_itemtype * items, void (*routine) (int w))
3214{
3215 char key;
3216 static int redrawitem = 1, lastitem = -1;
3217 int i, x, y, basey, exit, which, shape;
3218 int32_t lastBlinkTime, timer;
3219 ControlInfo ci;
3220
3221
3222 which = item_i->curpos;
3223 x = item_i->x & -8;
3224 basey = item_i->y - 2;
3225 y = basey + which * 13;
3226
3227 VWB_DrawPic (x, y, C_CURSOR1PIC);
3228 SetTextColor (items + which, 1);
3229 if (redrawitem)
3230 {
3231 PrintX = item_i->x + item_i->indent;
3232 PrintY = item_i->y + which * 13;
3233 US_Print ((items + which)->string);
3234 }
3235 //
3236 // CALL CUSTOM ROUTINE IF IT IS NEEDED
3237 //
3238 if (routine)
3239 routine (which);
3240 VW_UpdateScreen ();
3241
3242 shape = C_CURSOR1PIC;
3243 timer = 8;
3244 exit = 0;
3245 lastBlinkTime = GetTimeCount ();
3246 IN_ClearKeysDown ();
3247
3248
3249 do
3250 {
3251 //
3252 // CHANGE GUN SHAPE
3253 //
3254 if ((int32_t)GetTimeCount () - lastBlinkTime > timer)
3255 {
3256 lastBlinkTime = GetTimeCount ();
3257 if (shape == C_CURSOR1PIC)
3258 {
3259 shape = C_CURSOR2PIC;
3260 timer = 8;
3261 }
3262 else
3263 {
3264 shape = C_CURSOR1PIC;
3265 timer = 70;
3266 }
3267 VWB_DrawPic (x, y, shape);
3268 if (routine)
3269 routine (which);
3270 VW_UpdateScreen ();
3271 }
3272 else SDL_Delay(5);
3273
3274 CheckPause ();
3275
3276 //
3277 // SEE IF ANY KEYS ARE PRESSED FOR INITIAL CHAR FINDING
3278 //
3279 key = LastASCII;
3280 if (key)
3281 {
3282 int ok = 0;
3283
3284 if (key >= 'a')
3285 key -= 'a' - 'A';
3286
3287 for (i = which + 1; i < item_i->amount; i++)
3288 if ((items + i)->active && (items + i)->string[0] == key)
3289 {
3290 EraseGun (item_i, items, x, y, which);
3291 which = i;
3292 DrawGun (item_i, items, x, &y, which, basey, routine);
3293 ok = 1;
3294 IN_ClearKeysDown ();
3295 break;
3296 }
3297
3298 //
3299 // DIDN'T FIND A MATCH FIRST TIME THRU. CHECK AGAIN.
3300 //
3301 if (!ok)
3302 {
3303 for (i = 0; i < which; i++)
3304 if ((items + i)->active && (items + i)->string[0] == key)
3305 {
3306 EraseGun (item_i, items, x, y, which);
3307 which = i;
3308 DrawGun (item_i, items, x, &y, which, basey, routine);
3309 IN_ClearKeysDown ();
3310 break;
3311 }
3312 }
3313 }
3314
3315 //
3316 // GET INPUT
3317 //
3318 ReadAnyControl (&ci);
3319 switch (ci.dir)
3320 {
3321 ////////////////////////////////////////////////
3322 //
3323 // MOVE UP
3324 //
3325 case dir_North:
3326
3327 EraseGun (item_i, items, x, y, which);
3328
3329 //
3330 // ANIMATE HALF-STEP
3331 //
3332 if (which && (items + which - 1)->active)
3333 {
3334 y -= 6;
3335 DrawHalfStep (x, y);
3336 }
3337
3338 //
3339 // MOVE TO NEXT AVAILABLE SPOT
3340 //
3341 do
3342 {
3343 if (!which)
3344 which = item_i->amount - 1;
3345 else
3346 which--;
3347 }
3348 while (!(items + which)->active);
3349
3350 DrawGun (item_i, items, x, &y, which, basey, routine);
3351 //
3352 // WAIT FOR BUTTON-UP OR DELAY NEXT MOVE
3353 //
3354 TicDelay (20);
3355 break;
3356
3357 ////////////////////////////////////////////////
3358 //
3359 // MOVE DOWN
3360 //
3361 case dir_South:
3362
3363 EraseGun (item_i, items, x, y, which);
3364 //
3365 // ANIMATE HALF-STEP
3366 //
3367 if (which != item_i->amount - 1 && (items + which + 1)->active)
3368 {
3369 y += 6;
3370 DrawHalfStep (x, y);
3371 }
3372
3373 do
3374 {
3375 if (which == item_i->amount - 1)
3376 which = 0;
3377 else
3378 which++;
3379 }
3380 while (!(items + which)->active);
3381
3382 DrawGun (item_i, items, x, &y, which, basey, routine);
3383
3384 //
3385 // WAIT FOR BUTTON-UP OR DELAY NEXT MOVE
3386 //
3387 TicDelay (20);
3388 break;
3389 }
3390
3391 if (ci.button0 || Keyboard[sc_Space] || Keyboard[sc_Enter])
3392 exit = 1;
3393
3394 if (ci.button1 && !Keyboard[sc_Alt] || Keyboard[sc_Escape])
3395 exit = 2;
3396
3397 }
3398 while (!exit);
3399
3400
3401 IN_ClearKeysDown ();
3402
3403 //
3404 // ERASE EVERYTHING
3405 //
3406 if (lastitem != which)
3407 {
3408 VWB_Bar (x - 1, y, 25, 16, BKGDCOLOR);
3409 PrintX = item_i->x + item_i->indent;
3410 PrintY = item_i->y + which * 13;
3411 US_Print ((items + which)->string);
3412 redrawitem = 1;
3413 }
3414 else
3415 redrawitem = 0;
3416
3417 if (routine)
3418 routine (which);
3419 VW_UpdateScreen ();
3420
3421 item_i->curpos = which;
3422
3423 lastitem = which;
3424 switch (exit)
3425 {
3426 case 1:
3427 //
3428 // CALL THE ROUTINE
3429 //
3430 if ((items + which)->routine != NULL)
3431 {
3432 ShootSnd ();
3433 MenuFadeOut ();
3434 (items + which)->routine (0);
3435 }
3436 return which;
3437
3438 case 2:
3439 SD_PlaySound (ESCPRESSEDSND);
3440 return -1;
3441 }
3442
3443 return 0; // JUST TO SHUT UP THE ERROR MESSAGES!
3444}
3445
3446
3447//
3448// ERASE GUN & DE-HIGHLIGHT STRING
3449//
3450void
3451EraseGun (CP_iteminfo * item_i, CP_itemtype * items, int x, int y, int which)
3452{
3453 VWB_Bar (x - 1, y, 25, 16, BKGDCOLOR);
3454 SetTextColor (items + which, 0);
3455
3456 PrintX = item_i->x + item_i->indent;
3457 PrintY = item_i->y + which * 13;
3458 US_Print ((items + which)->string);
3459 VW_UpdateScreen ();
3460}
3461
3462
3463//
3464// DRAW HALF STEP OF GUN TO NEXT POSITION
3465//
3466void
3467DrawHalfStep (int x, int y)
3468{
3469 VWB_DrawPic (x, y, C_CURSOR1PIC);
3470 VW_UpdateScreen ();
3471 SD_PlaySound (MOVEGUN1SND);
3472 SDL_Delay (8 * 100 / 7);
3473}
3474
3475
3476//
3477// DRAW GUN AT NEW POSITION
3478//
3479void
3480DrawGun (CP_iteminfo * item_i, CP_itemtype * items, int x, int *y, int which, int basey,
3481 void (*routine) (int w))
3482{
3483 VWB_Bar (x - 1, *y, 25, 16, BKGDCOLOR);
3484 *y = basey + which * 13;
3485 VWB_DrawPic (x, *y, C_CURSOR1PIC);
3486 SetTextColor (items + which, 1);
3487
3488 PrintX = item_i->x + item_i->indent;
3489 PrintY = item_i->y + which * 13;
3490 US_Print ((items + which)->string);
3491
3492 //
3493 // CALL CUSTOM ROUTINE IF IT IS NEEDED
3494 //
3495 if (routine)
3496 routine (which);
3497 VW_UpdateScreen ();
3498 SD_PlaySound (MOVEGUN2SND);
3499}
3500
3501////////////////////////////////////////////////////////////////////
3502//
3503// DELAY FOR AN AMOUNT OF TICS OR UNTIL CONTROLS ARE INACTIVE
3504//
3505////////////////////////////////////////////////////////////////////
3506void
3507TicDelay (int count)
3508{
3509 ControlInfo ci;
3510
3511 int32_t startTime = GetTimeCount ();
3512 do
3513 {
3514 SDL_Delay(5);
3515 ReadAnyControl (&ci);
3516 }
3517 while ((int32_t) GetTimeCount () - startTime < count && ci.dir != dir_None);
3518}
3519
3520
3521////////////////////////////////////////////////////////////////////
3522//
3523// Draw a menu
3524//
3525////////////////////////////////////////////////////////////////////
3526void
3527DrawMenu (CP_iteminfo * item_i, CP_itemtype * items)
3528{
3529 int i, which = item_i->curpos;
3530
3531
3532 WindowX = PrintX = item_i->x + item_i->indent;
3533 WindowY = PrintY = item_i->y;
3534 WindowW = 320;
3535 WindowH = 200;
3536
3537 for (i = 0; i < item_i->amount; i++)
3538 {
3539 SetTextColor (items + i, which == i);
3540
3541 PrintY = item_i->y + i * 13;
3542 if ((items + i)->active)
3543 US_Print ((items + i)->string);
3544 else
3545 {
3546 SETFONTCOLOR (DEACTIVE, BKGDCOLOR);
3547 US_Print ((items + i)->string);
3548 SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
3549 }
3550
3551 US_Print ("\n");
3552 }
3553}
3554
3555
3556////////////////////////////////////////////////////////////////////
3557//
3558// SET TEXT COLOR (HIGHLIGHT OR NO)
3559//
3560////////////////////////////////////////////////////////////////////
3561void
3562SetTextColor (CP_itemtype * items, int hlight)
3563{
3564 if (hlight)
3565 {
3566 SETFONTCOLOR (color_hlite[items->active], BKGDCOLOR);
3567 }
3568 else
3569 {
3570 SETFONTCOLOR (color_norml[items->active], BKGDCOLOR);
3571 }
3572}
3573
3574
3575////////////////////////////////////////////////////////////////////
3576//
3577// WAIT FOR CTRLKEY-UP OR BUTTON-UP
3578//
3579////////////////////////////////////////////////////////////////////
3580void
3581WaitKeyUp (void)
3582{
3583 ControlInfo ci;
3584 while (ReadAnyControl (&ci), ci.button0 |
3585 ci.button1 |
3586 ci.button2 | ci.button3 | Keyboard[sc_Space] | Keyboard[sc_Enter] | Keyboard[sc_Escape])
3587 {
3588 IN_WaitAndProcessEvents();
3589 }
3590}
3591
3592
3593////////////////////////////////////////////////////////////////////
3594//
3595// READ KEYBOARD, JOYSTICK AND MOUSE FOR INPUT
3596//
3597////////////////////////////////////////////////////////////////////
3598void
3599ReadAnyControl (ControlInfo * ci)
3600{
3601 int mouseactive = 0;
3602
3603 IN_ReadControl (0, ci);
3604#if 0
3605 if (mouseenabled && IN_IsInputGrabbed())
3606 {
3607 int mousex, mousey, buttons;
3608 buttons = SDL_GetMouseState(&mousex, &mousey);
3609 int middlePressed = buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE);
3610 int rightPressed = buttons & SDL_BUTTON(SDL_BUTTON_RIGHT);
3611 buttons &= ~(SDL_BUTTON(SDL_BUTTON_MIDDLE) | SDL_BUTTON(SDL_BUTTON_RIGHT));
3612 if(middlePressed) buttons |= 1 << 2;
3613 if(rightPressed) buttons |= 1 << 1;
3614
3615 if(mousey - CENTERY < -SENSITIVE)
3616 {
3617 ci->dir = dir_North;
3618 mouseactive = 1;
3619 }
3620 else if(mousey - CENTERY > SENSITIVE)
3621 {
3622 ci->dir = dir_South;
3623 mouseactive = 1;
3624 }
3625
3626 if(mousex - CENTERX < -SENSITIVE)
3627 {
3628 ci->dir = dir_West;
3629 mouseactive = 1;
3630 }
3631 else if(mousex - CENTERX > SENSITIVE)
3632 {
3633 ci->dir = dir_East;
3634 mouseactive = 1;
3635 }
3636
3637 if(mouseactive)
3638 IN_CenterMouse();
3639
3640 if (buttons)
3641 {
3642 ci->button0 = buttons & 1;
3643 ci->button1 = buttons & 2;
3644 ci->button2 = buttons & 4;
3645 ci->button3 = false;
3646 mouseactive = 1;
3647 }
3648 }
3649
3650 if (joystickenabled && !mouseactive)
3651 {
3652 int jx, jy, jb;
3653
3654 IN_GetJoyDelta (&jx, &jy);
3655 if (jy < -SENSITIVE)
3656 ci->dir = dir_North;
3657 else if (jy > SENSITIVE)
3658 ci->dir = dir_South;
3659
3660 if (jx < -SENSITIVE)
3661 ci->dir = dir_West;
3662 else if (jx > SENSITIVE)
3663 ci->dir = dir_East;
3664
3665 jb = IN_JoyButtons ();
3666 if (jb)
3667 {
3668 ci->button0 = jb & 1;
3669 ci->button1 = jb & 2;
3670 ci->button2 = jb & 4;
3671 ci->button3 = jb & 8;
3672 }
3673 }
3674#endif
3675}
3676
3677
3678////////////////////////////////////////////////////////////////////
3679//
3680// DRAW DIALOG AND CONFIRM YES OR NO TO QUESTION
3681//
3682////////////////////////////////////////////////////////////////////
3683int
3684Confirm (const char *string)
3685{
3686 int xit = 0, x, y, tick = 0, lastBlinkTime;
3687 int whichsnd[2] = { ESCPRESSEDSND, SHOOTSND };
3688 ControlInfo ci;
3689
3690 Message (string);
3691 IN_ClearKeysDown ();
3692 WaitKeyUp ();
3693
3694 //
3695 // BLINK CURSOR
3696 //
3697 x = PrintX;
3698 y = PrintY;
3699 lastBlinkTime = GetTimeCount();
3700
3701 do
3702 {
3703 ReadAnyControl(&ci);
3704
3705 if (GetTimeCount() - lastBlinkTime >= 10)
3706 {
3707 switch (tick)
3708 {
3709 case 0:
3710 VWB_Bar (x, y, 8, 13, TEXTCOLOR);
3711 break;
3712 case 1:
3713 PrintX = x;
3714 PrintY = y;
3715 US_Print ("_");
3716 }
3717 VW_UpdateScreen ();
3718 tick ^= 1;
3719 lastBlinkTime = GetTimeCount();
3720 }
3721 else SDL_Delay(5);
3722
3723#ifdef SPANISH
3724 }
3725 while (!Keyboard[sc_S] && !Keyboard[sc_N] && !Keyboard[sc_Escape]);
3726#else
3727 }
3728 while (!Keyboard[sc_Return] && !Keyboard[sc_Y] && !Keyboard[sc_N] && !Keyboard[sc_Escape] && !ci.button0 && !ci.button1);
3729#endif
3730
3731#ifdef SPANISH
3732 if (Keyboard[sc_S] || ci.button0)
3733 {
3734 xit = 1;
3735 ShootSnd ();
3736 }
3737#else
3738 if (Keyboard[sc_Y] || Keyboard[sc_Return] || ci.button0)
3739 {
3740 xit = 1;
3741 ShootSnd ();
3742 }
3743#endif
3744
3745 IN_ClearKeysDown ();
3746 WaitKeyUp ();
3747
3748 SD_PlaySound ((soundnames) whichsnd[xit]);
3749
3750 return xit;
3751}
3752
3753#ifdef JAPAN
3754////////////////////////////////////////////////////////////////////
3755//
3756// DRAW MESSAGE & GET Y OR N
3757//
3758////////////////////////////////////////////////////////////////////
3759int
3760GetYorN (int x, int y, int pic)
3761{
3762 int xit = 0, whichsnd[2] = { ESCPRESSEDSND, SHOOTSND };
3763
3764
3765 CA_CacheGrChunk (pic);
3766 VWB_DrawPic (x * 8, y * 8, pic);
3767 UNCACHEGRCHUNK (pic);
3768 VW_UpdateScreen ();
3769 IN_ClearKeysDown ();
3770
3771 do
3772 {
3773 IN_WaitAndProcessEvents();
3774#ifndef SPEAR
3775 if (Keyboard[sc_Tab] && Keyboard[sc_P] && param_debugmode)
3776 PicturePause ();
3777#endif
3778
3779#ifdef SPANISH
3780 }
3781 while (!Keyboard[sc_S] && !Keyboard[sc_N] && !Keyboard[sc_Escape]);
3782#else
3783 }
3784 while (!Keyboard[sc_Y] && !Keyboard[sc_N] && !Keyboard[sc_Escape]);
3785#endif
3786
3787#ifdef SPANISH
3788 if (Keyboard[sc_S])
3789 {
3790 xit = 1;
3791 ShootSnd ();
3792 }
3793
3794 while (Keyboard[sc_S] || Keyboard[sc_N] || Keyboard[sc_Escape])
3795 IN_WaitAndProcessEvents();
3796
3797#else
3798
3799 if (Keyboard[sc_Y])
3800 {
3801 xit = 1;
3802 ShootSnd ();
3803 }
3804
3805 while (Keyboard[sc_Y] || Keyboard[sc_N] || Keyboard[sc_Escape])
3806 IN_WaitAndProcessEvents();
3807#endif
3808
3809 IN_ClearKeysDown ();
3810 SD_PlaySound (whichsnd[xit]);
3811 return xit;
3812}
3813#endif
3814
3815
3816////////////////////////////////////////////////////////////////////
3817//
3818// PRINT A MESSAGE IN A WINDOW
3819//
3820////////////////////////////////////////////////////////////////////
3821void
3822Message (const char *string)
3823{
3824 int h = 0, w = 0, mw = 0, i, len = (int) strlen(string);
3825 fontstruct *font;
3826
3827
3828 CA_CacheGrChunk (STARTFONT + 1);
3829 fontnumber = 1;
3830 font = (fontstruct *) grsegs[STARTFONT + fontnumber];
3831 h = font->height;
3832 for (i = 0; i < len; i++)
3833 {
3834 if (string[i] == '\n')
3835 {
3836 if (w > mw)
3837 mw = w;
3838 w = 0;
3839 h += font->height;
3840 }
3841 else
3842 w += font->width[string[i]];
3843 }
3844
3845 if (w + 10 > mw)
3846 mw = w + 10;
3847
3848 PrintY = (WindowH / 2) - h / 2;
3849 PrintX = WindowX = 160 - mw / 2;
3850
3851 DrawWindow (WindowX - 5, PrintY - 5, mw + 10, h + 10, TEXTCOLOR);
3852 DrawOutline (WindowX - 5, PrintY - 5, mw + 10, h + 10, 0, HIGHLIGHT);
3853 SETFONTCOLOR (0, TEXTCOLOR);
3854 US_Print (string);
3855 VW_UpdateScreen ();
3856}
3857
3858////////////////////////////////////////////////////////////////////
3859//
3860// THIS MAY BE FIXED A LITTLE LATER...
3861//
3862////////////////////////////////////////////////////////////////////
3863static int lastmusic;
3864
3865int
3866StartCPMusic (int song)
3867{
3868 int lastoffs;
3869
3870 lastmusic = song;
3871 lastoffs = SD_MusicOff ();
3872 UNCACHEAUDIOCHUNK (STARTMUSIC + lastmusic);
3873
3874 SD_StartMusic(STARTMUSIC + song);
3875 return lastoffs;
3876}
3877
3878void
3879FreeMusic (void)
3880{
3881 UNCACHEAUDIOCHUNK (STARTMUSIC + lastmusic);
3882}
3883
3884
3885///////////////////////////////////////////////////////////////////////////
3886//
3887// IN_GetScanName() - Returns a string containing the name of the
3888// specified scan code
3889//
3890///////////////////////////////////////////////////////////////////////////
3891const char *
3892IN_GetScanName (ScanCode scan)
3893{
3894/* const char **p;
3895 ScanCode *s;
3896
3897 for (s = ExtScanCodes, p = ExtScanNames; *s; p++, s++)
3898 if (*s == scan)
3899 return (*p);*/
3900
3901 return (ScanNames[scan]);
3902}
3903
3904
3905///////////////////////////////////////////////////////////////////////////
3906//
3907// CHECK FOR PAUSE KEY (FOR MUSIC ONLY)
3908//
3909///////////////////////////////////////////////////////////////////////////
3910void
3911CheckPause (void)
3912{
3913 if (Paused)
3914 {
3915 switch (SoundStatus)
3916 {
3917 case 0:
3918 SD_MusicOn ();
3919 break;
3920 case 1:
3921 SD_MusicOff ();
3922 break;
3923 }
3924
3925 SoundStatus ^= 1;
3926 VW_WaitVBL (3);
3927 IN_ClearKeysDown ();
3928 Paused = false;
3929 }
3930}
3931
3932
3933///////////////////////////////////////////////////////////////////////////
3934//
3935// DRAW GUN CURSOR AT CORRECT POSITION IN MENU
3936//
3937///////////////////////////////////////////////////////////////////////////
3938void
3939DrawMenuGun (CP_iteminfo * iteminfo)
3940{
3941 int x, y;
3942
3943
3944 x = iteminfo->x;
3945 y = iteminfo->y + iteminfo->curpos * 13 - 2;
3946 VWB_DrawPic (x, y, C_CURSOR1PIC);
3947}
3948
3949
3950///////////////////////////////////////////////////////////////////////////
3951//
3952// DRAW SCREEN TITLE STRIPES
3953//
3954///////////////////////////////////////////////////////////////////////////
3955void
3956DrawStripes (int y)
3957{
3958#ifndef SPEAR
3959 VWB_Bar (0, y, 320, 24, 0);
3960 VWB_Hlin (0, 319, y + 22, STRIPE);
3961#else
3962 VWB_Bar (0, y, 320, 22, 0);
3963 VWB_Hlin (0, 319, y + 23, 0);
3964#endif
3965}
3966
3967void
3968ShootSnd (void)
3969{
3970 SD_PlaySound (SHOOTSND);
3971}
3972
3973
3974///////////////////////////////////////////////////////////////////////////
3975//
3976// CHECK FOR EPISODES
3977//
3978///////////////////////////////////////////////////////////////////////////
3979
3980#define stat my_stat
3981void *my_stat(const char *path, int *buf)
3982{
3983 if(rb->file_exists(path))
3984 return NULL;
3985 else
3986 return 1;
3987}
3988
3989void
3990CheckForEpisodes (void)
3991{
3992 int statbuf;
3993
3994 // On Linux like systems, the configdir defaults to $HOME/.wolf4sdl
3995#if !defined(_WIN32) && !defined(_arch_dreamcast)
3996 if(configdir[0] == 0)
3997 {
3998 // Set config location to home directory for multi-user support
3999 char *homedir = "/";
4000 if(homedir == NULL)
4001 {
4002 Quit("Your $HOME directory is not defined. You must set this before playing.");
4003 }
4004 #define WOLFDIR "/.wolf4sdl"
4005 if(strlen(homedir) + sizeof(WOLFDIR) > sizeof(configdir))
4006 {
4007 Quit("Your $HOME directory path is too long. It cannot be used for saving games.");
4008 }
4009 snprintf(configdir, sizeof(configdir), "%s" WOLFDIR, homedir);
4010 }
4011#endif
4012
4013 if(configdir[0] != 0)
4014 {
4015 // Ensure config directory exists and create if necessary
4016 if(stat(configdir, &statbuf) != 0)
4017 {
4018#ifdef _WIN32
4019 if(_mkdir(configdir) != 0)
4020#else
4021 if(mkdir(configdir) != 0)
4022#endif
4023 {
4024 Quit("The configuration directory \"%s\" could not be created.", configdir);
4025 }
4026 }
4027 }
4028
4029//
4030// JAPANESE VERSION
4031//
4032#ifdef JAPAN
4033#ifdef JAPDEMO
4034 if(!stat(DATADIR "vswap.wj1", &statbuf))
4035 {
4036 strcpy (extension, "wj1");
4037 numEpisodesMissing = 5;
4038#else
4039 if(!stat(DATADIR "vswap.wj6", &statbuf))
4040 {
4041 strcpy (extension, "wj6");
4042#endif
4043 strcat (configname, extension);
4044 strcat (SaveName, extension);
4045 strcat (demoname, extension);
4046 EpisodeSelect[1] =
4047 EpisodeSelect[2] = EpisodeSelect[3] = EpisodeSelect[4] = EpisodeSelect[5] = 1;
4048 }
4049 else
4050 Quit ("NO JAPANESE WOLFENSTEIN 3-D DATA FILES to be found!");
4051#else
4052
4053//
4054// ENGLISH
4055//
4056#ifdef UPLOAD
4057 if(!stat(DATADIR "vswap.wl1", &statbuf))
4058 {
4059 strcpy (extension, "wl1");
4060 numEpisodesMissing = 5;
4061 }
4062 else
4063 Quit ("NO WOLFENSTEIN 3-D DATA FILES to be found! %s", DATADIR"vswap.wl1");
4064#else
4065#ifndef SPEAR
4066 if(!stat(DATADIR "vswap.wl6", &statbuf))
4067 {
4068 strcpy (extension, "wl6");
4069 NewEmenu[2].active =
4070 NewEmenu[4].active =
4071 NewEmenu[6].active =
4072 NewEmenu[8].active =
4073 NewEmenu[10].active =
4074 EpisodeSelect[1] =
4075 EpisodeSelect[2] = EpisodeSelect[3] = EpisodeSelect[4] = EpisodeSelect[5] = 1;
4076 }
4077 else
4078 {
4079 if(!stat(DATADIR "vswap.wl3", &statbuf))
4080 {
4081 strcpy (extension, "wl3");
4082 numEpisodesMissing = 3;
4083 NewEmenu[2].active = NewEmenu[4].active = EpisodeSelect[1] = EpisodeSelect[2] = 1;
4084 }
4085 else
4086 {
4087 if(!stat(DATADIR "vswap.wl1", &statbuf))
4088 {
4089 strcpy (extension, "wl1");
4090 numEpisodesMissing = 5;
4091 }
4092 else
4093 Quit ("NO WOLFENSTEIN 3-D DATA FILES to be found!"DATADIR"vswap.wl[6,3,1]");
4094 }
4095 }
4096#endif
4097#endif
4098
4099
4100#ifdef SPEAR
4101#ifndef SPEARDEMO
4102 if(param_mission == 0)
4103 {
4104 if(!stat(DATADIR "vswap.sod", &statbuf))
4105 strcpy (extension, "sod");
4106 else
4107 Quit ("NO SPEAR OF DESTINY DATA FILES TO BE FOUND!");
4108 }
4109 else if(param_mission == 1)
4110 {
4111 if(!stat(DATADIR "vswap.sd1", &statbuf))
4112 strcpy (extension, "sd1");
4113 else
4114 Quit ("NO SPEAR OF DESTINY DATA FILES TO BE FOUND!");
4115 }
4116 else if(param_mission == 2)
4117 {
4118 if(!stat(DATADIR "vswap.sd2", &statbuf))
4119 strcpy (extension, "sd2");
4120 else
4121 Quit ("NO SPEAR OF DESTINY DATA FILES TO BE FOUND!");
4122 }
4123 else if(param_mission == 3)
4124 {
4125 if(!stat(DATADIR "vswap.sd3", &statbuf))
4126 strcpy (extension, "sd3");
4127 else
4128 Quit ("NO SPEAR OF DESTINY DATA FILES TO BE FOUND!");
4129 }
4130 else
4131 Quit ("UNSUPPORTED MISSION!");
4132 strcpy (graphext, "sod");
4133 strcpy (audioext, "sod");
4134#else
4135 if(!stat(DATADIR "vswap.sdm", &statbuf))
4136 {
4137 strcpy (extension, "sdm");
4138 }
4139 else
4140 Quit ("NO SPEAR OF DESTINY DEMO DATA FILES TO BE FOUND!");
4141 strcpy (graphext, "sdm");
4142 strcpy (audioext, "sdm");
4143#endif
4144#else
4145 strcpy (graphext, extension);
4146 strcpy (audioext, extension);
4147#endif
4148
4149 strcat (configname, extension);
4150 strcat (SaveName, extension);
4151 strcat (demoname, extension);
4152
4153#ifndef SPEAR
4154#ifndef GOODTIMES
4155 strcat (helpfilename, extension);
4156#endif
4157 strcat (endfilename, extension);
4158#endif
4159#endif
4160}