7 extern bool keyboardfrozen;
8 extern bool buttons[3];
9 /********************> IsKeyDown() <*****/
10 Boolean IsKeyDown( unsigned char *keyMap, unsigned short theKey )
12 if(keyboardfrozen)return 0;
13 if(theKey< 0x80 /*1000*/){
14 static long keyMapIndex;
15 static Boolean isKeyDown;
16 static short bitToCheck;
18 // Calculate the key map index
19 keyMapIndex = keyMap[theKey/8];
21 // Calculate the individual bit to check
22 bitToCheck = theKey%8;
24 // Check the status of the key
25 isKeyDown = ( keyMapIndex >> bitToCheck ) & 0x01;
27 // Return the status of the key
30 else if(theKey==MAC_MOUSEBUTTON1)
32 else if(theKey==MAC_MOUSEBUTTON2)
38 unsigned short CharToKey(char* which)
41 if(!stricmp(which,"a")){
44 if(!stricmp(which,"b")){
47 if(!stricmp(which,"c")){
50 if(!stricmp(which,"d")){
53 if(!stricmp(which,"e")){
56 if(!stricmp(which,"f")){
59 if(!stricmp(which,"g")){
62 if(!stricmp(which,"h")){
65 if(!stricmp(which,"i")){
68 if(!stricmp(which,"j")){
71 if(!stricmp(which,"k")){
74 if(!stricmp(which,"l")){
77 if(!stricmp(which,"m")){
80 if(!stricmp(which,"n")){
83 if(!stricmp(which,"o")){
86 if(!stricmp(which,"p")){
89 if(!stricmp(which,"q")){
92 if(!stricmp(which,"r")){
95 if(!stricmp(which,"s")){
98 if(!stricmp(which,"t")){
101 if(!stricmp(which,"u")){
104 if(!stricmp(which,"v")){
107 if(!stricmp(which,"w")){
110 if(!stricmp(which,"x")){
113 if(!stricmp(which,"y")){
116 if(!stricmp(which,"z")){
121 if(!stricmp(which,"KP0")){
122 return MAC_NUMPAD_0_KEY;
124 if(!stricmp(which,"KP1")){
125 return MAC_NUMPAD_1_KEY;
127 if(!stricmp(which,"KP2")){
128 return MAC_NUMPAD_2_KEY;
130 if(!stricmp(which,"KP3")){
131 return MAC_NUMPAD_3_KEY;
133 if(!stricmp(which,"KP4")){
134 return MAC_NUMPAD_4_KEY;
136 if(!stricmp(which,"KP5")){
137 return MAC_NUMPAD_5_KEY;
139 if(!stricmp(which,"KP6")){
140 return MAC_NUMPAD_6_KEY;
142 if(!stricmp(which,"KP7")){
143 return MAC_NUMPAD_7_KEY;
145 if(!stricmp(which,"KP8")){
146 return MAC_NUMPAD_8_KEY;
148 if(!stricmp(which,"KP9")){
149 return MAC_NUMPAD_9_KEY;
153 if(!stricmp(which,"enter")){
154 return MAC_ENTER_KEY;
158 if(!stricmp(which,"0")){
161 if(!stricmp(which,"1")){
164 if(!stricmp(which,"2")){
167 if(!stricmp(which,"3")){
170 if(!stricmp(which,"4")){
173 if(!stricmp(which,"5")){
176 if(!stricmp(which,"6")){
179 if(!stricmp(which,"7")){
182 if(!stricmp(which,"8")){
185 if(!stricmp(which,"9")){
190 if(!stricmp(which,"F1")){
193 if(!stricmp(which,"F2")){
196 if(!stricmp(which,"F3")){
199 if(!stricmp(which,"F4")){
202 if(!stricmp(which,"F5")){
205 if(!stricmp(which,"F6")){
208 if(!stricmp(which,"F7")){
211 if(!stricmp(which,"F8")){
214 if(!stricmp(which,"F9")){
217 if(!stricmp(which,"F10")){
220 if(!stricmp(which,"F11")){
223 if(!stricmp(which,"F12")){
228 if(!stricmp(which,"escape")){
229 return MAC_ESCAPE_KEY;
231 if(!stricmp(which,"backspace")){
232 return MAC_DELETE_KEY;
234 if(!stricmp(which,"tab")){
237 if(!stricmp(which,"`")){
238 return MAC_TILDE_KEY;
240 if(!stricmp(which,"caps_lock")){
241 return MAC_CAPS_LOCK_KEY;
246 if(!stricmp(which,"command")){
247 return MAC_COMMAND_KEY;
249 if(!stricmp(which,"option")){
250 return MAC_OPTION_KEY;
252 if(!stricmp(which,"delete")){
255 if(!stricmp(which,"insert")){
256 return MAC_INSERT_KEY;
258 if(!stricmp(which,"home")){
261 if(!stricmp(which,"end")){
264 if(!stricmp(which,"page_up")){
265 return MAC_PAGE_UP_KEY;
267 if(!stricmp(which,"page_down")){
268 return MAC_PAGE_DOWN_KEY;
270 if(!stricmp(which,"clear")){
271 return MAC_NUMPAD_CLEAR_KEY;
274 if(!stricmp(which,"control")){
275 return MAC_CONTROL_KEY;
277 if(!stricmp(which,"return")){
278 return MAC_RETURN_KEY;
280 if(!stricmp(which,"space")){
281 return MAC_SPACE_KEY;
283 if(!stricmp(which,"shift")){
284 return MAC_SHIFT_KEY;
286 if(!stricmp(which,"uparrow")){
287 return MAC_ARROW_UP_KEY;
289 if(!stricmp(which,"downarrow")){
290 return MAC_ARROW_DOWN_KEY;
292 if(!stricmp(which,"leftarrow")){
293 return MAC_ARROW_LEFT_KEY;
295 if(!stricmp(which,"rightarrow")){
296 return MAC_ARROW_RIGHT_KEY;
298 if(!stricmp(which,"mouse1")){
299 return MAC_MOUSEBUTTON1;
301 if(!stricmp(which,"mouse2")){
302 return MAC_MOUSEBUTTON2;
304 if(!stricmp(which,"+")){
305 return MAC_NUMPAD_PLUS_KEY;
307 if(!stricmp(which,"*")){
308 return MAC_NUMPAD_ASTERISK_KEY;
310 if(!stricmp(which,"/")){
311 return MAC_SLASH_KEY;
313 if(!stricmp(which,"\\")){
314 return MAC_BACKSLASH_KEY;
316 if(!stricmp(which,"[")){
317 return MAC_LEFTBRACKET_KEY;
319 if(!stricmp(which,"]")){
320 return MAC_RIGHTBRACKET_KEY;
322 if(!stricmp(which,".")){
323 return MAC_PERIOD_KEY;
325 if(!stricmp(which,",")){
326 return MAC_COMMA_KEY;
328 if(!stricmp(which,"\"")){
329 return MAC_APOSTROPHE_KEY;
331 if(!stricmp(which,";")){
332 return MAC_SEMICOLON_KEY;
337 char* KeyToChar(unsigned short which)
342 if(which==MAC_A_KEY){
345 if(which==MAC_B_KEY){
348 if(which==MAC_C_KEY){
351 if(which==MAC_D_KEY){
354 if(which==MAC_E_KEY){
357 if(which==MAC_F_KEY){
360 if(which==MAC_G_KEY){
363 if(which==MAC_H_KEY){
366 if(which==MAC_I_KEY){
369 if(which==MAC_J_KEY){
372 if(which==MAC_K_KEY){
375 if(which==MAC_L_KEY){
378 if(which==MAC_M_KEY){
381 if(which==MAC_N_KEY){
384 if(which==MAC_O_KEY){
387 if(which==MAC_P_KEY){
390 if(which==MAC_Q_KEY){
393 if(which==MAC_R_KEY){
396 if(which==MAC_S_KEY){
399 if(which==MAC_T_KEY){
402 if(which==MAC_U_KEY){
405 if(which==MAC_V_KEY){
408 if(which==MAC_W_KEY){
411 if(which==MAC_X_KEY){
414 if(which==MAC_Y_KEY){
417 if(which==MAC_Z_KEY){
422 if(which==MAC_NUMPAD_1_KEY){
425 if(which==MAC_NUMPAD_2_KEY){
428 if(which==MAC_NUMPAD_3_KEY){
431 if(which==MAC_NUMPAD_4_KEY){
434 if(which==MAC_NUMPAD_5_KEY){
437 if(which==MAC_NUMPAD_6_KEY){
440 if(which==MAC_NUMPAD_7_KEY){
443 if(which==MAC_NUMPAD_8_KEY){
446 if(which==MAC_NUMPAD_9_KEY){
449 if(which==MAC_NUMPAD_0_KEY){
454 if(which==MAC_ENTER_KEY){
459 if(which==MAC_1_KEY){
462 if(which==MAC_2_KEY){
465 if(which==MAC_3_KEY){
468 if(which==MAC_4_KEY){
471 if(which==MAC_5_KEY){
474 if(which==MAC_6_KEY){
477 if(which==MAC_7_KEY){
480 if(which==MAC_8_KEY){
483 if(which==MAC_9_KEY){
486 if(which==MAC_0_KEY){
491 if(which==MAC_F1_KEY){
494 if(which==MAC_F2_KEY){
497 if(which==MAC_F3_KEY){
500 if(which==MAC_F4_KEY){
503 if(which==MAC_F5_KEY){
506 if(which==MAC_F6_KEY){
509 if(which==MAC_F7_KEY){
512 if(which==MAC_F8_KEY){
515 if(which==MAC_F9_KEY){
518 if(which==MAC_F10_KEY){
521 if(which==MAC_F11_KEY){
524 if(which==MAC_F12_KEY){
529 if(which==MAC_ESCAPE_KEY){
532 if(which==MAC_DELETE_KEY){
535 if(which==MAC_TAB_KEY){
538 if(which==MAC_TILDE_KEY){
541 if(which==MAC_CAPS_LOCK_KEY){
544 if(which==MAC_COMMAND_KEY){
547 if(which==MAC_OPTION_KEY){
550 if(which==MAC_DEL_KEY){
553 if(which==MAC_INSERT_KEY){
556 if(which==MAC_HOME_KEY){
559 if(which==MAC_END_KEY){
562 if(which==MAC_PAGE_UP_KEY){
565 if(which==MAC_PAGE_DOWN_KEY){
568 if(which==MAC_NUMPAD_CLEAR_KEY){
571 if(which==MAC_CONTROL_KEY){
574 if(which==MAC_SPACE_KEY){
577 if(which==MAC_RETURN_KEY){
580 if(which==MAC_SHIFT_KEY){
583 if(which==MAC_ARROW_UP_KEY){
586 if(which==MAC_ARROW_DOWN_KEY){
589 if(which==MAC_ARROW_LEFT_KEY){
592 if(which==MAC_ARROW_RIGHT_KEY){
595 if(which==MAC_MOUSEBUTTON1){
598 if(which==MAC_MOUSEBUTTON2){
601 if(which==MAC_ARROW_RIGHT_KEY){
604 if(which==MAC_MINUS_KEY||which==MAC_NUMPAD_MINUS_KEY){
607 if(which==MAC_PLUS_KEY||which==MAC_NUMPAD_EQUALS_KEY){
610 if(which==MAC_NUMPAD_PLUS_KEY){
613 if(which==MAC_NUMPAD_ASTERISK_KEY){
616 if(which==MAC_SLASH_KEY||which==MAC_NUMPAD_SLASH_KEY){
619 if(which==MAC_BACKSLASH_KEY){
622 if(which==MAC_LEFTBRACKET_KEY){
625 if(which==MAC_RIGHTBRACKET_KEY){
628 if(which==MAC_PERIOD_KEY||which==MAC_NUMPAD_PERIOD_KEY){
631 if(which==MAC_COMMA_KEY){
634 if(which==MAC_APOSTROPHE_KEY){
637 if(which==MAC_SEMICOLON_KEY){
643 char KeyToSingleChar(unsigned short which)
647 if(which==MAC_A_KEY){
650 if(which==MAC_B_KEY){
653 if(which==MAC_C_KEY){
656 if(which==MAC_D_KEY){
659 if(which==MAC_E_KEY){
662 if(which==MAC_F_KEY){
665 if(which==MAC_G_KEY){
668 if(which==MAC_H_KEY){
671 if(which==MAC_I_KEY){
674 if(which==MAC_J_KEY){
677 if(which==MAC_K_KEY){
680 if(which==MAC_L_KEY){
683 if(which==MAC_M_KEY){
686 if(which==MAC_N_KEY){
689 if(which==MAC_O_KEY){
692 if(which==MAC_P_KEY){
695 if(which==MAC_Q_KEY){
698 if(which==MAC_R_KEY){
701 if(which==MAC_S_KEY){
704 if(which==MAC_T_KEY){
707 if(which==MAC_U_KEY){
710 if(which==MAC_V_KEY){
713 if(which==MAC_W_KEY){
716 if(which==MAC_X_KEY){
719 if(which==MAC_Y_KEY){
722 if(which==MAC_Z_KEY){
725 if(which==MAC_NUMPAD_1_KEY){
728 if(which==MAC_NUMPAD_2_KEY){
731 if(which==MAC_NUMPAD_3_KEY){
734 if(which==MAC_NUMPAD_4_KEY){
737 if(which==MAC_NUMPAD_5_KEY){
740 if(which==MAC_NUMPAD_6_KEY){
743 if(which==MAC_NUMPAD_7_KEY){
746 if(which==MAC_NUMPAD_8_KEY){
749 if(which==MAC_NUMPAD_9_KEY){
752 if(which==MAC_NUMPAD_0_KEY){
755 if(which==MAC_1_KEY){
758 if(which==MAC_2_KEY){
761 if(which==MAC_3_KEY){
764 if(which==MAC_4_KEY){
767 if(which==MAC_5_KEY){
770 if(which==MAC_6_KEY){
773 if(which==MAC_7_KEY){
776 if(which==MAC_8_KEY){
779 if(which==MAC_9_KEY){
782 if(which==MAC_0_KEY){
785 if(which==MAC_SPACE_KEY){
788 if(which==MAC_MINUS_KEY||which==MAC_NUMPAD_MINUS_KEY){
791 if(which==MAC_PLUS_KEY||which==MAC_NUMPAD_EQUALS_KEY){
794 if(which==MAC_NUMPAD_PLUS_KEY){
797 if(which==MAC_NUMPAD_ASTERISK_KEY){
800 if(which==MAC_SLASH_KEY||which==MAC_NUMPAD_SLASH_KEY){
803 if(which==MAC_BACKSLASH_KEY){
806 if(which==MAC_LEFTBRACKET_KEY){
809 if(which==MAC_RIGHTBRACKET_KEY){
812 if(which==MAC_PERIOD_KEY||which==MAC_NUMPAD_PERIOD_KEY){
815 if(which==MAC_COMMA_KEY){
818 if(which==MAC_APOSTROPHE_KEY){
821 if(which==MAC_SEMICOLON_KEY){
827 char Shift(char which)
984 bool Compare(char *thestring, char *tocompare, int start, int end)
987 for(i=start;i<=end;i++){
988 if(thestring[i]!=tocompare[i-start]&&thestring[i]!=tocompare[i-start]+'A'-'a')return 0;