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 \
......
This diff is collapsed.
......@@ -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);
......
This diff is collapsed.
......@@ -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