remove some dead code and a lot of unnecessary diffs

This commit is contained in:
Bill Currie 2002-12-11 16:45:40 +00:00
parent ca55210c6e
commit bf3fa3dc76
7 changed files with 245 additions and 331 deletions

View file

@ -44,9 +44,8 @@ static const char rcsid[] =
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/draw.h" #include "QF/draw.h"
#include "QF/keys.h" #include "QF/keys.h"
#include "QF/pcx.h" #include "QF/quakefs.h"
#include "QF/quakefs.h" // MAX_OSPATH #include "QF/render.h"
#include "QF/render.h" // r_refdef
#include "QF/screen.h" #include "QF/screen.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/texture.h" #include "QF/texture.h"
@ -64,47 +63,44 @@ static const char rcsid[] =
#include "view.h" #include "view.h"
/* /*
background clear background clear
rendering rendering
turtle/net/ram icons turtle/net/ram icons
sbar sbar
centerprint / slow centerprint centerprint / slow centerprint
notify lines
intermission / finale overlay
loading plaque
console
menu
required background clears
required update regions
syncronous draw mode or async
One off screen buffer, with updates either copied or xblited
Need to double buffer?
async draw will require the refresh area to be cleared, because it will be
xblited, but sync draw can just ignore it.
sync
draw
CenterPrint ()
SlowPrint ()
Screen_Update ();
Con_Printf ();
net
turn off messages option
the refresh is always rendered, unless the console is full screen
console is:
notify lines notify lines
half intermission / finale overlay
full loading plaque
console
menu
required background clears
required update regions
syncronous draw mode or async
One off screen buffer, with updates either copied or xblited
Need to double buffer?
async draw will require the refresh area to be cleared, because it will be
xblited, but sync draw can just ignore it.
sync
draw
CenterPrint ()
SlowPrint ()
Screen_Update ();
Con_Printf ();
net
turn off messages option
the refresh is always rendered, unless the console is full screen
console is:
notify lines
half
full
*/ */
int glx, gly, glwidth, glheight; int glx, gly, glwidth, glheight;
@ -116,7 +112,8 @@ int scr_copyeverything;
float scr_con_current; float scr_con_current;
float scr_conlines; // lines of console to display float scr_conlines; // lines of console to display
int oldscreensize, oldfov; int oldscreensize;
float oldfov;
int oldsbar; int oldsbar;
qboolean scr_initialized; // ready to draw qboolean scr_initialized; // ready to draw
@ -134,9 +131,6 @@ viddef_t vid; // global video state
vrect_t scr_vrect; vrect_t scr_vrect;
qboolean scr_disabled_for_loading;
float scr_disabled_time;
qboolean block_drawing; qboolean block_drawing;
/* CENTER PRINTING */ /* CENTER PRINTING */
@ -304,8 +298,8 @@ SCR_CalcRefdef (void)
} }
r_refdef.vrect.height = vid.height * size + 0.5; r_refdef.vrect.height = vid.height * size + 0.5;
if (r_refdef.vrect.height > vid.height - r_lineadj) if (r_refdef.vrect.height > h)
r_refdef.vrect.height = vid.height - r_lineadj; r_refdef.vrect.height = h;
r_refdef.vrect.x = (vid.width - r_refdef.vrect.width) / 2; r_refdef.vrect.x = (vid.width - r_refdef.vrect.width) / 2;
if (full) if (full)
r_refdef.vrect.y = 0; r_refdef.vrect.y = 0;
@ -424,11 +418,11 @@ SCR_DrawFPS (void)
void void
SCR_DrawTime (void) SCR_DrawTime (void)
{ {
char st[80]; char st[80];
char *timefmt = NULL; char *timefmt = NULL;
int x, y; int x, y;
struct tm *local = NULL; struct tm *local = NULL;
time_t utc = 0; time_t utc = 0;
// any cvar that can take multiple settings must be able to handle abuse. // any cvar that can take multiple settings must be able to handle abuse.
if (show_time->int_val <= 0) if (show_time->int_val <= 0)
@ -591,7 +585,7 @@ SCR_ScreenShot_f (void)
} }
/* /*
Find closest color in the palette for named color Find closest color in the palette for named color
*/ */
int int
MipColor (int r, int g, int b) MipColor (int r, int g, int b)
@ -608,7 +602,7 @@ MipColor (int r, int g, int b)
bestdist = 256 * 256 * 3; bestdist = 256 * 256 * 3;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
static int j; int j;
j = i * 3; j = i * 3;
r1 = vid.palette[j] - r; r1 = vid.palette[j] - r;
g1 = vid.palette[j + 1] - g; g1 = vid.palette[j + 1] - g;
@ -658,7 +652,7 @@ SCR_DrawStringToSnap (const char *s, tex_t *tex, int x, int y)
byte *dest; byte *dest;
byte *buf = tex->data; byte *buf = tex->data;
const unsigned char *p; const unsigned char *p;
int width = tex->width; int width = tex->width;
dest = buf + ((y * width) + x); dest = buf + ((y * width) + x);
@ -753,15 +747,6 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs)
scr_copytop = 0; scr_copytop = 0;
scr_copyeverything = 0; scr_copyeverything = 0;
if (scr_disabled_for_loading) {
if (r_realtime - scr_disabled_time > 60) {
scr_disabled_for_loading = false;
Con_Printf ("load failed.\n");
} else {
return;
}
}
if (!scr_initialized) if (!scr_initialized)
return; // not initialized yet return; // not initialized yet

View file

@ -50,54 +50,53 @@ static const char rcsid[] =
#include "QF/screen.h" #include "QF/screen.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/texture.h" #include "QF/texture.h"
#include "QF/vid.h"
#include "compat.h" #include "compat.h"
#include "d_iface.h"
#include "r_cvar.h" #include "r_cvar.h"
#include "r_dynamic.h"
#include "r_local.h" #include "r_local.h"
#include "sbar.h" #include "sbar.h"
#include "view.h" #include "view.h"
/* /*
background clear background clear
rendering rendering
turtle/net/ram icons turtle/net/ram icons
sbar sbar
centerprint / slow centerprint centerprint / slow centerprint
notify lines
intermission / finale overlay
loading plaque
console
menu
required background clears
required update regions
syncronous draw mode or async
One off screen buffer, with updates either copied or xblited
Need to double buffer?
async draw will require the refresh area to be cleared, because it will be
xblited, but sync draw can just ignore it.
sync
draw
CenterPrint ()
SlowPrint ()
Screen_Update ();
Con_Printf ();
net
turn off messages option
the refresh is always rendered, unless the console is full screen
console is:
notify lines notify lines
half intermission / finale overlay
full loading plaque
console
menu
required background clears
required update regions
syncronous draw mode or async
One off screen buffer, with updates either copied or xblited
Need to double buffer?
async draw will require the refresh area to be cleared, because it will be
xblited, but sync draw can just ignore it.
sync
draw
CenterPrint ()
SlowPrint ()
Screen_Update ();
Con_Printf ();
net
turn off messages option
the refresh is always rendered, unless the console is full screen
console is:
notify lines
half
full
*/ */
// only the refresh window will be updated unless these variables are flagged // only the refresh window will be updated unless these variables are flagged
@ -107,7 +106,8 @@ int scr_copyeverything;
float scr_con_current; float scr_con_current;
float scr_conlines; // lines of console to display float scr_conlines; // lines of console to display
int oldscreensize, oldfov; int oldscreensize;
float oldfov;
int oldsbar; int oldsbar;
qboolean scr_initialized; // ready to draw qboolean scr_initialized; // ready to draw
@ -121,21 +121,16 @@ int scr_fullupdate;
int clearconsole; int clearconsole;
int clearnotify; int clearnotify;
viddef_t vid; // global video state viddef_t vid; // global video state
vrect_t *pconupdate; vrect_t *pconupdate;
vrect_t scr_vrect; vrect_t scr_vrect;
qboolean scr_disabled_for_loading;
qboolean scr_skipupdate; qboolean scr_skipupdate;
qboolean block_drawing; qboolean block_drawing;
/* /* CENTER PRINTING */
CENTER PRINTING
*/
char scr_centerstring[1024]; char scr_centerstring[1024];
float scr_centertime_start; // for slow victory printing float scr_centertime_start; // for slow victory printing
@ -171,13 +166,10 @@ void
SCR_DrawCenterString (void) SCR_DrawCenterString (void)
{ {
char *start; char *start;
int l; int remaining, j, l, x, y;
int j;
int x, y;
int remaining;
// the finale prints the characters one at a time // the finale prints the characters one at a time
if (r_force_fullscreen /*FIXME*/) if (r_force_fullscreen /* FIXME: better test */)
remaining = scr_printspeed->value * (r_realtime - remaining = scr_printspeed->value * (r_realtime -
scr_centertime_start); scr_centertime_start);
else else
@ -223,7 +215,7 @@ SCR_CheckDrawCenterString (void)
scr_centertime_off -= r_frametime; scr_centertime_off -= r_frametime;
if (scr_centertime_off <= 0 && !r_force_fullscreen /*FIXME*/) if (scr_centertime_off <= 0 && !r_force_fullscreen /*FIXME: better test*/)
return; return;
if (key_dest != key_game) if (key_dest != key_game)
return; return;
@ -231,22 +223,19 @@ SCR_CheckDrawCenterString (void)
SCR_DrawCenterString (); SCR_DrawCenterString ();
} }
//============================================================================= static float
float
CalcFov (float fov_x, float width, float height) CalcFov (float fov_x, float width, float height)
{ {
float a; float a, x;
float x;
if (fov_x < 1 || fov_x > 179) if (fov_x < 1 || fov_x > 179)
Sys_Error ("Bad fov: %f", fov_x); Sys_Error ("Bad fov: %f", fov_x);
x = width / tan (fov_x / 360 * M_PI); x = width / tan (fov_x * (M_PI / 360));
a = (x == 0) ? 90 : atan (height / x); // 0 shouldn't happen a = (x == 0) ? 90 : atan (height / x); // 0 shouldn't happen
a = a * 360 / M_PI; a = a * (360 / M_PI);
return a; return a;
} }
@ -271,8 +260,6 @@ SCR_CalcRefdef (void)
// force the status bar to redraw // force the status bar to redraw
Sbar_Changed (); Sbar_Changed ();
//========================================
// bound viewsize // bound viewsize
Cvar_SetValue (scr_viewsize, bound (30, scr_viewsize->int_val, 120)); Cvar_SetValue (scr_viewsize, bound (30, scr_viewsize->int_val, 120));
@ -293,7 +280,7 @@ SCR_CalcRefdef (void)
size = scr_viewsize->int_val; size = scr_viewsize->int_val;
} }
// intermission is always full screen // intermission is always full screen
if (r_force_fullscreen /*FIXME*/) { if (r_force_fullscreen /* FIXME: better test */) {
full = true; full = true;
size = 100.0; size = 100.0;
sb_lines = 0; sb_lines = 0;
@ -395,8 +382,6 @@ SCR_SizeDown_f (void)
vid.recalc_refdef = 1; vid.recalc_refdef = 1;
} }
//============================================================================
void void
SCR_DrawRam (void) SCR_DrawRam (void)
{ {
@ -433,12 +418,13 @@ SCR_DrawTurtle (void)
void void
SCR_DrawFPS (void) SCR_DrawFPS (void)
{ {
char st[80];
double t;
static double lastframetime; static double lastframetime;
double t; int i, x, y;
extern int fps_count; static int lastfps;
static int lastfps;
int i, x, y; extern int fps_count; //FIXME
char st[80];
if (!show_fps->int_val) if (!show_fps->int_val)
return; return;
@ -450,6 +436,9 @@ SCR_DrawFPS (void)
lastframetime = t; lastframetime = t;
} }
snprintf (st, sizeof (st), "%3d FPS", lastfps); snprintf (st, sizeof (st), "%3d FPS", lastfps);
// FIXME! This is evil. -- Deek
// calculate the location of the clock
if (show_time->int_val <= 0) { if (show_time->int_val <= 0) {
i = 8; i = 8;
} else if (show_time->int_val == 1) { } else if (show_time->int_val == 1) {
@ -457,8 +446,9 @@ SCR_DrawFPS (void)
} else { } else {
i = 80; i = 80;
} }
x = hudswap ? vid.width - ((strlen (st) * 8) + i) : i; x = hudswap ? vid.width - ((strlen (st) * 8) + i) : i;
y = vid.height - (sb_lines + 8); y = vid.height - sb_lines - 8;
Draw_String (x, y, st); Draw_String (x, y, st);
} }
@ -466,17 +456,16 @@ SCR_DrawFPS (void)
SCR_DrawTime SCR_DrawTime
Draw a clock on the screen Draw a clock on the screen
Written by Misty, rewritten by Deek Written by Misty, rewritten by Deek.
*/ */
void void
SCR_DrawTime (void) SCR_DrawTime (void)
{ {
int x, y; char st[80];
char st[80]; char *timefmt = NULL;
int x, y;
time_t utc = 0; struct tm *local = NULL;
struct tm *local = NULL; time_t utc = 0;
char *timefmt = NULL;
// any cvar that can take multiple settings must be able to handle abuse. // any cvar that can take multiple settings must be able to handle abuse.
if (show_time->int_val <= 0) if (show_time->int_val <= 0)
@ -491,9 +480,9 @@ SCR_DrawTime (void)
} else if (show_time->int_val >= 2) { // US AM/PM display } else if (show_time->int_val >= 2) { // US AM/PM display
timefmt = "%l:%M %P"; timefmt = "%l:%M %P";
} }
// Print it next to the fps meter
strftime (st, sizeof (st), timefmt, local); strftime (st, sizeof (st), timefmt, local);
// Print it at far left/right of screen
x = hudswap ? (vid.width - ((strlen (st) * 8) + 8)) : 8; x = hudswap ? (vid.width - ((strlen (st) * 8) + 8)) : 8;
y = vid.height - (sb_lines + 8); y = vid.height - (sb_lines + 8);
Draw_String (x, y, st); Draw_String (x, y, st);
@ -515,8 +504,6 @@ SCR_DrawPause (void)
(vid.height - 48 - pic->height) / 2, pic); (vid.height - 48 - pic->height) / 2, pic);
} }
//=============================================================================
void void
SCR_SetUpToDrawConsole (void) SCR_SetUpToDrawConsole (void)
{ {
@ -556,21 +543,15 @@ SCR_DrawConsole (void)
Con_DrawConsole (scr_con_current); Con_DrawConsole (scr_con_current);
} }
/* /* SCREEN SHOTS */
SCREEN SHOTS
*/
tex_t * tex_t *
SCR_ScreenShot (int width, int height) SCR_ScreenShot (int width, int height)
{ {
int x, y;
unsigned char *src, *dest; unsigned char *src, *dest;
int w, h; float fracw, frach;
int dx, dy, dex, dey, nx; int count, dex, dey, dx, dy, nx, r, g, b, x, y, w, h;
int r, b, g; tex_t *tex;
int count;
float fracw, frach;
tex_t *tex;
// enable direct drawing of console to back buffer // enable direct drawing of console to back buffer
D_EnableBackBufferAccess (); D_EnableBackBufferAccess ();
@ -605,7 +586,7 @@ SCR_ScreenShot (int width, int height)
dey++; // at least one dey++; // at least one
count = 0; count = 0;
for ( /* */ ; dy < dey; dy++) { for (; dy < dey; dy++) {
src = vid.buffer + (vid.rowbytes * dy) + dx; src = vid.buffer + (vid.rowbytes * dy) + dx;
for (nx = dx; nx < dex; nx++) { for (nx = dx; nx < dex; nx++) {
r += vid.basepal[*src * 3]; r += vid.basepal[*src * 3];
@ -661,13 +642,11 @@ SCR_ScreenShot_f (void)
int int
MipColor (int r, int g, int b) MipColor (int r, int g, int b)
{ {
int i; float bestdist, dist;
float dist; int r1, g1, b1, i;
int best = 0; int best = 0;
float bestdist;
int r1, g1, b1;
static int lr = -1, lg = -1, lb = -1;
static int lastbest; static int lastbest;
static int lr = -1, lg = -1, lb = -1;
if (r == lr && g == lg && b == lb) if (r == lr && g == lg && b == lb)
return lastbest; return lastbest;
@ -675,9 +654,11 @@ MipColor (int r, int g, int b)
bestdist = 256 * 256 * 3; bestdist = 256 * 256 * 3;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
r1 = vid.palette[i * 3] - r; int j;
g1 = vid.palette[i * 3 + 1] - g; j = i * 3;
b1 = vid.palette[i * 3 + 2] - b; r1 = vid.palette[j] - r;
g1 = vid.palette[j + 1] - g;
b1 = vid.palette[j + 2] - b;
dist = r1 * r1 + g1 * g1 + b1 * b1; dist = r1 * r1 + g1 * g1 + b1 * b1;
if (dist < bestdist) { if (dist < bestdist) {
bestdist = dist; bestdist = dist;
@ -696,10 +677,8 @@ MipColor (int r, int g, int b)
void void
SCR_DrawCharToSnap (int num, byte * dest, int width) SCR_DrawCharToSnap (int num, byte * dest, int width)
{ {
int row, col;
byte *source; byte *source;
int drawline; int col, row, drawline, x;
int x;
row = num >> 4; row = num >> 4;
col = num & 15; col = num & 15;
@ -722,10 +701,10 @@ SCR_DrawCharToSnap (int num, byte * dest, int width)
void void
SCR_DrawStringToSnap (const char *s, tex_t *tex, int x, int y) SCR_DrawStringToSnap (const char *s, tex_t *tex, int x, int y)
{ {
byte *buf = tex->data;
byte *dest; byte *dest;
byte *buf = tex->data;
const unsigned char *p; const unsigned char *p;
int width = tex->width; int width = tex->width;
dest = buf + ((y * width) + x); dest = buf + ((y * width) + x);
@ -736,16 +715,13 @@ SCR_DrawStringToSnap (const char *s, tex_t *tex, int x, int y)
} }
} }
//=============================================================================
char *scr_notifystring; char *scr_notifystring;
void void
SCR_DrawNotifyString (void) SCR_DrawNotifyString (void)
{ {
char *start; char *start;
int l; int l, x, y;
int x, y;
start = scr_notifystring; start = scr_notifystring;
@ -770,8 +746,6 @@ SCR_DrawNotifyString (void)
} while (1); } while (1);
} }
//=============================================================================
/* /*
SCR_UpdateScreen SCR_UpdateScreen
@ -784,15 +758,12 @@ SCR_DrawNotifyString (void)
void void
SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs)
{ {
static int oldscr_viewsize; static int oldviewsize;
vrect_t vrect; vrect_t vrect;
if (scr_skipupdate || block_drawing) if (scr_skipupdate || block_drawing)
return; return;
if (scr_disabled_for_loading)
return;
r_realtime = realtime; r_realtime = realtime;
scr_copytop = 0; scr_copytop = 0;
@ -801,14 +772,13 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs)
if (!scr_initialized) if (!scr_initialized)
return; // not initialized yet return; // not initialized yet
if (scr_viewsize->int_val != oldscr_viewsize) { if (oldviewsize != scr_viewsize->int_val) {
oldscr_viewsize = scr_viewsize->int_val; oldviewsize = scr_viewsize->int_val;
vid.recalc_refdef = 1; vid.recalc_refdef = true;
} }
// check for vid changes if (oldfov != scr_fov->value) { // determine size of refresh window
if (oldfov != scr_fov->int_val) { oldfov = scr_fov->value;
oldfov = scr_fov->int_val;
vid.recalc_refdef = true; vid.recalc_refdef = true;
} }
@ -817,10 +787,8 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs)
vid.recalc_refdef = true; vid.recalc_refdef = true;
} }
if (vid.recalc_refdef) { if (vid.recalc_refdef)
// something changed, so reorder the screen
SCR_CalcRefdef (); SCR_CalcRefdef ();
}
// do 3D refresh drawing, and then update the screen // do 3D refresh drawing, and then update the screen
D_EnableBackBufferAccess (); // of all overlay stuff if drawing D_EnableBackBufferAccess (); // of all overlay stuff if drawing
@ -897,11 +865,10 @@ void
SCR_Init (void) SCR_Init (void)
{ {
// register our commands // register our commands
Cmd_AddCommand ("screenshot", SCR_ScreenShot_f, "Take a screenshot and " Cmd_AddCommand ("screenshot", SCR_ScreenShot_f, "Take a screenshot, "
"write it as qfxxx.tga in the current directory"); "saves as qfxxx.pcx in the current directory");
Cmd_AddCommand ("sizeup", SCR_SizeUp_f, "Increase the size of the screen"); Cmd_AddCommand ("sizeup", SCR_SizeUp_f, "Increases the screen size");
Cmd_AddCommand ("sizedown", SCR_SizeDown_f, "Decrease the size of the " Cmd_AddCommand ("sizedown", SCR_SizeDown_f, "Decreases the screen size");
"screen");
scr_ram = Draw_PicFromWad ("ram"); scr_ram = Draw_PicFromWad ("ram");
scr_net = Draw_PicFromWad ("net"); scr_net = Draw_PicFromWad ("net");

View file

@ -50,54 +50,53 @@ static const char rcsid[] =
#include "QF/screen.h" #include "QF/screen.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/texture.h" #include "QF/texture.h"
#include "QF/vid.h"
#include "compat.h" #include "compat.h"
#include "d_iface.h"
#include "r_cvar.h" #include "r_cvar.h"
#include "r_dynamic.h"
#include "r_local.h" #include "r_local.h"
#include "sbar.h" #include "sbar.h"
#include "view.h" #include "view.h"
/* /*
background clear background clear
rendering rendering
turtle/net/ram icons turtle/net/ram icons
sbar sbar
centerprint / slow centerprint centerprint / slow centerprint
notify lines
intermission / finale overlay
loading plaque
console
menu
required background clears
required update regions
syncronous draw mode or async
One off screen buffer, with updates either copied or xblited
Need to double buffer?
async draw will require the refresh area to be cleared, because it will be
xblited, but sync draw can just ignore it.
sync
draw
CenterPrint ()
SlowPrint ()
Screen_Update ();
Con_Printf ();
net
turn off messages option
the refresh is always rendered, unless the console is full screen
console is:
notify lines notify lines
half intermission / finale overlay
full loading plaque
console
menu
required background clears
required update regions
syncronous draw mode or async
One off screen buffer, with updates either copied or xblited
Need to double buffer?
async draw will require the refresh area to be cleared, because it will be
xblited, but sync draw can just ignore it.
sync
draw
CenterPrint ()
SlowPrint ()
Screen_Update ();
Con_Printf ();
net
turn off messages option
the refresh is always rendered, unless the console is full screen
console is:
notify lines
half
full
*/ */
// only the refresh window will be updated unless these variables are flagged // only the refresh window will be updated unless these variables are flagged
@ -107,7 +106,8 @@ int scr_copyeverything;
float scr_con_current; float scr_con_current;
float scr_conlines; // lines of console to display float scr_conlines; // lines of console to display
int oldscreensize, oldfov; int oldscreensize;
float oldfov;
int oldsbar; int oldsbar;
qboolean scr_initialized; // ready to draw qboolean scr_initialized; // ready to draw
@ -121,21 +121,16 @@ int scr_fullupdate;
int clearconsole; int clearconsole;
int clearnotify; int clearnotify;
viddef_t vid; // global video state viddef_t vid; // global video state
vrect_t *pconupdate; vrect_t *pconupdate;
vrect_t scr_vrect; vrect_t scr_vrect;
qboolean scr_disabled_for_loading;
qboolean scr_skipupdate; qboolean scr_skipupdate;
qboolean block_drawing; qboolean block_drawing;
/* /* CENTER PRINTING */
CENTER PRINTING
*/
char scr_centerstring[1024]; char scr_centerstring[1024];
float scr_centertime_start; // for slow victory printing float scr_centertime_start; // for slow victory printing
@ -171,13 +166,10 @@ void
SCR_DrawCenterString (void) SCR_DrawCenterString (void)
{ {
char *start; char *start;
int l; int remaining, j, l, x, y;
int j;
int x, y;
int remaining;
// the finale prints the characters one at a time // the finale prints the characters one at a time
if (r_force_fullscreen /*FIXME*/) if (r_force_fullscreen /* FIXME: better test */)
remaining = scr_printspeed->value * (r_realtime - remaining = scr_printspeed->value * (r_realtime -
scr_centertime_start); scr_centertime_start);
else else
@ -223,7 +215,7 @@ SCR_CheckDrawCenterString (void)
scr_centertime_off -= r_frametime; scr_centertime_off -= r_frametime;
if (scr_centertime_off <= 0 && !r_force_fullscreen /*FIXME*/) if (scr_centertime_off <= 0 && !r_force_fullscreen /*FIXME: better test*/)
return; return;
if (key_dest != key_game) if (key_dest != key_game)
return; return;
@ -231,22 +223,19 @@ SCR_CheckDrawCenterString (void)
SCR_DrawCenterString (); SCR_DrawCenterString ();
} }
//============================================================================= static float
float
CalcFov (float fov_x, float width, float height) CalcFov (float fov_x, float width, float height)
{ {
float a; float a, x;
float x;
if (fov_x < 1 || fov_x > 179) if (fov_x < 1 || fov_x > 179)
Sys_Error ("Bad fov: %f", fov_x); Sys_Error ("Bad fov: %f", fov_x);
x = width / tan (fov_x / 360 * M_PI); x = width / tan (fov_x * (M_PI / 360));
a = (x == 0) ? 90 : atan (height / x); // 0 shouldn't happen a = (x == 0) ? 90 : atan (height / x); // 0 shouldn't happen
a = a * 360 / M_PI; a = a * (360 / M_PI);
return a; return a;
} }
@ -271,8 +260,6 @@ SCR_CalcRefdef (void)
// force the status bar to redraw // force the status bar to redraw
Sbar_Changed (); Sbar_Changed ();
//========================================
// bound viewsize // bound viewsize
Cvar_SetValue (scr_viewsize, bound (30, scr_viewsize->int_val, 120)); Cvar_SetValue (scr_viewsize, bound (30, scr_viewsize->int_val, 120));
@ -293,7 +280,7 @@ SCR_CalcRefdef (void)
size = scr_viewsize->int_val; size = scr_viewsize->int_val;
} }
// intermission is always full screen // intermission is always full screen
if (r_force_fullscreen /*FIXME*/) { if (r_force_fullscreen /* FIXME: better test */) {
full = true; full = true;
size = 100.0; size = 100.0;
sb_lines = 0; sb_lines = 0;
@ -343,11 +330,11 @@ SCR_CalcRefdef (void)
void void
SCR_ApplyBlend (void) // Used to be V_UpdatePalette SCR_ApplyBlend (void) // Used to be V_UpdatePalette
{ {
int r, b, g, i; int r, g, b, i;
byte *basepal, *newpal; byte *basepal, *newpal;
byte pal[768]; byte pal[768];
switch(r_pixbytes) { switch(r_pixbytes) {
case 1: case 1:
@ -462,8 +449,6 @@ SCR_SizeDown_f (void)
vid.recalc_refdef = 1; vid.recalc_refdef = 1;
} }
//============================================================================
void void
SCR_DrawRam (void) SCR_DrawRam (void)
{ {
@ -500,12 +485,13 @@ SCR_DrawTurtle (void)
void void
SCR_DrawFPS (void) SCR_DrawFPS (void)
{ {
char st[80];
double t;
static double lastframetime; static double lastframetime;
double t; int i, x, y;
extern int fps_count; static int lastfps;
static int lastfps;
int i, x, y; extern int fps_count; //FIXME
char st[80];
if (!show_fps->int_val) if (!show_fps->int_val)
return; return;
@ -517,6 +503,9 @@ SCR_DrawFPS (void)
lastframetime = t; lastframetime = t;
} }
snprintf (st, sizeof (st), "%3d FPS", lastfps); snprintf (st, sizeof (st), "%3d FPS", lastfps);
// FIXME! This is evil. -- Deek
// calculate the location of the clock
if (show_time->int_val <= 0) { if (show_time->int_val <= 0) {
i = 8; i = 8;
} else if (show_time->int_val == 1) { } else if (show_time->int_val == 1) {
@ -524,8 +513,9 @@ SCR_DrawFPS (void)
} else { } else {
i = 80; i = 80;
} }
x = hudswap ? vid.width - ((strlen (st) * 8) + i) : i; x = hudswap ? vid.width - ((strlen (st) * 8) + i) : i;
y = vid.height - (sb_lines + 8); y = vid.height - sb_lines - 8;
Draw_String (x, y, st); Draw_String (x, y, st);
} }
@ -533,17 +523,16 @@ SCR_DrawFPS (void)
SCR_DrawTime SCR_DrawTime
Draw a clock on the screen Draw a clock on the screen
Written by Misty, rewritten by Deek Written by Misty, rewritten by Deek.
*/ */
void void
SCR_DrawTime (void) SCR_DrawTime (void)
{ {
int x, y; char st[80];
char st[80]; char *timefmt = NULL;
int x, y;
time_t utc = 0; struct tm *local = NULL;
struct tm *local = NULL; time_t utc = 0;
char *timefmt = NULL;
// any cvar that can take multiple settings must be able to handle abuse. // any cvar that can take multiple settings must be able to handle abuse.
if (show_time->int_val <= 0) if (show_time->int_val <= 0)
@ -558,9 +547,9 @@ SCR_DrawTime (void)
} else if (show_time->int_val >= 2) { // US AM/PM display } else if (show_time->int_val >= 2) { // US AM/PM display
timefmt = "%l:%M %P"; timefmt = "%l:%M %P";
} }
// Print it next to the fps meter
strftime (st, sizeof (st), timefmt, local); strftime (st, sizeof (st), timefmt, local);
// Print it at far left/right of screen
x = hudswap ? (vid.width - ((strlen (st) * 8) + 8)) : 8; x = hudswap ? (vid.width - ((strlen (st) * 8) + 8)) : 8;
y = vid.height - (sb_lines + 8); y = vid.height - (sb_lines + 8);
Draw_String (x, y, st); Draw_String (x, y, st);
@ -582,8 +571,6 @@ SCR_DrawPause (void)
(vid.height - 48 - pic->height) / 2, pic); (vid.height - 48 - pic->height) / 2, pic);
} }
//=============================================================================
void void
SCR_SetUpToDrawConsole (void) SCR_SetUpToDrawConsole (void)
{ {
@ -623,9 +610,7 @@ SCR_DrawConsole (void)
Con_DrawConsole (scr_con_current); Con_DrawConsole (scr_con_current);
} }
/* /* SCREEN SHOTS */
SCREEN SHOTS
*/
tex_t * tex_t *
SCR_ScreenShot (int width, int height) SCR_ScreenShot (int width, int height)
@ -677,13 +662,11 @@ SCR_ScreenShot_f (void)
int int
MipColor (int r, int g, int b) MipColor (int r, int g, int b)
{ {
int i; float bestdist, dist;
float dist; int r1, g1, b1, i;
int best = 0; int best = 0;
float bestdist;
int r1, g1, b1;
static int lr = -1, lg = -1, lb = -1;
static int lastbest; static int lastbest;
static int lr = -1, lg = -1, lb = -1;
if (r == lr && g == lg && b == lb) if (r == lr && g == lg && b == lb)
return lastbest; return lastbest;
@ -691,9 +674,11 @@ MipColor (int r, int g, int b)
bestdist = 256 * 256 * 3; bestdist = 256 * 256 * 3;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
r1 = vid.palette[i * 3] - r; int j;
g1 = vid.palette[i * 3 + 1] - g; j = i * 3;
b1 = vid.palette[i * 3 + 2] - b; r1 = vid.palette[j] - r;
g1 = vid.palette[j + 1] - g;
b1 = vid.palette[j + 2] - b;
dist = r1 * r1 + g1 * g1 + b1 * b1; dist = r1 * r1 + g1 * g1 + b1 * b1;
if (dist < bestdist) { if (dist < bestdist) {
bestdist = dist; bestdist = dist;
@ -712,10 +697,8 @@ MipColor (int r, int g, int b)
void void
SCR_DrawCharToSnap (int num, byte * dest, int width) SCR_DrawCharToSnap (int num, byte * dest, int width)
{ {
int row, col;
byte *source; byte *source;
int drawline; int col, row, drawline, x;
int x;
row = num >> 4; row = num >> 4;
col = num & 15; col = num & 15;
@ -730,7 +713,7 @@ SCR_DrawCharToSnap (int num, byte * dest, int width)
else else
dest[x] = 98; dest[x] = 98;
source += 128; source += 128;
dest += width; dest -= width;
} }
} }
@ -738,10 +721,10 @@ SCR_DrawCharToSnap (int num, byte * dest, int width)
void void
SCR_DrawStringToSnap (const char *s, tex_t *tex, int x, int y) SCR_DrawStringToSnap (const char *s, tex_t *tex, int x, int y)
{ {
byte *buf = tex->data;
byte *dest; byte *dest;
byte *buf = tex->data;
const unsigned char *p; const unsigned char *p;
int width = tex->width; int width = tex->width;
dest = buf + ((y * width) + x); dest = buf + ((y * width) + x);
@ -752,16 +735,13 @@ SCR_DrawStringToSnap (const char *s, tex_t *tex, int x, int y)
} }
} }
//=============================================================================
char *scr_notifystring; char *scr_notifystring;
void void
SCR_DrawNotifyString (void) SCR_DrawNotifyString (void)
{ {
char *start; char *start;
int l; int l, x, y;
int x, y;
start = scr_notifystring; start = scr_notifystring;
@ -775,6 +755,8 @@ SCR_DrawNotifyString (void)
x = (vid.width - l * 8) / 2; x = (vid.width - l * 8) / 2;
Draw_nString (x, y, start, l); Draw_nString (x, y, start, l);
y += 8;
while (*start && *start != '\n') while (*start && *start != '\n')
start++; start++;
@ -784,8 +766,6 @@ SCR_DrawNotifyString (void)
} while (1); } while (1);
} }
//=============================================================================
/* /*
SCR_UpdateScreen SCR_UpdateScreen
@ -798,15 +778,12 @@ SCR_DrawNotifyString (void)
void void
SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs)
{ {
static int oldscr_viewsize; static int oldviewsize;
vrect_t vrect; vrect_t vrect;
if (scr_skipupdate || block_drawing) if (scr_skipupdate || block_drawing)
return; return;
if (scr_disabled_for_loading)
return;
r_realtime = realtime; r_realtime = realtime;
scr_copytop = 0; scr_copytop = 0;
@ -815,14 +792,13 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs)
if (!scr_initialized) if (!scr_initialized)
return; // not initialized yet return; // not initialized yet
if (scr_viewsize->int_val != oldscr_viewsize) { if (oldviewsize != scr_viewsize->int_val) {
oldscr_viewsize = scr_viewsize->int_val; oldviewsize = scr_viewsize->int_val;
vid.recalc_refdef = 1; vid.recalc_refdef = true;
} }
// check for vid changes if (oldfov != scr_fov->value) { // determine size of refresh window
if (oldfov != scr_fov->int_val) { oldfov = scr_fov->value;
oldfov = scr_fov->int_val;
vid.recalc_refdef = true; vid.recalc_refdef = true;
} }
@ -831,10 +807,8 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs)
vid.recalc_refdef = true; vid.recalc_refdef = true;
} }
if (vid.recalc_refdef) { if (vid.recalc_refdef)
// something changed, so reorder the screen
SCR_CalcRefdef (); SCR_CalcRefdef ();
}
// do 3D refresh drawing, and then update the screen // do 3D refresh drawing, and then update the screen
D_EnableBackBufferAccess (); // of all overlay stuff if drawing D_EnableBackBufferAccess (); // of all overlay stuff if drawing
@ -911,11 +885,10 @@ void
SCR_Init (void) SCR_Init (void)
{ {
// register our commands // register our commands
Cmd_AddCommand ("screenshot", SCR_ScreenShot_f, "Take a screenshot and " Cmd_AddCommand ("screenshot", SCR_ScreenShot_f, "Take a screenshot, "
"write it as qfxxx.tga in the current directory"); "saves as qfxxx.pcx in the current directory");
Cmd_AddCommand ("sizeup", SCR_SizeUp_f, "Increase the size of the screen"); Cmd_AddCommand ("sizeup", SCR_SizeUp_f, "Increases the screen size");
Cmd_AddCommand ("sizedown", SCR_SizeDown_f, "Decrease the size of the " Cmd_AddCommand ("sizedown", SCR_SizeDown_f, "Decreases the screen size");
"screen");
scr_ram = Draw_PicFromWad ("ram"); scr_ram = Draw_PicFromWad ("ram");
scr_net = Draw_PicFromWad ("net"); scr_net = Draw_PicFromWad ("net");

View file

@ -1412,8 +1412,6 @@ VID_SetMode (int modenum, unsigned char *palette)
return true; return true;
// so Con_Printfs don't mess us up by forcing vid and snd updates // so Con_Printfs don't mess us up by forcing vid and snd updates
temp = scr_disabled_for_loading;
scr_disabled_for_loading = true;
in_mode_set = true; in_mode_set = true;
CDAudio_Pause (); CDAudio_Pause ();
@ -1450,7 +1448,6 @@ VID_SetMode (int modenum, unsigned char *palette)
VID_UpdateWindowStatus (window_x, window_y); VID_UpdateWindowStatus (window_x, window_y);
CDAudio_Resume (); CDAudio_Resume ();
scr_disabled_for_loading = temp;
if (!stat) { if (!stat) {
VID_RestoreOldMode (original_mode); VID_RestoreOldMode (original_mode);

View file

@ -366,8 +366,6 @@ VID_SetMode (int modenum, unsigned char *palette)
} }
// so Con_Printfs don't mess us up by forcing vid and snd updates // so Con_Printfs don't mess us up by forcing vid and snd updates
temp = scr_disabled_for_loading;
scr_disabled_for_loading = true;
CDAudio_Pause (); CDAudio_Pause ();
@ -398,7 +396,6 @@ VID_SetMode (int modenum, unsigned char *palette)
VID_UpdateWindowStatus (window_x, window_y); VID_UpdateWindowStatus (window_x, window_y);
CDAudio_Resume (); CDAudio_Resume ();
scr_disabled_for_loading = temp;
if (!stat) { if (!stat) {
Sys_Error ("Couldn't set video mode"); Sys_Error ("Couldn't set video mode");

View file

@ -1027,9 +1027,6 @@ Host_Shutdown (void)
} }
isdown = true; isdown = true;
// keep Con_Printf from trying to update the screen
scr_disabled_for_loading = true;
Host_WriteConfiguration (); Host_WriteConfiguration ();
NET_Shutdown (); NET_Shutdown ();

View file

@ -57,8 +57,6 @@ cvar_t *chase_active;
int fps_count; int fps_count;
int viewentity; int viewentity;
qboolean scr_disabled_for_loading;
byte *vid_colormap; byte *vid_colormap;
vec3_t vpn, vright, vup; vec3_t vpn, vright, vup;