fix(prompts): texts already on screen follow a new face at once (the HUD's item button) #1184
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1184
Loading…
Reference in a new issue
No description provided.
Delete branch "gab9281/Longshot:fix/prompts-hud-texts-live"
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?
Type: fix · Risk: medium · Tested on: Linux, Radeon 680M (RADV) · Needs: Windows, any GPU
Why
When you change Button prompts in the Insert menu while playing, many texts already on screen keep the old face until the next start. That includes the HUD's item button (R2/ZR under the item, and the R above it). New texts, such as an item's pop-up, do follow. The game lays these texts out once and never draws them through the hook that rewrites a text's button codes, so the change never reached them.
See #413 (its "stays on the connected pad's face" may be this, seen after a change in the menu).
How to reproduce
Seen on: Linux, Radeon 680M (RADV); main @
71b1edd8Settings and switches: Button prompts = PlayStation 5 at start
Steps: load a save with an item on ZR (here the slingshot), close the pause menu, then change Button prompts in the Insert menu to Xbox, Keyboard or Switch.
Expected: the item's labels change to RB/RT, R/X or R/ZR.
Actual: they stay R1/R2. With the keyboard face at start, they stay R/X under every face.
What changed
The text boxes seen with a button's code are now kept, and a change rewrites the ones still on screen and has the game lay them out and draw them again. Hint bars (the stick hints at the bottom of the screen, the ocarina's "Play a note" bar) are left as they are on main: laid out again on their own, the game draws them empty.
remember_boxinhost/prompts.ckeeps each box the layout hook (hos_prompts_text_layout, f_8152aec0) sees with a button's code. Along with the box it keeps what says it's still that box: its class (+0), its status's address (+8), its text's address (+0xf0), its length and a hash of the text. A box drawn through the draw hook every frame already follows a change, so the per-frame hook doesn't keep anything. A box laid out again with no button code is dropped. The list holds up to 1024, and a full list replaces the box seen longest ago.boxes_follow, called fromlive_fontafter the font is rewritten, rewrites each kept box that still matches all of those (text_rewrite, leaving the sticks' codes) and sets 0x20000 | 0x100000 in its status. Anything else (a box that's gone, another object, another text) is dropped and never written.STICK_GAMEcodes, the game laid them out again and drew them empty, under every face. The font does have those glyphs (checked: U+F8D6 maps to the same glyph as U+E05E), and marking 0x20000 alone did the same. In a box that mixes a button with a stick, the sweep leaves the stick's code as it is.stick_of()names a stick's code, including the key slot a stick icon gets on the keyboard face, fortext_code,text_rewriteandhas_button_code.box_textandcode_atread a text's codes for all of them.in_bar()leaves out a box in a bar of hints, one whose parent pane (+0xe0) has its word at +0x10 set. With the ocarina out, a change blanked every icon of its hint bar, as it had the stick hints, whichever status bits were marked (0x20000, 0x100000 or both). Rewriting without marking didn't redraw anything. The HUD item button's parent has that word clear, and the HUD needs the layout to show its new icon. Such a box keeps the face it had until the bar is shown again: the ocarina taken out after a change shows the new face. The parent words were read from the three parents involved (both hint bars, the HUD slot), so the rule rests on that sample.mark_boxsets the bits atomically, since the sweep runs beside the game's threads.tests/test_prompt_boxes_follow.py(game-free), andtests/test_prompt_font_bind.pynow also cutsstick_of.Measurements
Verdict: it passes. The HUD's item button follows each change (PS5 → Xbox → keyboard → Switch). The stick hints and the ocarina's hint bar keep their icons, as on main. There's nothing to measure for speed: the sweep runs once per change, over at most 1024 boxes.
The numbers still hold on main @
615b2498: none of the 13 commits main gained since71b1edd8touches the prompt code (host/prompts.c,host/pad_sdl.c,nx2/oot_patches.py,nx2/prompt_assets.py: no diff), and the final in-game check ran on this PR's last commit.Hardware: Linux (CachyOS 7.3.4), Radeon 680M (RADV), Ryzen 9 6900HX
Scene: Kokiri Forest, Link's house, 1280x720 window
Method: a save made with the cheat menu (slingshot on ZR); Button prompts set to PS5 at start, then changed live through the control bridge to each face; screenshots 2 s and 12 s after each change; the log lines below.
How to reproduce:
HOS_OOT_CHEATS=1; set Button prompts at start to PS5, equip the slingshot, then change Button prompts in the Insert menu.71b1edd826c066f6Flags and settings
None.
Testing
Tested:
tests/test_prompt_boxes_follow.pypasses here and fails on main ("host/prompts.c keeps no text boxes for a change to rewrite"). The othertests/test_prompt*.pychecks andtest_utf8_paths.pypass.host/prompts.ccompiles cleanly with clang (Linux) and llvm-mingw (Windows).Not tested: Windows; other languages and resolutions.
Must be tested:
Risks
What could break: texts on screen at a change get rewritten from outside the game's own text path, on the thread that applies the change (the controller poll), while the game may be drawing them. The 3 bytes of a code aren't written atomically, so a frame could draw a half-written code once. If the game's own update of a status word overwrites the bits set here, that box keeps its old face until it's next laid out. A box is written only while its class, status, text address, length and text hash all match, so a freed box would need all five to match before anything is written. The sweep holds its lock while it runs, so a layout at that moment waits; it runs once per change, over at most 1024 boxes. Still open, as on main: hint bars keep the face they were shown with until they're shown again. That means the stick hints keep their start face (for example L/R on the keyboard face rather than WASD), and the ocarina's bar keeps its face while it stays out. The bar rule reads a parent's word that was only observed on three parents: a bar it misses could still be drawn empty at a change (until it's shown again), and a non-bar box it catches keeps its old face, as on main.
Turning it off: revert the commit.
Compatibility: Nothing changes.
Issues
See #413
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named). 604 passed, 14 failed, 76 skipped (Linux), after the rebase on main @615b2498. The same 14 fail on main on this PC (build-environment checks): test_bug_report_defaults, test_crt_options, test_dlss_feature_size, test_failed_compile_keeps_objects, test_guest_imported, test_linux_preflight, test_linux_update, test_make_game_cache, test_missing_nup, test_mods_size_table, test_pending_guest_import, test_run_all_changed, test_vk_occlusion_queries, test_walk_key.third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.mainand passing here.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
https://claude.ai/code/session_015KgSKmCc7pkXGyByWtmErh
Tested in game: Linux, Radeon 680M RADV, Kokiri Forest: Button prompts PS5 at start, changed live to Xbox/Keyboard/Switch; the HUD item labels follow each change; the stick hints lose their icon (open, being fixed)
Possibly related, for context:
Pushed
29decdac: boxes holding only stick icons are no longer swept. Rewritten to STICK_GAME codes, the game drew the Move and Change View hints empty under every face; marking 0x20000 alone did the same, and the font has the glyphs. They now keep the start's icon as on main. Re-run in game (Linux, Radeon 680M): the item labels follow PS5 -> Xbox -> Keyboard -> Switch, and the stick hints keep their icon.Screenshots (Linux, Radeon 680M, Kokiri Forest, 1280x720), the HUD's item slot and the stick hints. Top: main @
71b1edd8, PS5 at start, then a live change to Xbox (unchanged R1/R2). Bottom: this PR @29decdac, PS5 at start, then live Xbox (RB/RT), Keyboard (R/X), Switch (R/ZR); the stick hints keep their icon.Ran tests/run_all.py on Linux: 589 passed, 15 failed, 74 skipped. The same 15 fail on main @
71b1edd8on this PC, and they're named in the checklist.Pushed
1b1d41dawith the /code-review high fixes. A box is written only while its class, status, text address, length and text hash match. The sweep leaves stick codes in every box, and stick_of knows the key slots. Boxes are kept from the layout hook only, a box re-laid with no button code is dropped, and a full list evicts the box seen longest ago. A shared text-code reader replaces the duplicated scan. Not changed, now under Risks: the write from the controller thread and the lock held during the sweep. Re-run in game (Linux, Radeon 680M, PS5 -> Xbox -> Keyboard -> Switch): same result as the screenshots above. The prompt checks pass.@Beanstalk windows: start with Button prompts set to PlayStation 5 and a save with an item on ZR (the slingshot) in Kokiri Forest. In the Insert menu, change Button prompts to Xbox, then Keyboard, then Switch, closing the menu after each. Expected: the HUD item slot (top right) shows R1/R2, then RB/RT, then R/X, then R/ZR, and the Move/Change View hints at the bottom keep an icon. Also look for any crash or a log line starting "prompts:" with an error after a change.
Beanstalk test farm · an earlier run: commit
1b1d41d(the newer results are in a comment below)Commit
1b1d41d· tier reviewed · approved by gab9281 · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)On Windows, this plan compares the PlayStation 5 prompt display in Kokiri Forest against main and checks for crashes and prompt errors, taking about 12 minutes per tester. The available save does not include an equipped slingshot, and the plan cannot change Button prompts live because that setting is restart-only in the farm schema. Consequently, this is a smoke test only: it cannot verify the requested face changes or the equipped-item labels. A crash, prompt error, or screenshot difference fails the plan.
kokiri-start(settings button_prompts=4), then teleport to Kokiri Forest, take the picture ps5-hud to compare with main; 1 run on each side.Started.
1b1d41daa226c066f680Pushed
26c066f6, rebased on main @615b2498. Fourth commit: with the ocarina out (d-pad left), a change blanked every icon of its Play a note bar. That was this PR's own sweep: with the sweep switched off locally, the icons stayed. A box in a bar of hints (its parent's word at +0x10 set) is drawn empty when laid out again on its own, whichever bits are marked, while the HUD needs the layout. So such boxes are no longer kept. Checked in game on a clean build (Linux, Radeon 680M): the HUD follows PS5 -> Xbox -> Switch, and the stick hints and the ocarina bar keep their icons. run_all: 604 passed, 14 failed (all also fail on main).Beanstalk test farm
Commit
26c066f· tier untrusted · approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.This PR @
26c066f6(clean build, Linux, Radeon 680M, PS5 at start). Top: the HUD item slot at start, after a live change to Xbox, then to Switch (R1/R2 -> RB/RT -> R/ZR). Below: the stick hints after the Xbox change, then the ocarina's hint bar opened under Xbox and after a live change to Switch. The icons are kept, not blanked; the bar shows Switch the next time the ocarina is taken out.WIP: fix(prompts): texts already on screen follow a new face at once (the HUD's item button)to fix(prompts): texts already on screen follow a new face at once (the HUD's item button)Measurements: added why the numbers still hold after the rebase (main's 13 new commits don't touch the prompt code).
Languages and resolutions, this PR @
26c066f6with #1125 and #1126 (clean build, Linux, Radeon 680M, PS5 at start, the saved slingshot on ZR): de at 3840x2160, ja at 2560x1440, ko at 1280x720, zh-Hant at 1920x1080. Each starts withprompts: ps5 icons. Each row: the HUD item slot at start, after a live change to Xbox, then to Switch (R1/R2 -> RB/RT -> R/ZR); the stick hints after the Xbox change; the ocarina bar opened under Xbox, then after the live change to Switch (icons kept). Traditional Chinese, whose own fonts have Switch icons at the same code points, shows the face chosen.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.