1315 Commits
Author SHA1 Message Date
ipavlin98 68078948f5 With sync_ahead an invalidate of pool storage waits for the GPU write of a value the game was told is done when the range holds no older result, so the pixels TotK reads back once through a buffer per request are no longer zeros or an answer from the ring's last round, which in the Depths put Link in gloom on clean ground; buffers the game reads every frame still get the result of the frame before without a wait 2026-11-18 00:21:46 +03:00
ipavlin98 fd08b5cee3 DLSS is created without auto exposure, so large distant blocks behind the fog in the Depths no longer turn darker or lighter for a frame while the camera moves 2026-11-18 00:21:25 +03:00
Valiantsin DzerakhandClaude Opus 5.5 6b0974f08d Merge pull request #1188: opt-in quick save and quick load on rebindable keys with no menu on the screen, game 1.4.3 (itaskaev2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:17:57 +03:00
Valiantsin DzerakhandClaude Opus 5.5 52d913c7e0 Quick save takes its request back with an atomic and, and the no-quick-save note names the key by its role, as it can be rebound (#1188)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:17:57 +03:00
Valiantsin DzerakhandClaude Opus 5.5 358b7916d8 Merge task/hud: hud_width keeps the HUD within the middle 21:9 or 16:9 of a wide screen, from pull request #1262 (Marjaperse, ProSep, #643)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:15:16 +03:00
Valiantsin DzerakhandClaude Opus 5.5 7e2712e87e Quick save logs once that it is 1.4.3 only on other game versions, and a quick load under way goes on while the settings menu opens, so the held picture always ends (#1188)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:15:04 +03:00
Valiantsin DzerakhandClaude Opus 5.5 96afa531c9 Merge pull request #1131: with frame-ahead on, fence write-backs no longer wait for the GPU about every ninth frame (ProSep)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:13:01 +03:00
Valiantsin DzerakhandClaude Opus 5.5 6efa75f3dd romfs_shapes_check.py links its harness with lld, which MSYS2 UCRT64 Clang needs for LTO objects
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:12:56 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c781238d6d The Shapes step keeps its old key when it writes no capped HUD folder, so an install with hud_width full does not prepare its shaped folders again (#643)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:12:56 +03:00
Valiantsin DzerakhandClaude Opus 5.5 64e965078c wb_eager moves to the diagnostics settings and out of totk.ini.example, as part of sync_ahead
It acts only with sync_ahead in effect and is on by default there, so a player who turns on sync_ahead gets it; 0 and check stay for comparing. docs/settings.md keeps the row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:12:19 +03:00
Valiantsin DzerakhandClaude Opus 5.5 8232ac4505 The exit log counts the fence write-backs that waited for the GPU and their time with frame-ahead on
The new line is written for wb_eager 0, 1 and check alike, so the stall wb_eager removes can be compared between the settings. It costs a clock read only on the blocking path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:12:18 +03:00
Valiantsin DzerakhandClaude Opus 5.5 f801169e1c Merge pull request #1188: opt-in quick save and quick load with no menu on the screen (itaskaev2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:07:20 +03:00
Valiantsin DzerakhandClaude Opus 5.5 1974b671be Merge pull request #1263: with DLAA, fog and particles can be drawn over the smoothed picture, so dust in shrine fog no longer vanishes; off by default until checked on NVIDIA (ipavlin98)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:07:08 +03:00
Valiantsin DzerakhandClaude Opus 5.5 a702c33f91 dlaa_effects_after is off by default until the inventory preview, the scope and water edges are checked on NVIDIA
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:06:49 +03:00
Valiantsin Dzerakh 006c186928 Merge pull request #1262 into task/hud: hud_width keeps the HUD narrower than a wide screen on the Shapes step (Marjaperse, ProSep) 2026-11-17 20:06:17 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c76a38852e The DLAA effects switch sits with the other DLSS settings and is read only while DLSS runs
dlaa_effects_after moves to the Screen tab under the DLSS rows, to [display] in totk.ini and totk.ini.example next
to dlss_char_mask, and vk_dlaa_frame reads it after the dl_active check, so a game without DLSS does no new work
per frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:05:44 +03:00
ProSepandClaude Sonnet 5.5 3b2bd1f6ba Stop fence write-backs from stalling the game behind the GPU with frame-ahead on
With sync_ahead on, the fence write-back of small GPU-drawn targets that the game reads back still blocked the game thread behind the running frame, about every ninth frame. wb_eager copies those targets into staging at the end of the submission that rendered them, so the write-back at the fence wait needs no GPU wait.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 20:05:15 +03:00
Valiantsin DzerakhandClaude Opus 5.5 a36e7917da Merge task/cascade: shadow_range moves the sun cascades on 1.2.1 and 1.4.3, from pull requests #1258 and #1254 (shinodanpen, #606)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:03:05 +03:00
Valiantsin DzerakhandClaude Opus 5.5 f53b86c61d Merge pull request #1253: sync_ahead works on game 1.1.0, and game-time scripts find the player there (Marjaperse)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:01:26 +03:00
Valiantsin DzerakhandClaude Opus 5.5 1ccefb46f2 Merge pull request #1252: the dynamic resolution switch holds the full scene size on game 1.1.0 (Marjaperse)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:01:25 +03:00
Valiantsin DzerakhandClaude Opus 5.5 e031ac596a Merge dev into task/pr1263
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:59:52 +03:00
Valiantsin DzerakhandClaude Opus 5.5 4613d9b458 res_shadow_range's comment names both cascade tables and the controller's boundaries they scale (#606)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:58:02 +03:00
Valiantsin DzerakhandClaude Opus 5.5 1cc47c7768 Merge pull request #1255: the field-of-view setting works on game 1.2.1 (shinodanpen)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:57:54 +03:00
Valiantsin DzerakhandClaude Opus 5.5 bd8c5d637f Merge task/objreuse: a private build compiles only the generated chunks that differ from the main build, so a private lift of a patch builds in seconds
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:38:43 +03:00
Valiantsin DzerakhandClaude Opus 5.5 2b95408642 A private build reuses each main build object whose compile is provably the same, also for a private lift in another generated dir
build_game.py used to reuse build/<ver>'s generated objects only as a whole and only for generated/<ver>, so a private
lift of a patch change (gen.py --out generated/<ver>-prN, build_game.py --gen) compiled all 421 chunks, about 5 min on
12 jobs, for one changed chunk. main_objects now decides per object: same compiler, flags and rule in the main
build.ninja (with the main runtime/ and generated dir in place of ours), main build up to date, and every file the main
compile read according to its Ninja deps log byte-identical on our side and unchanged since the object was written
(NTFS ChangeTime, st_ctime elsewhere), the compiler binaries too. A file new on our side whose name those compiles
included or probed blocks the reuse. Anything unknown compiles. The build prints "reused N of M generated objects",
--verbose lists the rest with the reason; obj/reused.txt lets a later build delete a copied object before compiling it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:37:43 +03:00
shinodanpenandClaude 13819ab6d8 Add the field-of-view setting for 1.2.1
recomp/patches-v121.txt gets set fov on the two camera routines the aspect set already patches, at the load of the
camera's vertical view angle (+0x13c): camera update main+0xcb4ad8, camera setup main+0x1252194. The update site matches
1.4.3's instruction for instruction around the load; the setup site copies the camera's fields with other instructions
and registers before it and matches 1.4.3's from the load on. Both call sinf, cosf and tanf in the same order as on
1.4.3. Each version fills sead's perspective projection this way in ten places, each with its counterpart in the other
version: these two camera copies, which are the only places 1.4.3 patches, and eight others (inlined copies, projection
routines and four projections on the stack), none patched. The replacement words are those of the 1.1.0 and 1.4.3 sets
(x10 kept on the stack, s8 overwritten by the next instruction), so no register liveness is assumed. #621 (ipavlin98,
closed by its author) chose the same two sites with x8 and s2 as scratch registers.

The setting's text in totk.ini.example and in the four menu languages names 1.2.1, and the comment of
runtime/resolution.c res_fov_live names the patch files of all three versions.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-17 19:29:43 +03:00
Valiantsin Dzerakh 5b99256cd3 Merge pull request #1254: shadow_range moves the sun cascades on 1.2.1 (shinodanpen, #606) 2026-11-17 19:27:41 +03:00
Valiantsin Dzerakh 8125431676 Merge pull request #1258: shadow_range moves the sun cascades on 1.4.3 (shinodanpen, #606) 2026-11-17 19:27:40 +03:00
Valiantsin DzerakhandClaude Opus 5.5 3afebbfdae Merge pull request #1256: the audio thread takes every queued sound command list, so the sound stays on above 200 fps (shinodanpen, #337)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:26:10 +03:00
shinodanpenandClaude 037a39d303 The sound engine's audio thread takes every queued command list, so the game keeps its sound above 200 fps (#337)
The game thread hands its sound commands to the audio thread in lists: 16, of which 4 are always held, so at most 12
wait in the command ring. The game thread submits at most one per update (1.2.1 main+0x9bd144), the audio thread
takes one per 5 ms audio frame (after a list, main+0x883780 goes on past the ring's check). Above about 200 updates a
second the ring stays full. The game's guard (main+0x9bcdc4) counts the updates that find the ring of free lists
empty and exactly 12 lists in the command ring (0x9bce1c cmp w9, #0xc); the count returns to 0 only when a free list
is there. At every multiple of 300 (10 s at 30 fps, 1.25 s at 240) it clears the sound command switch
(main+0x2268bfc) and stops every active voice (main+0x226f29c). Only the switch's constructor sets it to 1
(main+0xf31ce8, from the engine's init main+0xf31530), so the game is silent until it is restarted.

Measured on 1.2.1 (Linux, RX 6750 XT), same save and scripted input, mix dumped without a device: with fps_limit 60,
144, 180, 200 and 201 the mix has sound; with 205, 210, 220, 230, 239 and 240 it goes silent after the boot logo and
stays silent, also at the 130-148 fps of the scene that follows. The guard is read from the code; the switch going
to 0 has not been observed in a run.

The set audiodrain (TOTK_AUDIO_DRAIN_FIX, audio_drain_fix, on by default) sends the audio thread back to the ring's
check after each list, so it takes every queued list in the pass: one site per version (1.2.1 main+0x883780, 1.4.3
main+0x149244), each going to a target the game's own code already branches to in the same way (1.2.1 main+0x883c18,
1.4.3 main+0x149700). The setting is in runtime/cfg.c, totk.ini.example and docs/settings.md.

At fps_limit 240, 120 s runs of one build per game version with the set switched, seconds with sound in the mix: on
1.2.1 5 of 118 with the set off and 108 of 118 with it on; on 1.4.3 2 of 118 off and 110 of 119 on. Not run:
Windows. Not covered: 1.1.0, whose main we do not have, so its table has no site and it keeps the game's code.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-17 18:56:55 +03:00
Valiantsin DzerakhandClaude Opus 5.5 a5c3e0f9f5 A game with a mod plugin no longer stops at start: plugin_trace has its row in the settings table (#845)
plugin_init.c reads TOTK_PLUGIN_TRACE through cfg_bool, which stops the game when the key is unset and metas[] has no
row. Every test run set the key, so only a plain start hit it. tests/settings_doc_check.py now fails on any
cfg_value/cfg_int/cfg_double/cfg_bool reading without a metas[] row that is not guarded by cfg_get of the same key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 12:49:27 +03:00
Valiantsin DzerakhandClaude Opus 5.5 4957dc78e3 Merge task/buildkit: the setup installs a build kit into the game folder, so code mods rebuild without the setup folder and after a move (#845)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 12:04:35 +03:00
Valiantsin DzerakhandClaude Opus 5.5 e7c901b864 The setup's builds name every path relative to the build kit, so a moved game folder rebuilds incrementally (#845)
tools/build_game.py --portable writes build.ninja paths on the tools' drive relative to the kit, also through '..'
(the generated C and objects in build-cache/work), names the compiler, windres and ar the same way (backslashes:
CreateProcess does not find a relative program with forward slashes), and passes clang -resource-dir and --sysroot
relative to the kit, because clang names its own headers by its absolute folder whatever argv[0] says. The Ninja deps
log then holds no absolute path. installer/steps.py build_args passes --portable for the build kit.

Measured on an install moved after a portable build: the rebuild compiled modules.c only, 3.5 s; before, the move cost
a full compile of 430 objects (335 s on 12 cores). Without --portable build.ninja is byte-identical to before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 11:57:12 +03:00
Valiantsin DzerakhandClaude Opus 5.5 8c9c18a6d2 A kit whose replacement fails is put back, so the game keeps a build kit; docs rewrapped to 120 columns (#845)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 11:06:32 +03:00
Valiantsin DzerakhandClaude Opus 5.5 501f0d3e6f The setup installs a build kit into the game folder, and the game's rebuild for code mods runs from it (#845)
The rebuild for ExeFS patches, code cheats and mod plugins ran the setup window from the setup folder, whose absolute
path build-cache/rebuild.txt held, with the generated C and objects in that folder's temp/. A moved or deleted setup
folder left code mods without a rebuild.

- A new Kit step after the check copies the release folder without TotK-Setup.exe into <game>/build-kit
  (installer/layout.py KIT_ITEMS), and every later step runs its tools from there. A newer setup replaces the kit,
  the kit's own rebuild keeps it.
- The release's temp folder is <game>/build-cache/work, so the lift cache and the objects stay with the game.
- rebuild.txt names the kit relative to the game folder; runtime/cheats.c and runtime/romfs.c resolve relative
  entries against the exe's folder.
- runtime_key drops the lines of clang --version that name its folder, so a rebuild from the kit or a moved game
  folder keeps the compile and prepare steps the setup recorded.
- An update over an install of an older setup moves that setup's temp folder into build-cache/work when both are on
  one disk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:54:17 +03:00
Valiantsin DzerakhandClaude Opus 5.5 d33d8d2e2f Merge task/plugins2: each mod plugin is built or refused on its own, and the release builds plugins in on a player's install (#845)
Per-plugin service runs (a refused, crashed or hung plugin costs only itself) and four fixes the real setup path
needed: plugin_init.c compiled per install, the service run's DLLs beside its exe, module tables sized for plugins in
the runtime library, and a failed plugin stage rerun after a fixed release. Checked with a release install: The
Second Quest built in and played with 7 hooks on, and removed again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:37:03 +03:00
Valiantsin DzerakhandClaude Opus 5.5 791e077c54 docs/mods.md: removing a plugin mod starts the rebuild without it (#845)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:36:10 +03:00
Valiantsin DzerakhandClaude Opus 5.5 aa184f9fd2 A mod plugin the build has whose file is gone starts the rebuild, which goes back to a build without it (#845)
Removing a plugin mod left its module in the layout: the loader skipped the missing file and the game ran, but the
rebuild that drops the plugin never came. The loader counts layout plugins whose file no longer exists
(ldr_plugins_gone) and rebuild_if_needed treats them like files waiting for the rebuild. A changed file was already
pending through its mod's status line. On the 1.4.3 install: The Second Quest removed, the start asked for the
rebuild, the setup lifted and compiled the no-plugin build in 30.5 s, the game reached gameplay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:35:49 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c477b67a09 The runtime library's module tables hold 32 modules, not the release's MOD_COUNT: an install's plugins fit (#845)
loader.c and memory.c sized their tables by MOD_COUNT of the layout.h make_release.py built libtotkrt.a against (3:
main, subsdk0, sdk). An install whose rebuild adds a plugin has 4, and its service run stopped at once with "loader: 4
modules in the layout"; dev builds compile those files against their own layout and never saw it. RT_MAX_MODULES
(host.h) is the bound now; the loader still refuses a layout above it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:35:49 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c97ceb6451 A plugin stage that failed runs again once a release changes the installer: steps.py is in the lift key with plugins (#845)
After warn.plugins_skipped the lift key still matched its inputs, so the next setup run (with the fixed release) found
lift and compile current and never built the plugin. installer/steps.py runs that stage, so it joins the key when the
mods hold a plugin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:35:32 +03:00
Valiantsin DzerakhandClaude Opus 5.5 81c004094d The installer's plugin service run finds its DLLs: they go beside the totk.exe it builds in temp (#845)
On the release path the service run's totk.exe in <temp>/build stopped before main with 0xc0000135 (SDL3.dll not
found): the DLLs are copied next to totk.exe in the install folder only by the compile step, after the lift. Every
plugin was skipped with warn.plugins_skipped. The fake-tool tests did not see it; installer_test now checks the copy.
exefs_plugins_test covers run()'s hang and crash reasons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:52:37 +03:00
ipavlin98 40c0071dd2 With DLAA, DLSS runs before the fog and the particles, which are drawn over its picture without jitter, so the dust in shrine fog no longer vanishes
DLSS ran at the bloom, after the volumetric fog composite and the particle pass. Neither has motion vectors or jitter
of its own, and DLSS wiped out the smallest motes. In DLAA mode DLSS now runs right after the deferred lighting: the
light target is the G-buffer's scene colour target, the lighting is the first pass into it after the G-buffer, with
a D16 depth, and the first pass into it with any other depth (the scene's, none, or the D16 of an ability's highlight)
is an effect. The order of the effects changes from frame to frame (the yard's half-size effects pass is in some
frames only; with Ultrahand or Ascend open the highlight comes before or after the fog layer), and rules that waited
for one of them, or took any D16 pass for the lighting, flickered. As a safety net the point is used only after it
held for 60 frames with nothing of the scene drawn after it; otherwise DLSS stays at the bloom.

dlaa_effects_after (Advanced tab, Render fixes, default 1, live) turns it off. The upscaling DLSS modes are unchanged.
2026-11-17 09:41:08 +03:00
Valiantsin DzerakhandClaude Opus 5.5 77f34a05f5 A plugin build whose plugins all stay off gives the game its own QueryMemory back (#845)
plugins_start returned before clearing mem_query_hook and rt_process_memory when no plugin's set was on (the mod off,
removed, or its file changed), so the game ran with the service run's view of memory: host ranges Inaccessible, the
rtld stand-in below main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:33:49 +03:00
Valiantsin DzerakhandClaude Opus 5.5 b9b8f3dce1 Each mod plugin is built or refused on its own: one that is refused, crashes or hangs costs only itself (#845)
tools/exefs_plugins.py ran every plugin's init in one service run and refused them all when one was refused. Now a run
without inits lists the plugin modules, then each plugin runs in service runs of its own (TOTK_PLUGIN_ONLY, the others
stay loaded): a refused svc, a crash (the FATAL line is the reason), a timeout or a failed check refuses that plugin
alone, with its reason in plugins.status; the rest are built in. 4 plugins take 2.3 s.

At start, plugins_start compares each plugin right after its own init and takes its branches out of main's .text before
the next one, so each init sees the game's bytes, as in its service run. Only that init's aliases are flushed: the
start stays at 113 ms for Full Inventory Expansion + Quick Weapon Durability (107 ms before).

The installer's second lift keeps every plugin of the service runs in the layout when one is built: the records hold
that layout's addresses. A refused plugin stays loaded and never starts. A mod with a built plugin and a refused one,
used without its code, runs the built one (mods.c; --probe-mods case T).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:25:24 +03:00
Valiantsin DzerakhandClaude Opus 5.5 152b00494b The release compiles plugin_init.c per install: it reads the install's plugin records from patches.h (#845)
make_release.py stopped at the runtime library: plugin_init.c includes patches.h, a per-version header, so the library
build refused it. Built per install like patches.c, it sees the RT_PLUGINS and RT_PLUGIN_WRITES of the install's own
rebuild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:25:15 +03:00
Valiantsin DzerakhandClaude Opus 5.5 aea4c0c5b3 Merge task/plugins: mod code plugins (exlaunch) run in the game, their hooks ranked by the Mods tab order (#845, #790, #1249)
After the design in #845 by itaskaev2, with the plugin's init run natively on our kernel instead of under Unicorn:
the rebuild runs it in a service run and generates its hook sites (inline, replace, call-site), and every start
runs it again and turns its hooks on when it writes what the build recorded. Checked in game with The Second Quest
(MSFix, 1.4.3), Full Inventory Expansion and Quick Weapon Durability (1.2.1). Without plugins the generated C, the
layout and the boot order are byte-identical to dev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:02:00 +03:00
Valiantsin DzerakhandClaude Opus 5.5 8cee1afe5d The rebuild builds mod plugins in: service run, checks, patch sets and status lines (#845)
After the design in #845 by itaskaev2. tools/exefs_plugins.py writes an accepted plugin's patch set
(recomp/patches.py plugin lines and hook sites, one ordered set mod_<hash> per plugin, several plugins
in one record told apart by their hooks) and a line per plugin of build-cache/plugins.status: built, or
refused with the first reason. It also checks the code the hooks reach (direct branches and calls from
the stubs, impls, callbacks and targets): no svc but OutputDebugString, imports only from a reviewed
list. The init's imports may now include malloc, free, memcpy, memmove and memset, because the init runs
again at every start and its heap blocks exist while the game runs.

The setup's lift step runs the plugin stage when a mod has exefs/subsdk*: a lift with the plugins, a
totk.exe of it in the compile step's folder, the service run, then the lift with the hook sites; a failed
stage warns (warn.plugins_skipped) and installs without the plugins. docs/mods.md describes what works,
what is refused and why, and the rebuild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 08:48:31 +03:00
Valiantsin DzerakhandClaude Opus 5.5 d865000929 A mod plugin's init runs at every start and its hooks go on when it writes what the build recorded (#845)
After the design in #845 by itaskaev2, with one change: no image taken after a build-time run. When a
plugin's patch set is on, sdk's DT_INIT runs first, then the plugin's, in the environment of the service
run (rtld image below main, the QueryMemory view, the alias pool, process-memory aliases), then the game's
constructors. That is rtld's order on the Switch (oss-rtld, librtld/source/ld.cpp __rtld_modules_init
runs the modules from the last loaded to the first). sdk's first DT_INIT only registers it with its musl
and main's DT_INIT finishes it, so its flag stays 1 and it is not called a second time. The plugin keeps
its heap blocks, GOT and alias addresses.

The words the init wrote into the game modules and the plugin's .text after it are compared with
patches.h: equal, the set stays on; different, it goes off for this run, the reason is logged, the Mods
tab row says so and build-cache/plugins.stale has the next start run the rebuild. The branches written
into main's .text are taken back. mods.c reads build-cache/plugins.status: a built plugin's set joins its
mod's sets and the Mods tab order, a refused one keeps its mod off with the reason (the catalog texts in
en, ru, pt-BR, zh-Hans), a plugin without a line waits for the rebuild. A plugin file changed after the
build is left out by the loader. TOTK_PLUGIN_TRACE=1 logs the first call of each hook entry.

Without a plugin in the build nothing of this runs. --probe-mods covers a plugin set against another mod's
patch on one site, a refused plugin, one the build lacks and one whose start differs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 08:48:23 +03:00
Valiantsin DzerakhandClaude Opus 5.5 db6d548ba2 The generator lifts a mod plugin's hook sites: a call into its stub, its replace target and its call-site rewrite (#845)
After the design in #845 by itaskaev2. New patch lines carry an exlaunch plugin whose init runs at every
start: `plugin` lifts the module from its image after the init (the hook stubs and trampolines the file
has as zeros) and names the hash of that .text, `expect` lists the words the init writes into the game,
`stub` lifts an inline-hook stub's branch to its trampoline as a return, `seed` adds the callbacks, impls
and targets, and `orig` lists an unpatched copy of a hooked main function (fo_<address>) at the replace
hook's trampoline address in the plugin's function table, so the plugin's call of the original does not
reach the hook again and rt_dispatch stays as it is.

A replacement word @call:<module>+<offset> calls the stub without writing x30, with every register in
the Cpu before it and read back after it; the site's own instruction runs after it in place. patches.h
gets RT_PLUGINS, RT_PLUGIN_WRITES and RT_PLUGIN_ROOTS for the runtime. Without plugin lines the output is
byte-identical to dev (generated C, patches.h and layout of 1.2.1 and 1.4.3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 08:48:14 +03:00
Valiantsin DzerakhandClaude Opus 5.5 b2b85c05fa tools/exefs_plugins.py runs a plugin's init twice and checks the record (#845)
Two service runs with other GetSystemTick values, the words that differ between them listed with what they point
into, and a check that refuses a plugin with a reason per broken rule: a refused run, svcs, GetInfo ids or imports
outside the reviewed lists, writes outside main's .text, and writes that are none of exlaunch's inline hooks
(b to a stur/bl impl/ldur/b/.quad stub whose trampoline is the original relocated plus b site+4), call-site rewrites
(bl to a function start of the plugin's lift) or replace hooks (b from a main function start, Orig trampoline found).
tests/exefs_plugins_test.py covers the layout with and without plugins and one bad record per rule.

After the design in #845 by itaskaev2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 08:05:19 +03:00