Commit b5746514 authored by Steven Fuller's avatar Steven Fuller

Updated TODO list

misc.c, misc.h, id_heads.h: removed most of the "DOSISM" junk for now

vi_*, vi_comm.c: finally moved the wolf3d input code into a seperate file

wl_draw.c: fixed a texture bug (slivers didn't "line up" correctly)

rest: misc. changes as usual
parent 0e85990d
...@@ -10,7 +10,7 @@ CFLAGS = -g -Wall -pedantic ...@@ -10,7 +10,7 @@ CFLAGS = -g -Wall -pedantic
OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \ OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
wl_act1.o wl_act2.o wl_act3.o wl_agent.o wl_game.o \ wl_act1.o wl_act2.o wl_act3.o wl_agent.o wl_game.o \
wl_inter.o wl_menu.o wl_play.o wl_state.o wl_text.o wl_main.o \ wl_inter.o wl_menu.o wl_play.o wl_state.o wl_text.o wl_main.o \
wl_debug.o wl_debug.o vi_comm.o
ROBJS = wl_draw.o ROBJS = wl_draw.o
SOBJS = $(OBJS) $(ROBJS) vi_svga.o SOBJS = $(OBJS) $(ROBJS) vi_svga.o
XOBJS = $(OBJS) $(ROBJS) vi_xlib.o XOBJS = $(OBJS) $(ROBJS) vi_xlib.o
......
Priority Levels: I > R > M (I, R required to be complete before release)
Program: P=PC Wolf3D, M=Mac Wolf3D, B=Both
P R - create a better "read direction" for menu movement
P M - convert while (Keyboard[sc_Blah]) IN_CheckAck() to IN_WaitKeyDown(sc..
P I - finish changing the game movement to the new style
P R - update input menus/config
P M - rewrite menu code
P R - update sound menus/config
P I - rewrite sound code: get rid of packed structs, clean up thread stuff
P R - openal sound
P I - fix issues (speed, hacks) with variable screen size
P M - BSP trees (or something similar), then OpenGL support
M R - port menu code (after fixed up)
M R - add sound
M M - complete/fix opengl mode
M M - add music (would need to RE the sound lib)
B I - complete savegame, config formats
M I - add SDL
B R - decide if to keep SVGA/X11 targets
B M - configure scripts?
B M - port to dreamcast?
B M - add compression to savegames/config
B I - play through (w/ sound and music) to make sure things work
B M - use stdint.h where appropiate
B M - finish serializing reads/writes, endian issues
P I - fix raycast bug where at certain points you can see through corners
B I - merge other TODO lists into this list
B M - use something like config file or getenv to point at data directories
P I - finish handling/mapping for all keys in sys. specific code
B I - add mouse support
B M - add joystick/gamepad support
Complete:
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Control Menu: Control Menu:
* TODO * TODO
Sound Menu: Sound Menu:
* Sound Effects: * Digital Sound Effects:
- PCM - On [PCM]
- OPL2 - Off
* Sound Effects
- On [AdLib/OPL2]
- PC Speaker? - PC Speaker?
- None - Off
* Music: * Music:
- OPL2 - On [AdLib/OPL2]
- None - Off
* Sampling Rate:
- 44100
- 22050
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
* use int16_t, etc (stdint)
* finish serializing reads/writes, endian issues
* fix fix fix different size stuff
works alright at some res, but breaks on others currently
add support for resolution changing at any time?
probably will only support 320x200, 640x400, 960x600
* add ylookup? * add ylookup?
* remove farmapylookup? * remove farmapylookup?
* would be nice if Quit() used vsnprintf, etc * would be nice if Quit() used vsnprintf, etc
* actor walking through door is drawn in front of door: near end of E1M1 for * actor walking through door is drawn in front of door: near end of E1M1 for
example (is this reproducible?) example (is this reproducible?)
* getenv so that you can point an env. var to the proper dir
* rewrite hw (sound, input) code, remove stuff like SD_SetSoundMode
* fix the input code, everything is spread out... ideally everything should
work the same, let the input handler do it all instead
i think its safe for now to go with the scancodes as being the "universal"
key type, and for everything not scancode-based, have a function to
translate
* use static and const where appropriate * use static and const where appropriate
* menu code is a mess, always does things differently than the rest of the * menu code is a mess, always does things differently than the rest of the
code, it really needs to be cleaned up code, it really needs to be cleaned up
...@@ -101,3 +120,6 @@ Version 0x00000001 Data: (Official) ...@@ -101,3 +120,6 @@ Version 0x00000001 Data: (Official)
<undetermined but will be compressed> <undetermined but will be compressed>
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
fix:
void ControlMovement(objtype *ob) (wl_agent.c)
void UpdateInput() / void PollControls() (wl_play.c)
#ifndef __ID_HEADS_H__ #ifndef __ID_HEADS_H__
#define __ID_HEADS_H__ #define __ID_HEADS_H__
#ifdef _WIN32 #include <stdio.h>
#include <stdlib.h>
/* TODO: rename dosism, because for example djgpp has glob() */ #include <string.h>
#define DOSISM /* for junk which isn't abstracted (namely stuff in wl_menu.c with glob/findfirst and misc.c) */ #include <time.h>
#undef HAVE_FFBLK /* TODO: what to do with hacks like this */ #include <sys/stat.h>
#include <sys/types.h>
#define WIN32_LEAN_AND_MEAN #include <stdint.h>
#include <windows.h>
#include <io.h>
#include <dos.h>
#ifdef __cplusplus
typedef bool boolean;
#else
#define boolean BOOLEAN
#define false FALSE
#define true TRUE
#endif
#define ssize_t SSIZE_T
#else
#undef DOSISM
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <values.h>
#include <glob.h> #include <glob.h>
#include <ctype.h>
#include <fcntl.h>
#include <math.h>
#ifdef __cplusplus #ifdef __cplusplus
typedef bool boolean; typedef bool boolean;
...@@ -37,20 +21,6 @@ typedef bool boolean; ...@@ -37,20 +21,6 @@ typedef bool boolean;
typedef enum { false, true } boolean; typedef enum { false, true } boolean;
#endif #endif
#endif
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdint.h>
#include <math.h>
#ifndef O_BINARY #ifndef O_BINARY
#define O_BINARY 0 #define O_BINARY 0
#endif #endif
...@@ -115,7 +85,7 @@ int MS_CheckParm(char *string); ...@@ -115,7 +85,7 @@ int MS_CheckParm(char *string);
void Quit(char *error); void Quit(char *error);
#undef PI #undef PI
#define PI 3.141592657 #define PI 3.1415926535897932384626433832795028841971693993751058209749445920
#define MAXTICS 10 #define MAXTICS 10
#define DEMOTICS 4 #define DEMOTICS 4
......
#include "wl_def.h" #include "wl_def.h"
#ifdef DOSISM /* TODO: bad name.. since djgpp code would use interrupt (maybe uclock?) most likely */
#define TICKCOUNT 70
long TimeCount;
double AdjClock = CLOCKS_PER_SEC / TICKCOUNT;
double LastClock;
void set_TimeCount(unsigned long count)
{
/* TODO: would using queryperformancecounter be better? */
TimeCount = count;
LastClock = clock();
}
unsigned long get_TimeCount()
{
return (unsigned long)(TimeCount + ((clock() - LastClock) / AdjClock));
}
#else /* DOSISM */
/* TimeCount from David Haslam -- dch@sirius.demon.co.uk */ /* TimeCount from David Haslam -- dch@sirius.demon.co.uk */
static struct timeval t0; static struct timeval t0;
...@@ -95,8 +73,6 @@ char *ultoa(unsigned long value, char *string, int radix) ...@@ -95,8 +73,6 @@ char *ultoa(unsigned long value, char *string, int radix)
return string; return string;
} }
#endif /* DOSISM */
/* from Dan Olson */ /* from Dan Olson */
static void put_dos2ansi(byte attrib) static void put_dos2ansi(byte attrib)
{ {
......
...@@ -10,8 +10,6 @@ void SavePCXRGBToFile(unsigned char *buf, int width, int height, char *name); ...@@ -10,8 +10,6 @@ void SavePCXRGBToFile(unsigned char *buf, int width, int height, char *name);
void set_TimeCount(unsigned long t); void set_TimeCount(unsigned long t);
unsigned long get_TimeCount(); unsigned long get_TimeCount();
#ifndef DOSISM
long filelength(int handle); long filelength(int handle);
#define stricmp strcasecmp #define stricmp strcasecmp
...@@ -22,8 +20,6 @@ char *itoa(int value, char *string, int radix); ...@@ -22,8 +20,6 @@ char *itoa(int value, char *string, int radix);
char *ltoa(long value, char *string, int radix); char *ltoa(long value, char *string, int radix);
char *ultoa(unsigned long value, char *string, int radix); char *ultoa(unsigned long value, char *string, int radix);
#endif /* DOSISM */
uint16_t SwapInt16L(uint16_t i); uint16_t SwapInt16L(uint16_t i);
uint32_t SwapInt32L(uint32_t i); uint32_t SwapInt32L(uint32_t i);
......
#include "wl_def.h"
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
//
// configuration variables
//
boolean MousePresent;
boolean JoysPresent[MaxJoys];
// Global variables
boolean Keyboard[NumCodes];
boolean Paused;
char LastASCII;
ScanCode LastScan;
KeyboardDef KbdDefs = {sc_Control, sc_Alt, sc_Home, sc_UpArrow, sc_PgUp, sc_LeftArrow, sc_RightArrow, sc_End, sc_DownArrow, sc_PgDn};
ControlType Controls[MaxPlayers];
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
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 ,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
},
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
};
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
};
void keyboard_handler(int code, int press)
{
byte k, c = 0;
k = code;
if (k == 0xe1) // Handle Pause key
Paused = true;
else
{
if (press == 0)
{
Keyboard[k] = false;
}
else // Make code
{
LastCode = CurCode;
CurCode = LastScan = k;
Keyboard[k] = true;
if (k == sc_CapsLock)
{
CapsLock ^= true;
}
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;
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// 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(longword delay)
{
longword lasttime;
lasttime = get_TimeCount();
IN_StartAck();
do {
if (IN_CheckAck())
return true;
} while ( (get_TimeCount() - lasttime) < delay );
return false;
}
//===========================================================================
/*
===================
=
= IN_MouseButtons
=
===================
*/
byte IN_MouseButtons()
{
return 0;
}
/*
===================
=
= IN_JoyButtons
=
===================
*/
byte IN_JoyButtons()
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseDelta() - Gets the amount that the mouse has moved from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static void INL_GetMouseDelta(int *x,int *y)
{
*x = 0;
*y = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseButtons() - Gets the status of the mouse buttons from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static word INL_GetMouseButtons(void)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_GetJoyAbs() - Reads the absolute position of the specified joystick
//
///////////////////////////////////////////////////////////////////////////
void IN_GetJoyAbs(word joy,word *xp,word *yp)
{
*xp = 0;
*yp = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyDelta() - Returns the relative movement of the specified
// joystick (from +/-127)
//
///////////////////////////////////////////////////////////////////////////
void INL_GetJoyDelta(word joy,int *dx,int *dy)
{
*dx = 0;
*dy = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyButtons() - Returns the button status of the specified
// joystick
//
///////////////////////////////////////////////////////////////////////////
static word INL_GetJoyButtons(word joy)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartKbd() - Sets up my keyboard stuff for use
//
///////////////////////////////////////////////////////////////////////////
static void INL_StartKbd(void)
{
IN_ClearKeysDown();
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutKbd() - Restores keyboard control to the BIOS
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutKbd(void)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartMouse() - Detects and sets up the mouse
//
///////////////////////////////////////////////////////////////////////////
static boolean INL_StartMouse(void)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutMouse() - Cleans up after the mouse
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutMouse(void)
{
}
///////////////////////////////////////////////////////////////////////////
//
// 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)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartJoy() - Detects & auto-configures the specified joystick
// The auto-config assumes the joystick is centered
//
///////////////////////////////////////////////////////////////////////////
static boolean INL_StartJoy(word joy)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// 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;
if (MS_CheckParm("nojoy"))
checkjoys = false;
if (MS_CheckParm("nomouse"))
checkmouse = false;
INL_StartKbd();
MousePresent = checkmouse ? INL_StartMouse() : false;
for (i = 0;i < MaxJoys;i++)
JoysPresent[i] = checkjoys ? INL_StartJoy(i) : false;
IN_Started = true;
}
///////////////////////////////////////////////////////////////////////////
//
// 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_ClearKeysDown() - Clears the keyboard array
//
///////////////////////////////////////////////////////////////////////////
void IN_ClearKeysDown(void)
{
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,ControlInfo *info)
{
boolean realdelta = false;
word buttons;
int dx,dy;
Motion mx,my;
ControlType type;
KeyboardDef *def;
dx = dy = 0;
mx = my = motion_None;
buttons = 0;
IN_CheckAck();
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)];
}
///////////////////////////////////////////////////////////////////////////
//
// 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()
{
unsigned i, buttons;
INL_Update();
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()
{
IN_StartAck();
while(!IN_CheckAck()) ;
}
...@@ -47,8 +47,6 @@ typedef int8_t ScanCode; ...@@ -47,8 +47,6 @@ typedef int8_t ScanCode;
#define sc_LShift 0x2a #define sc_LShift 0x2a
#define sc_RShift 0x36 #define sc_RShift 0x36
/* TODO */
/*
#define sc_UpArrow 0x48 #define sc_UpArrow 0x48
#define sc_DownArrow 0x50 #define sc_DownArrow 0x50
#define sc_LeftArrow 0x4b #define sc_LeftArrow 0x4b
...@@ -57,16 +55,6 @@ typedef int8_t ScanCode; ...@@ -57,16 +55,6 @@ typedef int8_t ScanCode;
#define sc_End 0x4f #define sc_End 0x4f
#define sc_PgUp 0x49 #define sc_PgUp 0x49
#define sc_PgDn 0x51 #define sc_PgDn 0x51
*/
/* SVGAlib specific */
#define sc_UpArrow 103
#define sc_DownArrow 108
#define sc_LeftArrow 105
#define sc_RightArrow 106
#define sc_Home 102
#define sc_End 107
#define sc_PgUp 104
#define sc_PgDn 109
#define sc_Insert 0x52 #define sc_Insert 0x52
#define sc_Delete 0x53 #define sc_Delete 0x53
...@@ -163,7 +151,6 @@ typedef struct { ...@@ -163,7 +151,6 @@ typedef struct {
left, right, downleft, down, downright; left, right, downleft, down, downright;
} KeyboardDef; } KeyboardDef;
// Global variables
extern boolean Keyboard[], MousePresent, JoysPresent[]; extern boolean Keyboard[], MousePresent, JoysPresent[];
extern boolean Paused; extern boolean Paused;
...@@ -174,6 +161,8 @@ extern ControlType Controls[MaxPlayers]; ...@@ -174,6 +161,8 @@ extern ControlType Controls[MaxPlayers];
#define IN_KeyDown(code) (Keyboard[(code)]) #define IN_KeyDown(code) (Keyboard[(code)])
extern void INL_Update();
extern void IN_Startup(), IN_Shutdown(), IN_ClearKeysDown(), extern void IN_Startup(), IN_Shutdown(), IN_ClearKeysDown(),
IN_ReadControl(int,ControlInfo *), IN_ReadControl(int,ControlInfo *),
IN_GetJoyAbs(word joy,word *xp,word *yp), IN_GetJoyAbs(word joy,word *xp,word *yp),
...@@ -183,7 +172,6 @@ extern void IN_Startup(), IN_Shutdown(), IN_ClearKeysDown(), ...@@ -183,7 +172,6 @@ extern void IN_Startup(), IN_Shutdown(), IN_ClearKeysDown(),
extern boolean IN_UserInput(longword delay); extern boolean IN_UserInput(longword delay);
extern char *IN_GetScanName(ScanCode); extern char *IN_GetScanName(ScanCode);
byte IN_MouseButtons(); byte IN_MouseButtons();
byte IN_JoyButtons(); byte IN_JoyButtons();
......
...@@ -5,13 +5,8 @@ ...@@ -5,13 +5,8 @@
byte *gfxbuf = NULL; byte *gfxbuf = NULL;
SDL_Surface *surface; SDL_Surface *surface;
/*
========================== void keyboard_handler(int code, int press);
=
= Quit
=
==========================
*/
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
...@@ -20,6 +15,14 @@ int main (int argc, char *argv[]) ...@@ -20,6 +15,14 @@ int main (int argc, char *argv[])
void DisplayTextSplash(byte *text); void DisplayTextSplash(byte *text);
/*
==========================
=
= Quit
=
==========================
*/
void Quit(char *error) void Quit(char *error)
{ {
memptr screen = NULL; memptr screen = NULL;
...@@ -174,74 +177,7 @@ void VL_DirectPlotFlush() ...@@ -174,74 +177,7 @@ void VL_DirectPlotFlush()
SDL_UpdateRect(surface, 0, 0, 0, 0); SDL_UpdateRect(surface, 0, 0, 0, 0);
} }
/* static int XKeysymToScancode(unsigned int keysym)
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
//
// configuration variables
//
boolean MousePresent;
boolean JoysPresent[MaxJoys];
// Global variables
boolean Keyboard[NumCodes];
boolean Paused;
char LastASCII;
ScanCode LastScan;
KeyboardDef KbdDefs = {sc_Control, sc_Alt, sc_Home, sc_UpArrow, sc_PgUp, sc_LeftArrow, sc_RightArrow, sc_End, sc_DownArrow, sc_PgDn};
ControlType Controls[MaxPlayers];
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
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 ,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
},
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
};
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
};
int XKeysymToScancode(unsigned int keysym)
{ {
switch (keysym) { switch (keysym) {
case SDLK_1: case SDLK_1:
...@@ -318,364 +254,14 @@ int XKeysymToScancode(unsigned int keysym) ...@@ -318,364 +254,14 @@ int XKeysymToScancode(unsigned int keysym)
case SDLK_PAUSE: case SDLK_PAUSE:
return 0xE1; return 0xE1;
default: default:
//printf("unknown: %s\n", XKeysymToString(keysym));
return sc_None; return sc_None;
} }
} }
void keyboard_handler(int code, int press) void INL_Update()
{
byte k, c = 0;
k = code;
if (k == 0xe1) // Handle Pause key
Paused = true;
else
{
if (press == 0)
{
Keyboard[k] = false;
}
else // Make code
{
LastCode = CurCode;
CurCode = LastScan = k;
Keyboard[k] = true;
if (k == sc_CapsLock)
{
CapsLock ^= true;
}
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;
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseDelta() - Gets the amount that the mouse has moved from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static void INL_GetMouseDelta(int *x,int *y)
{
*x = 0;
*y = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseButtons() - Gets the status of the mouse buttons from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static word INL_GetMouseButtons(void)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_GetJoyAbs() - Reads the absolute position of the specified joystick
//
///////////////////////////////////////////////////////////////////////////
void IN_GetJoyAbs(word joy,word *xp,word *yp)
{
*xp = 0;
*yp = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyDelta() - Returns the relative movement of the specified
// joystick (from +/-127)
//
///////////////////////////////////////////////////////////////////////////
void INL_GetJoyDelta(word joy,int *dx,int *dy)
{
*dx = 0;
*dy = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyButtons() - Returns the button status of the specified
// joystick
//
///////////////////////////////////////////////////////////////////////////
static word INL_GetJoyButtons(word joy)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartKbd() - Sets up my keyboard stuff for use
//
///////////////////////////////////////////////////////////////////////////
static void INL_StartKbd(void)
{
IN_ClearKeysDown();
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutKbd() - Restores keyboard control to the BIOS
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutKbd(void)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartMouse() - Detects and sets up the mouse
//
///////////////////////////////////////////////////////////////////////////
static boolean INL_StartMouse(void)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutMouse() - Cleans up after the mouse
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutMouse(void)
{
}
///////////////////////////////////////////////////////////////////////////
//
// 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)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartJoy() - Detects & auto-configures the specified joystick
// The auto-config assumes the joystick is centered
//
///////////////////////////////////////////////////////////////////////////
static boolean INL_StartJoy(word joy)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// 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;
if (MS_CheckParm("nojoy"))
checkjoys = false;
if (MS_CheckParm("nomouse"))
checkmouse = false;
INL_StartKbd();
MousePresent = checkmouse ? INL_StartMouse() : false;
for (i = 0;i < MaxJoys;i++)
JoysPresent[i] = checkjoys ? INL_StartJoy(i) : false;
IN_Started = true;
}
///////////////////////////////////////////////////////////////////////////
//
// 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_ClearKeysDown() - Clears the keyboard array
//
///////////////////////////////////////////////////////////////////////////
void IN_ClearKeysDown(void)
{
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,ControlInfo *info)
{
boolean realdelta = false;
word buttons;
int dx,dy;
Motion mx,my;
ControlType type;
KeyboardDef *def;
dx = dy = 0;
mx = my = motion_None;
buttons = 0;
IN_CheckAck();
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)];
}
///////////////////////////////////////////////////////////////////////////
//
// 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()
{ {
SDL_Event event; SDL_Event event;
unsigned i, buttons;
if (SDL_PollEvent(&event)) { if (SDL_PollEvent(&event)) {
do { do {
switch(event.type) { switch(event.type) {
...@@ -690,80 +276,4 @@ boolean IN_CheckAck() ...@@ -690,80 +276,4 @@ boolean IN_CheckAck()
} }
} while (SDL_PollEvent(&event)); } while (SDL_PollEvent(&event));
} }
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()
{
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(longword delay)
{
longword lasttime;
lasttime = get_TimeCount();
IN_StartAck();
do {
if (IN_CheckAck())
return true;
} while ( (get_TimeCount() - lasttime) < delay );
return false;
}
//===========================================================================
/*
===================
=
= IN_MouseButtons
=
===================
*/
byte IN_MouseButtons()
{
return 0;
}
/*
===================
=
= IN_JoyButtons
=
===================
*/
byte IN_JoyButtons()
{
return 0;
} }
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
byte *gfxbuf = NULL; byte *gfxbuf = NULL;
byte *graphmem = NULL; byte *graphmem = NULL;
void keyboard_handler(int code, int press);
void keyboard_handlerx(int code, int press);
void DisplayTextSplash(byte *text);
/* /*
========================== ==========================
= =
...@@ -14,8 +19,6 @@ byte *graphmem = NULL; ...@@ -14,8 +19,6 @@ byte *graphmem = NULL;
========================== ==========================
*/ */
void DisplayTextSplash(byte *text);
void Quit(char *error) void Quit(char *error)
{ {
memptr screen = NULL; memptr screen = NULL;
...@@ -49,10 +52,6 @@ void VL_WaitVBL(int vbls) ...@@ -49,10 +52,6 @@ void VL_WaitVBL(int vbls)
for (i = 0; i < vbls; i++) for (i = 0; i < vbls; i++)
vga_waitretrace(); vga_waitretrace();
// long last = get_TimeCount() + vbls;
// while (last > get_TimeCount()) ;
} }
void VW_UpdateScreen() void VW_UpdateScreen()
...@@ -98,6 +97,9 @@ void VL_Startup() ...@@ -98,6 +97,9 @@ void VL_Startup()
Quit("vga_setlinearaddressing failed!"); Quit("vga_setlinearaddressing failed!");
graphmem = vga_getgraphmem(); graphmem = vga_getgraphmem();
keyboard_init();
keyboard_seteventhandler(keyboard_handlerx);
} }
/* /*
...@@ -110,6 +112,8 @@ void VL_Startup() ...@@ -110,6 +112,8 @@ void VL_Startup()
void VL_Shutdown() void VL_Shutdown()
{ {
keyboard_close();
if (gfxbuf != NULL) { if (gfxbuf != NULL) {
free(gfxbuf); free(gfxbuf);
gfxbuf = NULL; gfxbuf = NULL;
...@@ -117,7 +121,7 @@ void VL_Shutdown() ...@@ -117,7 +121,7 @@ void VL_Shutdown()
vga_setmode(TEXT); vga_setmode(TEXT);
} }
//=========================================================================== /* ======================================================================== */
/* /*
================= =================
...@@ -174,498 +178,45 @@ void VL_DirectPlotFlush() ...@@ -174,498 +178,45 @@ void VL_DirectPlotFlush()
============================================================================= =============================================================================
*/ */
// static int SVGALibToScancode(int key)
// configuration variables {
// switch(key) {
boolean MousePresent; case SCANCODE_BREAK:
boolean JoysPresent[MaxJoys]; case SCANCODE_BREAK_ALTERNATIVE:
return 0xe1; /* paused */
// Global variables case SCANCODE_CURSORBLOCKUP:
boolean Keyboard[NumCodes]; return sc_UpArrow;
boolean Paused; case SCANCODE_CURSORBLOCKDOWN:
char LastASCII; return sc_DownArrow;
ScanCode LastScan; case SCANCODE_CURSORBLOCKLEFT:
return sc_LeftArrow;
KeyboardDef KbdDefs = {sc_Control, sc_Alt, sc_Home, sc_UpArrow, sc_PgUp, sc_LeftArrow, sc_RightArrow, sc_End, sc_DownArrow, sc_PgDn}; case SCANCODE_CURSORBLOCKRIGHT:
return sc_RightArrow;
ControlType Controls[MaxPlayers]; case SCANCODE_HOME:
return sc_Home;
/* case SCANCODE_END:
============================================================================= return sc_End;
case SCANCODE_PAGEUP:
LOCAL VARIABLES return sc_PgUp;
case SCANCODE_PAGEDOWN:
============================================================================= return sc_PgDn;
*/ case SCANCODE_INSERT:
static byte ASCIINames[] = // Unshifted ASCII for scan codes return sc_Insert;
{ case SCANCODE_REMOVE:
// 0 1 2 3 4 5 6 7 8 9 A B C D E F return sc_Delete;
0 ,27 ,'1','2','3','4','5','6','7','8','9','0','-','=',8 ,9 , // 0 default: /* rest should be the same hopefully */
'q','w','e','r','t','y','u','i','o','p','[',']',13 ,0 ,'a','s', // 1 return key;
'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 void keyboard_handlerx(int code, int press)
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 keyboard_handler(SVGALibToScancode(code), press);
}, }
ShiftNames[] = // Shifted ASCII for scan codes
{ void INL_Update()
// 0 1 2 3 4 5 6 7 8 9 A B C D E F {
0 ,27 ,'!','@','#','$','%','^','&','*','(',')','_','+',8 ,9 , // 0 while (keyboard_update()) ; /* get all events */
'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
};
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
};
void keyboard_handler(int code, int press)
{
byte k, c = 0;
k = code;
if ( (k == SCANCODE_BREAK) || (k == SCANCODE_BREAK_ALTERNATIVE) ) // Handle Pause key
Paused = true;
else
{
if (press == 0)
{
Keyboard[k] = false;
}
else // Make code
{
LastCode = CurCode;
CurCode = LastScan = k;
Keyboard[k] = true;
if (k == sc_CapsLock)
{
CapsLock ^= true;
}
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;
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseDelta() - Gets the amount that the mouse has moved from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static void INL_GetMouseDelta(int *x,int *y)
{
*x = 0;
*y = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseButtons() - Gets the status of the mouse buttons from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static word INL_GetMouseButtons(void)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_GetJoyAbs() - Reads the absolute position of the specified joystick
//
///////////////////////////////////////////////////////////////////////////
void IN_GetJoyAbs(word joy,word *xp,word *yp)
{
*xp = 0;
*yp = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyDelta() - Returns the relative movement of the specified
// joystick (from +/-127)
//
///////////////////////////////////////////////////////////////////////////
void INL_GetJoyDelta(word joy,int *dx,int *dy)
{
*dx = 0;
*dy = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyButtons() - Returns the button status of the specified
// joystick
//
///////////////////////////////////////////////////////////////////////////
static word INL_GetJoyButtons(word joy)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartKbd() - Sets up my keyboard stuff for use
//
///////////////////////////////////////////////////////////////////////////
static void INL_StartKbd(void)
{
keyboard_init();
keyboard_seteventhandler(keyboard_handler);
IN_ClearKeysDown();
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutKbd() - Restores keyboard control to the BIOS
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutKbd(void)
{
keyboard_close();
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartMouse() - Detects and sets up the mouse
//
///////////////////////////////////////////////////////////////////////////
static boolean INL_StartMouse(void)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutMouse() - Cleans up after the mouse
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutMouse(void)
{
}
///////////////////////////////////////////////////////////////////////////
//
// 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)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartJoy() - Detects & auto-configures the specified joystick
// The auto-config assumes the joystick is centered
//
///////////////////////////////////////////////////////////////////////////
static boolean INL_StartJoy(word joy)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// 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;
if (MS_CheckParm("nojoy"))
checkjoys = false;
if (MS_CheckParm("nomouse"))
checkmouse = false;
INL_StartKbd();
MousePresent = checkmouse ? INL_StartMouse() : false;
for (i = 0;i < MaxJoys;i++)
JoysPresent[i] = checkjoys ? INL_StartJoy(i) : false;
IN_Started = true;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_Shutdown() - Shuts down the Input Mgr
//
///////////////////////////////////////////////////////////////////////////
void IN_Shutdown()
{
word i;
if (!IN_Started)
return;
INL_ShutMouse();
for (i = 0;i < MaxJoys;i++)
INL_ShutJoy(i);
INL_ShutKbd();
IN_Started = false;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_ClearKeysDown() - Clears the keyboard array
//
///////////////////////////////////////////////////////////////////////////
void IN_ClearKeysDown()
{
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,ControlInfo *info)
{
boolean realdelta = false;
word buttons;
int dx,dy;
Motion mx,my;
ControlType type;
KeyboardDef *def;
dx = dy = 0;
mx = my = motion_None;
buttons = 0;
IN_CheckAck();
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)];
}
///////////////////////////////////////////////////////////////////////////
//
// 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()
{
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()
{
unsigned i,buttons;
while (keyboard_update()) ; /* get all events */
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 ();
// return; /* TODO: fix when keyboard implemented */
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(longword delay)
{
longword lasttime;
lasttime = get_TimeCount();
IN_StartAck ();
do {
if (IN_CheckAck())
return true;
} while ( (get_TimeCount() - lasttime) < delay );
return false;
}
//===========================================================================
/*
===================
=
= IN_MouseButtons
=
===================
*/
byte IN_MouseButtons (void)
{
return 0;
}
/*
===================
=
= IN_JoyButtons
=
===================
*/
byte IN_JoyButtons()
{
return 0;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
......
...@@ -356,7 +356,7 @@ void VW_UpdateScreen() ...@@ -356,7 +356,7 @@ void VW_UpdateScreen()
} }
void keyboard_handler(int code, int press); void keyboard_handler(int code, int press);
int XKeysymToScancode(KeySym keysym); static int XKeysymToScancode(KeySym keysym);
static void HandleXEvents() static void HandleXEvents()
{ {
...@@ -496,7 +496,6 @@ void Quit(char *error) ...@@ -496,7 +496,6 @@ void Quit(char *error)
ShutdownId(); ShutdownId();
if (screen) { if (screen) {
//printf("TODO: spiffy ansi screen goes here..\n");
DisplayTextSplash(screen, l); DisplayTextSplash(screen, l);
} }
...@@ -532,74 +531,7 @@ void VL_DirectPlotFlush() ...@@ -532,74 +531,7 @@ void VL_DirectPlotFlush()
{ {
} }
/* static int XKeysymToScancode(KeySym keysym)
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
//
// configuration variables
//
boolean MousePresent;
boolean JoysPresent[MaxJoys];
// Global variables
boolean Keyboard[NumCodes];
boolean Paused;
char LastASCII;
ScanCode LastScan;
KeyboardDef KbdDefs = {sc_Control, sc_Alt, sc_Home, sc_UpArrow, sc_PgUp, sc_LeftArrow, sc_RightArrow, sc_End, sc_DownArrow, sc_PgDn};
ControlType Controls[MaxPlayers];
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
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 ,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
},
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
};
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
};
int XKeysymToScancode(KeySym keysym)
{ {
switch (keysym) { switch (keysym) {
case XK_1: case XK_1:
...@@ -696,432 +628,7 @@ int XKeysymToScancode(KeySym keysym) ...@@ -696,432 +628,7 @@ int XKeysymToScancode(KeySym keysym)
} }
} }
void keyboard_handler(int code, int press) void INL_Update()
{
byte k, c = 0;
k = code;
if (k == 0xE1) // Handle Pause key
Paused = true;
else
{
if (press == 0)
{
Keyboard[k] = false;
}
else // Make code
{
LastCode = CurCode;
CurCode = LastScan = k;
Keyboard[k] = true;
if (k == sc_CapsLock)
{
CapsLock ^= true;
}
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;
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseDelta() - Gets the amount that the mouse has moved from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static void INL_GetMouseDelta(int *x,int *y)
{
*x = 0;
*y = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseButtons() - Gets the status of the mouse buttons from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static word INL_GetMouseButtons(void)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_GetJoyAbs() - Reads the absolute position of the specified joystick
//
///////////////////////////////////////////////////////////////////////////
void IN_GetJoyAbs(word joy,word *xp,word *yp)
{
*xp = 0;
*yp = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyDelta() - Returns the relative movement of the specified
// joystick (from +/-127)
//
///////////////////////////////////////////////////////////////////////////
void INL_GetJoyDelta(word joy,int *dx,int *dy)
{
*dx = 0;
*dy = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyButtons() - Returns the button status of the specified
// joystick
//
///////////////////////////////////////////////////////////////////////////
static word INL_GetJoyButtons(word joy)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartKbd() - Sets up my keyboard stuff for use
//
///////////////////////////////////////////////////////////////////////////
static void INL_StartKbd(void)
{
IN_ClearKeysDown();
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutKbd() - Restores keyboard control to the BIOS
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutKbd(void)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartMouse() - Detects and sets up the mouse
//
///////////////////////////////////////////////////////////////////////////
static boolean INL_StartMouse(void)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutMouse() - Cleans up after the mouse
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutMouse(void)
{
}
///////////////////////////////////////////////////////////////////////////
//
// 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)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartJoy() - Detects & auto-configures the specified joystick
// The auto-config assumes the joystick is centered
//
///////////////////////////////////////////////////////////////////////////
static boolean INL_StartJoy(word joy)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// 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;
if (MS_CheckParm("nojoy"))
checkjoys = false;
if (MS_CheckParm("nomouse"))
checkmouse = false;
INL_StartKbd();
MousePresent = checkmouse ? INL_StartMouse() : false;
for (i = 0;i < MaxJoys;i++)
JoysPresent[i] = checkjoys ? INL_StartJoy(i) : false;
IN_Started = true;
}
///////////////////////////////////////////////////////////////////////////
//
// 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_ClearKeysDown() - Clears the keyboard array
//
///////////////////////////////////////////////////////////////////////////
void IN_ClearKeysDown(void)
{
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,ControlInfo *info)
{
boolean realdelta = false;
word buttons;
int dx,dy;
Motion mx,my;
ControlType type;
KeyboardDef *def;
dx = dy = 0;
mx = my = motion_None;
buttons = 0;
IN_CheckAck();
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)];
}
///////////////////////////////////////////////////////////////////////////
//
// 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()
{ {
unsigned i, buttons;
HandleXEvents(); HandleXEvents();
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()
{
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(longword delay)
{
longword lasttime;
lasttime = get_TimeCount();
IN_StartAck();
do {
if (IN_CheckAck())
return true;
} while ( (get_TimeCount() - lasttime) < delay );
return false;
}
//===========================================================================
/*
===================
=
= IN_MouseButtons
=
===================
*/
byte IN_MouseButtons (void)
{
return 0;
}
/*
===================
=
= IN_JoyButtons
=
===================
*/
byte IN_JoyButtons (void)
{
return 0;
} }
...@@ -106,7 +106,7 @@ void CheckWeaponChange() ...@@ -106,7 +106,7 @@ void CheckWeaponChange()
======================= =======================
*/ */
void ControlMovement (objtype *ob) void ControlMovement(objtype *ob)
{ {
int angle; int angle;
int angleunits; int angleunits;
...@@ -1221,7 +1221,7 @@ void T_Attack(objtype *ob) ...@@ -1221,7 +1221,7 @@ void T_Attack(objtype *ob)
if ( buttonstate[bt_attack] && !buttonheld[bt_attack]) if ( buttonstate[bt_attack] && !buttonheld[bt_attack])
buttonstate[bt_attack] = false; buttonstate[bt_attack] = false;
ControlMovement (ob); ControlMovement(ob);
if (gamestate.victoryflag) // watching the BJ actor if (gamestate.victoryflag) // watching the BJ actor
return; return;
......
...@@ -338,7 +338,7 @@ static void DrawScaleds() ...@@ -338,7 +338,7 @@ static void DrawScaleds()
} }
//========================================================================== /* ======================================================================== */
/* /*
============== ==============
...@@ -662,51 +662,51 @@ static void ScaledDrawTrans(byte *gfx, int count, byte *vid, unsigned int frac, ...@@ -662,51 +662,51 @@ static void ScaledDrawTrans(byte *gfx, int count, byte *vid, unsigned int frac,
static void ScaleLine(unsigned int height, byte *source, int x) static void ScaleLine(unsigned int height, byte *source, int x)
{ {
unsigned long TheFrac; unsigned int y, frac, delta;
unsigned long y;
if (height) { if (height) {
TheFrac = (64 << 16) / height; frac = (64 << 16) / height;
delta = (64 << 16) - frac*height;
if (height < viewheight) { if (height < viewheight) {
y = yoffset + (viewheight - height) / 2; y = yoffset + (viewheight - height) / 2;
ScaledDraw(source, height, gfxbuf + (y * vwidth) + x + xoffset, ScaledDraw(source, height, gfxbuf + (y * vwidth) + x + xoffset,
0, TheFrac); delta, frac);
return; return;
} }
y = (height - viewheight) / 2; y = (height - viewheight) / 2;
y *= TheFrac; y *= frac;
ScaledDraw(source, viewheight, gfxbuf + (yoffset * vwidth) + x + xoffset, ScaledDraw(source, viewheight, gfxbuf + (yoffset * vwidth) + x + xoffset,
y, TheFrac); y+delta, frac);
} }
} }
static void ScaleLineTrans(unsigned int height, byte *source, int x) static void ScaleLineTrans(unsigned int height, byte *source, int x)
{ {
unsigned long TheFrac; unsigned int y, frac, delta;
unsigned long y;
if (height) { if (height) {
TheFrac = (64 << 16) / height; frac = (64 << 16) / height;
delta = (64 << 16) - frac*height;
if (height < viewheight) { if (height < viewheight) {
y = yoffset + (viewheight - height) / 2; y = yoffset + (viewheight - height) / 2;
ScaledDrawTrans(source, height, gfxbuf + (y * vwidth) + x + xoffset, ScaledDrawTrans(source, height, gfxbuf + (y * vwidth) + x + xoffset,
0, TheFrac); delta, frac);
return; return;
} }
y = (height - viewheight) / 2; y = (height - viewheight) / 2;
y *= TheFrac; y *= frac;
ScaledDrawTrans(&source[y >> 24], viewheight, gfxbuf + (yoffset * vwidth) + x + xoffset, ScaledDrawTrans(&source[y >> 24], viewheight, gfxbuf + (yoffset * vwidth) + x + xoffset,
y, TheFrac); y+delta, frac);
} }
} }
...@@ -1047,9 +1047,9 @@ static void AsmRefresh() ...@@ -1047,9 +1047,9 @@ static void AsmRefresh()
int xstep, ystep; int xstep, ystep;
midangle = viewangle*(FINEANGLES/ANGLES); midangle = viewangle*(FINEANGLES/ANGLES);
xpartialdown = viewx&(TILEGLOBAL-1); xpartialdown = (viewx&(TILEGLOBAL-1));
xpartialup = TILEGLOBAL-xpartialdown; xpartialup = TILEGLOBAL-xpartialdown;
ypartialdown = viewy&(TILEGLOBAL-1); ypartialdown = (viewy&(TILEGLOBAL-1));
ypartialup = TILEGLOBAL-ypartialdown; ypartialup = TILEGLOBAL-ypartialdown;
focaltx = viewx>>TILESHIFT; focaltx = viewx>>TILESHIFT;
...@@ -1101,11 +1101,11 @@ for (postx = 0; postx < viewwidth; postx++) { ...@@ -1101,11 +1101,11 @@ for (postx = 0; postx < viewwidth; postx++) {
goto entry90; goto entry90;
} }
/* add tilestep to fix raycasting problems? */
yintercept = viewy + xpartialbyystep(); yintercept = viewy + xpartialbyystep(); // + xtilestep;
xtile = focaltx + xtilestep; xtile = focaltx + xtilestep;
xintercept = viewx + ypartialbyxstep(); xintercept = viewx + ypartialbyxstep(); // + ytilestep;
ytile = focalty + ytilestep; ytile = focalty + ytilestep;
/* CORE LOOP */ /* CORE LOOP */
...@@ -1113,12 +1113,13 @@ for (postx = 0; postx < viewwidth; postx++) { ...@@ -1113,12 +1113,13 @@ for (postx = 0; postx < viewwidth; postx++) {
#define TILE(n) ((n)>>16) #define TILE(n) ((n)>>16)
/* check intersections with vertical walls */ /* check intersections with vertical walls */
vertcheck: vertcheck:
if (!samey(yintercept, ytile)) if (!samey(yintercept, ytile))
goto horizentry; goto horizentry;
vertentry: vertentry:
tilehit = tilemap[xtile][TILE(yintercept)]; tilehit = tilemap[xtile][TILE(yintercept)];
/* printf("vert: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", postx, tilehit, xtile, ytile, xintercept, yintercept, xpartialup, xpartialdown, ypartialup, ypartialdown, xpartial, ypartial, doorhit, angle, midangle, focaltx, focalty, xstep, ystep); */
if (tilehit) { if (tilehit) {
if (tilehit & 0x80) { if (tilehit & 0x80) {
...@@ -1167,6 +1168,7 @@ horizcheck: ...@@ -1167,6 +1168,7 @@ horizcheck:
horizentry: horizentry:
tilehit = tilemap[TILE(xintercept)][ytile]; tilehit = tilemap[TILE(xintercept)][ytile];
/* printf("horz: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", postx, tilehit, xtile, ytile, xintercept, yintercept, xpartialup, xpartialdown, ypartialup, ypartialdown, xpartial, ypartial, doorhit, angle, midangle, focaltx, focalty, xstep, ystep); */
if (tilehit) { if (tilehit) {
if (tilehit & 0x80) { if (tilehit & 0x80) {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
============================================================================= =============================================================================
*/ */
#define FOCALLENGTH (0x5700l) // in global coordinates #define FOCALLENGTH 0x5700 // in global coordinates
#define VIEWGLOBAL 0x10000 // globals visable flush to wall #define VIEWGLOBAL 0x10000 // globals visable flush to wall
char str[80], str2[20]; char str[80], str2[20];
...@@ -26,7 +26,7 @@ int vwidth, vheight; /* size of screen */ ...@@ -26,7 +26,7 @@ int vwidth, vheight; /* size of screen */
int viewsize; int viewsize;
int centerx; int centerx;
int shootdelta; // pixels away from centerx a target can be int shootdelta; /* pixels away from centerx a target can be */
fixed scale; fixed scale;
long heightnumerator; long heightnumerator;
...@@ -36,7 +36,7 @@ int mouseadjustment; ...@@ -36,7 +36,7 @@ int mouseadjustment;
long frameon; long frameon;
long lasttimecount; long lasttimecount;
fixed viewsin, viewcos; fixed viewsin, viewcos;
fixed viewx, viewy; // the focal point fixed viewx, viewy; /* the focal point */
int pixelangle[MAXVIEWWIDTH]; int pixelangle[MAXVIEWWIDTH];
long finetangent[FINEANGLES/4]; long finetangent[FINEANGLES/4];
int horizwall[MAXWALLTILES], vertwall[MAXWALLTILES]; int horizwall[MAXWALLTILES], vertwall[MAXWALLTILES];
...@@ -762,7 +762,6 @@ int MS_CheckParm(char *check) ...@@ -762,7 +762,6 @@ int MS_CheckParm(char *check)
static int wolfdigimap[] = static int wolfdigimap[] =
{ {
// These first sounds are in the upload version
#ifndef SPEAR #ifndef SPEAR
HALTSND, 0, HALTSND, 0,
DOGBARKSND, 1, DOGBARKSND, 1,
...@@ -786,7 +785,6 @@ static int wolfdigimap[] = ...@@ -786,7 +785,6 @@ static int wolfdigimap[] =
SLURPIESND, 22, SLURPIESND, 22,
YEAHSND, 32, YEAHSND, 32,
#ifndef UPLOAD #ifndef UPLOAD
// These are in all other episodes
DOGDEATHSND, 16, DOGDEATHSND, 16,
AHHHGSND, 17, AHHHGSND, 17,
DIESND, 18, DIESND, 18,
...@@ -815,10 +813,8 @@ static int wolfdigimap[] = ...@@ -815,10 +813,8 @@ static int wolfdigimap[] =
MEINSND, 44, // EPISODE 6 BOSS DIE MEINSND, 44, // EPISODE 6 BOSS DIE
ROSESND, 45, // EPISODE 5 BOSS DIE ROSESND, 45, // EPISODE 5 BOSS DIE
#endif #endif
#else
// #else /* SPEAR OF DESTINY DIGISOUNDS */
// SPEAR OF DESTINY DIGISOUNDS
//
HALTSND, 0, HALTSND, 0,
CLOSEDOORSND, 2, CLOSEDOORSND, 2,
OPENDOORSND, 3, OPENDOORSND, 3,
...@@ -866,7 +862,6 @@ static int wolfdigimap[] = ...@@ -866,7 +862,6 @@ static int wolfdigimap[] =
LASTSOUND LASTSOUND
}; };
void InitDigiMap() void InitDigiMap()
{ {
int *map; int *map;
...@@ -875,7 +870,7 @@ void InitDigiMap() ...@@ -875,7 +870,7 @@ void InitDigiMap()
DigiMap[map[0]] = map[1]; DigiMap[map[0]] = map[1];
} }
//=========================================================================== /* ======================================================================== */
/* /*
================== ==================
...@@ -895,14 +890,15 @@ void BuildTables() ...@@ -895,14 +890,15 @@ void BuildTables()
/* calculate fine tangents */ /* calculate fine tangents */
for (i = 0; i < FINEANGLES/8; i++) { finetangent[0] = 0;
for (i = 1; i < FINEANGLES/8; i++) {
tang = tan((double)i/radtoint); tang = tan((double)i/radtoint);
finetangent[i] = tang*TILEGLOBAL; finetangent[i] = tang*TILEGLOBAL;
finetangent[FINEANGLES/4-1-i] = 1/tang*TILEGLOBAL; finetangent[FINEANGLES/4-1-i] = TILEGLOBAL/tang;
} }
/* fight off asymptotic behaviour at 90 degrees */ /* fight off asymptotic behaviour at 90 degrees */
finetangent[FINEANGLES/4-1] = finetangent[FINEANGLES/4-2]; finetangent[FINEANGLES/4-1] = finetangent[FINEANGLES/4-2]+1;
// //
// costable overlays sintable with a quarter phase shift // costable overlays sintable with a quarter phase shift
...@@ -1085,7 +1081,7 @@ CP_itemtype MusicMenu[]= ...@@ -1085,7 +1081,7 @@ CP_itemtype MusicMenu[]=
}; };
#endif #endif
static int songs[]= static const int songs[] =
{ {
#ifndef SPEAR #ifndef SPEAR
GETTHEM_MUS, GETTHEM_MUS,
...@@ -1418,7 +1414,7 @@ void DemoLoop() ...@@ -1418,7 +1414,7 @@ void DemoLoop()
VW_FadeOut(); VW_FadeOut();
if (IN_KeyDown(sc_Tab) && MS_CheckParm("debugmode")) if (IN_KeyDown(sc_Tab) && MS_CheckParm("debugmode"))
RecordDemo (); RecordDemo();
else else
US_ControlPanel(0); US_ControlPanel(0);
...@@ -1432,7 +1428,7 @@ void DemoLoop() ...@@ -1432,7 +1428,7 @@ void DemoLoop()
} }
//=========================================================================== /* ======================================================================== */
/* /*
......
...@@ -220,7 +220,7 @@ static char ...@@ -220,7 +220,7 @@ static char
{ {
1,0xe,0xf,0x1d,sc_LShift,0x39,0x3a,0x3b,0x3c,0x3d,0x3e, 1,0xe,0xf,0x1d,sc_LShift,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,
0x3f,0x40,0x41,0x42,0x43,0x44,0x57,0x59,0x46,0x1c,sc_RShift, 0x3f,0x40,0x41,0x42,0x43,0x44,0x57,0x59,0x46,0x1c,sc_RShift,
0x37,0x38,0x47,0x49,0x4f,0x51,0x52,0x53,0x45,sc_UpArrow, 0x37,0x38,sc_Home,sc_PgUp,sc_End,sc_PgDn,sc_Insert,sc_Delete,0x45,sc_UpArrow,
sc_DownArrow,sc_LeftArrow,sc_RightArrow,0x00 sc_DownArrow,sc_LeftArrow,sc_RightArrow,0x00
}, },
*ExtScanNames[] = // Names corresponding to ExtScanCodes *ExtScanNames[] = // Names corresponding to ExtScanCodes
......
...@@ -47,7 +47,7 @@ memptr demobuffer; ...@@ -47,7 +47,7 @@ memptr demobuffer;
// //
// curent user input // curent user input
// //
int controlx,controly; // range from -100 to 100 per tic int controlx,controly; /* range from -100 to 100 per tic */
boolean buttonstate[NUMBUTTONS]; boolean buttonstate[NUMBUTTONS];
static void RemoveObj(objtype *gone); static void RemoveObj(objtype *gone);
...@@ -61,7 +61,7 @@ static void RemoveObj(objtype *gone); ...@@ -61,7 +61,7 @@ static void RemoveObj(objtype *gone);
*/ */
/* LIST OF SONGS FOR EACH VERSION */ /* LIST OF SONGS FOR EACH VERSION */
static int songs[]= static const int songs[]=
{ {
#ifndef SPEAR #ifndef SPEAR
/* Episode One */ /* Episode One */
...@@ -263,7 +263,6 @@ void PollJoystickButtons() ...@@ -263,7 +263,6 @@ void PollJoystickButtons()
} }
} }
/* /*
=================== ===================
= =
...@@ -315,8 +314,6 @@ void PollMouseMove() ...@@ -315,8 +314,6 @@ void PollMouseMove()
controly += mouseymove*20/(13-mouseadjustment); controly += mouseymove*20/(13-mouseadjustment);
} }
/* /*
=================== ===================
= =
...@@ -355,6 +352,30 @@ void PollJoystickMove() ...@@ -355,6 +352,30 @@ void PollJoystickMove()
} }
} }
void UpdateInput()
{
//
// get button states
//
PollKeyboardButtons();
if (mouseenabled)
PollMouseButtons();
if (joystickenabled)
PollJoystickButtons();
//
// get movements
//
PollKeyboardMove();
if (mouseenabled)
PollMouseMove();
if (joystickenabled)
PollJoystickMove();
}
/* /*
=================== ===================
...@@ -404,32 +425,10 @@ void PollControls() ...@@ -404,32 +425,10 @@ void PollControls()
return; return;
} }
//
// get button states
//
/* Update keys */ /* Update keys */
IN_CheckAck(); IN_CheckAck();
PollKeyboardButtons(); UpdateInput();
if (mouseenabled)
PollMouseButtons();
if (joystickenabled)
PollJoystickButtons();
//
// get movements
//
PollKeyboardMove();
if (mouseenabled)
PollMouseMove();
if (joystickenabled)
PollJoystickMove();
// //
// bound movement to a maximum // bound movement to a maximum
...@@ -740,9 +739,7 @@ void InitActorList() ...@@ -740,9 +739,7 @@ void InitActorList()
objfreelist = &objlist[0]; objfreelist = &objlist[0];
lastobj = NULL; lastobj = NULL;
// /* give the player the first free spots */
// give the player the first free spots
//
GetNewActor(); GetNewActor();
player = new; player = new;
...@@ -799,7 +796,7 @@ void GetNewActor() ...@@ -799,7 +796,7 @@ void GetNewActor()
static void RemoveObj(objtype *gone) static void RemoveObj(objtype *gone)
{ {
if (gone == player) if (gone == player)
Quit ("RemoveObj: Tried to remove the player!"); Quit("RemoveObj: Tried to remove the player!");
gone->state = s_none; gone->state = s_none;
......
...@@ -102,7 +102,7 @@ void NewState(objtype *ob, int state) /* stateenum */ ...@@ -102,7 +102,7 @@ void NewState(objtype *ob, int state) /* stateenum */
= ob->tilex = new destination = ob->tilex = new destination
= ob->tiley = ob->tiley
= ob->areanumber = the floor tile number (0-(NUMAREAS-1)) of destination = ob->areanumber = the floor tile number (0-(NUMAREAS-1)) of destination
= ob->distance = TILEGLOBAl, or -doornumber if a door is blocking the way = ob->distance = TILEGLOBAL, or -doornumber if a door is blocking the way
= =
= If a door is in the way, an OpenDoor call is made to start it opening. = If a door is in the way, an OpenDoor call is made to start it opening.
= The actor code should wait until = The actor code should wait until
......
...@@ -557,7 +557,7 @@ void CacheLayoutGraphics() ...@@ -557,7 +557,7 @@ void CacheLayoutGraphics()
} }
if (ch == 'T') // timed draw graphic command, so mark graphics if (ch == 'T') // timed draw graphic command, so mark graphics
{ {
ParseTimedCommand (); ParseTimedCommand();
CA_CacheGrChunk(picnum); CA_CacheGrChunk(picnum);
} }
} }
...@@ -580,7 +580,7 @@ void CacheLayoutGraphics() ...@@ -580,7 +580,7 @@ void CacheLayoutGraphics()
void ShowArticle(char *article) void ShowArticle(char *article)
{ {
unsigned oldfontnumber; unsigned oldfontnumber;
boolean newpage,firstpage; boolean newpage, firstpage;
text = article; text = article;
...@@ -588,7 +588,7 @@ void ShowArticle(char *article) ...@@ -588,7 +588,7 @@ void ShowArticle(char *article)
fontnumber = 0; fontnumber = 0;
CA_CacheGrChunk(STARTFONT); CA_CacheGrChunk(STARTFONT);
VW_Bar (0,0,320,200,BACKCOLOR); VW_Bar (0,0,320,200,BACKCOLOR);
CacheLayoutGraphics (); CacheLayoutGraphics();
newpage = true; newpage = true;
firstpage = true; firstpage = true;
...@@ -598,18 +598,17 @@ void ShowArticle(char *article) ...@@ -598,18 +598,17 @@ void ShowArticle(char *article)
if (newpage) if (newpage)
{ {
newpage = false; newpage = false;
PageLayout (true); PageLayout(true);
VW_UpdateScreen (); VW_UpdateScreen();
if (firstpage) if (firstpage)
{ {
VL_FadeIn(0,255,gamepal,10); VL_FadeIn(0,255,gamepal,10);
// VW_FadeIn ()
firstpage = false; firstpage = false;
} }
} }
LastScan = 0; LastScan = 0;
while (!LastScan) IN_CheckAck(); /* TODO: update events */ while (!LastScan) IN_CheckAck(); /* update events */
switch (LastScan) switch (LastScan)
{ {
...@@ -627,7 +626,7 @@ void ShowArticle(char *article) ...@@ -627,7 +626,7 @@ void ShowArticle(char *article)
case sc_Enter: case sc_Enter:
case sc_DownArrow: case sc_DownArrow:
case sc_PgDn: case sc_PgDn:
case sc_RightArrow: // the text allready points at next page case sc_RightArrow: // the text already points at next page
if (pagenum<numpages) if (pagenum<numpages)
{ {
newpage = true; newpage = true;
...@@ -645,10 +644,10 @@ void ShowArticle(char *article) ...@@ -645,10 +644,10 @@ void ShowArticle(char *article)
} }
//=========================================================================== /* ======================================================================== */
int endextern = T_ENDART1; #define endextern T_ENDART1
int helpextern = T_HELPART; #define helpextern T_HELPART
/* /*
================= =================
...@@ -691,7 +690,7 @@ void EndText() ...@@ -691,7 +690,7 @@ void EndText()
CA_UpLevel(); CA_UpLevel();
artnum = endextern+gamestate.episode; artnum = endextern+gamestate.episode;
CA_CacheGrChunk (artnum); CA_CacheGrChunk(artnum);
text = (char *)grsegs[artnum]; text = (char *)grsegs[artnum];
ShowArticle(text); ShowArticle(text);
......
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