fix(nfc): put the amiibo model fields in the SDK's order #2505
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!2505
Loading…
Reference in a new issue
No description provided.
Delete branch "dazemc/Longshot:fix/nfp-model-info-field-order"
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
On
main, a Zelda amiibo tapped in Hyrule Field is usually rejected: the game answers "This amiibo is not supported."for every figure except the one whose per-character amiibo settings happen to match. The tag keeps a figure's model as
character, variant, figure type, model number, series (
0x54to0x5A, in that order);nn::nfp::ModelInfokeeps it ascharacter id, series, model number, figure type.
GetModelInfoinhost/nn_nfp.ccopied the tag's seven bytes straightthrough, so the game read the figure's type as the series id and the series as the type, and only the matching figure was
accepted.
GetModelInfonow fills the SDK's order: the character id's three bytes copied, the series in[3], the model's numberas a native u16 in
[4..5], and the figure's type in[6]. Every figure whose tag says it belongs to a supported seriesis accepted. The NFC fixtures also use the shared compiler command parser to preserve Windows compiler paths.
To see the bug on
main: buildmain, put a 540-byte tag file in the NFC folder, run the game windowed, open Insert,the NFC tab, pick the tag, Tap tag, and walk into Hyrule Field so the game asks for a tag.
mainreads it (the logsays
nfp: the game reads the NFC tag "...") and then answers "This amiibo is not supported." The same tag on thisbranch is read and its items arrive.
Read first:
host/nn_nfp.c,GetModelInfo(the four changed lines); thentests/test_nfc_model_info_fields.py, which isthe two layouts written down.
The old test was wrong, and that is why
mainis green.tests/test_nfc_model_info.pyasserted the tag's own order —memcmp(out, cases[i], 4)andout[6] == cases[i][6]— so it agreed with the bug instead of the SDK and passed onmainwhile the game rejected every other figure. It now asserts the SDK's order (memcmp(out, cases[i], 3),out[3] == cases[i][6],out[6] == cases[i][3]), and onmainit fails withFAIL case 0: ModelInfo 12 34 56 01 34 12 09, expected character 12 34 56, series 09, number 34 12, type 01. The newtests/test_nfc_model_info_fields.pysays the same thing from both sides: the tag's order in, the SDK's order out.Fixes #2489.
Rebase status (2026-11-25, current):
9ef83d87f→01b1be9d1ontomain @ 8f7300756701b7c9a278e576bb075ac20e622a32. Stable patch-id8ca929a67ccf1bd32058306a193779863dde1a0eis unchanged and main's old-base→new-main file intersection with this PR is empty. The evidence already named below (suite, platform, in-game and measurement, as applicable) therefore still stands at the historical heads that produced it. Earlier rebase notes are history; where they say "this head", they mean the evidence commit named beside that run, not01b1be9d1.Testing
Rebase (2026-11-25). Rebased onto
origin/mainbe663a08a30fa953420104d3cef6877bed6674a2. The head this note starts from is24b97e5f046152efa811f7d68900e9c84038d07c(it had already moved from1a4a650654by the Windows-fixture commit24b97e5f, message and tests only), and the new head is9ef83d87fe706db5d724930abcdcbbcbcc8cee1d.git diff -U0 6b928cb4d..24b97e5fandgit diff -U0 be663a08a3..9ef83d87hold the identical changed-line set (143 added/removed lines, 0 differing), so the rebase changed none of this PR's content. Main's new commits do touchtests/test_host_guest_writes.py(+7/−7, #2411), which this PR's NFC fixture work edits, so the checks below — already taken on the earlier head1a4a650654— are not re-established at this head. Themise run testbox stays unticked pending a suite at9ef83d87feafter the quiet window; the Linux in-game runs and the Windows cross-compile describehost/nn_nfp.c, which main has not changed, and are kept as the record of those heads.Tested: Linux (kernel 7.3.5), NVIDIA GeForce RTX 4070 Ti, Vulkan 1.4, driver
0x9b124100, windowed runs of the builtruntime (not headless): a 540-byte synthetic Yunobo tag (a valid NTAG215 container, its model block at
0x54reading01 0c 00 00 a6 04 09) in a temporaryLONGSHOT_NFC_DIR, held to the reader from Insert, the NFC tab, then tapped inHyrule Field.
v3.2.0-15-g9046a8d75-dirty, built from9046a8d75019with the fix applied, before it wascommitted): the game reads the tag and the figure's items arrive. Log
/tmp/opencode/longshot-2489/runs/fix-e/log.txt,screenshots
/tmp/opencode/longshot-2489/runs/fix-e-scan3.pngandfix-e-scan2.png.main(v3.2.0-12-g8aa5ab876): the same tag is read and the game answers "This amiibo is not supported." Log/tmp/opencode/longshot-2489/runs/base-a/log.txt, screenshot/tmp/opencode/longshot-2489/runs/base-a-scan2.png.Both runs are windowed with 0
vk: no windowlines. None of this leaves the PC: the game logs and screenshots staythere, so they are named by path above and not attached.
Two traps for anyone reproducing it:
--profile testforcesHOS_HEADLESS=1, so use the default profile for the window;and the Insert menu ignores keys and the gamepad unless its window is foreground, so a headless run cannot tap a tag at
all.
The checks, on the earlier head
1a4a6506546c:963 checks, 18 skipped, 5 at once (linux)and962 passed, 1 failed, 18 skipped in 419 s (linux, 5 at once). The one failure istests/test_cpm_discovery.py, whichfails the same way on
main(AssertionError: '/usr/local' is not None), and the 18 skips aremain's own, id for id.tests/test_nfc_model_info.pyandtests/test_nfc_model_info_fields.pypass here and fail onmainwith 6 failed checkseach, all of them the swapped fields.
Still to test: None for the game or the checks: the suite at
9ef83d87fincluded the Windows compiler command parsing, and the empty-intersection rebase carries it to01b1be9d1. No amiibo hardware was used: this function only reads the tag's model bytes, and a synthetic dump carries the same bytes a real tag does for it.Measurements
Verdict: the bug reproduced on
mainand gone here; a fix's measurement is the failure and its absence.Setup: Linux, NVIDIA GeForce RTX 4070 Ti, driver
0x9b124100; the windowed runtime of each side, the same 540-byte tagfile, tapped from Insert, the NFC tab, in Hyrule Field.
8aa5ab871a4a6506tests/test_nfc_model_info.pytests/test_nfc_model_info_fields.pyThe before side ran
mainat8aa5ab87, the mainmainwas at when the runs were made;host/nn_nfp.cis byte forbyte identical at
8aa5ab87and at the pre-rebase basebe663a08a3(blob9be1e3b89d, measured), and the two tests fail identically at both, so thebefore row describes this base too.
Risks
The runtime change is the order of seven bytes in a 0x40-byte struct the game reads once per tag. A game or mod
that expected
main's order would see the series and the figure's type swapped, which is the bug this fixes; nothingelse moves, and the rest of the struct is still zeroed. There is no switch: a revert is enough. Nothing changes on disk
after updating (no save,
longshot_options.inior cache), and a player notices only that figures other than the matchingone are accepted.
Checklist
Ready for review
main; the title is a Conventional Commit. — Rebased head01b1be9d1is directly onmain @ 8f7300756701b7c9a278e576bb075ac20e622a32; the preserved diff is the single topic described in Summary: one HLE function and three checks.same synthetic tag.
mise run testpasses on the rebased head by the empty-intersection evidence rule (any failure that also fails onmainis named). Historical suite at9ef83d87fe706db5d724930abcdcbbcbcc8cee1d: 834 passed, 2 failed, 8 skipped in 502 s (linux, 5 at once), exit 1; logprrefresh-logs/suite-2505-9ef83d87.log, sha25640ed4e704a79defd3892b10e5b6247b1bcd8761405694fc3e9ed83a8b823ec73,.head= that sha,.start/.end/.exitand JUnit beside it. Passes against Amendment 1's CORE ∪ FLAKY plus the base failures of Amendment 2 — CORE/FLAKY: none; base-exempt:tests/test_display_startup_failure.py,tests/test_title_card_strips.py; same 8 skips. base failuretests/test_display_startup_failure.pyexempt: fails identically at the merge-basebe663a08a—display_startup_actual.inc:82:5: error: use of undeclared identifier 'bc_claim'; reproductionprrefresh-logs/base-be663a08a-two-ids.log, sha256a26e89fa21110e64aa11987f7acae1a9d166b3c6e1877e8335aa3c9b0b9ac257. base failuretests/test_title_card_strips.pyexempt: fails identically at the merge-basebe663a08a—ModuleNotFoundError: No module named 'oot_patches'; same reproduction, same sha256. This is the second attempt under this ticket: the first (08:12) was voided by a foreignrun_all.pyfrom another lane's suite, and its log was overwritten. The pressure sampler did not cover the second attempt either — a stale.exitfrom the first made it stop after one sample — so guard evidence for it is absent;dev.py queue historyshows no other suite started while it ran (only a 25 slongshot-builderbuild at 08:22), and the run reached its summary line with blocks agreeing.main, or Measurements says why there is nothing to measure. For a fix: the refusal onmainandits absence here, plus the test that fails on both.
third_party/untouched; nothing GPL-incompatible. Thediff is
host/nn_nfp.c,tests/test_nfc_model_info.py,tests/test_nfc_model_info_fields.pyand one line oftests/test_host_guest_writes.py.When it applies
mainand passes here. Both new and corrected checks fail onmain'shost/nn_nfp.cwith the swapped fields and passed on the earlier tested head.tests/that reads changed source is updated, not weakened.tests/test_host_guest_writes.pyliststhe bulk write it reads, now the 3-byte copy instead of the 7-byte one;
tests/test_nfc_model_info.pygained per-fieldmessages and now asserts the SDK's order rather than the tag's.
Windows with llvm-mingw 20261104 (the release
tools.lockpins and.forgejo/workflows/build-windows.ymlruns on itsLinux runner):
--target=x86_64-w64-mingw32, the host flags, a COFF-x86-64 object of 38,360 bytes, no warnings. OnLinux the suite compiles the same function with
-std=c11 -Wall -Wextra -Werror. The change adds no include, noplatform call and no path, and it was not linked into a full Windows build.
mainand here, for a change that shows on screen. Hyrule Field, the same tag:/tmp/opencode/longshot-2489/runs/base-a-scan2.pngshows the refusal,fix-e-scan3.pngthe items arriving; kept on thePC with the logs and named by path rather than attached.
Assisted-by:/Co-Authored-By:trailers. The commit ends withAssisted-by: DeepSeek V4.1 Flash 1017 (opencode-go).Ready to merge
main, measured again or a comment says why the numbers still hold. — Awaiting CI on the current head; this update does not claim a CI run.Tested in game: Linux, NVIDIA GeForce RTX 4070 Ti, Vulkan 1.4, driver 0x9b124100, windowed run (not headless), Hyrule Field: a 540-byte synthetic Yunobo tag tapped from Insert, the NFC tab, is read on this branch and the figure's items arrive; the same tag on main (v3.2.0-12-g8aa5ab876) is read and the game answers "This amiibo is not supported." The logs and screenshots stay on the PC (the no-game-material rule), so they are named by path in the description rather than attached.
@review
Recommendation: Approve. The field mapping fixes the reproduced rejection, but the new test mishandles a normal Windows compiler path supplied through CC. The remaining CI checks also need to finish. Nothing blocking is left. Recommend approval; not approved on the forge.
GetModelInfo returns the tag’s series and figure type in the SDK’s field order. The reported Linux game run shows the previously rejected synthetic tag working; the new test duplicates much of the existing fixture.
Should fix (1): not blocking, but worth doing before merging.
tests/test_nfc_model_info_fields.py:101: The new test parses CC with POSIX shell rules on Windows, which removes backslashes from an unquoted Windows compiler path. (more on the line) Do: Parse CC in a platform-aware way that preserves Windows paths and compiler arguments, and apply the same correction to the existing NFC fixture if sharing the helper.@fixcan do L1.Checks: Still running: 9 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The reported same-tag game runs rejected the tag on main and delivered its items with the fix. The author also reports both field-order tests failing on the base and passing with the fix.
Other systems: Both file-backed tags and the Windows controller reader populate the same locked tag buffer, so both use the corrected mapping. The change does not touch rendering, saves, audio, input timing, or GPU-specific code. The author reports a Windows cross-compilation of the host file but no full Windows build or game run.
Switches: None added, changed, or removed.
Reviewed:
1a4a650654against9046a8d750: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the commit and diff, and the changed test files. Read the changed NFC function and surrounding tag-loading, locking, and reader paths; skimmed the remainder of host/nn_nfp.c. The named local run artifacts were not available for inspection. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no code, scripts, builds, or tests were run. The supplied CI status lists checks still running and no head-only failures.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -0,0 +98,4 @@class NfcModelInfoFields(unittest.TestCase):def test_each_field_lands_where_the_sdk_puts_it(self):L1 (should fix): The new test parses CC with POSIX shell rules on Windows, which removes backslashes from an unquoted Windows compiler path.
When: With CC set to a path such as C:\llvm\bin\clang.exe, shlex.split produces C:llvmbinclang.exe. subprocess.run then cannot find the compiler, so this new check errors on a supported platform.
Do: Parse CC in a platform-aware way that preserves Windows paths and compiler arguments, and apply the same correction to the existing NFC fixture if sharing the helper.
@fix
1a4a65065424b97e5f04Recommendation: Approve. The compiler parsing fix preserves Windows paths in both NFC fixtures while keeping their existing compiler fallback. The recorded game run shows the NFC field-order fix working for the tested tag. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
24b97e5f04. I rebased it ontomain(6b928cb4dc). I edited its description to match the change.Changed
Nothing was built or run: the checks run again on the new head.
The runtime change puts amiibo model fields in the order the game expects; the fixture change makes configured Windows compiler paths usable. The fix reuses the suite's shared parser without disabling the NFC tests.
Checks: they run again on this head; a failure shows on the pull request.
Also noticed (4; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes. The author reports that the same synthetic Yunobo tag was rejected on main and produced items with the fix in a windowed Linux game run. No performance gain is claimed.
Other systems: The runtime field mapping is shared across platforms. The reported game run was on Linux; the changed host file was also reported to cross-compile for Windows. The parser selects Windows argument rules on Windows and shell parsing elsewhere.
Switches: None added, changed, or removed.
Reviewed:
24b97e5f04against6b928cb4dc: Read AGENTS.md, CONTRIBUTING.md, the pull request template, both NFC fixtures, the shared compiler parser, the fix diff, and the GetModelInfo implementation. The full base diff includes additional unrelated changes and was skimmed, not reviewed in full; docs/review-checklist.md and the adjacent Tooling AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports a windowed before-and-after game run and passing NFC fixtures on the earlier head; CI has not run on the final head.
Overlaps and merge order: Unknown; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
24b97e5f049ef83d87fe9ef83d87fe01b1be9d16Rebased
9ef83d87fto01b1be9d1on main8f7300756; patch-id unchanged and intersection empty. Existing suite, game and Windows evidence stands; stale final-head wording corrected.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.