Commit 7d7c4678 authored by Steven Fuller's avatar Steven Fuller

More cleanups, id_in.c ready

parent abf4a36f
// /* id_in.c */
// ID Engine
// ID_IN.c - Input Manager
// v1.0d1
// By Jason Blochowiak
//
//
// 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 "id_heads.h" #include "id_heads.h"
#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
/* /*
============================================================================= =============================================================================
...@@ -66,10 +30,6 @@ boolean JoyPadPresent; ...@@ -66,10 +30,6 @@ boolean JoyPadPresent;
longword MouseDownCount; longword MouseDownCount;
Demo DemoMode = demo_Off;
byte *DemoBuffer;
word DemoOffset,DemoSize;
/* /*
============================================================================= =============================================================================
...@@ -80,7 +40,7 @@ boolean JoyPadPresent; ...@@ -80,7 +40,7 @@ boolean JoyPadPresent;
static byte ASCIINames[] = // Unshifted ASCII for scan codes static byte ASCIINames[] = // Unshifted ASCII for scan codes
{ {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F // 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 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 '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 '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 'b','n','m',',','.','/',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3
...@@ -126,9 +86,6 @@ static Direction DirTable[] = // Quick lookup for total direction ...@@ -126,9 +86,6 @@ static Direction DirTable[] = // Quick lookup for total direction
dir_SouthWest, dir_South, dir_SouthEast dir_SouthWest, dir_South, dir_SouthEast
}; };
static void (*INL_KeyHook)(void);
static void (*OldKeyVect)(void);
static char *ParmStrings[] = {"nojoys","nomouse",nil}; static char *ParmStrings[] = {"nojoys","nomouse",nil};
// Internal routines // Internal routines
...@@ -140,17 +97,12 @@ static char *ParmStrings[] = {"nojoys","nomouse",nil}; ...@@ -140,17 +97,12 @@ static char *ParmStrings[] = {"nojoys","nomouse",nil};
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static void INL_KeyService(void) static void INL_KeyService(void)
{ {
static boolean special; static boolean special;
byte k,c, byte k, c, temp;
temp; int i;
int i;
k = inportb(0x60); // Get the scan code k = inportb(0x60); // Get the scan code
// Tell the XT keyboard controller to clear the key
outportb(0x61,(temp = inportb(0x61)) | 0x80);
outportb(0x61,temp);
if (k == 0xe0) // Special key prefix if (k == 0xe0) // Special key prefix
special = true; special = true;
else if (k == 0xe1) // Handle Pause key else if (k == 0xe1) // Handle Pause key
...@@ -178,7 +130,6 @@ static boolean special; ...@@ -178,7 +130,6 @@ static boolean special;
if (k == sc_CapsLock) if (k == sc_CapsLock)
{ {
CapsLock ^= true; CapsLock ^= true;
// DEBUG - make caps lock light work
} }
if (Keyboard[sc_LShift] || Keyboard[sc_RShift]) // If shifted if (Keyboard[sc_LShift] || Keyboard[sc_RShift]) // If shifted
...@@ -200,10 +151,6 @@ static boolean special; ...@@ -200,10 +151,6 @@ static boolean special;
special = false; special = false;
} }
if (INL_KeyHook && !special)
INL_KeyHook();
outportb(0x20,0x20);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -212,12 +159,10 @@ static boolean special; ...@@ -212,12 +159,10 @@ static boolean special;
// mouse driver // mouse driver
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static void static void INL_GetMouseDelta(int *x,int *y)
INL_GetMouseDelta(int *x,int *y)
{ {
Mouse(MDelta); *x = 0;
*x = _CX; *y = 0;
*y = _DX;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -226,14 +171,8 @@ INL_GetMouseDelta(int *x,int *y) ...@@ -226,14 +171,8 @@ INL_GetMouseDelta(int *x,int *y)
// mouse driver // mouse driver
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static word static word INL_GetMouseButtons(void)
INL_GetMouseButtons(void)
{ {
word buttons;
Mouse(MButtons);
buttons = _BX;
return(buttons);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -241,76 +180,10 @@ INL_GetMouseButtons(void) ...@@ -241,76 +180,10 @@ INL_GetMouseButtons(void)
// IN_GetJoyAbs() - Reads the absolute position of the specified joystick // IN_GetJoyAbs() - Reads the absolute position of the specified joystick
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void void IN_GetJoyAbs(word joy,word *xp,word *yp)
IN_GetJoyAbs(word joy,word *xp,word *yp)
{ {
byte xb,yb, *xp = 0;
xs,ys; *yp = 0;
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;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -321,61 +194,8 @@ asm popf // Restore the registers ...@@ -321,61 +194,8 @@ asm popf // Restore the registers
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void INL_GetJoyDelta(word joy,int *dx,int *dy) void INL_GetJoyDelta(word joy,int *dx,int *dy)
{ {
word x,y; *dx = 0;
longword time; *dy = 0;
JoystickDef *def;
static longword 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;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -384,39 +204,9 @@ static longword lasttime; ...@@ -384,39 +204,9 @@ static longword lasttime;
// joystick // joystick
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static word static word INL_GetJoyButtons(word joy)
INL_GetJoyButtons(word joy)
{ {
register word result; return 0;
result = inportb(0x201); // Get all the joystick buttons
result >>= joy? 6 : 4; // Shift into bits 0-1
result &= 3; // Mask off the useless bits
result ^= 3;
return(result);
}
///////////////////////////////////////////////////////////////////////////
//
// IN_GetJoyButtonsDB() - Returns the de-bounced button status of the
// specified joystick
//
///////////////////////////////////////////////////////////////////////////
word
IN_GetJoyButtonsDB(word joy)
{
longword lasttime;
word result1,result2;
do
{
result1 = INL_GetJoyButtons(joy);
lasttime = TimeCount;
while (TimeCount == lasttime)
;
result2 = INL_GetJoyButtons(joy);
} while (result1 != result2);
return(result1);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -424,15 +214,9 @@ IN_GetJoyButtonsDB(word joy) ...@@ -424,15 +214,9 @@ IN_GetJoyButtonsDB(word joy)
// INL_StartKbd() - Sets up my keyboard stuff for use // INL_StartKbd() - Sets up my keyboard stuff for use
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static void static void INL_StartKbd(void)
INL_StartKbd(void)
{ {
INL_KeyHook = NULL; // no key hook routine
IN_ClearKeysDown(); IN_ClearKeysDown();
OldKeyVect = getvect(KeyInt);
setvect(KeyInt,INL_KeyService);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -440,12 +224,8 @@ INL_StartKbd(void) ...@@ -440,12 +224,8 @@ INL_StartKbd(void)
// INL_ShutKbd() - Restores keyboard control to the BIOS // INL_ShutKbd() - Restores keyboard control to the BIOS
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static void static void INL_ShutKbd(void)
INL_ShutKbd(void)
{ {
poke(0x40,0x17,peek(0x40,0x17) & 0xfaf0); // Clear ctrl/alt/shift flags
setvect(KeyInt,OldKeyVect);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -453,30 +233,9 @@ INL_ShutKbd(void) ...@@ -453,30 +233,9 @@ INL_ShutKbd(void)
// INL_StartMouse() - Detects and sets up the mouse // INL_StartMouse() - Detects and sets up the mouse
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static boolean static boolean INL_StartMouse(void)
INL_StartMouse(void)
{ {
#if 0 return false;
if (getvect(MouseInt))
{
Mouse(MReset);
if (_AX == 0xffff)
return(true);
}
return(false);
#endif
union REGS regs;
unsigned char *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;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -484,24 +243,15 @@ INL_StartMouse(void) ...@@ -484,24 +243,15 @@ INL_StartMouse(void)
// INL_ShutMouse() - Cleans up after the mouse // INL_ShutMouse() - Cleans up after the mouse
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static void static void INL_ShutMouse(void)
INL_ShutMouse(void)
{ {
} }
// //
// INL_SetJoyScale() - Sets up scaling values for the specified joystick // INL_SetJoyScale() - Sets up scaling values for the specified joystick
// //
static void static void INL_SetJoyScale(word joy)
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);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -510,29 +260,8 @@ INL_SetJoyScale(word joy) ...@@ -510,29 +260,8 @@ INL_SetJoyScale(word joy)
// to set up scaling values // to set up scaling values
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void 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)
{ {
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);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -541,24 +270,9 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy) ...@@ -541,24 +270,9 @@ IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy)
// The auto-config assumes the joystick is centered // The auto-config assumes the joystick is centered
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static boolean static boolean INL_StartJoy(word joy)
INL_StartJoy(word joy)
{ {
word x,y; return false;
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);
}
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -566,8 +280,7 @@ INL_StartJoy(word joy) ...@@ -566,8 +280,7 @@ INL_StartJoy(word joy)
// INL_ShutJoy() - Cleans up the joystick stuff // INL_ShutJoy() - Cleans up the joystick stuff
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static void static void INL_ShutJoy(word joy)
INL_ShutJoy(word joy)
{ {
JoysPresent[joy] = false; JoysPresent[joy] = false;
} }
...@@ -578,8 +291,7 @@ INL_ShutJoy(word joy) ...@@ -578,8 +291,7 @@ INL_ShutJoy(word joy)
// IN_Startup() - Starts up the Input Mgr // IN_Startup() - Starts up the Input Mgr
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void void IN_Startup(void)
IN_Startup(void)
{ {
boolean checkjoys,checkmouse; boolean checkjoys,checkmouse;
word i; word i;
...@@ -603,42 +315,22 @@ IN_Startup(void) ...@@ -603,42 +315,22 @@ IN_Startup(void)
} }
INL_StartKbd(); INL_StartKbd();
MousePresent = checkmouse? INL_StartMouse() : false; MousePresent = checkmouse ? INL_StartMouse() : false;
for (i = 0;i < MaxJoys;i++) for (i = 0;i < MaxJoys;i++)
JoysPresent[i] = checkjoys? INL_StartJoy(i) : false; JoysPresent[i] = checkjoys ? INL_StartJoy(i) : false;
IN_Started = true; 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 // IN_Shutdown() - Shuts down the Input Mgr
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void void IN_Shutdown(void)
IN_Shutdown(void)
{ {
word i; word i;
if (!IN_Started) if (!IN_Started)
return; return;
...@@ -651,42 +343,27 @@ IN_Shutdown(void) ...@@ -651,42 +343,27 @@ IN_Shutdown(void)
IN_Started = false; 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 // IN_ClearKeysDown() - Clears the keyboard array
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void void IN_ClearKeysDown(void)
IN_ClearKeysDown(void)
{ {
int i; int i;
LastScan = sc_None; LastScan = sc_None;
LastASCII = key_None; LastASCII = key_None;
memset (Keyboard,0,sizeof(Keyboard)); memset(Keyboard, 0, sizeof(Keyboard));
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// //
// IN_ReadControl() - Reads the device associated with the specified // IN_ReadControl() - Reads the device associated with the specified
// player and fills in the control info struct // player and fills in the control info struct
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void void IN_ReadControl(int player,ControlInfo *info)
IN_ReadControl(int player,ControlInfo *info)
{ {
boolean realdelta; boolean realdelta;
byte dbyte; byte dbyte;
...@@ -694,32 +371,12 @@ IN_ReadControl(int player,ControlInfo *info) ...@@ -694,32 +371,12 @@ IN_ReadControl(int player,ControlInfo *info)
int dx,dy; int dx,dy;
Motion mx,my; Motion mx,my;
ControlType type; ControlType type;
register KeyboardDef *def; KeyboardDef *def;
dx = dy = 0; dx = dy = 0;
mx = my = motion_None; mx = my = motion_None;
buttons = 0; 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]) switch (type = Controls[player])
{ {
case ctrl_Keyboard: case ctrl_Keyboard:
...@@ -762,7 +419,6 @@ register KeyboardDef *def; ...@@ -762,7 +419,6 @@ register KeyboardDef *def;
realdelta = true; realdelta = true;
break; break;
} }
}
if (realdelta) if (realdelta)
{ {
...@@ -785,29 +441,6 @@ register KeyboardDef *def; ...@@ -785,29 +441,6 @@ register KeyboardDef *def;
info->button3 = buttons & (1 << 3); info->button3 = buttons & (1 << 3);
info->dir = DirTable[((my + 1) * 3) + (mx + 1)]; 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;
}
}
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -816,38 +449,19 @@ register KeyboardDef *def; ...@@ -816,38 +449,19 @@ register KeyboardDef *def;
// player // player
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void void IN_SetControlType(int player, ControlType type)
IN_SetControlType(int player,ControlType type)
{ {
// DEBUG - check that requested type is present? // DEBUG - check that requested type is present?
Controls[player] = type; 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 // IN_WaitForASCII() - Waits for an ASCII char, then clears LastASCII and
// returns the ASCII value // returns the ASCII value
// //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
char char IN_WaitForASCII(void)
IN_WaitForASCII(void)
{ {
char result; char result;
...@@ -885,7 +499,6 @@ void IN_StartAck(void) ...@@ -885,7 +499,6 @@ void IN_StartAck(void)
btnstate[i] = true; btnstate[i] = true;
} }
boolean IN_CheckAck (void) boolean IN_CheckAck (void)
{ {
unsigned i,buttons; unsigned i,buttons;
...@@ -912,7 +525,6 @@ boolean IN_CheckAck (void) ...@@ -912,7 +525,6 @@ boolean IN_CheckAck (void)
return false; return false;
} }
void IN_Ack (void) void IN_Ack (void)
{ {
IN_StartAck (); IN_StartAck ();
...@@ -921,7 +533,6 @@ void IN_Ack (void) ...@@ -921,7 +533,6 @@ void IN_Ack (void)
; ;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// //
// IN_UserInput() - Waits for the specified delay time (in ticks) or the // IN_UserInput() - Waits for the specified delay time (in ticks) or the
...@@ -954,18 +565,11 @@ boolean IN_UserInput(longword delay) ...@@ -954,18 +565,11 @@ boolean IN_UserInput(longword delay)
=================== ===================
*/ */
byte IN_MouseButtons (void) byte IN_MouseButtons (void)
{ {
if (MousePresent) return 0;
{
Mouse(MButtons);
return _BX;
}
else
return 0;
} }
/* /*
=================== ===================
= =
...@@ -974,15 +578,7 @@ byte IN_MouseButtons (void) ...@@ -974,15 +578,7 @@ byte IN_MouseButtons (void)
=================== ===================
*/ */
byte IN_JoyButtons (void) byte IN_JoyButtons (void)
{ {
unsigned joybits; return 0;
joybits = inportb(0x201); // Get all the joystick buttons
joybits >>= 4; // only the high bits are useful
joybits ^= 15; // return with 1=pressed
return joybits;
} }
// #ifndef __ID_IN_H__
// ID Engine #define __ID_IN_H__
// ID_IN.h - Header file for Input Manager
// v1.0d1
// By Jason Blochowiak
//
#ifndef __ID_IN__
#define __ID_IN__
#define MaxPlayers 4 #define MaxPlayers 4
#define MaxKbds 2
#define MaxJoys 2 #define MaxJoys 2
#define NumCodes 128 #define NumCodes 128
...@@ -105,12 +97,8 @@ typedef byte ScanCode; ...@@ -105,12 +97,8 @@ typedef byte ScanCode;
#define MouseInt 0x33 #define MouseInt 0x33
#define Mouse(x) _AX = x,geninterrupt(MouseInt) #define Mouse(x) _AX = x,geninterrupt(MouseInt)
typedef enum {
demo_Off,demo_Record,demo_Playback,demo_PlayDone
} Demo;
typedef enum { typedef enum {
ctrl_Keyboard, ctrl_Keyboard,
ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,
ctrl_Joystick, ctrl_Joystick,
ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2, ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,
ctrl_Mouse ctrl_Mouse
...@@ -159,10 +147,6 @@ extern KeyboardDef KbdDefs; ...@@ -159,10 +147,6 @@ extern KeyboardDef KbdDefs;
extern JoystickDef JoyDefs[]; extern JoystickDef JoyDefs[];
extern ControlType Controls[MaxPlayers]; extern ControlType Controls[MaxPlayers];
extern Demo DemoMode;
extern byte *DemoBuffer;
extern word DemoOffset,DemoSize;
// Function prototypes // Function prototypes
#define IN_KeyDown(code) (Keyboard[(code)]) #define IN_KeyDown(code) (Keyboard[(code)])
#define IN_ClearKey(code) {Keyboard[code] = false; \ #define IN_ClearKey(code) {Keyboard[code] = false; \
...@@ -173,18 +157,14 @@ extern void IN_Startup(void),IN_Shutdown(void), ...@@ -173,18 +157,14 @@ extern void IN_Startup(void),IN_Shutdown(void),
IN_Default(boolean gotit,ControlType in), IN_Default(boolean gotit,ControlType in),
IN_SetKeyHook(void (*)()), IN_SetKeyHook(void (*)()),
IN_ClearKeysDown(void), IN_ClearKeysDown(void),
IN_ReadCursor(CursorInfo *),
IN_ReadControl(int,ControlInfo *), IN_ReadControl(int,ControlInfo *),
IN_SetControlType(int,ControlType), IN_SetControlType(int,ControlType),
IN_GetJoyAbs(word joy,word *xp,word *yp), IN_GetJoyAbs(word joy,word *xp,word *yp),
IN_SetupJoy(word joy,word minx,word maxx, IN_SetupJoy(word joy,word minx,word maxx,
word miny,word maxy), word miny,word maxy),
IN_StopDemo(void),IN_FreeDemoBuffer(void), IN_Ack(void);
IN_Ack(void),IN_AckBack(void);
extern boolean IN_UserInput(longword delay); extern boolean IN_UserInput(longword delay);
extern char IN_WaitForASCII(void); extern char IN_WaitForASCII(void);
extern ScanCode IN_WaitForKey(void);
extern word IN_GetJoyButtonsDB(word joy);
extern byte *IN_GetScanName(ScanCode); extern byte *IN_GetScanName(ScanCode);
...@@ -195,4 +175,6 @@ void INL_GetJoyDelta(word joy,int *dx,int *dy); ...@@ -195,4 +175,6 @@ void INL_GetJoyDelta(word joy,int *dx,int *dy);
void IN_StartAck(void); void IN_StartAck(void);
boolean IN_CheckAck (void); boolean IN_CheckAck (void);
#elif
#error "fix me TODO"
#endif #endif
// /* id_sd.c */
// ID Engine
// ID_SD.c - Sound Manager for Wolfenstein 3D
// v1.2
// By Jason Blochowiak
//
//
// This module handles dealing with generating sound on the appropriate
// hardware
//
// Depends on: User Mgr (for parm checking)
//
// Globals:
// For User Mgr:
// SoundSourcePresent - Sound Source thingie present?
// SoundBlasterPresent - SoundBlaster card present?
// AdLibPresent - AdLib card present?
// SoundMode - What device is used for sound effects
// (Use SM_SetSoundMode() to set)
// MusicMode - What device is used for music
// (Use SM_SetMusicMode() to set)
// DigiMode - What device is used for digitized sound effects
// (Use SM_SetDigiDevice() to set)
//
// For Cache Mgr:
// NeedsDigitized - load digitized sounds?
// NeedsMusic - load music?
//
#include <dos.h>
#include "id_heads.h" #include "id_heads.h"
#ifdef nil
#undef nil
#endif
#define nil 0
#define SDL_SoundFinished() {SoundNumber = SoundPriority = 0;} #define SDL_SoundFinished() {SoundNumber = SoundPriority = 0;}
// Macros for SoundBlaster stuff // Macros for SoundBlaster stuff
...@@ -92,7 +58,6 @@ static void (*SoundUserHook)(void); ...@@ -92,7 +58,6 @@ static void (*SoundUserHook)(void);
soundnames SoundNumber,DigiNumber; soundnames SoundNumber,DigiNumber;
word SoundPriority,DigiPriority; word SoundPriority,DigiPriority;
int LeftPosition,RightPosition; int LeftPosition,RightPosition;
void interrupt (*t0OldService)(void);
long LocalTime; long LocalTime;
word TimerRate; word TimerRate;
...@@ -106,9 +71,9 @@ static word DigiNextLen; ...@@ -106,9 +71,9 @@ static word DigiNextLen;
// SoundBlaster variables // SoundBlaster variables
static boolean sbNoCheck,sbNoProCheck; static boolean sbNoCheck,sbNoProCheck;
static volatile boolean sbSamplePlaying; static boolean sbSamplePlaying;
static byte sbOldIntMask = -1; static byte sbOldIntMask = -1;
static volatile byte *sbNextSegPtr; static byte *sbNextSegPtr;
static byte sbDMA = 1, static byte sbDMA = 1,
sbDMAa1 = 0x83,sbDMAa2 = 2,sbDMAa3 = 3, sbDMAa1 = 0x83,sbDMAa2 = 2,sbDMAa3 = 3,
sba1Vals[] = {0x87,0x83,0,0x82}, sba1Vals[] = {0x87,0x83,0,0x82},
......
#ifndef __MISC_H__ #ifndef __MISC_H__
#define __MISC_H__ #define __MISC_H__
extern int _argc;
extern char **_argv;
long filelength(int handle); long filelength(int handle);
#elif #elif
......
/* wl_main.c */ /* wl_main.c */
#include <conio.h>
#include "wl_def.h" #include "wl_def.h"
/* /*
============================================================================= =============================================================================
...@@ -61,8 +59,11 @@ void Quit (char *error); ...@@ -61,8 +59,11 @@ void Quit (char *error);
boolean startgame,loadedgame,virtualreality; boolean startgame,loadedgame,virtualreality;
int mouseadjustment; int mouseadjustment;
char configname[13]="CONFIG."; char configname[13]="config.";
int _argc;
char **argv;
/* /*
============================================================================= =============================================================================
...@@ -1525,10 +1526,13 @@ void DemoLoop (void) ...@@ -1525,10 +1526,13 @@ void DemoLoop (void)
========================== ==========================
*/ */
void main (void) void main(int argc, char *argv[])
{ {
int i; int i;
_argc = argc;
_argv = argv;
CheckForEpisodes(); CheckForEpisodes();
InitGame(); InitGame();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment