From 0ffcb107af4b440f06d380d9da851383f45761ea Mon Sep 17 00:00:00 2001 From: Austin Hurst Date: Fri, 16 Jun 2023 01:18:15 -0300 Subject: [PATCH] Implement SCALE_2X for Fallout 2 (#306) --- src/svga.cc | 19 ++++++++++++++++--- src/svga.h | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/svga.cc b/src/svga.cc index e361fea..0d90650 100644 --- a/src/svga.cc +++ b/src/svga.cc @@ -102,6 +102,7 @@ void _zero_vid_mem() int _GNW95_init_mode_ex(int width, int height, int bpp) { bool fullscreen = true; + int scale = 1; Config resolutionConfig; if (configInit(&resolutionConfig)) { @@ -121,6 +122,18 @@ int _GNW95_init_mode_ex(int width, int height, int bpp) fullscreen = !windowed; } + int scaleValue; + if (configGetInt(&resolutionConfig, "MAIN", "SCALE_2X", &scaleValue)) { + scale = scaleValue + 1; // 0 = 1x, 1 = 2x + // Only allow scaling if resulting game resolution is >= 640x480 + if ((width / scale) < 640 || (height / scale) < 480) { + scale = 1; + } else { + width /= scale; + height /= scale; + } + } + configGetBool(&resolutionConfig, "IFACE", "IFACE_BAR_MODE", &gInterfaceBarMode); configGetInt(&resolutionConfig, "IFACE", "IFACE_BAR_WIDTH", &gInterfaceBarWidth); configGetInt(&resolutionConfig, "IFACE", "IFACE_BAR_SIDE_ART", &gInterfaceSidePanelsImageId); @@ -129,7 +142,7 @@ int _GNW95_init_mode_ex(int width, int height, int bpp) configFree(&resolutionConfig); } - if (_GNW95_init_window(width, height, fullscreen) == -1) { + if (_GNW95_init_window(width, height, fullscreen, scale) == -1) { return -1; } @@ -157,7 +170,7 @@ int _init_vesa_mode(int width, int height) } // 0x4CAEDC -int _GNW95_init_window(int width, int height, bool fullscreen) +int _GNW95_init_window(int width, int height, bool fullscreen, int scale) { if (gSdlWindow == NULL) { SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); @@ -172,7 +185,7 @@ int _GNW95_init_window(int width, int height, bool fullscreen) windowFlags |= SDL_WINDOW_FULLSCREEN; } - gSdlWindow = SDL_CreateWindow(gProgramWindowTitle, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, windowFlags); + gSdlWindow = SDL_CreateWindow(gProgramWindowTitle, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width * scale, height * scale, windowFlags); if (gSdlWindow == NULL) { return -1; } diff --git a/src/svga.h b/src/svga.h index 510d724..b5882df 100644 --- a/src/svga.h +++ b/src/svga.h @@ -31,7 +31,7 @@ void _get_start_mode_(); void _zero_vid_mem(); int _GNW95_init_mode_ex(int width, int height, int bpp); int _init_vesa_mode(int width, int height); -int _GNW95_init_window(int width, int height, bool fullscreen); +int _GNW95_init_window(int width, int height, bool fullscreen, int scale); int directDrawInit(int width, int height, int bpp); void directDrawFree(); void directDrawSetPaletteInRange(unsigned char* a1, int a2, int a3);