]> 4ch.mooo.com Git - 16.git/blob - src/core/wl_menu.c
cannot do more
[16.git] / src / core / wl_menu.c
1 ////////////////////////////////////////////////////////////////////\r
2 //\r
3 // WL_MENU.C\r
4 // by John Romero (C) 1992 Id Software, Inc.\r
5 //\r
6 ////////////////////////////////////////////////////////////////////\r
7 #include "wl_def.h"\r
8 #pragma hdrstop\r
9 \r
10 //\r
11 // PRIVATE PROTOTYPES\r
12 //\r
13 void CP_ReadThis(void);\r
14 \r
15 #ifdef SPEAR\r
16 #define STARTITEM       newgame\r
17 \r
18 #else\r
19 #ifdef GOODTIMES\r
20 #define STARTITEM       newgame\r
21 \r
22 #else\r
23 #define STARTITEM       readthis\r
24 #endif\r
25 #endif\r
26 \r
27 char far endStrings[9][80]=\r
28 {\r
29 #ifndef SPEAR\r
30         {"Dost thou wish to\nleave with such hasty\nabandon?"},\r
31         {"Chickening out...\nalready?"},\r
32         {"Press N for more carnage.\nPress Y to be a weenie."},\r
33         {"So, you think you can\nquit this easily, huh?"},\r
34         {"Press N to save the world.\nPress Y to abandon it in\nits hour of need."},\r
35         {"Press N if you are brave.\nPress Y to cower in shame."},\r
36         {"Heroes, press N.\nWimps, press Y."},\r
37         {"You are at an intersection.\nA sign says, 'Press Y to quit.'\n>"},\r
38         {"For guns and glory, press N.\nFor work and worry, press Y."}\r
39 #else\r
40         ENDSTR1,\r
41         ENDSTR2,\r
42         ENDSTR3,\r
43         ENDSTR4,\r
44         ENDSTR5,\r
45         ENDSTR6,\r
46         ENDSTR7,\r
47         ENDSTR8,\r
48         ENDSTR9\r
49 #endif\r
50 };\r
51 \r
52 CP_iteminfo\r
53         MainItems={MENU_X,MENU_Y,10,STARTITEM,24},\r
54         SndItems={SM_X,SM_Y1,12,0,52},\r
55         LSItems={LSM_X,LSM_Y,10,0,24},\r
56         CtlItems={CTL_X,CTL_Y,6,-1,56},\r
57         CusItems={8,CST_Y+13*2,9,-1,0},\r
58         NewEitems={NE_X,NE_Y,11,0,88},\r
59         NewItems={NM_X,NM_Y,4,2,24};\r
60 \r
61 #pragma warn -sus\r
62 CP_itemtype far\r
63 MainMenu[]=\r
64 {\r
65 #ifdef JAPAN\r
66         {1,"",CP_NewGame},\r
67         {1,"",CP_Sound},\r
68         {1,"",CP_Control},\r
69         {1,"",CP_LoadGame},\r
70         {0,"",CP_SaveGame},\r
71         {1,"",CP_ChangeView},\r
72         {2,"",CP_ReadThis},\r
73         {1,"",CP_ViewScores},\r
74         {1,"",0},\r
75         {1,"",0}\r
76 #else\r
77 \r
78         {1,STR_NG,CP_NewGame},\r
79         {1,STR_SD,CP_Sound},\r
80         {1,STR_CL,CP_Control},\r
81         {1,STR_LG,CP_LoadGame},\r
82         {0,STR_SG,CP_SaveGame},\r
83         {1,STR_CV,CP_ChangeView},\r
84 \r
85 #ifndef GOODTIMES\r
86 #ifndef SPEAR\r
87 \r
88         #ifdef SPANISH\r
89         {2,"Ve esto!",CP_ReadThis},\r
90         #else\r
91         {2,"Read This!",CP_ReadThis},\r
92         #endif\r
93 \r
94 #endif\r
95 #endif\r
96 \r
97         {1,STR_VS,CP_ViewScores},\r
98         {1,STR_BD,0},\r
99         {1,STR_QT,0}\r
100 #endif\r
101 },\r
102 \r
103 far SndMenu[]=\r
104 {\r
105 #ifdef JAPAN\r
106         {1,"",0},\r
107         {1,"",0},\r
108         {1,"",0},\r
109         {0,"",0},\r
110         {0,"",0},\r
111         {1,"",0},\r
112         {1,"",0},\r
113         {1,"",0},\r
114         {0,"",0},\r
115         {0,"",0},\r
116         {1,"",0},\r
117         {1,"",0},\r
118 #else\r
119         {1,STR_NONE,0},\r
120         {1,STR_PC,0},\r
121         {1,STR_ALSB,0},\r
122         {0,"",0},\r
123         {0,"",0},\r
124         {1,STR_NONE,0},\r
125         {1,STR_DISNEY,0},\r
126         {1,STR_SB,0},\r
127         {0,"",0},\r
128         {0,"",0},\r
129         {1,STR_NONE,0},\r
130         {1,STR_ALSB,0}\r
131 #endif\r
132 },\r
133 \r
134 far CtlMenu[]=\r
135 {\r
136 #ifdef JAPAN\r
137         {0,"",0},\r
138         {0,"",0},\r
139         {0,"",0},\r
140         {0,"",0},\r
141         {0,"",MouseSensitivity},\r
142         {1,"",CustomControls}\r
143 #else\r
144         {0,STR_MOUSEEN,0},\r
145         {0,STR_JOYEN,0},\r
146         {0,STR_PORT2,0},\r
147         {0,STR_GAMEPAD,0},\r
148         {0,STR_SENS,MouseSensitivity},\r
149         {1,STR_CUSTOM,CustomControls}\r
150 #endif\r
151 },\r
152 \r
153 #pragma warn +sus\r
154 \r
155 #ifndef SPEAR\r
156 far NewEmenu[]=\r
157 {\r
158 #ifdef JAPAN\r
159 #ifdef JAPDEMO\r
160         {1,"",0},\r
161         {0,"",0},\r
162         {0,"",0},\r
163         {0,"",0},\r
164         {0,"",0},\r
165         {0,"",0},\r
166         {0,"",0},\r
167         {0,"",0},\r
168         {0,"",0},\r
169         {0,"",0},\r
170         {0,"",0},\r
171         {0,"",0},\r
172 #else\r
173         {1,"",0},\r
174         {0,"",0},\r
175         {1,"",0},\r
176         {0,"",0},\r
177         {1,"",0},\r
178         {0,"",0},\r
179         {1,"",0},\r
180         {0,"",0},\r
181         {1,"",0},\r
182         {0,"",0},\r
183         {1,"",0},\r
184         {0,"",0}\r
185 #endif\r
186 #else\r
187         #ifdef SPANISH\r
188         {1,"Episodio 1\n"\r
189            "Fuga desde Wolfenstein",0},\r
190         {0,"",0},\r
191         {3,"Episodio 2\n"\r
192                    "Operacion Eisenfaust",0},\r
193         {0,"",0},\r
194         {3,"Episodio 3\n"\r
195                    "Muere, Fuhrer, Muere!",0},\r
196         {0,"",0},\r
197         {3,"Episodio 4\n"\r
198                   "Un Negro Secreto",0},\r
199         {0,"",0},\r
200         {3,"Episodio 5\n"\r
201                   "Huellas del Loco",0},\r
202         {0,"",0},\r
203         {3,"Episodio 6\n"\r
204                   "Confrontacion",0}\r
205         #else\r
206         {1,"Episode 1\n"\r
207            "Escape from Wolfenstein",0},\r
208         {0,"",0},\r
209         {3,"Episode 2\n"\r
210                    "Operation: Eisenfaust",0},\r
211         {0,"",0},\r
212         {3,"Episode 3\n"\r
213                    "Die, Fuhrer, Die!",0},\r
214         {0,"",0},\r
215         {3,"Episode 4\n"\r
216                   "A Dark Secret",0},\r
217         {0,"",0},\r
218         {3,"Episode 5\n"\r
219                   "Trail of the Madman",0},\r
220         {0,"",0},\r
221         {3,"Episode 6\n"\r
222                   "Confrontation",0}\r
223         #endif\r
224 #endif\r
225 },\r
226 #endif\r
227 \r
228 \r
229 far NewMenu[]=\r
230 {\r
231 #ifdef JAPAN\r
232         {1,"",0},\r
233         {1,"",0},\r
234         {1,"",0},\r
235         {1,"",0}\r
236 #else\r
237         {1,STR_DADDY,0},\r
238         {1,STR_HURTME,0},\r
239         {1,STR_BRINGEM,0},\r
240         {1,STR_DEATH,0}\r
241 #endif\r
242 },\r
243 \r
244 far LSMenu[]=\r
245 {\r
246         {1,"",0},\r
247         {1,"",0},\r
248         {1,"",0},\r
249         {1,"",0},\r
250         {1,"",0},\r
251         {1,"",0},\r
252         {1,"",0},\r
253         {1,"",0},\r
254         {1,"",0},\r
255         {1,"",0}\r
256 },\r
257 \r
258 far CusMenu[]=\r
259 {\r
260         {1,"",0},\r
261         {0,"",0},\r
262         {0,"",0},\r
263         {1,"",0},\r
264         {0,"",0},\r
265         {0,"",0},\r
266         {1,"",0},\r
267         {0,"",0},\r
268         {1,"",0}\r
269 }\r
270 ;\r
271 \r
272 \r
273 int color_hlite[]={\r
274    DEACTIVE,\r
275    HIGHLIGHT,\r
276    READHCOLOR,\r
277    0x67\r
278    },\r
279 \r
280    color_norml[]={\r
281    DEACTIVE,\r
282    TEXTCOLOR,\r
283    READCOLOR,\r
284    0x6b\r
285    };\r
286 \r
287 int EpisodeSelect[6]={1};\r
288 \r
289 \r
290 int SaveGamesAvail[10],StartGame,SoundStatus=1,pickquick;\r
291 char SaveGameNames[10][32],SaveName[13]="SAVEGAM?.";\r
292 \r
293 \r
294 ////////////////////////////////////////////////////////////////////\r
295 //\r
296 // INPUT MANAGER SCANCODE TABLES\r
297 //\r
298 ////////////////////////////////////////////////////////////////////\r
299 static byte\r
300                                         *ScanNames[] =          // Scan code names with single chars\r
301                                         {\r
302         "?","?","1","2","3","4","5","6","7","8","9","0","-","+","?","?",\r
303         "Q","W","E","R","T","Y","U","I","O","P","[","]","|","?","A","S",\r
304         "D","F","G","H","J","K","L",";","\"","?","?","?","Z","X","C","V",\r
305         "B","N","M",",",".","/","?","?","?","?","?","?","?","?","?","?",\r
306         "?","?","?","?","?","?","?","?","\xf","?","-","\x15","5","\x11","+","?",\r
307         "\x13","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?",\r
308         "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?",\r
309         "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?"\r
310                                         },      // DEBUG - consolidate these\r
311                                         far ExtScanCodes[] =    // Scan codes with >1 char names\r
312                                         {\r
313         1,0xe,0xf,0x1d,0x2a,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,\r
314         0x3f,0x40,0x41,0x42,0x43,0x44,0x57,0x59,0x46,0x1c,0x36,\r
315         0x37,0x38,0x47,0x49,0x4f,0x51,0x52,0x53,0x45,0x48,\r
316         0x50,0x4b,0x4d,0x00\r
317                                         },\r
318                                         *ExtScanNames[] =       // Names corresponding to ExtScanCodes\r
319                                         {\r
320         "Esc","BkSp","Tab","Ctrl","LShft","Space","CapsLk","F1","F2","F3","F4",\r
321         "F5","F6","F7","F8","F9","F10","F11","F12","ScrlLk","Enter","RShft",\r
322         "PrtSc","Alt","Home","PgUp","End","PgDn","Ins","Del","NumLk","Up",\r
323         "Down","Left","Right",""\r
324                                         };\r
325 \r
326 \r
327 ////////////////////////////////////////////////////////////////////\r
328 //\r
329 // Wolfenstein Control Panel!  Ta Da!\r
330 //\r
331 ////////////////////////////////////////////////////////////////////\r
332 void US_ControlPanel(byte scancode)\r
333 {\r
334         int which,i,start;\r
335 \r
336 \r
337         if (ingame)\r
338                 if (CP_CheckQuick(scancode))\r
339                         return;\r
340 \r
341         StartCPMusic(MENUSONG);\r
342         SetupControlPanel();\r
343 \r
344         //\r
345         // F-KEYS FROM WITHIN GAME\r
346         //\r
347         switch(scancode)\r
348         {\r
349                 case sc_F1:\r
350                         #ifdef SPEAR\r
351                         BossKey();\r
352                         #else\r
353                         #ifdef GOODTIMES\r
354                         BossKey();\r
355                         #else\r
356                         HelpScreens();\r
357                         #endif\r
358                         #endif\r
359                         goto finishup;\r
360 \r
361                 case sc_F2:\r
362                         CP_SaveGame(0);\r
363                         goto finishup;\r
364 \r
365                 case sc_F3:\r
366                         CP_LoadGame(0);\r
367                         goto finishup;\r
368 \r
369                 case sc_F4:\r
370                         CP_Sound();\r
371                         goto finishup;\r
372 \r
373                 case sc_F5:\r
374                         CP_ChangeView();\r
375                         goto finishup;\r
376 \r
377                 case sc_F6:\r
378                         CP_Control();\r
379                         goto finishup;\r
380 \r
381                 finishup:\r
382                         CleanupControlPanel();\r
383                         #ifdef SPEAR\r
384                         UnCacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
385                         #endif\r
386                         return;\r
387         }\r
388 \r
389 #ifdef SPEAR\r
390         CacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
391 #endif\r
392 \r
393         DrawMainMenu();\r
394         MenuFadeIn();\r
395         StartGame=0;\r
396 \r
397         //\r
398         // MAIN MENU LOOP\r
399         //\r
400         do\r
401         {\r
402                 which=HandleMenu(&MainItems,&MainMenu[0],NULL);\r
403 \r
404                 #ifdef SPEAR\r
405                 #ifndef SPEARDEMO\r
406                 //\r
407                 // EASTER EGG FOR SPEAR OF DESTINY!\r
408                 //\r
409                 if (Keyboard[sc_I] && Keyboard[sc_D])\r
410                 {\r
411                         VW_FadeOut();\r
412                         StartCPMusic (XJAZNAZI_MUS);\r
413                         UnCacheLump(OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
414                         UnCacheLump(BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
415                         MM_SortMem ();\r
416                         ClearMemory ();\r
417 \r
418 \r
419                         CA_CacheGrChunk (IDGUYS1PIC);\r
420                         VWB_DrawPic(0,0,IDGUYS1PIC);\r
421                         UNCACHEGRCHUNK(IDGUYS1PIC);\r
422 \r
423                         CA_CacheGrChunk (IDGUYS2PIC);\r
424                         VWB_DrawPic(0,80,IDGUYS2PIC);\r
425                         UNCACHEGRCHUNK(IDGUYS2PIC);\r
426 \r
427                         VW_UpdateScreen();\r
428 \r
429                         CA_CacheGrChunk (IDGUYSPALETTE);\r
430                         VL_FadeIn(0,255,grsegs[IDGUYSPALETTE],30);\r
431                         UNCACHEGRCHUNK(IDGUYSPALETTE);\r
432 \r
433                         while (Keyboard[sc_I] || Keyboard[sc_D]);\r
434                         IN_ClearKeysDown();\r
435                         IN_Ack();\r
436 \r
437                         VW_FadeOut();\r
438 \r
439                         CacheLump(BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
440                         CacheLump(OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
441                         DrawMainMenu();\r
442                         StartCPMusic (MENUSONG);\r
443                         MenuFadeIn();\r
444                 }\r
445                 #endif\r
446                 #endif\r
447 \r
448                 switch(which)\r
449                 {\r
450                         case viewscores:\r
451                                 if (MainMenu[viewscores].routine == NULL)\r
452                                         if (CP_EndGame())\r
453                                                 StartGame=1;\r
454 \r
455                                 DrawMainMenu();\r
456                                 MenuFadeIn();\r
457                                 break;\r
458 \r
459                         case backtodemo:\r
460                                 #ifdef SPEAR\r
461                                 if (!ingame)\r
462                                 {\r
463                                         //\r
464                                         // DEALLOCATE ALL SOUNDS!\r
465                                         //\r
466                                         switch (SoundMode)\r
467                                         {\r
468                                                 case sdm_PC:\r
469                                                         start = STARTPCSOUNDS;\r
470                                                         break;\r
471                                                 case sdm_AdLib:\r
472                                                         start = STARTADLIBSOUNDS;\r
473                                                         break;\r
474                                         }\r
475 \r
476                                         if (SoundMode != sdm_Off)\r
477                                                 for (i=0;i<NUMSOUNDS;i++,start++)\r
478                                                         if (audiosegs[start])\r
479                                                                 MM_SetPurge (&(memptr)audiosegs[start],3);              // make purgable\r
480                                 }\r
481                                 #endif\r
482 \r
483                                 MM_SortMem();\r
484                                 StartGame=1;\r
485                                 if (!ingame)\r
486                                         StartCPMusic(INTROSONG);\r
487                                 VL_FadeOut(0,255,0,0,0,10);\r
488                                 break;\r
489 \r
490                         case -1:\r
491                         case quit:\r
492                                 CP_Quit();\r
493                                 break;\r
494 \r
495                         default:\r
496                                 if (!StartGame)\r
497                                 {\r
498                                         DrawMainMenu();\r
499                                         MenuFadeIn();\r
500                                 }\r
501                 }\r
502 \r
503         //\r
504         // "EXIT OPTIONS" OR "NEW GAME" EXITS\r
505         //\r
506         } while(!StartGame);\r
507 \r
508         //\r
509         // DEALLOCATE EVERYTHING\r
510         //\r
511         CleanupControlPanel();\r
512 \r
513         //\r
514         // CHANGE MAINMENU ITEM\r
515         //\r
516         if (startgame || loadedgame)\r
517         {\r
518                 #pragma warn -sus\r
519                 MainMenu[viewscores].routine = NULL;\r
520                 #ifndef JAPAN\r
521                 _fstrcpy(MainMenu[viewscores].string,STR_EG);\r
522                 #endif\r
523                 #pragma warn +sus\r
524         }\r
525 \r
526         // RETURN/START GAME EXECUTION\r
527 \r
528 #ifdef SPEAR\r
529         UnCacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
530         MM_SortMem ();\r
531 #endif\r
532 }\r
533 \r
534 \r
535 ////////////////////////\r
536 //\r
537 // DRAW MAIN MENU SCREEN\r
538 //\r
539 void DrawMainMenu(void)\r
540 {\r
541 #ifdef JAPAN\r
542         CA_CacheScreen(S_OPTIONSPIC);\r
543 #else\r
544         ClearMScreen();\r
545 \r
546         VWB_DrawPic(112,184,C_MOUSELBACKPIC);\r
547         DrawStripes(10);\r
548         VWB_DrawPic(84,0,C_OPTIONSPIC);\r
549 \r
550         #ifdef SPANISH\r
551         DrawWindow(MENU_X-8,MENU_Y-3,MENU_W+8,MENU_H,BKGDCOLOR);\r
552         #else\r
553         DrawWindow(MENU_X-8,MENU_Y-3,MENU_W,MENU_H,BKGDCOLOR);\r
554         #endif\r
555 #endif\r
556 \r
557         //\r
558         // CHANGE "GAME" AND "DEMO"\r
559         //\r
560         if (ingame)\r
561         {\r
562                 #ifndef JAPAN\r
563 \r
564                 #ifdef SPANISH\r
565                 _fstrcpy(&MainMenu[backtodemo].string,STR_GAME);\r
566                 #else\r
567                 _fstrcpy(&MainMenu[backtodemo].string[8],STR_GAME);\r
568                 #endif\r
569 \r
570                 #else\r
571                 CA_CacheGrChunk(C_MRETGAMEPIC);\r
572                 VWB_DrawPic(12*8,20*8,C_MRETGAMEPIC);\r
573                 UNCACHEGRCHUNK(C_MRETGAMEPIC);\r
574                 CA_CacheGrChunk(C_MENDGAMEPIC);\r
575                 VWB_DrawPic(12*8,18*8,C_MENDGAMEPIC);\r
576                 UNCACHEGRCHUNK(C_MENDGAMEPIC);\r
577                 #endif\r
578                 MainMenu[backtodemo].active=2;\r
579         }\r
580         else\r
581         {\r
582                 #ifndef JAPAN\r
583                 #ifdef SPANISH\r
584                 _fstrcpy(&MainMenu[backtodemo].string,STR_BD);\r
585                 #else\r
586                 _fstrcpy(&MainMenu[backtodemo].string[8],STR_DEMO);\r
587                 #endif\r
588                 #else\r
589                 CA_CacheGrChunk(C_MRETDEMOPIC);\r
590                 VWB_DrawPic(12*8,20*8,C_MRETDEMOPIC);\r
591                 UNCACHEGRCHUNK(C_MRETDEMOPIC);\r
592                 CA_CacheGrChunk(C_MSCORESPIC);\r
593                 VWB_DrawPic(12*8,18*8,C_MSCORESPIC);\r
594                 UNCACHEGRCHUNK(C_MSCORESPIC);\r
595                 #endif\r
596                 MainMenu[backtodemo].active=1;\r
597         }\r
598 \r
599         DrawMenu(&MainItems,&MainMenu[0]);\r
600         VW_UpdateScreen();\r
601 }\r
602 \r
603 #ifndef GOODTIMES\r
604 #ifndef SPEAR\r
605 ////////////////////////////////////////////////////////////////////\r
606 //\r
607 // READ THIS!\r
608 //\r
609 ////////////////////////////////////////////////////////////////////\r
610 void CP_ReadThis(void)\r
611 {\r
612         StartCPMusic(CORNER_MUS);\r
613         HelpScreens();\r
614         StartCPMusic(MENUSONG);\r
615 }\r
616 #endif\r
617 #endif\r
618 \r
619 #ifndef SPEAR\r
620 #ifndef GOODTIMES\r
621 #else\r
622 ////////////////////////////////////////////////////////////////////\r
623 //\r
624 // BOSS KEY\r
625 //\r
626 ////////////////////////////////////////////////////////////////////\r
627 void BossKey(void)\r
628 {\r
629         SD_MusicOff();\r
630         _AX = 3;\r
631         geninterrupt(0x10);\r
632         printf("C>");\r
633         while (!Keyboard[sc_Escape])\r
634         IN_ClearKeysDown();\r
635 \r
636         SD_MusicOn();\r
637         VL_SetVGAPlaneMode ();\r
638         VL_TestPaletteSet ();\r
639         VL_SetPalette (&gamepal);\r
640         LoadLatchMem();\r
641 }\r
642 #endif\r
643 #endif\r
644 \r
645 ////////////////////////////////////////////////////////////////////\r
646 //\r
647 // CHECK QUICK-KEYS & QUIT (WHILE IN A GAME)\r
648 //\r
649 ////////////////////////////////////////////////////////////////////\r
650 int CP_CheckQuick(unsigned scancode)\r
651 {\r
652         switch(scancode)\r
653         {\r
654                 //\r
655                 // END GAME\r
656                 //\r
657                 case sc_F7:\r
658                         CA_CacheGrChunk(STARTFONT+1);\r
659 \r
660                         WindowH=160;\r
661                         #ifdef JAPAN\r
662                         if (GetYorN(7,8,C_JAPQUITPIC))\r
663                         #else\r
664                         if (Confirm(ENDGAMESTR))\r
665                         #endif\r
666                         {\r
667                                 playstate = ex_died;\r
668                                 pickquick = gamestate.lives = 0;\r
669                         }\r
670 \r
671                         DrawAllPlayBorder();\r
672                         WindowH=200;\r
673                         fontnumber=0;\r
674                         MainMenu[savegame].active = 0;\r
675                         return 1;\r
676 \r
677                 //\r
678                 // QUICKSAVE\r
679                 //\r
680                 case sc_F8:\r
681                         if (SaveGamesAvail[LSItems.curpos] && pickquick)\r
682                         {\r
683                                 CA_CacheGrChunk(STARTFONT+1);\r
684                                 fontnumber = 1;\r
685                                 Message(STR_SAVING"...");\r
686                                 CP_SaveGame(1);\r
687                                 fontnumber=0;\r
688                         }\r
689                         else\r
690                         {\r
691                                 #ifndef SPEAR\r
692                                 CA_CacheGrChunk(STARTFONT+1);\r
693                                 CA_CacheGrChunk(C_CURSOR1PIC);\r
694                                 CA_CacheGrChunk(C_CURSOR2PIC);\r
695                                 CA_CacheGrChunk(C_DISKLOADING1PIC);\r
696                                 CA_CacheGrChunk(C_DISKLOADING2PIC);\r
697                                 CA_CacheGrChunk(C_SAVEGAMEPIC);\r
698                                 CA_CacheGrChunk(C_MOUSELBACKPIC);\r
699                                 #else\r
700                                 CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
701                                 CA_CacheGrChunk(C_CURSOR1PIC);\r
702                                 #endif\r
703 \r
704                                 VW_FadeOut ();\r
705 \r
706                                 StartCPMusic(MENUSONG);\r
707                                 pickquick=CP_SaveGame(0);\r
708 \r
709                                 SETFONTCOLOR(0,15);\r
710                                 IN_ClearKeysDown();\r
711                                 DrawPlayScreen ();\r
712 \r
713                                 if (!startgame && !loadedgame)\r
714                                 {\r
715                                         VW_FadeIn ();\r
716                                         StartMusic ();\r
717                                 }\r
718 \r
719                                 if (loadedgame)\r
720                                         playstate = ex_abort;\r
721                                 lasttimecount = TimeCount;\r
722 \r
723                                 if (MousePresent)\r
724                                         Mouse(MDelta);  // Clear accumulated mouse movement\r
725 \r
726                                 PM_CheckMainMem ();\r
727 \r
728                                 #ifndef SPEAR\r
729                                 UNCACHEGRCHUNK(C_CURSOR1PIC);\r
730                                 UNCACHEGRCHUNK(C_CURSOR2PIC);\r
731                                 UNCACHEGRCHUNK(C_DISKLOADING1PIC);\r
732                                 UNCACHEGRCHUNK(C_DISKLOADING2PIC);\r
733                                 UNCACHEGRCHUNK(C_SAVEGAMEPIC);\r
734                                 UNCACHEGRCHUNK(C_MOUSELBACKPIC);\r
735                                 #else\r
736                                 UnCacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
737                                 #endif\r
738                         }\r
739                         return 1;\r
740 \r
741                 //\r
742                 // QUICKLOAD\r
743                 //\r
744                 case sc_F9:\r
745                         if (SaveGamesAvail[LSItems.curpos] && pickquick)\r
746                         {\r
747                                 char string[100]=STR_LGC;\r
748 \r
749 \r
750                                 CA_CacheGrChunk(STARTFONT+1);\r
751                                 fontnumber = 1;\r
752 \r
753                                 strcat(string,SaveGameNames[LSItems.curpos]);\r
754                                 strcat(string,"\"?");\r
755 \r
756                                 if (Confirm(string))\r
757                                         CP_LoadGame(1);\r
758 \r
759                                 DrawAllPlayBorder();\r
760                                 fontnumber=0;\r
761                         }\r
762                         else\r
763                         {\r
764                                 #ifndef SPEAR\r
765                                 CA_CacheGrChunk(STARTFONT+1);\r
766                                 CA_CacheGrChunk(C_CURSOR1PIC);\r
767                                 CA_CacheGrChunk(C_CURSOR2PIC);\r
768                                 CA_CacheGrChunk(C_DISKLOADING1PIC);\r
769                                 CA_CacheGrChunk(C_DISKLOADING2PIC);\r
770                                 CA_CacheGrChunk(C_LOADGAMEPIC);\r
771                                 CA_CacheGrChunk(C_MOUSELBACKPIC);\r
772                                 #else\r
773                                 CA_CacheGrChunk(C_CURSOR1PIC);\r
774                                 CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
775                                 #endif\r
776 \r
777                                 VW_FadeOut ();\r
778 \r
779                                 StartCPMusic(MENUSONG);\r
780                                 pickquick=CP_LoadGame(0);\r
781 \r
782                                 SETFONTCOLOR(0,15);\r
783                                 IN_ClearKeysDown();\r
784                                 DrawPlayScreen ();\r
785 \r
786                                 if (!startgame && !loadedgame)\r
787                                 {\r
788                                         VW_FadeIn ();\r
789                                         StartMusic ();\r
790                                 }\r
791 \r
792                                 if (loadedgame)\r
793                                         playstate = ex_abort;\r
794 \r
795                                 lasttimecount = TimeCount;\r
796 \r
797                                 if (MousePresent)\r
798                                         Mouse(MDelta);  // Clear accumulated mouse movement\r
799                                 PM_CheckMainMem ();\r
800 \r
801                                 #ifndef SPEAR\r
802                                 UNCACHEGRCHUNK(C_CURSOR1PIC);\r
803                                 UNCACHEGRCHUNK(C_CURSOR2PIC);\r
804                                 UNCACHEGRCHUNK(C_DISKLOADING1PIC);\r
805                                 UNCACHEGRCHUNK(C_DISKLOADING2PIC);\r
806                                 UNCACHEGRCHUNK(C_LOADGAMEPIC);\r
807                                 UNCACHEGRCHUNK(C_MOUSELBACKPIC);\r
808                                 #else\r
809                                 UnCacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
810                                 #endif\r
811                         }\r
812                         return 1;\r
813 \r
814                 //\r
815                 // QUIT\r
816                 //\r
817                 case sc_F10:\r
818                         CA_CacheGrChunk(STARTFONT+1);\r
819 \r
820                         WindowX=WindowY=0;\r
821                         WindowW=320;\r
822                         WindowH=160;\r
823                         #ifdef JAPAN\r
824                         if (GetYorN(7,8,C_QUITMSGPIC))\r
825                         #else\r
826                                 #ifdef SPANISH\r
827                         if (Confirm(ENDGAMESTR))\r
828                                 #else\r
829                         if (Confirm(endStrings[US_RndT()&0x7+(US_RndT()&1)]))\r
830                                 #endif\r
831                         #endif\r
832                         {\r
833                                 int i;\r
834 \r
835 \r
836                                 VW_UpdateScreen();\r
837                                 SD_MusicOff();\r
838                                 SD_StopSound();\r
839                                 MenuFadeOut();\r
840 \r
841                                 //\r
842                                 // SHUT-UP THE ADLIB\r
843                                 //\r
844                                 for (i=1;i<=0xf5;i++)\r
845                                         alOut(i,0);\r
846                                 Quit(NULL);\r
847                         }\r
848 \r
849                         DrawAllPlayBorder();\r
850                         WindowH=200;\r
851                         fontnumber=0;\r
852                         return 1;\r
853                 }\r
854 \r
855         return 0;\r
856 }\r
857 \r
858 \r
859 ////////////////////////////////////////////////////////////////////\r
860 //\r
861 // END THE CURRENT GAME\r
862 //\r
863 ////////////////////////////////////////////////////////////////////\r
864 int CP_EndGame(void)\r
865 {\r
866 #ifdef JAPAN\r
867         if (!GetYorN(7,8,C_JAPQUITPIC))\r
868 #else\r
869         if (!Confirm(ENDGAMESTR))\r
870 #endif\r
871                 return 0;\r
872 \r
873         pickquick = gamestate.lives = 0;\r
874         playstate = ex_died;\r
875 \r
876         #pragma warn -sus\r
877         MainMenu[savegame].active = 0;\r
878         MainMenu[viewscores].routine=CP_ViewScores;\r
879         #ifndef JAPAN\r
880         _fstrcpy(MainMenu[viewscores].string,STR_VS);\r
881         #endif\r
882         #pragma warn +sus\r
883 \r
884         return 1;\r
885 }\r
886 \r
887 \r
888 ////////////////////////////////////////////////////////////////////\r
889 //\r
890 // VIEW THE HIGH SCORES\r
891 //\r
892 ////////////////////////////////////////////////////////////////////\r
893 void CP_ViewScores(void)\r
894 {\r
895         fontnumber=0;\r
896 \r
897 #ifdef SPEAR\r
898         UnCacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
899         StartCPMusic (XAWARD_MUS);\r
900 #else\r
901         StartCPMusic (ROSTER_MUS);\r
902 #endif\r
903 \r
904         DrawHighScores ();\r
905         VW_UpdateScreen ();\r
906         MenuFadeIn();\r
907         fontnumber=1;\r
908 \r
909         IN_Ack();\r
910 \r
911         StartCPMusic(MENUSONG);\r
912         MenuFadeOut();\r
913 \r
914 #ifdef SPEAR\r
915         CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
916         CacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
917 #endif\r
918 }\r
919 \r
920 \r
921 ////////////////////////////////////////////////////////////////////\r
922 //\r
923 // START A NEW GAME\r
924 //\r
925 ////////////////////////////////////////////////////////////////////\r
926 void CP_NewGame(void)\r
927 {\r
928         int which,episode;\r
929 \r
930 #ifdef SPEAR\r
931         UnCacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
932 #endif\r
933 \r
934 \r
935 #ifndef SPEAR\r
936 firstpart:\r
937 \r
938         DrawNewEpisode();\r
939         do\r
940         {\r
941                 which=HandleMenu(&NewEitems,&NewEmenu[0],NULL);\r
942                 switch(which)\r
943                 {\r
944                         case -1:\r
945                                 MenuFadeOut();\r
946                                 return;\r
947 \r
948                         default:\r
949                                 if (!EpisodeSelect[which/2])\r
950                                 {\r
951                                         SD_PlaySound (NOWAYSND);\r
952                                         Message("Please select \"Read This!\"\n"\r
953                                                         "from the Options menu to\n"\r
954                                                         "find out how to order this\n"\r
955                                                         "episode from Apogee.");\r
956                                         IN_ClearKeysDown();\r
957                                         IN_Ack();\r
958                                         DrawNewEpisode();\r
959                                         which = 0;\r
960                                 }\r
961                                 else\r
962                                 {\r
963                                         episode = which/2;\r
964                                         which = 1;\r
965                                 }\r
966                                 break;\r
967                 }\r
968 \r
969         } while (!which);\r
970 \r
971         ShootSnd();\r
972 \r
973         //\r
974         // ALREADY IN A GAME?\r
975         //\r
976         if (ingame)\r
977                 #ifdef JAPAN\r
978                 if (!GetYorN(7,8,C_JAPNEWGAMEPIC))\r
979                 #else\r
980                 if (!Confirm(CURGAME))\r
981                 #endif\r
982                 {\r
983                         MenuFadeOut();\r
984                         return;\r
985                 }\r
986 \r
987         MenuFadeOut();\r
988 \r
989 #else\r
990         episode = 0;\r
991 \r
992         //\r
993         // ALREADY IN A GAME?\r
994         //\r
995         CacheLump (NEWGAME_LUMP_START,NEWGAME_LUMP_END);\r
996         DrawNewGame();\r
997         if (ingame)\r
998                 if (!Confirm(CURGAME))\r
999                 {\r
1000                         MenuFadeOut();\r
1001                         UnCacheLump (NEWGAME_LUMP_START,NEWGAME_LUMP_END);\r
1002                         CacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1003                         return;\r
1004                 }\r
1005 \r
1006 #endif\r
1007 \r
1008         DrawNewGame();\r
1009         which=HandleMenu(&NewItems,&NewMenu[0],DrawNewGameDiff);\r
1010         if (which<0)\r
1011         {\r
1012                 MenuFadeOut();\r
1013                 #ifndef SPEAR\r
1014                 goto firstpart;\r
1015                 #else\r
1016                 UnCacheLump (NEWGAME_LUMP_START,NEWGAME_LUMP_END);\r
1017                 CacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1018                 return;\r
1019                 #endif\r
1020         }\r
1021 \r
1022         ShootSnd();\r
1023         NewGame(which,episode);\r
1024         StartGame=1;\r
1025         MenuFadeOut();\r
1026 \r
1027         //\r
1028         // CHANGE "READ THIS!" TO NORMAL COLOR\r
1029         //\r
1030         #ifndef SPEAR\r
1031         #ifndef GOODTIMES\r
1032         MainMenu[readthis].active=1;\r
1033         #endif\r
1034         #endif\r
1035 \r
1036         pickquick = 0;\r
1037 \r
1038 #ifdef SPEAR\r
1039         UnCacheLump (NEWGAME_LUMP_START,NEWGAME_LUMP_END);\r
1040         CacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1041 #endif\r
1042 }\r
1043 \r
1044 \r
1045 #ifndef SPEAR\r
1046 /////////////////////\r
1047 //\r
1048 // DRAW NEW EPISODE MENU\r
1049 //\r
1050 void DrawNewEpisode(void)\r
1051 {\r
1052         int i;\r
1053 \r
1054 #ifdef JAPAN\r
1055         CA_CacheScreen(S_EPISODEPIC);\r
1056 #else\r
1057         ClearMScreen();\r
1058         VWB_DrawPic(112,184,C_MOUSELBACKPIC);\r
1059 \r
1060         DrawWindow(NE_X-4,NE_Y-4,NE_W+8,NE_H+8,BKGDCOLOR);\r
1061         SETFONTCOLOR(READHCOLOR,BKGDCOLOR);\r
1062         PrintY=2;\r
1063         WindowX=0;\r
1064         #ifdef SPANISH\r
1065         US_CPrint("Cual episodio jugar?");\r
1066         #else\r
1067         US_CPrint("Which episode to play?");\r
1068         #endif\r
1069 #endif\r
1070 \r
1071         SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
1072         DrawMenu(&NewEitems,&NewEmenu[0]);\r
1073 \r
1074         for (i=0;i<6;i++)\r
1075                 VWB_DrawPic(NE_X+32,NE_Y+i*26,C_EPISODE1PIC+i);\r
1076 \r
1077         VW_UpdateScreen();\r
1078         MenuFadeIn();\r
1079         WaitKeyUp();\r
1080 }\r
1081 #endif\r
1082 \r
1083 /////////////////////\r
1084 //\r
1085 // DRAW NEW GAME MENU\r
1086 //\r
1087 void DrawNewGame(void)\r
1088 {\r
1089 #ifdef JAPAN\r
1090         CA_CacheScreen(S_SKILLPIC);\r
1091 #else\r
1092         ClearMScreen();\r
1093         VWB_DrawPic(112,184,C_MOUSELBACKPIC);\r
1094 \r
1095         SETFONTCOLOR(READHCOLOR,BKGDCOLOR);\r
1096         PrintX=NM_X+20;\r
1097         PrintY=NM_Y-32;\r
1098 \r
1099 #ifndef SPEAR\r
1100         #ifdef SPANISH\r
1101         US_Print("Eres macho?");\r
1102         #else\r
1103         US_Print("How tough are you?");\r
1104         #endif\r
1105 #else\r
1106         VWB_DrawPic (PrintX,PrintY,C_HOWTOUGHPIC);\r
1107 #endif\r
1108 \r
1109         DrawWindow(NM_X-5,NM_Y-10,NM_W,NM_H,BKGDCOLOR);\r
1110 #endif\r
1111 \r
1112         DrawMenu(&NewItems,&NewMenu[0]);\r
1113         DrawNewGameDiff(NewItems.curpos);\r
1114         VW_UpdateScreen();\r
1115         MenuFadeIn();\r
1116         WaitKeyUp();\r
1117 }\r
1118 \r
1119 \r
1120 ////////////////////////\r
1121 //\r
1122 // DRAW NEW GAME GRAPHIC\r
1123 //\r
1124 void DrawNewGameDiff(int w)\r
1125 {\r
1126         VWB_DrawPic(NM_X+185,NM_Y+7,w+C_BABYMODEPIC);\r
1127 }\r
1128 \r
1129 \r
1130 ////////////////////////////////////////////////////////////////////\r
1131 //\r
1132 // HANDLE SOUND MENU\r
1133 //\r
1134 ////////////////////////////////////////////////////////////////////\r
1135 void CP_Sound(void)\r
1136 {\r
1137         int which,i;\r
1138 \r
1139 \r
1140 #ifdef SPEAR\r
1141         UnCacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1142         CacheLump (SOUND_LUMP_START,SOUND_LUMP_END);\r
1143 #endif\r
1144 \r
1145         DrawSoundMenu();\r
1146         MenuFadeIn();\r
1147         WaitKeyUp();\r
1148 \r
1149         do\r
1150         {\r
1151                 which=HandleMenu(&SndItems,&SndMenu[0],NULL);\r
1152                 //\r
1153                 // HANDLE MENU CHOICES\r
1154                 //\r
1155                 switch(which)\r
1156                 {\r
1157                         //\r
1158                         // SOUND EFFECTS\r
1159                         //\r
1160                         case 0:\r
1161                                 if (SoundMode!=sdm_Off)\r
1162                                 {\r
1163                                         SD_WaitSoundDone();\r
1164                                         SD_SetSoundMode(sdm_Off);\r
1165                                         DrawSoundMenu();\r
1166                                 }\r
1167                                 break;\r
1168                         case 1:\r
1169                                 if (SoundMode!=sdm_PC)\r
1170                                 {\r
1171                                         SD_WaitSoundDone();\r
1172                                         SD_SetSoundMode(sdm_PC);\r
1173                                         CA_LoadAllSounds();\r
1174                                         DrawSoundMenu();\r
1175                                         ShootSnd();\r
1176                                 }\r
1177                                 break;\r
1178                         case 2:\r
1179                                 if (SoundMode!=sdm_AdLib)\r
1180                                 {\r
1181                                         SD_WaitSoundDone();\r
1182                                         SD_SetSoundMode(sdm_AdLib);\r
1183                                         CA_LoadAllSounds();\r
1184                                         DrawSoundMenu();\r
1185                                         ShootSnd();\r
1186                                 }\r
1187                                 break;\r
1188 \r
1189                         //\r
1190                         // DIGITIZED SOUND\r
1191                         //\r
1192                         case 5:\r
1193                                 if (DigiMode!=sds_Off)\r
1194                                 {\r
1195                                         SD_SetDigiDevice(sds_Off);\r
1196                                         DrawSoundMenu();\r
1197                                 }\r
1198                                 break;\r
1199                         case 6:\r
1200                                 if (DigiMode!=sds_SoundSource)\r
1201                                 {\r
1202                                         SD_SetDigiDevice(sds_SoundSource);\r
1203                                         DrawSoundMenu();\r
1204                                         ShootSnd();\r
1205                                 }\r
1206                                 break;\r
1207                         case 7:\r
1208                                 if (DigiMode!=sds_SoundBlaster)\r
1209                                 {\r
1210                                         SD_SetDigiDevice(sds_SoundBlaster);\r
1211                                         DrawSoundMenu();\r
1212                                         ShootSnd();\r
1213                                 }\r
1214                                 break;\r
1215 \r
1216                         //\r
1217                         // MUSIC\r
1218                         //\r
1219                         case 10:\r
1220                                 if (MusicMode!=smm_Off)\r
1221                                 {\r
1222                                         SD_SetMusicMode(smm_Off);\r
1223                                         DrawSoundMenu();\r
1224                                         ShootSnd();\r
1225                                 }\r
1226                                 break;\r
1227                         case 11:\r
1228                                 if (MusicMode!=smm_AdLib)\r
1229                                 {\r
1230                                         SD_SetMusicMode(smm_AdLib);\r
1231                                         DrawSoundMenu();\r
1232                                         ShootSnd();\r
1233                                         StartCPMusic(MENUSONG);\r
1234                                 }\r
1235                                 break;\r
1236                 }\r
1237         } while(which>=0);\r
1238 \r
1239         MenuFadeOut();\r
1240 \r
1241 #ifdef SPEAR\r
1242         UnCacheLump (SOUND_LUMP_START,SOUND_LUMP_END);\r
1243         CacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1244 #endif\r
1245 }\r
1246 \r
1247 \r
1248 //////////////////////\r
1249 //\r
1250 // DRAW THE SOUND MENU\r
1251 //\r
1252 void DrawSoundMenu(void)\r
1253 {\r
1254         int i,on;\r
1255 \r
1256 \r
1257 #ifdef JAPAN\r
1258         CA_CacheScreen(S_SOUNDPIC);\r
1259 #else\r
1260         //\r
1261         // DRAW SOUND MENU\r
1262         //\r
1263         ClearMScreen();\r
1264         VWB_DrawPic(112,184,C_MOUSELBACKPIC);\r
1265 \r
1266         DrawWindow(SM_X-8,SM_Y1-3,SM_W,SM_H1,BKGDCOLOR);\r
1267         DrawWindow(SM_X-8,SM_Y2-3,SM_W,SM_H2,BKGDCOLOR);\r
1268         DrawWindow(SM_X-8,SM_Y3-3,SM_W,SM_H3,BKGDCOLOR);\r
1269 #endif\r
1270 \r
1271         //\r
1272         // IF NO ADLIB, NON-CHOOSENESS!\r
1273         //\r
1274         if (!AdLibPresent && !SoundBlasterPresent)\r
1275         {\r
1276                 SndMenu[2].active=SndMenu[10].active=SndMenu[11].active=0;\r
1277         }\r
1278 \r
1279         if (!SoundSourcePresent)\r
1280                 SndMenu[6].active=0;\r
1281 \r
1282         if (!SoundBlasterPresent)\r
1283                 SndMenu[7].active=0;\r
1284 \r
1285         if (!SoundSourcePresent && !SoundBlasterPresent)\r
1286                 SndMenu[5].active=0;\r
1287 \r
1288         DrawMenu(&SndItems,&SndMenu[0]);\r
1289 #ifndef JAPAN\r
1290         VWB_DrawPic(100,SM_Y1-20,C_FXTITLEPIC);\r
1291         VWB_DrawPic(100,SM_Y2-20,C_DIGITITLEPIC);\r
1292         VWB_DrawPic(100,SM_Y3-20,C_MUSICTITLEPIC);\r
1293 #endif\r
1294 \r
1295         for (i=0;i<SndItems.amount;i++)\r
1296 #ifdef JAPAN\r
1297                 if (i!=3 && i!=4 && i!=8 && i!=9)\r
1298 #else\r
1299                 if (SndMenu[i].string[0])\r
1300 #endif\r
1301                 {\r
1302                         //\r
1303                         // DRAW SELECTED/NOT SELECTED GRAPHIC BUTTONS\r
1304                         //\r
1305                         on=0;\r
1306                         switch(i)\r
1307                         {\r
1308                                 //\r
1309                                 // SOUND EFFECTS\r
1310                                 //\r
1311                                 case 0: if (SoundMode==sdm_Off) on=1; break;\r
1312                                 case 1: if (SoundMode==sdm_PC) on=1; break;\r
1313                                 case 2: if (SoundMode==sdm_AdLib) on=1; break;\r
1314 \r
1315                                 //\r
1316                                 // DIGITIZED SOUND\r
1317                                 //\r
1318                                 case 5: if (DigiMode==sds_Off) on=1; break;\r
1319                                 case 6: if (DigiMode==sds_SoundSource) on=1; break;\r
1320                                 case 7: if (DigiMode==sds_SoundBlaster) on=1; break;\r
1321 \r
1322                                 //\r
1323                                 // MUSIC\r
1324                                 //\r
1325                                 case 10: if (MusicMode==smm_Off) on=1; break;\r
1326                                 case 11: if (MusicMode==smm_AdLib) on=1; break;\r
1327                         }\r
1328 \r
1329                         if (on)\r
1330                                 VWB_DrawPic(SM_X+24,SM_Y1+i*13+2,C_SELECTEDPIC);\r
1331                         else\r
1332                                 VWB_DrawPic(SM_X+24,SM_Y1+i*13+2,C_NOTSELECTEDPIC);\r
1333                 }\r
1334 \r
1335         DrawMenuGun(&SndItems);\r
1336         VW_UpdateScreen();\r
1337 }\r
1338 \r
1339 \r
1340 //\r
1341 // DRAW LOAD/SAVE IN PROGRESS\r
1342 //\r
1343 void DrawLSAction(int which)\r
1344 {\r
1345         #define LSA_X   96\r
1346         #define LSA_Y   80\r
1347         #define LSA_W   130\r
1348         #define LSA_H   42\r
1349 \r
1350         DrawWindow(LSA_X,LSA_Y,LSA_W,LSA_H,TEXTCOLOR);\r
1351         DrawOutline(LSA_X,LSA_Y,LSA_W,LSA_H,0,HIGHLIGHT);\r
1352         VWB_DrawPic(LSA_X+8,LSA_Y+5,C_DISKLOADING1PIC);\r
1353 \r
1354         fontnumber=1;\r
1355         SETFONTCOLOR(0,TEXTCOLOR);\r
1356         PrintX=LSA_X+46;\r
1357         PrintY=LSA_Y+13;\r
1358 \r
1359         if (!which)\r
1360                 US_Print(STR_LOADING"...");\r
1361         else\r
1362                 US_Print(STR_SAVING"...");\r
1363 \r
1364         VW_UpdateScreen();\r
1365 }\r
1366 \r
1367 \r
1368 ////////////////////////////////////////////////////////////////////\r
1369 //\r
1370 // LOAD SAVED GAMES\r
1371 //\r
1372 ////////////////////////////////////////////////////////////////////\r
1373 int CP_LoadGame(int quick)\r
1374 {\r
1375         int handle,which,exit=0;\r
1376         char name[13];\r
1377 \r
1378 \r
1379         strcpy(name,SaveName);\r
1380 \r
1381         //\r
1382         // QUICKLOAD?\r
1383         //\r
1384         if (quick)\r
1385         {\r
1386                 which=LSItems.curpos;\r
1387 \r
1388                 if (SaveGamesAvail[which])\r
1389                 {\r
1390                         name[7]=which+'0';\r
1391                         handle=open(name,O_BINARY);\r
1392                         lseek(handle,32,SEEK_SET);\r
1393                         loadedgame=true;\r
1394                         LoadTheGame(handle,0,0);\r
1395                         loadedgame=false;\r
1396                         close(handle);\r
1397 \r
1398                         DrawFace ();\r
1399                         DrawHealth ();\r
1400                         DrawLives ();\r
1401                         DrawLevel ();\r
1402                         DrawAmmo ();\r
1403                         DrawKeys ();\r
1404                         DrawWeapon ();\r
1405                         DrawScore ();\r
1406                         return 1;\r
1407                 }\r
1408         }\r
1409 \r
1410 \r
1411 #ifdef SPEAR\r
1412         UnCacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1413         CacheLump (LOADSAVE_LUMP_START,LOADSAVE_LUMP_END);\r
1414 #endif\r
1415 \r
1416         DrawLoadSaveScreen(0);\r
1417 \r
1418         do\r
1419         {\r
1420                 which=HandleMenu(&LSItems,&LSMenu[0],TrackWhichGame);\r
1421                 if (which>=0 && SaveGamesAvail[which])\r
1422                 {\r
1423                         ShootSnd();\r
1424                         name[7]=which+'0';\r
1425 \r
1426                         handle=open(name,O_BINARY);\r
1427                         lseek(handle,32,SEEK_SET);\r
1428 \r
1429                         DrawLSAction(0);\r
1430                         loadedgame=true;\r
1431 \r
1432                         LoadTheGame(handle,LSA_X+8,LSA_Y+5);\r
1433                         close(handle);\r
1434 \r
1435                         StartGame=1;\r
1436                         ShootSnd();\r
1437                         //\r
1438                         // CHANGE "READ THIS!" TO NORMAL COLOR\r
1439                         //\r
1440 \r
1441                         #ifndef SPEAR\r
1442                         #ifndef GOODTIMES\r
1443                         MainMenu[readthis].active=1;\r
1444                         #endif\r
1445                         #endif\r
1446 \r
1447                         exit=1;\r
1448                         break;\r
1449                 }\r
1450 \r
1451         } while(which>=0);\r
1452 \r
1453         MenuFadeOut();\r
1454 \r
1455 #ifdef SPEAR\r
1456         UnCacheLump (LOADSAVE_LUMP_START,LOADSAVE_LUMP_END);\r
1457         CacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1458 #endif\r
1459 \r
1460         return exit;\r
1461 }\r
1462 \r
1463 \r
1464 ///////////////////////////////////\r
1465 //\r
1466 // HIGHLIGHT CURRENT SELECTED ENTRY\r
1467 //\r
1468 void TrackWhichGame(int w)\r
1469 {\r
1470         static int lastgameon=0;\r
1471 \r
1472         PrintLSEntry(lastgameon,TEXTCOLOR);\r
1473         PrintLSEntry(w,HIGHLIGHT);\r
1474 \r
1475         lastgameon=w;\r
1476 }\r
1477 \r
1478 \r
1479 ////////////////////////////\r
1480 //\r
1481 // DRAW THE LOAD/SAVE SCREEN\r
1482 //\r
1483 void DrawLoadSaveScreen(int loadsave)\r
1484 {\r
1485         #define DISKX   100\r
1486         #define DISKY   0\r
1487 \r
1488         int i;\r
1489 \r
1490 \r
1491         ClearMScreen();\r
1492         fontnumber=1;\r
1493         VWB_DrawPic(112,184,C_MOUSELBACKPIC);\r
1494         DrawWindow(LSM_X-10,LSM_Y-5,LSM_W,LSM_H,BKGDCOLOR);\r
1495         DrawStripes(10);\r
1496 \r
1497         if (!loadsave)\r
1498                 VWB_DrawPic(60,0,C_LOADGAMEPIC);\r
1499         else\r
1500                 VWB_DrawPic(60,0,C_SAVEGAMEPIC);\r
1501 \r
1502         for (i=0;i<10;i++)\r
1503                 PrintLSEntry(i,TEXTCOLOR);\r
1504 \r
1505         DrawMenu(&LSItems,&LSMenu[0]);\r
1506         VW_UpdateScreen();\r
1507         MenuFadeIn();\r
1508         WaitKeyUp();\r
1509 }\r
1510 \r
1511 \r
1512 ///////////////////////////////////////////\r
1513 //\r
1514 // PRINT LOAD/SAVE GAME ENTRY W/BOX OUTLINE\r
1515 //\r
1516 void PrintLSEntry(int w,int color)\r
1517 {\r
1518         SETFONTCOLOR(color,BKGDCOLOR);\r
1519         DrawOutline(LSM_X+LSItems.indent,LSM_Y+w*13,LSM_W-LSItems.indent-15,11,color,color);\r
1520         PrintX=LSM_X+LSItems.indent+2;\r
1521         PrintY=LSM_Y+w*13+1;\r
1522         fontnumber=0;\r
1523 \r
1524         if (SaveGamesAvail[w])\r
1525                 US_Print(SaveGameNames[w]);\r
1526         else\r
1527                 US_Print("      - "STR_EMPTY" -");\r
1528 \r
1529         fontnumber=1;\r
1530 }\r
1531 \r
1532 \r
1533 ////////////////////////////////////////////////////////////////////\r
1534 //\r
1535 // SAVE CURRENT GAME\r
1536 //\r
1537 ////////////////////////////////////////////////////////////////////\r
1538 int CP_SaveGame(int quick)\r
1539 {\r
1540         int handle,which,exit=0;\r
1541         unsigned nwritten;\r
1542         char name[13],input[32];\r
1543 \r
1544 \r
1545         strcpy(name,SaveName);\r
1546 \r
1547         //\r
1548         // QUICKSAVE?\r
1549         //\r
1550         if (quick)\r
1551         {\r
1552                 which=LSItems.curpos;\r
1553 \r
1554                 if (SaveGamesAvail[which])\r
1555                 {\r
1556                         name[7]=which+'0';\r
1557                         unlink(name);\r
1558                         handle=creat(name,S_IREAD|S_IWRITE);\r
1559 \r
1560                         strcpy(input,&SaveGameNames[which][0]);\r
1561 \r
1562                         _dos_write(handle,(void far *)input,32,&nwritten);\r
1563                         lseek(handle,32,SEEK_SET);\r
1564                         SaveTheGame(handle,0,0);\r
1565                         close(handle);\r
1566 \r
1567                         return 1;\r
1568                 }\r
1569         }\r
1570 \r
1571 \r
1572 #ifdef SPEAR\r
1573         UnCacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1574         CacheLump (LOADSAVE_LUMP_START,LOADSAVE_LUMP_END);\r
1575 #endif\r
1576 \r
1577         DrawLoadSaveScreen(1);\r
1578 \r
1579         do\r
1580         {\r
1581                 which=HandleMenu(&LSItems,&LSMenu[0],TrackWhichGame);\r
1582                 if (which>=0)\r
1583                 {\r
1584                         //\r
1585                         // OVERWRITE EXISTING SAVEGAME?\r
1586                         //\r
1587                         if (SaveGamesAvail[which])\r
1588                                 #ifdef JAPAN\r
1589                                 if (!GetYorN(7,8,C_JAPSAVEOVERPIC))\r
1590                                 #else\r
1591                                 if (!Confirm(GAMESVD))\r
1592                                 #endif\r
1593                                 {\r
1594                                         DrawLoadSaveScreen(1);\r
1595                                         continue;\r
1596                                 }\r
1597                                 else\r
1598                                 {\r
1599                                         DrawLoadSaveScreen(1);\r
1600                                         PrintLSEntry(which,HIGHLIGHT);\r
1601                                         VW_UpdateScreen();\r
1602                                 }\r
1603 \r
1604                         ShootSnd();\r
1605 \r
1606                         strcpy(input,&SaveGameNames[which][0]);\r
1607                         name[7]=which+'0';\r
1608 \r
1609                         fontnumber=0;\r
1610                         if (!SaveGamesAvail[which])\r
1611                                 VWB_Bar(LSM_X+LSItems.indent+1,LSM_Y+which*13+1,LSM_W-LSItems.indent-16,10,BKGDCOLOR);\r
1612                         VW_UpdateScreen();\r
1613 \r
1614                         if (US_LineInput(LSM_X+LSItems.indent+2,LSM_Y+which*13+1,input,input,true,31,LSM_W-LSItems.indent-30))\r
1615                         {\r
1616                                 SaveGamesAvail[which]=1;\r
1617                                 strcpy(&SaveGameNames[which][0],input);\r
1618 \r
1619                                 unlink(name);\r
1620                                 handle=creat(name,S_IREAD|S_IWRITE);\r
1621                                 _dos_write(handle,(void far *)input,32,&nwritten);\r
1622                                 lseek(handle,32,SEEK_SET);\r
1623 \r
1624                                 DrawLSAction(1);\r
1625                                 SaveTheGame(handle,LSA_X+8,LSA_Y+5);\r
1626 \r
1627                                 close(handle);\r
1628 \r
1629                                 ShootSnd();\r
1630                                 exit=1;\r
1631                         }\r
1632                         else\r
1633                         {\r
1634                                 VWB_Bar(LSM_X+LSItems.indent+1,LSM_Y+which*13+1,LSM_W-LSItems.indent-16,10,BKGDCOLOR);\r
1635                                 PrintLSEntry(which,HIGHLIGHT);\r
1636                                 VW_UpdateScreen();\r
1637                                 SD_PlaySound(ESCPRESSEDSND);\r
1638                                 continue;\r
1639                         }\r
1640 \r
1641                         fontnumber=1;\r
1642                         break;\r
1643                 }\r
1644 \r
1645         } while(which>=0);\r
1646 \r
1647         MenuFadeOut();\r
1648 \r
1649 #ifdef SPEAR\r
1650         UnCacheLump (LOADSAVE_LUMP_START,LOADSAVE_LUMP_END);\r
1651         CacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1652 #endif\r
1653 \r
1654         return exit;\r
1655 }\r
1656 \r
1657 \r
1658 ////////////////////////////////////////////////////////////////////\r
1659 //\r
1660 // CALIBRATE JOYSTICK\r
1661 //\r
1662 ////////////////////////////////////////////////////////////////////\r
1663 int CalibrateJoystick(void)\r
1664 {\r
1665         #define CALX    85\r
1666         #define CALY    40\r
1667         #define CALW    158\r
1668         #define CALH    140\r
1669 \r
1670         unsigned xmin,ymin,xmax,ymax,jb;\r
1671 \r
1672 \r
1673 \r
1674         #ifdef JAPAN\r
1675         VWB_DrawPic(CALX,CALY,C_JOY0PIC);\r
1676         #else\r
1677         DrawWindow(CALX-5,CALY-5,CALW,CALH,TEXTCOLOR);\r
1678         DrawOutline(CALX-5,CALY-5,CALW,CALH,0,HIGHLIGHT);\r
1679         SETFONTCOLOR(0,TEXTCOLOR);\r
1680 \r
1681         WindowX = PrintX = CALX;\r
1682         WindowW = CALW;\r
1683         WindowH = CALH;\r
1684         WindowY = PrintY = CALY;\r
1685         US_Print("    "STR_CALIB"\n    "STR_JOYST"\n");\r
1686         VWB_DrawPic(CALX+40,CALY+30,C_JOY1PIC);\r
1687         PrintY = CALY+80;\r
1688         US_Print(STR_MOVEJOY);\r
1689         SETFONTCOLOR(BKGDCOLOR,TEXTCOLOR);\r
1690         US_Print("   "STR_ESCEXIT);\r
1691         #endif\r
1692         VW_UpdateScreen();\r
1693 \r
1694         do\r
1695         {\r
1696                 jb=IN_JoyButtons();\r
1697                 if (Keyboard[sc_Escape])\r
1698                         return 0;\r
1699                 #ifndef SPEAR\r
1700                 if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))\r
1701                         PicturePause();\r
1702                 #endif\r
1703 \r
1704         } while(!(jb&1));\r
1705 \r
1706         SD_PlaySound(SHOOTSND);\r
1707         IN_GetJoyAbs(joystickport,&xmin,&ymin);\r
1708 \r
1709 \r
1710         #ifdef JAPAN\r
1711         VWB_DrawPic(CALX,CALY,C_JOY1PIC);\r
1712         #else\r
1713         DrawWindow(CALX-5,CALY-5,CALW,CALH,TEXTCOLOR);\r
1714         DrawOutline(CALX-5,CALY-5,CALW,CALH,0,HIGHLIGHT);\r
1715         SETFONTCOLOR(0,TEXTCOLOR);\r
1716 \r
1717         PrintX = CALX;\r
1718         PrintY = CALY;\r
1719         US_Print("    "STR_CALIB"\n    "STR_JOYST"\n");\r
1720         VWB_DrawPic(CALX+40,CALY+30,C_JOY2PIC);\r
1721         PrintY = CALY+80;\r
1722         US_Print(STR_MOVEJOY2);\r
1723         SETFONTCOLOR(BKGDCOLOR,TEXTCOLOR);\r
1724         US_Print("   "STR_ESCEXIT);\r
1725         #endif\r
1726         VW_UpdateScreen();\r
1727 \r
1728         do\r
1729         {\r
1730                 jb=IN_JoyButtons();\r
1731                 if (Keyboard[sc_Escape])\r
1732                         return 0;\r
1733                 #ifndef SPEAR\r
1734                 if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))\r
1735                         PicturePause();\r
1736                 #endif\r
1737         } while(!(jb&2));\r
1738 \r
1739         IN_GetJoyAbs(joystickport,&xmax,&ymax);\r
1740         SD_PlaySound(SHOOTSND);\r
1741 \r
1742         while (IN_JoyButtons());\r
1743 \r
1744         //\r
1745         // ASSIGN ACTUAL VALUES HERE\r
1746         //\r
1747         if ((xmin != xmax) && (ymin != ymax))\r
1748                 IN_SetupJoy(joystickport,xmin,xmax,ymin,ymax);\r
1749         else\r
1750                 return 0;\r
1751 \r
1752         return 1;\r
1753 }\r
1754 \r
1755 \r
1756 ////////////////////////////////////////////////////////////////////\r
1757 //\r
1758 // DEFINE CONTROLS\r
1759 //\r
1760 ////////////////////////////////////////////////////////////////////\r
1761 void CP_Control(void)\r
1762 {\r
1763         #define CTL_SPC 70\r
1764         enum {MOUSEENABLE,JOYENABLE,USEPORT2,PADENABLE,MOUSESENS,CUSTOMIZE};\r
1765         int i,which;\r
1766 \r
1767 \r
1768 #ifdef SPEAR\r
1769         UnCacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1770         CacheLump (CONTROL_LUMP_START,CONTROL_LUMP_END);\r
1771 #endif\r
1772 \r
1773         DrawCtlScreen();\r
1774         MenuFadeIn();\r
1775         WaitKeyUp();\r
1776 \r
1777         do\r
1778         {\r
1779                 which=HandleMenu(&CtlItems,&CtlMenu[0],NULL);\r
1780                 switch(which)\r
1781                 {\r
1782                         case MOUSEENABLE:\r
1783                                 mouseenabled^=1;\r
1784                                 _CX=_DX=CENTER;\r
1785                                 Mouse(4);\r
1786                                 DrawCtlScreen();\r
1787                                 CusItems.curpos=-1;\r
1788                                 ShootSnd();\r
1789                                 break;\r
1790 \r
1791                         case JOYENABLE:\r
1792                                 joystickenabled^=1;\r
1793                                 if (joystickenabled)\r
1794                                         if (!CalibrateJoystick())\r
1795                                                 joystickenabled = 0;\r
1796                                 DrawCtlScreen();\r
1797                                 CusItems.curpos=-1;\r
1798                                 ShootSnd();\r
1799                                 break;\r
1800 \r
1801                         case USEPORT2:\r
1802                                 joystickport^=1;\r
1803                                 DrawCtlScreen();\r
1804                                 ShootSnd();\r
1805                                 break;\r
1806 \r
1807                         case PADENABLE:\r
1808                                 joypadenabled^=1;\r
1809                                 DrawCtlScreen();\r
1810                                 ShootSnd();\r
1811                                 break;\r
1812 \r
1813                         case MOUSESENS:\r
1814                         case CUSTOMIZE:\r
1815                                 DrawCtlScreen();\r
1816                                 MenuFadeIn();\r
1817                                 WaitKeyUp();\r
1818                                 break;\r
1819                 }\r
1820         } while(which>=0);\r
1821 \r
1822         MenuFadeOut();\r
1823 \r
1824 #ifdef SPEAR\r
1825         UnCacheLump (CONTROL_LUMP_START,CONTROL_LUMP_END);\r
1826         CacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);\r
1827 #endif\r
1828 }\r
1829 \r
1830 \r
1831 ////////////////////////////////\r
1832 //\r
1833 // DRAW MOUSE SENSITIVITY SCREEN\r
1834 //\r
1835 void DrawMouseSens(void)\r
1836 {\r
1837 #ifdef JAPAN\r
1838         CA_CacheScreen(S_MOUSESENSPIC);\r
1839 #else\r
1840         ClearMScreen();\r
1841         VWB_DrawPic(112,184,C_MOUSELBACKPIC);\r
1842         #ifdef SPANISH\r
1843         DrawWindow(10,80,300,43,BKGDCOLOR);\r
1844         #else\r
1845         DrawWindow(10,80,300,30,BKGDCOLOR);\r
1846         #endif\r
1847 \r
1848         WindowX=0;\r
1849         WindowW=320;\r
1850         PrintY=82;\r
1851         SETFONTCOLOR(READCOLOR,BKGDCOLOR);\r
1852         US_CPrint(STR_MOUSEADJ);\r
1853 \r
1854         SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
1855         #ifdef SPANISH\r
1856         PrintX=14;\r
1857         PrintY=95+13;\r
1858         US_Print(STR_SLOW);\r
1859         PrintX=252;\r
1860         US_Print(STR_FAST);\r
1861         #else\r
1862         PrintX=14;\r
1863         PrintY=95;\r
1864         US_Print(STR_SLOW);\r
1865         PrintX=269;\r
1866         US_Print(STR_FAST);\r
1867         #endif\r
1868 #endif\r
1869 \r
1870         VWB_Bar(60,97,200,10,TEXTCOLOR);\r
1871         DrawOutline(60,97,200,10,0,HIGHLIGHT);\r
1872         DrawOutline(60+20*mouseadjustment,97,20,10,0,READCOLOR);\r
1873         VWB_Bar(61+20*mouseadjustment,98,19,9,READHCOLOR);\r
1874 \r
1875         VW_UpdateScreen();\r
1876         MenuFadeIn();\r
1877 }\r
1878 \r
1879 \r
1880 ///////////////////////////\r
1881 //\r
1882 // ADJUST MOUSE SENSITIVITY\r
1883 //\r
1884 void MouseSensitivity(void)\r
1885 {\r
1886         ControlInfo ci;\r
1887         int exit=0,oldMA;\r
1888 \r
1889 \r
1890         oldMA=mouseadjustment;\r
1891         DrawMouseSens();\r
1892         do\r
1893         {\r
1894                 ReadAnyControl(&ci);\r
1895                 switch(ci.dir)\r
1896                 {\r
1897                         case dir_North:\r
1898                         case dir_West:\r
1899                                 if (mouseadjustment)\r
1900                                 {\r
1901                                         mouseadjustment--;\r
1902                                         VWB_Bar(60,97,200,10,TEXTCOLOR);\r
1903                                         DrawOutline(60,97,200,10,0,HIGHLIGHT);\r
1904                                         DrawOutline(60+20*mouseadjustment,97,20,10,0,READCOLOR);\r
1905                                         VWB_Bar(61+20*mouseadjustment,98,19,9,READHCOLOR);\r
1906                                         VW_UpdateScreen();\r
1907                                         SD_PlaySound(MOVEGUN1SND);\r
1908                                         while(Keyboard[sc_LeftArrow]);\r
1909                                         WaitKeyUp();\r
1910                                 }\r
1911                                 break;\r
1912 \r
1913                         case dir_South:\r
1914                         case dir_East:\r
1915                                 if (mouseadjustment<9)\r
1916                                 {\r
1917                                         mouseadjustment++;\r
1918                                         VWB_Bar(60,97,200,10,TEXTCOLOR);\r
1919                                         DrawOutline(60,97,200,10,0,HIGHLIGHT);\r
1920                                         DrawOutline(60+20*mouseadjustment,97,20,10,0,READCOLOR);\r
1921                                         VWB_Bar(61+20*mouseadjustment,98,19,9,READHCOLOR);\r
1922                                         VW_UpdateScreen();\r
1923                                         SD_PlaySound(MOVEGUN1SND);\r
1924                                         while(Keyboard[sc_RightArrow]);\r
1925                                         WaitKeyUp();\r
1926                                 }\r
1927                                 break;\r
1928                 }\r
1929 \r
1930                 #ifndef SPEAR\r
1931                 if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))\r
1932                 #else\r
1933                 if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("debugmode"))\r
1934                 #endif\r
1935                         PicturePause();\r
1936 \r
1937                 if (ci.button0 || Keyboard[sc_Space] || Keyboard[sc_Enter])\r
1938                         exit=1;\r
1939                 else\r
1940                 if (ci.button1 || Keyboard[sc_Escape])\r
1941                         exit=2;\r
1942 \r
1943         } while(!exit);\r
1944 \r
1945         if (exit==2)\r
1946         {\r
1947                 mouseadjustment=oldMA;\r
1948                 SD_PlaySound(ESCPRESSEDSND);\r
1949         }\r
1950         else\r
1951                 SD_PlaySound(SHOOTSND);\r
1952 \r
1953         WaitKeyUp();\r
1954         MenuFadeOut();\r
1955 }\r
1956 \r
1957 \r
1958 ///////////////////////////\r
1959 //\r
1960 // DRAW CONTROL MENU SCREEN\r
1961 //\r
1962 void DrawCtlScreen(void)\r
1963 {\r
1964  int i,x,y;\r
1965 \r
1966 \r
1967 #ifdef JAPAN\r
1968         CA_CacheScreen(S_CONTROLPIC);\r
1969 #else\r
1970  ClearMScreen();\r
1971  DrawStripes(10);\r
1972  VWB_DrawPic(80,0,C_CONTROLPIC);\r
1973  VWB_DrawPic(112,184,C_MOUSELBACKPIC);\r
1974  DrawWindow(CTL_X-8,CTL_Y-5,CTL_W,CTL_H,BKGDCOLOR);\r
1975 #endif\r
1976  WindowX=0;\r
1977  WindowW=320;\r
1978  SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
1979 \r
1980  if (JoysPresent[0])\r
1981    CtlMenu[1].active=\r
1982    CtlMenu[2].active=\r
1983    CtlMenu[3].active=1;\r
1984 \r
1985  CtlMenu[2].active=CtlMenu[3].active=joystickenabled;\r
1986 \r
1987  if (MousePresent)\r
1988  {\r
1989   CtlMenu[4].active=\r
1990   CtlMenu[0].active=1;\r
1991  }\r
1992 \r
1993  CtlMenu[4].active=mouseenabled;\r
1994 \r
1995 \r
1996  DrawMenu(&CtlItems,&CtlMenu[0]);\r
1997 \r
1998 \r
1999  x=CTL_X+CtlItems.indent-24;\r
2000  y=CTL_Y+3;\r
2001  if (mouseenabled)\r
2002    VWB_DrawPic(x,y,C_SELECTEDPIC);\r
2003  else\r
2004    VWB_DrawPic(x,y,C_NOTSELECTEDPIC);\r
2005 \r
2006  y=CTL_Y+16;\r
2007  if (joystickenabled)\r
2008    VWB_DrawPic(x,y,C_SELECTEDPIC);\r
2009  else\r
2010    VWB_DrawPic(x,y,C_NOTSELECTEDPIC);\r
2011 \r
2012  y=CTL_Y+29;\r
2013  if (joystickport)\r
2014    VWB_DrawPic(x,y,C_SELECTEDPIC);\r
2015  else\r
2016    VWB_DrawPic(x,y,C_NOTSELECTEDPIC);\r
2017 \r
2018  y=CTL_Y+42;\r
2019  if (joypadenabled)\r
2020    VWB_DrawPic(x,y,C_SELECTEDPIC);\r
2021  else\r
2022    VWB_DrawPic(x,y,C_NOTSELECTEDPIC);\r
2023 \r
2024  //\r
2025  // PICK FIRST AVAILABLE SPOT\r
2026  //\r
2027  if (CtlItems.curpos<0 || !CtlMenu[CtlItems.curpos].active)\r
2028    for (i=0;i<6;i++)\r
2029          if (CtlMenu[i].active)\r
2030          {\r
2031           CtlItems.curpos=i;\r
2032           break;\r
2033          }\r
2034 \r
2035  DrawMenuGun(&CtlItems);\r
2036  VW_UpdateScreen();\r
2037 }\r
2038 \r
2039 \r
2040 ////////////////////////////////////////////////////////////////////\r
2041 //\r
2042 // CUSTOMIZE CONTROLS\r
2043 //\r
2044 ////////////////////////////////////////////////////////////////////\r
2045 enum {FIRE,STRAFE,RUN,OPEN};\r
2046 char mbarray[4][3]={"b0","b1","b2","b3"},\r
2047            order[4]={RUN,OPEN,FIRE,STRAFE};\r
2048 \r
2049 \r
2050 void CustomControls(void)\r
2051 {\r
2052  int which;\r
2053 \r
2054 \r
2055  DrawCustomScreen();\r
2056  do\r
2057  {\r
2058   which=HandleMenu(&CusItems,&CusMenu[0],FixupCustom);\r
2059   switch(which)\r
2060   {\r
2061    case 0:\r
2062          DefineMouseBtns();\r
2063          DrawCustMouse(1);\r
2064          break;\r
2065    case 3:\r
2066          DefineJoyBtns();\r
2067          DrawCustJoy(0);\r
2068          break;\r
2069    case 6:\r
2070          DefineKeyBtns();\r
2071          DrawCustKeybd(0);\r
2072          break;\r
2073    case 8:\r
2074          DefineKeyMove();\r
2075          DrawCustKeys(0);\r
2076   }\r
2077  } while(which>=0);\r
2078 \r
2079 \r
2080 \r
2081  MenuFadeOut();\r
2082 }\r
2083 \r
2084 \r
2085 ////////////////////////\r
2086 //\r
2087 // DEFINE THE MOUSE BUTTONS\r
2088 //\r
2089 void DefineMouseBtns(void)\r
2090 {\r
2091  CustomCtrls mouseallowed={0,1,1,1};\r
2092  EnterCtrlData(2,&mouseallowed,DrawCustMouse,PrintCustMouse,MOUSE);\r
2093 }\r
2094 \r
2095 \r
2096 ////////////////////////\r
2097 //\r
2098 // DEFINE THE JOYSTICK BUTTONS\r
2099 //\r
2100 void DefineJoyBtns(void)\r
2101 {\r
2102  CustomCtrls joyallowed={1,1,1,1};\r
2103  EnterCtrlData(5,&joyallowed,DrawCustJoy,PrintCustJoy,JOYSTICK);\r
2104 }\r
2105 \r
2106 \r
2107 ////////////////////////\r
2108 //\r
2109 // DEFINE THE KEYBOARD BUTTONS\r
2110 //\r
2111 void DefineKeyBtns(void)\r
2112 {\r
2113  CustomCtrls keyallowed={1,1,1,1};\r
2114  EnterCtrlData(8,&keyallowed,DrawCustKeybd,PrintCustKeybd,KEYBOARDBTNS);\r
2115 }\r
2116 \r
2117 \r
2118 ////////////////////////\r
2119 //\r
2120 // DEFINE THE KEYBOARD BUTTONS\r
2121 //\r
2122 void DefineKeyMove(void)\r
2123 {\r
2124         CustomCtrls keyallowed={1,1,1,1};\r
2125         EnterCtrlData(10,&keyallowed,DrawCustKeys,PrintCustKeys,KEYBOARDMOVE);\r
2126 }\r
2127 \r
2128 \r
2129 ////////////////////////\r
2130 //\r
2131 // ENTER CONTROL DATA FOR ANY TYPE OF CONTROL\r
2132 //\r
2133 enum {FWRD,RIGHT,BKWD,LEFT};\r
2134 int moveorder[4]={LEFT,RIGHT,FWRD,BKWD};\r
2135 \r
2136 void EnterCtrlData(int index,CustomCtrls *cust,void (*DrawRtn)(int),void (*PrintRtn)(int),int type)\r
2137 {\r
2138  int j,exit,tick,redraw,which,x,picked;\r
2139  ControlInfo ci;\r
2140 \r
2141 \r
2142  ShootSnd();\r
2143  PrintY=CST_Y+13*index;\r
2144  IN_ClearKeysDown();\r
2145  exit=0;\r
2146  redraw=1;\r
2147  //\r
2148  // FIND FIRST SPOT IN ALLOWED ARRAY\r
2149  //\r
2150  for (j=0;j<4;j++)\r
2151    if (cust->allowed[j])\r
2152    {\r
2153         which=j;\r
2154         break;\r
2155    }\r
2156 \r
2157  do\r
2158  {\r
2159   if (redraw)\r
2160   {\r
2161    x=CST_START+CST_SPC*which;\r
2162    DrawWindow(5,PrintY-1,310,13,BKGDCOLOR);\r
2163 \r
2164    DrawRtn(1);\r
2165    DrawWindow(x-2,PrintY,CST_SPC,11,TEXTCOLOR);\r
2166    DrawOutline(x-2,PrintY,CST_SPC,11,0,HIGHLIGHT);\r
2167    SETFONTCOLOR(0,TEXTCOLOR);\r
2168    PrintRtn(which);\r
2169    PrintX=x;\r
2170    SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
2171    VW_UpdateScreen();\r
2172    WaitKeyUp();\r
2173    redraw=0;\r
2174   }\r
2175 \r
2176   ReadAnyControl(&ci);\r
2177 \r
2178   if (type==MOUSE || type==JOYSTICK)\r
2179         if (IN_KeyDown(sc_Enter)||IN_KeyDown(sc_Control)||IN_KeyDown(sc_Alt))\r
2180         {\r
2181          IN_ClearKeysDown();\r
2182          ci.button0=ci.button1=false;\r
2183         }\r
2184 \r
2185   //\r
2186   // CHANGE BUTTON VALUE?\r
2187   //\r
2188   if ((ci.button0|ci.button1|ci.button2|ci.button3)||\r
2189           ((type==KEYBOARDBTNS||type==KEYBOARDMOVE) && LastScan==sc_Enter))\r
2190   {\r
2191    tick=TimeCount=picked=0;\r
2192    SETFONTCOLOR(0,TEXTCOLOR);\r
2193 \r
2194    do\r
2195    {\r
2196         int button,result=0;\r
2197 \r
2198 \r
2199         if (type==KEYBOARDBTNS||type==KEYBOARDMOVE)\r
2200           IN_ClearKeysDown();\r
2201 \r
2202         //\r
2203         // FLASH CURSOR\r
2204         //\r
2205         if (TimeCount>10)\r
2206         {\r
2207          switch(tick)\r
2208          {\r
2209           case 0:\r
2210         VWB_Bar(x,PrintY+1,CST_SPC-2,10,TEXTCOLOR);\r
2211         break;\r
2212           case 1:\r
2213         PrintX=x;\r
2214         US_Print("?");\r
2215         SD_PlaySound(HITWALLSND);\r
2216          }\r
2217          tick^=1;\r
2218          TimeCount=0;\r
2219          VW_UpdateScreen();\r
2220         }\r
2221 \r
2222         //\r
2223         // WHICH TYPE OF INPUT DO WE PROCESS?\r
2224         //\r
2225         switch(type)\r
2226         {\r
2227          case MOUSE:\r
2228            Mouse(3);\r
2229            button=_BX;\r
2230            switch(button)\r
2231            {\r
2232         case 1: result=1; break;\r
2233         case 2: result=2; break;\r
2234         case 4: result=3; break;\r
2235            }\r
2236 \r
2237            if (result)\r
2238            {\r
2239         int z;\r
2240 \r
2241 \r
2242         for (z=0;z<4;z++)\r
2243           if (order[which]==buttonmouse[z])\r
2244           {\r
2245            buttonmouse[z]=bt_nobutton;\r
2246            break;\r
2247           }\r
2248 \r
2249         buttonmouse[result-1]=order[which];\r
2250         picked=1;\r
2251         SD_PlaySound(SHOOTDOORSND);\r
2252            }\r
2253            break;\r
2254 \r
2255          case JOYSTICK:\r
2256            if (ci.button0) result=1;\r
2257            else\r
2258            if (ci.button1) result=2;\r
2259            else\r
2260            if (ci.button2) result=3;\r
2261            else\r
2262            if (ci.button3) result=4;\r
2263 \r
2264            if (result)\r
2265            {\r
2266         int z;\r
2267 \r
2268 \r
2269         for (z=0;z<4;z++)\r
2270           if (order[which]==buttonjoy[z])\r
2271           {\r
2272            buttonjoy[z]=bt_nobutton;\r
2273            break;\r
2274           }\r
2275 \r
2276         buttonjoy[result-1]=order[which];\r
2277         picked=1;\r
2278         SD_PlaySound(SHOOTDOORSND);\r
2279            }\r
2280            break;\r
2281 \r
2282          case KEYBOARDBTNS:\r
2283            if (LastScan)\r
2284            {\r
2285         buttonscan[order[which]]=LastScan;\r
2286         picked=1;\r
2287         ShootSnd();\r
2288         IN_ClearKeysDown();\r
2289            }\r
2290            break;\r
2291 \r
2292          case KEYBOARDMOVE:\r
2293            if (LastScan)\r
2294            {\r
2295         dirscan[moveorder[which]]=LastScan;\r
2296         picked=1;\r
2297         ShootSnd();\r
2298         IN_ClearKeysDown();\r
2299            }\r
2300            break;\r
2301         }\r
2302 \r
2303         //\r
2304         // EXIT INPUT?\r
2305         //\r
2306         if (IN_KeyDown(sc_Escape))\r
2307         {\r
2308          picked=1;\r
2309          continue;\r
2310         }\r
2311 \r
2312    } while(!picked);\r
2313 \r
2314    SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
2315    redraw=1;\r
2316    WaitKeyUp();\r
2317    continue;\r
2318   }\r
2319 \r
2320   if (ci.button1 || IN_KeyDown(sc_Escape))\r
2321         exit=1;\r
2322 \r
2323   //\r
2324   // MOVE TO ANOTHER SPOT?\r
2325   //\r
2326   switch(ci.dir)\r
2327   {\r
2328    case dir_West:\r
2329          do\r
2330          {\r
2331           which--;\r
2332           if (which<0)\r
2333         which=3;\r
2334          } while(!cust->allowed[which]);\r
2335          redraw=1;\r
2336          SD_PlaySound(MOVEGUN1SND);\r
2337          while(ReadAnyControl(&ci),ci.dir!=dir_None);\r
2338          IN_ClearKeysDown();\r
2339          break;\r
2340 \r
2341    case dir_East:\r
2342          do\r
2343          {\r
2344           which++;\r
2345           if (which>3)\r
2346         which=0;\r
2347          } while(!cust->allowed[which]);\r
2348          redraw=1;\r
2349          SD_PlaySound(MOVEGUN1SND);\r
2350          while(ReadAnyControl(&ci),ci.dir!=dir_None);\r
2351          IN_ClearKeysDown();\r
2352          break;\r
2353    case dir_North:\r
2354    case dir_South:\r
2355          exit=1;\r
2356   }\r
2357  } while(!exit);\r
2358 \r
2359  SD_PlaySound(ESCPRESSEDSND);\r
2360  WaitKeyUp();\r
2361  DrawWindow(5,PrintY-1,310,13,BKGDCOLOR);\r
2362 }\r
2363 \r
2364 \r
2365 ////////////////////////\r
2366 //\r
2367 // FIXUP GUN CURSOR OVERDRAW SHIT\r
2368 //\r
2369 void FixupCustom(int w)\r
2370 {\r
2371         static int lastwhich=-1;\r
2372         int y=CST_Y+26+w*13;\r
2373 \r
2374 \r
2375         VWB_Hlin(7,32,y-1,DEACTIVE);\r
2376         VWB_Hlin(7,32,y+12,BORD2COLOR);\r
2377 #ifndef SPEAR\r
2378         VWB_Hlin(7,32,y-2,BORDCOLOR);\r
2379         VWB_Hlin(7,32,y+13,BORDCOLOR);\r
2380 #else\r
2381         VWB_Hlin(7,32,y-2,BORD2COLOR);\r
2382         VWB_Hlin(7,32,y+13,BORD2COLOR);\r
2383 #endif\r
2384 \r
2385         switch(w)\r
2386         {\r
2387                 case 0: DrawCustMouse(1); break;\r
2388                 case 3: DrawCustJoy(1); break;\r
2389                 case 6: DrawCustKeybd(1); break;\r
2390                 case 8: DrawCustKeys(1);\r
2391         }\r
2392 \r
2393 \r
2394         if (lastwhich>=0)\r
2395         {\r
2396                 y=CST_Y+26+lastwhich*13;\r
2397                 VWB_Hlin(7,32,y-1,DEACTIVE);\r
2398                 VWB_Hlin(7,32,y+12,BORD2COLOR);\r
2399 #ifndef SPEAR\r
2400                 VWB_Hlin(7,32,y-2,BORDCOLOR);\r
2401                 VWB_Hlin(7,32,y+13,BORDCOLOR);\r
2402 #else\r
2403                 VWB_Hlin(7,32,y-2,BORD2COLOR);\r
2404                 VWB_Hlin(7,32,y+13,BORD2COLOR);\r
2405 #endif\r
2406 \r
2407                 if (lastwhich!=w)\r
2408                         switch(lastwhich)\r
2409                         {\r
2410                                 case 0: DrawCustMouse(0); break;\r
2411                                 case 3: DrawCustJoy(0); break;\r
2412                                 case 6: DrawCustKeybd(0); break;\r
2413                                 case 8: DrawCustKeys(0);\r
2414                         }\r
2415         }\r
2416 \r
2417         lastwhich=w;\r
2418 }\r
2419 \r
2420 \r
2421 ////////////////////////\r
2422 //\r
2423 // DRAW CUSTOMIZE SCREEN\r
2424 //\r
2425 void DrawCustomScreen(void)\r
2426 {\r
2427         int i;\r
2428 \r
2429 \r
2430 #ifdef JAPAN\r
2431         CA_CacheScreen(S_CUSTOMPIC);\r
2432         fontnumber=1;\r
2433 \r
2434         PrintX=CST_START;\r
2435         PrintY = CST_Y+26;\r
2436         DrawCustMouse(0);\r
2437 \r
2438         PrintX=CST_START;\r
2439         US_Print("\n\n\n");\r
2440         DrawCustJoy(0);\r
2441 \r
2442         PrintX=CST_START;\r
2443         US_Print("\n\n\n");\r
2444         DrawCustKeybd(0);\r
2445 \r
2446         PrintX=CST_START;\r
2447         US_Print("\n\n\n");\r
2448         DrawCustKeys(0);\r
2449 #else\r
2450         ClearMScreen();\r
2451         WindowX=0;\r
2452         WindowW=320;\r
2453         VWB_DrawPic(112,184,C_MOUSELBACKPIC);\r
2454         DrawStripes(10);\r
2455         VWB_DrawPic(80,0,C_CUSTOMIZEPIC);\r
2456 \r
2457         //\r
2458         // MOUSE\r
2459         //\r
2460         SETFONTCOLOR(READCOLOR,BKGDCOLOR);\r
2461         WindowX=0;\r
2462         WindowW=320;\r
2463 \r
2464 #ifndef SPEAR\r
2465         PrintY=CST_Y;\r
2466         US_CPrint("Mouse\n");\r
2467 #else\r
2468         PrintY = CST_Y+13;\r
2469         VWB_DrawPic (128,48,C_MOUSEPIC);\r
2470 #endif\r
2471 \r
2472         SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
2473         #ifdef SPANISH\r
2474         PrintX=CST_START-16;\r
2475         US_Print(STR_CRUN);\r
2476         PrintX=CST_START-16+CST_SPC*1;\r
2477         US_Print(STR_COPEN);\r
2478         PrintX=CST_START-16+CST_SPC*2;\r
2479         US_Print(STR_CFIRE);\r
2480         PrintX=CST_START-16+CST_SPC*3;\r
2481         US_Print(STR_CSTRAFE"\n");\r
2482         #else\r
2483         PrintX=CST_START;\r
2484         US_Print(STR_CRUN);\r
2485         PrintX=CST_START+CST_SPC*1;\r
2486         US_Print(STR_COPEN);\r
2487         PrintX=CST_START+CST_SPC*2;\r
2488         US_Print(STR_CFIRE);\r
2489         PrintX=CST_START+CST_SPC*3;\r
2490         US_Print(STR_CSTRAFE"\n");\r
2491         #endif\r
2492 \r
2493         DrawWindow(5,PrintY-1,310,13,BKGDCOLOR);\r
2494         DrawCustMouse(0);\r
2495         US_Print("\n");\r
2496 \r
2497 \r
2498         //\r
2499         // JOYSTICK/PAD\r
2500         //\r
2501 #ifndef SPEAR\r
2502         SETFONTCOLOR(READCOLOR,BKGDCOLOR);\r
2503         US_CPrint("Joystick/Gravis GamePad\n");\r
2504 #else\r
2505         PrintY += 13;\r
2506         VWB_DrawPic (40,88,C_JOYSTICKPIC);\r
2507 #endif\r
2508 \r
2509 #ifdef SPEAR\r
2510         VWB_DrawPic (112,120,C_KEYBOARDPIC);\r
2511 #endif\r
2512 \r
2513         SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
2514         #ifdef SPANISH\r
2515         PrintX=CST_START-16;\r
2516         US_Print(STR_CRUN);\r
2517         PrintX=CST_START-16+CST_SPC*1;\r
2518         US_Print(STR_COPEN);\r
2519         PrintX=CST_START-16+CST_SPC*2;\r
2520         US_Print(STR_CFIRE);\r
2521         PrintX=CST_START-16+CST_SPC*3;\r
2522         US_Print(STR_CSTRAFE"\n");\r
2523         #else\r
2524         PrintX=CST_START;\r
2525         US_Print(STR_CRUN);\r
2526         PrintX=CST_START+CST_SPC*1;\r
2527         US_Print(STR_COPEN);\r
2528         PrintX=CST_START+CST_SPC*2;\r
2529         US_Print(STR_CFIRE);\r
2530         PrintX=CST_START+CST_SPC*3;\r
2531         US_Print(STR_CSTRAFE"\n");\r
2532         #endif\r
2533         DrawWindow(5,PrintY-1,310,13,BKGDCOLOR);\r
2534         DrawCustJoy(0);\r
2535         US_Print("\n");\r
2536 \r
2537 \r
2538         //\r
2539         // KEYBOARD\r
2540         //\r
2541 #ifndef SPEAR\r
2542         SETFONTCOLOR(READCOLOR,BKGDCOLOR);\r
2543         US_CPrint("Keyboard\n");\r
2544 #else\r
2545         PrintY += 13;\r
2546 #endif\r
2547         SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
2548         #ifdef SPANISH\r
2549         PrintX=CST_START-16;\r
2550         US_Print(STR_CRUN);\r
2551         PrintX=CST_START-16+CST_SPC*1;\r
2552         US_Print(STR_COPEN);\r
2553         PrintX=CST_START-16+CST_SPC*2;\r
2554         US_Print(STR_CFIRE);\r
2555         PrintX=CST_START-16+CST_SPC*3;\r
2556         US_Print(STR_CSTRAFE"\n");\r
2557         #else\r
2558         PrintX=CST_START;\r
2559         US_Print(STR_CRUN);\r
2560         PrintX=CST_START+CST_SPC*1;\r
2561         US_Print(STR_COPEN);\r
2562         PrintX=CST_START+CST_SPC*2;\r
2563         US_Print(STR_CFIRE);\r
2564         PrintX=CST_START+CST_SPC*3;\r
2565         US_Print(STR_CSTRAFE"\n");\r
2566         #endif\r
2567         DrawWindow(5,PrintY-1,310,13,BKGDCOLOR);\r
2568         DrawCustKeybd(0);\r
2569         US_Print("\n");\r
2570 \r
2571 \r
2572         //\r
2573         // KEYBOARD MOVE KEYS\r
2574         //\r
2575         SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
2576         #ifdef SPANISH\r
2577         PrintX=4;\r
2578         US_Print(STR_LEFT);\r
2579         US_Print("/");\r
2580         US_Print(STR_RIGHT);\r
2581         US_Print("/");\r
2582         US_Print(STR_FRWD);\r
2583         US_Print("/");\r
2584         US_Print(STR_BKWD"\n");\r
2585         #else\r
2586         PrintX=CST_START;\r
2587         US_Print(STR_LEFT);\r
2588         PrintX=CST_START+CST_SPC*1;\r
2589         US_Print(STR_RIGHT);\r
2590         PrintX=CST_START+CST_SPC*2;\r
2591         US_Print(STR_FRWD);\r
2592         PrintX=CST_START+CST_SPC*3;\r
2593         US_Print(STR_BKWD"\n");\r
2594         #endif\r
2595         DrawWindow(5,PrintY-1,310,13,BKGDCOLOR);\r
2596         DrawCustKeys(0);\r
2597 #endif\r
2598         //\r
2599         // PICK STARTING POINT IN MENU\r
2600         //\r
2601         if (CusItems.curpos<0)\r
2602                 for (i=0;i<CusItems.amount;i++)\r
2603                         if (CusMenu[i].active)\r
2604                         {\r
2605                                 CusItems.curpos=i;\r
2606                                 break;\r
2607                         }\r
2608 \r
2609 \r
2610         VW_UpdateScreen();\r
2611         MenuFadeIn();\r
2612 }\r
2613 \r
2614 \r
2615 void PrintCustMouse(int i)\r
2616 {\r
2617         int j;\r
2618 \r
2619         for (j=0;j<4;j++)\r
2620                 if (order[i]==buttonmouse[j])\r
2621                 {\r
2622                         PrintX=CST_START+CST_SPC*i;\r
2623                         US_Print(mbarray[j]);\r
2624                         break;\r
2625                 }\r
2626 }\r
2627 \r
2628 void DrawCustMouse(int hilight)\r
2629 {\r
2630         int i,color;\r
2631 \r
2632 \r
2633         color=TEXTCOLOR;\r
2634         if (hilight)\r
2635                 color=HIGHLIGHT;\r
2636         SETFONTCOLOR(color,BKGDCOLOR);\r
2637 \r
2638         if (!mouseenabled)\r
2639         {\r
2640                 SETFONTCOLOR(DEACTIVE,BKGDCOLOR);\r
2641                 CusMenu[0].active=0;\r
2642         }\r
2643         else\r
2644                 CusMenu[0].active=1;\r
2645 \r
2646         PrintY=CST_Y+13*2;\r
2647         for (i=0;i<4;i++)\r
2648                 PrintCustMouse(i);\r
2649 }\r
2650 \r
2651 void PrintCustJoy(int i)\r
2652 {\r
2653         int j;\r
2654 \r
2655         for (j=0;j<4;j++)\r
2656                 if (order[i]==buttonjoy[j])\r
2657                 {\r
2658                         PrintX=CST_START+CST_SPC*i;\r
2659                         US_Print(mbarray[j]);\r
2660                         break;\r
2661                 }\r
2662 }\r
2663 \r
2664 void DrawCustJoy(int hilight)\r
2665 {\r
2666         int i,color;\r
2667 \r
2668 \r
2669         color=TEXTCOLOR;\r
2670         if (hilight)\r
2671                 color=HIGHLIGHT;\r
2672         SETFONTCOLOR(color,BKGDCOLOR);\r
2673 \r
2674         if (!joystickenabled)\r
2675         {\r
2676                 SETFONTCOLOR(DEACTIVE,BKGDCOLOR);\r
2677                 CusMenu[3].active=0;\r
2678         }\r
2679         else\r
2680                 CusMenu[3].active=1;\r
2681 \r
2682         PrintY=CST_Y+13*5;\r
2683         for (i=0;i<4;i++)\r
2684                 PrintCustJoy(i);\r
2685 }\r
2686 \r
2687 \r
2688 void PrintCustKeybd(int i)\r
2689 {\r
2690         PrintX=CST_START+CST_SPC*i;\r
2691         US_Print(IN_GetScanName(buttonscan[order[i]]));\r
2692 }\r
2693 \r
2694 void DrawCustKeybd(int hilight)\r
2695 {\r
2696         int i,color;\r
2697 \r
2698 \r
2699         color=TEXTCOLOR;\r
2700         if (hilight)\r
2701                 color=HIGHLIGHT;\r
2702         SETFONTCOLOR(color,BKGDCOLOR);\r
2703 \r
2704         PrintY=CST_Y+13*8;\r
2705         for (i=0;i<4;i++)\r
2706                 PrintCustKeybd(i);\r
2707 }\r
2708 \r
2709 void PrintCustKeys(int i)\r
2710 {\r
2711         PrintX=CST_START+CST_SPC*i;\r
2712         US_Print(IN_GetScanName(dirscan[moveorder[i]]));\r
2713 }\r
2714 \r
2715 void DrawCustKeys(int hilight)\r
2716 {\r
2717         int i,color;\r
2718 \r
2719 \r
2720         color=TEXTCOLOR;\r
2721         if (hilight)\r
2722                 color=HIGHLIGHT;\r
2723         SETFONTCOLOR(color,BKGDCOLOR);\r
2724 \r
2725         PrintY=CST_Y+13*10;\r
2726         for (i=0;i<4;i++)\r
2727                 PrintCustKeys(i);\r
2728 }\r
2729 \r
2730 \r
2731 ////////////////////////////////////////////////////////////////////\r
2732 //\r
2733 // CHANGE SCREEN VIEWING SIZE\r
2734 //\r
2735 ////////////////////////////////////////////////////////////////////\r
2736 void CP_ChangeView(void)\r
2737 {\r
2738         int exit=0,oldview,newview;\r
2739         ControlInfo ci;\r
2740 \r
2741 \r
2742         WindowX=WindowY=0;\r
2743         WindowW=320;\r
2744         WindowH=200;\r
2745         newview=oldview=viewwidth/16;\r
2746         DrawChangeView(oldview);\r
2747 \r
2748         do\r
2749         {\r
2750                 CheckPause();\r
2751                 ReadAnyControl(&ci);\r
2752                 switch(ci.dir)\r
2753                 {\r
2754                 case dir_South:\r
2755                 case dir_West:\r
2756                         newview--;\r
2757                         if (newview<4)\r
2758                                 newview=4;\r
2759                         ShowViewSize(newview);\r
2760                         VW_UpdateScreen();\r
2761                         SD_PlaySound(HITWALLSND);\r
2762                         TicDelay(10);\r
2763                         break;\r
2764 \r
2765                 case dir_North:\r
2766                 case dir_East:\r
2767                         newview++;\r
2768                         if (newview>19)\r
2769                                 newview=19;\r
2770                         ShowViewSize(newview);\r
2771                         VW_UpdateScreen();\r
2772                         SD_PlaySound(HITWALLSND);\r
2773                         TicDelay(10);\r
2774                         break;\r
2775                 }\r
2776 \r
2777                 #ifndef SPEAR\r
2778                 if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))\r
2779                 #else\r
2780                 if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("debugmode"))\r
2781                 #endif\r
2782                         PicturePause();\r
2783 \r
2784                 if (ci.button0 || Keyboard[sc_Enter])\r
2785                         exit=1;\r
2786                 else\r
2787                 if (ci.button1 || Keyboard[sc_Escape])\r
2788                 {\r
2789                         viewwidth=oldview*16;\r
2790                         SD_PlaySound(ESCPRESSEDSND);\r
2791                         MenuFadeOut();\r
2792                         return;\r
2793                 }\r
2794 \r
2795         } while(!exit);\r
2796 \r
2797 \r
2798         if (oldview!=newview)\r
2799         {\r
2800                 SD_PlaySound (SHOOTSND);\r
2801                 Message(STR_THINK"...");\r
2802                 NewViewSize(newview);\r
2803         }\r
2804 \r
2805         ShootSnd();\r
2806         MenuFadeOut();\r
2807 }\r
2808 \r
2809 \r
2810 /////////////////////////////\r
2811 //\r
2812 // DRAW THE CHANGEVIEW SCREEN\r
2813 //\r
2814 void DrawChangeView(int view)\r
2815 {\r
2816 #ifdef JAPAN\r
2817         CA_CacheScreen(S_CHANGEPIC);\r
2818 \r
2819         ShowViewSize(view);\r
2820 #else\r
2821         VWB_Bar(0,160,320,40,VIEWCOLOR);\r
2822         ShowViewSize(view);\r
2823 \r
2824         PrintY=161;\r
2825         WindowX=0;\r
2826         WindowY=320;\r
2827         SETFONTCOLOR(HIGHLIGHT,BKGDCOLOR);\r
2828 \r
2829         US_CPrint(STR_SIZE1"\n");\r
2830         US_CPrint(STR_SIZE2"\n");\r
2831         US_CPrint(STR_SIZE3);\r
2832 #endif\r
2833         VW_UpdateScreen();\r
2834 \r
2835         MenuFadeIn();\r
2836 }\r
2837 \r
2838 \r
2839 ////////////////////////////////////////////////////////////////////\r
2840 //\r
2841 // QUIT THIS INFERNAL GAME!\r
2842 //\r
2843 ////////////////////////////////////////////////////////////////////\r
2844 void CP_Quit(void)\r
2845 {\r
2846         int i;\r
2847 \r
2848 \r
2849         #ifdef JAPAN\r
2850         if (GetYorN(7,11,C_QUITMSGPIC))\r
2851         #else\r
2852 \r
2853         #ifdef SPANISH\r
2854         if (Confirm(ENDGAMESTR))\r
2855         #else\r
2856         if (Confirm(endStrings[US_RndT()&0x7+(US_RndT()&1)]))\r
2857         #endif\r
2858 \r
2859         #endif\r
2860         {\r
2861                 VW_UpdateScreen();\r
2862                 SD_MusicOff();\r
2863                 SD_StopSound();\r
2864                 MenuFadeOut();\r
2865                 //\r
2866                 // SHUT-UP THE ADLIB\r
2867                 //\r
2868                 for (i=1;i<=0xf5;i++)\r
2869                         alOut(i,0);\r
2870                 Quit(NULL);\r
2871         }\r
2872 \r
2873         DrawMainMenu();\r
2874 }\r
2875 \r
2876 \r
2877 ////////////////////////////////////////////////////////////////////\r
2878 //\r
2879 // HANDLE INTRO SCREEN (SYSTEM CONFIG)\r
2880 //\r
2881 ////////////////////////////////////////////////////////////////////\r
2882 void IntroScreen(void)\r
2883 {\r
2884 #ifdef SPEAR\r
2885 \r
2886 #define MAINCOLOR       0x4f\r
2887 #define EMSCOLOR        0x4f\r
2888 #define XMSCOLOR        0x4f\r
2889 \r
2890 #else\r
2891 \r
2892 #define MAINCOLOR       0x6c\r
2893 #define EMSCOLOR        0x6c\r
2894 #define XMSCOLOR        0x6c\r
2895 \r
2896 #endif\r
2897 #define FILLCOLOR       14\r
2898 \r
2899         long memory,emshere,xmshere;\r
2900         int i,num,ems[10]={100,200,300,400,500,600,700,800,900,1000},\r
2901                 xms[10]={100,200,300,400,500,600,700,800,900,1000},\r
2902                 main[10]={32,64,96,128,160,192,224,256,288,320};\r
2903 \r
2904 \r
2905         //\r
2906         // DRAW MAIN MEMORY\r
2907         //\r
2908         memory=(1023l+mminfo.nearheap+mminfo.farheap)/1024l;\r
2909         for (i=0;i<10;i++)\r
2910                 if (memory>=main[i])\r
2911                         VWB_Bar(49,163-8*i,6,5,MAINCOLOR-i);\r
2912 \r
2913 \r
2914         //\r
2915         // DRAW EMS MEMORY\r
2916         //\r
2917         if (EMSPresent)\r
2918         {\r
2919                 emshere=4l*EMSPagesAvail;\r
2920                 for (i=0;i<10;i++)\r
2921                         if (emshere>=ems[i])\r
2922                                 VWB_Bar(89,163-8*i,6,5,EMSCOLOR-i);\r
2923         }\r
2924 \r
2925         //\r
2926         // DRAW XMS MEMORY\r
2927         //\r
2928         if (XMSPresent)\r
2929         {\r
2930                 xmshere=4l*XMSPagesAvail;\r
2931                 for (i=0;i<10;i++)\r
2932                         if (xmshere>=xms[i])\r
2933                                 VWB_Bar(129,163-8*i,6,5,XMSCOLOR-i);\r
2934         }\r
2935 \r
2936         //\r
2937         // FILL BOXES\r
2938         //\r
2939         if (MousePresent)\r
2940                 VWB_Bar(164,82,12,2,FILLCOLOR);\r
2941 \r
2942         if (JoysPresent[0] || JoysPresent[1])\r
2943                 VWB_Bar(164,105,12,2,FILLCOLOR);\r
2944 \r
2945         if (AdLibPresent && !SoundBlasterPresent)\r
2946                 VWB_Bar(164,128,12,2,FILLCOLOR);\r
2947 \r
2948         if (SoundBlasterPresent)\r
2949                 VWB_Bar(164,151,12,2,FILLCOLOR);\r
2950 \r
2951         if (SoundSourcePresent)\r
2952                 VWB_Bar(164,174,12,2,FILLCOLOR);\r
2953 }\r
2954 \r
2955 \r
2956 ////////////////////////////////////////////////////////////////////\r
2957 ////////////////////////////////////////////////////////////////////\r
2958 //\r
2959 // SUPPORT ROUTINES\r
2960 //\r
2961 ////////////////////////////////////////////////////////////////////\r
2962 ////////////////////////////////////////////////////////////////////\r
2963 \r
2964 ////////////////////////////////////////////////////////////////////\r
2965 //\r
2966 // Clear Menu screens to dark red\r
2967 //\r
2968 ////////////////////////////////////////////////////////////////////\r
2969 void ClearMScreen(void)\r
2970 {\r
2971 #ifndef SPEAR\r
2972         VWB_Bar(0,0,320,200,BORDCOLOR);\r
2973 #else\r
2974         VWB_DrawPic(0,0,C_BACKDROPPIC);\r
2975 #endif\r
2976 }\r
2977 \r
2978 \r
2979 ////////////////////////////////////////////////////////////////////\r
2980 //\r
2981 // Un/Cache a LUMP of graphics\r
2982 //\r
2983 ////////////////////////////////////////////////////////////////////\r
2984 void CacheLump(int lumpstart,int lumpend)\r
2985 {\r
2986  int i;\r
2987 \r
2988  for (i=lumpstart;i<=lumpend;i++)\r
2989    CA_CacheGrChunk(i);\r
2990 }\r
2991 \r
2992 \r
2993 void UnCacheLump(int lumpstart,int lumpend)\r
2994 {\r
2995  int i;\r
2996 \r
2997  for (i=lumpstart;i<=lumpend;i++)\r
2998         if (grsegs[i])\r
2999                 UNCACHEGRCHUNK(i);\r
3000 }\r
3001 \r
3002 \r
3003 ////////////////////////////////////////////////////////////////////\r
3004 //\r
3005 // Draw a window for a menu\r
3006 //\r
3007 ////////////////////////////////////////////////////////////////////\r
3008 void DrawWindow(int x,int y,int w,int h,int wcolor)\r
3009 {\r
3010         VWB_Bar(x,y,w,h,wcolor);\r
3011         DrawOutline(x,y,w,h,BORD2COLOR,DEACTIVE);\r
3012 }\r
3013 \r
3014 \r
3015 void DrawOutline(int x,int y,int w,int h,int color1,int color2)\r
3016 {\r
3017         VWB_Hlin(x,x+w,y,color2);\r
3018         VWB_Vlin(y,y+h,x,color2);\r
3019         VWB_Hlin(x,x+w,y+h,color1);\r
3020         VWB_Vlin(y,y+h,x+w,color1);\r
3021 }\r
3022 \r
3023 \r
3024 ////////////////////////////////////////////////////////////////////\r
3025 //\r
3026 // Setup Control Panel stuff - graphics, etc.\r
3027 //\r
3028 ////////////////////////////////////////////////////////////////////\r
3029 void SetupControlPanel(void)\r
3030 {\r
3031         struct ffblk f;\r
3032         char name[13];\r
3033         int which,i;\r
3034 \r
3035 \r
3036         //\r
3037         // CACHE GRAPHICS & SOUNDS\r
3038         //\r
3039         CA_CacheGrChunk(STARTFONT+1);\r
3040 #ifndef SPEAR\r
3041         CacheLump(CONTROLS_LUMP_START,CONTROLS_LUMP_END);\r
3042 #else\r
3043         CacheLump(BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
3044 #endif\r
3045 \r
3046         SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
3047         fontnumber=1;\r
3048         WindowH=200;\r
3049 \r
3050         if (!ingame)\r
3051                 CA_LoadAllSounds();\r
3052         else\r
3053                 MainMenu[savegame].active=1;\r
3054 \r
3055         //\r
3056         // SEE WHICH SAVE GAME FILES ARE AVAILABLE & READ STRING IN\r
3057         //\r
3058         strcpy(name,SaveName);\r
3059         if (!findfirst(name,&f,0))\r
3060                 do\r
3061                 {\r
3062                         which=f.ff_name[7]-'0';\r
3063                         if (which<10)\r
3064                         {\r
3065                                 int handle;\r
3066                                 char temp[32];\r
3067 \r
3068                                 SaveGamesAvail[which]=1;\r
3069                                 handle=open(f.ff_name,O_BINARY);\r
3070                                 read(handle,temp,32);\r
3071                                 close(handle);\r
3072                                 strcpy(&SaveGameNames[which][0],temp);\r
3073                         }\r
3074                 } while(!findnext(&f));\r
3075 \r
3076         //\r
3077         // CENTER MOUSE\r
3078         //\r
3079         _CX=_DX=CENTER;\r
3080         Mouse(4);\r
3081 }\r
3082 \r
3083 \r
3084 ////////////////////////////////////////////////////////////////////\r
3085 //\r
3086 // Clean up all the Control Panel stuff\r
3087 //\r
3088 ////////////////////////////////////////////////////////////////////\r
3089 void CleanupControlPanel(void)\r
3090 {\r
3091 #ifndef SPEAR\r
3092         UnCacheLump(CONTROLS_LUMP_START,CONTROLS_LUMP_END);\r
3093 #else\r
3094         UnCacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
3095 #endif\r
3096 \r
3097         fontnumber = 0;\r
3098 }\r
3099 \r
3100 \r
3101 ////////////////////////////////////////////////////////////////////\r
3102 //\r
3103 // Handle moving gun around a menu\r
3104 //\r
3105 ////////////////////////////////////////////////////////////////////\r
3106 int HandleMenu(CP_iteminfo *item_i,CP_itemtype far *items,void (*routine)(int w))\r
3107 {\r
3108         char key;\r
3109         static int redrawitem=1,lastitem=-1;\r
3110         int i,x,y,basey,exit,which,shape,timer;\r
3111         ControlInfo ci;\r
3112 \r
3113 \r
3114         which=item_i->curpos;\r
3115         x=item_i->x&-8;\r
3116         basey=item_i->y-2;\r
3117         y=basey+which*13;\r
3118 \r
3119         VWB_DrawPic(x,y,C_CURSOR1PIC);\r
3120         SetTextColor(items+which,1);\r
3121         if (redrawitem)\r
3122         {\r
3123                 PrintX=item_i->x+item_i->indent;\r
3124                 PrintY=item_i->y+which*13;\r
3125                 US_Print((items+which)->string);\r
3126         }\r
3127         //\r
3128         // CALL CUSTOM ROUTINE IF IT IS NEEDED\r
3129         //\r
3130         if (routine)\r
3131                 routine(which);\r
3132         VW_UpdateScreen();\r
3133 \r
3134         shape=C_CURSOR1PIC;\r
3135         timer=8;\r
3136         exit=0;\r
3137         TimeCount=0;\r
3138         IN_ClearKeysDown();\r
3139 \r
3140 \r
3141         do\r
3142         {\r
3143                 //\r
3144                 // CHANGE GUN SHAPE\r
3145                 //\r
3146                 if (TimeCount>timer)\r
3147                 {\r
3148                         TimeCount=0;\r
3149                         if (shape==C_CURSOR1PIC)\r
3150                         {\r
3151                                 shape=C_CURSOR2PIC;\r
3152                                 timer=8;\r
3153                         }\r
3154                         else\r
3155                         {\r
3156                                 shape=C_CURSOR1PIC;\r
3157                                 timer=70;\r
3158                         }\r
3159                         VWB_DrawPic(x,y,shape);\r
3160                         if (routine)\r
3161                                 routine(which);\r
3162                         VW_UpdateScreen();\r
3163                 }\r
3164 \r
3165                 CheckPause();\r
3166 \r
3167                 //\r
3168                 // SEE IF ANY KEYS ARE PRESSED FOR INITIAL CHAR FINDING\r
3169                 //\r
3170                 key=LastASCII;\r
3171                 if (key)\r
3172                 {\r
3173                         int ok=0;\r
3174 \r
3175                         //\r
3176                         // CHECK FOR SCREEN CAPTURE\r
3177                         //\r
3178                         #ifndef SPEAR\r
3179                         if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))\r
3180                         #else\r
3181                         if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("debugmode"))\r
3182                         #endif\r
3183                                 PicturePause();\r
3184 \r
3185 \r
3186                         if (key>='a')\r
3187                                 key-='a'-'A';\r
3188 \r
3189                         for (i=which+1;i<item_i->amount;i++)\r
3190                                 if ((items+i)->active && (items+i)->string[0]==key)\r
3191                                 {\r
3192                                         EraseGun(item_i,items,x,y,which);\r
3193                                         which=i;\r
3194                                         DrawGun(item_i,items,x,&y,which,basey,routine);\r
3195                                         ok=1;\r
3196                                         IN_ClearKeysDown();\r
3197                                         break;\r
3198                                 }\r
3199 \r
3200                         //\r
3201                         // DIDN'T FIND A MATCH FIRST TIME THRU. CHECK AGAIN.\r
3202                         //\r
3203                         if (!ok)\r
3204                         {\r
3205                                 for (i=0;i<which;i++)\r
3206                                         if ((items+i)->active && (items+i)->string[0]==key)\r
3207                                         {\r
3208                                                 EraseGun(item_i,items,x,y,which);\r
3209                                                 which=i;\r
3210                                                 DrawGun(item_i,items,x,&y,which,basey,routine);\r
3211                                                 IN_ClearKeysDown();\r
3212                                                 break;\r
3213                                         }\r
3214                         }\r
3215                 }\r
3216 \r
3217                 //\r
3218                 // GET INPUT\r
3219                 //\r
3220                 ReadAnyControl(&ci);\r
3221                 switch(ci.dir)\r
3222                 {\r
3223                         ////////////////////////////////////////////////\r
3224                         //\r
3225                         // MOVE UP\r
3226                         //\r
3227                         case dir_North:\r
3228 \r
3229                         EraseGun(item_i,items,x,y,which);\r
3230 \r
3231                         //\r
3232                         // ANIMATE HALF-STEP\r
3233                         //\r
3234                         if (which && (items+which-1)->active)\r
3235                         {\r
3236                                 y-=6;\r
3237                                 DrawHalfStep(x,y);\r
3238                         }\r
3239 \r
3240                         //\r
3241                         // MOVE TO NEXT AVAILABLE SPOT\r
3242                         //\r
3243                         do\r
3244                         {\r
3245                                 if (!which)\r
3246                                         which=item_i->amount-1;\r
3247                                 else\r
3248                                         which--;\r
3249                         } while(!(items+which)->active);\r
3250 \r
3251                         DrawGun(item_i,items,x,&y,which,basey,routine);\r
3252                         //\r
3253                         // WAIT FOR BUTTON-UP OR DELAY NEXT MOVE\r
3254                         //\r
3255                         TicDelay(20);\r
3256                         break;\r
3257 \r
3258                         ////////////////////////////////////////////////\r
3259                         //\r
3260                         // MOVE DOWN\r
3261                         //\r
3262                         case dir_South:\r
3263 \r
3264                         EraseGun(item_i,items,x,y,which);\r
3265                         //\r
3266                         // ANIMATE HALF-STEP\r
3267                         //\r
3268                         if (which!=item_i->amount-1 && (items+which+1)->active)\r
3269                         {\r
3270                                 y+=6;\r
3271                                 DrawHalfStep(x,y);\r
3272                         }\r
3273 \r
3274                         do\r
3275                         {\r
3276                                 if (which==item_i->amount-1)\r
3277                                         which=0;\r
3278                                 else\r
3279                                         which++;\r
3280                         } while(!(items+which)->active);\r
3281 \r
3282                         DrawGun(item_i,items,x,&y,which,basey,routine);\r
3283 \r
3284                         //\r
3285                         // WAIT FOR BUTTON-UP OR DELAY NEXT MOVE\r
3286                         //\r
3287                         TicDelay(20);\r
3288                         break;\r
3289                 }\r
3290 \r
3291                 if (ci.button0 ||\r
3292                         Keyboard[sc_Space] ||\r
3293                         Keyboard[sc_Enter])\r
3294                                 exit=1;\r
3295 \r
3296                 if (ci.button1 ||\r
3297                         Keyboard[sc_Escape])\r
3298                                 exit=2;\r
3299 \r
3300         } while(!exit);\r
3301 \r
3302 \r
3303         IN_ClearKeysDown();\r
3304 \r
3305         //\r
3306         // ERASE EVERYTHING\r
3307         //\r
3308         if (lastitem!=which)\r
3309         {\r
3310                 VWB_Bar(x-1,y,25,16,BKGDCOLOR);\r
3311                 PrintX=item_i->x+item_i->indent;\r
3312                 PrintY=item_i->y+which*13;\r
3313                 US_Print((items+which)->string);\r
3314                 redrawitem=1;\r
3315         }\r
3316         else\r
3317                 redrawitem=0;\r
3318 \r
3319         if (routine)\r
3320                 routine(which);\r
3321         VW_UpdateScreen();\r
3322 \r
3323         item_i->curpos=which;\r
3324 \r
3325         lastitem=which;\r
3326         switch(exit)\r
3327         {\r
3328                 case 1:\r
3329                         //\r
3330                         // CALL THE ROUTINE\r
3331                         //\r
3332                         if ((items+which)->routine!=NULL)\r
3333                         {\r
3334                                 ShootSnd();\r
3335                                 MenuFadeOut();\r
3336                                 (items+which)->routine(0);\r
3337                         }\r
3338                         return which;\r
3339 \r
3340                 case 2:\r
3341                         SD_PlaySound(ESCPRESSEDSND);\r
3342                         return -1;\r
3343         }\r
3344 \r
3345         return 0; // JUST TO SHUT UP THE ERROR MESSAGES!\r
3346 }\r
3347 \r
3348 \r
3349 //\r
3350 // ERASE GUN & DE-HIGHLIGHT STRING\r
3351 //\r
3352 void EraseGun(CP_iteminfo *item_i,CP_itemtype far *items,int x,int y,int which)\r
3353 {\r
3354         VWB_Bar(x-1,y,25,16,BKGDCOLOR);\r
3355         SetTextColor(items+which,0);\r
3356 \r
3357         PrintX=item_i->x+item_i->indent;\r
3358         PrintY=item_i->y+which*13;\r
3359         US_Print((items+which)->string);\r
3360         VW_UpdateScreen();\r
3361 }\r
3362 \r
3363 \r
3364 //\r
3365 // DRAW HALF STEP OF GUN TO NEXT POSITION\r
3366 //\r
3367 void DrawHalfStep(int x,int y)\r
3368 {\r
3369         VWB_DrawPic(x,y,C_CURSOR1PIC);\r
3370         VW_UpdateScreen();\r
3371         SD_PlaySound(MOVEGUN1SND);\r
3372         TimeCount=0;\r
3373         while(TimeCount<8);\r
3374 }\r
3375 \r
3376 \r
3377 //\r
3378 // DRAW GUN AT NEW POSITION\r
3379 //\r
3380 void DrawGun(CP_iteminfo *item_i,CP_itemtype far *items,int x,int *y,int which,int basey,void (*routine)(int w))\r
3381 {\r
3382         VWB_Bar(x-1,*y,25,16,BKGDCOLOR);\r
3383         *y=basey+which*13;\r
3384         VWB_DrawPic(x,*y,C_CURSOR1PIC);\r
3385         SetTextColor(items+which,1);\r
3386 \r
3387         PrintX=item_i->x+item_i->indent;\r
3388         PrintY=item_i->y+which*13;\r
3389         US_Print((items+which)->string);\r
3390 \r
3391         //\r
3392         // CALL CUSTOM ROUTINE IF IT IS NEEDED\r
3393         //\r
3394         if (routine)\r
3395                 routine(which);\r
3396         VW_UpdateScreen();\r
3397         SD_PlaySound(MOVEGUN2SND);\r
3398 }\r
3399 \r
3400 ////////////////////////////////////////////////////////////////////\r
3401 //\r
3402 // DELAY FOR AN AMOUNT OF TICS OR UNTIL CONTROLS ARE INACTIVE\r
3403 //\r
3404 ////////////////////////////////////////////////////////////////////\r
3405 void TicDelay(int count)\r
3406 {\r
3407         ControlInfo ci;\r
3408 \r
3409 \r
3410         TimeCount=0;\r
3411         do\r
3412         {\r
3413                 ReadAnyControl(&ci);\r
3414         } while(TimeCount<count && ci.dir!=dir_None);\r
3415 }\r
3416 \r
3417 \r
3418 ////////////////////////////////////////////////////////////////////\r
3419 //\r
3420 // Draw a menu\r
3421 //\r
3422 ////////////////////////////////////////////////////////////////////\r
3423 void DrawMenu(CP_iteminfo *item_i,CP_itemtype far *items)\r
3424 {\r
3425         int i,which=item_i->curpos;\r
3426 \r
3427 \r
3428         WindowX=PrintX=item_i->x+item_i->indent;\r
3429         WindowY=PrintY=item_i->y;\r
3430         WindowW=320;\r
3431         WindowH=200;\r
3432 \r
3433         for (i=0;i<item_i->amount;i++)\r
3434         {\r
3435                 SetTextColor(items+i,which==i);\r
3436 \r
3437                 PrintY=item_i->y+i*13;\r
3438                 if ((items+i)->active)\r
3439                         US_Print((items+i)->string);\r
3440                 else\r
3441                 {\r
3442                         SETFONTCOLOR(DEACTIVE,BKGDCOLOR);\r
3443                         US_Print((items+i)->string);\r
3444                         SETFONTCOLOR(TEXTCOLOR,BKGDCOLOR);\r
3445                 }\r
3446 \r
3447                 US_Print("\n");\r
3448         }\r
3449 }\r
3450 \r
3451 \r
3452 ////////////////////////////////////////////////////////////////////\r
3453 //\r
3454 // SET TEXT COLOR (HIGHLIGHT OR NO)\r
3455 //\r
3456 ////////////////////////////////////////////////////////////////////\r
3457 void SetTextColor(CP_itemtype far *items,int hlight)\r
3458 {\r
3459         if (hlight)\r
3460                 {SETFONTCOLOR(color_hlite[items->active],BKGDCOLOR);}\r
3461         else\r
3462                 {SETFONTCOLOR(color_norml[items->active],BKGDCOLOR);}\r
3463 }\r
3464 \r
3465 \r
3466 ////////////////////////////////////////////////////////////////////\r
3467 //\r
3468 // WAIT FOR CTRLKEY-UP OR BUTTON-UP\r
3469 //\r
3470 ////////////////////////////////////////////////////////////////////\r
3471 void WaitKeyUp(void)\r
3472 {\r
3473         ControlInfo ci;\r
3474         while(ReadAnyControl(&ci),      ci.button0|\r
3475                                                                 ci.button1|\r
3476                                                                 ci.button2|\r
3477                                                                 ci.button3|\r
3478                                                                 Keyboard[sc_Space]|\r
3479                                                                 Keyboard[sc_Enter]|\r
3480                                                                 Keyboard[sc_Escape]);\r
3481 }\r
3482 \r
3483 \r
3484 ////////////////////////////////////////////////////////////////////\r
3485 //\r
3486 // READ KEYBOARD, JOYSTICK AND MOUSE FOR INPUT\r
3487 //\r
3488 ////////////////////////////////////////////////////////////////////\r
3489 void ReadAnyControl(ControlInfo *ci)\r
3490 {\r
3491         int mouseactive=0;\r
3492 \r
3493 \r
3494         IN_ReadControl(0,ci);\r
3495 \r
3496         if (mouseenabled)\r
3497         {\r
3498                 int mousey,mousex;\r
3499 \r
3500 \r
3501                 // READ MOUSE MOTION COUNTERS\r
3502                 // RETURN DIRECTION\r
3503                 // HOME MOUSE\r
3504                 // CHECK MOUSE BUTTONS\r
3505 \r
3506                 Mouse(3);\r
3507                 mousex=_CX;\r
3508                 mousey=_DX;\r
3509 \r
3510                 if (mousey<CENTER-SENSITIVE)\r
3511                 {\r
3512                         ci->dir=dir_North;\r
3513                         _CX=_DX=CENTER;\r
3514                         Mouse(4);\r
3515                         mouseactive=1;\r
3516                 }\r
3517                 else\r
3518                 if (mousey>CENTER+SENSITIVE)\r
3519                 {\r
3520                         ci->dir=dir_South;\r
3521                         _CX=_DX=CENTER;\r
3522                         Mouse(4);\r
3523                         mouseactive=1;\r
3524                 }\r
3525 \r
3526                 if (mousex<CENTER-SENSITIVE)\r
3527                 {\r
3528                         ci->dir=dir_West;\r
3529                         _CX=_DX=CENTER;\r
3530                         Mouse(4);\r
3531                         mouseactive=1;\r
3532                 }\r
3533                 else\r
3534                 if (mousex>CENTER+SENSITIVE)\r
3535                 {\r
3536                         ci->dir=dir_East;\r
3537                         _CX=_DX=CENTER;\r
3538                         Mouse(4);\r
3539                         mouseactive=1;\r
3540                 }\r
3541 \r
3542                 if (IN_MouseButtons())\r
3543                 {\r
3544                         ci->button0=IN_MouseButtons()&1;\r
3545                         ci->button1=IN_MouseButtons()&2;\r
3546                         ci->button2=IN_MouseButtons()&4;\r
3547                         ci->button3=false;\r
3548                         mouseactive=1;\r
3549                 }\r
3550         }\r
3551 \r
3552         if (joystickenabled && !mouseactive)\r
3553         {\r
3554                 int jx,jy,jb;\r
3555 \r
3556 \r
3557                 INL_GetJoyDelta(joystickport,&jx,&jy);\r
3558                 if (jy<-SENSITIVE)\r
3559                         ci->dir=dir_North;\r
3560                 else\r
3561                 if (jy>SENSITIVE)\r
3562                         ci->dir=dir_South;\r
3563 \r
3564                 if (jx<-SENSITIVE)\r
3565                         ci->dir=dir_West;\r
3566                 else\r
3567                 if (jx>SENSITIVE)\r
3568                         ci->dir=dir_East;\r
3569 \r
3570                 jb=IN_JoyButtons();\r
3571                 if (jb)\r
3572                 {\r
3573                         ci->button0=jb&1;\r
3574                         ci->button1=jb&2;\r
3575                         if (joypadenabled)\r
3576                         {\r
3577                                 ci->button2=jb&4;\r
3578                                 ci->button3=jb&8;\r
3579                         }\r
3580                         else\r
3581                                 ci->button2=ci->button3=false;\r
3582                 }\r
3583         }\r
3584 }\r
3585 \r
3586 \r
3587 ////////////////////////////////////////////////////////////////////\r
3588 //\r
3589 // DRAW DIALOG AND CONFIRM YES OR NO TO QUESTION\r
3590 //\r
3591 ////////////////////////////////////////////////////////////////////\r
3592 int Confirm(char far *string)\r
3593 {\r
3594         int xit=0,i,x,y,tick=0,time,whichsnd[2]={ESCPRESSEDSND,SHOOTSND};\r
3595 \r
3596 \r
3597         Message(string);\r
3598         IN_ClearKeysDown();\r
3599 \r
3600         //\r
3601         // BLINK CURSOR\r
3602         //\r
3603         x=PrintX;\r
3604         y=PrintY;\r
3605         TimeCount=0;\r
3606 \r
3607         do\r
3608         {\r
3609                 if (TimeCount>=10)\r
3610                 {\r
3611                         switch(tick)\r
3612                         {\r
3613                                 case 0:\r
3614                                         VWB_Bar(x,y,8,13,TEXTCOLOR);\r
3615                                         break;\r
3616                                 case 1:\r
3617                                         PrintX=x;\r
3618                                         PrintY=y;\r
3619                                         US_Print("_");\r
3620                         }\r
3621                         VW_UpdateScreen();\r
3622                         tick^=1;\r
3623                         TimeCount=0;\r
3624                 }\r
3625 \r
3626                 #ifndef SPEAR\r
3627                 if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))\r
3628                         PicturePause();\r
3629                 #endif\r
3630 \r
3631         #ifdef SPANISH\r
3632         } while(!Keyboard[sc_S] && !Keyboard[sc_N] && !Keyboard[sc_Escape]);\r
3633         #else\r
3634         } while(!Keyboard[sc_Y] && !Keyboard[sc_N] && !Keyboard[sc_Escape]);\r
3635         #endif\r
3636 \r
3637         #ifdef SPANISH\r
3638         if (Keyboard[sc_S])\r
3639         {\r
3640                 xit=1;\r
3641                 ShootSnd();\r
3642         }\r
3643 \r
3644         while(Keyboard[sc_S] || Keyboard[sc_N] || Keyboard[sc_Escape]);\r
3645 \r
3646         #else\r
3647 \r
3648         if (Keyboard[sc_Y])\r
3649         {\r
3650                 xit=1;\r
3651                 ShootSnd();\r
3652         }\r
3653 \r
3654         while(Keyboard[sc_Y] || Keyboard[sc_N] || Keyboard[sc_Escape]);\r
3655         #endif\r
3656 \r
3657         IN_ClearKeysDown();\r
3658         SD_PlaySound(whichsnd[xit]);\r
3659         return xit;\r
3660 }\r
3661 \r
3662 #ifdef JAPAN\r
3663 ////////////////////////////////////////////////////////////////////\r
3664 //\r
3665 // DRAW MESSAGE & GET Y OR N\r
3666 //\r
3667 ////////////////////////////////////////////////////////////////////\r
3668 int GetYorN(int x,int y,int pic)\r
3669 {\r
3670         int xit=0,whichsnd[2]={ESCPRESSEDSND,SHOOTSND};\r
3671 \r
3672 \r
3673         CA_CacheGrChunk(pic);\r
3674         VWB_DrawPic(x * 8,y * 8,pic);\r
3675         UNCACHEGRCHUNK(pic);\r
3676         VW_UpdateScreen();\r
3677         IN_ClearKeysDown();\r
3678 \r
3679         do\r
3680         {\r
3681                 #ifndef SPEAR\r
3682                 if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))\r
3683                         PicturePause();\r
3684                 #endif\r
3685 \r
3686         #ifdef SPANISH\r
3687         } while(!Keyboard[sc_S] && !Keyboard[sc_N] && !Keyboard[sc_Escape]);\r
3688         #else\r
3689         } while(!Keyboard[sc_Y] && !Keyboard[sc_N] && !Keyboard[sc_Escape]);\r
3690         #endif\r
3691 \r
3692         #ifdef SPANISH\r
3693         if (Keyboard[sc_S])\r
3694         {\r
3695                 xit=1;\r
3696                 ShootSnd();\r
3697         }\r
3698 \r
3699         while(Keyboard[sc_S] || Keyboard[sc_N] || Keyboard[sc_Escape]);\r
3700 \r
3701         #else\r
3702 \r
3703         if (Keyboard[sc_Y])\r
3704         {\r
3705                 xit=1;\r
3706                 ShootSnd();\r
3707         }\r
3708 \r
3709         while(Keyboard[sc_Y] || Keyboard[sc_N] || Keyboard[sc_Escape]);\r
3710         #endif\r
3711 \r
3712         IN_ClearKeysDown();\r
3713         SD_PlaySound(whichsnd[xit]);\r
3714         return xit;\r
3715 }\r
3716 #endif\r
3717 \r
3718 \r
3719 ////////////////////////////////////////////////////////////////////\r
3720 //\r
3721 // PRINT A MESSAGE IN A WINDOW\r
3722 //\r
3723 ////////////////////////////////////////////////////////////////////\r
3724 void Message(char far *string)\r
3725 {\r
3726         int h=0,w=0,mw=0,i,x,y,time;\r
3727         fontstruct _seg *font;\r
3728 \r
3729 \r
3730         CA_CacheGrChunk (STARTFONT+1);\r
3731         fontnumber=1;\r
3732         font=grsegs[STARTFONT+fontnumber];\r
3733         h=font->height;\r
3734         for (i=0;i<_fstrlen(string);i++)\r
3735                 if (string[i]=='\n')\r
3736                 {\r
3737                         if (w>mw)\r
3738                                 mw=w;\r
3739                         w=0;\r
3740                         h+=font->height;\r
3741                 }\r
3742                 else\r
3743                         w+=font->width[string[i]];\r
3744 \r
3745         if (w+10>mw)\r
3746                 mw=w+10;\r
3747 \r
3748         PrintY=(WindowH/2)-h/2;\r
3749         PrintX=WindowX=160-mw/2;\r
3750 \r
3751         DrawWindow(WindowX-5,PrintY-5,mw+10,h+10,TEXTCOLOR);\r
3752         DrawOutline(WindowX-5,PrintY-5,mw+10,h+10,0,HIGHLIGHT);\r
3753         SETFONTCOLOR(0,TEXTCOLOR);\r
3754         US_Print(string);\r
3755         VW_UpdateScreen();\r
3756 }\r
3757 \r
3758 \r
3759 ////////////////////////////////////////////////////////////////////\r
3760 //\r
3761 // THIS MAY BE FIXED A LITTLE LATER...\r
3762 //\r
3763 ////////////////////////////////////////////////////////////////////\r
3764 static  int     lastmusic;\r
3765 \r
3766 void StartCPMusic(int song)\r
3767 {\r
3768         musicnames      chunk;\r
3769 \r
3770         if (audiosegs[STARTMUSIC + lastmusic])  // JDC\r
3771                 MM_FreePtr ((memptr *)&audiosegs[STARTMUSIC + lastmusic]);\r
3772         lastmusic = song;\r
3773 \r
3774         SD_MusicOff();\r
3775         chunk = song;\r
3776 \r
3777         MM_BombOnError (false);\r
3778         CA_CacheAudioChunk(STARTMUSIC + chunk);\r
3779         MM_BombOnError (true);\r
3780         if (mmerror)\r
3781                 mmerror = false;\r
3782         else\r
3783         {\r
3784                 MM_SetLock(&((memptr)audiosegs[STARTMUSIC + chunk]),true);\r
3785                 SD_StartMusic((MusicGroup far *)audiosegs[STARTMUSIC + chunk]);\r
3786         }\r
3787 }\r
3788 \r
3789 void FreeMusic (void)\r
3790 {\r
3791         if (audiosegs[STARTMUSIC + lastmusic])  // JDC\r
3792                 MM_FreePtr ((memptr *)&audiosegs[STARTMUSIC + lastmusic]);\r
3793 }\r
3794 \r
3795 \r
3796 ///////////////////////////////////////////////////////////////////////////\r
3797 //\r
3798 //      IN_GetScanName() - Returns a string containing the name of the\r
3799 //              specified scan code\r
3800 //\r
3801 ///////////////////////////////////////////////////////////////////////////\r
3802 byte *\r
3803 IN_GetScanName(ScanCode scan)\r
3804 {\r
3805         byte            **p;\r
3806         ScanCode        far *s;\r
3807 \r
3808         for (s = ExtScanCodes,p = ExtScanNames;*s;p++,s++)\r
3809                 if (*s == scan)\r
3810                         return(*p);\r
3811 \r
3812         return(ScanNames[scan]);\r
3813 }\r
3814 \r
3815 \r
3816 ///////////////////////////////////////////////////////////////////////////\r
3817 //\r
3818 // CHECK FOR PAUSE KEY (FOR MUSIC ONLY)\r
3819 //\r
3820 ///////////////////////////////////////////////////////////////////////////\r
3821 void CheckPause(void)\r
3822 {\r
3823         if (Paused)\r
3824         {\r
3825                 switch(SoundStatus)\r
3826                 {\r
3827                         case 0: SD_MusicOn(); break;\r
3828                         case 1: SD_MusicOff(); break;\r
3829                 }\r
3830 \r
3831                 SoundStatus^=1;\r
3832                 VW_WaitVBL(3);\r
3833                 IN_ClearKeysDown();\r
3834                 Paused=false;\r
3835  }\r
3836 }\r
3837 \r
3838 \r
3839 ///////////////////////////////////////////////////////////////////////////\r
3840 //\r
3841 // DRAW GUN CURSOR AT CORRECT POSITION IN MENU\r
3842 //\r
3843 ///////////////////////////////////////////////////////////////////////////\r
3844 void DrawMenuGun(CP_iteminfo *iteminfo)\r
3845 {\r
3846         int x,y;\r
3847 \r
3848 \r
3849         x=iteminfo->x;\r
3850         y=iteminfo->y+iteminfo->curpos*13-2;\r
3851         VWB_DrawPic(x,y,C_CURSOR1PIC);\r
3852 }\r
3853 \r
3854 \r
3855 ///////////////////////////////////////////////////////////////////////////\r
3856 //\r
3857 // DRAW SCREEN TITLE STRIPES\r
3858 //\r
3859 ///////////////////////////////////////////////////////////////////////////\r
3860 void DrawStripes(int y)\r
3861 {\r
3862 #ifndef SPEAR\r
3863         VWB_Bar(0,y,320,24,0);\r
3864         VWB_Hlin(0,319,y+22,STRIPE);\r
3865 #else\r
3866         VWB_Bar(0,y,320,22,0);\r
3867         VWB_Hlin(0,319,y+23,0);\r
3868 #endif\r
3869 }\r
3870 \r
3871 void ShootSnd(void)\r
3872 {\r
3873         SD_PlaySound(SHOOTSND);\r
3874 }\r
3875 \r
3876 \r
3877 ///////////////////////////////////////////////////////////////////////////\r
3878 //\r
3879 // CHECK FOR EPISODES\r
3880 //\r
3881 ///////////////////////////////////////////////////////////////////////////\r
3882 void CheckForEpisodes(void)\r
3883 {\r
3884         struct ffblk f;\r
3885 \r
3886 //\r
3887 // JAPANESE VERSION\r
3888 //\r
3889 #ifdef JAPAN\r
3890 #ifdef JAPDEMO\r
3891         if (!findfirst("*.WJ1",&f,FA_ARCH))\r
3892         {\r
3893                 strcpy(extension,"WJ1");\r
3894 #else\r
3895         if (!findfirst("*.WJ6",&f,FA_ARCH))\r
3896         {\r
3897                 strcpy(extension,"WJ6");\r
3898 #endif\r
3899                 strcat(configname,extension);\r
3900                 strcat(SaveName,extension);\r
3901                 strcat(PageFileName,extension);\r
3902                 strcat(audioname,extension);\r
3903                 strcat(demoname,extension);\r
3904                 EpisodeSelect[1] =\r
3905                 EpisodeSelect[2] =\r
3906                 EpisodeSelect[3] =\r
3907                 EpisodeSelect[4] =\r
3908                 EpisodeSelect[5] = 1;\r
3909         }\r
3910         else\r
3911                 Quit("NO JAPANESE WOLFENSTEIN 3-D DATA FILES to be found!");\r
3912 #else\r
3913 \r
3914 //\r
3915 // ENGLISH\r
3916 //\r
3917 #ifndef UPLOAD\r
3918 #ifndef SPEAR\r
3919         if (!findfirst("*.WL6",&f,FA_ARCH))\r
3920         {\r
3921                 strcpy(extension,"WL6");\r
3922                 NewEmenu[2].active =\r
3923                 NewEmenu[4].active =\r
3924                 NewEmenu[6].active =\r
3925                 NewEmenu[8].active =\r
3926                 NewEmenu[10].active =\r
3927                 EpisodeSelect[1] =\r
3928                 EpisodeSelect[2] =\r
3929                 EpisodeSelect[3] =\r
3930                 EpisodeSelect[4] =\r
3931                 EpisodeSelect[5] = 1;\r
3932         }\r
3933         else\r
3934         if (!findfirst("*.WL3",&f,FA_ARCH))\r
3935         {\r
3936                 strcpy(extension,"WL3");\r
3937                 NewEmenu[2].active =\r
3938                 NewEmenu[4].active =\r
3939                 EpisodeSelect[1] =\r
3940                 EpisodeSelect[2] = 1;\r
3941         }\r
3942         else\r
3943 #endif\r
3944 #endif\r
3945 \r
3946 \r
3947 \r
3948 #ifdef SPEAR\r
3949 #ifndef SPEARDEMO\r
3950         if (!findfirst("*.SOD",&f,FA_ARCH))\r
3951         {\r
3952                 strcpy(extension,"SOD");\r
3953         }\r
3954         else\r
3955                 Quit("NO SPEAR OF DESTINY DATA FILES TO BE FOUND!");\r
3956 #else\r
3957         if (!findfirst("*.SDM",&f,FA_ARCH))\r
3958         {\r
3959                 strcpy(extension,"SDM");\r
3960         }\r
3961         else\r
3962                 Quit("NO SPEAR OF DESTINY DEMO DATA FILES TO BE FOUND!");\r
3963 #endif\r
3964 \r
3965 #else\r
3966         if (!findfirst("*.WL1",&f,FA_ARCH))\r
3967         {\r
3968                 strcpy(extension,"WL1");\r
3969         }\r
3970         else\r
3971                 Quit("NO WOLFENSTEIN 3-D DATA FILES to be found!");\r
3972 #endif\r
3973 \r
3974         strcat(configname,extension);\r
3975         strcat(SaveName,extension);\r
3976         strcat(PageFileName,extension);\r
3977         strcat(audioname,extension);\r
3978         strcat(demoname,extension);\r
3979 #ifndef SPEAR\r
3980 #ifndef GOODTIMES\r
3981         strcat(helpfilename,extension);\r
3982 #endif\r
3983         strcat(endfilename,extension);\r
3984 #endif\r
3985 #endif\r
3986 }\r