From c421d6353c601dc59f7d9e42883f0711c6a89805 Mon Sep 17 00:00:00 2001
From: sparky4 <sparky4@cock.li>
Date: Fri, 10 Mar 2017 10:24:48 -0600
Subject: [PATCH] __seguse.txt added to show _seg usage also OpenVGMFile needs
 to be ported to 16_snd.c  ][ ca needs huge amounts of work and i should
 remember what needs to be done soon also i should reverify 16_in.c to make
 sure it can work with other code of id engine ][ 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]

---
 makefile          |   6 ++-
 src/inntest.c     | 112 ++++++++++++++++++++++++++++++++++++++++++++++
 src/lib/16_in.c   |   1 +
 src/lib/16_in_.c  |   4 +-
 src/lib/16_in_.h  |  43 ------------------
 src/lib/16_tdef.h |  10 ++---
 6 files changed, 125 insertions(+), 51 deletions(-)
 create mode 100755 src/inntest.c

diff --git a/makefile b/makefile
index cc491802..c396e4c6 100755
--- a/makefile
+++ b/makefile
@@ -125,7 +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)
-16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_in.$(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)
+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)
 DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ)
 !ifeq DEBUGSERIAL 1
 DOSLIBOBJ += 8250.$(OBJ)
@@ -242,6 +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)
 #sountest.exe:	sountest.$(OBJ) $(16LIB)
 pcxtest.exe:	pcxtest.$(OBJ) gfx.lib $(DOSLIB) $(16LIB)
 vrstest.exe:	vrstest.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
@@ -282,6 +284,7 @@ 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
@@ -336,6 +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_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/inntest.c b/src/inntest.c
new file mode 100755
index 00000000..1ba8b227
--- /dev/null
+++ b/src/inntest.c
@@ -0,0 +1,112 @@
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
+ *
+ * This file is part of Project 16.
+ *
+ * Project 16 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Project 16 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, see <http://www.gnu.org/licenses/>, or
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+/*
+	input test
+*/
+#include "src/lib/16_in.h"
+#include "src/lib/16_tail.h"
+
+void
+main(int argc, char *argv[])
+{
+	static global_game_variables_t gvar;
+	//extern struct inconfig inpu;
+	dbg_testkeyin=0;
+	dbg_testcontrolnoisy=1;
+	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);
+
+	gvar.player[0].enti.q=1;
+	gvar.player[0].enti.d=2;
+	gvar.player[0].enti.speed=4;
+
+//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))
+	{
+//0000		shinkutxt(&gvar);
+		IN_ReadControl(0, &gvar.player);
+		switch(gvar.player[0].enti.d)
+		{
+		//right movement
+		case 3:
+			if(gvar.player[0].enti.q<=(TILEWH/(gvar.player[0].enti.speed)))
+			{
+				gvar.player[0].enti.q++;
+			} else { gvar.player[0].enti.q = 1; gvar.player[0].enti.d = 2; }
+		break;
+
+		//left movement
+		case 1:
+			if(gvar.player[0].enti.q<=(TILEWH/(gvar.player[0].enti.speed)))
+			{
+				gvar.player[0].enti.q++;
+			} else { gvar.player[0].enti.q = 1; gvar.player[0].enti.d = 2; }
+		break;
+
+		//down movement
+		case 4:
+			if(gvar.player[0].enti.q<=(TILEWH/(gvar.player[0].enti.speed)))
+			{
+				gvar.player[0].enti.q++;
+			} else { gvar.player[0].enti.q = 1; gvar.player[0].enti.d = 2; }
+		break;
+
+		//up movement
+		case 0:
+			if(gvar.player[0].enti.q<=(TILEWH/(gvar.player[0].enti.speed)))
+			{
+				gvar.player[0].enti.q++;
+			} else { gvar.player[0].enti.q = 1; gvar.player[0].enti.d = 2; }
+		break;
+	}
+		//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
+		{
+			switch(gvar.kurokku.fpscap)
+			{
+				case 0:
+					gvar.kurokku.fpscap=1;
+				break;
+				case 1:
+					gvar.kurokku.fpscap=0;
+				break;
+			}
+			//IN_Ack();
+		}
+	}
+	IN_Shutdown();
+		//Shutdown16(&gvar);
+	//printf("%u\n", in.Keyboard[sc_Escape]);
+	printf("inputest.exe ");
+	printf("version %s\n", VERSION);
+	printf("testkeyin=%u\n", dbg_testkeyin);
+	printf("testcontrolnoisy=%u\n", dbg_testcontrolnoisy);
+}
diff --git a/src/lib/16_in.c b/src/lib/16_in.c
index a6b43dfb..a2b28046 100755
--- a/src/lib/16_in.c
+++ b/src/lib/16_in.c
@@ -37,6 +37,7 @@
 //
 
 #include "src/lib/16_in.h"
+#pragma	hdrstop
 
 static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */
 
diff --git a/src/lib/16_in_.c b/src/lib/16_in_.c
index 8ae2a327..6a2602e4 100755
--- a/src/lib/16_in_.c
+++ b/src/lib/16_in_.c
@@ -661,7 +661,9 @@ IN_Startup()
 	for (i = 0;i < MaxJoys;i++)
 		inpu.JoysPresent[i] = checkjoys? INL_StartJoy(i) : false;
 
-	{{0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51}};
+	for (i = 0;i < MaxKbds;i++)
+		inpu.KbdDefs = {{0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51}};
+
 	inst.IN_Started = true;
 
 }
diff --git a/src/lib/16_in_.h b/src/lib/16_in_.h
index 39519c20..969fdb7e 100755
--- a/src/lib/16_in_.h
+++ b/src/lib/16_in_.h
@@ -204,36 +204,6 @@ typedef	struct		{
 									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;*/
-
 /*
 =============================================================================
 
@@ -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;
diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h
index 9cb36102..be166c7e 100755
--- a/src/lib/16_tdef.h
+++ b/src/lib/16_tdef.h
@@ -228,12 +228,10 @@ typedef	enum		{
 						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,
+typedef	enum		{		// Quick lookup for total direction
+						/*dir_NorthWest,	*/dir_North,/*	dir_NorthEast,*/
+						dir_West,		dir_None,	dir_East,
+						/*dir_SouthWest,	*/dir_South/*,	dir_SouthEast*/
 					} Direction;
 typedef	struct		{
 						boolean	near	button0,button1,button2,button3;
-- 
2.39.5