OSDN Git Service

updated copyleft and need to test and fix newer version of open watcom
[proj16/16.git] / src / lib / 16_in.h
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2022 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 //\r
23 //      ID Engine\r
24 //      ID_IN.h - Header file for Input Manager\r
25 //      v1.0d1w\r
26 //      By Jason Blochowiak\r
27 //      Open Watcom port by sparky4\r
28 //\r
29 \r
30 #ifndef __16_IN__\r
31 #define __16_IN__\r
32 \r
33 #include <string.h>\r
34 #include "src/lib/16_head.h"\r
35 #include "src/lib/16_timer.h"\r
36 #include "src/lib/16_dbg.h"\r
37 #ifdef __WATCOMC__      //borland C BCEXMM.EXE\r
38 #include "src/lib/16_spri.h"\r
39 #include "src/lib/16_enti.h"\r
40 #endif\r
41 \r
42 #define KeyInt  9       // The keyboard ISR number\r
43 \r
44 // Stuff for the joystick\r
45 #define JoyScaleMax             32768\r
46 #define JoyScaleShift   8\r
47 #define MaxJoyValue             5000\r
48 \r
49 //#define       MaxPlayers              2//future plans for multiple playable charaters and being able to alternate\r
50 #define MaxKbds         2\r
51 #define MaxJoys         2\r
52 #define NumCodes        128\r
53 \r
54 //typedef       byte            ScanCode;\r
55 #define sc_None                 0\r
56 #define sc_Bad                  0xff\r
57 #define sc_Return               0x1c\r
58 #define sc_Enter                sc_Return\r
59 #define sc_Escape               0x01\r
60 #define sc_Space                0x39\r
61 #define sc_BackSpace    0x0e\r
62 #define sc_Tab                  0x0f\r
63 #define sc_Alt                  0x38\r
64 #define sc_Control              0x1d\r
65 #define sc_CapsLock             0x3a\r
66 #define sc_LShift               0x2a\r
67 #define sc_RShift               0x36\r
68 #define sc_UpArrow              0x48\r
69 #define sc_DownArrow    0x50\r
70 #define sc_LeftArrow    0x4b\r
71 #define sc_RightArrow   0x4d\r
72 #define sc_Insert               0x52\r
73 #define sc_Delete               0x53\r
74 #define sc_Home                 0x47\r
75 #define sc_End                  0x4f\r
76 #define sc_PgUp                 0x49\r
77 #define sc_PgDn                 0x51\r
78 #define sc_F1                   0x3b\r
79 #define sc_F2                   0x3c\r
80 #define sc_F3                   0x3d\r
81 #define sc_F4                   0x3e\r
82 #define sc_F5                   0x3f\r
83 #define sc_F6                   0x40\r
84 #define sc_F7                   0x41\r
85 #define sc_F8                   0x42\r
86 #define sc_F9                   0x43\r
87 #define sc_F10                  0x44\r
88 #define sc_F11                  0x57\r
89 #define sc_F12                  0x59\r
90 \r
91 #define sc_1                    0x02\r
92 #define sc_2                    0x03\r
93 #define sc_3                    0x04\r
94 #define sc_4                    0x05\r
95 #define sc_5                    0x06\r
96 #define sc_6                    0x07\r
97 #define sc_7                    0x08\r
98 #define sc_8                    0x09\r
99 #define sc_9                    0x0a\r
100 #define sc_0                    0x0b\r
101 \r
102 #define sc_A                    0x1e\r
103 #define sc_B                    0x30\r
104 #define sc_C                    0x2e\r
105 #define sc_D                    0x20\r
106 #define sc_E                    0x12\r
107 #define sc_F                    0x21\r
108 #define sc_G                    0x22\r
109 #define sc_H                    0x23\r
110 #define sc_I                    0x17\r
111 #define sc_J                    0x24\r
112 #define sc_K                    0x25\r
113 #define sc_L                    0x26\r
114 #define sc_M                    0x32\r
115 #define sc_N                    0x31\r
116 #define sc_O                    0x18\r
117 #define sc_P                    0x19\r
118 #define sc_Q                    0x10\r
119 #define sc_R                    0x13\r
120 #define sc_S                    0x1f\r
121 #define sc_T                    0x14\r
122 #define sc_U                    0x16\r
123 #define sc_V                    0x2f\r
124 #define sc_W                    0x11\r
125 #define sc_X                    0x2d\r
126 #define sc_Y                    0x15\r
127 #define sc_Z                    0x2c\r
128 \r
129 #define key_None                0\r
130 #define key_Return              0x0d\r
131 #define key_Enter               key_Return\r
132 #define key_Escape              0x1b\r
133 #define key_Space               0x20\r
134 #define key_BackSpace   0x08\r
135 #define key_Tab                 0x09\r
136 #define key_Delete              0x7f\r
137 \r
138 #define key_LSuper                      0x5b\r
139 #define key_RSuper                      0x5c\r
140 #define key_Menu                        0x5d\r
141 #define sc_LBrkt                0x1a    //      [\r
142 #define sc_RBrkt                0x1b    //      ]\r
143 #define sc_BackSlash    0x2b    //      |\r
144 #define sc_ForeSlash    0x35    //      / ?\r
145 \r
146 //      Stuff for the mouse\r
147 //moved to 16_tdef.h\r
148 /*#define       MReset          0\r
149 #define MButtons        3\r
150 #define MDelta          11\r
151 \r
152 #define MouseInt        0x33*/\r
153 #define Mouse(x)        _AX = x,geninterrupt(MouseInt)\r
154 \r
155 #ifdef DEMO0\r
156 typedef enum            {\r
157                                                 demo_Off,demo_Record,demo_Playback,demo_PlayDone\r
158                                         } Demo;\r
159 #endif\r
160 //moved to 16_tdef.h\r
161 /*typedef       enum            {\r
162                                                 //ctrl_None,                            // MDM (GAMERS EDGE) - added\r
163                                                 ctrl_Keyboard,\r
164                                                         ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,\r
165                                                 ctrl_Joystick,\r
166                                                         ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,\r
167                                                 ctrl_Mouse,\r
168                                         } ControlType;\r
169 typedef enum            {\r
170                                                 motion_Left = -1,motion_Up = -1,\r
171                                                 motion_None = 0,\r
172                                                 motion_Right = 1,motion_Down = 1\r
173                                         } Motion;\r
174 typedef enum            {\r
175                                                 dir_North,//dir_NorthEast,\r
176                                                 dir_West,//dir_Nortinest,\r
177                                                 dir_None,\r
178                                                 dir_East,//,dir_SouthEast,\r
179                                                 dir_South,//dir_Soutinest,\r
180                                         } Direction;\r
181 typedef struct          {\r
182                                                 boolean near    button0,button1,button2,button3;\r
183                                                 int     near            x,y;\r
184                                                 Motion  near    xaxis,yaxis;\r
185                                                 Direction near  dir;\r
186                                         } CursorInfo;\r
187 \r
188 typedef struct          {\r
189                                                 ScanCode near   button0,button1,\r
190                                                                         //upleft,\r
191                                                                         up,\r
192                                                                         down,\r
193                                                                         left,\r
194                                                                         right\r
195                                                                         //upright,\r
196                                                                         //downleft,\r
197                                                                         //,downright\r
198                                                                         ;\r
199                                         } KeyboardDef;\r
200 typedef struct          {\r
201                                                 word    near    joyMinX,joyMinY,\r
202                                                                         threshMinX,threshMinY,\r
203                                                                         threshMaxX,threshMaxY,\r
204                                                                         joyMaxX,joyMaxY,\r
205                                                                         joyMultXL,joyMultYL,\r
206                                                                         joyMultXH,joyMultYH;\r
207                                         } JoystickDef;*/\r
208 \r
209 /*\r
210 =============================================================================\r
211 \r
212                                         GLOBAL VARIABLES\r
213 \r
214 =============================================================================\r
215 */\r
216 #ifdef DEMO0\r
217                 static Demo             DemoMode = demo_Off;\r
218                 static byte /*_seg*/    *DemoBuffer;\r
219                 static word             DemoOffset,DemoSize;\r
220 #endif\r
221 \r
222 //      Internal routines\r
223 extern  void            IN_Startup(global_game_variables_t *gvar),IN_Shutdown(global_game_variables_t *gvar),\r
224                                         IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar),\r
225                                         IN_SetKeyHook(void (*)()),\r
226                                         IN_ClearKeysDown(void),\r
227                                         IN_ReadCursor(CursorInfo *, global_game_variables_t *gvar),\r
228                                         IN_ReadControl(player_t *player, global_game_variables_t *gvar),\r
229                                         IN_SetControlType(player_t *player,ControlType type),\r
230                                         IN_GetJoyAbs(word joy,word *xp,word *yp),\r
231                                         IN_SetupJoy(word joy,word minx,word maxx,\r
232                                                                 word miny,word maxy, global_game_variables_t *gvar),\r
233 #if DEMO0\r
234                                         IN_StopDemo(void),IN_FreeDemoBuffer(void),\r
235 #endif\r
236                                         IN_Ack(global_game_variables_t *gvar),IN_AckBack(void);\r
237 extern  boolean         IN_UserInput(word delay, global_game_variables_t *gvar);\r
238 extern  char            IN_WaitForASCII(void);\r
239 extern  ScanCode        IN_WaitForKey(void);\r
240 extern  word            IN_GetJoyButtonsDB(word joy);\r
241 extern  byte            *IN_GetScanName(ScanCode);\r
242 \r
243 \r
244 byte    IN_MouseButtons (global_game_variables_t *gvar);\r
245 word    IN_JoyButtons (void);\r
246 \r
247 void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/, global_game_variables_t *gvar);\r
248 void IN_StartAck(global_game_variables_t *gvar);\r
249 boolean IN_CheckAck (global_game_variables_t *gvar);\r
250 boolean IN_IsUserInput(global_game_variables_t *gvar);\r
251 #if DEMO0\r
252 boolean IN_StartDemoRecord(word bufsize);\r
253 void IN_StartDemoPlayback(byte *buffer,word bufsize);\r
254 void IN_StopDemo(void);\r
255 void IN_FreeDemoBuffer(void);\r
256 #endif\r
257 \r
258 //boolean       IN_KeyDown(byte code),\r
259 //              IN_qb(byte kee);\r
260 void            IN_ClearKey(byte code),\r
261                 IN_KbdLED();\r
262 ScanCode        IN_GetLastScan(),\r
263                 IN_GetCurCode();\r
264 \r
265 #endif\r