Clean up the mess with host_basepal and vid_colormap.

Libs should not be reaching into the exe :P
This commit is contained in:
Bill Currie 2012-02-01 19:52:13 +09:00
parent d76e4608ab
commit fa0ff96533
13 changed files with 36 additions and 32 deletions

View file

@ -98,7 +98,7 @@ void VID_Init_Cvars (void);
// Called at startup to set up translation tables, takes 256 8 bit RGB values
// the palette data will go away after the call, so it must be copied off if
// the video driver will need it again
void VID_Init (unsigned char *);
void VID_Init (byte *palette, byte *colormap);
// Called at shutdown
void VID_Shutdown (void);

View file

@ -51,6 +51,7 @@ static __attribute__ ((used)) const char rcsid[] =
/* Software and hardware gamma support */
VISIBLE byte gammatable[256];
byte *vid_colormap;
cvar_t *vid_gamma;
cvar_t *vid_system_gamma;
cvar_t *con_width; // FIXME: Try to move with rest of con code

View file

@ -271,7 +271,7 @@ findres (unsigned int *width, unsigned int *height)
}
void
VID_Init (unsigned char *palette)
VID_Init (byte *palette, byte *colormap)
{
GLint attribs[32];
@ -290,7 +290,7 @@ VID_Init (unsigned char *palette)
vid.maxwarpwidth = WARP_WIDTH;
vid.maxwarpheight = WARP_HEIGHT;
vid.colormap8 = vid_colormap;
vid.colormap8 = vid_colormap = colormap;
vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES];
// interpret command-line params

View file

@ -399,7 +399,7 @@ fb_switch_init (void)
}
void
VID_Init (unsigned char *palette)
VID_Init (byte *palette, byte *colormap)
{
struct VideoMode *vmode;
const char *modestr;
@ -410,6 +410,8 @@ VID_Init (unsigned char *palette)
if (fbdev_inited)
return;
vid_colormap = colormap;
if (COM_CheckParm ("-novideo")) {
vid.width = 320;
vid.height = 200;

View file

@ -187,7 +187,7 @@ GL_EndRendering (void)
}
void
VID_Init (unsigned char *palette)
VID_Init (byte *palette, byte *colormap)
{
int attrib[] = {
GLX_RGBA,
@ -205,7 +205,7 @@ VID_Init (unsigned char *palette)
vid.maxwarpwidth = WARP_WIDTH;
vid.maxwarpheight = WARP_HEIGHT;
vid.colormap8 = vid_colormap;
vid.colormap8 = vid_colormap = colormap;
vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES];
X11_OpenDisplay ();

View file

@ -85,7 +85,7 @@ do_screen_buffer (void)
}
void
VID_Init (unsigned char *palette)
VID_Init (byte *palette, byte *colormap)
{
Uint32 flags;
@ -104,6 +104,8 @@ VID_Init (unsigned char *palette)
// Initialize display
if (!(screen = SDL_SetVideoMode (vid.width, vid.height, 8, flags)))
Sys_Error ("VID: Couldn't set video mode: %s", SDL_GetError ());
vid_colormap = colormap;
VID_InitGamma (palette);
VID_SetPalette (vid.palette);

View file

@ -89,7 +89,7 @@ do_screen_buffer (void)
}
void
VID_Init (unsigned char *palette)
VID_Init (byte *palette, byte *colormap)
{
Uint32 flags;
@ -119,6 +119,8 @@ VID_Init (unsigned char *palette)
if (!(screen = SDL_SetVideoMode (vid.width, vid.height,
vid_bitdepth->int_val, flags)))
Sys_Error ("VID: Couldn't set video mode: %s", SDL_GetError ());
vid_colormap = colormap;
VID_InitGamma (palette);
VID_SetPalette (vid.palette);

View file

@ -99,7 +99,7 @@ GL_EndRendering (void)
}
void
VID_Init (unsigned char *palette)
VID_Init (byte *palette, byte *colormap)
{
Uint32 flags = SDL_OPENGL;
int i, j;
@ -114,7 +114,7 @@ VID_Init (unsigned char *palette)
vid.maxwarpwidth = WARP_WIDTH;
vid.maxwarpheight = WARP_HEIGHT;
vid.colormap8 = vid_colormap;
vid.colormap8 = vid_colormap = colormap;
vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES];
// Check if we want fullscreen

View file

@ -352,7 +352,7 @@ comefrom_background (void)
}
void
VID_Init (unsigned char *palette)
VID_Init (byte *palette, byte *colormap)
{
int err;
@ -382,6 +382,7 @@ VID_Init (unsigned char *palette)
current_mode = get_mode (vid.width, vid.height, 8);
/* Set vid parameters */
vid_colormap = colormap;
VID_SetMode (current_mode, palette);
VID_InitGamma (palette);

View file

@ -450,7 +450,7 @@ bSetupPixelFormat (HDC hDC)
}
void
VID_Init (unsigned char *palette)
VID_Init (byte *palette, byte *colormap)
{
BOOL stat;
WORD bpp, vid_mode;
@ -536,7 +536,7 @@ VID_Init (unsigned char *palette)
vid.maxwarpwidth = WARP_WIDTH;
vid.maxwarpheight = WARP_HEIGHT;
vid.colormap8 = vid_colormap;
vid.colormap8 = vid_colormap = colormap;
vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES];
#ifdef SPLASH_SCREEN

View file

@ -392,7 +392,7 @@ x11_init_buffers (void)
need it later.
*/
void
VID_Init (unsigned char *palette)
VID_Init (byte *palette, byte *colormap)
{
int pnum, i;
XVisualInfo template;
@ -402,7 +402,7 @@ VID_Init (unsigned char *palette)
VID_GetWindowSize (320, 200);
vid.numpages = 2;
vid.colormap8 = vid_colormap;
vid.colormap8 = vid_colormap = colormap;
vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES];
srandom (getpid ());

View file

@ -60,8 +60,6 @@ static __attribute__ ((used)) const char rcsid[] =
#include "server.h"
#include "sbar.h"
byte *vid_colormap;
// these two are not intended to be set directly
cvar_t *cl_name;
cvar_t *cl_color;
@ -505,17 +503,17 @@ Force_CenterView_f (void)
void
CL_Init (cbuf_t *cbuf)
{
byte *basepal;
byte *basepal, *colormap;
basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp");
if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp");
vid_colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp");
if (!vid_colormap)
colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp");
if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp");
Key_Init (cbuf);
VID_Init (basepal);
VID_Init (basepal, colormap);
Draw_Init ();
SCR_Init ();
R_Init ();

View file

@ -118,7 +118,7 @@ static __attribute__ ((used)) const char rcsid[] =
CLIENT_PLUGIN_PROTOS
static plugin_list_t client_plugin_list[] = {
CLIENT_PLUGIN_LIST
CLIENT_PLUGIN_LIST
};
// we need to declare some mouse variables here, because the menu system
@ -212,9 +212,6 @@ double oldcon_realtime;
int host_hunklevel;
byte *host_basepal;
byte *vid_colormap;
cvar_t *host_speeds;
cvar_t *hud_fps;
cvar_t *hud_ping;
@ -1717,6 +1714,8 @@ CL_Autoexec (int phase)
void
Host_Init (void)
{
byte *basepal, *colormap;
cl_cbuf = Cbuf_New (&id_interp);
cl_stbuf = Cbuf_New (&id_interp);
@ -1798,14 +1797,14 @@ Host_Init (void)
Sys_Printf ("%4.1f megabyte heap.\n", cl_mem_size->value);
host_basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp");
if (!host_basepal)
basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp");
if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp");
vid_colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp");
if (!vid_colormap)
colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp");
if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp");
VID_Init (host_basepal);
VID_Init (basepal, colormap);
Draw_Init ();
SCR_Init ();
R_Init ();
@ -1877,6 +1876,5 @@ Host_Shutdown (void)
NET_Shutdown ();
S_Shutdown ();
IN_Shutdown ();
if (host_basepal)
VID_Shutdown ();
VID_Shutdown ();
}