X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_in.c;h=85709c5e00c53fc90dd649a8698984b3741005ba;hb=0b5d62cb0555345fd843ef139b5f9a18bb90a405;hp=52a767741345c520baa7d5078b7df8e68f075124;hpb=3401a0bddcdce075f8cda8b6392c541050fd36e2;p=16.git diff --git a/src/lib/16_in.c b/src/lib/16_in.c index 52a76774..85709c5e 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -38,7 +38,9 @@ #include "src/lib/16_in.h" -byte testkeyin=0,testcontrolnoisy=0,gfxtest=0; +#ifdef __DEBUG_InputMgr__ +boolean dbg_testkeyin=0,dbg_testcontrolnoisy=0; +#endif /* ============================================================================= @@ -51,7 +53,6 @@ struct inconfig { boolean MousePresent; boolean JoysPresent[MaxJoys]; - boolean JoyPadPresent[MaxPads]; boolean Keyboard[NumCodes]; boolean Paused; char LastASCII; @@ -59,7 +60,6 @@ struct inconfig KeyboardDef KbdDefs[MaxKbds]; JoystickDef JoyDefs[MaxJoys]; - JoypadDef JoypadDefs[MaxPads]; } inpu; //extern inconfig inpu; @@ -166,6 +166,7 @@ static Direction DirTable[] = // Quick lookup for total direction #endif // Internal routines + /////////////////////////////////////////////////////////////////////////// // // INL_KeyService() - Handles a keyboard interrupt (key up/down) @@ -236,18 +237,22 @@ static boolean special; if (INL_KeyHook && !special) INL_KeyHook(); -//#ifdef TESTKEYIN - if(testkeyin > 0) printf("%c [0x%x %u] %u\n", 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); } /////////////////////////////////////////////////////////////////////////// @@ -301,8 +306,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 @@ -322,8 +326,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 @@ -340,8 +349,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 @@ -639,9 +653,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; @@ -659,6 +673,7 @@ IN_Startup() inpu.JoysPresent[i] = checkjoys? INL_StartJoy(i) : false; inst.IN_Started = true; + } /////////////////////////////////////////////////////////////////////////// @@ -676,8 +691,6 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) || ((nt == ctrl_Joystick1) && !inpu.JoysPresent[0]) || ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1]) || ((nt == ctrl_Mouse) && !inpu.MousePresent) - || ((nt == ctrl_Joypad1) && !inpu.JoyPadPresent[0]) - || ((nt == ctrl_Joypad2) && !inpu.JoyPadPresent[1]) ) nt = ctrl_Keyboard1; inpu.KbdDefs[0].button0 = 0x1c; @@ -812,6 +825,7 @@ IN_ReadControl(int pn,player_t *player) Motion mx,my; ControlType type; sword conpee; + byte dir=DirTable[2]; register KeyboardDef *def; dx = dy = 0; @@ -854,20 +868,38 @@ register KeyboardDef *def; mx = motion_Left,my = motion_Down; else if (Keyboard[def->downright]) mx = motion_Right,my = motion_Down;*/ - if(DIRECTIONIFELSEGFXTEST) +//TODO: make this into a function that the joystick AND keyboard can use wwww + if(DIRECTIONIFELSE)//(player[pn].info.dir == 2) { - if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){// && (inpu.Keyboard[def->up] || inpu.Keyboard[def->down])){ -// if(testcontrolnoisy > 0){ printf("ud "); printf("%u ", inpu.Keyboard[def->up]); printf("%u ", inpu.Keyboard[def->down]);} - if(inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])// || player[pn].info.pdir == 0) + if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){ + if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) my = motion_Up; - if(inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])// || player[pn].info.pdir == 4) + if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) my = motion_Down; - }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){// && (inpu.Keyboard[def->left] || inpu.Keyboard[def->right])){ -// if(testcontrolnoisy > 0){ printf("lr "); printf("%u ", inpu.Keyboard[def->left]); printf("%u ", inpu.Keyboard[def->right]); } - if(inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])// || player[pn].info.pdir == 1) + }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].info.pdir == 3) + if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) mx = motion_Right; + }else{ //2 keys pressed + switch (player[pn].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; } + 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; } + break; + default: + break; + } +#ifdef __DEBUG_InputMgr__ + //if(dbg_testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player[pn].pdir)); } +#endif } } //input from player @@ -888,10 +920,6 @@ register KeyboardDef *def; buttons = INL_GetMouseButtons(); realdelta = true; break; - case ctrl_Joypad1: - case ctrl_Joypad2: - printf("wwww"); - break; } #ifdef DEMO0 } @@ -917,14 +945,14 @@ register KeyboardDef *def; player[pn].info.button2 = buttons & (1 << 2); player[pn].info.button3 = buttons & (1 << 3); // player[pn].info.dir = DirTable[((my + 1) * 3) + (mx + 1)]; - conpee=(((my + 1) * 2) + (mx + 1))-1; //if(conpee) conpee--; + conpee=(((my + 1) * 2) + (mx + 1))-1; player[pn].info.dir = DirTable[conpee]; - //TODO: overwriting direction must be added - if(DIRECTIONIFELSEGFXTEST && player[pn].d != player[pn].info.dir) player[pn].pdir=DirTable[conpee]; - if(player[pn].q==1 && (mx!=motion_None || my!=motion_None)) + if(DirTable[conpee]!=2) player[pn].pdir=DirTable[conpee]; + if(player[pn].q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) { - player[pn].d = player[pn].info.dir; + if(dir==2) player[pn].d = player[pn].info.dir; + else player[pn].d = DirTable[dir]; } #if DEMO0 @@ -952,17 +980,19 @@ register KeyboardDef *def; } } #endif -//#ifdef TESTCONTROLNOISY -if(testcontrolnoisy > 0) -if((inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right]) && NDIRECTIONIFELSEGFXTEST) +#ifdef __DEBUG_InputMgr__ +if(dbg_testcontrolnoisy > 0) +if(player[pn].info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])*/ || player[pn].q>1) { - printf("q=%d ", player[pn].q); - printf("cpee=%d ", conpee); - printf("(mx)=%d ", mx); - printf("(my)=%d ", my); - printf("pdir=%d d=%d dir=%d\n", player[pn].pdir, player[pn].d, player[pn].info.dir); + //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); + //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("\n"); } -//#endif +#endif } /////////////////////////////////////////////////////////////////////////// @@ -1145,6 +1175,9 @@ IN_Ack() { word i; + if (!inst.IN_Started) + return; + IN_ClearKey(inpu.LastScan); inpu.LastScan = sc_None; @@ -1226,9 +1259,28 @@ 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) +{ + 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 +}