]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_in_.c
__seguse.txt added to show _seg usage also OpenVGMFile needs to be ported to 16_snd...
[16.git] / src / lib / 16_in_.c
index 9b6bc7a92e6c3733fa428a66a8189b3919974a12..c04d15aab2279e3123247bd3be11e196bf9eb528 100755 (executable)
@@ -36,7 +36,7 @@
 //     DEBUG - there are more globals\r
 //\r
 \r
-#include "src/lib/16_in.h"\r
+#include "src/lib/16_in_.h"\r
 #pragma        hdrstop\r
 \r
 /*\r
 extern "C" {\r
 #endif\r
 \r
+static void                    (*INL_KeyHook)(void);\r
+static void interrupt  (*OldKeyVect)(void);\r
+static char                    *ParmStringsIN[] = {"nojoys","nomouse",nil};\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
@@ -128,22 +132,11 @@ static    byte        far ASCIINames[] =          // Unshifted ASCII for scan codes
 \r
 static Direction       DirTable[] =            // Quick lookup for total direction\r
                                        {\r
-                                               //dir_Nortinest,\r
-                                               dir_North,\r
-                                               dir_West,\r
-                                               dir_None,\r
-                                               dir_East,\r
-                                               dir_South\r
-                                               //dir_NorthEast,\r
-                                               //dir_Soutinest,\r
-                                               //,dir_SouthEast\r
+                                               /*dir_NorthWest,        */dir_North,/*  dir_NorthEast,*/\r
+                                               dir_West,               dir_None,       dir_East,\r
+                                               /*dir_SouthWest,        */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
 #ifdef __cplusplus\r
 }\r
 #endif\r
@@ -155,12 +148,12 @@ static    char                    *ParmStringsIN[] = {"nojoys","nomouse",nil};
 //     INL_KeyService() - Handles a keyboard interrupt (key up/down)\r
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
-void interrupt\r
-INL_KeyService()\r
+/*static */void interrupt\r
+INL_KeyService(global_game_variables_t *gvar)\r
 {\r
 static boolean special;\r
-               byte    k,c;\r
-               register byte temp;\r
+               byte    k,c,\r
+                               temp;\r
 \r
        k = inp(0x60);  // Get the scan code\r
 \r
@@ -171,7 +164,7 @@ static      boolean special;
        if (k == 0xe0)          // Special key prefix\r
                special = true;\r
        else if (k == 0xe1)     // Handle Pause key\r
-               inpu.Paused = true;\r
+               gvar->in.Paused = true;\r
        else\r
        {\r
                if (k & 0x80)   // Break code\r
@@ -180,13 +173,13 @@ static    boolean special;
 \r
 // DEBUG - handle special keys: ctl-alt-delete, print scrn\r
 \r
-                       inpu.Keyboard[k] = false;\r
+                       gvar->in.Keyboard[k] = false;\r
                }\r
                else                    // Make code\r
                {\r
-                       inst.LastCode = inst.CurCode;\r
-                       inst.CurCode = inpu.LastScan = k;\r
-                       inpu.Keyboard[k] = true;\r
+                       gvar->in.LastCode = gvar->in.CurCode;\r
+                       gvar->in.CurCode = gvar->in.LastScan = k;\r
+                       gvar->in.Keyboard[k] = true;\r
 \r
                        if (special)\r
                                c = SpecialNames[k];\r
@@ -194,25 +187,25 @@ static    boolean special;
                        {\r
                                if (k == sc_CapsLock)\r
                                {\r
-                                       inst.CapsLock ^= true;\r
+                                       gvar->in.CapsLock ^= true;\r
                                        // DEBUG - make caps lock light work\r
                                }\r
 \r
-                               if (inpu.Keyboard[sc_LShift] || inpu.Keyboard[sc_RShift])       // If shifted\r
+                               if (gvar->in.Keyboard[sc_LShift] || gvar->in.Keyboard[sc_RShift])       // If shifted\r
                                {\r
                                        c = ShiftNames[k];\r
-                                       if ((c >= 'A') && (c <= 'Z') && inst.CapsLock)\r
+                                       if ((c >= 'A') && (c <= 'Z') && gvar->in.CapsLock)\r
                                                c += 'a' - 'A';\r
                                }\r
                                else\r
                                {\r
                                        c = ASCIINames[k];\r
-                                       if ((c >= 'a') && (c <= 'z') && inst.CapsLock)\r
+                                       if ((c >= 'a') && (c <= 'z') && gvar->in.CapsLock)\r
                                                c -= 'a' - 'A';\r
                                }\r
                        }\r
                        if (c)\r
-                               inpu.LastASCII = c;\r
+                               gvar->in.LastASCII = c;\r
                }\r
 \r
                special = false;\r
@@ -221,7 +214,7 @@ static      boolean special;
        if (INL_KeyHook && !special)\r
                INL_KeyHook();\r
 #ifdef __DEBUG_InputMgr__\r
-       if(dbg_testkeyin > 0) printf("%c        %u      [0x%x %u]       %u\n", c, c, k, k, inpu.Keyboard[k]);\r
+       if(dbg_testkeyin > 0) printf("%c        %u      [0x%x %u]       %u\n", c, c, k, k, gvar->in.Keyboard[k]);\r
 #endif\r
        outp(0x20,0x20);\r
 }\r
@@ -366,16 +359,16 @@ done:
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 static void\r
-INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive)\r
+INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive, global_game_variables_t *gvar)\r
 {\r
        word            x,y;\r
        word    time;\r
-       word TimeCount = *clockw;\r
+       word TimeCount = gvar->kurokku.clock_start;\r
        JoystickDef     *def;\r
 static word    lasttime;\r
 \r
        IN_GetJoyAbs(joy,&x,&y);\r
-       def = inpu.JoyDefs + joy;\r
+       def = gvar->in.JoyDefs + joy;\r
 \r
        if (x < def->threshMinX)\r
        {\r
@@ -462,9 +455,9 @@ register    word    result;
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 word\r
-IN_GetJoyButtonsDB(word joy)\r
+IN_GetJoyButtonsDB(word joy, global_game_variables_t *gvar)\r
 {\r
-       word TimeCount = *clockw;\r
+       word TimeCount = gvar->kurokku.clock_start;\r
        word    lasttime;\r
        word            result1,result2;\r
 \r
@@ -484,12 +477,12 @@ IN_GetJoyButtonsDB(word joy)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 static void\r
-INL_StartKbd()\r
+INL_StartKbd(global_game_variables_t *gvar)\r
 {\r
        byte far *lock_key;\r
        INL_KeyHook = 0;        // Clear key hook\r
 \r
-       IN_ClearKeysDown();\r
+       IN_ClearKeysDown(gvar);\r
 \r
        OldKeyVect = _dos_getvect(KeyInt);\r
 \r
@@ -545,11 +538,11 @@ INL_ShutMouse(void)
 //     INL_SetJoyScale() - Sets up scaling values for the specified joystick\r
 //\r
 static void\r
-INL_SetJoyScale(word joy)\r
+INL_SetJoyScale(word joy, global_game_variables_t *gvar)\r
 {\r
        JoystickDef     *def;\r
 \r
-       def = &(inpu.JoyDefs[joy]);\r
+       def = &(gvar->in.JoyDefs[joy]);\r
        def->joyMultXL = JoyScaleMax / (def->threshMinX - def->joyMinX);\r
        def->joyMultXH = JoyScaleMax / (def->joyMaxX - def->threshMaxX);\r
        def->joyMultYL = JoyScaleMax / (def->threshMinY - def->joyMinY);\r
@@ -563,12 +556,12 @@ INL_SetJoyScale(word joy)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy)\r
+IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, global_game_variables_t *gvar)\r
 {\r
        word            d,r;\r
        JoystickDef     *def;\r
 \r
-       def = &(inpu.JoyDefs[joy]);\r
+       def = &(gvar->in.JoyDefs[joy]);\r
 \r
        def->joyMinX = minx;\r
        def->joyMaxX = maxx;\r
@@ -584,7 +577,7 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy)
        def->threshMinY = ((r / 2) - d) + miny;\r
        def->threshMaxY = ((r / 2) + d) + miny;\r
 \r
-       INL_SetJoyScale(joy);\r
+       INL_SetJoyScale(joy, gvar);\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
@@ -594,7 +587,7 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 static boolean\r
-INL_StartJoy(word joy)\r
+INL_StartJoy(word joy, global_game_variables_t *gvar)\r
 {\r
        word            x,y;\r
 \r
@@ -608,7 +601,7 @@ INL_StartJoy(word joy)
                return(false);\r
        else\r
        {\r
-               IN_SetupJoy(joy,0,x * 2,0,y * 2);\r
+               IN_SetupJoy(joy,0,x * 2,0,y * 2, gvar);\r
                return(true);\r
        }\r
 }\r
@@ -619,9 +612,9 @@ INL_StartJoy(word joy)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 static void\r
-INL_ShutJoy(word joy)\r
+INL_ShutJoy(word joy, global_game_variables_t *gvar)\r
 {\r
-       inpu.JoysPresent[joy] = false;\r
+       gvar->in.JoysPresent[joy] = false;\r
 }\r
 \r
 //     Public routines\r
@@ -632,12 +625,12 @@ INL_ShutJoy(word joy)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-IN_Startup()\r
+IN_Startup(global_game_variables_t *gvar)\r
 {\r
        boolean checkjoys,checkmouse;\r
        word    i;\r
 \r
-       if (inst.IN_Started)\r
+       if (gvar->in.IN_Started)\r
                return;\r
 \r
        checkjoys = true;\r
@@ -655,16 +648,16 @@ IN_Startup()
                }\r
        }\r
 \r
-       INL_StartKbd();\r
-       inpu.MousePresent = checkmouse? INL_StartMouse() : false;\r
+       INL_StartKbd(gvar);\r
+       gvar->in.MousePresent = checkmouse? INL_StartMouse() : false;\r
 \r
        for (i = 0;i < MaxJoys;i++)\r
-               ININFO_JoysPresent[i] = checkjoys? INL_StartJoy(i) : false;\r
+               gvar->in.JoysPresent[i] = checkjoys? INL_StartJoy(i, gvar) : false;\r
 \r
-       for (i = 0;i < MaxKbds;i++)\r
-               ININFO_KbdDefs[i] = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/};\r
+       //for (i = 0;i < MaxKbds;i++)\r
+       //      gvar->in.KbdDefs[i] = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/};\r
 \r
-       inst.IN_Started = true;\r
+       gvar->in.IN_Started = true;\r
 \r
 }\r
 \r
@@ -674,26 +667,26 @@ IN_Startup()
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-IN_Default(boolean gotit,player_t *player,ControlType nt)\r
+IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar)\r
 {\r
        int i;\r
        if\r
        (\r
                (!gotit)\r
-       ||      ((nt == ctrl_Joystick1) && !inpu.JoysPresent[0])\r
-       ||      ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1])\r
-       ||      ((nt == ctrl_Mouse) && !inpu.MousePresent)\r
+       ||      ((nt == ctrl_Joystick1) && !gvar->in.JoysPresent[0])\r
+       ||      ((nt == ctrl_Joystick2) && !gvar->in.JoysPresent[1])\r
+       ||      ((nt == ctrl_Mouse) && !gvar->in.MousePresent)\r
        )\r
                nt = ctrl_Keyboard1;\r
-       ININFO_KbdDefs[0].button0 = 0x1c;\r
-       ININFO_KbdDefs[0].button1 = 0x38;\r
+       gvar->in.KbdDefs[0].button0 = 0x1c;\r
+       gvar->in.KbdDefs[0].button1 = 0x38;\r
        //in.KbdDefs[0].upleft = 0x47;\r
-       ININFO_KbdDefs[0].up = 0x48;\r
+       gvar->in.KbdDefs[0].up = 0x48;\r
        //in.KbdDefs[0].upright = 0x49;\r
-       ININFO_KbdDefs[0].left = 0x4b;\r
-       ININFO_KbdDefs[0].right = 0x4d;\r
+       gvar->in.KbdDefs[0].left = 0x4b;\r
+       gvar->in.KbdDefs[0].right = 0x4d;\r
        //in.KbdDefs[0].downleft = 0x4f;\r
-       ININFO_KbdDefs[0].down = 0x50;\r
+       gvar->in.KbdDefs[0].down = 0x50;\r
        //in.KbdDefs[0].downright = 0x51;\r
        IN_SetControlType(0,player,nt);\r
        for(i=0; i>MaxPlayers;i++)\r
@@ -706,19 +699,19 @@ IN_Default(boolean gotit,player_t *player,ControlType nt)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-IN_Shutdown()\r
+IN_Shutdown(global_game_variables_t *gvar)\r
 {\r
        word    i;\r
 \r
-       if (!inst.IN_Started)\r
+       if (!gvar->in.IN_Started)\r
                return;\r
 \r
        INL_ShutMouse();\r
        for (i = 0;i < MaxJoys;i++)\r
-               INL_ShutJoy(i);\r
+               INL_ShutJoy(i, gvar);\r
        INL_ShutKbd();\r
 \r
-       inst.IN_Started = false;\r
+       gvar->in.IN_Started = false;\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
@@ -739,13 +732,13 @@ IN_SetKeyHook(void (*hook)())
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-IN_ClearKeysDown()\r
+IN_ClearKeysDown(global_game_variables_t *gvar)\r
 {\r
        //int   i;\r
 \r
-       inpu.LastScan = sc_None;\r
-       inpu.LastASCII = key_None;\r
-       memset (inpu.Keyboard,0,sizeof(inpu.Keyboard));\r
+       gvar->in.LastScan = sc_None;\r
+       gvar->in.LastASCII = key_None;\r
+       memset (gvar->in.Keyboard,0,sizeof(gvar->in.Keyboard));\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
@@ -772,7 +765,7 @@ INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-IN_ReadCursor(CursorInfo *info)\r
+IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar)\r
 {\r
        word    i,\r
                        buttons;\r
@@ -781,7 +774,7 @@ IN_ReadCursor(CursorInfo *info)
        info->x = info->y = 0;\r
        info->button0 = info->button1 = false;\r
 \r
-       if (inpu.MousePresent)\r
+       if (gvar->in.MousePresent)\r
        {\r
                buttons = INL_GetMouseButtons();\r
                INL_GetMouseDelta(&dx,&dy);\r
@@ -790,11 +783,11 @@ IN_ReadCursor(CursorInfo *info)
 \r
        for (i = 0;i < MaxJoys;i++)\r
        {\r
-               if (!inpu.JoysPresent[i])\r
+               if (!gvar->in.JoysPresent[i])\r
                        continue;\r
 \r
                buttons = INL_GetJoyButtons(i);\r
-               INL_GetJoyDelta(i,&dx,&dy,true);\r
+               INL_GetJoyDelta(i,&dx,&dy,true, gvar);\r
                dx /= 64;\r
                dy /= 64;\r
                INL_AdjustCursor(info,buttons,dx,dy);\r
@@ -808,7 +801,7 @@ IN_ReadCursor(CursorInfo *info)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void near\r
-IN_ReadControl(word pn, player_t *player)\r
+IN_ReadControl(word pn, player_t *player, global_game_variables_t *gvar)\r
 {\r
                        boolean         realdelta;\r
 #if DEMO0\r
@@ -852,7 +845,7 @@ register    KeyboardDef     *def;
                {\r
                case ctrl_Keyboard1:\r
                case ctrl_Keyboard2:\r
-                       def = &(ININFO_KbdDefs[type - ctrl_Keyboard]);\r
+                       def = &(gvar->in.KbdDefs[type - ctrl_Keyboard]);\r
 \r
 /*                     if (Keyboard[def->upleft])\r
                                mx = motion_Left,my = motion_Up;\r
@@ -865,28 +858,28 @@ register  KeyboardDef     *def;
 //TODO: make this into a function that the joystick AND keyboard can use wwww\r
                        if(DIRECTIONIFELSE)//(player[pn].info.dir == 2)\r
                        {\r
-                       if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){\r
-                               if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]))\r
+                       if(!gvar->in.Keyboard[def->left] && !gvar->in.Keyboard[def->right]){\r
+                               if((gvar->in.Keyboard[def->up] && !gvar->in.Keyboard[def->down]))\r
                                        my = motion_Up;\r
-                               if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up]))\r
+                               if((gvar->in.Keyboard[def->down] && !gvar->in.Keyboard[def->up]))\r
                                        my = motion_Down;\r
-                       }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){\r
-                               if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]))\r
+                       }else if(!gvar->in.Keyboard[def->up] && !gvar->in.Keyboard[def->down]){\r
+                               if((gvar->in.Keyboard[def->left] && !gvar->in.Keyboard[def->right]))\r
                                        mx = motion_Left;\r
-                               if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left]))\r
+                               if((gvar->in.Keyboard[def->right] && !gvar->in.Keyboard[def->left]))\r
                                        mx = motion_Right;\r
                        }else{  //2 keys pressed\r
                                        switch (player[pn].pdir)\r
                                        {\r
                                                case 0:\r
                                                case 4:\r
-                                                       if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])){ dir = DirTable[1]; }//mx = motion_Left; }\r
-                                                       else if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])){ dir = DirTable[3]; }//mx = motion_Right; }\r
+                                                       if((gvar->in.Keyboard[def->left] && !gvar->in.Keyboard[def->right])){ dir = DirTable[1]; }//mx = motion_Left; }\r
+                                                       else if((gvar->in.Keyboard[def->right] && !gvar->in.Keyboard[def->left])){ dir = DirTable[3]; }//mx = motion_Right; }\r
                                                break;\r
                                                case 1:\r
                                                case 3:\r
-                                                       if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])){ dir = DirTable[0]; }//my = motion_Up; }\r
-                                                       else if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])){ dir = DirTable[4]; }//my = motion_Down; }\r
+                                                       if((gvar->in.Keyboard[def->up] && !gvar->in.Keyboard[def->down])){ dir = DirTable[0]; }//my = motion_Up; }\r
+                                                       else if((gvar->in.Keyboard[def->down] && !gvar->in.Keyboard[def->up])){ dir = DirTable[4]; }//my = motion_Down; }\r
                                                break;\r
                                                default:\r
                                                break;\r
@@ -897,15 +890,15 @@ register  KeyboardDef     *def;
                                }\r
                        }\r
                        //input from player\r
-                       if (inpu.Keyboard[def->button0])\r
+                       if (gvar->in.Keyboard[def->button0])\r
                                buttons += 1 << 0;\r
-                       if (inpu.Keyboard[def->button1])\r
+                       if (gvar->in.Keyboard[def->button1])\r
                                buttons += 1 << 1;\r
                        realdelta = false;\r
                        break;\r
                case ctrl_Joystick1:\r
                case ctrl_Joystick2:\r
-                       INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false);\r
+                       INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false, gvar);\r
                        buttons = INL_GetJoyButtons(type - ctrl_Joystick);\r
                        realdelta = true;\r
                        break;\r
@@ -976,14 +969,14 @@ register  KeyboardDef     *def;
 #endif\r
 #ifdef __DEBUG_InputMgr__\r
 if(dbg_testcontrolnoisy > 0)\r
-if(player[pn].info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])*/ || player[pn].enti.q>1)\r
+if(player[pn].info.dir!=2/*(gvar->in.Keyboard[def->up] || gvar->in.Keyboard[def->down] || gvar->in.Keyboard[def->left] || gvar->in.Keyboard[def->right])*/ || player[pn].enti.q>1)\r
 {\r
        //printf("b1=%u b2=%u b3=%u b4=%u       ", player[pn].info.button0, player[pn].info.button1, player[pn].info.button2, player[pn].info.button3);\r
        //printf("q=%d ", player[pn].enti.q);\r
        //printf("cpee=%c ", dirchar(conpee));\r
        printf("pdir=%c d=%c dir=%c ", dirchar(player[pn].pdir), dirchar(player[pn].enti.d), dirchar(player[pn].info.dir));\r
        /*if(realdelta) */printf("dx=%d dy=%d   mx=%d   my=%d", player[pn].info.x, player[pn].info.y, player[pn].info.xaxis, player[pn].info.yaxis);\r
-       //else if(!realdelta) printf("%c%d %c%d %c%d %c%d", dirchar(0), inpu.Keyboard[def->up], dirchar(4), inpu.Keyboard[def->down], dirchar(1), inpu.Keyboard[def->left], dirchar(3), inpu.Keyboard[def->right]);\r
+       //else if(!realdelta) printf("%c%d %c%d %c%d %c%d", dirchar(0), gvar->in.Keyboard[def->up], dirchar(4), gvar->in.Keyboard[def->down], dirchar(1), gvar->in.Keyboard[def->left], dirchar(3), gvar->in.Keyboard[def->right]);\r
        printf("\n");\r
 }\r
 #endif\r
@@ -1092,13 +1085,13 @@ IN_GetScanName(ScanCode scan)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 ScanCode\r
-IN_WaitForKey()\r
+IN_WaitForKey(global_game_variables_t *gvar)\r
 {\r
        ScanCode        result;\r
 \r
-       while (!(result = inpu.LastScan))\r
+       while (!(result = gvar->in.LastScan))\r
                ;\r
-       inpu.LastScan = 0;\r
+       gvar->in.LastScan = 0;\r
        return(result);\r
 }\r
 \r
@@ -1109,13 +1102,13 @@ IN_WaitForKey()
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 char\r
-IN_WaitForASCII()\r
+IN_WaitForASCII(global_game_variables_t *gvar)\r
 {\r
        char            result;\r
 \r
-       while (!(result = inpu.LastASCII))\r
+       while (!(result = gvar->in.LastASCII))\r
                ;\r
-       inpu.LastASCII = '\0';\r
+       gvar->in.LastASCII = '\0';\r
        return(result);\r
 }\r
 \r
@@ -1125,13 +1118,13 @@ IN_WaitForASCII()
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-IN_AckBack()\r
+IN_AckBack(global_game_variables_t *gvar)\r
 {\r
        word    i;\r
 \r
-       while (!inpu.LastScan)\r
+       while (!gvar->in.LastScan)\r
        {\r
-               if (inpu.MousePresent)\r
+               if (gvar->in.MousePresent)\r
                {\r
                        if (INL_GetMouseButtons())\r
                        {\r
@@ -1143,11 +1136,11 @@ IN_AckBack()
 \r
                for (i = 0;i < MaxJoys;i++)\r
                {\r
-                       if (inpu.JoysPresent[i])\r
+                       if (gvar->in.JoysPresent[i])\r
                        {\r
-                               if (IN_GetJoyButtonsDB(i))\r
+                               if (IN_GetJoyButtonsDB(i, gvar))\r
                                {\r
-                                       while (IN_GetJoyButtonsDB(i))\r
+                                       while (IN_GetJoyButtonsDB(i, gvar))\r
                                                ;\r
                                        return;\r
                                }\r
@@ -1155,8 +1148,8 @@ IN_AckBack()
                }\r
        }\r
 \r
-       IN_ClearKey(inpu.LastScan);\r
-       inpu.LastScan = sc_None;\r
+       IN_ClearKey(gvar->in.LastScan, gvar);\r
+       gvar->in.LastScan = sc_None;\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
@@ -1165,25 +1158,25 @@ IN_AckBack()
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-IN_Ack()\r
+IN_Ack(global_game_variables_t *gvar)\r
 {\r
        word    i;\r
 \r
-       if (!inst.IN_Started)\r
+       if (!gvar->in.IN_Started)\r
                return;\r
 \r
-       IN_ClearKey(inpu.LastScan);\r
-       inpu.LastScan = sc_None;\r
+       IN_ClearKey(gvar->in.LastScan, gvar);\r
+       gvar->in.LastScan = sc_None;\r
 \r
-       if (inpu.MousePresent)\r
+       if (gvar->in.MousePresent)\r
                while (INL_GetMouseButtons())\r
                                        ;\r
        for (i = 0;i < MaxJoys;i++)\r
-               if (inpu.JoysPresent[i])\r
-                       while (IN_GetJoyButtonsDB(i))\r
+               if (gvar->in.JoysPresent[i])\r
+                       while (IN_GetJoyButtonsDB(i, gvar))\r
                                ;\r
 \r
-       IN_AckBack();\r
+       IN_AckBack(gvar);\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
@@ -1193,19 +1186,19 @@ IN_Ack()
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 boolean\r
-IN_IsUserInput()\r
+IN_IsUserInput(global_game_variables_t *gvar)\r
 {\r
        boolean result;\r
        word    i;\r
 \r
-       result = inpu.LastScan;\r
+       result = gvar->in.LastScan;\r
 \r
-       if (inpu.MousePresent)\r
+       if (gvar->in.MousePresent)\r
                if (INL_GetMouseButtons())\r
                        result = true;\r
 \r
        for (i = 0;i < MaxJoys;i++)\r
-               if (inpu.JoysPresent[i])\r
+               if (gvar->in.JoysPresent[i])\r
                        if (INL_GetJoyButtons(i))\r
                                result = true;\r
 \r
@@ -1221,18 +1214,18 @@ IN_IsUserInput()
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 boolean\r
-IN_UserInput(dword delay,boolean clear)\r
+IN_UserInput(dword delay,boolean clear, global_game_variables_t *gvar)\r
 {\r
-       word TimeCount = *clockw;\r
+       word TimeCount = gvar->kurokku.clock_start;\r
        word    lasttime;\r
 \r
        lasttime = TimeCount;\r
        do\r
        {\r
-               if (IN_IsUserInput())\r
+               if (IN_IsUserInput(gvar))\r
                {\r
                        if (clear)\r
-                               IN_AckBack();\r
+                               IN_AckBack(gvar);\r
                        return(true);\r
                }\r
        } while (TimeCount - lasttime < delay);\r
@@ -1249,10 +1242,10 @@ IN_UserInput(dword delay,boolean clear)
 ===================\r
 */\r
 \r
-byte   IN_MouseButtons (void)\r
+byte   IN_MouseButtons (global_game_variables_t *gvar)\r
 {\r
        union REGS CPURegs;\r
-       if (inpu.MousePresent)\r
+       if (gvar->in.MousePresent)\r
        {\r
                Mouse(MButtons);\r
                return CPURegs.x.bx;\r
@@ -1281,12 +1274,12 @@ byte    IN_JoyButtons (void)
        return joybits;\r
 }\r
 \r
-boolean IN_KeyDown(byte code)\r
+boolean IN_KeyDown(byte code, global_game_variables_t *gvar)\r
 {\r
 #ifdef __DEBUG_InputMgr__\r
        if(!dbg_nointest)\r
 #endif\r
-       return inpu.Keyboard[code];\r
+       return gvar->in.Keyboard[code];\r
 #ifdef __DEBUG_InputMgr__\r
        else\r
                if(dbg_nointest && kbhit())\r
@@ -1296,28 +1289,28 @@ boolean IN_KeyDown(byte code)
 #endif\r
 }\r
 \r
-void IN_ClearKey(byte code)\r
+void IN_ClearKey(byte code, global_game_variables_t *gvar)\r
 {\r
-       inpu.Keyboard[code] = false;\r
-       if(code == inpu.LastScan)\r
-               inpu.LastScan = sc_None;\r
+       gvar->in.Keyboard[code] = false;\r
+       if(code == gvar->in.LastScan)\r
+               gvar->in.LastScan = sc_None;\r
        }\r
 \r
-boolean IN_qb(byte kee)\r
+boolean IN_qb(byte kee, global_game_variables_t *gvar)\r
 {\r
 #ifdef __DEBUG_InputMgr__\r
-       if(dbg_testkeyin) printf("%u\n", inpu.Keyboard[kee]);\r
+       if(dbg_testkeyin) printf("%u\n", gvar->in.Keyboard[kee]);\r
 #endif\r
-       if(inpu.Keyboard[kee]==true) return 1;\r
+       if(gvar->in.Keyboard[kee]==true) return 1;\r
        else return 0;\r
 }\r
 \r
-ScanCode IN_GetLastScan()\r
+ScanCode IN_GetLastScan(global_game_variables_t *gvar)\r
 {\r
-       return inpu.LastScan;\r
+       return gvar->in.LastScan;\r
 }\r
 \r
-ScanCode IN_GetCurCode()\r
+ScanCode IN_GetCurCode(global_game_variables_t *gvar)\r
 {\r
-       return inst.CurCode;\r
+       return gvar->in.CurCode;\r
 }\r