From: sparky4 Date: Fri, 10 Mar 2017 20:00:18 +0000 (-0600) 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/?a=commitdiff_plain;h=cbd1a853acf0cd2feb3cf359b98d80694dec7ca9;p=16.git __seguse.txt added to show _seg usage also OpenVGMFile needs to be ported to 16_snd.c ][ ca needs huge amounts of work and i should remember what needs to be done soon also i should reverify 16_in.c to make sure it can work with other code of id engine ][ added 1.9 support wwww and fixed 16_vlpal.obj compile error\~ [it was a 8.3 file name extention error it was a simple issue wwww] [going to work on more on 16_in.c] --- diff --git a/DEBUG.16B b/DEBUG.16B index f476aef7..47d8a9f4 100755 --- a/DEBUG.16B +++ b/DEBUG.16B @@ -1,210 +1,210 @@ -Seg:0 Size:5515 Owner:0x0 -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0 -Seg:158b Size:256 Owner:0x2e15 -+++++ -Seg:168b Size:256 Owner:0x2c18 +Seg:0 Size:4884 Owner:0x0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0 +Seg:1314 Size:256 Owner:0x2e31 +++++ +Seg:1414 Size:256 Owner:0x2c34 ++++ -Seg:178b Size:256 Owner:0x2c1a +Seg:1514 Size:256 Owner:0x2c36 ++++ -Seg:188b Size:256 Owner:0x2c1c +Seg:1614 Size:256 Owner:0x2c38 ++++ -Seg:198b Size:256 Owner:0x2c1e -++++ -Seg:1a8b Size:256 Owner:0x2c20 +Seg:1714 Size:256 Owner:0x2c3a +++++ -Seg:1b8b Size:256 Owner:0x2c22 +Seg:1814 Size:256 Owner:0x2c3c ++++ -Seg:1c8b Size:256 Owner:0x2c24 +Seg:1914 Size:256 Owner:0x2c3e ++++ -Seg:1d8b Size:256 Owner:0x2c26 +Seg:1a14 Size:256 Owner:0x2c40 ++++ -Seg:1e9e Size:34 Owner:0x0 -++ -Seg:1ec0 Size:256 Owner:0x2c28 +Seg:1b14 Size:256 Owner:0x2c42 ++++ -Seg:1fc0 Size:256 Owner:0x2c2a +Seg:1c14 Size:256 Owner:0x2c44 ++++++ +Seg:1d14 Size:256 Owner:0x2c46 ++++ -Seg:20c0 Size:256 Owner:0x2c2c +Seg:1e14 Size:256 Owner:0x2c48 ++++ -Seg:21c0 Size:256 Owner:0x2c2e +Seg:1fde Size:34 Owner:0x0 +++ +Seg:2000 Size:256 Owner:0x2c4a ++++ -Seg:22c0 Size:256 Owner:0x2c30 +Seg:2100 Size:256 Owner:0x2c4c ++++ -Seg:23c0 Size:256 Owner:0x2c32 +Seg:2200 Size:256 Owner:0x2c4e ++++ -Seg:24c0 Size:256 Owner:0x2c34 +Seg:2300 Size:256 Owner:0x2c50 ++++ -Seg:25c0 Size:256 Owner:0x2c36 +Seg:2400 Size:256 Owner:0x2c52 ++++ -Seg:26c0 Size:256 Owner:0x2c38 +Seg:2500 Size:256 Owner:0x2c54 ++++ -Seg:27c0 Size:256 Owner:0x2c3a +Seg:2600 Size:256 Owner:0x2c56 ++++ -Seg:28c0 Size:256 Owner:0x2c3c +Seg:2700 Size:256 Owner:0x2c58 ++++ -Seg:29c0 Size:256 Owner:0x2c3e +Seg:2800 Size:256 Owner:0x2c5a ++++ -Seg:2ac0 Size:256 Owner:0x2c40 +Seg:2900 Size:256 Owner:0x2c5c ++++ -Seg:2bc0 Size:256 Owner:0x2c42 +Seg:2a00 Size:256 Owner:0x2c5e ++++ -Seg:2cc0 Size:256 Owner:0x2c44 +Seg:2b00 Size:256 Owner:0x2c60 ++++ -Seg:2dc0 Size:256 Owner:0x2c46 +Seg:2c00 Size:256 Owner:0x2c62 ++++ -Seg:2ec0 Size:256 Owner:0x2c48 +Seg:2d00 Size:256 Owner:0x2c64 ++++ -Seg:2fc0 Size:256 Owner:0x2c4a +Seg:2e00 Size:256 Owner:0x2c66 ++++ -Seg:30c0 Size:256 Owner:0x2c4c +Seg:2f00 Size:256 Owner:0x2c68 ++++ -Seg:31c0 Size:256 Owner:0x2c4e +Seg:3000 Size:256 Owner:0x2c6a ++++ -Seg:32c0 Size:256 Owner:0x2c50 +Seg:3100 Size:256 Owner:0x2c6c ++++ -Seg:33c0 Size:256 Owner:0x2c52 +Seg:3200 Size:256 Owner:0x2c6e ++++ -Seg:34c0 Size:256 Owner:0x2c54 +Seg:3300 Size:256 Owner:0x2c70 ++++ -Seg:35c0 Size:256 Owner:0x2c56 +Seg:3400 Size:256 Owner:0x2c72 ++++ -Seg:36c0 Size:256 Owner:0x2c58 +Seg:3500 Size:256 Owner:0x2c74 ++++ -Seg:37c0 Size:256 Owner:0x2c5a +Seg:3600 Size:256 Owner:0x2c76 ++++ -Seg:38c0 Size:256 Owner:0x2c5c +Seg:3700 Size:256 Owner:0x2c78 ++++ -Seg:39c0 Size:256 Owner:0x2c5e +Seg:3800 Size:256 Owner:0x2c7a ++++ -Seg:3ac0 Size:256 Owner:0x2c60 +Seg:3900 Size:256 Owner:0x2c7c ++++ -Seg:3bc0 Size:256 Owner:0x2c62 +Seg:3a00 Size:256 Owner:0x2c7e ++++ -Seg:3cc0 Size:256 Owner:0x2c64 +Seg:3b00 Size:256 Owner:0x2c80 ++++ -Seg:3dc0 Size:256 Owner:0x2c66 +Seg:3c00 Size:256 Owner:0x2c82 ++++ -Seg:3ec0 Size:256 Owner:0x2c68 +Seg:3d00 Size:256 Owner:0x2c84 ++++ -Seg:3fc0 Size:256 Owner:0x2c6a +Seg:3e00 Size:256 Owner:0x2c86 ++++ -Seg:40c0 Size:256 Owner:0x2c6c +Seg:3f00 Size:256 Owner:0x2c88 ++++ -Seg:41c0 Size:256 Owner:0x2c6e +Seg:4000 Size:256 Owner:0x2c8a ++++ -Seg:42c0 Size:256 Owner:0x2c70 +Seg:4100 Size:256 Owner:0x2c8c ++++ -Seg:43c0 Size:256 Owner:0x2c72 +Seg:4200 Size:256 Owner:0x2c8e ++++ -Seg:44c0 Size:256 Owner:0x2c74 +Seg:4300 Size:256 Owner:0x2c90 ++++ -Seg:45c0 Size:256 Owner:0x2c76 +Seg:4400 Size:256 Owner:0x2c92 ++++ -Seg:46c0 Size:256 Owner:0x2c78 +Seg:4500 Size:256 Owner:0x2c94 ++++ -Seg:47c0 Size:256 Owner:0x2c7a +Seg:4600 Size:256 Owner:0x2c96 ++++ -Seg:48c0 Size:256 Owner:0x2c7c +Seg:4700 Size:256 Owner:0x2c98 ++++ -Seg:49c0 Size:256 Owner:0x2c7e +Seg:4800 Size:256 Owner:0x2c9a ++++ -Seg:4ac0 Size:256 Owner:0x2c80 +Seg:4900 Size:256 Owner:0x2c9c ++++ -Seg:4bc0 Size:256 Owner:0x2c82 +Seg:4a00 Size:256 Owner:0x2c9e ++++ -Seg:4cc0 Size:256 Owner:0x2c84 +Seg:4b00 Size:256 Owner:0x2ca0 ++++ -Seg:4dc0 Size:256 Owner:0x2c86 +Seg:4c00 Size:256 Owner:0x2ca2 ++++ -Seg:4ec0 Size:256 Owner:0x2c88 +Seg:4d00 Size:256 Owner:0x2ca4 ++++ -Seg:4fc0 Size:256 Owner:0x2c8a +Seg:4e00 Size:256 Owner:0x2ca6 ++++ -Seg:50c0 Size:256 Owner:0x2c8c +Seg:4f00 Size:256 Owner:0x2ca8 ++++ -Seg:51c0 Size:256 Owner:0x2c8e +Seg:5000 Size:256 Owner:0x2caa ++++ -Seg:52c0 Size:256 Owner:0x2c90 +Seg:5100 Size:256 Owner:0x2cac ++++ -Seg:53c0 Size:256 Owner:0x2c92 +Seg:5200 Size:256 Owner:0x2cae ++++ -Seg:54c0 Size:256 Owner:0x2c94 +Seg:5300 Size:256 Owner:0x2cb0 ++++ -Seg:55c0 Size:256 Owner:0x2c96 +Seg:5400 Size:256 Owner:0x2cb2 ++++ -Seg:56c0 Size:256 Owner:0x2c98 +Seg:5500 Size:256 Owner:0x2cb4 ++++ -Seg:57c0 Size:256 Owner:0x2c9a +Seg:5600 Size:256 Owner:0x2cb6 ++++ -Seg:58c0 Size:256 Owner:0x2c9c +Seg:5700 Size:256 Owner:0x2cb8 ++++ -Seg:59c0 Size:256 Owner:0x2c9e +Seg:5800 Size:256 Owner:0x2cba ++++ -Seg:5ac0 Size:256 Owner:0x2ca0 +Seg:5900 Size:256 Owner:0x2cbc ++++ -Seg:5bc0 Size:256 Owner:0x2ca2 +Seg:5a00 Size:256 Owner:0x2cbe ++++ -Seg:5cc0 Size:256 Owner:0x2ca4 +Seg:5b00 Size:256 Owner:0x2cc0 ++++ -Seg:5dc0 Size:256 Owner:0x2ca6 +Seg:5c00 Size:256 Owner:0x2cc2 ++++ -Seg:5ec0 Size:256 Owner:0x2ca8 +Seg:5d00 Size:256 Owner:0x2cc4 ++++ -Seg:5fc0 Size:256 Owner:0x2caa +Seg:5e00 Size:256 Owner:0x2cc6 ++++ -Seg:60c0 Size:256 Owner:0x2cac +Seg:5f00 Size:256 Owner:0x2cc8 ++++ -Seg:61c0 Size:256 Owner:0x2cae +Seg:6000 Size:256 Owner:0x2cca ++++ -Seg:62c0 Size:256 Owner:0x2cb0 +Seg:6100 Size:256 Owner:0x2ccc ++++ -Seg:63c0 Size:256 Owner:0x2cb2 +Seg:6200 Size:256 Owner:0x2cce ++++ -Seg:64c0 Size:256 Owner:0x2cb4 +Seg:6300 Size:256 Owner:0x2cd0 ++++ -Seg:65c0 Size:256 Owner:0x2cb6 +Seg:6400 Size:256 Owner:0x2cd2 ++++ -Seg:66c0 Size:256 Owner:0x2cb8 +Seg:6500 Size:256 Owner:0x2cd4 ++++ -Seg:67c0 Size:256 Owner:0x2cba +Seg:6600 Size:256 Owner:0x2cd6 ++++ -Seg:68c0 Size:256 Owner:0x2cbc +Seg:6700 Size:256 Owner:0x2cd8 ++++ -Seg:69c0 Size:256 Owner:0x2cbe +Seg:6800 Size:256 Owner:0x2cda ++++ -Seg:6ac0 Size:256 Owner:0x2cc0 +Seg:6900 Size:256 Owner:0x2cdc ++++ -Seg:6bc0 Size:256 Owner:0x2cc2 +Seg:6a00 Size:256 Owner:0x2cde ++++ -Seg:6cc0 Size:256 Owner:0x2cc4 +Seg:6b00 Size:256 Owner:0x2ce0 ++++ -Seg:6dc0 Size:256 Owner:0x2cc6 +Seg:6c00 Size:256 Owner:0x2ce2 ++++ -Seg:6ec0 Size:256 Owner:0x2cc8 +Seg:6d00 Size:256 Owner:0x2ce4 ++++ -Seg:6fc0 Size:256 Owner:0x2cca +Seg:6e00 Size:256 Owner:0x2ce6 ++++ -Seg:70c0 Size:256 Owner:0x2ccc +Seg:6f00 Size:256 Owner:0x2ce8 ++++ -Seg:71c0 Size:256 Owner:0x2cce +Seg:7000 Size:256 Owner:0x2cea ++++ -Seg:72c0 Size:256 Owner:0x2cd0 +Seg:7100 Size:256 Owner:0x2cec ++++ -Seg:73c0 Size:256 Owner:0x2cd2 +Seg:7200 Size:256 Owner:0x2cee ++++ -Seg:74c0 Size:256 Owner:0x2cd4 +Seg:7300 Size:256 Owner:0x2cf0 ++++ -Seg:75c0 Size:256 Owner:0x2cd6 +Seg:7400 Size:256 Owner:0x2cf2 ++++ -Seg:76c0 Size:256 Owner:0x2cd8 +Seg:7500 Size:256 Owner:0x2cf4 ++++ -Seg:77c0 Size:256 Owner:0x2cda +Seg:7600 Size:256 Owner:0x2cf6 ++++ -Seg:78c0 Size:256 Owner:0x2cdc +Seg:7700 Size:256 Owner:0x2cf8 ++++ -Seg:79c0 Size:256 Owner:0x2cde +Seg:7800 Size:256 Owner:0x2cfa ++++ -Seg:7ac0 Size:273 Owner:0x2bee -+++++ -Seg:9dff Size:25088 Owner:0x0 -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file +Seg:7900 Size:273 Owner:0x2c0a +++++ +Seg:9f3f Size:24768 Owner:0x0 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/MEMINFO.16W b/MEMINFO.16W new file mode 100755 index 00000000..e69de29b diff --git a/MMDUMP.16B b/MMDUMP.16B index fe3f37d8..5053477b 100755 Binary files a/MMDUMP.16B and b/MMDUMP.16B differ diff --git a/bcexmm.dsk b/bcexmm.dsk index 3f30f2e8..a2a7f77f 100755 Binary files a/bcexmm.dsk and b/bcexmm.dsk differ diff --git a/bcexmm.exe b/bcexmm.exe index 00dd4fbe..cf74b444 100755 Binary files a/bcexmm.exe and b/bcexmm.exe differ diff --git a/bcexmm.prj b/bcexmm.prj index 7ec1ecda..30807dcc 100755 Binary files a/bcexmm.prj and b/bcexmm.prj differ diff --git a/db.exe b/db.exe index 587c001b..457a9fa1 100755 Binary files a/db.exe and b/db.exe differ diff --git a/makefile b/makefile index 58f4ec18..34621533 100755 --- a/makefile +++ b/makefile @@ -125,8 +125,8 @@ 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) 16_enti.$(OBJ) -16LIBOBJS = $(16LIBNOINOBJS) 16_in.$(OBJ) +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) DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) !ifeq DEBUGSERIAL 1 DOSLIBOBJ += 8250.$(OBJ) @@ -243,7 +243,7 @@ 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) $(DOSLIB) $(16LIBNOINOBJS) 16_in_.$(OBJ) +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) @@ -339,7 +339,7 @@ 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_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 diff --git a/src/0.c b/src/0.c index ba9ced80..d3c6ba50 100755 --- a/src/0.c +++ b/src/0.c @@ -102,7 +102,7 @@ int main(int argc,char **argv) vrl_lineoffs = vrl1_vgax_genlineoffsets(vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); if (vrl_lineoffs == NULL) return 1; - IN_Startup(); + IN_Startup(&gvar); IN_Default(0,&gvar.player,ctrl_Keyboard1); EN_initPlayer(&gvar.player, 0, &gvar.video); @@ -302,7 +302,7 @@ if(!noanim) { } } } - IN_Shutdown(); + IN_Shutdown(&gvar); VGAmodeX(0, 1, &gvar); free(vrl_lineoffs); buffer = NULL; diff --git a/src/inntest.c b/src/inntest.c index 1ba8b227..3742f87f 100755 --- a/src/inntest.c +++ b/src/inntest.c @@ -22,8 +22,12 @@ /* input test */ -#include "src/lib/16_in.h" -#include "src/lib/16_tail.h" +#include "src/lib/16_in_.h" + +void probe_dos(){} +void cpu_probe(){} +int probe_vga(){ return 0; } +void VGAmodeX(){} void main(int argc, char *argv[]) @@ -34,23 +38,23 @@ main(int argc, char *argv[]) dbg_testcontrolnoisy=1; start_timer(&gvar); //Startup16(&gvar); - IN_Startup(); + IN_Startup(&gvar); //IN_Default(0,&gvar.player,ctrl_Joystick1); //IN_SetControlType(0,&gvar.player,ctrl_Joystick1); - IN_Default(0,&gvar.player,ctrl_Keyboard1); + IN_Default(0,&gvar.player,ctrl_Keyboard1, &gvar); IN_SetControlType(0,&gvar.player,ctrl_Keyboard1); gvar.player[0].enti.q=1; gvar.player[0].enti.d=2; gvar.player[0].enti.speed=4; -//0000 nibbletest(); -//0000 booleantest(); +//0000 nibbletest(){} +//0000 booleantest(){} //printf("dbg_testkeyin=%u dbg_testcontrolnoisy=%u dbg_nogvar.playerinpu=%u\nloop if this is not responsive then please KILL or reset machine sorry!!\n", dbg_testkeyin, dbg_testcontrolnoisy, dbg_nogvar.playerinpu); - while(!IN_KeyDown(sc_Escape)) + while(!IN_KeyDown(sc_Escape, &gvar)) { //0000 shinkutxt(&gvar); - IN_ReadControl(0, &gvar.player); + IN_ReadControl(0, &gvar.player, &gvar); switch(gvar.player[0].enti.d) { //right movement @@ -87,8 +91,8 @@ main(int argc, char *argv[]) } //printf("%u\n", IN_KeyDown(sc_Escape)); //if( - IN_qb(sc_9);//>0) printf("IN_qb(sc_9)=%u\n", IN_qb(sc_9)); - if(IN_KeyDown(88)) //speed + IN_qb(sc_9, &gvar);//>0) printf("IN_qb(sc_9)=%u\n", IN_qb(sc_9)); + if(IN_KeyDown(88, &gvar)) //speed { switch(gvar.kurokku.fpscap) { @@ -99,10 +103,10 @@ main(int argc, char *argv[]) gvar.kurokku.fpscap=0; break; } - //IN_Ack(); + //IN_Ack(){} } } - IN_Shutdown(); + IN_Shutdown(&gvar); //Shutdown16(&gvar); //printf("%u\n", in.Keyboard[sc_Escape]); printf("inputest.exe "); diff --git a/src/inputest.c b/src/inputest.c index 1ba8b227..6481ad7b 100755 --- a/src/inputest.c +++ b/src/inputest.c @@ -34,7 +34,7 @@ main(int argc, char *argv[]) dbg_testcontrolnoisy=1; start_timer(&gvar); //Startup16(&gvar); - IN_Startup(); + IN_Startup(&gvar); //IN_Default(0,&gvar.player,ctrl_Joystick1); //IN_SetControlType(0,&gvar.player,ctrl_Joystick1); IN_Default(0,&gvar.player,ctrl_Keyboard1); @@ -102,7 +102,7 @@ main(int argc, char *argv[]) //IN_Ack(); } } - IN_Shutdown(); + IN_Shutdown(&gvar); //Shutdown16(&gvar); //printf("%u\n", in.Keyboard[sc_Escape]); printf("inputest.exe "); diff --git a/src/lib/16_in.c b/src/lib/16_in.c index a2b28046..c2550ec7 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -61,7 +61,6 @@ struct inconfig JoystickDef JoyDefs[MaxJoys]; } inpu; -//extern inconfig inpu; //inpu.KbdDefs = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/}; /* @@ -150,15 +149,9 @@ static byte far ASCIINames[] = // Unshifted ASCII for scan codes static Direction DirTable[] = // Quick lookup for total direction { - //dir_Nortinest, - dir_North, - dir_West, - dir_None, - dir_East, - dir_South - //dir_NorthEast, - //dir_Soutinest, - //,dir_SouthEast + /*dir_NorthWest, */dir_North,/* dir_NorthEast,*/ + dir_West, dir_None, dir_East, + /*dir_SouthWest, */dir_South/*, dir_SouthEast*/ }; #ifdef __cplusplus } @@ -175,8 +168,8 @@ void interrupt INL_KeyService() { static boolean special; - byte k,c; - register byte temp; + byte k,c, + temp; k = inp(0x60); // Get the scan code diff --git a/src/lib/16_in.h b/src/lib/16_in.h index 4c039165..86980fe8 100755 --- a/src/lib/16_in.h +++ b/src/lib/16_in.h @@ -218,48 +218,48 @@ typedef struct { #endif // Internal routines -extern void interrupt INL_KeyService(); -extern void Mouse(int x); +void interrupt INL_KeyService(); +void Mouse(int x); //static void INL_GetMouseDelta(int *x,int *y); //static word INL_GetMouseButtons(void); -extern void IN_GetJoyAbs(word joy,word *xp,word *yp); +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); -extern word IN_GetJoyButtonsDB(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); -extern void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy); +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); -extern void IN_Startup(); -extern void IN_Default(boolean gotit,player_t *player,ControlType nt); -extern void IN_Shutdown(); -extern void IN_SetKeyHook(void (*hook)()); -extern void IN_ClearKeysDown(); +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); -extern void IN_ReadCursor(CursorInfo *info); -extern void near IN_ReadControl(word pn, player_t *player); -extern void IN_SetControlType(word pn,player_t *player,ControlType type); +void IN_ReadCursor(CursorInfo *info); +void near IN_ReadControl(word pn, player_t *player); +void IN_SetControlType(word pn,player_t *player,ControlType type); #if DEMO0 -extern boolean IN_StartDemoRecord(word bufsize); -extern void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize); -extern void IN_StopDemo(void); -extern void IN_FreeDemoBuffer(void); +boolean IN_StartDemoRecord(word bufsize); +void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize); +void IN_StopDemo(void); +void IN_FreeDemoBuffer(void); #endif -extern byte *IN_GetScanName(ScanCode scan); -extern ScanCode IN_WaitForKey(); -extern char IN_WaitForASCII(); -extern void IN_AckBack(); -extern void IN_Ack(); -extern boolean IN_IsUserInput(); -extern boolean IN_UserInput(dword delay,boolean clear); -extern boolean IN_KeyDown(byte code); -extern void IN_ClearKey(byte code); -extern boolean IN_qb(byte kee); -extern ScanCode IN_GetLastScan(); -extern ScanCode IN_GetCurCode(); +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(); #endif diff --git a/src/lib/16_in_.c b/src/lib/16_in_.c index 9b6bc7a9..c04d15aa 100755 --- a/src/lib/16_in_.c +++ b/src/lib/16_in_.c @@ -36,7 +36,7 @@ // DEBUG - there are more globals // -#include "src/lib/16_in.h" +#include "src/lib/16_in_.h" #pragma hdrstop /* @@ -60,6 +60,10 @@ 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 @@ -128,22 +132,11 @@ static byte far ASCIINames[] = // Unshifted ASCII for scan codes static Direction DirTable[] = // Quick lookup for total direction { - //dir_Nortinest, - dir_North, - dir_West, - dir_None, - dir_East, - dir_South - //dir_NorthEast, - //dir_Soutinest, - //,dir_SouthEast + /*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 *ParmStringsIN[] = {"nojoys","nomouse",nil}; - #ifdef __cplusplus } #endif @@ -155,12 +148,12 @@ static char *ParmStringsIN[] = {"nojoys","nomouse",nil}; // INL_KeyService() - Handles a keyboard interrupt (key up/down) // /////////////////////////////////////////////////////////////////////////// -void interrupt -INL_KeyService() +/*static */void interrupt +INL_KeyService(global_game_variables_t *gvar) { static boolean special; - byte k,c; - register byte temp; + byte k,c, + temp; k = inp(0x60); // Get the scan code @@ -171,7 +164,7 @@ static boolean special; if (k == 0xe0) // Special key prefix special = true; else if (k == 0xe1) // Handle Pause key - inpu.Paused = true; + gvar->in.Paused = true; else { if (k & 0x80) // Break code @@ -180,13 +173,13 @@ static boolean special; // DEBUG - handle special keys: ctl-alt-delete, print scrn - inpu.Keyboard[k] = false; + gvar->in.Keyboard[k] = false; } else // Make code { - inst.LastCode = inst.CurCode; - inst.CurCode = inpu.LastScan = k; - inpu.Keyboard[k] = true; + gvar->in.LastCode = gvar->in.CurCode; + gvar->in.CurCode = gvar->in.LastScan = k; + gvar->in.Keyboard[k] = true; if (special) c = SpecialNames[k]; @@ -194,25 +187,25 @@ static boolean special; { if (k == sc_CapsLock) { - inst.CapsLock ^= true; + gvar->in.CapsLock ^= true; // DEBUG - make caps lock light work } - if (inpu.Keyboard[sc_LShift] || inpu.Keyboard[sc_RShift]) // If shifted + if (gvar->in.Keyboard[sc_LShift] || gvar->in.Keyboard[sc_RShift]) // If shifted { c = ShiftNames[k]; - if ((c >= 'A') && (c <= 'Z') && inst.CapsLock) + if ((c >= 'A') && (c <= 'Z') && gvar->in.CapsLock) c += 'a' - 'A'; } else { c = ASCIINames[k]; - if ((c >= 'a') && (c <= 'z') && inst.CapsLock) + if ((c >= 'a') && (c <= 'z') && gvar->in.CapsLock) c -= 'a' - 'A'; } } if (c) - inpu.LastASCII = c; + gvar->in.LastASCII = c; } special = false; @@ -221,7 +214,7 @@ static boolean special; if (INL_KeyHook && !special) INL_KeyHook(); #ifdef __DEBUG_InputMgr__ - if(dbg_testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, inpu.Keyboard[k]); + if(dbg_testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, gvar->in.Keyboard[k]); #endif outp(0x20,0x20); } @@ -366,16 +359,16 @@ done: // /////////////////////////////////////////////////////////////////////////// static void -INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive) +INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive, global_game_variables_t *gvar) { word x,y; word time; - word TimeCount = *clockw; + word TimeCount = gvar->kurokku.clock_start; JoystickDef *def; static word lasttime; IN_GetJoyAbs(joy,&x,&y); - def = inpu.JoyDefs + joy; + def = gvar->in.JoyDefs + joy; if (x < def->threshMinX) { @@ -462,9 +455,9 @@ register word result; // /////////////////////////////////////////////////////////////////////////// word -IN_GetJoyButtonsDB(word joy) +IN_GetJoyButtonsDB(word joy, global_game_variables_t *gvar) { - word TimeCount = *clockw; + word TimeCount = gvar->kurokku.clock_start; word lasttime; word result1,result2; @@ -484,12 +477,12 @@ IN_GetJoyButtonsDB(word joy) // /////////////////////////////////////////////////////////////////////////// static void -INL_StartKbd() +INL_StartKbd(global_game_variables_t *gvar) { byte far *lock_key; INL_KeyHook = 0; // Clear key hook - IN_ClearKeysDown(); + IN_ClearKeysDown(gvar); OldKeyVect = _dos_getvect(KeyInt); @@ -545,11 +538,11 @@ INL_ShutMouse(void) // INL_SetJoyScale() - Sets up scaling values for the specified joystick // static void -INL_SetJoyScale(word joy) +INL_SetJoyScale(word joy, global_game_variables_t *gvar) { JoystickDef *def; - def = &(inpu.JoyDefs[joy]); + def = &(gvar->in.JoyDefs[joy]); def->joyMultXL = JoyScaleMax / (def->threshMinX - def->joyMinX); def->joyMultXH = JoyScaleMax / (def->joyMaxX - def->threshMaxX); def->joyMultYL = JoyScaleMax / (def->threshMinY - def->joyMinY); @@ -563,12 +556,12 @@ INL_SetJoyScale(word joy) // /////////////////////////////////////////////////////////////////////////// void -IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy) +IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, global_game_variables_t *gvar) { word d,r; JoystickDef *def; - def = &(inpu.JoyDefs[joy]); + def = &(gvar->in.JoyDefs[joy]); def->joyMinX = minx; def->joyMaxX = maxx; @@ -584,7 +577,7 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy) def->threshMinY = ((r / 2) - d) + miny; def->threshMaxY = ((r / 2) + d) + miny; - INL_SetJoyScale(joy); + INL_SetJoyScale(joy, gvar); } /////////////////////////////////////////////////////////////////////////// @@ -594,7 +587,7 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy) // /////////////////////////////////////////////////////////////////////////// static boolean -INL_StartJoy(word joy) +INL_StartJoy(word joy, global_game_variables_t *gvar) { word x,y; @@ -608,7 +601,7 @@ INL_StartJoy(word joy) return(false); else { - IN_SetupJoy(joy,0,x * 2,0,y * 2); + IN_SetupJoy(joy,0,x * 2,0,y * 2, gvar); return(true); } } @@ -619,9 +612,9 @@ INL_StartJoy(word joy) // /////////////////////////////////////////////////////////////////////////// static void -INL_ShutJoy(word joy) +INL_ShutJoy(word joy, global_game_variables_t *gvar) { - inpu.JoysPresent[joy] = false; + gvar->in.JoysPresent[joy] = false; } // Public routines @@ -632,12 +625,12 @@ INL_ShutJoy(word joy) // /////////////////////////////////////////////////////////////////////////// void -IN_Startup() +IN_Startup(global_game_variables_t *gvar) { boolean checkjoys,checkmouse; word i; - if (inst.IN_Started) + if (gvar->in.IN_Started) return; checkjoys = true; @@ -655,16 +648,16 @@ IN_Startup() } } - INL_StartKbd(); - inpu.MousePresent = checkmouse? INL_StartMouse() : false; + INL_StartKbd(gvar); + gvar->in.MousePresent = checkmouse? INL_StartMouse() : false; for (i = 0;i < MaxJoys;i++) - ININFO_JoysPresent[i] = checkjoys? INL_StartJoy(i) : false; + gvar->in.JoysPresent[i] = checkjoys? INL_StartJoy(i, gvar) : false; - for (i = 0;i < MaxKbds;i++) - ININFO_KbdDefs[i] = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/}; + //for (i = 0;i < MaxKbds;i++) + // gvar->in.KbdDefs[i] = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/}; - inst.IN_Started = true; + gvar->in.IN_Started = true; } @@ -674,26 +667,26 @@ IN_Startup() // /////////////////////////////////////////////////////////////////////////// void -IN_Default(boolean gotit,player_t *player,ControlType nt) +IN_Default(boolean gotit,player_t *player,ControlType nt, global_game_variables_t *gvar) { int i; if ( (!gotit) - || ((nt == ctrl_Joystick1) && !inpu.JoysPresent[0]) - || ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1]) - || ((nt == ctrl_Mouse) && !inpu.MousePresent) + || ((nt == ctrl_Joystick1) && !gvar->in.JoysPresent[0]) + || ((nt == ctrl_Joystick2) && !gvar->in.JoysPresent[1]) + || ((nt == ctrl_Mouse) && !gvar->in.MousePresent) ) nt = ctrl_Keyboard1; - ININFO_KbdDefs[0].button0 = 0x1c; - ININFO_KbdDefs[0].button1 = 0x38; + gvar->in.KbdDefs[0].button0 = 0x1c; + gvar->in.KbdDefs[0].button1 = 0x38; //in.KbdDefs[0].upleft = 0x47; - ININFO_KbdDefs[0].up = 0x48; + gvar->in.KbdDefs[0].up = 0x48; //in.KbdDefs[0].upright = 0x49; - ININFO_KbdDefs[0].left = 0x4b; - ININFO_KbdDefs[0].right = 0x4d; + gvar->in.KbdDefs[0].left = 0x4b; + gvar->in.KbdDefs[0].right = 0x4d; //in.KbdDefs[0].downleft = 0x4f; - ININFO_KbdDefs[0].down = 0x50; + gvar->in.KbdDefs[0].down = 0x50; //in.KbdDefs[0].downright = 0x51; IN_SetControlType(0,player,nt); for(i=0; i>MaxPlayers;i++) @@ -706,19 +699,19 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) // /////////////////////////////////////////////////////////////////////////// void -IN_Shutdown() +IN_Shutdown(global_game_variables_t *gvar) { word i; - if (!inst.IN_Started) + if (!gvar->in.IN_Started) return; INL_ShutMouse(); for (i = 0;i < MaxJoys;i++) - INL_ShutJoy(i); + INL_ShutJoy(i, gvar); INL_ShutKbd(); - inst.IN_Started = false; + gvar->in.IN_Started = false; } /////////////////////////////////////////////////////////////////////////// @@ -739,13 +732,13 @@ IN_SetKeyHook(void (*hook)()) // /////////////////////////////////////////////////////////////////////////// void -IN_ClearKeysDown() +IN_ClearKeysDown(global_game_variables_t *gvar) { //int i; - inpu.LastScan = sc_None; - inpu.LastASCII = key_None; - memset (inpu.Keyboard,0,sizeof(inpu.Keyboard)); + gvar->in.LastScan = sc_None; + gvar->in.LastASCII = key_None; + memset (gvar->in.Keyboard,0,sizeof(gvar->in.Keyboard)); } /////////////////////////////////////////////////////////////////////////// @@ -772,7 +765,7 @@ INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy) // /////////////////////////////////////////////////////////////////////////// void -IN_ReadCursor(CursorInfo *info) +IN_ReadCursor(CursorInfo *info, global_game_variables_t *gvar) { word i, buttons; @@ -781,7 +774,7 @@ IN_ReadCursor(CursorInfo *info) info->x = info->y = 0; info->button0 = info->button1 = false; - if (inpu.MousePresent) + if (gvar->in.MousePresent) { buttons = INL_GetMouseButtons(); INL_GetMouseDelta(&dx,&dy); @@ -790,11 +783,11 @@ IN_ReadCursor(CursorInfo *info) for (i = 0;i < MaxJoys;i++) { - if (!inpu.JoysPresent[i]) + if (!gvar->in.JoysPresent[i]) continue; buttons = INL_GetJoyButtons(i); - INL_GetJoyDelta(i,&dx,&dy,true); + INL_GetJoyDelta(i,&dx,&dy,true, gvar); dx /= 64; dy /= 64; INL_AdjustCursor(info,buttons,dx,dy); @@ -808,7 +801,7 @@ IN_ReadCursor(CursorInfo *info) // /////////////////////////////////////////////////////////////////////////// void near -IN_ReadControl(word pn, player_t *player) +IN_ReadControl(word pn, player_t *player, global_game_variables_t *gvar) { boolean realdelta; #if DEMO0 @@ -852,7 +845,7 @@ register KeyboardDef *def; { case ctrl_Keyboard1: case ctrl_Keyboard2: - def = &(ININFO_KbdDefs[type - ctrl_Keyboard]); + def = &(gvar->in.KbdDefs[type - ctrl_Keyboard]); /* if (Keyboard[def->upleft]) mx = motion_Left,my = motion_Up; @@ -865,28 +858,28 @@ register KeyboardDef *def; //TODO: make this into a function that the joystick AND keyboard can use wwww if(DIRECTIONIFELSE)//(player[pn].info.dir == 2) { - if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){ - if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) + 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((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) + if((gvar->in.Keyboard[def->down] && !gvar->in.Keyboard[def->up])) my = motion_Down; - }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){ - if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) + }else if(!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((inpu.Keyboard[def->right] && !inpu.Keyboard[def->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((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])){ dir = DirTable[1]; }//mx = motion_Left; } - else if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])){ dir = DirTable[3]; }//mx = motion_Right; } + if((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((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])){ dir = DirTable[0]; }//my = motion_Up; } - else if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])){ dir = DirTable[4]; }//my = motion_Down; } + if((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; @@ -897,15 +890,15 @@ register KeyboardDef *def; } } //input from player - if (inpu.Keyboard[def->button0]) + if (gvar->in.Keyboard[def->button0]) buttons += 1 << 0; - if (inpu.Keyboard[def->button1]) + 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); + INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false, gvar); buttons = INL_GetJoyButtons(type - ctrl_Joystick); realdelta = true; break; @@ -976,14 +969,14 @@ 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[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), inpu.Keyboard[def->up], dirchar(4), inpu.Keyboard[def->down], dirchar(1), inpu.Keyboard[def->left], dirchar(3), inpu.Keyboard[def->right]); + //else if(!realdelta) printf("%c%d %c%d %c%d %c%d", dirchar(0), 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 @@ -1092,13 +1085,13 @@ IN_GetScanName(ScanCode scan) // /////////////////////////////////////////////////////////////////////////// ScanCode -IN_WaitForKey() +IN_WaitForKey(global_game_variables_t *gvar) { ScanCode result; - while (!(result = inpu.LastScan)) + while (!(result = gvar->in.LastScan)) ; - inpu.LastScan = 0; + gvar->in.LastScan = 0; return(result); } @@ -1109,13 +1102,13 @@ IN_WaitForKey() // /////////////////////////////////////////////////////////////////////////// char -IN_WaitForASCII() +IN_WaitForASCII(global_game_variables_t *gvar) { char result; - while (!(result = inpu.LastASCII)) + while (!(result = gvar->in.LastASCII)) ; - inpu.LastASCII = '\0'; + gvar->in.LastASCII = '\0'; return(result); } @@ -1125,13 +1118,13 @@ IN_WaitForASCII() // /////////////////////////////////////////////////////////////////////////// void -IN_AckBack() +IN_AckBack(global_game_variables_t *gvar) { word i; - while (!inpu.LastScan) + while (!gvar->in.LastScan) { - if (inpu.MousePresent) + if (gvar->in.MousePresent) { if (INL_GetMouseButtons()) { @@ -1143,11 +1136,11 @@ IN_AckBack() for (i = 0;i < MaxJoys;i++) { - if (inpu.JoysPresent[i]) + if (gvar->in.JoysPresent[i]) { - if (IN_GetJoyButtonsDB(i)) + if (IN_GetJoyButtonsDB(i, gvar)) { - while (IN_GetJoyButtonsDB(i)) + while (IN_GetJoyButtonsDB(i, gvar)) ; return; } @@ -1155,8 +1148,8 @@ IN_AckBack() } } - IN_ClearKey(inpu.LastScan); - inpu.LastScan = sc_None; + IN_ClearKey(gvar->in.LastScan, gvar); + gvar->in.LastScan = sc_None; } /////////////////////////////////////////////////////////////////////////// @@ -1165,25 +1158,25 @@ IN_AckBack() // /////////////////////////////////////////////////////////////////////////// void -IN_Ack() +IN_Ack(global_game_variables_t *gvar) { word i; - if (!inst.IN_Started) + if (!gvar->in.IN_Started) return; - IN_ClearKey(inpu.LastScan); - inpu.LastScan = sc_None; + IN_ClearKey(gvar->in.LastScan, gvar); + gvar->in.LastScan = sc_None; - if (inpu.MousePresent) + if (gvar->in.MousePresent) while (INL_GetMouseButtons()) ; for (i = 0;i < MaxJoys;i++) - if (inpu.JoysPresent[i]) - while (IN_GetJoyButtonsDB(i)) + if (gvar->in.JoysPresent[i]) + while (IN_GetJoyButtonsDB(i, gvar)) ; - IN_AckBack(); + IN_AckBack(gvar); } /////////////////////////////////////////////////////////////////////////// @@ -1193,19 +1186,19 @@ IN_Ack() // /////////////////////////////////////////////////////////////////////////// boolean -IN_IsUserInput() +IN_IsUserInput(global_game_variables_t *gvar) { boolean result; word i; - result = inpu.LastScan; + result = gvar->in.LastScan; - if (inpu.MousePresent) + if (gvar->in.MousePresent) if (INL_GetMouseButtons()) result = true; for (i = 0;i < MaxJoys;i++) - if (inpu.JoysPresent[i]) + if (gvar->in.JoysPresent[i]) if (INL_GetJoyButtons(i)) result = true; @@ -1221,18 +1214,18 @@ IN_IsUserInput() // /////////////////////////////////////////////////////////////////////////// boolean -IN_UserInput(dword delay,boolean clear) +IN_UserInput(dword delay,boolean clear, global_game_variables_t *gvar) { - word TimeCount = *clockw; + word TimeCount = gvar->kurokku.clock_start; word lasttime; lasttime = TimeCount; do { - if (IN_IsUserInput()) + if (IN_IsUserInput(gvar)) { if (clear) - IN_AckBack(); + IN_AckBack(gvar); return(true); } } while (TimeCount - lasttime < delay); @@ -1249,10 +1242,10 @@ IN_UserInput(dword delay,boolean clear) =================== */ -byte IN_MouseButtons (void) +byte IN_MouseButtons (global_game_variables_t *gvar) { union REGS CPURegs; - if (inpu.MousePresent) + if (gvar->in.MousePresent) { Mouse(MButtons); return CPURegs.x.bx; @@ -1281,12 +1274,12 @@ byte IN_JoyButtons (void) return joybits; } -boolean IN_KeyDown(byte code) +boolean IN_KeyDown(byte code, global_game_variables_t *gvar) { #ifdef __DEBUG_InputMgr__ if(!dbg_nointest) #endif - return inpu.Keyboard[code]; + return gvar->in.Keyboard[code]; #ifdef __DEBUG_InputMgr__ else if(dbg_nointest && kbhit()) @@ -1296,28 +1289,28 @@ boolean IN_KeyDown(byte code) #endif } -void IN_ClearKey(byte code) +void IN_ClearKey(byte code, global_game_variables_t *gvar) { - inpu.Keyboard[code] = false; - if(code == inpu.LastScan) - inpu.LastScan = sc_None; + gvar->in.Keyboard[code] = false; + if(code == gvar->in.LastScan) + gvar->in.LastScan = sc_None; } -boolean IN_qb(byte kee) +boolean IN_qb(byte kee, global_game_variables_t *gvar) { #ifdef __DEBUG_InputMgr__ - if(dbg_testkeyin) printf("%u\n", inpu.Keyboard[kee]); + if(dbg_testkeyin) printf("%u\n", gvar->in.Keyboard[kee]); #endif - if(inpu.Keyboard[kee]==true) return 1; + if(gvar->in.Keyboard[kee]==true) return 1; else return 0; } -ScanCode IN_GetLastScan() +ScanCode IN_GetLastScan(global_game_variables_t *gvar) { - return inpu.LastScan; + return gvar->in.LastScan; } -ScanCode IN_GetCurCode() +ScanCode IN_GetCurCode(global_game_variables_t *gvar) { - return inst.CurCode; + return gvar->in.CurCode; } diff --git a/src/lib/16_in_.h b/src/lib/16_in_.h index 39519c20..f84b3a46 100755 --- a/src/lib/16_in_.h +++ b/src/lib/16_in_.h @@ -202,37 +202,7 @@ typedef struct { joyMaxX,joyMaxY, joyMultXL,joyMultYL, joyMultXH,joyMultYH; - } JoystickDef; - -typedef struct -{ - int x; //player exact position on the viewable map - int y; //player exact position on the viewable map - int tx; //player tile position on the viewable map - int ty; //player tile position on the viewable map - int triggerx; //player's trigger box tile position on the viewable map - int triggery; //player's trigger box tile position on the viewable map - int sheetsetx; //NOT USED YET! player sprite sheet set on the image x - int sheetsety; //NOT USED YET! player sprite sheet set on the image y - byte d; //direction to render sprite!! wwww - byte q; //loop variable for anumation and locking the playing to compleate the animation cycle to prevent issues with misalignment www - byte near pdir; //previous direction~ - word speed; //player speed! - word spt; //speed per tile -#ifdef __WATCOMC__ - struct sprite *spri; //supposively the sprite sheet data - memptr gr; - entity_t *ent; -#endif - bitmap_t *data; //supposively the sprite sheet data//old format - bitmap_t bmp; - sword hp; //hitpoints of the player - int persist_aniframe; // gonna be increased to 1 before being used, so 0 is ok for default - CursorInfo info; - ControlType Controls; -//newer vars - int dx, dy, delta; //TODO: what is this? ^^ -} player_t;*/ + } JoystickDef;*/ /* ============================================================================= @@ -241,19 +211,6 @@ typedef struct ============================================================================= */ -/*extern struct inconfig -{ - boolean MousePresent; - boolean JoysPresent[MaxJoys]; - boolean Keyboard[NumCodes]; - boolean Paused; - char LastASCII; - ScanCode LastScan; - - KeyboardDef KbdDefs[MaxKbds]; - JoystickDef JoyDefs[MaxJoys]; -} inpu;*/ - #ifdef DEMO0 static Demo DemoMode = demo_Off; static byte /*_seg*/ *DemoBuffer; @@ -261,48 +218,48 @@ typedef struct #endif // Internal routines -extern void interrupt INL_KeyService(); -extern void Mouse(int x); +//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); -extern void IN_GetJoyAbs(word joy,word *xp,word *yp); +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); -extern word IN_GetJoyButtonsDB(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); -extern void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy); +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); -extern void IN_Startup(); -extern void IN_Default(boolean gotit,player_t *player,ControlType nt); -extern void IN_Shutdown(); -extern void IN_SetKeyHook(void (*hook)()); -extern void IN_ClearKeysDown(); +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); -extern void IN_ReadCursor(CursorInfo *info); -extern void near IN_ReadControl(word pn, player_t *player); -extern void IN_SetControlType(word pn,player_t *player,ControlType type); +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 -extern boolean IN_StartDemoRecord(word bufsize); -extern void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize); -extern void IN_StopDemo(void); -extern void IN_FreeDemoBuffer(void); +boolean IN_StartDemoRecord(word bufsize); +void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize); +void IN_StopDemo(void); +void IN_FreeDemoBuffer(void); #endif -extern byte *IN_GetScanName(ScanCode scan); -extern ScanCode IN_WaitForKey(); -extern char IN_WaitForASCII(); -extern void IN_AckBack(); -extern void IN_Ack(); -extern boolean IN_IsUserInput(); -extern boolean IN_UserInput(dword delay,boolean clear); -extern boolean IN_KeyDown(byte code); -extern void IN_ClearKey(byte code); -extern boolean IN_qb(byte kee); -extern ScanCode IN_GetLastScan(); -extern ScanCode IN_GetCurCode(); +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 new file mode 100755 index 00000000..2534af75 --- /dev/null +++ b/src/lib/16_in__.c @@ -0,0 +1,991 @@ +// +// 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 new file mode 100755 index 00000000..f493ce6e --- /dev/null +++ b/src/lib/16_in__.h @@ -0,0 +1,213 @@ +// +// 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_tail.c b/src/lib/16_tail.c index 7b5fdcb4..c1cef87d 100755 --- a/src/lib/16_tail.c +++ b/src/lib/16_tail.c @@ -57,10 +57,10 @@ void Startup16(global_game_variables_t *gvar) return; } // hardware must be VGA or higher! - if (!(vga_state.vga_flags & VGA_IS_VGA)) { - printf("This program requires VGA or higher graphics hardware\n"); - return; - } +// if (!(vga_state.vga_flags & VGA_IS_VGA)) { +// printf("This program requires VGA or higher graphics hardware\n"); +// return; +// } if (_DEBUG_INIT() == 0) { #ifdef DEBUGSERIAL diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 3aa8e145..504e6731 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -261,16 +261,11 @@ typedef struct { joyMultXH,joyMultYH; } JoystickDef; -typedef struct// instat +/*typedef struct// inconfig { boolean IN_Started; boolean CapsLock; ScanCode CurCode,LastCode; -} in_status_t; - -typedef struct// inconfig -{ - in_status_t instat; // // configuration variables // @@ -286,8 +281,7 @@ typedef struct// inconfig KeyboardDef KbdDefs[MaxKbds]; JoystickDef JoyDefs[MaxJoys]; -} in_info_t; -#define ININFO_ gvar->in. +} in_info_t;*/ //========================================================================== @@ -619,7 +613,7 @@ typedef struct loghandle_t handle; //handles for file logging kurokku_t kurokku; //clock struct mminfo_t mm; mminfotype mmi; // mm stuff - in_info_t in; // 16_in info +//++++ in_info_t in; // 16_in info player_t player[MaxPlayers]; // player vars //==== word far* clockw; /* 18.2hz clock */ } global_game_variables_t; diff --git a/wbuild.sh b/wbuild.sh index fa6245cd..17c1b3e3 100755 --- a/wbuild.sh +++ b/wbuild.sh @@ -12,3 +12,4 @@ wmake -h comp #then # rm *.o #fi +####wmake -h inntest.exe diff --git a/wcpu.exe b/wcpu.exe index 75555b8f..6a5fae4e 100755 Binary files a/wcpu.exe and b/wcpu.exe differ