Skip to content

Try to Fix/strain deadzone overflow - #108

Draft
hugou74130 wants to merge 23 commits into
mupen64:mainfrom
hugou74130:fix/strain-deadzone-overflow
Draft

hugou74130 wants to merge 23 commits into
mupen64:mainfrom
hugou74130:fix/strain-deadzone-overflow

Conversation

@hugou74130

Copy link
Copy Markdown
Member

Potential Fix #36 @crackhex

Strain of .99 drops to .00 in the deadzone

The SM64 joystick deadzone zeros out any component where $|val| \leq 7$. The tool was calculating magnitude incorrectly and could return joystick inputs like $(7, -2)$, which the game silently zeros, resulting in a magnitude of 0 and Mario not moving.

Changes

get_magnitude_for_stick — Fixed the deadzone threshold. The old formula math.max(0, |x| - 6) returned $1$ for $x=7$, whereas the game actually zeros it. It now uses $|val| \geq 8$ as the correct threshold.inputsForAngle — After the binary search, if the result falls within the deadzone (mag = 0), the tool scans neighboring entries in the Angles table to find the nearest valid (non-deadzone) input.scaleInputsForMagnitude — Improved candidate selection to prioritize non-deadzone results and handle edge cases where the ideal input has one axis inside the deadzone.

Root

CauseWhen goal_mag = 127, scaleInputsForMagnitude exits immediately, and the raw result from inputsForAngle is used directly. If the binary search landed on a deadzone entry, nothing downstream was correcting it.

hugou74130 and others added 23 commits April 11, 2026 11:56
The BUG AREA comment in scaleInputsForMagnitude claimed an inconsistency
between the code (|val| < 8) and the game (|val| <= 6). Checking the SM64
decomp (src/game/game_init.c, adjust_analog_stick) shows the game also
uses |val| < 8 (i.e. |val| <= 7) as the deadzone boundary, then subtracts 6.

All thresholds in this file are therefore consistent with the engine.

Refs: n64decomp/sm64 src/game/game_init.c
The BUG AREA comment in scaleInputsForMagnitude claimed an inconsistency
between the code (|val| < 8) and the game (|val| <= 6). Checking the SM64
decomp (src/game/game_init.c, adjust_analog_stick) shows the game also
uses |val| < 8 (i.e. |val| <= 7) as the deadzone boundary, then subtracts 6.

All thresholds in this file are therefore consistent with the engine.

Refs: n64decomp/sm64 src/game/game_init.c
@MikeXander

Copy link
Copy Markdown
Contributor

This fundamentally changes the choice of input by completely ignoring how close the inputs are in angle to the original target angle. Considering this PR seems to be mostly produced by an LLM, I would want proof that this change is actually beneficial.

This also doesn't actually address the referenced issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.99 strain goes to .00 in deadzone

2 participants