mirror of
https://github.com/seedds/nxnative.git
synced 2026-11-23 11:39:42 -10:00
hle_cheats.c loads the running build's <build ID>.txt from DM_CHEATS (default <DM_ROOT>/cheats, flat or the atmosphere/contents tree) and runs the dmnt cheat VM, opcodes 0-C4 as Atmosphère 1.12.1 runs them (docs/reference/cheats.md says where the host differs), once per presented frame and from a ~60 Hz thread while the game is not presenting. On top of the plain format: labels and EdiZon sections, on / off pairs as one switch, per-build toggles (<build ID>.enabled), typed values, run-once cheats, a dry run, a master switch and, on the Mac, safe mode after an unclean exit. The Mac window gets a Cheats menu and a floating Cheats panel (⌘⇧C) that never takes the keyboard from the game. scripts/cheat_anchor.py imports a cheat file into a version-independent source anchored to the game's code and data and compiles it for any build. docs/frontends.md has the files as the contract for front ends. Changes to the pull request: - Cheats never write over the rewriter's work. patch_nso.py writes <name>.changed.tsv: the text words it changed (sites, cuts, lock acquires, jump tables) and those whose copies run instead (windows, spin waits); Mac apps carry it. A code write that covers one turns the cheat off with the reason: the Switch's original word there (an "X - off" restore, most often) would run an SVC or a TLS read natively or undo an ldaxr, and a write into a copied instruction never runs. Without the list (an older rewriter's modules) no code write is allowed. Writes past the game's own image (the key page, the frame step page, the patch areas) are refused too. - No thread without cheats: the ~60 Hz apply thread starts with the first file that has a cheat in it, not for every game. - No code writes without the writable alias of main. On the iPhone the code pages are the app's signed pages, and toggling the game's own pages writable on the Mac races with its cores, so the mprotect fallback is gone: the iPhone runs data cheats only. t_cheats covers the refusals (143 checks, also under ASan and UBSan). The clang-tidy findings the new files brought are fixed (a realloc that lost its buffer, a shift by 64 on an untyped value, three nils handed to AppKit, the test's unchecked lookups) or marked: file loads under the cheats lock, which the per-frame pass only trylocks. Regression (normal reach, 3 games), check againstfe6d3dfa: - Super Mario Bros. Wonder: PASS (16268/16268 shaders, fps 59.4 → 59.6, no new RED). - Tears of the Kingdom: the first run never presented. Its window resigned key before the first frame and the game suspended on the out-of-focus notification, as on a Switch. A second run booted (first frame 7.9 s, fps 34.5 → 46.5, p99 51.6 → 17.9 ms, 28669/28669 shaders); only its 90 s screenshot was missing, after a late focus loss. - Breath of the Wild: frame p99 17.5 → 33.4 ms in 3 of 3 runs (fps 60.0 → 58.5, 19592/19592 shaders, no new RED). This baseline's 17.5 ms is the outlier: BotW's other checks today measured 32.8 to 33.5 ms on both sides (e513bfeb,195986fa). Without a cheats file the host's only new per-frame work is a timestamp and a flag check. Co-authored-by: Amost <[email protected]>
2.7 KiB
2.7 KiB
Subsystem references
How the host meets each part of a Switch game, and every failure met so far, one entry per mechanism: symptom, cause, fix (file and function), the games it was found on (linked to their notes in dm/games/<id>/README.md). Start from the symptom index when you have a log line or a visible result; the workflows that lead here are in docs/agents.
| File | Covers |
|---|---|
| packing.md | NSP script, compressed inputs and build artifacts |
| rewriter.md | The NSO rewriter patch_nso.py: jump tables, exclusive windows, patch area reach, cuts and observation gates (and cheats carried across builds with the same matcher), functions without unwind entries, stack and system registers, relocations |
| memory.md | Guest layout, heap and application pool, virtual address memory and the alias region (the SDK's node area), engine allocators, mapping SVCs, running out of memory |
| threads.md | Thread creation and cores, address arbitration, yields and spin waits, events |
| services.md | SDK calls and system services: sm connections, names that changed between SDKs, file system and saves, add-on content, input, keyboard and applets, display and operation mode, accounts and network, settings and fonts, C library and time, modules |
| movies.md | The SDK's movie library: decoder lifecycle, output slots, native-texture output, demuxers and codecs, game movie players |
| audio.md | The audio renderer and its command lists by SDK, AudioOut and devices, codecs, timing |
| frame-rate.md | The host's frame step, engine frame limiters, present intervals and display rates, CPU cost |
| nvn-objects.md | NVN object sizes, memory pools, command memory, queues and syncs, CPU-written textures, NVN entry points |
| rendering.md | The replay on Metal: textures, passes and clears, blend / depth / stencil, vertex input, uniforms and ordering, conditional rendering; the Vulkan and OpenGL layers |
| shaders.md | Shader containers by engine, control sections and code, translation, bindings and handles, shaders compiled at run time, pipelines and caches |
| cheats.md | How cheats work on a Switch with Atmosphère (dmnt, the file, the VM, its behaviour on failure) and where this host differs |
| game-state.md | Saves, scripted state, and game behaviour that looks like a host bug but is not |
A new general finding goes into the file and section it belongs to, in the same form, with a line in the symptom index; a fact about one game goes into that game's note.