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