From af2715fef8681d909afe82f7baaf5e13baabb76f Mon Sep 17 00:00:00 2001 From: sparky4 Date: Thu, 23 Mar 2017 16:46:02 -0500 Subject: [PATCH] __seguse.txt added to show _seg usage also OpenVGMFile needs to be ported to 16_snd.c ][ ca needs huge amounts of work and i should remember what needs to be done soon also i should reverify 16_in.c to make sure it can work with other code of id engine] going to port rest of code to borland c some time so we can use the core components of id engine here [going to add 16_us.c eventually but the debug system and CA_ PM_ and MM_ usage is priority now] i fixed a bad bug on building the code initionally ^^; [NEW IMPROVED 16_IN_1.C ADDED AND IN TESTING PROCESS] --- makefile | 3 +- src/0.c | 14 +-- src/16.c | 4 +- src/inputest.c | 8 +- src/lib/16_in.c | 202 +++++++++++++++--------------- src/lib/16_in.h | 24 ++-- src/lib/{16_in_1.c => 16_in_o.c} | 204 +++++++++++++++---------------- src/lib/{16_in_1.h => 16_in_o.h} | 24 ++-- src/lib/16_tail.c | 4 +- src/lib/16_tail.h | 26 ++-- src/test.c | 10 +- src/vrstest.c | 6 +- src/zcroll.c | 8 +- 13 files changed, 268 insertions(+), 269 deletions(-) rename src/lib/{16_in_1.c => 16_in_o.c} (83%) rename src/lib/{16_in_1.h => 16_in_o.h} (85%) diff --git a/makefile b/makefile index eeb4d5ac..defcd3fd 100755 --- a/makefile +++ b/makefile @@ -196,8 +196,7 @@ TESTEXEC = & zcroll.exe & inputest.exe & vrstest.exe & - maptest.exe & - inntest.exe + maptest.exe TESTEXEC2 = & pcxtest.exe & scroll.exe & diff --git a/src/0.c b/src/0.c index 28d5ff05..96d8e7aa 100755 --- a/src/0.c +++ b/src/0.c @@ -101,8 +101,8 @@ int main(int argc,char **argv) vrl_lineoffs = vrl1_vgax_genlineoffsets(vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); if (vrl_lineoffs == NULL) return 1; - IN_Startup(); - IN_Default(0,&gvar.player[0],ctrl_Keyboard1); + IN_Startup(&gvar); + IN_Default(0,&gvar.player[0],ctrl_Keyboard1, &gvar); EN_initPlayer(&gvar.player[0], &gvar.video); /* setup camera and screen~ */ @@ -140,14 +140,14 @@ int main(int argc,char **argv) while(!IN_KeyDown(sc_Escape)) { - IN_ReadControl(&gvar.player[0]); - if(IN_KeyDown(68)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap; IN_UserInput(1); } //f10 + IN_ReadControl(&gvar.player[0], &gvar); + if(IN_KeyDown(68)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap; IN_UserInput(1, &gvar); } //f10 TAIL_PANKEYFUN; if(IN_KeyDown(sc_Space) || zerostoppause) //space { anim=!anim; DRAWCORNERBOXES; - if(!zerostoppause) IN_UserInput(1); else zerostoppause=0; + if(!zerostoppause) IN_UserInput(1, &gvar); else zerostoppause=0; } if(IN_KeyDown(sc_R)){ gvar.video.page[0].dx=gvar.video.page[0].dy=gvar.video.page[1].dx=gvar.video.page[1].dy=16; @@ -213,7 +213,7 @@ draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header } } - IN_UserInput(1); + IN_UserInput(1, &gvar); //===========================================================================// @@ -301,7 +301,7 @@ if(!noanim) { } } } - IN_Shutdown(); + IN_Shutdown(&gvar); VGAmodeX(0, 1, &gvar); free(vrl_lineoffs); buffer = NULL; diff --git a/src/16.c b/src/16.c index 4fda90d4..af711c37 100755 --- a/src/16.c +++ b/src/16.c @@ -37,11 +37,11 @@ main(int argc, char *argv[]) modexSavePalFile("data/g.pal", gvar.video.palette); VGAmodeX(1, 1, &gvar); // modexPalBlack(); //so player will not see loadings~ - IN_Default(0,&gvar.player[0],ctrl_Joystick); + IN_Default(0,&gvar.player[0],ctrl_Joystick, &gvar); //modexprint(&screen, 32, 32, 1, 2, 0, "a", 1); while(ENGI_QUIT != gvar.engi_stat) { - IN_ReadControl(&gvar.player[0]); + IN_ReadControl(&gvar.player[0], &gvar); if(IN_KeyDown(sc_Escape)) gvar.engi_stat = ENGI_QUIT; shinku(&gvar); _DEBUGF("Serial debug output printf test %u %u %u\n",1U,2U,3U); diff --git a/src/inputest.c b/src/inputest.c index 2b2d564b..56370b74 100755 --- a/src/inputest.c +++ b/src/inputest.c @@ -34,9 +34,9 @@ main(int argc, char *argv[]) dbg_testcontrolnoisy=1; start_timer(&gvar); //Startup16(&gvar); - IN_Startup(); + IN_Startup(&gvar); IN_Default(0,&gvar.player[0], -ctrl_Keyboard1); +ctrl_Keyboard1, &gvar); //ctrl_Joystick1); IN_SetControlType(&gvar.player[0], ctrl_Keyboard1); @@ -52,7 +52,7 @@ ctrl_Keyboard1); while(!IN_KeyDown(sc_Escape)) { //0000 shinkutxt(&gvar); - IN_ReadControl(&gvar.player[0]); + IN_ReadControl(&gvar.player[0], &gvar); switch(gvar.player[0].enti.d) { //right movement @@ -104,7 +104,7 @@ ctrl_Keyboard1); //IN_Ack(); } } - IN_Shutdown(); + IN_Shutdown(&gvar); //Shutdown16(&gvar); //printf("%u\n", in.Keyboard[sc_Escape]); printf("inputest.exe "); diff --git a/src/lib/16_in.c b/src/lib/16_in.c index e7ed19ed..98ecb70d 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -51,7 +51,7 @@ static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ ============================================================================= */ -struct inconfig +/*struct inconfig { boolean MousePresent; boolean JoysPresent[MaxJoys]; @@ -62,9 +62,9 @@ struct inconfig KeyboardDef KbdDefs[MaxKbds]; JoystickDef JoyDefs[MaxJoys]; -} inpu; +} inpu;*/ -//inpu.KbdDefs = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/}; +//gvar->in.KbdDefs = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/}; /* ============================================================================= @@ -79,9 +79,13 @@ extern "C" { #endif static struct instat { - boolean IN_Started; boolean CapsLock; ScanCode CurCode,LastCode; + + boolean Keyboard[NumCodes]; + boolean Paused; + char LastASCII; + ScanCode LastScan; } inst; static byte far ASCIINames[] = // Unshifted ASCII for scan codes @@ -183,7 +187,7 @@ static boolean special; if (k == 0xe0) // Special key prefix special = true; else if (k == 0xe1) // Handle Pause key - inpu.Paused = true; + inst.Paused = true; else { if (k & 0x80) // Break code @@ -192,13 +196,13 @@ static boolean special; // DEBUG - handle special keys: ctl-alt-delete, print scrn - inpu.Keyboard[k] = false; + inst.Keyboard[k] = false; } else // Make code { inst.LastCode = inst.CurCode; - inst.CurCode = inpu.LastScan = k; - inpu.Keyboard[k] = true; + inst.CurCode = inst.LastScan = k; + inst.Keyboard[k] = true; if (special) c = SpecialNames[k]; @@ -210,7 +214,7 @@ static boolean special; // DEBUG - make caps lock light work } - if (inpu.Keyboard[sc_LShift] || inpu.Keyboard[sc_RShift]) // If shifted + if (inst.Keyboard[sc_LShift] || inst.Keyboard[sc_RShift]) // If shifted { c = ShiftNames[k]; if ((c >= 'A') && (c <= 'Z') && inst.CapsLock) @@ -224,7 +228,7 @@ static boolean special; } } if (c) - inpu.LastASCII = c; + inst.LastASCII = c; } special = false; @@ -233,7 +237,7 @@ static boolean special; if (INL_KeyHook && !special) INL_KeyHook(); #ifdef __DEBUG_InputMgr__ - if(dbg_testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, inpu.Keyboard[k]); + if(dbg_testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, inst.Keyboard[k]); #endif outportb(0x20,0x20); } @@ -376,7 +380,7 @@ done: // joystick (from +/-127) // /////////////////////////////////////////////////////////////////////////// -void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/) +void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/, global_game_variables_t *gvar) { word x,y; word TimeCount = *clockw; @@ -384,7 +388,7 @@ void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/) static word lasttime; IN_GetJoyAbs(joy,&x,&y); - def = inpu.JoyDefs + joy; + def = gvar->in.JoyDefs + joy; if (x < def->threshMinX) { @@ -493,7 +497,7 @@ IN_GetJoyButtonsDB(word joy) // /////////////////////////////////////////////////////////////////////////// static void -INL_StartKbd(void) +INL_StartKbd(global_game_variables_t *gvar) { INL_KeyHook = NULL; // Clear key hook @@ -560,11 +564,11 @@ INL_ShutMouse(void) // INL_SetJoyScale() - Sets up scaling values for the specified joystick // static void -INL_SetJoyScale(word joy) +INL_SetJoyScale(word joy, global_game_variables_t *gvar) { JoystickDef *def; - def = &(inpu.JoyDefs[joy]); + def = &(gvar->in.JoyDefs[joy]); def->joyMultXL = JoyScaleMax / (def->threshMinX - def->joyMinX); def->joyMultXH = JoyScaleMax / (def->joyMaxX - def->threshMaxX); def->joyMultYL = JoyScaleMax / (def->threshMinY - def->joyMinY); @@ -578,12 +582,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, global_game_variables_t *gvar) { word d,r; JoystickDef *def; - def = &(inpu.JoyDefs[joy]); + def = &(gvar->in.JoyDefs[joy]); def->joyMinX = minx; def->joyMaxX = maxx; @@ -599,7 +603,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, gvar); } /////////////////////////////////////////////////////////////////////////// @@ -609,7 +613,7 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy) // /////////////////////////////////////////////////////////////////////////// static boolean -INL_StartJoy(word joy) +INL_StartJoy(word joy, global_game_variables_t *gvar) { word x,y; @@ -623,7 +627,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, gvar); return(true); } } @@ -634,9 +638,9 @@ INL_StartJoy(word joy) // /////////////////////////////////////////////////////////////////////////// static void -INL_ShutJoy(word joy) +INL_ShutJoy(word joy, global_game_variables_t *gvar) { - inpu.JoysPresent[joy] = false; + gvar->in.JoysPresent[joy] = false; } // Public routines @@ -647,12 +651,12 @@ INL_ShutJoy(word joy) // /////////////////////////////////////////////////////////////////////////// void -IN_Startup() +IN_Startup(global_game_variables_t *gvar) { boolean checkjoys,checkmouse; word i; - if (inst.IN_Started) + if (gvar->in.IN_Started) return; checkjoys = true; @@ -670,13 +674,15 @@ IN_Startup() } } - INL_StartKbd(); - inpu.MousePresent = checkmouse? INL_StartMouse() : false; + INL_StartKbd(gvar); + gvar->in.MousePresent = checkmouse? INL_StartMouse() : false; for (i = 0;i < MaxJoys;i++) - inpu.JoysPresent[i] = checkjoys? INL_StartJoy(i) : false; + gvar->in.JoysPresent[i] = checkjoys? INL_StartJoy(i, gvar) : false; + + gvar->in.inst = &inst; - inst.IN_Started = true; + gvar->in.IN_Started = true; } @@ -686,26 +692,26 @@ IN_Startup() // /////////////////////////////////////////////////////////////////////////// void -IN_Default(boolean gotit,player_t *player,ControlType nt) +IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar) { int i; if ( (!gotit) - || ((nt == ctrl_Joystick1) && !inpu.JoysPresent[0]) - || ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1]) - || ((nt == ctrl_Mouse) && !inpu.MousePresent) + || ((nt == ctrl_Joystick1) && !gvar->in.JoysPresent[0]) + || ((nt == ctrl_Joystick2) && !gvar->in.JoysPresent[1]) + || ((nt == ctrl_Mouse) && !gvar->in.MousePresent) ) nt = ctrl_Keyboard1; - inpu.KbdDefs[0].button0 = 0x1c; - inpu.KbdDefs[0].button1 = 0x38; + gvar->in.KbdDefs[0].button0 = 0x1c; + gvar->in.KbdDefs[0].button1 = 0x38; //in.KbdDefs[0].upleft = 0x47; - inpu.KbdDefs[0].up = 0x48; + gvar->in.KbdDefs[0].up = 0x48; //in.KbdDefs[0].upright = 0x49; - inpu.KbdDefs[0].left = 0x4b; - inpu.KbdDefs[0].right = 0x4d; + gvar->in.KbdDefs[0].left = 0x4b; + gvar->in.KbdDefs[0].right = 0x4d; //in.KbdDefs[0].downleft = 0x4f; - inpu.KbdDefs[0].down = 0x50; + gvar->in.KbdDefs[0].down = 0x50; //in.KbdDefs[0].downright = 0x51; IN_SetControlType(player,nt); for(i=0; i>MaxPlayers;i++) @@ -718,19 +724,19 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) // /////////////////////////////////////////////////////////////////////////// void -IN_Shutdown(void) +IN_Shutdown(global_game_variables_t *gvar) { word i; - if (!inst.IN_Started) + if (!gvar->in.IN_Started) return; INL_ShutMouse(); for (i = 0;i < MaxJoys;i++) - INL_ShutJoy(i); + INL_ShutJoy(i, gvar); INL_ShutKbd(); - inst.IN_Started = false; + gvar->in.IN_Started = false; } /////////////////////////////////////////////////////////////////////////// @@ -755,9 +761,9 @@ IN_ClearKeysDown(void) { //int i; - inpu.LastScan = sc_None; - inpu.LastASCII = key_None; - memset (inpu.Keyboard,0,sizeof(inpu.Keyboard)); + inst.LastScan = sc_None; + inst.LastASCII = key_None; + memset (inst.Keyboard,0,sizeof(inst.Keyboard)); } /////////////////////////////////////////////////////////////////////////// @@ -784,7 +790,7 @@ INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy) // /////////////////////////////////////////////////////////////////////////// void -IN_ReadCursor(CursorInfo *info) +IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar) { word i, buttons; @@ -793,7 +799,7 @@ IN_ReadCursor(CursorInfo *info) info->x = info->y = 0; info->button0 = info->button1 = false; - if (inpu.MousePresent) + if (gvar->in.MousePresent) { buttons = INL_GetMouseButtons(); INL_GetMouseDelta(&dx,&dy); @@ -802,11 +808,11 @@ IN_ReadCursor(CursorInfo *info) for (i = 0;i < MaxJoys;i++) { - if (!inpu.JoysPresent[i]) + if (!gvar->in.JoysPresent[i]) continue; buttons = INL_GetJoyButtons(i); - INL_GetJoyDelta(i,&dx,&dy/*,true*/); + INL_GetJoyDelta(i,&dx,&dy/*,true*/, gvar); dx /= 64; dy /= 64; INL_AdjustCursor(info,buttons,dx,dy); @@ -824,7 +830,7 @@ IN_ReadCursor(CursorInfo *info) // /////////////////////////////////////////////////////////////////////////// void -IN_ReadControl(player_t *player) +IN_ReadControl(player_t *player, global_game_variables_t *gvar) { boolean realdelta; #if DEMO0 @@ -868,7 +874,7 @@ register KeyboardDef *def; { case ctrl_Keyboard1: case ctrl_Keyboard2: - def = &(inpu.KbdDefs[type - ctrl_Keyboard]); + def = &(gvar->in.KbdDefs[type - ctrl_Keyboard]); /* if (Keyboard[def->upleft]) mx = motion_Left,my = motion_Up; @@ -881,28 +887,28 @@ register KeyboardDef *def; //TODO: make this into a function that the joystick AND keyboard can use wwww if(DIRECTIONIFELSE)//(player->info.dir == 2) { - if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){ - if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) + if(!inst.Keyboard[def->left] && !inst.Keyboard[def->right]){ + if((inst.Keyboard[def->up] && !inst.Keyboard[def->down])) my = motion_Up; - if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) + if((inst.Keyboard[def->down] && !inst.Keyboard[def->up])) my = motion_Down; - }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){ - if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) + }else if(!inst.Keyboard[def->up] && !inst.Keyboard[def->down]){ + if((inst.Keyboard[def->left] && !inst.Keyboard[def->right])) mx = motion_Left; - if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) + if((inst.Keyboard[def->right] && !inst.Keyboard[def->left])) mx = motion_Right; }else{ //2 keys pressed switch (player->pdir) { case 0: case 4: - if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])){ dir = DirTable[1]; }//mx = motion_Left; } - else if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])){ dir = DirTable[3]; }//mx = motion_Right; } + if((inst.Keyboard[def->left] && !inst.Keyboard[def->right])){ dir = DirTable[1]; }//mx = motion_Left; } + else if((inst.Keyboard[def->right] && !inst.Keyboard[def->left])){ dir = DirTable[3]; }//mx = motion_Right; } break; case 1: case 3: - if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])){ dir = DirTable[0]; }//my = motion_Up; } - else if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])){ dir = DirTable[4]; }//my = motion_Down; } + if((inst.Keyboard[def->up] && !inst.Keyboard[def->down])){ dir = DirTable[0]; }//my = motion_Up; } + else if((inst.Keyboard[def->down] && !inst.Keyboard[def->up])){ dir = DirTable[4]; }//my = motion_Down; } break; default: break; @@ -913,15 +919,15 @@ register KeyboardDef *def; } } //input from player - if (inpu.Keyboard[def->button0]) + if (inst.Keyboard[def->button0]) buttons += 1 << 0; - if (inpu.Keyboard[def->button1]) + if (inst.Keyboard[def->button1]) buttons += 1 << 1; realdelta = false; break; case ctrl_Joystick1: case ctrl_Joystick2: - INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy/*,false*/); + INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy/*,false*/, gvar); buttons = INL_GetJoyButtons(type - ctrl_Joystick); realdelta = true; break; @@ -992,14 +998,14 @@ register KeyboardDef *def; #endif #ifdef __DEBUG_InputMgr__ if(dbg_testcontrolnoisy > 0) -if(player->info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])*/ || player->enti.q>1) +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) { //printf("b1=%u b2=%u b3=%u b4=%u ", player->info.button0, player->info.button1, player->info.button2, player->info.button3); //printf("q=%d ", player->enti.q); //printf("cpee=%c ", dirchar(conpee)); printf("pdir=%c d=%c dir=%c ", dirchar(player->pdir), dirchar(player->enti.d), dirchar(player->info.dir)); /*if(realdelta) */printf("dx=%d dy=%d mx=%d my=%d", player->info.x, player->info.y, player->info.xaxis, player->info.yaxis); - //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]); + //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]); printf("\n"); } #endif @@ -1112,9 +1118,9 @@ IN_WaitForKey(void) { ScanCode result; - while (!(result = inpu.LastScan)) + while (!(result = inst.LastScan)) ; - inpu.LastScan = 0; + inst.LastScan = 0; return(result); } @@ -1129,9 +1135,9 @@ IN_WaitForASCII(void) { char result; - while (!(result = inpu.LastASCII)) + while (!(result = inst.LastASCII)) ; - inpu.LastASCII = '\0'; + inst.LastASCII = '\0'; return(result); } @@ -1144,7 +1150,7 @@ IN_WaitForASCII(void) boolean btnstate[8]; -void IN_StartAck(void) +void IN_StartAck(global_game_variables_t *gvar) { unsigned i,buttons; @@ -1155,8 +1161,8 @@ void IN_StartAck(void) memset (btnstate,0,sizeof(btnstate)); buttons = IN_JoyButtons () << 4; - if (inpu.MousePresent) - buttons |= IN_MouseButtons (); + if (gvar->in.MousePresent) + buttons |= IN_MouseButtons (gvar); for (i=0;i<8;i++,buttons>>=1) if (buttons&1) @@ -1164,19 +1170,19 @@ void IN_StartAck(void) } -boolean IN_CheckAck (void) +boolean IN_CheckAck (global_game_variables_t *gvar) { unsigned i,buttons; // // see if something has been pressed // - if (inpu.LastScan) + if (inst.LastScan) return true; buttons = IN_JoyButtons () << 4; - if (inpu.MousePresent) - buttons |= IN_MouseButtons (); + if (gvar->in.MousePresent) + buttons |= IN_MouseButtons (gvar); for (i=0;i<8;i++,buttons>>=1) if ( buttons&1 ) @@ -1191,11 +1197,11 @@ boolean IN_CheckAck (void) } -void IN_Ack (void) +void IN_Ack (global_game_variables_t *gvar) { - IN_StartAck (); + IN_StartAck (gvar); - while (!IN_CheckAck ()) + while (!IN_CheckAck (gvar)) ; } @@ -1206,19 +1212,19 @@ void IN_Ack (void) // /////////////////////////////////////////////////////////////////////////// boolean -IN_IsUserInput() +IN_IsUserInput(global_game_variables_t *gvar) { boolean result; word i; - result = inpu.LastScan; + result = inst.LastScan; - if (inpu.MousePresent) + if (gvar->in.MousePresent) if (INL_GetMouseButtons()) result = true; for (i = 0;i < MaxJoys;i++) - if (inpu.JoysPresent[i]) + if (gvar->in.JoysPresent[i]) if (INL_GetJoyButtons(i)) result = true; @@ -1233,16 +1239,16 @@ IN_IsUserInput() // button up. // /////////////////////////////////////////////////////////////////////////// -boolean IN_UserInput(word delay) +boolean IN_UserInput(word delay, global_game_variables_t *gvar) { word TimeCount = *clockw; word lasttime; lasttime = TimeCount; - IN_StartAck (); + IN_StartAck (gvar); do { - if (IN_CheckAck()) + if (IN_CheckAck(gvar)) return true; } while (TimeCount - lasttime < delay); return(false); @@ -1258,10 +1264,10 @@ boolean IN_UserInput(word delay) =================== */ -byte IN_MouseButtons (void) +byte IN_MouseButtons (global_game_variables_t *gvar) { union REGS CPURegs; - if (inpu.MousePresent) + if (gvar->in.MousePresent) { Mouse(MButtons); return CPURegs.x.bx; @@ -1293,9 +1299,11 @@ byte IN_JoyButtons (void) boolean IN_KeyDown(byte code) { #ifdef __DEBUG_InputMgr__ + if(inst.Keyboard[code]) + printf("IN_KeyDown(%c): %u\n", code, inst.Keyboard[code]); if(!dbg_nointest) #endif - return inpu.Keyboard[code]; + return inst.Keyboard[code]; #ifdef __DEBUG_InputMgr__ else if(dbg_nointest && kbhit()) @@ -1307,23 +1315,23 @@ boolean IN_KeyDown(byte code) void IN_ClearKey(byte code) { - inpu.Keyboard[code] = false; - if(code == inpu.LastScan) - inpu.LastScan = sc_None; + inst.Keyboard[code] = false; + if(code == inst.LastScan) + inst.LastScan = sc_None; } boolean IN_qb(byte kee) { #ifdef __DEBUG_InputMgr__ - if(dbg_testkeyin) printf("%u\n", inpu.Keyboard[kee]); + if(dbg_testkeyin) if(inst.Keyboard[kee]) printf("IN_qb(): %u\n", inst.Keyboard[kee]); #endif - if(inpu.Keyboard[kee]==true) return 1; + if(inst.Keyboard[kee]==true) return 1; else return 0; } ScanCode IN_GetLastScan() { - return inpu.LastScan; + return inst.LastScan; } ScanCode IN_GetCurCode() diff --git a/src/lib/16_in.h b/src/lib/16_in.h index eb8048bc..97a560d0 100755 --- a/src/lib/16_in.h +++ b/src/lib/16_in.h @@ -213,34 +213,34 @@ typedef struct { #endif // Internal routines -extern void IN_Startup(void),IN_Shutdown(void), - IN_Default(boolean gotit,player_t *player,ControlType nt), +extern void IN_Startup(global_game_variables_t *gvar),IN_Shutdown(global_game_variables_t *gvar), + IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar), IN_SetKeyHook(void (*)()), IN_ClearKeysDown(void), - IN_ReadCursor(CursorInfo *), - IN_ReadControl(player_t *player), + IN_ReadCursor(CursorInfo *, global_game_variables_t *gvar), + IN_ReadControl(player_t *player, global_game_variables_t *gvar), IN_SetControlType(player_t *player,ControlType type), IN_GetJoyAbs(word joy,word *xp,word *yp), IN_SetupJoy(word joy,word minx,word maxx, - word miny,word maxy), + word miny,word maxy, global_game_variables_t *gvar), #if DEMO0 IN_StopDemo(void),IN_FreeDemoBuffer(void), #endif - IN_Ack(void),IN_AckBack(void); -extern boolean IN_UserInput(word delay); + IN_Ack(global_game_variables_t *gvar),IN_AckBack(void); +extern boolean IN_UserInput(word delay, global_game_variables_t *gvar); extern char IN_WaitForASCII(void); extern ScanCode IN_WaitForKey(void); extern word IN_GetJoyButtonsDB(word joy); extern byte *IN_GetScanName(ScanCode); -byte IN_MouseButtons (void); +byte IN_MouseButtons (global_game_variables_t *gvar); byte IN_JoyButtons (void); -void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/); -void IN_StartAck(void); -boolean IN_CheckAck (void); -boolean IN_IsUserInput(); +void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/, global_game_variables_t *gvar); +void IN_StartAck(global_game_variables_t *gvar); +boolean IN_CheckAck (global_game_variables_t *gvar); +boolean IN_IsUserInput(global_game_variables_t *gvar); #define Mouse(x) INL_Mouse(x) //void IN_SetKeyHook(void (*hook)()); #if DEMO0 diff --git a/src/lib/16_in_1.c b/src/lib/16_in_o.c similarity index 83% rename from src/lib/16_in_1.c rename to src/lib/16_in_o.c index 3eb669d3..e7ed19ed 100755 --- a/src/lib/16_in_1.c +++ b/src/lib/16_in_o.c @@ -39,7 +39,7 @@ // DEBUG - there are more globals // -#include "src/lib/16_in_1.h" +#include "src/lib/16_in.h" #pragma hdrstop static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ @@ -51,7 +51,7 @@ static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ ============================================================================= */ -/*struct inconfig +struct inconfig { boolean MousePresent; boolean JoysPresent[MaxJoys]; @@ -62,9 +62,9 @@ static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ KeyboardDef KbdDefs[MaxKbds]; JoystickDef JoyDefs[MaxJoys]; -} inpu;*/ +} inpu; -//gvar->in.KbdDefs = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/}; +//inpu.KbdDefs = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/}; /* ============================================================================= @@ -79,13 +79,9 @@ extern "C" { #endif static struct instat { + boolean IN_Started; boolean CapsLock; ScanCode CurCode,LastCode; - - boolean Keyboard[NumCodes]; - boolean Paused; - char LastASCII; - ScanCode LastScan; } inst; static byte far ASCIINames[] = // Unshifted ASCII for scan codes @@ -187,7 +183,7 @@ static boolean special; if (k == 0xe0) // Special key prefix special = true; else if (k == 0xe1) // Handle Pause key - inst.Paused = true; + inpu.Paused = true; else { if (k & 0x80) // Break code @@ -196,13 +192,13 @@ static boolean special; // DEBUG - handle special keys: ctl-alt-delete, print scrn - inst.Keyboard[k] = false; + inpu.Keyboard[k] = false; } else // Make code { inst.LastCode = inst.CurCode; - inst.CurCode = inst.LastScan = k; - inst.Keyboard[k] = true; + inst.CurCode = inpu.LastScan = k; + inpu.Keyboard[k] = true; if (special) c = SpecialNames[k]; @@ -214,7 +210,7 @@ static boolean special; // DEBUG - make caps lock light work } - if (inst.Keyboard[sc_LShift] || inst.Keyboard[sc_RShift]) // If shifted + if (inpu.Keyboard[sc_LShift] || inpu.Keyboard[sc_RShift]) // If shifted { c = ShiftNames[k]; if ((c >= 'A') && (c <= 'Z') && inst.CapsLock) @@ -228,7 +224,7 @@ static boolean special; } } if (c) - inst.LastASCII = c; + inpu.LastASCII = c; } special = false; @@ -237,7 +233,7 @@ static boolean special; if (INL_KeyHook && !special) INL_KeyHook(); #ifdef __DEBUG_InputMgr__ - if(dbg_testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, inst.Keyboard[k]); + if(dbg_testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, inpu.Keyboard[k]); #endif outportb(0x20,0x20); } @@ -380,7 +376,7 @@ done: // joystick (from +/-127) // /////////////////////////////////////////////////////////////////////////// -void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/, global_game_variables_t *gvar) +void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/) { word x,y; word TimeCount = *clockw; @@ -388,7 +384,7 @@ void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/, global_game_ static word lasttime; IN_GetJoyAbs(joy,&x,&y); - def = gvar->in.JoyDefs + joy; + def = inpu.JoyDefs + joy; if (x < def->threshMinX) { @@ -497,7 +493,7 @@ IN_GetJoyButtonsDB(word joy) // /////////////////////////////////////////////////////////////////////////// static void -INL_StartKbd(global_game_variables_t *gvar) +INL_StartKbd(void) { INL_KeyHook = NULL; // Clear key hook @@ -564,11 +560,11 @@ INL_ShutMouse(void) // INL_SetJoyScale() - Sets up scaling values for the specified joystick // static void -INL_SetJoyScale(word joy, global_game_variables_t *gvar) +INL_SetJoyScale(word joy) { JoystickDef *def; - def = &(gvar->in.JoyDefs[joy]); + def = &(inpu.JoyDefs[joy]); def->joyMultXL = JoyScaleMax / (def->threshMinX - def->joyMinX); def->joyMultXH = JoyScaleMax / (def->joyMaxX - def->threshMaxX); def->joyMultYL = JoyScaleMax / (def->threshMinY - def->joyMinY); @@ -582,12 +578,12 @@ INL_SetJoyScale(word joy, global_game_variables_t *gvar) // /////////////////////////////////////////////////////////////////////////// void -IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, global_game_variables_t *gvar) +IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy) { word d,r; JoystickDef *def; - def = &(gvar->in.JoyDefs[joy]); + def = &(inpu.JoyDefs[joy]); def->joyMinX = minx; def->joyMaxX = maxx; @@ -603,7 +599,7 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, global_game_variab def->threshMinY = ((r / 2) - d) + miny; def->threshMaxY = ((r / 2) + d) + miny; - INL_SetJoyScale(joy, gvar); + INL_SetJoyScale(joy); } /////////////////////////////////////////////////////////////////////////// @@ -613,7 +609,7 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, global_game_variab // /////////////////////////////////////////////////////////////////////////// static boolean -INL_StartJoy(word joy, global_game_variables_t *gvar) +INL_StartJoy(word joy) { word x,y; @@ -627,7 +623,7 @@ INL_StartJoy(word joy, global_game_variables_t *gvar) return(false); else { - IN_SetupJoy(joy,0,x * 2,0,y * 2, gvar); + IN_SetupJoy(joy,0,x * 2,0,y * 2); return(true); } } @@ -638,9 +634,9 @@ INL_StartJoy(word joy, global_game_variables_t *gvar) // /////////////////////////////////////////////////////////////////////////// static void -INL_ShutJoy(word joy, global_game_variables_t *gvar) +INL_ShutJoy(word joy) { - gvar->in.JoysPresent[joy] = false; + inpu.JoysPresent[joy] = false; } // Public routines @@ -651,12 +647,12 @@ INL_ShutJoy(word joy, global_game_variables_t *gvar) // /////////////////////////////////////////////////////////////////////////// void -IN_Startup(global_game_variables_t *gvar) +IN_Startup() { boolean checkjoys,checkmouse; word i; - if (gvar->in.IN_Started) + if (inst.IN_Started) return; checkjoys = true; @@ -674,15 +670,13 @@ IN_Startup(global_game_variables_t *gvar) } } - INL_StartKbd(gvar); - gvar->in.MousePresent = checkmouse? INL_StartMouse() : false; + INL_StartKbd(); + inpu.MousePresent = checkmouse? INL_StartMouse() : false; for (i = 0;i < MaxJoys;i++) - gvar->in.JoysPresent[i] = checkjoys? INL_StartJoy(i, gvar) : false; - - gvar->in.inst = &inst; + inpu.JoysPresent[i] = checkjoys? INL_StartJoy(i) : false; - gvar->in.IN_Started = true; + inst.IN_Started = true; } @@ -692,26 +686,26 @@ IN_Startup(global_game_variables_t *gvar) // /////////////////////////////////////////////////////////////////////////// void -IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar) +IN_Default(boolean gotit,player_t *player,ControlType nt) { int i; if ( (!gotit) - || ((nt == ctrl_Joystick1) && !gvar->in.JoysPresent[0]) - || ((nt == ctrl_Joystick2) && !gvar->in.JoysPresent[1]) - || ((nt == ctrl_Mouse) && !gvar->in.MousePresent) + || ((nt == ctrl_Joystick1) && !inpu.JoysPresent[0]) + || ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1]) + || ((nt == ctrl_Mouse) && !inpu.MousePresent) ) nt = ctrl_Keyboard1; - gvar->in.KbdDefs[0].button0 = 0x1c; - gvar->in.KbdDefs[0].button1 = 0x38; + inpu.KbdDefs[0].button0 = 0x1c; + inpu.KbdDefs[0].button1 = 0x38; //in.KbdDefs[0].upleft = 0x47; - gvar->in.KbdDefs[0].up = 0x48; + inpu.KbdDefs[0].up = 0x48; //in.KbdDefs[0].upright = 0x49; - gvar->in.KbdDefs[0].left = 0x4b; - gvar->in.KbdDefs[0].right = 0x4d; + inpu.KbdDefs[0].left = 0x4b; + inpu.KbdDefs[0].right = 0x4d; //in.KbdDefs[0].downleft = 0x4f; - gvar->in.KbdDefs[0].down = 0x50; + inpu.KbdDefs[0].down = 0x50; //in.KbdDefs[0].downright = 0x51; IN_SetControlType(player,nt); for(i=0; i>MaxPlayers;i++) @@ -724,19 +718,19 @@ IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_ // /////////////////////////////////////////////////////////////////////////// void -IN_Shutdown(global_game_variables_t *gvar) +IN_Shutdown(void) { word i; - if (!gvar->in.IN_Started) + if (!inst.IN_Started) return; INL_ShutMouse(); for (i = 0;i < MaxJoys;i++) - INL_ShutJoy(i, gvar); + INL_ShutJoy(i); INL_ShutKbd(); - gvar->in.IN_Started = false; + inst.IN_Started = false; } /////////////////////////////////////////////////////////////////////////// @@ -761,9 +755,9 @@ IN_ClearKeysDown(void) { //int i; - inst.LastScan = sc_None; - inst.LastASCII = key_None; - memset (inst.Keyboard,0,sizeof(inst.Keyboard)); + inpu.LastScan = sc_None; + inpu.LastASCII = key_None; + memset (inpu.Keyboard,0,sizeof(inpu.Keyboard)); } /////////////////////////////////////////////////////////////////////////// @@ -790,7 +784,7 @@ INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy) // /////////////////////////////////////////////////////////////////////////// void -IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar) +IN_ReadCursor(CursorInfo *info) { word i, buttons; @@ -799,7 +793,7 @@ IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar) info->x = info->y = 0; info->button0 = info->button1 = false; - if (gvar->in.MousePresent) + if (inpu.MousePresent) { buttons = INL_GetMouseButtons(); INL_GetMouseDelta(&dx,&dy); @@ -808,11 +802,11 @@ IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar) for (i = 0;i < MaxJoys;i++) { - if (!gvar->in.JoysPresent[i]) + if (!inpu.JoysPresent[i]) continue; buttons = INL_GetJoyButtons(i); - INL_GetJoyDelta(i,&dx,&dy/*,true*/, gvar); + INL_GetJoyDelta(i,&dx,&dy/*,true*/); dx /= 64; dy /= 64; INL_AdjustCursor(info,buttons,dx,dy); @@ -830,7 +824,7 @@ IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar) // /////////////////////////////////////////////////////////////////////////// void -IN_ReadControl(player_t *player, global_game_variables_t *gvar) +IN_ReadControl(player_t *player) { boolean realdelta; #if DEMO0 @@ -874,7 +868,7 @@ register KeyboardDef *def; { case ctrl_Keyboard1: case ctrl_Keyboard2: - def = &(gvar->in.KbdDefs[type - ctrl_Keyboard]); + def = &(inpu.KbdDefs[type - ctrl_Keyboard]); /* if (Keyboard[def->upleft]) mx = motion_Left,my = motion_Up; @@ -887,28 +881,28 @@ register KeyboardDef *def; //TODO: make this into a function that the joystick AND keyboard can use wwww if(DIRECTIONIFELSE)//(player->info.dir == 2) { - if(!inst.Keyboard[def->left] && !inst.Keyboard[def->right]){ - if((inst.Keyboard[def->up] && !inst.Keyboard[def->down])) + if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){ + if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) my = motion_Up; - if((inst.Keyboard[def->down] && !inst.Keyboard[def->up])) + if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) my = motion_Down; - }else if(!inst.Keyboard[def->up] && !inst.Keyboard[def->down]){ - if((inst.Keyboard[def->left] && !inst.Keyboard[def->right])) + }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){ + if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) mx = motion_Left; - if((inst.Keyboard[def->right] && !inst.Keyboard[def->left])) + if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) mx = motion_Right; }else{ //2 keys pressed switch (player->pdir) { case 0: case 4: - if((inst.Keyboard[def->left] && !inst.Keyboard[def->right])){ dir = DirTable[1]; }//mx = motion_Left; } - else if((inst.Keyboard[def->right] && !inst.Keyboard[def->left])){ dir = DirTable[3]; }//mx = motion_Right; } + if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])){ dir = DirTable[1]; }//mx = motion_Left; } + else if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])){ dir = DirTable[3]; }//mx = motion_Right; } break; case 1: case 3: - if((inst.Keyboard[def->up] && !inst.Keyboard[def->down])){ dir = DirTable[0]; }//my = motion_Up; } - else if((inst.Keyboard[def->down] && !inst.Keyboard[def->up])){ dir = DirTable[4]; }//my = motion_Down; } + if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])){ dir = DirTable[0]; }//my = motion_Up; } + else if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])){ dir = DirTable[4]; }//my = motion_Down; } break; default: break; @@ -919,15 +913,15 @@ register KeyboardDef *def; } } //input from player - if (inst.Keyboard[def->button0]) + if (inpu.Keyboard[def->button0]) buttons += 1 << 0; - if (inst.Keyboard[def->button1]) + if (inpu.Keyboard[def->button1]) buttons += 1 << 1; realdelta = false; break; case ctrl_Joystick1: case ctrl_Joystick2: - INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy/*,false*/, gvar); + INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy/*,false*/); buttons = INL_GetJoyButtons(type - ctrl_Joystick); realdelta = true; break; @@ -998,14 +992,14 @@ register KeyboardDef *def; #endif #ifdef __DEBUG_InputMgr__ if(dbg_testcontrolnoisy > 0) -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) +if(player->info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])*/ || player->enti.q>1) { //printf("b1=%u b2=%u b3=%u b4=%u ", player->info.button0, player->info.button1, player->info.button2, player->info.button3); //printf("q=%d ", player->enti.q); //printf("cpee=%c ", dirchar(conpee)); printf("pdir=%c d=%c dir=%c ", dirchar(player->pdir), dirchar(player->enti.d), dirchar(player->info.dir)); /*if(realdelta) */printf("dx=%d dy=%d mx=%d my=%d", player->info.x, player->info.y, player->info.xaxis, player->info.yaxis); - //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]); + //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]); printf("\n"); } #endif @@ -1118,9 +1112,9 @@ IN_WaitForKey(void) { ScanCode result; - while (!(result = inst.LastScan)) + while (!(result = inpu.LastScan)) ; - inst.LastScan = 0; + inpu.LastScan = 0; return(result); } @@ -1135,9 +1129,9 @@ IN_WaitForASCII(void) { char result; - while (!(result = inst.LastASCII)) + while (!(result = inpu.LastASCII)) ; - inst.LastASCII = '\0'; + inpu.LastASCII = '\0'; return(result); } @@ -1150,7 +1144,7 @@ IN_WaitForASCII(void) boolean btnstate[8]; -void IN_StartAck(global_game_variables_t *gvar) +void IN_StartAck(void) { unsigned i,buttons; @@ -1161,8 +1155,8 @@ void IN_StartAck(global_game_variables_t *gvar) memset (btnstate,0,sizeof(btnstate)); buttons = IN_JoyButtons () << 4; - if (gvar->in.MousePresent) - buttons |= IN_MouseButtons (gvar); + if (inpu.MousePresent) + buttons |= IN_MouseButtons (); for (i=0;i<8;i++,buttons>>=1) if (buttons&1) @@ -1170,19 +1164,19 @@ void IN_StartAck(global_game_variables_t *gvar) } -boolean IN_CheckAck (global_game_variables_t *gvar) +boolean IN_CheckAck (void) { unsigned i,buttons; // // see if something has been pressed // - if (inst.LastScan) + if (inpu.LastScan) return true; buttons = IN_JoyButtons () << 4; - if (gvar->in.MousePresent) - buttons |= IN_MouseButtons (gvar); + if (inpu.MousePresent) + buttons |= IN_MouseButtons (); for (i=0;i<8;i++,buttons>>=1) if ( buttons&1 ) @@ -1197,11 +1191,11 @@ boolean IN_CheckAck (global_game_variables_t *gvar) } -void IN_Ack (global_game_variables_t *gvar) +void IN_Ack (void) { - IN_StartAck (gvar); + IN_StartAck (); - while (!IN_CheckAck (gvar)) + while (!IN_CheckAck ()) ; } @@ -1212,19 +1206,19 @@ void IN_Ack (global_game_variables_t *gvar) // /////////////////////////////////////////////////////////////////////////// boolean -IN_IsUserInput(global_game_variables_t *gvar) +IN_IsUserInput() { boolean result; word i; - result = inst.LastScan; + result = inpu.LastScan; - if (gvar->in.MousePresent) + if (inpu.MousePresent) if (INL_GetMouseButtons()) result = true; for (i = 0;i < MaxJoys;i++) - if (gvar->in.JoysPresent[i]) + if (inpu.JoysPresent[i]) if (INL_GetJoyButtons(i)) result = true; @@ -1239,16 +1233,16 @@ IN_IsUserInput(global_game_variables_t *gvar) // button up. // /////////////////////////////////////////////////////////////////////////// -boolean IN_UserInput(word delay, global_game_variables_t *gvar) +boolean IN_UserInput(word delay) { word TimeCount = *clockw; word lasttime; lasttime = TimeCount; - IN_StartAck (gvar); + IN_StartAck (); do { - if (IN_CheckAck(gvar)) + if (IN_CheckAck()) return true; } while (TimeCount - lasttime < delay); return(false); @@ -1264,10 +1258,10 @@ boolean IN_UserInput(word delay, global_game_variables_t *gvar) =================== */ -byte IN_MouseButtons (global_game_variables_t *gvar) +byte IN_MouseButtons (void) { union REGS CPURegs; - if (gvar->in.MousePresent) + if (inpu.MousePresent) { Mouse(MButtons); return CPURegs.x.bx; @@ -1299,11 +1293,9 @@ byte IN_JoyButtons (void) boolean IN_KeyDown(byte code) { #ifdef __DEBUG_InputMgr__ - if(inst.Keyboard[code]) - printf("IN_KeyDown(%c): %u\n", code, inst.Keyboard[code]); if(!dbg_nointest) #endif - return inst.Keyboard[code]; + return inpu.Keyboard[code]; #ifdef __DEBUG_InputMgr__ else if(dbg_nointest && kbhit()) @@ -1315,23 +1307,23 @@ boolean IN_KeyDown(byte code) void IN_ClearKey(byte code) { - inst.Keyboard[code] = false; - if(code == inst.LastScan) - inst.LastScan = sc_None; + inpu.Keyboard[code] = false; + if(code == inpu.LastScan) + inpu.LastScan = sc_None; } boolean IN_qb(byte kee) { #ifdef __DEBUG_InputMgr__ - if(dbg_testkeyin) if(inst.Keyboard[kee]) printf("IN_qb(): %u\n", inst.Keyboard[kee]); + if(dbg_testkeyin) printf("%u\n", inpu.Keyboard[kee]); #endif - if(inst.Keyboard[kee]==true) return 1; + if(inpu.Keyboard[kee]==true) return 1; else return 0; } ScanCode IN_GetLastScan() { - return inst.LastScan; + return inpu.LastScan; } ScanCode IN_GetCurCode() diff --git a/src/lib/16_in_1.h b/src/lib/16_in_o.h similarity index 85% rename from src/lib/16_in_1.h rename to src/lib/16_in_o.h index 97a560d0..eb8048bc 100755 --- a/src/lib/16_in_1.h +++ b/src/lib/16_in_o.h @@ -213,34 +213,34 @@ typedef struct { #endif // Internal routines -extern void IN_Startup(global_game_variables_t *gvar),IN_Shutdown(global_game_variables_t *gvar), - IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar), +extern void IN_Startup(void),IN_Shutdown(void), + IN_Default(boolean gotit,player_t *player,ControlType nt), IN_SetKeyHook(void (*)()), IN_ClearKeysDown(void), - IN_ReadCursor(CursorInfo *, global_game_variables_t *gvar), - IN_ReadControl(player_t *player, global_game_variables_t *gvar), + IN_ReadCursor(CursorInfo *), + IN_ReadControl(player_t *player), IN_SetControlType(player_t *player,ControlType type), IN_GetJoyAbs(word joy,word *xp,word *yp), IN_SetupJoy(word joy,word minx,word maxx, - word miny,word maxy, global_game_variables_t *gvar), + word miny,word maxy), #if DEMO0 IN_StopDemo(void),IN_FreeDemoBuffer(void), #endif - IN_Ack(global_game_variables_t *gvar),IN_AckBack(void); -extern boolean IN_UserInput(word delay, global_game_variables_t *gvar); + IN_Ack(void),IN_AckBack(void); +extern boolean IN_UserInput(word delay); extern char IN_WaitForASCII(void); extern ScanCode IN_WaitForKey(void); extern word IN_GetJoyButtonsDB(word joy); extern byte *IN_GetScanName(ScanCode); -byte IN_MouseButtons (global_game_variables_t *gvar); +byte IN_MouseButtons (void); byte IN_JoyButtons (void); -void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/, global_game_variables_t *gvar); -void IN_StartAck(global_game_variables_t *gvar); -boolean IN_CheckAck (global_game_variables_t *gvar); -boolean IN_IsUserInput(global_game_variables_t *gvar); +void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/); +void IN_StartAck(void); +boolean IN_CheckAck (void); +boolean IN_IsUserInput(); #define Mouse(x) INL_Mouse(x) //void IN_SetKeyHook(void (*hook)()); #if DEMO0 diff --git a/src/lib/16_tail.c b/src/lib/16_tail.c index 557c4968..7b5fdcb4 100755 --- a/src/lib/16_tail.c +++ b/src/lib/16_tail.c @@ -79,7 +79,7 @@ void Startup16(global_game_variables_t *gvar) #ifdef __DEBUG_InputMgr__ if(!dbg_nointest) #endif - IN_Startup(); + IN_Startup(gvar); #endif #ifdef __16_PM__ PM_Startup(gvar); @@ -110,7 +110,7 @@ void Shutdown16(global_game_variables_t *gvar) #ifdef __DEBUG_InputMgr__ if(!dbg_nointest) #endif - IN_Shutdown(); + IN_Shutdown(gvar); #endif CA_Shutdown(gvar); MM_Shutdown(gvar); diff --git a/src/lib/16_tail.h b/src/lib/16_tail.h index 6bd889fd..3e1a455f 100755 --- a/src/lib/16_tail.h +++ b/src/lib/16_tail.h @@ -34,19 +34,19 @@ #include "src/lib/testpatt.h" #define TAIL_FUNCTIONKEYFUNCTIONS \ - if(IN_KeyDown(88)){ panswitch=!panswitch; IN_UserInput(1); } \ + if(IN_KeyDown(88)){ panswitch=!panswitch; IN_UserInput(1, &gvar); } \ TAIL_FUNCTIONKEYFUNCTIONS0EXE #define TAIL_FUNCTIONKEYFUNCTIONS0EXE \ - if(IN_KeyDown(sc_F4)){ turboXT(12); IN_UserInput(1); } \ - if(IN_KeyDown(87/*sc_F11*/)){ pagedelayrendermap=!pagedelayrendermap; IN_UserInput(1); } \ - if(IN_KeyDown(68/*sc_F10*/)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap; IN_UserInput(1); } \ - if(IN_KeyDown(sc_F9)){ pagenorendermap=!pagenorendermap; IN_UserInput(1); } \ - if(IN_KeyDown(sc_F8)){ gvar.video.bgps=!gvar.video.bgps; IN_UserInput(1); } \ - if(IN_KeyDown(sc_F7)){ ZC_ShowMV(&gvar.mv, 0, 1); IN_UserInput(1); } \ - if(IN_KeyDown(sc_F6)){ ZC_ShowMV(&gvar.mv, 0, 0); IN_UserInput(1); } \ - if(IN_KeyDown(sc_T)){ gvar.video.rss=!gvar.video.rss; IN_UserInput(1); } \ - if(IN_KeyDown(sc_P)){ modexpdump(&gvar.video.page[0]); IN_UserInput(1); } + if(IN_KeyDown(sc_F4)){ turboXT(12); IN_UserInput(1, &gvar); } \ + if(IN_KeyDown(87/*sc_F11*/)){ pagedelayrendermap=!pagedelayrendermap; IN_UserInput(1, &gvar); } \ + if(IN_KeyDown(68/*sc_F10*/)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap; IN_UserInput(1, &gvar); } \ + if(IN_KeyDown(sc_F9)){ pagenorendermap=!pagenorendermap; IN_UserInput(1, &gvar); } \ + if(IN_KeyDown(sc_F8)){ gvar.video.bgps=!gvar.video.bgps; IN_UserInput(1, &gvar); } \ + if(IN_KeyDown(sc_F7)){ ZC_ShowMV(&gvar.mv, 0, 1); IN_UserInput(1, &gvar); } \ + if(IN_KeyDown(sc_F6)){ ZC_ShowMV(&gvar.mv, 0, 0); IN_UserInput(1, &gvar); } \ + if(IN_KeyDown(sc_T)){ gvar.video.rss=!gvar.video.rss; IN_UserInput(1, &gvar); } \ + if(IN_KeyDown(sc_P)){ modexpdump(&gvar.video.page[0]); IN_UserInput(1, &gvar); } #define TAIL_PANKEYFUN \ TAIL_PANKEYFUNZC \ @@ -73,13 +73,13 @@ if(IN_KeyDown(sc_X)){ TESTBG12 } \ if(IN_KeyDown(sc_C)){ TESTBG34 } \ if(IN_KeyDown(sc_V)) VL_PatternDraw(&gvar.video, 0, 1, 1); \ - if(IN_KeyDown(sc_I)){ dbg_maptext=!dbg_maptext; IN_UserInput(1); } + if(IN_KeyDown(sc_I)){ dbg_maptext=!dbg_maptext; IN_UserInput(1, &gvar); } /* if(IN_KeyDown(sc_PgDn)){ \ rotateR(gvar.video.palette, sizeof(gvar.video.palette)/sizeof(gvar.video.palette[0])); \ - VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1); } \ + VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1, &gvar); } \ if(IN_KeyDown(sc_PgUp)){ \ rotateL(gvar.video.palette, sizeof(gvar.video.palette)/sizeof(gvar.video.palette[0])); \ - VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1); }*/ + VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1, &gvar); }*/ void DebugMemory_(global_game_variables_t *gvar, boolean q); void Shutdown16(global_game_variables_t *gvar); diff --git a/src/test.c b/src/test.c index a4a7f489..785e0110 100755 --- a/src/test.c +++ b/src/test.c @@ -100,7 +100,7 @@ void main(int argc, char *argv[]) //====modexPalBlack(); //IN_Startup(); - IN_Default(0,&gvar.player[0],ctrl_Keyboard1); + IN_Default(0,&gvar.player[0],ctrl_Keyboard1, &gvar); EN_initPlayer(&gvar.player[0], &gvar.video); VGAmodeX(1, 1, &gvar); @@ -149,7 +149,7 @@ void main(int argc, char *argv[]) startclk = *clockw; while(!IN_KeyDown(sc_Escape)) { - IN_ReadControl(&gvar.player[0]); + IN_ReadControl(&gvar.player[0], &gvar); ZC_panPageManual(&gvar.mv, &gvar.player, 0); // if(IN_KeyDown(sc_5)){ modexClearRegion(&gvar.video.page[1], gvar.video.page[1].sw, 16, 8, 4, 45); } // if(IN_KeyDown(sc_4)){ @@ -170,9 +170,9 @@ void main(int argc, char *argv[]) } // if(i>PAL_SIZE) i=0; }//9*/ - if(IN_KeyDown(25)){ modexpdump(&gvar.video.page[gvar.video.sp]); IN_UserInput(1); }//p - if(IN_KeyDown(sc_I)){ drawboxesmodex(&gvar.video.page[gvar.video.sp]); IN_UserInput(1); }//i - if(IN_KeyDown(sc_O)){ copyboxesmodex(&gvar.video.page, !gvar.video.sp); IN_UserInput(1); }//o + if(IN_KeyDown(25)){ modexpdump(&gvar.video.page[gvar.video.sp]); IN_UserInput(1, &gvar); }//p + if(IN_KeyDown(sc_I)){ drawboxesmodex(&gvar.video.page[gvar.video.sp]); IN_UserInput(1, &gvar); }//i + if(IN_KeyDown(sc_O)){ copyboxesmodex(&gvar.video.page, !gvar.video.sp); IN_UserInput(1, &gvar); }//o //VL_ShowPage(&gvar.video.page[gvar.video.sp], 0, 0); ZC_ShowMV(&gvar.mv, 0, 0); } diff --git a/src/vrstest.c b/src/vrstest.c index 69ee777a..166a10e0 100755 --- a/src/vrstest.c +++ b/src/vrstest.c @@ -145,9 +145,9 @@ void main() break; } TAIL_FUNCTIONKEYDRAWJUNKNOMV - if(IN_KeyDown(sc_F7)){ VL_ShowPage(&gvar.video.page[0], 1, 1); IN_UserInput(1); } - if(IN_KeyDown(sc_F6)){ VL_ShowPage(&gvar.video.page[0], 1, 0); IN_UserInput(1); } - if(IN_KeyDown(25)){ modexpdump(&gvar.video.page[0]); IN_UserInput(1); } //p + if(IN_KeyDown(sc_F7)){ VL_ShowPage(&gvar.video.page[0], 1, 1); IN_UserInput(1, &gvar); } + if(IN_KeyDown(sc_F6)){ VL_ShowPage(&gvar.video.page[0], 1, 0); IN_UserInput(1, &gvar); } + if(IN_KeyDown(25)){ modexpdump(&gvar.video.page[0]); IN_UserInput(1, &gvar); } //p } VGAmodeX(0, 1, &gvar); MM_ShowMemory(&gvar); diff --git a/src/zcroll.c b/src/zcroll.c index b7e2b730..888a0034 100755 --- a/src/zcroll.c +++ b/src/zcroll.c @@ -87,7 +87,7 @@ void main(int argc, char *argv[]) VRS_LoadVRS(bakapee1, &gvar.player[0].enti, &gvar); // input! - IN_Default(0, &gvar.player[0],ctrl_Keyboard1); + IN_Default(0, &gvar.player[0],ctrl_Keyboard1, &gvar); // save the palette #ifdef FADE @@ -155,7 +155,7 @@ void main(int argc, char *argv[]) //when gvar.player[0].tx or gvar.player[0].ty == 0 or gvar.player[0].tx == 20 or gvar.player[0].ty == 15 then stop because that is edge of map and you do not want to walk of the map //gvar.player movement - IN_ReadControl(&gvar.player[0]); + IN_ReadControl(&gvar.player[0], &gvar); if(!panswitch){ //ZC_walk2(gvar.player[0].ent, mv); ZC_walk(&gvar.mv, &gvar.player, 0); @@ -178,7 +178,7 @@ void main(int argc, char *argv[]) if(gvar.player[0].enti.q == (TILEWH/(gvar.player[0].enti.speed))+1 && gvar.player[0].info.dir != 2 && (gvar.player[0].enti.triggerx == 5 && gvar.player[0].enti.triggery == 5)){ gvar.player[0].enti.hp--; } //debugging binds! - if(IN_KeyDown(24)){ modexPalUpdate0(&gvar.video.palette); /*paloffset=0;*/ modexpdump(gvar.mv[0].page); IN_UserInput(1); } //o + if(IN_KeyDown(24)){ modexPalUpdate0(&gvar.video.palette); /*paloffset=0;*/ modexpdump(gvar.mv[0].page); IN_UserInput(1, &gvar); } //o if(IN_KeyDown(22)){ modexPalUpdate0(&gvar.video.palette); } //u TAIL_FUNCTIONKEYFUNCTIONS @@ -203,7 +203,7 @@ void main(int argc, char *argv[]) VL_LoadPalFile(bakapee1p, &gvar.video.palette); }//JK #ifdef FADE - if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(gvar.video.dpal); IN_UserInput(1); } + if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(gvar.video.dpal); IN_UserInput(1, &gvar); } #endif if(IN_KeyDown(sc_R)){ modexPalOverscan(rand()%56); } //r -- 2.39.2