]> 4ch.mooo.com Git - 16.git/commitdiff
converting
authorsparky4 <sparky4@cock.li>
Mon, 29 Jun 2015 04:10:46 +0000 (23:10 -0500)
committersparky4 <sparky4@cock.li>
Mon, 29 Jun 2015 04:10:46 +0000 (23:10 -0500)
modified:   src/inputest.c
modified:   src/lib/16_in.c
modified:   src/lib/16_in.h

src/inputest.c
src/lib/16_in.c
src/lib/16_in.h

index 15a405f5065ac61feb1864e3cb5897b89e1fe394..9693104657c8cae19a318d09d173bf53caf6db17 100644 (file)
 void\r
 main(int argc, char *argv[])\r
 {\r
-       CursorInfo control;\r
+//     CursorInfo control;
+       player_t player[MaxPlayers];
+       hwconfig hw;
+       player.KbdDefs = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};
+\r
        extern boolean Keyboard[NumCodes];\r
-       IN_Startup();\r
-       IN_Default(0,ctrl_Joystick);\r
+       IN_Startup();
+       IN_Default(0,&player,ctrl_Joystick);\r
+//     IN_Default(0,ctrl_Joystick);\r
        while(!IN_qb(sc_Escape))\r
        {\r
                IN_ReadControl(0,&control);\r
index ea90a7159711e9cb1a047409d740481d89938edd..176144abf3d842c247d1730e9db0fb752ea69c18 100644 (file)
 //     Global variables
 //             boolean JoystickCalibrated=false;               // MDM (GAMERS EDGE) - added\r
 //             ControlType ControlTypeUsed;                            // MDM (GAMERS EDGE) - added\r
-               boolean         Keyboard[NumCodes];\r
-               boolean         Paused;\r
-               char            LastASCII;\r
-               ScanCode        LastScan;\r
+               //boolean               Keyboard[NumCodes];\r
+               //boolean               Paused;\r
+               //char          LastASCII;\r
+               //ScanCode      LastScan;\r
 \r
                //KeyboardDef   KbdDefs = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};\r
-               JoystickDef     JoyDefs[MaxJoys];\r
-               ControlType     Controls[MaxPlayers];\r
+               //JoystickDef   JoyDefs[MaxJoys];\r
+               //ControlType   Controls[MaxPlayers];\r
 \r
-               dword   MouseDownCount;
+               //dword MouseDownCount;
 
 //     Internal routines
 ///////////////////////////////////////////////////////////////////////////
@@ -66,7 +66,7 @@
 //
 ///////////////////////////////////////////////////////////////////////////
 void interrupt
-INL_KeyService(void)
+INL_KeyService(inconfig *in)
 {
 static boolean special;
                byte    k,c;
@@ -81,7 +81,7 @@ static        boolean special;
        if (k == 0xe0)          // Special key prefix
                special = true;
        else if (k == 0xe1)     // Handle Pause key
-               Paused = true;
+               in->Paused = true;
        else
        {
                if (k & 0x80)   // Break code
@@ -90,13 +90,13 @@ static      boolean special;
 
 // DEBUG - handle special keys: ctl-alt-delete, print scrn
 
-                       Keyboard[k] = false;
+                       in->Keyboard[k] = false;
                }
                else                    // Make code
                {
-                       LastCode = CurCode;
-                       CurCode = LastScan = k;
-                       Keyboard[k] = true;
+                       in->LastCode = in->CurCode;
+                       in->CurCode = in->LastScan = k;
+                       in->Keyboard[k] = true;
 
                        if (special)
                                c = SpecialNames[k];
@@ -104,25 +104,25 @@ static    boolean special;
                        {
                                if (k == sc_CapsLock)
                                {
-                                       CapsLock ^= true;
+                                       in->CapsLock ^= true;
                                        // DEBUG - make caps lock light work
                                }
 
-                               if (Keyboard[sc_LShift] || Keyboard[sc_RShift]) // If shifted
+                               if (in->Keyboard[sc_LShift] || in->Keyboard[sc_RShift]) // If shifted
                                {
                                        c = ShiftNames[k];
-                                       if ((c >= 'A') && (c <= 'Z') && CapsLock)
+                                       if ((c >= 'A') && (c <= 'Z') && in->CapsLock)
                                                c += 'a' - 'A';
                                }
                                else
                                {
                                        c = ASCIINames[k];
-                                       if ((c >= 'a') && (c <= 'z') && CapsLock)
+                                       if ((c >= 'a') && (c <= 'z') && in->CapsLock)
                                                c -= 'a' - 'A';
                                }
                        }
                        if (c)
-                               LastASCII = c;
+                               in->LastASCII = c;
                }
 
                special = false;
@@ -131,7 +131,7 @@ static      boolean special;
        if (INL_KeyHook && !special)
                INL_KeyHook();
        #ifdef TESTKEYIN
-       printf("%c %x %u\n", c, k, Keyboard[k]);
+       printf("%c %x %u\n", c, k, in->Keyboard[k]);
        #endif
        outp(0x20,0x20);
 }
@@ -263,7 +263,7 @@ done:
 //
 ///////////////////////////////////////////////////////////////////////////
 static void
-INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive)
+INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive, inconfig *in)
 {
        word            x,y;
        dword   time;
@@ -272,7 +272,7 @@ INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive)
 static dword   lasttime;
 
        IN_GetJoyAbs(joy,&x,&y);
-       def = JoyDefs + joy;
+       def = in->JoyDefs + joy;
 
        if (x < def->threshMinX)
        {
@@ -381,11 +381,11 @@ IN_GetJoyButtonsDB(word joy)
 //
 ///////////////////////////////////////////////////////////////////////////
 static void
-INL_StartKbd(void)
+INL_StartKbd(inconfig *in)
 {
        INL_KeyHook = 0;        // Clear key hook
 
-       IN_ClearKeysDown();
+       IN_ClearKeysDown(in);
 
        OldKeyVect = _dos_getvect(KeyInt);
        _dos_setvect(KeyInt,INL_KeyService);
@@ -436,11 +436,11 @@ INL_ShutMouse(void)
 //     INL_SetJoyScale() - Sets up scaling values for the specified joystick
 //
 static void
-INL_SetJoyScale(word joy)
+INL_SetJoyScale(word joy, inconfig *in)
 {
        JoystickDef     *def;
 
-       def = &JoyDefs[joy];
+       def = &(in->JoyDefs[joy]);
        def->joyMultXL = JoyScaleMax / (def->threshMinX - def->joyMinX);
        def->joyMultXH = JoyScaleMax / (def->joyMaxX - def->threshMaxX);
        def->joyMultYL = JoyScaleMax / (def->threshMinY - def->joyMinY);
@@ -454,12 +454,12 @@ INL_SetJoyScale(word joy)
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy)
+IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, inconfig *in)
 {
        word            d,r;
        JoystickDef     *def;
 
-       def = &JoyDefs[joy];
+       def = &(in->JoyDefs[joy]);
 
        def->joyMinX = minx;
        def->joyMaxX = maxx;
@@ -475,7 +475,7 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy)
        def->threshMinY = ((r / 2) - d) + miny;
        def->threshMaxY = ((r / 2) + d) + miny;
 
-       INL_SetJoyScale(joy);
+       INL_SetJoyScale(joy, in);
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -485,7 +485,7 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy)
 //
 ///////////////////////////////////////////////////////////////////////////
 static boolean
-INL_StartJoy(word joy)
+INL_StartJoy(word joy, inconfig *in)
 {
        word            x,y;
 
@@ -499,7 +499,7 @@ INL_StartJoy(word joy)
                return(false);
        else
        {
-               IN_SetupJoy(joy,0,x * 2,0,y * 2);
+               IN_SetupJoy(joy,0,x * 2,0,y * 2, in);
                return(true);
        }
 }
@@ -510,9 +510,9 @@ INL_StartJoy(word joy)
 //
 ///////////////////////////////////////////////////////////////////////////
 static void
-INL_ShutJoy(word joy)
+INL_ShutJoy(word joy, inconfig *in)
 {
-       JoysPresent[joy] = false;
+       in->JoysPresent[joy] = false;
 }
 
 //     Public routines
@@ -523,12 +523,12 @@ INL_ShutJoy(word joy)
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_Startup(void)
+IN_Startup(inconfig *in)
 {
        boolean checkjoys,checkmouse;
        word    i;
 
-       if (IN_Started)
+       if (in->IN_Started)
                return;
 
        checkjoys = true;
@@ -546,13 +546,13 @@ IN_Startup(void)
                }
        }
 
-       INL_StartKbd();
-       MousePresent = checkmouse? INL_StartMouse() : false;
+       INL_StartKbd(in);
+       in->MousePresent = checkmouse? INL_StartMouse() : false;
 
        for (i = 0;i < MaxJoys;i++)
-               JoysPresent[i] = checkjoys? INL_StartJoy(i) : false;
+               in->JoysPresent[i] = checkjoys? INL_StartJoy(i, in) : false;
 
-       IN_Started = true;
+       in->IN_Started = true;
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -561,17 +561,19 @@ IN_Startup(void)
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_Default(boolean gotit,ControlType in)
+IN_Default(boolean gotit,player_t *player,ControlType nt, inconfig *in)
 {
        if
        (
                (!gotit)
-       ||      ((in == ctrl_Joystick1) && !JoysPresent[0])
-       ||      ((in == ctrl_Joystick2) && !JoysPresent[1])
-       ||      ((in == ctrl_Mouse) && !MousePresent)
+       ||      ((nt == ctrl_Joystick1) && !in->JoysPresent[0])
+       ||      ((nt == ctrl_Joystick2) && !in->JoysPresent[1])
+       ||      ((nt == ctrl_Mouse) && !in->MousePresent)
+       ||      ((nt == ctrl_Joypad1) && !in->JoyPadPresent[0])
+       ||      ((nt == ctrl_Joypad2) && !in->JoyPadPresent[1])
        )
-               in = ctrl_Keyboard1;
-       IN_SetControlType(0,in);
+               nt = ctrl_Keyboard1;
+       IN_SetControlType(0,player,nt);
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -580,19 +582,19 @@ IN_Default(boolean gotit,ControlType in)
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_Shutdown(void)
+IN_Shutdown(inconfig *in)
 {
        word    i;
 
-       if (!IN_Started)
+       if (!in->IN_Started)
                return;
 
        INL_ShutMouse();
        for (i = 0;i < MaxJoys;i++)
-               INL_ShutJoy(i);
+               INL_ShutJoy(i, in);
        INL_ShutKbd();
 
-       IN_Started = false;
+       in->IN_Started = false;
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -613,13 +615,13 @@ IN_SetKeyHook(void (*hook)())
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_ClearKeysDown(void)
+IN_ClearKeysDown(inconfig *in)
 {
        int     i;
 
-       LastScan = sc_None;
-       LastASCII = key_None;
-       memset (Keyboard,0,sizeof(Keyboard));
+       in->LastScan = sc_None;
+       in->LastASCII = key_None;
+       memset (in->Keyboard,0,sizeof(in->Keyboard));
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -682,7 +684,7 @@ IN_ReadCursor(CursorInfo *info)
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_ReadControl(int player,CursorInfo *info)
+IN_ReadControl(int playnum,player_t *player)
 {
                        boolean         realdelta;
                        byte            dbyte;
@@ -718,11 +720,11 @@ register  KeyboardDef     *def;
        else
        {
 #endif
-               switch (type = Controls[player])
+               switch (type = player[playnum]->Controls)
                {
                case ctrl_Keyboard1:
                case ctrl_Keyboard2:
-                       def = &KbdDefs[type - ctrl_Keyboard];
+                       def = player[playnum]->KbdDefs[type - ctrl_Keyboard];
 
 /*                     if (Keyboard[def->upleft])
                                mx = motion_Left,my = motion_Up;
@@ -780,15 +782,15 @@ register  KeyboardDef     *def;
                dy = my * 127;
        }
 
-       info->x = dx;
-       info->xaxis = mx;
-       info->y = dy;
-       info->yaxis = my;
-       info->button0 = buttons & (1 << 0);
-       info->button1 = buttons & (1 << 1);
-       info->button2 = buttons & (1 << 2);
-       info->button3 = buttons & (1 << 3);
-       info->dir = DirTable[((my + 1) * 3) + (mx + 1)];
+       player[playnum]->info.x = dx;
+       player[playnum]->info.xaxis = mx;
+       player[playnum]->info.y = dy;
+       player[playnum]->info.yaxis = my;
+       player[playnum]->info.button0 = buttons & (1 << 0);
+       player[playnum]->info.button1 = buttons & (1 << 1);
+       player[playnum]->info.button2 = buttons & (1 << 2);
+       player[playnum]->info.button3 = buttons & (1 << 3);
+       player[playnum]->info.dir = DirTable[((my + 1) * 3) + (mx + 1)];
 
 #if DEMO0
        if (DemoMode == demo_Record)
@@ -824,10 +826,10 @@ register  KeyboardDef     *def;
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_SetControlType(int player,ControlType type)
+IN_SetControlType(word playnum,player_t *player,ControlType type)
 {
        // DEBUG - check that requested type is present?
-       Controls[player] = type;
+       player[playnum]->Controls = type;
 }
 
 #if DEMO0
index b157446f76a864943e9c4fb8a1268fa32e09183b..2d15828ee4b98045bdbc5cb7467148403c30bd92 100644 (file)
@@ -46,7 +46,8 @@
 \r
 #define        MaxPlayers      4\r
 #define        MaxKbds         2\r
-#define        MaxJoys         2\r
+#define        MaxJoys         2
+#define        MaxPads         2\r
 #define        NumCodes        128\r
 \r
 typedef        byte            ScanCode;\r
@@ -166,8 +167,8 @@ typedef     enum            {
 typedef        enum            {\r
                                                dir_North,//dir_NorthEast,\r
                                                dir_East,//dir_SouthEast,\r
-                                               dir_South,//dir_SouthWest,\r
-                                               dir_West,//dir_NorthWest,\r
+                                               dir_South,//dir_Soutinest,\r
+                                               dir_West,//dir_Nortinest,\r
                                                dir_None\r
                                        } Direction;\r
 typedef        struct          {\r
@@ -196,11 +197,36 @@ typedef   struct          {
                                                                        joyMultXL,joyMultYL,\r
                                                                        joyMultXH,joyMultYH;\r
                                        } JoystickDef;
+typedef        struct
+{
+       boolean w;\r
+} JoypadDef;
+
+typedef        struct
+{
+       CursorInfo      info;
+       ControlType     Controls;
+} player_t;
 
-/*typedef      struct
+typedef        struct
 {
-       CursorInfo;
-}      ControlInfo;*/\r
+       boolean                 MousePresent;\r
+       boolean                 JoysPresent[MaxJoys];\r
+       boolean                 JoyPadPresent[MaxPads];
+       boolean         Keyboard[NumCodes];\r
+       boolean         Paused;\r
+       char            LastASCII;\r
+       ScanCode        LastScan;
+
+       boolean         IN_Started;\r
+       boolean         CapsLock;\r
+       ScanCode        CurCode,LastCode;
+
+       KeyboardDef     KbdDefs[MaxKbds];
+       JoystickDef     JoyDefs[MaxJoys];
+       JoypadDef       JoypadDefs[MaxPads];
+} inconfig;
+\r
 /*\r
 =============================================================================\r
 \r
@@ -212,25 +238,25 @@ typedef   struct          {
 //\r
 // configuration variables\r
 //\r
-static boolean                 MousePresent;\r
-static boolean                 JoysPresent[MaxJoys];\r
-static boolean                 JoyPadPresent;\r
+//static boolean                       MousePresent;\r
+//static boolean                       JoysPresent[MaxJoys];\r
+//static boolean                       JoyPadPresent[MaxPads];\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
+               //extern boolean                Keyboard[NumCodes];\r
+               //extern boolean                Paused;\r
+               //extern char           LastASCII;\r
+               //extern ScanCode       LastScan;\r
 \r
                //extern KeyboardDef    KbdDefs[];
-               static KeyboardDef      KbdDefs[MaxKbds] = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};\r
-               extern JoystickDef      JoyDefs[MaxJoys];\r
-               extern ControlType      Controls[MaxPlayers];\r
+               //static KeyboardDef    KbdDefs[MaxKbds] = {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
+               //extern dword  MouseDownCount;\r
 \r
 #ifdef DEMO0\r
                static Demo             DemoMode = demo_Off;\r
@@ -309,17 +335,13 @@ static    byte        far ASCIINames[] =          // Unshifted ASCII for scan codes
        "Down","Left","Right",""\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_Nortinest,\r
                                                dir_North,\r
                                                //dir_NorthEast,\r
                                                dir_West,               dir_None,       dir_East,\r
-                                               //dir_SouthWest,\r
+                                               //dir_Soutinest,\r
                                                dir_South//,dir_SouthEast\r
                                        };\r
 \r
@@ -333,7 +355,7 @@ static      char                    *ParmStringsIN[] = {"nojoys","nomouse",nil};
 #define        IN_ClearKey(code)       {Keyboard[code] = false; if (code == LastScan) LastScan = sc_None;}\r
 
 //     Internal routines
-void interrupt INL_KeyService(void);
+void interrupt INL_KeyService(inconfig *in);
 void Mouse(int x);
 //static void INL_GetMouseDelta(int *x,int *y);
 //static word INL_GetMouseButtons(void);
@@ -346,18 +368,18 @@ word IN_GetJoyButtonsDB(word joy);
 //static boolean INL_StartMouse(void);
 //static void INL_ShutMouse(void);
 //static void INL_SetJoyScale(word joy);
-void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy);
+void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, inconfig *in);
 //static boolean INL_StartJoy(word joy);
 //static void INL_ShutJoy(word joy);
-void IN_Startup(void);
-void IN_Default(boolean gotit,ControlType in);
-void IN_Shutdown(void);
+void IN_Startup(inconfig *in);
+void IN_Default(boolean gotit,player_t *player,ControlType nt, inconfig *in);
+void IN_Shutdown(inconfig *in);
 void IN_SetKeyHook(void (*hook)());
-void IN_ClearKeysDown(void);
+void IN_ClearKeysDown(inconfig *in);
 //static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy);
 void IN_ReadCursor(CursorInfo *info);
-void IN_ReadControl(int player,CursorInfo *info);
-void IN_SetControlType(int player,ControlType type);
+void IN_ReadControl(int playnum,player_t *player);
+void IN_SetControlType(word playnum,player_t *player,ControlType type);
 #if DEMO0
 boolean IN_StartDemoRecord(word bufsize);
 void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize);
@@ -371,7 +393,6 @@ void IN_AckBack(void);
 void IN_Ack(void);
 boolean IN_IsUserInput(void);
 boolean IN_UserInput(dword delay,boolean clear);
-
 \r
 /*extern       void            IN_Startup(void),IN_Shutdown(void),\r
                                        IN_Default(boolean gotit,ControlType in),\r
@@ -400,7 +421,5 @@ extern      char            IN_WaitForASCII(void);
 extern ScanCode        IN_WaitForKey(void);\r
 extern word            IN_GetJoyButtonsDB(word joy);*/\r
 \r
-\r
-void interrupt INL_KeyService(void);\r
 boolean IN_qb(byte kee);\r
 #endif\r