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