home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SLOWRUNS.ZIP / SLOWSRC.ZIP / MAGIC5.H < prev    next >
C/C++ Source or Header  |  1997-09-06  |  10KB  |  302 lines

  1. // defines for the keyboard interface
  2.  
  3. #define KEYBOARD_INTERRUPT            0x09    // the keyboard interrupt number
  4. #define KEY_BUFFER                    0x60    // the port of the keyboard buffer
  5. #define KEY_CONTROL                    0x61    // the port of the keyboard controller
  6. #define PIC_PORT                    0x20    // the port of the peripheral
  7.                                             // interrupt controller (PIC)
  8. // these are the scan codes for the keys on the keyboard, note they are all
  9. // from 0-127 and hence are the "make" scan codes, 128-255 are for the break
  10. // scan codes and are computed simply by adding 128 to each of the make codes
  11.  
  12. #define MAKE_ESC                    1
  13. #define MAKE_1                        2
  14. #define MAKE_2                        3
  15. #define MAKE_3                        4
  16. #define MAKE_4                        5
  17. #define MAKE_5                        6
  18. #define MAKE_6                        7
  19. #define MAKE_7                        8
  20. #define MAKE_8                        9
  21. #define MAKE_9                        10
  22. #define MAKE_0                        11
  23. #define MAKE_MINUS                    12
  24. #define MAKE_EQUALS                    13
  25. #define MAKE_BKSP                    14
  26. #define MAKE_TAB                    15
  27. #define MAKE_Q                        16
  28. #define MAKE_W                        17
  29. #define MAKE_E                        18
  30. #define MAKE_R                        19
  31. #define MAKE_T                        20
  32. #define MAKE_Y                        21
  33. #define MAKE_U                        22
  34. #define MAKE_I                        23
  35. #define MAKE_O                        24
  36. #define MAKE_P                        25
  37. #define MAKE_LFT_BRACKET            26
  38. #define MAKE_RGT_BRACKET            27
  39. #define MAKE_ENTER                    28
  40. #define MAKE_CTRL                    29
  41. #define MAKE_A                        30
  42. #define MAKE_S                        31
  43. #define MAKE_D                        32
  44. #define MAKE_F                        33
  45. #define MAKE_G                        34
  46. #define MAKE_H                        35
  47. #define MAKE_J                        36
  48. #define MAKE_K                        37
  49. #define MAKE_L                        38
  50. #define MAKE_SEMI                    39
  51. #define MAKE_APOS                    40
  52. #define MAKE_TILDE                    41
  53. #define MAKE_LEFT_SHIFT                42
  54. #define MAKE_BACK_SLASH                43
  55. #define MAKE_Z                        44
  56. #define MAKE_X                        45
  57. #define MAKE_C                        46
  58. #define MAKE_V                        47
  59. #define MAKE_B                        48
  60. #define MAKE_N                        49
  61. #define MAKE_M                        50
  62. #define MAKE_COMMA                    51
  63. #define MAKE_PERIOD                    52
  64. #define MAKE_FORWARD_SLASH            53
  65. #define MAKE_RIGHT_SHIFT            54
  66. #define MAKE_PRT_SCRN                55
  67. #define MAKE_ALT                    56
  68. #define MAKE_SPACE                    57
  69. #define MAKE_CAPS_LOCK                58
  70. #define MAKE_F1                        59
  71. #define MAKE_F2                        60
  72. #define MAKE_F3                        61
  73. #define MAKE_F4                        62
  74. #define MAKE_F5                        63
  75. #define MAKE_F6                        64
  76. #define MAKE_F7                        65
  77. #define MAKE_F8                        66
  78. #define MAKE_F9                        67
  79. #define MAKE_F10                    68
  80. #define MAKE_F11                    87
  81. #define MAKE_F12                    88
  82. #define MAKE_NUM_LOCK                69
  83. #define MAKE_SCROLL_LOCK            70
  84. #define MAKE_HOME                    71
  85. #define MAKE_UP                        72
  86. #define MAKE_PGUP                    73
  87. #define MAKE_KEYPAD_MINUS            74
  88. #define MAKE_LEFT                    75
  89. #define MAKE_CENTER                    76
  90. #define MAKE_RIGHT                    77
  91. #define MAKE_KEYPAD_PLUS            78
  92. #define MAKE_END                    79
  93. #define MAKE_DOWN                    80
  94. #define MAKE_PGDWN                    81
  95. #define MAKE_INS                    82
  96. #define MAKE_DEL                    83
  97.  
  98. #define BREAK_ESC                    129
  99. #define BREAK_1                        130
  100. #define BREAK_2                        131
  101. #define BREAK_3                        132
  102. #define BREAK_4                        133
  103. #define BREAK_5                        134
  104. #define BREAK_6                        135
  105. #define BREAK_7                        136
  106. #define BREAK_8                        137
  107. #define BREAK_9                        138
  108. #define BREAK_0                        139
  109. #define BREAK_MINUS                    140
  110. #define BREAK_EQUALS                141
  111. #define BREAK_BKSP                    142
  112. #define BREAK_TAB                    143
  113. #define BREAK_Q                        144
  114. #define BREAK_W                        145
  115. #define BREAK_E                        146
  116. #define BREAK_R                        147
  117. #define BREAK_T                        148
  118. #define BREAK_Y                        149
  119. #define BREAK_U                        150
  120. #define BREAK_I                        151
  121. #define BREAK_O                        152
  122. #define BREAK_P                        153
  123. #define BREAK_LFT_BRACKET            154
  124. #define BREAK_RGT_BRACKET            155
  125. #define BREAK_ENTER                    156
  126. #define BREAK_CTRL                    157
  127. #define BREAK_A                        158
  128. #define BREAK_S                        159
  129. #define BREAK_D                        160
  130. #define BREAK_F                        161
  131. #define BREAK_G                        162
  132. #define BREAK_H                        163
  133. #define BREAK_J                        164
  134. #define BREAK_K                        165
  135. #define BREAK_L                        166
  136. #define BREAK_SEMI                    167
  137. #define BREAK_APOS                    168
  138. #define BREAK_TILDE                    169
  139. #define BREAK_LEFT_SHIFT            170
  140. #define BREAK_BACK_SLASH            171
  141. #define BREAK_Z                        172
  142. #define BREAK_X                        173
  143. #define BREAK_C                        174
  144. #define BREAK_V                        175
  145. #define BREAK_B                        176
  146. #define BREAK_N                        177
  147. #define BREAK_M                        178
  148. #define BREAK_COMMA                    179
  149. #define BREAK_PERIOD                180
  150. #define BREAK_FORWARD_SLASH            181
  151. #define BREAK_RIGHT_SHIFT            182
  152. #define BREAK_PRT_SCRN                183
  153. #define BREAK_ALT                    184
  154. #define BREAK_SPACE                    185
  155. #define BREAK_CAPS_LOCK                186
  156. #define BREAK_F1                    187
  157. #define BREAK_F2                    188
  158. #define BREAK_F3                    189
  159. #define BREAK_F4                    190
  160. #define BREAK_F5                    191
  161. #define BREAK_F6                    192
  162. #define BREAK_F7                    193
  163. #define BREAK_F8                    194
  164. #define BREAK_F9                    195
  165. #define BREAK_F10                    196
  166. #define BREAK_F11                    215
  167. #define BREAK_F12                    216
  168. #define BREAK_NUM_LOCK                197
  169. #define BREAK_SCROLL_LOCK            198
  170. #define BREAK_HOME                    199
  171. #define BREAK_UP                    200
  172. #define BREAK_PGUP                    201
  173. #define BREAK_KEYPAD_MINUS            202
  174. #define BREAK_LEFT                    203
  175. #define BREAK_CENTER                204
  176. #define BREAK_RIGHT                    205
  177. #define BREAK_KEYPAD_PLUS            206
  178. #define BREAK_END                    207
  179. #define BREAK_DOWN                    208
  180. #define BREAK_PGDWN                    209
  181. #define BREAK_INS                    210
  182. #define BREAK_DEL                    211
  183.  
  184. // bitmasks for the "shift state"
  185.  
  186. // note there is a difference between "on" and "down"
  187. #define KEY_UP                        0
  188. #define KEY_DOWN                    1
  189.  
  190. #define SHIFT_RIGHT                    0x0001    // right shift
  191. #define SHIFT_LEFT                    0x0002    // left shift
  192. #define CTRL                        0x0004    // control key
  193. #define ALT                            0x0008    // alternate key
  194. #define SCROLL_LOCK_ON                0x0010    // the scroll lock is on
  195. #define NUM_LOCK_ON                    0x0020    // the numeric lock is on
  196. #define CAPS_LOCK_ON                0x0040    // the capitals lock is on
  197. #define INSERT_MODE                    0x0080    // insert or overlay mode
  198. #define CTRL_LEFT                    0x0100    // the left control key is pressed
  199. #define ALT_LEFT                    0x0200    // the left alternate key is pressed
  200. #define CTRL_RIGHT                    0x0400    // the right control key is pressed
  201. #define ALT_RIGHT                    0x0800    // the right alternate key is pressed
  202. #define SCROLL_LOCK_DOWN            0x1000    // the scroll lock key is pressed
  203. #define NUM_LOCK_DOWN                0x2000    // the numeric lock key is pressed
  204. #define CAPS_LOCK_DOWN                0x4000    // the capitals lock key is pressed
  205. #define SYS_REG_DOWN                0x8000    // the system request key is pressed
  206.  
  207. // Joystick stuff
  208.  
  209. #define JOYPORT                        0x201    // joyport is at 201 hex
  210.  
  211. #define USE_BIOS                    0         // command to use BIOS version
  212. #define USE_LOW_LEVEL                1        // command to use our own low level version
  213.  
  214. #define JOYSTICK_BUTTON_1_1            0x10    // joystick1, button 1
  215. #define JOYSTICK_BUTTON_1_2            0x20    // joystick1, button 2
  216. #define JOYSTICK_BUTTON_2_1            0x40    // joystick2, button 1
  217. #define JOYSTICK_BUTTON_2_2            0x80    // joystick2, button 2
  218.  
  219. #define JOYSTICK_1                    0x01    // joystick 1
  220. #define JOYSTICK_2                    0x02    // joystick 2
  221. #define JOYSTICK_1_X                0x01    // joystick 1, x axis
  222. #define JOYSTICK_1_Y                0x02    // joystick 1, y axis
  223. #define JOYSTICK_2_X                0x04    // joystick 2, x axis
  224. #define JOYSTICK_2_Y                0x08    // joystick 2, y axis
  225.  
  226. // mouse stuff
  227.  
  228. #define MOUSE_INTERRUPT                0x33    // mouse interrupt handler
  229. #define MOUSE_RESET                    0x00    // reset the mouse
  230. #define MOUSE_SHOW                    0x01    // show the mouse
  231. #define MOUSE_HIDE                    0x02    // hide the mouse
  232. #define MOUSE_POSITION_BUTTONS        0x03    // get buttons and position
  233. #define MOUSE_MOTION_REL            0x0B    // query motion counters
  234.                                             // to compute relative motion
  235. #define MOUSE_SET_SENSITIVITY        0x1A    // set the sensitivity of mouse
  236.  
  237. // mouse button bitmasks
  238.  
  239. #define MOUSE_LEFT_BUTTON            0x01    // left mouse button mask
  240. #define MOUSE_MIDDLE_BUTTON            0x04    // middle mouse button mask
  241. #define MOUSE_RIGHT_BUTTON            0x02    // right mouse button mask
  242.  
  243. // E X T E R N A L S /////////////////////////////////////////////////////////
  244.  
  245. extern void (_interrupt _far *Old_Keyboard_ISR)();  // holds old keyboard interrupt handler
  246.  
  247. extern int raw_scan_code;  // the global keyboard scan code
  248.  
  249. extern int askey_code;   // the global keyboard ASCii code
  250.  
  251. // this holds the keyboard state table which tracks the state of every key
  252. // on the keyboard, if any element is a one then the key is down
  253.  
  254. extern int keyboard_state[128];
  255.  
  256. // this tracks the number of keys that are currently pressed, helps
  257. // with keyboard testing logic
  258.  
  259. extern int keys_active;
  260.  
  261. // these values hold the maximum, minimum and neutral joystick values for
  262. // both joysticks
  263.  
  264. extern unsigned int joystick_1_max_x,     // maximum deflection of X axis joy 1
  265.                     joystick_1_max_y,     // maximum deflection of Y axis joy 1
  266.                     joystick_1_min_x,     // minimum deflection of X axis joy 1
  267.                     joystick_1_min_y,     // minimum deflection of Y axis joy 1
  268.                     joystick_1_neutral_x, // neutral or center of X axis joy 1
  269.                     joystick_1_neutral_y, // neutral or center of Y axis joy 1
  270.  
  271.                     joystick_2_max_x,     // maximum deflection of X axis joy 2
  272.                     joystick_2_max_y,     // maximum deflection of Y axis joy 2
  273.                     joystick_2_min_x,     // minimum deflection of X axis joy 2
  274.                     joystick_2_min_y,     // minimum deflection of Y axis joy 2
  275.                     joystick_2_neutral_x, // neutral or center of X axis joy 2
  276.                     joystick_2_neutral_y; // neutral or center of Y axis joy 2
  277.  
  278. // P R O T O T Y P E S ////////////////////////////////////////////////////////
  279. // FUNCTION PROTOTYPES //////////////////////
  280.  
  281. unsigned char Get_Key(void);
  282. unsigned char Get_Scan_Code(void);
  283. unsigned int Get_Shift_State(unsigned int mask);
  284.  
  285. void Keyboard_Install_Driver(void);
  286. void Keyboard_Remove_Driver(void);
  287.  
  288. void _interrupt _far Keyboard_Driver(void);
  289.  
  290. // joystick stuff
  291.  
  292. unsigned char Joystick_Buttons(unsigned char button);
  293. unsigned int Joystick(unsigned char stick);
  294. unsigned int Joystick_Bios(unsigned char stick);
  295. void Joystick_Calibrate(int stick, int method);
  296.  
  297. int Joystick_Available(int stick_num);
  298.  
  299. // mouse stuff
  300.  
  301. int Mouse_Control(int command, int *x, int *y, int *buttons);
  302.