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