X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_in.c;h=ef0f1fa65660ae238dd057c88b82054a60736e53;hb=989f287818c93cf9b1ff96c13e66720571210513;hp=f019646427b1d58a2eb0c9c3a9a8ad77bfaf4e11;hpb=07811f4fa4c414a4181c5859c60b2a99414858b0;p=16.git diff --git a/src/lib/16_in.c b/src/lib/16_in.c index f0196464..ef0f1fa6 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -38,7 +38,11 @@ #include "src/lib/16_in.h" -boolean testkeyin=0,testcontrolnoisy=0; +#ifdef __DEBUG_InputMgr__ +boolean dbg_testkeyin=0,dbg_testcontrolnoisy=0; +#endif + +static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ /* ============================================================================= @@ -49,8 +53,8 @@ boolean testkeyin=0,testcontrolnoisy=0; */ struct inconfig { - boolean MousePresent; - boolean JoysPresent[MaxJoys]; + boolean MousePresent; + boolean JoysPresent[MaxJoys]; boolean Keyboard[NumCodes]; boolean Paused; char LastASCII; @@ -164,6 +168,7 @@ static Direction DirTable[] = // Quick lookup for total direction #endif // Internal routines + /////////////////////////////////////////////////////////////////////////// // // INL_KeyService() - Handles a keyboard interrupt (key up/down) @@ -234,18 +239,22 @@ static boolean special; if (INL_KeyHook && !special) INL_KeyHook(); -//#ifdef TESTKEYIN - if(testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, inpu.Keyboard[k]); -//endif +#ifdef __DEBUG_InputMgr__ + if(dbg_testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, inpu.Keyboard[k]); +#endif outp(0x20,0x20); } void Mouse(int x) { - union REGS CPURegs; - x = CPURegs.x.ax; - int86(MouseInt,&CPURegs,&CPURegs); + //union REGS CPURegs; + //x = CPURegs.x.ax; + __asm { + mov ax,x + int MouseInt + } + //int86(MouseInt,&CPURegs,&CPURegs); } /////////////////////////////////////////////////////////////////////////// @@ -299,8 +308,7 @@ IN_GetJoyAbs(word joy,word *xp,word *yp) yb = 1 << ys; // Read the absolute joystick values - __asm - { + __asm { pushf // Save some registers push si push di @@ -320,8 +328,13 @@ IN_GetJoyAbs(word joy,word *xp,word *yp) push bp // Don't mess up stack frame mov bp,MaxJoyValue - +#ifdef __BORLANDC__ + } +#endif loo: +#ifdef __BORLANDC__ + __asm { +#endif in al,dx // Get bits indicating whether all are finished dec bp // Check bounding register @@ -338,8 +351,13 @@ loo: add cl,bl jnz loo // If both bits were 0, drop out - +#ifdef __BORLANDC__ + } +#endif done: +#ifdef __BORLANDC__ + __asm { +#endif pop bp mov cl,[xs] // Get the number of bits to shift @@ -378,10 +396,6 @@ static word lasttime; IN_GetJoyAbs(joy,&x,&y); def = inpu.JoyDefs + joy; - //TODO: inject p16 input controls! - //which is this - //into joystick code! - //look at IN_ReadControl if (x < def->threshMinX) { if (x < def->joyMinX) @@ -496,7 +510,7 @@ INL_StartKbd() IN_ClearKeysDown(); OldKeyVect = _dos_getvect(KeyInt); - _dos_setvect(KeyInt,INL_KeyService); + //_dos_setvect(KeyInt,INL_KeyService); } /////////////////////////////////////////////////////////////////////////// @@ -641,9 +655,9 @@ IN_Startup() checkjoys = true; checkmouse = true; - for (i = 1;i < __argc;i++) + for (i = 1;i < _argc;i++) { - switch (US_CheckParm(__argv[i],ParmStringsIN)) + switch (US_CheckParm(_argv[i],ParmStringsIN)) { case 0: checkjoys = false; @@ -680,7 +694,7 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) || ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1]) || ((nt == ctrl_Mouse) && !inpu.MousePresent) ) - nt = ctrl_Keyboard1; nt = ctrl_Joystick1;//temp + nt = ctrl_Keyboard1; inpu.KbdDefs[0].button0 = 0x1c; inpu.KbdDefs[0].button1 = 0x38; //in.KbdDefs[0].upleft = 0x47; @@ -691,9 +705,8 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) //in.KbdDefs[0].downleft = 0x4f; inpu.KbdDefs[0].down = 0x50; //in.KbdDefs[0].downright = 0x51; - IN_SetControlType(0,player,nt); - for(i=0; i>MaxPlayers;i++) - player[i].d=2; + IN_SetControlType(player,nt); + player->d=2; } /////////////////////////////////////////////////////////////////////////// @@ -737,7 +750,7 @@ IN_SetKeyHook(void (*hook)()) void IN_ClearKeysDown() { - int i; + //int i; inpu.LastScan = sc_None; inpu.LastASCII = key_None; @@ -804,10 +817,12 @@ IN_ReadCursor(CursorInfo *info) // /////////////////////////////////////////////////////////////////////////// void near -IN_ReadControl(int pn,player_t *player) +IN_ReadControl(player_t *player) { boolean realdelta; +#if DEMO0 byte dbyte; +#endif word buttons; int dx,dy; Motion mx,my; @@ -842,7 +857,7 @@ register KeyboardDef *def; else { #endif - switch (type = player[pn].Controls) + switch (type = player->Controls) { case ctrl_Keyboard1: case ctrl_Keyboard2: @@ -856,7 +871,8 @@ register KeyboardDef *def; mx = motion_Left,my = motion_Down; else if (Keyboard[def->downright]) mx = motion_Right,my = motion_Down;*/ - if(DIRECTIONIFELSE)//(player[pn].info.dir == 2) +//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])) @@ -866,28 +882,28 @@ register KeyboardDef *def; }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){ if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) mx = motion_Left; - if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left]))// || player[pn].pdir != 1) + if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) mx = motion_Right; - }else - //if(mx+my!=1 && mx+my!=-1 && mx!=my!=0) - { //2 keys pressed - switch (player[pn].pdir) + }else{ //2 keys pressed + switch (player->pdir) { case 0: case 4: - if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) dir = DirTable[1]; - else if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) dir = DirTable[3]; + 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((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) dir = DirTable[0]; - else if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) dir = DirTable[4]; + 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; } - if(testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player[pn].pdir)); } - }//else printf(" "); +#ifdef __DEBUG_InputMgr__ + //if(dbg_testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player->pdir)); } +#endif + } } //input from player if (inpu.Keyboard[def->button0]) @@ -923,23 +939,23 @@ register KeyboardDef *def; dy = my;// * 127; } - player[pn].info.x = dx; - player[pn].info.xaxis = mx; - player[pn].info.y = dy; - player[pn].info.yaxis = my; - player[pn].info.button0 = buttons & (1 << 0); - player[pn].info.button1 = buttons & (1 << 1); - player[pn].info.button2 = buttons & (1 << 2); - player[pn].info.button3 = buttons & (1 << 3); -// player[pn].info.dir = DirTable[((my + 1) * 3) + (mx + 1)]; + player->info.x = dx; + player->info.xaxis = mx; + player->info.y = dy; + player->info.yaxis = my; + player->info.button0 = buttons & (1 << 0); + player->info.button1 = buttons & (1 << 1); + player->info.button2 = buttons & (1 << 2); + player->info.button3 = buttons & (1 << 3); +// player->info.dir = DirTable[((my + 1) * 3) + (mx + 1)]; conpee=(((my + 1) * 2) + (mx + 1))-1; - player[pn].info.dir = DirTable[conpee]; + player->info.dir = DirTable[conpee]; - if(DirTable[conpee]!=2) player[pn].pdir=DirTable[conpee]; - if(player[pn].q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) + if(DirTable[conpee]!=2) player->pdir=DirTable[conpee]; + if(player->q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) { - if(dir==2) player[pn].d = player[pn].info.dir; - else player[pn].d = DirTable[dir]; + if(dir==2) player->d = player->info.dir; + else player->d = DirTable[dir]; } #if DEMO0 @@ -967,16 +983,19 @@ register KeyboardDef *def; } } #endif -if(testcontrolnoisy > 0) -if(player[pn].d /*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])*/ || player[pn].q>1) +#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->q>1) { - printf("q=%d ", player[pn].q); - printf("cpee=%c ", dirchar(conpee)); - printf("pdir=%c d=%c dir=%c ", dirchar(player[pn].pdir), dirchar(player[pn].d), dirchar(player[pn].info.dir)); - 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); - 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("b1=%u b2=%u b3=%u b4=%u ", player->info.button0, player->info.button1, player->info.button2, player->info.button3); + //printf("q=%d ", player->q); + //printf("cpee=%c ", dirchar(conpee)); + printf("pdir=%c d=%c dir=%c ", dirchar(player->pdir), dirchar(player->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]); printf("\n"); } +#endif } /////////////////////////////////////////////////////////////////////////// @@ -986,10 +1005,10 @@ if(player[pn].d /*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Ke // /////////////////////////////////////////////////////////////////////////// void -IN_SetControlType(word pn,player_t *player,ControlType type) +IN_SetControlType(player_t *player,ControlType type) { // DEBUG - check that requested type is present? - player[pn].Controls = type; + player->Controls = type; } #if DEMO0 @@ -1159,6 +1178,9 @@ IN_Ack() { word i; + if (!inst.IN_Started) + return; + IN_ClearKey(inpu.LastScan); inpu.LastScan = sc_None; @@ -1240,28 +1262,24 @@ void IN_ClearKey(byte code) boolean IN_qb(byte kee) { -//#ifdef TESTKEYIN -// if(testkeyin > 0) printf("%u\n", inpu.Keyboard[kee]); -//#endif +#ifdef __DEBUG_InputMgr__ +// if(dbg_testkeyin > 0) printf("%u\n", inpu.Keyboard[kee]); +#endif if(inpu.Keyboard[kee]==true) return 1; else return 0; } //init player! -void IN_initplayer(player_t *player, word pn) +void IN_initplayer(player_t *player) { - player[pn].x = player[pn].tx*TILEWH; - player[pn].y = player[pn].ty*TILEWH; - player[pn].triggerx = player[pn].tx; - player[pn].triggery = player[pn].ty+1; -/* player[0].info.x = player[0].tx; - player[0].info.xaxis = player[0].tx*TILEWH; - player[0].info.y = player[0].ty; - player[0].info.yaxis = player[0].ty*TILEWH;*/ - player[pn].q=1; - player[pn].d=2; - player[pn].hp=4; - player[pn].speed=4; - player[pn].persist_aniframe=0; - player[pn].spt=(TILEWH/(player[pn].speed)); //speed per tile wwww + player->x = player->tx*TILEWH; + player->y = player->ty*TILEWH; + player->triggerx = player->tx; + player->triggery = player->ty+1; + player->q=1; + player->d=2; + player->hp=4; + player->speed=4; + player->persist_aniframe=0; + player->spt=(TILEWH/(player->speed)); //speed per tile wwww }