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
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_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
SOBJS = $(OBJS) $(ROBJS) vi_svga.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:
* TODO
Sound Menu:
* Sound Effects:
- PCM
- OPL2
* Digital Sound Effects:
- On [PCM]
- Off
* Sound Effects
- On [AdLib/OPL2]
- PC Speaker?
- None
- Off
* Music:
- OPL2
- None
* Sampling Rate:
- 44100
- 22050
- On [AdLib/OPL2]
- Off
------------------------------------------------------------------------------
* 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?
* remove farmapylookup?
* would be nice if Quit() used vsnprintf, etc
* actor walking through door is drawn in front of door: near end of E1M1 for
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
* menu code is a mess, always does things differently than the rest of the
code, it really needs to be cleaned up
......@@ -101,3 +120,6 @@ Version 0x00000001 Data: (Official)
<undetermined but will be compressed>
------------------------------------------------------------------------------
fix:
void ControlMovement(objtype *ob) (wl_agent.c)
void UpdateInput() / void PollControls() (wl_play.c)
#ifndef __ID_HEADS_H__
#define __ID_HEADS_H__
#ifdef _WIN32
/* TODO: rename dosism, because for example djgpp has glob() */
#define DOSISM /* for junk which isn't abstracted (namely stuff in wl_menu.c with glob/findfirst and misc.c) */
#undef HAVE_FFBLK /* TODO: what to do with hacks like this */
#define WIN32_LEAN_AND_MEAN
#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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/time.h>
#include <values.h>
#include <glob.h>
#include <ctype.h>
#include <fcntl.h>
#include <math.h>
#ifdef __cplusplus
typedef bool boolean;
......@@ -37,20 +21,6 @@ typedef bool boolean;
typedef enum { false, true } boolean;
#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
#define O_BINARY 0
#endif
......@@ -115,7 +85,7 @@ int MS_CheckParm(char *string);
void Quit(char *error);
#undef PI
#define PI 3.141592657
#define PI 3.1415926535897932384626433832795028841971693993751058209749445920
#define MAXTICS 10
#define DEMOTICS 4
......
#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 */
static struct timeval t0;
......@@ -95,8 +73,6 @@ char *ultoa(unsigned long value, char *string, int radix)
return string;
}
#endif /* DOSISM */
/* from Dan Olson */
static void put_dos2ansi(byte attrib)
{
......
......@@ -10,8 +10,6 @@ void SavePCXRGBToFile(unsigned char *buf, int width, int height, char *name);
void set_TimeCount(unsigned long t);
unsigned long get_TimeCount();
#ifndef DOSISM
long filelength(int handle);
#define stricmp strcasecmp
......@@ -22,8 +20,6 @@ char *itoa(int value, char *string, int radix);
char *ltoa(long value, char *string, int radix);
char *ultoa(unsigned long value, char *string, int radix);
#endif /* DOSISM */
uint16_t SwapInt16L(uint16_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;
#define sc_LShift 0x2a
#define sc_RShift 0x36
/* TODO */
/*
#define sc_UpArrow 0x48
#define sc_DownArrow 0x50
#define sc_LeftArrow 0x4b
......@@ -57,16 +55,6 @@ typedef int8_t ScanCode;
#define sc_End 0x4f
#define sc_PgUp 0x49
#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_Delete 0x53
......@@ -163,7 +151,6 @@ typedef struct {
left, right, downleft, down, downright;
} KeyboardDef;
// Global variables
extern boolean Keyboard[], MousePresent, JoysPresent[];
extern boolean Paused;
......@@ -174,6 +161,8 @@ extern ControlType Controls[MaxPlayers];
#define IN_KeyDown(code) (Keyboard[(code)])
extern void INL_Update();
extern void IN_Startup(), IN_Shutdown(), IN_ClearKeysDown(),
IN_ReadControl(int,ControlInfo *),
IN_GetJoyAbs(word joy,word *xp,word *yp),
......@@ -183,7 +172,6 @@ extern void IN_Startup(), IN_Shutdown(), IN_ClearKeysDown(),
extern boolean IN_UserInput(longword delay);
extern char *IN_GetScanName(ScanCode);
byte IN_MouseButtons();
byte IN_JoyButtons();
......
......@@ -5,13 +5,8 @@
byte *gfxbuf = NULL;
SDL_Surface *surface;
/*
==========================
=
= Quit
=
==========================
*/
void keyboard_handler(int code, int press);
int main (int argc, char *argv[])
{
......@@ -20,6 +15,14 @@ int main (int argc, char *argv[])
void DisplayTextSplash(byte *text);
/*
==========================
=
= Quit
=
==========================
*/
void Quit(char *error)
{
memptr screen = NULL;
......@@ -174,74 +177,7 @@ void VL_DirectPlotFlush()
SDL_UpdateRect(surface, 0, 0, 0, 0);
}
/*
=============================================================================
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)
static int XKeysymToScancode(unsigned int keysym)
{
switch (keysym) {
case SDLK_1:
......@@ -318,364 +254,14 @@ int XKeysymToScancode(unsigned int keysym)
case SDLK_PAUSE:
return 0xE1;
default:
//printf("unknown: %s\n", XKeysymToString(keysym));
return sc_None;
}
}
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;
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// 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()
void INL_Update()
{
SDL_Event event;
unsigned i, buttons;
if (SDL_PollEvent(&event)) {
do {
switch(event.type) {
......@@ -690,80 +276,4 @@ boolean IN_CheckAck()
}
} 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 @@
byte *gfxbuf = 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;
==========================
*/
void DisplayTextSplash(byte *text);
void Quit(char *error)
{
memptr screen = NULL;
......@@ -49,10 +52,6 @@ void VL_WaitVBL(int vbls)
for (i = 0; i < vbls; i++)
vga_waitretrace();
// long last = get_TimeCount() + vbls;
// while (last > get_TimeCount()) ;
}
void VW_UpdateScreen()
......@@ -98,6 +97,9 @@ void VL_Startup()
Quit("vga_setlinearaddressing failed!");
graphmem = vga_getgraphmem();
keyboard_init();
keyboard_seteventhandler(keyboard_handlerx);
}
/*
......@@ -110,6 +112,8 @@ void VL_Startup()
void VL_Shutdown()
{
keyboard_close();
if (gfxbuf != NULL) {
free(gfxbuf);
gfxbuf = NULL;
......@@ -117,7 +121,7 @@ void VL_Shutdown()
vga_setmode(TEXT);
}
//===========================================================================
/* ======================================================================== */
/*
=================
......@@ -174,498 +178,45 @@ void VL_DirectPlotFlush()
=============================================================================
*/
//
// 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 == 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;
static int SVGALibToScancode(int key)
{
switch(key) {
case SCANCODE_BREAK:
case SCANCODE_BREAK_ALTERNATIVE:
return 0xe1; /* paused */
case SCANCODE_CURSORBLOCKUP:
return sc_UpArrow;
case SCANCODE_CURSORBLOCKDOWN:
return sc_DownArrow;
case SCANCODE_CURSORBLOCKLEFT:
return sc_LeftArrow;
case SCANCODE_CURSORBLOCKRIGHT:
return sc_RightArrow;
case SCANCODE_HOME:
return sc_Home;
case SCANCODE_END:
return sc_End;
case SCANCODE_PAGEUP:
return sc_PgUp;
case SCANCODE_PAGEDOWN:
return sc_PgDn;
case SCANCODE_INSERT:
return sc_Insert;
case SCANCODE_REMOVE:
return sc_Delete;
default: /* rest should be the same hopefully */
return key;
}
}
void keyboard_handlerx(int code, int press)
{
keyboard_handler(SVGALibToScancode(code), press);
}
void INL_Update()
{
while (keyboard_update()) ; /* get all events */
}
int main(int argc, char *argv[])
......
......@@ -356,7 +356,7 @@ void VW_UpdateScreen()
}
void keyboard_handler(int code, int press);
int XKeysymToScancode(KeySym keysym);
static int XKeysymToScancode(KeySym keysym);
static void HandleXEvents()
{
......@@ -496,7 +496,6 @@ void Quit(char *error)
ShutdownId();
if (screen) {
//printf("TODO: spiffy ansi screen goes here..\n");
DisplayTextSplash(screen, l);
}
......@@ -532,74 +531,7 @@ void VL_DirectPlotFlush()
{
}
/*
=============================================================================
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)
static int XKeysymToScancode(KeySym keysym)
{
switch (keysym) {
case XK_1:
......@@ -696,432 +628,7 @@ int XKeysymToScancode(KeySym keysym)
}
}
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;
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// 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()
void INL_Update()
{
unsigned i, buttons;
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()
=======================
*/
void ControlMovement (objtype *ob)
void ControlMovement(objtype *ob)
{
int angle;
int angleunits;
......@@ -1221,7 +1221,7 @@ void T_Attack(objtype *ob)
if ( buttonstate[bt_attack] && !buttonheld[bt_attack])
buttonstate[bt_attack] = false;
ControlMovement (ob);
ControlMovement(ob);
if (gamestate.victoryflag) // watching the BJ actor
return;
......
......@@ -338,7 +338,7 @@ static void DrawScaleds()
}
//==========================================================================
/* ======================================================================== */
/*
==============
......@@ -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)
{
unsigned long TheFrac;
unsigned long y;
unsigned int y, frac, delta;
if (height) {
TheFrac = (64 << 16) / height;
frac = (64 << 16) / height;
delta = (64 << 16) - frac*height;
if (height < viewheight) {
y = yoffset + (viewheight - height) / 2;
ScaledDraw(source, height, gfxbuf + (y * vwidth) + x + xoffset,
0, TheFrac);
delta, frac);
return;
}
y = (height - viewheight) / 2;
y *= TheFrac;
y *= frac;
ScaledDraw(source, viewheight, gfxbuf + (yoffset * vwidth) + x + xoffset,
y, TheFrac);
y+delta, frac);
}
}
static void ScaleLineTrans(unsigned int height, byte *source, int x)
{
unsigned long TheFrac;
unsigned long y;
unsigned int y, frac, delta;
if (height) {
TheFrac = (64 << 16) / height;
frac = (64 << 16) / height;
delta = (64 << 16) - frac*height;
if (height < viewheight) {
y = yoffset + (viewheight - height) / 2;
ScaledDrawTrans(source, height, gfxbuf + (y * vwidth) + x + xoffset,
0, TheFrac);
delta, frac);
return;
}
y = (height - viewheight) / 2;
y *= TheFrac;
y *= frac;
ScaledDrawTrans(&source[y >> 24], viewheight, gfxbuf + (yoffset * vwidth) + x + xoffset,
y, TheFrac);
y+delta, frac);
}
}
......@@ -1047,9 +1047,9 @@ static void AsmRefresh()
int xstep, ystep;
midangle = viewangle*(FINEANGLES/ANGLES);
xpartialdown = viewx&(TILEGLOBAL-1);
xpartialdown = (viewx&(TILEGLOBAL-1));
xpartialup = TILEGLOBAL-xpartialdown;
ypartialdown = viewy&(TILEGLOBAL-1);
ypartialdown = (viewy&(TILEGLOBAL-1));
ypartialup = TILEGLOBAL-ypartialdown;
focaltx = viewx>>TILESHIFT;
......@@ -1101,11 +1101,11 @@ for (postx = 0; postx < viewwidth; postx++) {
goto entry90;
}
yintercept = viewy + xpartialbyystep();
/* add tilestep to fix raycasting problems? */
yintercept = viewy + xpartialbyystep(); // + xtilestep;
xtile = focaltx + xtilestep;
xintercept = viewx + ypartialbyxstep();
xintercept = viewx + ypartialbyxstep(); // + ytilestep;
ytile = focalty + ytilestep;
/* CORE LOOP */
......@@ -1113,12 +1113,13 @@ for (postx = 0; postx < viewwidth; postx++) {
#define TILE(n) ((n)>>16)
/* check intersections with vertical walls */
vertcheck:
vertcheck:
if (!samey(yintercept, ytile))
goto horizentry;
vertentry:
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 & 0x80) {
......@@ -1167,6 +1168,7 @@ horizcheck:
horizentry:
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 & 0x80) {
......
......@@ -12,7 +12,7 @@
=============================================================================
*/
#define FOCALLENGTH (0x5700l) // in global coordinates
#define FOCALLENGTH 0x5700 // in global coordinates
#define VIEWGLOBAL 0x10000 // globals visable flush to wall
char str[80], str2[20];
......@@ -26,7 +26,7 @@ int vwidth, vheight; /* size of screen */
int viewsize;
int centerx;
int shootdelta; // pixels away from centerx a target can be
int shootdelta; /* pixels away from centerx a target can be */
fixed scale;
long heightnumerator;
......@@ -36,7 +36,7 @@ int mouseadjustment;
long frameon;
long lasttimecount;
fixed viewsin, viewcos;
fixed viewx, viewy; // the focal point
fixed viewx, viewy; /* the focal point */
int pixelangle[MAXVIEWWIDTH];
long finetangent[FINEANGLES/4];
int horizwall[MAXWALLTILES], vertwall[MAXWALLTILES];
......@@ -762,7 +762,6 @@ int MS_CheckParm(char *check)
static int wolfdigimap[] =
{
// These first sounds are in the upload version
#ifndef SPEAR
HALTSND, 0,
DOGBARKSND, 1,
......@@ -786,7 +785,6 @@ static int wolfdigimap[] =
SLURPIESND, 22,
YEAHSND, 32,
#ifndef UPLOAD
// These are in all other episodes
DOGDEATHSND, 16,
AHHHGSND, 17,
DIESND, 18,
......@@ -815,10 +813,8 @@ static int wolfdigimap[] =
MEINSND, 44, // EPISODE 6 BOSS DIE
ROSESND, 45, // EPISODE 5 BOSS DIE
#endif
#else
//
// SPEAR OF DESTINY DIGISOUNDS
//
#else /* SPEAR OF DESTINY DIGISOUNDS */
HALTSND, 0,
CLOSEDOORSND, 2,
OPENDOORSND, 3,
......@@ -866,7 +862,6 @@ static int wolfdigimap[] =
LASTSOUND
};
void InitDigiMap()
{
int *map;
......@@ -875,7 +870,7 @@ void InitDigiMap()
DigiMap[map[0]] = map[1];
}
//===========================================================================
/* ======================================================================== */
/*
==================
......@@ -895,14 +890,15 @@ void BuildTables()
/* 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);
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 */
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
......@@ -1085,7 +1081,7 @@ CP_itemtype MusicMenu[]=
};
#endif
static int songs[]=
static const int songs[] =
{
#ifndef SPEAR
GETTHEM_MUS,
......@@ -1418,7 +1414,7 @@ void DemoLoop()
VW_FadeOut();
if (IN_KeyDown(sc_Tab) && MS_CheckParm("debugmode"))
RecordDemo ();
RecordDemo();
else
US_ControlPanel(0);
......@@ -1432,7 +1428,7 @@ void DemoLoop()
}
//===========================================================================
/* ======================================================================== */
/*
......
......@@ -220,7 +220,7 @@ static char
{
1,0xe,0xf,0x1d,sc_LShift,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,
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
},
*ExtScanNames[] = // Names corresponding to ExtScanCodes
......
......@@ -47,7 +47,7 @@ memptr demobuffer;
//
// 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];
static void RemoveObj(objtype *gone);
......@@ -61,7 +61,7 @@ static void RemoveObj(objtype *gone);
*/
/* LIST OF SONGS FOR EACH VERSION */
static int songs[]=
static const int songs[]=
{
#ifndef SPEAR
/* Episode One */
......@@ -263,7 +263,6 @@ void PollJoystickButtons()
}
}
/*
===================
=
......@@ -315,8 +314,6 @@ void PollMouseMove()
controly += mouseymove*20/(13-mouseadjustment);
}
/*
===================
=
......@@ -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()
return;
}
//
// get button states
//
/* Update keys */
IN_CheckAck();
PollKeyboardButtons();
if (mouseenabled)
PollMouseButtons();
if (joystickenabled)
PollJoystickButtons();
//
// get movements
//
PollKeyboardMove();
if (mouseenabled)
PollMouseMove();
if (joystickenabled)
PollJoystickMove();
UpdateInput();
//
// bound movement to a maximum
......@@ -740,9 +739,7 @@ void InitActorList()
objfreelist = &objlist[0];
lastobj = NULL;
//
// give the player the first free spots
//
/* give the player the first free spots */
GetNewActor();
player = new;
......@@ -799,7 +796,7 @@ void GetNewActor()
static void RemoveObj(objtype *gone)
{
if (gone == player)
Quit ("RemoveObj: Tried to remove the player!");
Quit("RemoveObj: Tried to remove the player!");
gone->state = s_none;
......
......@@ -102,7 +102,7 @@ void NewState(objtype *ob, int state) /* stateenum */
= ob->tilex = new destination
= ob->tiley
= 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.
= The actor code should wait until
......
......@@ -557,7 +557,7 @@ void CacheLayoutGraphics()
}
if (ch == 'T') // timed draw graphic command, so mark graphics
{
ParseTimedCommand ();
ParseTimedCommand();
CA_CacheGrChunk(picnum);
}
}
......@@ -580,7 +580,7 @@ void CacheLayoutGraphics()
void ShowArticle(char *article)
{
unsigned oldfontnumber;
boolean newpage,firstpage;
boolean newpage, firstpage;
text = article;
......@@ -588,7 +588,7 @@ void ShowArticle(char *article)
fontnumber = 0;
CA_CacheGrChunk(STARTFONT);
VW_Bar (0,0,320,200,BACKCOLOR);
CacheLayoutGraphics ();
CacheLayoutGraphics();
newpage = true;
firstpage = true;
......@@ -598,18 +598,17 @@ void ShowArticle(char *article)
if (newpage)
{
newpage = false;
PageLayout (true);
VW_UpdateScreen ();
PageLayout(true);
VW_UpdateScreen();
if (firstpage)
{
VL_FadeIn(0,255,gamepal,10);
// VW_FadeIn ()
firstpage = false;
}
}
LastScan = 0;
while (!LastScan) IN_CheckAck(); /* TODO: update events */
while (!LastScan) IN_CheckAck(); /* update events */
switch (LastScan)
{
......@@ -627,7 +626,7 @@ void ShowArticle(char *article)
case sc_Enter:
case sc_DownArrow:
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)
{
newpage = true;
......@@ -645,10 +644,10 @@ void ShowArticle(char *article)
}
//===========================================================================
/* ======================================================================== */
int endextern = T_ENDART1;
int helpextern = T_HELPART;
#define endextern T_ENDART1
#define helpextern T_HELPART
/*
=================
......@@ -691,7 +690,7 @@ void EndText()
CA_UpLevel();
artnum = endextern+gamestate.episode;
CA_CacheGrChunk (artnum);
CA_CacheGrChunk(artnum);
text = (char *)grsegs[artnum];
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