extern "C" {\r
#endif\r
\r
-/*static struct instat {\r
- boolean IN_Started;\r
+static struct instat {\r
boolean CapsLock;\r
ScanCode CurCode,LastCode;\r
-} inst;*/\r
+\r
+ boolean Keyboard[NumCodes];\r
+ boolean Paused;\r
+ char LastASCII;\r
+ ScanCode LastScan;\r
+} inst;\r
\r
static byte far ASCIINames[] = // Unshifted ASCII for scan codes\r
{\r
//\r
///////////////////////////////////////////////////////////////////////////\r
/*static */void interrupt\r
-INL_KeyService(global_game_variables_t *gvar)//!\r
+INL_KeyService(void)\r
{\r
static boolean special;\r
byte k,c,\r
if (k == 0xe0) // Special key prefix\r
special = true;\r
else if (k == 0xe1) // Handle Pause key\r
- gvar->in.Paused = true;\r
+ inst.Paused = true;\r
else\r
{\r
if (k & 0x80) // Break code\r
\r
// DEBUG - handle special keys: ctl-alt-delete, print scrn\r
\r
- gvar->in.Keyboard[k] = false;\r
+ inst.Keyboard[k] = false;\r
}\r
else // Make code\r
{\r
- gvar->in.LastCode = gvar->in.CurCode;\r
- gvar->in.CurCode = gvar->in.LastScan = k;\r
- gvar->in.Keyboard[k] = true;\r
+ inst.LastCode = inst.CurCode;\r
+ inst.CurCode = inst.LastScan = k;\r
+ inst.Keyboard[k] = true;\r
\r
if (special)\r
c = SpecialNames[k];\r
{\r
if (k == sc_CapsLock)\r
{\r
- gvar->in.CapsLock ^= true;\r
+ inst.CapsLock ^= true;\r
// DEBUG - make caps lock light work\r
}\r
\r
- if (gvar->in.Keyboard[sc_LShift] || gvar->in.Keyboard[sc_RShift]) // If shifted\r
+ if (inst.Keyboard[sc_LShift] || inst.Keyboard[sc_RShift]) // If shifted\r
{\r
c = ShiftNames[k];\r
- if ((c >= 'A') && (c <= 'Z') && gvar->in.CapsLock)\r
+ if ((c >= 'A') && (c <= 'Z') && inst.CapsLock)\r
c += 'a' - 'A';\r
}\r
else\r
{\r
c = ASCIINames[k];\r
- if ((c >= 'a') && (c <= 'z') && gvar->in.CapsLock)\r
+ if ((c >= 'a') && (c <= 'z') && inst.CapsLock)\r
c -= 'a' - 'A';\r
}\r
}\r
if (c)\r
- gvar->in.LastASCII = c;\r
+ inst.LastASCII = c;\r
}\r
\r
special = false;\r
\r
if (INL_KeyHook && !special)\r
INL_KeyHook();\r
-#ifdef __DEBUG_InputMgr2__\r
- if(dbg_testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, gvar->in.Keyboard[k]);\r
+#ifdef __DEBUG_InputMgr__\r
+ if(dbg_testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, inst.Keyboard[k]);\r
#endif\r
outportb(0x20,0x20);\r
}\r
// joystick (from +/-127)\r
//\r
///////////////////////////////////////////////////////////////////////////\r
-void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/, global_game_variables_t *gvar)//!\r
+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
{\r
INL_KeyHook = NULL; // Clear key hook\r
\r
- IN_ClearKeysDown(gvar);\r
+ IN_ClearKeysDown();\r
\r
OldKeyVect = getvect(KeyInt);//IN_KbdLED();\r
setvect(KeyInt,INL_KeyService);\r
//\r
///////////////////////////////////////////////////////////////////////////\r
void\r
-IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, global_game_variables_t *gvar)//!\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
///////////////////////////////////////////////////////////////////////////\r
static void\r
-INL_ShutJoy(word joy, global_game_variables_t *gvar)//!\r
+INL_ShutJoy(word joy, global_game_variables_t *gvar)\r
{\r
gvar->in.JoysPresent[joy] = false;\r
}\r
//\r
///////////////////////////////////////////////////////////////////////////\r
void\r
-IN_Startup(global_game_variables_t *gvar)//!\r
+IN_Startup(global_game_variables_t *gvar)\r
{\r
boolean checkjoys,checkmouse;\r
word i;\r
for (i = 0;i < MaxJoys;i++)\r
gvar->in.JoysPresent[i] = checkjoys? INL_StartJoy(i, gvar) : false;\r
\r
+ gvar->in.inst = &inst;\r
+\r
gvar->in.IN_Started = true;\r
\r
}\r
//\r
///////////////////////////////////////////////////////////////////////////\r
void\r
-IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar)//!\r
+IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar)\r
{\r
int i;\r
if\r
//\r
///////////////////////////////////////////////////////////////////////////\r
void\r
-IN_Shutdown(global_game_variables_t *gvar)//!\r
+IN_Shutdown(global_game_variables_t *gvar)\r
{\r
word i;\r
\r
//\r
///////////////////////////////////////////////////////////////////////////\r
void\r
-IN_ClearKeysDown(global_game_variables_t *gvar)//!\r
+IN_ClearKeysDown(void)\r
{\r
//int i;\r
\r
- gvar->in.LastScan = sc_None;\r
- gvar->in.LastASCII = key_None;\r
- memset (gvar->in.Keyboard,0,sizeof(gvar->in.Keyboard));\r
+ inst.LastScan = sc_None;\r
+ inst.LastASCII = key_None;\r
+ memset (inst.Keyboard,0,sizeof(inst.Keyboard));\r
}\r
\r
///////////////////////////////////////////////////////////////////////////\r
//\r
///////////////////////////////////////////////////////////////////////////\r
void\r
-IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar)//!\r
+IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar)\r
{\r
word i,\r
buttons;\r
//\r
///////////////////////////////////////////////////////////////////////////\r
void\r
-IN_ReadControl(player_t *player, global_game_variables_t *gvar)//!\r
+IN_ReadControl(player_t *player, global_game_variables_t *gvar)\r
{\r
boolean realdelta;\r
#if DEMO0\r
//TODO: make this into a function that the joystick AND keyboard can use wwww\r
if(DIRECTIONIFELSE)//(player->info.dir == 2)\r
{\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
+ if(!inst.Keyboard[def->left] && !inst.Keyboard[def->right]){\r
+ if((inst.Keyboard[def->up] && !inst.Keyboard[def->down]))\r
my = motion_Up;\r
- if((gvar->in.Keyboard[def->down] && !gvar->in.Keyboard[def->up]))\r
+ if((inst.Keyboard[def->down] && !inst.Keyboard[def->up]))\r
my = motion_Down;\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
+ }else if(!inst.Keyboard[def->up] && !inst.Keyboard[def->down]){\r
+ if((inst.Keyboard[def->left] && !inst.Keyboard[def->right]))\r
mx = motion_Left;\r
- if((gvar->in.Keyboard[def->right] && !gvar->in.Keyboard[def->left]))\r
+ if((inst.Keyboard[def->right] && !inst.Keyboard[def->left]))\r
mx = motion_Right;\r
}else{ //2 keys pressed\r
switch (player->pdir)\r
{\r
case 0:\r
case 4:\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
+ if((inst.Keyboard[def->left] && !inst.Keyboard[def->right])){ dir = DirTable[1]; }//mx = motion_Left; }\r
+ else if((inst.Keyboard[def->right] && !inst.Keyboard[def->left])){ dir = DirTable[3]; }//mx = motion_Right; }\r
break;\r
case 1:\r
case 3:\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
+ if((inst.Keyboard[def->up] && !inst.Keyboard[def->down])){ dir = DirTable[0]; }//my = motion_Up; }\r
+ else if((inst.Keyboard[def->down] && !inst.Keyboard[def->up])){ dir = DirTable[4]; }//my = motion_Down; }\r
break;\r
default:\r
break;\r
}\r
-#ifdef __DEBUG_InputMgr2__\r
+#ifdef __DEBUG_InputMgr__\r
//if(dbg_testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player->pdir)); }\r
#endif\r
}\r
}\r
//input from player\r
- if (gvar->in.Keyboard[def->button0])\r
+ if (inst.Keyboard[def->button0])\r
buttons += 1 << 0;\r
- if (gvar->in.Keyboard[def->button1])\r
+ if (inst.Keyboard[def->button1])\r
buttons += 1 << 1;\r
realdelta = false;\r
break;\r
}\r
}\r
#endif\r
-#ifdef __DEBUG_InputMgr2__\r
+#ifdef __DEBUG_InputMgr__\r
if(dbg_testcontrolnoisy > 0)\r
-if(player->info.dir!=2/*(gvar->in.Keyboard[def->up] || gvar->in.Keyboard[def->down] || gvar->in.Keyboard[def->left] || gvar->in.Keyboard[def->right])*/ || player->enti.q>1)\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
//printf("b1=%u b2=%u b3=%u b4=%u ", player->info.button0, player->info.button1, player->info.button2, player->info.button3);\r
//printf("q=%d ", player->enti.q);\r
//printf("cpee=%c ", dirchar(conpee));\r
printf("pdir=%c d=%c dir=%c ", dirchar(player->pdir), dirchar(player->enti.d), dirchar(player->info.dir));\r
/*if(realdelta) */printf("dx=%d dy=%d mx=%d my=%d", player->info.x, player->info.y, player->info.xaxis, player->info.yaxis);\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
+ //else if(!realdelta) printf("%c%d %c%d %c%d %c%d", dirchar(0), inst.Keyboard[def->up], dirchar(4), inst.Keyboard[def->down], dirchar(1), inst.Keyboard[def->left], dirchar(3), inst.Keyboard[def->right]);\r
printf("\n");\r
}\r
#endif\r
//\r
///////////////////////////////////////////////////////////////////////////\r
ScanCode\r
-IN_WaitForKey(global_game_variables_t *gvar)//!\r
+IN_WaitForKey(void)\r
{\r
ScanCode result;\r
\r
- while (!(result = gvar->in.LastScan))\r
+ while (!(result = inst.LastScan))\r
;\r
- gvar->in.LastScan = 0;\r
+ inst.LastScan = 0;\r
return(result);\r
}\r
\r
//\r
///////////////////////////////////////////////////////////////////////////\r
char\r
-IN_WaitForASCII(global_game_variables_t *gvar)//!\r
+IN_WaitForASCII(void)\r
{\r
char result;\r
\r
- while (!(result = gvar->in.LastASCII))\r
+ while (!(result = inst.LastASCII))\r
;\r
- gvar->in.LastASCII = '\0';\r
+ inst.LastASCII = '\0';\r
return(result);\r
}\r
\r
\r
boolean btnstate[8];\r
\r
-void IN_StartAck(global_game_variables_t *gvar)//!\r
+void IN_StartAck(global_game_variables_t *gvar)\r
{\r
unsigned i,buttons;\r
\r
//\r
// get initial state of everything\r
//\r
- IN_ClearKeysDown(gvar);\r
+ IN_ClearKeysDown();\r
memset (btnstate,0,sizeof(btnstate));\r
\r
buttons = IN_JoyButtons () << 4;\r
}\r
\r
\r
-boolean IN_CheckAck (global_game_variables_t *gvar)//!\r
+boolean IN_CheckAck (global_game_variables_t *gvar)\r
{\r
unsigned i,buttons;\r
\r
//\r
// see if something has been pressed\r
//\r
- if (gvar->in.LastScan)\r
+ if (inst.LastScan)\r
return true;\r
\r
buttons = IN_JoyButtons () << 4;\r
//\r
///////////////////////////////////////////////////////////////////////////\r
boolean\r
-IN_IsUserInput(global_game_variables_t *gvar)//!\r
+IN_IsUserInput(global_game_variables_t *gvar)\r
{\r
boolean result;\r
word i;\r
\r
- result = gvar->in.LastScan;\r
+ result = inst.LastScan;\r
\r
if (gvar->in.MousePresent)\r
if (INL_GetMouseButtons())\r
===================\r
*/\r
\r
-byte IN_MouseButtons (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
return joybits;\r
}\r
\r
-boolean IN_KeyDown(byte code, global_game_variables_t *gvar)//!\r
+boolean IN_KeyDown(byte code)\r
{\r
-#ifdef __DEBUG_InputMgr2__\r
- if(gvar->in.Keyboard[code])\r
- printf("IN_KeyDown(%c): %u\n", code, gvar->in.Keyboard[code]);\r
+#ifdef __DEBUG_InputMgr__\r
+ if(inst.Keyboard[code])\r
+ printf("IN_KeyDown(%c): %u\n", code, inst.Keyboard[code]);\r
if(!dbg_nointest)\r
#endif\r
- return gvar->in.Keyboard[code];\r
-#ifdef __DEBUG_InputMgr2__\r
+ return inst.Keyboard[code];\r
+#ifdef __DEBUG_InputMgr__\r
else\r
if(dbg_nointest && kbhit())\r
return 1;\r
#endif\r
}\r
\r
-void IN_ClearKey(byte code, global_game_variables_t *gvar)//!\r
+void IN_ClearKey(byte code)\r
{\r
- gvar->in.Keyboard[code] = false;\r
- if(code == gvar->in.LastScan)\r
- gvar->in.LastScan = sc_None;\r
+ inst.Keyboard[code] = false;\r
+ if(code == inst.LastScan)\r
+ inst.LastScan = sc_None;\r
}\r
\r
-boolean IN_qb(byte kee, global_game_variables_t *gvar)//!\r
+boolean IN_qb(byte kee)\r
{\r
-#ifdef __DEBUG_InputMgr2__\r
- if(dbg_testkeyin) if(gvar->in.Keyboard[kee]) printf("IN_qb(): %u\n", gvar->in.Keyboard[kee]);\r
+#ifdef __DEBUG_InputMgr__\r
+ if(dbg_testkeyin) if(inst.Keyboard[kee]) printf("IN_qb(): %u\n", inst.Keyboard[kee]);\r
#endif\r
- if(gvar->in.Keyboard[kee]==true) return 1;\r
+ if(inst.Keyboard[kee]==true) return 1;\r
else return 0;\r
}\r
\r
-ScanCode IN_GetLastScan(global_game_variables_t *gvar)//!\r
+ScanCode IN_GetLastScan()\r
{\r
- return gvar->in.LastScan;\r
+ return inst.LastScan;\r
}\r
\r
-ScanCode IN_GetCurCode(global_game_variables_t *gvar)//!\r
+ScanCode IN_GetCurCode()\r
{\r
- return gvar->in.CurCode;\r
+ return inst.CurCode;\r
}\r
\r
void IN_KbdLED()\r