1 /* Reconstructed Commander Keen 4-6 Source Code
\r
2 * Copyright (C) 2021 K1n9_Duk3
\r
4 * This file is primarily based on:
\r
5 * Catacomb 3-D Source Code
\r
6 * Copyright (C) 1993-2014 Flat Rock Software
\r
8 * This program is free software; you can redistribute it and/or modify
\r
9 * it under the terms of the GNU General Public License as published by
\r
10 * the Free Software Foundation; either version 2 of the License, or
\r
11 * (at your option) any later version.
\r
13 * This program is distributed in the hope that it will be useful,
\r
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 * GNU General Public License for more details.
\r
18 * You should have received a copy of the GNU General Public License along
\r
19 * with this program; if not, write to the Free Software Foundation, Inc.,
\r
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
25 // ID_US.c - User Manager - User interface
\r
27 // By Jason Blochowiak
\r
28 // Hacked up for Catacomb 3D
\r
31 #include "ID_HEADS.H"
\r
37 extern boolean showscorebox;
\r
39 extern boolean jerk;
\r
40 extern boolean oldshooting;
\r
41 extern ScanCode firescan;
\r
42 void USL_CheckSavedGames(void);
\r
48 boolean ingame,abortgame,loadedgame;
\r
49 GameDiff restartgame = gd_Continue;
\r
51 // Internal variables
\r
52 static boolean GameIsDirty,
\r
58 boolean checkpassed;
\r
61 // Forward reference prototypes
\r
62 static void USL_SetupCard(void);
\r
64 // Control panel data
\r
66 #define CtlPanelSX 74
\r
67 #define CtlPanelSY 48
\r
68 #define CtlPanelEX 234
\r
69 #define CtlPanelEY 150
\r
70 #define CtlPanelW (CtlPanelEX - CtlPanelSX)
\r
71 #define CtlPanelH (CtlPanelEY - CtlPanelSY)
\r
80 #define HiliteColor (BackColor ^ 3)
\r
81 #define NohiliteColor (BackColor ^ 2)
\r
86 #define HiliteColor (BackColor ^ 10)
\r
87 #define NohiliteColor (BackColor ^ 2)
\r
89 #endif // if GRMODE == CGAGR ... else ...
\r
97 #define HiliteColor (BackColor ^ 12)
\r
98 #define NohiliteColor (BackColor ^ 4)
\r
116 uii_Button,uii_RadioButton,uii_Folder
\r
126 #define UISelectFlags (ui_Pushed | ui_Selected | ui_Disabled)
\r
130 uic_SetupCard,uic_DrawCard,uic_TouchupCard,
\r
131 uic_DrawIcon,uic_Draw,uic_Hit
\r
134 typedef struct UserItem
\r
141 void far *child; // Should be (UserItemGroup *)
\r
145 typedef struct UserItemGroup
\r
150 UserItem far *items;
\r
151 boolean (*custom)(UserCall,struct UserItem far *); // Custom routine
\r
154 struct UserItemGroup far *parent;
\r
157 static char *BottomS1,*BottomS2,*BottomS3;
\r
158 static UComm Communication;
\r
159 static ScanCode *KeyMaps[] =
\r
161 &KbdDefs[0].button0,
\r
162 &KbdDefs[0].button1,
\r
164 &KbdDefs[0].upleft,
\r
166 &KbdDefs[0].upright,
\r
168 &KbdDefs[0].downright,
\r
170 &KbdDefs[0].downleft,
\r
174 // Custom routine prototypes
\r
175 static boolean USL_ConfigCustom(UserCall call,struct UserItem far *item),
\r
176 USL_KeyCustom(UserCall call,struct UserItem far *item),
\r
177 USL_KeySCustom(UserCall call,struct UserItem far *item),
\r
178 USL_Joy1Custom(UserCall call,struct UserItem far *item),
\r
179 USL_Joy2Custom(UserCall call,struct UserItem far *item),
\r
180 USL_JoyGCustom(UserCall call,struct UserItem far *item),
\r
181 USL_LoadCustom(UserCall call,struct UserItem far *item),
\r
182 USL_SaveCustom(UserCall call,struct UserItem far *item),
\r
183 USL_ScoreCustom(UserCall call,struct UserItem far *item),
\r
184 USL_CompCustom(UserCall call,struct UserItem far *item),
\r
185 USL_SmoothCustom(UserCall call,struct UserItem far *item),
\r
187 USL_TwoCustom(UserCall call,struct UserItem far *item),
\r
189 USL_PongCustom(UserCall call,struct UserItem far *item);
\r
191 #define DefButton(key,text) uii_Button,ui_Normal,key,text
\r
192 #define DefRButton(key,text) uii_RadioButton,ui_Normal,key,text
\r
193 #define DefFolder(key,text,child) uii_Folder,ui_Normal,key,text,uc_None,child
\r
194 #define CustomGroup(title,key,custom) 0,0,title,key,0,custom
\r
195 UserItem far holder[] =
\r
197 {DefButton(sc_None,"DEBUG")},
\r
200 UserItemGroup far holdergroup = {0,0,CP_MAINMENUPIC,sc_None,holder};
\r
203 UserItem far soundi[] =
\r
205 {DefRButton(sc_N,"NO SOUND EFFECTS")},
\r
206 {DefRButton(sc_P,"PC SPEAKER")},
\r
207 {DefRButton(sc_A,"ADLIB/SOUNDBLASTER")},
\r
208 {DefRButton(sc_Q,"QUIET ADLIB/SOUNDBLASTER")},
\r
211 UserItemGroup far soundgroup = {8,0,CP_SOUNDMENUPIC,sc_None,soundi};
\r
214 UserItem far musici[] =
\r
216 {DefRButton(sc_N,"NO MUSIC")},
\r
217 {DefRButton(sc_A,"ADLIB/SOUNDBLASTER")},
\r
220 UserItemGroup far musicgroup = {8,0,CP_MUSICMENUPIC,sc_None,musici};
\r
223 UserItem far newgamei[] =
\r
225 {DefButton(sc_E,"BEGIN EASY GAME"),uc_SEasy},
\r
226 {DefButton(sc_N,"BEGIN NORMAL GAME"),uc_SNormal},
\r
227 {DefButton(sc_H,"BEGIN HARD GAME"),uc_SHard},
\r
230 UserItemGroup far newgamegroup = {8,0,CP_NEWGAMEMENUPIC,sc_None,newgamei,0,1};
\r
232 // Load/Save game menu
\r
233 UserItem far loadsavegamei[] =
\r
236 {uii_Button,ui_Normal,sc_None},
\r
237 {uii_Button,ui_Normal,sc_None},
\r
238 {uii_Button,ui_Normal,sc_None},
\r
239 {uii_Button,ui_Normal,sc_None},
\r
240 {uii_Button,ui_Normal,sc_None},
\r
241 {uii_Button,ui_Normal,sc_None},
\r
243 {uii_Button,ui_Normal,sc_1},
\r
244 {uii_Button,ui_Normal,sc_2},
\r
245 {uii_Button,ui_Normal,sc_3},
\r
246 {uii_Button,ui_Normal,sc_4},
\r
247 {uii_Button,ui_Normal,sc_5},
\r
248 {uii_Button,ui_Normal,sc_6},
\r
252 UserItemGroup far loadgamegroup = {4,3,CP_LOADMENUPIC,sc_None,loadsavegamei,USL_LoadCustom};
\r
253 UserItemGroup far savegamegroup = {4,3,CP_SAVEMENUPIC,sc_None,loadsavegamei,USL_SaveCustom};
\r
256 UserItemGroup far scoregroup = {0,0,0,sc_None,0,USL_ScoreCustom};
\r
258 UserItemGroup far twogroup = {0,0,0,sc_None,0,USL_TwoCustom};
\r
260 #if GRMODE != CGAGR
\r
261 UserItemGroup far smoothgroup = {0,0,0,sc_None,0,USL_SmoothCustom};
\r
262 UserItemGroup far compgroup = {0,0,0,sc_None,0,USL_CompCustom};
\r
265 UserItem far optionsi[] =
\r
267 {DefFolder(sc_S,"",&scoregroup)},
\r
269 {DefFolder(sc_T,"",&twogroup)},
\r
271 #if GRMODE != CGAGR
\r
272 {DefFolder(sc_M,"",&smoothgroup)},
\r
273 {DefFolder(sc_C,"",&compgroup)},
\r
277 UserItemGroup far optionsgroup = {8,0,CP_OPTIONSMENUPIC,sc_None,optionsi};
\r
280 UserItem far keyi[] =
\r
282 {DefButton(sc_None,"UP & LEFT")},
\r
283 {DefButton(sc_None,"UP")},
\r
284 {DefButton(sc_None,"UP & RIGHT")},
\r
285 {DefButton(sc_None,"RIGHT")},
\r
286 {DefButton(sc_None,"DOWN & RIGHT")},
\r
287 {DefButton(sc_None,"DOWN")},
\r
288 {DefButton(sc_None,"DOWN & LEFT")},
\r
289 {DefButton(sc_None,"LEFT")},
\r
292 UserItemGroup far keygroup = {0,0,CP_KEYMOVEMENTPIC,sc_None,keyi,USL_KeyCustom};
\r
293 UserItem far keybi[] =
\r
296 {DefButton(sc_J,"JUMP")},
\r
297 {DefButton(sc_P,"POGO")},
\r
298 {DefButton(sc_F,"FIRE")},
\r
301 {DefButton(sc_J,"FIRE")},
\r
302 {DefButton(sc_P,"STRAFE")},
\r
305 {DefButton(sc_J,"SHOOT")},
\r
306 {DefButton(sc_P,"BOMB")},
\r
310 UserItemGroup far keybgroup = {0,0,CP_KEYBUTTONPIC,sc_None,keybi,USL_KeyCustom};
\r
311 UserItem far keysi[] =
\r
313 {DefFolder(sc_M,"MOVEMENT",&keygroup)},
\r
314 {DefFolder(sc_B,"BUTTONS",&keybgroup)},
\r
317 UserItemGroup far keysgroup = {8,0,CP_KEYBOARDMENUPIC,sc_None,keysi,USL_KeySCustom};
\r
319 // Joystick #1 & #2
\r
320 UserItemGroup far joy1group = {CustomGroup(CP_JOYSTICKMENUPIC,sc_None,USL_Joy1Custom)};
\r
321 UserItemGroup far joy2group = {CustomGroup(CP_JOYSTICKMENUPIC,sc_None,USL_Joy2Custom)};
\r
322 UserItemGroup far gravisgroup = {CustomGroup(CP_JOYSTICKMENUPIC,sc_None,USL_JoyGCustom)};
\r
325 UserItem far configi[] =
\r
327 {DefFolder(sc_S,"SOUND",&soundgroup)},
\r
328 {DefFolder(sc_M,"MUSIC",&musicgroup)},
\r
330 {DefFolder(sc_O,"OPTIONS",&optionsgroup)},
\r
332 {uii_Folder,ui_Separated,sc_K,"USE KEYBOARD",uc_None,&keysgroup},
\r
333 {DefFolder(sc_1,"USE JOYSTICK #1",&joy1group)},
\r
334 {DefFolder(sc_2,"USE JOYSTICK #2",&joy2group)},
\r
335 {DefFolder(sc_G,"",&gravisgroup)},
\r
339 UserItemGroup far configgroup = {8,0,CP_CONFIGMENUPIC,sc_None,configi,USL_ConfigCustom};
\r
341 UserItemGroup far configgroup = {0,0,CP_CONFIGMENUPIC,sc_None,configi,USL_ConfigCustom};
\r
345 UserItemGroup far ponggroup = {0,0,0,sc_None,0,USL_PongCustom};
\r
346 UserItem far rooti[] =
\r
348 {DefFolder(sc_N,"NEW GAME",&newgamegroup)},
\r
349 {DefFolder(sc_L,"LOAD GAME",&loadgamegroup)},
\r
350 {DefFolder(sc_S,"SAVE GAME",&savegamegroup)},
\r
351 {DefFolder(sc_C,"CONFIGURE",&configgroup)},
\r
352 {DefButton(sc_R,nil),uc_Return}, // Return to Game/Demo
\r
353 {DefButton(sc_E,"END GAME"),uc_Abort},
\r
355 {DefFolder(sc_P,"PADDLE WAR",&ponggroup)},
\r
356 #elif defined CAT3D
\r
357 {DefFolder(sc_B,"SKULL 'N' BONES",&ponggroup)},
\r
359 {DefButton(sc_Q,"QUIT"),uc_Quit},
\r
362 UserItemGroup far rootgroup = {32,4,CP_MAINMENUPIC,sc_None,rooti};
\r
368 UserItemGroup far *cardstack[MaxCards],
\r
373 USL_SetupStack(void)
\r
376 cardstack[0] = topcard = &rootgroup;
\r
385 topcard = cardstack[--cstackptr];
\r
389 USL_PushCard(UserItemGroup far *card)
\r
391 if (cstackptr == MaxCards - 1)
\r
394 topcard = cardstack[++cstackptr] = card;
\r
398 USL_DrawItemIcon(UserItem far *item)
\r
402 if (topcard->custom && topcard->custom(uic_DrawIcon,item))
\r
405 flags = item->flags;
\r
406 if (flags & ui_Disabled)
\r
407 tile = TileBase + ((flags & ui_Selected)? 5 : 4);
\r
408 else if ((item->type == uii_RadioButton) && (!(flags & ui_Pushed)))
\r
409 tile = TileBase + ((flags & ui_Selected)? 3 : 2);
\r
411 tile = TileBase + ((flags & ui_Selected)? 1 : 0);
\r
412 VWB_DrawTile8(item->x,item->y,tile);
\r
416 USL_DrawItem(UserItem far *item)
\r
418 if (topcard->custom && topcard->custom(uic_Draw,item))
\r
421 VWB_Bar(CtlPanelSX + 1,item->y,
\r
422 CtlPanelEX - CtlPanelSX - 1,8,BackColor); // Clear out background
\r
423 USL_DrawItemIcon(item);
\r
424 if ((item->flags & ui_Selected) && !(item->flags & ui_Disabled))
\r
425 fontcolor = HiliteColor;
\r
427 fontcolor = NohiliteColor;
\r
430 USL_DrawString(item->text);
\r
431 fontcolor = F_BLACK;
\r
435 #if GRMODE == CGAGR
\r
436 #define MyLine(y) VWB_Hlin(CtlPanelSX + 3,CtlPanelEX - 3,y,3);
\r
438 #define MyLine(y) VWB_Hlin(CtlPanelSX + 3,CtlPanelEX - 3,y,10);
\r
441 #define MyLine(y) VWB_Hlin(CtlPanelSX + 3,CtlPanelEX - 3,y,12);
\r
445 USL_DrawBottom(void)
\r
449 fontcolor = NohiliteColor;
\r
451 px = CtlPanelSX + 4;
\r
452 py = CtlPanelEY - 15;
\r
453 USL_DrawString(BottomS1);
\r
455 USL_MeasureString(BottomS2,&w,&h);
\r
456 px = CtlPanelEX - 4 - w;
\r
457 USL_DrawString(BottomS2);
\r
459 USL_MeasureString(BottomS3,&w,&h);
\r
460 px = CtlPanelSX + ((CtlPanelEX - CtlPanelSX - w) / 2);
\r
462 USL_DrawString(BottomS3);
\r
464 fontcolor = F_WHITE;
\r
465 MyLine(CtlPanelEY - 17);
\r
469 USL_DrawCtlPanelContents(void)
\r
472 UserItem far *item;
\r
474 if (topcard->custom && topcard->custom(uic_DrawCard,nil))
\r
477 if (topcard->title)
\r
480 MyLine(CtlPanelSY + 7);
\r
481 VWB_DrawPic(CtlPanelSX + 6,CtlPanelSY,topcard->title);
\r
486 if (!topcard->items)
\r
489 x = topcard->x + CtlPanelSX;
\r
492 y = topcard->y + CtlPanelSY + 12;
\r
493 for (item = topcard->items;item->type != uii_Bad;item++)
\r
495 if (item->flags & ui_Separated)
\r
500 USL_DrawItem(item);
\r
503 if (topcard->custom)
\r
504 topcard->custom(uic_TouchupCard,nil);
\r
508 USL_DrawCtlPanel(void)
\r
510 if (topcard->items || topcard->title)
\r
512 // Draw the backdrop
\r
513 VWB_DrawPic(0,0,CP_MENUSCREENPIC);
\r
515 // Draw the contents
\r
516 USL_DrawCtlPanelContents();
\r
519 // Refresh the screen
\r
524 USL_DialogSetup(word w,word h,word *x,word *y)
\r
526 VWB_DrawMPic(CtlPanelSX,CtlPanelSY,CP_MENUMASKPICM);
\r
528 *x = CtlPanelSX + ((CtlPanelW - w) / 2);
\r
529 *y = CtlPanelSY + ((CtlPanelH - h) / 2);
\r
530 VWB_Bar(*x,*y,w + 1,h + 1,BackColor);
\r
531 VWB_Hlin(*x - 1,*x + w + 1,*y - 1,NohiliteColor);
\r
532 VWB_Hlin(*x - 1,*x + w + 1,*y + h + 1,NohiliteColor);
\r
533 VWB_Vlin(*y - 1,*y + h + 1,*x - 1,NohiliteColor);
\r
534 VWB_Vlin(*y - 1,*y + h + 1,*x + w + 1,NohiliteColor);
\r
538 USL_ShowLoadSave(char *s,char *name)
\r
543 char msg[MaxGameName + 4];
\r
548 USL_MeasureString(s,&sw,&h);
\r
549 USL_MeasureString(msg,&w,&h);
\r
550 tw = ((sw > w)? sw : w) + 6;
\r
551 USL_DialogSetup(tw,(h * 2) + 2,&x,&y);
\r
553 px = x + ((tw - sw) / 2);
\r
556 px = x + ((tw - w) / 2);
\r
557 USL_DrawString(msg);
\r
561 IN_UserInput(100, true);
\r
566 USL_CtlDialog(char *s1,char *s2,char *s3)
\r
572 CursorInfo cursorinfo;
\r
574 USL_MeasureString(s1,&w1,&h);
\r
575 USL_MeasureString(s2,&w2,&h);
\r
577 USL_MeasureString(s3,&w3,&h);
\r
580 w = (w1 > w2)? ((w1 > w3)? w1 : w3) : ((w2 > w3)? w2 : w3);
\r
585 USL_DialogSetup(w,h,&x,&y);
\r
587 fontcolor = HiliteColor;
\r
588 px = x + ((w - w1) / 2);
\r
590 USL_DrawString(s1);
\r
591 py += (sh * 2) - 1;
\r
593 VWB_Hlin(x + 3,x + w - 3,py,NohiliteColor);
\r
596 fontcolor = NohiliteColor;
\r
597 px = x + ((w - w2) / 2);
\r
598 USL_DrawString(s2);
\r
603 px = x + ((w - w3) / 2);
\r
604 USL_DrawString(s3);
\r
609 IN_ClearKeysDown();
\r
612 IN_ReadCursor(&cursorinfo);
\r
613 if (cursorinfo.button0)
\r
615 else if (cursorinfo.button1)
\r
619 } while (c == sc_None);
\r
622 IN_ReadCursor(&cursorinfo);
\r
623 } while (cursorinfo.button0 || cursorinfo.button1);
\r
625 IN_ClearKeysDown();
\r
626 USL_DrawCtlPanel();
\r
631 USL_ConfirmComm(UComm comm)
\r
633 boolean confirm,dialog;
\r
637 Quit("USL_ConfirmComm() - empty comm");
\r
641 s3 = "ESC TO BACK OUT";
\r
645 s1 = "REALLY END CURRENT GAME?";
\r
646 s2 = "PRESS Y TO END IT";
\r
647 if (ingame && GameIsDirty)
\r
651 s1 = "REALLY QUIT?";
\r
652 s2 = "PRESS Y TO QUIT";
\r
656 s1 = "YOU'RE IN A GAME";
\r
657 s2 = "PRESS Y TO LOAD GAME";
\r
658 if (ingame && GameIsDirty)
\r
664 s1 = "YOU'RE IN A GAME";
\r
665 s2 = "PRESS Y FOR NEW GAME";
\r
666 if (ingame && GameIsDirty)
\r
671 confirm = dialog? USL_CtlDialog(s1,s2,s3) : true;
\r
674 Communication = comm;
\r
675 CtlPanelDone = true;
\r
680 ///////////////////////////////////////////////////////////////////////////
\r
682 // USL_HandleError() - Handles telling the user that there's been an error
\r
684 ///////////////////////////////////////////////////////////////////////////
\r
686 USL_HandleError(int num)
\r
690 strcpy(buf,"Error: ");
\r
692 strcat(buf,"Unknown");
\r
693 else if (num == ENOMEM)
\r
694 strcat(buf,"Disk is Full");
\r
695 else if (num == EINVFMT)
\r
696 strcat(buf,"File is Incomplete");
\r
698 strcat(buf,sys_errlist[num]);
\r
702 USL_CtlDialog(buf,"PRESS ANY KEY",nil);
\r
705 IN_ClearKeysDown();
\r
715 USL_GenericCustom(UserCall call,UserItem far *item)
\r
728 USL_SetOptionsText(void)
\r
730 optionsi[0].text = showscorebox? "SCORE BOX (ON)" : "SCORE BOX (OFF)";
\r
731 optionsi[1].text = oldshooting? "TWO-BUTTON FIRING (ON)" : "TWO-BUTTON FIRING (OFF)";
\r
732 #if GRMODE != CGAGR
\r
733 optionsi[2].text = jerk? "FIX JERKY MOTION (ON)" : "FIX JERKY MOTION (OFF)";
\r
734 optionsi[3].text = compatability? "SVGA COMPATIBILITY (ON)" : "SVGA COMPATIBILITY (OFF)";
\r
737 keybi[2].flags &= ~ui_Disabled;
\r
739 keybi[2].flags |= ui_Disabled;
\r
741 // gravis option is only enabled when a joystick is selected
\r
742 configi[6].flags |= ui_Disabled;
\r
743 if (Controls[0] == ctrl_Joystick1 || Controls[0] == ctrl_Joystick2)
\r
744 configi[6].flags &= ~ui_Disabled;
\r
746 configi[6].text = GravisGamepad? "USE GRAVIS GAMEPAD (ON)" : "USE GRAVIS GAMEPAD (OFF)";
\r
751 USL_ScoreCustom(UserCall call,UserItem far *item)
\r
753 if (call != uic_SetupCard)
\r
756 showscorebox ^= true;
\r
757 USL_CtlDialog(showscorebox? "Score box now on" : "Score box now off",
\r
758 "Press any key",nil);
\r
759 USL_SetOptionsText();
\r
765 USL_SmoothCustom(UserCall call,UserItem far *item)
\r
767 if (call != uic_SetupCard)
\r
771 USL_CtlDialog(jerk? "Jerky motion fix enabled" : "Jerky motion fix disabled",
\r
772 "Press any key",nil);
\r
773 USL_SetOptionsText();
\r
779 USL_CompCustom(UserCall call,UserItem far *item)
\r
781 if (call != uic_SetupCard)
\r
784 compatability ^= true;
\r
785 USL_CtlDialog(compatability? "SVGA compatibility now on" : "SVGA compatibility now off",
\r
786 "Press any key",nil);
\r
787 USL_SetOptionsText();
\r
794 USL_TwoCustom(UserCall call,UserItem far *item)
\r
796 if (call != uic_SetupCard)
\r
799 oldshooting ^= true;
\r
800 USL_CtlDialog(oldshooting? "Two-button firing now on" : "Two-button firing now off",
\r
801 "Press any key",nil);
\r
802 USL_SetOptionsText();
\r
808 USL_ConfigCustom(UserCall call,UserItem far *item)
\r
810 static char *CtlNames[] = {"KEYBOARD","KEYBOARD","JOYSTICK #1","JOYSTICK #2","MOUSE"};
\r
815 if (call == uic_TouchupCard)
\r
818 USL_MeasureString(s,&w,&h);
\r
820 USL_MeasureString(CtlNames[Controls[0]],&w,&h);
\r
822 py = CtlPanelEY - 18 - h;
\r
823 px = CtlPanelSX + ((CtlPanelW - tw) / 2);
\r
824 fontcolor = NohiliteColor;
\r
826 USL_DrawString(CtlNames[Controls[0]]);
\r
828 item++; // Shut the compiler up
\r
833 USL_CKSetKey(UserItem far *item,word i)
\r
839 CursorInfo cursorinfo;
\r
843 LastScan = sc_None;
\r
844 fontcolor = HiliteColor;
\r
847 if (TimeCount >= time)
\r
850 VWB_Bar(item->x + 90,item->y,40,8,fontcolor ^ BackColor);
\r
851 VWB_Bar(item->x + 90 + 1,item->y + 1,40 - 2,8 - 2,BackColor);
\r
853 VWB_DrawTile8(item->x + 90 + 16,item->y,TileBase + 8);
\r
856 time = TimeCount + (TickBase / 2);
\r
859 IN_ReadCursor(&cursorinfo);
\r
860 while (cursorinfo.button0 || cursorinfo.button1)
\r
862 IN_ReadCursor(&cursorinfo);
\r
863 LastScan = sc_Escape;
\r
868 if (LastScan == sc_LShift)
\r
869 LastScan = sc_None;
\r
871 } while (!(scan = LastScan));
\r
873 if (scan != sc_Escape)
\r
875 for (j = 0,on = false;j < 11;j++)
\r
879 if (*(KeyMaps[j]) == scan)
\r
887 USL_CtlDialog("Key already used","Press any key",nil);
\r
889 USL_CtlDialog("Key already used","Press a key",nil);
\r
892 *(KeyMaps[i]) = scan;
\r
894 IN_ClearKeysDown();
\r
899 USL_KeySCustom(UserCall call,UserItem far *item)
\r
901 if (call == uic_SetupCard)
\r
903 Controls[0] = ctrl_Keyboard;
\r
904 GravisGamepad = false;
\r
905 USL_SetOptionsText();
\r
912 USL_KeyCustom(UserCall call,UserItem far *item)
\r
918 i = (topcard == &keygroup)? (3 + (item - keyi)) : (item - keybi);
\r
921 case uic_SetupCard:
\r
922 Controls[0] = ctrl_Keyboard;
\r
925 VWB_Bar(CtlPanelSX + 1,item->y,
\r
926 CtlPanelEX - CtlPanelSX - 1,8,BackColor); // Clear out background
\r
927 USL_DrawItemIcon(item);
\r
928 fontcolor = (item->flags & ui_Selected)? HiliteColor : NohiliteColor;
\r
931 USL_DrawString(item->text);
\r
932 VWB_Bar(item->x + 90,item->y,40,8,fontcolor ^ BackColor);
\r
933 VWB_Bar(item->x + 90 + 1,item->y + 1,40 - 2,8 - 2,BackColor);
\r
934 px = item->x + 90 + 6;
\r
936 USL_DrawString(IN_GetScanName(*KeyMaps[i]));
\r
940 USL_KeyCustom(uic_Draw,item);
\r
941 USL_CKSetKey(item,i);
\r
942 USL_DrawCtlPanel();
\r
950 USL_CJDraw(char *s1,char *s2)
\r
954 USL_MeasureString(s1,&w,&h);
\r
955 px = CtlPanelSX + ((CtlPanelW - w) / 2);
\r
956 py = CtlPanelEY - 34;
\r
957 VWB_Bar(CtlPanelSX + 1,py,CtlPanelW - 2,h * 2,BackColor);
\r
958 fontcolor = HiliteColor;
\r
959 USL_DrawString(s1);
\r
961 USL_MeasureString(s2,&w,&h);
\r
962 px = CtlPanelSX + ((CtlPanelW - w) / 2);
\r
963 USL_DrawString(s2);
\r
967 USL_CJGet(word joy,word button,word x,word y,word *xaxis,word *yaxis)
\r
972 while (IN_GetJoyButtonsDB(joy))
\r
973 if (LastScan == sc_Escape)
\r
978 while (!(IN_GetJoyButtonsDB(joy) & (1 << button)))
\r
980 if (TimeCount >= time)
\r
983 time = TimeCount + (TickBase / 2);
\r
984 VWB_DrawTile8(x,y,TileBase + on);
\r
988 if (LastScan == sc_Escape)
\r
991 IN_GetJoyAbs(joy,xaxis,yaxis);
\r
996 USL_ConfigJoystick(word joy)
\r
1002 BottomS1 = BottomS2 = "";
\r
1004 BottomS3 = "ESC to back out";
\r
1006 BottomS3 = "Esc to back out";
\r
1008 USL_DrawCtlPanel();
\r
1009 x = CtlPanelSX + 60;
\r
1010 y = CtlPanelSY + 19;
\r
1011 VWB_DrawPic(x,y,CP_JOYSTICKPIC);
\r
1013 USL_CJDraw("Move Joystick to upper left","and press button #1");
\r
1014 VWB_DrawTile8(x + 24,y + 8,TileBase + 6);
\r
1015 VWB_DrawTile8(x + 8,y + 8,TileBase + 1);
\r
1016 VWB_DrawTile8(x + 8,y + 24,TileBase + 0);
\r
1017 VW_UpdateScreen();
\r
1018 if (!USL_CJGet(joy,0,x + 8,y + 8,&minx,&miny))
\r
1021 USL_CJDraw("Move Joystick to lower right","and press button #2");
\r
1022 VWB_DrawTile8(x + 24,y + 8,TileBase - 25);
\r
1023 VWB_DrawTile8(x + 40,y + 24,TileBase + 7);
\r
1024 VWB_DrawTile8(x + 8,y + 8,TileBase + 0);
\r
1025 VWB_DrawTile8(x + 8,y + 24,TileBase + 1);
\r
1026 VW_UpdateScreen();
\r
1027 if (!USL_CJGet(joy,1,x + 8,y + 24,&maxx,&maxy))
\r
1030 while (IN_GetJoyButtonsDB(joy))
\r
1034 if (minx != maxx && miny != maxy)
\r
1036 IN_SetupJoy(joy,minx,maxx,miny,maxy);
\r
1041 IN_SetupJoy(joy,minx,maxx,miny,maxy);
\r
1048 USL_Joy1Custom(UserCall call,UserItem far *item)
\r
1050 if (call == uic_SetupCard)
\r
1052 if (USL_ConfigJoystick(0))
\r
1054 Controls[0] = ctrl_Joystick1;
\r
1055 USL_CtlDialog("USING JOYSTICK #1","PRESS ANY KEY",nil);
\r
1056 USL_SetOptionsText();
\r
1066 USL_Joy2Custom(UserCall call,UserItem far *item)
\r
1068 if (call == uic_SetupCard)
\r
1070 if (USL_ConfigJoystick(1))
\r
1072 Controls[0] = ctrl_Joystick2;
\r
1073 USL_CtlDialog("USING JOYSTICK #2","PRESS ANY KEY",nil);
\r
1074 USL_SetOptionsText();
\r
1083 USL_CGDraw(char *s1, char *s2, int buttonsDone)
\r
1085 static char *GButtonNames[4] = {"Red","Blue","Yellow","Green"};
\r
1086 static char *GActionNames[4] = {"Jump","Pogo","Fire","Status"};
\r
1092 VWB_Bar(CtlPanelSX+1, CtlPanelSY+16, CtlPanelW-2, 68, BackColor);
\r
1093 px = CtlPanelSX+8;
\r
1094 py = CtlPanelSY+16;
\r
1095 USL_DrawString("Make sure that the button");
\r
1096 px = CtlPanelSX+8;
\r
1097 py = CtlPanelSY+24;
\r
1098 USL_DrawString("switch is set for 4 buttons");
\r
1100 for (i=0; i<4; i++)
\r
1102 px = CtlPanelSX+8;
\r
1103 py = i*8 + CtlPanelSY+40;
\r
1104 USL_DrawString(GButtonNames[i]);
\r
1105 USL_DrawString(":");
\r
1107 for (n=0;n<buttonsDone;n++)
\r
1109 if (GravisMap[n] == i)
\r
1110 actionstr = GActionNames[n];
\r
1112 px = CtlPanelSX+56;
\r
1113 USL_DrawString(actionstr);
\r
1116 USL_MeasureString(s1, &w, &h);
\r
1118 USL_MeasureString(s2, &w, &h);
\r
1119 px = (CtlPanelW-px-w)/2 + CtlPanelSX;
\r
1120 py = CtlPanelSY+76;
\r
1121 USL_DrawString(s1);
\r
1122 USL_DrawString(s2);
\r
1123 VW_UpdateScreen();
\r
1127 USL_CGGet(int buttonsDone, char *action)
\r
1129 word buttons, i, n;
\r
1131 USL_CGDraw("PRESS BUTTON FOR ", action, buttonsDone);
\r
1136 if (LastScan == sc_Escape)
\r
1138 Keyboard[sc_Escape] = false;
\r
1139 if (LastScan == sc_Escape)
\r
1140 LastScan = sc_None;
\r
1144 buttons = IN_GetJoyButtonsDB(2);
\r
1148 for(i=n=0; i<4; i++)
\r
1150 if (buttons & (1 << i))
\r
1158 for (i=0; i<buttonsDone; i++)
\r
1160 if (GravisMap[i] == n)
\r
1164 GravisMap[buttonsDone] = n;
\r
1171 USL_JoyGCustom(UserCall call,UserItem far *item)
\r
1173 if (call == uic_SetupCard)
\r
1175 if (GravisGamepad)
\r
1177 GravisGamepad = false;
\r
1181 BottomS1 = BottomS2 = "";
\r
1182 BottomS3 = "ESC to back out";
\r
1183 USL_DrawCtlPanel();
\r
1184 fontcolor = HiliteColor;
\r
1185 px = CtlPanelSX + 8;
\r
1186 py = CtlPanelSX + 8;
\r
1187 fontcolor = HiliteColor; // redundant...
\r
1188 IN_ClearKeysDown();
\r
1189 if ( USL_CGGet(0, "JUMP")
\r
1190 && USL_CGGet(1, "POGO")
\r
1191 && USL_CGGet(2, "FIRE")
\r
1192 && USL_CGGet(3, "STATUS") )
\r
1194 GravisGamepad = true;
\r
1195 USL_CGDraw("PRESS ANY KEY", "", 4);
\r
1200 GravisGamepad = false;
\r
1203 USL_SetOptionsText();
\r
1210 USL_DrawFileIcon(UserItem far *item)
\r
1214 item->y = topcard->y + CtlPanelSY + 12;
\r
1215 item->y += (item - loadsavegamei) * 11;
\r
1217 fontcolor = (item->flags & ui_Selected)? HiliteColor : NohiliteColor;
\r
1218 color = fontcolor ^ BackColor; // Blech!
\r
1219 VWB_Hlin(item->x,item->x + (CtlPanelW - 12),item->y,color);
\r
1220 VWB_Hlin(item->x,item->x + (CtlPanelW - 12),item->y + 9,color);
\r
1221 VWB_Vlin(item->y,item->y + 9,item->x,color);
\r
1222 VWB_Vlin(item->y,item->y + 9,item->x + (CtlPanelW - 12),color);
\r
1226 USL_DoLoadGame(UserItem far *item)
\r
1234 if (!USL_ConfirmComm(uc_Loaded))
\r
1237 n = item - loadsavegamei;
\r
1240 USL_ShowLoadSave("Loading",game->name);
\r
1243 filename = USL_GiveSaveName(n);
\r
1244 if ((file = open(filename,O_BINARY | O_RDONLY)) != -1)
\r
1246 if (read(file,game,sizeof(*game)) == sizeof(*game))
\r
1249 if (!USL_LoadGame(file))
\r
1250 USL_HandleError(err = errno);
\r
1253 USL_HandleError(err = errno);
\r
1257 USL_HandleError(err = errno);
\r
1261 Communication = uc_None;
\r
1262 CtlPanelDone = false;
\r
1265 loadedgame = true;
\r
1266 game->present = true;
\r
1271 USL_DrawCtlPanel();
\r
1275 USL_LoadCustom(UserCall call,UserItem far *item)
\r
1283 case uic_SetupCard:
\r
1285 if (getenv("UID"))
\r
1286 USL_CheckSavedGames();
\r
1288 for (i = 0;i < MaxSaveGames;i++)
\r
1290 if (Games[i].present)
\r
1291 loadsavegamei[i].flags &= ~ui_Disabled;
\r
1293 loadsavegamei[i].flags |= ui_Disabled;
\r
1296 case uic_DrawIcon:
\r
1297 USL_DrawFileIcon(item);
\r
1301 USL_DrawFileIcon(item);
\r
1302 VWB_Bar(item->x + 1,item->y + 2,CtlPanelW - 12 - 2,7,BackColor);
\r
1304 i = item - loadsavegamei;
\r
1305 if (Games[i].present)
\r
1308 px = item->x + 60;
\r
1310 USL_DrawString(Games[i].present? Games[i].name : "Empty");
\r
1314 USL_DoLoadGame(item);
\r
1322 USL_DoSaveGame(UserItem far *item)
\r
1330 BottomS1 = "Type name";
\r
1331 BottomS2 = "Enter accepts";
\r
1332 USL_DrawCtlPanel();
\r
1334 n = item - loadsavegamei;
\r
1336 fontcolor = HiliteColor;
\r
1337 VWB_Bar(item->x + 1,item->y + 2,CtlPanelW - 12 - 2,7,BackColor);
\r
1338 game->oldtest = &PrintX;
\r
1339 ok = US_LineInput(item->x + 2,item->y + 2,
\r
1340 game->name,game->present? game->name : nil,
\r
1343 if (!strlen(game->name))
\r
1344 strcpy(game->name,"Untitled");
\r
1347 USL_ShowLoadSave("Saving",game->name);
\r
1349 filename = USL_GiveSaveName(n);
\r
1351 file = open(filename,O_CREAT | O_BINARY | O_WRONLY,
\r
1352 S_IREAD | S_IWRITE | S_IFREG);
\r
1355 if (write(file,game,sizeof(*game)) == sizeof(*game))
\r
1358 ok = USL_SaveGame(file);
\r
1360 USL_HandleError(err = errno);
\r
1363 USL_HandleError(err = ((errno == ENOENT)? ENOMEM : errno));
\r
1367 USL_HandleError(err = ((errno == ENOENT)? ENOMEM : errno));
\r
1376 if (!game->present)
\r
1377 game->present = ok;
\r
1380 GameIsDirty = false;
\r
1385 USL_SaveCustom(UserCall call,UserItem far *item)
\r
1391 case uic_SetupCard:
\r
1393 if (getenv("UID"))
\r
1394 USL_CheckSavedGames();
\r
1396 for (i = 0;i < MaxSaveGames;i++)
\r
1397 loadsavegamei[i].flags &= ~ui_Disabled;
\r
1400 USL_DoSaveGame(item);
\r
1404 return(USL_LoadCustom(call,item));
\r
1407 #define PaddleMinX (CtlPanelSX + 4)
\r
1408 #define PaddleMaxX (CtlPanelEX - 15)
\r
1409 #define BallMinX (CtlPanelSX + 4)
\r
1410 #define BallMinY (CtlPanelSY + 12 + 2)
\r
1411 #define BallMaxX (CtlPanelEX - 6)
\r
1412 #define BallMaxY (CtlPanelEY - 13)
\r
1413 #define CPaddleY (BallMinY + 4)
\r
1414 #define KPaddleY (BallMaxY - 2)
\r
1416 USL_DrawPongScore(word k,word c)
\r
1418 fontcolor = HiliteColor;
\r
1419 PrintY = py = CtlPanelSY + 4;
\r
1420 px = CtlPanelSX + 6;
\r
1421 VWB_Bar(px,py,42,6,BackColor);
\r
1422 USL_DrawString("KEEN:");
\r
1424 US_PrintUnsigned(k);
\r
1425 px = CtlPanelSX + 108;
\r
1426 VWB_Bar(px,py,50,6,BackColor);
\r
1427 USL_DrawString("COMP:");
\r
1429 US_PrintUnsigned(c);
\r
1433 USL_PlayPong(void)
\r
1435 boolean ball,killball,revdir,done,lastscore;
\r
1441 oldkx,oldcx,oldbx,oldby,
\r
1445 longword balltime,lasttime,waittime;
\r
1446 CursorInfo cursorinfo;
\r
1448 kx = cx = PaddleMinX + ((PaddleMaxX - PaddleMinX) / 2);
\r
1449 bx = by = bdx = bdy = 0;
\r
1450 oldbx = oldcx = oldkx = PaddleMinX;
\r
1452 kscore = cscore = 0;
\r
1453 USL_DrawPongScore(0,0);
\r
1458 lastscore = false;
\r
1459 lasttime = TimeCount;
\r
1462 while ((waittime = TimeCount - lasttime) == 0)
\r
1465 lasttime = TimeCount;
\r
1469 while (waittime-- && !done && LastScan != sc_Escape)
\r
1471 IN_ReadCursor(&cursorinfo);
\r
1472 if (((cursorinfo.x < 0) || IN_KeyDown(sc_LeftArrow)) && (kx > PaddleMinX))
\r
1474 else if (((cursorinfo.x > 0) || IN_KeyDown(sc_RightArrow)) && (kx < PaddleMaxX))
\r
1480 balltime = TickBase;
\r
1483 VWB_Bar(oldbx,oldby,5,5,BackColor);
\r
1486 if (ball && (cycle++ % 3))
\r
1490 x += (US_RndT() & 1);
\r
1492 if ((cx + 6 < x) && (cx < PaddleMaxX))
\r
1494 else if ((cx + 6 > x) && (cx > PaddleMinX))
\r
1498 if (!ball && !--balltime)
\r
1501 bdx = 1 - (US_RndT() % 3);
\r
1505 bx = (BallMinX + ((BallMaxX - BallMinX) / 2)) << 2;
\r
1506 by = (BallMinY + ((BallMaxY - BallMinY) / 2)) << 2;
\r
1513 (((bx + bdx) >> 2) > BallMaxX)
\r
1514 || (((bx + bdx) >> 2) < BallMinX)
\r
1517 SD_PlaySound(BALLBOUNCESND);
\r
1522 if (((by + bdy) >> 2) > BallMaxY)
\r
1525 lastscore = false;
\r
1527 SD_PlaySound(COMPSCOREDSND);
\r
1528 USL_DrawPongScore(kscore,cscore);
\r
1531 USL_CtlDialog("You lost!","Press any key",nil);
\r
1536 else if (((by + bdy) >> 2) < BallMinY)
\r
1541 SD_PlaySound(KEENSCOREDSND);
\r
1542 USL_DrawPongScore(kscore,cscore);
\r
1545 USL_CtlDialog("You won!","Press any key",nil);
\r
1559 && ((y >= CPaddleY) && (y < CPaddleY + 3))
\r
1560 && ((x >= (cx - 5)) && (x < (cx + 11)))
\r
1565 SD_PlaySound(COMPPADDLESND);
\r
1570 && ((y >= (KPaddleY - 3)) && (y < KPaddleY))
\r
1571 && ((x >= (kx - 5)) && (x < (kx + 11)))
\r
1574 if (((bdy >> 2) < 3) && !(--speedup))
\r
1581 SD_PlaySound(KEENPADDLESND);
\r
1586 bdx = ((x + 5 - rx) >> 1) - (1 << 2);
\r
1597 VWB_Bar(oldbx,oldby,5,5,BackColor);
\r
1600 #if GRMODE == CGAGR
\r
1602 static int ballsprites[4] = {BALLSPR, BALL1PIXELTOTHERIGHTSPR, BALL2PIXELSTOTHERIGHTSPR, BALL3PIXELSTOTHERIGHTSPR};
\r
1603 VWB_DrawSprite(x,y,ballsprites[x & 3]);
\r
1606 VWB_DrawSprite(x,y,(x & 1)? BALL1PIXELTOTHERIGHTSPR : BALLSPR);
\r
1609 VWB_Bar(oldcx-3,CPaddleY,16,3,BackColor);
\r
1611 VWB_DrawSprite(cx,CPaddleY,PADDLESPR);
\r
1612 VWB_Bar(oldkx-3,KPaddleY,16,3,BackColor);
\r
1614 VWB_DrawSprite(kx,KPaddleY,PADDLESPR);
\r
1616 VW_UpdateScreen();
\r
1617 } while ((LastScan != sc_Escape) && !done);
\r
1618 IN_ClearKeysDown();
\r
1623 USL_PongCustom(UserCall call,struct UserItem far *item)
\r
1625 if (call != uic_SetupCard)
\r
1628 VWB_DrawPic(0,0,CP_MENUSCREENPIC);
\r
1629 VWB_DrawPic(CtlPanelSX + 56,CtlPanelSY,CP_PADDLEWARPIC);
\r
1630 VWB_Hlin(CtlPanelSX + 3,CtlPanelEX - 3,CtlPanelSY + 12,HiliteColor ^ BackColor);
\r
1631 VWB_Hlin(CtlPanelSX + 3,CtlPanelEX - 3,CtlPanelEY - 7,HiliteColor ^ BackColor);
\r
1637 // Flag management stuff
\r
1639 USL_ClearFlags(UserItemGroup far *node)
\r
1646 for (i = node->items;i->type != uii_Bad;i++)
\r
1648 i->flags &= ~UISelectFlags;
\r
1650 USL_ClearFlags((UserItemGroup far *)i->child);
\r
1655 USL_FindPushedItem(UserItemGroup far *group)
\r
1658 UserItem far *item;
\r
1660 for (item = group->items,i = 0;item->type != uii_Bad;item++,i++)
\r
1661 if (item->flags & ui_Pushed)
\r
1667 USL_SelectItem(UserItemGroup far *group,word index,boolean draw)
\r
1669 UserItem far *item;
\r
1671 if (index != group->cursor)
\r
1673 item = &group->items[group->cursor];
\r
1674 item->flags &= ~ui_Selected;
\r
1676 USL_DrawItem(item);
\r
1679 group->cursor = index;
\r
1680 item = &group->items[group->cursor];
\r
1681 group->items[group->cursor].flags |= ui_Selected;
\r
1683 USL_DrawItem(item);
\r
1687 USL_PushItem(UserItemGroup far *group,word index,boolean draw)
\r
1690 UserItem far *item;
\r
1692 USL_SelectItem(group,index,draw);
\r
1693 for (item = group->items,i = 0;item->type != uii_Bad;item++,i++)
\r
1695 if (item->type != uii_RadioButton)
\r
1700 item->flags |= ui_Pushed;
\r
1702 USL_DrawItem(item);
\r
1704 else if (item->flags & ui_Pushed)
\r
1706 item->flags &= ~ui_Pushed;
\r
1708 USL_DrawItem(item);
\r
1714 USL_NextItem(void)
\r
1716 if (topcard->items[topcard->cursor + 1].type == uii_Bad)
\r
1718 USL_SelectItem(topcard,topcard->cursor + 1,true);
\r
1722 USL_PrevItem(void)
\r
1724 if (!topcard->cursor)
\r
1726 USL_SelectItem(topcard,topcard->cursor - 1,true);
\r
1730 USL_SetupCard(void)
\r
1732 BottomS1 = "Arrows move";
\r
1733 BottomS2 = "Enter selects";
\r
1734 BottomS3 = cstackptr? "ESC to back out" : "ESC to quit";
\r
1736 USL_SelectItem(topcard,topcard->cursor,false);
\r
1737 USL_DrawCtlPanel(); // Contents?
\r
1741 USL_DownLevel(UserItemGroup far *group)
\r
1744 Quit("USL_DownLevel() - nil card");
\r
1745 USL_PushCard(group);
\r
1746 if (group->custom && group->custom(uic_SetupCard,nil))
\r
1756 USL_ConfirmComm(uc_Quit);
\r
1760 if (topcard->items)
\r
1761 topcard->items[topcard->cursor].flags &= ~ui_Selected;
\r
1769 // DEBUG - finish this routine
\r
1770 UserItem far *item;
\r
1772 item = &topcard->items[topcard->cursor];
\r
1773 if (item->flags & ui_Disabled)
\r
1774 SD_PlaySound(NOWAYSND);
\r
1777 switch (item->type)
\r
1780 if (!(topcard->custom && topcard->custom(uic_Hit,item)))
\r
1781 USL_ConfirmComm(item->comm);
\r
1783 case uii_RadioButton:
\r
1784 USL_PushItem(topcard,topcard->cursor,true);
\r
1787 USL_DownLevel(item->child);
\r
1794 USL_SetControlValues(void)
\r
1798 sndindex = SoundMode;
\r
1799 if (sndindex == sdm_AdLib && QuietFX)
\r
1802 USL_PushItem(&soundgroup,sndindex,false);
\r
1803 USL_PushItem(&musicgroup,MusicMode,false);
\r
1804 if (!AdLibPresent)
\r
1806 soundi[2].flags |= ui_Disabled; // AdLib sound effects
\r
1807 soundi[3].flags |= ui_Disabled; // Quiet AdLib sound effects
\r
1808 musici[1].flags |= ui_Disabled; // AdLib music
\r
1812 if (!JoysPresent[0])
\r
1813 configi[3].flags |= ui_Disabled;
\r
1814 if (!JoysPresent[1])
\r
1815 configi[4].flags |= ui_Disabled;
\r
1817 if (!JoysPresent[0])
\r
1818 configi[4].flags |= ui_Disabled;
\r
1819 if (!JoysPresent[1])
\r
1820 configi[5].flags |= ui_Disabled;
\r
1821 if (!JoysPresent[0] && !JoysPresent[1])
\r
1822 configi[6].flags |= ui_Disabled;
\r
1825 rooti[4].text = ingame? "RETURN TO GAME" : "RETURN TO DEMO";
\r
1828 rooti[2].flags |= ui_Disabled; // Save Game
\r
1829 rooti[5].flags |= ui_Disabled; // End Game
\r
1831 rootgroup.cursor = ingame? 4 : 0;
\r
1832 USL_SetOptionsText();
\r
1833 // DEBUG - write the rest of this
\r
1836 ///////////////////////////////////////////////////////////////////////////
\r
1838 // USL_SetUpCtlPanel() - Sets the states of the UserItems to reflect the
\r
1839 // values of all the appropriate variables
\r
1841 ///////////////////////////////////////////////////////////////////////////
\r
1843 USL_SetUpCtlPanel(void)
\r
1847 // Cache in all of the stuff for the control panel
\r
1849 for (i = CONTROLS_LUMP_START;i <= CONTROLS_LUMP_END;i++)
\r
1850 CA_MarkGrChunk(i);
\r
1851 for (i = PADDLE_LUMP_START;i <= PADDLE_LUMP_END;i++)
\r
1852 CA_MarkGrChunk(i);
\r
1853 CA_MarkGrChunk(STARTFONT+1); // Little font
\r
1854 CA_MarkGrChunk(CP_MENUMASKPICM); // Mask for dialogs
\r
1855 CA_CacheMarks("Control Panel");
\r
1856 CA_LoadAllSounds();
\r
1858 // Do some other setup
\r
1860 US_SetPrintRoutines(VW_MeasurePropString,VWB_DrawPropString);
\r
1861 fontcolor = F_BLACK;
\r
1863 VW_Bar (0,0,320,200,3); // CAT3D patch
\r
1868 VW_InitDoubleBuffer();
\r
1870 Communication = uc_None;
\r
1871 USL_ClearFlags(&rootgroup);
\r
1872 USL_SetControlValues();
\r
1877 GameIsDirty = true;
\r
1879 IN_ClearKeysDown();
\r
1883 USL_HandleComm(UComm comm)
\r
1897 restartgame = gd_Easy;
\r
1900 restartgame = gd_Normal;
\r
1903 restartgame = gd_Hard;
\r
1907 Quit("USL_HandleComm() - unknown");
\r
1913 USL_GetControlValues(void)
\r
1917 // DEBUG - write the rest of this
\r
1918 i = USL_FindPushedItem(&soundgroup);
\r
1928 if (i != SoundMode)
\r
1929 SD_SetSoundMode(i);
\r
1931 i = USL_FindPushedItem(&musicgroup);
\r
1932 if (i != MusicMode)
\r
1933 SD_SetMusicMode(i);
\r
1936 ///////////////////////////////////////////////////////////////////////////
\r
1938 // USL_TearDownCtlPanel() - Given the state of the control panel, sets the
\r
1939 // modes and values as appropriate
\r
1941 ///////////////////////////////////////////////////////////////////////////
\r
1943 USL_TearDownCtlPanel(void)
\r
1945 USL_GetControlValues();
\r
1946 if (Communication)
\r
1947 USL_HandleComm(Communication);
\r
1949 fontnumber = 0; // Normal font
\r
1950 fontcolor = F_BLACK;
\r
1951 if (restartgame && USL_ResetGame)
\r
1953 else if (QuitToDos)
\r
1959 US_CenterWindow(20,3);
\r
1960 fontcolor = F_SECONDCOLOR;
\r
1961 US_PrintCentered("Quitting...");
\r
1962 fontcolor = F_BLACK;
\r
1963 VW_UpdateScreen();
\r
1968 IN_ClearKeysDown();
\r
1969 SD_WaitSoundDone();
\r
1971 VW_Bar (0,0,320,200,3); // CAT3D patch
\r
1976 CA_LoadAllSounds();
\r
1979 ///////////////////////////////////////////////////////////////////////////
\r
1981 // US_ControlPanel() - This is the main routine for the control panel
\r
1983 ///////////////////////////////////////////////////////////////////////////
\r
1984 #define MoveMin 40
\r
1986 US_ControlPanel(void)
\r
1988 extern void HelpScreens(void);
\r
1990 boolean resetitem,on;
\r
1993 longword flashtime;
\r
1994 UserItem far *item;
\r
1995 CursorInfo cursorinfo;
\r
2000 USL_SetUpCtlPanel();
\r
2001 Communication = uc_Loaded;
\r
2002 CtlPanelDone = true;
\r
2003 loadedgame = true;
\r
2004 USL_TearDownCtlPanel();
\r
2009 if ((LastScan < sc_F1) || (LastScan > sc_F10))
\r
2010 IN_ClearKeysDown();
\r
2012 USL_SetUpCtlPanel();
\r
2013 USL_DrawCtlPanel();
\r
2016 for (CtlPanelDone = false,resetitem = on = true;!CtlPanelDone;)
\r
2018 item = &(topcard->items[topcard->cursor]);
\r
2022 flashtime = TimeCount + (TickBase / 2);
\r
2023 resetitem = false;
\r
2026 if (TimeCount >= flashtime)
\r
2031 item->flags &= ~ui_Selected;
\r
2032 USL_DrawItemIcon(item);
\r
2033 item->flags |= ui_Selected;
\r
2036 VW_UpdateScreen();
\r
2046 case sc_DownArrow:
\r
2061 USL_DrawCtlPanel();
\r
2071 (LastScan == KbdDefs[0].button0)
\r
2072 || (LastScan == KbdDefs[0].button1)
\r
2082 for (item = topcard->items,i = 0;item->type != uii_Bad;item++,i++)
\r
2084 if (item->hotkey == LastScan)
\r
2086 USL_SelectItem(topcard,i,true);
\r
2093 IN_ClearKeysDown();
\r
2097 IN_ReadCursor(&cursorinfo);
\r
2098 ydelta += cursorinfo.y;
\r
2099 if (cursorinfo.button0)
\r
2103 IN_ReadCursor(&cursorinfo);
\r
2104 } while (cursorinfo.button0);
\r
2108 else if (cursorinfo.button1)
\r
2112 IN_ReadCursor(&cursorinfo);
\r
2113 } while (cursorinfo.button1);
\r
2117 else if (ydelta < -MoveMin)
\r
2119 ydelta += MoveMin;
\r
2123 else if (ydelta > MoveMin)
\r
2125 ydelta -= MoveMin;
\r
2132 USL_TearDownCtlPanel();
\r
2137 boolean US_ManualCheck(void)
\r
2145 static creatureinfo list[] = {
\r
2146 {"BIP", BIPSHIPRSPR, -2, 0},
\r
2147 {"BABOBBA", BABOBBAR1SPR, 0, 0},
\r
2148 {"BLORB", BLORB1SPR, -2, 0},
\r
2149 {"GIK", GIKWALKR1SPR, -1, 0},
\r
2150 {"CEILICK", CEILICK1SPR, 0, 0},
\r
2151 {"BLOOGLET", RBLOOGLETWALKR1SPR, -2, 0},
\r
2152 {"BLOOGUARD", BLOOGUARDWALKL1SPR, -3, -1},
\r
2153 {"FLECT", FLECTSTANDSPR, -1, 0},
\r
2154 {"BOBBA", BOBBAR1SPR, -2, 0},
\r
2155 {"NOSPIKE", NOSPIKESTANDSPR, -2, 0},
\r
2156 {"ORBATRIX", ORBATRIXR1SPR, -2, 1},
\r
2157 {"FLEEX", FLEEXWALKR1SPR, -2, 0}
\r
2164 unsigned spriteheight, spritewidth;
\r
2167 creatureinfo info;
\r
2174 if (listindex == -1)
\r
2176 _AH = 0x2C; // get time
\r
2177 geninterrupt(0x21);
\r
2178 x = _CH; // store hours
\r
2179 _AH = 0x2A; // get date
\r
2180 geninterrupt(0x21);
\r
2181 y = _DL; // store day
\r
2183 listindex = (x + y) % (int)(sizeof(list)/sizeof(creatureinfo));
\r
2187 info = list[listindex];
\r
2190 CA_MarkGrChunk(info.shapenum);
\r
2191 CA_CacheMarks(NULL);
\r
2193 VWB_Bar(0, 0, 320, 200, BackColor);
\r
2194 spritewidth = spritetable[info.shapenum - STARTSPRITES].width;
\r
2195 spriteheight = spritetable[info.shapenum - STARTSPRITES].height;
\r
2196 US_CenterWindow(30, (spriteheight+41)/8 + 1);
\r
2197 PrintY = WindowY + 2;
\r
2198 US_CPrint("What is the name of this creature?");
\r
2200 x = WindowX + (WindowW-spritewidth)/2 + info.x*8;
\r
2202 if (info.shapenum == CEILICK1SPR)
\r
2210 VWB_DrawSprite(x, y, info.shapenum);
\r
2212 y = WindowY + WindowH - 16;
\r
2214 x = WindowX + (WindowW - 100) / 2;
\r
2215 VWB_Bar(x, y, editwidth, 14, BLACK);
\r
2216 VWB_Bar(x+1, y+1, editwidth-2, 12, WHITE);
\r
2220 VW_UpdateScreen();
\r
2222 if (US_LineInput(x, y, strbuf, NULL, true, sizeof(strbuf), editwidth))
\r
2229 if ((islower(c)? _toupper(c) : c) != *name)
\r
2244 VWB_Bar(0, 0, 320, 200, BackColor);
\r
2245 US_CenterWindow(35, 5);
\r
2247 US_CPrint("Sorry, that's not quite right.");
\r
2248 US_CPrint("Please check your manual and try again.");
\r
2249 VW_UpdateScreen();
\r
2254 VWB_Bar(0, 0, 320, 200, BackColor);
\r
2256 checkpassed = correct;
\r