feat(input):Improving Sprint feature: Sprint sets the game's dash input instead of holding A #2038
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2038
Loading…
Reference in a new issue
No description provided.
Delete branch "kendowashere/Longshot:feat/sprint-dash-input"
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?
Summary
Sprint (#1929, #1948, #1977, built on thegrandao's #196) gets the game's run by holding A and then hiding A's "pressed" bit from the game's controllers, so the game sees a held A (its run) without a press (no roll, no talk). This PR keeps everything players see from those PRs: the Sprint row on the Controls tab, the Controls page's Sprint line (Shift and L3 by default, rebindable), its Toggle cell and the saved keys (
sprint=,toggle_sprint=,key_sprint,pad_sprint). It replaces only how Link is made to run, with the engine of my Sprint button from the NX2navi runtime (its PRs 752, 887 and 927; Alimjan suggested putting the two together on #196).How: Link sprints while bit 4 of his input flags (
*(Link +0x50)), the dash input, is set: the flag the game sets itself for the run that follows a roll. Two places load those flags: his movement update (f_804caa80at0x804ce798, the sprint's start and keep tests) and his stance and camera update (f_80c225d0at0x80c27f3c).nx2/oot_patches.pyputs a call right after each load, andhost/oot_sprint.cORs the bit in while Sprint runs, only for the Link the player controls. The game's own sprint then runs: its speed, animation, camera, and every rule that ends it.Why this is better than holding A:
SPRINT_ROLL_GAP_MS) so the game can see a fresh press, then holds it again; a tap counts only through that gapf_8038a220and also the menus'f_834a3680: every reader of A sees the mask+0x470and its actor), never the other instance of his classWhat players notice: Sprint feels the same (it is the same game run), A works while sprinting, L3 hides the text box again with Sprint on, and a toggled sprint stops when Link stops instead of coming back later.
Also: the Toggle cell's help says a toggled sprint ends with Link's state (all 13 languages), the user guide's Sprint paragraph and the control bridge's Sprint check follow, and
injected_buttons(only the A handoff read it) is gone.Read first:
host/oot_sprint.c,hos_sprint_input's call innpad_states(host/nn_hid.c),patch_sprint_linkandpatch_sprint_stanceinnx2/oot_patches.py.Testing
Tested: Windows 11, NVIDIA GeForce RTX 5070 Ti (driver 621.24), by hand in the game: an earlier version of this branch's engine built together with my other open PRs (#699, #711, #1294) on
main@fd7dc40d(build/combined). Sprint On, Toggle off and on: L3 held (and Shift) runs the game's sprint with no roll and the plain run on letting go; Toggle on starts it with a press, keeps it through a roll and a jump, ends it when Link stops or attacks; A while sprinting rolls and talks as usual; in a conversation L3 hides the text box and starts nothing. Everything worked.dev.py packs base, llvm-mingw):oot_patches: Sprint's link site in code_hot.cand... stance site in code_hot.c, each found once;oot_sprint.ccompiled.tests/test_sprint.py(8 tests): the bindings and layout cases as before, andhost/oot_sprint.ccompiled alone against a fake game (Link's state chain, the actor and event managers): held on while held and off when let go; A never added and the player's A passed through; Toggle on through jumps, landings, slides and rolls, off at the next press, an attack, ZL, the host's reset, 4 frames standing still (16 updates at 240 fps), 90 frames after a press made standing; a conversation's L3 handed to the game as LS for as long as it is held; nothing handed for a key; blocked (Insert, ocarina) neither; a press held on from a load stays the game's; another Link never sprints. The patch tests have since changed to use synthetic functions and anchors; the updated tests still need to run.tests/test_input_background.py(every case butstick-directions, which fails onmain@7c23d2betoo,sprint-togglenow checks whatnpad_stateshandshost/oot_sprint.cand that the game's buttons stay the player's),test_walk_key,test_bound_keys,test_menu_i18n,test_settings_table,test_menu_modules,test_option_ids,test_alt_enter,test_pad_layout: pass.test_pads_after_menufails onmaintoo (#1721's stand-in, named in #1977), andtest_menu_i18nfails onmain@7c23d2bethe same way (an Output resolution text #1859 changed). The whole suite onmain@e6196f0f: the same failures with and without this change.Still to test:
Measurements
Nothing to measure: per frame, a few guest pointer reads at Link's two updates replace the A handoff and a mask in the controllers' update; no switch is added.
Risks
oot_patches.pyexpects, the build printsWARNING: Sprint's sites were found .... The sites are patched independently, so one hook may still run if the other is missing.sprint=,toggle_sprint=, the bindings). A revert brings back A held.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.WIP: feat(input): Sprint sets the game's dash input instead of holding Ato feat(input): Sprint sets the game's dash input instead of holding Afeat(input): Sprint sets the game's dash input instead of holding Ato feat(input):Improving Sprint feature: Sprint sets the game's dash input instead of holding A@review
Recommendation: Request changes. The new sprint can remain active when input is blocked or an event begins, and the controlled-Link check can affect another actor. The change also commits examples described as lifted game output, which the repository forbids.
Sprint uses the game’s dash input instead of holding A, allowing the player’s A press to pass through and restoring L3 in conversations. The new state handling and guest-memory reads add complexity and per-frame work, including when Sprint is off.
@fixwill do (5)tests/test_sprint.py:536: These fixtures are described as the two places written by the lift and reproduce sequences from the game’s lifted output. (more on the line)host/oot_sprint.c:150: Blocking input clears the held latch but does not clear an already active toggle or request a reset. (more on the line)host/oot_sprint.c:140: The event check only decides who receives a new press; it does not end an existing toggle. (more on the line)host/oot_sprint.c:98: The controlled-Link check accepts every Link instance when the actor manager or controlled-actor pointer is missing or fails its class check. (more on the line)host/oot_sprint.c:185: Skip the actor and state lookups when Sprint is disabled, while preserving the reset and gameplay-detection behavior needed when it is enabled.Before merging, for the author (2) (a run, a measurement or a decision; it doesn't hold the recommendation)
host/oot_sprint.c:185: Both hooks inspect guest pointers on every relevant update even when Sprint is off; each non-image pointer check takes the memory map lock. (more on the line)Checks: Failing on this head, which is behind its base, where it passes:
PR description / Description follows the template (pull_request_target).@rebase(or@fix) brings it up to date and runs it again; not held against it.More: does it help, other systems, switches, what was read
Does it help: Unproven for this head: the author reports successful manual gameplay on Windows with a combined build containing other PRs, but no run of this head alone. No before-and-after frame-time numbers are provided for the new per-frame work.
Other systems: The hooks run for Link updates even with Sprint off and can affect actor updates, camera and movement. Windows keyboard and controller behavior has partial evidence from a combined build; Xbox, Linux and Steam Deck behavior remains untested. The patch matcher and fake-game tests do not establish behavior with the actual game on those systems.
Switches: No environment switch added, changed or removed. The existing Sprint setting remains off by default and Toggle remains off by default; their behavior when enabled changes.
Reviewed:
6f44624e85against7c23d2be26: Read the repository rules, PR template, standards, commit history, sprint engine, input call site, guest-memory validation, patch changes and relevant test changes. Skimmed translations and documentation changes. The full diff output and some long changed files were truncated; the remaining unchanged portions of those files were not read in full. docs/review-checklist.md and ../Tooling/AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run, as requested. The author’s Windows combined-build run and stated test results were considered; Linux and Xbox runs remain outstanding.
Overlaps and merge order: The description names combined testing with PRs #699, #711 and #1294; their diffs and merge order were not available.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +95,4 @@if (!link || rd64(link) != g_module_base + LINK_CLASS) return 0;const uint64_t mgr = rd64(rd64(g_module_base + ACTOR_MGR));if (!mgr || rd64(mgr) != g_module_base + ACTOR_MGR_CLASS) return 1;const uint64_t ctl = rd64(mgr + 0x470);L4: The controlled-Link check accepts every Link instance when the actor manager or controlled-actor pointer is missing or fails its class check. During initialization or a transition, the other instance can therefore consume a press, update the shared sprint state and receive the dash bit. Fail closed until the controlled actor can be identified, and cover missing and invalid manager pointers in the fixture.
@ -0,0 +137,4 @@}const int n = LOAD(polls);if (n <= GAMEPLAY_POLLS) STORE(polls, n + 1);const int gameplay = n < GAMEPLAY_POLLS && !event_running();L3: The event check only decides who receives a new press; it does not end an existing toggle. A conversation can keep updating Link in a permitted movement state, so a sprint started before the conversation can continue through it and resume afterward. Clear the active toggle when an event starts, with a test beginning the event after sprint has latched.
@ -0,0 +147,4 @@passing = !mine && !blocked && l3;} else if (!down) {STORE(latched, 0);passing = 0;L2: Blocking input clears the held latch but does not clear an already active toggle or request a reset. For example, entering the ocarina note wait or an exclusive control-bridge session while a toggled sprint is active leaves the dash bit set on subsequent Link updates. End the active sprint when input becomes blocked, and test the transition from an active toggle.
@ -0,0 +182,4 @@return on;}/* (nx2/oot_patches.py) f_804caa80 at 0x804ce798, after its load of Link's input flags into x10 (Link in x19): the flagsL5 (minor): Both hooks inspect guest pointers on every relevant update even when Sprint is off; each non-image pointer check takes the memory map lock. Measure frame time and 1% lows with Sprint off and on against the base in representative scenes, including Linux or Steam Deck.
@ -480,2 +535,2 @@run = subprocess.run([str(binary)], text=True, capture_output=True, timeout=30)self.assertEqual(run.returncode, 0, run.stdout + run.stderr)# The two places as the lift writes them, inside their functionsLINK_FN = ('#include "a64.h"\n' + "void f_804caa80(Ctx *__restrict A64_NOESC c) {\n"L1: These fixtures are described as the two places written by the lift and reproduce sequences from the game’s lifted output. The repository forbids committing anything made from the game, including sampled output. Replace them with independently authored synthetic functions and matching anchors that do not reproduce game output; remove any such samples from the patch code too.
@fix
I didn't fix this pull request: it doesn't allow edits from maintainers (the author can turn on Allow edits from maintainers).
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Tested in game: Windows 11, NVIDIA GeForce RTX 5070 Ti (driver 621.24): this engine in a build with my other open PRs (#699, #711, #1294) on
main@fd7dc40d. Sprint on L3 and Shift, held and with Toggle (keeps through a roll, ends when Link stops or attacks), A rolls and talks while sprinting, L3 hides the text box in a conversation: all worked.@BeanBot wrote in #2038 (comment):
I have turned allow edits on (sorry wasn't meant to be off) @HumanBean @BeanBot
@fix
Recommendation: Approve. The recorded gameplay run used an earlier engine with other pull requests, and the current head has no recorded gameplay or performance measurements. The requested Windows and Linux or Steam Deck runs and frame-time comparisons are still needed. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
2c039ef5dd. I mergedmain(c7bd8f80af) into it, as it has merge commits. I edited its description to match the change.Changed
Changed in part (the rest is for the author)
Nothing was built or run: the checks run again on the new head.
Sprint sets Link’s dash input instead of holding A, allowing the player’s A input to pass through and returning L3 to the game for conversations. The new hooks add per-update work whose cost has not been measured.
Before merging, for the author (2) (a run, a measurement or a decision; it doesn't hold the recommendation)
host/oot_sprint.c:185: Measure frame time and 1% lows with Sprint off and on against the base in representative scenes, including Linux or Steam Deck. The disabled hooks now skip actor and state lookups.Checks: they run again on this head (
PR description / Description follows the template (pull_request_target)failed on the last one); a failure shows on the pull request.More: does it help, other systems, switches, what was read
Does it help: Unproven on this head. The author reports successful gameplay on Windows with an earlier engine combined with other changes; no frame-time or 1% low comparisons are recorded.
Other systems: The hooks affect Link’s movement and stance updates; controller reads also detect events and blocked input. Windows Xbox controller and Linux or Steam Deck behavior remain untested on this head.
Switches: No switch added or changed. Existing Sprint and Toggle settings remain player-controlled; Toggle defaults off.
Reviewed:
2c039ef5ddagainstc7bd8f80af: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, host/oot_sprint.c, the Sprint patch code and relevant controller references. Skimmed the Sprint test changes and diff; the full base-to-head diff includes many additional merged-main files and was not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run code were executed. CI has not run on this head; the author’s recorded gameplay and automated checks cover an earlier engine.
Overlaps and merge order: The recorded gameplay build included PRs #699, #711 and #1294; their current overlap and merge order are unknown.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.