Improve selection of a failsafe video mode if videoSetGameMode() fails at game startup

git-svn-id: https://svn.eduke32.com/eduke32@7221 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-11-18 18:13:14 +00:00
parent 992d5abac2
commit 592ee52d2b

View file

@ -6492,7 +6492,7 @@ int app_main(int argc, char const * const * argv)
CONTROL_MouseEnabled = (ud.setup.usemouse && CONTROL_MousePresent); CONTROL_MouseEnabled = (ud.setup.usemouse && CONTROL_MousePresent);
// JBF 20040215: evil and nasty place to do this, but joysticks are evil and nasty too // JBF 20040215: evil and nasty place to do this, but joysticks are evil and nasty too
for (bssize_t i=0; i<joystick.numAxes; i++) for (int i=0; i<joystick.numAxes; i++)
joySetDeadZone(i,ud.config.JoystickAnalogueDead[i],ud.config.JoystickAnalogueSaturate[i]); joySetDeadZone(i,ud.config.JoystickAnalogueDead[i],ud.config.JoystickAnalogueSaturate[i]);
} }
@ -6527,42 +6527,44 @@ int app_main(int argc, char const * const * argv)
{ {
if (videoSetGameMode(ud.setup.fullscreen, ud.setup.xdim, ud.setup.ydim, ud.setup.bpp, ud.detail) < 0) if (videoSetGameMode(ud.setup.fullscreen, ud.setup.xdim, ud.setup.ydim, ud.setup.bpp, ud.detail) < 0)
{ {
vec2_t const res[] = { initprintf("Failure setting video mode %dx%dx%d %s! Trying next mode...\n", ud.setup.xdim, ud.setup.ydim,
{ ud.setup.xdim, ud.setup.ydim }, { 800, 600 }, { 640, 480 }, { 320, 240 },
};
#ifdef USE_OPENGL
int const bpp[] = { 32, 16, 8 };
#else
int const bpp[] = { 8 };
#endif
initprintf("Failure setting video mode %dx%dx%d %s! Attempting safer mode...\n", ud.setup.xdim, ud.setup.ydim,
ud.setup.bpp, ud.setup.fullscreen ? "fullscreen" : "windowed"); ud.setup.bpp, ud.setup.fullscreen ? "fullscreen" : "windowed");
int resIdx = 0; int resIdx = 0;
int bppIdx = 0;
while (videoSetGameMode(0, res[resIdx].x, res[resIdx].y, bpp[bppIdx], ud.detail) < 0) for (int i=0; i < validmodecnt; i++)
{ {
initprintf("Failure setting video mode %dx%dx%d windowed! Attempting safer mode...\n", res[resIdx].x, res[resIdx].y, if (validmode[i].xdim == ud.setup.xdim && validmode[i].ydim == ud.setup.ydim)
bpp[bppIdx]);
if (++bppIdx == ARRAY_SIZE(bpp))
{ {
if (++resIdx == ARRAY_SIZE(res)) resIdx = i;
G_GameExit("Unable to set failsafe video mode!"); break;
bppIdx = 0;
} }
} }
ud.setup.xdim = res[resIdx].x; int const savedIdx = resIdx;
ud.setup.ydim = res[resIdx].y; int bpp = ud.setup.bpp;
ud.setup.bpp = bpp[bppIdx];
while (videoSetGameMode(0, validmode[resIdx].xdim, validmode[resIdx].ydim, bpp, ud.detail) < 0)
{
initprintf("Failure setting video mode %dx%dx%d windowed! Trying next mode...\n",
validmode[resIdx].xdim, validmode[resIdx].ydim, bpp);
if (++resIdx == validmodecnt)
{
if (bpp == 8)
G_GameExit("Fatal error: unable to set any video mode!");
resIdx = savedIdx;
bpp = 8;
}
}
ud.setup.xdim = validmode[resIdx].xdim;
ud.setup.ydim = validmode[resIdx].ydim;
ud.setup.bpp = bpp;
} }
videoSetPalette(ud.brightness>>2, myplayer.palette, 0); videoSetPalette(ud.brightness>>2, myplayer.palette, 0);
S_MusicStartup(); S_MusicStartup();
S_SoundStartup(); S_SoundStartup();
} }
@ -6571,7 +6573,7 @@ int app_main(int argc, char const * const * argv)
// there is room for them in tiles012.art between "[\]^_." and "{|}~" // there is room for them in tiles012.art between "[\]^_." and "{|}~"
minitext_lowercase = 1; minitext_lowercase = 1;
for (bssize_t i = MINIFONT + ('a'-'!'); minitext_lowercase && i < MINIFONT + ('z'-'!') + 1; ++i) for (int i = MINIFONT + ('a'-'!'); minitext_lowercase && i < MINIFONT + ('z'-'!') + 1; ++i)
minitext_lowercase &= (int)tileLoad(i); minitext_lowercase &= (int)tileLoad(i);
if (g_networkMode != NET_DEDICATED_SERVER) if (g_networkMode != NET_DEDICATED_SERVER)