Skip to content

Ocarina of Time: virtual amiibo (picker, masks, no daily limit) + nfp ModelInfo fix - #4

Open
Tizzle2x wants to merge 5 commits into
cheemu21:x9from
Tizzle2x:x1-amiibo
Open

Tizzle2x wants to merge 5 commits into
cheemu21:x9from
Tizzle2x:x1-amiibo

Conversation

@Tizzle2x

@Tizzle2x Tizzle2x commented Nov 10, 2026 •

Copy link
Copy Markdown

Adds virtual amiibo to Ocarina of Time, on top of x9. Tested on an iPhone Duo (A20 Pro, iOS 27.1).

Now based on x9. This PR started on x1. The branch has since been merged with x9 (frame generation, the pipeline archive, the prewarm list) without conflicts, and the PR now targets x9. The branch name still says x1 from before. The X9 build was tested on an iPhone Duo: the game, frame generation, the amiibo list and NFC scanning.

What it does

Fixes found while testing

  1. Startup crash. The game sizes the heap for Game/AmiiboSetting from the resource size table. My first rewrite of that file was bigger (2,448 bytes against 1,476) and crashed at boot (null allocation at main+0xe156e4). The BYML writer now shares identical containers the way Nintendo's does, so it rewrites the original byte for byte. The overlay also raises the file's size table entry (11672 → 23344).

  2. ModelInfo layout. nn::nfp::ModelInfo is not the tag's byte order. It holds:

    • the character ID (big-endian) and variant
    • the series at byte 3
    • the numbering ID, little-endian, at byte 4
    • the figure type

    With the raw tag bytes, the game (main+0x326b518 / +0x326b5f4) saw every amiibo as series 00. Daruk and the other series-only figures were rejected as unsupported, and the masks' numbering IDs came through byte-swapped. Only the Link/Zelda/Ganon character rule matched. This should affect other games that read the series or numbering ID too.

Testing

  • t_amiibo passes; t_nfc passes 91 checks, 0 failed.
  • On the phone:
    • Link (Majora's Mask) and Daruk give drops.
    • The Young Link and Young Zelda masks drop.
    • No crash at boot.

The game's files are read from your own dump at build time (scripts/oot_amiibo_overlay.py). None of them are in the repo.

Atomsk-debug and others added 4 commits November 10, 2026 06:34
…nds that amiibo, and the game reads its identity and keeps its application area

The host has no NFC reader, and every nfp tag call answered "tag not found", so no game's amiibo feature could be used. amiibo.h is a virtual tag: DM_AMIIBO is an
amiibo ID (16 hex digits) or a file holding one, read again at each StartDetection so the amiibo can be swapped or taken away between scans. Detection finds it and
signals the activate event; GetTagInfo gives a 7-byte NTAG215 UID made from the ID, GetModelInfo the ID, GetCommonInfo the write counter and the date,
GetRegisterInfo the host's default Mii as owner (hle_mii.c dm_mii_default_charinfo) and DM_AMIIBO_NAME as nickname. The application area is created (written at
once), opened by access ID, read, set and kept by Flush, and an unflushed area is dropped at Unmount and StopDetection; it is stored as <ID>.area in
DM_AMIIBO_DIR, else in an amiibo folder beside DM_SAVE, made only when an amiibo is named. Device states and results follow the nfp service (Ryujinx's and yuzu's
tables). With an amiibo named, nfc::IsNfcEnabled answers true, matching nfp. No dump or key is read. Without DM_AMIIBO every answer is as before.

tests/t_amiibo.c checks the structures, every state and result, the stored area across scans, a second game's access ID, a damaged file and a missing folder.
t_nfc.c runs a whole scan through the registered hooks, with its earlier checks unchanged; built off the Mac against a stub of HLE_FORCE, its 95 checks pass.
Not run with a game: the extended application area and the amiibo settings applets still answer no tag.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The rewritten Game/AmiiboSetting grew from 1,476 to 2,448 bytes (identical
containers written once each) and ran the game's heap for the file out: a null
allocation at main+0xe156e4, 5 s after start. The BYML writer now shares
identical containers as Nintendo's does (the original rewrites byte for byte),
and the overlay raises the file's resource size table entry (11672 -> 23344).
The launcher's two amiibo rows are gone: amiibo-nolimit/ always loads.
Mask rows named Young Link / Young Zelda (Ocarina of Time series).
nn::nfp::ModelInfo is character ID (big-endian), variant, series, numbering ID
(little-endian), figure type, tag type. The raw tag bytes put the figure type
where games read the series and byte-swapped the numbering ID: Ocarina of Time
(main+0x326b518/+0x326b5f4) saw every amiibo as series 00, rejected Daruk and
the other Zelda-series figures as unsupported, and could not match its two mask
figures by numbering ID; only its character rule (Link, Zelda, Ganon) worked.
@github-actions github-actions Bot added host The Horizon host: SVCs, services, threads, memory (dm/host) ios The iPhone and iPad app (dm/ios); on an issue, seen on one tools Tools and scripts (dm/tools, scripts) docs Documentation game: 0400486024DEC000 The Legend of Zelda: Ocarina of Time labels Nov 10, 2026
@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers shader chain The shader translation chain (DMSH_CHAIN): a change rebuilds every game's shaders game: 040074A01BF12000 Donkey Kong Bananza game: 0400E88025B1A000 Star Fox labels Nov 10, 2026
@Tizzle2x
Tizzle2x changed the base branch from x1 to x9 November 10, 2026 20:29
cheemu21 added a commit that referenced this pull request Nov 13, 2026
…d its amiibo-nolimit folder served first

The amiibo work of Tizzle2x and Atomsk (#4 and #5) came from the X line, where build_ipa.sh packed a romfs_overlay folder beside the RomFS and
hle_fs.c's rom_overlay_set chose its per-mode resolution and amiibo folders. The FF line has neither (its render scale is a patch), so:
- build_ipa.sh: a profile with amiibo.tsv gets a romfs_overlay folder of its own in the app: the list (the in-game Amiibo menu, GameMenu.swift) and, with amiibo_overlay on, the game's
  Game/AmiiboSetting with every amiibo's daily limit off and its resource size table entry, made from the player's own RomFS image by scripts/oot_amiibo_overlay.py (nothing of the game
  in the repository; the list alone when the script fails). The X line's resolution folders beside the RomFS are not packed.
- hle_fs.c rom_overlay_expand: DM_ROMFS_OVERLAY's folders, each after its amiibo-nolimit/ subfolder where it has one; no per-mode folders on this line.

Checked: t_amiibo ok, t_nfc 95 checks 0 failed, t_fs 146 checks 0 failed, the Mac host builds. Not yet on an iPhone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iDams pushed a commit to iDams/nxnative that referenced this pull request Nov 13, 2026
…d its amiibo-nolimit folder served first

The amiibo work of Tizzle2x and Atomsk (cheemu21#4 and seedds#5) came from the X line, where build_ipa.sh packed a romfs_overlay folder beside the RomFS and
hle_fs.c's rom_overlay_set chose its per-mode resolution and amiibo folders. The FF line has neither (its render scale is a patch), so:
- build_ipa.sh: a profile with amiibo.tsv gets a romfs_overlay folder of its own in the app: the list (the in-game Amiibo menu, GameMenu.swift) and, with amiibo_overlay on, the game's
  Game/AmiiboSetting with every amiibo's daily limit off and its resource size table entry, made from the player's own RomFS image by scripts/oot_amiibo_overlay.py (nothing of the game
  in the repository; the list alone when the script fails). The X line's resolution folders beside the RomFS are not packed.
- hle_fs.c rom_overlay_expand: DM_ROMFS_OVERLAY's folders, each after its amiibo-nolimit/ subfolder where it has one; no per-mode folders on this line.

Checked: t_amiibo ok, t_nfc 95 checks 0 failed, t_fs 146 checks 0 failed, the Mac host builds. Not yet on an iPhone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 20a9c0d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0400E88025B1A000 Star Fox game: 040074A01BF12000 Donkey Kong Bananza game: 0400486024DEC000 The Legend of Zelda: Ocarina of Time host The Horizon host: SVCs, services, threads, memory (dm/host) ios The iPhone and iPad app (dm/ios); on an issue, seen on one nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers shader chain The shader translation chain (DMSH_CHAIN): a change rebuilds every game's shaders tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants