Closed a-hurst closed 1 year ago
Thanks a-hurst for the hint how to add scaling, i'm not a coder but managed to somehow come up with this. SCALE=2 in fs1_res.ini for desired effect.
--- svga.cc.orig Sat May 6 11:49:43 2023
+++ svga.cc Sat May 6 11:52:27 2023
@@ -99,6 +99,8 @@
{
}
+int scalewin = 1;
+
// 0x4CAE1C
static int GNW95_init_mode_ex(int width, int height, int bpp)
{
@@ -121,6 +123,9 @@
if (configGetBool(&resolutionConfig, "MAIN", "WINDOWED", &windowed)) {
fullscreen = !windowed;
}
+
+ if (config_get_value(&resolutionConfig, "MAIN", "SCALE", &scalewin)) {
+ }
}
config_exit(&resolutionConfig);
}
@@ -167,7 +172,7 @@
windowFlags |= SDL_WINDOW_FULLSCREEN;
}
- gSdlWindow = SDL_CreateWindow(GNW95_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, windowFlags);
+ gSdlWindow = SDL_CreateWindow(GNW95_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width *scalewin, height *scalewin, windowFlags);
if (gSdlWindow == NULL) {
return -1;
}
@c64skin Nice! I guess if all we're going for is equivalence with Sfall/HRP on Windows we'd only need to support 2X scaling as a binary option, but with 4/5K monitors becoming increasingly popular support for higher integer scaling factors would be handy as well.
Also, a quick update/note from play-testing: due to how mouse motion is handled in Fallout and reported in SDL2 (relative to the window's pixels and not the renderer's pixels), my simple patch above ends up making the mouse cursor extremely sensitive. Basically, each pixel of the game is now 2 pixels in the actual window, but SDL still reports mouse motion in window coordinates and not game coordinates, so the mouse is 2x more sensitive than normal. Dividing the mouse motion x/y returned by dxinput_get_mouse_state
in half fixes the issue.
Huh, can't say i've noticed anything odd regarding the mouse and i've just finished a playthru. I'll take you word for it :)
I'm sure alexbatalov will add all of the features in due time.
Hello. Is there a branch or a pull request for this? i would love to try it.
@VincenzoLaSpesa I cleaned it up into a proper PR here, let me know if it works for you! https://github.com/alexbatalov/fallout1-ce/pull/75
Ok, I've tried it.
First of all: I'm not sure what the SCALE_2X
is supposed to do in the original implementation, so my assumptions can be wrong.
As far I can see what you do is making a window that is bigger then the texture, so the SDL will zoom the texture for you. So the window will not respect the resolution written into the ini file.
For example, this file
[MAIN]
SCR_WIDTH=640
SCR_HEIGHT=480
WINDOWED=1
SCALE_2X=1
Will produce a window of 1280x960. Did it happen with the original implementation too?
@VincenzoLaSpesa ah, yep: looking at the original sfall code I see they've implemented it the way you suggested:
if (sf::IniReader::GetInt("Main", "SCALE_2X", 0, f2ResIni)) {
if (SCR_HEIGHT < 960 && SCR_WIDTH < 1280) {
SCR_WIDTH = 640;
SCR_HEIGHT = 480;
} else {
SCR_WIDTH /= 2;
SCR_HEIGHT /= 2;
}
SCALE_2X = 1;
}
I'll revise my PR accordingly! That said, I'm not a huge fan of how Sfall implements this: shouldn't it check width and height individually to make sure they're above their respective minimum values? As-is, it looks like their logic would allow someone running the game in a 1280x720 window to enable SCALE_2X
, resulting in a game resolution of 640x360. I'll see if I can come up with something better.
@VincenzoLaSpesa Okay, I've updated my PR to better match Sfall's approach. The main differences are that my code allows for higher scaling factors (3x scaling tested and working on my 1440p iMac), and also simply disables scaling if the resulting game resolution would be below 640x480 (Sfall tries to force the window resolution to 1280x960 in that case, which would likely cause problems with monitors that don't support it).
It's exactly what I was looking for :D
On the weekend I will try to implement some upscaling filter like hq2x ( like this one https://github.com/TASEmulators/fceux/blob/530fec6aff4d1dbe446f3e0a9ecc66c7d7340d82/src/drivers/common/hq2x.cpp#L1 )
I don't know if it would be approved, since it's not an original feature, but I will do it at least for my own playing.
Closed by #75!
Hi there,
First of all: thank you so much for your work on this project! It's great to have Fallout 1 & 2 running natively on modern macOS/Linux, especially after years of bad luck trying to get them to run smoothly in WINE.
Anyway, one thing I'd like to request is proper
SCALE_2X
support inf1_res.ini
for better playability on high-res screens. Thanks to the SDL renderer API doing a pretty great job of separating game resolution from window resolution, all I had to do to get a rough proof-of-concept working was changewidth
andheight
towidth * 2
andheight * 2
in the following part ofsvga.cc
: https://github.com/alexbatalov/fallout1-ce/blob/194110e078da405e2986d8e28799fa1dcfbfd2af/src/plib/gnw/svga.cc#LL169C1-L174C1Since you still set the renderer's resolution separately below, you end up with the game running at half the window's native resolution! Additionally, if desired, you can switch from nearest-neighbour resizing to linear smoothing by adding
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
somewhere before the renderer gets created:Anyway, I'm not quite sure enough of my C skills to make a proper pull request with .ini toggle support (I'm mostly a Python/R developer), but hopefully this helps with implementation!