]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_in.c
i did some minor things including commenting out some joy stick timing stuff and...
[16.git] / src / lib / 16_in.c
index 14086bd8909381c57da08fa8836a4a881efbc708..0ac77f15d5cb49a06d6ce0a0e6bdf27cde49666c 100755 (executable)
@@ -169,6 +169,7 @@ static      Direction       DirTable[] =            // Quick lookup for total direction
 static void                    (*INL_KeyHook)(void);\r
 static void interrupt  (*OldKeyVect)(void);\r
 static char                    *ParmStringsIN[] = {"nojoys","nomouse",nil};\r
+static void                    INL_StartKbd(void);\r
 \r
 //     Internal routines\r
 \r
@@ -248,17 +249,6 @@ static     boolean special;
        outportb(0x20,0x20);\r
 }\r
 \r
-void INL_Mouse(int x)\r
-{\r
-       //union REGS CPURegs;\r
-       //x = CPURegs.x.ax;\r
-       __asm {\r
-               mov     ax,x\r
-               int     MouseInt\r
-       }\r
-       //int86(MouseInt,&CPURegs,&CPURegs);\r
-}\r
-\r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
 //     INL_GetMouseDelta() - Gets the amount that the mouse has moved from the\r
@@ -268,10 +258,9 @@ void INL_Mouse(int x)
 static void\r
 INL_GetMouseDelta(int *x,int *y)\r
 {\r
-       union REGS CPURegs;\r
        Mouse(MDelta);\r
-       *x = CPURegs.x.cx;\r
-       *y = CPURegs.x.dx;\r
+       *x = _CX;\r
+       *y = _DX;\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
@@ -283,11 +272,10 @@ INL_GetMouseDelta(int *x,int *y)
 static word\r
 INL_GetMouseButtons(void)\r
 {\r
-       union REGS CPURegs;\r
        word    buttons;\r
 \r
        Mouse(MButtons);\r
-       buttons = CPURegs.x.bx;\r
+       buttons = _BX;\r
        return(buttons);\r
 }\r
 \r
@@ -389,9 +377,9 @@ done:
 void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/, global_game_variables_t *gvar)\r
 {\r
        word            x,y;\r
-       word TimeCount = *clockw;\r
+//00   word TimeCount = *clockw;\r
        JoystickDef     *def;\r
-static word    lasttime;\r
+//00static     word    lasttime;\r
 \r
        IN_GetJoyAbs(joy,&x,&y);\r
        def = gvar->in.JoyDefs + joy;\r
@@ -452,7 +440,7 @@ static      word    lasttime;
 //                     *dy *= time;\r
 //             }\r
 //     }\r
-       lasttime = TimeCount;\r
+//00   lasttime = TimeCount;\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
@@ -482,15 +470,15 @@ register  word    result;
 word\r
 IN_GetJoyButtonsDB(word joy)\r
 {\r
-       word TimeCount = *clockw;\r
-       word    lasttime;\r
+//00   word TimeCount = *clockw;\r
+//00   word    lasttime;\r
        word            result1,result2;\r
 \r
        do\r
        {\r
                result1 = INL_GetJoyButtons(joy);\r
-               lasttime = TimeCount;\r
-               while(TimeCount == lasttime)\r
+//00           lasttime = TimeCount;\r
+//00           while(TimeCount == lasttime)\r
                        //;\r
                result2 = INL_GetJoyButtons(joy);\r
        } while(result1 != result2);\r
@@ -503,7 +491,7 @@ IN_GetJoyButtonsDB(word joy)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 static void\r
-INL_StartKbd(global_game_variables_t *gvar)\r
+INL_StartKbd(void)\r
 {\r
        INL_KeyHook = NULL;     // Clear key hook\r
 \r
@@ -542,7 +530,7 @@ INL_StartMouse(void)
                        return(true);\r
        }\r
        return(false);\r
-#endif\r
+#else\r
        byte far *vector;\r
 \r
 \r
@@ -554,6 +542,7 @@ INL_StartMouse(void)
 \r
        Mouse(MReset);\r
        return true;\r
+#endif\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
@@ -680,7 +669,7 @@ IN_Startup(global_game_variables_t *gvar)
                }\r
        }\r
 \r
-       INL_StartKbd(gvar);\r
+       INL_StartKbd();\r
        gvar->in.MousePresent = checkmouse? INL_StartMouse() : false;\r
 \r
        for (i = 0;i < MaxJoys;i++)\r
@@ -689,7 +678,6 @@ IN_Startup(global_game_variables_t *gvar)
        gvar->in.inst = &inst;\r
 \r
        gvar->in.IN_Started = true;\r
-\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
@@ -878,8 +866,7 @@ register    KeyboardDef     *def;
 #endif\r
                switch (type = player->Controls)\r
                {\r
-               case ctrl_Keyboard1:\r
-               case ctrl_Keyboard2:\r
+               case ctrl_Keyboard:\r
                        def = &(gvar->in.KbdDefs[type - ctrl_Keyboard]);\r
 \r
 /*                     if (Keyboard[def->upleft])\r
@@ -954,8 +941,8 @@ register    KeyboardDef     *def;
        }\r
        else\r
        {\r
-               dx = mx;// * 127;\r
-               dy = my;// * 127;\r
+               dx = mx * 127;\r
+               dy = my * 127;\r
        }\r
 \r
        player->info.x = dx;\r
@@ -1003,6 +990,22 @@ register  KeyboardDef     *def;
        }\r
 #endif\r
 #ifdef __DEBUG_InputMgr__\r
+if(dbg_joymousedelta)\r
+{\r
+       {\r
+static         int                     old_dx,old_dy;\r
+static         word            old_buttons=0;\r
+               if(dx!=old_dx || dy!=old_dy) printf("dx,dy      [%d,%d] %d,%d\n", dx, dy, mx, my);\r
+               if(dx!=old_dx)  old_dx=dx;\r
+               if(dy!=old_dy)  old_dy=dy;\r
+               if(old_buttons!=buttons)\r
+               {\r
+                       printf("        buttons={%u,%u,%u,%u}\n", player->info.button0, player->info.button1, player->info.button2, player->info.button3);\r
+                       old_buttons=buttons;\r
+               }\r
+       }\r
+}\r
+\r
 if(dbg_testcontrolnoisy > 0)\r
 if(player->info.dir!=2/*(inst.Keyboard[def->up] || inst.Keyboard[def->down] || inst.Keyboard[def->left] || inst.Keyboard[def->right])*/ || player->enti.q>1)\r
 {\r
@@ -1183,8 +1186,13 @@ boolean IN_CheckAck (global_game_variables_t *gvar)
 //\r
 // see if something has been pressed\r
 //\r
-       if (inst.LastScan)\r
-               return true;\r
+       if(!gvar->in.IN_Started)\r
+               getch();\r
+       else\r
+       {\r
+               if (inst.LastScan)\r
+                       return true;\r
+       }\r
 \r
        buttons = IN_JoyButtons () << 4;\r
        if (gvar->in.MousePresent)\r
@@ -1272,11 +1280,10 @@ boolean IN_UserInput(word delay, global_game_variables_t *gvar)
 \r
 byte   IN_MouseButtons (global_game_variables_t *gvar)\r
 {\r
-       union REGS CPURegs;\r
        if (gvar->in.MousePresent)\r
        {\r
                Mouse(MButtons);\r
-               return CPURegs.x.bx;\r
+               return _BX;\r
        }\r
        else\r
                return 0;\r
@@ -1305,8 +1312,8 @@ byte      IN_JoyButtons (void)
 boolean IN_KeyDown(byte code)\r
 {\r
 #ifdef __DEBUG_InputMgr__\r
-       if(inst.Keyboard[code])\r
-               printf("IN_KeyDown(%c): %u\n", code, inst.Keyboard[code]);\r
+//     if(inst.Keyboard[code])\r
+//             printf("IN_KeyDown(%c): %u\n", code, inst.Keyboard[code]);\r
        if(!dbg_nointest)\r
 #endif\r
        return inst.Keyboard[code];\r