From: sparky4 Date: Mon, 13 Mar 2017 14:23:36 +0000 (-0500) Subject: __seguse.txt added to show _seg usage also OpenVGMFile needs to be ported to 16_snd... X-Git-Url: http://4ch.mooo.com/gitweb/?p=16.git;a=commitdiff_plain;h=93e1ab2e43ce82facb47476d9ee461b0d5beb83e __seguse.txt added to show _seg usage also OpenVGMFile needs to be ported to 16_snd.c so we can use CA MM and PM ][ 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 ] --- diff --git a/.gitignore b/.gitignore index 15ee4357..70ed7d75 100755 --- a/.gitignore +++ b/.gitignore @@ -17,8 +17,8 @@ makefile~ README~ TODO~ LICENCE~ -*.mah -*.MAH +*.meh +*.MEH __wcl__.lnk !bcexmm.map !makefile diff --git a/MEMINFO.16W b/MEMINFO.16W new file mode 100755 index 00000000..e69de29b diff --git a/makefile b/makefile index 216243e0..f650f020 100755 --- a/makefile +++ b/makefile @@ -64,6 +64,7 @@ DATADIR=data$(DIRSEP) SPRI=$(DATADIR)/spri SRC=src UTIL=$(SRC)/util +GITCONFIGDIR=$(UTIL)/git SRCLIB=$(SRC)/lib JSMNLIB=$(SRCLIB)/jsmn NYANLIB=$(SRCLIB)/nyan @@ -109,7 +110,7 @@ Z_FLAGS=-zk0 -zc -zp8 -zm O_FLAGS=-opnr -oe=24 -oil+ -outback -ohm -zp4##-ei T_FLAGS=-bt=dos -wx -m$(MEMORYMODE) -0 -fpi87 -d1 -fo=.$(OBJ) ##-e=65536 -DBUGFLAGS=-fm=$^&.mah -fd=$^& +DBUGFLAGS=-fm=$^&.meh -fd=$^& CPPFLAGS=-DTARGET_MSDOS=16 -DMSDOS=1 !ifeq DEBUGSERIAL 1 CPPFLAGS += -DDEBUGSERIAL @@ -125,8 +126,7 @@ LIBFLAGS=$(WLIBQ) -b -n VGMSNDOBJ = vgmSnd.$(OBJ) 16_snd.$(OBJ) #OLDLIBOBJS=bitmap.$(OBJ) 16render.$(OBJ) GFXLIBOBJS = 16_vl.$(OBJ) 16_vlpal.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16_vrs.$(OBJ) 16_spri.$(OBJ) $(OLDLIBOBJS) -16LIBNOINOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_head.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_wcpu.$(OBJ) 16_timer.$(OBJ) jsmn.$(OBJ) 16_map.$(OBJ) 16text.$(OBJ) -16LIBOBJS = $(16LIBNOINOBJS) 16_in.$(OBJ) 16_enti.$(OBJ) +16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_head.$(OBJ) 16_in.$(OBJ) 16_enti.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_wcpu.$(OBJ) 16_timer.$(OBJ) jsmn.$(OBJ) 16_map.$(OBJ) 16text.$(OBJ) DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) !ifeq DEBUGSERIAL 1 DOSLIBOBJ += 8250.$(OBJ) @@ -243,7 +243,6 @@ fonttest.exe: fonttest.$(OBJ) gfx.lib #fonttes0.exe: fonttes0.$(OBJ) $(16LIB) fontgfx.exe: fontgfx.$(OBJ) gfx.lib $(DOSLIB) inputest.exe: inputest.$(OBJ) $(16LIB) $(DOSLIB) gfx.lib -inntest.exe: inntest.$(OBJ) $(16LIBNOINOBJS) 16_in__.$(OBJ) #sountest.exe: sountest.$(OBJ) $(16LIB) pcxtest.exe: pcxtest.$(OBJ) gfx.lib $(DOSLIB) $(16LIB) vrstest.exe: vrstest.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) @@ -284,7 +283,6 @@ fonttest.$(OBJ):$(SRC)/fonttest.c #fonttes0.$(OBJ): $(SRC)/fonttes0.c fontgfx.$(OBJ):$(SRC)/fontgfx.c inputest.$(OBJ):$(SRC)/inputest.c -inntest.$(OBJ):$(SRC)/inntest.c #sountest.$(OBJ): $(SRC)/sountest.c #miditest.$(OBJ): $(SRC)/miditest.c #testemm.$(OBJ):$(SRC)/testemm.c @@ -339,7 +337,6 @@ mapread.$(OBJ):$(SRCLIB)/mapread.c $(SRCLIB)/mapread.h 16_map.$(OBJ):$(SRCLIB)/16_map.c $(SRCLIB)/16_map.h 16_timer.$(OBJ):$(SRCLIB)/16_timer.c $(SRCLIB)/16_timer.h 16_in.$(OBJ): $(SRCLIB)/16_in.c $(SRCLIB)/16_in.h -16_in__.$(OBJ): $(SRCLIB)/16_in__.c $(SRCLIB)/16_in.h 16_rf.$(OBJ): $(SRCLIB)/16_rf.c $(SRCLIB)/16_rf.h 16_mm.$(OBJ): $(SRCLIB)/16_mm.c $(SRCLIB)/16_mm.h 16_pm.$(OBJ): $(SRCLIB)/16_pm.c $(SRCLIB)/16_pm.h @@ -404,9 +401,9 @@ nuke: .symbolic @wmake comp backupconfig: .symbolic - @$(COPYCOMMAND) .git$(DIRSEP)config git_con.fig - @$(COPYCOMMAND) .gitmodules git_modu.les - @$(COPYCOMMAND) .gitignore git_igno.re + @$(COPYCOMMAND) .git$(DIRSEP)config $(GITCONFIGDIR)git_con.fig + @$(COPYCOMMAND) .gitmodules $(GITCONFIGDIR)git_modu.les + @$(COPYCOMMAND) .gitignore $(GITCONFIGDIR)git_igno.re comp: .symbolic @*upx -9 $(EXEC) @@ -482,9 +479,9 @@ reinitlibs: .symbolic @wmake -h initlibs initlibs: .symbolic - @$(COPYCOMMAND) git_con.fig .git/config - @$(COPYCOMMAND) git_modu.les .gitmodules - @$(COPYCOMMAND) git_igno.re .gitignore + @$(COPYCOMMAND) $(GITCONFIGDIR)git_con.fig .git/config + @$(COPYCOMMAND) $(GITCONFIGDIR)git_modu.les .gitmodules + @$(COPYCOMMAND) $(GITCONFIGDIR)git_igno.re .gitignore @wmake -h getlib @cd 16 @git clone https://github.com/FlatRockSoft/CatacombApocalypse.git diff --git a/src/0.c b/src/0.c index ba9ced80..80ff31bb 100755 --- a/src/0.c +++ b/src/0.c @@ -103,7 +103,7 @@ int main(int argc,char **argv) if (vrl_lineoffs == NULL) return 1; IN_Startup(); - IN_Default(0,&gvar.player,ctrl_Keyboard1); + IN_Default(0,&gvar.player[0],ctrl_Keyboard1); EN_initPlayer(&gvar.player, 0, &gvar.video); /* setup camera and screen~ */ @@ -141,14 +141,14 @@ int main(int argc,char **argv) while(!IN_KeyDown(sc_Escape)) { - IN_ReadControl(0,&gvar.player); - if(IN_KeyDown(68)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap; IN_UserInput(1,1); } //f10 + IN_ReadControl(&gvar.player[0]); + if(IN_KeyDown(68)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap; IN_UserInput(1); } //f10 TAIL_PANKEYFUN; if(IN_KeyDown(sc_Space) || zerostoppause) //space { anim=!anim; DRAWCORNERBOXES; - if(!zerostoppause) IN_UserInput(1,1); else zerostoppause=0; + if(!zerostoppause) IN_UserInput(1); 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; @@ -214,7 +214,7 @@ draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header } } - IN_UserInput(1,1); + IN_UserInput(1); //===========================================================================// diff --git a/src/16.c b/src/16.c index 55ea5400..a96b1c49 100755 --- a/src/16.c +++ b/src/16.c @@ -39,11 +39,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,ctrl_Joystick); + IN_Default(0,&gvar.player[0],ctrl_Joystick); //modexprint(&screen, 32, 32, 1, 2, 0, "a", 1); while(ENGI_EXIT != engi_stat) { - IN_ReadControl(0,&gvar.player); + IN_ReadControl(&gvar.player[0]); if(IN_KeyDown(sc_Escape)) engi_stat = ENGI_EXIT; 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 1ba8b227..2b2d564b 100755 --- a/src/inputest.c +++ b/src/inputest.c @@ -35,10 +35,12 @@ main(int argc, char *argv[]) start_timer(&gvar); //Startup16(&gvar); IN_Startup(); - //IN_Default(0,&gvar.player,ctrl_Joystick1); - //IN_SetControlType(0,&gvar.player,ctrl_Joystick1); - IN_Default(0,&gvar.player,ctrl_Keyboard1); - IN_SetControlType(0,&gvar.player,ctrl_Keyboard1); + IN_Default(0,&gvar.player[0], +ctrl_Keyboard1); +//ctrl_Joystick1); + IN_SetControlType(&gvar.player[0], +ctrl_Keyboard1); +//ctrl_Joystick1); gvar.player[0].enti.q=1; gvar.player[0].enti.d=2; @@ -50,7 +52,7 @@ main(int argc, char *argv[]) while(!IN_KeyDown(sc_Escape)) { //0000 shinkutxt(&gvar); - IN_ReadControl(0, &gvar.player); + IN_ReadControl(&gvar.player[0]); switch(gvar.player[0].enti.d) { //right movement diff --git a/src/lib/16_in.c b/src/lib/16_in.c index c2550ec7..f3a80766 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -1,21 +1,3 @@ -/* Catacomb Apocalypse Source Code - * Copyright (C) 1993-2014 Flat Rock Software - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - // // ID Engine // ID_IN.c - Input Manager @@ -81,10 +63,6 @@ static struct instat { ScanCode CurCode,LastCode; } inst; -static void (*INL_KeyHook)(void); -static void interrupt (*OldKeyVect)(void); -static char *ParmStringsIN[] = {"nojoys","nomouse",nil}; - static byte far ASCIINames[] = // Unshifted ASCII for scan codes { // 0 1 2 3 4 5 6 7 8 9 A B C D E F @@ -157,6 +135,10 @@ static Direction DirTable[] = // Quick lookup for total direction } #endif +static void (*INL_KeyHook)(void); +static void interrupt (*OldKeyVect)(void); +static char *ParmStringsIN[] = {"nojoys","nomouse",nil}; + // Internal routines /////////////////////////////////////////////////////////////////////////// @@ -164,18 +146,18 @@ static Direction DirTable[] = // Quick lookup for total direction // INL_KeyService() - Handles a keyboard interrupt (key up/down) // /////////////////////////////////////////////////////////////////////////// -void interrupt -INL_KeyService() +/*static */void interrupt +INL_KeyService(void) { static boolean special; byte k,c, temp; - k = inp(0x60); // Get the scan code + k = inportb(0x60); // Get the scan code // Tell the XT keyboard controller to clear the key - outp(0x61,(temp = inp(0x61)) | 0x80); - outp(0x61,temp); + outportb(0x61,(temp = inportb(0x61)) | 0x80); + outportb(0x61,temp); if (k == 0xe0) // Special key prefix special = true; @@ -232,11 +214,10 @@ static boolean special; #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); + outportb(0x20,0x20); } -void -Mouse(int x) +void INL_Mouse(int x) { //union REGS CPURegs; //x = CPURegs.x.ax; @@ -371,14 +352,12 @@ done: /////////////////////////////////////////////////////////////////////////// // // INL_GetJoyDelta() - Returns the relative movement of the specified -// joystick (from +/-127, scaled adaptively) +// joystick (from +/-127) // /////////////////////////////////////////////////////////////////////////// -static void -INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive) +void INL_GetJoyDelta(word joy,int *dx,int *dy/*,boolean adaptive*/) { word x,y; - word time; word TimeCount = *clockw; JoystickDef *def; static word lasttime; @@ -431,18 +410,17 @@ static word lasttime; } else *dy = 0; - - if (adaptive) - { - time = (TimeCount - lasttime) / 2; - if (time) - { - if (time > 8) - time = 8; - *dx *= time; - *dy *= time; - } - } +// if (adaptive) +// { +// time = (TimeCount - lasttime) / 2; +// if (time) +// { +// if (time > 8) +// time = 8; +// *dx *= time; +// *dy *= time; +// } +// } lasttime = TimeCount; } @@ -457,7 +435,7 @@ INL_GetJoyButtons(word joy) { register word result; - result = inp(0x201); // Get all the joystick buttons + result = inportb(0x201); // Get all the joystick buttons result >>= joy? 6 : 4; // Shift into bits 0-1 result &= 3; // Mask off the useless bits result ^= 3; @@ -482,6 +460,7 @@ IN_GetJoyButtonsDB(word joy) result1 = INL_GetJoyButtons(joy); lasttime = TimeCount; while(TimeCount == lasttime) + //; result2 = INL_GetJoyButtons(joy); } while(result1 != result2); return(result1); @@ -493,20 +472,14 @@ IN_GetJoyButtonsDB(word joy) // /////////////////////////////////////////////////////////////////////////// static void -INL_StartKbd() +INL_StartKbd(void) { - byte far *lock_key; - INL_KeyHook = 0; // Clear key hook + INL_KeyHook = NULL; // Clear key hook IN_ClearKeysDown(); - OldKeyVect = _dos_getvect(KeyInt); - - // turn off num-lock via BIOS - lock_key = MK_FP(0x040, 0x017); // Pointing to the address of the bios shift state keys - *lock_key&=(~(16 | 32 | 64)); // toggle off the locks by changing the values of the 4th, 5th, and 6th bits of the address byte of 0040:0017 - OldKeyVect(); // call BIOS keyhandler to change keyboard lights - _dos_setvect(KeyInt,INL_KeyService); + OldKeyVect = getvect(KeyInt);//IN_KbdLED(); + setvect(KeyInt,INL_KeyService); } /////////////////////////////////////////////////////////////////////////// @@ -519,7 +492,7 @@ INL_ShutKbd(void) { pokeb(0x40,0x17,peekb(0x40,0x17) & 0xfaf0); // Clear ctrl/alt/shift flags - _dos_setvect(KeyInt,OldKeyVect); + setvect(KeyInt,OldKeyVect); } /////////////////////////////////////////////////////////////////////////// @@ -530,14 +503,26 @@ INL_ShutKbd(void) static boolean INL_StartMouse(void) { - union REGS CPURegs; - if(_dos_getvect(MouseInt)) +#if 0 + if (getvect(MouseInt)) { Mouse(MReset); - if(CPURegs.x.ax == 0xffff) + if (_AX == 0xffff) return(true); } return(false); +#endif + byte far *vector; + + + if ((vector=MK_FP(peek(0,0x33*4+2),peek(0,0x33*4)))==NULL) + return false; + + if (*vector == 207) + return false; + + Mouse(MReset); + return true; } /////////////////////////////////////////////////////////////////////////// @@ -701,7 +686,7 @@ 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); + IN_SetControlType(player,nt); for(i=0; i>MaxPlayers;i++) player[i].enti.d =2; } @@ -712,7 +697,7 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) // /////////////////////////////////////////////////////////////////////////// void -IN_Shutdown() +IN_Shutdown(void) { word i; @@ -741,11 +726,11 @@ IN_SetKeyHook(void (*hook)()) /////////////////////////////////////////////////////////////////////////// // -// IN_ClearKeyDown() - Clears the keyboard array +// IN_ClearKeysDown() - Clears the keyboard array // /////////////////////////////////////////////////////////////////////////// void -IN_ClearKeysDown() +IN_ClearKeysDown(void) { //int i; @@ -800,21 +785,25 @@ IN_ReadCursor(CursorInfo *info) continue; buttons = INL_GetJoyButtons(i); - INL_GetJoyDelta(i,&dx,&dy,true); + INL_GetJoyDelta(i,&dx,&dy/*,true*/); dx /= 64; dy /= 64; INL_AdjustCursor(info,buttons,dx,dy); } } +//if else for gfxtesting and direction +#define DIRECTIONIFELSE (player->info.dir == 2) +//#define NDIRECTIONIFELSE (player->info.dir != 2) + /////////////////////////////////////////////////////////////////////////// // // IN_ReadControl() - Reads the device associated with the specified // player and fills in the control info struct // /////////////////////////////////////////////////////////////////////////// -void near -IN_ReadControl(word pn, player_t *player) +void +IN_ReadControl(player_t *player) { boolean realdelta; #if DEMO0 @@ -854,7 +843,7 @@ register KeyboardDef *def; else { #endif - switch (type = player[pn].Controls) + switch (type = player->Controls) { case ctrl_Keyboard1: case ctrl_Keyboard2: @@ -869,7 +858,7 @@ register KeyboardDef *def; else if (Keyboard[def->downright]) mx = motion_Right,my = motion_Down;*/ //TODO: make this into a function that the joystick AND keyboard can use wwww - if(DIRECTIONIFELSE)//(player[pn].info.dir == 2) + if(DIRECTIONIFELSE)//(player->info.dir == 2) { if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){ if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) @@ -882,7 +871,7 @@ register KeyboardDef *def; if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) mx = motion_Right; }else{ //2 keys pressed - switch (player[pn].pdir) + switch (player->pdir) { case 0: case 4: @@ -898,7 +887,7 @@ register KeyboardDef *def; break; } #ifdef __DEBUG_InputMgr__ - //if(dbg_testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player[pn].pdir)); } + //if(dbg_testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player->pdir)); } #endif } } @@ -911,7 +900,7 @@ register KeyboardDef *def; break; case ctrl_Joystick1: case ctrl_Joystick2: - INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false); + INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy/*,false*/); buttons = INL_GetJoyButtons(type - ctrl_Joystick); realdelta = true; break; @@ -936,23 +925,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].enti.q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) + if(DirTable[conpee]!=2) player->pdir=DirTable[conpee]; + if(player->enti.q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) { - if(dir==2) player[pn].enti.d = player[pn].info.dir; - else player[pn].enti.d = DirTable[dir]; + if(dir==2) player->enti.d = player->info.dir; + else player->enti.d = DirTable[dir]; } #if DEMO0 @@ -982,13 +971,13 @@ register KeyboardDef *def; #endif #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].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[pn].info.button0, player[pn].info.button1, player[pn].info.button2, player[pn].info.button3); - //printf("q=%d ", player[pn].enti.q); + //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[pn].pdir), dirchar(player[pn].enti.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); + 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]); printf("\n"); } @@ -1002,10 +991,10 @@ if(player[pn].info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] | // /////////////////////////////////////////////////////////////////////////// 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 @@ -1098,7 +1087,7 @@ IN_GetScanName(ScanCode scan) // /////////////////////////////////////////////////////////////////////////// ScanCode -IN_WaitForKey() +IN_WaitForKey(void) { ScanCode result; @@ -1115,7 +1104,7 @@ IN_WaitForKey() // /////////////////////////////////////////////////////////////////////////// char -IN_WaitForASCII() +IN_WaitForASCII(void) { char result; @@ -1127,69 +1116,66 @@ IN_WaitForASCII() /////////////////////////////////////////////////////////////////////////// // -// IN_AckBack() - Waits for either an ASCII keypress or a button press +// IN_Ack() - waits for a button or key press. If a button is down, upon +// calling, it must be released for it to be recognized // /////////////////////////////////////////////////////////////////////////// -void -IN_AckBack() + +boolean btnstate[8]; + +void IN_StartAck(void) { - word i; + unsigned i,buttons; - while (!inpu.LastScan) - { - if (inpu.MousePresent) - { - if (INL_GetMouseButtons()) - { - while (INL_GetMouseButtons()) - ; - return; - } - } +// +// get initial state of everything +// + IN_ClearKeysDown(); + memset (btnstate,0,sizeof(btnstate)); - for (i = 0;i < MaxJoys;i++) - { - if (inpu.JoysPresent[i]) - { - if (IN_GetJoyButtonsDB(i)) - { - while (IN_GetJoyButtonsDB(i)) - ; - return; - } - } - } - } + buttons = IN_JoyButtons () << 4; + if (inpu.MousePresent) + buttons |= IN_MouseButtons (); - IN_ClearKey(inpu.LastScan); - inpu.LastScan = sc_None; + for (i=0;i<8;i++,buttons>>=1) + if (buttons&1) + btnstate[i] = true; } -/////////////////////////////////////////////////////////////////////////// + +boolean IN_CheckAck (void) +{ + unsigned i,buttons; + // -// IN_Ack() - Clears user input & then calls IN_AckBack() +// see if something has been pressed // -/////////////////////////////////////////////////////////////////////////// -void -IN_Ack() -{ - word i; + if (inpu.LastScan) + return true; - if (!inst.IN_Started) - return; + buttons = IN_JoyButtons () << 4; + if (inpu.MousePresent) + buttons |= IN_MouseButtons (); - IN_ClearKey(inpu.LastScan); - inpu.LastScan = sc_None; + for (i=0;i<8;i++,buttons>>=1) + if ( buttons&1 ) + { + if (!btnstate[i]) + return true; + } + else + btnstate[i]=false; + + return false; +} - if (inpu.MousePresent) - while (INL_GetMouseButtons()) - ; - for (i = 0;i < MaxJoys;i++) - if (inpu.JoysPresent[i]) - while (IN_GetJoyButtonsDB(i)) - ; - IN_AckBack(); +void IN_Ack (void) +{ + IN_StartAck (); + + while (!IN_CheckAck ()) + ; } /////////////////////////////////////////////////////////////////////////// @@ -1226,21 +1212,17 @@ IN_IsUserInput() // button up. // /////////////////////////////////////////////////////////////////////////// -boolean -IN_UserInput(dword delay,boolean clear) +boolean IN_UserInput(word delay) { word TimeCount = *clockw; word lasttime; lasttime = TimeCount; + IN_StartAck (); do { - if (IN_IsUserInput()) - { - if (clear) - IN_AckBack(); - return(true); - } + if (IN_CheckAck()) + return true; } while (TimeCount - lasttime < delay); return(false); } @@ -1280,7 +1262,7 @@ byte IN_JoyButtons (void) { byte joybits; - joybits = inp(0x201); // Get all the joystick buttons + joybits = inportb(0x201); // Get all the joystick buttons joybits >>= 4; // only the high bits are useful joybits ^= 15; // return with 1=pressed @@ -1327,3 +1309,13 @@ ScanCode IN_GetCurCode() { return inst.CurCode; } + +void IN_KbdLED() +{ + byte far *lock_key; + + // turn off num-lock via BIOS + lock_key = MK_FP(0x040, 0x017); // Pointing to the address of the bios shift state keys + *lock_key&=(~(16 | 32 | 64)); // toggle off the locks by changing the values of the 4th, 5th, and 6th bits of the address byte of 0040:0017 + OldKeyVect(); // call BIOS keyhandler to change keyboard lights +} diff --git a/src/lib/16_in.h b/src/lib/16_in.h index 86980fe8..540cc4d4 100755 --- a/src/lib/16_in.h +++ b/src/lib/16_in.h @@ -1,21 +1,3 @@ -/* Catacomb Apocalypse Source Code - * Copyright (C) 1993-2014 Flat Rock Software - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - // // ID Engine // ID_IN.h - Header file for Input Manager @@ -34,15 +16,8 @@ #include "src/lib/16_dbg.h" #include "src/lib/16_spri.h" #include "src/lib/16_enti.h" -//#include "src/lib/bitmap.h" //old format #endif -//if else for gfxtesting and direction -//player[pn].d == 2 || -//player[pn].d != 2 || -#define DIRECTIONIFELSE (player[pn].info.dir == 2) -//#define NDIRECTIONIFELSE (player[pn].info.dir != 2) - #define KeyInt 9 // The keyboard ISR number // Stuff for the joystick @@ -53,7 +28,6 @@ //#define MaxPlayers 2//future plans for multiple playable charaters and being able to alternate #define MaxKbds 2 #define MaxJoys 2 -#define MaxPads 2 #define NumCodes 128 //typedef byte ScanCode; @@ -218,48 +192,48 @@ typedef struct { #endif // Internal routines -void interrupt INL_KeyService(); -void Mouse(int x); -//static void INL_GetMouseDelta(int *x,int *y); -//static word INL_GetMouseButtons(void); -void IN_GetJoyAbs(word joy,word *xp,word *yp); -//static void INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive); -//static word INL_GetJoyButtons(word joy); -word IN_GetJoyButtonsDB(word joy); -//static void INL_StartKbd(void); -//static void INL_ShutKbd(void); -//static boolean INL_StartMouse(void); -//static void INL_ShutMouse(void); -//static void INL_SetJoyScale(word joy); -void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy); -//static boolean INL_StartJoy(word joy); -//static void INL_ShutJoy(word joy); -void IN_Startup(); -void IN_Default(boolean gotit,player_t *player,ControlType nt); -void IN_Shutdown(); -void IN_SetKeyHook(void (*hook)()); -void IN_ClearKeysDown(); -//static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy); -void IN_ReadCursor(CursorInfo *info); -void near IN_ReadControl(word pn, player_t *player); -void IN_SetControlType(word pn,player_t *player,ControlType type); +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 *), + 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), +#if DEMO0 + IN_StopDemo(void),IN_FreeDemoBuffer(void), +#endif + 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 (void); +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(); +#define Mouse(x) INL_Mouse(x) +//void IN_SetKeyHook(void (*hook)()); #if DEMO0 boolean IN_StartDemoRecord(word bufsize); -void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize); +void IN_StartDemoPlayback(byte *buffer,word bufsize); void IN_StopDemo(void); void IN_FreeDemoBuffer(void); #endif -byte *IN_GetScanName(ScanCode scan); -ScanCode IN_WaitForKey(); -char IN_WaitForASCII(); -void IN_AckBack(); -void IN_Ack(); -boolean IN_IsUserInput(); -boolean IN_UserInput(dword delay,boolean clear); -boolean IN_KeyDown(byte code); -void IN_ClearKey(byte code); -boolean IN_qb(byte kee); -ScanCode IN_GetLastScan(); -ScanCode IN_GetCurCode(); + +boolean IN_KeyDown(byte code), + IN_qb(byte kee); +void IN_ClearKey(byte code), + IN_KbdLED(); +ScanCode IN_GetLastScan(), + IN_GetCurCode(); #endif diff --git a/src/lib/16_in_.c b/src/lib/16_in_.c deleted file mode 100755 index c04d15aa..00000000 --- a/src/lib/16_in_.c +++ /dev/null @@ -1,1316 +0,0 @@ -/* Catacomb Apocalypse Source Code - * Copyright (C) 1993-2014 Flat Rock Software - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -// -// ID Engine -// ID_IN.c - Input Manager -// v1.0d1w -// By Jason Blochowiak -// Open Watcom port by sparky4 -// - -// -// This module handles dealing with the various input devices -// -// Depends on: Memory Mgr (for demo recording), Sound Mgr (for timing stuff), -// User Mgr (for command line parms) -// -// Globals: -// LastScan - The keyboard scan code of the last key pressed -// LastASCII - The ASCII value of the last key pressed -// DEBUG - there are more globals -// - -#include "src/lib/16_in_.h" -#pragma hdrstop - -/* -============================================================================= - - GLOBAL VARIABLES - -============================================================================= -*/ -// moved to 16_tdef.h - -/* -============================================================================= - - LOCAL VARIABLES - -============================================================================= -*/ - -#ifdef __cplusplus /* Function must be declared C style */ -extern "C" { -#endif - -static void (*INL_KeyHook)(void); -static void interrupt (*OldKeyVect)(void); -static char *ParmStringsIN[] = {"nojoys","nomouse",nil}; - -static byte far ASCIINames[] = // Unshifted ASCII for scan codes - { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0 ,27 ,'1','2','3','4','5','6','7','8','9','0','-','=',8 ,9 , // 0 - 'q','w','e','r','t','y','u','i','o','p','[',']',13 ,0 ,'a','s', // 1 - 'd','f','g','h','j','k','l',';',39 ,'`',0 ,92 ,'z','x','c','v', // 2 - 'b','n','m',',','.','/',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4 - '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 - }, - far ShiftNames[] = // Shifted ASCII for scan codes - { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0 ,27 ,'!','@','#','$','%','^','&','*','(',')','_','+',8 ,9 , // 0 - 'Q','W','E','R','T','Y','U','I','O','P','{','}',13 ,0 ,'A','S', // 1 - 'D','F','G','H','J','K','L',':',34 ,'~',0 ,'|','Z','X','C','V', // 2 - 'B','N','M','<','>','?',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4 - '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 - }, - far SpecialNames[] = // ASCII for 0xe0 prefixed codes - { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 0 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,13 ,0 ,0 ,0 , // 1 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 2 - 0 ,0 ,0 ,0 ,0 ,'/',0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 3 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 - }, - - - *ScanNames[] = // Scan code names with single chars - { - "?","?","1","2","3","4","5","6","7","8","9","0","-","+","?","?", - "Q","W","E","R","T","Y","U","I","O","P","[","]","|","?","A","S", - "D","F","G","H","J","K","L",";","\"","?","?","?","Z","X","C","V", - "B","N","M",",",".","/","?","?","?","?","?","?","?","?","?","?", - "?","?","?","?","?","?","?","?","\xf","?","-","\x15","5","\x11","+","?", - "\x13","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?", - "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?", - "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?" - }, // DEBUG - consolidate these - - - far ExtScanCodes[] = // Scan codes with >1 char names - { - 1,0xe,0xf,0x1d,0x2a,0x39,0x3a,0x3b,0x3c,0x3d,0x3e, - 0x3f,0x40,0x41,0x42,0x43,0x44,0x57,0x59,0x46,0x1c,0x36, - 0x37,0x38,0x47,0x49,0x4f,0x51,0x52,0x53,0x45,0x48, - 0x50,0x4b,0x4d,0x00 - }, - *ExtScanNames[] = // Names corresponding to ExtScanCodes - { - "Esc","BkSp","Tab","Ctrl","LShft","Space","CapsLk","F1","F2","F3","F4", - "F5","F6","F7","F8","F9","F10","F11","F12","ScrlLk","Enter","RShft", - "PrtSc","Alt","Home","PgUp","End","PgDn","Ins","Del","NumLk","Up", - "Down","Left","Right","" - }; - -static Direction DirTable[] = // Quick lookup for total direction - { - /*dir_NorthWest, */dir_North,/* dir_NorthEast,*/ - dir_West, dir_None, dir_East, - /*dir_SouthWest, */dir_South/*, dir_SouthEast*/ - }; - -#ifdef __cplusplus -} -#endif - -// Internal routines - -/////////////////////////////////////////////////////////////////////////// -// -// INL_KeyService() - Handles a keyboard interrupt (key up/down) -// -/////////////////////////////////////////////////////////////////////////// -/*static */void interrupt -INL_KeyService(global_game_variables_t *gvar) -{ -static boolean special; - byte k,c, - temp; - - k = inp(0x60); // Get the scan code - - // Tell the XT keyboard controller to clear the key - outp(0x61,(temp = inp(0x61)) | 0x80); - outp(0x61,temp); - - if (k == 0xe0) // Special key prefix - special = true; - else if (k == 0xe1) // Handle Pause key - gvar->in.Paused = true; - else - { - if (k & 0x80) // Break code - { - k &= 0x7f; - -// DEBUG - handle special keys: ctl-alt-delete, print scrn - - gvar->in.Keyboard[k] = false; - } - else // Make code - { - gvar->in.LastCode = gvar->in.CurCode; - gvar->in.CurCode = gvar->in.LastScan = k; - gvar->in.Keyboard[k] = true; - - if (special) - c = SpecialNames[k]; - else - { - if (k == sc_CapsLock) - { - gvar->in.CapsLock ^= true; - // DEBUG - make caps lock light work - } - - if (gvar->in.Keyboard[sc_LShift] || gvar->in.Keyboard[sc_RShift]) // If shifted - { - c = ShiftNames[k]; - if ((c >= 'A') && (c <= 'Z') && gvar->in.CapsLock) - c += 'a' - 'A'; - } - else - { - c = ASCIINames[k]; - if ((c >= 'a') && (c <= 'z') && gvar->in.CapsLock) - c -= 'a' - 'A'; - } - } - if (c) - gvar->in.LastASCII = c; - } - - special = false; - } - - 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, gvar->in.Keyboard[k]); -#endif - outp(0x20,0x20); -} - -void -Mouse(int x) -{ - //union REGS CPURegs; - //x = CPURegs.x.ax; - __asm { - mov ax,x - int MouseInt - } - //int86(MouseInt,&CPURegs,&CPURegs); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetMouseDelta() - Gets the amount that the mouse has moved from the -// mouse driver -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_GetMouseDelta(int *x,int *y) -{ - union REGS CPURegs; - Mouse(MDelta); - *x = CPURegs.x.cx; - *y = CPURegs.x.dx; -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetMouseButtons() - Gets the status of the mouse buttons from the -// mouse driver -// -/////////////////////////////////////////////////////////////////////////// -static word -INL_GetMouseButtons(void) -{ - union REGS CPURegs; - word buttons; - - Mouse(MButtons); - buttons = CPURegs.x.bx; - return(buttons); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_GetJoyAbs() - Reads the absolute position of the specified joystick -// -/////////////////////////////////////////////////////////////////////////// -void -IN_GetJoyAbs(word joy,word *xp,word *yp) -{ - byte xb,yb, - xs,ys; - word x,y; - - x = y = 0; - xs = joy? 2 : 0; // Find shift value for x axis - xb = 1 << xs; // Use shift value to get x bit mask - ys = joy? 3 : 1; // Do the same for y axis - yb = 1 << ys; - -// Read the absolute joystick values - __asm { - pushf // Save some registers - push si - push di - cli // Make sure an interrupt doesn't screw the timings - - - mov dx,0x201 - in al,dx - out dx,al // Clear the resistors - - mov ah,[xb] // Get masks into registers - mov ch,[yb] - - xor si,si // Clear count registers - xor di,di - xor bh,bh // Clear high byte of bx for later - - 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 - jz done // We have a silly value - abort - - mov bl,al // Duplicate the bits - and bl,ah // Mask off useless bits (in [xb]) - add si,bx // Possibly increment count register - mov cl,bl // Save for testing later - - mov bl,al - and bl,ch // [yb] - add di,bx - - 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 - shr si,cl // and shift the count that many times - - mov cl,[ys] - shr di,cl - - mov [x],si // Store the values into the variables - mov [y],di - - pop di - pop si - popf // Restore the registers - } - - *xp = x; - *yp = y; -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetJoyDelta() - Returns the relative movement of the specified -// joystick (from +/-127, scaled adaptively) -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive, global_game_variables_t *gvar) -{ - word x,y; - word time; - word TimeCount = gvar->kurokku.clock_start; - JoystickDef *def; -static word lasttime; - - IN_GetJoyAbs(joy,&x,&y); - def = gvar->in.JoyDefs + joy; - - if (x < def->threshMinX) - { - if (x < def->joyMinX) - x = def->joyMinX; - - x = -(x - def->threshMinX); - x *= def->joyMultXL; - x >>= JoyScaleShift; - *dx = (x > 127)? -127 : -x; - } - else if (x > def->threshMaxX) - { - if (x > def->joyMaxX) - x = def->joyMaxX; - - x = x - def->threshMaxX; - x *= def->joyMultXH; - x >>= JoyScaleShift; - *dx = (x > 127)? 127 : x; - } - else - *dx = 0; - - if (y < def->threshMinY) - { - if (y < def->joyMinY) - y = def->joyMinY; - - y = -(y - def->threshMinY); - y *= def->joyMultYL; - y >>= JoyScaleShift; - *dy = (y > 127)? -127 : -y; - } - else if (y > def->threshMaxY) - { - if (y > def->joyMaxY) - y = def->joyMaxY; - - y = y - def->threshMaxY; - y *= def->joyMultYH; - y >>= JoyScaleShift; - *dy = (y > 127)? 127 : y; - } - else - *dy = 0; - - if (adaptive) - { - time = (TimeCount - lasttime) / 2; - if (time) - { - if (time > 8) - time = 8; - *dx *= time; - *dy *= time; - } - } - lasttime = TimeCount; -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetJoyButtons() - Returns the button status of the specified -// joystick -// -/////////////////////////////////////////////////////////////////////////// -static word -INL_GetJoyButtons(word joy) -{ -register word result; - - result = inp(0x201); // Get all the joystick buttons - result >>= joy? 6 : 4; // Shift into bits 0-1 - result &= 3; // Mask off the useless bits - result ^= 3; - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_GetJoyButtonsDB() - Returns the de-bounced button status of the -// specified joystick -// -/////////////////////////////////////////////////////////////////////////// -word -IN_GetJoyButtonsDB(word joy, global_game_variables_t *gvar) -{ - word TimeCount = gvar->kurokku.clock_start; - word lasttime; - word result1,result2; - - do - { - result1 = INL_GetJoyButtons(joy); - lasttime = TimeCount; - while(TimeCount == lasttime) - result2 = INL_GetJoyButtons(joy); - } while(result1 != result2); - return(result1); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_StartKbd() - Sets up my keyboard stuff for use -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_StartKbd(global_game_variables_t *gvar) -{ - byte far *lock_key; - INL_KeyHook = 0; // Clear key hook - - IN_ClearKeysDown(gvar); - - OldKeyVect = _dos_getvect(KeyInt); - - // turn off num-lock via BIOS - lock_key = MK_FP(0x040, 0x017); // Pointing to the address of the bios shift state keys - *lock_key&=(~(16 | 32 | 64)); // toggle off the locks by changing the values of the 4th, 5th, and 6th bits of the address byte of 0040:0017 - OldKeyVect(); // call BIOS keyhandler to change keyboard lights - _dos_setvect(KeyInt,INL_KeyService); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_ShutKbd() - Restores keyboard control to the BIOS -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_ShutKbd(void) -{ - pokeb(0x40,0x17,peekb(0x40,0x17) & 0xfaf0); // Clear ctrl/alt/shift flags - - _dos_setvect(KeyInt,OldKeyVect); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_StartMouse() - Detects and sets up the mouse -// -/////////////////////////////////////////////////////////////////////////// -static boolean -INL_StartMouse(void) -{ - union REGS CPURegs; - if(_dos_getvect(MouseInt)) - { - Mouse(MReset); - if(CPURegs.x.ax == 0xffff) - return(true); - } - return(false); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_ShutMouse() - Cleans up after the mouse -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_ShutMouse(void) -{ -} - -// -// INL_SetJoyScale() - Sets up scaling values for the specified joystick -// -static void -INL_SetJoyScale(word joy, global_game_variables_t *gvar) -{ - JoystickDef *def; - - 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); - def->joyMultYH = JoyScaleMax / (def->joyMaxY - def->threshMaxY); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_SetupJoy() - Sets up thresholding values and calls INL_SetJoyScale() -// to set up scaling values -// -/////////////////////////////////////////////////////////////////////////// -void -IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, global_game_variables_t *gvar) -{ - word d,r; - JoystickDef *def; - - def = &(gvar->in.JoyDefs[joy]); - - def->joyMinX = minx; - def->joyMaxX = maxx; - r = maxx - minx; - d = r / 3; - def->threshMinX = ((r / 2) - d) + minx; - def->threshMaxX = ((r / 2) + d) + minx; - - def->joyMinY = miny; - def->joyMaxY = maxy; - r = maxy - miny; - d = r / 3; - def->threshMinY = ((r / 2) - d) + miny; - def->threshMaxY = ((r / 2) + d) + miny; - - INL_SetJoyScale(joy, gvar); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_StartJoy() - Detects & auto-configures the specified joystick -// The auto-config assumes the joystick is centered -// -/////////////////////////////////////////////////////////////////////////// -static boolean -INL_StartJoy(word joy, global_game_variables_t *gvar) -{ - word x,y; - - IN_GetJoyAbs(joy,&x,&y); - - if - ( - ((x == 0) || (x > MaxJoyValue - 10)) - || ((y == 0) || (y > MaxJoyValue - 10)) - ) - return(false); - else - { - IN_SetupJoy(joy,0,x * 2,0,y * 2, gvar); - return(true); - } -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_ShutJoy() - Cleans up the joystick stuff -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_ShutJoy(word joy, global_game_variables_t *gvar) -{ - gvar->in.JoysPresent[joy] = false; -} - -// Public routines - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Startup() - Starts up the Input Mgr -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Startup(global_game_variables_t *gvar) -{ - boolean checkjoys,checkmouse; - word i; - - if (gvar->in.IN_Started) - return; - - checkjoys = true; - checkmouse = true; - for (i = 1;i < _argc;i++) - { - switch (US_CheckParm(_argv[i],ParmStringsIN)) - { - case 0: - checkjoys = false; - break; - case 1: - checkmouse = false; - break; - } - } - - INL_StartKbd(gvar); - gvar->in.MousePresent = checkmouse? INL_StartMouse() : false; - - for (i = 0;i < MaxJoys;i++) - gvar->in.JoysPresent[i] = checkjoys? INL_StartJoy(i, gvar) : false; - - //for (i = 0;i < MaxKbds;i++) - // gvar->in.KbdDefs[i] = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/}; - - gvar->in.IN_Started = true; - -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Default() - Sets up default conditions for the Input Mgr -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar) -{ - 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_Keyboard1; - gvar->in.KbdDefs[0].button0 = 0x1c; - gvar->in.KbdDefs[0].button1 = 0x38; - //in.KbdDefs[0].upleft = 0x47; - gvar->in.KbdDefs[0].up = 0x48; - //in.KbdDefs[0].upright = 0x49; - gvar->in.KbdDefs[0].left = 0x4b; - gvar->in.KbdDefs[0].right = 0x4d; - //in.KbdDefs[0].downleft = 0x4f; - gvar->in.KbdDefs[0].down = 0x50; - //in.KbdDefs[0].downright = 0x51; - IN_SetControlType(0,player,nt); - for(i=0; i>MaxPlayers;i++) - player[i].enti.d =2; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Shutdown() - Shuts down the Input Mgr -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Shutdown(global_game_variables_t *gvar) -{ - word i; - - if (!gvar->in.IN_Started) - return; - - INL_ShutMouse(); - for (i = 0;i < MaxJoys;i++) - INL_ShutJoy(i, gvar); - INL_ShutKbd(); - - gvar->in.IN_Started = false; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_SetKeyHook() - Sets the routine that gets called by INL_KeyService() -// everytime a real make/break code gets hit -// -/////////////////////////////////////////////////////////////////////////// -void -IN_SetKeyHook(void (*hook)()) -{ - INL_KeyHook = hook; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_ClearKeyDown() - Clears the keyboard array -// -/////////////////////////////////////////////////////////////////////////// -void -IN_ClearKeysDown(global_game_variables_t *gvar) -{ - //int i; - - gvar->in.LastScan = sc_None; - gvar->in.LastASCII = key_None; - memset (gvar->in.Keyboard,0,sizeof(gvar->in.Keyboard)); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_AdjustCursor() - Internal routine of common code from IN_ReadCursor() -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy) -{ - if (buttons & (1 << 0)) - info->button0 = true; - if (buttons & (1 << 1)) - info->button1 = true; - - info->x += dx; - info->y += dy; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_ReadCursor() - Reads the input devices and fills in the cursor info -// struct -// -/////////////////////////////////////////////////////////////////////////// -void -IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar) -{ - word i, - buttons; - int dx,dy; - - info->x = info->y = 0; - info->button0 = info->button1 = false; - - if (gvar->in.MousePresent) - { - buttons = INL_GetMouseButtons(); - INL_GetMouseDelta(&dx,&dy); - INL_AdjustCursor(info,buttons,dx,dy); - } - - for (i = 0;i < MaxJoys;i++) - { - if (!gvar->in.JoysPresent[i]) - continue; - - buttons = INL_GetJoyButtons(i); - INL_GetJoyDelta(i,&dx,&dy,true, gvar); - dx /= 64; - dy /= 64; - INL_AdjustCursor(info,buttons,dx,dy); - } -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_ReadControl() - Reads the device associated with the specified -// player and fills in the control info struct -// -/////////////////////////////////////////////////////////////////////////// -void near -IN_ReadControl(word pn, player_t *player, global_game_variables_t *gvar) -{ - boolean realdelta; -#if DEMO0 - byte dbyte; -#endif - word buttons; - int dx,dy; - Motion mx,my; - ControlType type; - sword conpee; - byte dir=DirTable[2]; -register KeyboardDef *def; - - dx = dy = 0; - mx = my = motion_None; - buttons = 0; - -#if DEMO0 - if (DemoMode == demo_Playback) - { - dbyte = DemoBuffer[DemoOffset + 1]; - my = (dbyte & 3) - 1; - mx = ((dbyte >> 2) & 3) - 1; - buttons = (dbyte >> 4) & 3; - - if (!(--DemoBuffer[DemoOffset])) - { - DemoOffset += 2; - if (DemoOffset >= DemoSize) - DemoMode = demo_PlayDone; - } - - realdelta = false; - } - else if (DemoMode == demo_PlayDone) - Quit ("Demo playback exceeded"); - else - { -#endif - switch (type = player[pn].Controls) - { - case ctrl_Keyboard1: - case ctrl_Keyboard2: - def = &(gvar->in.KbdDefs[type - ctrl_Keyboard]); - -/* if (Keyboard[def->upleft]) - mx = motion_Left,my = motion_Up; - else if (Keyboard[def->upright]) - mx = motion_Right,my = motion_Up; - else if (Keyboard[def->downleft]) - mx = motion_Left,my = motion_Down; - else if (Keyboard[def->downright]) - mx = motion_Right,my = motion_Down;*/ -//TODO: make this into a function that the joystick AND keyboard can use wwww - if(DIRECTIONIFELSE)//(player[pn].info.dir == 2) - { - if(!gvar->in.Keyboard[def->left] && !gvar->in.Keyboard[def->right]){ - if((gvar->in.Keyboard[def->up] && !gvar->in.Keyboard[def->down])) - my = motion_Up; - if((gvar->in.Keyboard[def->down] && !gvar->in.Keyboard[def->up])) - my = motion_Down; - }else if(!gvar->in.Keyboard[def->up] && !gvar->in.Keyboard[def->down]){ - if((gvar->in.Keyboard[def->left] && !gvar->in.Keyboard[def->right])) - mx = motion_Left; - if((gvar->in.Keyboard[def->right] && !gvar->in.Keyboard[def->left])) - mx = motion_Right; - }else{ //2 keys pressed - switch (player[pn].pdir) - { - case 0: - case 4: - if((gvar->in.Keyboard[def->left] && !gvar->in.Keyboard[def->right])){ dir = DirTable[1]; }//mx = motion_Left; } - else if((gvar->in.Keyboard[def->right] && !gvar->in.Keyboard[def->left])){ dir = DirTable[3]; }//mx = motion_Right; } - break; - case 1: - case 3: - if((gvar->in.Keyboard[def->up] && !gvar->in.Keyboard[def->down])){ dir = DirTable[0]; }//my = motion_Up; } - else if((gvar->in.Keyboard[def->down] && !gvar->in.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 - if (gvar->in.Keyboard[def->button0]) - buttons += 1 << 0; - if (gvar->in.Keyboard[def->button1]) - buttons += 1 << 1; - realdelta = false; - break; - case ctrl_Joystick1: - case ctrl_Joystick2: - INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false, gvar); - buttons = INL_GetJoyButtons(type - ctrl_Joystick); - realdelta = true; - break; - case ctrl_Mouse: - INL_GetMouseDelta(&dx,&dy); - buttons = INL_GetMouseButtons(); - realdelta = true; - break; - } -#ifdef DEMO0 - } -#endif - - if (realdelta) - { - mx = (dx < 0)? motion_Left : ((dx > 0)? motion_Right : motion_None); - my = (dy < 0)? motion_Up : ((dy > 0)? motion_Down : motion_None); - } - else - { - dx = mx;// * 127; - 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)]; - conpee=(((my + 1) * 2) + (mx + 1))-1; - player[pn].info.dir = DirTable[conpee]; - - if(DirTable[conpee]!=2) player[pn].pdir=DirTable[conpee]; - if(player[pn].enti.q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) - { - if(dir==2) player[pn].enti.d = player[pn].info.dir; - else player[pn].enti.d = DirTable[dir]; - } - -#if DEMO0 - if (DemoMode == demo_Record) - { - // Pack the control info into a byte - dbyte = (buttons << 4) | ((mx + 1) << 2) | (my + 1); - - if - ( - (DemoBuffer[DemoOffset + 1] == dbyte) - && (DemoBuffer[DemoOffset] < 255) - ) - (DemoBuffer[DemoOffset])++; - else - { - if (DemoOffset || DemoBuffer[DemoOffset]) - DemoOffset += 2; - - if (DemoOffset >= DemoSize) - Quit ("Demo buffer overflow"); - - DemoBuffer[DemoOffset] = 1; - DemoBuffer[DemoOffset + 1] = dbyte; - } - } -#endif -#ifdef __DEBUG_InputMgr__ -if(dbg_testcontrolnoisy > 0) -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) -{ - //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].enti.q); - //printf("cpee=%c ", dirchar(conpee)); - printf("pdir=%c d=%c dir=%c ", dirchar(player[pn].pdir), dirchar(player[pn].enti.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), 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]); - printf("\n"); -} -#endif -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_SetControlType() - Sets the control type to be used by the specified -// player -// -/////////////////////////////////////////////////////////////////////////// -void -IN_SetControlType(word pn,player_t *player,ControlType type) -{ - // DEBUG - check that requested type is present? - player[pn].Controls = type; -} - -#if DEMO0 -/////////////////////////////////////////////////////////////////////////// -// -// IN_StartDemoRecord() - Starts the demo recording, using a buffer the -// size passed. Returns if the buffer allocation was successful -// -/////////////////////////////////////////////////////////////////////////// -boolean -IN_StartDemoRecord(word bufsize) -{ - if (!bufsize) - return(false); - - MM_GetPtr((memptr *)&DemoBuffer,bufsize); - DemoMode = demo_Record; - DemoSize = bufsize & ~1; - DemoOffset = 0; - DemoBuffer[0] = DemoBuffer[1] = 0; - - return(true); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_StartDemoPlayback() - Plays back the demo pointed to of the given size -// -/////////////////////////////////////////////////////////////////////////// -void -IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize) -{ - DemoBuffer = buffer; - DemoMode = demo_Playback; - DemoSize = bufsize & ~1; - DemoOffset = 0; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_StopDemo() - Turns off demo mode -// -/////////////////////////////////////////////////////////////////////////// -void -IN_StopDemo(void) -{ - if ((DemoMode == demo_Record) && DemoOffset) - DemoOffset += 2; - - DemoMode = demo_Off; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_FreeDemoBuffer() - Frees the demo buffer, if it's been allocated -// -/////////////////////////////////////////////////////////////////////////// -void -IN_FreeDemoBuffer(void) -{ - if (DemoBuffer) - MM_FreePtr((memptr *)&DemoBuffer); -} -#endif - - -/////////////////////////////////////////////////////////////////////////// -// -// IN_GetScanName() - Returns a string containing the name of the -// specified scan code -// -/////////////////////////////////////////////////////////////////////////// -byte * -IN_GetScanName(ScanCode scan) -{ - byte **p; - ScanCode far *s; - - for (s = ExtScanCodes,p = ExtScanNames;*s;p++,s++) - if (*s == scan) - return(*p); - - return(ScanNames[scan]); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_WaitForKey() - Waits for a scan code, then clears LastScan and -// returns the scan code -// -/////////////////////////////////////////////////////////////////////////// -ScanCode -IN_WaitForKey(global_game_variables_t *gvar) -{ - ScanCode result; - - while (!(result = gvar->in.LastScan)) - ; - gvar->in.LastScan = 0; - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_WaitForASCII() - Waits for an ASCII char, then clears LastASCII and -// returns the ASCII value -// -/////////////////////////////////////////////////////////////////////////// -char -IN_WaitForASCII(global_game_variables_t *gvar) -{ - char result; - - while (!(result = gvar->in.LastASCII)) - ; - gvar->in.LastASCII = '\0'; - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_AckBack() - Waits for either an ASCII keypress or a button press -// -/////////////////////////////////////////////////////////////////////////// -void -IN_AckBack(global_game_variables_t *gvar) -{ - word i; - - while (!gvar->in.LastScan) - { - if (gvar->in.MousePresent) - { - if (INL_GetMouseButtons()) - { - while (INL_GetMouseButtons()) - ; - return; - } - } - - for (i = 0;i < MaxJoys;i++) - { - if (gvar->in.JoysPresent[i]) - { - if (IN_GetJoyButtonsDB(i, gvar)) - { - while (IN_GetJoyButtonsDB(i, gvar)) - ; - return; - } - } - } - } - - IN_ClearKey(gvar->in.LastScan, gvar); - gvar->in.LastScan = sc_None; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Ack() - Clears user input & then calls IN_AckBack() -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Ack(global_game_variables_t *gvar) -{ - word i; - - if (!gvar->in.IN_Started) - return; - - IN_ClearKey(gvar->in.LastScan, gvar); - gvar->in.LastScan = sc_None; - - if (gvar->in.MousePresent) - while (INL_GetMouseButtons()) - ; - for (i = 0;i < MaxJoys;i++) - if (gvar->in.JoysPresent[i]) - while (IN_GetJoyButtonsDB(i, gvar)) - ; - - IN_AckBack(gvar); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_IsUserInput() - Returns true if a key has been pressed or a button -// is down -// -/////////////////////////////////////////////////////////////////////////// -boolean -IN_IsUserInput(global_game_variables_t *gvar) -{ - boolean result; - word i; - - result = gvar->in.LastScan; - - if (gvar->in.MousePresent) - if (INL_GetMouseButtons()) - result = true; - - for (i = 0;i < MaxJoys;i++) - if (gvar->in.JoysPresent[i]) - if (INL_GetJoyButtons(i)) - result = true; - - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_UserInput() - Waits for the specified delay time (in ticks) or the -// user pressing a key or a mouse button. If the clear flag is set, it -// then either clears the key or waits for the user to let the mouse -// button up. -// -/////////////////////////////////////////////////////////////////////////// -boolean -IN_UserInput(dword delay,boolean clear, global_game_variables_t *gvar) -{ - word TimeCount = gvar->kurokku.clock_start; - word lasttime; - - lasttime = TimeCount; - do - { - if (IN_IsUserInput(gvar)) - { - if (clear) - IN_AckBack(gvar); - return(true); - } - } while (TimeCount - lasttime < delay); - return(false); -} - -//=========================================================================== - -/* -=================== -= -= IN_MouseButtons -= -=================== -*/ - -byte IN_MouseButtons (global_game_variables_t *gvar) -{ - union REGS CPURegs; - if (gvar->in.MousePresent) - { - Mouse(MButtons); - return CPURegs.x.bx; - } - else - return 0; -} - - -/* -=================== -= -= IN_JoyButtons -= -=================== -*/ - -byte IN_JoyButtons (void) -{ - byte joybits; - - joybits = inp(0x201); // Get all the joystick buttons - joybits >>= 4; // only the high bits are useful - joybits ^= 15; // return with 1=pressed - - return joybits; -} - -boolean IN_KeyDown(byte code, global_game_variables_t *gvar) -{ -#ifdef __DEBUG_InputMgr__ - if(!dbg_nointest) -#endif - return gvar->in.Keyboard[code]; -#ifdef __DEBUG_InputMgr__ - else - if(dbg_nointest && kbhit()) - return 1; - else - return 0; -#endif -} - -void IN_ClearKey(byte code, global_game_variables_t *gvar) -{ - gvar->in.Keyboard[code] = false; - if(code == gvar->in.LastScan) - gvar->in.LastScan = sc_None; - } - -boolean IN_qb(byte kee, global_game_variables_t *gvar) -{ -#ifdef __DEBUG_InputMgr__ - if(dbg_testkeyin) printf("%u\n", gvar->in.Keyboard[kee]); -#endif - if(gvar->in.Keyboard[kee]==true) return 1; - else return 0; -} - -ScanCode IN_GetLastScan(global_game_variables_t *gvar) -{ - return gvar->in.LastScan; -} - -ScanCode IN_GetCurCode(global_game_variables_t *gvar) -{ - return gvar->in.CurCode; -} diff --git a/src/lib/16_in_.h b/src/lib/16_in_.h deleted file mode 100755 index f84b3a46..00000000 --- a/src/lib/16_in_.h +++ /dev/null @@ -1,265 +0,0 @@ -/* Catacomb Apocalypse Source Code - * Copyright (C) 1993-2014 Flat Rock Software - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -// -// ID Engine -// ID_IN.h - Header file for Input Manager -// v1.0d1w -// By Jason Blochowiak -// Open Watcom port by sparky4 -// - -#ifndef __16_IN__ -#define __16_IN__ - -#include -#include "src/lib/16_head.h" -#include "src/lib/16_timer.h" -#ifdef __WATCOMC__ //borland C BCEXMM.EXE -#include "src/lib/16_dbg.h" -#include "src/lib/16_spri.h" -#include "src/lib/16_enti.h" -//#include "src/lib/bitmap.h" //old format -#endif - -//if else for gfxtesting and direction -//player[pn].d == 2 || -//player[pn].d != 2 || -#define DIRECTIONIFELSE (player[pn].info.dir == 2) -//#define NDIRECTIONIFELSE (player[pn].info.dir != 2) - -#define KeyInt 9 // The keyboard ISR number - -// Stuff for the joystick -#define JoyScaleMax 32768 -#define JoyScaleShift 8 -#define MaxJoyValue 5000 - -//#define MaxPlayers 2//future plans for multiple playable charaters and being able to alternate -#define MaxKbds 2 -#define MaxJoys 2 -#define MaxPads 2 -#define NumCodes 128 - -//typedef byte ScanCode; -#define sc_None 0 -#define sc_Bad 0xff -#define sc_Return 0x1c -#define sc_Enter sc_Return -#define sc_Escape 0x01 -#define sc_Space 0x39 -#define sc_BackSpace 0x0e -#define sc_Tab 0x0f -#define sc_Alt 0x38 -#define sc_Control 0x1d -#define sc_CapsLock 0x3a -#define sc_LShift 0x2a -#define sc_RShift 0x36 -#define sc_UpArrow 0x48 -#define sc_DownArrow 0x50 -#define sc_LeftArrow 0x4b -#define sc_RightArrow 0x4d -#define sc_Insert 0x52 -#define sc_Delete 0x53 -#define sc_Home 0x47 -#define sc_End 0x4f -#define sc_PgUp 0x49 -#define sc_PgDn 0x51 -#define sc_F1 0x3b -#define sc_F2 0x3c -#define sc_F3 0x3d -#define sc_F4 0x3e -#define sc_F5 0x3f -#define sc_F6 0x40 -#define sc_F7 0x41 -#define sc_F8 0x42 -#define sc_F9 0x43 -#define sc_F10 0x44 -#define sc_F11 0x57 -#define sc_F12 0x59 - -#define sc_1 0x02 -#define sc_2 0x03 -#define sc_3 0x04 -#define sc_4 0x05 -#define sc_5 0x06 -#define sc_6 0x07 -#define sc_7 0x08 -#define sc_8 0x09 -#define sc_9 0x0a -#define sc_0 0x0b - -#define sc_A 0x1e -#define sc_B 0x30 -#define sc_C 0x2e -#define sc_D 0x20 -#define sc_E 0x12 -#define sc_F 0x21 -#define sc_G 0x22 -#define sc_H 0x23 -#define sc_I 0x17 -#define sc_J 0x24 -#define sc_K 0x25 -#define sc_L 0x26 -#define sc_M 0x32 -#define sc_N 0x31 -#define sc_O 0x18 -#define sc_P 0x19 -#define sc_Q 0x10 -#define sc_R 0x13 -#define sc_S 0x1f -#define sc_T 0x14 -#define sc_U 0x16 -#define sc_V 0x2f -#define sc_W 0x11 -#define sc_X 0x2d -#define sc_Y 0x15 -#define sc_Z 0x2c - -#define key_None 0 -#define key_Return 0x0d -#define key_Enter key_Return -#define key_Escape 0x1b -#define key_Space 0x20 -#define key_BackSpace 0x08 -#define key_Tab 0x09 -#define key_Delete 0x7f - -#define key_LSuper 0x5b -#define key_RSuper 0x5c -#define key_Menu 0x5d - -// Stuff for the mouse -#define MReset 0 -#define MButtons 3 -#define MDelta 11 - -#define MouseInt 0x33 -#ifdef DEMO0 -typedef enum { - demo_Off,demo_Record,demo_Playback,demo_PlayDone - } Demo; -#endif -//moved to 16_tdef.h -/*typedef enum { - //ctrl_None, // MDM (GAMERS EDGE) - added - ctrl_Keyboard, - ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2, - ctrl_Joystick, - ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2, - ctrl_Mouse, - } ControlType; -typedef enum { - motion_Left = -1,motion_Up = -1, - motion_None = 0, - motion_Right = 1,motion_Down = 1 - } Motion; -typedef enum { - dir_North,//dir_NorthEast, - dir_West,//dir_Nortinest, - dir_None, - dir_East,//,dir_SouthEast, - dir_South,//dir_Soutinest, - } Direction; -typedef struct { - boolean near button0,button1,button2,button3; - int near x,y; - Motion near xaxis,yaxis; - Direction near dir; - } CursorInfo; - -typedef struct { - ScanCode near button0,button1, - //upleft, - up, - down, - left, - right - //upright, - //downleft, - //,downright - ; - } KeyboardDef; -typedef struct { - word near joyMinX,joyMinY, - threshMinX,threshMinY, - threshMaxX,threshMaxY, - joyMaxX,joyMaxY, - joyMultXL,joyMultYL, - joyMultXH,joyMultYH; - } JoystickDef;*/ - -/* -============================================================================= - - GLOBAL VARIABLES - -============================================================================= -*/ -#ifdef DEMO0 - static Demo DemoMode = demo_Off; - static byte /*_seg*/ *DemoBuffer; - static word DemoOffset,DemoSize; -#endif - -// Internal routines -//void interrupt INL_KeyService(global_game_variables_t *gvar); -void Mouse(int x); -//static void INL_GetMouseDelta(int *x,int *y); -//static word INL_GetMouseButtons(void); -void IN_GetJoyAbs(word joy,word *xp,word *yp); -//static void INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive); -//static word INL_GetJoyButtons(word joy); -word IN_GetJoyButtonsDB(word joy, global_game_variables_t *gvar); -//static void INL_StartKbd(void); -//static void INL_ShutKbd(void); -//static boolean INL_StartMouse(void); -//static void INL_ShutMouse(void); -//static void INL_SetJoyScale(word joy); -void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, global_game_variables_t *gvar); -//static boolean INL_StartJoy(word joy); -//static void INL_ShutJoy(word joy); -void IN_Startup(global_game_variables_t *gvar); -void IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar); -void IN_Shutdown(global_game_variables_t *gvar); -void IN_SetKeyHook(void (*hook)()); -void IN_ClearKeysDown(global_game_variables_t *gvar); -//static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy); -void IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar); -void near IN_ReadControl(word pn, player_t *player, global_game_variables_t *gvar); -void IN_SetControlType(word pn,player_t *player,ControlType type); -#if DEMO0 -boolean IN_StartDemoRecord(word bufsize); -void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize); -void IN_StopDemo(void); -void IN_FreeDemoBuffer(void); -#endif -byte *IN_GetScanName(ScanCode scan); -ScanCode IN_WaitForKey(global_game_variables_t *gvar); -char IN_WaitForASCII(global_game_variables_t *gvar); -void IN_AckBack(global_game_variables_t *gvar); -void IN_Ack(global_game_variables_t *gvar); -boolean IN_IsUserInput(global_game_variables_t *gvar); -boolean IN_UserInput(dword delay,boolean clear, global_game_variables_t *gvar); -boolean IN_KeyDown(byte code, global_game_variables_t *gvar); -void IN_ClearKey(byte code, global_game_variables_t *gvar); -boolean IN_qb(byte kee, global_game_variables_t *gvar); -ScanCode IN_GetLastScan(global_game_variables_t *gvar); -ScanCode IN_GetCurCode(global_game_variables_t *gvar); - -#endif diff --git a/src/lib/16_in__.c b/src/lib/16_in__.c deleted file mode 100755 index 2534af75..00000000 --- a/src/lib/16_in__.c +++ /dev/null @@ -1,991 +0,0 @@ -// -// ID Engine -// ID_IN.c - Input Manager -// v1.0d1w -// By Jason Blochowiak -// Open Watcom port by sparky4 -// - -// -// This module handles dealing with the various input devices -// -// Depends on: Memory Mgr (for demo recording), Sound Mgr (for timing stuff), -// User Mgr (for command line parms) -// -// Globals: -// LastScan - The keyboard scan code of the last key pressed -// LastASCII - The ASCII value of the last key pressed -// DEBUG - there are more globals -// - -#include "src/lib/16_in__.h" -#pragma hdrstop - -#define KeyInt 9 // The keyboard ISR number - -// -// mouse constants -// -#define MReset 0 -#define MButtons 3 -#define MDelta 11 - -#define MouseInt 0x33 -#define Mouse(x) _AX = x,geninterrupt(MouseInt) - -// -// joystick constants -// -#define JoyScaleMax 32768 -#define JoyScaleShift 8 -#define MaxJoyValue 5000 - -/* -============================================================================= - - GLOBAL VARIABLES - -============================================================================= -*/ - -// -// configuration variables -// -boolean MousePresent; -boolean JoysPresent[MaxJoys]; -boolean JoyPadPresent; - - -// Global variables - boolean Keyboard[NumCodes]; - boolean Paused; - char LastASCII; - ScanCode LastScan; - - KeyboardDef KbdDefs = {{0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51}}; - JoystickDef JoyDefs[MaxJoys]; - ControlType Controls[MaxPlayers]; - - dword MouseDownCount; - - Demo DemoMode = demo_Off; - byte _seg *DemoBuffer; - word DemoOffset,DemoSize; - -/* -============================================================================= - - LOCAL VARIABLES - -============================================================================= -*/ -static byte far ASCIINames[] = // Unshifted ASCII for scan codes - { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0 ,27 ,'1','2','3','4','5','6','7','8','9','0','-','=',8 ,9 , // 0 - 'q','w','e','r','t','y','u','i','o','p','[',']',13 ,0 ,'a','s', // 1 - 'd','f','g','h','j','k','l',';',39 ,'`',0 ,92 ,'z','x','c','v', // 2 - 'b','n','m',',','.','/',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4 - '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 - }, - far ShiftNames[] = // Shifted ASCII for scan codes - { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0 ,27 ,'!','@','#','$','%','^','&','*','(',')','_','+',8 ,9 , // 0 - 'Q','W','E','R','T','Y','U','I','O','P','{','}',13 ,0 ,'A','S', // 1 - 'D','F','G','H','J','K','L',':',34 ,'~',0 ,'|','Z','X','C','V', // 2 - 'B','N','M','<','>','?',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4 - '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 - }, - far SpecialNames[] = // ASCII for 0xe0 prefixed codes - { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 0 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,13 ,0 ,0 ,0 , // 1 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 2 - 0 ,0 ,0 ,0 ,0 ,'/',0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 3 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 - }; - - -static boolean IN_Started; -static boolean CapsLock; -static ScanCode CurCode,LastCode; - -static Direction DirTable[] = // Quick lookup for total direction - { - dir_NorthWest, dir_North, dir_NorthEast, - dir_West, dir_None, dir_East, - dir_SouthWest, dir_South, dir_SouthEast - }; - -static void (*INL_KeyHook)(void); -static void interrupt (*OldKeyVect)(void); - -static char *ParmStrings[] = {"nojoys","nomouse",nil}; - -// Internal routines - -/////////////////////////////////////////////////////////////////////////// -// -// INL_KeyService() - Handles a keyboard interrupt (key up/down) -// -/////////////////////////////////////////////////////////////////////////// -static void interrupt -INL_KeyService(void) -{ -static boolean special; - byte k,c, - temp; - int i; - - k = inp(0x60); // Get the scan code - - // Tell the XT keyboard controller to clear the key - outportb(0x61,(temp = inp(0x61)) | 0x80); - outportb(0x61,temp); - - if (k == 0xe0) // Special key prefix - special = true; - else if (k == 0xe1) // Handle Pause key - Paused = true; - else - { - if (k & 0x80) // Break code - { - k &= 0x7f; - -// DEBUG - handle special keys: ctl-alt-delete, print scrn - - Keyboard[k] = false; - } - else // Make code - { - LastCode = CurCode; - CurCode = LastScan = k; - Keyboard[k] = true; - - if (special) - c = SpecialNames[k]; - else - { - if (k == sc_CapsLock) - { - CapsLock ^= true; - // DEBUG - make caps lock light work - } - - if (Keyboard[sc_LShift] || Keyboard[sc_RShift]) // If shifted - { - c = ShiftNames[k]; - if ((c >= 'A') && (c <= 'Z') && CapsLock) - c += 'a' - 'A'; - } - else - { - c = ASCIINames[k]; - if ((c >= 'a') && (c <= 'z') && CapsLock) - c -= 'a' - 'A'; - } - } - if (c) - LastASCII = c; - } - - special = false; - } - - if (INL_KeyHook && !special) - INL_KeyHook(); - outportb(0x20,0x20); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetMouseDelta() - Gets the amount that the mouse has moved from the -// mouse driver -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_GetMouseDelta(int *x,int *y) -{ - Mouse(MDelta); - *x = _CX; - *y = _DX; -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetMouseButtons() - Gets the status of the mouse buttons from the -// mouse driver -// -/////////////////////////////////////////////////////////////////////////// -static word -INL_GetMouseButtons(void) -{ - word buttons; - - Mouse(MButtons); - buttons = _BX; - return(buttons); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_GetJoyAbs() - Reads the absolute position of the specified joystick -// -/////////////////////////////////////////////////////////////////////////// -void -IN_GetJoyAbs(word joy,word *xp,word *yp) -{ - byte xb,yb, - xs,ys; - word x,y; - - x = y = 0; - xs = joy? 2 : 0; // Find shift value for x axis - xb = 1 << xs; // Use shift value to get x bit mask - ys = joy? 3 : 1; // Do the same for y axis - yb = 1 << ys; - -// Read the absolute joystick values -asm pushf // Save some registers -asm push si -asm push di -asm cli // Make sure an interrupt doesn't screw the timings - - -asm mov dx,0x201 -asm in al,dx -asm out dx,al // Clear the resistors - -asm mov ah,[xb] // Get masks into registers -asm mov ch,[yb] - -asm xor si,si // Clear count registers -asm xor di,di -asm xor bh,bh // Clear high byte of bx for later - -asm push bp // Don't mess up stack frame -asm mov bp,MaxJoyValue - -loop: -asm in al,dx // Get bits indicating whether all are finished - -asm dec bp // Check bounding register -asm jz done // We have a silly value - abort - -asm mov bl,al // Duplicate the bits -asm and bl,ah // Mask off useless bits (in [xb]) -asm add si,bx // Possibly increment count register -asm mov cl,bl // Save for testing later - -asm mov bl,al -asm and bl,ch // [yb] -asm add di,bx - -asm add cl,bl -asm jnz loop // If both bits were 0, drop out - -done: -asm pop bp - -asm mov cl,[xs] // Get the number of bits to shift -asm shr si,cl // and shift the count that many times - -asm mov cl,[ys] -asm shr di,cl - -asm mov [x],si // Store the values into the variables -asm mov [y],di - -asm pop di -asm pop si -asm popf // Restore the registers - - *xp = x; - *yp = y; -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetJoyDelta() - Returns the relative movement of the specified -// joystick (from +/-127) -// -/////////////////////////////////////////////////////////////////////////// -void INL_GetJoyDelta(word joy,int *dx,int *dy) -{ - word x,y; - dword time; - JoystickDef *def; -static dword lasttime; - - IN_GetJoyAbs(joy,&x,&y); - def = JoyDefs + joy; - - if (x < def->threshMinX) - { - if (x < def->joyMinX) - x = def->joyMinX; - - x = -(x - def->threshMinX); - x *= def->joyMultXL; - x >>= JoyScaleShift; - *dx = (x > 127)? -127 : -x; - } - else if (x > def->threshMaxX) - { - if (x > def->joyMaxX) - x = def->joyMaxX; - - x = x - def->threshMaxX; - x *= def->joyMultXH; - x >>= JoyScaleShift; - *dx = (x > 127)? 127 : x; - } - else - *dx = 0; - - if (y < def->threshMinY) - { - if (y < def->joyMinY) - y = def->joyMinY; - - y = -(y - def->threshMinY); - y *= def->joyMultYL; - y >>= JoyScaleShift; - *dy = (y > 127)? -127 : -y; - } - else if (y > def->threshMaxY) - { - if (y > def->joyMaxY) - y = def->joyMaxY; - - y = y - def->threshMaxY; - y *= def->joyMultYH; - y >>= JoyScaleShift; - *dy = (y > 127)? 127 : y; - } - else - *dy = 0; - - lasttime = TimeCount; -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetJoyButtons() - Returns the button status of the specified -// joystick -// -/////////////////////////////////////////////////////////////////////////// -static word -INL_GetJoyButtons(word joy) -{ -register word result; - - result = inp(0x201); // Get all the joystick buttons - result >>= joy? 6 : 4; // Shift into bits 0-1 - result &= 3; // Mask off the useless bits - result ^= 3; - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_GetJoyButtonsDB() - Returns the de-bounced button status of the -// specified joystick -// -/////////////////////////////////////////////////////////////////////////// -word -IN_GetJoyButtonsDB(word joy) -{ - dword lasttime; - word result1,result2; - - do - { - result1 = INL_GetJoyButtons(joy); - lasttime = TimeCount; - while (TimeCount == lasttime) - ; - result2 = INL_GetJoyButtons(joy); - } while (result1 != result2); - return(result1); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_StartKbd() - Sets up my keyboard stuff for use -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_StartKbd(void) -{ - INL_KeyHook = NULL; // no key hook routine - - IN_ClearKeysDown(); - - OldKeyVect = getvect(KeyInt); - setvect(KeyInt,INL_KeyService); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_ShutKbd() - Restores keyboard control to the BIOS -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_ShutKbd(void) -{ - poke(0x40,0x17,peek(0x40,0x17) & 0xfaf0); // Clear ctrl/alt/shift flags - - setvect(KeyInt,OldKeyVect); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_StartMouse() - Detects and sets up the mouse -// -/////////////////////////////////////////////////////////////////////////// -static boolean -INL_StartMouse(void) -{ -#if 0 - if (getvect(MouseInt)) - { - Mouse(MReset); - if (_AX == 0xffff) - return(true); - } - return(false); -#endif - union REGS regs; - unsigned char far *vector; - - - if ((vector=MK_FP(peek(0,0x33*4+2),peek(0,0x33*4)))==NULL) - return false; - - if (*vector == 207) - return false; - - Mouse(MReset); - return true; -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_ShutMouse() - Cleans up after the mouse -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_ShutMouse(void) -{ -} - -// -// INL_SetJoyScale() - Sets up scaling values for the specified joystick -// -static void -INL_SetJoyScale(word joy) -{ - JoystickDef *def; - - def = &JoyDefs[joy]; - def->joyMultXL = JoyScaleMax / (def->threshMinX - def->joyMinX); - def->joyMultXH = JoyScaleMax / (def->joyMaxX - def->threshMaxX); - def->joyMultYL = JoyScaleMax / (def->threshMinY - def->joyMinY); - def->joyMultYH = JoyScaleMax / (def->joyMaxY - def->threshMaxY); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_SetupJoy() - Sets up thresholding values and calls INL_SetJoyScale() -// to set up scaling values -// -/////////////////////////////////////////////////////////////////////////// -void -IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy) -{ - word d,r; - JoystickDef *def; - - def = &JoyDefs[joy]; - - def->joyMinX = minx; - def->joyMaxX = maxx; - r = maxx - minx; - d = r / 3; - def->threshMinX = ((r / 2) - d) + minx; - def->threshMaxX = ((r / 2) + d) + minx; - - def->joyMinY = miny; - def->joyMaxY = maxy; - r = maxy - miny; - d = r / 3; - def->threshMinY = ((r / 2) - d) + miny; - def->threshMaxY = ((r / 2) + d) + miny; - - INL_SetJoyScale(joy); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_StartJoy() - Detects & auto-configures the specified joystick -// The auto-config assumes the joystick is centered -// -/////////////////////////////////////////////////////////////////////////// -static boolean -INL_StartJoy(word joy) -{ - word x,y; - - IN_GetJoyAbs(joy,&x,&y); - - if - ( - ((x == 0) || (x > MaxJoyValue - 10)) - || ((y == 0) || (y > MaxJoyValue - 10)) - ) - return(false); - else - { - IN_SetupJoy(joy,0,x * 2,0,y * 2); - return(true); - } -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_ShutJoy() - Cleans up the joystick stuff -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_ShutJoy(word joy) -{ - JoysPresent[joy] = false; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Startup() - Starts up the Input Mgr -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Startup(void) -{ - boolean checkjoys,checkmouse; - word i; - - if (IN_Started) - return; - - checkjoys = true; - checkmouse = true; - for (i = 1;i < _argc;i++) - { - switch (US_CheckParm(_argv[i],ParmStrings)) - { - case 0: - checkjoys = false; - break; - case 1: - checkmouse = false; - break; - } - } - - INL_StartKbd(); - MousePresent = checkmouse? INL_StartMouse() : false; - - for (i = 0;i < MaxJoys;i++) - JoysPresent[i] = checkjoys? INL_StartJoy(i) : false; - - IN_Started = true; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Default() - Sets up default conditions for the Input Mgr -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Default(boolean gotit,ControlType in) -{ - if - ( - (!gotit) - || ((in == ctrl_Joystick1) && !JoysPresent[0]) - || ((in == ctrl_Joystick2) && !JoysPresent[1]) - || ((in == ctrl_Mouse) && !MousePresent) - ) - in = ctrl_Keyboard1; - IN_SetControlType(0,in); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Shutdown() - Shuts down the Input Mgr -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Shutdown(void) -{ - word i; - - if (!IN_Started) - return; - - INL_ShutMouse(); - for (i = 0;i < MaxJoys;i++) - INL_ShutJoy(i); - INL_ShutKbd(); - - IN_Started = false; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_SetKeyHook() - Sets the routine that gets called by INL_KeyService() -// everytime a real make/break code gets hit -// -/////////////////////////////////////////////////////////////////////////// -void -IN_SetKeyHook(void (*hook)()) -{ - INL_KeyHook = hook; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_ClearKeysDown() - Clears the keyboard array -// -/////////////////////////////////////////////////////////////////////////// -void -IN_ClearKeysDown(void) -{ - int i; - - LastScan = sc_None; - LastASCII = key_None; - memset (Keyboard,0,sizeof(Keyboard)); -} - - -/////////////////////////////////////////////////////////////////////////// -// -// IN_ReadControl() - Reads the device associated with the specified -// player and fills in the control info struct -// -/////////////////////////////////////////////////////////////////////////// -void -IN_ReadControl(int player,CursorInfo *info) -{ - boolean realdelta; - byte dbyte; - word buttons; - int dx,dy; - Motion mx,my; - ControlType type; -register KeyboardDef *def; - - dx = dy = 0; - mx = my = motion_None; - buttons = 0; - - if (DemoMode == demo_Playback) - { - dbyte = DemoBuffer[DemoOffset + 1]; - my = (dbyte & 3) - 1; - mx = ((dbyte >> 2) & 3) - 1; - buttons = (dbyte >> 4) & 3; - - if (!(--DemoBuffer[DemoOffset])) - { - DemoOffset += 2; - if (DemoOffset >= DemoSize) - DemoMode = demo_PlayDone; - } - - realdelta = false; - } - else if (DemoMode == demo_PlayDone) - Quit("Demo playback exceeded"); - else - { - switch (type = Controls[player]) - { - case ctrl_Keyboard: - def = &KbdDefs; - - if (Keyboard[def->upleft]) - mx = motion_Left,my = motion_Up; - else if (Keyboard[def->upright]) - mx = motion_Right,my = motion_Up; - else if (Keyboard[def->downleft]) - mx = motion_Left,my = motion_Down; - else if (Keyboard[def->downright]) - mx = motion_Right,my = motion_Down; - - if (Keyboard[def->up]) - my = motion_Up; - else if (Keyboard[def->down]) - my = motion_Down; - - if (Keyboard[def->left]) - mx = motion_Left; - else if (Keyboard[def->right]) - mx = motion_Right; - - if (Keyboard[def->button0]) - buttons += 1 << 0; - if (Keyboard[def->button1]) - buttons += 1 << 1; - realdelta = false; - break; - case ctrl_Joystick1: - case ctrl_Joystick2: - INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy); - buttons = INL_GetJoyButtons(type - ctrl_Joystick); - realdelta = true; - break; - case ctrl_Mouse: - INL_GetMouseDelta(&dx,&dy); - buttons = INL_GetMouseButtons(); - realdelta = true; - break; - } - } - - if (realdelta) - { - mx = (dx < 0)? motion_Left : ((dx > 0)? motion_Right : motion_None); - my = (dy < 0)? motion_Up : ((dy > 0)? motion_Down : motion_None); - } - else - { - dx = mx * 127; - dy = my * 127; - } - - info->x = dx; - info->xaxis = mx; - info->y = dy; - info->yaxis = my; - info->button0 = buttons & (1 << 0); - info->button1 = buttons & (1 << 1); - info->button2 = buttons & (1 << 2); - info->button3 = buttons & (1 << 3); - info->dir = DirTable[((my + 1) * 3) + (mx + 1)]; - - if (DemoMode == demo_Record) - { - // Pack the control info into a byte - dbyte = (buttons << 4) | ((mx + 1) << 2) | (my + 1); - - if - ( - (DemoBuffer[DemoOffset + 1] == dbyte) - && (DemoBuffer[DemoOffset] < 255) - ) - (DemoBuffer[DemoOffset])++; - else - { - if (DemoOffset || DemoBuffer[DemoOffset]) - DemoOffset += 2; - - if (DemoOffset >= DemoSize) - Quit("Demo buffer overflow"); - - DemoBuffer[DemoOffset] = 1; - DemoBuffer[DemoOffset + 1] = dbyte; - } - } -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_SetControlType() - Sets the control type to be used by the specified -// player -// -/////////////////////////////////////////////////////////////////////////// -void -IN_SetControlType(int player,ControlType type) -{ - // DEBUG - check that requested type is present? - Controls[player] = type; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_WaitForKey() - Waits for a scan code, then clears LastScan and -// returns the scan code -// -/////////////////////////////////////////////////////////////////////////// -ScanCode -IN_WaitForKey(void) -{ - ScanCode result; - - while (!(result = LastScan)) - ; - LastScan = 0; - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_WaitForASCII() - Waits for an ASCII char, then clears LastASCII and -// returns the ASCII value -// -/////////////////////////////////////////////////////////////////////////// -char -IN_WaitForASCII(void) -{ - char result; - - while (!(result = LastASCII)) - ; - LastASCII = '\0'; - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Ack() - waits for a button or key press. If a button is down, upon -// calling, it must be released for it to be recognized -// -/////////////////////////////////////////////////////////////////////////// - -boolean btnstate[8]; - -void IN_StartAck(void) -{ - unsigned i,buttons; - -// -// get initial state of everything -// - IN_ClearKeysDown(); - memset (btnstate,0,sizeof(btnstate)); - - buttons = IN_JoyButtons () << 4; - if (MousePresent) - buttons |= IN_MouseButtons (); - - for (i=0;i<8;i++,buttons>>=1) - if (buttons&1) - btnstate[i] = true; -} - - -boolean IN_CheckAck (void) -{ - unsigned i,buttons; - -// -// see if something has been pressed -// - if (LastScan) - return true; - - buttons = IN_JoyButtons () << 4; - if (MousePresent) - buttons |= IN_MouseButtons (); - - for (i=0;i<8;i++,buttons>>=1) - if ( buttons&1 ) - { - if (!btnstate[i]) - return true; - } - else - btnstate[i]=false; - - return false; -} - - -void IN_Ack (void) -{ - IN_StartAck (); - - while (!IN_CheckAck ()) - ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// IN_UserInput() - Waits for the specified delay time (in ticks) or the -// user pressing a key or a mouse button. If the clear flag is set, it -// then either clears the key or waits for the user to let the mouse -// button up. -// -/////////////////////////////////////////////////////////////////////////// -boolean IN_UserInput(dword delay) -{ - dword lasttime; - - lasttime = TimeCount; - IN_StartAck (); - do - { - if (IN_CheckAck()) - return true; - } while (TimeCount - lasttime < delay); - return(false); -} - -//=========================================================================== - -/* -=================== -= -= IN_MouseButtons -= -=================== -*/ - -byte IN_MouseButtons (void) -{ - if (MousePresent) - { - Mouse(MButtons); - return _BX; - } - else - return 0; -} - - -/* -=================== -= -= IN_JoyButtons -= -=================== -*/ - -byte IN_JoyButtons (void) -{ - unsigned joybits; - - joybits = inp(0x201); // Get all the joystick buttons - joybits >>= 4; // only the high bits are useful - joybits ^= 15; // return with 1=pressed - - return joybits; -} - - diff --git a/src/lib/16_in__.h b/src/lib/16_in__.h deleted file mode 100755 index f493ce6e..00000000 --- a/src/lib/16_in__.h +++ /dev/null @@ -1,213 +0,0 @@ -// -// ID Engine -// ID_IN.h - Header file for Input Manager -// v1.0d1w -// By Jason Blochowiak -// Open Watcom port by sparky4 -// - -#ifndef __16_IN__ -#define __16_IN__ -#include "src/lib/16_head.h" - -#ifdef __DEBUG__ -#define __DEBUG_InputMgr__ -#endif - -#define MaxPlayers 4 -#define MaxKbds 2 -#define MaxJoys 2 -#define NumCodes 128 - -typedef byte ScanCode; -#define sc_None 0 -#define sc_Bad 0xff -#define sc_Return 0x1c -#define sc_Enter sc_Return -#define sc_Escape 0x01 -#define sc_Space 0x39 -#define sc_BackSpace 0x0e -#define sc_Tab 0x0f -#define sc_Alt 0x38 -#define sc_Control 0x1d -#define sc_CapsLock 0x3a -#define sc_LShift 0x2a -#define sc_RShift 0x36 -#define sc_UpArrow 0x48 -#define sc_DownArrow 0x50 -#define sc_LeftArrow 0x4b -#define sc_RightArrow 0x4d -#define sc_Insert 0x52 -#define sc_Delete 0x53 -#define sc_Home 0x47 -#define sc_End 0x4f -#define sc_PgUp 0x49 -#define sc_PgDn 0x51 -#define sc_F1 0x3b -#define sc_F2 0x3c -#define sc_F3 0x3d -#define sc_F4 0x3e -#define sc_F5 0x3f -#define sc_F6 0x40 -#define sc_F7 0x41 -#define sc_F8 0x42 -#define sc_F9 0x43 -#define sc_F10 0x44 -#define sc_F11 0x57 -#define sc_F12 0x59 - -#define sc_1 0x02 -#define sc_2 0x03 -#define sc_3 0x04 -#define sc_4 0x05 -#define sc_5 0x06 -#define sc_6 0x07 -#define sc_7 0x08 -#define sc_8 0x09 -#define sc_9 0x0a -#define sc_0 0x0b - -#define sc_A 0x1e -#define sc_B 0x30 -#define sc_C 0x2e -#define sc_D 0x20 -#define sc_E 0x12 -#define sc_F 0x21 -#define sc_G 0x22 -#define sc_H 0x23 -#define sc_I 0x17 -#define sc_J 0x24 -#define sc_K 0x25 -#define sc_L 0x26 -#define sc_M 0x32 -#define sc_N 0x31 -#define sc_O 0x18 -#define sc_P 0x19 -#define sc_Q 0x10 -#define sc_R 0x13 -#define sc_S 0x1f -#define sc_T 0x14 -#define sc_U 0x16 -#define sc_V 0x2f -#define sc_W 0x11 -#define sc_X 0x2d -#define sc_Y 0x15 -#define sc_Z 0x2c - -#define key_None 0 -#define key_Return 0x0d -#define key_Enter key_Return -#define key_Escape 0x1b -#define key_Space 0x20 -#define key_BackSpace 0x08 -#define key_Tab 0x09 -#define key_Delete 0x7f - -// Stuff for the mouse -#define MReset 0 -#define MButtons 3 -#define MDelta 11 - -#define MouseInt 0x33 -#define Mouse(x) _AX = x,geninterrupt(MouseInt) - -#ifdef DEMO0 -typedef enum { - demo_Off,demo_Record,demo_Playback,demo_PlayDone - } Demo; -#endif -//moved to 16_tdef.h -/*typedef enum { - //ctrl_None, // MDM (GAMERS EDGE) - added - ctrl_Keyboard, - ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2, - ctrl_Joystick, - ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2, - ctrl_Mouse, - } ControlType; -typedef enum { - motion_Left = -1,motion_Up = -1, - motion_None = 0, - motion_Right = 1,motion_Down = 1 - } Motion; -typedef enum { - dir_North,//dir_NorthEast, - dir_West,//dir_Nortinest, - dir_None, - dir_East,//,dir_SouthEast, - dir_South,//dir_Soutinest, - } Direction; -typedef struct { - boolean near button0,button1,button2,button3; - int near x,y; - Motion near xaxis,yaxis; - Direction near dir; - } CursorInfo; - -typedef struct { - ScanCode near button0,button1, - //upleft, - up, - down, - left, - right - //upright, - //downleft, - //,downright - ; - } KeyboardDef; -typedef struct { - word near joyMinX,joyMinY, - threshMinX,threshMinY, - threshMaxX,threshMaxY, - joyMaxX,joyMaxY, - joyMultXL,joyMultYL, - joyMultXH,joyMultYH; - } JoystickDef;*/ - -/* -============================================================================= - - GLOBAL VARIABLES - -============================================================================= -*/ -#ifdef DEMO0 - static Demo DemoMode = demo_Off; - static byte /*_seg*/ *DemoBuffer; - static word DemoOffset,DemoSize; -#endif - -// Function prototypes -#define IN_KeyDown(code) (Keyboard[(code)]) -#define IN_ClearKey(code) {Keyboard[code] = false;\ - if (code == LastScan) LastScan = sc_None;} - -// DEBUG - put names in prototypes -extern void IN_Startup(void),IN_Shutdown(void), - IN_Default(boolean gotit,ControlType in), - IN_SetKeyHook(void (*)()), - IN_ClearKeysDown(void), - IN_ReadCursor(CursorInfo *), - IN_ReadControl(int,CursorInfo *), - IN_SetControlType(int,ControlType), - IN_GetJoyAbs(word joy,word *xp,word *yp), - IN_SetupJoy(word joy,word minx,word maxx, - word miny,word maxy), - IN_StopDemo(void),IN_FreeDemoBuffer(void), - IN_Ack(void),IN_AckBack(void); -extern boolean IN_UserInput(dword 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 (void); -byte IN_JoyButtons (void); - -void INL_GetJoyDelta(word joy,int *dx,int *dy); -void IN_StartAck(void); -boolean IN_CheckAck (void); - -#endif diff --git a/src/lib/16_t.h b/src/lib/16_t.h index d04b382d..a42051a5 100755 --- a/src/lib/16_t.h +++ b/src/lib/16_t.h @@ -65,9 +65,24 @@ MK_FP(segment value, 0)*/ typedef void _seg * memptr; -#ifdef __WATCOMC__ +#ifdef __WATCOMC__ //functions found in borland c but not watcom c #define _argv __argv #define _argc __argc +#define geninterrupt(n) int86(n,&CPURegs,&CPURegs); + +#define peekb(segm,ofs) (*(byte far*)MK_FP((segm),(ofs))) +#define peek(segm,ofs) (*(word far*)MK_FP((segm),(ofs))) +#define pokeb(segm,ofs,value) (peekb((segm),(ofs)) = (byte)(value)) +#define poke(segm,ofs,value) (peek((segm),(ofs)) = (word)(value)) + +#define inportb(port) inp(port) +#define inport(port) inpw(port) +#define outportb(port, val) outp(port, val) +#define outport(port, val) outpw(port, val) + +//#define asm __asm +#define getvect _dos_getvect +#define setvect _dos_setvect //from http://www.verycomputer.com/3_65d875cc818b54ec_1.htm void clrscr(void); diff --git a/src/lib/16_tail.c b/src/lib/16_tail.c index 7b5fdcb4..557c4968 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(gvar); + IN_Startup(); #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(gvar); + IN_Shutdown(); #endif CA_Shutdown(gvar); MM_Shutdown(gvar); diff --git a/src/lib/16_tail.h b/src/lib/16_tail.h index 26b37fab..ecb3ba52 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,1); } \ + if(IN_KeyDown(88)){ panswitch=!panswitch; IN_UserInput(1); } \ TAIL_FUNCTIONKEYFUNCTIONS0EXE #define TAIL_FUNCTIONKEYFUNCTIONS0EXE \ - if(IN_KeyDown(sc_F4)){ turboXT(12); IN_UserInput(1,1); } \ - if(IN_KeyDown(87/*sc_F11*/)){ pagedelayrendermap=!pagedelayrendermap; IN_UserInput(1,1); } \ - if(IN_KeyDown(68/*sc_F10*/)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap; IN_UserInput(1,1); } \ - if(IN_KeyDown(sc_F9)){ pagenorendermap=!pagenorendermap; IN_UserInput(1,1); } \ - if(IN_KeyDown(sc_F8)){ gvar.video.bgps=!gvar.video.bgps; IN_UserInput(1,1); } \ - if(IN_KeyDown(sc_F7)){ ZC_ShowMV(&mv, 0, 1); IN_UserInput(1,1); } \ - if(IN_KeyDown(sc_F6)){ ZC_ShowMV(&mv, 0, 0); IN_UserInput(1,1); } \ - if(IN_KeyDown(sc_T)){ gvar.video.rss=!gvar.video.rss; IN_UserInput(1,1); } \ - if(IN_KeyDown(sc_P)){ modexpdump(&gvar.video.page[0]); IN_UserInput(1,1); } + 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(&mv, 0, 1); IN_UserInput(1); } \ + if(IN_KeyDown(sc_F6)){ ZC_ShowMV(&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); } #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,1); } + if(IN_KeyDown(sc_I)){ dbg_maptext=!dbg_maptext; IN_UserInput(1); } /* 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,1); } \ + VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1); } \ 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,1); }*/ + VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1); }*/ void DebugMemory_(global_game_variables_t *gvar, boolean q); void Shutdown16(global_game_variables_t *gvar); diff --git a/src/scroll.c b/src/scroll.c index 7fb6f755..228c1a89 100755 --- a/src/scroll.c +++ b/src/scroll.c @@ -68,7 +68,7 @@ void main(int argc, char *argv[]) #endif /* input! */ - IN_Default(0, &gvar.gvar.player,ctrl_Keyboard1); + IN_Default(0, &gvar.gvar.player[0],ctrl_Keyboard1); /* save the palette */ #ifdef MODEX @@ -191,14 +191,14 @@ void main(int argc, char *argv[]) //debugging binds! #ifdef MODEX #ifdef FADE - if(IN_KeyDown(24)){ modexPalUpdate0(&gvar.video.palette); paloffset=0; modexpdump(mv[0].page); modexpdump(mv[1].page); IN_UserInput(1,1); } //p + if(IN_KeyDown(24)){ modexPalUpdate0(&gvar.video.palette); paloffset=0; modexpdump(mv[0].page); modexpdump(mv[1].page); IN_UserInput(1); } //p /*if(IN_KeyDown(22)){ paloffset=0; modexPalBlack(); modexPalUpdate(PCXBMPVAR, &paloffset, 0, 0); printf("1paloffset = %d\n", paloffset/3); modexPalUpdate(map.tiles->data, &paloffset, 0, 0); printf("2paloffset = %d\n", paloffset/3); modexpdump(mv[0].page); modexpdump(mv[1].page); - IN_UserInput(1,1); + IN_UserInput(1); }*/ #endif #endif @@ -209,7 +209,7 @@ void main(int argc, char *argv[]) modexClearRegion(mv[2].page, 0, 0, mv[2].page->width, mv[2].page->height, 3); modexClearRegion(mv[3].page, 0, 0, mv[3].page->width, mv[3].page->height, 4); modexClearRegion(mv[3].page, 0, 0, 20, 36, 15); - //IN_UserInput(1,1); + //IN_UserInput(1); } FUNCTIONKEYFUNCTIONS @@ -218,7 +218,7 @@ void main(int argc, char *argv[]) //9 #ifdef FADE - if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(gvar.video.dpal); IN_UserInput(1,1); } + if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(gvar.video.dpal); IN_UserInput(1); } #endif if(IN_KeyDown(sc_R)){ modexPalOverscan(rand()%56); } //r diff --git a/src/test.c b/src/test.c index acd6886a..37116b28 100755 --- a/src/test.c +++ b/src/test.c @@ -87,7 +87,7 @@ void main(int argc, char *argv[]) //====modexPalBlack(); //IN_Startup(); - IN_Default(0,&gvar.player,ctrl_Keyboard1); + IN_Default(0,&gvar.player[0],ctrl_Keyboard1); EN_initPlayer(&gvar.player, 0, &gvar.video); VGAmodeX(1, 1, &gvar); @@ -140,7 +140,7 @@ void main(int argc, char *argv[]) startclk = *clockw; while(!IN_KeyDown(sc_Escape)) { - IN_ReadControl(0,&gvar.player); + IN_ReadControl(&gvar.player[0]); ZC_panPageManual(&mv, &gvar.player, 0); //[gvar.video.sp] //ZC_MVSync(&mv); @@ -201,7 +201,7 @@ 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,1); }//p + if(IN_KeyDown(25)){ modexpdump(&gvar.video.page[gvar.video.sp]); IN_UserInput(1); }//p //VL_ShowPage(&gvar.video.page[gvar.video.sp], 0, 0); ZC_ShowMV(&mv, 0, 0); } diff --git a/git_con.fig b/src/util/git/git_con.fig similarity index 100% rename from git_con.fig rename to src/util/git/git_con.fig diff --git a/git_igno.re b/src/util/git/git_igno.re similarity index 89% rename from git_igno.re rename to src/util/git/git_igno.re index 15ee4357..70ed7d75 100755 --- a/git_igno.re +++ b/src/util/git/git_igno.re @@ -17,8 +17,8 @@ makefile~ README~ TODO~ LICENCE~ -*.mah -*.MAH +*.meh +*.MEH __wcl__.lnk !bcexmm.map !makefile diff --git a/git_modu.les b/src/util/git/git_modu.les similarity index 100% rename from git_modu.les rename to src/util/git/git_modu.les diff --git a/src/util/gitgit_con.fig b/src/util/gitgit_con.fig new file mode 100755 index 00000000..f07fc6d5 --- /dev/null +++ b/src/util/gitgit_con.fig @@ -0,0 +1,23 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true +[remote "x4"] + url = ssh://sparky4@4ch.mooo.com:26/var/www/16/16.git + fetch = +refs/heads/*:refs/remotes/x4/* +[branch "master"] + remote = origin + merge = refs/heads/master +[remote "origin"] + url = git@github.com:sparky4/16.git + fetch = +refs/heads/*:refs/remotes/origin/* +[remote "sf"] + url = ssh://sparky4q@git.code.sf.net/p/project16/code + fetch = +refs/heads/*:refs/remotes/sf/* +[remote "jp"] + url = ssh://sparky4@git.osdn.jp:/gitroot/proj16/16.git + fetch = +refs/heads/*:refs/remotes/jp/* +[remote "bb"] + url = git@bitbucket.org:sparky4/16.git + fetch = +refs/heads/*:refs/remotes/bb/* diff --git a/src/util/gitgit_igno.re b/src/util/gitgit_igno.re new file mode 100755 index 00000000..70ed7d75 --- /dev/null +++ b/src/util/gitgit_igno.re @@ -0,0 +1,32 @@ +# Lines starting with '#' are considered comments. +# Ignore (generated) html files, +*.html +*.htm +!proj16.bfproject +*.obj +*.OBJ +*.[O] +*.BCO +*.*~ +FUCK +*.err +*.ERR +*.lib +*.LIB +makefile~ +README~ +TODO~ +LICENCE~ +*.meh +*.MEH +__wcl__.lnk +!bcexmm.map +!makefile +!modex.lib +img +!.git/config +!.gitmodules +# except foo.html which is maintained by hand. +#!foo.html +# Ignore objects and archives. +*.[oa] diff --git a/src/util/gitgit_modu.les b/src/util/gitgit_modu.les new file mode 100755 index 00000000..11d69bb6 --- /dev/null +++ b/src/util/gitgit_modu.les @@ -0,0 +1,23 @@ +[submodule "src/lib/doslib"] + path = src/lib/doslib + url = https://github.com/joncampbell123/doslib.git + +[submodule "src/lib/jsmn"] + path = src/lib/jsmn + url = https://github.com/zserge/jsmn.git + +[submodule "CatacombApocalypse"] + path = 16/CatacombApocalypse + url = https://github.com/FlatRockSoft/CatacombApocalypse.git + +[submodule "wolf3d"] + path = 16/wolf3d + url = https://github.com/id-Software/wolf3d.git + +[submodule "keen"] + path = 16/keen + url = https://github.com/keendreams/keen.git + +[submodule "Catacomb3D"] + path = 16/Catacomb3D + url = https://github.com/FlatRockSoft/Catacomb3D.git diff --git a/src/vgmtest.c b/src/vgmtest.c index f20327eb..b2b1b040 100755 --- a/src/vgmtest.c +++ b/src/vgmtest.c @@ -56,7 +56,7 @@ main(int argc, char *argv[]) if(argv[1]) bakapee = argv[1]; else bakapee = "data/adlib.vgm"; printf("%x\n", OpenVGMFile(bakapee, &pee[0])); -// IN_Startup(); IN_Default(0,&gvar.player,ctrl_Keyboard1); +// IN_Startup(); IN_Default(0,&gvar.player[0],ctrl_Keyboard1); InitEngine(); PlayMusic(&pee[0]); // while(!IN_KeyDown(sc_Escape)) diff --git a/src/vrstest.c b/src/vrstest.c index 4ca83465..9e3a9ae1 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,1); } - if(IN_KeyDown(sc_F6)){ VL_ShowPage(&gvar.video.page[0], 1, 0); IN_UserInput(1,1); } - if(IN_KeyDown(25)){ modexpdump(&gvar.video.page[0]); IN_UserInput(1,1); } //p + 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 } VGAmodeX(0, 1, &gvar); MM_ShowMemory(&gvar); diff --git a/src/zcroll.c b/src/zcroll.c index 4f78be47..3cc838dc 100755 --- a/src/zcroll.c +++ b/src/zcroll.c @@ -88,7 +88,7 @@ void main(int argc, char *argv[]) VRS_LoadVRS(bakapee1, &gvar.player[0].enti, &gvar); // input! - IN_Default(0, &gvar.player,ctrl_Keyboard1); + IN_Default(0, &gvar.player[0],ctrl_Keyboard1); // save the palette #ifdef FADE @@ -156,7 +156,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(0, &gvar.player); + IN_ReadControl(&gvar.player[0]); if(!panswitch){ //ZC_walk2(gvar.player[0].ent, mv); ZC_walk(&mv, &gvar.player, 0); @@ -179,7 +179,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(mv[0].page); IN_UserInput(1,1); } //o + if(IN_KeyDown(24)){ modexPalUpdate0(&gvar.video.palette); /*paloffset=0;*/ modexpdump(mv[0].page); IN_UserInput(1); } //o if(IN_KeyDown(22)){ modexPalUpdate0(&gvar.video.palette); } //u TAIL_FUNCTIONKEYFUNCTIONS @@ -204,7 +204,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,1); } + if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(gvar.video.dpal); IN_UserInput(1); } #endif if(IN_KeyDown(sc_R)){ modexPalOverscan(rand()%56); } //r