X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_in.h;h=78ebd8053db4bec143f7dc2995773c0712fd92db;hb=d31b48962de4f4384cca54f92db59ccc0bb06fbc;hp=b157446f76a864943e9c4fb8a1268fa32e09183b;hpb=e3dca57bc80ceb1b0664c8e5a7c34acb665a5c73;p=16.git diff --git a/src/lib/16_in.h b/src/lib/16_in.h old mode 100644 new mode 100755 index b157446f..78ebd805 --- a/src/lib/16_in.h +++ b/src/lib/16_in.h @@ -20,22 +20,35 @@ // ID Engine // ID_IN.h - Header file for Input Manager // v1.0d1w -// By Jason Blochowiak +// By Jason Blochowiak // Open Watcom port by sparky4 // #ifndef __16_IN__ #define __16_IN__ - + #include -#include "src/lib/lib_head.h" +#include "src/lib/16_head.h" +#include "src/lib/16_timer.h" +#include "src/lib/bitmap.h" +#include "src/lib/planar.h" + +#ifdef __DEBUG__ +//#define __DEBUG_InputMgr__ +#endif + +#ifdef __DEBUG_InputMgr__ +//#define TESTKEYIN +//#define TESTCONTROLNOISY +#endif -//++++#ifdef __DEBUG__ -#define __DEBUG_InputMgr__ -//++++#endif +extern boolean testkeyin,testcontrolnoisy,testctrltype; -#define TESTKEYIN -#define TESTCONTROLNOISY +//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 @@ -47,6 +60,7 @@ #define MaxPlayers 4 #define MaxKbds 2 #define MaxJoys 2 +#define MaxPads 2 #define NumCodes 128 typedef byte ScanCode; @@ -132,10 +146,10 @@ typedef byte ScanCode; #define key_BackSpace 0x08 #define key_Tab 0x09 #define key_Delete 0x7f - -#define key_LSuper 0x5b -#define key_RSuper 0x5c -#define key_Menu 0x5d + +#define key_LSuper 0x5b +#define key_RSuper 0x5c +#define key_Menu 0x5d // Stuff for the mouse #define MReset 0 @@ -154,9 +168,7 @@ typedef enum { ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2, ctrl_Joystick, ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2, - ctrl_Mouse, - ctrl_Joypad, - ctrl_Joypad1 = ctrl_Joypad,ctrl_Joypad2 + ctrl_Mouse, } ControlType; typedef enum { motion_Left = -1,motion_Up = -1, @@ -165,42 +177,64 @@ typedef enum { } Motion; typedef enum { dir_North,//dir_NorthEast, - dir_East,//dir_SouthEast, - dir_South,//dir_SouthWest, - dir_West,//dir_NorthWest, - dir_None + dir_West,//dir_Nortinest, + dir_None, + dir_East,//,dir_SouthEast, + dir_South,//dir_Soutinest, } Direction; typedef struct { - boolean button0,button1,button2,button3; - int x,y; - Motion xaxis,yaxis; - Direction dir; + boolean near button0,button1,button2,button3; + int near x,y; + Motion near xaxis,yaxis; + Direction near dir; } CursorInfo; typedef struct { - ScanCode button0,button1, + ScanCode near button0,button1, //upleft, up, + down, + left, + right //upright, - left, right, //downleft, - down //,downright ; } KeyboardDef; typedef struct { - word joyMinX,joyMinY, + word near joyMinX,joyMinY, threshMinX,threshMinY, threshMaxX,threshMaxY, joyMaxX,joyMaxY, joyMultXL,joyMultYL, joyMultXH,joyMultYH; - } JoystickDef; - -/*typedef struct -{ - CursorInfo; -} ControlInfo;*/ + } 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~ + //byte near kd[2]; //array of arrow key pressed + word speed; //player speed! +//0000 planar_buf_t huge *data; //supposively the sprite sheet data +// planar_buf_t data; //supposively the sprite sheet data +////0000---- + bitmap_t huge *data; //supposively the sprite sheet data + 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; +} player_t; + /* ============================================================================= @@ -208,29 +242,18 @@ typedef struct { ============================================================================= */ - -// -// configuration variables -// -static boolean MousePresent; -static boolean JoysPresent[MaxJoys]; -static boolean JoyPadPresent; - -// Global variables -// extern boolean JoystickCalibrated; // MDM (GAMERS EDGE) - added -// extern ControlType ControlTypeUsed; // MDM (GAMERS EDGE) - added - - extern boolean Keyboard[NumCodes]; - extern boolean Paused; - extern char LastASCII; - extern ScanCode LastScan; - - //extern KeyboardDef KbdDefs[]; - static KeyboardDef KbdDefs[MaxKbds] = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51}; - extern JoystickDef JoyDefs[MaxJoys]; - extern ControlType Controls[MaxPlayers]; - - extern dword MouseDownCount; +/*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; @@ -238,169 +261,48 @@ static boolean JoyPadPresent; static word DemoOffset,DemoSize; #endif -extern dword far* clockdw; - -/* -============================================================================= - - 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','-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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 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 *ParmStringsIN[] = {"nojoys","nomouse",nil}; - -// Function prototypes -#define IN_KeyDown(code) (Keyboard[(code)]) -#define IN_ClearKey(code) {Keyboard[code] = false; if (code == LastScan) LastScan = sc_None;} - -// Internal routines -void interrupt INL_KeyService(void); -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); -void IN_Default(boolean gotit,ControlType in); -void IN_Shutdown(void); -void IN_SetKeyHook(void (*hook)()); -void IN_ClearKeysDown(void); -//static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy); -void IN_ReadCursor(CursorInfo *info); -void IN_ReadControl(int player,CursorInfo *info); -void IN_SetControlType(int 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(void); -char IN_WaitForASCII(void); -void IN_AckBack(void); -void IN_Ack(void); -boolean IN_IsUserInput(void); -boolean IN_UserInput(dword delay,boolean clear); - - -/*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,ControlInfo *), - IN_SetControlType(int,ControlType), - IN_GetJoyAbs(word joy,word *xp,word *yp), - IN_SetupJoy(word joy,word minx,word maxx, - word miny,word maxy), - Mouse(int x), -#ifdef DEMO0 - IN_StartDemoPlayback(byte __segment *buffer,word bufsize), - IN_StopDemo(void),IN_FreeDemoBuffer(void), +// Internal routines +extern void interrupt INL_KeyService(); +extern 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); +//static void INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive); +//static word INL_GetJoyButtons(word joy); +extern 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); +//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(); +//static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy); +extern void IN_ReadCursor(CursorInfo *info); +extern void near IN_ReadControl(int pn,player_t *player); +extern 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); #endif - IN_Ack(void),IN_AckBack(void); -extern boolean IN_UserInput(dword delay,boolean clear), - IN_IsUserInput(void) -#ifdef DEMO0 - , IN_StartDemoRecord(word bufsize) -#endif -; -extern byte *IN_GetScanName(ScanCode); -extern char IN_WaitForASCII(void); -extern ScanCode IN_WaitForKey(void); -extern word IN_GetJoyButtonsDB(word joy);*/ - +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); +void IN_initplayer(player_t *player, word pn); -void interrupt INL_KeyService(void); -boolean IN_qb(byte kee); #endif