1 /* Catacomb Apocalypse Source Code
\r
2 * Copyright (C) 1993-2014 Flat Rock Software
\r
4 * This program is free software; you can redistribute it and/or modify
\r
5 * it under the terms of the GNU General Public License as published by
\r
6 * the Free Software Foundation; either version 2 of the License, or
\r
7 * (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License along
\r
15 * with this program; if not, write to the Free Software Foundation, Inc.,
\r
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
21 // ID_IN.h - Header file for Input Manager
\r
23 // By Jason Blochowiak
\r
24 // Open Watcom port by sparky4
\r
31 #include "src/lib/16_head.h"
\r
32 #include "src/lib/16_timer.h"
\r
33 #ifdef __WATCOMC__ //borland C BCEXMM.EXE
\r
34 #include "src/lib/16_dbg.h"
\r
35 #include "src/lib/16_sprit.h"
\r
36 #include "src/lib/bitmap.h" //old format
\r
39 //#define __DEBUG_InputMgr__
\r
42 #ifdef __DEBUG_InputMgr__
\r
44 //#define TESTCONTROLNOISY
\r
47 extern boolean testkeyin,testcontrolnoisy;
\r
49 //if else for gfxtesting and direction
\r
50 //player[pn].d == 2 ||
\r
51 //player[pn].d != 2 ||
\r
52 #define DIRECTIONIFELSE (player[pn].info.dir == 2)
\r
53 //#define NDIRECTIONIFELSE (player[pn].info.dir != 2)
\r
55 #define KeyInt 9 // The keyboard ISR number
\r
57 // Stuff for the joystick
\r
58 #define JoyScaleMax 32768
\r
59 #define JoyScaleShift 8
\r
60 #define MaxJoyValue 5000
\r
62 #define MaxPlayers 4
\r
66 #define NumCodes 128
\r
68 typedef byte ScanCode;
\r
71 #define sc_Return 0x1c
\r
72 #define sc_Enter sc_Return
\r
73 #define sc_Escape 0x01
\r
74 #define sc_Space 0x39
\r
75 #define sc_BackSpace 0x0e
\r
78 #define sc_Control 0x1d
\r
79 #define sc_CapsLock 0x3a
\r
80 #define sc_LShift 0x2a
\r
81 #define sc_RShift 0x36
\r
82 #define sc_UpArrow 0x48
\r
83 #define sc_DownArrow 0x50
\r
84 #define sc_LeftArrow 0x4b
\r
85 #define sc_RightArrow 0x4d
\r
86 #define sc_Insert 0x52
\r
87 #define sc_Delete 0x53
\r
88 #define sc_Home 0x47
\r
90 #define sc_PgUp 0x49
\r
91 #define sc_PgDn 0x51
\r
101 #define sc_F10 0x44
\r
102 #define sc_F11 0x57
\r
103 #define sc_F12 0x59
\r
144 #define key_Return 0x0d
\r
145 #define key_Enter key_Return
\r
146 #define key_Escape 0x1b
\r
147 #define key_Space 0x20
\r
148 #define key_BackSpace 0x08
\r
149 #define key_Tab 0x09
\r
150 #define key_Delete 0x7f
\r
152 #define key_LSuper 0x5b
\r
153 #define key_RSuper 0x5c
\r
154 #define key_Menu 0x5d
\r
156 // Stuff for the mouse
\r
161 #define MouseInt 0x33
\r
164 demo_Off,demo_Record,demo_Playback,demo_PlayDone
\r
168 //ctrl_None, // MDM (GAMERS EDGE) - added
\r
170 ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,
\r
172 ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,
\r
176 motion_Left = -1,motion_Up = -1,
\r
178 motion_Right = 1,motion_Down = 1
\r
181 dir_North,//dir_NorthEast,
\r
182 dir_West,//dir_Nortinest,
\r
184 dir_East,//,dir_SouthEast,
\r
185 dir_South,//dir_Soutinest,
\r
188 boolean near button0,button1,button2,button3;
\r
190 Motion near xaxis,yaxis;
\r
191 Direction near dir;
\r
195 ScanCode near button0,button1,
\r
207 word near joyMinX,joyMinY,
\r
208 threshMinX,threshMinY,
\r
209 threshMaxX,threshMaxY,
\r
211 joyMultXL,joyMultYL,
\r
212 joyMultXH,joyMultYH;
\r
217 int x; //player exact position on the viewable map
\r
218 int y; //player exact position on the viewable map
\r
219 int tx; //player tile position on the viewable map
\r
220 int ty; //player tile position on the viewable map
\r
221 int triggerx; //player's trigger box tile position on the viewable map
\r
222 int triggery; //player's trigger box tile position on the viewable map
\r
223 int sheetsetx; //NOT USED YET! player sprite sheet set on the image x
\r
224 int sheetsety; //NOT USED YET! player sprite sheet set on the image y
\r
225 byte d; //direction to render sprite!! wwww
\r
226 byte q; //loop variable for anumation and locking the playing to compleate the animation cycle to prevent issues with misalignment www
\r
227 byte near pdir; //previous direction~
\r
228 //byte near kd[2]; //array of arrow key pressed
\r
229 word speed; //player speed!
\r
230 word spt; //speed per tile
\r
231 //0000 planar_buf_t huge *data; //supposively the sprite sheet data
\r
232 // planar_buf_t data; //supposively the sprite sheet data
\r
234 struct sprite *spri; //supposively the sprite sheet data
\r
235 bitmap_t *data; //supposively the sprite sheet data//old format
\r
236 sword hp; //hitpoints of the player
\r
237 int persist_aniframe; /* gonna be increased to 1 before being used, so 0 is ok for default */
\r
239 ControlType Controls;
\r
243 =============================================================================
\r
247 =============================================================================
\r
249 /*extern struct inconfig
\r
251 boolean MousePresent;
\r
252 boolean JoysPresent[MaxJoys];
\r
253 boolean Keyboard[NumCodes];
\r
258 KeyboardDef KbdDefs[MaxKbds];
\r
259 JoystickDef JoyDefs[MaxJoys];
\r
263 static Demo DemoMode = demo_Off;
\r
264 static byte /*_seg*/ *DemoBuffer;
\r
265 static word DemoOffset,DemoSize;
\r
268 // Internal routines
\r
269 extern void interrupt INL_KeyService();
\r
270 extern void Mouse(int x);
\r
271 //static void INL_GetMouseDelta(int *x,int *y);
\r
272 //static word INL_GetMouseButtons(void);
\r
273 extern void IN_GetJoyAbs(word joy,word *xp,word *yp);
\r
274 //static void INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive);
\r
275 //static word INL_GetJoyButtons(word joy);
\r
276 extern word IN_GetJoyButtonsDB(word joy);
\r
277 //static void INL_StartKbd(void);
\r
278 //static void INL_ShutKbd(void);
\r
279 //static boolean INL_StartMouse(void);
\r
280 //static void INL_ShutMouse(void);
\r
281 //static void INL_SetJoyScale(word joy);
\r
282 extern void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy);
\r
283 //static boolean INL_StartJoy(word joy);
\r
284 //static void INL_ShutJoy(word joy);
\r
285 extern void IN_Startup();
\r
286 extern void IN_Default(boolean gotit,player_t *player,ControlType nt);
\r
287 extern void IN_Shutdown();
\r
288 extern void IN_SetKeyHook(void (*hook)());
\r
289 extern void IN_ClearKeysDown();
\r
290 //static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy);
\r
291 extern void IN_ReadCursor(CursorInfo *info);
\r
292 extern void near IN_ReadControl(int pn,player_t *player);
\r
293 extern void IN_SetControlType(word pn,player_t *player,ControlType type);
\r
295 extern boolean IN_StartDemoRecord(word bufsize);
\r
296 extern void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize);
\r
297 extern void IN_StopDemo(void);
\r
298 extern void IN_FreeDemoBuffer(void);
\r
300 extern byte *IN_GetScanName(ScanCode scan);
\r
301 extern ScanCode IN_WaitForKey();
\r
302 extern char IN_WaitForASCII();
\r
303 extern void IN_AckBack();
\r
304 extern void IN_Ack();
\r
305 extern boolean IN_IsUserInput();
\r
306 extern boolean IN_UserInput(dword delay,boolean clear);
\r
307 extern boolean IN_KeyDown(byte code);
\r
308 extern void IN_ClearKey(byte code);
\r
309 extern boolean IN_qb(byte kee);
\r
310 void IN_initplayer(player_t *player, word pn);
\r