1 /*
2 Copyright (C) 1994-1995 Apogee Software, Ltd.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 //******************************************************************************
21 //
22 // RT_MENU.C
23 //    Contains the menu stuff!
24 //
25 //******************************************************************************
26 
27 
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <stdarg.h>
31 #include <fcntl.h>
32 #include <string.h>
33 #include <ctype.h>
34 
35 #if PLATFORM_DOS
36 #include <conio.h>
37 #include <dos.h>
38 #include <io.h>
39 #elif PLATFORM_UNIX
40 #include <unistd.h>
41 #endif
42 
43 #include <sys/types.h>
44 #include <sys/stat.h>
45 
46 #include "rt_def.h"
47 #include "_rt_menu.h"
48 #include "rt_menu.h"
49 #include "rt_sound.h"
50 #include "fx_man.h"
51 #include "rt_build.h"
52 #include "rt_in.h"
53 #include "isr.h"
54 #include "z_zone.h"
55 #include "w_wad.h"
56 #include "rt_util.h"
57 #include "rt_main.h"
58 #include "rt_playr.h"
59 #include "rt_rand.h"
60 #include "rt_game.h"
61 #include "rt_floor.h"
62 #include "rt_draw.h"
63 #include "rt_view.h"
64 #include "rt_str.h"
65 #include "rt_vid.h"
66 #include "rt_ted.h"
67 #include "rt_com.h"
68 #include "lumpy.h"
69 #include "rt_cfg.h"
70 #include "version.h"
71 #include "modexlib.h"
72 #include "rt_msg.h"
73 #include "rt_net.h"
74 #include "rt_spbal.h"
75 #include "rt_scale.h"
76 
77 #include "rt_battl.h"
78 #include "develop.h"
79 //MED
80 #include "memcheck.h"
81 
82 
83 //******************************************************************************
84 //
85 // GLOBALS
86 //
87 //******************************************************************************
88 
89 #define DELAYAMT  2
90 
91 #define SNDCARDS  12
92 
93 #define CP_NO     0
94 #define CP_ESC    -1
95 #define CP_YES    1
96 
97 int CP_Acknowledge;
98 
99 boolean POK = false;
100 char    pword[ 13 ];
101 
102 boolean ingame    = false;
103 boolean inmenu    = false;
104 boolean pickquick = false;
105 boolean NewGame   = false;
106 
107 //
108 // Global window coords
109 //
110 int PrintX;
111 int PrintY;
112 int WindowX;
113 int WindowY;
114 int WindowH = 160;
115 int WindowW;
116 
117 int px;
118 int py;
119 int bufferheight;
120 int bufferwidth;
121 
122 cfont_t *IFont;
123 font_t  *CurrentFont;
124 font_t  *newfont1;
125 font_t  *smallfont;
126 font_t  *bigfont;
127 font_t  *tinyfont;
128 
129 boolean loadedgame = false;
130 
131 battle_type BATTLE_Options[ battle_NumBattleModes ];
132 
133 int quicksaveslot=-1;
134 
135 //******************************************************************************
136 //
137 // LOCALS
138 //
139 //******************************************************************************
140 
141 char order[ 21 ] = {
142    di_west, di_east, di_north, di_south, bt_run, bt_use, bt_attack,
143    bt_strafe, bt_strafeleft, bt_straferight, bt_lookup, bt_lookdown,
144    bt_aimbutton, bt_horizonup, bt_horizondown, bt_swapweapon, bt_dropweapon,
145    bt_turnaround, bt_autorun, bt_message, bt_directmsg
146    };
147 
148 // bt_pistol, bt_dualpistol, bt_mp40, bt_missileweapon, bt_recordsound,
149 
150 #define RETURNVAL    100
151 
152 static boolean loadsavesound = false;
153 static int numdone;
154 
155 static char *endStrings[ 7 ] =
156    {
157    "Press Y to reformat \nand install Windows.\0\0",
158    "Press Y to activate \nguillotine.\0\0",
159    "Press Y to release \nthe cyanide gas.\0\0",
160    "Press Y to open \ntrap door.\0\0",
161    "Press Y to drive your \ncar off the cliff.\0\0",
162    "Press Y to pull \nyour plug.\0\0",
163    "Press Y to activate \nelectric chair.\0\0"
164    };
165 
166 static char *BattleModeDescriptions[ battle_NumBattleModes - 1 ] =
167    {
168    "Kill your enemies!  Don't get killed!  Kill some more!",
169    "Score more points for more difficult kills.",
170    "Collect the most triads to win the game.  Whoopee!",
171    "Collect triads to win the game--this time with weapons!",
172    "Armed hunters vs. unarmed prey--then the tables are turned!",
173    "Tag your enemies.  Run away.  Lowest points wins.",
174    "Chase roving 'Eluders'--tag them for points.",
175    "Use weapons to destroy roving Eluder triads for points.",
176    "Capture the opposing team's triad while guarding your own."
177    };
178 
179 static char *BattleOptionDescriptions[ 9 ] =
180    {
181    "Adjust the Gravitational Constant of the game universe!",
182    "Adjust the top speed for all players in the game",
183    "Adjust the amount of ammo in all missile weapons",
184    "Adjust the hit points of all players in the game",
185    "Radically change the way the game plays",
186    "Adjust the light characteristics of the game",
187    "Adjust the point goal of the game",
188    "Adjust the damage done by environment dangers",
189    "Adjust the time limit for the game"
190    };
191 
192 static char *GravityOptionDescriptions[ 3 ] =
193    {
194    "Similar to gravity on the moon",
195    "Normal Gravity (9.81 m/s^2 !)",
196    "Similar to gravity on Jupiter"
197    };
198 
199 static char *SpeedOptionDescriptions[ 2 ] =
200    {
201    "Player speeds are determined by character",
202    "All players can move at the fastest possible speed"
203    };
204 
205 static char *AmmoOptionDescriptions[ 3 ] =
206    {
207    "One piece of ammo per missile weapon",
208    "Normal ammo for all missile weapons",
209    "Infinite ammo for all missile weapons"
210    };
211 
212 static char *HitPointsOptionDescriptions[ 7 ] =
213    {
214    "One hit point for each player",
215    "25 hit points for each player",
216    "Hit points determined by character",
217    "100 hit points for each player",
218    "250 hit points for each player (default)",
219    "500 hit points for each player",
220    "4000 hit points for each player",
221    };
222 
223 static char *RadicalOptionDescriptions[ 8 ] =
224    {
225    "Control spawning of environment dangers",
226    "Control spawning of health items",
227    "Control spawning of missile weapons",
228    "Spawn mines instead of health items",
229    "Objects reappear a short time after being picked up",
230    "Missile weapons remain when picked up",
231    "Weapons are chosen randomly at the start of the game",
232    "Killing yourself or a team member counts as a suicide"
233    };
234 
235 static char *LightLevelOptionDescriptions[ 6 ] =
236    {
237    "Very dark, cave-like",
238    "Lighting determined by level design",
239    "Full brightness",
240    "Bright with fog",
241    "Periodic lighting (voobing)",
242    "Dark with lightning"
243    };
244 
245 static char *PointGoalOptionDescriptions[ 9 ] =
246    {
247    "One Point/Kill",
248    "5 Points/Kills",
249    "11 Points/Kills",
250    "21 Points/Kills",
251    "50 Points/Kills",
252    "100 Points/Kills",
253    "Random Points/Kills",
254    "Random Points/Kills but goal is not revealed",
255    "Infinite Points/Kills"
256    };
257 
258 static char *DangerDamageOptionDescriptions[ 3 ] =
259    {
260    "Environmental dangers' damage is relatively low",
261    "Environmental dangers' damage normal",
262    "One touch and you are dead!"
263    };
264 
265 static char *TimeLimitOptionDescriptions[ 8 ] =
266    {
267    "One Minute",
268    "2 Minutes",
269    "5 Minutes",
270    "10 Minutes",
271    "21 Minutes",
272    "30 Minutes",
273    "99 Minutes",
274    "No Time Limit"
275    };
276 
277 
278 static char *BattleModeNames[ battle_NumBattleModes - 1 ] =
279    {
280    "NORMAL COMM-BAT", "SCORE MORE", "COLLECTOR", "SCAVENGER",
281    "HUNTER", "TAG", "ELUDER", "DELUDER", "CAPTURE THE TRIAD"
282    };
283 
284 static int OptionNums[ 12 ] =
285    {
286    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
287    };
288 
289 static int HitPointNums[ 7 ] =
290    {
291    1, 25, bo_character_hitpoints, 100, 250, 500, 4000
292    };
293 
294 static int KillNums[ 9 ] =
295    {
296    1, 5, 11, 21, 50, 100, bo_kills_random,
297    bo_kills_blind, bo_kills_infinite
298    };
299 
300 static int GravityNums[ 3 ] =
301    {
302    LOW_GRAVITY, NORMAL_GRAVITY, HIGH_GRAVITY
303    };
304 
305 static int TimeLimitNums[ 8 ] =
306    {
307    1, 2, 5, 10, 21, 30, 99, bo_time_infinite
308    };
309 
310 static int DangerNums[ 3 ] =
311    {
312    bo_danger_low, bo_danger_normal, bo_danger_kill
313    };
314 
315 static int MenuNum = 0;
316 static int handlewhich;
317 static int CSTactive = 0;
318 static boolean INFXSETUP = false;
319 static int MaxVoices;
320 static int MaxBits;
321 static int MaxChannels;
322 
323 //
324 // MENU CURSOR SHAPES
325 //
326 
327 #define MAXCURSORNUM 24
328 
329 static int cursorwidth;
330 static int cursorheight;
331 static int yinc;
332 
333 static char *FontNames[] = { "itnyfont", "ifnt", "sifont", "lifont" };
334 static int   FontSize[]  = { 6, 7, 9, 14 };
335 static char *SmallCursor = "smallc01";
336 static char *LargeCursor = "cursor01";
337 static char *CursorLump  = "cursor01";
338 static int CursorNum = 0;
339 static int CursorFrame[ MAXCURSORNUM ] =
340    {
341    0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3,
342    4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1
343    };
344 
345 typedef enum
346    {
347    MOUSEENABLE,
348 	JOYENABLE,
349 	USEPORT2,
350 	PADENABLE,
351 	SPACEBALLENABLE,
352 	CYBERMANENABLE,
353 	THRESSENS,
354 	MOUSESENS,
355 	CUSTOMIZE
356    } controltypes;
357 
358 
359 static char *playerwadname[] =
360    {
361    "cass1", "bars1", "wens1", "lnis1", "ipfs1"
362    };
363 
364 char *colorname[] =
365    {
366    "Gray", "Brown", "Black", "Tan", "Red", "Olive",
367    "Blue", "White", "Green", "Purple", "Orange"
368    };
369 
370 //
371 // MENU ITEMS
372 //
373 CP_MenuNames MainMenuNames[] =
374    {
375    "NEW GAME",
376    "COMM-BAT� GAME",
377    "RESTORE GAME",
378    "SAVE GAME",
379    "OPTIONS",
380    "ORDERING INFO",
381    "VIEW SCORES", //"END GAME"
382    "BACK TO DEMO", //"BACK TO GAME"
383    "QUIT"
384    };
385 
386 CP_iteminfo MainItems  = { MENU_X, MENU_Y + 1, 9, STARTITEM, 32, MainMenuNames, mn_largefont };
387 CP_itemtype MainMenu[] =
388    {
389       { CP_CursorLocation, "mm_opt1\0",  'N', (menuptr)CP_NewGame },
390       { CP_Active,         "battle\0",   'C', (menuptr)CP_BattleModes },
391       { CP_Active,         "mm_opt2\0",  'R', (menuptr)CP_LoadGame },
392       { CP_Inactive,       "mm_opt3\0",  'S', (menuptr)CP_SaveGame },
393       { CP_Active,         "mm_opt5\0",  'O', (menuptr)CP_ControlMenu },
394       { CP_Active,         "ordrinfo\0", 'O', (menuptr)CP_OrderInfo },
395       { CP_Active,         "mm_opt7\0",  'V', (menuptr)CP_ViewScores },
396       { CP_Active,         "mm_opt8\0",  'B', (menuptr)NULL },
397       { CP_Active,         "mm_opt9\0",  'Q', (menuptr)CP_Quit }
398    };
399 
400 
401 CP_iteminfo LSItems  = { LSM_X, LSM_Y, NUMSAVEGAMES, 0, 10, NULL, mn_largefont };
402 CP_itemtype LSMenu[] =
403    {
404 	   { CP_Active, "", 'a', NULL },
405 	   { CP_Active, "", 'b', NULL },
406 	   { CP_Active, "", 'c', NULL },
407 	   { CP_Active, "", 'd', NULL },
408 	   { CP_Active, "", 'e', NULL },
409 	   { CP_Active, "", 'f', NULL },
410 	   { CP_Active, "", 'g', NULL },
411 	   { CP_Active, "", 'h', NULL },
412       { CP_Active, "", 'i', NULL },
413       { CP_Active, "", 'j', NULL },
414       { CP_Active, "", 'k', NULL },
415       { CP_Active, "", 'l', NULL },
416       { CP_Active, "", 'm', NULL },
417       { CP_Active, "", 'n', NULL },
418 	   { CP_Active, "", 'o', NULL }
419    };
420 
421 CP_MenuNames CtlMenuNames[] =
422    {
423    "MOUSE ENABLED",
424    "JOYSTICK ENABLED",
425    "USE JOYSTICK PORT 2",
426    "GAMEPAD ENABLED",
427    "SPACEBALL ENABLED",
428    "CYBERMAN ENABLED",
429    "ADJUST THRESHOLD",
430    "MOUSE SENSITIVITY",
431    "CUSTOMIZE CONTROLS"
432    };
433 
434 CP_iteminfo CtlItems  = { CTL_X, MENU_Y, 9, -1, 36, CtlMenuNames, mn_largefont };
435 CP_itemtype CtlMenu[] =
436    {
437       { CP_Inactive, "ctl_mic\0", 'M', NULL },
438       { CP_Inactive, "ctl_jen\0", 'J', NULL },
439       { CP_Inactive, "ctl_jp2\0", 'U', NULL },
440       { CP_Inactive, "ctl_gpd\0", 'G', NULL },
441       { CP_Inactive, "spball\0",  'S', NULL },
442       { CP_Inactive, "cyberman\0",'C', NULL },
443       { CP_Inactive, "ctl_thr\0", 'A', (menuptr)DoThreshold },
444       { CP_Inactive, "ctl_mse\0", 'M', (menuptr)MouseSensitivity },
445       { CP_Active,   "ctl_cus\0", 'C', (menuptr)CP_Custom }
446    };
447 
448 CP_iteminfo CusItems  = { 32, CST_Y + 13 * 2, 9, -1, 0, NULL, mn_largefont };
449 CP_itemtype CusMenu[] =
450    {
451       { CP_Active,   "ctl_mic\0", 'a', NULL },
452       { CP_Inactive, "ctl_mic\0", 'a', NULL },
453       { CP_Inactive, "ctl_mic\0", 'a', NULL },
454       { CP_Active,   "ctl_mic\0", 'a', NULL },
455       { CP_Inactive, "ctl_mic\0", 'a', NULL },
456       { CP_Inactive, "ctl_mic\0", 'a', NULL },
457       { CP_Active,   "ctl_mic\0", 'a', NULL },
458       { CP_Inactive, "ctl_mic\0", 'a', NULL },
459       { CP_Active,   "ctl_mic\0", 'a', NULL }
460    };
461 
462 
463 CP_iteminfo TufItems = { TUF_X, TUF_Y, 7, 0, 80, NULL, mn_largefont };
464 CP_itemtype TufMenu[ 4 ][ 7 ] =
465    {
466       {
467          { 2, "new11\0", 'a', NULL },
468          { 3, "new11\0", 'a', NULL },
469          { 1, "new12\0", 'a', NULL },
470          { 3, "new12\0", 'a', NULL },
471          { 1, "new13\0", 'a', NULL },
472          { 3, "new13\0", 'a', NULL },
473          { 1, "new14\0", 'a', NULL },
474       },
475 
476       {
477          { 2, "new21\0", 'a', NULL },
478          { 3, "new21\0", 'a', NULL },
479          { 1, "new22\0", 'a', NULL },
480          { 3, "new22\0", 'a', NULL },
481          { 1, "new23\0", 'a', NULL },
482          { 3, "new23\0", 'a', NULL },
483          { 1, "new24\0", 'a', NULL },
484       },
485 
486       {
487          { 2, "new31\0", 'a', NULL },
488          { 3, "new31\0", 'a', NULL },
489          { 1, "new32\0", 'a', NULL },
490          { 3, "new32\0", 'a', NULL },
491          { 1, "new33\0", 'a', NULL },
492          { 3, "new33\0", 'a', NULL },
493          { 1, "new34\0", 'a', NULL },
494       },
495 
496       {
497          { 2, "stk_1\0", 'a', NULL },
498          { 3, "stk_1\0", 'a', NULL },
499          { 1, "stk_2\0", 'a', NULL },
500          { 3, "stk_2\0", 'a', NULL },
501          { 1, "stk_3\0", 'a', NULL },
502          { 3, "stk_3\0", 'a', NULL },
503          { 1, "stk_4\0", 'a', NULL },
504       }
505    };
506 
507 CP_MenuNames CustomMenuNames[] =
508    {
509    "CUSTOMIZE KEYBOARD",
510    "CUSTOMIZE MOUSE",
511    "CUSTOMIZE JOYSTICK"
512    };
513 
514 CP_iteminfo CustomItems = {32, 64, 3, 0, 24, CustomMenuNames, mn_largefont };
515 
516 CP_itemtype CustomMenu[] =
517 {
518   {2, "custom1\0", 'C', (menuptr)CP_Keyboard},
519   {1, "custom2\0", 'C', (menuptr)CP_Mouse},
520   {1, "custom3\0", 'C', (menuptr)CP_Joystick}
521 };
522 
523 #define KEYNAMEINDEX 21
524 
525 CP_MenuNames NormalKeyNames[] =
526    {
527    "LEFT               \x9      ",
528    "RIGHT              \x9      ",
529    "FORWARD            \x9      ",
530    "BACKWARD           \x9      ",
531    "RUN                \x9      ",
532    "OPEN               \x9      ",
533    "FIRE               \x9      ",
534    "STRAFE             \x9      ",
535    "STRAFE LEFT        \x9      ",
536    "STRAFE RIGHT       \x9      ",
537    "LOOK/FLY UP        \x9      ",
538    "LOOK/FLY DOWN      \x9      ",
539    "AIM                \x9      ",
540    "AIM UP             \x9      ",
541    "AIM DOWN           \x9      ",
542    "TOGGLE WEAPON      \x9      ",
543    "DROP WEAPON        \x9      ",
544    "VOLTE-FACE         \x9      ",
545    "AUTORUN            \x9      ",
546    "SEND MESSAGE       \x9      ",
547    "DIRECT MESSAGE     \x9      "
548    };
549 
550 #define NORMALKEY_X  74
551 #define NORMALKEY_Y  16
552 CP_iteminfo NormalKeyItems = { NORMALKEY_X, 17, 21, 0, 16, NormalKeyNames, mn_tinyfont };
553 
554 CP_itemtype NormalKeyMenu[] =
555    {
556       { 2, "\0", 'L', (menuptr)DefineKey },
557       { 1, "\0", 'R', (menuptr)DefineKey },
558       { 1, "\0", 'F', (menuptr)DefineKey },
559       { 1, "\0", 'B', (menuptr)DefineKey },
560       { 1, "\0", 'R', (menuptr)DefineKey },
561       { 1, "\0", 'O', (menuptr)DefineKey },
562       { 1, "\0", 'F', (menuptr)DefineKey },
563       { 1, "\0", 'S', (menuptr)DefineKey },
564       { 1, "\0", 'S', (menuptr)DefineKey },
565       { 1, "\0", 'S', (menuptr)DefineKey },
566       { 1, "\0", 'L', (menuptr)DefineKey },
567       { 1, "\0", 'L', (menuptr)DefineKey },
568       { 1, "\0", 'A', (menuptr)DefineKey },
569       { 1, "\0", 'A', (menuptr)DefineKey },
570       { 1, "\0", 'T', (menuptr)DefineKey },
571       { 1, "\0", 'D', (menuptr)DefineKey },
572       { 1, "\0", 'V', (menuptr)DefineKey },
573       { 1, "\0", 'A', (menuptr)DefineKey },
574       { 1, "\0", 'A', (menuptr)DefineKey },
575       { 1, "\0", 'S', (menuptr)DefineKey },
576       { 1, "\0", 'D', (menuptr)DefineKey }
577    };
578 
579 #define NUMCONTROLNAMES 21
580 
581 CP_MenuNames ControlNames[] =
582    {
583    "NONE",
584    "LEFT",
585    "RIGHT",
586    "FORWARD",
587    "BACKWARD",
588    "RUN",
589    "OPEN",
590    "FIRE",
591    "STRAFE",
592    "STRAFE LEFT",
593    "STRAFE RIGHT",
594    "LOOK/FLY UP",
595    "LOOK/FLY DOWN",
596    "AIM",
597    "AIM UP",
598    "AIM DOWN",
599    "TOGGLE WEAPON",
600    "DROP WEAPON",
601    "VOLTE-FACE",
602    "AUTORUN",
603    "MAP"
604    };
605 
606 int controlorder[ NUMCONTROLNAMES ] = {
607    bt_nobutton, di_west, di_east, di_north, di_south, bt_run, bt_use,
608    bt_attack, bt_strafe, bt_strafeleft, bt_straferight, bt_lookup,
609    bt_lookdown, bt_aimbutton, bt_horizonup, bt_horizondown,
610    bt_swapweapon, bt_dropweapon, bt_turnaround, bt_autorun, bt_map
611    };
612 
613 #define CONTROLSELECT_X  106
614 CP_iteminfo ControlSelectItems = { CONTROLSELECT_X, 17, NUMCONTROLNAMES, 0, 16, ControlNames, mn_tinyfont };
615 
616 CP_itemtype ControlSelectMenu[] =
617    {
618       { 2, "\0", 'N', NULL },
619       { 1, "\0", 'L', NULL },
620       { 1, "\0", 'R', NULL },
621       { 1, "\0", 'F', NULL },
622       { 1, "\0", 'B', NULL },
623       { 1, "\0", 'R', NULL },
624       { 1, "\0", 'O', NULL },
625       { 1, "\0", 'F', NULL },
626       { 1, "\0", 'S', NULL },
627       { 1, "\0", 'S', NULL },
628       { 1, "\0", 'S', NULL },
629       { 1, "\0", 'L', NULL },
630       { 1, "\0", 'L', NULL },
631       { 1, "\0", 'A', NULL },
632       { 1, "\0", 'A', NULL },
633       { 1, "\0", 'A', NULL },
634       { 1, "\0", 'T', NULL },
635       { 1, "\0", 'D', NULL },
636       { 1, "\0", 'V', NULL },
637       { 1, "\0", 'A', NULL },
638       { 1, "\0", 'M', NULL }
639    };
640 
641 #ifdef DC
642 #define MOUSEBTNINDEX 17
643 
644 CP_MenuNames MouseBtnNames[] =
645    {
646    "          LEFT   \x9             ",
647    "          RIGHT  \x9             ",
648    "          MIDDLE \x9             ",
649    "          WHEELUP\x9             ",
650    "          WHEELDN\x9             ",
651    "DBL-CLICK LEFT   \x9             ",
652    "DBL-CLICK RIGHT  \x9             ",
653    "DBL-CLICK MIDLLE \x9             ",
654    "DBL-CLICK WHEELUP\x9             ",
655    "DBL-CLICK WHEELDN\x9             ",
656    };
657 
658 CP_iteminfo MouseBtnItems = { 19, 36, 10, 0, 11, MouseBtnNames, mn_8x8font };
659 
660 CP_itemtype MouseBtnMenu[] =
661    {
662       { 2, "\0", 'B', (menuptr)DefineMouseBtn },
663       { 1, "\0", 'B', (menuptr)DefineMouseBtn },
664       { 1, "\0", 'B', (menuptr)DefineMouseBtn },
665       { 1, "\0", 'B', (menuptr)DefineMouseBtn },
666       { 1, "\0", 'B', (menuptr)DefineMouseBtn },
667       { 1, "\0", 'D', (menuptr)DefineMouseBtn },
668       { 1, "\0", 'D', (menuptr)DefineMouseBtn },
669       { 1, "\0", 'D', (menuptr)DefineMouseBtn },
670       { 1, "\0", 'D', (menuptr)DefineMouseBtn },
671       { 1, "\0", 'D', (menuptr)DefineMouseBtn },
672    };
673 
674 #define JOYBTNINDEX 17
675 
676 CP_MenuNames JoyBtnNames[] =
677    {
678    "          A      \x9             ",
679    "          B      \x9             ",
680    "          X      \x9             ",
681    "          Y      \x9             ",
682    "          UP     \x9             ",
683    "          DOWN   \x9             ",
684    "          LEFT   \x9             ",
685    "          RIGHT  \x9             ",
686    "          L-TRIG \x9             ",
687    "          R-TRIG \x9             ",
688    "DBL-CLICK A      \x9             ",
689    "DBL-CLICK B      \x9             ",
690    "DBL-CLICK X      \x9             ",
691    "DBL-CLICK Y      \x9             ",
692    "DBL-CLICK UP     \x9             ",
693    "DBL-CLICK LEFT   \x9             ",
694    "DBL-CLICK DOWN   \x9             ",
695    "DBL-CLICK RIGHT  \x9             ",
696    "DBL-CLICK R-TRIG \x9             ",
697    "DBL-CLICK L-TRIG \x9             ",
698    };
699 
700 CP_iteminfo JoyBtnItems = { 19, 16, 20, 0, 11, JoyBtnNames, mn_8x8font };
701 
702 CP_itemtype JoyBtnMenu[] =
703    {
704       { 2, "\0", 'B', (menuptr)DefineJoyBtn },
705       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
706       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
707       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
708       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
709       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
710       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
711       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
712       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
713       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
714       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
715       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
716       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
717       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
718       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
719       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
720       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
721       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
722       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
723       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
724    };
725 
726 
727 #else
728 #define MOUSEBTNINDEX 17
729 
730 CP_MenuNames MouseBtnNames[] =
731    {
732    "             B0  \x9             ",
733    "             B1  \x9             ",
734    "             B2  \x9             ",
735    "DOUBLE-CLICK B0  \x9             ",
736    "DOUBLE-CLICK B1  \x9             ",
737    "DOUBLE-CLICK B2  \x9             "
738    };
739 
740 CP_iteminfo MouseBtnItems = { 19, 52, 6, 0, 11, MouseBtnNames, mn_8x8font };
741 
742 CP_itemtype MouseBtnMenu[] =
743    {
744       { 2, "\0", 'B', (menuptr)DefineMouseBtn },
745       { 1, "\0", 'B', (menuptr)DefineMouseBtn },
746       { 1, "\0", 'B', (menuptr)DefineMouseBtn },
747       { 1, "\0", 'D', (menuptr)DefineMouseBtn },
748       { 1, "\0", 'D', (menuptr)DefineMouseBtn },
749       { 1, "\0", 'D', (menuptr)DefineMouseBtn }
750    };
751 
752 #define JOYBTNINDEX 17
753 
754 CP_MenuNames JoyBtnNames[] =
755    {
756    "             B0  \x9             ",
757    "             B1  \x9             ",
758    "             B2  \x9             ",
759    "             B3  \x9             ",
760    "DOUBLE-CLICK B0  \x9             ",
761    "DOUBLE-CLICK B1  \x9             ",
762    "DOUBLE-CLICK B2  \x9             ",
763    "DOUBLE-CLICK B3  \x9             "
764    };
765 
766 CP_iteminfo JoyBtnItems = { 19, 48, 8, 0, 11, JoyBtnNames, mn_8x8font };
767 
768 CP_itemtype JoyBtnMenu[] =
769    {
770       { 2, "\0", 'B', (menuptr)DefineJoyBtn },
771       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
772       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
773       { 1, "\0", 'B', (menuptr)DefineJoyBtn },
774       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
775       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
776       { 1, "\0", 'D', (menuptr)DefineJoyBtn },
777       { 1, "\0", 'D', (menuptr)DefineJoyBtn }
778    };
779 
780 
781 #endif
782 
783 CP_MenuNames PlayerMenuNames[] =
784    {
785    "TARADINO CASSATT",
786    "THI BARRETT",
787    "DOUG WENDT",
788    "LORELEI NI",
789    "IAN PAUL FREELEY"
790    };
791 
792 CP_iteminfo PlayerItems = {TUF_X, 48, 5, 0, 80, PlayerMenuNames, mn_largefont };
793 
794 CP_itemtype PlayerMenu[] =
795 {
796 	{2, "name1\0", 'T', NULL},
797    {1, "name2\0", 'T', NULL},
798    {1, "name3\0", 'D', NULL},
799    {1, "name4\0", 'L', NULL},
800    {1, "name5\0", 'I', NULL},
801 };
802 
803 CP_MenuNames ControlMMenuNames[] =
804    {
805    "CONTROLS",
806    "USER OPTIONS",
807    "MUSIC VOLUME",
808    "SOUND FX VOLUME"
809    };
810 
811 CP_iteminfo ControlMItems = {32, 48, 4, 0, 32, ControlMMenuNames, mn_largefont };
812 
813 CP_itemtype ControlMMenu[] =
814 {
815    {2, "cntl\0",     'C', (menuptr)CP_Control},
816    {1, "uopt\0",     'U', (menuptr)CP_OptionsMenu},
817    {1, "muvolumn\0", 'M', (menuptr)MusicVolume},
818    {1, "fxvolumn\0", 'S', (menuptr)FXVolume}
819 };
820 
821 CP_MenuNames OptionsNames[] =
822    {
823    "AUTO DETAIL ADJUST",
824    "LIGHT DIMINISHING",
825    "BOBBIN'",
826    "FLOOR AND CEILING",
827    "DOUBLE-CLICK SPEED",
828    "MENU FLIP SPEED",
829    "DETAIL LEVELS",
830    "VIOLENCE LEVEL",
831    "SCREEN SIZE"
832    };
833 
834 CP_iteminfo OptionsItems = { 20, MENU_Y, 9, 0, 43, OptionsNames, mn_largefont };
835 
836 CP_itemtype OptionsMenu[] =
837 {
838    {2, "autoadj\0", 'A', NULL},
839    {1, "lightdim\0",'L', NULL},
840    {1, "bobbin\0",  'B', NULL},
841    {1, "fandc\0",   'F', NULL},
842    {1, "double\0",  'D', (menuptr)CP_DoubleClickSpeed},
843    {1, "menuspd\0", 'M', (menuptr)MenuFlipSpeed},
844    {1, "detail\0",  'D', (menuptr)CP_DetailMenu},
845    {1, "vlevel\0",  'V', (menuptr)CP_ViolenceMenu},
846    {1, "\0",        'S', (menuptr)CP_ScreenSize}
847 };
848 
849 CP_MenuNames DetailMenuNames[] =
850    {
851    "LOW DETAIL",
852    "MEDIUM DETAIL",
853    "HIGH DETAIL"
854    };
855 
856 CP_iteminfo DetailItems = { 32, 64, 3, 0, 43, DetailMenuNames, mn_largefont };
857 
858 CP_itemtype DetailMenu[] =
859 {
860    {2, "lowdtl\0", 'L', NULL},
861    {1, "meddtl\0", 'M', NULL},
862    {1, "hidtl\0",  'H', NULL}
863 };
864 
865 CP_MenuNames BattleMenuNames[] =
866    {
867    "PLAY GAME",
868    "PLAY TEAM GAME",
869    "COMM-BAT OPTIONS"
870    };
871 
872 CP_iteminfo BattleItems = { 32, 19, 3, 0, 24, BattleMenuNames, mn_largefont };
873 
874 CP_itemtype BattleMenu[] =
875 {
876    {2, "bplay\0",    'P', (menuptr)BattleNoTeams},
877    {1, "playteam\0", 'P', (menuptr)BattleTeams},
878    {1, "comopt\0",   'C', (menuptr)CP_BattleOptions}
879 };
880 
881 CP_MenuNames ViolenceMenuNames[] =
882    {
883    "NONE",
884    "SOME",
885    "A LOT",
886    "EXCESSIVE"
887    };
888 
889 CP_iteminfo ViolenceItems = { 32, 64, 4, 0, 45, ViolenceMenuNames, mn_largefont };
890 
891 CP_itemtype ViolenceMenu[] =
892 {
893    {2, "vnone\0",   'N', NULL},
894    {1, "vsome\0",   'S', NULL},
895    {1, "valot\0",   'A', NULL},
896    {1, "vexcess\0", 'E', NULL}
897 };
898 
899 CP_MenuNames VMenuNames[] =
900    {
901    "SET VIOLENCE LEVEL",
902    "" // "ENTER PASSWORD" // "CHANGE PASSWORD"
903    };
904 
905 CP_iteminfo VItems = { 32, MP_Y, 2, 0, 24, VMenuNames, mn_largefont };
906 
907 CP_itemtype VMenu[] =
908 {
909    {2, "msetv\0",  'S',  (menuptr)CP_ViolenceLevel},
910    {1, "mepass\0", 'E', (menuptr)CP_PWMenu}
911 };
912 
913 CP_MenuNames ModeMenuNames[] =
914    {
915    "NORMAL",
916    "SCORE MORE",
917    "COLLECTOR",
918    "SCAVENGER",
919    "HUNTER",
920    "TAG",
921    "ELUDER",
922    "DELUDER",
923    "CAPTURE THE TRIAD"
924    };
925 
926 CP_iteminfo ModeItems = { MENU_X, MENU_Y + 1, 9, 0, 24, ModeMenuNames, mn_largefont };
927 
928 CP_itemtype ModeMenu[] =
929 {
930    {CP_CursorLocation, "normal\0",   'N', (menuptr)CP_BattleMenu},
931    {CP_Active,         "scorem\0",   'S', (menuptr)CP_BattleMenu},
932    {CP_Active,         "collect\0",  'C', (menuptr)CP_BattleMenu},
933    {CP_Active,         "scaven\0",   'S', (menuptr)CP_BattleMenu},
934    {CP_Active,         "hunter\0",   'H', (menuptr)CP_BattleMenu},
935    {CP_Active,         "tag\0",      'T', (menuptr)CP_BattleMenu},
936    {CP_Active,         "eluder\0",   'E', (menuptr)CP_BattleMenu},
937    {CP_Active,         "deluder\0",  'D', (menuptr)CP_BattleMenu},
938    {CP_Active,         "captriad\0", 'C', (menuptr)CP_BattleMenu}
939 };
940 
941 CP_MenuNames BOptNames[] =
942    {
943    "GRAVITY",
944    "SPEED",
945    "AMMO PER WEAPON",
946    "HIT POINTS",
947    "RADICAL OPTIONS",
948    "LIGHT LEVELS",
949    "POINT GOAL",
950    "DANGER DAMAGE",
951    "TIME LIMIT"
952    };
953 
954 CP_iteminfo BOptItems = { MENU_X, MENU_Y + 1, 9, 0, 24, BOptNames, mn_largefont };
955 
956 CP_itemtype BOptMenu[] =
957 {
958    {2, "gravity\0",  'G', (menuptr)CP_GravityOptions},
959    {1, "speed\0",    'S', (menuptr)CP_SpeedOptions},
960    {1, "ammoper\0",  'A', (menuptr)CP_AmmoPerWeaponOptions},
961    {1, "hitp\0",     'H', (menuptr)CP_HitPointsOptions},
962    {1, "radical\0",  'R', (menuptr)CP_SpawnControlOptions},
963    {1, "lightl\0",   'L', (menuptr)CP_LightLevelOptions},
964    {1, "pntgoal\0",  'P', (menuptr)CP_PointGoalOptions},
965    {1, "danger\0",   'D', (menuptr)CP_DangerOptions},
966    {1, "timel\0",    'T', (menuptr)CP_TimeLimitOptions}
967 };
968 
969 CP_MenuNames GravityMenuNames[] =
970    {
971    "LOW",
972    "NORMAL",
973    "HIGH"
974    };
975 
976 CP_iteminfo GravityItems = { 32, 26, 3, 0, 45, GravityMenuNames, mn_largefont };
977 
978 CP_itemtype GravityMenu[] =
979 {
980 	{2, "b_low\0",    'L', NULL},
981 	{1, "b_normal\0", 'N', NULL},
982 	{1, "b_high\0",   'H', NULL}
983 };
984 
985 CP_MenuNames SpeedMenuNames[] =
986    {
987    "NORMAL",
988    "FAST"
989    };
990 
991 CP_iteminfo SpeedItems = { 32, MP_Y, 2, 0, 45, SpeedMenuNames, mn_largefont };
992 
993 CP_itemtype SpeedMenu[] =
994 {
995    {2, "b_normal\0", 'N', NULL},
996    {1, "b_fast\0",   'F', NULL}
997 };
998 
999 CP_MenuNames AmmoPerWeaponMenuNames[] =
1000    {
1001    "ONE",
1002    "NORMAL",
1003    "GUNFINITY"
1004    };
1005 
1006 CP_iteminfo AmmoPerWeaponItems = { 32, 26, 3, 0, 45, AmmoPerWeaponMenuNames, mn_largefont };
1007 
1008 CP_itemtype AmmoPerWeaponMenu[] =
1009 {
1010    {2, "b_one\0",    'O', NULL},
1011    {1, "b_normal\0", 'N', NULL},
1012    {1, "b_gunf\0",   'G', NULL}
1013 };
1014 
1015 CP_MenuNames HitPointMenuNames[] =
1016    {
1017    "ONE",
1018    "25",
1019    "BY CHARACTER",
1020    "100",
1021    "250",
1022    "500",
1023    "4000"
1024    };
1025 
1026 CP_iteminfo HitPointItems = { 32, 32, 7, 0, 45, HitPointMenuNames, mn_largefont };
1027 
1028 CP_itemtype HitPointMenu[] =
1029 {
1030    {2, "b_one\0",  'O', NULL},
1031    {1, "b_25\0",   'a', NULL},
1032    {1, "b_char\0", 'C', NULL},
1033    {1, "b_100\0",  'a', NULL},
1034    {1, "b_250\0",  'a', NULL},
1035 	{1, "b_500\0",  'a', NULL},
1036    {1, "b_4000\0", 'a', NULL}
1037 };
1038 
1039 CP_MenuNames SpawnMenuNames[] =
1040    {
1041    "SPAWN DANGERS",
1042    "SPAWN HEALTH",
1043    "SPAWN WEAPONS",
1044    "SPAWN MINES",
1045    "RESPAWN ITEMS",
1046    "WEAPON PERSISTENCE",
1047    "RANDOM WEAPONS",
1048    "FRIENDLY FIRE"
1049    };
1050 
1051 CP_iteminfo SpawnItems = { 20, 24, 8, 0, 35, SpawnMenuNames, mn_largefont };
1052 
1053 CP_itemtype SpawnMenu[] =
1054 {
1055    {2, "b_danger\0", 'S', NULL},
1056    {1, "b_health\0", 'S', NULL},
1057    {1, "b_weap\0",   'S', NULL},
1058    {1, "b_mines\0",  'S', NULL},
1059    {1, "b_rpawn\0",  'R', NULL},
1060    {1, "b_persis\0", 'W', NULL},
1061    {1, "b_rndwpn\0", 'R', NULL},
1062    {1, "b_friend\0", 'F', NULL}
1063 };
1064 
1065 CP_MenuNames LightLevelMenuNames[] =
1066    {
1067    "DARK",
1068    "NORMAL",
1069    "BRIGHT",
1070    "FOG",
1071    "PERIODIC",
1072    "LIGHTNING"
1073    };
1074 
1075 CP_iteminfo LightLevelItems = { 32, 40, 6, 0, 45, LightLevelMenuNames, mn_largefont };
1076 
1077 CP_itemtype LightLevelMenu[] =
1078 {
1079    {2, "b_dark\0",   'D', NULL},
1080    {1, "b_normal\0", 'N', NULL},
1081    {1, "b_bright\0", 'B', NULL},
1082    {1, "b_fog\0",    'F', NULL},
1083    {1, "b_period\0", 'P', NULL},
1084    {1, "b_light\0",  'L', NULL}
1085 };
1086 
1087 CP_MenuNames PointGoalMenuNames[] =
1088    {
1089    "1",
1090    "5",
1091    "11",
1092    "21",
1093    "50",
1094    "100",
1095    "RANDOM",
1096    "RANDOM BLIND",
1097    "INFINITE"
1098    };
1099 
1100 CP_iteminfo PointGoalItems = { 32, 16, 9, 0, 45, PointGoalMenuNames, mn_largefont };
1101 
1102 CP_itemtype PointGoalMenu[] =
1103 {
1104 	{2, "b_1\0",      'a', NULL},
1105    {1, "b_5\0",      'a', NULL},
1106    {1, "b_11\0",     'a', NULL},
1107    {1, "b_21\0",     'a', NULL},
1108    {1, "b_50\0",     'a', NULL},
1109    {1, "b_100\0",    'a', NULL},
1110    {1, "b_random\0", 'R', NULL},
1111 	{1, "b_randb\0",  'R', NULL},
1112 	{1, "b_inf\0",    'I', NULL}
1113 };
1114 
1115 CP_MenuNames DangerMenuNames[] =
1116    {
1117    "LOW",
1118    "NORMAL",
1119    "KILL"
1120    };
1121 
1122 CP_iteminfo DangerItems = { 32, 56, 3, 0, 45, DangerMenuNames, mn_largefont };
1123 
1124 CP_itemtype DangerMenu[] =
1125 {
1126    {2, "b_low\0",    'L', NULL},
1127    {1, "b_normal\0", 'N', NULL},
1128 	{1, "b_kill\0",   'K', NULL}
1129 };
1130 
1131 CP_MenuNames TimeLimitMenuNames[] =
1132    {
1133    "1",
1134    "2",
1135    "5",
1136    "10",
1137    "21",
1138    "30",
1139    "99",
1140    "NONE"
1141    };
1142 
1143 CP_iteminfo TimeLimitItems = { 32, 24, 8, 0, 45, TimeLimitMenuNames, mn_largefont };
1144 
1145 CP_itemtype TimeLimitMenu[] =
1146 {
1147 	{2, "b_1\0",    'a', NULL},
1148 	{1, "b_2\0",    'a', NULL},
1149 	{1, "b_5\0",    'a', NULL},
1150 	{1, "b_10\0",   'a', NULL},
1151    {1, "b_21\0",   'a', NULL},
1152 	{1, "b_30\0",   'a', NULL},
1153 	{1, "b_99\0",   'a', NULL},
1154    {1, "vnone\0",  'N', NULL}
1155 };
1156 
1157 CP_MenuNames MultiPageCustomNames[ MAXCUSTOM + 2 ] =
1158    {
1159    "NEXT PAGE",
1160    "PREVIOUS PAGE"
1161    };
1162 
1163 CP_iteminfo MultiPageCustomItems = { 18, 17, 0, 0, 12, MultiPageCustomNames, mn_smallfont };
1164 CP_itemtype MultiPageCustomMenu[] =
1165 {
1166 	{1, "", 'N', NULL},
1167    {1, "", 'P', NULL},
1168    {1, "", 'a', NULL},
1169    {1, "", 'a', NULL},
1170    {1, "", 'a', NULL},
1171    {1, "", 'a', NULL},
1172    {1, "", 'a', NULL},
1173    {1, "", 'a', NULL},
1174    {1, "", 'a', NULL},
1175    {1, "", 'a', NULL},
1176    {1, "", 'a', NULL},
1177    {1, "", 'a', NULL},
1178    {1, "", 'a', NULL},
1179    {1, "", 'a', NULL},
1180 };
1181 
1182 #define COLORX 113
1183 #define COLORY 43
1184 #define COLORW 60
1185 #define COLORH 96
1186 
1187 // Custom menu stuff
1188 static int CUSTOM_y[ 7 ] = { 31, 0, 63, 0, 94, 0, 126 };
1189 
1190 //
1191 // Save globals
1192 //
1193 static boolean StartGame = false;
1194 
1195 static int  SaveGamesAvail[ NUMSAVEGAMES ];
1196 static char SaveGameNames[ NUMSAVEGAMES ][ 32 ];
1197 static char SaveName[ 13 ] = "rottgam?.rot\0";
1198 
1199 static byte *savedscreen;
1200 static mapfileinfo_t * mapinfo;
1201 
1202 static void HideCursor
1203    (
1204    CP_iteminfo *item_i,
1205    CP_itemtype *items,
1206    int x,
1207    int y,
1208    int which
1209    );
1210 static void ShowCursor
1211    (
1212    CP_iteminfo *item_i,
1213    CP_itemtype *items,
1214    int x,
1215    int *y,
1216    int which,
1217    int basey
1218    );
1219 void CP_DrawSelectedGame (int w);
1220 int HandleMenu (CP_iteminfo *item_i, CP_itemtype *items, void (*routine)(int w));
1221 void DrawStoredGame ( byte * pic, int episode, int area );
1222 void DrawCustomKeyboard (void);
1223 void DrawBattleModeName( int which );
1224 void DrawBattleModeDescription( int w );
1225 void DrawSoundSetupMainMenu( void );
1226 int ColorMenu(void);
1227 
1228 //******************************************************************************
1229 //
1230 // MN_DrawButtons
1231 //
1232 //******************************************************************************
1233 
MN_DrawButtons(CP_iteminfo * item_i,CP_itemtype * items,int check,int * nums)1234 void MN_DrawButtons
1235    (
1236    CP_iteminfo *item_i,
1237    CP_itemtype *items,
1238    int check,
1239    int *nums
1240    )
1241 
1242    {
1243    int i;
1244    int button_on;
1245    int button_off;
1246 
1247    button_on  = W_GetNumForName( "snd_on" );
1248    button_off = W_GetNumForName( "snd_off" );
1249 
1250    for( i = 0; i < item_i->amount; i++ )
1251       {
1252       if ( items[ i ].active != CP_Active3 )
1253          {
1254          if ( nums[ i ] == check )
1255             {
1256             DrawMenuBufItem( item_i->x + 27, item_i->y + i *
1257                FontSize[ item_i->fontsize ] - 1, button_on);
1258             }
1259          else
1260             {
1261             DrawMenuBufItem( item_i->x + 27, item_i->y + i *
1262                FontSize[ item_i->fontsize ] - 1, button_off);
1263             }
1264          }
1265       }
1266    }
1267 
1268 
1269 //****************************************************************************
1270 //
1271 // MN_GetCursorLocation()
1272 //
1273 //****************************************************************************
1274 
MN_GetCursorLocation(CP_iteminfo * item_i,CP_itemtype * items)1275 void MN_GetCursorLocation
1276    (
1277    CP_iteminfo *item_i,
1278    CP_itemtype *items
1279    )
1280 
1281    {
1282    int i;
1283    int position;
1284 
1285    position = -1;
1286    for( i = 0; i < item_i->amount; i++ )
1287       {
1288       if ( items[ i ].active == CP_CursorLocation )
1289          {
1290          position = i;
1291          break;
1292          }
1293 
1294       if ( ( items[ i ].active == CP_Active ) && ( position == -1 ) )
1295          {
1296          position = i;
1297          }
1298       }
1299 
1300    if ( position != -1 )
1301       {
1302       item_i->curpos = position;
1303       items[ position ].active = CP_CursorLocation;
1304       }
1305    }
1306 
1307 
1308 //****************************************************************************
1309 //
1310 // MN_GetActive ()
1311 //
1312 //****************************************************************************
1313 
MN_GetActive(CP_iteminfo * item_i,CP_itemtype * items,int check,int * nums)1314 int MN_GetActive
1315    (
1316    CP_iteminfo *item_i,
1317    CP_itemtype *items,
1318    int check,
1319    int *nums
1320    )
1321 
1322    {
1323    int i;
1324    int returnval;
1325 
1326    returnval = 0;
1327    for( i = 0; i < item_i->amount; i++ )
1328       {
1329       items[ i ].active = CP_Active;
1330       if ( nums[ i ] == check )
1331          {
1332          item_i->curpos    = i;
1333          items[ i ].active = CP_CursorLocation;
1334          returnval = i;
1335          }
1336       }
1337 
1338    return( returnval );
1339    }
1340 
1341 
1342 //****************************************************************************
1343 //
1344 // MN_MakeActive ()
1345 //
1346 //****************************************************************************
1347 
MN_MakeActive(CP_iteminfo * item_i,CP_itemtype * items,int which)1348 void MN_MakeActive
1349    (
1350    CP_iteminfo *item_i,
1351    CP_itemtype *items,
1352    int which
1353    )
1354 
1355    {
1356    int i;
1357 
1358    for( i = 0; i < item_i->amount; i++ )
1359       if (i == which)
1360       {
1361          items[i].active = CP_CursorLocation;
1362          item_i->curpos    = i;
1363       }
1364       else
1365          items[i].active = CP_Active;
1366 }
1367 
1368 
1369 //******************************************************************************
1370 //
1371 // DrawMenu ()
1372 //
1373 // Purpose - Draws a menu
1374 //
1375 //******************************************************************************
DrawMenu(CP_iteminfo * item_i,CP_itemtype * items)1376 void DrawMenu
1377    (
1378    CP_iteminfo *item_i,
1379    CP_itemtype *items
1380    )
1381 
1382    {
1383    int i;
1384    int active;
1385    int color;
1386    int posx;
1387    int posy;
1388 
1389    posx = item_i->x + item_i->indent;
1390    posy = item_i->y;
1391    WindowX = posx;
1392    WindowY = posy;
1393    WindowW = 320;
1394    WindowH = 200;
1395 
1396    for ( i = 0; i < item_i->amount; i++ )
1397       {
1398       posy   = item_i->y + i * FontSize[ item_i->fontsize ];
1399       active = items[ i ].active;
1400 
1401       color = -1;
1402       switch( active )
1403          {
1404          case CP_CursorLocation :
1405             color = ACTIVECOLOR;
1406             break;
1407 
1408          case CP_Inactive :
1409             color = NOTAVAILABLECOLOR;
1410             break;
1411 
1412          case CP_Active :
1413             color = NORMALCOLOR;
1414             break;
1415 
1416          case CP_SemiActive :
1417             color = DIMMEDCOLOR;
1418             break;
1419 
1420          case CP_Highlight :
1421             color = HIGHLIGHTCOLOR;
1422             break;
1423          }
1424 
1425       if ( color != -1 )
1426          {
1427          if ( item_i->names == NULL )
1428             {
1429             DrawIMenuBufItem( posx, posy, W_GetNumForName( items[ i ].texture ),
1430                color );
1431             }
1432          else
1433             {
1434             IFont = ( cfont_t * )W_CacheLumpName( FontNames[ item_i->fontsize ],
1435                PU_CACHE, Cvt_cfont_t, 1 );
1436             if ( item_i->fontsize == mn_tinyfont )
1437                {
1438                DrawMenuBufIString( posx + 1, posy, item_i->names[ i ], 0 );
1439                }
1440             DrawMenuBufIString( posx, posy - 1, item_i->names[ i ], color );
1441             }
1442          }
1443       }
1444    }
1445 
1446 
1447 //******************************************************************************
1448 //
1449 // getASCII () - Gets info from Keyboard.
1450 //
1451 //******************************************************************************
1452 
getASCII(void)1453 int getASCII ( void )
1454 {
1455    int i;
1456    int LS;
1457    int RS;
1458    int returnvalue = 0;
1459    int scancode = 0;
1460 
1461 #ifdef DOS
1462    _disable ();      // must disable for SHIFT purposes
1463 #endif
1464 
1465    IN_UpdateKeyboard ();
1466 
1467    LS = Keyboard[sc_LShift];
1468    RS = Keyboard[sc_RShift];
1469 
1470    Keyboard[sc_LShift] = Keyboard[sc_RShift] = 0;
1471 
1472    scancode = 0;
1473 
1474    for (i = 0; i < 127; i++)
1475       if (Keyboard[i])
1476       {
1477          scancode = i;
1478          break;
1479       }
1480 
1481 	if (scancode)
1482    {
1483       if (LS || RS)
1484          returnvalue = ShiftNames[scancode];
1485       else
1486          returnvalue = ASCIINames[scancode];
1487    }
1488 
1489    Keyboard[sc_LShift] = LS;
1490    Keyboard[sc_RShift] = RS;
1491 
1492 #ifdef DOS
1493    _enable ();
1494 #endif
1495 
1496    return (returnvalue);
1497 }
1498 
1499 
1500 //******************************************************************************
1501 //
1502 // ScanForSavedGames ()
1503 //
1504 //******************************************************************************
1505 
ScanForSavedGames()1506 void ScanForSavedGames ()
1507 {
1508    struct find_t f;
1509    char filename[256];
1510    char str[45];
1511    int which;
1512    boolean found = false;
1513 #ifndef DOS
1514    char *pathsave;
1515 #endif
1516 
1517    //
1518    // SEE WHICH SAVE GAME FILES ARE AVAILABLE & READ STRING IN
1519    //
1520    memset (&SaveGamesAvail[0], 0, sizeof (SaveGamesAvail));
1521 #if 1 //PLATFORM_DOS || PLATFORM_WIN32
1522    GetPathFromEnvironment( filename, ApogeePath, SaveName );
1523 #else
1524    strncpy (filename, SaveName, 256);
1525    pathsave = getcwd (NULL, 0);
1526    chdir (ApogeePath);
1527 #endif
1528 
1529    if (!_dos_findfirst (filename, 0, &f))
1530       do
1531       {
1532          strcpy(str,&f.name[7]);
1533          sscanf((const char *)&str[0],"%x",&which);
1534 
1535          if (which < NUMSAVEGAMES)
1536          {
1537             found = true;
1538             SaveGamesAvail[which] = 1;
1539             GetSavedMessage (which, &SaveGameNames[which][0]);
1540          }
1541 
1542       } while (!_dos_findnext (&f));
1543 
1544       if (found)
1545       {
1546          if (MainMenu[loadgame].active == CP_Inactive)
1547             MainMenu[loadgame].active = CP_Active;
1548       }
1549       else
1550          MainMenu[loadgame].active = CP_Inactive;
1551 #if 0 //((!PLATFORM_DOS) && (!PLATFORM_WIN32))
1552       chdir (pathsave);
1553       free (pathsave);
1554 #endif
1555 }
1556 
1557 
1558 //******************************************************************************
1559 //
1560 // SetUpControlPanel ()
1561 //
1562 //******************************************************************************
1563 
SetUpControlPanel(void)1564 void SetUpControlPanel (void)
1565 {
1566    int i;
1567    int j;
1568    byte * b;
1569    byte * s;
1570 
1571    // Save the current game screen
1572 
1573    savedscreen = SafeMalloc (16000);
1574 
1575    // Copy the current screen to this buffer
1576 
1577    if (RefreshPause==false)
1578       {
1579       GamePaused=false;
1580       ThreeDRefresh();
1581       FlipPage();
1582       FlipPage();
1583       GamePaused=true;
1584       }
1585    s=savedscreen;
1586    for (i=0;i<320;i+=2)
1587       {
1588 #ifdef DOS
1589       VGAREADMAP(i&3);
1590       b=(byte *)bufferofs+(i>>2);
1591       for (j=0;j<100;j++,s++,b+=SCREENBWIDE<<1)
1592          *s=*b;
1593 #else
1594       b=(byte *)bufferofs+i;
1595       for (j=0;j<100;j++,s++,b+=(MAXSCREENWIDTH<<1))
1596          *s=*b;
1597 #endif
1598       }
1599 
1600    ScanForSavedGames ();
1601 
1602 
1603 
1604    if (modemgame == true)
1605       {
1606       // Make battle mode active
1607       //
1608       MainMenu[battlemode].active = CP_Active;
1609 
1610       // No save or load game in modem game
1611       //
1612       MainMenu[newgame].active    = CP_Inactive;
1613       MainMenu[backtodemo].active = CP_Inactive;
1614       MainMenu[loadgame].active   = CP_Inactive;
1615       MainMenu[savegame].active   = CP_Inactive;
1616 
1617       if ( MainMenu[ MainItems.curpos ].active == CP_Inactive )
1618          {
1619          MainItems.curpos = battlemode;
1620          }
1621 
1622       MainMenu[MainItems.curpos].active = CP_CursorLocation;
1623 
1624       if ( consoleplayer != 0 )
1625          {
1626          MainMenu[battlemode].routine = ( void (*)(int) )BattleGamePlayerSetup;
1627          }
1628       }
1629    }
1630 
1631 //******************************************************************************
1632 //
1633 // GetMenuInfo ()
1634 //
1635 // Gets the user's password
1636 //
1637 //******************************************************************************
1638 
GetMenuInfo(void)1639 void GetMenuInfo (void)
1640 {
1641    ConvertPasswordStringToPassword ();
1642 
1643    POK=true;
1644    if (pword[0]==0)
1645       POK=false;
1646 }
1647 
1648 
1649 //******************************************************************************
1650 //
1651 // WriteMenuInfo ()
1652 //
1653 // Writes out password
1654 //
1655 //******************************************************************************
1656 
WriteMenuInfo(void)1657 void WriteMenuInfo (void)
1658 {
1659    ConvertPasswordToPasswordString ();
1660 }
1661 
1662 //******************************************************************************
1663 //
1664 // AllocateSavedScreenPtr ()
1665 //
1666 //******************************************************************************
1667 
AllocateSavedScreenPtr(void)1668 void AllocateSavedScreenPtr (void)
1669 {
1670    // Save the current game screen
1671 
1672    savedscreen = SafeMalloc(16000);
1673    inmenu  = true;
1674    numdone = 0;
1675 }
1676 
1677 
1678 //******************************************************************************
1679 //
1680 // FreeSavedScreenPtr ()
1681 //
1682 //******************************************************************************
1683 
FreeSavedScreenPtr(void)1684 void FreeSavedScreenPtr (void)
1685 {
1686    SafeFree (savedscreen);
1687    inmenu  = false;
1688 }
1689 
1690 
1691 //******************************************************************************
1692 //
1693 // CleanUpControlPanel ()
1694 //
1695 //******************************************************************************
1696 
CleanUpControlPanel(void)1697 void CleanUpControlPanel (void)
1698 {
1699 	int   joyx, joyy;
1700 
1701    if ((playstate==ex_resetgame) || (loadedgame==true))
1702       ShutdownClientControls();
1703 
1704    // Free up saved screen image
1705 
1706    FreeSavedScreenPtr ();
1707 
1708    WriteConfig ();
1709 
1710    INL_GetJoyDelta (joystickport, &joyx, &joyy);
1711 
1712    if (mouseenabled)
1713       PollMouseMove ();    // Trying to kill movement
1714 
1715    if (cybermanenabled)
1716       PollCyberman ();
1717 
1718    RefreshPause = true;
1719 }
1720 
1721 
1722 //******************************************************************************
1723 //
1724 // CP_CheckQuick ()
1725 //
1726 //******************************************************************************
CP_CheckQuick(byte scancode)1727 boolean CP_CheckQuick
1728    (
1729    byte scancode
1730    )
1731 
1732    {
1733    if (demoplayback==true)
1734       {
1735       switch ( scancode )
1736          {
1737          case sc_Escape:
1738             inmenu = true;
1739             return( true );
1740             break;
1741          }
1742       }
1743    else
1744       {
1745       switch ( scancode )
1746          {
1747          case sc_Escape:
1748          case sc_F1:
1749          case sc_F2:
1750          case sc_F3:
1751          case sc_F4:
1752          case sc_F8:
1753          case sc_F9:
1754          case sc_F10:
1755             inmenu = true;
1756             return( true );
1757             break;
1758          }
1759       }
1760 
1761    return( false );
1762    }
1763 
1764 
1765 //******************************************************************************
1766 //
1767 // ControlPanel
1768 //
1769 //    ROTT Control Panel!
1770 //
1771 //******************************************************************************
ControlPanel(byte scancode)1772 void ControlPanel
1773    (
1774    byte scancode
1775    )
1776 
1777    {
1778    if ( scancode == sc_Escape )
1779       {
1780       CP_MainMenu();
1781       if ( ( playstate == ex_stillplaying ) && ( loadedgame == false ) )
1782          {
1783          fizzlein = true;
1784          }
1785       return;
1786       }
1787 
1788    SetupMenuBuf();
1789 
1790    numdone = 0;
1791    StartGame = false;
1792 
1793    SetUpControlPanel();
1794    //
1795    // F-KEYS FROM WITHIN GAME
1796    //
1797 	switch( scancode )
1798       {
1799       case sc_F1:
1800          CP_F1Help();
1801          break;
1802 
1803       case sc_F2:
1804          CP_SaveGame();
1805          break;
1806 
1807       case sc_F3:
1808          CP_LoadGame( 0, 0 );
1809          break;
1810 
1811       case sc_F4:
1812          CP_ControlMenu();
1813          break;
1814 
1815       case sc_F8:
1816          LastScan          = 0;
1817          Keyboard[ sc_F8 ] = 0;
1818          CP_EndGame();
1819          break;
1820 
1821       case sc_F9:
1822          LastScan          = 0;
1823          Keyboard[ sc_F9 ] = 0;
1824 
1825          loadsavesound = true;
1826          CP_LoadGame( 1, 0 );
1827          break;
1828 
1829       case sc_F10:
1830          SetMenuTitle ("Quit");
1831 
1832          LastScan           = 0;
1833          Keyboard[ sc_F10 ] = 0;
1834          CP_Quit( -1 );
1835          break;
1836 
1837       }
1838 
1839    CleanUpControlPanel();
1840    ShutdownMenuBuf();
1841 
1842    if ( loadedgame == false )
1843       {
1844       SetupScreen( false );
1845       fizzlein = true;
1846       inmenu = false;
1847       }
1848 
1849    loadsavesound = false;
1850    }
1851 
1852 
1853 //******************************************************************************
1854 //
1855 // CP_MainMenu
1856 //
1857 //******************************************************************************
CP_MainMenu(void)1858 menuitems CP_MainMenu
1859    (
1860    void
1861    )
1862 
1863    {
1864    int which;
1865 
1866    SetupMenuBuf();
1867 
1868    numdone = 0;
1869 
1870    SetUpControlPanel();
1871 
1872    DrawMainMenu();
1873 
1874    //
1875    // Main menu loop.  "Exit options" or "New game" exits
1876    //
1877    StartGame = false;
1878    while( !StartGame )
1879       {
1880       StartGame = false;
1881 
1882       IN_ClearKeysDown();
1883 
1884       which = HandleMenu( &MainItems, &MainMenu[ 0 ], NULL );
1885 
1886       switch( which )
1887          {
1888          case backtodemo:
1889             if ( !ingame )
1890                {
1891                playstate = ex_titles;
1892                }
1893 
1894             StartGame = true;
1895             break;
1896 
1897          case -1:
1898             CP_Quit( 0 );
1899             break;
1900 
1901          default:
1902             if ( !StartGame )
1903                {
1904                DoMainMenu();
1905                }
1906          }
1907       }
1908 
1909    // Deallocate everything
1910    CleanUpControlPanel();
1911    ShutdownMenuBuf();
1912 
1913    return( which );
1914    }
1915 
1916 
1917 //******************************************************************************
1918 //
1919 // DrawMainMenu ()
1920 //
1921 //******************************************************************************
1922 
DrawMainMenu(void)1923 void DrawMainMenu(void)
1924 {
1925 
1926    MenuNum = 1;
1927 
1928    //
1929    // CHANGE "GAME" AND "DEMO"
1930    //
1931    if ( ingame )
1932       {
1933       MainMenu[ backtodemo ].texture[ 6 ] = '1';
1934       MainMenu[ backtodemo ].texture[ 7 ] = '1';
1935       MainMenu[ backtodemo ].texture[ 8 ] = '\0';
1936       strcpy (MainMenuNames[ backtodemo ] , "BACK TO GAME");
1937       }
1938    else
1939       {
1940       MainMenu[ backtodemo ].texture[ 6 ] = '8';
1941       MainMenu[ backtodemo ].texture[ 7 ] = '\0';
1942       strcpy (MainMenuNames[ backtodemo ] , "BACK TO DEMO");
1943       }
1944 
1945    MN_GetCursorLocation( &MainItems, &MainMenu[ 0 ] );
1946    SetMenuTitle ("Main Menu");
1947    DrawMenu (&MainItems, &MainMenu[0]);
1948 
1949 	numdone ++;
1950    DisplayInfo (0);
1951 }
1952 
1953 
1954 //******************************************************************************
1955 //
1956 // Handle moving triad around a menu
1957 //
1958 //******************************************************************************
1959 
HandleMenu(CP_iteminfo * item_i,CP_itemtype * items,void (* routine)(int w))1960 int HandleMenu (CP_iteminfo *item_i, CP_itemtype *items, void (*routine)(int w))
1961 {
1962 
1963    char        key;
1964    int         i,
1965                x,
1966                y,
1967                basey,
1968                exit,
1969                numactive,
1970                count;
1971    int         newpos;
1972    volatile int timer;
1973    ControlInfo ci;
1974    boolean     playsnd = false;
1975 
1976    handlewhich = item_i->curpos;
1977    x     = item_i->x;
1978    if ((MenuNum == 4) || (MenuNum == 6) ||
1979       ( item_i->fontsize == mn_smallfont ) )
1980       {
1981       basey = item_i->y;
1982 
1983       CursorLump = SmallCursor;
1984       yinc = 9;
1985       cursorwidth = cursorheight = 8;
1986       }
1987    else if ( item_i->fontsize == mn_8x8font )
1988       {
1989       basey = item_i->y - 1;
1990 
1991       CursorLump = SmallCursor;
1992 		yinc = 7;
1993       cursorwidth = cursorheight = 8;
1994       }
1995    else if ( item_i->fontsize == mn_tinyfont )
1996       {
1997       basey = item_i->y - 2;
1998 
1999       CursorLump = SmallCursor;
2000 		yinc = 6;
2001       cursorwidth = cursorheight = 8;
2002       }
2003    else
2004       {
2005       basey = item_i->y-2;
2006 
2007       CursorLump = LargeCursor;
2008 		yinc = 14;
2009       cursorwidth = cursorheight = 16;
2010       }
2011 
2012 
2013    if (MenuNum)
2014       y = basey + handlewhich*yinc;
2015    else
2016       y = CUSTOM_y[handlewhich];
2017 
2018 
2019    if (MenuNum != 5)
2020       DrawMenuBufItem (x, y, W_GetNumForName( CursorLump ) +
2021          CursorFrame[ CursorNum ] );
2022 
2023    if (routine)
2024       routine (handlewhich);
2025 
2026    count    = 2;
2027    exit     = 0;
2028    timer    = GetTicCount();
2029    IN_ClearKeysDown ();
2030 
2031    numactive = GetNumActive (item_i, items);
2032 
2033    do
2034    {
2035       ReadAnyControl (&ci);
2036       RefreshMenuBuf (0);
2037      // Change Cursor Shape
2038       if ((GetTicCount() > (timer+count)) && (MenuNum != 5))
2039       {
2040          timer = GetTicCount();
2041 
2042          CursorNum++;
2043          if (CursorNum > (MAXCURSORNUM-1))
2044             CursorNum = 0;
2045 
2046          EraseMenuBufRegion(x, y, cursorwidth, cursorheight);
2047          DrawMenuBufItem (x, y, W_GetNumForName( CursorLump ) +
2048             CursorFrame[ CursorNum ] );
2049 
2050       }
2051 
2052      // Initial char - pass 1
2053       key = getASCII ();
2054       if (key)
2055       {
2056          int ok = 0;
2057 
2058          key = toupper (key);
2059 
2060          for (i = (handlewhich + 1); i < item_i->amount; i++)
2061             if ((items+i)->active && (items+i)->letter == key)
2062             {
2063                HideCursor (item_i, items, x, y, handlewhich);
2064                MN_PlayMenuSnd (SD_MOVECURSORSND);
2065                handlewhich = i;
2066 
2067 
2068                if (routine)
2069                   routine (handlewhich);
2070 
2071                ShowCursor (item_i, items, x, &y, handlewhich, basey);
2072                ok = 1;
2073                IN_ClearKeysDown();
2074                break;
2075             }
2076 
2077         // Initial char - pass 2
2078          if (!ok)
2079          {
2080             for (i = 0; i < handlewhich; i++)
2081                if ((items+i)->active && (items+i)->letter == key)
2082                {
2083                   HideCursor (item_i, items, x, y, handlewhich);
2084                   MN_PlayMenuSnd (SD_MOVECURSORSND);
2085                   handlewhich = i;
2086 
2087 
2088                   if (routine)
2089                      routine (handlewhich);
2090 
2091                   ShowCursor (item_i, items, x,& y, handlewhich, basey);
2092                   IN_ClearKeysDown ();
2093                   break;
2094                }
2095          }
2096       }
2097 
2098       ReadAnyControl (&ci);
2099 
2100       if (numactive > 1)
2101 		{
2102          switch (ci.dir)
2103          {
2104             case dir_North:
2105                HideCursor (item_i, items, x, y, handlewhich);
2106 
2107 
2108                CursorNum++;
2109                if (CursorNum > (MAXCURSORNUM-1))
2110                   CursorNum = 0;
2111 
2112 
2113               // Do a half step if possible
2114                if ((handlewhich) &&
2115                   (((items+handlewhich-1)->active == CP_CursorLocation) ||
2116                   ((items+handlewhich-1)->active == CP_Active)))
2117                {
2118                   y -= 6;
2119                   DrawHalfStep (x, y);
2120                   playsnd = false;
2121 
2122                   RefreshMenuBuf (0);
2123 
2124                   CursorNum++;
2125                   if (CursorNum > (MAXCURSORNUM-1))
2126                      CursorNum = 0;
2127                }
2128                else
2129                {
2130                   playsnd = true;
2131                   RefreshMenuBuf (0);
2132                }
2133 
2134                do
2135                {
2136                   if (!handlewhich)
2137                      handlewhich = item_i->amount-1;
2138                   else
2139                      handlewhich--;
2140                } while (((items+handlewhich)->active == CP_Inactive) || ((items+handlewhich)->active == CP_Active3));
2141 
2142                if (playsnd)
2143                   MN_PlayMenuSnd (SD_MOVECURSORSND);
2144 					ShowCursor (item_i, items, x, &y, handlewhich, basey);
2145 
2146                if (routine)
2147                   routine (handlewhich);
2148 
2149                RefreshMenuBuf(0);
2150             break;
2151 
2152             case dir_South:
2153                HideCursor (item_i, items, x, y, handlewhich);
2154 
2155                CursorNum++;
2156                if (CursorNum > (MAXCURSORNUM-1))
2157                   CursorNum = 0;
2158 
2159                // Do a half step if possible
2160                if ((handlewhich != item_i->amount-1) &&
2161                   (((items+handlewhich+1)->active == CP_CursorLocation) ||
2162                   ((items+handlewhich+1)->active == CP_Active)))
2163                {
2164                   y += 6;
2165                   DrawHalfStep(x,y);
2166                   playsnd = false;
2167 
2168                   RefreshMenuBuf (0);
2169 
2170                   CursorNum++;
2171                   if (CursorNum > (MAXCURSORNUM-1))
2172                      CursorNum = 0;
2173                }
2174                else
2175                {
2176                   playsnd = true;
2177                   RefreshMenuBuf (0);
2178                }
2179 
2180                do
2181                {
2182                   if (handlewhich==item_i->amount-1)
2183                      handlewhich=0;
2184                   else
2185                      handlewhich++;
2186                } while (((items+handlewhich)->active == CP_Inactive) || ((items+handlewhich)->active == CP_Active3));
2187 
2188                if (playsnd)
2189                   MN_PlayMenuSnd (SD_MOVECURSORSND);
2190                ShowCursor(item_i,items,x,&y,handlewhich,basey);
2191 
2192                if (routine)
2193                   routine (handlewhich);
2194 
2195                RefreshMenuBuf (0);
2196             break;
2197 	 default:
2198 	     ;
2199          }
2200       }
2201 
2202       ReadAnyControl (&ci);
2203       if (ci.button0 || Keyboard[sc_Space] || Keyboard[sc_Enter])
2204       {
2205          exit = 1;
2206          WaitKeyUp ();
2207          MN_PlayMenuSnd (SD_SELECTSND);
2208       }
2209 
2210       if (ci.button1 || Keyboard[sc_Escape])
2211       {
2212          WaitKeyUp ();
2213          exit = 2;
2214       }
2215 
2216       if ( ( Keyboard[ sc_Home ] ) && ( numactive > 1 ) )
2217          {
2218          newpos = 0;
2219          while( ( items[ newpos ].active == CP_Inactive ) ||
2220             ( items[ newpos ].active == CP_Active3 ) )
2221             {
2222             newpos++;
2223             }
2224 
2225          if ( newpos != handlewhich )
2226             {
2227             HideCursor( item_i, items, x, y, handlewhich );
2228 
2229             CursorNum++;
2230             if ( CursorNum > ( MAXCURSORNUM - 1 ) )
2231                {
2232                CursorNum = 0;
2233                }
2234 
2235             RefreshMenuBuf( 0 );
2236 
2237             handlewhich = newpos;
2238 
2239             MN_PlayMenuSnd( SD_MOVECURSORSND );
2240 
2241             ShowCursor( item_i, items, x, &y, handlewhich, basey );
2242 
2243             if ( routine )
2244                {
2245                routine( handlewhich );
2246                }
2247 
2248             RefreshMenuBuf( 0 );
2249             }
2250          }
2251       else if ( ( Keyboard[ sc_End ] ) && ( numactive > 1 ) )
2252          {
2253          newpos = item_i->amount - 1;
2254          while( ( items[ newpos ].active == CP_Inactive ) ||
2255             ( items[ newpos ].active == CP_Active3 ) )
2256             {
2257             newpos--;
2258             }
2259 
2260          if ( newpos != handlewhich )
2261             {
2262             HideCursor( item_i, items, x, y, handlewhich );
2263 
2264             CursorNum++;
2265             if ( CursorNum > ( MAXCURSORNUM - 1 ) )
2266                {
2267                CursorNum = 0;
2268                }
2269 
2270             RefreshMenuBuf( 0 );
2271 
2272             handlewhich = newpos;
2273 
2274             MN_PlayMenuSnd( SD_MOVECURSORSND );
2275 
2276             ShowCursor( item_i, items, x, &y, handlewhich, basey );
2277 
2278             if ( routine )
2279                {
2280                routine( handlewhich );
2281                }
2282 
2283             RefreshMenuBuf( 0 );
2284             }
2285          }
2286 
2287       // Page Up/Down
2288       if ( MenuNum == 11 )
2289          {
2290          if ( ( Keyboard[ sc_PgUp ] ) &&
2291             ( ( items + 1 )->active != CP_Inactive ) )
2292             {
2293             item_i->curpos = handlewhich;
2294             handlewhich = PAGEUP;
2295             exit = 3;
2296             MN_PlayMenuSnd( SD_SELECTSND );
2297             }
2298          else if ( ( Keyboard[ sc_PgDn ] ) &&
2299             ( ( items + 0 )->active != CP_Inactive ) )
2300             {
2301             item_i->curpos = handlewhich;
2302             handlewhich = PAGEDOWN;
2303             exit = 3;
2304             MN_PlayMenuSnd( SD_SELECTSND );
2305             }
2306          }
2307 
2308       // Delete save games
2309       if ((MenuNum == 4) || (MenuNum == 6))
2310       {
2311          if (Keyboard[sc_Delete] && SaveGamesAvail[handlewhich])
2312          {
2313             if (CP_DisplayMsg ("Delete saved game?\nAre you sure?", 12) == true)
2314             {
2315                char loadname[45] = "rottgam0.rot";
2316                char filename[128];
2317 
2318                // Create the proper file name
2319                itoa (handlewhich, &loadname[7], 16);
2320                loadname[8]='.';
2321 
2322                GetPathFromEnvironment( filename, ApogeePath, loadname );
2323 
2324                // Delete the file
2325 
2326 					unlink (filename);
2327 
2328                memset (&SaveGameNames[handlewhich][0], 0, 32);
2329                SaveGamesAvail[handlewhich] = 0;
2330                if (handlewhich==quicksaveslot)
2331                   quicksaveslot=-1;
2332 
2333                PrintX = LSM_X+LSItems.indent+2;
2334                PrintY = LSM_Y+handlewhich*9+2;
2335             }
2336             ScanForSavedGames ();
2337 
2338             LSItems.curpos = handlewhich;
2339             if (MenuNum == 4)
2340                DrawLoadSaveScreenAlt (1);
2341             else
2342                DrawLoadSaveScreenAlt (0);
2343             CP_DrawSelectedGame (handlewhich);
2344          }
2345       }
2346 
2347 
2348 #if SAVE_SCREEN
2349       if (Keyboard[sc_CapsLock] && Keyboard[sc_C])
2350       {
2351          inhmenu=true;
2352          SaveScreen (true);
2353          inhmenu=false;
2354       }
2355       else
2356          if (Keyboard[sc_CapsLock] && Keyboard[sc_X])
2357          {
2358             inhmenu=true;
2359             SaveScreen (false);
2360             inhmenu=false;
2361          }
2362          else
2363             if (Keyboard[sc_CapsLock] && Keyboard[sc_Q])
2364                Error ("Insta-Menu Quit!\n");
2365 #endif
2366 
2367    } while (!exit);
2368 
2369 
2370    IN_ClearKeysDown();
2371 
2372    if (routine)
2373       routine (handlewhich);
2374 
2375    if ( exit != 3 )
2376       {
2377       item_i->curpos = handlewhich;
2378       }
2379 
2380    if (MenuNum == 3)
2381    {
2382       if (exit != 2)
2383          CSTactive = handlewhich;
2384       else
2385          CSTactive = -1;
2386    }
2387 
2388    switch (exit)
2389    {
2390       case 1:
2391          if ((items+handlewhich)->routine!=NULL)
2392             (items+handlewhich)->routine(0);
2393          return (handlewhich);
2394 
2395       case 2:
2396          MN_PlayMenuSnd (SD_ESCPRESSEDSND);
2397          return (-1);
2398 
2399       case 3:
2400          return( handlewhich );
2401    }
2402 
2403 
2404    return (0);
2405 }
2406 
2407 //******************************************************************************
2408 //
2409 // HideCursor
2410 //
2411 //******************************************************************************
HideCursor(CP_iteminfo * item_i,CP_itemtype * items,int x,int y,int which)2412 void HideCursor
2413    (
2414    CP_iteminfo *item_i,
2415    CP_itemtype *items,
2416    int x,
2417    int y,
2418    int which
2419    )
2420 
2421    {
2422    int time = GetTicCount();
2423    int color;
2424    int delay;
2425    int posx;
2426    int posy;
2427 
2428    if ( MenuNum != 5 )
2429       {
2430 		EraseMenuBufRegion( x, y, cursorwidth, cursorheight );
2431       }
2432 
2433    if ( MenuNum && ( MenuNum != 4 ) && ( MenuNum != 6 ) )
2434       {
2435       posx = item_i->x + item_i->indent;
2436       posy = item_i->y + ( which * yinc );
2437 
2438       color = -1;
2439       switch( items[ which ].active )
2440          {
2441          case CP_Inactive :
2442             color = NOTAVAILABLECOLOR;
2443             break;
2444 
2445          case CP_CursorLocation :
2446          case CP_Active :
2447             color = NORMALCOLOR;
2448             break;
2449 
2450          case CP_SemiActive :
2451             color = DIMMEDCOLOR;
2452             break;
2453 
2454          case CP_Highlight :
2455             color = HIGHLIGHTCOLOR;
2456             break;
2457          }
2458 
2459       if ( color != -1 )
2460          {
2461          if ( item_i->names == NULL )
2462             {
2463             DrawIMenuBufItem( posx, posy,
2464                W_GetNumForName( items[ which ].texture ), color );
2465             }
2466          else
2467             {
2468             IFont = ( cfont_t * )W_CacheLumpName( FontNames[ item_i->fontsize ],
2469                PU_CACHE, Cvt_cfont_t, 1 );
2470             if ( item_i->fontsize == mn_tinyfont )
2471                {
2472                DrawMenuBufIString( posx + 1, posy, item_i->names[ which ], 0 );
2473                }
2474             DrawMenuBufIString( posx, posy - 1, item_i->names[ which ],
2475                color );
2476             }
2477          }
2478       }
2479 
2480    if ( ( items[ which ].active != CP_Inactive ) &&
2481       ( items[ which ].active != CP_SemiActive ) )
2482       {
2483       items[ which ].active = CP_Active;
2484       }
2485 
2486    delay = DELAYAMT - tics;
2487    while( ( time + delay ) > GetTicCount() )
2488       {
2489       RefreshMenuBuf (0);
2490       }
2491    }
2492 
2493 
2494 //******************************************************************************
2495 //
2496 // DrawHalfStep
2497 //
2498 //******************************************************************************
2499 
DrawHalfStep(int x,int y)2500 void DrawHalfStep (int x, int y)
2501 {
2502    MN_PlayMenuSnd (SD_MOVECURSORSND);
2503    if (MenuNum == 5)
2504       return;
2505 
2506    DrawMenuBufItem (x, y, W_GetNumForName( CursorLump ) +
2507       CursorFrame[ CursorNum ] );
2508 }
2509 
2510 
2511 //******************************************************************************
2512 //
2513 // GetNumActive ()
2514 //
2515 //******************************************************************************
2516 
GetNumActive(CP_iteminfo * item_i,CP_itemtype * items)2517 int GetNumActive (CP_iteminfo *item_i, CP_itemtype *items)
2518 {
2519    int cnt;
2520    int num = 0;
2521 
2522    for (cnt = 0; cnt < item_i->amount; cnt ++)
2523    {
2524       if ((items+cnt)->active != CP_Inactive)
2525          num++;
2526    }
2527 
2528    return (num);
2529 }
2530 
2531 
2532 //******************************************************************************
2533 //
2534 // ShowCursor
2535 //    Draw triad at new position.
2536 //
2537 //******************************************************************************
ShowCursor(CP_iteminfo * item_i,CP_itemtype * items,int x,int * y,int which,int basey)2538 void ShowCursor
2539    (
2540    CP_iteminfo *item_i,
2541    CP_itemtype *items,
2542    int x,
2543    int *y,
2544    int which,
2545    int basey
2546    )
2547 
2548    {
2549    int time = GetTicCount();
2550    int delay;
2551    int posx;
2552    int posy;
2553 
2554    if ( MenuNum )
2555       {
2556       EraseMenuBufRegion( x, *y, cursorwidth, cursorheight );
2557       *y = basey + which * yinc;
2558       }
2559    else
2560       {
2561       *y = CUSTOM_y[ which ];
2562       }
2563 
2564    if ( MenuNum != 5 )
2565       {
2566       DrawMenuBufItem( x, *y, W_GetNumForName( CursorLump ) +
2567          CursorFrame[ CursorNum ] );
2568       }
2569 
2570    if ( items[ which ].active != CP_SemiActive )
2571       {
2572       if ( MenuNum && ( MenuNum != 4 ) && ( MenuNum != 6 ) )
2573          {
2574          posx = item_i->x + item_i->indent;
2575          posy = item_i->y + which * yinc;
2576 
2577          if ( item_i->names == NULL )
2578             {
2579             DrawIMenuBufItem( posx, posy,
2580                W_GetNumForName( items[ which ].texture ), ACTIVECOLOR);
2581             }
2582          else
2583             {
2584             IFont = ( cfont_t * )W_CacheLumpName( FontNames[ item_i->fontsize ],
2585                PU_CACHE, Cvt_cfont_t, 1 );
2586             if ( item_i->fontsize == mn_tinyfont )
2587                {
2588                DrawMenuBufIString( posx + 1, posy, item_i->names[ which ], 0 );
2589                }
2590             DrawMenuBufIString( posx, posy - 1, item_i->names[ which ],
2591                ACTIVECOLOR );
2592             }
2593          }
2594 
2595       items[ which ].active = CP_CursorLocation;
2596       }
2597 
2598    delay = DELAYAMT - tics;
2599    while( ( time + delay ) > GetTicCount() )
2600       {
2601       RefreshMenuBuf( 0 );
2602       }
2603    }
2604 
2605 //******************************************************************************
2606 //
2607 // DrawOrderInfo()
2608 //
2609 //******************************************************************************
2610 
DrawOrderInfo(int which)2611 void DrawOrderInfo
2612    (
2613    int which
2614    )
2615 
2616    {
2617    int start;
2618    char *lumpname;
2619 
2620    start = W_GetNumForName( "ORDRSTRT" ) + 1;
2621 
2622    lumpname = W_GetNameForNum( start + which );
2623 
2624    // Screen shots are grabbed as pics
2625    if ( lumpname[ 0 ] == 'S' )
2626       {
2627       VWB_DrawPic( 0, 0, ( pic_t * )W_CacheLumpNum( start + which, PU_CACHE, Cvt_pic_t, 1 ) );
2628       }
2629    else
2630       {
2631       VL_DrawPostPic( W_GetNumForName( "trilogo" ) );
2632       DrawNormalSprite( 0, 0, start );
2633       DrawNormalSprite( 0, 0, start + which );
2634       }
2635 
2636    VW_UpdateScreen();
2637    }
2638 
2639 
2640 //******************************************************************************
2641 //
2642 // CP_OrderInfo()
2643 //
2644 //******************************************************************************
2645 
CP_OrderInfo(void)2646 void CP_OrderInfo
2647    (
2648    void
2649    )
2650 
2651    {
2652    int maxpage;
2653    int page;
2654    int key;
2655    boolean newpage;
2656 
2657    maxpage = W_GetNumForName( "ORDRSTOP" ) - W_GetNumForName( "ORDRSTRT" ) - 2;
2658    newpage = false;
2659    page = 1;
2660 
2661    do
2662       {
2663       DrawOrderInfo( page );
2664 
2665       if ( newpage )
2666          {
2667          while( Keyboard[ key ] )
2668             {
2669             VW_UpdateScreen();
2670             IN_UpdateKeyboard ();
2671             }
2672          }
2673 
2674       LastScan=0;
2675       while( LastScan == 0 )
2676          {
2677          VW_UpdateScreen();
2678          IN_UpdateKeyboard ();
2679          }
2680 
2681       key = LastScan;
2682       switch( key )
2683          {
2684          case sc_Home :
2685             if ( page != 1 )
2686                {
2687                page = 1;
2688                newpage = true;
2689                MN_PlayMenuSnd( SD_MOVECURSORSND );
2690                }
2691             break;
2692 
2693          case sc_End :
2694             if ( page != maxpage )
2695                {
2696                page = maxpage;
2697                newpage = true;
2698                MN_PlayMenuSnd( SD_MOVECURSORSND );
2699                }
2700             break;
2701 
2702          case sc_PgUp :
2703          case sc_UpArrow :
2704          case sc_LeftArrow :
2705             if ( page > 1 )
2706                {
2707                page--;
2708                newpage = true;
2709                MN_PlayMenuSnd( SD_MOVECURSORSND );
2710                }
2711             break;
2712 
2713          case sc_PgDn :
2714          case sc_DownArrow :
2715          case sc_RightArrow :
2716             if ( page < maxpage )
2717                {
2718                page++;
2719                newpage = true;
2720                MN_PlayMenuSnd( SD_MOVECURSORSND );
2721                }
2722             break;
2723          }
2724       }
2725    while( key != sc_Escape );
2726 
2727    Keyboard[ key ] = 0;
2728    LastScan = 0;
2729 
2730    MN_PlayMenuSnd( SD_ESCPRESSEDSND );
2731    }
2732 
2733 
2734 //******************************************************************************
2735 //
2736 // CP_ViewScores ()
2737 //
2738 //******************************************************************************
2739 
CP_ViewScores(void)2740 void CP_ViewScores (void)
2741 {
2742    CheckHighScore (0, 0, true);
2743 }
2744 
2745 
2746 //******************************************************************************
2747 //
2748 // CP_Quit () - QUIT THIS INFERNAL GAME!
2749 //
2750 //******************************************************************************
CP_Quit(int which)2751 void CP_Quit ( int which )
2752 {
2753    int num = 100;
2754    static int oldnum;
2755 
2756    while ((num >= 7) || (oldnum == num))
2757       num = (RandomNumber ("CP_QUIT", 0) & 7);
2758 
2759    oldnum = num;
2760 
2761    if (CP_DisplayMsg (endStrings[num], num))
2762    {
2763       int handle;
2764 
2765       MU_FadeOut(310);
2766       handle=SD_Play(SD_QUIT1SND+num);
2767       VL_FadeOut (0, 255, 0, 0, 0, 10);
2768       CleanUpControlPanel();
2769       SD_WaitSound (handle);
2770       QuitGame ();
2771    }
2772 
2773    if ( which != -1 )
2774       {
2775       ClearMenuBuf();
2776       DrawMainMenu();
2777       DrawMenuBufItem (MainItems.x,  ((MainItems.curpos*14)+(MainItems.y-2)),
2778          W_GetNumForName ( LargeCursor ) + CursorFrame[ CursorNum ] );
2779       RefreshMenuBuf (0);
2780       }
2781 }
2782 
2783 //******************************************************************************
2784 //
2785 // CP_DisplayMsg ()
2786 //
2787 //******************************************************************************
2788 
CP_DisplayMsg(char * s,int number)2789 boolean CP_DisplayMsg
2790    (
2791    char *s,
2792    int number
2793    )
2794 
2795    {
2796 #define Q_W    184
2797 #define Q_H    72
2798 #define Q_X    ((320-Q_W)/2)-18
2799 #define Q_Y    ((200-Q_H)/2)-33
2800 
2801 #define Q_b1X  (Q_X+85)
2802 #define Q_b2X  (Q_X+135)
2803 #define Q_bY   (Q_Y+45)
2804 #define Q_bW   33
2805 #define Q_bH   10
2806 
2807 #define W_X    72
2808 #define W_Y    11
2809 #define W_W    102
2810 
2811 #define YES    "q_yes\0"
2812 #define NO     "q_no\0"
2813 
2814    ControlInfo ci;
2815    boolean retval;
2816    boolean done;
2817    boolean YESON;
2818    boolean redraw;
2819    boolean blowout;
2820    char   *temp;
2821    char   *active;
2822    char   *inactive;
2823    int     activex;
2824    int     inactivex;
2825    int     W_H = 0;
2826    int     L_Y = 0;
2827    int     tri;
2828    int     QUITPIC;
2829    int     t;
2830 
2831    W_H = 1;
2832    retval  = false;
2833    done    = false;
2834    YESON   = true;
2835    redraw  = false;
2836    blowout = false;
2837 
2838    IN_ClearKeysDown();
2839    IN_IgnoreMouseButtons();
2840 
2841 
2842    QUITPIC = W_GetNumForName( "quitpic" );
2843 
2844    if ( number < 11 )
2845       {
2846       tri = W_GetNumForName( "QUIT01" ) + number;
2847       MN_PlayMenuSnd( SD_WARNINGBOXSND );
2848       }
2849    else
2850       {
2851       if ( number == 11 )
2852          {
2853          tri = W_GetNumForName( "tri1pic" );
2854          MN_PlayMenuSnd( SD_INFOBOXSND );
2855          }
2856       else
2857          {
2858          if ( number == 12 )
2859             {
2860             tri = W_GetNumForName( "tri2pic" );
2861             MN_PlayMenuSnd( SD_QUESTIONBOXSND );
2862             }
2863          if ( number == 13 )
2864             {
2865             tri = W_GetNumForName( "tri1pic" );
2866             MN_PlayMenuSnd( SD_WARNINGBOXSND );
2867             }
2868          }
2869       }
2870 
2871    DrawMenuBufPic( Q_X, Q_Y, QUITPIC );
2872    DrawMenuBufPic( Q_X + 12, Q_Y + 11, tri );
2873 
2874    temp = s;
2875    while( *temp )
2876       {
2877       if ( *temp == '\n' )
2878          {
2879          W_H++;
2880          }
2881       temp++;
2882       }
2883 
2884    CurrentFont = tinyfont;
2885    W_H = ( W_H * CurrentFont->height ) + 3;
2886 
2887    WindowX = Q_X + W_X;
2888    WindowY = L_Y + 2;
2889    L_Y     = Q_Y + W_Y;
2890    PrintX  = WindowX;
2891    PrintY  = WindowY;
2892 
2893    WindowW = W_W;
2894    WindowH = W_H;
2895 
2896    redraw = true;
2897 
2898    IFont = ( cfont_t * )W_CacheLumpName( FontNames[ mn_smallfont ],
2899       PU_CACHE, Cvt_cfont_t, 1 );
2900 /*
2901    DrawSTMenuBuf( WindowX, L_Y, W_W, W_H, false );
2902    MenuBufCPrint( s );
2903 
2904    DrawSTMenuBuf( Q_b1X, Q_bY, Q_bW, Q_bH, false );
2905    DrawMenuBufIString( Q_b1X + 3, Q_Y + 46, "YES", NORMALCOLOR );
2906 //   DrawIMenuBufItem (PrintX, PrintY, W_GetNumForName (YES), NORMALCOLOR);
2907 
2908    DrawSTMenuBuf( Q_b2X, Q_bY, Q_bW, Q_bH, true );
2909    DrawMenuBufIString( Q_b2X + 2, Q_Y + 45, "NO", ACTIVECOLOR );
2910 //   DrawIMenuBufItem (PrintX, PrintY, W_GetNumForName (NO), ACTIVECOLOR);
2911 */
2912    if (number != 13)
2913    {
2914    while ( !done )
2915       {
2916       RefreshMenuBuf( 0 );
2917 
2918       ReadAnyControl( &ci );
2919 
2920       if ( ( ci.dir == dir_West ) && ( !YESON ) )
2921          {
2922          MN_PlayMenuSnd( SD_MOVECURSORSND );
2923          YESON = 1;
2924          redraw = true;
2925          }
2926       else if ( ( ci.dir == dir_East ) && ( YESON ) )
2927          {
2928          MN_PlayMenuSnd( SD_MOVECURSORSND );
2929          YESON = 0;
2930          redraw = true;
2931          }
2932 
2933       if ( Keyboard[ sc_Y ] )
2934          {
2935          YESON  = 1;
2936          redraw = true;
2937          Keyboard[ sc_Enter ] = true;
2938          blowout = true;
2939          }
2940       else if ( Keyboard[ sc_N ] )
2941          {
2942          YESON  = 0;
2943          redraw = true;
2944          Keyboard[ sc_Enter ] = true;
2945          blowout = true;
2946          }
2947 
2948       if ( redraw )
2949          {
2950          redraw = false;
2951 
2952          DrawMenuBufPic( Q_X, Q_Y, QUITPIC );
2953          DrawMenuBufPic( Q_X + 12, Q_Y + 11, tri );
2954 
2955          PrintX = Q_X + W_X;
2956          PrintY = Q_Y + W_Y + 2;
2957          DrawSTMenuBuf( WindowX, L_Y, W_W, W_H, false );
2958          CurrentFont = tinyfont;
2959          MenuBufCPrint( s );
2960 
2961          if ( YESON )
2962             {
2963             active    = "YES";
2964             inactive  = "NO";
2965             activex   = Q_b1X;
2966             inactivex = Q_b2X;
2967             }
2968          else
2969             {
2970             active    = "NO";
2971             inactive  = "YES";
2972             activex   = Q_b2X;
2973             inactivex = Q_b1X;
2974             }
2975 
2976          DrawSTMenuBuf( activex, Q_bY, Q_bW, Q_bH, false );
2977          DrawMenuBufIString( activex + 3, Q_Y + 46, active, ACTIVECOLOR );
2978 //         DrawIMenuBufItem (PrintX, PrintY, W_GetNumForName (YES), NORMALCOLOR);
2979 
2980          DrawSTMenuBuf( inactivex, Q_bY, Q_bW, Q_bH, true );
2981          DrawMenuBufIString( inactivex + 2, Q_Y + 45, inactive, NORMALCOLOR );
2982 //         DrawIMenuBufItem (PrintX, PrintY, W_GetNumForName (NO), ACTIVECOLOR);
2983 
2984          for( t = 0; t < 5; t++ )
2985             {
2986             RefreshMenuBuf( 0 );
2987             }
2988          }
2989 
2990       if ( ( Keyboard[ sc_Space ] || Keyboard[ sc_Enter ] ||
2991          ci.button0 ) && YESON )
2992          {
2993          done   = true;
2994          retval = true;
2995          MN_PlayMenuSnd( SD_SELECTSND );
2996          CP_Acknowledge = CP_YES;
2997          }
2998       else if ( Keyboard[ sc_Escape ] || ci.button1 )
2999          {
3000          done   = true;
3001          retval = false;
3002          CP_Acknowledge = CP_ESC;
3003          MN_PlayMenuSnd( SD_ESCPRESSEDSND );
3004          }
3005       else if ( ( Keyboard[ sc_Space ] || Keyboard[ sc_Enter ] ||
3006          ci.button0 ) && !YESON )
3007          {
3008          done   = true;
3009          retval = false;
3010          CP_Acknowledge = CP_NO;
3011 
3012          if ( Keyboard[ sc_N ] )
3013             {
3014             MN_PlayMenuSnd( SD_SELECTSND );
3015             }
3016          else
3017             {
3018             MN_PlayMenuSnd( SD_ESCPRESSEDSND );
3019             }
3020          }
3021       }
3022 
3023    while( ( Keyboard[ sc_Enter ] || Keyboard[ sc_Space ] ||
3024       Keyboard[ sc_Escape ] ) && !blowout )
3025       {
3026       IN_UpdateKeyboard();
3027       RefreshMenuBuf( 0 );
3028       }
3029    }
3030    else
3031    {
3032       PrintX = Q_X + W_X;
3033       PrintY = Q_Y + W_Y + 2;
3034       DrawSTMenuBuf( WindowX, L_Y, W_W, W_H, false );
3035       CurrentFont = tinyfont;
3036       MenuBufCPrint( s );
3037       LastScan=0;
3038       while (LastScan == 0)
3039          {
3040          RefreshMenuBuf( 0 );
3041          }
3042       LastScan = 0;
3043       IN_UpdateKeyboard();
3044    }
3045    IN_ClearKeysDown();
3046    return( retval );
3047    }
3048 
3049 
3050 //******************************************************************************
3051 //
3052 // EndGameStuff ()
3053 //
3054 //******************************************************************************
3055 
EndGameStuff(void)3056 void EndGameStuff (void)
3057 {
3058    Z_FreeTags( PU_LEVELSTRUCT, PU_LEVELEND );
3059 
3060 	pickquick = false;
3061    CheckHighScore (gamestate.score, gamestate.mapon+1, true);
3062    locplayerstate->lives = 0;
3063    playstate = ex_died;
3064    damagecount = 0;
3065    SetBorderColor (0);
3066 
3067    AdjustMenuStruct ();
3068    ingame = false;
3069 
3070    GamePaused  = false;
3071 }
3072 
3073 
3074 //******************************************************************************
3075 //
3076 // START A NEW GAME
3077 //
3078 //******************************************************************************
3079 
3080 #define CURGAME   "You are currently in\n"\
3081       "a game. Continuing will\n"\
3082       "erase old game. Ok?\0"
3083 
3084 int ToughMenuNum;
3085 
CP_NewGame(void)3086 void CP_NewGame
3087    (
3088    void
3089    )
3090 
3091    {
3092    int which;
3093 
3094 #if ( SHAREWARE == 1 )
3095    ToughMenuNum = 0;
3096 #else
3097    int temp;
3098 
3099    temp = ToughMenuNum;
3100 
3101    while( ToughMenuNum == temp )
3102       {
3103 		temp = ( ( RandomNumber( "TOUGH MENU", 0 ) ) & 3 );
3104       if ( temp == 3 )
3105          {
3106          temp = 1;
3107          }
3108       }
3109 
3110    ToughMenuNum = temp;
3111 #endif
3112 
3113    //
3114    // ALREADY IN A GAME?
3115    //
3116    if ( ingame )
3117       {
3118       if ( !CP_DisplayMsg( CURGAME, 12 ) )
3119          {
3120          return;
3121          }
3122       else
3123          {
3124          EndGameStuff();
3125          }
3126       }
3127    else
3128       {
3129       handlewhich = 100;
3130       }
3131 
3132 	if ( CP_PlayerSelection() == 0 )
3133       {
3134 		return;
3135       }
3136 
3137    TufMenu[ ToughMenuNum ][ 0 ].active = CP_Active;
3138    TufMenu[ ToughMenuNum ][ 2 ].active = CP_Active;
3139    TufMenu[ ToughMenuNum ][ 4 ].active = CP_Active;
3140    TufMenu[ ToughMenuNum ][ 6 ].active = CP_Active;
3141 
3142    switch( DefaultDifficulty )
3143       {
3144       case gd_baby :
3145          TufItems.curpos = 0;
3146          break;
3147 
3148       case gd_easy :
3149          TufItems.curpos = 2;
3150          break;
3151 
3152       case gd_medium :
3153          TufItems.curpos = 4;
3154          break;
3155 
3156       case gd_hard :
3157          TufItems.curpos = 6;
3158          break;
3159 
3160       default :
3161          TufItems.curpos = 0;
3162          break;
3163       }
3164 
3165    TufMenu[ ToughMenuNum ][ TufItems.curpos ].active = CP_CursorLocation;
3166 
3167    DrawNewGame();
3168 
3169    which = HandleMenu( &TufItems, &TufMenu[ ToughMenuNum ][ 0 ],
3170       DrawNewGameDiff );
3171 
3172    if ( which < 0 )
3173       {
3174       handlewhich = 1;
3175       return;
3176       }
3177 
3178    handlewhich = 0;
3179 
3180    switch( which )
3181       {
3182       case 0 :
3183          DefaultDifficulty = gd_baby;
3184          break;
3185 
3186       case 2 :
3187          DefaultDifficulty = gd_easy;
3188          break;
3189 
3190       case 4 :
3191          DefaultDifficulty = gd_medium;
3192          break;
3193 
3194       case 6 :
3195          DefaultDifficulty = gd_hard;
3196          break;
3197       }
3198 
3199    MainMenu[ savegame ].active = CP_Active;
3200 
3201    gamestate.battlemode = battle_StandAloneGame;
3202    StartGame = true;
3203    playstate = ex_resetgame;
3204    }
3205 
3206 //******************************************************************************
3207 //
3208 // CP_EndGame ()
3209 //
3210 //******************************************************************************
3211 
3212 #define ENDGAMESTR   "Are you sure you want\n"\
3213                "to end the game you\n"\
3214                "are playing? (Y or N):"
3215 
CP_EndGame(void)3216 void CP_EndGame
3217    (
3218    void
3219    )
3220 
3221    {
3222    boolean action;
3223 
3224    SetMenuTitle( "End Game" );
3225    action = CP_DisplayMsg( ENDGAMESTR, 12 );
3226 
3227    StartGame = false;
3228    if ( action )
3229       {
3230       EndGameStuff ();
3231       pickquick = false;
3232       }
3233    }
3234 
3235 //******************************************************************************
3236 //
3237 // AdjustMenuStruct ()
3238 //
3239 //******************************************************************************
AdjustMenuStruct(void)3240 void AdjustMenuStruct
3241    (
3242    void
3243    )
3244 
3245    {
3246    MainMenu[ savegame ].active         = CP_Inactive;
3247    MainMenu[ viewscores ].routine      = ( void * )CP_ViewScores;
3248    MainMenu[ viewscores ].texture[ 6 ] = '7';
3249    MainMenu[ viewscores ].texture[ 7 ] = '\0';
3250    MainMenu[ viewscores ].letter       = 'V';
3251    strcpy (MainMenuNames[ viewscores ] , "VIEW SCORES");
3252    }
3253 
3254 //******************************************************************************
3255 //
3256 // CP_DrawSelectedGame
3257 //
3258 //******************************************************************************
3259 
CP_DrawSelectedGame(int w)3260 void CP_DrawSelectedGame (int w)
3261 {
3262    gamestorage_t game;
3263 
3264    if (SaveGamesAvail[w])
3265       {
3266       GetSavedHeader(w,&game);
3267 
3268       DrawStoredGame(&game.picture[0],game.episode,game.area);
3269       }
3270    else
3271       EraseMenuBufRegion(SaveGamePicX,SaveGamePicY,160,124);
3272 }
3273 
3274 //******************************************************************************
3275 //
3276 // DrawStoredGame
3277 //
3278 //******************************************************************************
3279 
DrawStoredGame(byte * pic,int episode,int area)3280 void DrawStoredGame ( byte * pic, int episode, int area )
3281 {
3282    char str[3];
3283    int level;
3284    byte *shape;
3285 
3286 	shape = W_CacheLumpNum (W_GetNumForName ("newfnt1"), PU_CACHE, Cvt_font_t, 1);
3287 	newfont1 = (font_t *)shape;
3288    CurrentFont = newfont1;
3289    EraseMenuBufRegion (74, 128, 85, 14);
3290 
3291 	DrawMenuBufPropString (74, 128, "E");
3292 
3293    itoa (episode, str, 10);
3294    DrawMenuBufPropString (87, 128, str);
3295 
3296    DrawMenuBufPropString (103, 128, "A");
3297 
3298    if (episode > 1)
3299       level = (area+1) - ((episode-1) << 3);
3300    else
3301       level = area+1;
3302 
3303    ltoa (level, str, 10);
3304    DrawMenuBufPropString (117, 128, str);
3305    CurrentFont = tinyfont;
3306 
3307    DrawMenuBufPicture(SaveGamePicX,SaveGamePicY,pic,160,100);
3308 }
3309 
3310 
3311 
3312 //******************************************************************************
3313 //
3314 // DoLoad ()
3315 //
3316 //******************************************************************************
3317 
DoLoad(int which)3318 int DoLoad (int which)
3319 {
3320    gamestorage_t game;
3321    int exit = 0;
3322 
3323    if ((which >= 0) && SaveGamesAvail[which])
3324    {
3325       loadedgame = true;
3326 
3327       if (loadsavesound)
3328          MN_PlayMenuSnd (SD_SELECTSND);
3329 
3330       if (LoadTheGame (which, &game) == true)
3331       {
3332          MenuFixup ();
3333          StartGame = true;
3334 			exit      = 1;
3335       }
3336       else
3337       {
3338          if (CP_DisplayMsg ("Saved Game is\n old or incompatible\nDelete it?", 12)==true)
3339          {
3340             char loadname[45] = "rottgam0.rot";
3341             char filename[128];
3342 
3343             // Create the proper file name
3344             itoa (which, &loadname[7], 16);
3345             loadname[8]='.';
3346 
3347             GetPathFromEnvironment( filename, ApogeePath, loadname );
3348 
3349             // Delete the file
3350 
3351             unlink (filename);
3352 
3353             memset (&SaveGameNames[which][0], 0, 32);
3354             SaveGamesAvail[which] = 0;
3355          }
3356 
3357          loadedgame = false;
3358          DrawLoadSaveScreenAlt (0);
3359       }
3360    }
3361 
3362    return (exit);
3363 }
3364 
3365 
3366 //******************************************************************************
3367 //
3368 // LOAD SAVED GAMES
3369 //
3370 //******************************************************************************
3371 
CP_LoadGame(int quick,int dieload)3372 int CP_LoadGame (int quick, int dieload)
3373 {
3374    int which,
3375        exit = 0;
3376 
3377 
3378 	MenuNum = 6;
3379 
3380    SaveTime = GetTicCount();
3381 
3382    //
3383    // QUICKLOAD?
3384    //
3385    if (quick)
3386    {
3387       which = LSItems.curpos;
3388 
3389       if (SaveGamesAvail[which])
3390       {
3391          if (dieload)
3392          {
3393             DrawLoadSaveScreenAlt (0);
3394             CP_DrawSelectedGame (which);
3395             RefreshMenuBuf (0);
3396             DoLoad (which);
3397 
3398             return (1);
3399          }
3400          else
3401          {
3402             DrawLoadSaveScreen (0);
3403             if (CP_DisplayMsg ("Quick load saved game?\nAre you sure?", 12) == true)
3404             {
3405                DrawLoadSaveScreen (0);
3406                CP_DrawSelectedGame (which);
3407                RefreshMenuBuf (0);
3408                DoLoad (which);
3409 
3410                return (1);
3411             }
3412             else
3413             {
3414 					return (0);
3415             }
3416          }
3417       }
3418    }
3419 
3420    DrawLoadSaveScreen (0);
3421    do
3422    {
3423       which = HandleMenu (&LSItems, &LSMenu[0], CP_DrawSelectedGame);
3424 
3425       if ((exit = DoLoad (which)))
3426          break;
3427 
3428    } while (which >= 0);
3429 
3430    handlewhich = OUTOFRANGE;
3431 
3432    if (MainMenu[loadgame].active == CP_Inactive)    // If all the saved games have been
3433    {
3434       MainItems.curpos = 0;               //  deleted dehighlight LOADGAME
3435       MainMenu[newgame].active = CP_CursorLocation;
3436    }
3437 
3438    return exit;
3439 }
3440 
3441 //******************************************************************************
3442 //
3443 // QuickSaveGame ()
3444 //
3445 //******************************************************************************
3446 
QuickSaveGame(void)3447 void QuickSaveGame (void)
3448 {
3449    int i;
3450    int j;
3451    byte * b;
3452    byte * s;
3453    int which;
3454    gamestorage_t game;
3455    byte * buf;
3456    int length;
3457 
3458    char   loadname[45]="rottgam0.rot";
3459    char   filename[128];
3460 
3461    // Create the proper file name
3462 
3463    itoa(quicksaveslot,&loadname[7],16);
3464    loadname[8]='.';
3465 
3466    GetPathFromEnvironment( filename, ApogeePath, loadname );
3467    length=LoadFile(filename,(void **)&buf);
3468    GetPathFromEnvironment( filename, ApogeePath, QUICKSAVEBACKUP );
3469    SaveFile(filename,buf,length);
3470    SafeFree(buf);
3471 
3472    s=&game.picture[0];
3473    for (i=0;i<320;i+=2)
3474       {
3475 #ifdef DOS
3476       VGAREADMAP(i&3);
3477       b=(byte *)bufferofs+(i>>2);
3478       for (j=0;j<100;j++,s++,b+=SCREENBWIDE<<1)
3479          *s=*b;
3480 #else
3481       b=(byte *)bufferofs+i;
3482       for (j=0;j<100;j++,s++,b+=(MAXSCREENWIDTH<<1))
3483          *s=*b;
3484 #endif
3485       }
3486 
3487    ScanForSavedGames ();
3488    which = quicksaveslot;
3489 
3490    if (SaveGamesAvail[which])
3491       {
3492       game.episode = gamestate.episode;
3493       game.area    = gamestate.mapon;
3494       game.version = ROTTVERSION;
3495       strcpy (game.message, &SaveGameNames[which][0]);
3496 
3497       if (SaveTheGame (which, &game) == true)
3498          {
3499          char str[50];
3500 
3501          strcpy (str, "Game Saved: ");
3502          strcat (str, &SaveGameNames[which][0]);
3503          AddMessage(str,MSG_SYSTEM);
3504          }
3505       else
3506          {
3507          AddMessage("Game Not Saved.",MSG_SYSTEM);
3508          }
3509       }
3510    else
3511       {
3512       AddMessage("No Quick Save Slot.",MSG_SYSTEM);
3513       }
3514 
3515    }
3516 
3517 //******************************************************************************
3518 //
3519 // UndoQuickSaveGame ()
3520 //
3521 //******************************************************************************
3522 
UndoQuickSaveGame(void)3523 void UndoQuickSaveGame (void)
3524 {
3525    byte * buf;
3526    char   loadname[45]="rottgam0.rot";
3527    char   filename[128];
3528    int length;
3529 
3530    if (quicksaveslot!=-1)
3531       {
3532       // Create the proper file name
3533 
3534       itoa(quicksaveslot,&loadname[7],16);
3535       loadname[8]='.';
3536       GetPathFromEnvironment( filename, ApogeePath, QUICKSAVEBACKUP );
3537       length=LoadFile(filename,(void **)&buf);
3538       GetPathFromEnvironment( filename, ApogeePath, loadname );
3539       SaveFile(filename,buf,length);
3540       SafeFree(buf);
3541       AddMessage("Previous Quicksave Game Restored.",MSG_SYSTEM);
3542       }
3543    else
3544       {
3545       AddMessage("No Quick Save Slot Selected.",MSG_SYSTEM);
3546       }
3547 }
3548 
3549 
3550 //******************************************************************************
3551 //
3552 // SAVE CURRENT GAME
3553 //
3554 //******************************************************************************
CP_SaveGame(void)3555 int CP_SaveGame ( void )
3556 {
3557    int  which,
3558         exit=0;
3559 
3560    char input[32];
3561    gamestorage_t game;
3562 
3563 
3564 	MenuNum = 4;
3565 
3566 
3567    DrawLoadSaveScreen (1);
3568 
3569    do
3570    {
3571       which = HandleMenu (&LSItems, &LSMenu[0], CP_DrawSelectedGame);
3572       if (which >= 0)
3573       {
3574          //
3575          // OVERWRITE EXISTING SAVEGAME?
3576          //
3577 	  if (SaveGamesAvail[which]) {
3578             if (!CP_DisplayMsg (GAMESVD, 12))
3579             {
3580                DrawLoadSaveScreenAlt (1);
3581                continue;
3582             }
3583             else
3584             {
3585                DrawLoadSaveScreenAlt (1);
3586                EraseMenuBufRegion (LSM_X+LSItems.indent, LSM_Y+1+which*9, 80, 8);
3587                PrintLSEntry (which);
3588             }
3589 	  }
3590          quicksaveslot=which;
3591 
3592          DrawStoredGame (savedscreen, gamestate.episode, gamestate.mapon);
3593 
3594          strcpy (input, &SaveGameNames[which][0]);
3595 
3596          if (!SaveGamesAvail[which])
3597             EraseMenuBufRegion (LSM_X+LSItems.indent+1, LSM_Y+which*9+2,
3598                                 77, 6);
3599 
3600 #ifdef DC
3601 	{
3602 	struct dosdate_t *date;
3603 	_dos_getdate(date);
3604 	sprintf(input,"E%dA%d %04d/%02d/%02d",gamestate.episode,gamestate.mapon+1,date->year,date->month,date->day);
3605 
3606 	}
3607 	if (1)
3608 #else
3609          if (US_LineInput (LSM_X+LSItems.indent+2, LSM_Y+which*9+2,
3610                            input, input, true, 22, 75, 0))
3611 #endif
3612          {
3613             SaveGamesAvail[which] = 1;
3614             memcpy(&game.picture[0],savedscreen,16000);
3615             game.episode=gamestate.episode;
3616             game.area=gamestate.mapon;
3617             game.version=ROTTVERSION;
3618             strcpy (game.message, input);
3619             strcpy (&SaveGameNames[which][0], input);
3620 
3621             if (SaveTheGame(which,&game)==true)
3622                {
3623 					MainMenu[loadgame].active=CP_Active;
3624 
3625 //               MN_PlayMenuSnd (SD_SELECTSND);
3626                exit = 1;
3627                }
3628             WaitKeyUp ();
3629          }
3630          else
3631          {
3632             EraseMenuBufRegion (LSM_X+LSItems.indent+1, LSM_Y+which*9+2,
3633                                 77, 6);
3634 
3635             PrintX = LSM_X+LSItems.indent+2;
3636             PrintY = LSM_Y+which*9+2;
3637 
3638             if (SaveGamesAvail[which])
3639                DrawMenuBufPropString (PrintX, PrintY, SaveGameNames[which]);
3640             else
3641                DrawMenuBufPropString (PrintX, PrintY, "     - � -");
3642 
3643 //            MN_PlayMenuSnd (SD_ESCPRESSEDSND);
3644             continue;
3645          }
3646          break;
3647       }
3648 
3649    } while (which >= 0);
3650 
3651    handlewhich = OUTOFRANGE;
3652 
3653    return (exit);
3654 }
3655 
3656 
3657 
3658 //******************************************************************************
3659 //
3660 // DEFINE CONTROLS
3661 //
3662 //******************************************************************************
3663 
CP_Control(void)3664 void CP_Control (void)
3665 {
3666    #define CTL_SPC   70
3667 
3668    int which;
3669 
3670    DrawCtlScreen ();
3671    WaitKeyUp ();
3672 
3673    do
3674    {
3675       which = HandleMenu (&CtlItems, &CtlMenu[0], NULL);
3676 
3677       switch (CSTactive)
3678       {
3679          case MOUSEENABLE:
3680             if (MousePresent)
3681             {
3682                mouseenabled^=1;
3683                DrawCtlButtons ();
3684                CusItems.curpos=-1;
3685             }
3686             else
3687                mouseenabled = 0;
3688          break;
3689 
3690 			case JOYENABLE:
3691             joystickenabled^=1;
3692             if ( joystickenabled )
3693                {
3694                if ( !CalibrateJoystick() )
3695                   {
3696                   joystickenabled = 0;
3697                   joypadenabled = 0;
3698                   }
3699                }
3700             else
3701                {
3702                joypadenabled = 0;
3703                }
3704             DrawCtlScreen();
3705             break;
3706 
3707          case USEPORT2:
3708             joystickport^=1;
3709             if ( joystickport )
3710                {
3711                joypadenabled = 0;
3712                }
3713 
3714             joystickenabled = 1;
3715             if ( !CalibrateJoystick() )
3716                {
3717                joystickenabled = 0;
3718                joystickport = 0;
3719                }
3720 
3721             if ( joystickport )
3722                {
3723                CtlMenu[ 3 ].active = CP_Inactive;
3724                joypadenabled = 0;
3725                }
3726             else
3727                {
3728                CtlMenu[ 3 ].active = CP_Active;
3729                }
3730 
3731             DrawCtlScreen();
3732          break;
3733 
3734          case PADENABLE:
3735             joypadenabled^=1;
3736             if ( ( joypadenabled ) && ( !joystickenabled ) )
3737                {
3738                joystickenabled=1;
3739                if ( !CalibrateJoystick() )
3740                   {
3741                   joystickenabled = 0;
3742                   joypadenabled = 0;
3743                   }
3744 
3745                DrawCtlScreen();
3746                }
3747             else
3748                {
3749                DrawCtlButtons ();
3750                }
3751          break;
3752 
3753          case SPACEBALLENABLE:
3754             spaceballenabled ^= 1;
3755             DrawCtlButtons ();
3756          break;
3757 
3758          case CYBERMANENABLE:
3759             cybermanenabled ^= 1;
3760             DrawCtlButtons ();
3761          break;
3762 
3763 			case THRESSENS:
3764          case MOUSESENS:
3765          case CUSTOMIZE:
3766             DrawCtlScreen ();
3767          break;
3768       }
3769 
3770    } while (which >= 0);
3771 
3772    DrawControlMenu ();
3773 
3774    if (which < 0)
3775    {
3776       handlewhich = 1;
3777       return;
3778    }
3779 }
3780 
3781 
3782 //****************************************************************************
3783 //
3784 // CP_Custom ()
3785 //
3786 //****************************************************************************
3787 
CP_Custom(void)3788 void CP_Custom (void)
3789 {
3790    int which;
3791 
3792    DrawCustomMenu();
3793 
3794    do
3795    {
3796       which = HandleMenu (&CustomItems, &CustomMenu[0], NULL);
3797    } while (which >= 0);
3798 
3799    DrawCtlScreen ();
3800 }
3801 
3802 
3803 //******************************************************************************
3804 //
3805 // CUSTOMIZE CONTROLS
3806 //
3807 //******************************************************************************
3808 
3809 //****************************************************************************
3810 //
3811 // CP_Keyboard ()
3812 //
3813 //****************************************************************************
CP_Keyboard(void)3814 void CP_Keyboard
3815    (
3816    void
3817    )
3818 
3819    {
3820    int which;
3821 
3822    MenuNum = 1;
3823 
3824    DrawCustomKeyboard ();
3825 
3826    do
3827       {
3828       which = HandleMenu( &NormalKeyItems, &NormalKeyMenu[ 0 ], NULL );
3829       }
3830    while( which >= 0 );
3831 
3832    DrawCustomMenu();
3833    }
3834 
3835 
3836 //******************************************************************************
3837 //
3838 // DEFINE THE KEYBOARD BUTTONS
3839 //
3840 //******************************************************************************
3841 
DefineKey(void)3842 void DefineKey
3843    (
3844    void
3845    )
3846 
3847    {
3848    boolean tick;
3849    boolean picked;
3850    int     timer;
3851    int     x;
3852    int     y;
3853 
3854    tick   = false;
3855    picked = false;
3856    timer  = GetTicCount();
3857 
3858    x = NORMALKEY_X + 97;
3859    y = NORMALKEY_Y + ( handlewhich * FontSize[ NormalKeyItems.fontsize ] );
3860 
3861    strcpy( &NormalKeyNames[ handlewhich ][ KEYNAMEINDEX ],
3862       "     " );
3863 
3864 //   SetMenuTitle ( "Select which key to use" );
3865    ClearMenuBuf();
3866    DrawMenu( &NormalKeyItems, &NormalKeyMenu[ 0 ] );
3867    DisplayInfo( 0 );
3868 
3869    DrawMenuBufIString( x + 3, y, "?", 0 );
3870    DrawMenuBufIString( x + 2, y - 1, "?", HIGHLIGHTCOLOR );
3871 
3872    RefreshMenuBuf( 0 );
3873 
3874    do
3875       {
3876 
3877       IN_PumpEvents();
3878 
3879       //
3880       // FLASH CURSOR
3881       //
3882       if ( ( GetTicCount() - timer ) > 10 )
3883          {
3884          int color;
3885 
3886          if ( tick )
3887             {
3888             color = HIGHLIGHTCOLOR;
3889             }
3890          else
3891             {
3892             color = DIMMEDCOLOR;
3893             }
3894 
3895          DrawMenuBufIString( x + 3, y, "?", 0 );
3896          DrawMenuBufIString( x + 2, y - 1, "?", color );
3897 
3898          tick  = !tick;
3899          timer = GetTicCount();
3900          }
3901 
3902       RefreshMenuBuf( 0 );
3903 
3904 
3905       if ( LastScan )
3906          {
3907          int key;
3908 
3909          key = LastScan;
3910          LastScan = 0;
3911 
3912          buttonscan[ (unsigned int)order[ handlewhich ] ] = key;
3913 
3914          strcpy( &NormalKeyNames[ handlewhich ][ KEYNAMEINDEX ],
3915             IN_GetScanName( key ) );
3916 
3917          picked = true;
3918 
3919          WaitKeyUp();
3920          Keyboard[ key ] = 0;
3921 
3922          IN_ClearKeysDown();
3923          }
3924       }
3925    while( !picked );
3926 
3927    ClearMenuBuf();
3928    SetMenuTitle( "Customize Keyboard" );
3929 
3930    DrawMenu( &NormalKeyItems, &NormalKeyMenu[ 0 ] );
3931    DisplayInfo( 0 );
3932    RefreshMenuBuf (0);
3933    }
3934 
3935 //****************************************************************************
3936 //
3937 // DrawControlSelect ()
3938 //
3939 //****************************************************************************
3940 
DrawControlSelect(void)3941 void DrawControlSelect
3942    (
3943    void
3944    )
3945 
3946    {
3947    MenuNum = 1;
3948 
3949    SetAlternateMenuBuf();
3950    ClearMenuBuf();
3951    SetMenuTitle ("Select Button Function");
3952 
3953    MN_GetCursorLocation( &ControlSelectItems, &ControlSelectMenu[ 0 ] );
3954    DrawMenu( &ControlSelectItems, &ControlSelectMenu[ 0 ] );
3955 
3956    DisplayInfo( 0 );
3957    FlipMenuBuf();
3958    }
3959 
3960 
3961 //****************************************************************************
3962 //
3963 // DefineMouseBtn()
3964 //
3965 //****************************************************************************
3966 
DefineMouseBtn(void)3967 void DefineMouseBtn
3968    (
3969    void
3970    )
3971 
3972    {
3973    int button;
3974    int which;
3975 
3976    button = handlewhich;
3977 
3978    MN_GetActive( &ControlSelectItems, &ControlSelectMenu[ 0 ],
3979       buttonmouse[ button ], controlorder );
3980 
3981    DrawControlSelect();
3982 
3983    which = HandleMenu( &ControlSelectItems, &ControlSelectMenu[ 0 ], NULL );
3984    if ( which != -1 )
3985       {
3986       buttonmouse[ button ] = controlorder[ which ];
3987       }
3988 
3989    handlewhich = OUTOFRANGE;
3990    }
3991 
3992 //****************************************************************************
3993 //
3994 // CP_Mouse ()
3995 //
3996 //****************************************************************************
CP_Mouse(void)3997 void CP_Mouse
3998    (
3999    void
4000    )
4001 
4002    {
4003    int which;
4004 
4005    MenuNum = 1;
4006 
4007    do
4008       {
4009       DrawCustomMouse();
4010       which = HandleMenu( &MouseBtnItems, &MouseBtnMenu[ 0 ], NULL );
4011       }
4012    while( which >= 0 );
4013 
4014    handlewhich = OUTOFRANGE;
4015 
4016    DrawCustomMenu();
4017    }
4018 
4019 
4020 //****************************************************************************
4021 //
4022 // DrawCustomMouse ()
4023 //
4024 //****************************************************************************
4025 
DrawCustomMouse(void)4026 void DrawCustomMouse
4027    (
4028    void
4029    )
4030 
4031    {
4032    int i;
4033    int j;
4034    int num;
4035    int button;
4036 
4037    SetAlternateMenuBuf();
4038    ClearMenuBuf();
4039    SetMenuTitle ("Customize Mouse");
4040 
4041    for( i = 0; i < MAX_MOUSEBTN*2; i++ )
4042       {
4043       num = 0;
4044       button = buttonmouse[ i ];
4045       buttonmouse[ i ] = bt_nobutton;
4046       MouseBtnNames[ i ][ MOUSEBTNINDEX ] = 0;
4047 
4048       for( j = 0; j < NUMCONTROLNAMES; j++ )
4049          {
4050          if ( button == controlorder[ j ] )
4051             {
4052             buttonmouse[ i ] = button;
4053             num = j;
4054             break;
4055             }
4056          }
4057 
4058       strcpy( &MouseBtnNames[ i ][ MOUSEBTNINDEX ],
4059          ControlNames[ num ] );
4060       }
4061 
4062    MN_GetCursorLocation( &MouseBtnItems, &MouseBtnMenu[ 0 ] );
4063    DrawMenu( &MouseBtnItems, &MouseBtnMenu[ 0 ] );
4064 
4065    DisplayInfo( 0 );
4066    FlipMenuBuf();
4067    }
4068 
4069 
4070 //****************************************************************************
4071 //
4072 // DefineJoyBtn()
4073 //
4074 //****************************************************************************
4075 
DefineJoyBtn(void)4076 void DefineJoyBtn
4077    (
4078    void
4079    )
4080 
4081    {
4082    int button;
4083    int which;
4084 
4085    button = handlewhich;
4086 
4087    MN_GetActive( &ControlSelectItems, &ControlSelectMenu[ 0 ],
4088       buttonjoy[ button ], controlorder );
4089 
4090    DrawControlSelect();
4091 
4092    which = HandleMenu( &ControlSelectItems, &ControlSelectMenu[ 0 ], NULL );
4093    if ( which != -1 )
4094       {
4095       buttonjoy[ button ] = controlorder[ which ];
4096       }
4097 
4098    handlewhich = OUTOFRANGE;
4099    }
4100 
4101 
4102 //****************************************************************************
4103 //
4104 // DrawCustomJoystick ()
4105 //
4106 //****************************************************************************
4107 
DrawCustomJoystick(void)4108 void DrawCustomJoystick
4109    (
4110    void
4111    )
4112 
4113    {
4114    int i;
4115    int j;
4116    int num;
4117    int button;
4118    int active;
4119    int n_btn;
4120 
4121    SetAlternateMenuBuf();
4122    ClearMenuBuf();
4123    SetMenuTitle ("Customize Joystick");
4124    for( i = 0; i < MAX_JOYBTN*2; i++ )
4125       {
4126       num = 0;
4127       button = buttonjoy[ i ];
4128       buttonjoy[ i ] = bt_nobutton;
4129       JoyBtnNames[ i ][ JOYBTNINDEX ] = 0;
4130 
4131       for( j = 0; j < NUMCONTROLNAMES; j++ )
4132          {
4133          if ( button == controlorder[ j ] )
4134             {
4135             buttonjoy[ i ] = button;
4136             num = j;
4137             break;
4138             }
4139          }
4140 
4141       strcpy( &JoyBtnNames[ i ][ JOYBTNINDEX ], ControlNames[ num ] );
4142       }
4143 
4144 #ifdef DC
4145     n_btn = MAX_JOYBTN;
4146 #else
4147     n_btn = (joypadenabled)?4:2;
4148 #endif
4149     for(i=0;i<n_btn;i++) {
4150         JoyBtnMenu[i].active = CP_Active;
4151         JoyBtnMenu[i+MAX_JOYBTN].active = CP_Active;
4152     }
4153     for(;i<MAX_JOYBTN;i++) {
4154         JoyBtnMenu[i].active = CP_Inactive;
4155         JoyBtnMenu[i+MAX_JOYBTN].active = CP_Inactive;
4156     }
4157 
4158    if ( JoyBtnMenu[ JoyBtnItems.curpos ].active == CP_Inactive )
4159       {
4160       MN_GetCursorLocation( &JoyBtnItems, &JoyBtnMenu[ 0 ] );
4161       }
4162    else
4163       {
4164       JoyBtnMenu[ JoyBtnItems.curpos ].active = CP_CursorLocation;
4165       }
4166 
4167    DrawMenu( &JoyBtnItems, &JoyBtnMenu[ 0 ] );
4168 
4169    DisplayInfo( 0 );
4170    FlipMenuBuf();
4171    }
4172 
4173 
4174 //****************************************************************************
4175 //
4176 // CP_Joystick ()
4177 //
4178 //****************************************************************************
4179 
CP_Joystick(void)4180 void CP_Joystick
4181    (
4182    void
4183    )
4184 
4185    {
4186    int which;
4187 
4188    MenuNum = 1;
4189 
4190    do
4191       {
4192       DrawCustomJoystick();
4193       which = HandleMenu( &JoyBtnItems, &JoyBtnMenu[ 0 ], NULL );
4194       }
4195    while( which >= 0 );
4196 
4197    handlewhich = OUTOFRANGE;
4198 
4199    DrawCustomMenu();
4200    }
4201 
4202 
4203 //******************************************************************************
4204 //
4205 // PRINT A MESSAGE IN A WINDOW
4206 //
4207 //******************************************************************************
4208 
Message(char * string)4209 void Message (char *string)
4210 {
4211    int   h = 0,
4212          w = 0,
4213          mw = 0,
4214          i;
4215    byte *shape;
4216 
4217 	shape = W_CacheLumpNum (W_GetNumForName ("newfnt1"), PU_CACHE, Cvt_font_t, 1);
4218 	newfont1 = (font_t *)shape;
4219    CurrentFont = newfont1;
4220    h = CurrentFont->height;
4221 
4222    for (i = 0; i < (int)strlen (string); i++)
4223       if (string[i] == '\n')
4224       {
4225          if (w > mw)
4226             mw = w;
4227          w = 0;
4228          h += CurrentFont->height;
4229       }
4230       else
4231          w += CurrentFont->width[string[i]-31];
4232 
4233    if ((w + 10) > mw)
4234       mw = w+10;
4235 
4236    PrintY = 78 - (h / 2);
4237    PrintX = WindowX = 143 - (mw / 2);
4238    WindowW = mw;
4239 
4240    EraseMenuBufRegion (WindowX-5, PrintY-5, (mw+14)&0xFFFC, h+10);
4241 	DrawSTMenuBuf (WindowX-5, PrintY-5, (mw+14)&0xFFFC, h+10, true);
4242 
4243    MenuBufCPrint (string);
4244    RefreshMenuBuf (0);
4245 }
4246 
4247 
4248 
4249 //******************************************************************************
4250 //
4251 // DRAW NEW GAME MENU
4252 //
4253 //******************************************************************************
4254 
DrawNewGame(void)4255 void DrawNewGame (void)
4256 {
4257    MenuNum = 5;
4258 
4259    SetAlternateMenuBuf ();
4260    ClearMenuBuf ();
4261    SetMenuTitle ("Choose Difficulty");
4262    DrawMenu (&TufItems, &TufMenu[ToughMenuNum][0]);
4263    DrawNewGameDiff (TufItems.curpos);
4264    DisplayInfo (0);
4265    FlipMenuBuf();
4266 
4267 }
4268 
4269 //******************************************************************************
4270 //
4271 // DRAW NEW GAME GRAPHIC
4272 //
4273 //******************************************************************************
4274 
4275 int newgameY[7] = {19, 0, 42, 0, 74, 0, 93};
4276 char *DifficultyStrings[ 4 ] =
4277    {
4278    "Easy", "Medium", "Hard", "Crezzy Man"
4279    };
4280 
DrawNewGameDiff(int w)4281 void DrawNewGameDiff
4282    (
4283    int w
4284    )
4285 
4286    {
4287    int x;
4288 
4289    switch ( w )
4290       {
4291       case 0:
4292          x = 0;
4293          break;
4294 
4295       case 2:
4296          x = 1;
4297          break;
4298 
4299       case 4:
4300          x = 2;
4301          break;
4302 
4303       case 6:
4304          x = 3;
4305          break;
4306       }
4307 
4308    EraseMenuBufRegion( 25, 18, 52, 125 );
4309    DrawMenuBufPic( 25, newgameY[ w ], W_GetNumForName( "NEWG1" ) +
4310       ( ToughMenuNum * 4 ) + x );
4311    EraseMenuBufRegion( 25, 149, 64, 8 );
4312 //   DrawMenuBufPic (25, 149, W_GetNumForName( "O_EASY" ) + x );
4313 
4314    CurrentFont = tinyfont;
4315    DrawMenuBufPropString( 25, 149, DifficultyStrings[ x ] );
4316    }
4317 
4318 
4319 //******************************************************************************
4320 //
4321 // DRAW THE LOAD/SAVE SCREEN
4322 //
4323 //******************************************************************************
4324 
DrawLoadSaveScreen(int loadsave)4325 void DrawLoadSaveScreen (int loadsave)
4326 {
4327    int i;
4328    byte *shape;
4329 
4330 	shape = W_CacheLumpNum (W_GetNumForName ("newfnt1"), PU_CACHE, Cvt_font_t, 1);
4331 	newfont1 = (font_t *)shape;
4332    CurrentFont = newfont1;
4333 
4334    if (numdone || (!ingame) || (!inmenu))
4335       SetAlternateMenuBuf();
4336 
4337    ClearMenuBuf();
4338    if (loadsave)
4339       {
4340       SetMenuTitle ("Save Game");
4341       }
4342    else
4343       {
4344       SetMenuTitle ("Load Game");
4345       }
4346 
4347    for (i = 0; i < NUMSAVEGAMES; i++)
4348       PrintLSEntry (i);
4349    DrawMenuBufItem (LSItems.x, ((LSItems.curpos*9)+(LSItems.y)),
4350       W_GetNumForName( SmallCursor ) + CursorFrame[ CursorNum ] );
4351    DisplayInfo (7);
4352    if ((!numdone) && ingame && inmenu)
4353       RefreshMenuBuf (0);
4354    else
4355 		FlipMenuBuf();
4356 
4357    WaitKeyUp ();
4358 
4359    numdone++;
4360 }
4361 
4362 //******************************************************************************
4363 //
4364 // DRAW THE LOAD/SAVE SCREEN - no flip
4365 //
4366 //******************************************************************************
4367 
DrawLoadSaveScreenAlt(int loadsave)4368 void DrawLoadSaveScreenAlt (int loadsave)
4369 {
4370    int i;
4371    byte *shape;
4372 
4373 	shape = W_CacheLumpNum (W_GetNumForName ("newfnt1"), PU_CACHE, Cvt_font_t, 1);
4374 	newfont1 = (font_t *)shape;
4375    CurrentFont = newfont1;
4376 
4377    ClearMenuBuf();
4378    if (loadsave)
4379       {
4380       SetMenuTitle ("Save Game");
4381       }
4382    else
4383       {
4384       SetMenuTitle ("Load Game");
4385       }
4386 
4387    for (i = 0; i < NUMSAVEGAMES; i++)
4388       PrintLSEntry (i);
4389    DrawMenuBufItem (LSItems.x, ((LSItems.curpos*9)+(LSItems.y)),
4390       W_GetNumForName( SmallCursor ) + CursorFrame[ CursorNum ] );
4391    DisplayInfo (7);
4392    RefreshMenuBuf (0);
4393 
4394    WaitKeyUp ();
4395 
4396    numdone++;
4397 }
4398 
4399 
4400 //******************************************************************************
4401 //
4402 // PRINT LOAD/SAVE GAME ENTRY W/BOX OUTLINE
4403 //
4404 //******************************************************************************
4405 
PrintLSEntry(int w)4406 void PrintLSEntry (int w)
4407 {
4408 
4409    DrawSTMenuBuf (LSM_X+LSItems.indent, LSM_Y+1+w*9, 80, 7, false);
4410 
4411    PrintX = LSM_X+LSItems.indent+2;
4412    PrintY = LSM_Y+(w*9)+2;
4413 
4414    CurrentFont = tinyfont;
4415 
4416    if (SaveGamesAvail[w])
4417       DrawMenuBufPropString (PrintX, PrintY, SaveGameNames[w]);
4418    else
4419       DrawMenuBufPropString (PrintX, PrintY, "     - � -");
4420 }
4421 
4422 
4423 
4424 //******************************************************************************
4425 //
4426 // CALIBRATE JOYSTICK
4427 //
4428 //******************************************************************************
CalibrateJoystick(void)4429 int CalibrateJoystick
4430    (
4431    void
4432    )
4433 
4434    {
4435    #define CALX   45
4436    #define CALY   22
4437 
4438    word xmax, ymax, xmin, ymin, jb;
4439    int  checkbits;
4440    int  status;
4441    boolean done;
4442 
4443    if ( joypadenabled )
4444       {
4445       // Gravis GamePad : Check all buttons
4446       checkbits = ( 1 << 0 ) + ( 1 << 1 ) + ( 1 << 2 ) + ( 1 << 3 );
4447       }
4448    else if ( joystickport )
4449       {
4450       // Joystick port 2 : check only buttons 2 and 3
4451       checkbits = ( 1 << 2 ) + ( 1 << 3 );
4452       }
4453    else
4454       {
4455       // Joystick port 1 : check only buttons 0 and 1
4456       checkbits = ( 1 << 0 ) + ( 1 << 1 );
4457       }
4458 
4459    status = 0;
4460    done = false;
4461    while( !done )
4462       {
4463       SetAlternateMenuBuf();
4464       ClearMenuBuf();
4465       SetMenuTitle ("Calibrate Joystick");
4466       //DrawMenuBufItem( CALX, CALY, W_GetNumForName( "joystk2" ) );
4467       WindowW = 288;
4468       WindowH = 158;
4469       PrintX = WindowX = 0;
4470       PrintY = WindowY = 50;
4471 
4472       newfont1 = (font_t *)W_CacheLumpName( "newfnt1", PU_CACHE, Cvt_font_t, 1 );
4473       CurrentFont = newfont1;
4474       MenuBufCPrint( "MOVE JOYSTICK TO\nUPPER LEFT AND\nPRESS A BUTTON." );
4475 
4476       DisplayInfo( 2 );
4477       FlipMenuBuf();
4478 
4479       do
4480          {
4481          RefreshMenuBuf( 0 );
4482          jb = IN_JoyButtons();
4483          IN_UpdateKeyboard();
4484 
4485          if ( Keyboard[ sc_Escape ] )
4486             {
4487             return( 0 );
4488             }
4489          }
4490       while( !( jb & checkbits ) );
4491 
4492       IN_GetJoyAbs( joystickport, &xmin, &ymin );
4493       MN_PlayMenuSnd( SD_SELECTSND );
4494 
4495       while( IN_JoyButtons() & checkbits )
4496          {
4497          IN_UpdateKeyboard();
4498 
4499          if ( Keyboard[ sc_Escape ] )
4500             {
4501             return( 0 );
4502             }
4503          }
4504 
4505       ClearMenuBuf();
4506 //      DrawMenuBufItem( CALX, CALY, W_GetNumForName( "joystk1" ) );
4507       WindowW = 288;
4508       WindowH = 158;
4509       PrintX = WindowX = 0;
4510       PrintY = WindowY = 50;
4511 
4512       newfont1 = (font_t *)W_CacheLumpName( "newfnt1", PU_CACHE, Cvt_font_t, 1 );
4513       CurrentFont = newfont1;
4514       MenuBufCPrint( "MOVE JOYSTICK TO\nLOWER RIGHT AND\nPRESS A BUTTON." );
4515 
4516       DisplayInfo( 2 );
4517 
4518       do
4519          {
4520          RefreshMenuBuf( 0 );
4521          jb = IN_JoyButtons();
4522          IN_UpdateKeyboard();
4523 
4524          if ( Keyboard[ sc_Escape ] )
4525             {
4526             return( 0 );
4527             }
4528          }
4529       while( !( jb & checkbits ) );
4530 
4531       IN_GetJoyAbs( joystickport, &xmax, &ymax );
4532       MN_PlayMenuSnd( SD_SELECTSND );
4533 
4534       while( IN_JoyButtons() & checkbits )
4535          {
4536          IN_UpdateKeyboard();
4537 
4538          if ( Keyboard[ sc_Escape ] )
4539             {
4540             return( 0 );
4541             }
4542          }
4543 
4544       //
4545       // ASSIGN ACTUAL VALUES HERE
4546       //
4547       if ( ( xmin < xmax ) && ( ymin < ymax ) )
4548          {
4549          IN_SetupJoy( joystickport, xmin, xmax, ymin, ymax );
4550          joyxmin = xmin;
4551          joyxmax = xmax;
4552          joyymin = ymin;
4553          joyymax = ymax;
4554 
4555          status = 1;
4556          done = true;
4557          }
4558       else
4559          {
4560          CP_ErrorMsg( "Joystick Error",
4561             "Calibration failed.  The joystick must be moved "
4562             "to the upper-left first and then the lower-right.",
4563             mn_smallfont );
4564          }
4565       }
4566 
4567    return( status );
4568    }
4569 
4570 
4571 //******************************************************************************
4572 //
4573 // ADJUST MOUSE SENSITIVITY
4574 //
4575 //******************************************************************************
4576 
MouseSensitivity(void)4577 void MouseSensitivity
4578    (
4579    void
4580    )
4581 
4582    {
4583    SliderMenu( &mouseadjustment, 11, 0, 21, 81, 240, 1, "block1", NULL,
4584       "Mouse Sensitivity", "Slow", "Fast" );
4585    }
4586 
4587 //******************************************************************************
4588 //
4589 // ADJUST MOUSE AND JOYSTICK THRESHOLD
4590 //
4591 //******************************************************************************
4592 
DoThreshold(void)4593 void DoThreshold
4594    (
4595    void
4596    )
4597 
4598    {
4599    SliderMenu (&threshold, 15, 1, 44, 81, 194, 1, "block2", NULL,
4600       "Adjust Threshold", "Small", "Large" );
4601    }
4602 
4603 //******************************************************************************
4604 //
4605 // DRAW CONTROL MENU SCREEN
4606 //
4607 //******************************************************************************
4608 
DrawCtlScreen(void)4609 void DrawCtlScreen (void)
4610 {
4611    MenuNum = 3;
4612 
4613    if (numdone || (!ingame) || (!inmenu))
4614       SetAlternateMenuBuf();
4615 
4616    ClearMenuBuf();
4617    SetMenuTitle ("Options");
4618 
4619 
4620    DrawCtlButtons ();
4621 
4622    DisplayInfo (0);
4623    DrawMenu (&CtlItems, &CtlMenu[0]);
4624    DrawMenuBufItem (CtlItems.x, ((CtlItems.curpos*14)+(CtlItems.y-2)),
4625                   W_GetNumForName( LargeCursor ) + CursorFrame[ CursorNum ] );
4626 
4627    if (ingame && inmenu && (!numdone))
4628       RefreshMenuBuf (0);
4629    else
4630       FlipMenuBuf();
4631 
4632 	numdone++;
4633 }
4634 
4635 
4636 //******************************************************************************
4637 //
4638 // DrawCtlButtons ()
4639 //
4640 //******************************************************************************
4641 
DrawCtlButtons(void)4642 void DrawCtlButtons (void)
4643 {
4644    int i,
4645        x,
4646        y;
4647    static boolean first = true;
4648    int button_on;
4649    int button_off;
4650 
4651    button_on  = W_GetNumForName ("snd_on");
4652    button_off = W_GetNumForName ("snd_off");
4653 
4654    WindowX = 0;
4655    WindowW = 320;
4656 
4657    if (first)
4658    {
4659       if (JoysPresent[0] || JoysPresent[1])
4660          {
4661          CtlMenu[JOYENABLE].active = CP_Active;
4662          CtlMenu[USEPORT2].active  = CP_Active;
4663          CtlMenu[PADENABLE].active = CP_Active;
4664          CtlMenu[THRESSENS].active = CP_Active;
4665          }
4666       else
4667       {
4668          joystickenabled = 0;
4669          joypadenabled   = 0;
4670          joystickport    = 0;
4671       }
4672 
4673       if (MousePresent)
4674       {
4675 			CtlMenu[THRESSENS].active = CP_Active;
4676          CtlMenu[MOUSESENS].active = CP_Active;
4677          CtlMenu[MOUSEENABLE].active = CP_Active;
4678       }
4679       else
4680       {
4681          CtlMenu[0].active = CP_Inactive;
4682          mouseenabled = 0;
4683       }
4684 
4685       if (SpaceBallPresent)
4686          CtlMenu[SPACEBALLENABLE].active = CP_Active;
4687 
4688       if (CybermanPresent)
4689          CtlMenu[CYBERMANENABLE].active = CP_Active;
4690 
4691       for (x = 0; x < CtlItems.amount; x++)
4692       {
4693          if (CtlMenu[x].active)
4694          {
4695             CtlMenu[x].active = CP_CursorLocation;
4696             break;
4697          }
4698       }
4699       first = false;
4700    }
4701 
4702    x = CTL_X+CtlItems.indent-18;
4703    y = MENU_Y-1;
4704 
4705    if (mouseenabled)
4706       DrawMenuBufItem (x, y, button_on);
4707    else
4708    {
4709       EraseMenuBufRegion (x, y, 16, 16);
4710       DrawMenuBufItem  (x, y, button_off);
4711    }
4712 
4713    y += 14;
4714    if (joystickenabled)
4715       DrawMenuBufItem (x, y, button_on);
4716    else
4717    {
4718 		EraseMenuBufRegion (x, y, 16, 16);
4719       DrawMenuBufItem (x, y, button_off);
4720    }
4721 
4722    y += 14;
4723    if (joystickport)
4724       DrawMenuBufItem (x, y, button_on);
4725    else
4726    {
4727       EraseMenuBufRegion (x, y, 16, 16);
4728       DrawMenuBufItem (x, y, button_off);
4729    }
4730 
4731    y += 14;
4732    if (joypadenabled)
4733       DrawMenuBufItem (x, y, button_on);
4734    else
4735    {
4736       EraseMenuBufRegion (x, y, 16, 16);
4737       DrawMenuBufItem (x, y, button_off);
4738    }
4739 
4740    y += 14;
4741    if (spaceballenabled)
4742       DrawMenuBufItem (x, y, button_on);
4743    else
4744    {
4745       EraseMenuBufRegion (x, y, 16, 16);
4746       DrawMenuBufItem (x, y, button_off);
4747    }
4748 
4749    y += 14;
4750    if (cybermanenabled)
4751       DrawMenuBufItem (x, y, button_on);
4752    else
4753    {
4754       EraseMenuBufRegion (x, y, 16, 16);
4755       DrawMenuBufItem (x, y, button_off);
4756    }
4757 
4758 
4759    if ((CtlItems.curpos < 0) || (!CtlMenu[CtlItems.curpos].active))
4760       for (i = 0; i < CtlItems.amount; i++)
4761 			if (CtlMenu[i].active)
4762          {
4763             CtlItems.curpos = i;
4764             break;
4765          }
4766 
4767 }
4768 
4769 //******************************************************************************
4770 //
4771 // WAIT FOR CTRLKEY-UP OR BUTTON-UP
4772 //
4773 //******************************************************************************
4774 
WaitKeyUp(void)4775 void WaitKeyUp (void)
4776 {
4777    ControlInfo ci;
4778 
4779    IN_IgnoreMouseButtons();
4780    ReadAnyControl (&ci);
4781 
4782    while (ci.button0 || ci.button1 || ci.button2 || ci.button3 ||
4783           Keyboard[sc_Space] || Keyboard[sc_Enter] || Keyboard[sc_Escape])
4784    {
4785       ReadAnyControl (&ci);
4786       RefreshMenuBuf (0);
4787       if (Keystate[sc_CapsLock] && Keystate[sc_Q])
4788          Error("Stuck in WaitKeyUp\n");
4789    }
4790 }
4791 
4792 #define PMOUSE    3
4793 #define SMOUSE    4
4794 
4795 //******************************************************************************
4796 //
4797 // READ KEYBOARD, JOYSTICK AND MOUSE FOR INPUT
4798 //
4799 //******************************************************************************
4800 
ReadAnyControl(ControlInfo * ci)4801 void ReadAnyControl (ControlInfo *ci)
4802 {
4803 
4804 #if PLATFORM_DOS
4805    union REGS inregs;
4806    union REGS outregs;
4807 #endif
4808 
4809    int mouseactive = 0;
4810    word buttons = 0;
4811 //   struct Spw_IntPacket packet;
4812 
4813 
4814    IN_UpdateKeyboard ();  /* implies IN_PumpEvents() ... */
4815    IN_ReadControl (0, ci);
4816 
4817    if (MousePresent && mouseenabled)
4818    {
4819       int mousey,
4820           mousex;
4821 
4822 #if USE_SDL
4823       INL_GetMouseDelta(&mousex, &mousey);
4824       if (mousex >= SENSITIVE)
4825       {
4826          ci->dir = dir_East;
4827          mouseactive = 1;
4828       }
4829       else if (mousex <= -SENSITIVE)
4830       {
4831          ci->dir = dir_West;
4832          mouseactive = 1;
4833       }
4834 
4835       if (mousey >= SENSITIVE)
4836       {
4837          ci->dir = dir_South;
4838          mouseactive = 1;
4839       }
4840       else if (mousey <= -SENSITIVE)
4841       {
4842          ci->dir = dir_North;
4843          mouseactive = 1;
4844       }
4845 
4846 #elif PLATFORM_DOS
4847 		// READ MOUSE MOTION COUNTERS
4848       // RETURN DIRECTION
4849       // HOME MOUSE
4850       // CHECK MOUSE BUTTONS
4851 
4852       inregs.w.ax = PMOUSE;
4853       int386 (MouseInt, &inregs, &outregs);
4854 
4855       mousex = outregs.w.cx;
4856       mousey = outregs.w.dx;
4857 
4858 
4859       if (mousey < (CENTER-SENSITIVE))
4860       {
4861          ci->dir = dir_North;
4862 
4863          inregs.w.cx = CENTER;
4864          inregs.w.dx = CENTER;
4865 
4866          inregs.w.ax = SMOUSE;
4867          int386 (MouseInt, &inregs, &outregs);
4868 
4869          mouseactive = 1;
4870 
4871       }
4872       else
4873       if (mousey > (CENTER+SENSITIVE))
4874       {
4875          ci->dir = dir_South;
4876 
4877          inregs.w.cx = CENTER;
4878          inregs.w.dx = CENTER;
4879 
4880          inregs.w.ax = SMOUSE;
4881          int386 (MouseInt, &inregs, &outregs);
4882 
4883          mouseactive = 1;
4884       }
4885 
4886       if (mousex < (CENTER-SENSITIVE))
4887       {
4888          ci->dir = dir_West;
4889 
4890 			inregs.w.cx = CENTER;
4891          inregs.w.dx = CENTER;
4892 
4893          inregs.w.ax = SMOUSE;
4894          int386 (MouseInt, &inregs, &outregs);
4895 
4896 
4897          mouseactive = 1;
4898       }
4899       else
4900       if (mousex > (CENTER+SENSITIVE))
4901       {
4902          ci->dir = dir_East;
4903 
4904          inregs.w.cx = CENTER;
4905          inregs.w.dx = CENTER;
4906 
4907          inregs.w.ax = SMOUSE;
4908          int386 (MouseInt, &inregs, &outregs);
4909 
4910          mouseactive = 1;
4911       }
4912 #else
4913 #error please define your platform.  /* or maybe just nuke the DOS section? */
4914 #endif
4915 
4916       buttons = IN_GetMouseButtons();
4917       if ( buttons )
4918          {
4919          ci->button0 = buttons & 1;
4920          ci->button1 = buttons & 2;
4921          ci->button2 = buttons & 4;
4922          ci->button3 = false;
4923          mouseactive = 1;
4924          }
4925       }
4926 
4927    if (joystickenabled && !mouseactive)
4928    {
4929       int jx,jy,jb;
4930 
4931 
4932       INL_GetJoyDelta (joystickport, &jx, &jy);
4933 
4934       if (jy<-SENSITIVE)
4935          ci->dir=dir_North;
4936       else
4937 		if (jy>SENSITIVE)
4938          ci->dir=dir_South;
4939 
4940       if (jx<-SENSITIVE)
4941          ci->dir=dir_West;
4942       else
4943       if (jx>SENSITIVE)
4944          ci->dir=dir_East;
4945 
4946       jb = IN_JoyButtons();
4947       if (jb)
4948       {
4949          ci->button0=jb&1;
4950          ci->button1=jb&2;
4951          if (joypadenabled)
4952          {
4953             ci->button2=jb&4;
4954             ci->button3=jb&8;
4955          }
4956          else
4957             ci->button2=ci->button3=false;
4958       }
4959    }
4960 
4961 
4962 #if 0
4963    if (SpaceBallPresent && spaceballenabled)
4964    {
4965 		SP_Get(&packet);
4966 
4967       if (packet.button)
4968       {
4969          if (packet.button & SP_BTN_1)
4970             ci->button0 = true;
4971 
4972          if (packet.button & SP_BTN_2)
4973             ci->button1 = true;
4974       }
4975 
4976 		if (packet.ty >  MENU_AMT)
4977          ci->dir = dir_North;
4978       else
4979          if (packet.ty < -MENU_AMT)
4980             ci->dir = dir_South;
4981 
4982 		if (packet.tx < (-MENU_AMT* 6))
4983          ci->dir = dir_West;
4984       else
4985          if (packet.tx > (MENU_AMT * 6))
4986             ci->dir = dir_East;
4987    }
4988 #endif
4989 }
4990 
4991 
4992 //******************************************************************************
4993 //
4994 // IN_GetScanName () - Returns a string containing the name of the
4995 //                     specified scan code
4996 //
4997 //******************************************************************************
4998 
IN_GetScanName(ScanCode scan)4999 byte * IN_GetScanName (ScanCode scan)
5000 {
5001    byte     **p;
5002    ScanCode *s;
5003 
5004    for (s = ExtScanCodes, p = ExtScanNames; *s; p++, s++)
5005       if (*s == scan)
5006          return (*p);
5007 
5008    return(ScanNames[scan]);
5009 }
5010 
5011 
5012 //******************************************************************************
5013 //
5014 // DisplayInfo ()
5015 //
5016 //******************************************************************************
5017 
DisplayInfo(int which)5018 void DisplayInfo (int which)
5019 {
5020    patch_t *p;
5021    int x;
5022    int num;
5023 
5024    num = W_GetNumForName ( "info1" ) + which;
5025    p = (patch_t *) W_CacheLumpNum (num, PU_CACHE, Cvt_patch_t, 1);
5026 
5027    x = (288 - p->width) >> 1;
5028 
5029    DrawMenuBufItem (x, 149, num);
5030 }
5031 
5032 
5033 //******************************************************************************
5034 //
5035 // DrawSTMenuBuf()
5036 //
5037 //******************************************************************************
5038 
DrawSTMenuBuf(int x,int y,int w,int h,boolean up)5039 void DrawSTMenuBuf (int x, int y, int w, int h, boolean up)
5040 {
5041    if (!up)
5042    {
5043       DrawTMenuBufHLine (x,   y,   w+1, false);
5044       DrawTMenuBufVLine (x,   y+1, h-1, false);
5045       DrawTMenuBufHLine (x,   y+h, w+1, true);
5046       DrawTMenuBufVLine (x+w, y+1, h-1, true);
5047    }
5048    else
5049    {
5050       DrawTMenuBufHLine (x,   y,   w+1, true);
5051       DrawTMenuBufVLine (x,   y+1, h-1, true);
5052       DrawTMenuBufHLine (x,   y+h, w+1, false);
5053       DrawTMenuBufVLine (x+w, y+1, h-1, false);
5054    }
5055 }
5056 
5057 
5058 //****************************************************************************
5059 //
5060 // DoMainMenu ()
5061 //
5062 //****************************************************************************
5063 
DoMainMenu(void)5064 void DoMainMenu (void)
5065 {
5066    SetAlternateMenuBuf();
5067    ClearMenuBuf();
5068    DrawMainMenu();
5069 	DrawMenuBufItem (MainItems.x,  ((MainItems.curpos*14)+(MainItems.y-2)),
5070                   W_GetNumForName( LargeCursor ) + CursorFrame[ CursorNum ] );
5071    FlipMenuBuf();
5072 }
5073 
5074 
5075 //****************************************************************************
5076 //
5077 // DrawCustomMenu ()
5078 //
5079 //****************************************************************************
5080 
DrawCustomMenu(void)5081 void DrawCustomMenu (void)
5082 {
5083    MenuNum = 3;
5084    SetAlternateMenuBuf();
5085    ClearMenuBuf();
5086    SetMenuTitle ("Customize Menu");
5087    MN_GetCursorLocation( &CustomItems, &CustomMenu[ 0 ] );
5088    DrawMenu (&CustomItems, &CustomMenu[0]);
5089    DrawMenuBufItem (CustomItems.x, ((CustomItems.curpos*14)+(CustomItems.y-2)),
5090                   W_GetNumForName( LargeCursor ) + CursorFrame[ CursorNum ] );
5091    DisplayInfo (0);
5092    FlipMenuBuf();
5093 }
5094 
5095 
5096 
5097 //****************************************************************************
5098 //
5099 // DrawCustomKeyboard ()
5100 //
5101 //****************************************************************************
DrawCustomKeyboard(void)5102 void DrawCustomKeyboard (void)
5103 {
5104    int i;
5105 
5106    SetAlternateMenuBuf();
5107    ClearMenuBuf();
5108    SetMenuTitle ("Customize Keyboard");
5109 
5110    for( i = 0; i < NormalKeyItems.amount; i++ )
5111       {
5112       strcpy( &NormalKeyNames[ i ][ KEYNAMEINDEX ],
5113          IN_GetScanName( buttonscan[ (unsigned int)order[ i ] ] ) );
5114       }
5115 
5116    MN_GetCursorLocation( &NormalKeyItems, &NormalKeyMenu[ 0 ] );
5117    DrawMenu( &NormalKeyItems, &NormalKeyMenu[ 0 ] );
5118 
5119    DisplayInfo( 0 );
5120    FlipMenuBuf();
5121    }
5122 
5123 
5124 //****************************************************************************
5125 //
5126 // MusicVolume ()
5127 //
5128 //****************************************************************************
5129 
MusicVolume(void)5130 void MusicVolume
5131    (
5132    void
5133    )
5134 
5135    {
5136    extern boolean SOUNDSETUP;
5137 
5138    SliderMenu( &MUvolume, 254, 0, 33, 81, 225, 8, "block3", MUSIC_SetVolume,
5139       "Music Volume", "Low", "High" );
5140 
5141    if ( SOUNDSETUP )
5142       {
5143       DrawSoundSetupMainMenu();
5144       }
5145    else
5146       {
5147       DrawControlMenu();
5148       }
5149    }
5150 
5151 
5152 //****************************************************************************
5153 //
5154 // FXVolume ()
5155 //
5156 //****************************************************************************
5157 
FXVolume(void)5158 void FXVolume
5159    (
5160    void
5161    )
5162 
5163    {
5164    extern boolean SOUNDSETUP;
5165    int oldvolume;
5166 
5167    oldvolume = FXvolume;
5168 
5169    SliderMenu( &FXvolume, 254, 0, 33, 81, 225, 8, "block3", FX_SetVolume,
5170       "Sound Volume", "Low", "High" );
5171 
5172    if ( SOUNDSETUP )
5173       {
5174       DrawSoundSetupMainMenu();
5175       }
5176    else
5177       {
5178       DrawControlMenu();
5179       }
5180    }
5181 
5182 
5183 
5184 //****************************************************************************
5185 //
5186 // DrawPlayerMenu ()
5187 //
5188 //****************************************************************************
5189 
DrawPlayerMenu(void)5190 void DrawPlayerMenu (void)
5191 {
5192    MenuNum = 5;
5193 
5194 
5195    MN_MakeActive( &PlayerItems, &PlayerMenu[0], DefaultPlayerCharacter );
5196 
5197 #if ( SHAREWARE == 1 )
5198    PlayerMenu[ 1 ].active = CP_SemiActive; // Thi Barrett
5199    PlayerMenu[ 2 ].active = CP_SemiActive; // Doug Wendt
5200    PlayerMenu[ 3 ].active = CP_SemiActive; // Lorelei Ni
5201    PlayerMenu[ 4 ].active = CP_SemiActive; // Ian Paul Freeley
5202 #endif
5203 
5204    if (numdone || (!ingame) || (!inmenu))
5205       SetAlternateMenuBuf();
5206    ClearMenuBuf();
5207    SetMenuTitle ("Choose Player");
5208 
5209    DrawMenu (&PlayerItems, &PlayerMenu[0]);
5210    DrawNewPlayerDiff (PlayerItems.curpos);
5211 
5212    DisplayInfo (0);
5213 
5214 
5215    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
5216       ( consoleplayer == 0 ) )
5217       {
5218       DrawBattleModeName( gamestate.battlemode );
5219       }
5220 
5221    if (ingame && inmenu && (!numdone))
5222       RefreshMenuBuf (0);
5223    else
5224       FlipMenuBuf();
5225 }
5226 
5227 //******************************************************************************
5228 //
5229 // DRAW NEW PLAYER GRAPHIC
5230 //
5231 //******************************************************************************
5232 
5233 int newplayerY[5] = {28, 42, 56, 70, 84};
5234 
DrawNewPlayerDiff(int w)5235 void DrawNewPlayerDiff (int w)
5236 {
5237    EraseMenuBufRegion (25, 18, 52, 125);
5238    DrawMenuBufPic (25, newplayerY[w], W_GetNumForName( "PLAYER1" ) + w );
5239 }
5240 
5241 
5242 //******************************************************************************
5243 //
5244 // MenuFixup ()
5245 //
5246 //******************************************************************************
MenuFixup(void)5247 void MenuFixup
5248    (
5249    void
5250    )
5251 
5252    {
5253    MainMenu[ viewscores ].texture[ 6 ] = '1';
5254    MainMenu[ viewscores ].texture[ 7 ] = '0';
5255    MainMenu[ viewscores ].texture[ 8 ] = '\0';
5256    MainMenu[ viewscores ].routine      = ( void * )CP_EndGame;
5257    MainMenu[ viewscores ].letter       = 'E';
5258    strcpy (MainMenuNames[ viewscores ] , "END GAME");
5259    MainMenu[ savegame ].active         = CP_Active;
5260    ingame = true;
5261    }
5262 
5263 //******************************************************************************
5264 //
5265 // GetEpisode ()
5266 //
5267 //******************************************************************************
5268 
GetEpisode(int level)5269 void GetEpisode (int level)
5270 {
5271    if (level < 8)
5272       gamestate.episode = 1;
5273    else
5274       if (level < 16)
5275          gamestate.episode = 2;
5276       else
5277          if (level < 24)
5278             gamestate.episode = 3;
5279          else
5280             gamestate.episode = 4;
5281 }
5282 
5283 
5284 //****************************************************************************
5285 //
5286 // DrawControlMenu ()
5287 //
5288 //****************************************************************************
5289 
DrawControlMenu(void)5290 void DrawControlMenu (void)
5291 {
5292    MenuNum = 1;
5293 
5294    if (numdone || (!ingame) || (!inmenu))
5295       SetAlternateMenuBuf();
5296 
5297    ClearMenuBuf();
5298    SetMenuTitle ("Options");
5299 
5300    MN_GetCursorLocation( &ControlMItems, &ControlMMenu[ 0 ] );
5301    DrawMenu (&ControlMItems, &ControlMMenu[0]);
5302    DisplayInfo (0);
5303 
5304    if (ingame && inmenu && (!numdone))
5305       RefreshMenuBuf (0);
5306    else
5307       FlipMenuBuf();
5308 
5309    numdone ++;
5310 }
5311 
5312 //****************************************************************************
5313 //
5314 //  CP_ControlMenu ()
5315 //
5316 //****************************************************************************
5317 
CP_ControlMenu(void)5318 void CP_ControlMenu (void)
5319 {
5320    int which;
5321 
5322    DrawControlMenu();
5323 
5324    do
5325    {
5326       which = HandleMenu (&ControlMItems, &ControlMMenu[0], NULL);
5327 
5328    } while (which >= 0);
5329 
5330    handlewhich = OUTOFRANGE;
5331 }
5332 
5333 
5334 
5335 //****************************************************************************
5336 //
5337 // DrawOptionsMenu ()
5338 //
5339 //****************************************************************************
5340 
DrawOptionsMenu(void)5341 void DrawOptionsMenu (void)
5342 {
5343    MenuNum = 1;
5344 
5345    SetAlternateMenuBuf();
5346    ClearMenuBuf();
5347    SetMenuTitle ("User Options");
5348 
5349    MN_GetCursorLocation( &OptionsItems, &OptionsMenu[ 0 ] );
5350    DrawMenu (&OptionsItems, &OptionsMenu[0]);
5351    DrawOptionsButtons ();
5352    DisplayInfo (0);
5353    FlipMenuBuf();
5354 }
5355 
5356 //****************************************************************************
5357 //
5358 // CP_OptionsMenu ()
5359 //
5360 //****************************************************************************
5361 
CP_OptionsMenu(void)5362 void CP_OptionsMenu (void)
5363 {
5364    int which;
5365 
5366    DrawOptionsMenu();
5367 
5368    do
5369    {
5370       which = HandleMenu (&OptionsItems, &OptionsMenu[0], NULL);
5371 
5372       switch (which)
5373       {
5374          case 0: AutoDetailOn  ^= 1; DrawOptionsButtons (); break;
5375          case 1: fulllight     ^= 1; DrawOptionsButtons (); break;
5376          case 2: BobbinOn      ^= 1; DrawOptionsButtons (); break;
5377          case 3: fandc         ^= 1; DrawOptionsButtons (); break;
5378       }
5379 
5380 	} while (which >= 0);
5381 
5382    DrawControlMenu();
5383 }
5384 
5385 //****************************************************************************
5386 //
5387 // DrawOptionsButtons
5388 //
5389 //****************************************************************************
5390 
DrawOptionsButtons(void)5391 void DrawOptionsButtons (void)
5392 {
5393    int i,
5394        on;
5395    int button_on;
5396    int button_off;
5397 
5398    button_on  = W_GetNumForName ("snd_on");
5399    button_off = W_GetNumForName ("snd_off");
5400 
5401    for (i = 0; i < OptionsItems.amount-5; i++)
5402       if (OptionsMenu[i].active != CP_Active3)
5403       {
5404          //
5405          // DRAW SELECTED/NOT SELECTED GRAPHIC BUTTONS
5406          //
5407 
5408          on = 0;
5409 
5410          switch (i)
5411          {
5412             case 0: if (AutoDetailOn  == 1) on = 1; break;
5413             case 1: if (fulllight     == 0) on = 1; break;
5414             case 2: if (BobbinOn      == 1) on = 1; break;
5415             case 3: if (fandc         == 1) on = 1; break;
5416          }
5417 
5418          if (on)
5419             DrawMenuBufItem (20+22, OptionsItems.y+i*14-1, button_on);
5420          else
5421             DrawMenuBufItem (20+22, OptionsItems.y+i*14-1, button_off);
5422 		}
5423 }
5424 
5425 
5426 //****************************************************************************
5427 //
5428 // CP_DoubleClickSpeed()
5429 //
5430 //****************************************************************************
5431 
CP_DoubleClickSpeed(void)5432 void CP_DoubleClickSpeed
5433    (
5434    void
5435    )
5436 
5437    {
5438    int temp;
5439 
5440    temp = 50 - ( DoubleClickSpeed - 5 );
5441    SliderMenu( &temp, 50, 5, 31, 81, 225, 3, "block1", NULL,
5442       "Double-Click Speed", "Slow", "Fast" );
5443    DoubleClickSpeed = 50 - ( temp - 5 );
5444 
5445    handlewhich = 100;
5446    DrawOptionsMenu();
5447    }
5448 
5449 //****************************************************************************
5450 //
5451 // MenuFlipSpeed ()
5452 //
5453 //****************************************************************************
5454 
MenuFlipSpeed(void)5455 void MenuFlipSpeed
5456    (
5457    void
5458    )
5459 
5460    {
5461    int temp;
5462 
5463    temp = 50 - ( Menuflipspeed - 5 );
5464 
5465    SliderMenu( &temp, 50, 5, 31, 81, 225, 3, "block1", NULL,
5466       "Menu Flip Speed", "Slow", "Fast" );
5467 
5468    Menuflipspeed = 50 - ( temp - 5 );
5469 
5470    DrawOptionsMenu ();
5471    handlewhich = 10;
5472    }
5473 
5474 
5475 //****************************************************************************
5476 //
5477 // DrawDetailMenu ()
5478 //
5479 //****************************************************************************
5480 
DrawDetailMenu(void)5481 void DrawDetailMenu (void)
5482 {
5483    MenuNum = 1;
5484 
5485    SetAlternateMenuBuf();
5486    ClearMenuBuf();
5487    SetMenuTitle ("Detail Menu");
5488 
5489    MN_DrawButtons (&DetailItems, &DetailMenu[0], DetailLevel, OptionNums);
5490    MN_GetCursorLocation( &DetailItems, &DetailMenu[ 0 ] );
5491    DrawMenu (&DetailItems, &DetailMenu[0]);
5492    DisplayInfo (0);
5493    FlipMenuBuf();
5494 }
5495 
5496 //****************************************************************************
5497 //
5498 // CP_DetailMenu ()
5499 //
5500 //****************************************************************************
5501 
CP_DetailMenu(void)5502 void CP_DetailMenu (void)
5503 {
5504    int which;
5505 
5506    DrawDetailMenu();
5507 
5508    do
5509    {
5510       which = HandleMenu (&DetailItems, &DetailMenu[0], NULL);
5511 
5512       switch (which)
5513       {
5514          case 0:
5515             DetailLevel = 0;
5516             MN_DrawButtons (&DetailItems, &DetailMenu[0], DetailLevel, OptionNums);
5517          break;
5518 
5519          case 1:
5520             DetailLevel = 1;
5521             MN_DrawButtons (&DetailItems, &DetailMenu[0], DetailLevel, OptionNums);
5522          break;
5523 
5524          case 2:
5525             DetailLevel = 2;
5526             MN_DrawButtons (&DetailItems, &DetailMenu[0], DetailLevel, OptionNums);
5527          break;
5528       }
5529 
5530    } while (which >= 0);
5531 
5532    handlewhich = 10;
5533    DrawOptionsMenu();
5534 }
5535 
5536 
5537 //****************************************************************************
5538 //
5539 // DrawBattleMenu ()
5540 //
5541 //****************************************************************************
5542 
DrawBattleMenu(void)5543 void DrawBattleMenu (void)
5544 {
5545    MenuNum = 1;
5546 
5547    if (numdone || (!ingame) || (!inmenu))
5548       SetAlternateMenuBuf();
5549 
5550    ClearMenuBuf();
5551    SetMenuTitle ("Battle Menu");
5552 
5553    DrawBattleModeName( gamestate.battlemode );
5554 
5555    MN_GetCursorLocation( &BattleItems, &BattleMenu[ 0 ] );
5556    DrawMenu (&BattleItems, &BattleMenu[0]);
5557    DisplayInfo (0);
5558 
5559    BATTLE_SetOptions( &BATTLE_Options[ gamestate.battlemode ] );
5560    ShowBattleOptions( true, MENU_X, MENU_Y + 49 );
5561 
5562    if (ingame && inmenu && (!numdone))
5563       RefreshMenuBuf (0);
5564    else
5565       FlipMenuBuf();
5566 }
5567 
5568 
5569 //****************************************************************************
5570 //
5571 // BattleGamePlayerSetup()
5572 //
5573 //****************************************************************************
5574 
BattleGamePlayerSetup(void)5575 void BattleGamePlayerSetup( void )
5576    {
5577    int status;
5578    int pos;
5579 
5580    pos = 1;
5581    if ( consoleplayer == 0 )
5582       {
5583       pos = 0;
5584       }
5585 
5586    while( 1 )
5587       {
5588       switch( pos )
5589          {
5590          case 0 :
5591             // Select level to play on
5592             status = CP_LevelSelectionMenu ();
5593             if ( status >= 0  )
5594                {
5595                gamestate.mapon=status;
5596                pos = 1;
5597                }
5598             else
5599                {
5600                DrawBattleMenu();
5601                return;
5602                }
5603             break;
5604 
5605          case 1 :
5606             // Select CodeName
5607             status = CP_EnterCodeNameMenu();
5608             pos = 2;
5609             if ( !status )
5610                {
5611                if ( consoleplayer == 0 )
5612                   {
5613                   pos = 0;
5614                   }
5615                else
5616                   {
5617                   return;
5618                   }
5619                }
5620             break;
5621 
5622          case 2 :
5623             // Select character
5624             status = CP_PlayerSelection ();
5625             pos = 1;
5626             if ( status )
5627                {
5628                pos = 3;
5629                }
5630             break;
5631 
5632          case 3 :
5633             // Select color/team
5634             status = CP_ColorSelection();
5635             pos = 2;
5636             if ( status )
5637                {
5638                StartGame   = true;
5639                handlewhich = -2;
5640                playstate   = ex_resetgame;
5641                BATTLEMODE  = true;
5642                // Show please wait
5643                CP_ModemGameMessage( consoleplayer );
5644                return;
5645                }
5646             break;
5647          }
5648       }
5649    }
5650 
5651 
5652 //****************************************************************************
5653 //
5654 // BattleNoTeams()
5655 //
5656 //****************************************************************************
5657 
BattleNoTeams(void)5658 void BattleNoTeams( void )
5659    {
5660    BattleGamePlayerSetup();
5661    if ( StartGame )
5662       {
5663       gamestate.teamplay = false;
5664       }
5665    }
5666 
5667 
5668 //****************************************************************************
5669 //
5670 // BattleTeams()
5671 //
5672 //****************************************************************************
5673 
BattleTeams(void)5674 void BattleTeams( void )
5675    {
5676    BattleGamePlayerSetup();
5677    if ( StartGame )
5678       {
5679       gamestate.teamplay = true;
5680       }
5681    }
5682 
5683 
5684 //****************************************************************************
5685 //
5686 // CP_BattleMenu ()
5687 //
5688 //****************************************************************************
5689 
CP_BattleMenu(void)5690 void CP_BattleMenu (void)
5691 {
5692    int which;
5693 
5694    gamestate.battlemode = handlewhich + battle_Normal;
5695 
5696    BattleMenu[0].active = CP_Active;
5697    BattleMenu[1].active = CP_Active;
5698 
5699 
5700    // Tag can't be played in team mode
5701    // Also, can't play teams if only 1 person is playing
5702    if ( ( gamestate.battlemode == battle_Tag ) ||
5703       ( numplayers < 2 ) )
5704       {
5705       BattleMenu[1].active = CP_Inactive;
5706       if ( BattleItems.curpos == 1 )
5707          {
5708          BattleItems.curpos = 0;
5709          }
5710       }
5711 
5712    // Capture the Triad can only be played in team mode
5713    if ( gamestate.battlemode == battle_CaptureTheTriad )
5714       {
5715       BattleMenu[0].active = CP_Inactive;
5716       if ( BattleItems.curpos == 0 )
5717          {
5718          BattleItems.curpos = 1;
5719          }
5720       }
5721 
5722    BattleMenu[ BattleItems.curpos ].active = CP_CursorLocation;
5723    DrawBattleMenu();
5724 
5725    do
5726       {
5727 		which = HandleMenu (&BattleItems, &BattleMenu[0], NULL);
5728       }
5729    while (which >= 0);
5730 
5731    if ( which == -1 )
5732       {
5733       DrawBattleModes ();
5734       handlewhich = OUTOFRANGE;
5735       }
5736    }
5737 
5738 
5739 //****************************************************************************
5740 //
5741 // MN_PlayMenuSnd ()
5742 //
5743 //****************************************************************************
5744 
5745 extern boolean dopefish;
MN_PlayMenuSnd(int which)5746 void MN_PlayMenuSnd (int which)
5747 {
5748    if (INFXSETUP || (SD_Started == false))
5749       return;
5750 #if (SHAREWARE==0)
5751    if (dopefish==true)
5752       {
5753       switch (which)
5754          {
5755          case SD_ESCPRESSEDSND:
5756             which = SD_SOUNDESCSND;
5757          break;
5758          case SD_MOVECURSORSND:
5759             which = SD_SILLYMOVESND;
5760          break;
5761          case SD_SELECTSND:
5762             which = SD_SOUNDSELECTSND;
5763          break;
5764          }
5765       }
5766 #endif
5767    SD_Play (which);
5768 }
5769 
5770 
5771 //******************************************************************************
5772 //
5773 // SliderMenu ()
5774 //
5775 //******************************************************************************
5776 
SliderMenu(int * number,int upperbound,int lowerbound,int erasex,int erasey,int erasew,int numadjust,char * blockname,void (* routine)(int w),char * title,char * left,char * right)5777 boolean SliderMenu
5778    (
5779    int *number,
5780    int upperbound,
5781    int lowerbound,
5782    int erasex,
5783    int erasey,
5784    int erasew,
5785    int numadjust,
5786    char *blockname,
5787    void ( *routine )( int w ),
5788    char *title,
5789    char *left,
5790    char *right
5791    )
5792 
5793    {
5794    ControlInfo ci;
5795    Direction   lastdir;
5796    patch_t    *shape;
5797    boolean     returnval;
5798    boolean     moved;
5799    unsigned long scale;
5800    int         exit;
5801    int         range;
5802    int         timer;
5803    int         width;
5804    int         height;
5805    int         blkx;
5806    int         eraseh;
5807    int         block;
5808 
5809    SetAlternateMenuBuf();
5810    ClearMenuBuf();
5811    SetMenuTitle( title );
5812 
5813    newfont1 = (font_t *)W_CacheLumpName( "newfnt1", PU_CACHE, Cvt_font_t, 1);
5814    CurrentFont = newfont1;
5815    PrintX = 25;
5816    PrintY = 62;
5817    DrawMenuBufPropString( PrintX, PrintY, left );
5818 
5819    VW_MeasurePropString( right, &width, &height );
5820    DrawMenuBufPropString( 263 - width, PrintY, right );
5821 
5822    block = W_GetNumForName( blockname );
5823    shape = ( patch_t * )W_CacheLumpNum( block, PU_CACHE, Cvt_patch_t, 1 );
5824    blkx  = erasex - shape->leftoffset;
5825    eraseh =  shape->height;
5826    scale = ( erasew + shape->leftoffset - shape->width ) << 16;
5827    range = upperbound - lowerbound;
5828 
5829    DrawSTMenuBuf( erasex - 1, erasey - 1, erasew + 1, eraseh + 1, false );
5830 
5831    DrawMenuBufItem( blkx + ( ( ( ( *number - lowerbound ) *
5832       scale ) / range ) >> 16 ), erasey, block );
5833 
5834    DisplayInfo( 1 );
5835    FlipMenuBuf();
5836 
5837    exit  = 0;
5838    moved = false;
5839    timer = GetTicCount();
5840    lastdir = dir_None;
5841 
5842    do
5843       {
5844       RefreshMenuBuf( 0 );
5845 
5846       ReadAnyControl( &ci );
5847       if ( ( ( GetTicCount() - timer ) > 5 ) || ( ci.dir != lastdir ) )
5848          {
5849          timer = GetTicCount();
5850 
5851          switch( ci.dir )
5852             {
5853             case dir_North:
5854             case dir_West:
5855                if ( *number > lowerbound )
5856                   {
5857                   *number = *number - numadjust;
5858 
5859                   if ( *number < lowerbound )
5860                      {
5861                      *number = lowerbound;
5862                      }
5863 
5864                   moved = true;
5865                   }
5866                break;
5867 
5868             case dir_South:
5869             case dir_East:
5870                if ( *number < upperbound )
5871                   {
5872                   *number = *number + numadjust;
5873 
5874                   if ( *number > upperbound )
5875                      {
5876                      *number = upperbound;
5877                      }
5878 
5879                   moved = true;
5880                   }
5881                break;
5882 	    default:
5883 		;
5884             }
5885 
5886          lastdir = ci.dir;
5887          }
5888 
5889       if ( moved )
5890          {
5891          moved = false;
5892 
5893          EraseMenuBufRegion( erasex, erasey, erasew, eraseh );
5894 
5895          DrawMenuBufItem( blkx + ( ( ( ( *number - lowerbound ) *
5896             scale ) / range ) >> 16 ), erasey, block );
5897 
5898          if ( routine )
5899             {
5900             routine( *number );
5901             }
5902 
5903          MN_PlayMenuSnd( SD_MOVECURSORSND );
5904          }
5905 
5906       if ( ci.button0 || Keyboard[ sc_Space ] || Keyboard[ sc_Enter ] )
5907          {
5908          exit = 1;
5909          }
5910       else if ( ci.button1 || Keyboard[ sc_Escape ] )
5911          {
5912          exit = 2;
5913          }
5914       }
5915    while( !exit );
5916 
5917    if ( exit == 2 )
5918       {
5919       MN_PlayMenuSnd( SD_ESCPRESSEDSND );
5920       returnval = false;
5921       }
5922    else
5923       {
5924       MN_PlayMenuSnd( SD_SELECTSND );
5925       returnval = true;
5926       }
5927 
5928    WaitKeyUp ();
5929    return( returnval );
5930    }
5931 
5932 
5933 //******************************************************************************
5934 //
5935 // DrawF1Help ()
5936 //
5937 //******************************************************************************
5938 
DrawF1Help(void)5939 void DrawF1Help (void)
5940 {
5941 
5942    VL_DrawPostPic (W_GetNumForName("trilogo"));
5943 
5944    DrawNormalSprite (0, 0, W_GetNumForName("help"));
5945 
5946    VW_UpdateScreen ();
5947 }
5948 
5949 //******************************************************************************
5950 //
5951 // CP_F1Help ()
5952 //
5953 //******************************************************************************
5954 
CP_F1Help(void)5955 void CP_F1Help (void)
5956 {
5957    LastScan=0;
5958 
5959    DrawF1Help ();
5960 
5961    while (LastScan == 0)
5962    {
5963       IN_UpdateKeyboard ();
5964    }
5965 
5966    LastScan=0;
5967 #if (SHAREWARE==1)
5968    {
5969    DrawOrderInfo( 2 );
5970    while (LastScan == 0)
5971    {
5972       IN_UpdateKeyboard ();
5973    }
5974 
5975    LastScan=0;
5976    }
5977 #endif
5978 }
5979 
5980 
5981 //****************************************************************************
5982 //
5983 // CP_ScreenSize()
5984 //
5985 //****************************************************************************
5986 
CP_ScreenSize(void)5987 void CP_ScreenSize
5988    (
5989    void
5990    )
5991 
5992    {
5993    SliderMenu( &viewsize, MAXVIEWSIZES - 1, 0, 33, 81, 225, 1, "block1",
5994       NULL, "Screen Size", "Small", "Large" );
5995 
5996    handlewhich = 100;
5997    DrawOptionsMenu();
5998    }
5999 
6000 
6001 //****************************************************************************
6002 //
6003 // DrawViolenceMenu ()
6004 //
6005 //****************************************************************************
6006 
DrawViolenceMenu(void)6007 void DrawViolenceMenu (void)
6008 {
6009    MenuNum = 1;
6010    if ( POK )
6011       {
6012       memcpy( &VMenu[ 1 ].texture, "mcpass\0", 7 );
6013       VMenu[ 1 ].letter = 'C';
6014       strcpy (VMenuNames[ 1 ] , "CHANGE PASSWORD");
6015       }
6016    else
6017       {
6018       memcpy( &VMenu[ 1 ].texture, "mepass\0", 7 );
6019       VMenu[ 1 ].letter = 'E';
6020       strcpy (VMenuNames[ 1 ] , "ENTER PASSWORD");
6021       }
6022 
6023    if (VMenu[0].active != CP_CursorLocation)
6024       VMenu[0].active = CP_Active;
6025 
6026    SetAlternateMenuBuf();
6027    ClearMenuBuf();
6028    SetMenuTitle ("Violence Level");
6029 
6030    MN_GetCursorLocation( &VItems, &VMenu[ 0 ] );
6031    DrawMenu (&VItems, &VMenu[0]);
6032    DisplayInfo (0);
6033    FlipMenuBuf();
6034 }
6035 
6036 
6037 //****************************************************************************
6038 //
6039 // CP_ViolenceMenu ()
6040 //
6041 //****************************************************************************
6042 
CP_ViolenceMenu(void)6043 void CP_ViolenceMenu (void)
6044 {
6045    int which;
6046 
6047    CurrentFont = smallfont;
6048    DrawViolenceMenu ();
6049 
6050    do
6051    {
6052       which = HandleMenu (&VItems, &VMenu[0], NULL);
6053 
6054    } while (which >= 0);
6055 
6056    handlewhich = 100;
6057    DrawOptionsMenu();
6058 }
6059 
6060 
6061 //****************************************************************************
6062 //
6063 // DrawViolenceLevel ()
6064 //
6065 //****************************************************************************
6066 
DrawViolenceLevel(void)6067 void DrawViolenceLevel (void)
6068 {
6069    MenuNum = 1;
6070 
6071    SetAlternateMenuBuf();
6072    ClearMenuBuf();
6073    SetMenuTitle ("Change Violence Level");
6074 
6075    MN_DrawButtons (&ViolenceItems, &ViolenceMenu[0], gamestate.violence, OptionNums);
6076    MN_GetActive (&ViolenceItems, &ViolenceMenu[0], gamestate.violence, OptionNums);
6077 
6078 //   DrawMenuBufItem (58, 24, W_GetNumForName ("blood"));
6079    IFont = ( cfont_t * )W_CacheLumpName( FontNames[ mn_largefont ],
6080       PU_CACHE, Cvt_cfont_t, 1 );
6081    DrawMenuBufIString( 58, 24, "HOW MUCH ", NORMALCOLOR );
6082    DrawMenuBufIString( PrintX, PrintY, "BLOOD", 51 );
6083    DrawMenuBufIString( 71, 37, "DO YOU WANT?", NORMALCOLOR );
6084 
6085    DrawMenu (&ViolenceItems, &ViolenceMenu[0]);
6086    DisplayInfo (0);
6087    FlipMenuBuf();
6088 }
6089 
6090 
6091 //****************************************************************************
6092 //
6093 // CP_ViolenceLevel ()
6094 //
6095 //****************************************************************************
6096 
CP_ViolenceLevel(void)6097 void CP_ViolenceLevel (void)
6098 {
6099    int which;
6100    char p1[13];
6101    boolean passok=false;
6102 
6103    if (ingame)
6104    	{
6105       CP_ErrorMsg( "Change Violence Level",
6106          "The current game must be ended to change the Violence Level.",
6107          mn_largefont );
6108       }
6109    else if ( POK )
6110       {
6111       memset (p1, 0, 13);
6112 
6113       CurrentFont = smallfont;
6114       DrawViolenceLevelPWord ();
6115 
6116       if (US_lineinput (PBOXX+2, PBOXY+1, p1, NULL, true, 12, 110, 0))
6117          {
6118          //compare user entered to password
6119          if (StringsNotEqual (p1, pword, StringLength (p1)) == false)
6120             passok=true;
6121          else
6122             {
6123             CP_ErrorMsg( "Violence Password", "Incorrect Password.",
6124                mn_largefont );
6125             }
6126          }
6127       }
6128    else
6129       passok=true;
6130    if (passok==true)
6131       {
6132       DrawViolenceLevel ();
6133       do
6134          {
6135          which = HandleMenu (&ViolenceItems, &ViolenceMenu[0], NULL);
6136 
6137          if (which >= 0)
6138             gamestate.violence = which;
6139 
6140          MN_DrawButtons (&ViolenceItems, &ViolenceMenu[0], gamestate.violence, OptionNums);
6141 
6142          } while (which >= 0);
6143 
6144       WriteMenuInfo ();
6145       }
6146 
6147    handlewhich = 100;
6148    DrawViolenceMenu();
6149 }
6150 
6151 
6152 
6153 //****************************************************************************
6154 //
6155 // DrawViolenceLevelPWord ();
6156 //
6157 //****************************************************************************
6158 
DrawViolenceLevelPWord(void)6159 void DrawViolenceLevelPWord
6160    (
6161    void
6162    )
6163 
6164    {
6165    MenuNum = 1;
6166 
6167    SetAlternateMenuBuf();
6168    ClearMenuBuf();
6169    SetMenuTitle( "Violence Password" );
6170 
6171 //   CurrentFont = newfont1;
6172 //   DrawMenuBufPropString( PWORDX, PWORDY, "ENTER PASSWORD" );
6173 
6174    IFont = ( cfont_t * )W_CacheLumpName( FontNames[ mn_largefont ],
6175       PU_CACHE, Cvt_cfont_t, 1 );
6176    DrawMenuBufIString( PWORDX, PWORDY, "ENTER PASSWORD", NORMALCOLOR );
6177 
6178    DrawSTMenuBuf( PBOXX, PBOXY, PBOXW, PBOXH, false );
6179    FlipMenuBuf();
6180    }
6181 
6182 
6183 
6184 //****************************************************************************
6185 //
6186 // DrawPWMenu ()
6187 //
6188 //****************************************************************************
6189 
DrawPWMenu(void)6190 void DrawPWMenu
6191    (
6192    void
6193    )
6194 
6195    {
6196    MenuNum = 1;
6197 
6198    SetAlternateMenuBuf();
6199    ClearMenuBuf();
6200    SetMenuTitle( "Violence Password" );
6201 
6202 //   CurrentFont = newfont1;
6203    IFont = ( cfont_t * )W_CacheLumpName( FontNames[ mn_largefont ],
6204       PU_CACHE, Cvt_cfont_t, 1 );
6205 
6206    if ( POK )
6207       {
6208 //      DrawMenuBufPropString( PWORDX - 24, PWORDY, "ENTER OLD PASSWORD" );
6209       DrawMenuBufIString( PWORDX - 24, PWORDY, "ENTER OLD PASSWORD", NORMALCOLOR );
6210       }
6211    else
6212       {
6213 //      DrawMenuBufPropString( PWORDX - 24, PWORDY, "ENTER PASSWORD" );
6214       DrawMenuBufIString( PWORDX - 24, PWORDY, "ENTER PASSWORD", NORMALCOLOR );
6215       }
6216 
6217    DrawSTMenuBuf( PBOXX, PBOXY, PBOXW, PBOXH, false );
6218    FlipMenuBuf();
6219    }
6220 
6221 
6222 //****************************************************************************
6223 //
6224 // CP_PWMenu ()
6225 //
6226 //****************************************************************************
6227 
CP_PWMenu(void)6228 void CP_PWMenu (void)
6229    {
6230    char p1[13];
6231    char p2[13];
6232    boolean EnterNewPassword;
6233    boolean AskForNew;
6234    boolean RetypePassword;
6235 
6236    memset (p1, 0, 13);
6237    memset (p2, 0, 13);
6238 
6239    CurrentFont = smallfont;
6240 
6241    EnterNewPassword = true;
6242    if ( POK )
6243       {
6244       DrawPWMenu ();
6245 
6246       // get old password
6247       //
6248       EnterNewPassword = false;
6249       if (US_lineinput (PBOXX+2, PBOXY+1, p1, NULL, true, 12, PSTRW, 0))
6250          {
6251          //compare user entered to old
6252          //
6253          if (StringsNotEqual (p1, pword, StringLength (p1))==false)
6254             {
6255 
6256             // Password was correct so they may change it.
6257             EnterNewPassword = true;
6258             }
6259          else
6260             {
6261             CP_ErrorMsg( "Violence Password", "Incorrect Password.",
6262                mn_largefont );
6263             }
6264          }
6265       }
6266 
6267    if ( EnterNewPassword )
6268       {
6269       MenuNum = 1;
6270 
6271       // get new password
6272       //
6273 		AskForNew = true;
6274       RetypePassword = false;
6275       while( AskForNew )
6276          {
6277          CurrentFont = smallfont;
6278 
6279          SetAlternateMenuBuf ();
6280          ClearMenuBuf();
6281          SetMenuTitle ("Violence Password");
6282 
6283          IFont = ( cfont_t * )W_CacheLumpName( FontNames[ mn_largefont ],
6284             PU_CACHE, Cvt_cfont_t, 1 );
6285          DrawMenuBufIString( PWORDX - 24, PWORDY, "ENTER NEW PASSWORD", NORMALCOLOR );
6286 
6287 //         CurrentFont = newfont1;
6288 //         DrawMenuBufPropString( PWORDX - 24, PWORDY, "ENTER NEW PASSWORD" );
6289 //         DrawMenuBufItem (PWORDX-24, PWORDY, W_GetNumForName ("mnewpass"));
6290 
6291          DrawSTMenuBuf (PBOXX, PBOXY, PBOXW, PBOXH, false);
6292          FlipMenuBuf();
6293 
6294          memset (p1, 0, 13);
6295 
6296          AskForNew = false;
6297          if (US_lineinput (PBOXX+2, PBOXY+1, p1, NULL, true, 12, PSTRW, 0))
6298             {
6299             // Check for blank password
6300             if ( p1[ 0 ] == 0 )
6301                {
6302                if ( CP_DisplayMsg ( "Clear Password?\nAre you sure?", 12 ) )
6303                   {
6304                   AskForNew = false;
6305                   memset (pword, 0, 13);
6306                   WriteMenuInfo ();
6307                   POK = false;
6308                   }
6309                else
6310                   {
6311                   AskForNew = true;
6312                   }
6313                }
6314             else
6315                {
6316                RetypePassword = true;
6317                }
6318             }
6319          }
6320 
6321       if ( RetypePassword )
6322          {
6323 			SetAlternateMenuBuf();
6324          ClearMenuBuf();
6325          SetMenuTitle ("Violence Password");
6326 
6327 //         CurrentFont = newfont1;
6328 //         DrawMenuBufPropString( PWORDX, PWORDY, "RETYPE PASSWORD" );
6329 
6330          IFont = ( cfont_t * )W_CacheLumpName( FontNames[ mn_largefont ],
6331             PU_CACHE, Cvt_cfont_t, 1 );
6332          DrawMenuBufIString( PWORDX, PWORDY, "RETYPE PASSWORD", NORMALCOLOR );
6333 
6334          DrawSTMenuBuf (PBOXX, PBOXY, PBOXW, PBOXH, false);
6335 
6336          FlipMenuBuf();
6337 
6338          // reenter password
6339          //
6340          if ( US_lineinput (PBOXX+2, PBOXY+1, p2, NULL, true, 12, PSTRW, 0) )
6341             {
6342             // compare password and retyped password
6343             //
6344             if (stricmp (p1, p2) == 0)
6345                {
6346                memset (pword, 0, 13);
6347                strcpy (pword, p1);
6348                WriteMenuInfo ();
6349 
6350                // If we have a null password, then we don't need to
6351                // ask for one.
6352                POK = true;
6353                if ( pword[ 0 ] == 0 )
6354                   {
6355                   POK = false;
6356                   }
6357                }
6358             else
6359                {
6360                CP_ErrorMsg( "Violence Password", "Passwords did not match.",
6361                   mn_largefont );
6362                }
6363             }
6364          }
6365       }
6366 
6367    DrawViolenceMenu ();
6368    }
6369 
6370 //****************************************************************************
6371 //
6372 // DrawOptionDescription()
6373 //
6374 //****************************************************************************
6375 
DrawOptionDescription(char ** options,int w)6376 void DrawOptionDescription( char ** options, int w )
6377    {
6378    int     width;
6379    int     height;
6380    char   *string;
6381    font_t *temp;
6382 
6383    EraseMenuBufRegion (25, 4, 287 - 25, 10 );
6384 
6385    temp = CurrentFont;
6386    CurrentFont = tinyfont;
6387 
6388    string = options[ w ];
6389 
6390 	VW_MeasurePropString ( string, &width, &height );
6391    DrawMenuBufPropString ( ( 288 - width) / 2, 4, string );
6392 
6393    CurrentFont = temp;
6394    }
6395 
6396 //****************************************************************************
6397 //
6398 // DrawBattleOptionDescription()
6399 //
6400 //****************************************************************************
6401 
DrawBattleOptionDescription(int w)6402 void DrawBattleOptionDescription( int w )
6403    {
6404    DrawOptionDescription( BattleOptionDescriptions, w );
6405    }
6406 //****************************************************************************
6407 //
6408 // DrawGravityOptionDescription()
6409 //
6410 //****************************************************************************
6411 
DrawGravityOptionDescription(int w)6412 void DrawGravityOptionDescription( int w )
6413    {
6414    DrawOptionDescription( GravityOptionDescriptions, w );
6415    }
6416 //****************************************************************************
6417 //
6418 // DrawSpeedOptionDescription()
6419 //
6420 //****************************************************************************
6421 
DrawSpeedOptionDescription(int w)6422 void DrawSpeedOptionDescription( int w )
6423    {
6424    DrawOptionDescription( SpeedOptionDescriptions, w );
6425    }
6426 //****************************************************************************
6427 //
6428 // DrawAmmoOptionDescription()
6429 //
6430 //****************************************************************************
6431 
DrawAmmoOptionDescription(int w)6432 void DrawAmmoOptionDescription( int w )
6433    {
6434    DrawOptionDescription( AmmoOptionDescriptions, w );
6435    }
6436 //****************************************************************************
6437 //
6438 // DrawHitPointsOptionDescription()
6439 //
6440 //****************************************************************************
6441 
DrawHitPointsOptionDescription(int w)6442 void DrawHitPointsOptionDescription( int w )
6443    {
6444    DrawOptionDescription( HitPointsOptionDescriptions, w );
6445    }
6446 //****************************************************************************
6447 //
6448 // DrawRadicalOptionDescription()
6449 //
6450 //****************************************************************************
6451 
DrawRadicalOptionDescription(int w)6452 void DrawRadicalOptionDescription( int w )
6453    {
6454    DrawOptionDescription( RadicalOptionDescriptions, w );
6455    }
6456 //****************************************************************************
6457 //
6458 // DrawLightLevelOptionDescription()
6459 //
6460 //****************************************************************************
6461 
DrawLightLevelOptionDescription(int w)6462 void DrawLightLevelOptionDescription( int w )
6463    {
6464    DrawOptionDescription( LightLevelOptionDescriptions, w );
6465    }
6466 //****************************************************************************
6467 //
6468 // DrawPointGoalOptionDescription()
6469 //
6470 //****************************************************************************
6471 
DrawPointGoalOptionDescription(int w)6472 void DrawPointGoalOptionDescription( int w )
6473    {
6474    DrawOptionDescription( PointGoalOptionDescriptions, w );
6475    }
6476 //****************************************************************************
6477 //
6478 // DrawDangerDamageOptionDescription()
6479 //
6480 //****************************************************************************
6481 
DrawDangerDamageOptionDescription(int w)6482 void DrawDangerDamageOptionDescription( int w )
6483    {
6484    DrawOptionDescription( DangerDamageOptionDescriptions, w );
6485    }
6486 
6487 //****************************************************************************
6488 //
6489 // DrawTimeLimitOptionDescription()
6490 //
6491 //****************************************************************************
6492 
DrawTimeLimitOptionDescription(int w)6493 void DrawTimeLimitOptionDescription( int w )
6494    {
6495    DrawOptionDescription( TimeLimitOptionDescriptions, w );
6496    }
6497 
6498 
6499 
6500 #define TURN_OFF_BATTLE_MODE( x ) \
6501    ModeMenu[ ( x ) - 1 ].active  = CP_SemiActive; \
6502    ModeMenu[ ( x ) - 1 ].routine = NULL;
6503 
6504 
6505 //****************************************************************************
6506 //
6507 // DrawBattleModes ()
6508 //
6509 //****************************************************************************
DrawBattleModes(void)6510 void DrawBattleModes
6511    (
6512    void
6513    )
6514 
6515    {
6516    int i;
6517 
6518    MenuNum = 1;
6519 
6520    SetAlternateMenuBuf();
6521    ClearMenuBuf();
6522    SetMenuTitle ("Battle Modes");
6523 
6524 
6525    MN_GetActive( &ModeItems, &ModeMenu[ 0 ], gamestate.battlemode -
6526       battle_Normal, OptionNums );
6527 
6528    #if ( SHAREWARE == 1 )
6529       TURN_OFF_BATTLE_MODE( battle_ScoreMore );
6530       TURN_OFF_BATTLE_MODE( battle_Scavenger );
6531       TURN_OFF_BATTLE_MODE( battle_Tag );
6532       TURN_OFF_BATTLE_MODE( battle_Eluder );
6533       TURN_OFF_BATTLE_MODE( battle_Deluder );
6534       TURN_OFF_BATTLE_MODE( battle_CaptureTheTriad );
6535    #endif
6536 
6537    // Capture the Triad, Tag, ScoreMore, and Hunter can only be
6538    // played with 2 or more players
6539    if ( numplayers < 2 )
6540       {
6541       TURN_OFF_BATTLE_MODE( battle_ScoreMore );
6542       TURN_OFF_BATTLE_MODE( battle_Tag );
6543       TURN_OFF_BATTLE_MODE( battle_Hunter );
6544       TURN_OFF_BATTLE_MODE( battle_CaptureTheTriad );
6545       }
6546 
6547    if ( ModeMenu[ ModeItems.curpos ].active != CP_CursorLocation )
6548       {
6549       for( i = 0; i < ModeItems.amount; i++ )
6550          {
6551          if ( ModeMenu[ i ].active == CP_Active )
6552             {
6553             ModeItems.curpos = i;
6554             ModeMenu[ i ].active = CP_CursorLocation;
6555             break;
6556             }
6557          }
6558       }
6559 
6560    DrawMenu( &ModeItems, &ModeMenu[ 0 ] );
6561    DisplayInfo( 0 );
6562    DrawBattleModeDescription( ModeItems.curpos );
6563 
6564    FlipMenuBuf();
6565    }
6566 
6567 
6568 
6569 //****************************************************************************
6570 //
6571 // DrawBattleModeName()
6572 //
6573 //****************************************************************************
6574 
DrawBattleModeName(int which)6575 void DrawBattleModeName( int which )
6576    {
6577    int     width;
6578    int     height;
6579    char   *string;
6580    font_t *temp;
6581 
6582 
6583    if ( ( which < battle_Normal ) || ( which > battle_CaptureTheTriad ) )
6584       {
6585       return;
6586       }
6587 
6588    string = BattleModeNames[ which - battle_Normal ];
6589 
6590    temp = CurrentFont;
6591    CurrentFont = tinyfont;
6592 
6593 	VW_MeasurePropString ( string, &width, &height );
6594    DrawMenuBufPropString ( ( 288 - width ) / 2, 4, string );
6595 //   DrawMenuBufPropString ( 270-width, 4, string );
6596 
6597    CurrentFont = temp;
6598    }
6599 
6600 
6601 //****************************************************************************
6602 //
6603 // DrawBattleModeDescription()
6604 //
6605 //****************************************************************************
6606 
DrawBattleModeDescription(int w)6607 void DrawBattleModeDescription( int w )
6608    {
6609    int     width;
6610    int     height;
6611    char   *string;
6612    font_t *temp;
6613 
6614    EraseMenuBufRegion (25, 4, 287 - 25, 10 );
6615 
6616    temp = CurrentFont;
6617    CurrentFont = tinyfont;
6618 
6619    string = BattleModeDescriptions[ w ];
6620 
6621    // Capture the Triad, Tag, ScoreMore, and Hunter can only be
6622    // played with 2 or more players
6623    if ( numplayers < 2 )
6624       {
6625       switch( w + 1 )
6626          {
6627          case battle_ScoreMore :
6628          case battle_Tag :
6629          case battle_Hunter :
6630          case battle_CaptureTheTriad :
6631             string = "This mode can only be played with 2 or more players.";
6632             break;
6633          }
6634       }
6635 
6636    #if ( SHAREWARE == 1 )
6637       switch( w + 1 )
6638          {
6639          case battle_ScoreMore :
6640          case battle_Scavenger :
6641          case battle_Tag :
6642          case battle_Eluder :
6643          case battle_Deluder :
6644          case battle_CaptureTheTriad :
6645             string = "See Ordering Info to find out how to get this game.";
6646             break;
6647          }
6648    #endif
6649 
6650 	VW_MeasurePropString ( string, &width, &height );
6651    DrawMenuBufPropString ( ( 288 - width ) / 2, 4, string );
6652 
6653    CurrentFont = temp;
6654    }
6655 
6656 
6657 //****************************************************************************
6658 //
6659 // CP_BattleModes ()
6660 //
6661 //****************************************************************************
6662 
CP_BattleModes(void)6663 void CP_BattleModes ( void )
6664    {
6665    int which;
6666    static char Warning = 0;
6667 
6668    //
6669    // ALREADY IN A GAME?
6670    //
6671    if ( ingame )
6672       {
6673       if ( !CP_DisplayMsg( CURGAME, 12 ) )
6674          {
6675          return;
6676          }
6677       else
6678          {
6679          EndGameStuff();
6680          }
6681       }
6682 
6683    if ( ( numplayers==1 ) && ( Warning == 0 ) )
6684       {
6685       Warning = 1;
6686       CP_OnePlayerWarningMessage();
6687       }
6688 
6689    DrawBattleModes ();
6690 
6691    damagecount = 0;
6692    BATTLEMODE  = true;
6693 
6694    do
6695       {
6696       which = HandleMenu( &ModeItems, &ModeMenu[ 0 ],
6697          DrawBattleModeDescription );
6698       }
6699    while ( which >= 0 );
6700 
6701    handlewhich = 100;
6702 
6703    if ( !StartGame )
6704       {
6705       BATTLEMODE = false;
6706       gamestate.battlemode = battle_StandAloneGame;
6707       }
6708    }
6709 
6710 //****************************************************************************
6711 //
6712 // DrawBattleOptions ()
6713 //
6714 //****************************************************************************
6715 
DrawBattleOptions(void)6716 void DrawBattleOptions (void)
6717 {
6718    int i;
6719 
6720 	MenuNum = 1;
6721 
6722 	SetAlternateMenuBuf();
6723    ClearMenuBuf();
6724    SetMenuTitle ("Battle Mode Options");
6725 
6726    MN_MakeActive ( &BOptItems, &BOptMenu[0], BOptItems.curpos );
6727 
6728    switch( gamestate.battlemode )
6729       {
6730       case battle_Collector :
6731          BOptMenu[2].active = CP_Inactive; // Ammo
6732          BOptMenu[6].active = CP_Inactive; // Point Goal
6733          break;
6734 
6735       case battle_Scavenger :
6736          BOptMenu[6].active = CP_Inactive; // Point Goal
6737          break;
6738 
6739       case battle_Tag :
6740          BOptMenu[2].active = CP_Inactive; // Ammo
6741          break;
6742 
6743       case battle_Eluder :
6744          BOptMenu[2].active = CP_Inactive; // Ammo
6745          BOptMenu[3].active = CP_Inactive; // Hit points
6746          BOptMenu[7].active = CP_Inactive; // Danger damage
6747          break;
6748       }
6749 
6750    if ( BOptMenu[ BOptItems.curpos ].active == CP_Inactive )
6751       {
6752       // Find an available cursor position
6753       for( i = 0; i < BOptItems.amount; i++ )
6754          {
6755          if ( BOptMenu[ i ].active == CP_Active )
6756             {
6757             BOptMenu[ i ].active = CP_CursorLocation;
6758             BOptItems.curpos = i;
6759             break;
6760             }
6761          }
6762       }
6763 
6764    DrawBattleModeName( gamestate.battlemode );
6765    DrawBattleOptionDescription( BOptItems.curpos );
6766    DrawMenu (&BOptItems, &BOptMenu[0]);
6767 	DisplayInfo (0);
6768 	FlipMenuBuf();
6769 }
6770 
6771 
6772 //****************************************************************************
6773 //
6774 // CP_BattleOptions ()
6775 //
6776 //****************************************************************************
6777 
CP_BattleOptions(void)6778 void CP_BattleOptions (void)
6779 {
6780 	int which;
6781 
6782 	DrawBattleOptions ();
6783 
6784 	do
6785 	{
6786       which = HandleMenu (&BOptItems, &BOptMenu[0], DrawBattleOptionDescription);
6787 
6788 	} while (which >= 0);
6789 
6790 	handlewhich = 100;
6791 //   WriteBattleConfig();
6792 	CalcTics();
6793 
6794 	DrawBattleMenu ();
6795 }
6796 
6797 
6798 
6799 //****************************************************************************
6800 //
6801 // DrawColorMenu ()
6802 //
6803 //****************************************************************************
6804 
6805 
DrawColorMenu(void)6806 void DrawColorMenu( void )
6807    {
6808    int   width;
6809    int   height;
6810    char *text;
6811 
6812    SetAlternateMenuBuf();
6813    ClearMenuBuf();
6814    SetMenuTitle ("Uniform Color");
6815 
6816    CurrentFont = smallfont;
6817 
6818    text = colorname[ locplayerstate->uniformcolor ];
6819    VW_MeasurePropString ( text, &width, &height );
6820    DrawMenuBufPropString ( ( 320 - width ) / 2 - 16, MENU_Y + 5, text );
6821    DisplayInfo( 8 );
6822    EraseMenuBufRegion( COLORX, COLORY, COLORW, COLORH );
6823    DrawTMenuBufBox( COLORX, COLORY, COLORW, COLORH );
6824    DrawColoredMenuBufItem( COLORX - 36, COLORY - 33,
6825       W_GetNumForName( playerwadname[ locplayerstate->player ] ),
6826       locplayerstate->uniformcolor);
6827 
6828 
6829    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
6830       ( consoleplayer == 0 ) )
6831       {
6832       DrawBattleModeName( gamestate.battlemode );
6833       }
6834 
6835    FlipMenuBuf();
6836    }
6837 
6838 
6839 //****************************************************************************
6840 //
6841 // CP_ColorSelection ()
6842 //
6843 //****************************************************************************
6844 
CP_ColorSelection(void)6845 int CP_ColorSelection (void)
6846 {
6847    int status;
6848 
6849    locplayerstate->uniformcolor = DefaultPlayerColor;
6850 
6851 	DrawColorMenu ();
6852 	status = ColorMenu();
6853    return( status );
6854 }
6855 
ColorMenu(void)6856 int ColorMenu
6857    (
6858    void
6859    )
6860 
6861    {
6862    ControlInfo ci;
6863    int colorindex;
6864    char *text;
6865    int width;
6866    int height;
6867    int timer;
6868    int baseshape;
6869    int status;
6870    boolean update;
6871    boolean done;
6872 
6873    colorindex = DefaultPlayerColor;
6874    timer      = GetTicCount();
6875    baseshape  = W_GetNumForName( playerwadname[ locplayerstate->player ] );
6876 
6877    update = false;
6878    done   = false;
6879    while( !done )
6880       {
6881       ReadAnyControl( &ci );
6882       if ( ( ci.dir == dir_East ) && ( ( GetTicCount() - timer ) > 5 ) )
6883          {
6884          update = true;
6885          timer = GetTicCount();
6886 
6887          colorindex++;
6888          if ( colorindex >= MAXPLAYERCOLORS )
6889             {
6890             colorindex = 0;
6891             }
6892 
6893          MN_PlayMenuSnd( SD_MOVECURSORSND );
6894          }
6895 
6896       if ( ( ci.dir == dir_West ) && ( ( GetTicCount() - timer ) > 5 ) )
6897          {
6898          update = true;
6899          timer = GetTicCount();
6900 
6901          colorindex--;
6902          if ( colorindex < 0 )
6903             {
6904             colorindex = MAXPLAYERCOLORS - 1;
6905             }
6906          MN_PlayMenuSnd( SD_MOVECURSORSND );
6907          }
6908 
6909       if ( update )
6910          {
6911          update = false;
6912          DefaultPlayerColor = colorindex;
6913          locplayerstate->uniformcolor = colorindex;
6914          text = colorname[ locplayerstate->uniformcolor ];
6915 
6916          EraseMenuBufRegion( 0, MENU_Y + 5, 200, 10 );
6917          EraseMenuBufRegion( COLORX, COLORY, COLORW, COLORH );
6918          VW_MeasurePropString( text, &width, &height );
6919          DrawMenuBufPropString( ( 320 - width ) / 2 - 16, MENU_Y + 5, text );
6920          DrawTMenuBufBox( COLORX, COLORY, COLORW, COLORH );
6921          DrawColoredMenuBufItem( COLORX - 36, COLORY - 33,
6922             baseshape, locplayerstate->uniformcolor );
6923          }
6924 
6925       if ( ci.button0 || Keyboard[ sc_Space ] || Keyboard[sc_Enter ] )
6926          {
6927          Keyboard[ sc_Space ] = 0;
6928          Keyboard[ sc_Enter ] = 0;
6929          MN_PlayMenuSnd( SD_SELECTSND );
6930          status = 1;
6931          done = true;
6932          }
6933       else if ( ci.button1 || Keyboard[ sc_Escape ] )
6934          {
6935          MN_PlayMenuSnd( SD_ESCPRESSEDSND );
6936          status = 0;
6937          done = true;
6938          }
6939 
6940       RefreshMenuBuf( 0 );
6941       }
6942 
6943    IN_ClearKeysDown();
6944    return( status );
6945    }
6946 
6947 
6948 //****************************************************************************
6949 //
6950 // CP_PlayerSelection ()
6951 //
6952 //****************************************************************************
CP_PlayerSelection(void)6953 int CP_PlayerSelection
6954    (
6955    void
6956    )
6957 
6958    {
6959 	int which;
6960 
6961    // Do Pick-A-Player menu
6962 	DrawPlayerMenu();
6963 
6964    do
6965       {
6966       which = HandleMenu( &PlayerItems, &PlayerMenu[ 0 ], DrawNewPlayerDiff );
6967       if ( which < 0 )
6968          {
6969          handlewhich = 1;
6970          return( 0 );
6971          }
6972 
6973       #if ( SHAREWARE == 1 )
6974          if ( PlayerMenu[ which ].active == CP_SemiActive )
6975             {
6976             CP_ErrorMsg( "Choose Player",
6977                "Read the Ordering Info section from the Main Menu to "
6978                "find out how to get the other characters.",
6979                mn_smallfont );
6980 
6981             DrawPlayerMenu();
6982             }
6983       #endif
6984       }
6985    while( PlayerMenu[ which ].active == CP_SemiActive );
6986 
6987 
6988 #if ( SHAREWARE == 1 )
6989    DefaultPlayerCharacter = 0;
6990    locplayerstate->player = 0;
6991 #else
6992    DefaultPlayerCharacter = which;
6993    locplayerstate->player = which;
6994 #endif
6995 
6996 	return (1);
6997 }
6998 
6999 //****************************************************************************
7000 //
7001 // CP_OnePlayerWarningMessage ()
7002 //
7003 //****************************************************************************
7004 
CP_OnePlayerWarningMessage(void)7005 void CP_OnePlayerWarningMessage
7006    (
7007    void
7008    )
7009 
7010    {
7011    CP_ErrorMsg( "Comm-bat Warning",
7012       "Comm-bat is designed for modem and network play.  "
7013       "One player mode is provided for exploration.  The "
7014       "Collector battle mode is still fun on your own.",
7015       mn_smallfont );
7016    }
7017 
7018 
7019 //****************************************************************************
7020 //
7021 // CP_CaptureTheTriadError()
7022 //
7023 //****************************************************************************
7024 
CP_CaptureTheTriadError(void)7025 void CP_CaptureTheTriadError
7026    (
7027    void
7028    )
7029 
7030    {
7031    SetupMenuBuf();
7032    SetUpControlPanel();
7033 
7034    CP_ErrorMsg( "Comm-bat Warning",
7035       "Capture the Traid can only be played with 2 teams."
7036       "  All players must return to the menu to choose their "
7037       "team colors.", mn_largefont );
7038 
7039    CleanUpControlPanel();
7040    ShutdownMenuBuf();
7041    }
7042 
7043 
7044 //****************************************************************************
7045 //
7046 // CP_TeamPlayErrorMessage()
7047 //
7048 //****************************************************************************
7049 
CP_TeamPlayErrorMessage(void)7050 void CP_TeamPlayErrorMessage
7051    (
7052    void
7053    )
7054 
7055    {
7056    SetupMenuBuf();
7057    SetUpControlPanel();
7058 
7059    CP_ErrorMsg( "Comm-bat Warning",
7060       "Team play can only be played with 2 or more teams."
7061       "  All players must return to the menu to choose their "
7062       "team colors.", mn_largefont );
7063 
7064    CleanUpControlPanel();
7065    ShutdownMenuBuf();
7066    }
7067 
7068 
7069 //****************************************************************************
7070 //
7071 // CP_ModemGameMessage ()
7072 //
7073 //****************************************************************************
7074 
7075 #if (SITELICENSE == 0)
7076 
7077 #define SITELINES 8
7078 
7079 char *sitemessage[] =
7080    {
7081    "HEY! ARE YOU PLAYING ON AN ILLEGAL COPY?",
7082    "Network players: it's easy to play legally!",
7083    "Just get a site license.  For a little over",
7084    "the price of two games, you get 10 more battle",
7085    "levels, 11 command cards, and a signed Site",
7086    "License.  We don't charge you for 11 copies--",
7087    "just for two!  Call 1-800-APOGEE1 to order.",
7088    "For more on site licenses, see ORDERING INFO."
7089    };
7090 
7091 #endif
7092 
CP_ModemGameMessage(int player)7093 void CP_ModemGameMessage
7094    (
7095    int player
7096    )
7097 
7098    {
7099    int i;
7100 
7101 	SetAlternateMenuBuf();
7102    ClearMenuBuf();
7103    SetMenuTitle ("Game Message");
7104 
7105    newfont1 = (font_t *)W_CacheLumpName( "newfnt1", PU_CACHE, Cvt_font_t, 1);
7106    CurrentFont = newfont1;
7107    if ( modemgame == false )
7108       {
7109       WindowW = 288;
7110       WindowH = 158;
7111       PrintX = WindowX = 0;
7112       PrintY = WindowY = 60;
7113       MenuBufCPrint ("Please wait.\nLoading game.");
7114       }
7115    else
7116       {
7117       WindowW = 288;
7118       WindowH = 158;
7119       PrintX = WindowX = 0;
7120       PrintY = WindowY = 50;
7121 
7122       if (networkgame==true)
7123          {
7124          PrintY = WindowY = 28;
7125          }
7126 
7127       if ( player == 0 )
7128          {
7129          MenuBufCPrint ("Please wait for\nplayers to choose\ntheir characters.");
7130          }
7131       else
7132          {
7133          MenuBufCPrint ("Please wait while\nMaster selects\nCOMM-BAT options.");
7134          }
7135 
7136 #if (SITELICENSE == 0)
7137       if (networkgame==true)
7138          {
7139          for( i = 0; i < SITELINES; i++ )
7140             {
7141             PrintBattleOption( true, 68, 77 + i * 8,
7142                sitemessage[ i ] );
7143             }
7144          }
7145 #endif
7146       }
7147 
7148    FlipMenuBuf();
7149 	RefreshMenuBuf (0);
7150    }
7151 
7152 
7153 //****************************************************************************
7154 //
7155 // DrawGravityMenu ()
7156 //
7157 //****************************************************************************
7158 
DrawGravityMenu(void)7159 void DrawGravityMenu (void)
7160 {
7161    MenuNum = 1;
7162 
7163    SetAlternateMenuBuf ();
7164    ClearMenuBuf();
7165    SetMenuTitle ("Gravity");
7166 
7167 
7168    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
7169       ( consoleplayer == 0 ) )
7170       {
7171       DrawBattleModeName( gamestate.battlemode );
7172       }
7173 
7174    MN_DrawButtons (&GravityItems, &GravityMenu[0],
7175 		BATTLE_Options[gamestate.battlemode].Gravity, GravityNums);
7176    MN_GetActive (&GravityItems, &GravityMenu[0],
7177 		BATTLE_Options[gamestate.battlemode].Gravity, GravityNums);
7178 
7179 	DrawMenu (&GravityItems, &GravityMenu[0]);
7180    DrawGravityOptionDescription( GravityItems.curpos );
7181    PrintBattleOption( true, 32, 79,
7182       "WARNING: High gravity has an unfortunate side effect in" );
7183    PrintBattleOption( true, 32, 87,
7184       "some levels.  It is possible to jump into an area that is" );
7185    PrintBattleOption( true, 32, 95,
7186       "impossible, or at least extremely difficult to get out" );
7187    PrintBattleOption( true, 32, 103,
7188       "of.  In these situations, the only thing you can do is" );
7189    PrintBattleOption( true, 32, 111,
7190       "kill your character, or find some kindly soul to do it" );
7191    PrintBattleOption( true, 32, 119,
7192       "for you.  If this fails, you'll just have to end your game." );
7193 
7194    DisplayInfo( 0 );
7195 
7196    FlipMenuBuf();
7197 }
7198 
7199 
7200 //****************************************************************************
7201 //
7202 // CP_GravityOptions ()
7203 //
7204 //****************************************************************************
7205 
CP_GravityOptions(void)7206 void CP_GravityOptions (void)
7207 {
7208    int which;
7209 
7210    DrawGravityMenu ();
7211 
7212    do
7213    {
7214       which = HandleMenu (&GravityItems, &GravityMenu[0], DrawGravityOptionDescription);
7215 
7216       if (which >= 0)
7217 		  BATTLE_Options[gamestate.battlemode].Gravity = GravityNums[ which ];
7218 
7219       MN_DrawButtons (&GravityItems, &GravityMenu[0],
7220 			BATTLE_Options[gamestate.battlemode].Gravity, GravityNums);
7221 
7222    } while (which >= 0);
7223 
7224    handlewhich = 100;
7225    DrawBattleOptions ();
7226 }
7227 
7228 
7229 //****************************************************************************
7230 //
7231 // DrawSpeedMenu ()
7232 //
7233 //****************************************************************************
7234 
DrawSpeedMenu(void)7235 void DrawSpeedMenu (void)
7236 {
7237 	MenuNum = 1;
7238 
7239    SetAlternateMenuBuf ();
7240    ClearMenuBuf();
7241    SetMenuTitle ("Speed");
7242 
7243 
7244    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
7245       ( consoleplayer == 0 ) )
7246       {
7247       DrawBattleModeName( gamestate.battlemode );
7248       }
7249 
7250    MN_DrawButtons (&SpeedItems, &SpeedMenu[0],
7251 						 BATTLE_Options[gamestate.battlemode].Speed, OptionNums );
7252    MN_GetActive (&SpeedItems, &SpeedMenu[0],
7253 					  BATTLE_Options[gamestate.battlemode].Speed, OptionNums );
7254 
7255    DrawMenu (&SpeedItems, &SpeedMenu[0]);
7256    DrawSpeedOptionDescription( SpeedItems.curpos );
7257    DisplayInfo (0);
7258    FlipMenuBuf();
7259 }
7260 
7261 
7262 //****************************************************************************
7263 //
7264 // CP_SpeedOptions ()
7265 //
7266 //****************************************************************************
7267 
CP_SpeedOptions(void)7268 void CP_SpeedOptions (void)
7269 {
7270    int which;
7271 
7272    DrawSpeedMenu ();
7273 
7274    do
7275    {
7276       which = HandleMenu (&SpeedItems, &SpeedMenu[0], DrawSpeedOptionDescription);
7277 
7278       if (which >= 0)
7279 		  BATTLE_Options[gamestate.battlemode].Speed = which;
7280 
7281       MN_DrawButtons (&SpeedItems, &SpeedMenu[0],
7282          BATTLE_Options[gamestate.battlemode].Speed, OptionNums );
7283    } while (which >= 0);
7284 
7285    handlewhich = 100;
7286    DrawBattleOptions ();
7287 }
7288 
7289 
7290 //****************************************************************************
7291 //
7292 // DrawAmmoPerWeaponMenu ()
7293 //
7294 //****************************************************************************
DrawAmmoPerWeaponMenu(void)7295 void DrawAmmoPerWeaponMenu
7296    (
7297    void
7298    )
7299 
7300    {
7301    MenuNum = 1;
7302 
7303    SetAlternateMenuBuf();
7304    ClearMenuBuf();
7305    SetMenuTitle ("Ammo Per Weapon");
7306 
7307    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
7308       ( consoleplayer == 0 ) )
7309       {
7310       DrawBattleModeName( gamestate.battlemode );
7311       }
7312 
7313    MN_DrawButtons( &AmmoPerWeaponItems, &AmmoPerWeaponMenu[ 0 ],
7314       BATTLE_Options[ gamestate.battlemode ].Ammo, OptionNums );
7315 
7316    MN_GetActive( &AmmoPerWeaponItems, &AmmoPerWeaponMenu[ 0 ],
7317       BATTLE_Options[ gamestate.battlemode ].Ammo, OptionNums );
7318 
7319    DrawMenu( &AmmoPerWeaponItems, &AmmoPerWeaponMenu[ 0 ] );
7320 
7321    PrintBattleOption( true, 32, 79,
7322       "WARNING: Infinite ammo can seriously alter the balance of" );
7323    PrintBattleOption( true, 32, 87,
7324       "the game.  We recommend that you only use it occasionally." );
7325    PrintBattleOption( true, 32, 95,
7326       "It tends to only work well on small levels with lots of" );
7327    PrintBattleOption( true, 32, 103,
7328       "weapons, where the action is far more intense.  On large" );
7329    PrintBattleOption( true, 32, 111,
7330       "levels, you may find it causes people to wait in easily" );
7331    PrintBattleOption( true, 32, 119,
7332       "guardable areas and pick off anyone that comes in the room" );
7333    PrintBattleOption( true, 32, 127,
7334       "(creating an unfair advantage)." );
7335 
7336    if ( AmmoPerWeaponItems.curpos == 2 )
7337       {
7338       PrintBattleOption( true, 102, 136, "You have been warned." );
7339       }
7340 
7341    DrawAmmoOptionDescription( AmmoPerWeaponItems.curpos );
7342    DisplayInfo( 0 );
7343    FlipMenuBuf();
7344    }
7345 
7346 
7347 //****************************************************************************
7348 //
7349 // CP_AmmoPerWeaponOptions ()
7350 //
7351 //****************************************************************************
CP_AmmoPerWeaponOptions(void)7352 void CP_AmmoPerWeaponOptions
7353    (
7354    void
7355    )
7356 
7357    {
7358    int which;
7359 
7360    DrawAmmoPerWeaponMenu();
7361 
7362    do
7363       {
7364       which = HandleMenu( &AmmoPerWeaponItems, &AmmoPerWeaponMenu[ 0 ], DrawAmmoOptionDescription);
7365 
7366       if (which >= 0)
7367          {
7368          if ( AmmoPerWeaponItems.curpos == 2 )
7369             {
7370             MN_PlayMenuSnd( SD_LIGHTNINGSND );
7371             PrintBattleOption( true, 102, 136, "You have been warned." );
7372             VL_FillPalette(255,255,255);
7373             VL_FadeIn(0,255,origpal,10);
7374             }
7375          else if ( BATTLE_Options[ gamestate.battlemode ].Ammo == 2 )
7376             {
7377             EraseMenuBufRegion( 102, 136, 84, 8 );
7378             MN_PlayMenuSnd( SD_PLAYERTCSND );
7379             }
7380 
7381          BATTLE_Options[ gamestate.battlemode ].Ammo = which;
7382          }
7383 
7384       MN_DrawButtons( &AmmoPerWeaponItems, &AmmoPerWeaponMenu[ 0 ],
7385          BATTLE_Options[ gamestate.battlemode ].Ammo, OptionNums );
7386       }
7387    while( which >= 0 );
7388 
7389    handlewhich = 100;
7390    DrawBattleOptions();
7391    }
7392 
7393 
7394 //****************************************************************************
7395 //
7396 // DrawHitPointsMenu ()
7397 //
7398 //****************************************************************************
DrawHitPointsMenu(void)7399 void DrawHitPointsMenu
7400    (
7401    void
7402    )
7403 
7404    {
7405    MenuNum = 1;
7406 
7407    SetAlternateMenuBuf ();
7408    ClearMenuBuf();
7409    SetMenuTitle ("Player Hitpoints");
7410 
7411    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
7412       ( consoleplayer == 0 ) )
7413       {
7414       DrawBattleModeName( gamestate.battlemode );
7415       }
7416 
7417    MN_DrawButtons( &HitPointItems, &HitPointMenu[ 0 ],
7418       BATTLE_Options[ gamestate.battlemode ].HitPoints, HitPointNums );
7419 
7420    MN_GetActive( &HitPointItems, &HitPointMenu[ 0 ],
7421       BATTLE_Options[ gamestate.battlemode ].HitPoints, HitPointNums );
7422 
7423    DrawMenu( &HitPointItems, &HitPointMenu[ 0 ] );
7424    DrawHitPointsOptionDescription( HitPointItems.curpos );
7425    DisplayInfo( 0 );
7426    FlipMenuBuf();
7427    }
7428 
7429 
7430 //****************************************************************************
7431 //
7432 // CP_HitPointsOptions ()
7433 //
7434 //****************************************************************************
7435 
CP_HitPointsOptions(void)7436 void CP_HitPointsOptions (void)
7437 {
7438    int which;
7439 
7440    DrawHitPointsMenu ();
7441 
7442    do
7443    {
7444       which = HandleMenu (&HitPointItems, &HitPointMenu[0], DrawHitPointsOptionDescription);
7445 
7446       if (which >= 0)
7447          BATTLE_Options[gamestate.battlemode].HitPoints = HitPointNums[ which ];
7448 
7449       MN_DrawButtons (&HitPointItems, &HitPointMenu[0],
7450 							 BATTLE_Options[gamestate.battlemode].HitPoints, HitPointNums);
7451 
7452    } while (which >= 0);
7453 
7454    handlewhich = 100;
7455    DrawBattleOptions ();
7456 }
7457 
7458 
7459 
7460 //****************************************************************************
7461 //
7462 // DrawSpawnControlMenu ()
7463 //
7464 //****************************************************************************
DrawSpawnControlMenu(void)7465 void DrawSpawnControlMenu
7466    (
7467    void
7468    )
7469 
7470    {
7471    int i;
7472 
7473    MenuNum = 1;
7474 
7475    SetAlternateMenuBuf();
7476    ClearMenuBuf();
7477    SetMenuTitle ("Radical Options");
7478 
7479    MN_MakeActive( &SpawnItems, &SpawnMenu[ 0 ], SpawnItems.curpos );
7480 
7481 #if ( SHAREWARE == 1 )
7482    BATTLE_Options[ gamestate.battlemode ].SpawnMines = false;
7483    SpawnMenu[ 3 ].active = CP_Inactive; // Mines
7484 #endif
7485 
7486    switch( gamestate.battlemode )
7487       {
7488       case battle_Normal :
7489          break;
7490 
7491       case battle_ScoreMore :
7492          break;
7493 
7494       case battle_Collector :
7495          SpawnMenu[ 2 ].active = CP_Inactive; // Weapons
7496          SpawnMenu[ 5 ].active = CP_Inactive; // Persistence
7497          SpawnMenu[ 6 ].active = CP_Inactive; // Random Weapons
7498          SpawnMenu[ 7 ].active = CP_Inactive; // Friendly Fire
7499          break;
7500 
7501       case battle_Scavenger :
7502          SpawnMenu[ 7 ].active = CP_Inactive; // Friendly Fire
7503          break;
7504 
7505       case battle_Hunter :
7506          break;
7507 
7508       case battle_Tag :
7509          SpawnMenu[ 2 ].active = CP_Inactive; // Weapons
7510          SpawnMenu[ 5 ].active = CP_Inactive; // Persistence
7511          SpawnMenu[ 6 ].active = CP_Inactive; // Random Weapons
7512          break;
7513 
7514       case battle_Eluder :
7515          SpawnMenu[ 1 ].active = CP_Inactive; // Health
7516          SpawnMenu[ 2 ].active = CP_Inactive; // Weapons
7517          SpawnMenu[ 4 ].active = CP_Inactive; // Respawn
7518          SpawnMenu[ 5 ].active = CP_Inactive; // Persistence
7519          SpawnMenu[ 6 ].active = CP_Inactive; // Random Weapons
7520          SpawnMenu[ 7 ].active = CP_Inactive; // Friendly Fire
7521          break;
7522 
7523       case battle_Deluder :
7524          SpawnMenu[ 7 ].active = CP_Inactive; // Friendly Fire
7525          break;
7526 
7527       case battle_CaptureTheTriad :
7528          SpawnMenu[ 7 ].active = CP_Inactive; // Friendly Fire
7529          break;
7530       }
7531 
7532    if ( SpawnMenu[ SpawnItems.curpos ].active == CP_Inactive )
7533       {
7534       // Find an available cursor position
7535       for( i = 0; i < SpawnItems.amount; i++ )
7536          {
7537          if ( SpawnMenu[ i ].active == CP_Active )
7538             {
7539             SpawnMenu[ i ].active = CP_CursorLocation;
7540             SpawnItems.curpos = i;
7541             break;
7542             }
7543          }
7544       }
7545 
7546    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
7547       ( consoleplayer == 0 ) )
7548       {
7549       DrawBattleModeName( gamestate.battlemode );
7550       }
7551 
7552    DrawSpawnControlButtons();
7553 
7554    MN_GetCursorLocation( &SpawnItems, &SpawnMenu[ 0 ] );
7555 
7556    DrawMenu( &SpawnItems, &SpawnMenu[ 0 ] );
7557    DrawRadicalOptionDescription( SpawnItems.curpos );
7558    DisplayInfo( 0 );
7559    FlipMenuBuf();
7560    }
7561 
7562 
7563 //****************************************************************************
7564 //
7565 // DrawSpawnControlButtons ()
7566 //
7567 //****************************************************************************
DrawSpawnControlButtons(void)7568 void DrawSpawnControlButtons
7569    (
7570    void
7571    )
7572 
7573    {
7574    int x;
7575    int y;
7576    int button_on;
7577    int button_off;
7578 
7579    button_on  = W_GetNumForName( "snd_on" );
7580    button_off = W_GetNumForName( "snd_off" );
7581 
7582    x = SpawnItems.x + 18;
7583    y = SpawnItems.y - 1;
7584 
7585 	if ( BATTLE_Options[ gamestate.battlemode ].SpawnDangers )
7586 		{
7587 		DrawMenuBufItem( x, y, button_on );
7588 		}
7589 	else
7590 		{
7591 		EraseMenuBufRegion( x, y, 16, 16 );
7592 		DrawMenuBufItem( x, y, button_off );
7593 		}
7594 
7595 	y += 14;
7596 	if ( BATTLE_Options[ gamestate.battlemode ].SpawnHealth )
7597 		{
7598 		DrawMenuBufItem( x, y, button_on );
7599 		}
7600 	else
7601 		{
7602 		EraseMenuBufRegion( x, y, 16, 16 );
7603 		DrawMenuBufItem( x, y, button_off );
7604 		}
7605 
7606 	y += 14;
7607 	if ( BATTLE_Options[ gamestate.battlemode ].SpawnWeapons )
7608 		{
7609 		DrawMenuBufItem( x, y, button_on );
7610 		}
7611 	else
7612 		{
7613 		EraseMenuBufRegion( x, y, 16, 16 );
7614 		DrawMenuBufItem( x, y, button_off );
7615 		}
7616 
7617 	y += 14;
7618 	if ( BATTLE_Options[ gamestate.battlemode ].SpawnMines )
7619 		{
7620 		DrawMenuBufItem( x, y, button_on );
7621 		}
7622 	else
7623 		{
7624 		EraseMenuBufRegion( x, y, 16, 16 );
7625 		DrawMenuBufItem( x, y, button_off );
7626 		}
7627 
7628 	y += 14;
7629 	if ( BATTLE_Options[ gamestate.battlemode ].RespawnItems )
7630 		{
7631 		DrawMenuBufItem( x, y, button_on );
7632 		}
7633 	else
7634 		{
7635 		EraseMenuBufRegion( x, y, 16, 16 );
7636 		DrawMenuBufItem( x, y, button_off );
7637 		}
7638 
7639 	y += 14;
7640 	if ( BATTLE_Options[ gamestate.battlemode ].WeaponPersistence )
7641 		{
7642 		DrawMenuBufItem( x, y, button_on );
7643 		}
7644 	else
7645 		{
7646 		EraseMenuBufRegion( x, y, 16, 16 );
7647 		DrawMenuBufItem( x, y, button_off );
7648 		}
7649 
7650 	y += 14;
7651 	if ( BATTLE_Options[ gamestate.battlemode ].RandomWeapons )
7652 		{
7653 		DrawMenuBufItem( x, y, button_on );
7654 		}
7655 	else
7656 		{
7657 		EraseMenuBufRegion( x, y, 16, 16 );
7658 		DrawMenuBufItem( x, y, button_off );
7659 		}
7660 
7661 	y += 14;
7662 	if ( BATTLE_Options[ gamestate.battlemode ].FriendlyFire )
7663 		{
7664 		DrawMenuBufItem( x, y, button_on );
7665 		}
7666 	else
7667 		{
7668 		EraseMenuBufRegion( x, y, 16, 16 );
7669 		DrawMenuBufItem( x, y, button_off );
7670 		}
7671 	}
7672 
7673 
7674 //****************************************************************************
7675 //
7676 // CP_SpawnControlOptions ()
7677 //
7678 //****************************************************************************
CP_SpawnControlOptions(void)7679 void CP_SpawnControlOptions
7680    (
7681    void
7682    )
7683 
7684    {
7685 	int which;
7686 
7687 	DrawSpawnControlMenu();
7688 
7689    do
7690       {
7691       which = HandleMenu( &SpawnItems, &SpawnMenu[ 0 ], DrawRadicalOptionDescription );
7692       switch( which )
7693          {
7694 			case 0 :
7695 				BATTLE_Options[ gamestate.battlemode ].SpawnDangers =
7696                !BATTLE_Options[ gamestate.battlemode ].SpawnDangers;
7697             break;
7698 
7699          case 1 :
7700 				BATTLE_Options[ gamestate.battlemode ].SpawnHealth =
7701                !BATTLE_Options[ gamestate.battlemode ].SpawnHealth;
7702             break;
7703 
7704          case 2 :
7705 				BATTLE_Options[ gamestate.battlemode ].SpawnWeapons =
7706                !BATTLE_Options[ gamestate.battlemode ].SpawnWeapons;
7707             break;
7708 
7709          case 3 :
7710 				BATTLE_Options[ gamestate.battlemode ].SpawnMines =
7711                !BATTLE_Options[ gamestate.battlemode ].SpawnMines;
7712             break;
7713 
7714          case 4 :
7715 				BATTLE_Options[ gamestate.battlemode ].RespawnItems =
7716                !BATTLE_Options[ gamestate.battlemode ].RespawnItems;
7717             break;
7718 
7719          case 5 :
7720 				BATTLE_Options[ gamestate.battlemode ].WeaponPersistence =
7721                !BATTLE_Options[ gamestate.battlemode ].WeaponPersistence;
7722             break;
7723 
7724          case 6 :
7725 				BATTLE_Options[ gamestate.battlemode ].RandomWeapons =
7726                !BATTLE_Options[ gamestate.battlemode ].RandomWeapons;
7727             break;
7728 
7729          case 7 :
7730 				BATTLE_Options[ gamestate.battlemode ].FriendlyFire =
7731                !BATTLE_Options[ gamestate.battlemode ].FriendlyFire;
7732             break;
7733          }
7734 
7735       DrawSpawnControlButtons();
7736       }
7737    while( which >= 0 );
7738 
7739    handlewhich = 100;
7740    DrawBattleOptions();
7741    }
7742 
7743 
7744 
7745 //****************************************************************************
7746 //
7747 // DrawLightLevelMenu ()
7748 //
7749 //****************************************************************************
7750 
DrawLightLevelMenu(void)7751 void DrawLightLevelMenu (void)
7752 {
7753    MenuNum = 1;
7754 
7755 	SetAlternateMenuBuf ();
7756    ClearMenuBuf();
7757    SetMenuTitle ("Light Levels");
7758 
7759 
7760    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
7761       ( consoleplayer == 0 ) )
7762       {
7763       DrawBattleModeName( gamestate.battlemode );
7764       }
7765 
7766    MN_DrawButtons (&LightLevelItems, &LightLevelMenu[0],
7767       BATTLE_Options[gamestate.battlemode].LightLevel, OptionNums );
7768    MN_GetActive (&LightLevelItems, &LightLevelMenu[0],
7769       BATTLE_Options[gamestate.battlemode].LightLevel, OptionNums );
7770 
7771    DrawMenu (&LightLevelItems, &LightLevelMenu[0]);
7772    DrawLightLevelOptionDescription( LightLevelItems.curpos );
7773    DisplayInfo (0);
7774    FlipMenuBuf();
7775 }
7776 
7777 
7778 //****************************************************************************
7779 //
7780 // CP_LightLevelOptions ()
7781 //
7782 //****************************************************************************
7783 
CP_LightLevelOptions(void)7784 void CP_LightLevelOptions (void)
7785 {
7786    int which;
7787 
7788    DrawLightLevelMenu ();
7789 
7790    do
7791    {
7792       which = HandleMenu (&LightLevelItems, &LightLevelMenu[0], DrawLightLevelOptionDescription);
7793 
7794       if (which >= 0)
7795 		  BATTLE_Options[gamestate.battlemode].LightLevel = which;
7796 
7797       MN_DrawButtons (&LightLevelItems, &LightLevelMenu[0],
7798          BATTLE_Options[gamestate.battlemode].LightLevel, OptionNums );
7799 
7800    } while (which >= 0);
7801 
7802    handlewhich = 100;
7803    DrawBattleOptions ();
7804 }
7805 
7806 
7807 
7808 //****************************************************************************
7809 //
7810 // DrawPointGoalMenu()
7811 //
7812 //****************************************************************************
7813 
DrawPointGoalMenu(void)7814 void DrawPointGoalMenu
7815    (
7816    void
7817    )
7818 
7819    {
7820    MenuNum = 1;
7821 
7822    SetAlternateMenuBuf();
7823    ClearMenuBuf();
7824    SetMenuTitle ("Point Goal");
7825 
7826    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
7827       ( consoleplayer == 0 ) )
7828       {
7829       DrawBattleModeName( gamestate.battlemode );
7830       }
7831 
7832    MN_DrawButtons( &PointGoalItems, &PointGoalMenu[ 0 ],
7833       BATTLE_Options[ gamestate.battlemode ].Kills, KillNums );
7834 
7835    MN_GetActive( &PointGoalItems, &PointGoalMenu[ 0 ],
7836 	   BATTLE_Options[ gamestate.battlemode ].Kills, KillNums );
7837 
7838    DrawMenu( &PointGoalItems, &PointGoalMenu[ 0 ] );
7839    DrawPointGoalOptionDescription( PointGoalItems.curpos );
7840    DisplayInfo( 0 );
7841    FlipMenuBuf();
7842    }
7843 
7844 
7845 //****************************************************************************
7846 //
7847 // CP_PointGoalOptions()
7848 //
7849 //****************************************************************************
7850 
CP_PointGoalOptions(void)7851 void CP_PointGoalOptions
7852    (
7853    void
7854    )
7855 
7856    {
7857    int which;
7858 
7859    DrawPointGoalMenu();
7860 
7861    do
7862       {
7863       which = HandleMenu( &PointGoalItems, &PointGoalMenu[ 0 ], DrawPointGoalOptionDescription );
7864 
7865       if ( which >= 0 )
7866          {
7867          BATTLE_Options[ gamestate.battlemode ].Kills = KillNums[ which ];
7868 
7869          MN_DrawButtons( &PointGoalItems, &PointGoalMenu[ 0 ],
7870             BATTLE_Options[ gamestate.battlemode ].Kills, KillNums );
7871          }
7872       }
7873    while( which >= 0 );
7874 
7875    handlewhich = 100;
7876    DrawBattleOptions();
7877    }
7878 
7879 
7880 //****************************************************************************
7881 //
7882 // DrawDangerMenu ()
7883 //
7884 //****************************************************************************
7885 
DrawDangerMenu(void)7886 void DrawDangerMenu (void)
7887 {
7888    MenuNum = 1;
7889 
7890    SetAlternateMenuBuf ();
7891    ClearMenuBuf();
7892    SetMenuTitle ("Danger Damage");
7893 
7894 
7895    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
7896       ( consoleplayer == 0 ) )
7897       {
7898       DrawBattleModeName( gamestate.battlemode );
7899       }
7900    MN_DrawButtons (&DangerItems, &DangerMenu[0],
7901 						 BATTLE_Options[gamestate.battlemode].DangerDamage, DangerNums);
7902    MN_GetActive (&DangerItems, &DangerMenu[0],
7903 						 BATTLE_Options[gamestate.battlemode].DangerDamage, DangerNums);
7904 
7905    DrawMenu (&DangerItems, &DangerMenu[0]);
7906    DrawDangerDamageOptionDescription( DangerItems.curpos );
7907    DisplayInfo (0);
7908    FlipMenuBuf();
7909 }
7910 
7911 
7912 //****************************************************************************
7913 //
7914 // CP_DangerOptions ()
7915 //
7916 //****************************************************************************
7917 
CP_DangerOptions(void)7918 void CP_DangerOptions (void)
7919 {
7920    int which;
7921 
7922    DrawDangerMenu ();
7923 
7924    do
7925    {
7926       which = HandleMenu (&DangerItems, &DangerMenu[0], DrawDangerDamageOptionDescription);
7927 
7928       if (which >= 0)
7929 		  BATTLE_Options[gamestate.battlemode].DangerDamage = DangerNums[which];
7930 
7931       MN_DrawButtons (&DangerItems, &DangerMenu[0],
7932 			BATTLE_Options[gamestate.battlemode].DangerDamage, DangerNums);
7933 
7934    } while (which >= 0);
7935 
7936    handlewhich = 100;
7937    DrawBattleOptions ();
7938 }
7939 
7940 
7941 //****************************************************************************
7942 //
7943 // DrawTimeLimitMenu ()
7944 //
7945 //****************************************************************************
7946 
DrawTimeLimitMenu(void)7947 void DrawTimeLimitMenu (void)
7948 {
7949    MenuNum = 1;
7950 
7951    SetAlternateMenuBuf ();
7952    ClearMenuBuf();
7953    SetMenuTitle ("Time Limit");
7954 
7955 
7956    if ( ( gamestate.battlemode != battle_StandAloneGame ) &&
7957       ( consoleplayer == 0 ) )
7958       {
7959       DrawBattleModeName( gamestate.battlemode );
7960       }
7961    MN_DrawButtons (&TimeLimitItems, &TimeLimitMenu[0],
7962 	   BATTLE_Options[gamestate.battlemode].TimeLimit, TimeLimitNums);
7963    MN_GetActive (&TimeLimitItems, &TimeLimitMenu[0],
7964       BATTLE_Options[gamestate.battlemode].TimeLimit, TimeLimitNums);
7965 
7966    if ( gamestate.battlemode == battle_Hunter )
7967       {
7968       TimeLimitMenu[7].active = CP_Inactive; // No time limit
7969       if ( TimeLimitItems.curpos == 7 )
7970          {
7971          TimeLimitMenu[0].active = CP_CursorLocation;
7972          TimeLimitItems.curpos = 0;
7973          }
7974       }
7975 
7976 	DrawMenu (&TimeLimitItems, &TimeLimitMenu[0]);
7977    DrawTimeLimitOptionDescription( TimeLimitItems.curpos );
7978    DisplayInfo (0);
7979    FlipMenuBuf();
7980 }
7981 
7982 
7983 //****************************************************************************
7984 //
7985 // CP_TimeLimitOptions ()
7986 //
7987 //****************************************************************************
7988 
CP_TimeLimitOptions(void)7989 void CP_TimeLimitOptions (void)
7990 {
7991    int which;
7992 
7993    DrawTimeLimitMenu ();
7994 
7995    do
7996    {
7997       which = HandleMenu (&TimeLimitItems, &TimeLimitMenu[0], DrawTimeLimitOptionDescription);
7998 
7999       if (which >= 0)
8000 		  BATTLE_Options[gamestate.battlemode].TimeLimit = TimeLimitNums[which];
8001 
8002       MN_DrawButtons (&TimeLimitItems, &TimeLimitMenu[0],
8003 			BATTLE_Options[gamestate.battlemode].TimeLimit, TimeLimitNums);
8004 
8005    } while (which >= 0);
8006 
8007 	handlewhich = 100;
8008 	DrawBattleOptions ();
8009 }
8010 
PrintBattleOption(boolean inmenu,int x,int y,char * text)8011 void PrintBattleOption
8012    (
8013    boolean inmenu,
8014    int x,
8015    int y,
8016    char *text
8017    )
8018 
8019    {
8020    if ( inmenu )
8021       {
8022       IFont = ( cfont_t * )W_CacheLumpName( "itnyfont", PU_CACHE, Cvt_cfont_t, 1 );
8023       DrawMenuBufIString( x + 1, y + 1, text, 0 );
8024       DrawMenuBufIString( x, y, text, ACTIVECOLOR );
8025       }
8026    else
8027       {
8028       PrintX = x;
8029       PrintY = y;
8030       US_BufPrint( text );
8031       }
8032    }
8033 
ShowBattleOption(boolean inmenu,int PosX,int PosY,int column,int Line,char * text1,char * text2)8034 void ShowBattleOption
8035    (
8036    boolean inmenu,
8037    int PosX,
8038    int PosY,
8039    int column,
8040    int Line,
8041    char *text1,
8042    char *text2
8043    )
8044 
8045    {
8046    char text[ 80 ];
8047    int x;
8048    int y;
8049 
8050    y = PosY + ( Line * 7 );
8051    x = PosX + column * 120;
8052 
8053    PrintBattleOption( inmenu, x, y, text1 );
8054 
8055    strcpy( text, ": " );
8056    strcat( text, text2 );
8057 
8058    PrintBattleOption( inmenu, x + 60, y, text );
8059    }
8060 
ShowBattleOptions(boolean inmenu,int PosX,int PosY)8061 void ShowBattleOptions
8062 	(
8063    boolean inmenu,
8064    int PosX,
8065    int PosY
8066 	)
8067 
8068 	{
8069    battle_type *options;
8070 	battle_type BatOps;
8071    char *string;
8072    char text[ 80 ];
8073    int  width;
8074    int  height;
8075    int  temp;
8076 
8077 	CurrentFont = tinyfont;
8078 
8079    strcpy( text, "CURRENT OPTIONS FOR " );
8080    strcat( text, BattleModeNames[ gamestate.battlemode - battle_Normal ] );
8081 	VW_MeasurePropString ( text, &width, &height );
8082    if ( inmenu )
8083       {
8084       temp = 288;
8085       }
8086    else
8087       {
8088       temp = 320;
8089       }
8090    PrintBattleOption( inmenu, (temp - width)/2, PosY, text );
8091 
8092    PosY++;
8093 
8094    BATTLE_GetOptions( &BatOps );
8095 	options = &BatOps;
8096 
8097    ShowBattleOption( inmenu, PosX, PosY, 0, 1, "Friendly Fire",
8098       ( options->FriendlyFire ) ? "On" : "Off" );
8099 
8100    ShowBattleOption( inmenu, PosX, PosY, 0, 2, "Weapon Persist",
8101       ( options->WeaponPersistence ) ? "On" : "Off" );
8102 
8103    ShowBattleOption( inmenu, PosX, PosY, 0, 3, "Random Weapons",
8104       ( options->RandomWeapons ) ? "On" : "Off" );
8105 
8106    ShowBattleOption( inmenu, PosX, PosY, 0, 4, "Respawn Items",
8107       ( options->RespawnItems ) ? "On" : "Off" );
8108 
8109    ShowBattleOption( inmenu, PosX, PosY, 0, 5, "Spawn Health",
8110       ( options->SpawnHealth ) ? "On" : "Off" );
8111 
8112    ShowBattleOption( inmenu, PosX, PosY, 0, 6, "Spawn Weapons",
8113       ( options->SpawnWeapons ) ? "On" : "Off" );
8114 
8115    ShowBattleOption( inmenu, PosX, PosY, 0, 7, "Spawn Mines",
8116       ( options->SpawnMines ) ? "On" : "Off" );
8117 
8118    ShowBattleOption( inmenu, PosX, PosY, 0, 8, "Spawn Dangers",
8119       ( options->SpawnDangers ) ? "On" : "Off" );
8120 
8121    switch( options->DangerDamage )
8122       {
8123       case bo_danger_low :
8124          string = "Low";
8125          break;
8126 
8127       case bo_danger_normal :
8128          string = "Normal";
8129          break;
8130 
8131       case bo_danger_kill :
8132          string = "Kill";
8133          break;
8134 
8135       default :
8136          itoa( options->DangerDamage, text, 10 );
8137          string = text;
8138       }
8139    ShowBattleOption( inmenu, PosX, PosY, 0, 9, "Danger Damage", string );
8140 
8141    GetMapFileName ( text );
8142    ShowBattleOption( inmenu, PosX, PosY, 0, 10, "Filename", text );
8143 
8144    itoa( numplayers, text, 10 );
8145    ShowBattleOption( inmenu, PosX, PosY, 1, 1, "Players", text );
8146 
8147    if ( options->TimeLimit == bo_time_infinite )
8148       {
8149       string = "None";
8150       }
8151    else
8152       {
8153       itoa( options->TimeLimit, text, 10 );
8154       string = text;
8155       }
8156    ShowBattleOption( inmenu, PosX, PosY, 1, 2, "Time Limit", string );
8157 
8158    if ( ( gamestate.battlemode == battle_Collector ) ||
8159       ( gamestate.battlemode == battle_Scavenger ) )
8160       {
8161       string = "?";
8162       }
8163    else
8164       {
8165       switch( options->Kills )
8166          {
8167          case bo_kills_random :
8168             string = "Random";
8169             break;
8170 
8171          case bo_kills_blind :
8172             string = "Blind";
8173             break;
8174 
8175          case bo_kills_infinite :
8176             string = "Infinite";
8177             break;
8178 
8179          default :
8180             itoa( options->Kills, text, 10 );
8181             string = text;
8182          }
8183       }
8184    ShowBattleOption( inmenu, PosX, PosY, 1, 3, "Point Goal", string );
8185 
8186    switch( options->Ammo )
8187       {
8188       case bo_one_shot :
8189          string = "One shot";
8190          break;
8191 
8192       case bo_normal_shots :
8193          string = "Normal";
8194          break;
8195 
8196       case bo_infinite_shots :
8197          string = "Gunfinity";
8198          break;
8199 		}
8200    ShowBattleOption( inmenu, PosX, PosY, 1, 4, "Ammo", string );
8201 
8202    if ( options->HitPoints == bo_character_hitpoints )
8203       {
8204       string = "Character";
8205       }
8206    else
8207       {
8208       itoa( options->HitPoints, text, 10 );
8209       string = text;
8210       }
8211    ShowBattleOption( inmenu, PosX, PosY, 1, 5, "Hit Points", string );
8212 
8213    itoa( options->RespawnTime, text, 10 );
8214    ShowBattleOption( inmenu, PosX, PosY, 1, 6, "Respawn Time", text );
8215 
8216    switch( options->Speed )
8217       {
8218       case bo_normal_speed :
8219          string = "Normal";
8220          break;
8221 
8222       case bo_fast_speed :
8223          string = "Fast";
8224          break;
8225       }
8226    ShowBattleOption( inmenu, PosX, PosY, 1, 7, "Speed", string );
8227 
8228    switch( options->LightLevel )
8229       {
8230       case bo_light_dark :
8231          string = "Dark";
8232          break;
8233 
8234       case bo_light_normal :
8235          string = "Normal";
8236          break;
8237 
8238       case bo_light_bright :
8239          string = "Bright";
8240          break;
8241 
8242       case bo_light_fog :
8243          string = "Fog";
8244          break;
8245 
8246       case bo_light_periodic :
8247          string = "Periodic";
8248 			break;
8249 
8250       case bo_light_lightning :
8251          string = "Lightning";
8252          break;
8253       }
8254    ShowBattleOption( inmenu, PosX, PosY, 1, 8, "Light", string );
8255 
8256    if ( options->Gravity == NORMAL_GRAVITY )
8257 		{
8258       string = "Normal";
8259       temp = NORMAL_GRAVITY;
8260       }
8261    else if ( options->Gravity < NORMAL_GRAVITY )
8262       {
8263       string = "Low";
8264       temp = LOW_GRAVITY;
8265       }
8266    else
8267       {
8268       string = "High";
8269       temp = HIGH_GRAVITY;
8270       }
8271 
8272    strcpy( text, string );
8273    if ( options->Gravity < (unsigned int)temp )
8274       {
8275       strcat( text, "-" );
8276       }
8277 
8278    if ( options->Gravity > (unsigned int)temp )
8279       {
8280       strcat( text, "+" );
8281       }
8282    ShowBattleOption( inmenu, PosX, PosY, 1, 9, "Gravity", text );
8283    }
8284 
8285 
8286 //****************************************************************************
8287 //
8288 // SetMenuHeader()
8289 //
8290 //****************************************************************************
8291 
SetMenuHeader(char * header)8292 void SetMenuHeader
8293    (
8294    char *header
8295    )
8296 
8297    {
8298    int width;
8299    int height;
8300 
8301    EraseMenuBufRegion( 16, 0, 256, 16 );
8302 
8303    CurrentFont = tinyfont;
8304    VW_MeasurePropString ( header, &width, &height );
8305    DrawMenuBufPropString ( ( 288 - width ) / 2, 4, header );
8306 
8307    RefreshMenuBuf( 0 );
8308    }
8309 
8310 
8311 //****************************************************************************
8312 //
8313 // DrawMultiPageCustomMenu()
8314 //
8315 //****************************************************************************
8316 
DrawMultiPageCustomMenu(char * title,void (* redrawfunc)(void))8317 void DrawMultiPageCustomMenu
8318    (
8319    char *title,
8320    void ( *redrawfunc )( void )
8321    )
8322 
8323    {
8324    SetAlternateMenuBuf();
8325    ClearMenuBuf();
8326    SetMenuTitle( title );
8327 
8328    DrawMenu( &MultiPageCustomItems, &MultiPageCustomMenu[ 0 ] );
8329 
8330    DisplayInfo( 0 );
8331 
8332    if ( redrawfunc != NULL )
8333       {
8334       redrawfunc();
8335       }
8336 
8337    CalcTics();
8338    FlipMenuBuf();
8339 	RefreshMenuBuf( 0 );
8340    }
8341 
8342 
8343 //****************************************************************************
8344 //
8345 // HandleMultiPageCustomMenu()
8346 //
8347 //****************************************************************************
8348 
HandleMultiPageCustomMenu(char ** names,int amount,int curpos,char * title,void (* routine)(int w),void (* redrawfunc)(void),boolean exitonselect)8349 int HandleMultiPageCustomMenu
8350    (
8351    char **names,
8352    int   amount,
8353    int   curpos,
8354    char *title,
8355    void  ( *routine )( int w ),
8356    void ( *redrawfunc )( void ),
8357    boolean exitonselect
8358    )
8359 
8360    {
8361    boolean redraw;
8362    int  page;
8363    int  cursorpos;
8364    int  maxpos;
8365    int  numpos;
8366    int  which;
8367    int  selection;
8368    int  i;
8369    char letter;
8370 
8371    MenuNum = 11;
8372 
8373    cursorpos = curpos % MAXCUSTOM;
8374    page      = curpos - cursorpos;
8375    MultiPageCustomItems.curpos = cursorpos + 2;
8376 
8377    redraw = true;
8378 
8379    do
8380       {
8381       if ( redraw )
8382          {
8383          redraw = false;
8384          MultiPageCustomMenu[ 0 ].active = CP_Active;
8385          MultiPageCustomMenu[ 1 ].active = CP_Active;
8386          if ( page == 0 )
8387             {
8388             MultiPageCustomMenu[ 1 ].active = CP_Inactive;
8389             }
8390 
8391          maxpos = page + MAXCUSTOM;
8392          if ( maxpos >= amount )
8393             {
8394             MultiPageCustomMenu[ 0 ].active = CP_Inactive;
8395             maxpos = amount;
8396             }
8397 
8398          numpos = maxpos - page + 2;
8399          MultiPageCustomItems.amount = numpos;
8400 
8401          for( i = 2; i < numpos; i++ )
8402             {
8403             MultiPageCustomMenu[ i ].active = CP_Active;
8404 
8405             // Set the name of the level
8406             strcpy (MultiPageCustomNames[ i ] , names[ page + i - 2 ]);
8407 
8408             // Set the quick key
8409             letter = *names[ page + i - 2 ];
8410 
8411             // Force it to upper case
8412             if ( ( letter >= 'a' ) && ( letter <= 'z' ) )
8413                {
8414                letter = letter - 'a' + 'A';
8415                }
8416 
8417             // Only use letters
8418             if ( ( letter < 'A' ) || ( letter > 'Z' ) )
8419                {
8420                letter = 'a';
8421                }
8422             MultiPageCustomMenu[ i ].letter = letter;
8423             }
8424 
8425          // If the cursor is at an invalid position, find a valid one
8426          cursorpos = MultiPageCustomItems.curpos;
8427          if ( cursorpos >= numpos )
8428             {
8429             cursorpos = numpos - 1;
8430             }
8431          else
8432             {
8433             while( MultiPageCustomMenu[ cursorpos ].active == CP_Inactive )
8434                {
8435                cursorpos++;
8436                }
8437             }
8438          MultiPageCustomItems.curpos = cursorpos;
8439          MultiPageCustomMenu[ cursorpos ].active = CP_CursorLocation;
8440 
8441          DrawMultiPageCustomMenu( title, redrawfunc );
8442          }
8443 
8444       which = HandleMenu( &MultiPageCustomItems, &MultiPageCustomMenu[ 0 ],
8445          NULL );
8446 
8447       switch( which )
8448          {
8449          case ESCPRESSED :
8450             selection = -1;
8451             break;
8452 
8453          case PAGEDOWN :
8454          case 0 :
8455             page += MAXCUSTOM;
8456             which = 0;
8457             redraw = true;
8458             break;
8459 
8460          case PAGEUP :
8461          case 1 :
8462             page -= MAXCUSTOM;
8463             which = 0;
8464             redraw = true;
8465             break;
8466 
8467          default :
8468             selection = page + which - 2;
8469             if ( routine )
8470                {
8471                routine( selection );
8472                }
8473 
8474             if ( exitonselect )
8475                {
8476                which = -1;
8477                }
8478             break;
8479          }
8480       }
8481    while( which >= 0 );
8482 
8483    return( selection );
8484    }
8485 
8486 
8487 //****************************************************************************
8488 //
8489 // CP_LevelSelectionRedraw()
8490 //
8491 //****************************************************************************
8492 
CP_LevelSelectionRedraw(void)8493 void CP_LevelSelectionRedraw
8494    (
8495    void
8496    )
8497 
8498    {
8499    if ( gamestate.battlemode >= battle_Normal )
8500       {
8501       SetMenuHeader( BattleModeNames[ gamestate.battlemode - battle_Normal ] );
8502       }
8503    }
8504 
8505 
8506 //****************************************************************************
8507 //
8508 // CP_LevelSelectionMenu ()
8509 //
8510 //****************************************************************************
CP_LevelSelectionMenu(void)8511 int CP_LevelSelectionMenu
8512    (
8513    void
8514    )
8515 
8516    {
8517    static char levelcursorpos[ 2 ] = { 0 };
8518 
8519    char *LevelNames[ 100 ];
8520    int   whichlevels;
8521    int   numlevels;
8522    int   level;
8523    int   i;
8524 
8525    whichlevels = 0;
8526    if ( BATTLEMODE )
8527       {
8528       whichlevels = 1;
8529       }
8530 
8531    mapinfo = ( mapfileinfo_t * )SafeMalloc( sizeof( mapfileinfo_t ) );
8532    GetMapInfo( mapinfo );
8533 
8534    numlevels = mapinfo->nummaps;
8535    if ( numlevels <= 0 )
8536       {
8537       Error( "CP_LevelSelectionMenu : No maps found in RTL/RTC file." );
8538       }
8539 
8540    for( i = 0; i < numlevels; i++ )
8541       {
8542       LevelNames[ i ] = mapinfo->maps[ i ].mapname;
8543       }
8544 
8545    level = HandleMultiPageCustomMenu( LevelNames, numlevels,
8546       levelcursorpos[ whichlevels ], "Level Selection", NULL,
8547       CP_LevelSelectionRedraw, true );
8548 
8549    SafeFree( mapinfo );
8550 
8551    if ( level >= 0 )
8552       {
8553       levelcursorpos[ whichlevels ] = level;
8554       }
8555 
8556    return( level );
8557    }
8558 
8559 
8560 //****************************************************************************
8561 //
8562 // DrawEnterCodeNameMenu ()
8563 //
8564 //****************************************************************************
DrawEnterCodeNameMenu(void)8565 void DrawEnterCodeNameMenu
8566    (
8567    void
8568    )
8569 
8570    {
8571 	SetAlternateMenuBuf();
8572    ClearMenuBuf();
8573    SetMenuTitle ("Enter CodeName");
8574 
8575    if ( consoleplayer == 0 )
8576       {
8577       DrawBattleModeName( gamestate.battlemode );
8578       }
8579 
8580    WindowW = 288;
8581    WindowH = 158;
8582    WindowX = 0;
8583    WindowY = 50;
8584    PrintX  = 0;
8585    PrintY  = 50;
8586 
8587    CurrentFont = smallfont;
8588 
8589    MenuBufCPrint( "Enter CodeName\n" );
8590    MenuBufCPrint( "maximum 8 letters\n" );
8591 
8592    DrawSTMenuBuf( ( 288 - 92 ) / 2 - 2, 80 - 2, 92 + 4, 10 + 4, false );
8593 
8594    DrawMenuBufPropString( ( 288 - 92 ) / 2, 80, CodeName );
8595 
8596    WindowX = 144 - ( 9 * 4 );
8597    PrintX  = WindowX;
8598 
8599    FlipMenuBuf();
8600 	RefreshMenuBuf( 0 );
8601    }
8602 
8603 //****************************************************************************
8604 //
8605 // CP_EnterCodeNameMenu ()
8606 //
8607 //****************************************************************************
CP_EnterCodeNameMenu(void)8608 int CP_EnterCodeNameMenu
8609    (
8610    void
8611    )
8612 
8613    {
8614    char input[10];
8615 
8616    DrawEnterCodeNameMenu();
8617 
8618    memset(input,0,sizeof(input));
8619    strcpy(input,CodeName);
8620 
8621 
8622    if (US_LineInput ((288-92)/2, 80, input, input, true, 8, 92, 0))
8623       {
8624       strcpy (&locplayerstate->codename[0], input);
8625       strcpy (CodeName, input);
8626       WaitKeyUp();
8627       return 1;
8628       }
8629    else
8630       {
8631       WaitKeyUp();
8632       return 0;
8633       }
8634    }
8635 
8636 void SS_DrawSBTypeMenu( void );
8637 void SS_SBTypeMenu( void );
8638 void SS_DrawPortMenu( void );
8639 void SS_PortMenu( void );
8640 void SS_Draw8BitDMAMenu( void );
8641 void SS_8BitDMAMenu( void );
8642 void SS_Draw16BitDMAMenu( void );
8643 void SS_16BitDMAMenu( void );
8644 void SS_DrawIrqMenu( void );
8645 void SS_IrqMenu( void );
8646 void SS_Quit( void );
8647 void DrawSoundSetupMainMenu( void );
8648 void CP_SoundSetup( void );
8649 void SS_MusicMenu( void );
8650 void SS_DrawMusicMenu( void );
8651 void SS_SoundMenu( void );
8652 void SS_DrawSoundMenu( void );
8653 void SS_SetupMusicCardMenu( void );
8654 void DrawMusicCardMenu( void );
8655 void SS_SetupSoundBlaster( int sbmenu );
8656 void SS_SetupSoundCardMenu( void );
8657 void SS_VoiceMenu( int sbmenu );
8658 void SS_DrawVoiceMenu( void );
8659 void SS_ChannelMenu( void );
8660 void SS_DrawChannelMenu( void );
8661 void SS_BitMenu( void );
8662 void SS_DrawBitMenu( void );
8663 
8664 extern int musicnums[ 11 ];
8665 extern int fxnums[ 11 ];
8666 
8667 static int midinums[ 12 ]  = {
8668    0x220, 0x230, 0x240, 0x250, 0x300, 0x320,
8669    0x330, 0x332, 0x334, 0x336, 0x340, 0x360
8670    };
8671 static int voicenums[8] = {1, 2, 3, 4, 5, 6, 7, 8};
8672 static int resnums[2]   = {8, 16};
8673 static int smnums[2]    = {1, 2};
8674 
8675 //
8676 // MENU ITEMS
8677 //
8678 CP_MenuNames SoundSetupMenuNames[] =
8679    {
8680    "SETUP SOUND FX",
8681    "SETUP MUSIC",
8682    "SOUND FX VOLUME",
8683    "MUSIC VOLUME",
8684    "QUIT"
8685    };
8686 
8687 CP_iteminfo SoundSetupMenuItems  = { MENU_X, 48, 5, STARTITEM, 32, SoundSetupMenuNames, mn_largefont };
8688 CP_itemtype SoundSetupMenu[] =
8689    {
8690       { CP_CursorLocation, "\0",  'S', (menuptr)SS_SoundMenu },
8691       { CP_Active,         "\0",  'S', (menuptr)SS_MusicMenu },
8692       { CP_Active,         "\0",  'S', (menuptr)FXVolume },
8693       { CP_Active,         "\0",  'M', (menuptr)MusicVolume },
8694       { CP_Active,         "\0",  'Q', (menuptr)SS_Quit }
8695    };
8696 
8697 CP_MenuNames SoundSetupMusicNames[] =
8698    {
8699    "None",
8700    "Ultrasound",
8701    "Sound Blaster",
8702    "Sound Man 16",
8703    "Pro Audio Spectrum",
8704    "AWE 32",
8705    "Soundscape",
8706    "Wave Blaster",
8707    "General Midi",
8708    "Sound Canvas",
8709    "Adlib"
8710    };
8711 
8712 CP_iteminfo SoundSetupMusicItems  = { 44, MENU_Y + 15, 11, STARTITEM, 16, SoundSetupMusicNames, mn_smallfont };
8713 CP_itemtype SoundSetupMusic[] =
8714    {
8715       { CP_CursorLocation, "\0",  'N', (menuptr)SS_SetupMusicCardMenu },
8716       { CP_Active,         "\0",  'U', (menuptr)SS_SetupMusicCardMenu },
8717       { CP_Active,         "\0",  'S', (menuptr)SS_SetupMusicCardMenu },
8718       { CP_Active,         "\0",  'S', (menuptr)SS_SetupMusicCardMenu },
8719       { CP_Active,         "\0",  'P', (menuptr)SS_SetupMusicCardMenu },
8720       { CP_Active,         "\0",  'A', (menuptr)SS_SetupMusicCardMenu },
8721       { CP_Active,         "\0",  'S', (menuptr)SS_SetupMusicCardMenu },
8722       { CP_Active,         "\0",  'W', (menuptr)SS_SetupMusicCardMenu },
8723       { CP_Active,         "\0",  'G', (menuptr)SS_SetupMusicCardMenu },
8724       { CP_Active,         "\0",  'S', (menuptr)SS_SetupMusicCardMenu },
8725       { CP_Active,         "\0",  'A', (menuptr)SS_SetupMusicCardMenu }
8726    };
8727 
8728 
8729 CP_MenuNames SoundSetupSoundNames[] =
8730    {
8731    "None",
8732    "Ultrasound",
8733    "Sound Blaster",
8734    "Sound Man 16",
8735    "Pro Audio Spectrum",
8736    "AWE 32",
8737    "Soundscape",
8738    "Adlib",
8739    "Disney Sound Source",
8740    "Tandy Sound Source",
8741    "PC Speaker"
8742    };
8743 
8744 CP_iteminfo SoundSetupSoundItems  = { MENU_X, MENU_Y + 15, 11, STARTITEM, 16, SoundSetupSoundNames, mn_smallfont };
8745 CP_itemtype SoundSetupSound[] =
8746    {
8747       { CP_CursorLocation, "\0",  'N', (menuptr)SS_SetupSoundCardMenu },
8748       { CP_Active,         "\0",  'U', (menuptr)SS_SetupSoundCardMenu },
8749       { CP_Active,         "\0",  'S', (menuptr)SS_SetupSoundCardMenu },
8750       { CP_Active,         "\0",  'S', (menuptr)SS_SetupSoundCardMenu },
8751       { CP_Active,         "\0",  'P', (menuptr)SS_SetupSoundCardMenu },
8752       { CP_Active,         "\0",  'A', (menuptr)SS_SetupSoundCardMenu },
8753       { CP_Active,         "\0",  'S', (menuptr)SS_SetupSoundCardMenu },
8754       { CP_Active,         "\0",  'A', (menuptr)SS_SetupSoundCardMenu },
8755       { CP_Active,         "\0",  'S', (menuptr)SS_SetupSoundCardMenu },
8756       { CP_Active,         "\0",  'T', (menuptr)SS_SetupSoundCardMenu },
8757       { CP_Active,         "\0",  'P', (menuptr)SS_SetupSoundCardMenu }
8758    };
8759 
8760 CP_MenuNames SoundSetupMidiPortNames[] =
8761    {
8762    "220", "230", "240", "250", "300", "320",
8763    "330", "332", "334", "336", "340", "360"
8764    };
8765 
8766 CP_iteminfo SoundSetupMidiPortItems = { 108, MENU_Y + 10, 12, STARTITEM, 16, SoundSetupMidiPortNames, mn_smallfont };
8767 CP_itemtype SoundSetupMidiPort[] =
8768    {
8769       { CP_Active,         "\0",  'a', NULL },
8770       { CP_Active,         "\0",  'a', NULL },
8771       { CP_Active,         "\0",  'a', NULL },
8772       { CP_Active,         "\0",  'a', NULL },
8773       { CP_Active,         "\0",  'a', NULL },
8774       { CP_CursorLocation, "\0",  'a', NULL },
8775       { CP_Active,         "\0",  'a', NULL },
8776       { CP_Active,         "\0",  'a', NULL },
8777       { CP_Active,         "\0",  'a', NULL },
8778       { CP_Active,         "\0",  'a', NULL },
8779       { CP_Active,         "\0",  'a', NULL },
8780       { CP_Active,         "\0",  'a', NULL }
8781    };
8782 
8783 CP_MenuNames SoundSetupVoiceNames[] =
8784    {
8785    "1 voice",
8786    "2 voices",
8787    "3 voices",
8788    "4 voices",
8789    "5 voices",
8790    "6 voices",
8791    "7 voices",
8792    "8 voices"
8793    };
8794 
8795 CP_iteminfo SoundSetupVoiceItems  = { MENU_X + 36, 24, 8, STARTITEM, 32, SoundSetupVoiceNames, mn_largefont };
8796 CP_itemtype SoundSetupVoice[] =
8797    {
8798       { CP_CursorLocation, "\0",  'a', NULL },
8799       { CP_Active,         "\0",  'a', NULL },
8800       { CP_Active,         "\0",  'a', NULL },
8801       { CP_Active,         "\0",  'a', NULL },
8802       { CP_Active,         "\0",  'a', NULL },
8803       { CP_Active,         "\0",  'a', NULL },
8804       { CP_Active,         "\0",  'a', NULL },
8805       { CP_Active,         "\0",  'a', NULL }
8806    };
8807 
8808 CP_MenuNames SoundSetupChannelNames[] =
8809    {
8810    "  Mono Sound FX",
8811    "Stereo Sound FX"
8812    };
8813 
8814 CP_iteminfo SoundSetupChannelItems  = { MENU_X, MP_Y, 2, STARTITEM, 32, SoundSetupChannelNames, mn_largefont };
8815 CP_itemtype SoundSetupChannel[] =
8816    {
8817       { CP_CursorLocation, "\0",  'M', NULL },
8818       { CP_Active,         "\0",  'S', NULL }
8819    };
8820 
8821 CP_MenuNames SoundSetupResolutionNames[] =
8822    {
8823    "8 Bit Mixing",
8824    "16 Bit Mixing"
8825    };
8826 
8827 CP_iteminfo SoundSetupResolutionItems  = { MENU_X, MP_Y, 2, STARTITEM, 32, SoundSetupResolutionNames, mn_largefont };
8828 CP_itemtype SoundSetupResolution[] =
8829    {
8830       { CP_CursorLocation, "\0",  'a', NULL },
8831       { CP_Active,         "\0",  'b', NULL }
8832    };
8833 
8834 static int typenums[ 5 ] =
8835    {
8836    fx_SB, fx_SB20, fx_SBPro, fx_SBPro2, fx_SB16
8837    };
8838 
8839 static char typetostring[ 6 ] =
8840    {
8841    5, 0, 2, 1, 3, 4
8842    };
8843 
8844 #define UNDEFINED -1
8845 
8846 CP_MenuNames TypeNames[] =
8847    {
8848    "Sound Blaster or compatible",
8849    "Sound Blaster 2.0",
8850    "Sound Blaster Pro (old)",
8851    "Sound Blaster Pro 2.0 (new)",
8852    "Sound Blaster 16 or AWE32",
8853    "Undefined"
8854    };
8855 
8856 CP_iteminfo TypeItems  = { MENU_X - 13, MENU_Y + 36, 5, STARTITEM, 10, TypeNames, mn_smallfont };
8857 CP_itemtype TypeMenu[] =
8858    {
8859       { CP_CursorLocation, "\0",  'S', NULL },
8860       { CP_Active,         "\0",  'S', NULL },
8861       { CP_Active,         "\0",  'S', NULL },
8862       { CP_Active,         "\0",  'S', NULL },
8863       { CP_Active,         "\0",  'S', NULL }
8864    };
8865 
8866 static int portnums[ 7 ] =
8867    {
8868    0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0x280
8869    };
8870 
8871 CP_MenuNames PortNames[] =
8872    {
8873    "210", "220", "230", "240", "250", "260", "280"
8874    };
8875 
8876 CP_iteminfo PortItems = { 92, 32, 7, STARTITEM, 32, PortNames, mn_largefont };
8877 CP_itemtype PortMenu [] =
8878    {
8879       { CP_CursorLocation, "\0",  '2', NULL },
8880       { CP_Active,         "\0",  '2', NULL },
8881       { CP_Active,         "\0",  '2', NULL },
8882       { CP_Active,         "\0",  '2', NULL },
8883       { CP_Active,         "\0",  '2', NULL },
8884       { CP_Active,         "\0",  '2', NULL },
8885       { CP_Active,         "\0",  '2', NULL }
8886    };
8887 
8888 static int _8BitDMAnums[ 3 ] =
8889    {
8890    0, 1, 3
8891    };
8892 
8893 CP_MenuNames _8BitDMANames[] =
8894    {
8895    "DMA channel 0",
8896    "DMA channel 1",
8897    "DMA channel 3"
8898    };
8899 
8900 CP_iteminfo _8BitDMAItems = { 32, 60, 3, STARTITEM, 32, _8BitDMANames, mn_largefont };
8901 CP_itemtype _8BitDMAMenu [] =
8902    {
8903       { CP_CursorLocation, "\0",  '0', NULL },
8904       { CP_Active,         "\0",  '1', NULL },
8905       { CP_Active,         "\0",  '3', NULL }
8906    };
8907 
8908 static int _16BitDMAnums[ 3 ] =
8909    {
8910    5, 6, 7
8911    };
8912 
8913 CP_MenuNames _16BitDMANames[] =
8914    {
8915    "DMA channel 5",
8916    "DMA channel 6",
8917    "DMA channel 7"
8918    };
8919 
8920 CP_iteminfo _16BitDMAItems = { 32, 60, 3, STARTITEM, 32, _16BitDMANames, mn_largefont };
8921 CP_itemtype _16BitDMAMenu [] =
8922    {
8923       { CP_CursorLocation, "\0",  '5', NULL },
8924       { CP_Active,         "\0",  '6', NULL },
8925       { CP_Active,         "\0",  '7', NULL }
8926    };
8927 
8928 static int irqnums[ 8 ] =
8929    {
8930    2, 3, 5, 7, 10, 11, 12, 15
8931    };
8932 
8933 CP_MenuNames IrqNames[] =
8934    {
8935    "IRQ 2",
8936    "IRQ 3",
8937    "IRQ 5",
8938    "IRQ 7",
8939    "IRQ 10",
8940    "IRQ 11",
8941    "IRQ 12",
8942    "IRQ 15"
8943    };
8944 
8945 CP_iteminfo IrqItems = { 82, 24, 8, STARTITEM, 32, IrqNames, mn_largefont };
8946 CP_itemtype IrqMenu [] =
8947    {
8948       { CP_CursorLocation, "\0",  'a', NULL },
8949       { CP_Active,         "\0",  'a', NULL },
8950       { CP_Active,         "\0",  'a', NULL },
8951       { CP_Active,         "\0",  'a', NULL },
8952       { CP_Active,         "\0",  'a', NULL },
8953       { CP_Active,         "\0",  'a', NULL },
8954       { CP_Active,         "\0",  'a', NULL },
8955       { CP_Active,         "\0",  'a', NULL }
8956    };
8957 
8958 CP_MenuNames SBSetupNames[] =
8959    {
8960    "Use Current Settings",
8961    "Custom Setup"
8962    };
8963 
8964 CP_iteminfo SBSetupItems  = { MENU_X - 11, MENU_Y + 76, 2, STARTITEM, 19, SBSetupNames, mn_largefont };
8965 CP_itemtype SBSetupMenu[] =
8966    {
8967       { CP_CursorLocation, "\0",  'U', SS_SetupSoundBlaster },
8968       { CP_Active,         "\0",  'C', (menuptr)SS_SBTypeMenu },
8969    };
8970 
8971 extern fx_blaster_config SBSettings;
8972 
8973 //******************************************************************************
8974 //
8975 // SS_DrawSBSetupMenu()
8976 //
8977 //******************************************************************************
8978 
SS_DrawSBSetupMenu(void)8979 void SS_DrawSBSetupMenu
8980    (
8981    void
8982    )
8983 
8984    {
8985    char text[ 80 ];
8986    char num[ 10 ];
8987    char *undefined;
8988 
8989    MenuNum = SNDCARDS;
8990    SetAlternateMenuBuf();
8991    ClearMenuBuf();
8992    SetMenuTitle( "Sound Blaster Setup" );
8993 
8994    WindowW = 288;
8995    WindowH = 158;
8996    WindowX = 96;
8997    WindowY = 32;
8998    PrintX  = 0;
8999    PrintY  = 32;
9000 
9001    CurrentFont = tinyfont;
9002 
9003    undefined = "Undefined";
9004 
9005    SBSetupMenu[ 0 ].active = CP_Active;
9006 
9007    PrintBattleOption( true, WindowX + 16, PrintY, "Current Settings:" );
9008    PrintY += 9;
9009 
9010    strcpy( text, "Card Type : " );
9011 
9012    if ( ( SBSettings.Type < fx_SB ) || ( SBSettings.Type > fx_SB16 ) )
9013       {
9014       SBSettings.Type = UNDEFINED;
9015       strcat( text, undefined );
9016       SBSetupMenu[ 0 ].active = CP_Inactive;
9017       }
9018    else
9019       {
9020 	  strcat( text, TypeNames[ (unsigned int)typetostring[ SBSettings.Type ] ] );
9021       }
9022 
9023    PrintBattleOption( true, WindowX, PrintY, text );
9024    PrintY += 6;
9025 
9026    strcpy( text, "Port : " );
9027    if ( SBSettings.Address != (unsigned long)UNDEFINED )
9028       {
9029       itoa( SBSettings.Address, num, 16 );
9030       strcat( text, num );
9031       }
9032    else
9033       {
9034       strcat( text, undefined );
9035       SBSetupMenu[ 0 ].active = CP_Inactive;
9036       }
9037 
9038    PrintBattleOption( true, WindowX + 19, PrintY, text );
9039    PrintY += 6;
9040 
9041    strcpy( text, "IRQ : " );
9042    if ( SBSettings.Interrupt != (unsigned long)UNDEFINED )
9043       {
9044       itoa( SBSettings.Interrupt, num, 10 );
9045       strcat( text, num );
9046       }
9047    else
9048       {
9049       strcat( text, undefined );
9050       SBSetupMenu[ 0 ].active = CP_Inactive;
9051       }
9052    PrintBattleOption( true, WindowX + 23, PrintY, text );
9053    PrintY += 6;
9054 
9055    strcpy( text, "DMA : " );
9056    if ( SBSettings.Dma8 != (unsigned long)UNDEFINED )
9057       {
9058       itoa( SBSettings.Dma8, num, 10 );
9059       strcat( text, num );
9060       }
9061    else
9062       {
9063       strcat( text, undefined );
9064       SBSetupMenu[ 0 ].active = CP_Inactive;
9065       }
9066    PrintBattleOption( true, WindowX + 21, PrintY, text );
9067    PrintY += 6;
9068 
9069    strcpy( text, "16-Bit DMA : " );
9070    if ( SBSettings.Dma16 != (unsigned long)UNDEFINED )
9071       {
9072       itoa( SBSettings.Dma16, num, 10 );
9073       strcat( text, num );
9074       }
9075    else
9076       {
9077       strcat( text, undefined );
9078       }
9079    PrintBattleOption( true, WindowX - 4, PrintY, text );
9080    PrintY += 6;
9081 
9082    MN_GetCursorLocation( &SBSetupItems, &SBSetupMenu[ 0 ] );
9083    DrawMenu( &SBSetupItems, &SBSetupMenu[ 0 ] );
9084    DisplayInfo( 0 );
9085 
9086    FlipMenuBuf();
9087    RefreshMenuBuf( 0 );
9088    }
9089 
9090 
9091 //******************************************************************************
9092 //
9093 // SS_DrawSBTypeMenu()
9094 //
9095 //******************************************************************************
9096 
SS_DrawSBTypeMenu(void)9097 void SS_DrawSBTypeMenu
9098    (
9099    void
9100    )
9101 
9102    {
9103    MenuNum = SNDCARDS;
9104    SetAlternateMenuBuf();
9105    ClearMenuBuf();
9106    SetMenuTitle( "Select Sound Blaster Type" );
9107    MN_GetActive( &TypeItems, &TypeMenu[ 0 ], SBSettings.Type, typenums );
9108    DrawMenu( &TypeItems, &TypeMenu[ 0 ] );
9109    DisplayInfo( 0 );
9110 
9111    FlipMenuBuf();
9112    }
9113 
9114 //******************************************************************************
9115 //
9116 // SS_SBTypeMenu()
9117 //
9118 //******************************************************************************
9119 
SS_SBTypeMenu(void)9120 void SS_SBTypeMenu
9121    (
9122    void
9123    )
9124 
9125    {
9126    int which;
9127 
9128    do
9129       {
9130       SS_DrawSBTypeMenu();
9131       which = HandleMenu( &TypeItems, &TypeMenu[0], NULL );
9132       if ( which >= 0 )
9133          {
9134          SBSettings.Type = typenums[ which ];
9135          SS_PortMenu();
9136          if ( handlewhich == -1 )
9137             {
9138             continue;
9139             }
9140          return;
9141          }
9142       }
9143    while( which >= 0 );
9144 
9145    handlewhich = -2;
9146    }
9147 
9148 //******************************************************************************
9149 //
9150 // SS_DrawPortMenu()
9151 //
9152 //******************************************************************************
9153 
SS_DrawPortMenu(void)9154 void SS_DrawPortMenu
9155    (
9156    void
9157    )
9158 
9159    {
9160    MenuNum = SNDCARDS;
9161    SetAlternateMenuBuf();
9162    ClearMenuBuf();
9163    SetMenuTitle( "Select Sound Blaster Port" );
9164    MN_GetActive( &PortItems, &PortMenu[ 0 ], SBSettings.Address, portnums );
9165    DrawMenu( &PortItems, &PortMenu[ 0 ] );
9166    DisplayInfo( 0 );
9167 
9168    FlipMenuBuf();
9169    }
9170 
9171 //******************************************************************************
9172 //
9173 // SS_PortMenu()
9174 //
9175 //******************************************************************************
9176 
SS_PortMenu(void)9177 void SS_PortMenu
9178    (
9179    void
9180    )
9181 
9182    {
9183    int which;
9184 
9185    do
9186       {
9187       SS_DrawPortMenu();
9188       which = HandleMenu( &PortItems, &PortMenu[0], NULL );
9189       if ( which >= 0 )
9190          {
9191          SBSettings.Address = portnums[ which ];
9192          SBSettings.Emu = SBSettings.Address;
9193          SS_8BitDMAMenu();
9194          if ( handlewhich == -1 )
9195             {
9196             continue;
9197             }
9198          return;
9199          }
9200       }
9201    while( which >= 0 );
9202 
9203    handlewhich = -1;
9204    }
9205 
9206 //******************************************************************************
9207 //
9208 // SS_Draw8BitDMAMenu()
9209 //
9210 //******************************************************************************
9211 
SS_Draw8BitDMAMenu(void)9212 void SS_Draw8BitDMAMenu
9213    (
9214    void
9215    )
9216 
9217    {
9218    MenuNum = SNDCARDS;
9219    SetAlternateMenuBuf();
9220    ClearMenuBuf();
9221    SetMenuTitle( "Select 8-bit DMA Channel" );
9222    MN_GetActive( &_8BitDMAItems, &_8BitDMAMenu[ 0 ], SBSettings.Dma8, _8BitDMAnums );
9223    DrawMenu( &_8BitDMAItems, &_8BitDMAMenu[ 0 ] );
9224    DisplayInfo( 0 );
9225 
9226    FlipMenuBuf();
9227    }
9228 
9229 //******************************************************************************
9230 //
9231 // SS_8BitDMAMenu()
9232 //
9233 //******************************************************************************
9234 
SS_8BitDMAMenu(void)9235 void SS_8BitDMAMenu
9236    (
9237    void
9238    )
9239 
9240    {
9241    int which;
9242 
9243    do
9244       {
9245       SS_Draw8BitDMAMenu();
9246       which = HandleMenu( &_8BitDMAItems, &_8BitDMAMenu[0], NULL );
9247       if ( which >= 0 )
9248          {
9249          SBSettings.Dma8 = _8BitDMAnums[ which ];
9250          SS_16BitDMAMenu();
9251          if ( handlewhich == -1 )
9252             {
9253             continue;
9254             }
9255          return;
9256          }
9257       }
9258    while( which >= 0 );
9259 
9260    handlewhich = -1;
9261    }
9262 
9263 //******************************************************************************
9264 //
9265 // SS_Draw16BitDMAMenu()
9266 //
9267 //******************************************************************************
9268 
SS_Draw16BitDMAMenu(void)9269 void SS_Draw16BitDMAMenu
9270    (
9271    void
9272    )
9273 
9274    {
9275    MenuNum = SNDCARDS;
9276    SetAlternateMenuBuf();
9277    ClearMenuBuf();
9278    SetMenuTitle( "Select 16-bit DMA Channel" );
9279    MN_GetActive( &_16BitDMAItems, &_16BitDMAMenu[ 0 ], SBSettings.Dma16, _16BitDMAnums );
9280    DrawMenu( &_16BitDMAItems, &_16BitDMAMenu[ 0 ] );
9281    DisplayInfo( 0 );
9282 
9283    FlipMenuBuf();
9284    }
9285 
9286 //******************************************************************************
9287 //
9288 // SS_16BitDMAMenu()
9289 //
9290 //******************************************************************************
9291 
SS_16BitDMAMenu(void)9292 void SS_16BitDMAMenu
9293    (
9294    void
9295    )
9296 
9297    {
9298    int which;
9299 
9300    if ( SBSettings.Type != fx_SB16 )
9301       {
9302       SS_IrqMenu();
9303       return;
9304       }
9305 
9306    do
9307       {
9308       SS_Draw16BitDMAMenu();
9309       which = HandleMenu( &_16BitDMAItems, &_16BitDMAMenu[0], NULL );
9310       if ( which >= 0 )
9311          {
9312          SBSettings.Dma16 = _16BitDMAnums[ which ];
9313          SS_IrqMenu();
9314          if ( handlewhich == -1 )
9315             {
9316             continue;
9317             }
9318          return;
9319          }
9320       }
9321    while( which >= 0 );
9322 
9323    handlewhich = -1;
9324    }
9325 
9326 //******************************************************************************
9327 //
9328 // SS_DrawIrqMenu()
9329 //
9330 //******************************************************************************
9331 
SS_DrawIrqMenu(void)9332 void SS_DrawIrqMenu
9333    (
9334    void
9335    )
9336 
9337    {
9338    MenuNum = SNDCARDS;
9339    SetAlternateMenuBuf();
9340    ClearMenuBuf();
9341    SetMenuTitle( "Select Sound Blaster IRQ" );
9342    MN_GetActive( &IrqItems, &IrqMenu[ 0 ], SBSettings.Interrupt, irqnums );
9343    DrawMenu( &IrqItems, &IrqMenu[ 0 ] );
9344    DisplayInfo( 0 );
9345 
9346    FlipMenuBuf();
9347    }
9348 
9349 //******************************************************************************
9350 //
9351 // SS_IrqMenu()
9352 //
9353 //******************************************************************************
9354 
SS_IrqMenu(void)9355 void SS_IrqMenu
9356    (
9357    void
9358    )
9359 
9360    {
9361    int which;
9362 
9363    do
9364       {
9365       SS_DrawIrqMenu();
9366       which = HandleMenu( &IrqItems, &IrqMenu[0], NULL );
9367 
9368       if ( which >= 0 )
9369          {
9370          SBSettings.Interrupt = irqnums[ which ];
9371          SS_SetupSoundBlaster( true );
9372 
9373          if ( handlewhich == -1 )
9374             {
9375             continue;
9376             }
9377 
9378          return;
9379          }
9380       }
9381    while( which >= 0 );
9382 
9383    handlewhich = -1;
9384    }
9385 
9386 
9387 //******************************************************************************
9388 //
9389 // GetNextWord()
9390 //
9391 //******************************************************************************
GetNextWord(char * dest,char * source,int length)9392 char *GetNextWord
9393    (
9394    char *dest,
9395    char *source,
9396    int  length
9397    )
9398 
9399    {
9400    while( ( *source != 0 ) && ( isspace( *source ) ) && ( length > 0 ) )
9401       {
9402       *dest = *source;
9403       length--;
9404       dest++;
9405       source++;
9406       }
9407 
9408    while( ( *source != 0 ) && ( !isspace( *source ) ) && ( length > 0 ) )
9409       {
9410       *dest = *source;
9411       length--;
9412       dest++;
9413       source++;
9414       }
9415 
9416    *dest = 0;
9417    return( source );
9418    }
9419 
9420 //******************************************************************************
9421 //
9422 // CP_ErrorMsg()
9423 //
9424 //******************************************************************************
9425 
CP_ErrorMsg(char * title,char * error,int font)9426 void CP_ErrorMsg
9427    (
9428    char *title,
9429    char *error,
9430    int font
9431    )
9432 
9433    {
9434    char wordtext[ 80 ];
9435    char text[ 10 ][ 80 ];
9436    int  pos;
9437    int  length;
9438    int  line;
9439    int  w;
9440    int  h;
9441    int  y;
9442    extern void VWL_MeasureIntensityString (char *s, int *width, int *height, cfont_t *font);
9443 
9444    SetAlternateMenuBuf();
9445    ClearMenuBuf();
9446    SetMenuTitle( title );
9447 
9448    WindowW = 288;
9449    WindowH = 158;
9450    WindowX = 0;
9451    WindowY = 40;
9452 
9453    IFont = ( cfont_t * )W_CacheLumpName( FontNames[ font ], PU_CACHE, Cvt_cfont_t, 1 );
9454 
9455    pos = 0;
9456    line = 0;
9457 
9458    text[ 0 ][ 0 ] = 0;
9459 
9460    while( *error != 0 )
9461       {
9462       error = GetNextWord( wordtext, error, 79 );
9463 
9464       pos = 0;
9465       while( ( wordtext[ pos ] != 0 ) && ( isspace( wordtext[ pos ] ) ) )
9466          {
9467          pos++;
9468          }
9469 
9470       length = strlen( text[ line ] );
9471       if ( length == 0 )
9472          {
9473          strcat( text[ line ], &wordtext[ pos ] );
9474          }
9475       else
9476          {
9477          strcat( text[ line ], wordtext );
9478          }
9479 
9480       VWL_MeasureIntensityString( text[ line ], &w, &h, IFont );
9481 
9482       if ( w > WindowW - 32 )
9483          {
9484          text[ line ][ length ] = 0;
9485          if ( line >= 10 )
9486             {
9487             break;
9488             }
9489          line++;
9490          strcpy( text[ line ], &wordtext[ pos ] );
9491          }
9492       }
9493 
9494    if ( strlen( text[ line ] ) == 0 )
9495       {
9496       line--;
9497       }
9498 
9499    VWL_MeasureIntensityString( text[ 0 ], &w, &h, IFont );
9500 
9501    y = ( WindowH - ( line + 1 ) * h ) / 2;
9502 
9503    for( pos = 0; pos <= line; pos++ )
9504       {
9505       VWL_MeasureIntensityString( text[ pos ], &w, &h, IFont );
9506       DrawMenuBufIString( ( 288 - w ) / 2, y, text[ pos ], ACTIVECOLOR );
9507       y += h;
9508       }
9509 
9510    DisplayInfo( 5 );
9511    FlipMenuBuf();
9512    RefreshMenuBuf( 0 );
9513 
9514    IN_Ack();
9515    WaitKeyUp();
9516 
9517    MN_PlayMenuSnd( SD_ESCPRESSEDSND );
9518    }
9519 
9520 //****************************************************************************
9521 //
9522 // DrawSoundSetupMainMenu ()
9523 //
9524 //****************************************************************************
DrawSoundSetupMainMenu(void)9525 void DrawSoundSetupMainMenu
9526    (
9527    void
9528    )
9529 
9530    {
9531    MenuNum = 1;
9532 
9533    SetAlternateMenuBuf();
9534    ClearMenuBuf();
9535    SetMenuTitle( "Sound Setup" );
9536    if ( FXMode == 0 )
9537       {
9538       SoundSetupMenu[ 2 ].active = CP_Inactive;
9539       }
9540    else if ( SoundSetupMenu[ 2 ].active == CP_Inactive )
9541       {
9542       SoundSetupMenu[ 2 ].active = CP_Active;
9543       }
9544 
9545    if ( MusicMode == 0 )
9546       {
9547       SoundSetupMenu[ 3 ].active = CP_Inactive;
9548       }
9549    else if ( SoundSetupMenu[ 3 ].active == CP_Inactive )
9550       {
9551       SoundSetupMenu[ 3 ].active = CP_Active;
9552       }
9553 
9554    MN_GetCursorLocation( &SoundSetupMenuItems, &SoundSetupMenu[ 0 ] );
9555    DrawMenu( &SoundSetupMenuItems, &SoundSetupMenu[ 0 ] );
9556    DisplayInfo( 0 );
9557 
9558    FlipMenuBuf();
9559    }
9560 
9561 
9562 //******************************************************************************
9563 //
9564 // Sound Setup Quit
9565 //
9566 //******************************************************************************
9567 
SS_Quit(void)9568 void SS_Quit
9569    (
9570    void
9571    )
9572 
9573    {
9574    extern boolean WriteSoundFile;
9575 
9576    CP_DisplayMsg( "Do you wish to\nsave your changes?\n"
9577       "Press ESC to return\nto sound setup.", 12 );
9578 
9579    if ( CP_Acknowledge != CP_ESC )
9580       {
9581       WriteSoundFile = true;
9582       if ( CP_Acknowledge == CP_NO )
9583          {
9584          WriteSoundFile = false;
9585          }
9586 
9587       MU_FadeOut(310);
9588       VL_FadeOut (0, 255, 0, 0, 0, 10);
9589       ShutdownMenuBuf();
9590       QuitGame ();
9591       }
9592 
9593    DrawSoundSetupMainMenu();
9594    }
9595 
9596 //******************************************************************************
9597 //
9598 // Sound Setup
9599 //
9600 //******************************************************************************
9601 
CP_SoundSetup(void)9602 void CP_SoundSetup ( void )
9603    {
9604    int which;
9605    extern boolean WriteSoundFile;
9606 
9607    WriteSoundFile = false;
9608 
9609    SetupMenuBuf();
9610    DrawSoundSetupMainMenu();
9611    IN_ClearKeysDown();
9612 
9613    if ( MusicMode != 0 )
9614       {
9615       MU_StartSong( song_title );
9616       }
9617 
9618    while( 1 )
9619       {
9620       which = HandleMenu( &SoundSetupMenuItems, SoundSetupMenu, NULL );
9621       if ( which == -1 )
9622          {
9623          SS_Quit();
9624          }
9625       }
9626    }
9627 
9628 //******************************************************************************
9629 //
9630 // SS_MusicMenu ()
9631 //
9632 //******************************************************************************
9633 
SS_MusicMenu(void)9634 void SS_MusicMenu
9635    (
9636    void
9637    )
9638 
9639    {
9640    int which;
9641 
9642    MN_MakeActive( &SoundSetupMusicItems, &SoundSetupMusic[ 0 ], MusicMode );
9643 
9644    SS_DrawMusicMenu ();
9645    IN_ClearKeysDown();
9646 
9647    do
9648       {
9649       which = HandleMenu( &SoundSetupMusicItems, &SoundSetupMusic[ 0 ], NULL );
9650       }
9651    while( which > 0 );
9652 
9653    DrawSoundSetupMainMenu();
9654    handlewhich = RETURNVAL;
9655    }
9656 
9657 
9658 //******************************************************************************
9659 //
9660 // SS_DrawMusicMenu ()
9661 //
9662 //******************************************************************************
9663 
SS_DrawMusicMenu(void)9664 void SS_DrawMusicMenu
9665    (
9666    void
9667    )
9668 
9669    {
9670    MenuNum = SNDCARDS;
9671 
9672    SetAlternateMenuBuf();
9673    ClearMenuBuf();
9674    SetMenuTitle( "Select Music Card" );
9675 
9676    MN_GetCursorLocation( &SoundSetupMusicItems, &SoundSetupMusic[ 0 ] );
9677    DrawMenu( &SoundSetupMusicItems, &SoundSetupMusic[ 0 ] );
9678    DisplayInfo( 0 );
9679 
9680    FlipMenuBuf();
9681    }
9682 
9683 
9684 //******************************************************************************
9685 //
9686 // SS_SetupMusicCardMenu()
9687 //
9688 //******************************************************************************
9689 
SS_SetupMusicCardMenu(void)9690 void SS_SetupMusicCardMenu
9691    (
9692    void
9693    )
9694 
9695    {
9696    int status;
9697    int select;
9698    if ( ( ( musicnums[ handlewhich ] == SoundBlaster ) ||
9699       ( musicnums[ handlewhich ] == WaveBlaster ) ||
9700       ( musicnums[ handlewhich ] == Awe32 ) ) &&
9701       ( fxnums[ FXMode ] != SoundBlaster ) &&
9702       ( fxnums[ FXMode ] != Awe32 ) )
9703       {
9704       CP_ErrorMsg( "Music Error",
9705          "Please set your Sound FX card to Sound Blaster before "
9706          "selecting this card for music.", mn_smallfont );
9707 
9708       handlewhich = -1;
9709       return;
9710       }
9711 
9712    MusicMode = handlewhich;
9713 
9714    MU_Shutdown();
9715 
9716    if ( ( musicnums[ MusicMode ] == GenMidi ) ||
9717       ( musicnums[ MusicMode ] == SoundCanvas ) ||
9718       ( musicnums[ MusicMode ] == WaveBlaster ) ||
9719       ( musicnums[ MusicMode ] == Awe32 ) )
9720       {
9721       DrawMusicCardMenu();
9722 
9723       IN_ClearKeysDown ();
9724 
9725       select = HandleMenu( &SoundSetupMidiPortItems,
9726          &SoundSetupMidiPort[0], NULL );
9727 
9728       if ( select > -1 )
9729          {
9730          MidiAddress = midinums[ select ];
9731          }
9732       else
9733          {
9734          SS_DrawMusicMenu ();
9735          handlewhich = RETURNVAL;
9736          MusicMode = 0;
9737          return;
9738          }
9739       }
9740 
9741    if ( MusicMode != 0 )
9742       {
9743       if ( ( musicnums[ handlewhich ] == WaveBlaster ) ||
9744          ( musicnums[ handlewhich ] == Awe32 ) )
9745          {
9746          SD_Shutdown();
9747          }
9748 
9749       SetAlternateMenuBuf();
9750       ClearMenuBuf();
9751       SetMenuTitle( "Music Card Initialization" );
9752       WindowW = 288;
9753       WindowH = 158;
9754       PrintX = WindowX = 0;
9755       PrintY = WindowY = 65;
9756       newfont1 = (font_t *)W_CacheLumpName( "newfnt1", PU_CACHE, Cvt_font_t, 1 );
9757       CurrentFont = newfont1;
9758       MenuBufCPrint( "Initializing card.\nPlease wait." );
9759       FlipMenuBuf();
9760       RefreshMenuBuf( 0 );
9761 
9762       status = MU_Startup( false );
9763       if ( status )
9764          {
9765          MusicMode = 0;
9766 
9767          CP_ErrorMsg( "Music Error", MUSIC_ErrorString( MUSIC_Error ),
9768             mn_smallfont );
9769          SS_DrawMusicMenu ();
9770          handlewhich = RETURNVAL;
9771          }
9772       else
9773          {
9774          handlewhich = -1;
9775          MU_StartSong( song_title );
9776          }
9777 
9778       if ( ( musicnums[ MusicMode ] == WaveBlaster ) ||
9779          ( musicnums[ MusicMode ] == Awe32 ) )
9780          {
9781          status = SD_Startup( false );
9782             if ( status != FX_Ok )
9783             {
9784             CP_ErrorMsg( "Sound FX Error", FX_ErrorString( FX_Error ),
9785                mn_smallfont );
9786 
9787             handlewhich = -2;
9788             }
9789          }
9790       }
9791    else
9792       {
9793       handlewhich = -1;
9794       MU_Shutdown();
9795       }
9796    }
9797 
9798 
9799 //******************************************************************************
9800 //
9801 // DrawMusicCardMenu()
9802 //
9803 //******************************************************************************
9804 
DrawMusicCardMenu(void)9805 void DrawMusicCardMenu
9806    (
9807    void
9808    )
9809 
9810    {
9811    MenuNum = SNDCARDS;
9812    SetAlternateMenuBuf();
9813    ClearMenuBuf();
9814    SetMenuTitle( "Select MIDI Port Address" );
9815    MN_GetActive( &SoundSetupMidiPortItems, &SoundSetupMidiPort[ 0 ],
9816       MidiAddress, midinums );
9817    DrawMenu( &SoundSetupMidiPortItems, &SoundSetupMidiPort[ 0 ] );
9818    DisplayInfo( 0 );
9819 
9820    FlipMenuBuf();
9821    }
9822 
9823 //******************************************************************************
9824 //
9825 // SS_SoundMenu ()
9826 //
9827 //******************************************************************************
9828 
SS_SoundMenu(void)9829 void SS_SoundMenu
9830    (
9831    void
9832    )
9833 
9834    {
9835    int which;
9836 
9837    MN_MakeActive( &SoundSetupSoundItems, &SoundSetupSound[0], FXMode );
9838 
9839    SS_DrawSoundMenu ();
9840    IN_ClearKeysDown();
9841 
9842    do {
9843       which = HandleMenu( &SoundSetupSoundItems, &SoundSetupSound[ 0 ], NULL );
9844       }
9845    while( which >= 0 );
9846 
9847    DrawSoundSetupMainMenu();
9848    handlewhich = RETURNVAL;
9849    }
9850 
9851 
9852 //******************************************************************************
9853 //
9854 // SS_DrawSoundMenu ()
9855 //
9856 //******************************************************************************
9857 
SS_DrawSoundMenu(void)9858 void SS_DrawSoundMenu
9859    (
9860    void
9861    )
9862 
9863    {
9864    MenuNum = SNDCARDS;
9865 
9866    SetAlternateMenuBuf();
9867    ClearMenuBuf();
9868    SetMenuTitle ("Select Sound FX Card");
9869 
9870    MN_GetCursorLocation( &SoundSetupSoundItems, &SoundSetupSound[0] );
9871 
9872    DrawMenu( &SoundSetupSoundItems, &SoundSetupSound[ 0 ] );
9873    DisplayInfo( 0 );
9874 
9875    FlipMenuBuf();
9876    }
9877 
9878 
9879 //******************************************************************************
9880 //
9881 // SS_SetupSoundBlaster()
9882 //
9883 //******************************************************************************
9884 
SS_SetupSoundBlaster(int sbmenu)9885 void SS_SetupSoundBlaster
9886    (
9887    int sbmenu
9888    )
9889 
9890    {
9891    int status;
9892 
9893    status = FX_SetupSoundBlaster( SBSettings, &MaxVoices,
9894       &MaxBits, &MaxChannels );
9895 
9896    if ( status == FX_Ok )
9897       {
9898       SS_VoiceMenu( sbmenu );
9899 
9900       if ( handlewhich < 0 )
9901          {
9902          return;
9903          }
9904       SetAlternateMenuBuf();
9905       ClearMenuBuf();
9906       SetMenuTitle( "Sound Card Initialization" );
9907       WindowW = 288;
9908       WindowH = 158;
9909       PrintX = WindowX = 0;
9910       PrintY = WindowY = 65;
9911       newfont1 = (font_t *)W_CacheLumpName( "newfnt1", PU_CACHE, Cvt_font_t, 1 );
9912       CurrentFont = newfont1;
9913       MenuBufCPrint( "Initializing card.\nPlease wait." );
9914       FlipMenuBuf();
9915       RefreshMenuBuf( 0 );
9916 
9917       status = SD_Startup( false );
9918 
9919       RefreshMenuBuf( 0 );
9920       }
9921 
9922    if ( status != FX_Ok )
9923       {
9924       CP_ErrorMsg( "Sound FX Error", FX_ErrorString( FX_Error ),
9925          mn_smallfont );
9926 
9927       handlewhich = -2;
9928       }
9929    }
9930 
9931 
9932 //******************************************************************************
9933 //
9934 // SS_SetupSoundCardMenu()
9935 //
9936 //******************************************************************************
9937 
SS_SetupSoundCardMenu(void)9938 void SS_SetupSoundCardMenu
9939    (
9940    void
9941    )
9942 
9943    {
9944    int which;
9945    int FXstatus;
9946    extern int fxnums[];
9947 
9948    INFXSETUP = true;
9949 
9950    FXMode = handlewhich;
9951 
9952    SD_Shutdown();
9953 
9954    if ( FXMode == 0 )
9955       {
9956       handlewhich = -1;
9957       }
9958    else
9959       {
9960       if ( ( fxnums[ FXMode ] == SoundBlaster ) ||
9961          ( fxnums[ FXMode ] == Awe32 ) )
9962          {
9963          do
9964             {
9965             SS_DrawSBSetupMenu();
9966             which = HandleMenu( &SBSetupItems, &SBSetupMenu[ 0 ], NULL );
9967             }
9968          while( which == -2 );
9969 
9970          if ( which == -1 )
9971             {
9972             FXMode = 0;
9973             handlewhich = 0;
9974             SS_DrawSoundMenu();
9975             }
9976          else
9977             {
9978             handlewhich = -1;
9979             }
9980 
9981          INFXSETUP = false;
9982          return;
9983          }
9984 
9985       FXstatus = SD_SetupFXCard( &MaxVoices, &MaxBits, &MaxChannels );
9986       if ( FXstatus == FX_Ok )
9987          {
9988          SS_VoiceMenu( true );
9989 
9990          if ( handlewhich == -1 )
9991             {
9992             SS_DrawSoundMenu ();
9993             handlewhich = RETURNVAL;
9994             FXMode = 0;
9995             SD_Shutdown ();
9996             INFXSETUP = false;
9997             return;
9998             }
9999 
10000          SetAlternateMenuBuf();
10001          ClearMenuBuf();
10002          SetMenuTitle( "Sound Card Initialization" );
10003          WindowW = 288;
10004          WindowH = 158;
10005          PrintX = WindowX = 0;
10006          PrintY = WindowY = 65;
10007          newfont1 = (font_t *)W_CacheLumpName( "newfnt1", PU_CACHE, Cvt_font_t, 1 );
10008          CurrentFont = newfont1;
10009          MenuBufCPrint( "Initializing card.\nPlease wait." );
10010          FlipMenuBuf();
10011          RefreshMenuBuf( 0 );
10012 
10013          FXstatus = SD_Startup( false );
10014 
10015          RefreshMenuBuf( 0 );
10016          }
10017 
10018       if ( FXstatus != FX_Ok )
10019          {
10020          FXMode = 0;
10021          handlewhich = RETURNVAL;
10022 
10023          CP_ErrorMsg( "Sound FX Error", FX_ErrorString( FX_Error ),
10024             mn_smallfont );
10025          SS_DrawSoundMenu();
10026          }
10027       else
10028          {
10029          handlewhich = -1;
10030          }
10031       }
10032 
10033    INFXSETUP = false;
10034    }
10035 
10036 
10037 //******************************************************************************
10038 //
10039 // SS_VoiceMenu ()
10040 //
10041 //******************************************************************************
10042 
SS_VoiceMenu(int sbmenu)10043 void SS_VoiceMenu
10044    (
10045    int sbmenu
10046    )
10047 
10048    {
10049    int which;
10050 
10051    if ( MaxVoices < 2 )
10052       {
10053       NumVoices = 1;
10054       SS_ChannelMenu();
10055       return;
10056       }
10057 
10058    do
10059       {
10060       SS_DrawVoiceMenu ();
10061 
10062       which = HandleMenu( &SoundSetupVoiceItems, &SoundSetupVoice[0],
10063          NULL );
10064       if ( which >= 0 )
10065          {
10066          NumVoices = voicenums[ which ];
10067          SS_ChannelMenu();
10068          if ( handlewhich == -1 )
10069             {
10070             continue;
10071             }
10072          return;
10073          }
10074       }
10075    while( which >= 0 );
10076 
10077    if ( sbmenu )
10078       {
10079       handlewhich = -1;
10080       }
10081    else
10082       {
10083       handlewhich = -2;
10084       }
10085    }
10086 
10087 //******************************************************************************
10088 //
10089 // SS_DrawVoiceMenu()
10090 //
10091 //******************************************************************************
10092 
SS_DrawVoiceMenu(void)10093 void SS_DrawVoiceMenu
10094    (
10095    void
10096    )
10097 
10098    {
10099    MenuNum = SNDCARDS;
10100 
10101    SetAlternateMenuBuf();
10102    ClearMenuBuf();
10103    SetMenuTitle ("Number of Voices");
10104 
10105    MN_GetActive( &SoundSetupVoiceItems, &SoundSetupVoice[0],
10106       NumVoices, voicenums );
10107 
10108    DrawMenu( &SoundSetupVoiceItems, &SoundSetupVoice[ 0 ] );
10109    DisplayInfo( 0 );
10110 
10111    FlipMenuBuf();
10112    }
10113 
10114 //******************************************************************************
10115 //
10116 // SS_ChannelMenu ()
10117 //
10118 //******************************************************************************
10119 
SS_ChannelMenu(void)10120 void SS_ChannelMenu
10121    (
10122    void
10123    )
10124 
10125    {
10126    int which;
10127 
10128    if ( MaxChannels < 2 )
10129       {
10130       NumChannels = 1;
10131       SS_BitMenu();
10132       return;
10133       }
10134 
10135    do
10136       {
10137       SS_DrawChannelMenu ();
10138       which = HandleMenu( &SoundSetupChannelItems, &SoundSetupChannel[0],
10139          NULL );
10140       if ( which >= 0 )
10141          {
10142          NumChannels = smnums[ which ];
10143          SS_BitMenu();
10144          if ( handlewhich == -1 )
10145             {
10146             continue;
10147             }
10148          return;
10149          }
10150       }
10151    while( which >= 0 );
10152 
10153    handlewhich = -1;
10154    }
10155 
10156 //******************************************************************************
10157 //
10158 // SS_DrawChannelMenu()
10159 //
10160 //******************************************************************************
10161 
SS_DrawChannelMenu(void)10162 void SS_DrawChannelMenu
10163    (
10164    void
10165    )
10166 
10167    {
10168    MenuNum = SNDCARDS;
10169 
10170    SetAlternateMenuBuf();
10171    ClearMenuBuf();
10172    SetMenuTitle ("Number of Channels");
10173 
10174    MN_GetActive( &SoundSetupChannelItems, &SoundSetupChannel[0],
10175       NumChannels, smnums );
10176 
10177    DrawMenu( &SoundSetupChannelItems, &SoundSetupChannel[ 0 ] );
10178    DisplayInfo( 0 );
10179 
10180    FlipMenuBuf();
10181    }
10182 
10183 //******************************************************************************
10184 //
10185 // SS_BitMenu ()
10186 //
10187 //******************************************************************************
10188 
SS_BitMenu(void)10189 void SS_BitMenu
10190    (
10191    void
10192    )
10193 
10194    {
10195    int which;
10196 
10197    if ( MaxBits < 16 )
10198       {
10199       NumBits = 8;
10200       return;
10201       }
10202 
10203    SS_DrawBitMenu ();
10204 
10205    which = HandleMenu( &SoundSetupResolutionItems,
10206       &SoundSetupResolution[0], NULL );
10207 
10208    if ( which >= 0 )
10209       {
10210       NumBits = resnums[ which ];
10211       return;
10212       }
10213 
10214    handlewhich = -1;
10215    }
10216 
10217 
10218 //******************************************************************************
10219 //
10220 // SS_DrawBitMenu()
10221 //
10222 //******************************************************************************
10223 
SS_DrawBitMenu(void)10224 void SS_DrawBitMenu
10225    (
10226    void
10227    )
10228 
10229    {
10230    MenuNum = SNDCARDS;
10231 
10232    SetAlternateMenuBuf();
10233    ClearMenuBuf();
10234    SetMenuTitle ("Playback Resolution");
10235 
10236    MN_GetActive( &SoundSetupResolutionItems, &SoundSetupResolution[0],
10237       NumBits, resnums );
10238 
10239    DrawMenu( &SoundSetupResolutionItems, &SoundSetupResolution[ 0 ] );
10240    DisplayInfo( 0 );
10241 
10242    FlipMenuBuf();
10243    }
10244