Status: stage 1 + stage 2a + stages 2b1–2b4 + initial 3a/3b/FS (7)

When none of the three ways is there, the 3DS device does not start, and its error gives all three reasons (which call refused which region, the VkResult), then the device and driver. The CPU side, the AOT modules and the settings still run; the game ends at its first GX command that needs the GPU (a command list, fill, display transfer or texture copy), with that error as the run's last line. A --frames N run with N above 0 ends at its start instead, saying that the frame limit needs a Vulkan presenter. 3ds_vk_ram checks the RAM on whatever device imports it or holds it as its own memory (a device that keeps a copy skips it, its buffer not being the guest's): what the guest wrote reaches the GPU, a GPU fill shows in every guest view, a store through the flat space reaches the GPU, and the RAM outlives the device; 3ds_memory_adopt checks the move with a memfd standing in for the dma-buf, on every host.

Audio runs on a high-level DSP (src/3ds/audio/, ported from Azahar's HLE audio core): dsp::DSP (services/dsp.c) takes the application's pipe writes, interrupt events, the semaphore and component loads. Initialize answers on the audio pipe with the DSP RAM addresses of the shared structures, and from then on every 160-sample frame (4.889 ms, paced by the host clock like the vblank) reads the region the application finished, plays the 24 sources' buffers out of FCRAM (PCM8, PCM16 and GC-ADPCM; no interpolation or linear, polyphase playing as linear as in Azahar), applies their simple and biquad filters and gain ramps, mixes the three intermediate mixes with the aux buses and delay effects, writes the statuses and final samples into the other region and raises the audio pipe's interrupt. Reverb, the limiter, the compressor and surround output are stubs in Azahar too. The binary pipe decodes AAC requests with FFmpeg. Frames play on the default device through SDL3, at the Switch's volume (--volume=N, 0 to 100 percent of the game's sound, which the launcher's Settings > Audio > Volume passes), and their first two minutes are recorded to <output>/audio.wav as the game makes them. libctru's ndsp loads sdmc:/3ds/dspfirm.cdc and leaves audio off without it, so a stand-in header goes there when the title's SD has none: the HLE DSP never runs the component, and a dumped file is used as it is. cfg:u, cfg:s and cfg:i (services/cfg.c) answer GetConfig for the sound output mode (stereo, Azahar's default), which ndsp reads, and stop on any other block.

See CTR IPC for the strict generator subset, descriptor/permission checks, quotas, malformed-request policy, tests and unimplemented operations. Unknown SVCs still stop explicitly. No service or device success is fabricated, except for unknown commands and services, which answer success as a Switch game's do unless --ctr-auto-stub-ipc=0 asks for the console's answers.

By default nothing of the game is extracted. scarletnx-3ds game maps the game read-only and checks it as the extraction would where it reads it (a CIA's content table, the NCCH and ExHeader hashes, the RomFS superblock and its metadata). A launch that reads the game where it lies skips the SHA-256 of each content and of each ExeFS file; an extraction checks those too. The game's ExeFS files and its RomFS (level 3, the image the game reads) are then read where they lie in the mapping, and only the decompressed .code is copied into memory. The game's folder keeps its module, its copy of the runtime, the DLLs beside that copy on Windows, its icon (icon.rgba) and its state alone: sdmc/ and the frames and audio it writes. An extraction an earlier --extract-container left there is taken away, its compiled module and saves kept. The image's identity is the same either way, so a module compiled in one mode loads in the other. The manifest records which container the game came from (container=, and overlay=1 when it is a cartridge's update), which the image loader ignores.

--extract-container (the launcher's Extract dump) extracts the game into its folder first and plays from the extraction, as before. -x extracts only:

build/3ds/scarletnx-3ds -x --output work/my-title game.cia

The output is a directory containing contents/*.app, exefs/ (with expanded/page-padded .code), romfs/, raw container/NCCH/ExHeader metadata and manifest.ini with source/code hashes and segment layout (a CIA's contents/ and container metadata; a cartridge image's, a bare NCCH's and a bundle's without them, a bundle's game read from its entry). The default directory is the game's folder, recompiled/<title ID>, in the data folder the Switch driver uses (--data DIR, else a portable copy's folder, else the user's data folder, from a build tree too). On Linux the user's data folder keeps work/ (the decrypted CIAs) in ~/.cache/scarletnx/work/3ds/. No source game needs to be mounted by the future guest FS. Extraction is privately staged, then published only after all checks succeed, and a failure removes the staging files. As in the Switch driver, a folder already at the output path is taken as a finished extraction and used as it is, never extracted again or hashed. Keep the input and output parent trusted and not concurrently modified; extraction is not a sandbox against hostile host processes racing parent directory changes.

-x/--extract stops after extraction and -r/--recompile compiles without playing, as the Switch driver's do. Otherwise the driver loads <title ID>_code.so and compiles it first only when needed: when it is missing, or no longer loads or matches the build's module ABI or the extracted image's identity (a changed .code). -r always compiles again. A new module replaces the old one only once it is complete, by a rename over it; the objects it was linked from stay in memory. A failed compile leaves the old module and the extracted tree. Once the module is ready the driver copies itself into the folder as the game's runtime, unless the copy there is the same program. The GUI uses this same driver path, not a separate engine.

The software keyboard (src/3ds/services/swkbd.c) and the Mii selector (src/3ds/services/mii_selector.c) are the library applets the runtime plays, in the applets' place as Azahar's HLE ones do. A game that asks for a text through the keyboard (a name, a password) is answered at once, with no box over the game to ask the player in: swkbd_text when it is set, else the game's own initial text, else the console's user name (the user's nickname, Player without one), cut to the game's most characters and checked against its input rule and filters. A text that breaks one is answered with Cancel where the keyboard has one. A game that checks the text itself (the callback filter) gets it first, and its answer closes the keyboard or lets the text through. The log says what was answered and why (3ds swkbd: ...), with the user name's length in place of the name. APT answers each step a game takes: PrepareToStartLibraryApplet, PreloadLibraryApplet, IsRegistered, the Request for the capture block and its Response, StartLibraryApplet, the NotifyToWait before the wakeup, and the WakeupByExit the game wakes with, which carries the answer. GetAppletInfo answers a slot's title, media type and attributes, and whether it is registered and loaded. Any other library applet (the error display, say) is one the runtime does not have: preparing it, or preloading it, answers as an unknown command does.

A game that has the player pick a Mii through the Mii selector (its StreetPass Mii, say) gets ScarletNX's own Mii at once, as a Mii of the console's database, as Azahar's default selector answers with its standard Mii: Baguette, a girl with red curled twin tails, made of her own fields in the 3DS's Mii format, no console's Mii; her author is the console's user name. The game's configuration (its title, Cancel, the Guest Miis) is in the log (3ds mii selector: ...); the answer is the same whatever it asks.

A launch runs until the game exits or its window is closed, as a Switch game does. --max-blocks N stops it after N native blocks instead. A larger-image block may execute up to 32 instructions, so this is not a cycle or exact instruction budget. Each instruction still checks fetch, identity and permissions. --model old|new selects RAM backing, not a different ISA or compiler. Without it, or --ctr-model= on the command line, a game runs on the console its own Settings pick (ctr_model= in <title ID>.picks beside its .ini), then on the launcher's for every game (--ctr-model= with --launcher-picks=1), then on the one its .ini names (model=), and on its first run on the one it asks for: a New 3DS when its SMDH marks it New 3DS exclusive (the flags at 0x2028, bit 12, which the Home Menu refuses on an Old 3DS) or its ExHeader names the New 3DS's 178 MiB system mode (0x20D, mode 2), which only a New 3DS has; an Old 3DS otherwise, as a title that names the 124 MiB New 3DS mode runs on both. The run says so, and the .ini keeps the choice, not the game's own pick. --board-info prints physical regions without allocating RAM. --ipc-stubs L, with --ctr-auto-stub-ipc=0, still answers the unknown commands of the services in L (all, or a comma list of srv, fs, apt, ptm, hid, gsp, cfg, dsp, system, am, y2r, ldr, ir, irrst, mic, cam, csnd) with success instead of stopping. Given more than once, the lists add up. It only changes a run, so it is refused with --board-info, -x and -r. --icon --out DIR writes the game's SMDH icon as RGBA into DIR (icon.rgba, what the launcher draws a dump's row by), with -x and --data as the launcher asks for it, and nothing else. An encrypted game is decrypted first, into work/3ds, as a run of it is. Guest ExitProcess: r0=... prints a register diagnostic, not a POSIX guest exit status. When the last thread ends with ExitThread the driver prints Guest's last thread exited instead. Exit codes:


Made from docs/platforms/3ds/README.md at 69237645142c. GPL-3.0-or-later.