]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_in.h
__seguse.txt added to show _seg usage also OpenVGMFile needs to be ported to 16_snd...
[16.git] / src / lib / 16_in.h
old mode 100644 (file)
new mode 100755 (executable)
index 542f6e2..97a560d
@@ -1,42 +1,43 @@
-/* Catacomb Armageddon Source Code\r
- * Copyright (C) 1993-2014 Flat Rock Software\r
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
  *\r
- * This program is free software; you can redistribute it and/or modify\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
+ * the Free Software Foundation; either version 3 of the License, or\r
  * (at your option) any later version.\r
  *\r
- * This program is distributed in the hope that it will be useful,\r
+ * Project 16 is distributed in the hope that it will be useful,\r
  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
  * GNU General Public License for more details.\r
  *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
  */\r
-\r
 //\r
 //     ID Engine\r
 //     ID_IN.h - Header file for Input Manager\r
 //     v1.0d1w\r
-//     By Jason Blochowiak
-// Open Watcom port by sparky4\r
+//     By Jason Blochowiak\r
+//     Open Watcom port by sparky4\r
 //\r
 \r
 #ifndef        __16_IN__\r
 #define        __16_IN__\r
-
-#include <string.h>\r
-#include "src/lib/lib_head.h"\r
-//#include "src/lib/16_us.h"\r
-\r
-//++++#ifdef   __DEBUG__\r
-#define        __DEBUG_InputMgr__\r
-//++++#endif\r
 \r
-//#define DOMO\r
-#define TESTKEYIN\r
+#include <string.h>\r
+#include "src/lib/16_head.h"\r
+#include "src/lib/16_timer.h"\r
+#include "src/lib/16_dbg.h"\r
+#ifdef __WATCOMC__     //borland C BCEXMM.EXE\r
+#include "src/lib/16_spri.h"\r
+#include "src/lib/16_enti.h"\r
+#endif\r
 \r
 #define        KeyInt  9       // The keyboard ISR number\r
 \r
 #define        JoyScaleShift   8\r
 #define        MaxJoyValue             5000\r
 \r
-#define        MaxPlayers      4\r
+//#define      MaxPlayers              2//future plans for multiple playable charaters and being able to alternate\r
 #define        MaxKbds         2\r
 #define        MaxJoys         2\r
 #define        NumCodes        128\r
 \r
-typedef        byte            ScanCode;\r
+//typedef      byte            ScanCode;\r
 #define        sc_None                 0\r
 #define        sc_Bad                  0xff\r
 #define        sc_Return               0x1c\r
@@ -134,6 +135,10 @@ typedef    byte            ScanCode;
 #define        key_Tab                 0x09\r
 #define        key_Delete              0x7f\r
 \r
+#define        key_LSuper                      0x5b\r
+#define        key_RSuper                      0x5c\r
+#define        key_Menu                        0x5d\r
+\r
 //     Stuff for the mouse\r
 #define        MReset          0\r
 #define        MButtons        3\r
@@ -145,13 +150,14 @@ typedef   enum            {
                                                demo_Off,demo_Record,demo_Playback,demo_PlayDone\r
                                        } Demo;\r
 #endif\r
-typedef        enum            {\r
-                                               ctrl_None,                              // MDM (GAMERS EDGE) - added\r
+//moved to 16_tdef.h\r
+/*typedef      enum            {\r
+                                               //ctrl_None,                            // MDM (GAMERS EDGE) - added\r
                                                ctrl_Keyboard,\r
                                                        ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,\r
                                                ctrl_Joystick,\r
                                                        ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,\r
-                                               ctrl_Mouse\r
+                                               ctrl_Mouse,\r
                                        } ControlType;\r
 typedef        enum            {\r
                                                motion_Left = -1,motion_Up = -1,\r
@@ -160,38 +166,39 @@ typedef   enum            {
                                        } Motion;\r
 typedef        enum            {\r
                                                dir_North,//dir_NorthEast,\r
-                                               dir_East,//dir_SouthEast,\r
-                                               dir_South,//dir_SouthWest,\r
-                                               dir_West,//dir_NorthWest,\r
-                                               dir_None\r
+                                               dir_West,//dir_Nortinest,\r
+                                               dir_None,\r
+                                               dir_East,//,dir_SouthEast,\r
+                                               dir_South,//dir_Soutinest,\r
                                        } Direction;\r
 typedef        struct          {\r
-                                               boolean         button0,button1;\r
-                                               int                     x,y;\r
-                                               Motion          xaxis,yaxis;\r
-                                               Direction       dir;\r
+                                               boolean near    button0,button1,button2,button3;\r
+                                               int     near            x,y;\r
+                                               Motion  near    xaxis,yaxis;\r
+                                               Direction near  dir;\r
                                        } CursorInfo;\r
-typedef        CursorInfo      ControlInfo;\r
 \r
 typedef        struct          {\r
-                                               ScanCode        button0,button1,\r
+                                               ScanCode near   button0,button1,\r
                                                                        //upleft,\r
                                                                        up,\r
+                                                                       down,\r
+                                                                       left,\r
+                                                                       right\r
                                                                        //upright,\r
-                                                                       left,                           right,\r
                                                                        //downleft,\r
-                                                                       down\r
                                                                        //,downright\r
                                                                        ;\r
                                        } KeyboardDef;\r
 typedef        struct          {\r
-                                               word            joyMinX,joyMinY,\r
+                                               word    near    joyMinX,joyMinY,\r
                                                                        threshMinX,threshMinY,\r
                                                                        threshMaxX,threshMaxY,\r
                                                                        joyMaxX,joyMaxY,\r
                                                                        joyMultXL,joyMultYL,\r
                                                                        joyMultXH,joyMultYH;\r
-                                       } JoystickDef;\r
+                                       } JoystickDef;*/\r
+\r
 /*\r
 =============================================================================\r
 \r
@@ -199,136 +206,55 @@ typedef  struct          {
 \r
 =============================================================================\r
 */\r
-\r
-//\r
-// configuration variables\r
-//\r
-static boolean                 MousePresent;\r
-static boolean                 JoysPresent[MaxJoys];\r
-static boolean                 JoyPadPresent;\r
-\r
-//     Global variables\r
-               extern boolean JoystickCalibrated;              // MDM (GAMERS EDGE) - added\r
-               extern ControlType ControlTypeUsed;                             // MDM (GAMERS EDGE) - added\r
-\r
-               extern boolean          Keyboard[NumCodes];\r
-               extern boolean          Paused;\r
-               extern char             LastASCII;\r
-               extern ScanCode LastScan;\r
-\r
-               //extern KeyboardDef    KbdDefs[];
-               static KeyboardDef      KbdDefs[] = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};\r
-               extern JoystickDef      JoyDefs[MaxJoys];\r
-               extern ControlType      Controls[MaxPlayers];\r
-\r
-               extern dword    MouseDownCount;\r
-\r
 #ifdef DEMO0\r
                static Demo             DemoMode = demo_Off;\r
                static byte /*_seg*/    *DemoBuffer;\r
                static word             DemoOffset,DemoSize;\r
 #endif\r
 \r
-extern dword far* clockdw;\r
-\r
-/*\r
-=============================================================================\r
-\r
-                                       LOCAL VARIABLES\r
-\r
-=============================================================================\r
-*/\r
-static byte        far ASCIINames[] =          // Unshifted ASCII for scan codes\r
-                                       {\r
-//      0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r
-       0  ,27 ,'1','2','3','4','5','6','7','8','9','0','-','=',8  ,9  ,        // 0\r
-       'q','w','e','r','t','y','u','i','o','p','[',']',13 ,0  ,'a','s',        // 1\r
-       'd','f','g','h','j','k','l',';',39 ,'`',0  ,92 ,'z','x','c','v',        // 2\r
-       'b','n','m',',','.','/',0  ,'*',0  ,' ',0  ,0  ,0  ,0  ,0  ,0  ,        // 3\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,'7','8','9','-','4','5','6','+','1',        // 4\r
-       '2','3','0',127,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 5\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 6\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0           // 7\r
-                                       },\r
-                                       far ShiftNames[] =              // Shifted ASCII for scan codes\r
-                                       {\r
-//      0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r
-       0  ,27 ,'!','@','#','$','%','^','&','*','(',')','_','+',8  ,9  ,        // 0\r
-       'Q','W','E','R','T','Y','U','I','O','P','{','}',13 ,0  ,'A','S',        // 1\r
-       'D','F','G','H','J','K','L',':',34 ,'~',0  ,'|','Z','X','C','V',        // 2\r
-       'B','N','M','<','>','?',0  ,'*',0  ,' ',0  ,0  ,0  ,0  ,0  ,0  ,        // 3\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,'7','8','9','-','4','5','6','+','1',        // 4\r
-       '2','3','0',127,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 5\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 6\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0           // 7\r
-                                       },\r
-                                       far SpecialNames[] =    // ASCII for 0xe0 prefixed codes\r
-                                       {\r
-//      0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 0\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,13 ,0  ,0  ,0  ,        // 1\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 2\r
-       0  ,0  ,0  ,0  ,0  ,'/',0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 3\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 4\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 5\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 6\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0           // 7\r
-                                       };\r
-\r
-\r
-static boolean         IN_Started;\r
-static boolean         CapsLock;\r
-static ScanCode        CurCode,LastCode;\r
-\r
-static Direction       DirTable[] =            // Quick lookup for total direction\r
-                                       {\r
-                                               //dir_NorthWest,\r
-                                               dir_North,\r
-                                               //dir_NorthEast,\r
-                                               dir_West,               dir_None,       dir_East,\r
-                                               //dir_SouthWest,\r
-                                               dir_South//,dir_SouthEast\r
-                                       };\r
-\r
-static void                    (*INL_KeyHook)(void);\r
-static void interrupt  (*OldKeyVect)(void);\r
-\r
-static char                    *ParmStringsIN[] = {"nojoys","nomouse",nil};\r
-\r
-// Function prototypes\r
-#define        IN_KeyDown(code)        (Keyboard[(code)])\r
-#define        IN_ClearKey(code)       {Keyboard[code] = false;\\r
-                                                       if (code == LastScan) LastScan = sc_None;}\r
-\r
-// DEBUG - put names in prototypes\r
-extern void            IN_Startup(void),IN_Shutdown(void),\r
-                                       IN_Default(boolean gotit,ControlType in),\r
+//     Internal routines\r
+extern void            IN_Startup(global_game_variables_t *gvar),IN_Shutdown(global_game_variables_t *gvar),\r
+                                       IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar),\r
                                        IN_SetKeyHook(void (*)()),\r
                                        IN_ClearKeysDown(void),\r
-                                       IN_ReadCursor(CursorInfo *),\r
-                                       IN_ReadControl(int,ControlInfo *),\r
-                                       IN_SetControlType(int,ControlType),\r
+                                       IN_ReadCursor(CursorInfo *, global_game_variables_t *gvar),\r
+                                       IN_ReadControl(player_t *player, global_game_variables_t *gvar),\r
+                                       IN_SetControlType(player_t *player,ControlType type),\r
                                        IN_GetJoyAbs(word joy,word *xp,word *yp),\r
                                        IN_SetupJoy(word joy,word minx,word maxx,\r
-                                                               word miny,word maxy),\r
-                                       Mouse(int x),\r
-#ifdef DEMO0\r
-                                       IN_StartDemoPlayback(byte __segment *buffer,word bufsize),\r
+                                                               word miny,word maxy, global_game_variables_t *gvar),\r
+#if DEMO0\r
                                        IN_StopDemo(void),IN_FreeDemoBuffer(void),\r
 #endif\r
-                                       IN_Ack(void),IN_AckBack(void);\r
-extern boolean         IN_UserInput(dword delay,boolean clear),\r
-                                       IN_IsUserInput(void)\r
-#ifdef DEMO0\r
-                                       , IN_StartDemoRecord(word bufsize)\r
-#endif\r
-;\r
-extern byte            *IN_GetScanName(ScanCode);\r
+                                       IN_Ack(global_game_variables_t *gvar),IN_AckBack(void);\r
+extern boolean         IN_UserInput(word delay, global_game_variables_t *gvar);\r
 extern char            IN_WaitForASCII(void);\r
 extern ScanCode        IN_WaitForKey(void);\r
 extern word            IN_GetJoyButtonsDB(word joy);\r
+extern byte            *IN_GetScanName(ScanCode);\r
+\r
+\r
+byte   IN_MouseButtons (global_game_variables_t *gvar);\r
+byte   IN_JoyButtons (void);\r
+\r
+void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/, global_game_variables_t *gvar);\r
+void IN_StartAck(global_game_variables_t *gvar);\r
+boolean IN_CheckAck (global_game_variables_t *gvar);\r
+boolean IN_IsUserInput(global_game_variables_t *gvar);\r
+#define Mouse(x)         INL_Mouse(x)\r
+//void IN_SetKeyHook(void (*hook)());\r
+#if DEMO0\r
+boolean IN_StartDemoRecord(word bufsize);\r
+void IN_StartDemoPlayback(byte *buffer,word bufsize);\r
+void IN_StopDemo(void);\r
+void IN_FreeDemoBuffer(void);\r
+#endif\r
 \r
+boolean        IN_KeyDown(byte code),\r
+               IN_qb(byte kee);\r
+void           IN_ClearKey(byte code),\r
+               IN_KbdLED();\r
+ScanCode       IN_GetLastScan(),\r
+               IN_GetCurCode();\r
 \r
-void interrupt INL_KeyService(void);\r
-boolean IN_qb(byte kee);\r
 #endif\r