Skip to content

Commit

Permalink
Implement SCALE_2X for Fallout 2 (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-hurst committed Jun 16, 2023
1 parent cf5f865 commit 0ffcb10
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/svga.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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");
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/svga.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0ffcb10

Please sign in to comment.