Commit 46f35dd2 authored by Steven Fuller's avatar Steven Fuller

More cleanups.

Removed the unnecessary third parameters to some calls to open().

Removed some unused code.

Rewrote CAL_CarmackExpand to prevent problems with unaligned access.

Changed direct access to the Keyboard array to use a macro IN_KeyDown()
(which could one day become a function).
parent f1995e1d
......@@ -3,8 +3,8 @@ CC = gcc
#CFLAGS = -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
CFLAGS = -g -Wall
#CFLAGS = -g
#CFLAGS = -Os
#CFLAGS = -Os -Wall
#CFLAGS = -Os -Wall -fomit-frame-pointer -ffast-math -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
#CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include
OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
......
......@@ -50,12 +50,13 @@ byte ca_levelbit,ca_levelnum;
*/
char extension[5],
gheadname[10]="vgahead.",
gfilename[10]="vgagraph.",
gdictname[10]="vgadict.",
mheadname[10]="maphead.",
aheadname[10]="audiohed.",
afilename[10]="audiot.";
gheadname[10] = "vgahead.",
gfilename[10] = "vgagraph.",
gdictname[10] = "vgadict.",
mheadname[10] = "maphead.",
gmapsname[10] = "gamemaps.",
aheadname[10] = "audiohed.",
afilename[10] = "audiot.";
long *grstarts; /* array of offsets in vgagraph, -1 for sparse */
long *audiostarts; /* array of offsets in audio / audiot */
......@@ -144,7 +145,7 @@ boolean CA_FarRead(int handle, byte *dest, long length)
==========================
*/
boolean CA_FarWrite (int handle, byte *source, long length)
boolean CA_FarWrite(int handle, byte *source, long length)
{
ssize_t l;
......@@ -177,7 +178,7 @@ boolean CA_ReadFile(char *filename, memptr *ptr)
int handle;
long size;
if ((handle = open(filename, O_RDONLY | O_BINARY, S_IREAD)) == -1)
if ((handle = open(filename, O_RDONLY | O_BINARY)) == -1)
return false;
size = filelength(handle);
......@@ -234,7 +235,7 @@ boolean CA_LoadFile (char *filename, memptr *ptr)
int handle;
long size;
if ((handle = open(filename,O_RDONLY | O_BINARY, S_IREAD)) == -1)
if ((handle = open(filename, O_RDONLY | O_BINARY)) == -1)
return false;
size = filelength(handle);
......@@ -266,7 +267,6 @@ boolean CA_LoadFile (char *filename, memptr *ptr)
======================
*/
#if 1
/* From Ryan C. Gordon -- ryan_gordon@hotmail.com */
void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
{
......@@ -289,56 +289,13 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
source++;
}
if (path < 256) {
*dest = (byte) path;
*dest = (byte)path;
dest++;
nodeon = headptr;
} else
nodeon = (htable + (path - 256));
} while (dest != endoff);
}
#else
void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *hufftable)
{
int x;
huffnode *headptr, *nodeon;
byte *ptr, *ptrd, *ptrm;
byte a, mask;
unsigned short int b;
ptrd = dest;
headptr = hufftable + 254; /* head node is always node 254 */
nodeon = headptr;
ptr = source;
a = *ptr;
ptr++;
mask = 1;
for (x = 0; x < length; x++) {
again:
if (a & mask)
b = nodeon->bit1;
else
b = nodeon->bit0;
mask <<= 1;
if (mask == 0) {
a = *ptr;
ptr++;
mask = 1;
}
if (b & 0xFF00) {
nodeon = hufftable + (b - 256);
goto again;
} else {
nodeon = headptr;
*ptrd = (b & 0x00FF);
ptrd++;
}
}
}
#endif
/*
======================
......@@ -353,6 +310,63 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *hufftable)
#define NEARTAG 0xa7
#define FARTAG 0xa8
void CAL_CarmackExpand(word *source, word *dest, word length)
{
unsigned int offset;
word *copyptr, *outptr;
byte chhigh, chlow, *inptr;
length /= 2;
inptr = (byte *)source;
outptr = dest;
while (length) {
/* LSB */
chlow = *inptr++; /* count */
chhigh = *inptr++;
if (chhigh == NEARTAG) {
if (!chlow) {
/* have to insert a word containing the tag byte */
*outptr++ = (chhigh << 8) | *inptr;
inptr++;
length--;
} else {
offset = *inptr;
inptr++;
copyptr = outptr - offset;
length -= chlow;
while (chlow--)
*outptr++ = *copyptr++;
}
} else if (chhigh == FARTAG) {
if (!chlow) {
/* have to insert a word containing the tag byte */
*outptr++ = (chhigh << 8) | *inptr;
inptr++;
length--;
} else {
offset = *inptr | (*(inptr+1) << 8);
inptr += 2;
copyptr = dest + offset;
length -= chlow;
while (chlow--)
*outptr++ = *copyptr++;
}
} else {
*outptr++ = (chhigh << 8) | chlow;
length--;
}
}
}
#if 0
void CAL_CarmackExpand(word *source, word *dest, word length)
{
word ch, chhigh, count, offset;
......@@ -404,47 +418,7 @@ void CAL_CarmackExpand(word *source, word *dest, word length)
}
}
}
/*
======================
=
= CA_RLEWcompress
=
======================
*/
/* TODO: actually this isn't used so it can be removed from here */
long CA_RLEWCompress(word *source, long length, word *dest, word rlewtag)
{
word value, count, i;
word *start, *end;
start = dest;
end = source + (length + 1)/2;
/* compress it */
do {
count = 1;
value = *source++;
while ( (*source == value) && (source < end) ) {
count++;
source++;
}
if ( (count > 3) || (value == rlewtag) ) {
/* send a tag / count / value string */
*dest++ = rlewtag;
*dest++ = count;
*dest++ = value;
} else {
/* send word without compressing */
for (i = 1; i <= count; i++)
*dest++ = value;
}
} while (source < end);
return 2*(dest-start);
}
#endif
/*
======================
......@@ -501,8 +475,8 @@ long CAL_GetGrChunkLength(int chunk)
{
long chunkexplen;
lseek(grhandle,GRFILEPOS(chunk),SEEK_SET);
read(grhandle,&chunkexplen,sizeof(chunkexplen));
lseek(grhandle, GRFILEPOS(chunk), SEEK_SET);
read(grhandle, &chunkexplen, sizeof(chunkexplen));
return GRFILEPOS(chunk+1)-GRFILEPOS(chunk)-4;
}
......@@ -514,7 +488,7 @@ long CAL_GetGrChunkLength(int chunk)
======================
*/
void CAL_SetupGrFile (void)
void CAL_SetupGrFile()
{
char fname[13];
int handle;
......@@ -525,11 +499,10 @@ void CAL_SetupGrFile (void)
// load ???dict.ext (huffman dictionary for graphics files)
//
strcpy(fname,gdictname);
strcat(fname,extension);
strcpy(fname, gdictname);
strcat(fname, extension);
if ((handle = open(fname,
O_RDONLY | O_BINARY, S_IREAD)) == -1)
if ((handle = open(fname, O_RDONLY | O_BINARY)) == -1)
CA_CannotOpen(fname);
read(handle, &grhuffman, sizeof(grhuffman));
......@@ -537,25 +510,23 @@ void CAL_SetupGrFile (void)
//
// load the data offsets from ???head.ext
//
MM_GetPtr ((memptr)&grstarts,(NUMCHUNKS+1)*FILEPOSSIZE);
MM_GetPtr((memptr)&grstarts, (NUMCHUNKS+1)*FILEPOSSIZE);
strcpy(fname,gheadname);
strcat(fname,extension);
strcpy(fname, gheadname);
strcat(fname, extension);
if ((handle = open(fname,
O_RDONLY | O_BINARY, S_IREAD)) == -1)
if ((handle = open(fname, O_RDONLY | O_BINARY)) == -1)
CA_CannotOpen(fname);
CA_FarRead(handle, (memptr)grstarts, (NUMCHUNKS+1)*FILEPOSSIZE);
close(handle);
//
// Open the graphics file, leaving it open until the game is finished
//
strcpy(fname,gfilename);
strcat(fname,extension);
strcpy(fname, gfilename);
strcat(fname, extension);
grhandle = open(fname, O_RDONLY | O_BINARY);
if (grhandle == -1)
......@@ -584,7 +555,7 @@ void CAL_SetupGrFile (void)
======================
*/
void CAL_SetupMapFile (void)
void CAL_SetupMapFile()
{
int i;
int handle;
......@@ -597,8 +568,7 @@ void CAL_SetupMapFile (void)
strcpy(fname,mheadname);
strcat(fname,extension);
if ((handle = open(fname,
O_RDONLY | O_BINARY, S_IREAD)) == -1)
if ((handle = open(fname, O_RDONLY | O_BINARY)) == -1)
CA_CannotOpen(fname);
length = filelength(handle);
......@@ -611,11 +581,10 @@ void CAL_SetupMapFile (void)
//
// open the data file
//
strcpy(fname,"gamemaps.");
strcpy(fname, gmapsname);
strcat(fname,extension);
if ((maphandle = open(fname,
O_RDONLY | O_BINARY, S_IREAD)) == -1)
if ((maphandle = open(fname, O_RDONLY | O_BINARY)) == -1)
CA_CannotOpen(fname);
//
......@@ -624,7 +593,7 @@ void CAL_SetupMapFile (void)
for (i=0;i<NUMMAPS;i++)
{
pos = ((mapfiletype *)tinf)->headeroffsets[i];
if (pos<0) /* $FFFFFFFF start is a sparse map */
if (pos < 0) /* $FFFFFFFF start is a sparse map */
continue;
MM_GetPtr((memptr)&mapheaderseg[i],sizeof(maptype));
......@@ -636,10 +605,9 @@ void CAL_SetupMapFile (void)
//
// allocate space for 2 64*64 planes
//
for (i=0;i<MAPPLANES;i++)
{
MM_GetPtr ((memptr)&mapsegs[i],64*64*2);
MM_SetLock ((memptr)&mapsegs[i],true);
for (i = 0;i < MAPPLANES; i++) {
MM_GetPtr((memptr)&mapsegs[i], 64*64*2);
MM_SetLock((memptr)&mapsegs[i], true);
}
}
......@@ -654,7 +622,7 @@ void CAL_SetupMapFile (void)
======================
*/
void CAL_SetupAudioFile (void)
void CAL_SetupAudioFile()
{
int handle;
long length;
......@@ -665,8 +633,7 @@ void CAL_SetupAudioFile (void)
strcpy(fname,aheadname);
strcat(fname,extension);
if ((handle = open(fname,
O_RDONLY | O_BINARY, S_IREAD)) == -1)
if ((handle = open(fname, O_RDONLY | O_BINARY)) == -1)
CA_CannotOpen(fname);
length = filelength(handle);
......@@ -680,8 +647,7 @@ void CAL_SetupAudioFile (void)
strcpy(fname,afilename);
strcat(fname,extension);
if ((audiohandle = open(fname,
O_RDONLY | O_BINARY, S_IREAD)) == -1)
if ((audiohandle = open(fname, O_RDONLY | O_BINARY)) == -1)
CA_CannotOpen(fname);
}
......@@ -842,7 +808,7 @@ cachein:
void CAL_ExpandGrChunk(int chunk, byte *source)
{
int tilecount = 0;
int tilecount = 0, i;
long expanded;
int width = 0, height = 0;
......@@ -852,25 +818,10 @@ void CAL_ExpandGrChunk(int chunk, byte *source)
//
// expanded sizes of tile8/16/32 are implicit
//
#define BLOCK 64
#define MASKBLOCK 128
if (chunk<STARTTILE8M) { /* tile 8s are all in one chunk! */
expanded = BLOCK*NUMTILE8;
width = 8;
height = 8;
tilecount = NUMTILE8;
} else if (chunk<STARTTILE16) /* TODO: This is removable */
expanded = MASKBLOCK*NUMTILE8M;
else if (chunk<STARTTILE16M) // all other tiles are one/chunk
expanded = BLOCK*4;
else if (chunk<STARTTILE32)
expanded = MASKBLOCK*4;
else if (chunk<STARTTILE32M)
expanded = BLOCK*16;
else
expanded = MASKBLOCK*16;
expanded = (8*8)*NUMTILE8;
width = 8;
height = 8;
tilecount = NUMTILE8;
} else if (chunk >= STARTPICS && chunk < STARTSPRITES) {
width = pictable[chunk - STARTPICS].width;
height = pictable[chunk - STARTPICS].height;
......@@ -891,7 +842,6 @@ void CAL_ExpandGrChunk(int chunk, byte *source)
CAL_HuffExpand(source, grsegs[chunk], expanded, grhuffman);
if (width && height) {
if (tilecount) {
int i;
for (i = 0; i < tilecount; i++)
VL_DeModeXize(grsegs[chunk]+(width*height)*i, width, height);
} else
......@@ -916,8 +866,8 @@ void CA_CacheGrChunk(int chunk)
byte *source;
int next;
/* this is due to Quit wanting to cache the error screen before this has been set up! */
if ( (grhandle == 0) || (grhandle == -1) ) /* make sure this works ok */
/* this is due to Quit() wanting to cache the error screen before this has been set up! */
if ( (grhandle == 0) || (grhandle == -1) )
return;
grneeded[chunk] |= ca_levelbit; /* make sure it doesn't get removed */
......@@ -959,7 +909,6 @@ void CA_UnCacheGrChunk(int chunk)
MM_FreePtr((void *)&grsegs[chunk]);
grneeded[chunk] &= ~ca_levelbit;
/* Or should MM_FreePtr set it to zero? */
grsegs[chunk] = 0;
}
......@@ -1346,7 +1295,7 @@ void CA_CacheMarks (void)
===================
*/
void MM_Startup (void)
void MM_Startup()
{
}
......@@ -1358,7 +1307,7 @@ void MM_Startup (void)
====================
*/
void MM_Shutdown(void)
void MM_Shutdown()
{
}
......@@ -1477,7 +1426,7 @@ void PML_OpenPageFile(void)
word *lengthptr;
PageListStruct *page;
PageFile = open(PageFileName,O_RDONLY | O_BINARY);
PageFile = open(PageFileName, O_RDONLY | O_BINARY);
if (PageFile == -1)
Quit("PML_OpenPageFile: Unable to open page file");
......
......@@ -48,7 +48,6 @@ boolean CA_ReadFile(char *filename, memptr *ptr);
boolean CA_LoadFile(char *filename, memptr *ptr);
boolean CA_WriteFile(char *filename, void *ptr, long length);
long CA_RLEWCompress(word *source, long length, word *dest, word rlewtag);
void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag);
void CA_Startup (void);
......@@ -78,7 +77,7 @@ void CA_CacheMarks();
void CA_CacheScreen(int chunk);
//==========================================================================
/* ======================================================================= */
void MM_Startup();
void MM_Shutdown();
......
#ifndef __VI_COMM_H__
#define __VI_COMM_H__
//===========================================================================
/* ======================================================================== */
extern byte *gfxbuf;
......@@ -32,14 +32,15 @@ void VL_DirectPlot(int x1, int y1, int x2, int y2);
#define MaxJoys 2
#define NumCodes 128
typedef byte ScanCode;
typedef byte ScanCode;
#define sc_None 0
#define sc_Bad 0xff
#define sc_Return 0x1c
#define sc_Enter sc_Return
#define sc_Escape 0x01
#define sc_Space 0x39
#define sc_BackSpace 0x0e
#define sc_BackSpace 0x0e
#define sc_Tab 0x0f
#define sc_Alt 0x38
#define sc_Control 0x1d
......@@ -47,7 +48,7 @@ typedef byte ScanCode;
#define sc_LShift 0x2a
#define sc_RShift 0x36
/* TODO: have all these defines map into system specific values */
/* TODO */
/*
#define sc_UpArrow 0x48
#define sc_DownArrow 0x50
......@@ -123,41 +124,49 @@ typedef byte ScanCode;
#define key_None 0
typedef enum {
ctrl_Keyboard,
ctrl_Joystick,
ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,
ctrl_Mouse
} ControlType;
typedef enum {
motion_Left = -1,motion_Up = -1,
motion_None = 0,
motion_Right = 1,motion_Down = 1
} Motion;
typedef enum {
dir_North,dir_NorthEast,
dir_East,dir_SouthEast,
dir_South,dir_SouthWest,
dir_West,dir_NorthWest,
dir_None
} Direction;
typedef struct {
boolean button0,button1,button2,button3;
int x,y;
Motion xaxis,yaxis;
Direction dir;
} CursorInfo;
typedef CursorInfo ControlInfo;
typedef struct {
ScanCode button0,button1,
upleft, up, upright,
left, right,
downleft, down, downright;
} KeyboardDef;
typedef enum {
ctrl_Keyboard,
ctrl_Joystick,
ctrl_Joystick1 = ctrl_Joystick,
ctrl_Joystick2,
ctrl_Mouse
} ControlType;
typedef enum {
motion_Left = -1,
motion_Up = -1,
motion_None = 0,
motion_Right = 1,
motion_Down = 1
} Motion;
typedef enum {
dir_North,
dir_NorthEast,
dir_East,
dir_SouthEast,
dir_South,
dir_SouthWest,
dir_West,
dir_NorthWest,
dir_None
} Direction;
typedef struct {
boolean button0, button1, button2, button3;
int x, y;
Motion xaxis, yaxis;
Direction dir;
} ControlInfo;
typedef struct {
ScanCode button0, button1, upleft, up, upright,
left, right, downleft, down, downright;
} KeyboardDef;
// Global variables
extern boolean Keyboard[],
MousePresent,
JoysPresent[];
extern boolean Keyboard[], MousePresent, JoysPresent[];
extern boolean Paused;
extern char LastASCII;
extern ScanCode LastScan;
......@@ -166,25 +175,28 @@ extern ControlType Controls[MaxPlayers];
// Function prototypes
#define IN_KeyDown(code) (Keyboard[(code)])
#define IN_ClearKey(code) {Keyboard[code] = false; \
if (code == LastScan) LastScan = sc_None;}
extern void IN_Startup(void),IN_Shutdown(void),
IN_ClearKeysDown(void),
IN_ReadControl(int,ControlInfo *),
IN_GetJoyAbs(word joy,word *xp,word *yp),
IN_SetupJoy(word joy,word minx,word maxx,
word miny,word maxy),
IN_Ack(void);
extern boolean IN_UserInput(longword delay);
extern byte *IN_GetScanName(ScanCode);
byte IN_MouseButtons (void);
byte IN_JoyButtons (void);
#define IN_ClearKey(code) { \
Keyboard[code] = false; \
if (code == LastScan) \
LastScan = sc_None; \
}
extern void IN_Startup(void),IN_Shutdown(void),
IN_ClearKeysDown(void),
IN_ReadControl(int,ControlInfo *),
IN_GetJoyAbs(word joy,word *xp,word *yp),
IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy),
IN_Ack(void);
extern boolean IN_UserInput(longword delay);
extern char *IN_GetScanName(ScanCode);
byte IN_MouseButtons();
byte IN_JoyButtons();
void INL_GetJoyDelta(word joy,int *dx,int *dy);
void IN_StartAck(void);
boolean IN_CheckAck (void);
void IN_StartAck();
boolean IN_CheckAck();
#endif
......@@ -313,18 +313,18 @@ void VL_DirectPlot(int x1, int y1, int x2, int y2)
//
// configuration variables
//
boolean MousePresent;
boolean JoysPresent[MaxJoys];
boolean MousePresent;
boolean JoysPresent[MaxJoys];
// Global variables
boolean Keyboard[NumCodes];
boolean Paused;
char LastASCII;
ScanCode LastScan;
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];
ControlType Controls[MaxPlayers];
/*
=============================================================================
......@@ -362,14 +362,11 @@ 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
};
// Internal routines
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)
{
......
......@@ -11,12 +11,12 @@
*/
statobj_t statobjlist[MAXSTATS],*laststatobj;
statobj_t statobjlist[MAXSTATS], *laststatobj;
struct
{
int picnum;
int picnum;
stat_t type;
} statinfo[] =
{
......@@ -120,13 +120,11 @@ struct
===============
*/
void InitStaticList (void)
void InitStaticList()
{
laststatobj = &statobjlist[0];
}
/*
===============
=
......@@ -135,7 +133,7 @@ void InitStaticList (void)
===============
*/
void SpawnStatic (int tilex, int tiley, int type)
void SpawnStatic(int tilex, int tiley, int type)
{
laststatobj->shapenum = statinfo[type].picnum;
laststatobj->tilex = tilex;
......@@ -197,15 +195,15 @@ void SpawnStatic (int tilex, int tiley, int type)
===============
*/
void PlaceItemType (int itemtype, int tilex, int tiley)
void PlaceItemType(int itemtype, int tilex, int tiley)
{
int type;
statobj_t *spot;
int type;
statobj_t *spot;
//
// find the item number
//
for (type=0 ; ; type++)
for (type = 0; ; type++)
{
if (statinfo[type].picnum == -1) /* end of list */
Quit("PlaceItemType: couldn't find type!");
......@@ -291,32 +289,32 @@ boolean areabyplayer[NUMAREAS];
==============
*/
void RecursiveConnect (int areanumber)
void RecursiveConnect(int areanumber)
{
int i;
int i;
for (i=0;i<NUMAREAS;i++)
for (i = 0; i < NUMAREAS; i++)
{
if (areaconnect[areanumber][i] && !areabyplayer[i])
{
areabyplayer[i] = true;
RecursiveConnect (i);
RecursiveConnect(i);
}
}
}
void ConnectAreas (void)
void ConnectAreas()
{
memset (areabyplayer,0,sizeof(areabyplayer));
memset(areabyplayer, 0, sizeof(areabyplayer));
areabyplayer[player->areanumber] = true;
RecursiveConnect (player->areanumber);
RecursiveConnect(player->areanumber);
}
void InitAreas (void)
void InitAreas()
{
memset (areabyplayer,0,sizeof(areabyplayer));
memset(areabyplayer, 0, sizeof(areabyplayer));
areabyplayer[player->areanumber] = true;
}
......@@ -330,7 +328,7 @@ void InitAreas (void)
===============
*/
void InitDoorList (void)
void InitDoorList()
{
memset (areabyplayer,0,sizeof(areabyplayer));
memset (areaconnect,0,sizeof(areaconnect));
......@@ -348,11 +346,11 @@ void InitDoorList (void)
===============
*/
void SpawnDoor (int tilex, int tiley, boolean vertical, int lock)
void SpawnDoor(int tilex, int tiley, boolean vertical, int lock)
{
word *map;
if (doornum==64)
if (doornum == 64)
Quit ("64+ doors on level!");
doorposition[doornum] = 0; // doors start out fully closed
......
......@@ -277,19 +277,19 @@ int DebugKeys()
boolean esc;
int level;
if (Keyboard[sc_C]) // C = count objects
if (IN_KeyDown(sc_C)) // C = count objects
{
CountObjects();
return 1;
}
if (Keyboard[sc_E]) // E = quit level
if (IN_KeyDown(sc_E)) // E = quit level
{
playstate = ex_completed;
// gamestate.mapon++;
}
if (Keyboard[sc_F]) // F = facing spot
if (IN_KeyDown(sc_F)) // F = facing spot
{
CenterWindow (14,4);
US_Print ("X:");
......@@ -303,7 +303,7 @@ int DebugKeys()
return 1;
}
if (Keyboard[sc_G]) // G = god mode
if (IN_KeyDown(sc_G)) // G = god mode
{
CenterWindow (12,2);
if (godmode)
......@@ -315,12 +315,12 @@ int DebugKeys()
godmode ^= 1;
return 1;
}
if (Keyboard[sc_H]) // H = hurt self
if (IN_KeyDown(sc_H)) // H = hurt self
{
IN_ClearKeysDown ();
TakeDamage (16,NULL);
}
else if (Keyboard[sc_I]) // I = item cheat
else if (IN_KeyDown(sc_I)) // I = item cheat
{
CenterWindow (12,3);
US_PrintCentered ("Free items!");
......@@ -336,7 +336,7 @@ int DebugKeys()
IN_Ack ();
return 1;
}
else if (Keyboard[sc_N]) // N = no clip
else if (IN_KeyDown(sc_N)) // N = no clip
{
noclip^=1;
CenterWindow (18,3);
......@@ -348,14 +348,14 @@ int DebugKeys()
IN_Ack ();
return 1;
}
else if (Keyboard[sc_P]) // P = pause with no screen disruptioon
else if (IN_KeyDown(sc_P)) // P = pause with no screen disruptioon
{
PicturePause ();
return 1;
}
else if (Keyboard[sc_Q]) // Q = fast quit
else if (IN_KeyDown(sc_Q)) // Q = fast quit
Quit(NULL);
else if (Keyboard[sc_S]) // S = slow motion
else if (IN_KeyDown(sc_S)) // S = slow motion
{
singlestep^=1;
CenterWindow (18,3);
......@@ -367,12 +367,12 @@ int DebugKeys()
IN_Ack ();
return 1;
}
else if (Keyboard[sc_T]) // T = shape test
else if (IN_KeyDown(sc_T)) // T = shape test
{
ShapeTest ();
ShapeTest();
return 1;
}
else if (Keyboard[sc_V]) // V = extra VBLs
else if (IN_KeyDown(sc_V)) // V = extra VBLs
{
CenterWindow(30,3);
PrintY+=6;
......@@ -387,11 +387,10 @@ int DebugKeys()
}
return 1;
}
else if (Keyboard[sc_W]) // W = warp to level
else if (IN_KeyDown(sc_W)) // W = warp to level
{
CenterWindow(26,3);
PrintY+=6;
/* TODO: wouldn't work on sod demo etc */
#ifndef SPEAR
US_Print(" Warp to which level(1-10):");
#elif defined(SPEARDEMO)
......
......@@ -224,7 +224,7 @@ void Victory (void)
IN_Ack();
#ifndef SPEAR
if (Keyboard[sc_P] && MS_CheckParm("goobers"))
if (IN_KeyDown(sc_P) && MS_CheckParm("goobers"))
PicturePause();
#endif
......@@ -833,7 +833,7 @@ void LevelCompleted()
#endif
#ifndef SPEAR
if (Keyboard[sc_P] && MS_CheckParm("goobers"))
if (IN_KeyDown(sc_P) && MS_CheckParm("goobers"))
PicturePause();
#endif
......
......@@ -1095,8 +1095,8 @@ void InitGame(void)
// HOLDING DOWN 'M' KEY?
//
#ifndef SPEARDEMO
if (Keyboard[sc_M])
DoJukebox();
if (IN_KeyDown(sc_M))
DoJukebox();
else
#endif
......@@ -1190,7 +1190,7 @@ void NewViewSize(int width)
=====================
*/
void DemoLoop (void)
void DemoLoop()
{
static int LastDemo;
......@@ -1211,7 +1211,7 @@ void DemoLoop (void)
PG13 ();
i = MS_CheckParm("playdemo");
if ( i && ( (i+1) < _argc) ) {
if (i && ((i+1) < _argc)) {
i++;
for (; i < _argc; i++) {
if (_argv[i][0] == '-')
......@@ -1240,8 +1240,8 @@ void DemoLoop (void)
CA_CacheGrChunk (TITLE2PIC);
VWB_DrawPic (0,80,TITLE2PIC);
CA_UnCacheGrChunk (TITLE2PIC);
VW_UpdateScreen ();
CA_UnCacheGrChunk(TITLE2PIC);
VW_UpdateScreen();
VL_FadeIn(0,255,grsegs[TITLEPALETTE],30);
CA_UnCacheGrChunk (TITLEPALETTE);
......@@ -1288,7 +1288,7 @@ void DemoLoop (void)
VW_FadeOut ();
if (Keyboard[sc_Tab] && MS_CheckParm("debugmode"))
if (IN_KeyDown(sc_Tab) && MS_CheckParm("debugmode"))
RecordDemo ();
else
US_ControlPanel (0);
......
......@@ -70,15 +70,9 @@ MainMenu[]=
{1,STR_LG,(void *)CP_LoadGame},
{0,STR_SG,(void *)CP_SaveGame},
{1,STR_CV,(void *)CP_ChangeView},
#ifndef GOODTIMES
#ifndef SPEAR
#if !defined(GOODTIMES) && !defined(SPEAR)
{2,"Read This!",(void *)CP_ReadThis},
#endif
#endif
{1,STR_VS,(void *)CP_ViewScores},
{1,STR_BD,0},
{1,STR_QT,0}
......@@ -171,19 +165,8 @@ CusMenu[]=
;
int color_hlite[]={
DEACTIVE,
HIGHLIGHT,
READHCOLOR,
0x67
},
color_norml[]={
DEACTIVE,
TEXTCOLOR,
READCOLOR,
0x6b
};
int color_hlite[] = { DEACTIVE, HIGHLIGHT, READHCOLOR, 0x67 };
int color_norml[] = { DEACTIVE, TEXTCOLOR, READCOLOR, 0x6b };
int EpisodeSelect[6]={1};
......@@ -194,9 +177,51 @@ char SaveGameNames[10][32],SaveName[13]="savegam?.";
////////////////////////////////////////////////////////////////////
//
// INPUT MANAGER SCANCODE TABLES
// INPUT MANAGER SCANCODE TABLES and
//
// IN_GetScanName() - Returns a string containing the name of the
// specified scan code
//
////////////////////////////////////////////////////////////////////
#if 0
static struct {
int sc;
char *str;
} ScanNames[] = {
{ sc_1, "1" },
{ sc_2, "2" },
{ sc_3, "3" },
{ sc_4, "4" },
{ sc_5, "5" },
{ sc_6, "6" },
{ sc_7, "7" },
{ sc_8, "8" },
{ sc_9, "9" },
{ sc_Escape, "Esc" },
{ sc_LeftArrow, "Left" },
{ sc_RightArrow,"Right" },
{ sc_UpArrow, "Up" },
{ sc_DownArrow, "Down" },
{ sc_Bad, "?" },
{ sc_None, "?" }
};
char *IN_GetScanName(ScanCode scan)
{
int i;
for (i = 0; i < (sizeof(ScanNames)/sizeof(ScanNames[0])); i++)
if (ScanNames[i].sc == scan)
return ScanNames[i].str;
return "?";
}
#else
static byte
*ScanNames[] = // Scan code names with single chars
{
......@@ -211,10 +236,10 @@ static byte
}, // DEBUG - consolidate these
ExtScanCodes[] = // Scan codes with >1 char names
{
1,0xe,0xf,0x1d,0x2a,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,
0x3f,0x40,0x41,0x42,0x43,0x44,0x57,0x59,0x46,0x1c,0x36,
0x37,0x38,0x47,0x49,0x4f,0x51,0x52,0x53,0x45,0x48,
0x50,0x4b,0x4d,0x00
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,
sc_DownArrow,sc_LeftArrow,sc_RightArrow,0x00
},
*ExtScanNames[] = // Names corresponding to ExtScanCodes
{
......@@ -224,6 +249,18 @@ static byte
"Down","Left","Right",""
};
char *IN_GetScanName(ScanCode scan)
{
byte **p;
ScanCode *s;
for (s = ExtScanCodes, p = ExtScanNames; *s; p++, s++)
if (*s == scan)
return *p;
return ScanNames[scan];
}
#endif
////////////////////////////////////////////////////////////////////
//
......@@ -306,15 +343,13 @@ void US_ControlPanel(byte scancode)
//
// EASTER EGG FOR SPEAR OF DESTINY!
//
if (Keyboard[sc_I] && Keyboard[sc_D])
{
if (IN_KeyDown(sc_I) && IN_KeyDown(sc_D)) {
VW_FadeOut();
StartCPMusic (XJAZNAZI_MUS);
UnCacheLump(OPTIONS_LUMP_START,OPTIONS_LUMP_END);
UnCacheLump(BACKDROP_LUMP_START,BACKDROP_LUMP_END);
MM_SortMem ();
ClearMemory ();
MM_SortMem();
ClearMemory();
CA_CacheGrChunk (IDGUYS1PIC);
VWB_DrawPic(0,0,IDGUYS1PIC);
......@@ -330,7 +365,8 @@ void US_ControlPanel(byte scancode)
VL_FadeIn(0,255,grsegs[IDGUYSPALETTE],30);
CA_UnCacheGrChunk(IDGUYSPALETTE);
while (Keyboard[sc_I] || Keyboard[sc_D]) IN_CheckAck();
while (IN_KeyDown(sc_I) || IN_KeyDown(sc_D)) IN_CheckAck();
IN_ClearKeysDown();
IN_Ack();
......@@ -1466,14 +1502,13 @@ int CalibrateJoystick(void)
VW_UpdateScreen();
do
{
do {
jb=IN_JoyButtons();
IN_CheckAck(); /* TODO: force update */
if (Keyboard[sc_Escape])
IN_CheckAck(); /* force update */
if (IN_KeyDown(sc_Escape))
return 0;
if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))
if (IN_KeyDown(sc_Tab) && IN_KeyDown(sc_P) && MS_CheckParm("goobers"))
PicturePause();
} while(!(jb&1));
......@@ -1497,13 +1532,12 @@ int CalibrateJoystick(void)
VW_UpdateScreen();
do
{
jb=IN_JoyButtons();
IN_CheckAck(); /* TODO: force update */
if (Keyboard[sc_Escape])
do {
jb = IN_JoyButtons();
IN_CheckAck(); /* force update */
if (IN_KeyDown(sc_Escape))
return 0;
if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))
if (IN_KeyDown(sc_Tab) && IN_KeyDown(sc_P) && MS_CheckParm("goobers"))
PicturePause();
} while(!(jb&2));
......@@ -1652,7 +1686,8 @@ void MouseSensitivity(void)
VW_Bar(61+20*mouseadjustment,98,19,9,READHCOLOR);
VW_UpdateScreen();
SD_PlaySound(MOVEGUN1SND);
while(Keyboard[sc_LeftArrow]) IN_CheckAck();
while(IN_KeyDown(sc_LeftArrow)) IN_CheckAck();
WaitKeyUp();
}
break;
......@@ -1668,7 +1703,8 @@ void MouseSensitivity(void)
VW_Bar(61+20*mouseadjustment,98,19,9,READHCOLOR);
VW_UpdateScreen();
SD_PlaySound(MOVEGUN1SND);
while(Keyboard[sc_RightArrow]) IN_CheckAck();
while(IN_KeyDown(sc_RightArrow)) IN_CheckAck();
WaitKeyUp();
}
break;
......@@ -1676,23 +1712,20 @@ void MouseSensitivity(void)
break;
}
if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("debugmode"))
if (IN_KeyDown(sc_Tab) && IN_KeyDown(sc_P) && MS_CheckParm("debugmode"))
PicturePause();
if (ci.button0 || Keyboard[sc_Space] || Keyboard[sc_Enter])
exit=1;
else
if (ci.button1 || Keyboard[sc_Escape])
exit=2;
if (ci.button0 || IN_KeyDown(sc_Space) || IN_KeyDown(sc_Enter))
exit = 1;
else if (ci.button1 || IN_KeyDown(sc_Escape))
exit = 2;
} while(!exit);
if (exit==2)
{
mouseadjustment=oldMA;
if (exit == 2) {
mouseadjustment = oldMA;
SD_PlaySound(ESCPRESSEDSND);
}
else
} else
SD_PlaySound(SHOOTSND);
WaitKeyUp();
......@@ -1704,16 +1737,15 @@ void MouseSensitivity(void)
//
// DRAW CONTROL MENU SCREEN
//
void DrawCtlScreen(void)
void DrawCtlScreen()
{
int i,x,y;
int i, x, y;
ClearMScreen();
DrawStripes(10);
VWB_DrawPic(80,0,C_CONTROLPIC);
VWB_DrawPic(112,184,C_MOUSELBACKPIC);
DrawWindow(CTL_X-8,CTL_Y-5,CTL_W,CTL_H,BKGDCOLOR);
ClearMScreen();
DrawStripes(10);
VWB_DrawPic(80,0,C_CONTROLPIC);
VWB_DrawPic(112,184,C_MOUSELBACKPIC);
DrawWindow(CTL_X-8,CTL_Y-5,CTL_W,CTL_H,BKGDCOLOR);
WindowX=0;
WindowW=320;
......@@ -1915,12 +1947,12 @@ void EnterCtrlData(int index,CustomCtrls *cust,void (*DrawRtn)(int),void (*Print
ReadAnyControl(&ci);
if (type==MOUSE || type==JOYSTICK)
if (IN_KeyDown(sc_Enter)||IN_KeyDown(sc_Control)||IN_KeyDown(sc_Alt))
{
IN_ClearKeysDown();
ci.button0=ci.button1=false;
}
if (type==MOUSE || type==JOYSTICK)
if (IN_KeyDown(sc_Enter) || IN_KeyDown(sc_Control) || IN_KeyDown(sc_Alt))
{
IN_ClearKeysDown();
ci.button0=ci.button1=false;
}
//
// CHANGE BUTTON VALUE?
......@@ -2458,14 +2490,12 @@ void CP_ChangeView(void)
break;
}
if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("debugmode"))
if (IN_KeyDown(sc_Tab) && IN_KeyDown(sc_P) && MS_CheckParm("debugmode"))
PicturePause();
if (ci.button0 || Keyboard[sc_Enter])
if (ci.button0 || IN_KeyDown(sc_Enter))
exit=1;
else
if (ci.button1 || Keyboard[sc_Escape])
{
else if (ci.button1 || IN_KeyDown(sc_Escape)) {
viewwidth=oldview*16;
SD_PlaySound(ESCPRESSEDSND);
MenuFadeOut();
......@@ -2830,9 +2860,9 @@ int HandleMenu(CP_iteminfo *item_i,CP_itemtype *items,void (*routine)(int w))
// CHECK FOR SCREEN CAPTURE
//
#ifndef SPEAR
if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))
if (IN_KeyDown(sc_Tab) && IN_KeyDown(sc_P) && MS_CheckParm("goobers"))
#else
if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("debugmode"))
if (IN_KeyDown(sc_Tab) && IN_KeyDown(sc_P) && MS_CheckParm("debugmode"))
#endif
PicturePause();
......@@ -2945,14 +2975,11 @@ int HandleMenu(CP_iteminfo *item_i,CP_itemtype *items,void (*routine)(int w))
break;
}
if (ci.button0 ||
Keyboard[sc_Space] ||
Keyboard[sc_Enter])
exit=1;
if (ci.button0 || IN_KeyDown(sc_Space) || IN_KeyDown(sc_Enter))
exit = 1;
if (ci.button1 ||
Keyboard[sc_Escape])
exit=2;
if (ci.button1 || IN_KeyDown(sc_Escape))
exit = 2;
} while(!exit);
......@@ -3126,13 +3153,9 @@ void SetMenuTextColor(CP_itemtype *items,int hlight)
void WaitKeyUp(void)
{
ControlInfo ci;
while(ReadAnyControl(&ci), ci.button0|
ci.button1|
ci.button2|
ci.button3|
Keyboard[sc_Space]|
Keyboard[sc_Enter]|
Keyboard[sc_Escape]);
while(ReadAnyControl(&ci),
ci.button0|ci.button1|ci.button2|ci.button3|
IN_KeyDown(sc_Space)|IN_KeyDown(sc_Enter)|IN_KeyDown(sc_Escape));
}
......@@ -3179,7 +3202,7 @@ int Confirm(char *string)
do
{
IN_CheckAck(); /* TODO: force update */
IN_CheckAck(); /* force update */
if (get_TimeCount() >= 10)
{
switch(tick)
......@@ -3197,18 +3220,17 @@ int Confirm(char *string)
set_TimeCount(0);
}
if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))
if (IN_KeyDown(sc_Tab) && IN_KeyDown(sc_P) && MS_CheckParm("goobers"))
PicturePause();
} while(!Keyboard[sc_Y] && !Keyboard[sc_N] && !Keyboard[sc_Escape]);
} while(!IN_KeyDown(sc_Y) && !IN_KeyDown(sc_N) && !IN_KeyDown(sc_Escape));
if (Keyboard[sc_Y])
{
if (IN_KeyDown(sc_Y)) {
xit=1;
ShootSnd();
}
while(Keyboard[sc_Y] || Keyboard[sc_N] || Keyboard[sc_Escape]) IN_CheckAck();
while(IN_KeyDown(sc_Y) || IN_KeyDown(sc_N) || IN_KeyDown(sc_Escape)) IN_CheckAck();
IN_ClearKeysDown();
SD_PlaySound(whichsnd[xit]);
......@@ -3283,24 +3305,6 @@ void FreeMusic(void)
}
///////////////////////////////////////////////////////////////////////////
//
// IN_GetScanName() - Returns a string containing the name of the
// specified scan code
//
///////////////////////////////////////////////////////////////////////////
byte *IN_GetScanName(ScanCode scan)
{
byte **p;
ScanCode *s;
for (s = ExtScanCodes,p = ExtScanNames;*s;p++,s++)
if (*s == scan)
return(*p);
return(ScanNames[scan]);
}
///////////////////////////////////////////////////////////////////////////
//
......@@ -3332,11 +3336,11 @@ void CheckPause(void)
///////////////////////////////////////////////////////////////////////////
void DrawMenuGun(CP_iteminfo *iteminfo)
{
int x,y;
int x, y;
x=iteminfo->x;
y=iteminfo->y+iteminfo->curpos*13-2;
x = iteminfo->x;
y = iteminfo->y+iteminfo->curpos*13-2;
VWB_DrawPic(x,y,C_CURSOR1PIC);
}
......@@ -3357,7 +3361,7 @@ void DrawStripes(int y)
#endif
}
void ShootSnd(void)
void ShootSnd()
{
SD_PlaySound(SHOOTSND);
}
......@@ -3378,9 +3382,8 @@ void CheckForEpisodes()
//
#ifndef UPLOAD
#ifndef SPEAR
if (!findfirst("*.WL6",&f,FA_ARCH))
{
strcpy(extension,"WL6");
if (!findfirst("*.wl6", &f, FA_ARCH)) {
strcpy(extension, "wl6");
NewEmenu[2].active =
NewEmenu[4].active =
NewEmenu[6].active =
......@@ -3392,10 +3395,8 @@ void CheckForEpisodes()
EpisodeSelect[4] =
EpisodeSelect[5] = 1;
}
else
if (!findfirst("*.WL3",&f,FA_ARCH))
{
strcpy(extension,"WL3");
else if (!findfirst("*.wl3", &f, FA_ARCH)) {
strcpy(extension, "wl3");
NewEmenu[2].active =
NewEmenu[4].active =
EpisodeSelect[1] =
......@@ -3407,33 +3408,27 @@ void CheckForEpisodes()
#ifdef SPEAR
#ifndef SPEARDEMO
if (!findfirst("*.SOD",&f,FA_ARCH))
{
strcpy(extension,"SOD");
}
else
if (!findfirst("*.sod", &f, FA_ARCH)) {
strcpy(extension, "sod");
} else
Quit("NO SPEAR OF DESTINY DATA FILES TO BE FOUND!");
#else /* SPEARDEMO */
if (!findfirst("*.SDM",&f,FA_ARCH))
{
strcpy(extension,"SDM");
}
else
if (!findfirst("*.sdm",&f,FA_ARCH)) {
strcpy(extension, "sdm");
} else
Quit("NO SPEAR OF DESTINY DEMO DATA FILES TO BE FOUND!");
#endif /* SPEARDEMO */
#else /* SPEAR */
if (!findfirst("*.WL1",&f,FA_ARCH))
{
strcpy(extension,"WL1");
}
else
if (!findfirst("*.wl1",&f,FA_ARCH)) {
strcpy(extension, "wl1");
} else
Quit("NO WOLFENSTEIN 3-D DATA FILES to be found!");
#endif /* SPEAR */
strcat(configname,extension);
strcat(SaveName,extension);
strcat(PageFileName,extension);
strcat(configname, extension);
strcat(SaveName, extension);
strcat(PageFileName, extension);
#else
......@@ -3444,9 +3439,9 @@ void CheckForEpisodes()
//
#ifndef UPLOAD
#ifndef SPEAR
if (_findfirst("*.WL6", &f) != -1)
if (_findfirst("*.wl6", &f) != -1)
{
strcpy(extension,"WL6");
strcpy(extension, "wl6");
NewEmenu[2].active =
NewEmenu[4].active =
NewEmenu[6].active =
......@@ -3457,8 +3452,8 @@ void CheckForEpisodes()
EpisodeSelect[3] =
EpisodeSelect[4] =
EpisodeSelect[5] = 1;
} else if (_findfirst("*.WL3",&f) != -1) {
strcpy(extension,"WL3");
} else if (_findfirst("*.wl3",&f) != -1) {
strcpy(extension, "wl3");
NewEmenu[2].active =
NewEmenu[4].active =
EpisodeSelect[1] =
......@@ -3470,33 +3465,27 @@ void CheckForEpisodes()
#ifdef SPEAR
#ifndef SPEARDEMO
if (_findfirst("*.SOD",&f) != -1)
{
strcpy(extension,"SOD");
}
else
if (_findfirst("*.sod", &f) != -1) {
strcpy(extension, "sod");
} else
Quit("NO SPEAR OF DESTINY DATA FILES TO BE FOUND!");
#else /* SPEARDEMO */
if (_findfirst("*.SDM",&f) != -1)
{
strcpy(extension,"SDM");
}
else
if (_findfirst("*.sdm", &f) != -1) {
strcpy(extension, "sdm");
} else
Quit("NO SPEAR OF DESTINY DEMO DATA FILES TO BE FOUND!");
#endif /* SPEARDEMO */
#else /* SPEAR */
if (_findfirst("*.WL1",&f) != -1)
{
strcpy(extension,"WL1");
}
else
if (_findfirst("*.wl1",&f) != -1) {
strcpy(extension, "wl1");
} else
Quit("NO WOLFENSTEIN 3-D DATA FILES to be found!");
#endif /* SPEAR */
strcat(configname,extension);
strcat(SaveName,extension);
strcat(PageFileName,extension);
strcat(configname, extension);
strcat(SaveName, extension);
strcat(PageFileName, extension);
#endif
#else
......@@ -3507,7 +3496,7 @@ void CheckForEpisodes()
#ifndef UPLOAD
#ifndef SPEAR
if (glob("*.wl6", 0, NULL, &globbuf) == 0) {
strcpy(extension,"wl6");
strcpy(extension, "wl6");
NewEmenu[2].active =
NewEmenu[4].active =
NewEmenu[6].active =
......@@ -3519,13 +3508,12 @@ void CheckForEpisodes()
EpisodeSelect[4] =
EpisodeSelect[5] = 1;
} else if (glob("*.wl3", 0, NULL, &globbuf) == 0) {
strcpy(extension,"wl3");
strcpy(extension, "wl3");
NewEmenu[2].active =
NewEmenu[4].active =
EpisodeSelect[1] =
EpisodeSelect[2] = 1;
}
else
} else
#endif /* SPEAR */
#endif /* UPLOAD */
......@@ -3538,22 +3526,20 @@ void CheckForEpisodes()
#else /* SPEARDEMO */
if (glob("*.sdm", 0, NULL, &globbuf) == 0) {
strcpy(extension, "sdm");
}
else
} else
Quit("NO SPEAR OF DESTINY DEMO DATA FILES TO BE FOUND!");
#endif /* SPEARDEMO */
#else /* SPEAR */
if (glob("*.wl1", 0, NULL, &globbuf) == 0) {
strcpy(extension,"wl1");
}
else
strcpy(extension, "wl1");
} else
Quit("NO WOLFENSTEIN 3-D DATA FILES to be found!");
#endif /* SPEAR */
strcat(configname,extension);
strcat(SaveName,extension);
strcat(PageFileName,extension);
strcat(configname, extension);
strcat(SaveName, extension);
strcat(PageFileName, extension);
#endif
......
......@@ -84,25 +84,25 @@
#define CST_X 20
#define CST_Y 48
#define CST_START 60
#define CST_SPC 60
#define CST_SPC 60
//
// TYPEDEFS
//
typedef struct {
int x,y,amount,curpos,indent;
} CP_iteminfo;
int x,y,amount,curpos,indent;
} CP_iteminfo;
typedef struct {
int active;
char string[36];
void (* routine)(int temp1);
} CP_itemtype;
int active;
char string[36];
void (* routine)(int temp1);
} CP_itemtype;
typedef struct {
int allowed[4];
} CustomCtrls;
int allowed[4];
} CustomCtrls;
extern CP_itemtype MainMenu[], NewEMenu[];
extern CP_iteminfo MainItems;
......@@ -114,9 +114,7 @@ void SetupControlPanel(void);
void CleanupControlPanel(void);
void DrawMenu(CP_iteminfo *item_i,CP_itemtype *items);
int HandleMenu(CP_iteminfo *item_i,
CP_itemtype *items,
void (*routine)(int w));
int HandleMenu(CP_iteminfo *item_i, CP_itemtype *items, void (*routine)(int w));
void ClearMScreen(void);
void DrawWindow(int x,int y,int w,int h,int wcolor);
void DrawOutline(int x,int y,int w,int h,int color1,int color2);
......@@ -214,13 +212,13 @@ enum
// WL_INTER
//
typedef struct {
int kill,secret,treasure;
long time;
} LRstruct;
int kill,secret,treasure;
long time;
} LRstruct;
extern LRstruct LevelRatios[];
void Write (int x,int y,char *string);
void Write(int x,int y,char *string);
int GetYorN(int x,int y,int pic);
#endif
......@@ -244,7 +244,7 @@ void PollKeyboardButtons (void)
int i;
for (i=0;i<NUMBUTTONS;i++)
if (Keyboard[buttonscan[i]])
if (IN_KeyDown(buttonscan[i]))
buttonstate[i] = true;
}
......@@ -319,28 +319,28 @@ void PollJoystickButtons (void)
===================
*/
void PollKeyboardMove (void)
void PollKeyboardMove()
{
if (buttonstate[bt_run])
{
if (Keyboard[dirscan[di_north]])
if (IN_KeyDown(dirscan[di_north]))
controly -= RUNMOVE*tics;
if (Keyboard[dirscan[di_south]])
if (IN_KeyDown(dirscan[di_south]))
controly += RUNMOVE*tics;
if (Keyboard[dirscan[di_west]])
if (IN_KeyDown(dirscan[di_west]))
controlx -= RUNMOVE*tics;
if (Keyboard[dirscan[di_east]])
if (IN_KeyDown(dirscan[di_east]))
controlx += RUNMOVE*tics;
}
else
{
if (Keyboard[dirscan[di_north]])
if (IN_KeyDown(dirscan[di_north]))
controly -= BASEMOVE*tics;
if (Keyboard[dirscan[di_south]])
if (IN_KeyDown(dirscan[di_south]))
controly += BASEMOVE*tics;
if (Keyboard[dirscan[di_west]])
if (IN_KeyDown(dirscan[di_west]))
controlx -= BASEMOVE*tics;
if (Keyboard[dirscan[di_east]])
if (IN_KeyDown(dirscan[di_east]))
controlx += BASEMOVE*tics;
}
}
......@@ -590,10 +590,7 @@ void CheckKeys (void)
//
// SECRET CHEAT CODE: TAB-G-F10
//
if (Keyboard[sc_Tab] &&
Keyboard[sc_G] &&
Keyboard[sc_F10])
{
if (IN_KeyDown(sc_Tab) && IN_KeyDown(sc_G) && IN_KeyDown(sc_F10)) {
WindowH = 160;
if (godmode)
{
......@@ -616,16 +613,13 @@ void CheckKeys (void)
//
// SECRET CHEAT CODE: 'MLI'
//
if (Keyboard[sc_M] &&
Keyboard[sc_L] &&
Keyboard[sc_I])
{
if (IN_KeyDown(sc_M) && IN_KeyDown(sc_L) && IN_KeyDown(sc_I)) {
gamestate.health = 100;
gamestate.ammo = 99;
gamestate.keys = 3;
gamestate.score = 0;
gamestate.TimeCount += 42000L;
GiveWeapon (wp_chaingun);
GiveWeapon(wp_chaingun);
DrawWeapon();
DrawHealth();
......@@ -653,11 +647,8 @@ void CheckKeys (void)
//
// OPEN UP DEBUG KEYS
//
if (Keyboard[sc_BackSpace] &&
Keyboard[sc_LShift] &&
Keyboard[sc_Alt] &&
MS_CheckParm("debugmode"))
{
if (IN_KeyDown(sc_BackSpace) && IN_KeyDown(sc_LShift) &&
IN_KeyDown(sc_Alt) && MS_CheckParm("debugmode")) {
ClearMemory ();
CA_CacheGrChunk (STARTFONT+1);
ClearSplitVWB ();
......@@ -674,35 +665,32 @@ void CheckKeys (void)
//
// TRYING THE KEEN CHEAT CODE!
//
if (Keyboard[sc_B] &&
Keyboard[sc_A] &&
Keyboard[sc_T])
{
ClearMemory ();
CA_CacheGrChunk (STARTFONT+1);
ClearSplitVWB ();
if (IN_KeyDown(sc_B) && IN_KeyDown(sc_A) && IN_KeyDown(sc_T)) {
ClearMemory();
CA_CacheGrChunk(STARTFONT+1);
ClearSplitVWB();
Message("Commander Keen is also\n"
"available from Apogee, but\n"
"then, you already know\n"
"that - right, Cheatmeister?!");
Message("Commander Keen is also\n"
"available from Apogee, but\n"
"then, you already know\n"
"that - right, Cheatmeister?!");
CA_UnCacheGrChunk(STARTFONT+1);
IN_ClearKeysDown();
IN_Ack();
CA_UnCacheGrChunk(STARTFONT+1);
IN_ClearKeysDown();
IN_Ack();
DrawAllPlayBorder ();
DrawAllPlayBorder();
}
if (Paused)
{
if (Paused) {
VWB_DrawPic(128, 64, PAUSEDPIC);
VW_UpdateScreen();
SD_MusicOff();
IN_Ack();
IN_ClearKeysDown ();
IN_ClearKeysDown();
SD_MusicOn();
Paused = false;
return;
}
......@@ -759,8 +747,7 @@ void CheckKeys (void)
//
// TAB-? debug keys
//
if (Keyboard[sc_Tab] && DebugOk)
{
if (IN_KeyDown(sc_Tab) && DebugOk) {
CA_CacheGrChunk (STARTFONT);
fontnumber=0;
SETFONTCOLOR(0,15);
......
......@@ -86,60 +86,6 @@ void SetupScaling(int maxscaleheight)
//===========================================================================
/*
========================
=
= BuildCompScale
=
= Builds a compiled scaler object that will scale a 64 tall object to
= the given height (centered vertically on the screen)
=
= height should be even
=
========================
*/
#if 0
void xBuildCompScale(int height, byte *source, int x)
{
int i;
long fix,step;
int startpix,endpix,toppix;
unsigned char al;
step = height << 10;
toppix = (viewheight-height) >> 1;
fix = 0;
for (i = 0; i < 64; i++)
{
startpix = fix>>16;
fix += step;
endpix = fix>>16;
startpix+=toppix;
endpix+=toppix;
if (startpix == endpix || endpix < 0 || startpix >= viewheight)
continue;
al = source[i];
for (;startpix<endpix;startpix++)
{
if (startpix >= viewheight)
break; /* off the bottom of the view area */
if (startpix < 0)
continue; /* not into the view area */
VL_Plot(x+xoffset, startpix+yoffset, al);
}
}
}
#endif
/* TODO: this accesses gfxbuf directly! */
static void ScaledDraw(byte *gfx, int scale, byte *vid, unsigned long tfrac, unsigned long tint, unsigned long delta)
{
......
......@@ -649,7 +649,7 @@ void ShowArticle(char *article)
break;
}
if (Keyboard[sc_Tab] && Keyboard[sc_P] && MS_CheckParm("goobers"))
if (IN_KeyDown(sc_Tab) && IN_KeyDown(sc_P) && MS_CheckParm("goobers"))
PicturePause();
} while (LastScan != sc_Escape);
......
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