feat: Monitor's shape for screens narrower than 16:9 (4:3, 16:10, 5:4) #1224
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!1224
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/narrow-screens"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What changed
The Ultrawide option's Monitor's shape only acted on screens wider than 16:9. On a 4:3 or 16:10 screen the log said
a 1.3333 screen is not wider than 16:9: the game's own pictureand the game showed its 16:9 picture with black bars.host/hos_main.cnow runs the same sizing for a narrower screen too, down to 5:4 (a narrower one is kept at 5:4, the same floor aspresent_window_sizeinrx_present_fx.cpp):hos_wide_squeezeis capped at 1, so the HUD and menus fill the picture's width instead of a middle 16:9 wider than the screen (it was 133% and cut the menus at both sides).hos_wide_marginis then 0 and movies fill the picture.Screens wider than 16:9 go through the exact same code as before (same sizes, squeeze and margin, checked by the test for 21:9 and 32:9). A 16:9 screen still gets the game's own picture. The menu's help line and the readme's Ultrawide rows now mention narrower screens.
Known limitation
As with ultrawide, the HUD is drawn on the game's 16:9 grid and stretched to the picture: on 4:3 it is 25% narrower than on 16:9, and movies are squeezed the same way. Proper 4:3 HUD placement would need new UI patches in
nx2/oot_wide.pyand is not part of this PR.How it was tested
tests/test_widescreen_shapes.py(new, game-free, registered intests/run_all.py): lifts the block out ofhos_main.cand checks picture, scene, camera ratio, HUD squeeze and movie margin for 4:3, 16:10, 5:4, narrower than 5:4, 4:3 at the 4K output, 16:9, 21:9, 32:9 and Ultrawide off. It fails onmainfor the narrow cases and passes for the wide ones unchanged.python -I -B tests/run_all.py: 140 passed, 0 failed, 17 skipped (Linux, missing headers or tools only).hookshot.exe(threshold of the 16:9 test,min(ratio, 16/9)for the HUD width). Played on a 4:3 IBM CRT at 2048 x 1536 (RTX 5080, Windows): the log showspicture 1920x1440, scene 1440x1080, camera ratio 1.3333, HUD and movies in the middle 100.0%, no black bars, correct camera and FOV, and the pause and System menus fit on screen. Kokiri Forest and Link's house.Nice, small change. What I checked:
||arm and the 5:4 clamp are added;fmin(1.0, ...)is a no-op when the ratio is above 16:9), so 21:9 / 32:9 results are unchanged.HUDandMOVIEpatches innx2/oot_wide.pybecome no-ops (*= 1.0, and_m > 0.0fis false), so a narrow screen just gets the game's 16:9 UI stretched to the picture, which is the limitation you describe.hos_rt_pool_sizetakes the larger of the output and the widescreen picture, so a narrower picture can't shrink the RT pool.hos_main.c, checks real values (including 21:9/32:9 as regression cases) and is registered inrun_all.pywith--cc gcc, like the other C fixtures.One issue before this is ready:
The default window stretches the 4:3 picture.
host/display.c(andhost/posix/display_sdl.con Linux) size the initial window ashos_aspect_ratio > 1.8f ? 720 * ratio : 1280, so with this PR a 4:3 or 16:10 screen still opens a 1280x720 window. On the Vulkan pathvk_replay.cppsetspreserve_stretchwheneveraspect_ratio() > 1.0f, sopresent_rectstretches the 1920x1440 picture over the whole 16:9 window: everything ends up 33% too wide until the player goes fullscreen. Fullscreen is off by default, and your CRT test was fullscreen, so this probably didn't show up. Something like(hos_aspect_ratio > 1.8f || (hos_aspect_ratio > 0.0f && hos_aspect_ratio < 1.76f)) ? (int)(720 * hos_aspect_ratio + 0.5f) : 1280in both files would open a 960x720 window for 4:3 instead.Small things:
hos_main.c("the world wider at the sides", "the HUD, menus and movies the middle 16:9") and thenx2/oot_wide.pydocstring ("the width grows"). Worth updating so they match.hos_wide_squeezetoo. With squeeze = 1 its patch leaves the viewport alone, so on 4:3 the save thumbnail will be the whole 4:3 picture squashed into the 16:9 texture. Not a blocker, just something to keep in mind if both land.@ -1376,2 +1378,4 @@if (want > game * 1.01 || (want > 1.0f && want < game * 0.99)) {double r = want > 32.0 / 9.0 ? 32.0 / 9.0 : want < 5.0 / 4.0 ? 5.0 / 4.0 : want;uint32_t hos_output_size(int height); /* (host/nn_applet.c: the Output resolution's height, 1440 as shipped) */unsigned oh = hos_output_size(1), ow = (unsigned)(oh * r / 8 + 0.5) * 8; /* (whole multiples of 8 pixels) */This now also covers 16:10 and 4:3, but the initial window size in
host/display.c/host/posix/display_sdl.conly followshos_aspect_ratioabove 1.8. A narrow picture still gets a 1280x720 window and is stretched over it (preserve_stretchinvk_replay.cpp). See the review summary.@ -1376,2 +1378,4 @@if (want > game * 1.01 || (want > 1.0f && want < game * 0.99)) {double r = want > 32.0 / 9.0 ? 32.0 / 9.0 : want < 5.0 / 4.0 ? 5.0 / 4.0 : want;uint32_t hos_output_size(int height); /* (host/nn_applet.c: the Output resolution's height, 1440 as shipped) */unsigned oh = hos_output_size(1), ow = (unsigned)(oh * r / 8 + 0.5) * 8; /* (whole multiples of 8 pixels) */Thanks for the review! Pushed
3060261(rebased on main, so the vk_menu.cpp conflict is gone):hos_aspect_ratio > 0.0f ? 720 * ratio : 1280. hos_aspect_ratio is only set when Monitor's shape is active, and it is never between 1.76 and 1.8 then, so this covers both sides: 960x720 for 4:3, 1720x720 for 21:9 as before.Looks good, thanks. The window now opens at the picture's shape on both platforms (960x720 for 4:3), HOS_WINDOW_SIZE and the DPI scaling are unaffected, and 16:9 and wide are unchanged. The save picture crop checks out too: the viewport is 306*(16/9)/ratio tall, centred, so the middle band fills the texture at the picture's own shape. Comments and tests are updated and registered. CI shows nothing run yet (workflows waiting for approval).