make -svga mode selection consistent with -x11 etc and also fix the mode

matching algo so it actually works
This commit is contained in:
Bill Currie 2002-12-16 18:50:09 +00:00
parent f053f3b70f
commit 1311773a90

View file

@ -70,7 +70,6 @@ static byte vid_current_palette[768];
static int svgalib_inited = 0; static int svgalib_inited = 0;
static int svgalib_backgrounded = 0; static int svgalib_backgrounded = 0;
static int UseDisplay = 1;
static cvar_t *vid_mode; static cvar_t *vid_mode;
static cvar_t *vid_redrawfull; static cvar_t *vid_redrawfull;
@ -282,25 +281,18 @@ VID_InitModes (void)
} }
static int static int
get_mode (char *name, int width, int height, int depth) get_mode (int width, int height, int depth)
{ {
int i, ok, match; int i, ok, match;
match = (!!width) + (!!height) * 2 + (!!depth) * 4; match = (!!width) + (!!height) * 2 + (!!depth) * 4;
if (name) {
i = vga_getmodenumber (name);
if (!modes[i].width) {
Sys_Printf ("Mode [%s] not supported\n", name);
i = G320x200x256;
}
} else {
for (i = 0; i < num_modes; i++) { for (i = 0; i < num_modes; i++) {
if (modes[i].width) { if (modes[i].width) {
ok = (modes[i].width == width) ok = (modes[i].width == width)
+ (modes[i].height == height) * 2 + (modes[i].height == height) * 2
+ (modes[i].bytesperpixel == depth / 8) * 4; + (modes[i].bytesperpixel == depth / 8) * 4;
if ((ok & match) == ok) if ((ok & match) == match)
break; break;
} }
} }
@ -309,7 +301,6 @@ get_mode (char *name, int width, int height, int depth)
width, height, depth); width, height, depth);
i = G320x200x256; i = G320x200x256;
} }
}
return i; return i;
} }
@ -322,9 +313,7 @@ VID_Shutdown (void)
if (!svgalib_inited) if (!svgalib_inited)
return; return;
if (UseDisplay) {
vga_setmode (TEXT); vga_setmode (TEXT);
}
svgalib_inited = 0; svgalib_inited = 0;
} }
@ -346,7 +335,7 @@ VID_SetPalette (byte * palette)
*(tp++) = *(palette++) >> 2; *(tp++) = *(palette++) >> 2;
} }
if (UseDisplay && vga_oktowrite ()) { if (vga_oktowrite ()) {
vga_setpalvec (0, 256, tmppal); vga_setpalvec (0, 256, tmppal);
} }
} }
@ -434,7 +423,6 @@ comefrom_background (void)
void void
VID_Init (unsigned char *palette) VID_Init (unsigned char *palette)
{ {
int w, h, d;
int err; int err;
// plugin_load("in_svgalib.so"); // plugin_load("in_svgalib.so");
@ -442,7 +430,6 @@ VID_Init (unsigned char *palette)
if (svgalib_inited) if (svgalib_inited)
return; return;
if (UseDisplay) {
err = vga_init (); err = vga_init ();
if (err) if (err)
Sys_Error ("SVGALib failed to allocate a new VC"); Sys_Error ("SVGALib failed to allocate a new VC");
@ -469,27 +456,9 @@ VID_Init (unsigned char *palette)
Cmd_AddCommand ("vid_debug", VID_Debug_f, "FIXME: No Description"); Cmd_AddCommand ("vid_debug", VID_Debug_f, "FIXME: No Description");
/* Interpret command-line params */ /* Interpret command-line params */
w = h = d = 0; VID_GetWindowSize (320, 200);
if (getenv ("GSVGAMODE")) {
current_mode = get_mode (getenv ("GSVGAMODE"), w, h, d); current_mode = get_mode (vid.width, vid.height, 0);
} else if (COM_CheckParm ("-mode")) {
current_mode =
get_mode (com_argv[COM_CheckParm ("-mode") + 1], w, h, d);
} else if (COM_CheckParm ("-w") || COM_CheckParm ("-h")
|| COM_CheckParm ("-d")) {
if (COM_CheckParm ("-w")) {
w = atoi (com_argv[COM_CheckParm ("-w") + 1]);
}
if (COM_CheckParm ("-h")) {
h = atoi (com_argv[COM_CheckParm ("-h") + 1]);
}
if (COM_CheckParm ("-d")) {
d = atoi (com_argv[COM_CheckParm ("-d") + 1]);
}
current_mode = get_mode (0, w, h, d);
} else {
current_mode = G320x200x256;
}
/* Set vid parameters */ /* Set vid parameters */
VID_SetMode (current_mode, palette); VID_SetMode (current_mode, palette);
@ -500,7 +469,6 @@ VID_Init (unsigned char *palette)
vid.initialized = true; vid.initialized = true;
} }
}
void void
VID_Init_Cvars () VID_Init_Cvars ()
@ -595,23 +563,6 @@ VID_ModeInfo (int modenum)
} }
} }
void
VID_ExtraOptionDraw (unsigned int options_draw_cursor)
{
/* No extra option menu items yet */
}
void
VID_ExtraOptionCmd (int option_cursor)
{
#if 0
switch (option_cursor) {
case 1: // Always start with 1
break;
}
#endif
}
void void
VID_LockBuffer (void) VID_LockBuffer (void)
{ {