Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SCALE_2X #306

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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