9 extern bool keyboardfrozen;
10 extern bool buttons[3];
11 /********************> IsKeyDown() <*****/
12 Boolean IsKeyDown( unsigned char *keyMap, unsigned short theKey )
14 if(keyboardfrozen)return 0;
15 if(theKey< 0x80 /*1000*/){
16 static long keyMapIndex;
17 static Boolean isKeyDown;
18 static short bitToCheck;
20 // Calculate the key map index
21 keyMapIndex = keyMap[theKey/8];
23 // Calculate the individual bit to check
24 bitToCheck = theKey%8;
26 // Check the status of the key
27 isKeyDown = ( keyMapIndex >> bitToCheck ) & 0x01;
29 // Return the status of the key
32 else if(theKey==MAC_MOUSEBUTTON1)
34 else if(theKey==MAC_MOUSEBUTTON2)
40 unsigned short CharToKey(char* which)
43 if(!stricmp(which,"a")){
46 if(!stricmp(which,"b")){
49 if(!stricmp(which,"c")){
52 if(!stricmp(which,"d")){
55 if(!stricmp(which,"e")){
58 if(!stricmp(which,"f")){
61 if(!stricmp(which,"g")){
64 if(!stricmp(which,"h")){
67 if(!stricmp(which,"i")){
70 if(!stricmp(which,"j")){
73 if(!stricmp(which,"k")){
76 if(!stricmp(which,"l")){
79 if(!stricmp(which,"m")){
82 if(!stricmp(which,"n")){
85 if(!stricmp(which,"o")){
88 if(!stricmp(which,"p")){
91 if(!stricmp(which,"q")){
94 if(!stricmp(which,"r")){
97 if(!stricmp(which,"s")){
100 if(!stricmp(which,"t")){
103 if(!stricmp(which,"u")){
106 if(!stricmp(which,"v")){
109 if(!stricmp(which,"w")){
112 if(!stricmp(which,"x")){
115 if(!stricmp(which,"y")){
118 if(!stricmp(which,"z")){
123 if(!stricmp(which,"KP0")){
124 return MAC_NUMPAD_0_KEY;
126 if(!stricmp(which,"KP1")){
127 return MAC_NUMPAD_1_KEY;
129 if(!stricmp(which,"KP2")){
130 return MAC_NUMPAD_2_KEY;
132 if(!stricmp(which,"KP3")){
133 return MAC_NUMPAD_3_KEY;
135 if(!stricmp(which,"KP4")){
136 return MAC_NUMPAD_4_KEY;
138 if(!stricmp(which,"KP5")){
139 return MAC_NUMPAD_5_KEY;
141 if(!stricmp(which,"KP6")){
142 return MAC_NUMPAD_6_KEY;
144 if(!stricmp(which,"KP7")){
145 return MAC_NUMPAD_7_KEY;
147 if(!stricmp(which,"KP8")){
148 return MAC_NUMPAD_8_KEY;
150 if(!stricmp(which,"KP9")){
151 return MAC_NUMPAD_9_KEY;
155 if(!stricmp(which,"enter")){
156 return MAC_ENTER_KEY;
160 if(!stricmp(which,"0")){
163 if(!stricmp(which,"1")){
166 if(!stricmp(which,"2")){
169 if(!stricmp(which,"3")){
172 if(!stricmp(which,"4")){
175 if(!stricmp(which,"5")){
178 if(!stricmp(which,"6")){
181 if(!stricmp(which,"7")){
184 if(!stricmp(which,"8")){
187 if(!stricmp(which,"9")){
192 if(!stricmp(which,"F1")){
195 if(!stricmp(which,"F2")){
198 if(!stricmp(which,"F3")){
201 if(!stricmp(which,"F4")){
204 if(!stricmp(which,"F5")){
207 if(!stricmp(which,"F6")){
210 if(!stricmp(which,"F7")){
213 if(!stricmp(which,"F8")){
216 if(!stricmp(which,"F9")){
219 if(!stricmp(which,"F10")){
222 if(!stricmp(which,"F11")){
225 if(!stricmp(which,"F12")){
230 if(!stricmp(which,"escape")){
231 return MAC_ESCAPE_KEY;
233 if(!stricmp(which,"backspace")){
234 return MAC_DELETE_KEY;
236 if(!stricmp(which,"tab")){
239 if(!stricmp(which,"`")){
240 return MAC_TILDE_KEY;
242 if(!stricmp(which,"caps_lock")){
243 return MAC_CAPS_LOCK_KEY;
248 if(!stricmp(which,"command")){
249 return MAC_COMMAND_KEY;
251 if(!stricmp(which,"option")){
252 return MAC_OPTION_KEY;
254 if(!stricmp(which,"delete")){
257 if(!stricmp(which,"insert")){
258 return MAC_INSERT_KEY;
260 if(!stricmp(which,"home")){
263 if(!stricmp(which,"end")){
266 if(!stricmp(which,"page_up")){
267 return MAC_PAGE_UP_KEY;
269 if(!stricmp(which,"page_down")){
270 return MAC_PAGE_DOWN_KEY;
272 if(!stricmp(which,"clear")){
273 return MAC_NUMPAD_CLEAR_KEY;
276 if(!stricmp(which,"control")){
277 return MAC_CONTROL_KEY;
279 if(!stricmp(which,"return")){
280 return MAC_RETURN_KEY;
282 if(!stricmp(which,"space")){
283 return MAC_SPACE_KEY;
285 if(!stricmp(which,"shift")){
286 return MAC_SHIFT_KEY;
288 if(!stricmp(which,"uparrow")){
289 return MAC_ARROW_UP_KEY;
291 if(!stricmp(which,"downarrow")){
292 return MAC_ARROW_DOWN_KEY;
294 if(!stricmp(which,"leftarrow")){
295 return MAC_ARROW_LEFT_KEY;
297 if(!stricmp(which,"rightarrow")){
298 return MAC_ARROW_RIGHT_KEY;
300 if(!stricmp(which,"mouse1")){
301 return MAC_MOUSEBUTTON1;
303 if(!stricmp(which,"mouse2")){
304 return MAC_MOUSEBUTTON2;
306 if(!stricmp(which,"+")){
307 return MAC_NUMPAD_PLUS_KEY;
309 if(!stricmp(which,"*")){
310 return MAC_NUMPAD_ASTERISK_KEY;
312 if(!stricmp(which,"/")){
313 return MAC_SLASH_KEY;
315 if(!stricmp(which,"\\")){
316 return MAC_BACKSLASH_KEY;
318 if(!stricmp(which,"[")){
319 return MAC_LEFTBRACKET_KEY;
321 if(!stricmp(which,"]")){
322 return MAC_RIGHTBRACKET_KEY;
324 if(!stricmp(which,".")){
325 return MAC_PERIOD_KEY;
327 if(!stricmp(which,",")){
328 return MAC_COMMA_KEY;
330 if(!stricmp(which,"\"")){
331 return MAC_APOSTROPHE_KEY;
333 if(!stricmp(which,";")){
334 return MAC_SEMICOLON_KEY;
339 char* KeyToChar(unsigned short which)
344 if(which==MAC_A_KEY){
347 if(which==MAC_B_KEY){
350 if(which==MAC_C_KEY){
353 if(which==MAC_D_KEY){
356 if(which==MAC_E_KEY){
359 if(which==MAC_F_KEY){
362 if(which==MAC_G_KEY){
365 if(which==MAC_H_KEY){
368 if(which==MAC_I_KEY){
371 if(which==MAC_J_KEY){
374 if(which==MAC_K_KEY){
377 if(which==MAC_L_KEY){
380 if(which==MAC_M_KEY){
383 if(which==MAC_N_KEY){
386 if(which==MAC_O_KEY){
389 if(which==MAC_P_KEY){
392 if(which==MAC_Q_KEY){
395 if(which==MAC_R_KEY){
398 if(which==MAC_S_KEY){
401 if(which==MAC_T_KEY){
404 if(which==MAC_U_KEY){
407 if(which==MAC_V_KEY){
410 if(which==MAC_W_KEY){
413 if(which==MAC_X_KEY){
416 if(which==MAC_Y_KEY){
419 if(which==MAC_Z_KEY){
424 if(which==MAC_NUMPAD_1_KEY){
427 if(which==MAC_NUMPAD_2_KEY){
430 if(which==MAC_NUMPAD_3_KEY){
433 if(which==MAC_NUMPAD_4_KEY){
436 if(which==MAC_NUMPAD_5_KEY){
439 if(which==MAC_NUMPAD_6_KEY){
442 if(which==MAC_NUMPAD_7_KEY){
445 if(which==MAC_NUMPAD_8_KEY){
448 if(which==MAC_NUMPAD_9_KEY){
451 if(which==MAC_NUMPAD_0_KEY){
456 if(which==MAC_ENTER_KEY){
461 if(which==MAC_1_KEY){
464 if(which==MAC_2_KEY){
467 if(which==MAC_3_KEY){
470 if(which==MAC_4_KEY){
473 if(which==MAC_5_KEY){
476 if(which==MAC_6_KEY){
479 if(which==MAC_7_KEY){
482 if(which==MAC_8_KEY){
485 if(which==MAC_9_KEY){
488 if(which==MAC_0_KEY){
493 if(which==MAC_F1_KEY){
496 if(which==MAC_F2_KEY){
499 if(which==MAC_F3_KEY){
502 if(which==MAC_F4_KEY){
505 if(which==MAC_F5_KEY){
508 if(which==MAC_F6_KEY){
511 if(which==MAC_F7_KEY){
514 if(which==MAC_F8_KEY){
517 if(which==MAC_F9_KEY){
520 if(which==MAC_F10_KEY){
523 if(which==MAC_F11_KEY){
526 if(which==MAC_F12_KEY){
531 if(which==MAC_ESCAPE_KEY){
534 if(which==MAC_DELETE_KEY){
537 if(which==MAC_TAB_KEY){
540 if(which==MAC_TILDE_KEY){
543 if(which==MAC_CAPS_LOCK_KEY){
546 if(which==MAC_COMMAND_KEY){
549 if(which==MAC_OPTION_KEY){
552 if(which==MAC_DEL_KEY){
555 if(which==MAC_INSERT_KEY){
558 if(which==MAC_HOME_KEY){
561 if(which==MAC_END_KEY){
564 if(which==MAC_PAGE_UP_KEY){
567 if(which==MAC_PAGE_DOWN_KEY){
570 if(which==MAC_NUMPAD_CLEAR_KEY){
573 if(which==MAC_CONTROL_KEY){
576 if(which==MAC_SPACE_KEY){
579 if(which==MAC_RETURN_KEY){
582 if(which==MAC_SHIFT_KEY){
585 if(which==MAC_ARROW_UP_KEY){
588 if(which==MAC_ARROW_DOWN_KEY){
591 if(which==MAC_ARROW_LEFT_KEY){
594 if(which==MAC_ARROW_RIGHT_KEY){
597 if(which==MAC_MOUSEBUTTON1){
600 if(which==MAC_MOUSEBUTTON2){
603 if(which==MAC_ARROW_RIGHT_KEY){
606 if(which==MAC_MINUS_KEY||which==MAC_NUMPAD_MINUS_KEY){
609 if(which==MAC_PLUS_KEY||which==MAC_NUMPAD_EQUALS_KEY){
612 if(which==MAC_NUMPAD_PLUS_KEY){
615 if(which==MAC_NUMPAD_ASTERISK_KEY){
618 if(which==MAC_SLASH_KEY||which==MAC_NUMPAD_SLASH_KEY){
621 if(which==MAC_BACKSLASH_KEY){
624 if(which==MAC_LEFTBRACKET_KEY){
627 if(which==MAC_RIGHTBRACKET_KEY){
630 if(which==MAC_PERIOD_KEY||which==MAC_NUMPAD_PERIOD_KEY){
633 if(which==MAC_COMMA_KEY){
636 if(which==MAC_APOSTROPHE_KEY){
639 if(which==MAC_SEMICOLON_KEY){
645 char KeyToSingleChar(unsigned short which)
649 if(which==MAC_A_KEY){
652 if(which==MAC_B_KEY){
655 if(which==MAC_C_KEY){
658 if(which==MAC_D_KEY){
661 if(which==MAC_E_KEY){
664 if(which==MAC_F_KEY){
667 if(which==MAC_G_KEY){
670 if(which==MAC_H_KEY){
673 if(which==MAC_I_KEY){
676 if(which==MAC_J_KEY){
679 if(which==MAC_K_KEY){
682 if(which==MAC_L_KEY){
685 if(which==MAC_M_KEY){
688 if(which==MAC_N_KEY){
691 if(which==MAC_O_KEY){
694 if(which==MAC_P_KEY){
697 if(which==MAC_Q_KEY){
700 if(which==MAC_R_KEY){
703 if(which==MAC_S_KEY){
706 if(which==MAC_T_KEY){
709 if(which==MAC_U_KEY){
712 if(which==MAC_V_KEY){
715 if(which==MAC_W_KEY){
718 if(which==MAC_X_KEY){
721 if(which==MAC_Y_KEY){
724 if(which==MAC_Z_KEY){
727 if(which==MAC_NUMPAD_1_KEY){
730 if(which==MAC_NUMPAD_2_KEY){
733 if(which==MAC_NUMPAD_3_KEY){
736 if(which==MAC_NUMPAD_4_KEY){
739 if(which==MAC_NUMPAD_5_KEY){
742 if(which==MAC_NUMPAD_6_KEY){
745 if(which==MAC_NUMPAD_7_KEY){
748 if(which==MAC_NUMPAD_8_KEY){
751 if(which==MAC_NUMPAD_9_KEY){
754 if(which==MAC_NUMPAD_0_KEY){
757 if(which==MAC_1_KEY){
760 if(which==MAC_2_KEY){
763 if(which==MAC_3_KEY){
766 if(which==MAC_4_KEY){
769 if(which==MAC_5_KEY){
772 if(which==MAC_6_KEY){
775 if(which==MAC_7_KEY){
778 if(which==MAC_8_KEY){
781 if(which==MAC_9_KEY){
784 if(which==MAC_0_KEY){
787 if(which==MAC_SPACE_KEY){
790 if(which==MAC_MINUS_KEY||which==MAC_NUMPAD_MINUS_KEY){
793 if(which==MAC_PLUS_KEY||which==MAC_NUMPAD_EQUALS_KEY){
796 if(which==MAC_NUMPAD_PLUS_KEY){
799 if(which==MAC_NUMPAD_ASTERISK_KEY){
802 if(which==MAC_SLASH_KEY||which==MAC_NUMPAD_SLASH_KEY){
805 if(which==MAC_BACKSLASH_KEY){
808 if(which==MAC_LEFTBRACKET_KEY){
811 if(which==MAC_RIGHTBRACKET_KEY){
814 if(which==MAC_PERIOD_KEY||which==MAC_NUMPAD_PERIOD_KEY){
817 if(which==MAC_COMMA_KEY){
820 if(which==MAC_APOSTROPHE_KEY){
823 if(which==MAC_SEMICOLON_KEY){
829 char Shift(char which)
986 bool Compare(char *thestring, char *tocompare, int start, int end)
989 for(i=start;i<=end;i++){
990 if(thestring[i]!=tocompare[i-start]&&thestring[i]!=tocompare[i-start]+'A'-'a')return 0;