feat(input):Improving Sprint feature: Sprint sets the game's dash input instead of holding A #2038

Open
kendowashere wants to merge 2 commits from kendowashere/Longshot:feat/sprint-dash-input into main
First-time contributor

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_804caa80 at 0x804ce798, the sprint's start and keep tests) and his stance and camera update (f_80c225d0 at 0x80c27f3c). nx2/oot_patches.py puts a call right after each load, and host/oot_sprint.c ORs 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:

main (A held, press hidden) this PR (dash input)
The player's own A while sprinting Sprint lets go of A for 50 ms (SPRINT_ROLL_GAP_MS) so the game can see a fresh press, then holds it again; a tap counts only through that gap Never touched: A rolls, talks, opens and picks up exactly as without Sprint
What is patched The game's controllers' update, f_8038a220 and also the menus' f_834a3680: every reader of A sees the mask Two loads in Link's own update code; no other actor, menu or controller reader sees anything
Where it acts A is held in whatever state Link is in while the stick is pushed (swimming, carrying, ladders, Epona, aiming...), and what a held A does there is up to the game Only Walk, Jump, Land, Fall and Clamber run it; Slide, StepOn and a roll keep it; any other state ends it
L3 in a conversation Turning Sprint on moves L3 from the Switch's LS to Sprint, so the press that hides the text box in a conversation never reaches the game A press that begins outside gameplay (a conversation or cutscene, an event running, or a load) goes to the game as LS while it is held, and starts no sprint
Toggle A latch: on until the next press, Insert, Plus/Minus or the focus lost; with the stick pushed it holds A again in any later state Also ends when Link stops (4 frames standing still, counted in 60 Hz frames so 240 fps behaves like 60), attacks, uses an item, swims, climbs or holds ZL; a roll or a jump keeps it
Other Links The controller's A, so whoever reads it Only the controlled Link (the actor manager's +0x470), never the other instance of his class

What 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 in npad_states (host/nn_hid.c), patch_sprint_link and patch_sprint_stance in nx2/oot_patches.py.

Testing

Tested: Windows 11, NVIDIA GeForce RTX 5070 Ti (driver 621.24), by hand in the game: this branch's engine built together with my other open PRs (#699, #711, #1294) on main @ fd7dc40d (build/combined, the same host/oot_sprint.c, nn_hid.c wiring and patch sites as this head). 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.

  • The game built from this head's engine (dev.py packs base, llvm-mingw): oot_patches: Sprint's link site in code_hot.c and ... stance site in code_hot.c, each found once; oot_sprint.c compiled.
  • tests/test_sprint.py (8 tests): the bindings and layout cases as before, and host/oot_sprint.c compiled 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 two patch sites on lifted text, a drifted build left alone and counted, and touches() keeping both functions out of guest_locals.
  • tests/test_input_background.py (every case but stick-directions, which fails on main @ 7c23d2be too, sprint-toggle now checks what npad_states hands host/oot_sprint.c and 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_menu fails on main too (#1721's stand-in, named in #1977), and test_menu_i18n fails on main @ 7c23d2be the same way (an Output resolution text #1859 changed). The whole suite on main @ e6196f0f: the same failures with and without this change.
  • The engine itself (the same state table, timings and hook sites) is my NX2navi Sprint button, played there since 0.10.0.

Still to test:

  • Windows, an Xbox controller: the same checks as above (by hand)
  • Linux: the build and the same checks with a controller (@Beanstalk build and start on Linux)

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

  • Sprint does nothing if the recompiler stops writing either load as oot_patches.py expects: the build prints WARNING: Sprint's sites were found ..., and nothing else breaks (no A is held any more).
  • Link's state ids and the event manager's address come from game 1.1.1; another build's ids would end a toggled sprint at once (the sites would not be found there anyway).
  • Players' settings carry over unchanged (sprint=, toggle_sprint=, the bindings). A revert brings back A held.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows: the base build above; Linux: the Test Farm)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary Sprint ([#1929](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1929), [#1948](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1948), [#1977](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1977), built on thegrandao's [#196](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/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_804caa80` at `0x804ce798`, the sprint's start and keep tests) and his stance and camera update (`f_80c225d0` at `0x80c27f3c`). `nx2/oot_patches.py` puts a call right after each load, and `host/oot_sprint.c` ORs 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:** | | main (A held, press hidden) | this PR (dash input) | |---|---|---| | The player's own A while sprinting | Sprint lets go of A for 50 ms (`SPRINT_ROLL_GAP_MS`) so the game can see a fresh press, then holds it again; a tap counts only through that gap | Never touched: A rolls, talks, opens and picks up exactly as without Sprint | | What is patched | The game's controllers' update, `f_8038a220` and also the **menus'** `f_834a3680`: every reader of A sees the mask | Two loads in **Link's own** update code; no other actor, menu or controller reader sees anything | | Where it acts | A is held in whatever state Link is in while the stick is pushed (swimming, carrying, ladders, Epona, aiming...), and what a held A does there is up to the game | Only Walk, Jump, Land, Fall and Clamber run it; Slide, StepOn and a roll keep it; any other state ends it | | L3 in a conversation | Turning Sprint on moves L3 from the Switch's LS to Sprint, so the press that **hides the text box** in a conversation never reaches the game | A press that begins outside gameplay (a conversation or cutscene, an event running, or a load) goes to the game as LS while it is held, and starts no sprint | | Toggle | A latch: on until the next press, Insert, Plus/Minus or the focus lost; with the stick pushed it holds A again in any later state | Also ends when Link stops (4 frames standing still, counted in 60 Hz frames so 240 fps behaves like 60), attacks, uses an item, swims, climbs or holds ZL; a roll or a jump keeps it | | Other Links | The controller's A, so whoever reads it | Only the controlled Link (the actor manager's `+0x470`), never the other instance of his class | What 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 in `npad_states` (`host/nn_hid.c`), `patch_sprint_link` and `patch_sprint_stance` in `nx2/oot_patches.py`. ## Testing **Tested:** Windows 11, NVIDIA GeForce RTX 5070 Ti (driver 621.24), by hand in the game: this branch's engine built together with my other open PRs (#699, #711, #1294) on `main` @ fd7dc40d (`build/combined`, the same `host/oot_sprint.c`, `nn_hid.c` wiring and patch sites as this head). 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. - The game built from this head's engine (`dev.py packs base`, llvm-mingw): `oot_patches: Sprint's link site in code_hot.c` and `... stance site in code_hot.c`, each found once; `oot_sprint.c` compiled. - `tests/test_sprint.py` (8 tests): the bindings and layout cases as before, and `host/oot_sprint.c` compiled 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 two patch sites on lifted text, a drifted build left alone and counted, and `touches()` keeping both functions out of `guest_locals`. - `tests/test_input_background.py` (every case but `stick-directions`, which fails on `main` @ 7c23d2be too, `sprint-toggle` now checks what `npad_states` hands `host/oot_sprint.c` and 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_menu` fails on `main` too (#1721's stand-in, named in #1977), and `test_menu_i18n` fails on `main` @ 7c23d2be the same way (an Output resolution text #1859 changed). The whole suite on `main` @ e6196f0f: the same failures with and without this change. - The engine itself (the same state table, timings and hook sites) is my NX2navi Sprint button, played there since 0.10.0. **Still to test:** - Windows, an Xbox controller: the same checks as above (by hand) - Linux: the build and the same checks with a controller (@Beanstalk build and start on Linux) ## 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 - Sprint does nothing if the recompiler stops writing either load as `oot_patches.py` expects: the build prints `WARNING: Sprint's sites were found ...`, and nothing else breaks (no A is held any more). - Link's state ids and the event manager's address come from game 1.1.1; another build's ids would end a toggled sprint at once (the sites would not be found there anyway). - Players' settings carry over unchanged (`sprint=`, `toggle_sprint=`, the bindings). A revert brings back A held. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows: the base build above; Linux: the Test Farm) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
Sprint keeps its row, its Controls page line and its Toggle, but no longer
holds A and hides A's press from the game's controllers. host/oot_sprint.c
sets bit 4 of Link's input flags (the dash input, the game's own run after a
roll) right after the two places that load them (nx2/oot_patches.py
patch_sprint_link at 0x804ce798, patch_sprint_stance at 0x80c27f3c), for the
controlled Link only.

- A is never touched: the player's A rolls, talks, opens and picks up as
  usual while sprinting, with no 50 ms release gap; the press mask in the
  controllers' update and the A handoff are gone.
- A toggled sprint ends with Link's state (stopping, an attack, an item,
  swimming, climbing, ZL held), keeps through jumps, slides and rolls, and
  counts standing still in 60 Hz frames at any frame rate.
- A press of the left stick that begins outside gameplay (a conversation or
  cutscene, where it hides the text box, or a load) goes to the game as LS
  again instead of being lost to Sprint.

Ported from the Sprint button of the NX2navi runtime (sprint-button,
sprint-event-pass, sprint-roll-keep).

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge remote-tracking branch 'origin/main' into feat/sprint-dash-input
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 6s
6f44624e85
kendowashere changed title from WIP: feat(input): Sprint sets the game's dash input instead of holding A to feat(input): Sprint sets the game's dash input instead of holding A 2026-11-21 07:46:09 +00:00
kendowashere changed title from feat(input): Sprint sets the game's dash input instead of holding A to feat(input):Improving Sprint feature: Sprint sets the game's dash input instead of holding A 2026-11-21 07:47:55 +00:00
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 6s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/sprint-dash-input:kendowashere-feat/sprint-dash-input'
git switch 'kendowashere-feat/sprint-dash-input'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2038
No description provided.