From 658b44f613f47963acb3ebb8bfafcc403c5bccb0 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 9 Feb 2020 01:51:19 +0000 Subject: [PATCH] SVid: Only switch video mode if full-screen borderless counts as full-screen here (this is what RetroFW reports when fullscreen=0) --- SourceX/display.h | 2 +- SourceX/storm/storm.cpp | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/SourceX/display.h b/SourceX/display.h index 7c2be73fc..2def6956f 100644 --- a/SourceX/display.h +++ b/SourceX/display.h @@ -19,8 +19,8 @@ extern unsigned int pal_surface_palette_version; #ifdef USE_SDL1 void SetVideoMode(int width, int height, int bpp, std::uint32_t flags); -void SetVideoModeToPrimary(bool fullscreen); bool IsFullScreen(); +void SetVideoModeToPrimary(bool fullscreen = IsFullScreen()); #endif // Returns: diff --git a/SourceX/storm/storm.cpp b/SourceX/storm/storm.cpp index 06f9619f8..74ac2ddfc 100644 --- a/SourceX/storm/storm.cpp +++ b/SourceX/storm/storm.cpp @@ -22,6 +22,10 @@ DWORD nLastError = 0; bool directFileAccess = false; char SBasePath[DVL_MAX_PATH]; +#ifdef USE_SDL1 +static bool IsSVidVideoMode = false; +#endif + static std::string getIniPath() { char path[DVL_MAX_PATH]; @@ -590,15 +594,18 @@ void SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HA // Set the video mode close to the SVid resolution while preserving aspect ratio. { const auto *display = SDL_GetVideoSurface(); - int w, h; - if (display->w * SVidWidth > display->h * SVidHeight) { - w = SVidWidth; - h = SVidWidth * display->h / display->w; - } else { - w = SVidHeight * display->w / display->h; - h = SVidHeight; + IsSVidVideoMode = (display->flags & (SDL_FULLSCREEN | SDL_NOFRAME)) != 0; + if (IsSVidVideoMode) { + int w, h; + if (display->w * SVidWidth > display->h * SVidHeight) { + w = SVidWidth; + h = SVidWidth * display->h / display->w; + } else { + w = SVidHeight * display->w / display->h; + h = SVidHeight; + } + SetVideoMode(w, h, display->format->BitsPerPixel, display->flags); } - SetVideoMode(w, h, display->format->BitsPerPixel, display->flags); } #endif memcpy(SVidPreviousPalette, orig_palette, 1024); @@ -787,7 +794,7 @@ void SVidPlayEnd(HANDLE video) } } #else - SetVideoModeToPrimary(IsFullScreen()); + if (IsSVidVideoMode) SetVideoModeToPrimary(); #endif }