WIP: feat(amiibo): read amiibo from your own figure dumps #2479

Draft
hckrman101 wants to merge 2 commits from hckrman101/feat/amiibo-steam-power into main
hckrman101 commented 2026-11-11 20:40:25 +00:00 (Migrated from github.com)

Branch: feat/amiibo-steam-power (#2479), new head 44e48391c0 on 545fd31a


The game asks for amiibo (it initializes nn::nfp at every start), but Hookshot answered every amiibo call with an empty stub, so no figure could ever be read (#621). This PR serves nn::nfp and lets the player put a dump of one of their own figures on the reader from the Insert menu.

Add to Steam and the Windows power-throttling log line, which this branch held at first, are now separate pull requests; the last commit here takes them out.

What changes

  • nn::nfp is now served by the host (host/nn_nfp.c, host/amiibo.c) instead of generated stubs: one NFC reader that is always there, as on the console with a Pro Controller or the right Joy-Con.
  • A new Amiibo row on the Insert menu's Gameplay tab lists the dumps in an amiibo folder in the game folder (HOS_AMIIBO_DIR for another folder). Choose one with Left/Right, and press Enter or A when the game asks for an amiibo. The help under the row says whether it is on the reader, whether the game is looking for it, and whether the game has read it. Once the game has read it and stops searching, the figure is taken off the reader again (or after 20 s if the game never reads it).
  • Only the player's own dumps are used; Hookshot includes and downloads nothing. The game gets what a figure keeps in the clear: its UID and amiibo ID (model info). The nickname, owner Mii and application area are encrypted on the tag with keys Hookshot does not have. The nickname shown is the file name, and an application area the game creates is kept in amiibo/appdata/<UID>.bin, never written into the dump.
  • MkwVkHost version 18: amiibo_count, amiibo_name, amiibo_choose, amiibo_state. If another open PR also bumps the version, whichever lands second takes the next number.
  • The amiibo settings applets (StartNicknameAndOwnerSettings, StartGameDataEraser, StartRestorer) stay stubs: there is no applet to show.

Credit

Ported from valentderah/totk-pc-recomp runtime/amiibo.c and runtime/nfp.c (MIT): leonelalej's amiibo support (totk-pc-recomp PR #235) with Valiantsin Dzerakh's fixes. The MIT notice is kept in host/amiibo.c and noted in host/PROVENANCE.md. totk-pc-recomp serves the nfp:user IPC commands; Hookshot serves the SDK's nn::nfp functions the game imports, and keeps the application area beside the dumps.

Verified

  • Game-free: tests/test_amiibo.py covers:

    • dump checks: size, capability container, UID check bytes;
    • the reader's states through search, found, mounted, read and taken off, and the 20 s timeout;
    • the model info layout;
    • application area create, open, get, set and flush into amiibo/appdata, with the dump never written;
    • the folder listing.

    tests/run_all.py on Linux on this branch: 396 passed, 0 failed, 12 skipped (Windows-only, PIL, dotnet).

  • In the game (RTX 3090, Linux, headless, a copy of a test save):

    • the boot log shows nfp: initialized;
    • the Gameplay tab shows the Amiibo row with a synthetic test tag (made-up UID and ID, made by the test, no real figure);
    • Enter puts it on the reader (log amiibo: Synthetic Test Tag: character 012345, figure type 02, model 0abc, series 07 and ... placed on the reader), and the row's help says so.

The Amiibo row with a test tag on the reader

  • Windows: amiibo.c, nn_nfp.c, rx_backend.c and vk_menu.cpp pass a syntax check with llvm-mingw (x86_64-w64-mingw32).

Not tested

  • The game actually reading a figure. I didn't find where the game offers amiibo (none of its English messages mention it), so the read path (search, mount, model info, application area) is checked game-free only, not in play. No real figure's dump was used.
Branch: feat/amiibo-steam-power (#2479), new head 44e48391c0f7654983e43e57b37a0397565e5548 on 545fd31a --- The game asks for amiibo (it initializes `nn::nfp` at every start), but Hookshot answered every amiibo call with an empty stub, so no figure could ever be read (#621). This PR serves `nn::nfp` and lets the player put a dump of one of their own figures on the reader from the Insert menu. Add to Steam and the Windows power-throttling log line, which this branch held at first, are now separate pull requests; the last commit here takes them out. ### What changes - `nn::nfp` is now served by the host (`host/nn_nfp.c`, `host/amiibo.c`) instead of generated stubs: one NFC reader that is always there, as on the console with a Pro Controller or the right Joy-Con. - A new **Amiibo** row on the Insert menu's Gameplay tab lists the dumps in an `amiibo` folder in the game folder (`HOS_AMIIBO_DIR` for another folder). Choose one with Left/Right, and press Enter or A when the game asks for an amiibo. The help under the row says whether it is on the reader, whether the game is looking for it, and whether the game has read it. Once the game has read it and stops searching, the figure is taken off the reader again (or after 20 s if the game never reads it). - Only the player's own dumps are used; Hookshot includes and downloads nothing. The game gets what a figure keeps in the clear: its UID and amiibo ID (model info). The nickname, owner Mii and application area are encrypted on the tag with keys Hookshot does not have. The nickname shown is the file name, and an application area the game creates is kept in `amiibo/appdata/<UID>.bin`, never written into the dump. - `MkwVkHost` version 18: `amiibo_count`, `amiibo_name`, `amiibo_choose`, `amiibo_state`. If another open PR also bumps the version, whichever lands second takes the next number. - The amiibo settings applets (`StartNicknameAndOwnerSettings`, `StartGameDataEraser`, `StartRestorer`) stay stubs: there is no applet to show. ### Credit Ported from [valentderah/totk-pc-recomp](https://github.com/valentderah/totk-pc-recomp) `runtime/amiibo.c` and `runtime/nfp.c` (MIT): leonelalej's amiibo support (totk-pc-recomp PR #235) with Valiantsin Dzerakh's fixes. The MIT notice is kept in `host/amiibo.c` and noted in `host/PROVENANCE.md`. totk-pc-recomp serves the nfp:user IPC commands; Hookshot serves the SDK's `nn::nfp` functions the game imports, and keeps the application area beside the dumps. ### Verified - Game-free: `tests/test_amiibo.py` covers: - dump checks: size, capability container, UID check bytes; - the reader's states through search, found, mounted, read and taken off, and the 20 s timeout; - the model info layout; - application area create, open, get, set and flush into `amiibo/appdata`, with the dump never written; - the folder listing. `tests/run_all.py` on Linux on this branch: 396 passed, 0 failed, 12 skipped (Windows-only, PIL, dotnet). - In the game (RTX 3090, Linux, headless, a copy of a test save): - the boot log shows `nfp: initialized`; - the Gameplay tab shows the Amiibo row with a synthetic test tag (made-up UID and ID, made by the test, no real figure); - Enter puts it on the reader (log `amiibo: Synthetic Test Tag: character 012345, figure type 02, model 0abc, series 07` and `... placed on the reader`), and the row's help says so. ![The Amiibo row with a test tag on the reader](https://raw.githubusercontent.com/hckrman101/Hookshot/1aefcdfa8f31a7910ad62e954181dc4726b95770/extras/menu-amiibo-on-reader.png) - Windows: `amiibo.c`, `nn_nfp.c`, `rx_backend.c` and `vk_menu.cpp` pass a syntax check with llvm-mingw (x86_64-w64-mingw32). ### Not tested - The game actually reading a figure. I didn't find where the game offers amiibo (none of its English messages mention it), so the read path (search, mount, model info, application area) is checked game-free only, not in play. No real figure's dump was used.
Commenting is not possible because the repository is archived.
No description provided.