Commit a6936485 authored by Steven Fuller's avatar Steven Fuller

More boring code reformatting.

Fixed a bug with sprite drawing (tops of sprites were not drawn if scaled
larger than view screen size).
parent 29eca737
......@@ -222,11 +222,9 @@ void US_ClearWindow(void)
// US_DrawWindow() - Draws a frame and sets the current window parms
//
///////////////////////////////////////////////////////////////////////////
void
US_DrawWindow(word x,word y,word w,word h)
void US_DrawWindow(word x,word y,word w,word h)
{
word i,
sx,sy,sw,sh;
word i,sx,sy,sw,sh;
WindowX = x * 8;
WindowY = y * 8;
......@@ -261,10 +259,10 @@ US_DrawWindow(word x,word y,word w,word h)
///////////////////////////////////////////////////////////////////////////
static void USL_XORICursor(int x, int y, char *s, word cursor)
{
static boolean status; // VGA doesn't XOR...
static boolean status;
char buf[MaxString];
int temp;
word w,h;
word w, h;
strcpy(buf,s);
buf[cursor] = '\0';
......@@ -272,10 +270,9 @@ static void USL_XORICursor(int x, int y, char *s, word cursor)
px = x + w - 1;
py = y;
if (status^=1)
if (status ^= 1)
USL_DrawString("\x80");
else
{
else {
temp = fontcolor;
fontcolor = backcolor;
USL_DrawString("\x80");
......@@ -297,16 +294,10 @@ static void USL_XORICursor(int x, int y, char *s, word cursor)
boolean US_LineInput(int x,int y,char *buf,char *def,boolean escok,
int maxchars,int maxwidth)
{
boolean redraw,
cursorvis,cursormoved,
done,result = true;
boolean redraw, cursorvis, cursormoved, done, result = true;
ScanCode sc;
char c,
s[MaxString],olds[MaxString];
word i,
cursor,
w,h,
len,temp;
char c, s[MaxString], olds[MaxString];
word i, cursor, w, h, len, temp;
longword lasttime;
if (def)
......@@ -474,7 +465,7 @@ boolean US_LineInput(int x,int y,char *buf,char *def,boolean escok,
return(result);
}
int rndtable[] ={
static const int rndtable[] ={
0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66,
74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36,
95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188,
......
......@@ -107,7 +107,7 @@ void LoadLatchMem()
for (i = LATCHPICS_LUMP_START; i <= LATCHPICS_LUMP_END; i++) {
/* TODO: this just caches them for eternity */
CA_CacheGrChunk (i);
CA_CacheGrChunk(i);
}
}
......@@ -141,7 +141,7 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, uns
do {
if (abortable && IN_CheckAck ())
return true;
for (p=0;p<pixperframe;p++) {
for (p = 0; p < pixperframe; p++) {
y = (rndval & 0x00FF) - 1;
x = (rndval & 0x00FFFF00) >> 8;
......@@ -186,7 +186,7 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
//
// fade through intermediate frames
//
for (i=0;i<steps;i++)
for (i = 0; i < steps; i++)
{
origptr = &palette1[start][0];
newptr = &palette2[start][0];
......@@ -204,7 +204,7 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
}
VL_WaitVBL(1);
VL_SetPalette (&palette2[0][0]);
VL_SetPalette(&palette2[0][0]);
}
//
......
......@@ -395,7 +395,7 @@ void SpawnDoor(int tilex, int tiley, boolean vertical, int lock)
=====================
*/
void OpenDoor (int door)
void OpenDoor(int door)
{
if (doorobjlist[door].action == dr_open)
doorobjlist[door].ticcount = 0; // reset open time
......@@ -412,7 +412,7 @@ void OpenDoor (int door)
=====================
*/
void CloseDoor (int door)
void CloseDoor(int door)
{
int tilex,tiley,area;
objtype *check;
......@@ -493,7 +493,7 @@ void CloseDoor (int door)
=====================
*/
void OperateDoor (int door)
void OperateDoor(int door)
{
int lock;
......@@ -549,7 +549,7 @@ void DoorOpen (int door)
===============
*/
void DoorOpening (int door)
void DoorOpening(int door)
{
int area1,area2;
word *map;
......@@ -612,7 +612,7 @@ void DoorOpening (int door)
===============
*/
void DoorClosing (int door)
void DoorClosing(int door)
{
int area1,area2;
word *map;
......@@ -668,9 +668,6 @@ void DoorClosing (int door)
doorposition[door] = position;
}
/*
=====================
=
......@@ -681,7 +678,7 @@ void DoorClosing (int door)
=====================
*/
void MoveDoors (void)
void MoveDoors()
{
int door;
......@@ -689,7 +686,7 @@ void MoveDoors (void)
return;
for (door = 0 ; door < doornum ; door++)
switch (doorobjlist[door].action)
switch(doorobjlist[door].action)
{
case dr_open:
DoorOpen (door);
......@@ -718,7 +715,7 @@ void MoveDoors (void)
unsigned pwallstate;
unsigned pwallpos; // amount a pushable wall has been moved (0-63)
unsigned pwallx,pwally;
unsigned pwallx, pwally;
int pwalldir;
/*
......@@ -729,7 +726,7 @@ int pwalldir;
===============
*/
void PushWall (int checkx, int checky, int dir)
void PushWall(int checkx, int checky, int dir)
{
int oldtile;
......@@ -806,9 +803,9 @@ void PushWall (int checkx, int checky, int dir)
=================
*/
void MovePWalls (void)
void MovePWalls()
{
int oldblock,oldtile;
int oldblock, oldtile;
if (!pwallstate)
return;
......@@ -893,8 +890,6 @@ void MovePWalls (void)
}
}
pwallpos = (pwallstate/2)&63;
}
......@@ -23,10 +23,6 @@
=============================================================================
*/
dirtype dirtable[9] = {northwest,north,northeast,west,nodir,east,
southwest,south,southeast};
int starthitpoints[4][NUMENEMIES] =
//
// BABY MODE
......@@ -3363,9 +3359,9 @@ void T_Path (objtype *ob)
if (ob->tilex>MAPSIZE || ob->tiley>MAPSIZE)
{
sprintf (str,"T_Path hit a wall at %u,%u, dir %u"
sprintf(str,"T_Path hit a wall at %u,%u, dir %u"
,ob->tilex,ob->tiley,ob->dir);
Quit (str);
Quit(str);
}
......
......@@ -691,7 +691,7 @@ typedef enum {
=============================================================================
*/
extern char str[80],str2[20];
extern char str[80], str2[20];
extern fixed focallength;
extern unsigned viewangles;
......
......@@ -34,9 +34,8 @@
=============================================================================
*/
char str[80],str2[20];
int dirangle[9] = {0,ANGLES/8,2*ANGLES/8,3*ANGLES/8,4*ANGLES/8,
5*ANGLES/8,6*ANGLES/8,7*ANGLES/8,ANGLES};
char str[80], str2[20];
int dirangle[9] = {0,ANGLES/8,2*ANGLES/8,3*ANGLES/8,4*ANGLES/8, 5*ANGLES/8,6*ANGLES/8,7*ANGLES/8,ANGLES};
//
// proejection variables
......@@ -49,8 +48,6 @@ int shootdelta; // pixels away from centerx a ta
fixed scale;
long heightnumerator;
void Quit(char *error);
boolean startgame,loadedgame;
int mouseadjustment;
......@@ -278,7 +275,7 @@ void WriteConfig()
=====================
*/
void NewGame(int difficulty,int episode)
void NewGame(int difficulty, int episode)
{
memset(&gamestate,0,sizeof(gamestate));
......
......@@ -15,9 +15,9 @@
/* scaling data for a given height */
typedef struct {
/* number of destination pixels each source pixels maps to in x and y */
unsigned count [65];
int count[65];
/* the destination pixel for each source pixel row */
short desty [65];
int desty[65];
} t_scaledata;
static t_scaledata scaledata[MAXSCALEHEIGHT+1];
......@@ -25,37 +25,40 @@ static int maxscale;
static void BuildCompScale(int height)
{
long fix,step;
unsigned src;
int startpix,endpix,toppix;
long fix, step;
int src;
int startpix, endpix, toppix;
step = ((long)height<<16) / 64;
toppix = (viewheight-height)/2;
step = ((long)height << 16) / 64;
toppix = (viewheight - height) / 2;
fix = 0;
for (src=0;src<=64;src++)
/* TODO: <= 64, or < 64? */
for (src = 0; src < 64; src++)
{
startpix = fix>>16;
startpix = fix >> 16;
fix += step;
endpix = fix>>16;
if (endpix>startpix)
scaledata [height].count[src] = endpix-startpix;
endpix = fix >> 16;
if (endpix > startpix)
scaledata[height].count[src] = endpix - startpix;
else
scaledata [height].count[src] = 0;
scaledata[height].count[src] = 0;
startpix+=toppix;
endpix+=toppix;
startpix += toppix;
endpix += toppix;
if (startpix == endpix || endpix < 0 || startpix >= viewheight || src == 64)
if ((startpix == endpix) || (endpix < 0) || (startpix >= viewheight) /*|| (src == 64)*/) {
/* source pixel goes off screen */
scaledata [height].desty[src] = -1;
else
scaledata [height].desty[src] = startpix;
scaledata[height].desty[src] = -1;
} else if (startpix < 0) {
scaledata[height].desty[src] = 0;
} else {
scaledata[height].desty[src] = startpix;
/* Clip if needed */
if ( ((signed)scaledata [height].count[src] + (signed)scaledata [height].desty[src]) > viewheight)
scaledata [height].count[src] = viewheight - scaledata [height].desty[src];
if ((scaledata[height].count[src] + scaledata[height].desty[src]) > viewheight)
scaledata[height].count[src] = viewheight - scaledata [height].desty[src];
}
}
}
......@@ -76,8 +79,7 @@ void SetupScaling(int maxscaleheight)
//
// build the compiled scalers
//
for (i=1;i<=maxscaleheight;i++)
{
for (i = 1; i <= maxscaleheight; i++) {
BuildCompScale(i);
}
......@@ -160,21 +162,23 @@ static void ScaleLine()
unsigned char color;
while (linecmds[0]) {
y0 = linecmds[2]/2;
y1 = linecmds[0]/2 - 1;
pixels = (unsigned char *) shapeptr + y0 + linecmds[1];
for (y=y0; y<=y1; y++) {
ys = scaledata[linescale].desty[y];
y0 = linecmds[2] / 2;
/* y1 = linecmds[0] / 2 - 1; */
y1 = linecmds[0] / 2;
pixels = (unsigned char *)shapeptr + y0 + linecmds[1];
if (y1 >= 65) printf("overflow! %d\n", y1);
/* for (y = y0; y <= y1; y++) { */
for (y = y0; y < y1; y++) {
color = *pixels++;
ys = scaledata[linescale].desty[y];
if (ys >= 0) {
for (ny=0; ny<scaledata[linescale].count[y]; ny++) {
for (n = 0, x = slinex; n < slinewidth; n++, x++) {
for (ny = 0; ny < scaledata[linescale].count[y]; ny++)
for (n = 0, x = slinex; n < slinewidth; n++, x++)
VL_Plot(x+xoffset, ys+ny+yoffset, color);
}
}
}
}
linecmds += 3;
}
}
......@@ -202,7 +206,7 @@ void ScaleShape(int xcenter, int shapenum, unsigned height)
word *cmdptr;
boolean leftvis,rightvis;
shape = PM_GetSpritePage (shapenum);
shape = PM_GetSpritePage(shapenum);
scale = height>>2; // low three bits are fractional
scale += 4; /* sprites look a bit better pulled up some */
......@@ -221,7 +225,7 @@ void ScaleShape(int xcenter, int shapenum, unsigned height)
stopx = shape->leftpix;
cmdptr = (word *)&(shape->dataofs[31-stopx]);
while ( --srcx >=stopx && slinex>0)
while ( --srcx >= stopx && slinex>0)
{
linecmds = (short *)((char *) shapeptr + *cmdptr--);
if ( !(slinewidth = scaledata[scale].count[srcx]) )
......@@ -281,7 +285,7 @@ void ScaleShape(int xcenter, int shapenum, unsigned height)
slinex++;
slinewidth--;
}
ScaleLine ();
ScaleLine();
break; // the rest of the shape is gone
}
}
......
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