Skip to content

A player's own system data and Mii database from DM_SYSTEM_DIR: Switch Sports Resort draws Mii heads and lists the console's Miis - #2274

Closed
FifteenPen wants to merge 1 commit into
seedds:mainfrom
FifteenPen:pr/mii-system-files
Closed

FifteenPen wants to merge 1 commit into
seedds:mainfrom
FifteenPen:pr/mii-system-files

Conversation

@FifteenPen

@FifteenPen FifteenPen commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Switch 2 games that show Miis need two things from the console, and the host ships support for neither:

  • The Mii head models: system data 0400000000000849, mounted as MiiResource:. Nintendo Switch Sports Resort (04008E001F098000, v65536) logs [RED] fs mount system data MiiResource: the host has no 0400000000000849 and draws no Mii heads and the boxing mini-game draws no hands/arms, making it unplayable.
  • The player's Miis: the mii service's database. The host answers with the six default Miis only.

This lets a player supply their own console's copies. They are firmware content and personal data, so they stay on the player's Mac and are never part of an app or the repository.

DM_SYSTEM_DIR is one folder of the console's own files, for every game. The Mac launcher sets ~/Library/Application Support/nxnative/system and the iOS app Documents/system:

  • sysdata/<id, 16 hex digits>/: a system data archive's RomFS files. MountSystemData mounts the folder read-only (hle_fs.c sysdata_own), ahead of the existing MiiModel stand-in. Without it nothing changes, and the [RED] line now names the folder to use.
  • save/8000000000000030/MiiDatabase.dat: the mii service's database. hle_mii.c reads it once at Database::Initialize:
    • Layout: 0x1a98 bytes. NFDB, then 100 StoreData of 0x44 bytes, the version (1) at +0x1a94, the count at +0x1a95, and a CRC-16/CCITT (polynomial 0x1021, initial 0) of the bytes before it at +0x1a96, big-endian.
    • Conversion: each StoreData (seven words of bit fields, the nickname and the create ID) becomes the 0x58-byte CharInfo the SDK returns (mii_from_store; the stored eyebrow y is 3 below the CharInfo's).
    • Service answers: Get lists them before the six default Miis (source 0, then 1), GetCount counts them, GetIndex and UpdateLatest find them by create ID, and IsFullDatabase is true at 100.
    • A bad file: another size, magic, version or CRC is logged and leaves the database empty, as before.
    • Read-only: the file is never written, and the Mii editor is still cancelled.

Where the Switch 2 keeps them. I read these from the Switch 2's mii service, system program 0400000000000039:

  • It mounts system save 8000000000000030 as mii (MountSystemSaveData("mii", 0, 0x8000000000000030)) and reads mii:/MiiDatabase.dat.
  • It checks the file's size (0x1a98), magic (0x4244464e), version byte at +0x1a94 and CRC-16 (0x1021) as above. That is the same database as the Switch's.
  • It also keeps mii_migration (system save 8000000100000030, Miis transferred from a Switch) and MiiImage:/database.dat (Mii pictures). This PR reads neither.

The StoreData bit layout is the Switch's, as documented by the open-source Mii implementations. The code here is written from the layout, not taken from them.

Why the Switch's archive cannot stand in. Switch Sports reads ShapeMid.dat / ShapeHigh.dat and OunceTexture{Low,Mid,High}{Linear,SRGB}.dat from MiiResource::

  • Its code also names the Switch MiiModel's four NXTexture* files. It picks the texture file from a table by a flag (main+0x1cdeb50), and its Mii setup (main+0x320040) only ever clears that flag, so it always reads the OunceTexture* files.
  • The host's empty MiiModel stand-in (0100000000000802) cannot take the Switch 2 archive's place either.
  • Without the archive, the setup's size query fails, it mounts nothing, and the game shows no heads.
  • With the files, everything works!

Checked

  • t_mii (new host test, address and undefined-behaviour sanitizers):
    • a database with known fields unpacks into them, including the eyebrow offset, the nickname and the create IDs;
    • a wrong CRC, a short file and version 2 are refused;
    • Initialize, GetCount, Get (the database's Miis first, source 0, then the defaults), GetIndex and UpdateLatest answer from a database in a folder given as DM_SYSTEM_DIR.
  • The whole host suite (make -C dm/host/tests run) passes; the host builds; the launcher and the iOS app compile.
  • test_docs.py, test_env_switches.py and the symptom index pass.
  • The game (M4 Pro, macOS 27.2): with a console's 0400000000000849 (its eight files) and a one-Mii database in place, the log shows fs mount system data MiiResource: 0400000000000849 from … and mii: 1 Miis of the console's database. The Mii is listed first on Select User, and Mii heads draw there, on Customize and in a golf round. That run was on a tree with this change plus the game's other open PRs; the game does not boot on main alone.

Not checked

  • A database dumped from a Switch 2 itself. The one used was in the same format (the service's checks above pass on it), but not from that console.
  • Other games, other system data, and iOS. Any other system data archive goes through the same folder; none was tried, and nothing was run on iOS.
  • Writing. Miis a game adds, or Format / Import, do not reach the file.

The game's profile is in #2107.

…em data archives from sysdata/<id>/, the Miis of MiiDatabase.dat (system save 8000000000000030) listed before the defaults
@github-actions github-actions Bot added host The Horizon host: SVCs, services, threads, memory (dm/host) ios The iPhone and iPad app (dm/ios) mac The Mac front end and app (dm/mac, front_mac.m) docs Documentation labels Nov 11, 2026
FifteenPen added a commit to FifteenPen/nxnative that referenced this pull request Nov 11, 2026
seedds#2273 (black outfits in menus); Miis with seedds#2274 and the player's own files; golf's far ground right with the seedds#2040 series
@FifteenPen

Copy link
Copy Markdown
Contributor Author

Something like this PR is needed forSwitch Sports Resort to be meaningfully playable. Without it, the boxing mode features players with no arms. Stand-in textures could be made and used, potentially!

seedds added a commit that referenced this pull request Nov 13, 2026
…_DIR (PR #2274)

A player can supply their own console's files in one folder for every
game (the Mac launcher sets ~/Library/Application Support/nxnative/system,
the iOS app Documents/system):
- sysdata/<id>/: a system data archive's RomFS files, mounted read-only
  ahead of the MiiModel stand-in (Switch Sports Resort's 0400000000000849
  Mii heads; the Switch's 0100000000000802 alike);
- save/8000000000000030/MiiDatabase.dat: the mii service's database, read
  once and never written; its Miis are listed before the six defaults.

Without them nothing changes. The player guide says where the files go.

Co-authored-by: FifteenPen <354289956+FifteenPen@users.noreply.github.com>
@seedds

seedds commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Landed with changes as 51492a9, with you credited as co-author. Thank you: the design is unchanged (the player's own system data and Mii database in DM_SYSTEM_DIR, mounted ahead of the empty stand-in, the database only read).

What changed on the way in:

  • It was rebased onto main. The only conflict was in the Mac launcher, where DM_SYSTEM_DIR now sits beside the other folders the launcher sets.
  • docs/playing.md has a new "Miis and console files" section, telling players where the files go on the Mac and on iOS.
  • Switch Sports Resort's note (the game has a profile on main now) links the reference entry. Mario Kart 8 Deluxe's open item about Mii heads now names the player's files.

The next commit, 2812675, builds on yours for #2361:

  • AppendMii adds the default Mii after the console's. Miis it makes are kept in a file of the host's own, <DM_SYSTEM_DIR>/host/MiiDatabase.dat, so the player's console file is still never written.
  • Without DM_SYSTEM_DIR, the folder is now $DM_ROOT/run/platform/system.

Your path with real console files wasn't run here, because I have none, so it rests on your Switch Sports Resort run and t_mii.

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

Labels

docs Documentation host The Horizon host: SVCs, services, threads, memory (dm/host) ios The iPhone and iPad app (dm/ios) mac The Mac front end and app (dm/mac, front_mac.m)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants